@mui/utils 7.3.10 → 7.3.11

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,40 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 7.3.11
4
+
5
+ <!-- generated comparing v7.3.10..v7.x -->
6
+
7
+ _May 6, 2026_
8
+
9
+ A big thanks to the 5 contributors who made this release possible.
10
+
11
+ ### `@mui/material@7.3.11`
12
+
13
+ - [autocomplete] Fix highlight sync and scroll preservation (#48350) @mj12albert
14
+ - [autocomplete] Fix popper rendering issues (#48343) @mj12albert
15
+ - [autocomplete] Improve highlight tracking and selection state (#48318) @mj12albert
16
+ - [button] Fix `startIcon` alignment (#48339) @mj12albert
17
+ - [button] Remove duplicated className entries (#48284) @silviuaavram
18
+ - [checkbox] Set `aria-checked=mixed` when indeterminate (#48286) @mj12albert
19
+ - [dialog][drawer][focus trap] Fix initial focus target (#48324) @mj12albert
20
+ - [drawer] Fix transition jump (#48340) @mj12albert
21
+ - [input] Fix layout shift with display: flex (#48359) @oliviertassinari
22
+ - [inputs] Fix autofocus in SSR environment (#48307) @mj12albert
23
+ - [popper] Persist positioning styles when popperOptions changes reference (#48302) @mj12albert
24
+ - [switch] Fix incorrect `role` with `slotProps.input` (#48472) @mj12albert
25
+ - [utils] Add shadow dom utils (#48309) @mj12albert
26
+
27
+ ### Docs
28
+
29
+ - [docs] Update banner to announce v9 (#48299) @siriwatknp
30
+ - [docs] Add v9 in the versions select in v7.mui.com (#48233) @alexfauquette
31
+
32
+ ### Core
33
+
34
+ - [internal] Update some host-reference entries (#48225) @silviuaavram
35
+
36
+ All contributors of this release in alphabetical order: @alexfauquette, @mj12albert, @oliviertassinari, @silviuaavram, @siriwatknp
37
+
3
38
  ## 7.3.10
4
39
 
5
40
  <!-- generated comparing v7.3.9..v7.x -->
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copied from @base-ui/utils
3
+ *
4
+ * Shadow DOM-aware containment check.
5
+ *
6
+ * Native `parent.contains(child)` returns `false` when the child is inside a
7
+ * shadow root that is a descendant of the parent. This function handles that
8
+ * case by traversing up through shadow root hosts.
9
+ *
10
+ * @param parent - The potential ancestor element.
11
+ * @param child - The potential descendant element.
12
+ * @returns Whether `parent` contains `child`, even across shadow root boundaries.
13
+ */
14
+ export default function contains(parent: Element | null | undefined, child: Element | null | undefined): boolean;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = contains;
7
+ /**
8
+ * Copied from @base-ui/utils
9
+ *
10
+ * Shadow DOM-aware containment check.
11
+ *
12
+ * Native `parent.contains(child)` returns `false` when the child is inside a
13
+ * shadow root that is a descendant of the parent. This function handles that
14
+ * case by traversing up through shadow root hosts.
15
+ *
16
+ * @param parent - The potential ancestor element.
17
+ * @param child - The potential descendant element.
18
+ * @returns Whether `parent` contains `child`, even across shadow root boundaries.
19
+ */
20
+ function contains(parent, child) {
21
+ if (!parent || !child) {
22
+ return false;
23
+ }
24
+
25
+ // First, attempt with the faster native method.
26
+ if (parent.contains(child)) {
27
+ return true;
28
+ }
29
+
30
+ // Then fall back to traversing out of shadow roots when needed.
31
+ const rootNode = child.getRootNode?.();
32
+ if (rootNode && rootNode instanceof ShadowRoot) {
33
+ let next = child;
34
+ while (next) {
35
+ if (parent === next) {
36
+ return true;
37
+ }
38
+ next = next.parentNode ?? next.host ?? null;
39
+ }
40
+ }
41
+ return false;
42
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./contains.js";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _contains.default;
11
+ }
12
+ });
13
+ var _contains = _interopRequireDefault(require("./contains"));
@@ -44,8 +44,10 @@ function elementTypeAcceptingRef(props, propName, componentName, location, propF
44
44
  if (propValue === React.Fragment) {
45
45
  warningHint = 'Did you accidentally provide a React.Fragment instead?';
46
46
  }
47
+
48
+ // #host-reference
47
49
  if (warningHint !== undefined) {
48
- return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an element type that can hold a ref. ${warningHint} ` + 'For more information see https://mui.com/r/caveat-with-refs-guide');
50
+ return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an element type that can hold a ref. ${warningHint} ` + 'For more information see https://v7.mui.com/r/caveat-with-refs-guide');
49
51
  }
50
52
  return null;
51
53
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copied from @base-ui/utils
3
+ *
4
+ * Shadow DOM-aware containment check.
5
+ *
6
+ * Native `parent.contains(child)` returns `false` when the child is inside a
7
+ * shadow root that is a descendant of the parent. This function handles that
8
+ * case by traversing up through shadow root hosts.
9
+ *
10
+ * @param parent - The potential ancestor element.
11
+ * @param child - The potential descendant element.
12
+ * @returns Whether `parent` contains `child`, even across shadow root boundaries.
13
+ */
14
+ export default function contains(parent: Element | null | undefined, child: Element | null | undefined): boolean;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copied from @base-ui/utils
3
+ *
4
+ * Shadow DOM-aware containment check.
5
+ *
6
+ * Native `parent.contains(child)` returns `false` when the child is inside a
7
+ * shadow root that is a descendant of the parent. This function handles that
8
+ * case by traversing up through shadow root hosts.
9
+ *
10
+ * @param parent - The potential ancestor element.
11
+ * @param child - The potential descendant element.
12
+ * @returns Whether `parent` contains `child`, even across shadow root boundaries.
13
+ */
14
+ export default function contains(parent, child) {
15
+ if (!parent || !child) {
16
+ return false;
17
+ }
18
+
19
+ // First, attempt with the faster native method.
20
+ if (parent.contains(child)) {
21
+ return true;
22
+ }
23
+
24
+ // Then fall back to traversing out of shadow roots when needed.
25
+ const rootNode = child.getRootNode?.();
26
+ if (rootNode && rootNode instanceof ShadowRoot) {
27
+ let next = child;
28
+ while (next) {
29
+ if (parent === next) {
30
+ return true;
31
+ }
32
+ next = next.parentNode ?? next.host ?? null;
33
+ }
34
+ }
35
+ return false;
36
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./contains.js";
@@ -0,0 +1 @@
1
+ export { default } from "./contains.js";
@@ -36,8 +36,10 @@ function elementTypeAcceptingRef(props, propName, componentName, location, propF
36
36
  if (propValue === React.Fragment) {
37
37
  warningHint = 'Did you accidentally provide a React.Fragment instead?';
38
38
  }
39
+
40
+ // #host-reference
39
41
  if (warningHint !== undefined) {
40
- return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an element type that can hold a ref. ${warningHint} ` + 'For more information see https://mui.com/r/caveat-with-refs-guide');
42
+ return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an element type that can hold a ref. ${warningHint} ` + 'For more information see https://v7.mui.com/r/caveat-with-refs-guide');
41
43
  }
42
44
  return null;
43
45
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copied from @base-ui/utils
3
+ *
4
+ * Gets the actual target of an event, using `composedPath()` to traverse
5
+ * shadow DOM boundaries.
6
+ *
7
+ * In shadow DOM, `event.target` may return the shadow host rather than the
8
+ * actual element that triggered the event. `composedPath()[0]` returns the
9
+ * true originating element.
10
+ *
11
+ * @param event - The event to get the target from.
12
+ * @returns The actual event target, or `null` if not available.
13
+ */
14
+ export default function getEventTarget(event: Event): EventTarget | null;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copied from @base-ui/utils
3
+ *
4
+ * Gets the actual target of an event, using `composedPath()` to traverse
5
+ * shadow DOM boundaries.
6
+ *
7
+ * In shadow DOM, `event.target` may return the shadow host rather than the
8
+ * actual element that triggered the event. `composedPath()[0]` returns the
9
+ * true originating element.
10
+ *
11
+ * @param event - The event to get the target from.
12
+ * @returns The actual event target, or `null` if not available.
13
+ */
14
+ export default function getEventTarget(event) {
15
+ return event.composedPath?.()[0] ?? event.target;
16
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./getEventTarget.js";
@@ -0,0 +1 @@
1
+ export { default } from "./getEventTarget.js";
package/esm/index.d.ts CHANGED
@@ -5,7 +5,9 @@ export { default as elementAcceptingRef } from "./elementAcceptingRef/index.js";
5
5
  export { default as elementTypeAcceptingRef } from "./elementTypeAcceptingRef/index.js";
6
6
  export { default as exactProp } from "./exactProp/index.js";
7
7
  export { default as formatMuiErrorMessage } from "./formatMuiErrorMessage/index.js";
8
+ export { default as unstable_contains } from "./contains/index.js";
8
9
  export { default as unstable_getActiveElement } from "./getActiveElement/index.js";
10
+ export { default as unstable_getEventTarget } from "./getEventTarget/index.js";
9
11
  export { default as getDisplayName } from "./getDisplayName/index.js";
10
12
  export { default as HTMLElementType } from "./HTMLElementType/index.js";
11
13
  export { default as ponyfillGlobal } from "./ponyfillGlobal/index.js";
@@ -29,6 +31,7 @@ export { default as unstable_useLazyRef } from "./useLazyRef/index.js";
29
31
  export { default as unstable_useTimeout, Timeout as unstable_Timeout } from "./useTimeout/index.js";
30
32
  export { default as unstable_useOnMount } from "./useOnMount/index.js";
31
33
  export { default as unstable_useIsFocusVisible } from "./useIsFocusVisible/index.js";
34
+ export { default as unstable_useForcedRerendering } from "./useForcedRerendering/index.js";
32
35
  export { default as unstable_isFocusVisible } from "./isFocusVisible/index.js";
33
36
  export { default as unstable_getScrollbarSize } from "./getScrollbarSize/index.js";
34
37
  export { default as usePreviousProps } from "./usePreviousProps/index.js";
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v7.3.10
2
+ * @mui/utils v7.3.11
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -12,7 +12,9 @@ export { default as elementAcceptingRef } from "./elementAcceptingRef/index.js";
12
12
  export { default as elementTypeAcceptingRef } from "./elementTypeAcceptingRef/index.js";
13
13
  export { default as exactProp } from "./exactProp/index.js";
14
14
  export { default as formatMuiErrorMessage } from "./formatMuiErrorMessage/index.js";
15
+ export { default as unstable_contains } from "./contains/index.js";
15
16
  export { default as unstable_getActiveElement } from "./getActiveElement/index.js";
17
+ export { default as unstable_getEventTarget } from "./getEventTarget/index.js";
16
18
  export { default as getDisplayName } from "./getDisplayName/index.js";
17
19
  export { default as HTMLElementType } from "./HTMLElementType/index.js";
18
20
  export { default as ponyfillGlobal } from "./ponyfillGlobal/index.js";
@@ -36,6 +38,7 @@ export { default as unstable_useLazyRef } from "./useLazyRef/index.js";
36
38
  export { default as unstable_useTimeout, Timeout as unstable_Timeout } from "./useTimeout/index.js";
37
39
  export { default as unstable_useOnMount } from "./useOnMount/index.js";
38
40
  export { default as unstable_useIsFocusVisible } from "./useIsFocusVisible/index.js";
41
+ export { default as unstable_useForcedRerendering } from "./useForcedRerendering/index.js";
39
42
  export { default as unstable_isFocusVisible } from "./isFocusVisible/index.js";
40
43
  export { default as unstable_getScrollbarSize } from "./getScrollbarSize/index.js";
41
44
  export { default as usePreviousProps } from "./usePreviousProps/index.js";
@@ -0,0 +1 @@
1
+ export { default } from "./useForcedRerendering.js";
@@ -0,0 +1 @@
1
+ export { default } from "./useForcedRerendering.js";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copied from @base-ui/utils
3
+ *
4
+ * Returns a function that forces a rerender.
5
+ */
6
+ export default function useForcedRerendering(): () => void;
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+
5
+ /**
6
+ * Copied from @base-ui/utils
7
+ *
8
+ * Returns a function that forces a rerender.
9
+ */
10
+ export default function useForcedRerendering() {
11
+ const [, setState] = React.useState({});
12
+ return React.useCallback(() => {
13
+ setState({});
14
+ }, []);
15
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copied from @base-ui/utils
3
+ *
4
+ * Gets the actual target of an event, using `composedPath()` to traverse
5
+ * shadow DOM boundaries.
6
+ *
7
+ * In shadow DOM, `event.target` may return the shadow host rather than the
8
+ * actual element that triggered the event. `composedPath()[0]` returns the
9
+ * true originating element.
10
+ *
11
+ * @param event - The event to get the target from.
12
+ * @returns The actual event target, or `null` if not available.
13
+ */
14
+ export default function getEventTarget(event: Event): EventTarget | null;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = getEventTarget;
7
+ /**
8
+ * Copied from @base-ui/utils
9
+ *
10
+ * Gets the actual target of an event, using `composedPath()` to traverse
11
+ * shadow DOM boundaries.
12
+ *
13
+ * In shadow DOM, `event.target` may return the shadow host rather than the
14
+ * actual element that triggered the event. `composedPath()[0]` returns the
15
+ * true originating element.
16
+ *
17
+ * @param event - The event to get the target from.
18
+ * @returns The actual event target, or `null` if not available.
19
+ */
20
+ function getEventTarget(event) {
21
+ return event.composedPath?.()[0] ?? event.target;
22
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./getEventTarget.js";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _getEventTarget.default;
11
+ }
12
+ });
13
+ var _getEventTarget = _interopRequireDefault(require("./getEventTarget"));
package/index.d.ts CHANGED
@@ -5,7 +5,9 @@ export { default as elementAcceptingRef } from "./elementAcceptingRef/index.js";
5
5
  export { default as elementTypeAcceptingRef } from "./elementTypeAcceptingRef/index.js";
6
6
  export { default as exactProp } from "./exactProp/index.js";
7
7
  export { default as formatMuiErrorMessage } from "./formatMuiErrorMessage/index.js";
8
+ export { default as unstable_contains } from "./contains/index.js";
8
9
  export { default as unstable_getActiveElement } from "./getActiveElement/index.js";
10
+ export { default as unstable_getEventTarget } from "./getEventTarget/index.js";
9
11
  export { default as getDisplayName } from "./getDisplayName/index.js";
10
12
  export { default as HTMLElementType } from "./HTMLElementType/index.js";
11
13
  export { default as ponyfillGlobal } from "./ponyfillGlobal/index.js";
@@ -29,6 +31,7 @@ export { default as unstable_useLazyRef } from "./useLazyRef/index.js";
29
31
  export { default as unstable_useTimeout, Timeout as unstable_Timeout } from "./useTimeout/index.js";
30
32
  export { default as unstable_useOnMount } from "./useOnMount/index.js";
31
33
  export { default as unstable_useIsFocusVisible } from "./useIsFocusVisible/index.js";
34
+ export { default as unstable_useForcedRerendering } from "./useForcedRerendering/index.js";
32
35
  export { default as unstable_isFocusVisible } from "./isFocusVisible/index.js";
33
36
  export { default as unstable_getScrollbarSize } from "./getScrollbarSize/index.js";
34
37
  export { default as usePreviousProps } from "./usePreviousProps/index.js";
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v7.3.10
2
+ * @mui/utils v7.3.11
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -20,7 +20,9 @@ var _exportNames = {
20
20
  elementTypeAcceptingRef: true,
21
21
  exactProp: true,
22
22
  formatMuiErrorMessage: true,
23
+ unstable_contains: true,
23
24
  unstable_getActiveElement: true,
25
+ unstable_getEventTarget: true,
24
26
  getDisplayName: true,
25
27
  HTMLElementType: true,
26
28
  ponyfillGlobal: true,
@@ -45,6 +47,7 @@ var _exportNames = {
45
47
  unstable_Timeout: true,
46
48
  unstable_useOnMount: true,
47
49
  unstable_useIsFocusVisible: true,
50
+ unstable_useForcedRerendering: true,
48
51
  unstable_isFocusVisible: true,
49
52
  unstable_getScrollbarSize: true,
50
53
  usePreviousProps: true,
@@ -178,6 +181,12 @@ Object.defineProperty(exports, "unstable_composeClasses", {
178
181
  return _composeClasses.default;
179
182
  }
180
183
  });
184
+ Object.defineProperty(exports, "unstable_contains", {
185
+ enumerable: true,
186
+ get: function () {
187
+ return _contains.default;
188
+ }
189
+ });
181
190
  Object.defineProperty(exports, "unstable_createChainedFunction", {
182
191
  enumerable: true,
183
192
  get: function () {
@@ -220,6 +229,12 @@ Object.defineProperty(exports, "unstable_getActiveElement", {
220
229
  return _getActiveElement.default;
221
230
  }
222
231
  });
232
+ Object.defineProperty(exports, "unstable_getEventTarget", {
233
+ enumerable: true,
234
+ get: function () {
235
+ return _getEventTarget.default;
236
+ }
237
+ });
223
238
  Object.defineProperty(exports, "unstable_getReactElementRef", {
224
239
  enumerable: true,
225
240
  get: function () {
@@ -310,6 +325,12 @@ Object.defineProperty(exports, "unstable_useEventCallback", {
310
325
  return _useEventCallback.default;
311
326
  }
312
327
  });
328
+ Object.defineProperty(exports, "unstable_useForcedRerendering", {
329
+ enumerable: true,
330
+ get: function () {
331
+ return _useForcedRerendering.default;
332
+ }
333
+ });
313
334
  Object.defineProperty(exports, "unstable_useForkRef", {
314
335
  enumerable: true,
315
336
  get: function () {
@@ -370,7 +391,9 @@ var _elementAcceptingRef = _interopRequireDefault(require("./elementAcceptingRef
370
391
  var _elementTypeAcceptingRef = _interopRequireDefault(require("./elementTypeAcceptingRef"));
371
392
  var _exactProp = _interopRequireDefault(require("./exactProp"));
372
393
  var _formatMuiErrorMessage = _interopRequireDefault(require("./formatMuiErrorMessage"));
394
+ var _contains = _interopRequireDefault(require("./contains"));
373
395
  var _getActiveElement = _interopRequireDefault(require("./getActiveElement"));
396
+ var _getEventTarget = _interopRequireDefault(require("./getEventTarget"));
374
397
  var _getDisplayName = _interopRequireDefault(require("./getDisplayName"));
375
398
  var _HTMLElementType = _interopRequireDefault(require("./HTMLElementType"));
376
399
  var _ponyfillGlobal = _interopRequireDefault(require("./ponyfillGlobal"));
@@ -394,6 +417,7 @@ var _useLazyRef = _interopRequireDefault(require("./useLazyRef"));
394
417
  var _useTimeout = _interopRequireWildcard(require("./useTimeout"));
395
418
  var _useOnMount = _interopRequireDefault(require("./useOnMount"));
396
419
  var _useIsFocusVisible = _interopRequireDefault(require("./useIsFocusVisible"));
420
+ var _useForcedRerendering = _interopRequireDefault(require("./useForcedRerendering"));
397
421
  var _isFocusVisible = _interopRequireDefault(require("./isFocusVisible"));
398
422
  var _getScrollbarSize = _interopRequireDefault(require("./getScrollbarSize"));
399
423
  var _usePreviousProps = _interopRequireDefault(require("./usePreviousProps"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/utils",
3
- "version": "7.3.10",
3
+ "version": "7.3.11",
4
4
  "author": "MUI Team",
5
5
  "description": "Utility functions for React components.",
6
6
  "keywords": [
@@ -0,0 +1 @@
1
+ export { default } from "./useForcedRerendering.js";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _useForcedRerendering.default;
11
+ }
12
+ });
13
+ var _useForcedRerendering = _interopRequireDefault(require("./useForcedRerendering"));
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copied from @base-ui/utils
3
+ *
4
+ * Returns a function that forces a rerender.
5
+ */
6
+ export default function useForcedRerendering(): () => void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = useForcedRerendering;
9
+ var React = _interopRequireWildcard(require("react"));
10
+ /**
11
+ * Copied from @base-ui/utils
12
+ *
13
+ * Returns a function that forces a rerender.
14
+ */
15
+ function useForcedRerendering() {
16
+ const [, setState] = React.useState({});
17
+ return React.useCallback(() => {
18
+ setState({});
19
+ }, []);
20
+ }