@mui/utils 6.0.0-alpha.1 → 6.0.0-alpha.11

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.
Files changed (119) hide show
  1. package/CHANGELOG.md +538 -4
  2. package/deepmerge/deepmerge.js +5 -6
  3. package/exactProp/exactProp.js +3 -3
  4. package/getDisplayName/getDisplayName.d.ts +0 -1
  5. package/getDisplayName/getDisplayName.js +1 -10
  6. package/getDisplayName/index.d.ts +0 -1
  7. package/getDisplayName/index.js +1 -2
  8. package/index.js +1 -1
  9. package/integerPropType/integerPropType.js +1 -8
  10. package/modern/deepmerge/deepmerge.js +5 -6
  11. package/modern/exactProp/exactProp.js +3 -3
  12. package/modern/getDisplayName/getDisplayName.js +1 -10
  13. package/modern/getDisplayName/index.js +1 -2
  14. package/modern/index.js +1 -1
  15. package/modern/integerPropType/integerPropType.js +1 -8
  16. package/modern/requirePropFactory/requirePropFactory.js +3 -2
  17. package/modern/resolveProps/resolveProps.js +10 -4
  18. package/modern/useControlled/useControlled.js +3 -1
  19. package/modern/useTimeout/useTimeout.js +11 -12
  20. package/node/deepmerge/deepmerge.js +5 -7
  21. package/node/exactProp/exactProp.js +3 -4
  22. package/node/getDisplayName/getDisplayName.js +1 -10
  23. package/node/getDisplayName/index.js +2 -15
  24. package/node/index.js +1 -1
  25. package/node/integerPropType/integerPropType.js +1 -8
  26. package/node/requirePropFactory/requirePropFactory.js +3 -3
  27. package/node/resolveProps/resolveProps.js +10 -5
  28. package/node/useControlled/useControlled.js +3 -1
  29. package/node/useTimeout/useTimeout.js +11 -12
  30. package/package.json +2 -2
  31. package/requirePropFactory/requirePropFactory.js +3 -2
  32. package/resolveProps/resolveProps.js +10 -4
  33. package/useControlled/useControlled.js +3 -1
  34. package/useTimeout/useTimeout.js +11 -12
  35. package/legacy/ClassNameGenerator/ClassNameGenerator.js +0 -19
  36. package/legacy/ClassNameGenerator/index.js +0 -1
  37. package/legacy/HTMLElementType/HTMLElementType.js +0 -14
  38. package/legacy/HTMLElementType/index.js +0 -1
  39. package/legacy/capitalize/capitalize.js +0 -11
  40. package/legacy/capitalize/index.js +0 -1
  41. package/legacy/chainPropTypes/chainPropTypes.js +0 -10
  42. package/legacy/chainPropTypes/index.js +0 -1
  43. package/legacy/clamp/clamp.js +0 -6
  44. package/legacy/clamp/index.js +0 -1
  45. package/legacy/composeClasses/composeClasses.js +0 -22
  46. package/legacy/composeClasses/index.js +0 -1
  47. package/legacy/createChainedFunction/createChainedFunction.js +0 -23
  48. package/legacy/createChainedFunction/index.js +0 -1
  49. package/legacy/debounce/debounce.js +0 -22
  50. package/legacy/debounce/index.js +0 -2
  51. package/legacy/deepmerge/deepmerge.js +0 -43
  52. package/legacy/deepmerge/index.js +0 -2
  53. package/legacy/deprecatedPropType/deprecatedPropType.js +0 -15
  54. package/legacy/deprecatedPropType/index.js +0 -1
  55. package/legacy/elementAcceptingRef/elementAcceptingRef.js +0 -41
  56. package/legacy/elementAcceptingRef/index.js +0 -1
  57. package/legacy/elementTypeAcceptingRef/elementTypeAcceptingRef.js +0 -39
  58. package/legacy/elementTypeAcceptingRef/index.js +0 -1
  59. package/legacy/exactProp/exactProp.js +0 -23
  60. package/legacy/exactProp/index.js +0 -1
  61. package/legacy/formatMuiErrorMessage/formatMuiErrorMessage.js +0 -19
  62. package/legacy/formatMuiErrorMessage/index.js +0 -1
  63. package/legacy/generateUtilityClass/generateUtilityClass.js +0 -23
  64. package/legacy/generateUtilityClass/index.js +0 -2
  65. package/legacy/generateUtilityClasses/generateUtilityClasses.js +0 -9
  66. package/legacy/generateUtilityClasses/index.js +0 -1
  67. package/legacy/getDisplayName/getDisplayName.js +0 -49
  68. package/legacy/getDisplayName/index.js +0 -2
  69. package/legacy/getScrollbarSize/getScrollbarSize.js +0 -7
  70. package/legacy/getScrollbarSize/index.js +0 -1
  71. package/legacy/getValidReactChildren/getValidReactChildren.js +0 -13
  72. package/legacy/getValidReactChildren/index.js +0 -1
  73. package/legacy/index.js +0 -51
  74. package/legacy/integerPropType/index.js +0 -2
  75. package/legacy/integerPropType/integerPropType.js +0 -55
  76. package/legacy/isMuiElement/index.js +0 -1
  77. package/legacy/isMuiElement/isMuiElement.js +0 -8
  78. package/legacy/ownerDocument/index.js +0 -1
  79. package/legacy/ownerDocument/ownerDocument.js +0 -3
  80. package/legacy/ownerWindow/index.js +0 -1
  81. package/legacy/ownerWindow/ownerWindow.js +0 -5
  82. package/legacy/ponyfillGlobal/index.js +0 -1
  83. package/legacy/ponyfillGlobal/ponyfillGlobal.js +0 -3
  84. package/legacy/refType/index.js +0 -1
  85. package/legacy/refType/refType.js +0 -3
  86. package/legacy/requirePropFactory/index.js +0 -1
  87. package/legacy/requirePropFactory/requirePropFactory.js +0 -31
  88. package/legacy/resolveProps/index.js +0 -1
  89. package/legacy/resolveProps/resolveProps.js +0 -34
  90. package/legacy/scrollLeft/index.js +0 -1
  91. package/legacy/scrollLeft/scrollLeft.js +0 -70
  92. package/legacy/setRef/index.js +0 -1
  93. package/legacy/setRef/setRef.js +0 -20
  94. package/legacy/unsupportedProp/index.js +0 -1
  95. package/legacy/unsupportedProp/unsupportedProp.js +0 -10
  96. package/legacy/useControlled/index.js +0 -1
  97. package/legacy/useControlled/useControlled.js +0 -38
  98. package/legacy/useEnhancedEffect/index.js +0 -1
  99. package/legacy/useEnhancedEffect/useEnhancedEffect.js +0 -13
  100. package/legacy/useEventCallback/index.js +0 -1
  101. package/legacy/useEventCallback/useEventCallback.js +0 -23
  102. package/legacy/useForkRef/index.js +0 -1
  103. package/legacy/useForkRef/useForkRef.js +0 -27
  104. package/legacy/useId/index.js +0 -1
  105. package/legacy/useId/useId.js +0 -38
  106. package/legacy/useIsFocusVisible/index.js +0 -2
  107. package/legacy/useIsFocusVisible/useIsFocusVisible.js +0 -160
  108. package/legacy/useLazyRef/index.js +0 -1
  109. package/legacy/useLazyRef/useLazyRef.js +0 -19
  110. package/legacy/useLocalStorageState/index.js +0 -1
  111. package/legacy/useLocalStorageState/useLocalStorageState.js +0 -121
  112. package/legacy/useOnMount/index.js +0 -1
  113. package/legacy/useOnMount/useOnMount.js +0 -13
  114. package/legacy/usePreviousProps/index.js +0 -1
  115. package/legacy/usePreviousProps/usePreviousProps.js +0 -11
  116. package/legacy/useTimeout/index.js +0 -2
  117. package/legacy/useTimeout/useTimeout.js +0 -47
  118. package/legacy/visuallyHidden/index.js +0 -1
  119. package/legacy/visuallyHidden/visuallyHidden.js +0 -12
@@ -21,16 +21,9 @@ export function getTypeByValue(value) {
21
21
  return valueType;
22
22
  }
23
23
  }
24
-
25
- // IE 11 support
26
- function ponyfillIsInteger(x) {
27
- // eslint-disable-next-line no-restricted-globals
28
- return typeof x === 'number' && isFinite(x) && Math.floor(x) === x;
29
- }
30
- const isInteger = Number.isInteger || ponyfillIsInteger;
31
24
  function requiredInteger(props, propName, componentName, location) {
32
25
  const propValue = props[propName];
33
- if (propValue == null || !isInteger(propValue)) {
26
+ if (propValue == null || !Number.isInteger(propValue)) {
34
27
  const propType = getTypeByValue(propValue);
35
28
  return new RangeError(`Invalid ${location} \`${propName}\` of type \`${propType}\` supplied to \`${componentName}\`, expected \`integer\`.`);
36
29
  }
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  // https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
3
2
  export function isPlainObject(item) {
4
3
  if (typeof item !== 'object' || item === null) {
@@ -20,14 +19,14 @@ function deepClone(source) {
20
19
  export default function deepmerge(target, source, options = {
21
20
  clone: true
22
21
  }) {
23
- const output = options.clone ? _extends({}, target) : target;
22
+ const output = options.clone ? {
23
+ ...target
24
+ } : target;
24
25
  if (isPlainObject(target) && isPlainObject(source)) {
25
26
  Object.keys(source).forEach(key => {
27
+ if (isPlainObject(source[key]) &&
26
28
  // Avoid prototype pollution
27
- if (key === '__proto__') {
28
- return;
29
- }
30
- if (isPlainObject(source[key]) && key in target && isPlainObject(target[key])) {
29
+ Object.prototype.hasOwnProperty.call(target, key) && isPlainObject(target[key])) {
31
30
  // Since `output` is a clone of `target` and we have narrowed `target` in this block we can cast to the same type.
32
31
  output[key] = deepmerge(target[key], source[key], options);
33
32
  } else if (options.clone) {
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  // This module is based on https://github.com/airbnb/prop-types-exact repository.
3
2
  // However, in order to reduce the number of dependencies and to remove some extra safe checks
4
3
  // the module was forked.
@@ -8,7 +7,8 @@ export default function exactProp(propTypes) {
8
7
  if (process.env.NODE_ENV === 'production') {
9
8
  return propTypes;
10
9
  }
11
- return _extends({}, propTypes, {
10
+ return {
11
+ ...propTypes,
12
12
  [specialProperty]: props => {
13
13
  const unsupportedProps = Object.keys(props).filter(prop => !propTypes.hasOwnProperty(prop));
14
14
  if (unsupportedProps.length > 0) {
@@ -16,5 +16,5 @@ export default function exactProp(propTypes) {
16
16
  }
17
17
  return null;
18
18
  }
19
- });
19
+ };
20
20
  }
@@ -1,15 +1,6 @@
1
1
  import { ForwardRef, Memo } from 'react-is';
2
-
3
- // Simplified polyfill for IE11 support
4
- // https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3
5
- const fnNameMatchRegex = /^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/;
6
- export function getFunctionName(fn) {
7
- const match = `${fn}`.match(fnNameMatchRegex);
8
- const name = match && match[1];
9
- return name || '';
10
- }
11
2
  function getFunctionComponentName(Component, fallback = '') {
12
- return Component.displayName || Component.name || getFunctionName(Component) || fallback;
3
+ return Component.displayName || Component.name || fallback;
13
4
  }
14
5
  function getWrappedName(outerType, innerType, wrapperName) {
15
6
  const functionName = getFunctionComponentName(innerType);
@@ -1,2 +1 @@
1
- export { default } from './getDisplayName';
2
- export * from './getDisplayName';
1
+ export { default } from './getDisplayName';
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v6.0.0-alpha.1
2
+ * @mui/utils v6.0.0-alpha.11
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -21,16 +21,9 @@ export function getTypeByValue(value) {
21
21
  return valueType;
22
22
  }
23
23
  }
24
-
25
- // IE 11 support
26
- function ponyfillIsInteger(x) {
27
- // eslint-disable-next-line no-restricted-globals
28
- return typeof x === 'number' && isFinite(x) && Math.floor(x) === x;
29
- }
30
- const isInteger = Number.isInteger || ponyfillIsInteger;
31
24
  function requiredInteger(props, propName, componentName, location) {
32
25
  const propValue = props[propName];
33
- if (propValue == null || !isInteger(propValue)) {
26
+ if (propValue == null || !Number.isInteger(propValue)) {
34
27
  const propType = getTypeByValue(propValue);
35
28
  return new RangeError(`Invalid ${location} \`${propName}\` of type \`${propType}\` supplied to \`${componentName}\`, expected \`integer\`.`);
36
29
  }
@@ -1,11 +1,12 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  export default function requirePropFactory(componentNameInError, Component) {
3
2
  if (process.env.NODE_ENV === 'production') {
4
3
  return () => null;
5
4
  }
6
5
 
7
6
  // eslint-disable-next-line react/forbid-foreign-prop-types
8
- const prevPropTypes = Component ? _extends({}, Component.propTypes) : null;
7
+ const prevPropTypes = Component ? {
8
+ ...Component.propTypes
9
+ } : null;
9
10
  const requireProp = requiredProp => (props, propName, componentName, location, propFullName, ...args) => {
10
11
  const propFullNameSafe = propFullName || propName;
11
12
  const defaultTypeChecker = prevPropTypes?.[propFullNameSafe];
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  /**
3
2
  * Add keys, values of `defaultProps` that does not exist in `props`
4
3
  * @param {object} defaultProps
@@ -6,10 +5,15 @@ import _extends from "@babel/runtime/helpers/esm/extends";
6
5
  * @returns {object} resolved props
7
6
  */
8
7
  export default function resolveProps(defaultProps, props) {
9
- const output = _extends({}, props);
8
+ const output = {
9
+ ...props
10
+ };
10
11
  Object.keys(defaultProps).forEach(propName => {
11
12
  if (propName.toString().match(/^(components|slots)$/)) {
12
- output[propName] = _extends({}, defaultProps[propName], output[propName]);
13
+ output[propName] = {
14
+ ...defaultProps[propName],
15
+ ...output[propName]
16
+ };
13
17
  } else if (propName.toString().match(/^(componentsProps|slotProps)$/)) {
14
18
  const defaultSlotProps = defaultProps[propName] || {};
15
19
  const slotProps = props[propName];
@@ -21,7 +25,9 @@ export default function resolveProps(defaultProps, props) {
21
25
  // Reduce the iteration if the default slot props is empty
22
26
  output[propName] = slotProps;
23
27
  } else {
24
- output[propName] = _extends({}, slotProps);
28
+ output[propName] = {
29
+ ...slotProps
30
+ };
25
31
  Object.keys(defaultSlotProps).forEach(slotPropName => {
26
32
  output[propName][slotPropName] = resolveProps(defaultSlotProps[slotPropName], slotProps[slotPropName]);
27
33
  });
@@ -24,7 +24,9 @@ export default function useControlled({
24
24
  current: defaultValue
25
25
  } = React.useRef(defaultProp);
26
26
  React.useEffect(() => {
27
- if (!isControlled && defaultValue !== defaultProp) {
27
+ // Object.is() is not equivalent to the === operator.
28
+ // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is for more details.
29
+ if (!isControlled && !Object.is(defaultValue, defaultProp)) {
28
30
  console.error([`MUI: A component is changing the default ${state} state of an uncontrolled ${name} after being initialized. ` + `To suppress this warning opt to use a controlled ${name}.`].join('\n'));
29
31
  }
30
32
  }, [JSON.stringify(defaultProp)]);
@@ -3,21 +3,11 @@
3
3
  import useLazyRef from '../useLazyRef/useLazyRef';
4
4
  import useOnMount from '../useOnMount/useOnMount';
5
5
  export class Timeout {
6
- constructor() {
7
- this.currentId = null;
8
- this.clear = () => {
9
- if (this.currentId !== null) {
10
- clearTimeout(this.currentId);
11
- this.currentId = null;
12
- }
13
- };
14
- this.disposeEffect = () => {
15
- return this.clear;
16
- };
17
- }
18
6
  static create() {
19
7
  return new Timeout();
20
8
  }
9
+ currentId = null;
10
+
21
11
  /**
22
12
  * Executes `fn` after `delay`, clearing any previously scheduled call.
23
13
  */
@@ -28,6 +18,15 @@ export class Timeout {
28
18
  fn();
29
19
  }, delay);
30
20
  }
21
+ clear = () => {
22
+ if (this.currentId !== null) {
23
+ clearTimeout(this.currentId);
24
+ this.currentId = null;
25
+ }
26
+ };
27
+ disposeEffect = () => {
28
+ return this.clear;
29
+ };
31
30
  }
32
31
  export default function useTimeout() {
33
32
  const timeout = useLazyRef(Timeout.create).current;
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = deepmerge;
8
7
  exports.isPlainObject = isPlainObject;
9
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
8
  // https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
11
9
  function isPlainObject(item) {
12
10
  if (typeof item !== 'object' || item === null) {
@@ -28,14 +26,14 @@ function deepClone(source) {
28
26
  function deepmerge(target, source, options = {
29
27
  clone: true
30
28
  }) {
31
- const output = options.clone ? (0, _extends2.default)({}, target) : target;
29
+ const output = options.clone ? {
30
+ ...target
31
+ } : target;
32
32
  if (isPlainObject(target) && isPlainObject(source)) {
33
33
  Object.keys(source).forEach(key => {
34
+ if (isPlainObject(source[key]) &&
34
35
  // Avoid prototype pollution
35
- if (key === '__proto__') {
36
- return;
37
- }
38
- if (isPlainObject(source[key]) && key in target && isPlainObject(target[key])) {
36
+ Object.prototype.hasOwnProperty.call(target, key) && isPlainObject(target[key])) {
39
37
  // Since `output` is a clone of `target` and we have narrowed `target` in this block we can cast to the same type.
40
38
  output[key] = deepmerge(target[key], source[key], options);
41
39
  } else if (options.clone) {
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = exactProp;
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
7
  // This module is based on https://github.com/airbnb/prop-types-exact repository.
10
8
  // However, in order to reduce the number of dependencies and to remove some extra safe checks
11
9
  // the module was forked.
@@ -15,7 +13,8 @@ function exactProp(propTypes) {
15
13
  if (process.env.NODE_ENV === 'production') {
16
14
  return propTypes;
17
15
  }
18
- return (0, _extends2.default)({}, propTypes, {
16
+ return {
17
+ ...propTypes,
19
18
  [specialProperty]: props => {
20
19
  const unsupportedProps = Object.keys(props).filter(prop => !propTypes.hasOwnProperty(prop));
21
20
  if (unsupportedProps.length > 0) {
@@ -23,5 +22,5 @@ function exactProp(propTypes) {
23
22
  }
24
23
  return null;
25
24
  }
26
- });
25
+ };
27
26
  }
@@ -4,18 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = getDisplayName;
7
- exports.getFunctionName = getFunctionName;
8
7
  var _reactIs = require("react-is");
9
- // Simplified polyfill for IE11 support
10
- // https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3
11
- const fnNameMatchRegex = /^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/;
12
- function getFunctionName(fn) {
13
- const match = `${fn}`.match(fnNameMatchRegex);
14
- const name = match && match[1];
15
- return name || '';
16
- }
17
8
  function getFunctionComponentName(Component, fallback = '') {
18
- return Component.displayName || Component.name || getFunctionName(Component) || fallback;
9
+ return Component.displayName || Component.name || fallback;
19
10
  }
20
11
  function getWrappedName(outerType, innerType, wrapperName) {
21
12
  const functionName = getFunctionComponentName(innerType);
@@ -1,26 +1,13 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
- var _exportNames = {};
7
7
  Object.defineProperty(exports, "default", {
8
8
  enumerable: true,
9
9
  get: function () {
10
10
  return _getDisplayName.default;
11
11
  }
12
12
  });
13
- var _getDisplayName = _interopRequireWildcard(require("./getDisplayName"));
14
- Object.keys(_getDisplayName).forEach(function (key) {
15
- if (key === "default" || key === "__esModule") return;
16
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
17
- if (key in exports && exports[key] === _getDisplayName[key]) return;
18
- Object.defineProperty(exports, key, {
19
- enumerable: true,
20
- get: function () {
21
- return _getDisplayName[key];
22
- }
23
- });
24
- });
25
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
26
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
+ var _getDisplayName = _interopRequireDefault(require("./getDisplayName"));
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v6.0.0-alpha.1
2
+ * @mui/utils v6.0.0-alpha.11
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -28,16 +28,9 @@ function getTypeByValue(value) {
28
28
  return valueType;
29
29
  }
30
30
  }
31
-
32
- // IE 11 support
33
- function ponyfillIsInteger(x) {
34
- // eslint-disable-next-line no-restricted-globals
35
- return typeof x === 'number' && isFinite(x) && Math.floor(x) === x;
36
- }
37
- const isInteger = Number.isInteger || ponyfillIsInteger;
38
31
  function requiredInteger(props, propName, componentName, location) {
39
32
  const propValue = props[propName];
40
- if (propValue == null || !isInteger(propValue)) {
33
+ if (propValue == null || !Number.isInteger(propValue)) {
41
34
  const propType = getTypeByValue(propValue);
42
35
  return new RangeError(`Invalid ${location} \`${propName}\` of type \`${propType}\` supplied to \`${componentName}\`, expected \`integer\`.`);
43
36
  }
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = requirePropFactory;
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
7
  function requirePropFactory(componentNameInError, Component) {
10
8
  if (process.env.NODE_ENV === 'production') {
11
9
  return () => null;
12
10
  }
13
11
 
14
12
  // eslint-disable-next-line react/forbid-foreign-prop-types
15
- const prevPropTypes = Component ? (0, _extends2.default)({}, Component.propTypes) : null;
13
+ const prevPropTypes = Component ? {
14
+ ...Component.propTypes
15
+ } : null;
16
16
  const requireProp = requiredProp => (props, propName, componentName, location, propFullName, ...args) => {
17
17
  const propFullNameSafe = propFullName || propName;
18
18
  const defaultTypeChecker = prevPropTypes == null ? void 0 : prevPropTypes[propFullNameSafe];
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = resolveProps;
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
7
  /**
10
8
  * Add keys, values of `defaultProps` that does not exist in `props`
11
9
  * @param {object} defaultProps
@@ -13,10 +11,15 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
13
11
  * @returns {object} resolved props
14
12
  */
15
13
  function resolveProps(defaultProps, props) {
16
- const output = (0, _extends2.default)({}, props);
14
+ const output = {
15
+ ...props
16
+ };
17
17
  Object.keys(defaultProps).forEach(propName => {
18
18
  if (propName.toString().match(/^(components|slots)$/)) {
19
- output[propName] = (0, _extends2.default)({}, defaultProps[propName], output[propName]);
19
+ output[propName] = {
20
+ ...defaultProps[propName],
21
+ ...output[propName]
22
+ };
20
23
  } else if (propName.toString().match(/^(componentsProps|slotProps)$/)) {
21
24
  const defaultSlotProps = defaultProps[propName] || {};
22
25
  const slotProps = props[propName];
@@ -28,7 +31,9 @@ function resolveProps(defaultProps, props) {
28
31
  // Reduce the iteration if the default slot props is empty
29
32
  output[propName] = slotProps;
30
33
  } else {
31
- output[propName] = (0, _extends2.default)({}, slotProps);
34
+ output[propName] = {
35
+ ...slotProps
36
+ };
32
37
  Object.keys(defaultSlotProps).forEach(slotPropName => {
33
38
  output[propName][slotPropName] = resolveProps(defaultSlotProps[slotPropName], slotProps[slotPropName]);
34
39
  });
@@ -31,7 +31,9 @@ function useControlled({
31
31
  current: defaultValue
32
32
  } = React.useRef(defaultProp);
33
33
  React.useEffect(() => {
34
- if (!isControlled && defaultValue !== defaultProp) {
34
+ // Object.is() is not equivalent to the === operator.
35
+ // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is for more details.
36
+ if (!isControlled && !Object.is(defaultValue, defaultProp)) {
35
37
  console.error([`MUI: A component is changing the default ${state} state of an uncontrolled ${name} after being initialized. ` + `To suppress this warning opt to use a controlled ${name}.`].join('\n'));
36
38
  }
37
39
  }, [JSON.stringify(defaultProp)]);
@@ -10,21 +10,11 @@ exports.default = useTimeout;
10
10
  var _useLazyRef = _interopRequireDefault(require("../useLazyRef/useLazyRef"));
11
11
  var _useOnMount = _interopRequireDefault(require("../useOnMount/useOnMount"));
12
12
  class Timeout {
13
- constructor() {
14
- this.currentId = null;
15
- this.clear = () => {
16
- if (this.currentId !== null) {
17
- clearTimeout(this.currentId);
18
- this.currentId = null;
19
- }
20
- };
21
- this.disposeEffect = () => {
22
- return this.clear;
23
- };
24
- }
25
13
  static create() {
26
14
  return new Timeout();
27
15
  }
16
+ currentId = null;
17
+
28
18
  /**
29
19
  * Executes `fn` after `delay`, clearing any previously scheduled call.
30
20
  */
@@ -35,6 +25,15 @@ class Timeout {
35
25
  fn();
36
26
  }, delay);
37
27
  }
28
+ clear = () => {
29
+ if (this.currentId !== null) {
30
+ clearTimeout(this.currentId);
31
+ this.currentId = null;
32
+ }
33
+ };
34
+ disposeEffect = () => {
35
+ return this.clear;
36
+ };
38
37
  }
39
38
  exports.Timeout = Timeout;
40
39
  function useTimeout() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/utils",
3
- "version": "6.0.0-alpha.1",
3
+ "version": "6.0.0-alpha.11",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "Utility functions for React components.",
@@ -26,7 +26,7 @@
26
26
  "url": "https://opencollective.com/mui-org"
27
27
  },
28
28
  "dependencies": {
29
- "@babel/runtime": "^7.24.4",
29
+ "@babel/runtime": "^7.24.7",
30
30
  "@types/prop-types": "^15.7.12",
31
31
  "prop-types": "^15.8.1",
32
32
  "react-is": "^18.2.0"
@@ -1,11 +1,12 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  export default function requirePropFactory(componentNameInError, Component) {
3
2
  if (process.env.NODE_ENV === 'production') {
4
3
  return () => null;
5
4
  }
6
5
 
7
6
  // eslint-disable-next-line react/forbid-foreign-prop-types
8
- const prevPropTypes = Component ? _extends({}, Component.propTypes) : null;
7
+ const prevPropTypes = Component ? {
8
+ ...Component.propTypes
9
+ } : null;
9
10
  const requireProp = requiredProp => (props, propName, componentName, location, propFullName, ...args) => {
10
11
  const propFullNameSafe = propFullName || propName;
11
12
  const defaultTypeChecker = prevPropTypes?.[propFullNameSafe];
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  /**
3
2
  * Add keys, values of `defaultProps` that does not exist in `props`
4
3
  * @param {object} defaultProps
@@ -6,10 +5,15 @@ import _extends from "@babel/runtime/helpers/esm/extends";
6
5
  * @returns {object} resolved props
7
6
  */
8
7
  export default function resolveProps(defaultProps, props) {
9
- const output = _extends({}, props);
8
+ const output = {
9
+ ...props
10
+ };
10
11
  Object.keys(defaultProps).forEach(propName => {
11
12
  if (propName.toString().match(/^(components|slots)$/)) {
12
- output[propName] = _extends({}, defaultProps[propName], output[propName]);
13
+ output[propName] = {
14
+ ...defaultProps[propName],
15
+ ...output[propName]
16
+ };
13
17
  } else if (propName.toString().match(/^(componentsProps|slotProps)$/)) {
14
18
  const defaultSlotProps = defaultProps[propName] || {};
15
19
  const slotProps = props[propName];
@@ -21,7 +25,9 @@ export default function resolveProps(defaultProps, props) {
21
25
  // Reduce the iteration if the default slot props is empty
22
26
  output[propName] = slotProps;
23
27
  } else {
24
- output[propName] = _extends({}, slotProps);
28
+ output[propName] = {
29
+ ...slotProps
30
+ };
25
31
  Object.keys(defaultSlotProps).forEach(slotPropName => {
26
32
  output[propName][slotPropName] = resolveProps(defaultSlotProps[slotPropName], slotProps[slotPropName]);
27
33
  });
@@ -24,7 +24,9 @@ export default function useControlled({
24
24
  current: defaultValue
25
25
  } = React.useRef(defaultProp);
26
26
  React.useEffect(() => {
27
- if (!isControlled && defaultValue !== defaultProp) {
27
+ // Object.is() is not equivalent to the === operator.
28
+ // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is for more details.
29
+ if (!isControlled && !Object.is(defaultValue, defaultProp)) {
28
30
  console.error([`MUI: A component is changing the default ${state} state of an uncontrolled ${name} after being initialized. ` + `To suppress this warning opt to use a controlled ${name}.`].join('\n'));
29
31
  }
30
32
  }, [JSON.stringify(defaultProp)]);
@@ -3,21 +3,11 @@
3
3
  import useLazyRef from '../useLazyRef/useLazyRef';
4
4
  import useOnMount from '../useOnMount/useOnMount';
5
5
  export class Timeout {
6
- constructor() {
7
- this.currentId = null;
8
- this.clear = () => {
9
- if (this.currentId !== null) {
10
- clearTimeout(this.currentId);
11
- this.currentId = null;
12
- }
13
- };
14
- this.disposeEffect = () => {
15
- return this.clear;
16
- };
17
- }
18
6
  static create() {
19
7
  return new Timeout();
20
8
  }
9
+ currentId = null;
10
+
21
11
  /**
22
12
  * Executes `fn` after `delay`, clearing any previously scheduled call.
23
13
  */
@@ -28,6 +18,15 @@ export class Timeout {
28
18
  fn();
29
19
  }, delay);
30
20
  }
21
+ clear = () => {
22
+ if (this.currentId !== null) {
23
+ clearTimeout(this.currentId);
24
+ this.currentId = null;
25
+ }
26
+ };
27
+ disposeEffect = () => {
28
+ return this.clear;
29
+ };
31
30
  }
32
31
  export default function useTimeout() {
33
32
  const timeout = useLazyRef(Timeout.create).current;
@@ -1,19 +0,0 @@
1
- var defaultGenerator = function defaultGenerator(componentName) {
2
- return componentName;
3
- };
4
- var createClassNameGenerator = function createClassNameGenerator() {
5
- var _generate = defaultGenerator;
6
- return {
7
- configure: function configure(generator) {
8
- _generate = generator;
9
- },
10
- generate: function generate(componentName) {
11
- return _generate(componentName);
12
- },
13
- reset: function reset() {
14
- _generate = defaultGenerator;
15
- }
16
- };
17
- };
18
- var ClassNameGenerator = createClassNameGenerator();
19
- export default ClassNameGenerator;
@@ -1 +0,0 @@
1
- export { default } from './ClassNameGenerator';
@@ -1,14 +0,0 @@
1
- export default function HTMLElementType(props, propName, componentName, location, propFullName) {
2
- if (process.env.NODE_ENV === 'production') {
3
- return null;
4
- }
5
- var propValue = props[propName];
6
- var safePropName = propFullName || propName;
7
- if (propValue == null) {
8
- return null;
9
- }
10
- if (propValue && propValue.nodeType !== 1) {
11
- return new Error("Invalid ".concat(location, " `").concat(safePropName, "` supplied to `").concat(componentName, "`. ") + "Expected an HTMLElement.");
12
- }
13
- return null;
14
- }
@@ -1 +0,0 @@
1
- export { default } from './HTMLElementType';
@@ -1,11 +0,0 @@
1
- import _formatMuiErrorMessage from "@mui/utils/formatMuiErrorMessage";
2
- // It should to be noted that this function isn't equivalent to `text-transform: capitalize`.
3
- //
4
- // A strict capitalization should uppercase the first letter of each word in the sentence.
5
- // We only handle the first word.
6
- export default function capitalize(string) {
7
- if (typeof string !== 'string') {
8
- throw new Error(process.env.NODE_ENV !== "production" ? "MUI: `capitalize(string)` expects a string argument." : _formatMuiErrorMessage(7));
9
- }
10
- return string.charAt(0).toUpperCase() + string.slice(1);
11
- }
@@ -1 +0,0 @@
1
- export { default } from './capitalize';