@wix/site-ui 1.347.0 → 1.348.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.
Files changed (226) hide show
  1. package/dist/{6706.js → 1093.js} +3 -3
  2. package/dist/{8724.js → 1219.js} +2 -2
  3. package/dist/{7373.js → 1288.js} +8 -2
  4. package/dist/{5299.js → 1381.js} +98 -127
  5. package/dist/{3056.js → 1607.js} +32 -34
  6. package/dist/1629.js +2 -0
  7. package/dist/1669.js +75 -0
  8. package/dist/1718.js +26 -0
  9. package/dist/{1477.js → 201.js} +17 -26
  10. package/dist/2221.js +9 -0
  11. package/dist/{2445.js → 226.js} +12 -48
  12. package/dist/2387.js +7 -0
  13. package/dist/2580.js +6 -0
  14. package/dist/{1500.js → 2859.js} +10 -34
  15. package/dist/3014.js +178 -0
  16. package/dist/{6247.js → 3054.js} +3 -3
  17. package/dist/{7642.js → 3093.js} +1 -1
  18. package/dist/3189.js +5 -0
  19. package/dist/{7564.js → 331.js} +2 -2
  20. package/dist/3357.js +7 -0
  21. package/dist/{487.js → 3398.js} +38 -39
  22. package/dist/3502.js +224 -0
  23. package/dist/3695.js +50 -0
  24. package/dist/3829.js +1 -1
  25. package/dist/{6588.js → 3859.js} +115 -92
  26. package/dist/{3670.js → 3910.js} +28 -21
  27. package/dist/392.js +7 -0
  28. package/dist/{4549.js → 4155.js} +11 -3
  29. package/dist/4226.js +7 -0
  30. package/dist/{6329.js → 4229.js} +1 -1
  31. package/dist/4293.js +3 -0
  32. package/dist/4346.js +853 -2
  33. package/dist/{285.js → 4472.js} +3 -3
  34. package/dist/4605.js +207 -0
  35. package/dist/{7366.js → 488.js} +60 -7
  36. package/dist/{8750.js → 497.js} +190 -375
  37. package/dist/4989.js +35 -0
  38. package/dist/{6270.js → 510.js} +157 -196
  39. package/dist/5258.js +26 -0
  40. package/dist/{5036.js → 5275.js} +0 -3
  41. package/dist/{8171.js → 5298.js} +90 -102
  42. package/dist/5473.js +11 -0
  43. package/dist/{4745.js → 5490.js} +3 -1
  44. package/dist/{6089.js → 5561.js} +869 -786
  45. package/dist/{8996.js → 5595.js} +4 -3
  46. package/dist/5890.js +25 -0
  47. package/dist/{6046.js → 5969.js} +1 -1
  48. package/dist/5984.js +38 -0
  49. package/dist/{8527.js → 6006.js} +3 -3
  50. package/dist/6040.js +97 -0
  51. package/dist/{8758.js → 6137.js} +10 -8
  52. package/dist/{4281.js → 6140.js} +18 -10
  53. package/dist/{8960.js → 6191.js} +2 -2
  54. package/dist/6240.js +121 -0
  55. package/dist/{4490.js → 6373.js} +7 -5
  56. package/dist/{904.js → 6487.js} +19 -17
  57. package/dist/{9635.js → 6498.js} +1 -1
  58. package/dist/6499.js +4 -7
  59. package/dist/6508.js +7 -0
  60. package/dist/{8225.js → 6540.js} +1 -0
  61. package/dist/6551.js +46 -0
  62. package/dist/{9369.js → 6620.js} +35 -34
  63. package/dist/{4143.js → 6838.js} +19 -10
  64. package/dist/6902.js +48 -0
  65. package/dist/6904.js +51 -0
  66. package/dist/70.js +24 -0
  67. package/dist/7024.js +39 -0
  68. package/dist/{6882.js → 721.js} +737 -362
  69. package/dist/{951.js → 7270.js} +4 -4
  70. package/dist/{3485.js → 7323.js} +143 -111
  71. package/dist/{7541.js → 7488.js} +2 -2
  72. package/dist/{4863.js → 7542.js} +7 -6
  73. package/dist/7551.js +28 -0
  74. package/dist/{7021.js → 7640.js} +1 -1
  75. package/dist/{353.js → 7692.js} +3 -7
  76. package/dist/{4707.js → 7930.js} +2 -2
  77. package/dist/{8052.js → 8.js} +80 -64
  78. package/dist/{6914.js → 8129.js} +3 -15
  79. package/dist/{3319.js → 8358.js} +62 -63
  80. package/dist/{5864.js → 8407.js} +13 -13
  81. package/dist/8488.js +15 -0
  82. package/dist/{4768.js → 8495.js} +1 -1
  83. package/dist/8734.js +171 -0
  84. package/dist/{1763.js → 9018.js} +205 -331
  85. package/dist/9053.js +29 -0
  86. package/dist/9067.js +41 -0
  87. package/dist/{2861.js → 9120.js} +2 -2
  88. package/dist/{42.js → 9197.js} +2 -2
  89. package/dist/{9189.js → 9248.js} +36 -17
  90. package/dist/{2801.js → 9252.js} +4 -9
  91. package/dist/9295.js +7 -0
  92. package/dist/9303.js +8 -0
  93. package/dist/{167.js → 9374.js} +1 -1
  94. package/dist/{9352.js → 9540.js} +17 -47
  95. package/dist/9576.js +51 -0
  96. package/dist/{8272.js → 9591.js} +36 -46
  97. package/dist/{6107.js → 9770.js} +2 -2
  98. package/dist/{5085.js → 9880.js} +6 -3
  99. package/dist/Accordion/index.d.ts +207 -41
  100. package/dist/Accordion/index.js +75 -177
  101. package/dist/AlertDialog/index.d.ts +440 -140
  102. package/dist/AlertDialog/index.js +3 -13
  103. package/dist/Autocomplete/index.d.ts +722 -150
  104. package/dist/Autocomplete/index.js +16 -29
  105. package/dist/Avatar/index.d.ts +38 -3
  106. package/dist/Avatar/index.js +82 -28
  107. package/dist/Breadcrumbs/index.d.ts +63 -91
  108. package/dist/Breadcrumbs/index.js +1 -1
  109. package/dist/Button/index.d.ts +11 -0
  110. package/dist/Button/index.js +2 -2
  111. package/dist/Checkbox/index.d.ts +206 -36
  112. package/dist/Checkbox/index.js +293 -8
  113. package/dist/CheckboxField/index.css +1 -1
  114. package/dist/CheckboxField/index.d.ts +40 -36
  115. package/dist/CheckboxGroup/index.d.ts +50 -36
  116. package/dist/CheckboxGroup/index.js +87 -58
  117. package/dist/CheckboxGroupField/index.css +1 -1
  118. package/dist/Collapsible/index.d.ts +128 -36
  119. package/dist/Collapsible/index.js +21 -25
  120. package/dist/Combobox/index.d.ts +801 -158
  121. package/dist/Combobox/index.js +70 -114
  122. package/dist/ContextMenu/index.d.ts +1162 -195
  123. package/dist/ContextMenu/index.js +46 -36
  124. package/dist/Dialog/index.d.ts +425 -133
  125. package/dist/Dialog/index.js +8 -4
  126. package/dist/Drawer/index.d.ts +589 -144
  127. package/dist/Drawer/index.js +482 -562
  128. package/dist/Field/index.css +1 -1
  129. package/dist/Field/index.d.ts +341 -42
  130. package/dist/Field/index.js +123 -273
  131. package/dist/Fieldset/index.d.ts +11 -0
  132. package/dist/Fieldset/index.js +10 -17
  133. package/dist/Form/index.d.ts +43 -39
  134. package/dist/Form/index.js +58 -50
  135. package/dist/Input/index.css +1 -1
  136. package/dist/Input/index.d.ts +94 -42
  137. package/dist/Input/index.js +1 -1
  138. package/dist/Menu/index.d.ts +1140 -175
  139. package/dist/Menu/index.js +51 -67
  140. package/dist/Menubar/index.d.ts +651 -173
  141. package/dist/Menubar/index.js +12 -16
  142. package/dist/Meter/index.js +21 -18
  143. package/dist/NavigationMenu/index.d.ts +370 -86
  144. package/dist/NavigationMenu/index.js +144 -178
  145. package/dist/NumberField/index.css +1 -1
  146. package/dist/NumberField/index.d.ts +507 -47
  147. package/dist/NumberField/index.js +434 -718
  148. package/dist/Popover/index.d.ts +561 -142
  149. package/dist/Popover/index.js +181 -252
  150. package/dist/PreviewCard/index.d.ts +507 -143
  151. package/dist/PreviewCard/index.js +97 -151
  152. package/dist/Progress/index.d.ts +117 -3
  153. package/dist/Progress/index.js +37 -36
  154. package/dist/Radio/index.d.ts +177 -7
  155. package/dist/Radio/index.js +54 -70
  156. package/dist/RadioField/index.css +1 -1
  157. package/dist/RadioField/index.d.ts +23 -7
  158. package/dist/RadioGroup/index.d.ts +51 -37
  159. package/dist/RadioGroup/index.js +60 -51
  160. package/dist/RadioGroupField/index.css +1 -1
  161. package/dist/RadioGroupField/index.d.ts +40 -37
  162. package/dist/ScrollArea/index.d.ts +295 -1
  163. package/dist/ScrollArea/index.js +256 -324
  164. package/dist/Select/index.d.ts +516 -123
  165. package/dist/Select/index.js +513 -635
  166. package/dist/SelectField/index.css +1 -1
  167. package/dist/SelectField/index.d.ts +109 -134
  168. package/dist/SelectField/index.js +5 -1
  169. package/dist/Separator/index.d.ts +12 -0
  170. package/dist/Separator/index.js +1 -1
  171. package/dist/Slider/index.d.ts +383 -64
  172. package/dist/Slider/index.js +298 -374
  173. package/dist/Switch/index.d.ts +184 -37
  174. package/dist/Switch/index.js +44 -58
  175. package/dist/Tabs/index.d.ts +220 -35
  176. package/dist/Tabs/index.js +199 -193
  177. package/dist/Toast/index.d.ts +280 -64
  178. package/dist/Toast/index.js +299 -374
  179. package/dist/Toggle/index.d.ts +55 -35
  180. package/dist/Toggle/index.js +19 -13
  181. package/dist/ToggleGroup/index.d.ts +62 -35
  182. package/dist/ToggleGroup/index.js +13 -31
  183. package/dist/Toolbar/index.d.ts +117 -2
  184. package/dist/Toolbar/index.js +31 -43
  185. package/dist/Tooltip/index.d.ts +507 -150
  186. package/dist/Tooltip/index.js +163 -213
  187. package/dist/index.d.ts +12912 -5382
  188. package/package.json +3 -3
  189. package/dist/2205.js +0 -26
  190. package/dist/2274.js +0 -34
  191. package/dist/2287.js +0 -17
  192. package/dist/3020.js +0 -7
  193. package/dist/3021.js +0 -72
  194. package/dist/3140.js +0 -4
  195. package/dist/3248.js +0 -307
  196. package/dist/4026.js +0 -12
  197. package/dist/4922.js +0 -15
  198. package/dist/5659.js +0 -4
  199. package/dist/5992.js +0 -447
  200. package/dist/6330.js +0 -30
  201. package/dist/6535.js +0 -72
  202. package/dist/6917.js +0 -55
  203. package/dist/7725.js +0 -10
  204. package/dist/7871.js +0 -38
  205. package/dist/8106.js +0 -239
  206. package/dist/8685.js +0 -102
  207. package/dist/8935.js +0 -8
  208. package/dist/8971.js +0 -40
  209. package/dist/8979.js +0 -10
  210. package/dist/9048.js +0 -52
  211. package/dist/9087.js +0 -256
  212. package/dist/9255.js +0 -136
  213. /package/dist/{1457.js → 1068.js} +0 -0
  214. /package/dist/{6003.js → 1234.js} +0 -0
  215. /package/dist/{4723.js → 1282.js} +0 -0
  216. /package/dist/{6825.js → 1876.js} +0 -0
  217. /package/dist/{5778.js → 1885.js} +0 -0
  218. /package/dist/{2445.js.LICENSE.txt → 226.js.LICENSE.txt} +0 -0
  219. /package/dist/{1279.js → 3278.js} +0 -0
  220. /package/dist/{3296.js → 5568.js} +0 -0
  221. /package/dist/{8685.css → 6240.css} +0 -0
  222. /package/dist/{9829.js → 6488.js} +0 -0
  223. /package/dist/{9863.js → 6534.js} +0 -0
  224. /package/dist/{4495.js → 7718.js} +0 -0
  225. /package/dist/{3395.js → 8866.js} +0 -0
  226. /package/dist/{2418.js → 9837.js} +0 -0
package/dist/9087.js DELETED
@@ -1,256 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { EMPTY_OBJECT, useMergedRefs, EMPTY_ARRAY as empty_EMPTY_ARRAY, useRenderElement } from "./8272.js";
3
- import { useStableCallback } from "./7541.js";
4
- import { ARROW_LEFT, scrollIntoViewIfNeeded, ARROW_UP, ARROW_DOWN, COMPOSITE_KEYS, ARROW_KEYS, VERTICAL_KEYS_WITH_EXTRA_KEYS, HORIZONTAL_KEYS, VERTICAL_KEYS, MODIFIER_KEYS, ARROW_RIGHT, HORIZONTAL_KEYS_WITH_EXTRA_KEYS, isNativeInput } from "./1500.js";
5
- import { ACTIVE_COMPOSITE_ITEM } from "./4346.js";
6
- import { getTarget } from "./4549.js";
7
- import { isElementDisabled } from "./3140.js";
8
- import { isListIndexDisabled, getGridCellIndices, findNonDisabledListIndex, getGridNavigatedIndex, createGridCellMap, getMinListIndex, getGridCellIndexOfCorner, isIndexOutOfListBounds, getMaxListIndex } from "./3319.js";
9
- import { useDirection } from "./9863.js";
10
- import { CompositeRootContext } from "./8724.js";
11
- import { CompositeList } from "./9255.js";
12
- import * as __rspack_external_react from "react";
13
- const EMPTY_ARRAY = [];
14
- function useCompositeRoot(params) {
15
- const { itemSizes, cols = 1, loopFocus = true, onLoop, dense = false, orientation = 'both', direction, highlightedIndex: externalHighlightedIndex, onHighlightedIndexChange: externalSetHighlightedIndex, rootRef: externalRef, enableHomeAndEndKeys = false, stopEventPropagation = false, disabledIndices, modifierKeys = EMPTY_ARRAY } = params;
16
- const [internalHighlightedIndex, internalSetHighlightedIndex] = __rspack_external_react.useState(0);
17
- const isGrid = cols > 1;
18
- const rootRef = __rspack_external_react.useRef(null);
19
- const mergedRef = useMergedRefs(rootRef, externalRef);
20
- const elementsRef = __rspack_external_react.useRef([]);
21
- const hasSetDefaultIndexRef = __rspack_external_react.useRef(false);
22
- const highlightedIndex = externalHighlightedIndex ?? internalHighlightedIndex;
23
- const onHighlightedIndexChange = useStableCallback((index, shouldScrollIntoView = false)=>{
24
- (externalSetHighlightedIndex ?? internalSetHighlightedIndex)(index);
25
- if (shouldScrollIntoView) {
26
- const newActiveItem = elementsRef.current[index];
27
- scrollIntoViewIfNeeded(rootRef.current, newActiveItem, direction, orientation);
28
- }
29
- });
30
- const onMapChange = useStableCallback((map)=>{
31
- if (0 === map.size || hasSetDefaultIndexRef.current) return;
32
- hasSetDefaultIndexRef.current = true;
33
- const sortedElements = Array.from(map.keys());
34
- const activeItem = sortedElements.find((compositeElement)=>compositeElement?.hasAttribute(ACTIVE_COMPOSITE_ITEM)) ?? null;
35
- const activeIndex = activeItem ? sortedElements.indexOf(activeItem) : -1;
36
- if (-1 !== activeIndex) onHighlightedIndexChange(activeIndex);
37
- scrollIntoViewIfNeeded(rootRef.current, activeItem, direction, orientation);
38
- });
39
- const wrappedOnLoop = useStableCallback((event, prevIndex, nextIndex)=>{
40
- if (!onLoop) return nextIndex;
41
- return onLoop?.(event, prevIndex, nextIndex, elementsRef);
42
- });
43
- const props = __rspack_external_react.useMemo(()=>({
44
- 'aria-orientation': 'both' === orientation ? void 0 : orientation,
45
- ref: mergedRef,
46
- onFocus (event) {
47
- const element = rootRef.current;
48
- const target = getTarget(event.nativeEvent);
49
- if (!element || null == target || !isNativeInput(target)) return;
50
- target.setSelectionRange(0, target.value.length ?? 0);
51
- },
52
- onKeyDown (event) {
53
- const RELEVANT_KEYS = enableHomeAndEndKeys ? COMPOSITE_KEYS : ARROW_KEYS;
54
- if (!RELEVANT_KEYS.has(event.key)) return;
55
- if (isModifierKeySet(event, modifierKeys)) return;
56
- const element = rootRef.current;
57
- if (!element) return;
58
- const isRtl = 'rtl' === direction;
59
- const horizontalForwardKey = isRtl ? ARROW_LEFT : ARROW_RIGHT;
60
- const forwardKey = {
61
- horizontal: horizontalForwardKey,
62
- vertical: ARROW_DOWN,
63
- both: horizontalForwardKey
64
- }[orientation];
65
- const horizontalBackwardKey = isRtl ? ARROW_RIGHT : ARROW_LEFT;
66
- const backwardKey = {
67
- horizontal: horizontalBackwardKey,
68
- vertical: ARROW_UP,
69
- both: horizontalBackwardKey
70
- }[orientation];
71
- const target = getTarget(event.nativeEvent);
72
- if (null != target && isNativeInput(target) && !isElementDisabled(target)) {
73
- const selectionStart = target.selectionStart;
74
- const selectionEnd = target.selectionEnd;
75
- const textContent = target.value ?? '';
76
- if (null == selectionStart || event.shiftKey || selectionStart !== selectionEnd) return;
77
- if (event.key !== backwardKey && selectionStart < textContent.length) return;
78
- if (event.key !== forwardKey && selectionStart > 0) return;
79
- }
80
- let nextIndex = highlightedIndex;
81
- const minIndex = getMinListIndex(elementsRef, disabledIndices);
82
- const maxIndex = getMaxListIndex(elementsRef, disabledIndices);
83
- if (isGrid) {
84
- const sizes = itemSizes || Array.from({
85
- length: elementsRef.current.length
86
- }, ()=>({
87
- width: 1,
88
- height: 1
89
- }));
90
- const cellMap = createGridCellMap(sizes, cols, dense);
91
- const minGridIndex = cellMap.findIndex((index)=>null != index && !isListIndexDisabled(elementsRef.current, index, disabledIndices));
92
- const maxGridIndex = cellMap.reduce((foundIndex, index, cellIndex)=>null == index || isListIndexDisabled(elementsRef.current, index, disabledIndices) ? foundIndex : cellIndex, -1);
93
- nextIndex = cellMap[getGridNavigatedIndex(cellMap.map((itemIndex)=>null != itemIndex ? elementsRef.current[itemIndex] : null), {
94
- event,
95
- orientation,
96
- loopFocus,
97
- onLoop: wrappedOnLoop,
98
- cols,
99
- disabledIndices: getGridCellIndices([
100
- ...disabledIndices || elementsRef.current.map((_, index)=>isListIndexDisabled(elementsRef.current, index) ? index : void 0),
101
- void 0
102
- ], cellMap),
103
- minIndex: minGridIndex,
104
- maxIndex: maxGridIndex,
105
- prevIndex: getGridCellIndexOfCorner(highlightedIndex > maxIndex ? minIndex : highlightedIndex, sizes, cellMap, cols, event.key === ARROW_DOWN ? 'bl' : event.key === ARROW_RIGHT ? 'tr' : 'tl'),
106
- rtl: isRtl
107
- })];
108
- }
109
- const forwardKeys = {
110
- horizontal: [
111
- horizontalForwardKey
112
- ],
113
- vertical: [
114
- ARROW_DOWN
115
- ],
116
- both: [
117
- horizontalForwardKey,
118
- ARROW_DOWN
119
- ]
120
- }[orientation];
121
- const backwardKeys = {
122
- horizontal: [
123
- horizontalBackwardKey
124
- ],
125
- vertical: [
126
- ARROW_UP
127
- ],
128
- both: [
129
- horizontalBackwardKey,
130
- ARROW_UP
131
- ]
132
- }[orientation];
133
- const preventedKeys = isGrid ? RELEVANT_KEYS : ({
134
- horizontal: enableHomeAndEndKeys ? HORIZONTAL_KEYS_WITH_EXTRA_KEYS : HORIZONTAL_KEYS,
135
- vertical: enableHomeAndEndKeys ? VERTICAL_KEYS_WITH_EXTRA_KEYS : VERTICAL_KEYS,
136
- both: RELEVANT_KEYS
137
- })[orientation];
138
- if (enableHomeAndEndKeys) {
139
- if ("Home" === event.key) nextIndex = minIndex;
140
- else if ("End" === event.key) nextIndex = maxIndex;
141
- }
142
- if (nextIndex === highlightedIndex && (forwardKeys.includes(event.key) || backwardKeys.includes(event.key))) if (loopFocus && nextIndex === maxIndex && forwardKeys.includes(event.key)) {
143
- nextIndex = minIndex;
144
- if (onLoop) nextIndex = onLoop(event, highlightedIndex, nextIndex, elementsRef);
145
- } else if (loopFocus && nextIndex === minIndex && backwardKeys.includes(event.key)) {
146
- nextIndex = maxIndex;
147
- if (onLoop) nextIndex = onLoop(event, highlightedIndex, nextIndex, elementsRef);
148
- } else nextIndex = findNonDisabledListIndex(elementsRef.current, {
149
- startingIndex: nextIndex,
150
- decrement: backwardKeys.includes(event.key),
151
- disabledIndices
152
- });
153
- if (nextIndex !== highlightedIndex && !isIndexOutOfListBounds(elementsRef.current, nextIndex)) {
154
- if (stopEventPropagation) event.stopPropagation();
155
- if (preventedKeys.has(event.key)) event.preventDefault();
156
- onHighlightedIndexChange(nextIndex, true);
157
- queueMicrotask(()=>{
158
- elementsRef.current[nextIndex]?.focus();
159
- });
160
- }
161
- }
162
- }), [
163
- cols,
164
- dense,
165
- direction,
166
- disabledIndices,
167
- elementsRef,
168
- enableHomeAndEndKeys,
169
- highlightedIndex,
170
- isGrid,
171
- itemSizes,
172
- loopFocus,
173
- onLoop,
174
- wrappedOnLoop,
175
- mergedRef,
176
- modifierKeys,
177
- onHighlightedIndexChange,
178
- orientation,
179
- stopEventPropagation
180
- ]);
181
- return __rspack_external_react.useMemo(()=>({
182
- props,
183
- highlightedIndex,
184
- onHighlightedIndexChange,
185
- elementsRef,
186
- disabledIndices,
187
- onMapChange,
188
- relayKeyboardEvent: props.onKeyDown
189
- }), [
190
- props,
191
- highlightedIndex,
192
- onHighlightedIndexChange,
193
- elementsRef,
194
- disabledIndices,
195
- onMapChange
196
- ]);
197
- }
198
- function isModifierKeySet(event, ignoredModifierKeys) {
199
- for (const key of MODIFIER_KEYS.values())if (!ignoredModifierKeys.includes(key)) {
200
- if (event.getModifierState(key)) return true;
201
- }
202
- return false;
203
- }
204
- function CompositeRoot(componentProps) {
205
- const { render, className, style, refs = empty_EMPTY_ARRAY, props = empty_EMPTY_ARRAY, state = EMPTY_OBJECT, stateAttributesMapping, highlightedIndex: highlightedIndexProp, onHighlightedIndexChange: onHighlightedIndexChangeProp, orientation, dense, itemSizes, loopFocus, onLoop, cols, enableHomeAndEndKeys, onMapChange: onMapChangeProp, stopEventPropagation = true, rootRef, disabledIndices, modifierKeys, highlightItemOnHover = false, tag = 'div', ...elementProps } = componentProps;
206
- const direction = useDirection();
207
- const { props: defaultProps, highlightedIndex, onHighlightedIndexChange, elementsRef, onMapChange: onMapChangeUnwrapped, relayKeyboardEvent } = useCompositeRoot({
208
- itemSizes,
209
- cols,
210
- loopFocus,
211
- onLoop,
212
- dense,
213
- orientation,
214
- highlightedIndex: highlightedIndexProp,
215
- onHighlightedIndexChange: onHighlightedIndexChangeProp,
216
- rootRef,
217
- stopEventPropagation,
218
- enableHomeAndEndKeys,
219
- direction,
220
- disabledIndices,
221
- modifierKeys
222
- });
223
- const element = useRenderElement(tag, componentProps, {
224
- state,
225
- ref: refs,
226
- props: [
227
- defaultProps,
228
- ...props,
229
- elementProps
230
- ],
231
- stateAttributesMapping
232
- });
233
- const contextValue = __rspack_external_react.useMemo(()=>({
234
- highlightedIndex,
235
- onHighlightedIndexChange,
236
- highlightItemOnHover,
237
- relayKeyboardEvent
238
- }), [
239
- highlightedIndex,
240
- onHighlightedIndexChange,
241
- highlightItemOnHover,
242
- relayKeyboardEvent
243
- ]);
244
- return /*#__PURE__*/ jsx(CompositeRootContext.Provider, {
245
- value: contextValue,
246
- children: /*#__PURE__*/ jsx(CompositeList, {
247
- elementsRef: elementsRef,
248
- onMapChange: (newMap)=>{
249
- onMapChangeProp?.(newMap);
250
- onMapChangeUnwrapped(newMap);
251
- },
252
- children: element
253
- })
254
- });
255
- }
256
- export { CompositeRoot };
package/dist/9255.js DELETED
@@ -1,136 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useStableCallback } from "./7541.js";
3
- import { useRefWithInit } from "./8272.js";
4
- import { useIsoLayoutEffect } from "./6499.js";
5
- import { CompositeListContext } from "./5036.js";
6
- import * as __rspack_external_react from "react";
7
- function CompositeList(props) {
8
- const { children, elementsRef, labelsRef, onMapChange: onMapChangeProp } = props;
9
- const onMapChange = useStableCallback(onMapChangeProp);
10
- const nextIndexRef = __rspack_external_react.useRef(0);
11
- const listeners = useRefWithInit(createListeners).current;
12
- const map = useRefWithInit(createMap).current;
13
- const [mapTick, setMapTick] = __rspack_external_react.useState(0);
14
- const lastTickRef = __rspack_external_react.useRef(mapTick);
15
- const register = useStableCallback((node, metadata)=>{
16
- map.set(node, metadata ?? null);
17
- lastTickRef.current += 1;
18
- setMapTick(lastTickRef.current);
19
- });
20
- const unregister = useStableCallback((node)=>{
21
- map.delete(node);
22
- lastTickRef.current += 1;
23
- setMapTick(lastTickRef.current);
24
- });
25
- const sortedMap = __rspack_external_react.useMemo(()=>{
26
- disableEslintWarning(mapTick);
27
- const newMap = new Map();
28
- const sortedNodes = Array.from(map.keys()).filter((node)=>node.isConnected).sort(sortByDocumentPosition);
29
- sortedNodes.forEach((node, index)=>{
30
- const metadata = map.get(node) ?? {};
31
- newMap.set(node, {
32
- ...metadata,
33
- index
34
- });
35
- });
36
- return newMap;
37
- }, [
38
- map,
39
- mapTick
40
- ]);
41
- useIsoLayoutEffect(()=>{
42
- if ('function' != typeof MutationObserver || 0 === sortedMap.size) return;
43
- const mutationObserver = new MutationObserver((entries)=>{
44
- const diff = new Set();
45
- const updateDiff = (node)=>diff.has(node) ? diff.delete(node) : diff.add(node);
46
- entries.forEach((entry)=>{
47
- entry.removedNodes.forEach(updateDiff);
48
- entry.addedNodes.forEach(updateDiff);
49
- });
50
- if (0 === diff.size) {
51
- lastTickRef.current += 1;
52
- setMapTick(lastTickRef.current);
53
- }
54
- });
55
- sortedMap.forEach((_, node)=>{
56
- if (node.parentElement) mutationObserver.observe(node.parentElement, {
57
- childList: true
58
- });
59
- });
60
- return ()=>{
61
- mutationObserver.disconnect();
62
- };
63
- }, [
64
- sortedMap
65
- ]);
66
- useIsoLayoutEffect(()=>{
67
- const shouldUpdateLengths = lastTickRef.current === mapTick;
68
- if (shouldUpdateLengths) {
69
- if (elementsRef.current.length !== sortedMap.size) elementsRef.current.length = sortedMap.size;
70
- if (labelsRef && labelsRef.current.length !== sortedMap.size) labelsRef.current.length = sortedMap.size;
71
- nextIndexRef.current = sortedMap.size;
72
- }
73
- onMapChange(sortedMap);
74
- }, [
75
- onMapChange,
76
- sortedMap,
77
- elementsRef,
78
- labelsRef,
79
- mapTick
80
- ]);
81
- useIsoLayoutEffect(()=>()=>{
82
- elementsRef.current = [];
83
- }, [
84
- elementsRef
85
- ]);
86
- useIsoLayoutEffect(()=>()=>{
87
- if (labelsRef) labelsRef.current = [];
88
- }, [
89
- labelsRef
90
- ]);
91
- const subscribeMapChange = useStableCallback((fn)=>{
92
- listeners.add(fn);
93
- return ()=>{
94
- listeners.delete(fn);
95
- };
96
- });
97
- useIsoLayoutEffect(()=>{
98
- listeners.forEach((l)=>l(sortedMap));
99
- }, [
100
- listeners,
101
- sortedMap
102
- ]);
103
- const contextValue = __rspack_external_react.useMemo(()=>({
104
- register,
105
- unregister,
106
- subscribeMapChange,
107
- elementsRef,
108
- labelsRef,
109
- nextIndexRef
110
- }), [
111
- register,
112
- unregister,
113
- subscribeMapChange,
114
- elementsRef,
115
- labelsRef,
116
- nextIndexRef
117
- ]);
118
- return /*#__PURE__*/ jsx(CompositeListContext.Provider, {
119
- value: contextValue,
120
- children: children
121
- });
122
- }
123
- function createMap() {
124
- return new Map();
125
- }
126
- function createListeners() {
127
- return new Set();
128
- }
129
- function sortByDocumentPosition(a, b) {
130
- const position = a.compareDocumentPosition(b);
131
- if (position & Node.DOCUMENT_POSITION_FOLLOWING || position & Node.DOCUMENT_POSITION_CONTAINED_BY) return -1;
132
- if (position & Node.DOCUMENT_POSITION_PRECEDING || position & Node.DOCUMENT_POSITION_CONTAINS) return 1;
133
- return 0;
134
- }
135
- function disableEslintWarning(_) {}
136
- export { CompositeList };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes