@mui/utils 6.0.0-beta.5 → 6.0.0-beta.6

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 CHANGED
@@ -1,5 +1,73 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 6.0.0-beta.6
4
+
5
+ <!-- generated comparing v6.0.0-beta.5..next -->
6
+
7
+ _Aug 16, 2024_
8
+
9
+ A big thanks to the 18 contributors who made this release possible.
10
+
11
+ ### `@mui/material@6.0.0-beta.6`
12
+
13
+ - [Autocomplete] Improve the `options` prop description (#41591) @pluvio72
14
+ - [Autocomplete] Remove autocomplete warning regarding value not equal to option (#43314) @ZeeshanTamboli
15
+ - [Divider] Add aria-orientation (#43241) @aarongarciah
16
+ - [IconButton] Fix hover background color behavior (#43271) @mnajdova
17
+ - [TypeScript] Refactor types so they're compatible with upcoming React 19 (#43276) @DiegoAndai
18
+ - [Typography] Replace dot notation color value to work with Pigment CSS (#43288) @siriwatknp
19
+ - [pigment-css] Fix `getSelector` prefers-color-scheme to be object (#43237) @siriwatknp
20
+ - Remove `display="block"` usage to work with Pigment CSS (#43307) @siriwatknp
21
+
22
+ ### `@mui/codemod@6.0.0-beta.6`
23
+
24
+ - [codemod] Skip sx spread transformation (#43291) @siriwatknp
25
+
26
+ ### `@mui/styles@6.0.0-beta.6`
27
+
28
+ - [styles] Fix issues reported by eslint-plugin-react-compiler (#43118) @jlewins
29
+
30
+ ### Docs
31
+
32
+ - [material-ui] Audit and copyedit the v6 migration doc (#43073) @samuelsycamore
33
+ - [material-ui] Fix Material Icon search lag and other improvements (#41330) @anle9650
34
+ - [material-ui][Popover] Fix description and title of hover interaction section (#43290) @ZeeshanTamboli
35
+ - [material-ui] Refine and unify custom template themes (#43220) @zanivan
36
+ - [joy-ui] Fix data grid redirection (#43247) @sai6855
37
+ - [mui-system] Add import statement in docs (#43223) @sai6855
38
+ - Update babel config (#43286) @romgrk
39
+ - Fix outdated references to Materal UI version (#43321) @oliviertassinari
40
+ - Polish migration git diff experience @oliviertassinari
41
+ - Update LTS to match format (#43212) @oliviertassinari
42
+ - Fix Pigment CSS migration content (#43217) @siriwatknp
43
+
44
+ ### Core
45
+
46
+ - [code-infra] Remove `userEvent` export from `@mui/internal-test-utils` (#43313) @LukasTy
47
+ - [code-infra] Remove unnecessary alias (#43320) @Janpot
48
+ - [code-infra] Fix utils bundle size entrypoint (#43304) @Janpot
49
+ - [core] missing and incorrect scripts (#43209) @Jay-Karia
50
+ - [core] Set Node 14 as minimum version in all browserslist envs (#43326) @aarongarciah
51
+ - [core] Add React 19 as peer dependency (#43216) @aarongarciah
52
+ - [core] Pin `eslint-plugin-jsx-a11y` version to 6.7.1 (#43292) @Janpot
53
+ - [core] Update supported Node.js version to 14 (#43315) @Janpot
54
+ - [core] Use fs instead of fs-extra in script utils (#43234) @DiegoAndai
55
+ - [core] Refactor system theme props (#43120) @romgrk
56
+ - [docs-infra] Fix some TS issues for X docs (#43285) @Janpot
57
+ - [docs-infra] Move API pages to TS (#43199) @alexfauquette
58
+ - [docs-infra] Fix broken sandboxes with relative module imports (#42767) @bharatkashyap
59
+ - [docs-infra] Simplify API sections typing (#43128) @alexfauquette
60
+ - [examples] Fix import (#43316) @aarongarciah
61
+ - [examples] Add material-ui-pigment-css for Next.js and Vite (#43065) @siriwatknp
62
+ - [examples] Replace wrong import with `@mui/material/styles` (#43236) @siriwatknp
63
+ - [useMediaQuery] Adapt test implementation for React 19 (#43269) @aarongarciah
64
+ - [test] Update `matchMedia` mocks (#43240) @cherniavskii
65
+ - [test] Remove unnecessary ref param (#43282) @aarongarciah
66
+ - [website] Update showcase to include Toolpad Core (#43226) @bharatkashyap
67
+ - [website] Replace React.MutableRefObject with React.RefObject (#43284) @aarongarciah
68
+
69
+ All contributors of this release in alphabetical order: @aarongarciah, @alexfauquette, @anle9650, @bharatkashyap, @cherniavskii, @DiegoAndai, @Janpot, @Jay-Karia, @jlewins, @mnajdova, @oliviertassinari, @pluvio72, @renovate[bot], @romgrk, @sai6855, @samuelsycamore, @siriwatknp, @ZeeshanTamboli
70
+
3
71
  ## 6.0.0-beta.5
4
72
 
5
73
  <!-- generated comparing v6.0.0-beta.4..next -->
@@ -1842,6 +1910,7 @@ This release was mostly about 🐛 bug fixes and 📚 documentation improvements
1842
1910
  - [core] Fix TypeScript spelling in changelog @oliviertassinari
1843
1911
  - [core] Fix small detail in the autocomplete demo @oliviertassinari
1844
1912
  - [core] Increase node memory limit on Netlify build (#41111) @michaldudak
1913
+ - [core] Fix Netlify build cache issue (#43281) @LukasTy
1845
1914
  - [core][Tooltip] Remove incorrect code comment (#41179) @ZeeshanTamboli
1846
1915
  - [core] Fix missing context display names (#41168) @oliviertassinari
1847
1916
  - [core][base-ui] Remove `@mui/base` dev dependency from Base UI workspace (#41216) @ZeeshanTamboli
@@ -1,40 +1,43 @@
1
1
  /**
2
2
  * Add keys, values of `defaultProps` that does not exist in `props`
3
- * @param {object} defaultProps
4
- * @param {object} props
5
- * @returns {object} resolved props
3
+ * @param defaultProps
4
+ * @param props
5
+ * @returns resolved props
6
6
  */
7
7
  export default function resolveProps(defaultProps, props) {
8
8
  const output = {
9
9
  ...props
10
10
  };
11
- Object.keys(defaultProps).forEach(propName => {
12
- if (propName.toString().match(/^(components|slots)$/)) {
13
- output[propName] = {
14
- ...defaultProps[propName],
15
- ...output[propName]
16
- };
17
- } else if (propName.toString().match(/^(componentsProps|slotProps)$/)) {
18
- const defaultSlotProps = defaultProps[propName] || {};
19
- const slotProps = props[propName];
20
- output[propName] = {};
21
- if (!slotProps || !Object.keys(slotProps)) {
22
- // Reduce the iteration if the slot props is empty
23
- output[propName] = defaultSlotProps;
24
- } else if (!defaultSlotProps || !Object.keys(defaultSlotProps)) {
25
- // Reduce the iteration if the default slot props is empty
26
- output[propName] = slotProps;
27
- } else {
11
+ for (const key in defaultProps) {
12
+ if (Object.prototype.hasOwnProperty.call(defaultProps, key)) {
13
+ const propName = key;
14
+ if (propName === 'components' || propName === 'slots') {
28
15
  output[propName] = {
29
- ...slotProps
16
+ ...defaultProps[propName],
17
+ ...output[propName]
30
18
  };
31
- Object.keys(defaultSlotProps).forEach(slotPropName => {
32
- output[propName][slotPropName] = resolveProps(defaultSlotProps[slotPropName], slotProps[slotPropName]);
33
- });
19
+ } else if (propName === 'componentsProps' || propName === 'slotProps') {
20
+ const defaultSlotProps = defaultProps[propName];
21
+ const slotProps = props[propName];
22
+ if (!slotProps) {
23
+ output[propName] = defaultSlotProps || {};
24
+ } else if (!defaultSlotProps) {
25
+ output[propName] = slotProps;
26
+ } else {
27
+ output[propName] = {
28
+ ...slotProps
29
+ };
30
+ for (const slotKey in defaultSlotProps) {
31
+ if (Object.prototype.hasOwnProperty.call(defaultSlotProps, slotKey)) {
32
+ const slotPropName = slotKey;
33
+ output[propName][slotPropName] = resolveProps(defaultSlotProps[slotPropName], slotProps[slotPropName]);
34
+ }
35
+ }
36
+ }
37
+ } else if (output[propName] === undefined) {
38
+ output[propName] = defaultProps[propName];
34
39
  }
35
- } else if (output[propName] === undefined) {
36
- output[propName] = defaultProps[propName];
37
40
  }
38
- });
41
+ }
39
42
  return output;
40
43
  }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v6.0.0-beta.5
2
+ * @mui/utils v6.0.0-beta.6
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -8,9 +8,9 @@ var React = _interopRequireWildcard(require("react"));
8
8
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
9
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
10
  function isMuiElement(element, muiNames) {
11
- var _muiName, _element$type;
12
- return /*#__PURE__*/React.isValidElement(element) && muiNames.indexOf( // For server components `muiName` is avaialble in element.type._payload.value.muiName
11
+ return /*#__PURE__*/React.isValidElement(element) && muiNames.indexOf(
12
+ // For server components `muiName` is avaialble in element.type._payload.value.muiName
13
13
  // relevant info - https://github.com/facebook/react/blob/2807d781a08db8e9873687fccc25c0f12b4fb3d4/packages/react/src/ReactLazy.js#L45
14
14
  // eslint-disable-next-line no-underscore-dangle
15
- (_muiName = element.type.muiName) != null ? _muiName : (_element$type = element.type) == null || (_element$type = _element$type._payload) == null || (_element$type = _element$type.value) == null ? void 0 : _element$type.muiName) !== -1;
15
+ element.type.muiName ?? element.type?._payload?.value?.muiName) !== -1;
16
16
  }
@@ -32,11 +32,11 @@ function mergeSlotProps(parameters) {
32
32
  if (!getSlotProps) {
33
33
  // The simpler case - getSlotProps is not defined, so no internal event handlers are defined,
34
34
  // so we can simply merge all the props without having to worry about extracting event handlers.
35
- const joinedClasses = (0, _clsx.default)(additionalProps == null ? void 0 : additionalProps.className, className, externalForwardedProps == null ? void 0 : externalForwardedProps.className, externalSlotProps == null ? void 0 : externalSlotProps.className);
35
+ const joinedClasses = (0, _clsx.default)(additionalProps?.className, className, externalForwardedProps?.className, externalSlotProps?.className);
36
36
  const mergedStyle = {
37
- ...(additionalProps == null ? void 0 : additionalProps.style),
38
- ...(externalForwardedProps == null ? void 0 : externalForwardedProps.style),
39
- ...(externalSlotProps == null ? void 0 : externalSlotProps.style)
37
+ ...additionalProps?.style,
38
+ ...externalForwardedProps?.style,
39
+ ...externalSlotProps?.style
40
40
  };
41
41
  const props = {
42
42
  ...additionalProps,
@@ -70,12 +70,12 @@ function mergeSlotProps(parameters) {
70
70
  // Emotion (that we use in libraries consuming Base UI) depends on this order
71
71
  // to properly override style. It requires the most important classes to be last
72
72
  // (see https://github.com/mui/material-ui/pull/33205) for the related discussion.
73
- const joinedClasses = (0, _clsx.default)(internalSlotProps == null ? void 0 : internalSlotProps.className, additionalProps == null ? void 0 : additionalProps.className, className, externalForwardedProps == null ? void 0 : externalForwardedProps.className, externalSlotProps == null ? void 0 : externalSlotProps.className);
73
+ const joinedClasses = (0, _clsx.default)(internalSlotProps?.className, additionalProps?.className, className, externalForwardedProps?.className, externalSlotProps?.className);
74
74
  const mergedStyle = {
75
- ...(internalSlotProps == null ? void 0 : internalSlotProps.style),
76
- ...(additionalProps == null ? void 0 : additionalProps.style),
77
- ...(externalForwardedProps == null ? void 0 : externalForwardedProps.style),
78
- ...(externalSlotProps == null ? void 0 : externalSlotProps.style)
75
+ ...internalSlotProps?.style,
76
+ ...additionalProps?.style,
77
+ ...externalForwardedProps?.style,
78
+ ...externalSlotProps?.style
79
79
  };
80
80
  const props = {
81
81
  ...internalSlotProps,
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v6.0.0-beta.5
2
+ * @mui/utils v6.0.0-beta.6
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,40 +1,43 @@
1
1
  /**
2
2
  * Add keys, values of `defaultProps` that does not exist in `props`
3
- * @param {object} defaultProps
4
- * @param {object} props
5
- * @returns {object} resolved props
3
+ * @param defaultProps
4
+ * @param props
5
+ * @returns resolved props
6
6
  */
7
7
  export default function resolveProps(defaultProps, props) {
8
8
  const output = {
9
9
  ...props
10
10
  };
11
- Object.keys(defaultProps).forEach(propName => {
12
- if (propName.toString().match(/^(components|slots)$/)) {
13
- output[propName] = {
14
- ...defaultProps[propName],
15
- ...output[propName]
16
- };
17
- } else if (propName.toString().match(/^(componentsProps|slotProps)$/)) {
18
- const defaultSlotProps = defaultProps[propName] || {};
19
- const slotProps = props[propName];
20
- output[propName] = {};
21
- if (!slotProps || !Object.keys(slotProps)) {
22
- // Reduce the iteration if the slot props is empty
23
- output[propName] = defaultSlotProps;
24
- } else if (!defaultSlotProps || !Object.keys(defaultSlotProps)) {
25
- // Reduce the iteration if the default slot props is empty
26
- output[propName] = slotProps;
27
- } else {
11
+ for (const key in defaultProps) {
12
+ if (Object.prototype.hasOwnProperty.call(defaultProps, key)) {
13
+ const propName = key;
14
+ if (propName === 'components' || propName === 'slots') {
28
15
  output[propName] = {
29
- ...slotProps
16
+ ...defaultProps[propName],
17
+ ...output[propName]
30
18
  };
31
- Object.keys(defaultSlotProps).forEach(slotPropName => {
32
- output[propName][slotPropName] = resolveProps(defaultSlotProps[slotPropName], slotProps[slotPropName]);
33
- });
19
+ } else if (propName === 'componentsProps' || propName === 'slotProps') {
20
+ const defaultSlotProps = defaultProps[propName];
21
+ const slotProps = props[propName];
22
+ if (!slotProps) {
23
+ output[propName] = defaultSlotProps || {};
24
+ } else if (!defaultSlotProps) {
25
+ output[propName] = slotProps;
26
+ } else {
27
+ output[propName] = {
28
+ ...slotProps
29
+ };
30
+ for (const slotKey in defaultSlotProps) {
31
+ if (Object.prototype.hasOwnProperty.call(defaultSlotProps, slotKey)) {
32
+ const slotPropName = slotKey;
33
+ output[propName][slotPropName] = resolveProps(defaultSlotProps[slotPropName], slotProps[slotPropName]);
34
+ }
35
+ }
36
+ }
37
+ } else if (output[propName] === undefined) {
38
+ output[propName] = defaultProps[propName];
34
39
  }
35
- } else if (output[propName] === undefined) {
36
- output[propName] = defaultProps[propName];
37
40
  }
38
- });
41
+ }
39
42
  return output;
40
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/utils",
3
- "version": "6.0.0-beta.5",
3
+ "version": "6.0.0-beta.6",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "Utility functions for React components.",
@@ -31,11 +31,11 @@
31
31
  "clsx": "^2.1.1",
32
32
  "prop-types": "^15.8.1",
33
33
  "react-is": "^18.3.1",
34
- "@mui/types": "^7.2.14"
34
+ "@mui/types": "^7.2.15"
35
35
  },
36
36
  "peerDependencies": {
37
- "@types/react": "^17.0.0 || ^18.0.0",
38
- "react": "^17.0.0 || ^18.0.0"
37
+ "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
38
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0"
39
39
  },
40
40
  "peerDependenciesMeta": {
41
41
  "@types/react": {
@@ -48,7 +48,7 @@
48
48
  "directory": "build"
49
49
  },
50
50
  "engines": {
51
- "node": ">=12.0.0"
51
+ "node": ">=14.0.0"
52
52
  },
53
53
  "module": "./esm/index.js",
54
54
  "types": "./index.d.ts"
@@ -15,7 +15,7 @@ function requirePropFactory(componentNameInError, Component) {
15
15
  } : null;
16
16
  const requireProp = requiredProp => (props, propName, componentName, location, propFullName, ...args) => {
17
17
  const propFullNameSafe = propFullName || propName;
18
- const defaultTypeChecker = prevPropTypes == null ? void 0 : prevPropTypes[propFullNameSafe];
18
+ const defaultTypeChecker = prevPropTypes?.[propFullNameSafe];
19
19
  if (defaultTypeChecker) {
20
20
  const typeCheckerResult = defaultTypeChecker(props, propName, componentName, location, propFullName, ...args);
21
21
  if (typeCheckerResult) {
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Add keys, values of `defaultProps` that does not exist in `props`
3
- * @param {object} defaultProps
4
- * @param {object} props
5
- * @returns {object} resolved props
3
+ * @param defaultProps
4
+ * @param props
5
+ * @returns resolved props
6
6
  */
7
7
  export default function resolveProps<T extends {
8
8
  components?: Record<string, unknown>;
@@ -6,41 +6,44 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = resolveProps;
7
7
  /**
8
8
  * Add keys, values of `defaultProps` that does not exist in `props`
9
- * @param {object} defaultProps
10
- * @param {object} props
11
- * @returns {object} resolved props
9
+ * @param defaultProps
10
+ * @param props
11
+ * @returns resolved props
12
12
  */
13
13
  function resolveProps(defaultProps, props) {
14
14
  const output = {
15
15
  ...props
16
16
  };
17
- Object.keys(defaultProps).forEach(propName => {
18
- if (propName.toString().match(/^(components|slots)$/)) {
19
- output[propName] = {
20
- ...defaultProps[propName],
21
- ...output[propName]
22
- };
23
- } else if (propName.toString().match(/^(componentsProps|slotProps)$/)) {
24
- const defaultSlotProps = defaultProps[propName] || {};
25
- const slotProps = props[propName];
26
- output[propName] = {};
27
- if (!slotProps || !Object.keys(slotProps)) {
28
- // Reduce the iteration if the slot props is empty
29
- output[propName] = defaultSlotProps;
30
- } else if (!defaultSlotProps || !Object.keys(defaultSlotProps)) {
31
- // Reduce the iteration if the default slot props is empty
32
- output[propName] = slotProps;
33
- } else {
17
+ for (const key in defaultProps) {
18
+ if (Object.prototype.hasOwnProperty.call(defaultProps, key)) {
19
+ const propName = key;
20
+ if (propName === 'components' || propName === 'slots') {
34
21
  output[propName] = {
35
- ...slotProps
22
+ ...defaultProps[propName],
23
+ ...output[propName]
36
24
  };
37
- Object.keys(defaultSlotProps).forEach(slotPropName => {
38
- output[propName][slotPropName] = resolveProps(defaultSlotProps[slotPropName], slotProps[slotPropName]);
39
- });
25
+ } else if (propName === 'componentsProps' || propName === 'slotProps') {
26
+ const defaultSlotProps = defaultProps[propName];
27
+ const slotProps = props[propName];
28
+ if (!slotProps) {
29
+ output[propName] = defaultSlotProps || {};
30
+ } else if (!defaultSlotProps) {
31
+ output[propName] = slotProps;
32
+ } else {
33
+ output[propName] = {
34
+ ...slotProps
35
+ };
36
+ for (const slotKey in defaultSlotProps) {
37
+ if (Object.prototype.hasOwnProperty.call(defaultSlotProps, slotKey)) {
38
+ const slotPropName = slotKey;
39
+ output[propName][slotPropName] = resolveProps(defaultSlotProps[slotPropName], slotProps[slotPropName]);
40
+ }
41
+ }
42
+ }
43
+ } else if (output[propName] === undefined) {
44
+ output[propName] = defaultProps[propName];
40
45
  }
41
- } else if (output[propName] === undefined) {
42
- output[propName] = defaultProps[propName];
43
46
  }
44
- });
47
+ }
45
48
  return output;
46
49
  }
package/useId/useId.js CHANGED
@@ -36,7 +36,7 @@ const maybeReactUseId = React['useId'.toString()];
36
36
  function useId(idOverride) {
37
37
  if (maybeReactUseId !== undefined) {
38
38
  const reactId = maybeReactUseId();
39
- return idOverride != null ? idOverride : reactId;
39
+ return idOverride ?? reactId;
40
40
  }
41
41
  // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler
42
42
  // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
@@ -96,10 +96,7 @@ function useLocalStorageStateBrowser(key, initializer = null) {
96
96
  const [initialValue] = React.useState(initializer);
97
97
  const area = window.localStorage;
98
98
  const subscribeKey = React.useCallback(callbark => subscribe(area, key, callbark), [area, key]);
99
- const getKeySnapshot = React.useCallback(() => {
100
- var _getSnapshot;
101
- return (_getSnapshot = getSnapshot(area, key)) != null ? _getSnapshot : initialValue;
102
- }, [area, initialValue, key]);
99
+ const getKeySnapshot = React.useCallback(() => getSnapshot(area, key) ?? initialValue, [area, initialValue, key]);
103
100
 
104
101
  // Start with null for the hydration, and then switch to the actual value.
105
102
  const getKeyServerSnapshot = () => null;
@@ -19,7 +19,6 @@ var _resolveComponentProps = _interopRequireDefault(require("../resolveComponent
19
19
  * @param parameters.getSlotProps - A function that returns the props to be passed to the slot component.
20
20
  */
21
21
  function useSlotProps(parameters) {
22
- var _parameters$additiona;
23
22
  const {
24
23
  elementType,
25
24
  externalSlotProps,
@@ -35,7 +34,7 @@ function useSlotProps(parameters) {
35
34
  ...other,
36
35
  externalSlotProps: resolvedComponentsProps
37
36
  });
38
- const ref = (0, _useForkRef.default)(internalRef, resolvedComponentsProps == null ? void 0 : resolvedComponentsProps.ref, (_parameters$additiona = parameters.additionalProps) == null ? void 0 : _parameters$additiona.ref);
37
+ const ref = (0, _useForkRef.default)(internalRef, resolvedComponentsProps?.ref, parameters.additionalProps?.ref);
39
38
  const props = (0, _appendOwnerState.default)(elementType, {
40
39
  ...mergedProps,
41
40
  ref