@instructure/ui-react-utils 10.26.1-snapshot-2 → 10.26.1

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 CHANGED
@@ -3,30 +3,9 @@
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
- ## [10.26.1-snapshot-2](https://github.com/instructure/instructure-ui/compare/v10.26.0...v10.26.1-snapshot-2) (2025-10-06)
6
+ ## [10.26.1](https://github.com/instructure/instructure-ui/compare/v10.26.0...v10.26.1) (2025-10-06)
7
7
 
8
-
9
- ### Features
10
-
11
- * **many:** instUI v11 release ([36f5438](https://github.com/instructure/instructure-ui/commit/36f54382669186227ba24798bbf7201ef2f5cd4c))
12
-
13
-
14
- ### BREAKING CHANGES
15
-
16
- * **many:** InstUI v11 contains the following breaking changes:
17
- - React 16 and 17 are no longer supported
18
- - remove `PropTypes` from all packages
19
- - remove `CodeEditor` component
20
- - remove `@instui/theme-registry` package
21
- - remove `@testable`, `@experimental`, `@hack` decorators
22
- - InstUISettingsProvider's `as` prop is removed
23
- - `canvas.use()`, `canvasHighContrast.use()` functions are removed
24
- - `canvasThemeLocal`, `canvasHighContrastThemeLocal` are removed
25
- - `variables` field on theme objects are removed
26
- - remove deprecated props from Table: Row's `isStacked`, Body's
27
- `isStacked`, `hover`, and `headers`
28
- - `Table`'s `caption` prop is now required
29
- - `ui-dom-utils`'s `getComputedStyle` can now return `undefined`
8
+ **Note:** Version bump only for package @instructure/ui-react-utils
30
9
 
31
10
 
32
11
 
@@ -52,6 +52,12 @@ const withDeterministicId = decorator(ComposedComponent => {
52
52
  });
53
53
  hoistNonReactStatics(WithDeterministicId, ComposedComponent);
54
54
 
55
+ // we have to pass these on, because sometimes users
56
+ // access propTypes of the component in other components
57
+ // eslint-disable-next-line react/forbid-foreign-prop-types
58
+ WithDeterministicId.propTypes = ComposedComponent.propTypes;
59
+ WithDeterministicId.defaultProps = ComposedComponent.defaultProps;
60
+
55
61
  // These static fields exist on InstUI components
56
62
  //@ts-expect-error fix this
57
63
  WithDeterministicId.allowedProps = ComposedComponent.allowedProps;
@@ -0,0 +1,147 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ import { decorator } from '@instructure/ui-decorator';
25
+ import { logWarnDeprecated as warnDeprecated } from '@instructure/console';
26
+ /**
27
+ * ---
28
+ * category: utilities/react
29
+ * ---
30
+ * Deprecate React component props. Warnings will display in the console when deprecated
31
+ * props are used. Include the version number when the deprecated component will be removed.
32
+ *
33
+ * ```js-code
34
+ * class Example extends Component {
35
+ * static propTypes = {
36
+ * currentProp: PropTypes.func
37
+ * }
38
+ * }
39
+ * export default deprecated('7.0.0', {
40
+ * deprecatedProp: 'currentProp',
41
+ * nowNonExistentProp: true
42
+ * })(Example)
43
+ * ```
44
+ *
45
+ * @param {string} version
46
+ * @param {object} oldProps (if this argument is null or undefined, the entire component is deprecated)
47
+ * @param {string} message
48
+ * @return {function} React component with deprecated props behavior
49
+ * @module deprecated
50
+ */
51
+ const deprecated = (() => {
52
+ if (process.env.NODE_ENV === 'production') {
53
+ const deprecated = function () {
54
+ return ComposedComponent => ComposedComponent;
55
+ };
56
+ deprecated.deprecatePropValues = () => () => null;
57
+ deprecated.warnDeprecatedProps = () => {};
58
+ deprecated.warnDeprecatedComponent = () => {};
59
+ deprecated.changedPackageWarning = () => '';
60
+ return deprecated;
61
+ }
62
+ const deprecated = decorator((ComposedComponent, version, oldProps, message = '') => {
63
+ class DeprecatedComponent extends ComposedComponent {}
64
+ DeprecatedComponent.prototype.componentDidMount = function () {
65
+ if (oldProps) {
66
+ warnDeprecatedProps(ComposedComponent.name, version, this.props, oldProps, message);
67
+ } else {
68
+ warnDeprecatedComponent(version, ComposedComponent.name, message);
69
+ }
70
+ if (ComposedComponent.prototype.componentDidMount) {
71
+ ComposedComponent.prototype.componentDidMount.call(this);
72
+ }
73
+ };
74
+ DeprecatedComponent.prototype.componentDidUpdate = function (prevProps, prevState, prevContext) {
75
+ if (oldProps) {
76
+ warnDeprecatedProps(ComposedComponent.name, version, this.props, oldProps, message);
77
+ } else {
78
+ warnDeprecatedComponent(version, ComposedComponent.name, message);
79
+ }
80
+ if (ComposedComponent.prototype.componentDidUpdate) {
81
+ ComposedComponent.prototype.componentDidUpdate.call(this, prevProps, prevState, prevContext);
82
+ }
83
+ };
84
+ return DeprecatedComponent;
85
+ })
86
+ /**
87
+ * ---
88
+ * category: utilities
89
+ * ---
90
+ * Trigger a console warning if the specified prop variant is deprecated
91
+ *
92
+ * @param {function} propType - validates the prop type. Returns null if valid, error otherwise
93
+ * @param {array} deprecated - an array of the deprecated variant names
94
+ * @param {string|function} message - a string with additional information (like the version the prop will be removed) or a function returning a string
95
+ */;
96
+ deprecated.deprecatePropValues = (propType, deprecated = [], message) => {
97
+ return (props, propName, componentName, ...rest) => {
98
+ const isDeprecatedValue = deprecated.includes(props[propName]);
99
+ const warningMessage = message && typeof message === 'function' ? message({
100
+ props,
101
+ propName,
102
+ propValue: props[propName]
103
+ }) : `The '${props[propName]}' value for the \`${propName}\` prop is deprecated. ${message || ''}`;
104
+ warnDeprecated(!isDeprecatedValue, `[${componentName}] ${warningMessage}`);
105
+ return isDeprecatedValue ? null : propType(props, propName, componentName, ...rest);
106
+ };
107
+ };
108
+ function warnDeprecatedProps(componentName, version, props, oldProps, message = '') {
109
+ Object.keys(oldProps).forEach(oldProp => {
110
+ if (typeof props[oldProp] !== 'undefined') {
111
+ const newProp = typeof oldProps[oldProp] === 'string' ? oldProps[oldProp] : null;
112
+ const newPropMessage = newProp ? `. Use \`${newProp}\` instead` : '';
113
+ warnDeprecated(false, `[${componentName}] \`${oldProp}\` is deprecated and will be removed in version ${version}${newPropMessage}. ${message}`);
114
+ }
115
+ });
116
+ }
117
+ ;
118
+ deprecated.warnDeprecatedProps = warnDeprecatedProps;
119
+ function warnDeprecatedComponent(version, componentName, message) {
120
+ warnDeprecated(false, `[${componentName}] is deprecated and will be removed in version ${version}. ${message || ''}`);
121
+ }
122
+ /**
123
+ * ---
124
+ * category: utilities
125
+ * ---
126
+ * @param {String} version the version of the package in which the component or function was deprecated
127
+ * @param {String} componentName the name of the component or Function.name of the utility function
128
+ * @param {String} message a message to display as a console error in DEV env when condition is false
129
+ */
130
+ ;
131
+ deprecated.warnDeprecatedComponent = warnDeprecatedComponent
132
+
133
+ /**
134
+ * ---
135
+ * category: utilities
136
+ * ---
137
+ * @param {String} prevPackage the previous name of the package
138
+ * @param {String} newPackage the new version of the package
139
+ * @return {String} the formatted warning string
140
+ */;
141
+ deprecated.changedPackageWarning = (prevPackage, newPackage) => {
142
+ return `It has been moved from @instructure/${prevPackage} to @instructure/${newPackage}.`;
143
+ };
144
+ return deprecated;
145
+ })();
146
+ export default deprecated;
147
+ export { deprecated };
@@ -0,0 +1,85 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ import { decorator } from '@instructure/ui-decorator';
25
+ import { logWarn as warn } from '@instructure/console';
26
+ /**
27
+ * ---
28
+ * category: utilities/react
29
+ * ---
30
+ * Flag React component and component props as experimental.
31
+ * Warnings will display in the console when experimental components/props
32
+ * props are used.
33
+ *
34
+ * ```js-code
35
+ * class Example extends Component {
36
+ * static propTypes = {
37
+ * currentProp: PropTypes.func
38
+ * }
39
+ * }
40
+ * export default experimental(['experimentalProp'])(Example)
41
+ * ```
42
+ *
43
+ * @module experimental
44
+ * @param {array} experimentalProps (if this argument is null or undefined, the entire component is flagged)
45
+ * @param {string} message
46
+ * @return {function} React component flagged as experimental
47
+ */
48
+ const experimental = process.env.NODE_ENV == 'production' ? () => ReactComponent => ReactComponent : decorator((ComposedComponent, experimentalProps, message) => {
49
+ return class ExperimentalComponent extends ComposedComponent {
50
+ componentDidMount() {
51
+ if (!this.props.__dangerouslyIgnoreExperimentalWarnings) {
52
+ if (experimentalProps) {
53
+ warnExperimentalProps(ComposedComponent.name, this.props, experimentalProps, message);
54
+ } else {
55
+ warnExperimentalComponent(ComposedComponent.name, message);
56
+ }
57
+ }
58
+ if (super.componentDidMount) {
59
+ super.componentDidMount();
60
+ }
61
+ }
62
+ componentDidUpdate(prevProps, prevState, prevContext) {
63
+ if (!this.props.__dangerouslyIgnoreExperimentalWarnings) {
64
+ if (experimentalProps) {
65
+ warnExperimentalProps(ComposedComponent.name, this.props, experimentalProps, message);
66
+ } else {
67
+ warnExperimentalComponent(ComposedComponent.name, message);
68
+ }
69
+ }
70
+ if (super.componentDidUpdate) {
71
+ super.componentDidUpdate(prevProps, prevState, prevContext);
72
+ }
73
+ }
74
+ };
75
+ });
76
+ function warnExperimentalProps(name, props, experimentalProps, message = '') {
77
+ experimentalProps.forEach(experimentalProp => {
78
+ warn(typeof props[experimentalProp] === 'undefined', `[${name}] The \`${experimentalProp}\` prop is experimental and its API could change significantly in a future release. ${message}`);
79
+ });
80
+ }
81
+ function warnExperimentalComponent(name, message = '') {
82
+ warn(false, `[${name}] is experimental and its API could change significantly in a future release. ${message}`);
83
+ }
84
+ export default experimental;
85
+ export { experimental };
package/es/hack.js ADDED
@@ -0,0 +1,96 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ import { decorator } from '@instructure/ui-decorator';
25
+ import { logWarn as warn } from '@instructure/console';
26
+
27
+ /**
28
+ * ---
29
+ * category: utilities/react
30
+ * ---
31
+ * Flag React component props as hack props.
32
+ * Warnings will display in the console when hack props are used.
33
+ *
34
+ * ```js-code
35
+ * class Example extends Component {
36
+ * static propTypes = {
37
+ * currentProp: PropTypes.func
38
+ * }
39
+ * }
40
+ * export default hack(['hackProp'])(Example)
41
+ * ```
42
+ *
43
+ * @module hack
44
+ * @param {array} hackProps
45
+ * @param {string} message
46
+ * @return {function} React component flagged as having hack props
47
+ */
48
+ const hack = process.env.NODE_ENV == 'production' ? () => Component => Component : decorator((ComposedComponent, hackProps, message) => {
49
+ return class HackComponent extends ComposedComponent {
50
+ componentDidMount() {
51
+ if (hackProps) {
52
+ warnHackProps(ComposedComponent.name, this.props, hackProps, message);
53
+ }
54
+ if (super.componentDidMount) {
55
+ super.componentDidMount();
56
+ }
57
+ }
58
+ componentDidUpdate(prevProps, prevState, prevContext) {
59
+ if (hackProps) {
60
+ warnHackProps(ComposedComponent.name, this.props, hackProps, message);
61
+ }
62
+ if (super.componentDidUpdate) {
63
+ super.componentDidUpdate(prevProps, prevState, prevContext);
64
+ }
65
+ }
66
+ };
67
+ });
68
+ function warnHackProps(name, props, hackProps, message = '') {
69
+ hackProps.forEach(hackProp => {
70
+ warn(typeof props[hackProp] === 'undefined', `[${name}] The \`${hackProp}\` prop is a temporary hack and will be removed in a future release. ${message}`);
71
+ });
72
+ }
73
+ export default hack;
74
+ export {
75
+ /**
76
+ * ---
77
+ * category: utilities/react
78
+ * ---
79
+ * Flag React component props as hack props.
80
+ * Warnings will display in the console when hack props are used.
81
+ *
82
+ * ```js
83
+ * class Example extends Component {
84
+ * static propTypes = {
85
+ * currentProp: PropTypes.func
86
+ * }
87
+ * }
88
+ * export default hack(['hackProp'])(Example)
89
+ * ```
90
+ *
91
+ * @module hack
92
+ * @param {array} hackProps
93
+ * @param {string} message
94
+ * @return {function} React component flagged as having hack props
95
+ */
96
+ hack };
package/es/index.js CHANGED
@@ -24,7 +24,10 @@
24
24
 
25
25
  /* list utils in alphabetical order */
26
26
  export { callRenderProp } from './callRenderProp';
27
+ export { deprecated } from './deprecated';
27
28
  export { ensureSingleChild } from './ensureSingleChild';
29
+ export { experimental } from './experimental';
30
+ export { hack } from './hack';
28
31
  export { getDisplayName } from './getDisplayName';
29
32
  export { getElementType } from './getElementType';
30
33
  export { getInteraction } from './getInteraction';
@@ -60,6 +60,12 @@ const withDeterministicId = exports.withDeterministicId = (0, _decorator.decorat
60
60
  });
61
61
  (0, _hoistNonReactStatics.default)(WithDeterministicId, ComposedComponent);
62
62
 
63
+ // we have to pass these on, because sometimes users
64
+ // access propTypes of the component in other components
65
+ // eslint-disable-next-line react/forbid-foreign-prop-types
66
+ WithDeterministicId.propTypes = ComposedComponent.propTypes;
67
+ WithDeterministicId.defaultProps = ComposedComponent.defaultProps;
68
+
63
69
  // These static fields exist on InstUI components
64
70
  //@ts-expect-error fix this
65
71
  WithDeterministicId.allowedProps = ComposedComponent.allowedProps;
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.deprecated = exports.default = void 0;
7
+ var _decorator = require("@instructure/ui-decorator/lib/decorator.js");
8
+ var _console = require("@instructure/console");
9
+ /*
10
+ * The MIT License (MIT)
11
+ *
12
+ * Copyright (c) 2015 - present Instructure, Inc.
13
+ *
14
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ * of this software and associated documentation files (the "Software"), to deal
16
+ * in the Software without restriction, including without limitation the rights
17
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ * copies of the Software, and to permit persons to whom the Software is
19
+ * furnished to do so, subject to the following conditions:
20
+ *
21
+ * The above copyright notice and this permission notice shall be included in all
22
+ * copies or substantial portions of the Software.
23
+ *
24
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ * SOFTWARE.
31
+ */
32
+
33
+ /**
34
+ * ---
35
+ * category: utilities/react
36
+ * ---
37
+ * Deprecate React component props. Warnings will display in the console when deprecated
38
+ * props are used. Include the version number when the deprecated component will be removed.
39
+ *
40
+ * ```js-code
41
+ * class Example extends Component {
42
+ * static propTypes = {
43
+ * currentProp: PropTypes.func
44
+ * }
45
+ * }
46
+ * export default deprecated('7.0.0', {
47
+ * deprecatedProp: 'currentProp',
48
+ * nowNonExistentProp: true
49
+ * })(Example)
50
+ * ```
51
+ *
52
+ * @param {string} version
53
+ * @param {object} oldProps (if this argument is null or undefined, the entire component is deprecated)
54
+ * @param {string} message
55
+ * @return {function} React component with deprecated props behavior
56
+ * @module deprecated
57
+ */
58
+ const deprecated = exports.deprecated = (() => {
59
+ if (process.env.NODE_ENV === 'production') {
60
+ const deprecated = function () {
61
+ return ComposedComponent => ComposedComponent;
62
+ };
63
+ deprecated.deprecatePropValues = () => () => null;
64
+ deprecated.warnDeprecatedProps = () => {};
65
+ deprecated.warnDeprecatedComponent = () => {};
66
+ deprecated.changedPackageWarning = () => '';
67
+ return deprecated;
68
+ }
69
+ const deprecated = (0, _decorator.decorator)((ComposedComponent, version, oldProps, message = '') => {
70
+ class DeprecatedComponent extends ComposedComponent {}
71
+ DeprecatedComponent.prototype.componentDidMount = function () {
72
+ if (oldProps) {
73
+ warnDeprecatedProps(ComposedComponent.name, version, this.props, oldProps, message);
74
+ } else {
75
+ warnDeprecatedComponent(version, ComposedComponent.name, message);
76
+ }
77
+ if (ComposedComponent.prototype.componentDidMount) {
78
+ ComposedComponent.prototype.componentDidMount.call(this);
79
+ }
80
+ };
81
+ DeprecatedComponent.prototype.componentDidUpdate = function (prevProps, prevState, prevContext) {
82
+ if (oldProps) {
83
+ warnDeprecatedProps(ComposedComponent.name, version, this.props, oldProps, message);
84
+ } else {
85
+ warnDeprecatedComponent(version, ComposedComponent.name, message);
86
+ }
87
+ if (ComposedComponent.prototype.componentDidUpdate) {
88
+ ComposedComponent.prototype.componentDidUpdate.call(this, prevProps, prevState, prevContext);
89
+ }
90
+ };
91
+ return DeprecatedComponent;
92
+ })
93
+ /**
94
+ * ---
95
+ * category: utilities
96
+ * ---
97
+ * Trigger a console warning if the specified prop variant is deprecated
98
+ *
99
+ * @param {function} propType - validates the prop type. Returns null if valid, error otherwise
100
+ * @param {array} deprecated - an array of the deprecated variant names
101
+ * @param {string|function} message - a string with additional information (like the version the prop will be removed) or a function returning a string
102
+ */;
103
+ deprecated.deprecatePropValues = (propType, deprecated = [], message) => {
104
+ return (props, propName, componentName, ...rest) => {
105
+ const isDeprecatedValue = deprecated.includes(props[propName]);
106
+ const warningMessage = message && typeof message === 'function' ? message({
107
+ props,
108
+ propName,
109
+ propValue: props[propName]
110
+ }) : `The '${props[propName]}' value for the \`${propName}\` prop is deprecated. ${message || ''}`;
111
+ (0, _console.logWarnDeprecated)(!isDeprecatedValue, `[${componentName}] ${warningMessage}`);
112
+ return isDeprecatedValue ? null : propType(props, propName, componentName, ...rest);
113
+ };
114
+ };
115
+ function warnDeprecatedProps(componentName, version, props, oldProps, message = '') {
116
+ Object.keys(oldProps).forEach(oldProp => {
117
+ if (typeof props[oldProp] !== 'undefined') {
118
+ const newProp = typeof oldProps[oldProp] === 'string' ? oldProps[oldProp] : null;
119
+ const newPropMessage = newProp ? `. Use \`${newProp}\` instead` : '';
120
+ (0, _console.logWarnDeprecated)(false, `[${componentName}] \`${oldProp}\` is deprecated and will be removed in version ${version}${newPropMessage}. ${message}`);
121
+ }
122
+ });
123
+ }
124
+ ;
125
+ deprecated.warnDeprecatedProps = warnDeprecatedProps;
126
+ function warnDeprecatedComponent(version, componentName, message) {
127
+ (0, _console.logWarnDeprecated)(false, `[${componentName}] is deprecated and will be removed in version ${version}. ${message || ''}`);
128
+ }
129
+ /**
130
+ * ---
131
+ * category: utilities
132
+ * ---
133
+ * @param {String} version the version of the package in which the component or function was deprecated
134
+ * @param {String} componentName the name of the component or Function.name of the utility function
135
+ * @param {String} message a message to display as a console error in DEV env when condition is false
136
+ */
137
+ ;
138
+ deprecated.warnDeprecatedComponent = warnDeprecatedComponent
139
+
140
+ /**
141
+ * ---
142
+ * category: utilities
143
+ * ---
144
+ * @param {String} prevPackage the previous name of the package
145
+ * @param {String} newPackage the new version of the package
146
+ * @return {String} the formatted warning string
147
+ */;
148
+ deprecated.changedPackageWarning = (prevPackage, newPackage) => {
149
+ return `It has been moved from @instructure/${prevPackage} to @instructure/${newPackage}.`;
150
+ };
151
+ return deprecated;
152
+ })();
153
+ var _default = exports.default = deprecated;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.experimental = exports.default = void 0;
7
+ var _decorator = require("@instructure/ui-decorator/lib/decorator.js");
8
+ var _console = require("@instructure/console");
9
+ /*
10
+ * The MIT License (MIT)
11
+ *
12
+ * Copyright (c) 2015 - present Instructure, Inc.
13
+ *
14
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ * of this software and associated documentation files (the "Software"), to deal
16
+ * in the Software without restriction, including without limitation the rights
17
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ * copies of the Software, and to permit persons to whom the Software is
19
+ * furnished to do so, subject to the following conditions:
20
+ *
21
+ * The above copyright notice and this permission notice shall be included in all
22
+ * copies or substantial portions of the Software.
23
+ *
24
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ * SOFTWARE.
31
+ */
32
+
33
+ /**
34
+ * ---
35
+ * category: utilities/react
36
+ * ---
37
+ * Flag React component and component props as experimental.
38
+ * Warnings will display in the console when experimental components/props
39
+ * props are used.
40
+ *
41
+ * ```js-code
42
+ * class Example extends Component {
43
+ * static propTypes = {
44
+ * currentProp: PropTypes.func
45
+ * }
46
+ * }
47
+ * export default experimental(['experimentalProp'])(Example)
48
+ * ```
49
+ *
50
+ * @module experimental
51
+ * @param {array} experimentalProps (if this argument is null or undefined, the entire component is flagged)
52
+ * @param {string} message
53
+ * @return {function} React component flagged as experimental
54
+ */
55
+ const experimental = exports.experimental = process.env.NODE_ENV == 'production' ? () => ReactComponent => ReactComponent : (0, _decorator.decorator)((ComposedComponent, experimentalProps, message) => {
56
+ return class ExperimentalComponent extends ComposedComponent {
57
+ componentDidMount() {
58
+ if (!this.props.__dangerouslyIgnoreExperimentalWarnings) {
59
+ if (experimentalProps) {
60
+ warnExperimentalProps(ComposedComponent.name, this.props, experimentalProps, message);
61
+ } else {
62
+ warnExperimentalComponent(ComposedComponent.name, message);
63
+ }
64
+ }
65
+ if (super.componentDidMount) {
66
+ super.componentDidMount();
67
+ }
68
+ }
69
+ componentDidUpdate(prevProps, prevState, prevContext) {
70
+ if (!this.props.__dangerouslyIgnoreExperimentalWarnings) {
71
+ if (experimentalProps) {
72
+ warnExperimentalProps(ComposedComponent.name, this.props, experimentalProps, message);
73
+ } else {
74
+ warnExperimentalComponent(ComposedComponent.name, message);
75
+ }
76
+ }
77
+ if (super.componentDidUpdate) {
78
+ super.componentDidUpdate(prevProps, prevState, prevContext);
79
+ }
80
+ }
81
+ };
82
+ });
83
+ function warnExperimentalProps(name, props, experimentalProps, message = '') {
84
+ experimentalProps.forEach(experimentalProp => {
85
+ (0, _console.logWarn)(typeof props[experimentalProp] === 'undefined', `[${name}] The \`${experimentalProp}\` prop is experimental and its API could change significantly in a future release. ${message}`);
86
+ });
87
+ }
88
+ function warnExperimentalComponent(name, message = '') {
89
+ (0, _console.logWarn)(false, `[${name}] is experimental and its API could change significantly in a future release. ${message}`);
90
+ }
91
+ var _default = exports.default = experimental;