@mui/utils 5.2.2 → 5.4.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/useId.js CHANGED
@@ -13,7 +13,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
13
13
 
14
14
  let globalId = 0;
15
15
 
16
- function useId(idOverride) {
16
+ function useGlobalId(idOverride) {
17
17
  const [defaultId, setDefaultId] = React.useState(idOverride);
18
18
  const id = idOverride || defaultId;
19
19
  React.useEffect(() => {
@@ -27,4 +27,23 @@ function useId(idOverride) {
27
27
  }
28
28
  }, [defaultId]);
29
29
  return id;
30
+ } // eslint-disable-next-line no-useless-concat -- Workaround for https://github.com/webpack/webpack/issues/14814
31
+
32
+
33
+ const maybeReactUseId = React['useId' + ''];
34
+ /**
35
+ *
36
+ * @example <div id={useId()} />
37
+ * @param idOverride
38
+ * @returns {string}
39
+ */
40
+
41
+ function useId(idOverride) {
42
+ if (maybeReactUseId !== undefined) {
43
+ const reactId = maybeReactUseId();
44
+ return idOverride != null ? idOverride : reactId;
45
+ } // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
46
+
47
+
48
+ return useGlobalId(idOverride);
30
49
  }
@@ -1,9 +1,9 @@
1
- import * as React from 'react';
2
- export declare function teardown(doc: Document): void;
3
- export interface UseIsFocusVisibleResult {
4
- isFocusVisibleRef: React.MutableRefObject<boolean>;
5
- onBlur: (event: React.FocusEvent<any>) => void;
6
- onFocus: (event: React.FocusEvent<any>) => void;
7
- ref: React.Ref<unknown>;
8
- }
9
- export default function useIsFocusVisible(): UseIsFocusVisibleResult;
1
+ import * as React from 'react';
2
+ export declare function teardown(doc: Document): void;
3
+ export interface UseIsFocusVisibleResult {
4
+ isFocusVisibleRef: React.MutableRefObject<boolean>;
5
+ onBlur: (event: React.FocusEvent<any>) => void;
6
+ onFocus: (event: React.FocusEvent<any>) => void;
7
+ ref: React.Ref<unknown>;
8
+ }
9
+ export default function useIsFocusVisible(): UseIsFocusVisibleResult;
@@ -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;