@mui/utils 5.16.5 → 5.16.8

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,99 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 5.16.8
4
+
5
+ <!-- generated comparing v5.16.7..v5.x -->
6
+
7
+ _Nov 26, 2024_
8
+
9
+ A big thanks to the 8 contributors who made this release possible.
10
+
11
+ ### `@mui/material@5.16.8`
12
+
13
+ - Cherry pick ref accessing PRs (#44543) @DiegoAndai
14
+
15
+ ### `@mui/utils@5.16.8`
16
+
17
+ - Skip deep clone React element (v5.x) (#44494) @jukkatupamaki
18
+
19
+ ### Docs
20
+
21
+ - Keep sponsors up to date @oliviertassinari
22
+ - Fix MUI Treasury Layout broken links (#43753) @oliviertassinari
23
+ - Strengthen CSP rule @oliviertassinari
24
+ - Give up on restoring search @oliviertassinari
25
+ - Normalize next major message @oliviertassinari
26
+ - Fix versions URL @oliviertassinari
27
+ - Fix use of absolute URLs (#43567) @oliviertassinari
28
+ - Restore search on v5 (#43566) @oliviertassinari
29
+ - Fix link from v5 to v6 (#43585) @alexfauquette
30
+ - Updated mui-x roadmap links with the new project URL (@michelengelen) (#43446) @michelengelen
31
+ - Fix broken link to Next.js docs @oliviertassinari
32
+
33
+ ### Core
34
+
35
+ - [blog] Polish Upcoming changes to MUI X pricing in 2024 (#43438) @oliviertassinari
36
+ - [blog] Add video to the Pigment CSS blog post (#42500) @oliviertassinari
37
+ - [blog] Announcing pricing changes Sep 2024 (#43272) @cherniavskii
38
+ - Prepare for moving to v5.x branch (#43447) @siriwatknp
39
+ - [core] Cherry pick #42346 to v5 (#44475) @DiegoAndai
40
+ - [core] Fix CI on v5.x branch (#44487) @DiegoAndai
41
+ - [core] Fix CI on v5.x branch (#43564) @oliviertassinari
42
+ - [examples] Fix v5 clone example instructions (#43755) @oliviertassinari
43
+ - [examples] Fix CLI download instructions @oliviertassinari
44
+ - [examples] Fix CDN live preview example @oliviertassinari
45
+ - [examples] Fix more examples to work with v5 @oliviertassinari
46
+ - [examples] Freeze examples dependency range (#43435) @oliviertassinari
47
+
48
+ All contributors of this release in alphabetical order: @alexfauquette, @cherniavskii, @DiegoAndai, @jukkatupamaki, @michelengelen, @oliviertassinari, @rluzists1, @siriwatknp
49
+
50
+ ## 5.16.7
51
+
52
+ <!-- generated comparing v5.16.6..master -->
53
+
54
+ _Aug 9, 2024_
55
+
56
+ A big thanks to the 3 contributors who made this release possible.
57
+
58
+ ### `@mui/material@5.16.7`
59
+
60
+ - &#8203;<!-- 3 -->[material-ui][mui-system] Add support for version runtime checks (#43233) @DiegoAndai
61
+
62
+ ### Docs
63
+
64
+ - &#8203;<!-- 4 -->[docs] Fix 301 @oliviertassinari
65
+
66
+ ### Core
67
+
68
+ - &#8203;<!-- 2 -->[website] Fix wrong link in pricing table (@zanivan) (#43143) @zanivan
69
+ - &#8203;<!-- 1 -->[website] Add blog link to pricing table (@zanivan) (#43140) @zanivan
70
+
71
+ All contributors of this release in alphabetical order: @DiegoAndai, @oliviertassinari, @zanivan
72
+
73
+ ## 5.16.6
74
+
75
+ <!-- generated comparing v5.16.5..master -->
76
+
77
+ _Jul 30, 2024_
78
+
79
+ A big thanks to the 5 contributors who made this release possible.
80
+
81
+ ### `@mui/material@5.16.6`
82
+
83
+ - [Divider] Enable borderStyle enhancement in divider with children (#43059) @anuujj
84
+
85
+ ### Docs
86
+
87
+ - [material-ui][Card] Update CardMedia description (#43121) @shahzaibdev1
88
+ - [material-ui] Replace deprecated `<ListItem button/>` with `ListItemButton` component in routing libraries list example (#43114) @aliharis99
89
+ - [material-ui][Snackbar] Improve close `reason` type in demos (#43105) @sai6855
90
+
91
+ ### Core
92
+
93
+ - [code-infra] Use the same CI names on master & next (#43064) @mnajdova
94
+
95
+ All contributors of this release in alphabetical order: @aliharis99, @anuujj, @mnajdova, @sai6855, @shahzaibdev1
96
+
3
97
  ## 5.16.5
4
98
 
5
99
  <!-- generated comparing v5.16.4..master -->
@@ -7,6 +7,9 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = deepmerge;
8
8
  exports.isPlainObject = isPlainObject;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var React = _interopRequireWildcard(require("react"));
11
+ 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); }
12
+ 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 && Object.prototype.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
13
  // https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
11
14
  function isPlainObject(item) {
12
15
  if (typeof item !== 'object' || item === null) {
@@ -16,7 +19,7 @@ function isPlainObject(item) {
16
19
  return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in item) && !(Symbol.iterator in item);
17
20
  }
18
21
  function deepClone(source) {
19
- if (!isPlainObject(source)) {
22
+ if ( /*#__PURE__*/React.isValidElement(source) || !isPlainObject(source)) {
20
23
  return source;
21
24
  }
22
25
  const output = {};
@@ -31,7 +34,9 @@ function deepmerge(target, source, options = {
31
34
  const output = options.clone ? (0, _extends2.default)({}, target) : target;
32
35
  if (isPlainObject(target) && isPlainObject(source)) {
33
36
  Object.keys(source).forEach(key => {
34
- if (isPlainObject(source[key]) &&
37
+ if ( /*#__PURE__*/React.isValidElement(source[key])) {
38
+ output[key] = source[key];
39
+ } else if (isPlainObject(source[key]) &&
35
40
  // Avoid prototype pollution
36
41
  Object.prototype.hasOwnProperty.call(target, key) && isPlainObject(target[key])) {
37
42
  // Since `output` is a clone of `target` and we have narrowed `target` in this block we can cast to the same type.
@@ -1,4 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+
2
4
  // https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
3
5
  export function isPlainObject(item) {
4
6
  if (typeof item !== 'object' || item === null) {
@@ -8,7 +10,7 @@ export function isPlainObject(item) {
8
10
  return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in item) && !(Symbol.iterator in item);
9
11
  }
10
12
  function deepClone(source) {
11
- if (!isPlainObject(source)) {
13
+ if ( /*#__PURE__*/React.isValidElement(source) || !isPlainObject(source)) {
12
14
  return source;
13
15
  }
14
16
  const output = {};
@@ -23,7 +25,9 @@ export default function deepmerge(target, source, options = {
23
25
  const output = options.clone ? _extends({}, target) : target;
24
26
  if (isPlainObject(target) && isPlainObject(source)) {
25
27
  Object.keys(source).forEach(key => {
26
- if (isPlainObject(source[key]) &&
28
+ if ( /*#__PURE__*/React.isValidElement(source[key])) {
29
+ output[key] = source[key];
30
+ } else if (isPlainObject(source[key]) &&
27
31
  // Avoid prototype pollution
28
32
  Object.prototype.hasOwnProperty.call(target, key) && isPlainObject(target[key])) {
29
33
  // Since `output` is a clone of `target` and we have narrowed `target` in this block we can cast to the same type.
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * Returns the ref of a React element handling differences between React 19 and older versions.
5
+ * It will throw runtime error if the element is not a valid React element.
6
+ *
7
+ * @param element React.ReactElement
8
+ * @returns React.Ref<any> | null
9
+ */
10
+ export default function getReactElementRef(element) {
11
+ // 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
12
+ if (parseInt(React.version, 10) >= 19) {
13
+ var _element$props;
14
+ return (element == null || (_element$props = element.props) == null ? void 0 : _element$props.ref) || null;
15
+ }
16
+ // @ts-expect-error element.ref is not included in the ReactElement type
17
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/70189
18
+ return (element == null ? void 0 : element.ref) || null;
19
+ }
@@ -0,0 +1 @@
1
+ export { default } from './getReactElementRef';
package/esm/index.js CHANGED
@@ -45,4 +45,5 @@ export { default as clamp } from './clamp';
45
45
  export { default as unstable_useSlotProps } 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_getReactElementRef } from './getReactElementRef';
48
49
  export * from './types';
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Returns the ref of a React element handling differences between React 19 and older versions.
4
+ * It will throw runtime error if the element is not a valid React element.
5
+ *
6
+ * @param element React.ReactElement
7
+ * @returns React.Ref<any> | null
8
+ */
9
+ export default function getReactElementRef(element: React.ReactElement): React.Ref<any> | null;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = getReactElementRef;
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 && Object.prototype.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 element handling differences between React 19 and older versions.
12
+ * It will throw runtime error if the element is not a valid React element.
13
+ *
14
+ * @param element React.ReactElement
15
+ * @returns React.Ref<any> | null
16
+ */
17
+ function getReactElementRef(element) {
18
+ // 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
19
+ if (parseInt(React.version, 10) >= 19) {
20
+ var _element$props;
21
+ return (element == null || (_element$props = element.props) == null ? void 0 : _element$props.ref) || null;
22
+ }
23
+ // @ts-expect-error element.ref is not included in the ReactElement type
24
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/70189
25
+ return (element == null ? void 0 : element.ref) || null;
26
+ }
@@ -0,0 +1 @@
1
+ export { default } from './getReactElementRef';
@@ -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 _getReactElementRef.default;
11
+ }
12
+ });
13
+ var _getReactElementRef = _interopRequireDefault(require("./getReactElementRef"));
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "../esm/getReactElementRef/index.js",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -5,4 +5,4 @@ import * as React from 'react';
5
5
  *
6
6
  * @param children the children
7
7
  */
8
- export default function getValidReactChildren(children: React.ReactNode): React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
8
+ export default function getValidReactChildren(children: React.ReactNode): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>[];
package/index.d.ts CHANGED
@@ -46,4 +46,5 @@ export { default as unstable_useSlotProps } from './useSlotProps';
46
46
  export type { UseSlotPropsParameters, UseSlotPropsResult } from './useSlotProps';
47
47
  export { default as unstable_resolveComponentProps } from './resolveComponentProps';
48
48
  export { default as unstable_extractEventHandlers } from './extractEventHandlers';
49
+ export { default as unstable_getReactElementRef } from './getReactElementRef';
49
50
  export * from './types';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v5.16.5
2
+ * @mui/utils v5.16.8
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -59,7 +59,8 @@ var _exportNames = {
59
59
  clamp: true,
60
60
  unstable_useSlotProps: true,
61
61
  unstable_resolveComponentProps: true,
62
- unstable_extractEventHandlers: true
62
+ unstable_extractEventHandlers: true,
63
+ unstable_getReactElementRef: true
63
64
  };
64
65
  Object.defineProperty(exports, "HTMLElementType", {
65
66
  enumerable: true,
@@ -223,6 +224,12 @@ Object.defineProperty(exports, "unstable_getNormalizedScrollLeft", {
223
224
  return _scrollLeft.getNormalizedScrollLeft;
224
225
  }
225
226
  });
227
+ Object.defineProperty(exports, "unstable_getReactElementRef", {
228
+ enumerable: true,
229
+ get: function () {
230
+ return _getReactElementRef.default;
231
+ }
232
+ });
226
233
  Object.defineProperty(exports, "unstable_getScrollbarSize", {
227
234
  enumerable: true,
228
235
  get: function () {
@@ -404,6 +411,7 @@ var _clamp = _interopRequireDefault(require("./clamp"));
404
411
  var _useSlotProps = _interopRequireDefault(require("./useSlotProps"));
405
412
  var _resolveComponentProps = _interopRequireDefault(require("./resolveComponentProps"));
406
413
  var _extractEventHandlers = _interopRequireDefault(require("./extractEventHandlers"));
414
+ var _getReactElementRef = _interopRequireDefault(require("./getReactElementRef"));
407
415
  var _types = require("./types");
408
416
  Object.keys(_types).forEach(function (key) {
409
417
  if (key === "default" || key === "__esModule") return;
@@ -1,5 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _typeof from "@babel/runtime/helpers/esm/typeof";
3
+ import * as React from 'react';
4
+
3
5
  // https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
4
6
  export function isPlainObject(item) {
5
7
  if (_typeof(item) !== 'object' || item === null) {
@@ -9,7 +11,7 @@ export function isPlainObject(item) {
9
11
  return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in item) && !(Symbol.iterator in item);
10
12
  }
11
13
  function deepClone(source) {
12
- if (!isPlainObject(source)) {
14
+ if ( /*#__PURE__*/React.isValidElement(source) || !isPlainObject(source)) {
13
15
  return source;
14
16
  }
15
17
  var output = {};
@@ -25,7 +27,9 @@ export default function deepmerge(target, source) {
25
27
  var output = options.clone ? _extends({}, target) : target;
26
28
  if (isPlainObject(target) && isPlainObject(source)) {
27
29
  Object.keys(source).forEach(function (key) {
28
- if (isPlainObject(source[key]) &&
30
+ if ( /*#__PURE__*/React.isValidElement(source[key])) {
31
+ output[key] = source[key];
32
+ } else if (isPlainObject(source[key]) &&
29
33
  // Avoid prototype pollution
30
34
  Object.prototype.hasOwnProperty.call(target, key) && isPlainObject(target[key])) {
31
35
  // Since `output` is a clone of `target` and we have narrowed `target` in this block we can cast to the same type.
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * Returns the ref of a React element handling differences between React 19 and older versions.
5
+ * It will throw runtime error if the element is not a valid React element.
6
+ *
7
+ * @param element React.ReactElement
8
+ * @returns React.Ref<any> | null
9
+ */
10
+ export default function getReactElementRef(element) {
11
+ // 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
12
+ if (parseInt(React.version, 10) >= 19) {
13
+ var _element$props;
14
+ return (element == null || (_element$props = element.props) == null ? void 0 : _element$props.ref) || null;
15
+ }
16
+ // @ts-expect-error element.ref is not included in the ReactElement type
17
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/70189
18
+ return (element == null ? void 0 : element.ref) || null;
19
+ }
@@ -0,0 +1 @@
1
+ export { default } from './getReactElementRef';
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v5.16.5
2
+ * @mui/utils v5.16.8
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -52,4 +52,5 @@ export { default as clamp } from './clamp';
52
52
  export { default as unstable_useSlotProps } from './useSlotProps';
53
53
  export { default as unstable_resolveComponentProps } from './resolveComponentProps';
54
54
  export { default as unstable_extractEventHandlers } from './extractEventHandlers';
55
+ export { default as unstable_getReactElementRef } from './getReactElementRef';
55
56
  export * from './types';
@@ -1,4 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+
2
4
  // https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
3
5
  export function isPlainObject(item) {
4
6
  if (typeof item !== 'object' || item === null) {
@@ -8,7 +10,7 @@ export function isPlainObject(item) {
8
10
  return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in item) && !(Symbol.iterator in item);
9
11
  }
10
12
  function deepClone(source) {
11
- if (!isPlainObject(source)) {
13
+ if ( /*#__PURE__*/React.isValidElement(source) || !isPlainObject(source)) {
12
14
  return source;
13
15
  }
14
16
  const output = {};
@@ -23,7 +25,9 @@ export default function deepmerge(target, source, options = {
23
25
  const output = options.clone ? _extends({}, target) : target;
24
26
  if (isPlainObject(target) && isPlainObject(source)) {
25
27
  Object.keys(source).forEach(key => {
26
- if (isPlainObject(source[key]) &&
28
+ if ( /*#__PURE__*/React.isValidElement(source[key])) {
29
+ output[key] = source[key];
30
+ } else if (isPlainObject(source[key]) &&
27
31
  // Avoid prototype pollution
28
32
  Object.prototype.hasOwnProperty.call(target, key) && isPlainObject(target[key])) {
29
33
  // Since `output` is a clone of `target` and we have narrowed `target` in this block we can cast to the same type.
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * Returns the ref of a React element handling differences between React 19 and older versions.
5
+ * It will throw runtime error if the element is not a valid React element.
6
+ *
7
+ * @param element React.ReactElement
8
+ * @returns React.Ref<any> | null
9
+ */
10
+ export default function getReactElementRef(element) {
11
+ // 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
12
+ if (parseInt(React.version, 10) >= 19) {
13
+ return element?.props?.ref || null;
14
+ }
15
+ // @ts-expect-error element.ref is not included in the ReactElement type
16
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/70189
17
+ return element?.ref || null;
18
+ }
@@ -0,0 +1 @@
1
+ export { default } from './getReactElementRef';
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v5.16.5
2
+ * @mui/utils v5.16.8
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -52,4 +52,5 @@ export { default as clamp } from './clamp';
52
52
  export { default as unstable_useSlotProps } from './useSlotProps';
53
53
  export { default as unstable_resolveComponentProps } from './resolveComponentProps';
54
54
  export { default as unstable_extractEventHandlers } from './extractEventHandlers';
55
+ export { default as unstable_getReactElementRef } from './getReactElementRef';
55
56
  export * from './types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/utils",
3
- "version": "5.16.5",
3
+ "version": "5.16.8",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "Utility functions for React components.",
@@ -34,8 +34,8 @@
34
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": {