@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.
Files changed (60) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/InputBase/InputBase.js +2 -2
  3. package/Select/SelectInput.js +2 -2
  4. package/StepLabel/StepLabel.d.ts +19 -1
  5. package/StepLabel/StepLabel.js +14 -5
  6. package/Switch/Switch.d.ts +62 -1
  7. package/Switch/Switch.js +71 -9
  8. package/TextField/TextField.d.ts +30 -0
  9. package/TextField/TextField.js +22 -11
  10. package/esm/InputBase/InputBase.js +2 -2
  11. package/esm/Select/SelectInput.js +2 -2
  12. package/esm/StepLabel/StepLabel.d.ts +19 -1
  13. package/esm/StepLabel/StepLabel.js +14 -5
  14. package/esm/Switch/Switch.d.ts +62 -1
  15. package/esm/Switch/Switch.js +71 -9
  16. package/esm/TextField/TextField.d.ts +30 -0
  17. package/esm/TextField/TextField.js +22 -11
  18. package/esm/index.js +1 -1
  19. package/esm/styles/createPalette.js +3 -3
  20. package/esm/styles/createThemeNoVars.js +2 -2
  21. package/esm/styles/createThemeWithVars.js +2 -2
  22. package/esm/styles/index.js +2 -2
  23. package/esm/styles/makeStyles.js +2 -2
  24. package/esm/styles/responsiveFontSizes.js +2 -2
  25. package/esm/styles/withStyles.js +2 -2
  26. package/esm/styles/withTheme.js +2 -2
  27. package/esm/utils/mergeSlotProps.js +25 -0
  28. package/esm/version/index.js +2 -2
  29. package/index.js +1 -1
  30. package/modern/InputBase/InputBase.js +2 -2
  31. package/modern/Select/SelectInput.js +2 -2
  32. package/modern/StepLabel/StepLabel.d.ts +19 -1
  33. package/modern/StepLabel/StepLabel.js +14 -5
  34. package/modern/Switch/Switch.d.ts +62 -1
  35. package/modern/Switch/Switch.js +71 -9
  36. package/modern/TextField/TextField.d.ts +30 -0
  37. package/modern/TextField/TextField.js +22 -11
  38. package/modern/index.js +1 -1
  39. package/modern/styles/createPalette.js +3 -3
  40. package/modern/styles/createThemeNoVars.js +2 -2
  41. package/modern/styles/createThemeWithVars.js +2 -2
  42. package/modern/styles/index.js +2 -2
  43. package/modern/styles/makeStyles.js +2 -2
  44. package/modern/styles/responsiveFontSizes.js +2 -2
  45. package/modern/styles/withStyles.js +2 -2
  46. package/modern/styles/withTheme.js +2 -2
  47. package/modern/utils/mergeSlotProps.js +25 -0
  48. package/modern/version/index.js +2 -2
  49. package/package.json +7 -7
  50. package/styles/createPalette.js +3 -3
  51. package/styles/createThemeNoVars.js +2 -2
  52. package/styles/createThemeWithVars.js +2 -2
  53. package/styles/index.js +2 -2
  54. package/styles/makeStyles.js +2 -2
  55. package/styles/responsiveFontSizes.js +2 -2
  56. package/styles/withStyles.js +2 -2
  57. package/styles/withTheme.js +2 -2
  58. package/tsconfig.build.tsbuildinfo +1 -1
  59. package/utils/mergeSlotProps.js +24 -0
  60. package/version/index.js +2 -2
@@ -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-beta.4";
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 = "beta.4";
11
+ const prerelease = exports.prerelease = "rc.0";
12
12
  var _default = exports.default = version;