@instructure/ui-react-utils 8.56.2-pr-snapshot-1721749364069 → 8.56.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/lib/DeterministicIdContext/withDeterministicId.js +4 -4
- package/lib/__new-tests__/safeCloneElement.test.js +2 -2
- package/lib/deprecated.js +2 -2
- package/lib/experimental.js +2 -2
- package/lib/hack.js +2 -2
- package/lib/safeCloneElement.js +2 -2
- package/lib/windowMessageListener.js +6 -6
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [8.56.2
|
|
6
|
+
## [8.56.2](https://github.com/instructure/instructure-ui/compare/v8.56.1...v8.56.2) (2024-08-06)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-react-utils
|
|
9
9
|
|
|
@@ -9,8 +9,8 @@ exports.withDeterministicId = exports.default = void 0;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
|
|
11
11
|
var _DeterministicIdContext = require("./DeterministicIdContext");
|
|
12
|
-
var
|
|
13
|
-
var
|
|
12
|
+
var _decorator = require("@instructure/ui-decorator/lib/decorator.js");
|
|
13
|
+
var _generateId = require("@instructure/ui-utils/lib/generateId.js");
|
|
14
14
|
var _console = require("@instructure/console");
|
|
15
15
|
/*
|
|
16
16
|
* The MIT License (MIT)
|
|
@@ -44,11 +44,11 @@ var _console = require("@instructure/console");
|
|
|
44
44
|
* in the child components to deterministically create ids for them based on the `instanceCounterMap`.
|
|
45
45
|
* Read more about it here: [SSR guide](https://instructure.design/#server-side-rendering)
|
|
46
46
|
*/
|
|
47
|
-
const withDeterministicId = exports.withDeterministicId = (0,
|
|
47
|
+
const withDeterministicId = exports.withDeterministicId = (0, _decorator.decorator)(ComposedComponent => {
|
|
48
48
|
const WithDeterministicId = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
49
49
|
const componentName = ComposedComponent.componentId || ComposedComponent.displayName || ComposedComponent.name;
|
|
50
50
|
const instanceCounterMap = (0, _react.useContext)(_DeterministicIdContext.DeterministicIdContext);
|
|
51
|
-
const deterministicId = (instanceName = componentName) => (0,
|
|
51
|
+
const deterministicId = (instanceName = componentName) => (0, _generateId.generateId)(instanceName, instanceCounterMap);
|
|
52
52
|
if (props.deterministicId) {
|
|
53
53
|
(0, _console.warn)(false, `Manually passing the "deterministicId" property is not allowed on the ${componentName} component.\n`, props.deterministicId);
|
|
54
54
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
var _react = _interopRequireDefault(require("react"));
|
|
5
|
-
var
|
|
5
|
+
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
6
6
|
var _react2 = require("@testing-library/react");
|
|
7
7
|
require("@testing-library/jest-dom");
|
|
8
8
|
var _safeCloneElement = require("../safeCloneElement");
|
|
@@ -77,7 +77,7 @@ describe('safeCloneElement', () => {
|
|
|
77
77
|
onClick: onClickA
|
|
78
78
|
}),
|
|
79
79
|
props: {
|
|
80
|
-
onClick: (0,
|
|
80
|
+
onClick: (0, _createChainedFunction.createChainedFunction)(onClickB, onClickC)
|
|
81
81
|
}
|
|
82
82
|
}));
|
|
83
83
|
const button = _react2.screen.getByRole('button');
|
package/lib/deprecated.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.deprecated = exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _decorator = require("@instructure/ui-decorator/lib/decorator.js");
|
|
8
8
|
var _console = require("@instructure/console");
|
|
9
9
|
/*
|
|
10
10
|
* The MIT License (MIT)
|
|
@@ -42,7 +42,7 @@ const deprecated = exports.deprecated = (() => {
|
|
|
42
42
|
deprecated.changedPackageWarning = () => '';
|
|
43
43
|
return deprecated;
|
|
44
44
|
}
|
|
45
|
-
const deprecated = (0,
|
|
45
|
+
const deprecated = (0, _decorator.decorator)((ComposedComponent, version, oldProps, message = '') => {
|
|
46
46
|
/**
|
|
47
47
|
* ---
|
|
48
48
|
* category: utilities/react
|
package/lib/experimental.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.experimental = exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _decorator = require("@instructure/ui-decorator/lib/decorator.js");
|
|
8
8
|
var _console = require("@instructure/console");
|
|
9
9
|
/*
|
|
10
10
|
* The MIT License (MIT)
|
|
@@ -30,7 +30,7 @@ var _console = require("@instructure/console");
|
|
|
30
30
|
* SOFTWARE.
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
-
const experimental = exports.experimental = process.env.NODE_ENV == 'production' ? () => ReactComponent => ReactComponent : (0,
|
|
33
|
+
const experimental = exports.experimental = process.env.NODE_ENV == 'production' ? () => ReactComponent => ReactComponent : (0, _decorator.decorator)((ComposedComponent, experimentalProps, message) => {
|
|
34
34
|
return class ExperimentalComponent extends ComposedComponent {
|
|
35
35
|
componentDidMount() {
|
|
36
36
|
if (!this.props.__dangerouslyIgnoreExperimentalWarnings) {
|
package/lib/hack.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.hack = exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _decorator = require("@instructure/ui-decorator/lib/decorator.js");
|
|
8
8
|
var _console = require("@instructure/console");
|
|
9
9
|
/*
|
|
10
10
|
* The MIT License (MIT)
|
|
@@ -51,7 +51,7 @@ var _console = require("@instructure/console");
|
|
|
51
51
|
* @param {string} message
|
|
52
52
|
* @return {function} React component flagged as having hack props
|
|
53
53
|
*/
|
|
54
|
-
const hack = exports.hack = process.env.NODE_ENV == 'production' ? () => Component => Component : (0,
|
|
54
|
+
const hack = exports.hack = process.env.NODE_ENV == 'production' ? () => Component => Component : (0, _decorator.decorator)((ComposedComponent, hackProps, message) => {
|
|
55
55
|
return class HackComponent extends ComposedComponent {
|
|
56
56
|
componentDidMount() {
|
|
57
57
|
if (hackProps) {
|
package/lib/safeCloneElement.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
exports.safeCloneElement = safeCloneElement;
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _console = require("@instructure/console");
|
|
11
|
-
var
|
|
11
|
+
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
12
12
|
/*
|
|
13
13
|
* The MIT License (MIT)
|
|
14
14
|
*
|
|
@@ -70,7 +70,7 @@ function safeCloneElement(element, props, ...children) {
|
|
|
70
70
|
// otherwise unwantedly override element.props[prop].
|
|
71
71
|
if (prop.indexOf('on') === 0 && (typeof props[prop] === 'function' || typeof element.props[prop] === 'function')) {
|
|
72
72
|
;
|
|
73
|
-
mergedProps[prop] = (0,
|
|
73
|
+
mergedProps[prop] = (0, _createChainedFunction.createChainedFunction)(element.props[prop], props[prop]);
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
if (originalRef == null || cloneRef == null) {
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.origin = origin;
|
|
8
8
|
exports.windowMessageListener = void 0;
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var _decorator = require("@instructure/ui-decorator/lib/decorator.js");
|
|
10
|
+
var _ownerWindow = require("@instructure/ui-dom-utils/lib/ownerWindow.js");
|
|
11
11
|
/*
|
|
12
12
|
* The MIT License (MIT)
|
|
13
13
|
*
|
|
@@ -45,7 +45,7 @@ var _uiDomUtils = require("@instructure/ui-dom-utils");
|
|
|
45
45
|
* @param {Function} validSource an optional function that would restrict message handling to a specified source.
|
|
46
46
|
* @returns {Function} a function that decorates a React component with the behavior
|
|
47
47
|
*/
|
|
48
|
-
const windowMessageListener = exports.windowMessageListener = (0,
|
|
48
|
+
const windowMessageListener = exports.windowMessageListener = (0, _decorator.decorator)((ComposedComponent, messageHandler, validSource) => {
|
|
49
49
|
var _class;
|
|
50
50
|
return _class = class extends ComposedComponent {
|
|
51
51
|
constructor(...args) {
|
|
@@ -57,14 +57,14 @@ const windowMessageListener = exports.windowMessageListener = (0, _uiDecorator.d
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
componentDidMount() {
|
|
60
|
-
const win = (0,
|
|
60
|
+
const win = (0, _ownerWindow.ownerWindow)(this);
|
|
61
61
|
win.addEventListener('message', this.handleMessage, false);
|
|
62
62
|
if (super.componentDidMount) {
|
|
63
63
|
super.componentDidMount();
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
componentWillUnmount() {
|
|
67
|
-
const win = (0,
|
|
67
|
+
const win = (0, _ownerWindow.ownerWindow)(this);
|
|
68
68
|
win.removeEventListener('message', this.handleMessage, false);
|
|
69
69
|
if (super.componentDidMount) {
|
|
70
70
|
super.componentDidMount();
|
|
@@ -96,7 +96,7 @@ const windowMessageListener = exports.windowMessageListener = (0, _uiDecorator.d
|
|
|
96
96
|
* @returns {String} the origin
|
|
97
97
|
*/
|
|
98
98
|
function origin(node) {
|
|
99
|
-
const ownWindow = (0,
|
|
99
|
+
const ownWindow = (0, _ownerWindow.ownerWindow)(node);
|
|
100
100
|
const location = ownWindow.location;
|
|
101
101
|
if (location.protocol === 'file:') {
|
|
102
102
|
return '*';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-react-utils",
|
|
3
|
-
"version": "8.56.2
|
|
3
|
+
"version": "8.56.2",
|
|
4
4
|
"description": "A React utility library made by Instructure Inc.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@instructure/ui-babel-preset": "8.56.2
|
|
25
|
+
"@instructure/ui-babel-preset": "8.56.2",
|
|
26
26
|
"@testing-library/jest-dom": "^6.1.4",
|
|
27
27
|
"@testing-library/react": "^14.1.2"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@babel/runtime": "^7.23.2",
|
|
31
31
|
"@emotion/is-prop-valid": "^1.2.1",
|
|
32
|
-
"@instructure/console": "8.56.2
|
|
33
|
-
"@instructure/shared-types": "8.56.2
|
|
34
|
-
"@instructure/ui-decorator": "8.56.2
|
|
35
|
-
"@instructure/ui-dom-utils": "8.56.2
|
|
36
|
-
"@instructure/ui-utils": "8.56.2
|
|
32
|
+
"@instructure/console": "8.56.2",
|
|
33
|
+
"@instructure/shared-types": "8.56.2",
|
|
34
|
+
"@instructure/ui-decorator": "8.56.2",
|
|
35
|
+
"@instructure/ui-dom-utils": "8.56.2",
|
|
36
|
+
"@instructure/ui-utils": "8.56.2",
|
|
37
37
|
"hoist-non-react-statics": "^3.3.2",
|
|
38
38
|
"prop-types": "^15.8.1"
|
|
39
39
|
},
|