@mui/utils 5.10.9 → 5.10.15
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 +636 -214
- package/ClassNameGenerator/ClassNameGenerator.js +0 -6
- package/ClassNameGenerator/index.js +0 -2
- package/HTMLElementType.js +0 -5
- package/capitalize.js +0 -4
- package/chainPropTypes.js +0 -2
- package/composeClasses/composeClasses.js +2 -4
- package/composeClasses/index.js +0 -2
- package/createChainedFunction.js +0 -2
- package/debounce.js +0 -5
- package/deepmerge.js +0 -7
- package/deprecatedPropType.js +0 -4
- package/elementAcceptingRef.js +2 -12
- 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.js +1 -7
- package/formatMuiErrorMessage.js +0 -4
- package/generateUtilityClass/generateUtilityClass.js +0 -4
- package/generateUtilityClass/index.js +0 -4
- package/generateUtilityClasses/generateUtilityClasses.js +0 -3
- package/generateUtilityClasses/index.js +0 -2
- package/getDisplayName.js +3 -14
- package/getScrollbarSize.js +0 -1
- package/index.js +1 -41
- package/integerPropType.js +2 -21
- 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.js +0 -1
- package/ownerWindow.js +0 -3
- package/package.json +2 -2
- package/ponyfillGlobal.js +0 -2
- package/refType.js +0 -4
- package/requirePropFactory.js +2 -11
- package/resolveProps.js +0 -3
- package/scrollLeft.js +5 -12
- package/setRef.js +0 -1
- package/unsupportedProp.js +0 -4
- package/useControlled.js +1 -6
- package/useEnhancedEffect.js +0 -4
- package/useEventCallback.js +2 -7
- package/useForkRef.js +2 -8
- package/useId.js +4 -11
- package/useIsFocusVisible.js +11 -30
- package/usePreviousProps.js +0 -5
|
@@ -4,27 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
const defaultGenerator = componentName => componentName;
|
|
9
|
-
|
|
10
8
|
const createClassNameGenerator = () => {
|
|
11
9
|
let generate = defaultGenerator;
|
|
12
10
|
return {
|
|
13
11
|
configure(generator) {
|
|
14
12
|
generate = generator;
|
|
15
13
|
},
|
|
16
|
-
|
|
17
14
|
generate(componentName) {
|
|
18
15
|
return generate(componentName);
|
|
19
16
|
},
|
|
20
|
-
|
|
21
17
|
reset() {
|
|
22
18
|
generate = defaultGenerator;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
};
|
|
26
21
|
};
|
|
27
|
-
|
|
28
22
|
const ClassNameGenerator = createClassNameGenerator();
|
|
29
23
|
var _default = ClassNameGenerator;
|
|
30
24
|
exports.default = _default;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -11,5 +10,4 @@ Object.defineProperty(exports, "default", {
|
|
|
11
10
|
return _ClassNameGenerator.default;
|
|
12
11
|
}
|
|
13
12
|
});
|
|
14
|
-
|
|
15
13
|
var _ClassNameGenerator = _interopRequireDefault(require("./ClassNameGenerator"));
|
package/HTMLElementType.js
CHANGED
|
@@ -4,22 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = HTMLElementType;
|
|
7
|
-
|
|
8
7
|
function HTMLElementType(props, propName, componentName, location, propFullName) {
|
|
9
8
|
if (process.env.NODE_ENV === 'production') {
|
|
10
9
|
return null;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
const propValue = props[propName];
|
|
14
12
|
const safePropName = propFullName || propName;
|
|
15
|
-
|
|
16
13
|
if (propValue == null) {
|
|
17
14
|
return null;
|
|
18
15
|
}
|
|
19
|
-
|
|
20
16
|
if (propValue && propValue.nodeType !== 1) {
|
|
21
17
|
return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an HTMLElement.`);
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
return null;
|
|
25
20
|
}
|
package/capitalize.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = capitalize;
|
|
9
|
-
|
|
10
8
|
var _formatMuiErrorMessage2 = _interopRequireDefault(require("./formatMuiErrorMessage"));
|
|
11
|
-
|
|
12
9
|
// It should to be noted that this function isn't equivalent to `text-transform: capitalize`.
|
|
13
10
|
//
|
|
14
11
|
// A strict capitalization should uppercase the first letter of each word in the sentence.
|
|
@@ -17,6 +14,5 @@ function capitalize(string) {
|
|
|
17
14
|
if (typeof string !== 'string') {
|
|
18
15
|
throw new Error(process.env.NODE_ENV !== "production" ? `MUI: \`capitalize(string)\` expects a string argument.` : (0, _formatMuiErrorMessage2.default)(7));
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
22
18
|
}
|
package/chainPropTypes.js
CHANGED
|
@@ -4,12 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = chainPropTypes;
|
|
7
|
-
|
|
8
7
|
function chainPropTypes(propType1, propType2) {
|
|
9
8
|
if (process.env.NODE_ENV === 'production') {
|
|
10
9
|
return () => null;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
return function validate(...args) {
|
|
14
12
|
return propType1(...args) || propType2(...args);
|
|
15
13
|
};
|
|
@@ -4,21 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = composeClasses;
|
|
7
|
-
|
|
8
7
|
function composeClasses(slots, getUtilityClass, classes) {
|
|
9
8
|
const output = {};
|
|
10
|
-
Object.keys(slots).forEach(
|
|
9
|
+
Object.keys(slots).forEach(
|
|
10
|
+
// `Objet.keys(slots)` can't be wider than `T` because we infer `T` from `slots`.
|
|
11
11
|
// @ts-expect-error https://github.com/microsoft/TypeScript/pull/12253#issuecomment-263132208
|
|
12
12
|
slot => {
|
|
13
13
|
output[slot] = slots[slot].reduce((acc, key) => {
|
|
14
14
|
if (key) {
|
|
15
15
|
acc.push(getUtilityClass(key));
|
|
16
|
-
|
|
17
16
|
if (classes && classes[key]) {
|
|
18
17
|
acc.push(classes[key]);
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
return acc;
|
|
23
21
|
}, []).join(' ');
|
|
24
22
|
});
|
package/composeClasses/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -11,5 +10,4 @@ Object.defineProperty(exports, "default", {
|
|
|
11
10
|
return _composeClasses.default;
|
|
12
11
|
}
|
|
13
12
|
});
|
|
14
|
-
|
|
15
13
|
var _composeClasses = _interopRequireDefault(require("./composeClasses"));
|
package/createChainedFunction.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = createChainedFunction;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Safe chained function.
|
|
10
9
|
*
|
|
@@ -16,7 +15,6 @@ function createChainedFunction(...funcs) {
|
|
|
16
15
|
if (func == null) {
|
|
17
16
|
return acc;
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
return function chainedFunction(...args) {
|
|
21
19
|
acc.apply(this, args);
|
|
22
20
|
func.apply(this, args);
|
package/debounce.js
CHANGED
|
@@ -4,24 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = debounce;
|
|
7
|
-
|
|
8
7
|
// Corresponds to 10 frames at 60 Hz.
|
|
9
8
|
// A few bytes payload overhead when lodash/debounce is ~3 kB and debounce ~300 B.
|
|
10
9
|
function debounce(func, wait = 166) {
|
|
11
10
|
let timeout;
|
|
12
|
-
|
|
13
11
|
function debounced(...args) {
|
|
14
12
|
const later = () => {
|
|
15
13
|
func.apply(this, args);
|
|
16
14
|
};
|
|
17
|
-
|
|
18
15
|
clearTimeout(timeout);
|
|
19
16
|
timeout = setTimeout(later, wait);
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
debounced.clear = () => {
|
|
23
19
|
clearTimeout(timeout);
|
|
24
20
|
};
|
|
25
|
-
|
|
26
21
|
return debounced;
|
|
27
22
|
}
|
package/deepmerge.js
CHANGED
|
@@ -1,31 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = deepmerge;
|
|
9
8
|
exports.isPlainObject = isPlainObject;
|
|
10
|
-
|
|
11
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
-
|
|
13
10
|
function isPlainObject(item) {
|
|
14
11
|
return item !== null && typeof item === 'object' && item.constructor === Object;
|
|
15
12
|
}
|
|
16
|
-
|
|
17
13
|
function deepmerge(target, source, options = {
|
|
18
14
|
clone: true
|
|
19
15
|
}) {
|
|
20
16
|
const output = options.clone ? (0, _extends2.default)({}, target) : target;
|
|
21
|
-
|
|
22
17
|
if (isPlainObject(target) && isPlainObject(source)) {
|
|
23
18
|
Object.keys(source).forEach(key => {
|
|
24
19
|
// Avoid prototype pollution
|
|
25
20
|
if (key === '__proto__') {
|
|
26
21
|
return;
|
|
27
22
|
}
|
|
28
|
-
|
|
29
23
|
if (isPlainObject(source[key]) && key in target && isPlainObject(target[key])) {
|
|
30
24
|
// Since `output` is a clone of `target` and we have narrowed `target` in this block we can cast to the same type.
|
|
31
25
|
output[key] = deepmerge(target[key], source[key], options);
|
|
@@ -34,6 +28,5 @@ function deepmerge(target, source, options = {
|
|
|
34
28
|
}
|
|
35
29
|
});
|
|
36
30
|
}
|
|
37
|
-
|
|
38
31
|
return output;
|
|
39
32
|
}
|
package/deprecatedPropType.js
CHANGED
|
@@ -4,20 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = deprecatedPropType;
|
|
7
|
-
|
|
8
7
|
function deprecatedPropType(validator, reason) {
|
|
9
8
|
if (process.env.NODE_ENV === 'production') {
|
|
10
9
|
return () => null;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
return (props, propName, componentName, location, propFullName) => {
|
|
14
12
|
const componentNameSafe = componentName || '<<anonymous>>';
|
|
15
13
|
const propFullNameSafe = propFullName || propName;
|
|
16
|
-
|
|
17
14
|
if (typeof props[propName] !== 'undefined') {
|
|
18
15
|
return new Error(`The ${location} \`${propFullNameSafe}\` of ` + `\`${componentNameSafe}\` is deprecated. ${reason}`);
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
return null;
|
|
22
18
|
};
|
|
23
19
|
}
|
package/elementAcceptingRef.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _chainPropTypes = _interopRequireDefault(require("./chainPropTypes"));
|
|
13
|
-
|
|
14
10
|
function isClassComponent(elementType) {
|
|
15
11
|
// elementType.prototype?.isReactComponent
|
|
16
12
|
const {
|
|
@@ -18,19 +14,17 @@ function isClassComponent(elementType) {
|
|
|
18
14
|
} = elementType;
|
|
19
15
|
return Boolean(prototype.isReactComponent);
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
function acceptingRef(props, propName, componentName, location, propFullName) {
|
|
23
18
|
const element = props[propName];
|
|
24
19
|
const safePropName = propFullName || propName;
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
if (element == null ||
|
|
21
|
+
// When server-side rendering React doesn't warn either.
|
|
27
22
|
// This is not an accurate check for SSR.
|
|
28
23
|
// This is only in place for Emotion compat.
|
|
29
24
|
// TODO: Revisit once https://github.com/facebook/react/issues/20047 is resolved.
|
|
30
25
|
typeof window === 'undefined') {
|
|
31
26
|
return null;
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
let warningHint;
|
|
35
29
|
const elementType = element.type;
|
|
36
30
|
/**
|
|
@@ -42,18 +36,14 @@ function acceptingRef(props, propName, componentName, location, propFullName) {
|
|
|
42
36
|
* or class components. "Safe" means there's no public API.
|
|
43
37
|
*
|
|
44
38
|
*/
|
|
45
|
-
|
|
46
39
|
if (typeof elementType === 'function' && !isClassComponent(elementType)) {
|
|
47
40
|
warningHint = 'Did you accidentally use a plain function component for an element instead?';
|
|
48
41
|
}
|
|
49
|
-
|
|
50
42
|
if (warningHint !== undefined) {
|
|
51
43
|
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');
|
|
52
44
|
}
|
|
53
|
-
|
|
54
45
|
return null;
|
|
55
46
|
}
|
|
56
|
-
|
|
57
47
|
const elementAcceptingRef = (0, _chainPropTypes.default)(_propTypes.default.element, acceptingRef);
|
|
58
48
|
elementAcceptingRef.isRequired = (0, _chainPropTypes.default)(_propTypes.default.element.isRequired, acceptingRef);
|
|
59
49
|
var _default = elementAcceptingRef;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _chainPropTypes = _interopRequireDefault(require("./chainPropTypes"));
|
|
13
|
-
|
|
14
10
|
function isClassComponent(elementType) {
|
|
15
11
|
// elementType.prototype?.isReactComponent
|
|
16
12
|
const {
|
|
@@ -18,20 +14,19 @@ function isClassComponent(elementType) {
|
|
|
18
14
|
} = elementType;
|
|
19
15
|
return Boolean(prototype.isReactComponent);
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
function elementTypeAcceptingRef(props, propName, componentName, location, propFullName) {
|
|
23
18
|
const propValue = props[propName];
|
|
24
19
|
const safePropName = propFullName || propName;
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
if (propValue == null ||
|
|
21
|
+
// When server-side rendering React doesn't warn either.
|
|
27
22
|
// This is not an accurate check for SSR.
|
|
28
23
|
// This is only in place for emotion compat.
|
|
29
24
|
// TODO: Revisit once https://github.com/facebook/react/issues/20047 is resolved.
|
|
30
25
|
typeof window === 'undefined') {
|
|
31
26
|
return null;
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
let warningHint;
|
|
29
|
+
|
|
35
30
|
/**
|
|
36
31
|
* Blacklisting instead of whitelisting
|
|
37
32
|
*
|
|
@@ -41,18 +36,13 @@ function elementTypeAcceptingRef(props, propName, componentName, location, propF
|
|
|
41
36
|
* or class components. "Safe" means there's no public API.
|
|
42
37
|
*
|
|
43
38
|
*/
|
|
44
|
-
|
|
45
39
|
if (typeof propValue === 'function' && !isClassComponent(propValue)) {
|
|
46
40
|
warningHint = 'Did you accidentally provide a plain function component instead?';
|
|
47
41
|
}
|
|
48
|
-
|
|
49
42
|
if (warningHint !== undefined) {
|
|
50
43
|
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');
|
|
51
44
|
}
|
|
52
|
-
|
|
53
45
|
return null;
|
|
54
46
|
}
|
|
55
|
-
|
|
56
47
|
var _default = (0, _chainPropTypes.default)(_propTypes.default.elementType, elementTypeAcceptingRef);
|
|
57
|
-
|
|
58
48
|
exports.default = _default;
|
|
@@ -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;
|
package/esm/HTMLElementType.js
CHANGED
|
@@ -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
|
}
|
package/esm/capitalize.js
CHANGED
|
@@ -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
|
}
|
package/esm/chainPropTypes.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
export default function composeClasses(slots, getUtilityClass, classes) {
|
|
2
2
|
const output = {};
|
|
3
|
-
Object.keys(slots).forEach(
|
|
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
|
});
|
package/esm/debounce.js
CHANGED
|
@@ -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
|
}
|
package/esm/deepmerge.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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);
|
package/esm/exactProp.js
CHANGED
|
@@ -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
|
}
|