@mui/material 7.0.0-beta.4 → 7.0.0-rc.0
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 +24 -0
- package/InputBase/InputBase.js +2 -2
- package/Select/SelectInput.js +2 -2
- package/StepLabel/StepLabel.d.ts +19 -1
- package/StepLabel/StepLabel.js +14 -5
- package/Switch/Switch.d.ts +62 -1
- package/Switch/Switch.js +71 -9
- package/TextField/TextField.d.ts +30 -0
- package/TextField/TextField.js +22 -11
- package/esm/InputBase/InputBase.js +2 -2
- package/esm/Select/SelectInput.js +2 -2
- package/esm/StepLabel/StepLabel.d.ts +19 -1
- package/esm/StepLabel/StepLabel.js +14 -5
- package/esm/Switch/Switch.d.ts +62 -1
- package/esm/Switch/Switch.js +71 -9
- package/esm/TextField/TextField.d.ts +30 -0
- package/esm/TextField/TextField.js +22 -11
- package/esm/index.js +1 -1
- package/esm/styles/createPalette.js +3 -3
- package/esm/styles/createThemeNoVars.js +2 -2
- package/esm/styles/createThemeWithVars.js +2 -2
- package/esm/styles/index.js +2 -2
- package/esm/styles/makeStyles.js +2 -2
- package/esm/styles/responsiveFontSizes.js +2 -2
- package/esm/styles/withStyles.js +2 -2
- package/esm/styles/withTheme.js +2 -2
- package/esm/utils/mergeSlotProps.js +25 -0
- package/esm/version/index.js +2 -2
- package/index.js +1 -1
- package/modern/InputBase/InputBase.js +2 -2
- package/modern/Select/SelectInput.js +2 -2
- package/modern/StepLabel/StepLabel.d.ts +19 -1
- package/modern/StepLabel/StepLabel.js +14 -5
- package/modern/Switch/Switch.d.ts +62 -1
- package/modern/Switch/Switch.js +71 -9
- package/modern/TextField/TextField.d.ts +30 -0
- package/modern/TextField/TextField.js +22 -11
- package/modern/index.js +1 -1
- package/modern/styles/createPalette.js +3 -3
- package/modern/styles/createThemeNoVars.js +2 -2
- package/modern/styles/createThemeWithVars.js +2 -2
- package/modern/styles/index.js +2 -2
- package/modern/styles/makeStyles.js +2 -2
- package/modern/styles/responsiveFontSizes.js +2 -2
- package/modern/styles/withStyles.js +2 -2
- package/modern/styles/withTheme.js +2 -2
- package/modern/utils/mergeSlotProps.js +25 -0
- package/modern/version/index.js +2 -2
- package/package.json +7 -7
- package/styles/createPalette.js +3 -3
- package/styles/createThemeNoVars.js +2 -2
- package/styles/createThemeWithVars.js +2 -2
- package/styles/index.js +2 -2
- package/styles/makeStyles.js +2 -2
- package/styles/responsiveFontSizes.js +2 -2
- package/styles/withStyles.js +2 -2
- package/styles/withTheme.js +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils/mergeSlotProps.js +24 -0
- package/version/index.js +2 -2
package/utils/mergeSlotProps.js
CHANGED
|
@@ -6,10 +6,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = mergeSlotProps;
|
|
8
8
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
9
|
+
// Brought from [Base UI](https://github.com/mui/base-ui/blob/master/packages/react/src/merge-props/mergeProps.ts#L119)
|
|
10
|
+
// Use it directly from Base UI once it's a package dependency.
|
|
11
|
+
function isEventHandler(key, value) {
|
|
12
|
+
// This approach is more efficient than using a regex.
|
|
13
|
+
const thirdCharCode = key.charCodeAt(2);
|
|
14
|
+
return key[0] === 'o' && key[1] === 'n' && thirdCharCode >= 65 /* A */ && thirdCharCode <= 90 /* Z */ && typeof value === 'function';
|
|
15
|
+
}
|
|
9
16
|
function mergeSlotProps(externalSlotProps, defaultSlotProps) {
|
|
10
17
|
if (!externalSlotProps) {
|
|
11
18
|
return defaultSlotProps;
|
|
12
19
|
}
|
|
20
|
+
function extractHandlers(externalSlotPropsValue, defaultSlotPropsValue) {
|
|
21
|
+
const handlers = {};
|
|
22
|
+
Object.keys(defaultSlotPropsValue).forEach(key => {
|
|
23
|
+
if (isEventHandler(key, defaultSlotPropsValue[key]) && typeof externalSlotPropsValue[key] === 'function') {
|
|
24
|
+
// only compose the handlers if both default and external slot props match the event handler
|
|
25
|
+
handlers[key] = (...args) => {
|
|
26
|
+
externalSlotPropsValue[key](...args);
|
|
27
|
+
defaultSlotPropsValue[key](...args);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return handlers;
|
|
32
|
+
}
|
|
13
33
|
if (typeof externalSlotProps === 'function' || typeof defaultSlotProps === 'function') {
|
|
14
34
|
return ownerState => {
|
|
15
35
|
const defaultSlotPropsValue = typeof defaultSlotProps === 'function' ? defaultSlotProps(ownerState) : defaultSlotProps;
|
|
@@ -18,9 +38,11 @@ function mergeSlotProps(externalSlotProps, defaultSlotProps) {
|
|
|
18
38
|
...defaultSlotPropsValue
|
|
19
39
|
}) : externalSlotProps;
|
|
20
40
|
const className = (0, _clsx.default)(ownerState?.className, defaultSlotPropsValue?.className, externalSlotPropsValue?.className);
|
|
41
|
+
const handlers = extractHandlers(externalSlotPropsValue, defaultSlotPropsValue);
|
|
21
42
|
return {
|
|
22
43
|
...defaultSlotPropsValue,
|
|
23
44
|
...externalSlotPropsValue,
|
|
45
|
+
...handlers,
|
|
24
46
|
...(!!className && {
|
|
25
47
|
className
|
|
26
48
|
}),
|
|
@@ -37,10 +59,12 @@ function mergeSlotProps(externalSlotProps, defaultSlotProps) {
|
|
|
37
59
|
};
|
|
38
60
|
}
|
|
39
61
|
const typedDefaultSlotProps = defaultSlotProps;
|
|
62
|
+
const handlers = extractHandlers(externalSlotProps, typedDefaultSlotProps);
|
|
40
63
|
const className = (0, _clsx.default)(typedDefaultSlotProps?.className, externalSlotProps?.className);
|
|
41
64
|
return {
|
|
42
65
|
...defaultSlotProps,
|
|
43
66
|
...externalSlotProps,
|
|
67
|
+
...handlers,
|
|
44
68
|
...(!!className && {
|
|
45
69
|
className
|
|
46
70
|
}),
|
package/version/index.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.version = exports.prerelease = exports.patch = exports.minor = exports.major = exports.default = void 0;
|
|
7
|
-
const version = exports.version = "7.0.0-
|
|
7
|
+
const version = exports.version = "7.0.0-rc.0";
|
|
8
8
|
const major = exports.major = Number("7");
|
|
9
9
|
const minor = exports.minor = Number("0");
|
|
10
10
|
const patch = exports.patch = Number("0");
|
|
11
|
-
const prerelease = exports.prerelease = "
|
|
11
|
+
const prerelease = exports.prerelease = "rc.0";
|
|
12
12
|
var _default = exports.default = version;
|