@mui/utils 5.10.9 → 5.10.14

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 (153) hide show
  1. package/CHANGELOG.md +574 -214
  2. package/ClassNameGenerator/ClassNameGenerator.d.ts +6 -6
  3. package/ClassNameGenerator/ClassNameGenerator.js +0 -6
  4. package/ClassNameGenerator/index.d.ts +1 -1
  5. package/ClassNameGenerator/index.js +0 -2
  6. package/HTMLElementType.d.ts +3 -3
  7. package/HTMLElementType.js +0 -5
  8. package/capitalize.js +0 -4
  9. package/chainPropTypes.d.ts +2 -2
  10. package/chainPropTypes.js +0 -2
  11. package/composeClasses/composeClasses.d.ts +1 -1
  12. package/composeClasses/composeClasses.js +2 -4
  13. package/composeClasses/index.d.ts +1 -1
  14. package/composeClasses/index.js +0 -2
  15. package/createChainedFunction.d.ts +7 -7
  16. package/createChainedFunction.js +0 -2
  17. package/debounce.js +0 -5
  18. package/deepmerge.d.ts +5 -5
  19. package/deepmerge.js +0 -7
  20. package/deprecatedPropType.js +0 -4
  21. package/elementAcceptingRef.d.ts +3 -3
  22. package/elementAcceptingRef.js +2 -12
  23. package/elementTypeAcceptingRef.d.ts +3 -3
  24. package/elementTypeAcceptingRef.js +3 -13
  25. package/esm/ClassNameGenerator/ClassNameGenerator.js +0 -5
  26. package/esm/HTMLElementType.js +0 -4
  27. package/esm/capitalize.js +0 -1
  28. package/esm/chainPropTypes.js +0 -1
  29. package/esm/composeClasses/composeClasses.js +2 -3
  30. package/esm/createChainedFunction.js +0 -1
  31. package/esm/debounce.js +0 -4
  32. package/esm/deepmerge.js +0 -3
  33. package/esm/deprecatedPropType.js +0 -3
  34. package/esm/elementAcceptingRef.js +2 -9
  35. package/esm/elementTypeAcceptingRef.js +3 -9
  36. package/esm/exactProp.js +1 -3
  37. package/esm/formatMuiErrorMessage.js +0 -3
  38. package/esm/getDisplayName.js +6 -13
  39. package/esm/integerPropType.js +2 -17
  40. package/esm/requirePropFactory.js +2 -8
  41. package/esm/resolveProps.js +0 -2
  42. package/esm/scrollLeft.js +5 -11
  43. package/esm/unsupportedProp.js +0 -3
  44. package/esm/useControlled.js +0 -2
  45. package/esm/useEventCallback.js +3 -2
  46. package/esm/useForkRef.js +2 -2
  47. package/esm/useId.js +4 -7
  48. package/esm/useIsFocusVisible.js +10 -26
  49. package/esm/usePreviousProps.js +0 -2
  50. package/exactProp.d.ts +2 -2
  51. package/exactProp.js +1 -7
  52. package/formatMuiErrorMessage.d.ts +6 -6
  53. package/formatMuiErrorMessage.js +0 -4
  54. package/generateUtilityClass/generateUtilityClass.d.ts +2 -2
  55. package/generateUtilityClass/generateUtilityClass.js +0 -4
  56. package/generateUtilityClass/index.d.ts +2 -2
  57. package/generateUtilityClass/index.js +0 -4
  58. package/generateUtilityClasses/generateUtilityClasses.d.ts +1 -1
  59. package/generateUtilityClasses/generateUtilityClasses.js +0 -3
  60. package/generateUtilityClasses/index.d.ts +1 -1
  61. package/generateUtilityClasses/index.js +0 -2
  62. package/getDisplayName.d.ts +8 -8
  63. package/getDisplayName.js +3 -14
  64. package/getScrollbarSize.d.ts +1 -1
  65. package/getScrollbarSize.js +0 -1
  66. package/index.d.ts +38 -38
  67. package/index.js +1 -41
  68. package/integerPropType.d.ts +7 -7
  69. package/integerPropType.js +2 -21
  70. package/isMuiElement.d.ts +1 -1
  71. package/isMuiElement.js +0 -4
  72. package/legacy/ClassNameGenerator/ClassNameGenerator.js +0 -2
  73. package/legacy/HTMLElementType.js +0 -4
  74. package/legacy/capitalize.js +0 -1
  75. package/legacy/chainPropTypes.js +0 -1
  76. package/legacy/composeClasses/composeClasses.js +2 -3
  77. package/legacy/createChainedFunction.js +0 -3
  78. package/legacy/debounce.js +0 -6
  79. package/legacy/deepmerge.js +0 -3
  80. package/legacy/deprecatedPropType.js +0 -3
  81. package/legacy/elementAcceptingRef.js +3 -10
  82. package/legacy/elementTypeAcceptingRef.js +4 -10
  83. package/legacy/exactProp.js +1 -3
  84. package/legacy/formatMuiErrorMessage.js +0 -3
  85. package/legacy/getDisplayName.js +6 -13
  86. package/legacy/index.js +1 -1
  87. package/legacy/integerPropType.js +2 -18
  88. package/legacy/requirePropFactory.js +2 -9
  89. package/legacy/resolveProps.js +0 -2
  90. package/legacy/scrollLeft.js +5 -11
  91. package/legacy/unsupportedProp.js +0 -3
  92. package/legacy/useControlled.js +8 -15
  93. package/legacy/useEventCallback.js +3 -2
  94. package/legacy/useForkRef.js +2 -3
  95. package/legacy/useId.js +6 -10
  96. package/legacy/useIsFocusVisible.js +12 -28
  97. package/legacy/usePreviousProps.js +0 -2
  98. package/modern/ClassNameGenerator/ClassNameGenerator.js +0 -5
  99. package/modern/HTMLElementType.js +0 -4
  100. package/modern/capitalize.js +0 -1
  101. package/modern/chainPropTypes.js +0 -1
  102. package/modern/composeClasses/composeClasses.js +2 -3
  103. package/modern/createChainedFunction.js +0 -1
  104. package/modern/debounce.js +0 -4
  105. package/modern/deepmerge.js +0 -3
  106. package/modern/deprecatedPropType.js +0 -3
  107. package/modern/elementAcceptingRef.js +2 -9
  108. package/modern/elementTypeAcceptingRef.js +3 -9
  109. package/modern/exactProp.js +1 -3
  110. package/modern/formatMuiErrorMessage.js +0 -3
  111. package/modern/getDisplayName.js +6 -13
  112. package/modern/index.js +1 -1
  113. package/modern/integerPropType.js +2 -17
  114. package/modern/requirePropFactory.js +2 -8
  115. package/modern/resolveProps.js +0 -2
  116. package/modern/scrollLeft.js +5 -11
  117. package/modern/unsupportedProp.js +0 -3
  118. package/modern/useControlled.js +0 -2
  119. package/modern/useEventCallback.js +3 -2
  120. package/modern/useForkRef.js +2 -2
  121. package/modern/useId.js +4 -7
  122. package/modern/useIsFocusVisible.js +10 -26
  123. package/modern/usePreviousProps.js +0 -2
  124. package/ownerDocument.d.ts +1 -1
  125. package/ownerDocument.js +0 -1
  126. package/ownerWindow.d.ts +1 -1
  127. package/ownerWindow.js +0 -3
  128. package/package.json +2 -2
  129. package/ponyfillGlobal.d.ts +2 -2
  130. package/ponyfillGlobal.js +0 -2
  131. package/refType.d.ts +3 -3
  132. package/refType.js +0 -4
  133. package/requirePropFactory.js +2 -11
  134. package/resolveProps.d.ts +9 -9
  135. package/resolveProps.js +0 -3
  136. package/scrollLeft.js +5 -12
  137. package/setRef.d.ts +15 -15
  138. package/setRef.js +0 -1
  139. package/unsupportedProp.js +0 -4
  140. package/useControlled.js +1 -6
  141. package/useEnhancedEffect.js +0 -4
  142. package/useEventCallback.d.ts +4 -4
  143. package/useEventCallback.js +2 -7
  144. package/useEventCallback.spec.d.ts +1 -1
  145. package/useForkRef.d.ts +2 -2
  146. package/useForkRef.js +2 -8
  147. package/useId.d.ts +7 -7
  148. package/useId.js +4 -11
  149. package/useIsFocusVisible.d.ts +9 -9
  150. package/useIsFocusVisible.js +11 -30
  151. package/usePreviousProps.d.ts +2 -2
  152. package/usePreviousProps.js +0 -5
  153. package/visuallyHidden.d.ts +2 -2
@@ -18,6 +18,7 @@ var inputTypesWhitelist = {
18
18
  datetime: true,
19
19
  'datetime-local': true
20
20
  };
21
+
21
22
  /**
22
23
  * Computes whether the given element should automatically trigger the
23
24
  * `focus-visible` class being added, i.e. whether it should always match
@@ -25,26 +26,22 @@ var inputTypesWhitelist = {
25
26
  * @param {Element} node
26
27
  * @returns {boolean}
27
28
  */
28
-
29
29
  function focusTriggersKeyboardModality(node) {
30
30
  var _ref = node,
31
- type = _ref.type,
32
- tagName = _ref.tagName;
33
-
31
+ type = _ref.type,
32
+ tagName = _ref.tagName;
34
33
  if (tagName === 'INPUT' && inputTypesWhitelist[type] && !node.readOnly) {
35
34
  return true;
36
35
  }
37
-
38
36
  if (tagName === 'TEXTAREA' && !node.readOnly) {
39
37
  return true;
40
38
  }
41
-
42
39
  if (node.isContentEditable) {
43
40
  return true;
44
41
  }
45
-
46
42
  return false;
47
43
  }
44
+
48
45
  /**
49
46
  * Keep track of our keyboard modality state with `hadKeyboardEvent`.
50
47
  * If the most recent user interaction was via the keyboard;
@@ -52,15 +49,13 @@ function focusTriggersKeyboardModality(node) {
52
49
  * then the modality is keyboard. Otherwise, the modality is not keyboard.
53
50
  * @param {KeyboardEvent} event
54
51
  */
55
-
56
-
57
52
  function handleKeyDown(event) {
58
53
  if (event.metaKey || event.altKey || event.ctrlKey) {
59
54
  return;
60
55
  }
61
-
62
56
  hadKeyboardEvent = true;
63
57
  }
58
+
64
59
  /**
65
60
  * If at any point a user clicks with a pointing device, ensure that we change
66
61
  * the modality away from keyboard.
@@ -68,12 +63,9 @@ function handleKeyDown(event) {
68
63
  * element, and then clicks on a different element, focusing it with a
69
64
  * pointing device, while we still think we're in keyboard modality.
70
65
  */
71
-
72
-
73
66
  function handlePointerDown() {
74
67
  hadKeyboardEvent = false;
75
68
  }
76
-
77
69
  function handleVisibilityChange() {
78
70
  if (this.visibilityState === 'hidden') {
79
71
  // If the tab becomes active again, the browser will handle calling focus
@@ -85,7 +77,6 @@ function handleVisibilityChange() {
85
77
  }
86
78
  }
87
79
  }
88
-
89
80
  function prepare(doc) {
90
81
  doc.addEventListener('keydown', handleKeyDown, true);
91
82
  doc.addEventListener('mousedown', handlePointerDown, true);
@@ -93,7 +84,6 @@ function prepare(doc) {
93
84
  doc.addEventListener('touchstart', handlePointerDown, true);
94
85
  doc.addEventListener('visibilitychange', handleVisibilityChange, true);
95
86
  }
96
-
97
87
  export function teardown(doc) {
98
88
  doc.removeEventListener('keydown', handleKeyDown, true);
99
89
  doc.removeEventListener('mousedown', handlePointerDown, true);
@@ -101,23 +91,21 @@ export function teardown(doc) {
101
91
  doc.removeEventListener('touchstart', handlePointerDown, true);
102
92
  doc.removeEventListener('visibilitychange', handleVisibilityChange, true);
103
93
  }
104
-
105
94
  function isFocusVisible(event) {
106
95
  var target = event.target;
107
-
108
96
  try {
109
97
  return target.matches(':focus-visible');
110
- } catch (error) {// Browsers not implementing :focus-visible will throw a SyntaxError.
98
+ } catch (error) {
99
+ // Browsers not implementing :focus-visible will throw a SyntaxError.
111
100
  // We use our own heuristic for those browsers.
112
101
  // Rethrow might be better if it's not the expected error but do we really
113
102
  // want to crash if focus-visible malfunctioned?
114
- } // No need for validFocusTarget check. The user does that by attaching it to
115
- // focusable events only.
116
-
103
+ }
117
104
 
105
+ // No need for validFocusTarget check. The user does that by attaching it to
106
+ // focusable events only.
118
107
  return hadKeyboardEvent || focusTriggersKeyboardModality(target);
119
108
  }
120
-
121
109
  export default function useIsFocusVisible() {
122
110
  var ref = React.useCallback(function (node) {
123
111
  if (node != null) {
@@ -125,10 +113,10 @@ export default function useIsFocusVisible() {
125
113
  }
126
114
  }, []);
127
115
  var isFocusVisibleRef = React.useRef(false);
116
+
128
117
  /**
129
118
  * Should be called if a blur event is fired
130
119
  */
131
-
132
120
  function handleBlurVisible() {
133
121
  // checking against potential state variable does not suffice if we focus and blur synchronously.
134
122
  // React wouldn't have time to trigger a re-render so `focusVisible` would be stale.
@@ -148,23 +136,19 @@ export default function useIsFocusVisible() {
148
136
  isFocusVisibleRef.current = false;
149
137
  return true;
150
138
  }
151
-
152
139
  return false;
153
140
  }
141
+
154
142
  /**
155
143
  * Should be called if a blur event is fired
156
144
  */
157
-
158
-
159
145
  function handleFocusVisible(event) {
160
146
  if (isFocusVisible(event)) {
161
147
  isFocusVisibleRef.current = true;
162
148
  return true;
163
149
  }
164
-
165
150
  return false;
166
151
  }
167
-
168
152
  return {
169
153
  isFocusVisibleRef: isFocusVisibleRef,
170
154
  onFocus: handleFocusVisible,
@@ -1,5 +1,4 @@
1
1
  import * as React from 'react';
2
-
3
2
  var usePreviousProps = function usePreviousProps(value) {
4
3
  var ref = React.useRef({});
5
4
  React.useEffect(function () {
@@ -7,5 +6,4 @@ var usePreviousProps = function usePreviousProps(value) {
7
6
  });
8
7
  return ref.current;
9
8
  };
10
-
11
9
  export default usePreviousProps;
@@ -1,22 +1,17 @@
1
1
  const defaultGenerator = componentName => componentName;
2
-
3
2
  const createClassNameGenerator = () => {
4
3
  let generate = defaultGenerator;
5
4
  return {
6
5
  configure(generator) {
7
6
  generate = generator;
8
7
  },
9
-
10
8
  generate(componentName) {
11
9
  return generate(componentName);
12
10
  },
13
-
14
11
  reset() {
15
12
  generate = defaultGenerator;
16
13
  }
17
-
18
14
  };
19
15
  };
20
-
21
16
  const ClassNameGenerator = createClassNameGenerator();
22
17
  export default ClassNameGenerator;
@@ -2,17 +2,13 @@ export default function HTMLElementType(props, propName, componentName, location
2
2
  if (process.env.NODE_ENV === 'production') {
3
3
  return null;
4
4
  }
5
-
6
5
  const propValue = props[propName];
7
6
  const safePropName = propFullName || propName;
8
-
9
7
  if (propValue == null) {
10
8
  return null;
11
9
  }
12
-
13
10
  if (propValue && propValue.nodeType !== 1) {
14
11
  return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an HTMLElement.`);
15
12
  }
16
-
17
13
  return null;
18
14
  }
@@ -7,6 +7,5 @@ export default function capitalize(string) {
7
7
  if (typeof string !== 'string') {
8
8
  throw new Error(process.env.NODE_ENV !== "production" ? `MUI: \`capitalize(string)\` expects a string argument.` : _formatMuiErrorMessage(7));
9
9
  }
10
-
11
10
  return string.charAt(0).toUpperCase() + string.slice(1);
12
11
  }
@@ -2,7 +2,6 @@ export default function chainPropTypes(propType1, propType2) {
2
2
  if (process.env.NODE_ENV === 'production') {
3
3
  return () => null;
4
4
  }
5
-
6
5
  return function validate(...args) {
7
6
  return propType1(...args) || propType2(...args);
8
7
  };
@@ -1,17 +1,16 @@
1
1
  export default function composeClasses(slots, getUtilityClass, classes) {
2
2
  const output = {};
3
- Object.keys(slots).forEach( // `Objet.keys(slots)` can't be wider than `T` because we infer `T` from `slots`.
3
+ Object.keys(slots).forEach(
4
+ // `Objet.keys(slots)` can't be wider than `T` because we infer `T` from `slots`.
4
5
  // @ts-expect-error https://github.com/microsoft/TypeScript/pull/12253#issuecomment-263132208
5
6
  slot => {
6
7
  output[slot] = slots[slot].reduce((acc, key) => {
7
8
  if (key) {
8
9
  acc.push(getUtilityClass(key));
9
-
10
10
  if (classes && classes[key]) {
11
11
  acc.push(classes[key]);
12
12
  }
13
13
  }
14
-
15
14
  return acc;
16
15
  }, []).join(' ');
17
16
  });
@@ -9,7 +9,6 @@ export default function createChainedFunction(...funcs) {
9
9
  if (func == null) {
10
10
  return acc;
11
11
  }
12
-
13
12
  return function chainedFunction(...args) {
14
13
  acc.apply(this, args);
15
14
  func.apply(this, args);
@@ -2,19 +2,15 @@
2
2
  // A few bytes payload overhead when lodash/debounce is ~3 kB and debounce ~300 B.
3
3
  export default function debounce(func, wait = 166) {
4
4
  let timeout;
5
-
6
5
  function debounced(...args) {
7
6
  const later = () => {
8
7
  func.apply(this, args);
9
8
  };
10
-
11
9
  clearTimeout(timeout);
12
10
  timeout = setTimeout(later, wait);
13
11
  }
14
-
15
12
  debounced.clear = () => {
16
13
  clearTimeout(timeout);
17
14
  };
18
-
19
15
  return debounced;
20
16
  }
@@ -6,14 +6,12 @@ export default function deepmerge(target, source, options = {
6
6
  clone: true
7
7
  }) {
8
8
  const output = options.clone ? _extends({}, target) : target;
9
-
10
9
  if (isPlainObject(target) && isPlainObject(source)) {
11
10
  Object.keys(source).forEach(key => {
12
11
  // Avoid prototype pollution
13
12
  if (key === '__proto__') {
14
13
  return;
15
14
  }
16
-
17
15
  if (isPlainObject(source[key]) && key in target && isPlainObject(target[key])) {
18
16
  // Since `output` is a clone of `target` and we have narrowed `target` in this block we can cast to the same type.
19
17
  output[key] = deepmerge(target[key], source[key], options);
@@ -22,6 +20,5 @@ export default function deepmerge(target, source, options = {
22
20
  }
23
21
  });
24
22
  }
25
-
26
23
  return output;
27
24
  }
@@ -2,15 +2,12 @@ export default function deprecatedPropType(validator, reason) {
2
2
  if (process.env.NODE_ENV === 'production') {
3
3
  return () => null;
4
4
  }
5
-
6
5
  return (props, propName, componentName, location, propFullName) => {
7
6
  const componentNameSafe = componentName || '<<anonymous>>';
8
7
  const propFullNameSafe = propFullName || propName;
9
-
10
8
  if (typeof props[propName] !== 'undefined') {
11
9
  return new Error(`The ${location} \`${propFullNameSafe}\` of ` + `\`${componentNameSafe}\` is deprecated. ${reason}`);
12
10
  }
13
-
14
11
  return null;
15
12
  };
16
13
  }
@@ -1,6 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import chainPropTypes from './chainPropTypes';
3
-
4
3
  function isClassComponent(elementType) {
5
4
  // elementType.prototype?.isReactComponent
6
5
  const {
@@ -8,19 +7,17 @@ function isClassComponent(elementType) {
8
7
  } = elementType;
9
8
  return Boolean(prototype.isReactComponent);
10
9
  }
11
-
12
10
  function acceptingRef(props, propName, componentName, location, propFullName) {
13
11
  const element = props[propName];
14
12
  const safePropName = propFullName || propName;
15
-
16
- if (element == null || // When server-side rendering React doesn't warn either.
13
+ if (element == null ||
14
+ // When server-side rendering React doesn't warn either.
17
15
  // This is not an accurate check for SSR.
18
16
  // This is only in place for Emotion compat.
19
17
  // TODO: Revisit once https://github.com/facebook/react/issues/20047 is resolved.
20
18
  typeof window === 'undefined') {
21
19
  return null;
22
20
  }
23
-
24
21
  let warningHint;
25
22
  const elementType = element.type;
26
23
  /**
@@ -32,18 +29,14 @@ function acceptingRef(props, propName, componentName, location, propFullName) {
32
29
  * or class components. "Safe" means there's no public API.
33
30
  *
34
31
  */
35
-
36
32
  if (typeof elementType === 'function' && !isClassComponent(elementType)) {
37
33
  warningHint = 'Did you accidentally use a plain function component for an element instead?';
38
34
  }
39
-
40
35
  if (warningHint !== undefined) {
41
36
  return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an element that can hold a ref. ${warningHint} ` + 'For more information see https://mui.com/r/caveat-with-refs-guide');
42
37
  }
43
-
44
38
  return null;
45
39
  }
46
-
47
40
  const elementAcceptingRef = chainPropTypes(PropTypes.element, acceptingRef);
48
41
  elementAcceptingRef.isRequired = chainPropTypes(PropTypes.element.isRequired, acceptingRef);
49
42
  export default elementAcceptingRef;
@@ -1,6 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import chainPropTypes from './chainPropTypes';
3
-
4
3
  function isClassComponent(elementType) {
5
4
  // elementType.prototype?.isReactComponent
6
5
  const {
@@ -8,20 +7,19 @@ function isClassComponent(elementType) {
8
7
  } = elementType;
9
8
  return Boolean(prototype.isReactComponent);
10
9
  }
11
-
12
10
  function elementTypeAcceptingRef(props, propName, componentName, location, propFullName) {
13
11
  const propValue = props[propName];
14
12
  const safePropName = propFullName || propName;
15
-
16
- if (propValue == null || // When server-side rendering React doesn't warn either.
13
+ if (propValue == null ||
14
+ // When server-side rendering React doesn't warn either.
17
15
  // This is not an accurate check for SSR.
18
16
  // This is only in place for emotion compat.
19
17
  // TODO: Revisit once https://github.com/facebook/react/issues/20047 is resolved.
20
18
  typeof window === 'undefined') {
21
19
  return null;
22
20
  }
23
-
24
21
  let warningHint;
22
+
25
23
  /**
26
24
  * Blacklisting instead of whitelisting
27
25
  *
@@ -31,16 +29,12 @@ function elementTypeAcceptingRef(props, propName, componentName, location, propF
31
29
  * or class components. "Safe" means there's no public API.
32
30
  *
33
31
  */
34
-
35
32
  if (typeof propValue === 'function' && !isClassComponent(propValue)) {
36
33
  warningHint = 'Did you accidentally provide a plain function component instead?';
37
34
  }
38
-
39
35
  if (warningHint !== undefined) {
40
36
  return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an element type that can hold a ref. ${warningHint} ` + 'For more information see https://mui.com/r/caveat-with-refs-guide');
41
37
  }
42
-
43
38
  return null;
44
39
  }
45
-
46
40
  export default chainPropTypes(PropTypes.elementType, elementTypeAcceptingRef);
@@ -2,20 +2,18 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  // This module is based on https://github.com/airbnb/prop-types-exact repository.
3
3
  // However, in order to reduce the number of dependencies and to remove some extra safe checks
4
4
  // the module was forked.
5
+
5
6
  const specialProperty = 'exact-prop: \u200b';
6
7
  export default function exactProp(propTypes) {
7
8
  if (process.env.NODE_ENV === 'production') {
8
9
  return propTypes;
9
10
  }
10
-
11
11
  return _extends({}, propTypes, {
12
12
  [specialProperty]: props => {
13
13
  const unsupportedProps = Object.keys(props).filter(prop => !propTypes.hasOwnProperty(prop));
14
-
15
14
  if (unsupportedProps.length > 0) {
16
15
  return new Error(`The following props are not supported: ${unsupportedProps.map(prop => `\`${prop}\``).join(', ')}. Please remove them.`);
17
16
  }
18
-
19
17
  return null;
20
18
  }
21
19
  });
@@ -7,16 +7,13 @@ export default function formatMuiErrorMessage(code) {
7
7
  // Apply babel-plugin-transform-template-literals in loose mode
8
8
  // loose mode is safe iff we're concatenating primitives
9
9
  // see https://babeljs.io/docs/en/babel-plugin-transform-template-literals#loose
10
-
11
10
  /* eslint-disable prefer-template */
12
11
  let url = 'https://mui.com/production-error/?code=' + code;
13
-
14
12
  for (let i = 1; i < arguments.length; i += 1) {
15
13
  // rest params over-transpile for this case
16
14
  // eslint-disable-next-line prefer-rest-params
17
15
  url += '&args[]=' + encodeURIComponent(arguments[i]);
18
16
  }
19
-
20
17
  return 'Minified MUI error #' + code + '; visit ' + url + ' for the full message.';
21
18
  /* eslint-enable prefer-template */
22
19
  }
@@ -1,54 +1,47 @@
1
- import { ForwardRef, Memo } from 'react-is'; // Simplified polyfill for IE11 support
2
- // https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3
1
+ import { ForwardRef, Memo } from 'react-is';
3
2
 
3
+ // Simplified polyfill for IE11 support
4
+ // https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3
4
5
  const fnNameMatchRegex = /^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/;
5
6
  export function getFunctionName(fn) {
6
7
  const match = `${fn}`.match(fnNameMatchRegex);
7
8
  const name = match && match[1];
8
9
  return name || '';
9
10
  }
10
-
11
11
  function getFunctionComponentName(Component, fallback = '') {
12
12
  return Component.displayName || Component.name || getFunctionName(Component) || fallback;
13
13
  }
14
-
15
14
  function getWrappedName(outerType, innerType, wrapperName) {
16
15
  const functionName = getFunctionComponentName(innerType);
17
16
  return outerType.displayName || (functionName !== '' ? `${wrapperName}(${functionName})` : wrapperName);
18
17
  }
18
+
19
19
  /**
20
20
  * cherry-pick from
21
21
  * https://github.com/facebook/react/blob/769b1f270e1251d9dbdce0fcbd9e92e502d059b8/packages/shared/getComponentName.js
22
22
  * originally forked from recompose/getDisplayName with added IE11 support
23
23
  */
24
-
25
-
26
24
  export default function getDisplayName(Component) {
27
25
  if (Component == null) {
28
26
  return undefined;
29
27
  }
30
-
31
28
  if (typeof Component === 'string') {
32
29
  return Component;
33
30
  }
34
-
35
31
  if (typeof Component === 'function') {
36
32
  return getFunctionComponentName(Component, 'Component');
37
- } // TypeScript can't have components as objects but they exist in the form of `memo` or `Suspense`
38
-
33
+ }
39
34
 
35
+ // TypeScript can't have components as objects but they exist in the form of `memo` or `Suspense`
40
36
  if (typeof Component === 'object') {
41
37
  switch (Component.$$typeof) {
42
38
  case ForwardRef:
43
39
  return getWrappedName(Component, Component.render, 'ForwardRef');
44
-
45
40
  case Memo:
46
41
  return getWrappedName(Component, Component.type, 'memo');
47
-
48
42
  default:
49
43
  return undefined;
50
44
  }
51
45
  }
52
-
53
46
  return undefined;
54
47
  }
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.10.9
1
+ /** @license MUI v5.10.14
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -1,66 +1,51 @@
1
1
  export function getTypeByValue(value) {
2
2
  const valueType = typeof value;
3
-
4
3
  switch (valueType) {
5
4
  case 'number':
6
5
  if (Number.isNaN(value)) {
7
6
  return 'NaN';
8
7
  }
9
-
10
8
  if (!Number.isFinite(value)) {
11
9
  return 'Infinity';
12
10
  }
13
-
14
11
  if (value !== Math.floor(value)) {
15
12
  return 'float';
16
13
  }
17
-
18
14
  return 'number';
19
-
20
15
  case 'object':
21
16
  if (value === null) {
22
17
  return 'null';
23
18
  }
24
-
25
19
  return value.constructor.name;
26
-
27
20
  default:
28
21
  return valueType;
29
22
  }
30
- } // IE 11 support
23
+ }
31
24
 
25
+ // IE 11 support
32
26
  function ponyfillIsInteger(x) {
33
27
  // eslint-disable-next-line no-restricted-globals
34
28
  return typeof x === 'number' && isFinite(x) && Math.floor(x) === x;
35
29
  }
36
-
37
30
  const isInteger = Number.isInteger || ponyfillIsInteger;
38
-
39
31
  function requiredInteger(props, propName, componentName, location) {
40
32
  const propValue = props[propName];
41
-
42
33
  if (propValue == null || !isInteger(propValue)) {
43
34
  const propType = getTypeByValue(propValue);
44
35
  return new RangeError(`Invalid ${location} \`${propName}\` of type \`${propType}\` supplied to \`${componentName}\`, expected \`integer\`.`);
45
36
  }
46
-
47
37
  return null;
48
38
  }
49
-
50
39
  function validator(props, propName, ...other) {
51
40
  const propValue = props[propName];
52
-
53
41
  if (propValue === undefined) {
54
42
  return null;
55
43
  }
56
-
57
44
  return requiredInteger(props, propName, ...other);
58
45
  }
59
-
60
46
  function validatorNoop() {
61
47
  return null;
62
48
  }
63
-
64
49
  validator.isRequired = requiredInteger;
65
50
  validatorNoop.isRequired = validatorNoop;
66
51
  export default process.env.NODE_ENV === 'production' ? validatorNoop : validator;
@@ -2,29 +2,23 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  export default function requirePropFactory(componentNameInError, Component) {
3
3
  if (process.env.NODE_ENV === 'production') {
4
4
  return () => null;
5
- } // eslint-disable-next-line react/forbid-foreign-prop-types
6
-
5
+ }
7
6
 
7
+ // eslint-disable-next-line react/forbid-foreign-prop-types
8
8
  const prevPropTypes = Component ? _extends({}, Component.propTypes) : null;
9
-
10
9
  const requireProp = requiredProp => (props, propName, componentName, location, propFullName, ...args) => {
11
10
  const propFullNameSafe = propFullName || propName;
12
11
  const defaultTypeChecker = prevPropTypes?.[propFullNameSafe];
13
-
14
12
  if (defaultTypeChecker) {
15
13
  const typeCheckerResult = defaultTypeChecker(props, propName, componentName, location, propFullName, ...args);
16
-
17
14
  if (typeCheckerResult) {
18
15
  return typeCheckerResult;
19
16
  }
20
17
  }
21
-
22
18
  if (typeof props[propName] !== 'undefined' && !props[requiredProp]) {
23
19
  return new Error(`The prop \`${propFullNameSafe}\` of ` + `\`${componentNameInError}\` can only be used together with the \`${requiredProp}\` prop.`);
24
20
  }
25
-
26
21
  return null;
27
22
  };
28
-
29
23
  return requireProp;
30
24
  }
@@ -1,5 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
-
3
2
  /**
4
3
  * Add keys, values of `defaultProps` that does not exist in `props`
5
4
  * @param {object} defaultProps
@@ -8,7 +7,6 @@ import _extends from "@babel/runtime/helpers/esm/extends";
8
7
  */
9
8
  export default function resolveProps(defaultProps, props) {
10
9
  const output = _extends({}, props);
11
-
12
10
  Object.keys(defaultProps).forEach(propName => {
13
11
  if (output[propName] === undefined) {
14
12
  output[propName] = defaultProps[propName];