@carbon/react 1.63.0 → 1.63.1
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/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1060 -1031
- package/es/components/ComboBox/ComboBox.d.ts +4 -1
- package/es/components/ComboBox/ComboBox.js +21 -3
- package/es/components/Dropdown/Dropdown.d.ts +4 -1
- package/es/components/Dropdown/Dropdown.js +23 -22
- package/es/components/FluidMultiSelect/FluidMultiSelect.js +4 -1
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +4 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +6 -3
- package/es/components/MultiSelect/MultiSelect.d.ts +4 -1
- package/es/components/MultiSelect/MultiSelect.js +6 -3
- package/es/internal/useId.js +39 -18
- package/lib/components/ComboBox/ComboBox.d.ts +4 -1
- package/lib/components/ComboBox/ComboBox.js +21 -3
- package/lib/components/Dropdown/Dropdown.d.ts +4 -1
- package/lib/components/Dropdown/Dropdown.js +23 -22
- package/lib/components/FluidMultiSelect/FluidMultiSelect.js +4 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +4 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +6 -3
- package/lib/components/MultiSelect/MultiSelect.d.ts +4 -1
- package/lib/components/MultiSelect/MultiSelect.js +6 -3
- package/lib/internal/useId.js +39 -17
- package/package.json +2 -2
package/lib/internal/useId.js
CHANGED
|
@@ -18,49 +18,70 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
18
18
|
|
|
19
19
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
20
20
|
|
|
21
|
-
// This file was heavily inspired by
|
|
22
|
-
|
|
21
|
+
// This file was heavily inspired by:
|
|
22
|
+
|
|
23
|
+
// This tricks bundlers so they can't statically analyze this and produce
|
|
24
|
+
// compilation warnings/errors.
|
|
25
|
+
// https://github.com/webpack/webpack/issues/14814
|
|
26
|
+
// https://github.com/mui/material-ui/issues/41190
|
|
27
|
+
const _React = {
|
|
28
|
+
...React__default["default"]
|
|
29
|
+
};
|
|
30
|
+
const instanceId = setupGetInstanceId["default"]();
|
|
23
31
|
const useIsomorphicLayoutEffect = environment.canUseDOM ? React.useLayoutEffect : React.useEffect;
|
|
24
32
|
let serverHandoffCompleted = false;
|
|
33
|
+
const defaultId = 'id';
|
|
25
34
|
|
|
26
35
|
/**
|
|
27
|
-
* Generate a unique ID with an optional prefix prepended to it
|
|
36
|
+
* Generate a unique ID for React <=17 with an optional prefix prepended to it.
|
|
37
|
+
* This is an internal utility, not intended for public usage.
|
|
28
38
|
* @param {string} [prefix]
|
|
29
39
|
* @returns {string}
|
|
30
40
|
*/
|
|
31
|
-
function
|
|
32
|
-
let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
33
|
-
const
|
|
41
|
+
function useCompatibleId() {
|
|
42
|
+
let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
|
|
43
|
+
const contextPrefix = useIdPrefix.useIdPrefix();
|
|
34
44
|
const [id, setId] = React.useState(() => {
|
|
35
45
|
if (serverHandoffCompleted) {
|
|
36
|
-
return `${
|
|
46
|
+
return `${contextPrefix ? `${contextPrefix}-` : ``}${prefix}-${instanceId()}`;
|
|
37
47
|
}
|
|
38
48
|
return null;
|
|
39
49
|
});
|
|
40
50
|
useIsomorphicLayoutEffect(() => {
|
|
41
51
|
if (id === null) {
|
|
42
|
-
setId(`${
|
|
52
|
+
setId(`${contextPrefix ? `${contextPrefix}-` : ``}${prefix}-${instanceId()}`);
|
|
43
53
|
}
|
|
44
|
-
}, [
|
|
54
|
+
}, [instanceId]);
|
|
45
55
|
React.useEffect(() => {
|
|
46
56
|
if (serverHandoffCompleted === false) {
|
|
47
57
|
serverHandoffCompleted = true;
|
|
48
58
|
}
|
|
49
59
|
}, []);
|
|
50
|
-
if (typeof React__default["default"]['useId'] === 'function') {
|
|
51
|
-
const id = nativeReactUseId(_prefix, prefix);
|
|
52
|
-
return id;
|
|
53
|
-
}
|
|
54
60
|
return id;
|
|
55
61
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Generate a unique ID for React >=18 with an optional prefix prepended to it.
|
|
65
|
+
* This is an internal utility, not intended for public usage.
|
|
66
|
+
* @param {string} [prefix]
|
|
67
|
+
* @returns {string}
|
|
68
|
+
*/
|
|
69
|
+
function useReactId() {
|
|
70
|
+
let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
|
|
71
|
+
const contextPrefix = useIdPrefix.useIdPrefix();
|
|
72
|
+
return `${contextPrefix ? `${contextPrefix}-` : ``}${prefix}-${_React.useId()}`;
|
|
60
73
|
}
|
|
61
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Uses React 18's built-in `useId()` when available, or falls back to a
|
|
77
|
+
* slightly less performant (requiring a double render) implementation for
|
|
78
|
+
* earlier React versions.
|
|
79
|
+
*/
|
|
80
|
+
const useId = _React.useId ? useReactId : useCompatibleId;
|
|
81
|
+
|
|
62
82
|
/**
|
|
63
83
|
* Generate a unique id if a given `id` is not provided
|
|
84
|
+
* This is an internal utility, not intended for public usage.
|
|
64
85
|
* @param {string|undefined} id
|
|
65
86
|
* @returns {string}
|
|
66
87
|
*/
|
|
@@ -69,5 +90,6 @@ function useFallbackId(id) {
|
|
|
69
90
|
return id ?? fallback;
|
|
70
91
|
}
|
|
71
92
|
|
|
93
|
+
exports.useCompatibleId = useCompatibleId;
|
|
72
94
|
exports.useFallbackId = useFallbackId;
|
|
73
95
|
exports.useId = useId;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.63.
|
|
4
|
+
"version": "1.63.1",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -141,5 +141,5 @@
|
|
|
141
141
|
"**/*.scss",
|
|
142
142
|
"**/*.css"
|
|
143
143
|
],
|
|
144
|
-
"gitHead": "
|
|
144
|
+
"gitHead": "950953f450dcdfbee94deceba31ce2cab8807414"
|
|
145
145
|
}
|