@mui/utils 6.0.2 → 6.1.1-dev.20240919-130050-82a6448768
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 +141 -15130
- package/esm/useId/useId.js +10 -2
- package/index.js +1 -1
- package/modern/index.js +1 -1
- package/modern/useId/useId.js +10 -2
- package/package.json +4 -4
- package/useId/useId.js +10 -2
package/esm/useId/useId.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
let globalId = 0;
|
|
5
|
+
|
|
6
|
+
// TODO React 17: Remove `useGlobalId` once React 17 support is removed
|
|
5
7
|
function useGlobalId(idOverride) {
|
|
6
8
|
const [defaultId, setDefaultId] = React.useState(idOverride);
|
|
7
9
|
const id = idOverride || defaultId;
|
|
@@ -18,8 +20,12 @@ function useGlobalId(idOverride) {
|
|
|
18
20
|
return id;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
//
|
|
22
|
-
const
|
|
23
|
+
// See https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379 for why
|
|
24
|
+
const safeReact = {
|
|
25
|
+
...React
|
|
26
|
+
};
|
|
27
|
+
const maybeReactUseId = safeReact.useId;
|
|
28
|
+
|
|
23
29
|
/**
|
|
24
30
|
*
|
|
25
31
|
* @example <div id={useId()} />
|
|
@@ -27,10 +33,12 @@ const maybeReactUseId = React['useId'.toString()];
|
|
|
27
33
|
* @returns {string}
|
|
28
34
|
*/
|
|
29
35
|
export default function useId(idOverride) {
|
|
36
|
+
// React.useId() is only available from React 17.0.0.
|
|
30
37
|
if (maybeReactUseId !== undefined) {
|
|
31
38
|
const reactId = maybeReactUseId();
|
|
32
39
|
return idOverride ?? reactId;
|
|
33
40
|
}
|
|
41
|
+
|
|
34
42
|
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler
|
|
35
43
|
// eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
|
|
36
44
|
return useGlobalId(idOverride);
|
package/index.js
CHANGED
package/modern/index.js
CHANGED
package/modern/useId/useId.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
let globalId = 0;
|
|
5
|
+
|
|
6
|
+
// TODO React 17: Remove `useGlobalId` once React 17 support is removed
|
|
5
7
|
function useGlobalId(idOverride) {
|
|
6
8
|
const [defaultId, setDefaultId] = React.useState(idOverride);
|
|
7
9
|
const id = idOverride || defaultId;
|
|
@@ -18,8 +20,12 @@ function useGlobalId(idOverride) {
|
|
|
18
20
|
return id;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
//
|
|
22
|
-
const
|
|
23
|
+
// See https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379 for why
|
|
24
|
+
const safeReact = {
|
|
25
|
+
...React
|
|
26
|
+
};
|
|
27
|
+
const maybeReactUseId = safeReact.useId;
|
|
28
|
+
|
|
23
29
|
/**
|
|
24
30
|
*
|
|
25
31
|
* @example <div id={useId()} />
|
|
@@ -27,10 +33,12 @@ const maybeReactUseId = React['useId'.toString()];
|
|
|
27
33
|
* @returns {string}
|
|
28
34
|
*/
|
|
29
35
|
export default function useId(idOverride) {
|
|
36
|
+
// React.useId() is only available from React 17.0.0.
|
|
30
37
|
if (maybeReactUseId !== undefined) {
|
|
31
38
|
const reactId = maybeReactUseId();
|
|
32
39
|
return idOverride ?? reactId;
|
|
33
40
|
}
|
|
41
|
+
|
|
34
42
|
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler
|
|
35
43
|
// eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
|
|
36
44
|
return useGlobalId(idOverride);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.1-dev.20240919-130050-82a6448768",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "Utility functions for React components.",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
],
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/mui/material-ui.git",
|
|
16
|
+
"url": "git+https://github.com/mui/material-ui.git",
|
|
17
17
|
"directory": "packages/mui-utils"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"url": "https://opencollective.com/mui-org"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@babel/runtime": "^7.25.
|
|
29
|
+
"@babel/runtime": "^7.25.6",
|
|
30
30
|
"@types/prop-types": "^15.7.12",
|
|
31
31
|
"clsx": "^2.1.1",
|
|
32
32
|
"prop-types": "^15.8.1",
|
|
33
33
|
"react-is": "^18.3.1",
|
|
34
|
-
"@mui/types": "^7.2.
|
|
34
|
+
"@mui/types": "^7.2.17"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
package/useId/useId.js
CHANGED
|
@@ -8,6 +8,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = useId;
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
10
|
let globalId = 0;
|
|
11
|
+
|
|
12
|
+
// TODO React 17: Remove `useGlobalId` once React 17 support is removed
|
|
11
13
|
function useGlobalId(idOverride) {
|
|
12
14
|
const [defaultId, setDefaultId] = React.useState(idOverride);
|
|
13
15
|
const id = idOverride || defaultId;
|
|
@@ -24,8 +26,12 @@ function useGlobalId(idOverride) {
|
|
|
24
26
|
return id;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
//
|
|
28
|
-
const
|
|
29
|
+
// See https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379 for why
|
|
30
|
+
const safeReact = {
|
|
31
|
+
...React
|
|
32
|
+
};
|
|
33
|
+
const maybeReactUseId = safeReact.useId;
|
|
34
|
+
|
|
29
35
|
/**
|
|
30
36
|
*
|
|
31
37
|
* @example <div id={useId()} />
|
|
@@ -33,10 +39,12 @@ const maybeReactUseId = React['useId'.toString()];
|
|
|
33
39
|
* @returns {string}
|
|
34
40
|
*/
|
|
35
41
|
function useId(idOverride) {
|
|
42
|
+
// React.useId() is only available from React 17.0.0.
|
|
36
43
|
if (maybeReactUseId !== undefined) {
|
|
37
44
|
const reactId = maybeReactUseId();
|
|
38
45
|
return idOverride ?? reactId;
|
|
39
46
|
}
|
|
47
|
+
|
|
40
48
|
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler
|
|
41
49
|
// eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
|
|
42
50
|
return useGlobalId(idOverride);
|