@instructure/ui-utils
Advanced tools
Comparing version 5.0.0-dev.6 to 5.0.0-dev.7
@@ -471,3 +471,5 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
deprecatedVariant: function deprecatedVariant(propType, deprecated, message) { | ||
return function (props, propName, componentName) { | ||
warning(false, '[%] was deprecated in version %s. %s', 'deprecatedVariant', '5.0.0', 'Use `deprecatePropValues` instead.'); | ||
return function (props, propName, componentName, location) { | ||
warning(props[propName] !== deprecated, '`' + componentName + '` `' + deprecated + '` variant is deprecated. ' + (message || '')); | ||
@@ -474,0 +476,0 @@ }; |
@@ -114,3 +114,26 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function warnDeprecatedProps(displayName, version, props, oldProps, message) { | ||
/** | ||
* | ||
* Trigger a console warning if the specified prop variant is deprecated | ||
* | ||
* @param {function} propType - validates the prop type. Returns null if valid, error otherwise | ||
* @param {array} deprecated - an array of the deprecated variant names | ||
* @param {string} message - additional information to display with the warning | ||
*/ | ||
export var deprecatePropValues = function deprecatePropValues(propType) { | ||
var deprecated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
var message = arguments[2]; | ||
return function (props, propName, componentName) { | ||
for (var _len = arguments.length, rest = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) { | ||
rest[_key - 3] = arguments[_key]; | ||
} | ||
var isDeprecatedValue = deprecated.includes(props[propName]); | ||
warning(!isDeprecatedValue, '[' + componentName + '] The \'' + props[propName] + '\' value for the `' + propName + '` prop is deprecated. ' + (message || '')); | ||
return isDeprecatedValue ? null : propType.apply(undefined, [props, propName, componentName].concat(rest)); | ||
}; | ||
}; | ||
function warnDeprecatedProps(componentName, version, props, oldProps, message) { | ||
Object.keys(oldProps).forEach(function (oldProp) { | ||
@@ -120,3 +143,3 @@ if (typeof props[oldProp] !== 'undefined') { | ||
warning(false, '[%s] `%s` was deprecated in %s%s. %s', displayName, oldProp, version, newProp ? '. Use `' + newProp + '` instead' : '', message || ''); | ||
warning(false, '[%s] `%s` was deprecated in %s%s. %s', componentName, oldProp, version, newProp ? '. Use `' + newProp + '` instead' : '', message || ''); | ||
} | ||
@@ -126,4 +149,4 @@ }); | ||
function warnDeprecatedComponent(version, displayName, message) { | ||
warning(false, '[%s] was deprecated in version %s. %s', displayName, version, message || ''); | ||
function warnDeprecatedComponent(version, componentName, message) { | ||
warning(false, '[%s] was deprecated in version %s. %s', componentName, version, message || ''); | ||
} | ||
@@ -130,0 +153,0 @@ |
@@ -495,3 +495,5 @@ 'use strict'; | ||
deprecatedVariant: function deprecatedVariant(propType, deprecated, message) { | ||
return function (props, propName, componentName) { | ||
(0, _warning2.default)(false, '[%] was deprecated in version %s. %s', 'deprecatedVariant', '5.0.0', 'Use `deprecatePropValues` instead.'); | ||
return function (props, propName, componentName, location) { | ||
(0, _warning2.default)(props[propName] !== deprecated, '`' + componentName + '` `' + deprecated + '` variant is deprecated. ' + (message || '')); | ||
@@ -498,0 +500,0 @@ }; |
@@ -6,2 +6,3 @@ 'use strict'; | ||
}); | ||
exports.deprecatePropValues = undefined; | ||
@@ -129,3 +130,26 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function warnDeprecatedProps(displayName, version, props, oldProps, message) { | ||
/** | ||
* | ||
* Trigger a console warning if the specified prop variant is deprecated | ||
* | ||
* @param {function} propType - validates the prop type. Returns null if valid, error otherwise | ||
* @param {array} deprecated - an array of the deprecated variant names | ||
* @param {string} message - additional information to display with the warning | ||
*/ | ||
var deprecatePropValues = exports.deprecatePropValues = function deprecatePropValues(propType) { | ||
var deprecated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
var message = arguments[2]; | ||
return function (props, propName, componentName) { | ||
for (var _len = arguments.length, rest = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) { | ||
rest[_key - 3] = arguments[_key]; | ||
} | ||
var isDeprecatedValue = deprecated.includes(props[propName]); | ||
(0, _warning2.default)(!isDeprecatedValue, '[' + componentName + '] The \'' + props[propName] + '\' value for the `' + propName + '` prop is deprecated. ' + (message || '')); | ||
return isDeprecatedValue ? null : propType.apply(undefined, [props, propName, componentName].concat(rest)); | ||
}; | ||
}; | ||
function warnDeprecatedProps(componentName, version, props, oldProps, message) { | ||
Object.keys(oldProps).forEach(function (oldProp) { | ||
@@ -135,3 +159,3 @@ if (typeof props[oldProp] !== 'undefined') { | ||
(0, _warning2.default)(false, '[%s] `%s` was deprecated in %s%s. %s', displayName, oldProp, version, newProp ? '. Use `' + newProp + '` instead' : '', message || ''); | ||
(0, _warning2.default)(false, '[%s] `%s` was deprecated in %s%s. %s', componentName, oldProp, version, newProp ? '. Use `' + newProp + '` instead' : '', message || ''); | ||
} | ||
@@ -141,4 +165,4 @@ }); | ||
function warnDeprecatedComponent(version, displayName, message) { | ||
(0, _warning2.default)(false, '[%s] was deprecated in version %s. %s', displayName, version, message || ''); | ||
function warnDeprecatedComponent(version, componentName, message) { | ||
(0, _warning2.default)(false, '[%s] was deprecated in version %s. %s', componentName, version, message || ''); | ||
} | ||
@@ -145,0 +169,0 @@ |
{ | ||
"name": "@instructure/ui-utils", | ||
"version": "5.0.0-dev.6", | ||
"version": "5.0.0-dev.7", | ||
"description": "A collection of utilities for UI components", | ||
@@ -25,3 +25,3 @@ "author": "Instructure, Inc. Engineering and Product Design", | ||
"devDependencies": { | ||
"@instructure/ui-presets": "^5.0.0-dev.6", | ||
"@instructure/ui-presets": "^5.0.0-dev.7", | ||
"react": "15.6.2", | ||
@@ -31,4 +31,4 @@ "react-dom": "15.6.2" | ||
"dependencies": { | ||
"@instructure/ui-i18n": "^5.0.0-dev.6", | ||
"bowser": "^1.9.1", | ||
"@instructure/ui-i18n": "^5.0.0-dev.7", | ||
"bowser": "^1.9.2", | ||
"decimal.js": "^9.0.1", | ||
@@ -35,0 +35,0 @@ "deep-equal": "^1.0.1", |
@@ -496,3 +496,5 @@ /* | ||
deprecatedVariant (propType, deprecated, message) { | ||
return (props, propName, componentName) => { | ||
warning(false, '[%] was deprecated in version %s. %s', 'deprecatedVariant', '5.0.0', 'Use `deprecatePropValues` instead.') | ||
return (props, propName, componentName, location) => { | ||
warning( | ||
@@ -499,0 +501,0 @@ (props[propName] !== deprecated), |
@@ -89,3 +89,22 @@ /* | ||
function warnDeprecatedProps (displayName, version, props, oldProps, message) { | ||
/** | ||
* | ||
* Trigger a console warning if the specified prop variant is deprecated | ||
* | ||
* @param {function} propType - validates the prop type. Returns null if valid, error otherwise | ||
* @param {array} deprecated - an array of the deprecated variant names | ||
* @param {string} message - additional information to display with the warning | ||
*/ | ||
export const deprecatePropValues = (propType, deprecated = [], message) => { | ||
return (props, propName, componentName, ...rest) => { | ||
const isDeprecatedValue = deprecated.includes(props[propName]) | ||
warning( | ||
(!isDeprecatedValue), | ||
`[${componentName}] The '${props[propName]}' value for the \`${propName}\` prop is deprecated. ${message || ''}` | ||
) | ||
return isDeprecatedValue ? null : propType(props, propName, componentName, ...rest) | ||
} | ||
} | ||
function warnDeprecatedProps (componentName, version, props, oldProps, message) { | ||
Object.keys(oldProps).forEach((oldProp) => { | ||
@@ -100,3 +119,3 @@ if (typeof props[oldProp] !== 'undefined') { | ||
'[%s] `%s` was deprecated in %s%s. %s', | ||
displayName, oldProp, version, (newProp ? `. Use \`${newProp}\` instead` : ''), message || '' | ||
componentName, oldProp, version, (newProp ? `. Use \`${newProp}\` instead` : ''), message || '' | ||
) | ||
@@ -107,4 +126,4 @@ } | ||
function warnDeprecatedComponent (version, displayName, message) { | ||
warning(false, '[%s] was deprecated in version %s. %s', displayName, version, message || '') | ||
function warnDeprecatedComponent (version, componentName, message) { | ||
warning(false, '[%s] was deprecated in version %s. %s', componentName, version, message || '') | ||
} | ||
@@ -111,0 +130,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
597336
11689
Updatedbowser@^1.9.2