@mui/utils 6.1.1 → 6.1.2

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,67 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## v6.1.2
4
+
5
+ <!-- generated comparing v6.1.1..master -->
6
+
7
+ _Oct 2, 2024_
8
+
9
+ A big thanks to the 13 contributors who made this release possible.
10
+
11
+ ### `@mui/material@6.1.2`
12
+
13
+ - [Modal] Remove unnecessary `manager` prop handling (#43867) @ZeeshanTamboli
14
+ - [Autocomplete] Fix listbox opens and closes on click when used with `limitTags` (#42494) @appleSimple
15
+ - [Button] Ignore `dark` and `contrastText` if not provided in the theme (#43861) @siriwatknp
16
+ - [Button] Fix regression for color `inherit` (#43862) @siriwatknp
17
+ - [LinearProgress] Fix background color (#43949) @sai6855
18
+ - Support CSS variables with shadow DOM (#43948) @siriwatknp
19
+ - Improve getReactElementRef() utils (#43022) @sai6855
20
+ - [Modal] Replace `show` parameter name with `hide` in modal manager (#43868) @ZeeshanTamboli
21
+ - [Rating] Use Rating `name` as prefix of input element ids (#43829) @yash49
22
+ - [Drawer] Refactor getScrollbarSize usages (#43828) @BrianWoolfolk
23
+ - [Drawer] Fix issue with main window being used instead of iframe's window (#43818) @albarv340
24
+ - [ThemeProvider] Support setting default mode (#43951) @siriwatknp
25
+
26
+ ### Docs
27
+
28
+ - Update theme toggle demo (#43956) @Janpot
29
+ - Add note about minimum required webpack version (#43864) @Janpot
30
+ - Format Pigment CSS docs (#43812) @oliviertassinari
31
+ - Fix visual bug on dashboard template (#43836) @oliviertassinari
32
+ - Fix pigment-css.md syntax error (#43837) @kdichev
33
+ - Fix Sign-in template form experience (#43838) @oliviertassinari
34
+ - Remove "To be continued" section from v0 –> v1 migration guide (#43832) @samuelsycamore
35
+ - Fix 301 to chromium (#43809) @oliviertassinari
36
+ - [joy-ui] Add missing ComponentLinkHeader components (#43865) @samuelsycamore
37
+ - [Modal] Remove unnecessary type assertion (#43825) @ZeeshanTamboli
38
+ - [Table] Stabilize random series in virtualized table demo (#43744) @Janpot
39
+ - [system] Add migration guide link to `@mui/styles` pages (#43833) @samuelsycamore
40
+
41
+ ### Core
42
+
43
+ - [code-infra] Fix flaky dashboard screenshot - take 2 (#43937) @Janpot
44
+ - [code-infra] Replace all instances of `e` with `event` and add eslint rule (#43866) @samuelsycamore
45
+ - [code-infra] Fix and update bundling fixtures (#43709) @Janpot
46
+ - [code-infra] Update transitive dependencies with vulnerabilties (#43895) @Janpot
47
+ - [code-infra] Optimize regression tests (#43889) @Janpot
48
+ - [code-infra] Remove custom playwright installation steps (#43881) @Janpot
49
+ - [code-infra] Fix flaky dashboard screenshot (#43890) @Janpot
50
+ - [code-infra] Add new instanceof proptypes for toolpad (#43814) @Janpot
51
+ - Fix eslint-plugin-react-compiler issues in usePagination tests (#43946) @wilhelmlofsten
52
+ - Uniformity in version range @oliviertassinari
53
+ - Replace `toBeAriaHidden` matcher with `toBeInaccessible` in tests (#43870) @ZeeshanTamboli
54
+ - [docs-infra] Strengthen CSP (#43711) @oliviertassinari
55
+ - [docs-infra] Open Codesandbox demo with fontsize=12 (#43860) @siriwatknp
56
+ - [icons] Reduce Material Icon page size (#43911) @oliviertassinari
57
+ - [test] Point Istanbul to correct URL (#43935) @sai6855
58
+ - [test] Sync React.version parse logic with codebase (#43820) @oliviertassinari
59
+ - [website] Add 'Row spanning' (#43831) @oliviertassinari
60
+ - [website] Improve Next roles section (#43822) @oliviertassinari
61
+ - [website] Open the xCharts, eXplore and X general react engineer roles (#43805) @DanailH
62
+
63
+ All contributors of this release in alphabetical order: @albarv340, @appleSimple, @BrianWoolfolk, @DanailH, @Janpot, @kdichev, @oliviertassinari, @sai6855, @samuelsycamore, @siriwatknp, @wilhelmlofsten, @yash49, @ZeeshanTamboli
64
+
3
65
  ## v6.1.1
4
66
 
5
67
  <!-- generated comparing v6.1.0..master -->
@@ -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 | undefined
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;
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;
18
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./getReactElementRef.js";
@@ -1,7 +1,7 @@
1
1
  // A change of the browser zoom change the scrollbar size.
2
2
  // Credit https://github.com/twbs/bootstrap/blob/488fd8afc535ca3a6ad4dc581f5e89217b6a36ac/js/src/util/scrollbar.js#L14-L18
3
- export default function getScrollbarSize(doc) {
3
+ export default function getScrollbarSize(win = window) {
4
4
  // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
5
- const documentWidth = doc.documentElement.clientWidth;
6
- return Math.abs(window.innerWidth - documentWidth);
5
+ const documentWidth = win.document.documentElement.clientWidth;
6
+ return win.innerWidth - documentWidth;
7
7
  }
package/esm/index.js CHANGED
@@ -44,5 +44,5 @@ export { default as clamp } from "./clamp/index.js";
44
44
  export { default as unstable_useSlotProps } from "./useSlotProps/index.js";
45
45
  export { default as unstable_resolveComponentProps } from "./resolveComponentProps/index.js";
46
46
  export { default as unstable_extractEventHandlers } from "./extractEventHandlers/index.js";
47
- export { default as unstable_getReactNodeRef } from "./getReactNodeRef/index.js";
47
+ export { default as unstable_getReactElementRef } from "./getReactElementRef/index.js";
48
48
  export * from "./types.js";
@@ -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 | undefined
8
+ */
9
+ export default function getReactElementRef(element: React.ReactElement): React.Ref<any> | null | undefined;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = getReactElementRef;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ /**
10
+ * Returns the ref of a React element handling differences between React 19 and older versions.
11
+ * It will throw runtime error if the element is not a valid React element.
12
+ *
13
+ * @param element React.ReactElement
14
+ * @returns React.Ref<any> | null | undefined
15
+ */
16
+ function getReactElementRef(element) {
17
+ // 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
18
+ if (parseInt(React.version, 10) >= 19) {
19
+ return element.props?.ref;
20
+ }
21
+ // @ts-expect-error element.ref is not included in the ReactElement type
22
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/70189
23
+ return element?.ref;
24
+ }
@@ -0,0 +1 @@
1
+ export { default } from './getReactElementRef';
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  Object.defineProperty(exports, "default", {
8
8
  enumerable: true,
9
9
  get: function () {
10
- return _getReactNodeRef.default;
10
+ return _getReactElementRef.default;
11
11
  }
12
12
  });
13
- var _getReactNodeRef = _interopRequireDefault(require("./getReactNodeRef"));
13
+ var _getReactElementRef = _interopRequireDefault(require("./getReactElementRef"));
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "sideEffects": false,
3
- "module": "../esm/getReactNodeRef/index.js",
3
+ "module": "../esm/getReactElementRef/index.js",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts"
6
6
  }
@@ -1 +1 @@
1
- export default function getScrollbarSize(doc: Document): number;
1
+ export default function getScrollbarSize(win?: Window): number;
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = getScrollbarSize;
7
7
  // A change of the browser zoom change the scrollbar size.
8
8
  // Credit https://github.com/twbs/bootstrap/blob/488fd8afc535ca3a6ad4dc581f5e89217b6a36ac/js/src/util/scrollbar.js#L14-L18
9
- function getScrollbarSize(doc) {
9
+ function getScrollbarSize(win = window) {
10
10
  // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
11
- const documentWidth = doc.documentElement.clientWidth;
12
- return Math.abs(window.innerWidth - documentWidth);
11
+ const documentWidth = win.document.documentElement.clientWidth;
12
+ return win.innerWidth - documentWidth;
13
13
  }
package/index.d.ts CHANGED
@@ -45,5 +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
+ export { default as unstable_getReactElementRef } from './getReactElementRef';
49
49
  export * from './types';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v6.1.1
2
+ * @mui/utils v6.1.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -59,7 +59,7 @@ var _exportNames = {
59
59
  unstable_useSlotProps: true,
60
60
  unstable_resolveComponentProps: true,
61
61
  unstable_extractEventHandlers: true,
62
- unstable_getReactNodeRef: true
62
+ unstable_getReactElementRef: true
63
63
  };
64
64
  Object.defineProperty(exports, "HTMLElementType", {
65
65
  enumerable: true,
@@ -211,10 +211,10 @@ Object.defineProperty(exports, "unstable_generateUtilityClasses", {
211
211
  return _generateUtilityClasses.default;
212
212
  }
213
213
  });
214
- Object.defineProperty(exports, "unstable_getReactNodeRef", {
214
+ Object.defineProperty(exports, "unstable_getReactElementRef", {
215
215
  enumerable: true,
216
216
  get: function () {
217
- return _getReactNodeRef.default;
217
+ return _getReactElementRef.default;
218
218
  }
219
219
  });
220
220
  Object.defineProperty(exports, "unstable_getScrollbarSize", {
@@ -397,7 +397,7 @@ var _clamp = _interopRequireDefault(require("./clamp"));
397
397
  var _useSlotProps = _interopRequireDefault(require("./useSlotProps"));
398
398
  var _resolveComponentProps = _interopRequireDefault(require("./resolveComponentProps"));
399
399
  var _extractEventHandlers = _interopRequireDefault(require("./extractEventHandlers"));
400
- var _getReactNodeRef = _interopRequireDefault(require("./getReactNodeRef"));
400
+ var _getReactElementRef = _interopRequireDefault(require("./getReactElementRef"));
401
401
  var _types = require("./types");
402
402
  Object.keys(_types).forEach(function (key) {
403
403
  if (key === "default" || key === "__esModule") return;
@@ -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 | undefined
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;
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;
18
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./getReactElementRef.js";
@@ -1,7 +1,7 @@
1
1
  // A change of the browser zoom change the scrollbar size.
2
2
  // Credit https://github.com/twbs/bootstrap/blob/488fd8afc535ca3a6ad4dc581f5e89217b6a36ac/js/src/util/scrollbar.js#L14-L18
3
- export default function getScrollbarSize(doc) {
3
+ export default function getScrollbarSize(win = window) {
4
4
  // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
5
- const documentWidth = doc.documentElement.clientWidth;
6
- return Math.abs(window.innerWidth - documentWidth);
5
+ const documentWidth = win.document.documentElement.clientWidth;
6
+ return win.innerWidth - documentWidth;
7
7
  }
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v6.1.1
2
+ * @mui/utils v6.1.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -51,5 +51,5 @@ export { default as clamp } from "./clamp/index.js";
51
51
  export { default as unstable_useSlotProps } from "./useSlotProps/index.js";
52
52
  export { default as unstable_resolveComponentProps } from "./resolveComponentProps/index.js";
53
53
  export { default as unstable_extractEventHandlers } from "./extractEventHandlers/index.js";
54
- export { default as unstable_getReactNodeRef } from "./getReactNodeRef/index.js";
54
+ export { default as unstable_getReactElementRef } from "./getReactElementRef/index.js";
55
55
  export * from "./types.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/utils",
3
- "version": "6.1.1",
3
+ "version": "6.1.2",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "Utility functions for React components.",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.25.6",
30
- "@types/prop-types": "^15.7.12",
30
+ "@types/prop-types": "^15.7.13",
31
31
  "clsx": "^2.1.1",
32
32
  "prop-types": "^15.8.1",
33
33
  "react-is": "^18.3.1",
@@ -1,21 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export { default } from "./getReactNodeRef.js";
@@ -1,9 +0,0 @@
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;
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = getReactNodeRef;
8
- var React = _interopRequireWildcard(require("react"));
9
- /**
10
- * Returns the ref of a React node handling differences between React 19 and older versions.
11
- * It will return null if the node is not a valid React element.
12
- *
13
- * @param element React.ReactNode
14
- * @returns React.Ref<any> | null
15
- */
16
- function getReactNodeRef(element) {
17
- if (!element || ! /*#__PURE__*/React.isValidElement(element)) {
18
- return null;
19
- }
20
-
21
- // 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
22
- return element.props.propertyIsEnumerable('ref') ? element.props.ref :
23
- // @ts-expect-error element.ref is not included in the ReactElement type
24
- // We cannot check for it, but isValidElement is true at this point
25
- // https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/70189
26
- element.ref;
27
- }
@@ -1 +0,0 @@
1
- export { default } from './getReactNodeRef';
@@ -1,21 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export { default } from "./getReactNodeRef.js";