@rescui/select 0.18.1-RUI-297-Add-react-compiler-to-the-packages-build-dbbefd7b8.10 → 0.18.1-RUI-297-Add-react-compiler-to-the-packages-build-8aaaed4be.39

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.
Files changed (40) hide show
  1. package/lib/_virtual/check-outline.js +294 -63
  2. package/lib/_virtual/close-outline.js +294 -63
  3. package/lib/_virtual/down-outline.js +294 -63
  4. package/lib/_virtual/index.css.js +12 -12
  5. package/lib/_virtual/loading-outline.js +310 -79
  6. package/lib/hooks/use-a11y.js +121 -33
  7. package/lib/hooks/use-actual-size-from-css.js +46 -17
  8. package/lib/hooks/use-focus.js +54 -10
  9. package/lib/hooks/use-hover.js +54 -10
  10. package/lib/hooks/use-label-focus.js +45 -15
  11. package/lib/hooks/use-multi-handlers.js +114 -36
  12. package/lib/hooks/use-no-memo-getter.d.ts +5 -0
  13. package/lib/hooks/use-no-memo-getter.js +15 -0
  14. package/lib/hooks/use-options.d.ts +2 -1
  15. package/lib/hooks/use-options.js +92 -56
  16. package/lib/hooks/use-primary-contrast-css-var-transfer.js +43 -16
  17. package/lib/hooks/use-safe-id.d.ts +3 -5
  18. package/lib/hooks/use-safe-id.js +7 -12
  19. package/lib/index.css +229 -189
  20. package/lib/multiselect.js +533 -158
  21. package/lib/native-select.js +412 -116
  22. package/lib/parts/form-trigger-wrapper.js +159 -39
  23. package/lib/parts/hidden-select.js +105 -29
  24. package/lib/parts/icons.js +164 -44
  25. package/lib/parts/list-box.js +294 -72
  26. package/lib/parts/multi-trigger.js +106 -43
  27. package/lib/parts/native-select-options-with-groups.js +154 -52
  28. package/lib/parts/popup-content.d.ts +2 -2
  29. package/lib/parts/popup-content.js +145 -45
  30. package/lib/public-api.p.css +5 -0
  31. package/lib/public-api.pcss +5 -0
  32. package/lib/select-basic.js +456 -136
  33. package/lib/select-searchable.js +435 -142
  34. package/lib/select.js +228 -56
  35. package/lib/styles/common.p.module.css.js +29 -29
  36. package/lib/styles/form-trigger.p.module.css.js +12 -12
  37. package/lib/styles/list-box.p.module.css.js +13 -13
  38. package/lib/types.d.ts +5 -0
  39. package/lib/utils/get-text-from-nodes.js +1 -1
  40. package/package.json +9 -8
@@ -1,17 +1,61 @@
1
+ import { c } from 'react-compiler-runtime';
1
2
  import { useState } from 'react';
2
3
 
3
- const useFocus = _ref => {
4
- let {
4
+ const useFocus = t0 => {
5
+ const $ = c(8);
6
+ const {
5
7
  isDisabled
6
- } = _ref;
8
+ } = t0;
7
9
  const [isFocused, setIsFocused] = useState(false);
8
- return {
9
- isFocused,
10
- focusProps: {
11
- onFocus: () => setIsFocused(!isDisabled),
12
- onBlur: () => setIsFocused(false)
13
- }
14
- };
10
+ let t1;
11
+
12
+ if ($[0] !== isDisabled) {
13
+ t1 = () => setIsFocused(!isDisabled);
14
+
15
+ $[0] = isDisabled;
16
+ $[1] = t1;
17
+ } else {
18
+ t1 = $[1];
19
+ }
20
+
21
+ let t2;
22
+
23
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
24
+ t2 = () => setIsFocused(false);
25
+
26
+ $[2] = t2;
27
+ } else {
28
+ t2 = $[2];
29
+ }
30
+
31
+ let t3;
32
+
33
+ if ($[3] !== t1) {
34
+ t3 = {
35
+ onFocus: t1,
36
+ onBlur: t2
37
+ };
38
+ $[3] = t1;
39
+ $[4] = t3;
40
+ } else {
41
+ t3 = $[4];
42
+ }
43
+
44
+ let t4;
45
+
46
+ if ($[5] !== isFocused || $[6] !== t3) {
47
+ t4 = {
48
+ isFocused,
49
+ focusProps: t3
50
+ };
51
+ $[5] = isFocused;
52
+ $[6] = t3;
53
+ $[7] = t4;
54
+ } else {
55
+ t4 = $[7];
56
+ }
57
+
58
+ return t4;
15
59
  };
16
60
 
17
61
  export { useFocus };
@@ -1,17 +1,61 @@
1
+ import { c } from 'react-compiler-runtime';
1
2
  import { useState } from 'react';
2
3
 
3
- const useHover = _ref => {
4
- let {
4
+ const useHover = t0 => {
5
+ const $ = c(8);
6
+ const {
5
7
  isDisabled
6
- } = _ref;
8
+ } = t0;
7
9
  const [isHovered, setIsHovered] = useState(false);
8
- return {
9
- isHovered,
10
- hoverProps: {
11
- onMouseEnter: () => setIsHovered(!isDisabled),
12
- onMouseLeave: () => setIsHovered(false)
13
- }
14
- };
10
+ let t1;
11
+
12
+ if ($[0] !== isDisabled) {
13
+ t1 = () => setIsHovered(!isDisabled);
14
+
15
+ $[0] = isDisabled;
16
+ $[1] = t1;
17
+ } else {
18
+ t1 = $[1];
19
+ }
20
+
21
+ let t2;
22
+
23
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
24
+ t2 = () => setIsHovered(false);
25
+
26
+ $[2] = t2;
27
+ } else {
28
+ t2 = $[2];
29
+ }
30
+
31
+ let t3;
32
+
33
+ if ($[3] !== t1) {
34
+ t3 = {
35
+ onMouseEnter: t1,
36
+ onMouseLeave: t2
37
+ };
38
+ $[3] = t1;
39
+ $[4] = t3;
40
+ } else {
41
+ t3 = $[4];
42
+ }
43
+
44
+ let t4;
45
+
46
+ if ($[5] !== isHovered || $[6] !== t3) {
47
+ t4 = {
48
+ isHovered,
49
+ hoverProps: t3
50
+ };
51
+ $[5] = isHovered;
52
+ $[6] = t3;
53
+ $[7] = t4;
54
+ } else {
55
+ t4 = $[7];
56
+ }
57
+
58
+ return t4;
15
59
  };
16
60
 
17
61
  export { useHover };
@@ -1,22 +1,52 @@
1
+ import { c } from 'react-compiler-runtime';
1
2
  import { useState } from 'react';
2
3
 
3
4
  const useLabelFocus = () => {
5
+ const $ = c(4);
4
6
  const [isFocusedByLabel, setIsFocusedByLabel] = useState(false);
5
- const triggerFocusProps = {
6
- onBlur: () => {
7
- setIsFocusedByLabel(false);
8
- }
9
- };
10
- const labelClickProps = {
11
- onClick: () => {
12
- setIsFocusedByLabel(true);
13
- }
14
- };
15
- return {
16
- isFocusedByLabel,
17
- triggerFocusProps,
18
- labelClickProps
19
- };
7
+ let t0;
8
+
9
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
10
+ t0 = {
11
+ onBlur: () => {
12
+ setIsFocusedByLabel(false);
13
+ }
14
+ };
15
+ $[0] = t0;
16
+ } else {
17
+ t0 = $[0];
18
+ }
19
+
20
+ const triggerFocusProps = t0;
21
+ let t1;
22
+
23
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
24
+ t1 = {
25
+ onClick: () => {
26
+ setIsFocusedByLabel(true);
27
+ }
28
+ };
29
+ $[1] = t1;
30
+ } else {
31
+ t1 = $[1];
32
+ }
33
+
34
+ const labelClickProps = t1;
35
+ let t2;
36
+
37
+ if ($[2] !== isFocusedByLabel) {
38
+ t2 = {
39
+ isFocusedByLabel,
40
+ triggerFocusProps,
41
+ labelClickProps
42
+ };
43
+ $[2] = isFocusedByLabel;
44
+ $[3] = t2;
45
+ } else {
46
+ t2 = $[3];
47
+ }
48
+
49
+ return t2;
20
50
  };
21
51
 
22
52
  export { useLabelFocus };
@@ -1,44 +1,122 @@
1
- import { useRef, useMemo, useCallback } from 'react';
1
+ import { c } from 'react-compiler-runtime';
2
+ import { useRef, useEffect, useLayoutEffect } from 'react';
2
3
  import { getOptionValue } from '../utils/get-option-value.js';
4
+ const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
3
5
 
4
- const useMultiHandlers = _ref => {
5
- let {
6
+ const useMultiHandlers = t0 => {
7
+ const $ = c(14);
8
+ const {
6
9
  selectedItems,
7
10
  onChange
8
- } = _ref;
11
+ } = t0;
9
12
  const onChangeRef = useRef(null);
10
- onChangeRef.current = onChange;
11
- const selectedMap = useMemo(() => new Map(selectedItems.map(item => [getOptionValue(item), item])), [selectedItems]);
12
- const addItem = useCallback(item => {
13
- if (selectedMap.has(getOptionValue(item))) {
14
- return;
15
- }
16
-
17
- const newValues = [...selectedMap.values(), item];
18
- onChangeRef.current?.(newValues);
19
- }, [selectedMap]);
20
- const removeItem = useCallback(item => {
21
- const key = getOptionValue(item);
22
- const newValues = [...selectedMap.entries()].filter(_ref2 => {
23
- let [k] = _ref2;
24
- return k !== key;
25
- }).map(_ref3 => {
26
- let [, v] = _ref3;
27
- return v;
28
- });
29
- onChangeRef.current?.(newValues);
30
- }, [selectedMap]);
31
-
32
- const removeAllItems = () => {
33
- onChangeRef.current?.([]);
34
- };
35
-
36
- return {
37
- selectedMap,
38
- addItem,
39
- removeItem,
40
- removeAllItems
41
- };
13
+ let t1;
14
+ let t2;
15
+
16
+ if ($[0] !== onChange) {
17
+ t1 = () => {
18
+ onChangeRef.current = onChange;
19
+ };
20
+
21
+ t2 = [onChange];
22
+ $[0] = onChange;
23
+ $[1] = t1;
24
+ $[2] = t2;
25
+ } else {
26
+ t1 = $[1];
27
+ t2 = $[2];
28
+ }
29
+
30
+ useIsomorphicLayoutEffect(t1, t2);
31
+ let t3;
32
+
33
+ if ($[3] !== selectedItems) {
34
+ t3 = new Map(selectedItems.map(_temp));
35
+ $[3] = selectedItems;
36
+ $[4] = t3;
37
+ } else {
38
+ t3 = $[4];
39
+ }
40
+
41
+ const selectedMap = t3;
42
+ let t4;
43
+
44
+ if ($[5] !== selectedMap) {
45
+ t4 = item_0 => {
46
+ if (selectedMap.has(getOptionValue(item_0))) {
47
+ return;
48
+ }
49
+
50
+ const newValues = [...selectedMap.values(), item_0];
51
+ onChangeRef.current?.(newValues);
52
+ };
53
+
54
+ $[5] = selectedMap;
55
+ $[6] = t4;
56
+ } else {
57
+ t4 = $[6];
58
+ }
59
+
60
+ const addItem = t4;
61
+ let t5;
62
+
63
+ if ($[7] !== selectedMap) {
64
+ t5 = item_1 => {
65
+ const key = getOptionValue(item_1);
66
+ const newValues_0 = [...selectedMap.entries()].filter(t6 => {
67
+ const [k] = t6;
68
+ return k !== key;
69
+ }).map(_temp2);
70
+ onChangeRef.current?.(newValues_0);
71
+ };
72
+
73
+ $[7] = selectedMap;
74
+ $[8] = t5;
75
+ } else {
76
+ t5 = $[8];
77
+ }
78
+
79
+ const removeItem = t5;
80
+ let t6;
81
+
82
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
83
+ t6 = () => {
84
+ onChangeRef.current?.([]);
85
+ };
86
+
87
+ $[9] = t6;
88
+ } else {
89
+ t6 = $[9];
90
+ }
91
+
92
+ const removeAllItems = t6;
93
+ let t7;
94
+
95
+ if ($[10] !== addItem || $[11] !== removeItem || $[12] !== selectedMap) {
96
+ t7 = {
97
+ selectedMap,
98
+ addItem,
99
+ removeItem,
100
+ removeAllItems
101
+ };
102
+ $[10] = addItem;
103
+ $[11] = removeItem;
104
+ $[12] = selectedMap;
105
+ $[13] = t7;
106
+ } else {
107
+ t7 = $[13];
108
+ }
109
+
110
+ return t7;
42
111
  };
43
112
 
113
+ function _temp(item) {
114
+ return [getOptionValue(item), item];
115
+ }
116
+
117
+ function _temp2(t0) {
118
+ const [, v] = t0;
119
+ return v;
120
+ }
121
+
44
122
  export { useMultiHandlers };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Some downshift `getSomethingProps` getters must be called on every render even if arguments haven't changed.
3
+ * We wrap all these getters in this hook interface, so react-compiler won't memoize them
4
+ */
5
+ export declare const useNoMemoGetter: <TArgs extends unknown[], TReturn>(getPartProps: (...args: TArgs) => TReturn, ...args: TArgs) => TReturn;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Some downshift `getSomethingProps` getters must be called on every render even if arguments haven't changed.
3
+ * We wrap all these getters in this hook interface, so react-compiler won't memoize them
4
+ */
5
+ const useNoMemoGetter = function (getPartProps) {
6
+ 'use no memo';
7
+
8
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
9
+ args[_key - 1] = arguments[_key];
10
+ }
11
+
12
+ return getPartProps(...args);
13
+ };
14
+
15
+ export { useNoMemoGetter };
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import type { SelectOptionOrGroup, SelectOption, ListBoxItem } from '../types';
2
3
  /**
3
4
  * Convert an array of options with possible groups to the flat array of options, stripping them of the groups.
@@ -6,7 +7,7 @@ import type { SelectOptionOrGroup, SelectOption, ListBoxItem } from '../types';
6
7
  * @param options
7
8
  */
8
9
  export declare const useOptions: (options: SelectOptionOrGroup[]) => {
9
- setFilterString: import("react").Dispatch<import("react").SetStateAction<string>>;
10
+ setFilterString: React.Dispatch<React.SetStateAction<string>>;
10
11
  filterString: string;
11
12
  flattenedOptions: SelectOption[];
12
13
  listBoxItems: ListBoxItem[];
@@ -1,5 +1,6 @@
1
- import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
2
- import { useState, useMemo } from 'react';
1
+ import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
2
+ import { c } from 'react-compiler-runtime';
3
+ import { useState } from 'react';
3
4
  import { isOptionAGroup } from '../utils/is-option-a-group.js';
4
5
  import { getTextFromNodes } from '../utils/get-text-from-nodes.js';
5
6
  import { getOptionValue } from '../utils/get-option-value.js';
@@ -16,6 +17,61 @@ const createFilter = substring => {
16
17
  return _includesInstanceProperty(_context = string.toLowerCase()).call(_context, lowerSubstring);
17
18
  };
18
19
  };
20
+
21
+ const processOptions = (options, filterFn) => {
22
+ const flattenedOptions = [];
23
+ const listBoxItems = [];
24
+ let index = 0;
25
+
26
+ const createOptionItem = option => {
27
+ return { ...option,
28
+ index: index++,
29
+ type: 'option',
30
+ key: getOptionValue(option)
31
+ };
32
+ };
33
+
34
+ options.forEach((optionOrGroup, arrayIndex) => {
35
+ if (isOptionAGroup(optionOrGroup)) {
36
+ const group = optionOrGroup;
37
+
38
+ if (!group.options || group.options.length === 0) {
39
+ return;
40
+ } // Render as Group (with or without label)
41
+
42
+
43
+ const groupLabelText = group.label ? getTextFromNodes(group.label) : ''; // Use a special prefix that's unlikely to collide with user values
44
+
45
+ const groupKey = `\0__rs_select_group_${arrayIndex}_${groupLabelText}`;
46
+ const listBoxGroupItem = { ...group,
47
+ type: 'group',
48
+ options: [],
49
+ key: groupKey
50
+ };
51
+ group.options.forEach(option => {
52
+ if (filterFn(getTextFromNodes(option.label))) {
53
+ flattenedOptions.push(option);
54
+ listBoxGroupItem.options.push(createOptionItem(option));
55
+ }
56
+ });
57
+
58
+ if (listBoxGroupItem.options.length > 0) {
59
+ listBoxItems.push(listBoxGroupItem);
60
+ }
61
+
62
+ return;
63
+ }
64
+
65
+ if (filterFn(getTextFromNodes(optionOrGroup.label))) {
66
+ flattenedOptions.push(optionOrGroup);
67
+ listBoxItems.push(createOptionItem(optionOrGroup));
68
+ }
69
+ });
70
+ return {
71
+ flattenedOptions,
72
+ listBoxItems
73
+ };
74
+ };
19
75
  /**
20
76
  * Convert an array of options with possible groups to the flat array of options, stripping them of the groups.
21
77
  * Also creating a list for ListBox component with indexes and keys.
@@ -25,66 +81,46 @@ const createFilter = substring => {
25
81
 
26
82
 
27
83
  const useOptions = options => {
28
- const [filterString, setFilterString] = useState('');
29
- const filterFn = useMemo(() => createFilter(filterString), [filterString]);
30
- const processedOptions = useMemo(() => {
31
- const flattenedOptions = [];
32
- const listBoxItems = [];
33
- let index = 0;
34
-
35
- const createOptionItem = option => {
36
- return { ...option,
37
- index: index++,
38
- type: 'option',
39
- key: getOptionValue(option)
40
- };
41
- };
84
+ const $ = c(8);
85
+ const [filterString, setFilterString] = useState("");
86
+ let t0;
42
87
 
43
- options.forEach((optionOrGroup, arrayIndex) => {
44
- if (isOptionAGroup(optionOrGroup)) {
45
- const group = optionOrGroup;
46
-
47
- if (!group.options || group.options.length === 0) {
48
- return;
49
- } // Render as Group (with or without label)
50
-
51
-
52
- const groupLabelText = group.label ? getTextFromNodes(group.label) : ''; // Use a special prefix that's unlikely to collide with user values
88
+ if ($[0] !== filterString) {
89
+ t0 = createFilter(filterString);
90
+ $[0] = filterString;
91
+ $[1] = t0;
92
+ } else {
93
+ t0 = $[1];
94
+ }
53
95
 
54
- const groupKey = `\0__rs_select_group_${arrayIndex}_${groupLabelText}`;
55
- const listBoxGroupItem = { ...group,
56
- type: 'group',
57
- options: [],
58
- key: groupKey
59
- };
60
- group.options.forEach(option => {
61
- if (filterFn(getTextFromNodes(option.label))) {
62
- flattenedOptions.push(option);
63
- listBoxGroupItem.options.push(createOptionItem(option));
64
- }
65
- });
96
+ const filterFn = t0;
97
+ let t1;
66
98
 
67
- if (listBoxGroupItem.options.length > 0) {
68
- listBoxItems.push(listBoxGroupItem);
69
- }
99
+ if ($[2] !== filterFn || $[3] !== options) {
100
+ t1 = processOptions(options, filterFn);
101
+ $[2] = filterFn;
102
+ $[3] = options;
103
+ $[4] = t1;
104
+ } else {
105
+ t1 = $[4];
106
+ }
70
107
 
71
- return;
72
- }
108
+ const processedOptions = t1;
109
+ let t2;
73
110
 
74
- if (filterFn(getTextFromNodes(optionOrGroup.label))) {
75
- flattenedOptions.push(optionOrGroup);
76
- listBoxItems.push(createOptionItem(optionOrGroup));
77
- }
78
- });
79
- return {
80
- flattenedOptions,
81
- listBoxItems
111
+ if ($[5] !== filterString || $[6] !== processedOptions) {
112
+ t2 = { ...processedOptions,
113
+ setFilterString,
114
+ filterString
82
115
  };
83
- }, [options, filterFn]);
84
- return { ...processedOptions,
85
- setFilterString,
86
- filterString
87
- };
116
+ $[5] = filterString;
117
+ $[6] = processedOptions;
118
+ $[7] = t2;
119
+ } else {
120
+ t2 = $[7];
121
+ }
122
+
123
+ return t2;
88
124
  };
89
125
 
90
126
  export { useOptions };
@@ -1,29 +1,56 @@
1
- import { useRef } from 'react';
1
+ import { c } from 'react-compiler-runtime';
2
+ import { useState, useEffect, useLayoutEffect } from 'react';
3
+ const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
2
4
  /**
3
5
  * Transfer primary contrast css var to the dropdown, but only when the dropdown opens
4
6
  */
5
7
 
6
- const usePrimaryContrastCssVarTransfer = _ref => {
7
- let {
8
+ const usePrimaryContrastCssVarTransfer = t0 => {
9
+ const $ = c(6);
10
+ const {
8
11
  triggerRef,
9
12
  isOpen
10
- } = _ref;
11
- const prevIsOpenRef = useRef(false);
12
- const isPrimaryContrastRef = useRef(false);
13
-
14
- if (prevIsOpenRef.current !== isOpen && isOpen && triggerRef.current && typeof window !== 'undefined') {
15
- const isPrimaryContrastFromCss = getComputedStyle(triggerRef.current)?.getPropertyValue('--rs-select-contrast-primary');
16
- isPrimaryContrastRef.current = isPrimaryContrastFromCss.toString() === '1';
17
- prevIsOpenRef.current = true;
13
+ } = t0;
14
+ const [isPrimaryContrast, setIsPrimaryContrast] = useState(false);
15
+ let t1;
16
+ let t2;
17
+
18
+ if ($[0] !== isOpen || $[1] !== triggerRef) {
19
+ t1 = () => {
20
+ const ownerWindow = triggerRef.current?.ownerDocument.defaultView;
21
+
22
+ if (!isOpen || !ownerWindow) {
23
+ return;
24
+ }
25
+
26
+ const isPrimaryContrastFromCss = ownerWindow.getComputedStyle(triggerRef.current).getPropertyValue("--rs-select-contrast-primary");
27
+ setIsPrimaryContrast(isPrimaryContrastFromCss === "1");
28
+ };
29
+
30
+ t2 = [isOpen, triggerRef];
31
+ $[0] = isOpen;
32
+ $[1] = triggerRef;
33
+ $[2] = t1;
34
+ $[3] = t2;
35
+ } else {
36
+ t1 = $[2];
37
+ t2 = $[3];
18
38
  }
19
39
 
20
- if (!isOpen) {
21
- prevIsOpenRef.current = false;
40
+ useIsomorphicLayoutEffect(t1, t2);
41
+ let t3;
42
+
43
+ if ($[4] !== isPrimaryContrast) {
44
+ t3 = {
45
+ isPrimaryContrast
46
+ };
47
+ $[4] = isPrimaryContrast;
48
+ $[5] = t3;
49
+ } else {
50
+ t3 = $[5];
22
51
  }
23
52
 
24
- return {
25
- isPrimaryContrast: isPrimaryContrastRef.current
26
- };
53
+ return t3;
27
54
  };
28
55
 
29
56
  export { usePrimaryContrastCssVarTransfer };
@@ -1,6 +1,4 @@
1
1
  import React from 'react';
2
- export declare const useFallbackId: {
3
- (): string;
4
- counter: number;
5
- };
6
- export declare const useSafeId: typeof React.useId;
2
+ declare function useFallbackId(): number;
3
+ export declare const useSafeId: typeof React.useId | typeof useFallbackId;
4
+ export {};
@@ -1,15 +1,10 @@
1
- import React, { useRef } from 'react';
1
+ import React, { useState } from 'react';
2
+ let nextFallbackId = 0;
2
3
 
3
- const useFallbackId = () => {
4
- const id = useRef(null);
4
+ function useFallbackId() {
5
+ const [id] = useState(() => nextFallbackId++);
6
+ return id;
7
+ }
5
8
 
6
- if (id.current === null) {
7
- id.current = useFallbackId.counter++;
8
- }
9
-
10
- return id.current.toString();
11
- };
12
-
13
- useFallbackId.counter = 0;
14
9
  const useSafeId = React.useId ?? useFallbackId;
15
- export { useFallbackId, useSafeId };
10
+ export { useSafeId };