@highlight-ui/utils-commons
Advanced tools
Comparing version
@@ -7,1 +7,2 @@ export * from './src/types'; | ||
export { parseMetadata, suffixMetadata } from './src/parseMetadata'; | ||
export { default as withDeprecationWarning } from './src/withDeprecationWarning'; |
@@ -9,2 +9,3 @@ 'use strict'; | ||
var curry = require('lodash/fp/curry'); | ||
var React = require('react'); | ||
function _interopDefaultLegacy(e) { | ||
@@ -18,2 +19,3 @@ return e && typeof e === 'object' && 'default' in e ? e : { | ||
var curry__default = /*#__PURE__*/_interopDefaultLegacy(curry); | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
var idCounter = {}; | ||
@@ -88,2 +90,46 @@ function uniqueId(prefix) { | ||
}); | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
var __assign = function () { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function getDisplayName(WrappedComponent) { | ||
return WrappedComponent.displayName || WrappedComponent.name || 'Component'; | ||
} | ||
function withDeprecationWarning(WrappedComponent, migrationGuideLink) { | ||
var componentName = getDisplayName(WrappedComponent); | ||
var deprecationMessage = "\u26A0\uFE0F Deprecation Warning: " + componentName + " is now deprecated."; | ||
var migrationGuideMessage = migrationGuideLink ? " See " + migrationGuideLink + " for migration guidance." : ''; | ||
var fullMessage = deprecationMessage + migrationGuideMessage; | ||
var DeprecatedComponent = function (props) { | ||
// Only show the deprecated warning in non-production environments | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn(fullMessage); | ||
} | ||
return React__default["default"].createElement(WrappedComponent, __assign({}, props)); | ||
}; | ||
DeprecatedComponent.displayName = "withDeprecationWarning(" + componentName + ")"; | ||
return DeprecatedComponent; | ||
} | ||
exports.forkHandlers = forkHandlers; | ||
@@ -95,2 +141,3 @@ exports.invariant = invariant; | ||
exports.uniqueId = uniqueId; | ||
exports.withDeprecationWarning = withDeprecationWarning; | ||
//# sourceMappingURL=index.js.map |
@@ -7,1 +7,2 @@ export * from './src/types'; | ||
export { parseMetadata, suffixMetadata } from './src/parseMetadata'; | ||
export { default as withDeprecationWarning } from './src/withDeprecationWarning'; |
import kebabCase from 'lodash/fp/kebabCase'; | ||
import mapValues from 'lodash/fp/mapValues'; | ||
import curry from 'lodash/fp/curry'; | ||
import React from 'react'; | ||
var idCounter = {}; | ||
@@ -73,3 +74,47 @@ function uniqueId(prefix) { | ||
}); | ||
export { forkHandlers, invariant, noop, parseMetadata, suffixMetadata, uniqueId }; | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
var __assign = function () { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function getDisplayName(WrappedComponent) { | ||
return WrappedComponent.displayName || WrappedComponent.name || 'Component'; | ||
} | ||
function withDeprecationWarning(WrappedComponent, migrationGuideLink) { | ||
var componentName = getDisplayName(WrappedComponent); | ||
var deprecationMessage = "\u26A0\uFE0F Deprecation Warning: " + componentName + " is now deprecated."; | ||
var migrationGuideMessage = migrationGuideLink ? " See " + migrationGuideLink + " for migration guidance." : ''; | ||
var fullMessage = deprecationMessage + migrationGuideMessage; | ||
var DeprecatedComponent = function (props) { | ||
// Only show the deprecated warning in non-production environments | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn(fullMessage); | ||
} | ||
return /*#__PURE__*/React.createElement(WrappedComponent, __assign({}, props)); | ||
}; | ||
DeprecatedComponent.displayName = "withDeprecationWarning(" + componentName + ")"; | ||
return DeprecatedComponent; | ||
} | ||
export { forkHandlers, invariant, noop, parseMetadata, suffixMetadata, uniqueId, withDeprecationWarning }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@highlight-ui/utils-commons", | ||
"version": "2.4.6", | ||
"version": "2.5.0", | ||
"author": "Personio GmbH & Co. KG", | ||
@@ -28,2 +28,3 @@ "main": "dist/cjs/index.js", | ||
"@highlight-ui/utils-dev": "^1.1.17", | ||
"@testing-library/react": "12.1.5", | ||
"jest": "~27.2.3", | ||
@@ -41,3 +42,3 @@ "lodash": "~4.17.21", | ||
}, | ||
"gitHead": "9822c2a9f7a4e942523dc88c31c3632cec6209ce" | ||
"gitHead": "3416702eb91e4af15ac29cf5d73ac192719d6d71" | ||
} |
@@ -81,1 +81,21 @@ # `@highlight-ui/utils-commons` | ||
``` | ||
### withDeprecationWarning() | ||
Higher order component that can be used to show a deprecation message as a warning in the console, with optional further information on how to use a replacement. | ||
| Prop | Type | Required | Default | Description | | ||
| :------------------- | :--------------- | :------- | :------ | :----------------------------------------------------------------------- | | ||
| `WrappedComponent` | `ReactComponent` | Yes | | Component to display console warning about deprecation - when used | | ||
| `migrationGuideLink` | `string` | No | `null` | Valid link to a migration guide from deprecated component to alternative | | ||
```jsx | ||
withDeprecationWarning( | ||
ADeprecatedComponent, | ||
'https://optional-link-to-a-migration-guide.com', | ||
); | ||
``` | ||
This will show as a warning on the console: | ||
> ⚠️ Deprecation Warning: ADeprecatedComponent is now deprecated. See https://optional-link-to-a-migration-guide.com for migration guidance. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
62952
151.21%23
9.52%407
29.21%101
24.69%0
-100%9
12.5%5
66.67%