@mui/utils 5.1.1 โ†’ 5.2.0

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,87 @@
1
1
  ### [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 5.2.0
4
+
5
+ <!-- generated comparing v5.1.1..master -->
6
+
7
+ _Nov 23, 2021_
8
+
9
+ A big thanks to the 18 contributors who made this release possible. Here are some highlights โœจ:
10
+
11
+ - ๐Ÿงช Created another unstyled component: [TabsUnstyled](https://mui.com/components/tabs/#unstyled) (#29597) @mnajdova.
12
+ - ๐ŸŽ‰ Updated the Material Icons set with the latest changes from Google (#29328) @michaldudak / (#29818) @chao813.
13
+ This update adds 200 new icons and tweaks the appearance of many more.
14
+ With it, we're getting close to having 2000 icons in our set.
15
+ - ๐Ÿ› Fixed bugs and improved the infrastructure and documentation ๐Ÿ“š.
16
+
17
+ ### `@mui/material@5.2.0`
18
+
19
+ - [IconButton] Remove on hover effect when `disableRipple` is set (#29298) @adamfitzgibbon
20
+ - [i18n] Add the amharic language (#29153) @NatiG100
21
+ - [material] Fix types for `variants.style` to accept callbacks (#29610) @mnajdova
22
+ - [Popper] Simplify prop types (#29680) @michaldudak
23
+ - [Select] Include aria-selected=false when option not selected (#29695) @michaldudak
24
+ - [useMediaQuery] Fix crash in Safari < 14 and IE 11 (#29776) @eps1lon
25
+ - [useMediaQuery] Ensure no tearing in React 18 (#28491) @eps1lon
26
+
27
+ ### `@mui/codemod@5.2.0`
28
+
29
+ - [codemod] Fix `jss-to-styled` to support multiple withStyles (#29824) @siriwatknp
30
+
31
+ ### `@mui/icons-material@5.2.0`
32
+
33
+ - [icons] Sync new Google Material Icons (#29818) @chao813
34
+ - [icons] Sync recent Material Icons from Google (#29328) @michaldudak
35
+
36
+ ### `@mui/system@5.2.0`
37
+
38
+ - [Box] Fix `sx` prop runtime issue when used as function (#29830) @mnajdova
39
+ - [system] Fix `sx` throw error when value is `null` or `undefined` (#29756) @siriwatknp
40
+ - [system] Fix minor CssVars issues (#29747) @siriwatknp
41
+
42
+ ### `@mui/styled-engine@5.2.0`
43
+
44
+ - [styled-engine] Fix props inference in styled-engine (#29739) @Janpot
45
+
46
+ ### `@mui/base@5.0.0-alpha.56`
47
+
48
+ - [FormControlUnstyled] `focused` is always false unless explicitly set to `true` @mwilkins91
49
+ - [TabsUnstyled] Introduce new component (#29597) @mnajdova
50
+
51
+ ### `@mui/lab@5.0.0-alpha.56`
52
+
53
+ - [DatePicker][timepicker] Add missing component declarations (#29517) @longzheng
54
+ - [Masonry] exports from root package (#29754) @abhinav-22-tech
55
+ - [pickers] Widen accepted `luxon` version range (#29761) @eps1lon
56
+
57
+ ### Docs
58
+
59
+ - [blog] MUI X v5 blog post (#29590) @DanailH
60
+ - [blog] Polish the Benny Joo joins MUI post (#29697) @oliviertassinari
61
+ - [CHANGELOG] Explain why we do breaking changes @oliviertassinari
62
+ - [core] Update latest issue template for codesandbox CI (#29783) @eps1lon
63
+ - [core] Ensure `@mui/core` is an alias for `@mui/base` (#29762) @eps1lon
64
+ - [docs] Fix broken Next and Previous links (#29711) @scallaway
65
+ - [docs] Add a note that ToggleButton exclusive does not enforce selection (#29812) @mmacu
66
+ - [docs] Update the list of supported locales (#29831) @michaldudak
67
+ - [docs] Update tooltip doc to better define touch action (#29717) @gnowland
68
+ - [website] Standardize the background color from the MUI team photos (#29738) @danilo-leal
69
+ - [website] Add Bharat to the About Us Page (#29714) @bharatkashyap
70
+ - [website] Add about page entry for jan (#29701) @Janpot
71
+ - [website] Adding Prakhar to the about page (#29737) @danilo-leal
72
+
73
+ ### Core
74
+
75
+ - [test] Allow debugging with Chrome and VSCode inspector (#29777) @eps1lon
76
+ - [test] Use renderer clock instead of custom useFakeTimers call (#29778) @eps1lon
77
+ - [test] Only mock Date in regression tests (#29763) @eps1lon
78
+ - [test] Disable nightly integration tests on `next` branch (#29748) @eps1lon
79
+ - [test] Allow configuring clock directly from `createRenderer` (#29684) @eps1lon
80
+ - [test] Accept backslashes as path separators in test CLI (#29694) @michaldudak
81
+ - [utils] Use built-in hook when available for useId (#26489) @eps1lon
82
+
83
+ All contributors of this release in alphabetical order: @abhinav-22-tech, @adamfitzgibbon, @bharatkashyap, @chao813, @DanailH, @danilo-leal, @eps1lon, @gnowland, @Janpot, @longzheng, @michaldudak, @mmacu, @mnajdova, @mwilkins91, @NatiG100, @oliviertassinari, @scallaway, @siriwatknp
84
+
3
85
  ## 5.1.1
4
86
 
5
87
  <!-- generated comparing v5.1.0..master -->
@@ -8,7 +90,7 @@ _Nov 16, 2021_
8
90
 
9
91
  A big thanks to the 15 contributors who made this release possible. Here are some highlights โœจ:
10
92
 
11
- - ๐Ÿ›  Rename `@mui/core` to `@mui/base`. (#29585) @michaldudak
93
+ - ๐Ÿ›  Renamed `@mui/core` to `@mui/base` (#29585) @michaldudak.
12
94
  - And many more ๐Ÿ› bug fixes and ๐Ÿ“š improvements.
13
95
 
14
96
  ### `@mui/material@5.1.1`
@@ -22,10 +104,19 @@ A big thanks to the 15 contributors who made this release possible. Here are som
22
104
 
23
105
  ### `@mui/base@5.0.0-alpha.55`
24
106
 
25
- #### BREAKING CHANGE
107
+ #### Breaking changes
26
108
 
27
109
  - &#8203;<!-- 27 -->[core] Rename mui/core to mui/base (#29585) @michaldudak
28
110
 
111
+ Based on the results of the [poll](https://twitter.com/michaldudak/status/1452630484706635779) and our internal discussions, we decided to rename the `@mui/core` package to `@mui/base`. The main rationale for this is the fact that we use the term "Core" to refer to the core components product family, the one that includes Material Design components, unstyled components, System utilities, etc. Therefore, @mui/core was effectively a subset of MUI Core. This was confusing.
112
+
113
+ The new name better reflects the purpose of the package: it contains unstyled components, hooks, and utilities that serve as a **base** to build on.
114
+
115
+ ```diff
116
+ -importย { useSwitch } from '@mui/core/SwitchUnstyled';
117
+ +importย { useSwitch } from '@mui/base/SwitchUnstyled';
118
+ ```
119
+
29
120
  ### `@mui/lab@5.0.0-alpha.55`
30
121
 
31
122
  - &#8203;<!-- 12 -->[LoadingButton] Text variant spacing fixed for both start and end (#29194) @joshua-lawrence
@@ -1,3 +1,3 @@
1
- export default function HTMLElementType(props: {
2
- [key: string]: unknown;
3
- }, propName: string, componentName: string, location: string, propFullName: string): Error | null;
1
+ export default function HTMLElementType(props: {
2
+ [key: string]: unknown;
3
+ }, propName: string, componentName: string, location: string, propFullName: string): Error | null;
@@ -1,2 +1,2 @@
1
- import PropTypes from 'prop-types';
2
- export default function chainPropTypes<A, B>(propType1: PropTypes.Validator<A>, propType2: PropTypes.Validator<B>): PropTypes.Validator<A & B>;
1
+ import PropTypes from 'prop-types';
2
+ export default function chainPropTypes<A, B>(propType1: PropTypes.Validator<A>, propType2: PropTypes.Validator<B>): PropTypes.Validator<A & B>;
@@ -1,7 +1,7 @@
1
- /**
2
- * Safe chained function.
3
- *
4
- * Will only create a new function if needed,
5
- * otherwise will pass back existing functions or null.
6
- */
7
- export default function createChainedFunction<Args extends any[], This>(...funcs: Array<(this: This, ...args: Args) => any>): (this: This, ...args: Args) => void;
1
+ /**
2
+ * Safe chained function.
3
+ *
4
+ * Will only create a new function if needed,
5
+ * otherwise will pass back existing functions or null.
6
+ */
7
+ export default function createChainedFunction<Args extends any[], This>(...funcs: Array<(this: This, ...args: Args) => any>): (this: This, ...args: Args) => void;
package/deepmerge.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export declare function isPlainObject(item: unknown): item is Record<keyof any, unknown>;
2
- export interface DeepmergeOptions {
3
- clone?: boolean;
4
- }
5
- export default function deepmerge<T>(target: T, source: unknown, options?: DeepmergeOptions): T;
1
+ export declare function isPlainObject(item: unknown): item is Record<keyof any, unknown>;
2
+ export interface DeepmergeOptions {
3
+ clone?: boolean;
4
+ }
5
+ export default function deepmerge<T>(target: T, source: unknown, options?: DeepmergeOptions): T;
package/deepmerge.js CHANGED
@@ -11,9 +11,7 @@ exports.isPlainObject = isPlainObject;
11
11
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
12
 
13
13
  function isPlainObject(item) {
14
- return item !== null && typeof item === 'object' && // TS thinks `item is possibly null` even though this was our first guard.
15
- // @ts-expect-error
16
- item.constructor === Object;
14
+ return item !== null && typeof item === 'object' && item.constructor === Object;
17
15
  }
18
16
 
19
17
  function deepmerge(target, source, options = {
@@ -1,3 +1,3 @@
1
- import PropTypes from 'prop-types';
2
- declare const elementAcceptingRef: PropTypes.Requireable<unknown>;
3
- export default elementAcceptingRef;
1
+ import PropTypes from 'prop-types';
2
+ declare const elementAcceptingRef: PropTypes.Requireable<unknown>;
3
+ export default elementAcceptingRef;
@@ -1,3 +1,3 @@
1
- import PropTypes from 'prop-types';
2
- declare const _default: PropTypes.Validator<PropTypes.ReactComponentLike | null | undefined>;
3
- export default _default;
1
+ import PropTypes from 'prop-types';
2
+ declare const _default: PropTypes.Validator<PropTypes.ReactComponentLike | null | undefined>;
3
+ export default _default;
package/esm/deepmerge.js CHANGED
@@ -1,8 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  export function isPlainObject(item) {
3
- return item !== null && typeof item === 'object' && // TS thinks `item is possibly null` even though this was our first guard.
4
- // @ts-expect-error
5
- item.constructor === Object;
3
+ return item !== null && typeof item === 'object' && item.constructor === Object;
6
4
  }
7
5
  export default function deepmerge(target, source, options = {
8
6
  clone: true
package/esm/useId.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
- export default function useId(idOverride) {
2
+
3
+ function useRandomId(idOverride) {
3
4
  const [defaultId, setDefaultId] = React.useState(idOverride);
4
5
  const id = idOverride || defaultId;
5
6
  React.useEffect(() => {
@@ -11,4 +12,22 @@ export default function useId(idOverride) {
11
12
  }
12
13
  }, [defaultId]);
13
14
  return id;
15
+ }
16
+ /**
17
+ *
18
+ * @example <div id={useId()} />
19
+ * @param idOverride
20
+ * @returns {string}
21
+ */
22
+
23
+
24
+ export default function useReactId(idOverride) {
25
+ // TODO: Remove `React as any` once `useId` is part of stable types.
26
+ if (React.useId !== undefined) {
27
+ const reactId = React.useId();
28
+ return idOverride != null ? idOverride : reactId;
29
+ } // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
30
+
31
+
32
+ return useRandomId(idOverride);
14
33
  }
package/exactProp.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { ValidationMap } from 'prop-types';
2
- export default function exactProp<T>(propTypes: ValidationMap<T>): ValidationMap<T>;
1
+ import { ValidationMap } from 'prop-types';
2
+ export default function exactProp<T>(propTypes: ValidationMap<T>): ValidationMap<T>;
@@ -1,6 +1,6 @@
1
- /**
2
- * WARNING: Don't import this directly.
3
- * Use `MuiError` from `@mui/utils/macros/MuiError.macro` instead.
4
- * @param {number} code
5
- */
6
- export default function formatMuiErrorMessage(code: number): string;
1
+ /**
2
+ * WARNING: Don't import this directly.
3
+ * Use `MuiError` from `@mui/utils/macros/MuiError.macro` instead.
4
+ * @param {number} code
5
+ */
6
+ export default function formatMuiErrorMessage(code: number): string;
@@ -1,8 +1,8 @@
1
- import * as React from 'react';
2
- export declare function getFunctionName(fn: Function): string;
3
- /**
4
- * cherry-pick from
5
- * https://github.com/facebook/react/blob/769b1f270e1251d9dbdce0fcbd9e92e502d059b8/packages/shared/getComponentName.js
6
- * originally forked from recompose/getDisplayName with added IE11 support
7
- */
8
- export default function getDisplayName(Component: React.ElementType): string | undefined;
1
+ import * as React from 'react';
2
+ export declare function getFunctionName(fn: Function): string;
3
+ /**
4
+ * cherry-pick from
5
+ * https://github.com/facebook/react/blob/769b1f270e1251d9dbdce0fcbd9e92e502d059b8/packages/shared/getComponentName.js
6
+ * originally forked from recompose/getDisplayName with added IE11 support
7
+ */
8
+ export default function getDisplayName(Component: React.ElementType): string | undefined;
@@ -1 +1 @@
1
- export default function getScrollbarSize(doc: Document): number;
1
+ export default function getScrollbarSize(doc: Document): number;
package/index.d.ts CHANGED
@@ -1,32 +1,32 @@
1
- export { default as chainPropTypes } from './chainPropTypes';
2
- export { default as deepmerge } from './deepmerge';
3
- export { isPlainObject } from './deepmerge';
4
- export { default as elementAcceptingRef } from './elementAcceptingRef';
5
- export { default as elementTypeAcceptingRef } from './elementTypeAcceptingRef';
6
- export { default as exactProp } from './exactProp';
7
- export { default as formatMuiErrorMessage } from './formatMuiErrorMessage';
8
- export { default as getDisplayName } from './getDisplayName';
9
- export { default as HTMLElementType } from './HTMLElementType';
10
- export { default as ponyfillGlobal } from './ponyfillGlobal';
11
- export { default as refType } from './refType';
12
- export { default as unstable_capitalize } from './capitalize';
13
- export { default as unstable_createChainedFunction } from './createChainedFunction';
14
- export { default as unstable_debounce } from './debounce';
15
- export { default as unstable_deprecatedPropType } from './deprecatedPropType';
16
- export { default as unstable_isMuiElement } from './isMuiElement';
17
- export { default as unstable_ownerDocument } from './ownerDocument';
18
- export { default as unstable_ownerWindow } from './ownerWindow';
19
- export { default as unstable_requirePropFactory } from './requirePropFactory';
20
- export { default as unstable_setRef } from './setRef';
21
- export { default as unstable_useEnhancedEffect } from './useEnhancedEffect';
22
- export { default as unstable_useId } from './useId';
23
- export { default as unstable_unsupportedProp } from './unsupportedProp';
24
- export { default as unstable_useControlled } from './useControlled';
25
- export { default as unstable_useEventCallback } from './useEventCallback';
26
- export { default as unstable_useForkRef } from './useForkRef';
27
- export { default as unstable_useIsFocusVisible } from './useIsFocusVisible';
28
- export { default as unstable_getScrollbarSize } from './getScrollbarSize';
29
- export { detectScrollType as unstable_detectScrollType, getNormalizedScrollLeft as unstable_getNormalizedScrollLeft, } from './scrollLeft';
30
- export { default as usePreviousProps } from './usePreviousProps';
31
- export { default as visuallyHidden } from './visuallyHidden';
32
- export { default as integerPropType } from './integerPropType';
1
+ export { default as chainPropTypes } from './chainPropTypes';
2
+ export { default as deepmerge } from './deepmerge';
3
+ export { isPlainObject } from './deepmerge';
4
+ export { default as elementAcceptingRef } from './elementAcceptingRef';
5
+ export { default as elementTypeAcceptingRef } from './elementTypeAcceptingRef';
6
+ export { default as exactProp } from './exactProp';
7
+ export { default as formatMuiErrorMessage } from './formatMuiErrorMessage';
8
+ export { default as getDisplayName } from './getDisplayName';
9
+ export { default as HTMLElementType } from './HTMLElementType';
10
+ export { default as ponyfillGlobal } from './ponyfillGlobal';
11
+ export { default as refType } from './refType';
12
+ export { default as unstable_capitalize } from './capitalize';
13
+ export { default as unstable_createChainedFunction } from './createChainedFunction';
14
+ export { default as unstable_debounce } from './debounce';
15
+ export { default as unstable_deprecatedPropType } from './deprecatedPropType';
16
+ export { default as unstable_isMuiElement } from './isMuiElement';
17
+ export { default as unstable_ownerDocument } from './ownerDocument';
18
+ export { default as unstable_ownerWindow } from './ownerWindow';
19
+ export { default as unstable_requirePropFactory } from './requirePropFactory';
20
+ export { default as unstable_setRef } from './setRef';
21
+ export { default as unstable_useEnhancedEffect } from './useEnhancedEffect';
22
+ export { default as unstable_useId } from './useId';
23
+ export { default as unstable_unsupportedProp } from './unsupportedProp';
24
+ export { default as unstable_useControlled } from './useControlled';
25
+ export { default as unstable_useEventCallback } from './useEventCallback';
26
+ export { default as unstable_useForkRef } from './useForkRef';
27
+ export { default as unstable_useIsFocusVisible } from './useIsFocusVisible';
28
+ export { default as unstable_getScrollbarSize } from './getScrollbarSize';
29
+ export { detectScrollType as unstable_detectScrollType, getNormalizedScrollLeft as unstable_getNormalizedScrollLeft, } from './scrollLeft';
30
+ export { default as usePreviousProps } from './usePreviousProps';
31
+ export { default as visuallyHidden } from './visuallyHidden';
32
+ export { default as integerPropType } from './integerPropType';
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.1.1
1
+ /** @license MUI v5.2.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -1,7 +1,7 @@
1
- export function getTypeByValue(value: any): any;
2
- declare function _default(props: any, propName: any, ...other: any[]): RangeError | null;
3
- declare namespace _default {
4
- export { requiredInteger as isRequired };
5
- }
6
- export default _default;
7
- declare function requiredInteger(props: any, propName: any, componentName: any, location: any): RangeError | null;
1
+ export function getTypeByValue(value: any): any;
2
+ declare function _default(props: any, propName: any, ...other: any[]): RangeError | null;
3
+ declare namespace _default {
4
+ export { requiredInteger as isRequired };
5
+ }
6
+ export default _default;
7
+ declare function requiredInteger(props: any, propName: any, componentName: any, location: any): RangeError | null;
package/isMuiElement.d.ts CHANGED
@@ -1 +1 @@
1
- export default function isMuiElement(element: any, muiNames: readonly string[]): boolean;
1
+ export default function isMuiElement(element: any, muiNames: readonly string[]): boolean;
@@ -1,9 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _typeof from "@babel/runtime/helpers/esm/typeof";
3
3
  export function isPlainObject(item) {
4
- return item !== null && _typeof(item) === 'object' && // TS thinks `item is possibly null` even though this was our first guard.
5
- // @ts-expect-error
6
- item.constructor === Object;
4
+ return item !== null && _typeof(item) === 'object' && item.constructor === Object;
7
5
  }
8
6
  export default function deepmerge(target, source) {
9
7
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.1.1
1
+ /** @license MUI v5.2.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/legacy/useId.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
- export default function useId(idOverride) {
2
+
3
+ function useRandomId(idOverride) {
3
4
  var _React$useState = React.useState(idOverride),
4
5
  defaultId = _React$useState[0],
5
6
  setDefaultId = _React$useState[1];
@@ -14,4 +15,22 @@ export default function useId(idOverride) {
14
15
  }
15
16
  }, [defaultId]);
16
17
  return id;
18
+ }
19
+ /**
20
+ *
21
+ * @example <div id={useId()} />
22
+ * @param idOverride
23
+ * @returns {string}
24
+ */
25
+
26
+
27
+ export default function useReactId(idOverride) {
28
+ // TODO: Remove `React as any` once `useId` is part of stable types.
29
+ if (React.useId !== undefined) {
30
+ var reactId = React.useId();
31
+ return idOverride != null ? idOverride : reactId;
32
+ } // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
33
+
34
+
35
+ return useRandomId(idOverride);
17
36
  }
@@ -1,8 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  export function isPlainObject(item) {
3
- return item !== null && typeof item === 'object' && // TS thinks `item is possibly null` even though this was our first guard.
4
- // @ts-expect-error
5
- item.constructor === Object;
3
+ return item !== null && typeof item === 'object' && item.constructor === Object;
6
4
  }
7
5
  export default function deepmerge(target, source, options = {
8
6
  clone: true
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.1.1
1
+ /** @license MUI v5.2.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/modern/useId.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
- export default function useId(idOverride) {
2
+
3
+ function useRandomId(idOverride) {
3
4
  const [defaultId, setDefaultId] = React.useState(idOverride);
4
5
  const id = idOverride || defaultId;
5
6
  React.useEffect(() => {
@@ -11,4 +12,22 @@ export default function useId(idOverride) {
11
12
  }
12
13
  }, [defaultId]);
13
14
  return id;
15
+ }
16
+ /**
17
+ *
18
+ * @example <div id={useId()} />
19
+ * @param idOverride
20
+ * @returns {string}
21
+ */
22
+
23
+
24
+ export default function useReactId(idOverride) {
25
+ // TODO: Remove `React as any` once `useId` is part of stable types.
26
+ if (React.useId !== undefined) {
27
+ const reactId = React.useId();
28
+ return idOverride ?? reactId;
29
+ } // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
30
+
31
+
32
+ return useRandomId(idOverride);
14
33
  }
@@ -1 +1 @@
1
- export default function ownerDocument(node: Node | null | undefined): Document;
1
+ export default function ownerDocument(node: Node | null | undefined): Document;
package/ownerWindow.d.ts CHANGED
@@ -1 +1 @@
1
- export default function ownerWindow(node: Node | undefined): Window;
1
+ export default function ownerWindow(node: Node | undefined): Window;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/utils",
3
- "version": "5.1.1",
3
+ "version": "5.2.0",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "Utility functions for React components.",
@@ -1,2 +1,2 @@
1
- declare const _default: any;
2
- export default _default;
1
+ declare const _default: any;
2
+ export default _default;
package/refType.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import PropTypes from 'prop-types';
2
- declare const refType: PropTypes.Requireable<object>;
3
- export default refType;
1
+ import PropTypes from 'prop-types';
2
+ declare const refType: PropTypes.Requireable<object>;
3
+ export default refType;
package/setRef.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- import * as React from 'react';
2
- /**
3
- * TODO v5: consider making it private
4
- *
5
- * passes {value} to {ref}
6
- *
7
- * WARNING: Be sure to only call this inside a callback that is passed as a ref.
8
- * Otherwise, make sure to cleanup the previous {ref} if it changes. See
9
- * https://github.com/mui-org/material-ui/issues/13539
10
- *
11
- * Useful if you want to expose the ref of an inner component to the public API
12
- * while still using it inside the component.
13
- * @param ref A ref callback or ref object. If anything falsy, this is a no-op.
14
- */
15
- export default function setRef<T>(ref: React.MutableRefObject<T | null> | ((instance: T | null) => void) | null | undefined, value: T | null): void;
1
+ import * as React from 'react';
2
+ /**
3
+ * TODO v5: consider making it private
4
+ *
5
+ * passes {value} to {ref}
6
+ *
7
+ * WARNING: Be sure to only call this inside a callback that is passed as a ref.
8
+ * Otherwise, make sure to cleanup the previous {ref} if it changes. See
9
+ * https://github.com/mui-org/material-ui/issues/13539
10
+ *
11
+ * Useful if you want to expose the ref of an inner component to the public API
12
+ * while still using it inside the component.
13
+ * @param ref A ref callback or ref object. If anything falsy, this is a no-op.
14
+ */
15
+ export default function setRef<T>(ref: React.MutableRefObject<T | null> | ((instance: T | null) => void) | null | undefined, value: T | null): void;
@@ -1,4 +1,4 @@
1
- /**
2
- * https://github.com/facebook/react/issues/14099#issuecomment-440013892
3
- */
4
- export default function useEventCallback<Args extends unknown[], Return>(fn: (...args: Args) => Return): (...args: Args) => Return;
1
+ /**
2
+ * https://github.com/facebook/react/issues/14099#issuecomment-440013892
3
+ */
4
+ export default function useEventCallback<Args extends unknown[], Return>(fn: (...args: Args) => Return): (...args: Args) => Return;
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/useForkRef.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import * as React from 'react';
2
- export default function useForkRef<Instance>(refA: React.Ref<Instance> | null | undefined, refB: React.Ref<Instance> | null | undefined): React.Ref<Instance> | null;
1
+ import * as React from 'react';
2
+ export default function useForkRef<Instance>(refA: React.Ref<Instance> | null | undefined, refB: React.Ref<Instance> | null | undefined): React.Ref<Instance> | null;
package/useId.d.ts CHANGED
@@ -1 +1,7 @@
1
- export default function useId(idOverride?: string): string | undefined;
1
+ /**
2
+ *
3
+ * @example <div id={useId()} />
4
+ * @param idOverride
5
+ * @returns {string}
6
+ */
7
+ export default function useReactId(idOverride?: string): string | undefined;
package/useId.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = useId;
6
+ exports.default = useReactId;
7
7
 
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
 
@@ -11,7 +11,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
11
11
 
12
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
13
 
14
- function useId(idOverride) {
14
+ function useRandomId(idOverride) {
15
15
  const [defaultId, setDefaultId] = React.useState(idOverride);
16
16
  const id = idOverride || defaultId;
17
17
  React.useEffect(() => {
@@ -23,4 +23,22 @@ function useId(idOverride) {
23
23
  }
24
24
  }, [defaultId]);
25
25
  return id;
26
+ }
27
+ /**
28
+ *
29
+ * @example <div id={useId()} />
30
+ * @param idOverride
31
+ * @returns {string}
32
+ */
33
+
34
+
35
+ function useReactId(idOverride) {
36
+ // TODO: Remove `React as any` once `useId` is part of stable types.
37
+ if (React.useId !== undefined) {
38
+ const reactId = React.useId();
39
+ return idOverride != null ? idOverride : reactId;
40
+ } // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
41
+
42
+
43
+ return useRandomId(idOverride);
26
44
  }
@@ -1,2 +1,2 @@
1
- declare const usePreviousProps: (value: object) => object;
2
- export default usePreviousProps;
1
+ declare const usePreviousProps: (value: object) => object;
2
+ export default usePreviousProps;
@@ -1,2 +1,2 @@
1
- declare const visuallyHidden: import('react').CSSProperties;
2
- export default visuallyHidden;
1
+ declare const visuallyHidden: import('react').CSSProperties;
2
+ export default visuallyHidden;