@mui/utils 6.0.0-beta.3 → 6.0.0-beta.4-dev.20240802-144226-85a3b55d22

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,46 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 6.0.0-beta.4
4
+
5
+ <!-- generated comparing v6.0.0-beta.3..next -->
6
+
7
+ _Jul 30, 2024_
8
+
9
+ A big thanks to the 12 contributors who made this release possible.
10
+
11
+ ### `@mui/material@6.0.0-beta.4`
12
+
13
+ - [Accordion] Render a heading wrapping `AccordionSummary` button per W3C Accordion Pattern standards (#42914) @ZeeshanTamboli
14
+ - [Divider] Enable borderStyle enhancement in divider with children (#42715) @anuujj
15
+ - [ImageListItemBar] Deprecate composed classes (#42905) @sai6855
16
+ - Attach selector for default color scheme (#43035) @siriwatknp
17
+ - Stabilize Grid v2 and deprecate Grid v1 (#43054) @DiegoAndai
18
+
19
+ ### `@mui/system@6.0.0-beta.4`
20
+
21
+ - Make `createBreakpoints` independent for stringify theme (#43048) @siriwatknp
22
+
23
+ ### `@mui/utils@6.0.0-beta.4`
24
+
25
+ - Fix issues reported by the React Compiler (#43051) @markliu2013
26
+
27
+ ### Docs
28
+
29
+ - [material-ui] Replace deprecated `<ListItem button/>` with `ListItemButton` component in routing libraries list example (#43110) @aliharis99
30
+ - [material-ui][Card] Update CardMedia description (#43067) @shahzaibdev1
31
+ - [material-ui] Polish out data table demo (#43072) @zanivan
32
+ - [material-ui][Snackbar] Improve reason type in demos (#43077) @sai6855
33
+ - [pigment-css] Fix syntax in migrating-to-pigment-css guide (#43107) @KevinVandy
34
+ - Fix page description line break @oliviertassinari
35
+
36
+ ### Core
37
+
38
+ - Fix event naming convention @oliviertassinari
39
+ - [docs-infra] Move ads to the `@mui/docs` package (#42944) @alexfauquette
40
+ - [website] Fine-tune button styles on the branding theme (#43082) @zanivan
41
+
42
+ All contributors of this release in alphabetical order: @alexfauquette, @aliharis99, @anuujj, @DiegoAndai, @KevinVandy, @markliu2013, @oliviertassinari, @sai6855, @shahzaibdev1, @siriwatknp, @zanivan, @ZeeshanTamboli
43
+
3
44
  ## 6.0.0-beta.3
4
45
 
5
46
  <!-- generated comparing v6.0.0-beta.2..next -->
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * Returns the ref of a React node handling differences between React 19 and older versions.
5
+ * It will return null if the node is not a valid React element.
6
+ *
7
+ * @param element React.ReactNode
8
+ * @returns React.Ref<any> | null
9
+ */
10
+ export default function getReactNodeRef(element) {
11
+ if (!element || ! /*#__PURE__*/React.isValidElement(element)) {
12
+ return null;
13
+ }
14
+
15
+ // 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
16
+ return element.props.propertyIsEnumerable('ref') ? element.props.ref :
17
+ // @ts-expect-error element.ref is not included in the ReactElement type
18
+ // We cannot check for it, but isValidElement is true at this point
19
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/70189
20
+ element.ref;
21
+ }
@@ -0,0 +1 @@
1
+ export { default } from './getReactNodeRef';
package/esm/index.js CHANGED
@@ -44,4 +44,5 @@ export { default as clamp } from './clamp';
44
44
  export { default as unstable_useSlotProps } from './useSlotProps';
45
45
  export { default as unstable_resolveComponentProps } from './resolveComponentProps';
46
46
  export { default as unstable_extractEventHandlers } from './extractEventHandlers';
47
+ export { default as unstable_getReactNodeRef } from './getReactNodeRef';
47
48
  export * from './types';
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
 
3
+ // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- process.env never changes, dependency arrays are intentionally ignored
3
4
  /* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */
4
5
  import * as React from 'react';
5
6
  export default function useControlled({
@@ -17,6 +17,7 @@ export default function useForkRef(...refs) {
17
17
  setRef(ref, instance);
18
18
  });
19
19
  };
20
+ // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- intentionally ignoring that the dependency array must be an array literal
20
21
  // eslint-disable-next-line react-hooks/exhaustive-deps
21
22
  }, refs);
22
23
  }
@@ -31,6 +31,7 @@ export default function useId(idOverride) {
31
31
  const reactId = maybeReactUseId();
32
32
  return idOverride ?? reactId;
33
33
  }
34
+ // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler
34
35
  // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
35
36
  return useGlobalId(idOverride);
36
37
  }
@@ -7,6 +7,7 @@ const EMPTY = [];
7
7
  * A React.useEffect equivalent that runs once, when the component is mounted.
8
8
  */
9
9
  export default function useOnMount(fn) {
10
+ // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- no need to put `fn` in the dependency array
10
11
  /* eslint-disable react-hooks/exhaustive-deps */
11
12
  React.useEffect(fn, EMPTY);
12
13
  /* eslint-enable react-hooks/exhaustive-deps */
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Returns the ref of a React node handling differences between React 19 and older versions.
4
+ * It will return null if the node is not a valid React element.
5
+ *
6
+ * @param element React.ReactNode
7
+ * @returns React.Ref<any> | null
8
+ */
9
+ export default function getReactNodeRef(element: React.ReactNode): React.Ref<any> | null;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = getReactNodeRef;
7
+ var React = _interopRequireWildcard(require("react"));
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
+ 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
+ /**
11
+ * Returns the ref of a React node handling differences between React 19 and older versions.
12
+ * It will return null if the node is not a valid React element.
13
+ *
14
+ * @param element React.ReactNode
15
+ * @returns React.Ref<any> | null
16
+ */
17
+ function getReactNodeRef(element) {
18
+ if (!element || ! /*#__PURE__*/React.isValidElement(element)) {
19
+ return null;
20
+ }
21
+
22
+ // 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
23
+ return element.props.propertyIsEnumerable('ref') ? element.props.ref :
24
+ // @ts-expect-error element.ref is not included in the ReactElement type
25
+ // We cannot check for it, but isValidElement is true at this point
26
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/70189
27
+ element.ref;
28
+ }
@@ -0,0 +1 @@
1
+ export { default } from './getReactNodeRef';
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _getReactNodeRef.default;
11
+ }
12
+ });
13
+ var _getReactNodeRef = _interopRequireDefault(require("./getReactNodeRef"));
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "../esm/getReactNodeRef/index.js",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts"
6
+ }
package/index.d.ts CHANGED
@@ -45,4 +45,5 @@ export { default as unstable_useSlotProps } from './useSlotProps';
45
45
  export type { UseSlotPropsParameters, UseSlotPropsResult } from './useSlotProps';
46
46
  export { default as unstable_resolveComponentProps } from './resolveComponentProps';
47
47
  export { default as unstable_extractEventHandlers } from './extractEventHandlers';
48
+ export { default as unstable_getReactNodeRef } from './getReactNodeRef';
48
49
  export * from './types';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v6.0.0-beta.3
2
+ * @mui/utils v6.0.0-beta.4-dev.20240802-144226-85a3b55d22
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -57,7 +57,8 @@ var _exportNames = {
57
57
  clamp: true,
58
58
  unstable_useSlotProps: true,
59
59
  unstable_resolveComponentProps: true,
60
- unstable_extractEventHandlers: true
60
+ unstable_extractEventHandlers: true,
61
+ unstable_getReactNodeRef: true
61
62
  };
62
63
  Object.defineProperty(exports, "HTMLElementType", {
63
64
  enumerable: true,
@@ -209,6 +210,12 @@ Object.defineProperty(exports, "unstable_generateUtilityClasses", {
209
210
  return _generateUtilityClasses.default;
210
211
  }
211
212
  });
213
+ Object.defineProperty(exports, "unstable_getReactNodeRef", {
214
+ enumerable: true,
215
+ get: function () {
216
+ return _getReactNodeRef.default;
217
+ }
218
+ });
212
219
  Object.defineProperty(exports, "unstable_getScrollbarSize", {
213
220
  enumerable: true,
214
221
  get: function () {
@@ -389,6 +396,7 @@ var _clamp = _interopRequireDefault(require("./clamp"));
389
396
  var _useSlotProps = _interopRequireDefault(require("./useSlotProps"));
390
397
  var _resolveComponentProps = _interopRequireDefault(require("./resolveComponentProps"));
391
398
  var _extractEventHandlers = _interopRequireDefault(require("./extractEventHandlers"));
399
+ var _getReactNodeRef = _interopRequireDefault(require("./getReactNodeRef"));
392
400
  var _types = require("./types");
393
401
  Object.keys(_types).forEach(function (key) {
394
402
  if (key === "default" || key === "__esModule") return;
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * Returns the ref of a React node handling differences between React 19 and older versions.
5
+ * It will return null if the node is not a valid React element.
6
+ *
7
+ * @param element React.ReactNode
8
+ * @returns React.Ref<any> | null
9
+ */
10
+ export default function getReactNodeRef(element) {
11
+ if (!element || ! /*#__PURE__*/React.isValidElement(element)) {
12
+ return null;
13
+ }
14
+
15
+ // 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
16
+ return element.props.propertyIsEnumerable('ref') ? element.props.ref :
17
+ // @ts-expect-error element.ref is not included in the ReactElement type
18
+ // We cannot check for it, but isValidElement is true at this point
19
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/70189
20
+ element.ref;
21
+ }
@@ -0,0 +1 @@
1
+ export { default } from './getReactNodeRef';
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v6.0.0-beta.3
2
+ * @mui/utils v6.0.0-beta.4-dev.20240802-144226-85a3b55d22
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -51,4 +51,5 @@ export { default as clamp } from './clamp';
51
51
  export { default as unstable_useSlotProps } from './useSlotProps';
52
52
  export { default as unstable_resolveComponentProps } from './resolveComponentProps';
53
53
  export { default as unstable_extractEventHandlers } from './extractEventHandlers';
54
+ export { default as unstable_getReactNodeRef } from './getReactNodeRef';
54
55
  export * from './types';
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
 
3
+ // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- process.env never changes, dependency arrays are intentionally ignored
3
4
  /* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */
4
5
  import * as React from 'react';
5
6
  export default function useControlled({
@@ -17,6 +17,7 @@ export default function useForkRef(...refs) {
17
17
  setRef(ref, instance);
18
18
  });
19
19
  };
20
+ // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- intentionally ignoring that the dependency array must be an array literal
20
21
  // eslint-disable-next-line react-hooks/exhaustive-deps
21
22
  }, refs);
22
23
  }
@@ -31,6 +31,7 @@ export default function useId(idOverride) {
31
31
  const reactId = maybeReactUseId();
32
32
  return idOverride ?? reactId;
33
33
  }
34
+ // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler
34
35
  // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
35
36
  return useGlobalId(idOverride);
36
37
  }
@@ -7,6 +7,7 @@ const EMPTY = [];
7
7
  * A React.useEffect equivalent that runs once, when the component is mounted.
8
8
  */
9
9
  export default function useOnMount(fn) {
10
+ // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- no need to put `fn` in the dependency array
10
11
  /* eslint-disable react-hooks/exhaustive-deps */
11
12
  React.useEffect(fn, EMPTY);
12
13
  /* eslint-enable react-hooks/exhaustive-deps */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/utils",
3
- "version": "6.0.0-beta.3",
3
+ "version": "6.0.0-beta.4-dev.20240802-144226-85a3b55d22",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "Utility functions for React components.",
@@ -26,7 +26,7 @@
26
26
  "url": "https://opencollective.com/mui-org"
27
27
  },
28
28
  "dependencies": {
29
- "@babel/runtime": "^7.24.8",
29
+ "@babel/runtime": "^7.25.0",
30
30
  "@types/prop-types": "^15.7.12",
31
31
  "clsx": "^2.1.1",
32
32
  "prop-types": "^15.8.1",
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  'use client';
3
3
 
4
+ // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- process.env never changes, dependency arrays are intentionally ignored
4
5
  /* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */
5
6
  Object.defineProperty(exports, "__esModule", {
6
7
  value: true
@@ -25,6 +25,7 @@ function useForkRef(...refs) {
25
25
  (0, _setRef.default)(ref, instance);
26
26
  });
27
27
  };
28
+ // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- intentionally ignoring that the dependency array must be an array literal
28
29
  // eslint-disable-next-line react-hooks/exhaustive-deps
29
30
  }, refs);
30
31
  }
package/useId/useId.js CHANGED
@@ -38,6 +38,7 @@ function useId(idOverride) {
38
38
  const reactId = maybeReactUseId();
39
39
  return idOverride != null ? idOverride : reactId;
40
40
  }
41
+ // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler
41
42
  // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
42
43
  return useGlobalId(idOverride);
43
44
  }
@@ -14,6 +14,7 @@ const EMPTY = [];
14
14
  * A React.useEffect equivalent that runs once, when the component is mounted.
15
15
  */
16
16
  function useOnMount(fn) {
17
+ // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- no need to put `fn` in the dependency array
17
18
  /* eslint-disable react-hooks/exhaustive-deps */
18
19
  React.useEffect(fn, EMPTY);
19
20
  /* eslint-enable react-hooks/exhaustive-deps */