@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.
- package/CHANGELOG.md +574 -214
- package/ClassNameGenerator/ClassNameGenerator.d.ts +6 -6
- package/ClassNameGenerator/ClassNameGenerator.js +0 -6
- package/ClassNameGenerator/index.d.ts +1 -1
- package/ClassNameGenerator/index.js +0 -2
- package/HTMLElementType.d.ts +3 -3
- package/HTMLElementType.js +0 -5
- package/capitalize.js +0 -4
- package/chainPropTypes.d.ts +2 -2
- package/chainPropTypes.js +0 -2
- package/composeClasses/composeClasses.d.ts +1 -1
- package/composeClasses/composeClasses.js +2 -4
- package/composeClasses/index.d.ts +1 -1
- package/composeClasses/index.js +0 -2
- package/createChainedFunction.d.ts +7 -7
- package/createChainedFunction.js +0 -2
- package/debounce.js +0 -5
- package/deepmerge.d.ts +5 -5
- package/deepmerge.js +0 -7
- package/deprecatedPropType.js +0 -4
- package/elementAcceptingRef.d.ts +3 -3
- package/elementAcceptingRef.js +2 -12
- package/elementTypeAcceptingRef.d.ts +3 -3
- package/elementTypeAcceptingRef.js +3 -13
- package/esm/ClassNameGenerator/ClassNameGenerator.js +0 -5
- package/esm/HTMLElementType.js +0 -4
- package/esm/capitalize.js +0 -1
- package/esm/chainPropTypes.js +0 -1
- package/esm/composeClasses/composeClasses.js +2 -3
- package/esm/createChainedFunction.js +0 -1
- package/esm/debounce.js +0 -4
- package/esm/deepmerge.js +0 -3
- package/esm/deprecatedPropType.js +0 -3
- package/esm/elementAcceptingRef.js +2 -9
- package/esm/elementTypeAcceptingRef.js +3 -9
- package/esm/exactProp.js +1 -3
- package/esm/formatMuiErrorMessage.js +0 -3
- package/esm/getDisplayName.js +6 -13
- package/esm/integerPropType.js +2 -17
- package/esm/requirePropFactory.js +2 -8
- package/esm/resolveProps.js +0 -2
- package/esm/scrollLeft.js +5 -11
- package/esm/unsupportedProp.js +0 -3
- package/esm/useControlled.js +0 -2
- package/esm/useEventCallback.js +3 -2
- package/esm/useForkRef.js +2 -2
- package/esm/useId.js +4 -7
- package/esm/useIsFocusVisible.js +10 -26
- package/esm/usePreviousProps.js +0 -2
- package/exactProp.d.ts +2 -2
- package/exactProp.js +1 -7
- package/formatMuiErrorMessage.d.ts +6 -6
- package/formatMuiErrorMessage.js +0 -4
- package/generateUtilityClass/generateUtilityClass.d.ts +2 -2
- package/generateUtilityClass/generateUtilityClass.js +0 -4
- package/generateUtilityClass/index.d.ts +2 -2
- package/generateUtilityClass/index.js +0 -4
- package/generateUtilityClasses/generateUtilityClasses.d.ts +1 -1
- package/generateUtilityClasses/generateUtilityClasses.js +0 -3
- package/generateUtilityClasses/index.d.ts +1 -1
- package/generateUtilityClasses/index.js +0 -2
- package/getDisplayName.d.ts +8 -8
- package/getDisplayName.js +3 -14
- package/getScrollbarSize.d.ts +1 -1
- package/getScrollbarSize.js +0 -1
- package/index.d.ts +38 -38
- package/index.js +1 -41
- package/integerPropType.d.ts +7 -7
- package/integerPropType.js +2 -21
- package/isMuiElement.d.ts +1 -1
- package/isMuiElement.js +0 -4
- package/legacy/ClassNameGenerator/ClassNameGenerator.js +0 -2
- package/legacy/HTMLElementType.js +0 -4
- package/legacy/capitalize.js +0 -1
- package/legacy/chainPropTypes.js +0 -1
- package/legacy/composeClasses/composeClasses.js +2 -3
- package/legacy/createChainedFunction.js +0 -3
- package/legacy/debounce.js +0 -6
- package/legacy/deepmerge.js +0 -3
- package/legacy/deprecatedPropType.js +0 -3
- package/legacy/elementAcceptingRef.js +3 -10
- package/legacy/elementTypeAcceptingRef.js +4 -10
- package/legacy/exactProp.js +1 -3
- package/legacy/formatMuiErrorMessage.js +0 -3
- package/legacy/getDisplayName.js +6 -13
- package/legacy/index.js +1 -1
- package/legacy/integerPropType.js +2 -18
- package/legacy/requirePropFactory.js +2 -9
- package/legacy/resolveProps.js +0 -2
- package/legacy/scrollLeft.js +5 -11
- package/legacy/unsupportedProp.js +0 -3
- package/legacy/useControlled.js +8 -15
- package/legacy/useEventCallback.js +3 -2
- package/legacy/useForkRef.js +2 -3
- package/legacy/useId.js +6 -10
- package/legacy/useIsFocusVisible.js +12 -28
- package/legacy/usePreviousProps.js +0 -2
- package/modern/ClassNameGenerator/ClassNameGenerator.js +0 -5
- package/modern/HTMLElementType.js +0 -4
- package/modern/capitalize.js +0 -1
- package/modern/chainPropTypes.js +0 -1
- package/modern/composeClasses/composeClasses.js +2 -3
- package/modern/createChainedFunction.js +0 -1
- package/modern/debounce.js +0 -4
- package/modern/deepmerge.js +0 -3
- package/modern/deprecatedPropType.js +0 -3
- package/modern/elementAcceptingRef.js +2 -9
- package/modern/elementTypeAcceptingRef.js +3 -9
- package/modern/exactProp.js +1 -3
- package/modern/formatMuiErrorMessage.js +0 -3
- package/modern/getDisplayName.js +6 -13
- package/modern/index.js +1 -1
- package/modern/integerPropType.js +2 -17
- package/modern/requirePropFactory.js +2 -8
- package/modern/resolveProps.js +0 -2
- package/modern/scrollLeft.js +5 -11
- package/modern/unsupportedProp.js +0 -3
- package/modern/useControlled.js +0 -2
- package/modern/useEventCallback.js +3 -2
- package/modern/useForkRef.js +2 -2
- package/modern/useId.js +4 -7
- package/modern/useIsFocusVisible.js +10 -26
- package/modern/usePreviousProps.js +0 -2
- package/ownerDocument.d.ts +1 -1
- package/ownerDocument.js +0 -1
- package/ownerWindow.d.ts +1 -1
- package/ownerWindow.js +0 -3
- package/package.json +2 -2
- package/ponyfillGlobal.d.ts +2 -2
- package/ponyfillGlobal.js +0 -2
- package/refType.d.ts +3 -3
- package/refType.js +0 -4
- package/requirePropFactory.js +2 -11
- package/resolveProps.d.ts +9 -9
- package/resolveProps.js +0 -3
- package/scrollLeft.js +5 -12
- package/setRef.d.ts +15 -15
- package/setRef.js +0 -1
- package/unsupportedProp.js +0 -4
- package/useControlled.js +1 -6
- package/useEnhancedEffect.js +0 -4
- package/useEventCallback.d.ts +4 -4
- package/useEventCallback.js +2 -7
- package/useEventCallback.spec.d.ts +1 -1
- package/useForkRef.d.ts +2 -2
- package/useForkRef.js +2 -8
- package/useId.d.ts +7 -7
- package/useId.js +4 -11
- package/useIsFocusVisible.d.ts +9 -9
- package/useIsFocusVisible.js +11 -30
- package/usePreviousProps.d.ts +2 -2
- package/usePreviousProps.js +0 -5
- package/visuallyHidden.d.ts +2 -2
|
@@ -1,25 +1,22 @@
|
|
|
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
|
var _elementType$prototyp = elementType.prototype,
|
|
7
|
-
|
|
6
|
+
prototype = _elementType$prototyp === void 0 ? {} : _elementType$prototyp;
|
|
8
7
|
return Boolean(prototype.isReactComponent);
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
function acceptingRef(props, propName, componentName, location, propFullName) {
|
|
12
10
|
var element = props[propName];
|
|
13
11
|
var safePropName = propFullName || propName;
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
if (element == null ||
|
|
13
|
+
// When server-side rendering React doesn't warn either.
|
|
16
14
|
// This is not an accurate check for SSR.
|
|
17
15
|
// This is only in place for Emotion compat.
|
|
18
16
|
// TODO: Revisit once https://github.com/facebook/react/issues/20047 is resolved.
|
|
19
17
|
typeof window === 'undefined') {
|
|
20
18
|
return null;
|
|
21
19
|
}
|
|
22
|
-
|
|
23
20
|
var warningHint;
|
|
24
21
|
var elementType = element.type;
|
|
25
22
|
/**
|
|
@@ -31,18 +28,14 @@ function acceptingRef(props, propName, componentName, location, propFullName) {
|
|
|
31
28
|
* or class components. "Safe" means there's no public API.
|
|
32
29
|
*
|
|
33
30
|
*/
|
|
34
|
-
|
|
35
31
|
if (typeof elementType === 'function' && !isClassComponent(elementType)) {
|
|
36
32
|
warningHint = 'Did you accidentally use a plain function component for an element instead?';
|
|
37
33
|
}
|
|
38
|
-
|
|
39
34
|
if (warningHint !== undefined) {
|
|
40
35
|
return new Error("Invalid ".concat(location, " `").concat(safePropName, "` supplied to `").concat(componentName, "`. ") + "Expected an element that can hold a ref. ".concat(warningHint, " ") + 'For more information see https://mui.com/r/caveat-with-refs-guide');
|
|
41
36
|
}
|
|
42
|
-
|
|
43
37
|
return null;
|
|
44
38
|
}
|
|
45
|
-
|
|
46
39
|
var elementAcceptingRef = chainPropTypes(PropTypes.element, acceptingRef);
|
|
47
40
|
elementAcceptingRef.isRequired = chainPropTypes(PropTypes.element.isRequired, acceptingRef);
|
|
48
41
|
export default elementAcceptingRef;
|
|
@@ -1,26 +1,24 @@
|
|
|
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
|
var _elementType$prototyp = elementType.prototype,
|
|
7
|
-
|
|
6
|
+
prototype = _elementType$prototyp === void 0 ? {} : _elementType$prototyp;
|
|
8
7
|
return Boolean(prototype.isReactComponent);
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
function elementTypeAcceptingRef(props, propName, componentName, location, propFullName) {
|
|
12
10
|
var propValue = props[propName];
|
|
13
11
|
var safePropName = propFullName || propName;
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
if (propValue == null ||
|
|
13
|
+
// When server-side rendering React doesn't warn either.
|
|
16
14
|
// This is not an accurate check for SSR.
|
|
17
15
|
// This is only in place for emotion compat.
|
|
18
16
|
// TODO: Revisit once https://github.com/facebook/react/issues/20047 is resolved.
|
|
19
17
|
typeof window === 'undefined') {
|
|
20
18
|
return null;
|
|
21
19
|
}
|
|
22
|
-
|
|
23
20
|
var warningHint;
|
|
21
|
+
|
|
24
22
|
/**
|
|
25
23
|
* Blacklisting instead of whitelisting
|
|
26
24
|
*
|
|
@@ -30,16 +28,12 @@ function elementTypeAcceptingRef(props, propName, componentName, location, propF
|
|
|
30
28
|
* or class components. "Safe" means there's no public API.
|
|
31
29
|
*
|
|
32
30
|
*/
|
|
33
|
-
|
|
34
31
|
if (typeof propValue === 'function' && !isClassComponent(propValue)) {
|
|
35
32
|
warningHint = 'Did you accidentally provide a plain function component instead?';
|
|
36
33
|
}
|
|
37
|
-
|
|
38
34
|
if (warningHint !== undefined) {
|
|
39
35
|
return new Error("Invalid ".concat(location, " `").concat(safePropName, "` supplied to `").concat(componentName, "`. ") + "Expected an element type that can hold a ref. ".concat(warningHint, " ") + 'For more information see https://mui.com/r/caveat-with-refs-guide');
|
|
40
36
|
}
|
|
41
|
-
|
|
42
37
|
return null;
|
|
43
38
|
}
|
|
44
|
-
|
|
45
39
|
export default chainPropTypes(PropTypes.elementType, elementTypeAcceptingRef);
|
package/legacy/exactProp.js
CHANGED
|
@@ -3,23 +3,21 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
// This module is based on https://github.com/airbnb/prop-types-exact repository.
|
|
4
4
|
// However, in order to reduce the number of dependencies and to remove some extra safe checks
|
|
5
5
|
// the module was forked.
|
|
6
|
+
|
|
6
7
|
var specialProperty = "exact-prop: \u200B";
|
|
7
8
|
export default function exactProp(propTypes) {
|
|
8
9
|
if (process.env.NODE_ENV === 'production') {
|
|
9
10
|
return propTypes;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
12
|
return _extends({}, propTypes, _defineProperty({}, specialProperty, function (props) {
|
|
13
13
|
var unsupportedProps = Object.keys(props).filter(function (prop) {
|
|
14
14
|
return !propTypes.hasOwnProperty(prop);
|
|
15
15
|
});
|
|
16
|
-
|
|
17
16
|
if (unsupportedProps.length > 0) {
|
|
18
17
|
return new Error("The following props are not supported: ".concat(unsupportedProps.map(function (prop) {
|
|
19
18
|
return "`".concat(prop, "`");
|
|
20
19
|
}).join(', '), ". Please remove them."));
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
return null;
|
|
24
22
|
}));
|
|
25
23
|
}
|
|
@@ -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
|
var url = 'https://mui.com/production-error/?code=' + code;
|
|
13
|
-
|
|
14
12
|
for (var 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
|
}
|
package/legacy/getDisplayName.js
CHANGED
|
@@ -1,56 +1,49 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
-
import { ForwardRef, Memo } from 'react-is';
|
|
3
|
-
// https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3
|
|
2
|
+
import { ForwardRef, Memo } from 'react-is';
|
|
4
3
|
|
|
4
|
+
// Simplified polyfill for IE11 support
|
|
5
|
+
// https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3
|
|
5
6
|
var fnNameMatchRegex = /^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/;
|
|
6
7
|
export function getFunctionName(fn) {
|
|
7
8
|
var match = "".concat(fn).match(fnNameMatchRegex);
|
|
8
9
|
var name = match && match[1];
|
|
9
10
|
return name || '';
|
|
10
11
|
}
|
|
11
|
-
|
|
12
12
|
function getFunctionComponentName(Component) {
|
|
13
13
|
var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
14
14
|
return Component.displayName || Component.name || getFunctionName(Component) || fallback;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
16
|
function getWrappedName(outerType, innerType, wrapperName) {
|
|
18
17
|
var functionName = getFunctionComponentName(innerType);
|
|
19
18
|
return outerType.displayName || (functionName !== '' ? "".concat(wrapperName, "(").concat(functionName, ")") : wrapperName);
|
|
20
19
|
}
|
|
20
|
+
|
|
21
21
|
/**
|
|
22
22
|
* cherry-pick from
|
|
23
23
|
* https://github.com/facebook/react/blob/769b1f270e1251d9dbdce0fcbd9e92e502d059b8/packages/shared/getComponentName.js
|
|
24
24
|
* originally forked from recompose/getDisplayName with added IE11 support
|
|
25
25
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
26
|
export default function getDisplayName(Component) {
|
|
29
27
|
if (Component == null) {
|
|
30
28
|
return undefined;
|
|
31
29
|
}
|
|
32
|
-
|
|
33
30
|
if (typeof Component === 'string') {
|
|
34
31
|
return Component;
|
|
35
32
|
}
|
|
36
|
-
|
|
37
33
|
if (typeof Component === 'function') {
|
|
38
34
|
return getFunctionComponentName(Component, 'Component');
|
|
39
|
-
}
|
|
40
|
-
|
|
35
|
+
}
|
|
41
36
|
|
|
37
|
+
// TypeScript can't have components as objects but they exist in the form of `memo` or `Suspense`
|
|
42
38
|
if (_typeof(Component) === 'object') {
|
|
43
39
|
switch (Component.$$typeof) {
|
|
44
40
|
case ForwardRef:
|
|
45
41
|
return getWrappedName(Component, Component.render, 'ForwardRef');
|
|
46
|
-
|
|
47
42
|
case Memo:
|
|
48
43
|
return getWrappedName(Component, Component.type, 'memo');
|
|
49
|
-
|
|
50
44
|
default:
|
|
51
45
|
return undefined;
|
|
52
46
|
}
|
|
53
47
|
}
|
|
54
|
-
|
|
55
48
|
return undefined;
|
|
56
49
|
}
|
package/legacy/index.js
CHANGED
|
@@ -1,71 +1,55 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
2
|
export function getTypeByValue(value) {
|
|
3
3
|
var valueType = _typeof(value);
|
|
4
|
-
|
|
5
4
|
switch (valueType) {
|
|
6
5
|
case 'number':
|
|
7
6
|
if (Number.isNaN(value)) {
|
|
8
7
|
return 'NaN';
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
if (!Number.isFinite(value)) {
|
|
12
10
|
return 'Infinity';
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
if (value !== Math.floor(value)) {
|
|
16
13
|
return 'float';
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
return 'number';
|
|
20
|
-
|
|
21
16
|
case 'object':
|
|
22
17
|
if (value === null) {
|
|
23
18
|
return 'null';
|
|
24
19
|
}
|
|
25
|
-
|
|
26
20
|
return value.constructor.name;
|
|
27
|
-
|
|
28
21
|
default:
|
|
29
22
|
return valueType;
|
|
30
23
|
}
|
|
31
|
-
}
|
|
24
|
+
}
|
|
32
25
|
|
|
26
|
+
// IE 11 support
|
|
33
27
|
function ponyfillIsInteger(x) {
|
|
34
28
|
// eslint-disable-next-line no-restricted-globals
|
|
35
29
|
return typeof x === 'number' && isFinite(x) && Math.floor(x) === x;
|
|
36
30
|
}
|
|
37
|
-
|
|
38
31
|
var isInteger = Number.isInteger || ponyfillIsInteger;
|
|
39
|
-
|
|
40
32
|
function requiredInteger(props, propName, componentName, location) {
|
|
41
33
|
var propValue = props[propName];
|
|
42
|
-
|
|
43
34
|
if (propValue == null || !isInteger(propValue)) {
|
|
44
35
|
var propType = getTypeByValue(propValue);
|
|
45
36
|
return new RangeError("Invalid ".concat(location, " `").concat(propName, "` of type `").concat(propType, "` supplied to `").concat(componentName, "`, expected `integer`."));
|
|
46
37
|
}
|
|
47
|
-
|
|
48
38
|
return null;
|
|
49
39
|
}
|
|
50
|
-
|
|
51
40
|
function validator(props, propName) {
|
|
52
41
|
var propValue = props[propName];
|
|
53
|
-
|
|
54
42
|
if (propValue === undefined) {
|
|
55
43
|
return null;
|
|
56
44
|
}
|
|
57
|
-
|
|
58
45
|
for (var _len = arguments.length, other = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
59
46
|
other[_key - 2] = arguments[_key];
|
|
60
47
|
}
|
|
61
|
-
|
|
62
48
|
return requiredInteger.apply(void 0, [props, propName].concat(other));
|
|
63
49
|
}
|
|
64
|
-
|
|
65
50
|
function validatorNoop() {
|
|
66
51
|
return null;
|
|
67
52
|
}
|
|
68
|
-
|
|
69
53
|
validator.isRequired = requiredInteger;
|
|
70
54
|
validatorNoop.isRequired = validatorNoop;
|
|
71
55
|
export default process.env.NODE_ENV === 'production' ? validatorNoop : validator;
|
|
@@ -4,35 +4,28 @@ export default function requirePropFactory(componentNameInError, Component) {
|
|
|
4
4
|
return function () {
|
|
5
5
|
return null;
|
|
6
6
|
};
|
|
7
|
-
}
|
|
8
|
-
|
|
7
|
+
}
|
|
9
8
|
|
|
9
|
+
// eslint-disable-next-line react/forbid-foreign-prop-types
|
|
10
10
|
var prevPropTypes = Component ? _extends({}, Component.propTypes) : null;
|
|
11
|
-
|
|
12
11
|
var requireProp = function requireProp(requiredProp) {
|
|
13
12
|
return function (props, propName, componentName, location, propFullName) {
|
|
14
13
|
var propFullNameSafe = propFullName || propName;
|
|
15
14
|
var defaultTypeChecker = prevPropTypes == null ? void 0 : prevPropTypes[propFullNameSafe];
|
|
16
|
-
|
|
17
15
|
if (defaultTypeChecker) {
|
|
18
16
|
for (var _len = arguments.length, args = new Array(_len > 5 ? _len - 5 : 0), _key = 5; _key < _len; _key++) {
|
|
19
17
|
args[_key - 5] = arguments[_key];
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
var typeCheckerResult = defaultTypeChecker.apply(void 0, [props, propName, componentName, location, propFullName].concat(args));
|
|
23
|
-
|
|
24
20
|
if (typeCheckerResult) {
|
|
25
21
|
return typeCheckerResult;
|
|
26
22
|
}
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
if (typeof props[propName] !== 'undefined' && !props[requiredProp]) {
|
|
30
25
|
return new Error("The prop `".concat(propFullNameSafe, "` of ") + "`".concat(componentNameInError, "` can only be used together with the `").concat(requiredProp, "` prop."));
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
return null;
|
|
34
28
|
};
|
|
35
29
|
};
|
|
36
|
-
|
|
37
30
|
return requireProp;
|
|
38
31
|
}
|
package/legacy/resolveProps.js
CHANGED
|
@@ -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
|
var output = _extends({}, props);
|
|
11
|
-
|
|
12
10
|
Object.keys(defaultProps).forEach(function (propName) {
|
|
13
11
|
if (output[propName] === undefined) {
|
|
14
12
|
output[propName] = defaultProps[propName];
|
package/legacy/scrollLeft.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Source from https://github.com/alitaheri/normalize-scroll-left
|
|
2
2
|
var cachedType;
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* Based on the jquery plugin https://github.com/othree/jquery.rtl-scroll-type
|
|
5
6
|
*
|
|
@@ -19,12 +20,10 @@ var cachedType;
|
|
|
19
20
|
*
|
|
20
21
|
* spec* https://drafts.csswg.org/cssom-view/#dom-window-scroll
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
23
|
export function detectScrollType() {
|
|
24
24
|
if (cachedType) {
|
|
25
25
|
return cachedType;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
27
|
var dummy = document.createElement('div');
|
|
29
28
|
var container = document.createElement('div');
|
|
30
29
|
container.style.width = '10px';
|
|
@@ -39,37 +38,32 @@ export function detectScrollType() {
|
|
|
39
38
|
dummy.style.overflow = 'scroll';
|
|
40
39
|
document.body.appendChild(dummy);
|
|
41
40
|
cachedType = 'reverse';
|
|
42
|
-
|
|
43
41
|
if (dummy.scrollLeft > 0) {
|
|
44
42
|
cachedType = 'default';
|
|
45
43
|
} else {
|
|
46
44
|
dummy.scrollLeft = 1;
|
|
47
|
-
|
|
48
45
|
if (dummy.scrollLeft === 0) {
|
|
49
46
|
cachedType = 'negative';
|
|
50
47
|
}
|
|
51
48
|
}
|
|
52
|
-
|
|
53
49
|
document.body.removeChild(dummy);
|
|
54
50
|
return cachedType;
|
|
55
|
-
}
|
|
51
|
+
}
|
|
56
52
|
|
|
53
|
+
// Based on https://stackoverflow.com/a/24394376
|
|
57
54
|
export function getNormalizedScrollLeft(element, direction) {
|
|
58
|
-
var scrollLeft = element.scrollLeft;
|
|
55
|
+
var scrollLeft = element.scrollLeft;
|
|
59
56
|
|
|
57
|
+
// Perform the calculations only when direction is rtl to avoid messing up the ltr behavior
|
|
60
58
|
if (direction !== 'rtl') {
|
|
61
59
|
return scrollLeft;
|
|
62
60
|
}
|
|
63
|
-
|
|
64
61
|
var type = detectScrollType();
|
|
65
|
-
|
|
66
62
|
switch (type) {
|
|
67
63
|
case 'negative':
|
|
68
64
|
return element.scrollWidth - element.clientWidth + scrollLeft;
|
|
69
|
-
|
|
70
65
|
case 'reverse':
|
|
71
66
|
return element.scrollWidth - element.clientWidth - scrollLeft;
|
|
72
|
-
|
|
73
67
|
default:
|
|
74
68
|
return scrollLeft;
|
|
75
69
|
}
|
|
@@ -2,12 +2,9 @@ export default function unsupportedProp(props, propName, componentName, location
|
|
|
2
2
|
if (process.env.NODE_ENV === 'production') {
|
|
3
3
|
return null;
|
|
4
4
|
}
|
|
5
|
-
|
|
6
5
|
var propFullNameSafe = propFullName || propName;
|
|
7
|
-
|
|
8
6
|
if (typeof props[propName] !== 'undefined') {
|
|
9
7
|
return new Error("The prop `".concat(propFullNameSafe, "` is not supported. Please remove it."));
|
|
10
8
|
}
|
|
11
|
-
|
|
12
9
|
return null;
|
|
13
10
|
}
|
package/legacy/useControlled.js
CHANGED
|
@@ -2,38 +2,31 @@
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
export default function useControlled(_ref) {
|
|
4
4
|
var controlled = _ref.controlled,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
defaultProp = _ref.default,
|
|
6
|
+
name = _ref.name,
|
|
7
|
+
_ref$state = _ref.state,
|
|
8
|
+
state = _ref$state === void 0 ? 'value' : _ref$state;
|
|
10
9
|
// isControlled is ignored in the hook dependency lists as it should never change.
|
|
11
10
|
var _React$useRef = React.useRef(controlled !== undefined),
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
isControlled = _React$useRef.current;
|
|
14
12
|
var _React$useState = React.useState(defaultProp),
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
valueState = _React$useState[0],
|
|
14
|
+
setValue = _React$useState[1];
|
|
18
15
|
var value = isControlled ? controlled : valueState;
|
|
19
|
-
|
|
20
16
|
if (process.env.NODE_ENV !== 'production') {
|
|
21
17
|
React.useEffect(function () {
|
|
22
18
|
if (isControlled !== (controlled !== undefined)) {
|
|
23
19
|
console.error(["MUI: A component is changing the ".concat(isControlled ? '' : 'un', "controlled ").concat(state, " state of ").concat(name, " to be ").concat(isControlled ? 'un' : '', "controlled."), 'Elements should not switch from uncontrolled to controlled (or vice versa).', "Decide between using a controlled or uncontrolled ".concat(name, " ") + 'element for the lifetime of the component.', "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", 'More info: https://fb.me/react-controlled-components'].join('\n'));
|
|
24
20
|
}
|
|
25
21
|
}, [state, name, controlled]);
|
|
26
|
-
|
|
27
22
|
var _React$useRef2 = React.useRef(defaultProp),
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
defaultValue = _React$useRef2.current;
|
|
30
24
|
React.useEffect(function () {
|
|
31
25
|
if (!isControlled && defaultValue !== defaultProp) {
|
|
32
26
|
console.error(["MUI: A component is changing the default ".concat(state, " state of an uncontrolled ").concat(name, " after being initialized. ") + "To suppress this warning opt to use a controlled ".concat(name, ".")].join('\n'));
|
|
33
27
|
}
|
|
34
28
|
}, [JSON.stringify(defaultProp)]);
|
|
35
29
|
}
|
|
36
|
-
|
|
37
30
|
var setValueIfUncontrolled = React.useCallback(function (newValue) {
|
|
38
31
|
if (!isControlled) {
|
|
39
32
|
setValue(newValue);
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import useEnhancedEffect from './useEnhancedEffect';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* https://github.com/facebook/react/issues/14099#issuecomment-440013892
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
7
|
export default function useEventCallback(fn) {
|
|
8
8
|
var ref = React.useRef(fn);
|
|
9
9
|
useEnhancedEffect(function () {
|
|
10
10
|
ref.current = fn;
|
|
11
11
|
});
|
|
12
12
|
return React.useCallback(function () {
|
|
13
|
-
return (
|
|
13
|
+
return (
|
|
14
|
+
// @ts-expect-error hide `this`
|
|
14
15
|
// tslint:disable-next-line:ban-comma-operator
|
|
15
16
|
(0, ref.current).apply(void 0, arguments)
|
|
16
17
|
);
|
package/legacy/useForkRef.js
CHANGED
|
@@ -4,7 +4,6 @@ export default function useForkRef() {
|
|
|
4
4
|
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5
5
|
refs[_key] = arguments[_key];
|
|
6
6
|
}
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* This will create a new function if the refs passed to this hook change and are all defined.
|
|
10
9
|
* This means react will call the old forkRef with `null` and the new forkRef
|
|
@@ -16,11 +15,11 @@ export default function useForkRef() {
|
|
|
16
15
|
})) {
|
|
17
16
|
return null;
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
return function (instance) {
|
|
21
19
|
refs.forEach(function (ref) {
|
|
22
20
|
setRef(ref, instance);
|
|
23
21
|
});
|
|
24
|
-
};
|
|
22
|
+
};
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
24
|
}, refs);
|
|
26
25
|
}
|
package/legacy/useId.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
var globalId = 0;
|
|
3
|
-
|
|
4
3
|
function useGlobalId(idOverride) {
|
|
5
4
|
var _React$useState = React.useState(idOverride),
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
defaultId = _React$useState[0],
|
|
6
|
+
setDefaultId = _React$useState[1];
|
|
9
7
|
var id = idOverride || defaultId;
|
|
10
8
|
React.useEffect(function () {
|
|
11
9
|
if (defaultId == null) {
|
|
@@ -18,9 +16,9 @@ function useGlobalId(idOverride) {
|
|
|
18
16
|
}
|
|
19
17
|
}, [defaultId]);
|
|
20
18
|
return id;
|
|
21
|
-
}
|
|
22
|
-
|
|
19
|
+
}
|
|
23
20
|
|
|
21
|
+
// eslint-disable-next-line no-useless-concat -- Workaround for https://github.com/webpack/webpack/issues/14814
|
|
24
22
|
var maybeReactUseId = React['useId' + ''];
|
|
25
23
|
/**
|
|
26
24
|
*
|
|
@@ -28,13 +26,11 @@ var maybeReactUseId = React['useId' + ''];
|
|
|
28
26
|
* @param idOverride
|
|
29
27
|
* @returns {string}
|
|
30
28
|
*/
|
|
31
|
-
|
|
32
29
|
export default function useId(idOverride) {
|
|
33
30
|
if (maybeReactUseId !== undefined) {
|
|
34
31
|
var reactId = maybeReactUseId();
|
|
35
32
|
return idOverride != null ? idOverride : reactId;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
}
|
|
34
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
|
|
39
35
|
return useGlobalId(idOverride);
|
|
40
36
|
}
|