@wix/site-ui 1.30.0 → 1.31.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 (173) hide show
  1. package/dist/1268.js +99 -0
  2. package/dist/1279.js +7 -0
  3. package/dist/1457.js +10 -0
  4. package/dist/1477.js +106 -0
  5. package/dist/1500.js +111 -0
  6. package/dist/167.js +6 -0
  7. package/dist/2274.js +34 -0
  8. package/dist/2287.js +17 -0
  9. package/dist/2418.js +31 -0
  10. package/dist/2801.js +20 -0
  11. package/dist/285.js +86 -0
  12. package/dist/2861.js +6 -0
  13. package/dist/3020.js +7 -0
  14. package/dist/3021.js +72 -0
  15. package/dist/3056.js +229 -0
  16. package/dist/3140.js +4 -0
  17. package/dist/3248.js +307 -0
  18. package/dist/3296.js +4 -0
  19. package/dist/3319.js +400 -0
  20. package/dist/3395.js +4 -0
  21. package/dist/3485.js +854 -0
  22. package/dist/353.js +14 -0
  23. package/dist/3670.js +418 -0
  24. package/dist/3829.js +113 -0
  25. package/dist/4026.js +12 -0
  26. package/dist/4143.js +46 -0
  27. package/dist/42.js +32 -0
  28. package/dist/4281.js +30 -0
  29. package/dist/4346.js +2 -0
  30. package/dist/4388.js +418 -0
  31. package/dist/4490.js +32 -0
  32. package/dist/4495.js +9 -0
  33. package/dist/4549.js +24 -0
  34. package/dist/4586.js +41 -0
  35. package/dist/4586.js.LICENSE.txt +19 -0
  36. package/dist/4707.js +19 -0
  37. package/dist/4723.js +7 -0
  38. package/dist/4745.js +7 -0
  39. package/dist/4768.js +35 -0
  40. package/dist/4922.js +15 -0
  41. package/dist/5036.js +17 -0
  42. package/dist/5085.js +20 -0
  43. package/dist/5299.js +597 -0
  44. package/dist/5659.js +4 -0
  45. package/dist/5778.js +10 -0
  46. package/dist/5864.js +86 -0
  47. package/dist/5992.js +913 -0
  48. package/dist/5992.js.LICENSE.txt +19 -0
  49. package/dist/6003.js +10 -0
  50. package/dist/6046.js +29 -0
  51. package/dist/6089.js +2355 -0
  52. package/dist/6107.js +10 -0
  53. package/dist/6247.js +20 -0
  54. package/dist/6270.js +487 -0
  55. package/dist/6329.js +32 -0
  56. package/dist/6330.js +30 -0
  57. package/dist/6499.js +7 -0
  58. package/dist/6535.js +71 -0
  59. package/dist/6588.js +382 -0
  60. package/dist/6706.js +16 -0
  61. package/dist/6825.js +7 -0
  62. package/dist/6882.js +1562 -0
  63. package/dist/6914.js +30 -0
  64. package/dist/7021.js +13 -0
  65. package/dist/7366.js +83 -0
  66. package/dist/7373.js +25 -0
  67. package/dist/7541.js +25 -0
  68. package/dist/7564.js +10 -0
  69. package/dist/7642.js +20 -0
  70. package/dist/7725.js +10 -0
  71. package/dist/7871.js +38 -0
  72. package/dist/8052.js +352 -0
  73. package/dist/8106.js +238 -0
  74. package/dist/8171.js +346 -0
  75. package/dist/8225.js +21 -0
  76. package/dist/8272.js +333 -0
  77. package/dist/8527.js +58 -0
  78. package/dist/8724.js +10 -0
  79. package/dist/8750.js +1920 -0
  80. package/dist/8758.js +43 -0
  81. package/dist/880.js +149 -0
  82. package/dist/8935.js +8 -0
  83. package/dist/8960.js +22 -0
  84. package/dist/8971.js +40 -0
  85. package/dist/8979.js +10 -0
  86. package/dist/8996.js +71 -0
  87. package/dist/904.js +121 -0
  88. package/dist/9048.js +52 -0
  89. package/dist/9087.js +256 -0
  90. package/dist/9189.js +158 -0
  91. package/dist/9255.js +136 -0
  92. package/dist/9352.js +148 -0
  93. package/dist/951.js +22 -0
  94. package/dist/9635.js +22 -0
  95. package/dist/9829.js +4 -0
  96. package/dist/9863.js +8 -0
  97. package/dist/Accordion/index.d.ts +569 -12
  98. package/dist/Accordion/index.js +423 -8
  99. package/dist/AlertDialog/index.d.ts +1417 -18
  100. package/dist/AlertDialog/index.js +34 -14
  101. package/dist/Autocomplete/index.d.ts +1861 -38
  102. package/dist/Autocomplete/index.js +98 -24
  103. package/dist/Avatar/index.d.ts +129 -7
  104. package/dist/Avatar/index.js +149 -6
  105. package/dist/Breadcrumbs/index.d.ts +960 -7
  106. package/dist/Breadcrumbs/index.js +5 -5
  107. package/dist/Button/index.d.ts +88 -6
  108. package/dist/Button/index.js +27 -3
  109. package/dist/Checkbox/index.d.ts +425 -5
  110. package/dist/Checkbox/index.js +45 -5
  111. package/dist/CheckboxGroup/index.d.ts +318 -3
  112. package/dist/CheckboxGroup/index.js +166 -3
  113. package/dist/Collapsible/index.d.ts +377 -7
  114. package/dist/Collapsible/index.js +160 -6
  115. package/dist/Combobox/index.d.ts +1984 -48
  116. package/dist/Combobox/index.js +352 -29
  117. package/dist/ContextMenu/index.d.ts +2340 -36
  118. package/dist/ContextMenu/index.js +197 -22
  119. package/dist/Dialog/index.d.ts +1355 -18
  120. package/dist/Dialog/index.js +16 -14
  121. package/dist/Drawer/index.d.ts +1653 -18
  122. package/dist/Drawer/index.js +2797 -20
  123. package/dist/Field/index.d.ts +655 -15
  124. package/dist/Field/index.js +677 -10
  125. package/dist/Fieldset/index.d.ts +94 -5
  126. package/dist/Fieldset/index.js +68 -5
  127. package/dist/Form/index.d.ts +331 -2
  128. package/dist/Form/index.js +106 -3
  129. package/dist/Input/index.d.ts +692 -3
  130. package/dist/Input/index.js +10 -3
  131. package/dist/Menu/index.d.ts +2301 -36
  132. package/dist/Menu/index.js +365 -26
  133. package/dist/Menubar/index.d.ts +2301 -3
  134. package/dist/Menubar/index.js +105 -3
  135. package/dist/Meter/index.d.ts +175 -11
  136. package/dist/Meter/index.js +129 -9
  137. package/dist/NavigationMenu/index.d.ts +978 -28
  138. package/dist/NavigationMenu/index.js +1034 -17
  139. package/dist/NumberField/index.d.ts +612 -15
  140. package/dist/NumberField/index.js +1409 -11
  141. package/dist/Popover/index.d.ts +1655 -20
  142. package/dist/Popover/index.js +792 -17
  143. package/dist/PreviewCard/index.d.ts +1523 -14
  144. package/dist/PreviewCard/index.js +679 -14
  145. package/dist/Progress/index.d.ts +183 -11
  146. package/dist/Progress/index.js +181 -9
  147. package/dist/Radio/index.d.ts +185 -6
  148. package/dist/Radio/index.js +253 -6
  149. package/dist/RadioGroup/index.d.ts +341 -2
  150. package/dist/RadioGroup/index.js +154 -3
  151. package/dist/ScrollArea/index.d.ts +265 -13
  152. package/dist/ScrollArea/index.js +892 -10
  153. package/dist/Select/index.d.ts +1493 -38
  154. package/dist/Select/index.js +1824 -23
  155. package/dist/Separator/index.d.ts +80 -6
  156. package/dist/Separator/index.js +3 -3
  157. package/dist/Slider/index.d.ts +678 -16
  158. package/dist/Slider/index.js +1199 -11
  159. package/dist/Switch/index.d.ts +393 -5
  160. package/dist/Switch/index.js +208 -6
  161. package/dist/Tabs/index.d.ts +523 -12
  162. package/dist/Tabs/index.js +685 -9
  163. package/dist/Toggle/index.d.ts +305 -2
  164. package/dist/Toggle/index.js +76 -3
  165. package/dist/ToggleGroup/index.d.ts +316 -2
  166. package/dist/ToggleGroup/index.js +102 -3
  167. package/dist/Toolbar/index.d.ts +282 -13
  168. package/dist/Toolbar/index.js +230 -9
  169. package/dist/Tooltip/index.d.ts +1572 -14
  170. package/dist/Tooltip/index.js +965 -14
  171. package/dist/index.d.ts +12749 -652
  172. package/dist/rslib-runtime.js +18 -0
  173. package/package.json +3 -3
package/dist/5085.js ADDED
@@ -0,0 +1,20 @@
1
+ import { NOOP } from "./8272.js";
2
+ import * as __rspack_external_react from "react";
3
+ const FormContext = /*#__PURE__*/ __rspack_external_react.createContext({
4
+ formRef: {
5
+ current: {
6
+ fields: new Map()
7
+ }
8
+ },
9
+ errors: {},
10
+ clearErrors: NOOP,
11
+ validationMode: 'onSubmit',
12
+ submitAttemptedRef: {
13
+ current: false
14
+ }
15
+ });
16
+ if ("production" !== process.env.NODE_ENV) FormContext.displayName = "FormContext";
17
+ function useFormContext() {
18
+ return __rspack_external_react.useContext(FormContext);
19
+ }
20
+ export { FormContext, useFormContext };
package/dist/5299.js ADDED
@@ -0,0 +1,597 @@
1
+ import { useTimeout } from "./42.js";
2
+ import { useStableCallback } from "./7541.js";
3
+ import { isListIndexDisabled, getGridCellIndices, findNonDisabledListIndex, getGridNavigatedIndex, createGridCellMap, getMinListIndex, isElementVisible, getGridCellIndexOfCorner, getMaxListIndex, isIndexOutOfListBounds } from "./3319.js";
4
+ import { stopEvent, isVirtualPointerEvent, isVirtualClick } from "./6330.js";
5
+ import { getTarget, contains, activeElement } from "./4549.js";
6
+ import { useIsoLayoutEffect } from "./6499.js";
7
+ import { ARROW_LEFT, ARROW_UP, ARROW_DOWN, ARROW_RIGHT } from "./4745.js";
8
+ import { getFloatingFocusElement, isTypeableCombobox } from "./8758.js";
9
+ import { useValueAsRef } from "./4707.js";
10
+ import { useFloatingParentNodeId, useFloatingTree } from "./285.js";
11
+ import { useAnimationFrame } from "./8996.js";
12
+ import { enqueueFocus } from "./3485.js";
13
+ import { ownerDocument } from "./9829.js";
14
+ import { createChangeEventDetails } from "./4768.js";
15
+ import { listNavigation, focusOut } from "./2418.js";
16
+ import { isHTMLElement } from "./3829.js";
17
+ import * as __rspack_external_react from "react";
18
+ function useTypeahead(context, props) {
19
+ const { listRef, elementsRef, activeIndex, onMatch: onMatchProp, onTyping, enabled = true, resetMs = 750, selectedIndex = null } = props;
20
+ const store = 'rootStore' in context ? context.rootStore : context;
21
+ const open = store.useState('open');
22
+ const timeout = useTimeout();
23
+ const stringRef = __rspack_external_react.useRef('');
24
+ const prevIndexRef = __rspack_external_react.useRef(selectedIndex ?? activeIndex ?? -1);
25
+ const matchIndexRef = __rspack_external_react.useRef(null);
26
+ const onKeyDown = useStableCallback((event)=>{
27
+ function isVisible(index) {
28
+ const element = elementsRef?.current[index];
29
+ return !element || isElementVisible(element);
30
+ }
31
+ function getMatchingIndex(list, string, startIndex = 0) {
32
+ if (0 === list.length) return -1;
33
+ const normalizedStartIndex = (startIndex % list.length + list.length) % list.length;
34
+ const lowerString = string.toLocaleLowerCase();
35
+ for(let offset = 0; offset < list.length; offset += 1){
36
+ const index = (normalizedStartIndex + offset) % list.length;
37
+ const text = list[index];
38
+ if (text?.toLocaleLowerCase().startsWith(lowerString) && isVisible(index)) return index;
39
+ }
40
+ return -1;
41
+ }
42
+ const listContent = listRef.current;
43
+ if (stringRef.current.length > 0 && ' ' === event.key) {
44
+ stopEvent(event);
45
+ onTyping?.(true);
46
+ }
47
+ if (stringRef.current.length > 0 && ' ' !== stringRef.current[0]) {
48
+ if (-1 === getMatchingIndex(listContent, stringRef.current) && ' ' !== event.key) onTyping?.(false);
49
+ }
50
+ if (null == listContent || 1 !== event.key.length || event.ctrlKey || event.metaKey || event.altKey) return;
51
+ if (open && ' ' !== event.key) {
52
+ stopEvent(event);
53
+ onTyping?.(true);
54
+ }
55
+ const isNewSession = '' === stringRef.current;
56
+ if (isNewSession) prevIndexRef.current = selectedIndex ?? activeIndex ?? -1;
57
+ const allowRapidSuccessionOfFirstLetter = listContent.every((text)=>text ? text[0]?.toLocaleLowerCase() !== text[1]?.toLocaleLowerCase() : true);
58
+ if (allowRapidSuccessionOfFirstLetter && stringRef.current === event.key) {
59
+ stringRef.current = '';
60
+ prevIndexRef.current = matchIndexRef.current;
61
+ }
62
+ stringRef.current += event.key;
63
+ timeout.start(resetMs, ()=>{
64
+ stringRef.current = '';
65
+ prevIndexRef.current = matchIndexRef.current;
66
+ onTyping?.(false);
67
+ });
68
+ const prevIndex = isNewSession ? selectedIndex ?? activeIndex ?? -1 : prevIndexRef.current;
69
+ const startIndex = (prevIndex ?? 0) + 1;
70
+ const index = getMatchingIndex(listContent, stringRef.current, startIndex);
71
+ if (-1 !== index) {
72
+ onMatchProp?.(index);
73
+ matchIndexRef.current = index;
74
+ } else if (' ' !== event.key) {
75
+ stringRef.current = '';
76
+ onTyping?.(false);
77
+ }
78
+ });
79
+ const onBlur = useStableCallback((event)=>{
80
+ const next = event.relatedTarget;
81
+ const currentDomReferenceElement = store.select('domReferenceElement');
82
+ const currentFloatingElement = store.select('floatingElement');
83
+ const withinComposite = contains(currentDomReferenceElement, next) || contains(currentFloatingElement, next);
84
+ if (withinComposite) return;
85
+ timeout.clear();
86
+ stringRef.current = '';
87
+ prevIndexRef.current = matchIndexRef.current;
88
+ onTyping?.(false);
89
+ });
90
+ useIsoLayoutEffect(()=>{
91
+ if (!open && null !== selectedIndex) return;
92
+ timeout.clear();
93
+ matchIndexRef.current = null;
94
+ if ('' !== stringRef.current) stringRef.current = '';
95
+ }, [
96
+ open,
97
+ selectedIndex,
98
+ timeout
99
+ ]);
100
+ useIsoLayoutEffect(()=>{
101
+ if (open && '' === stringRef.current) prevIndexRef.current = selectedIndex ?? activeIndex ?? -1;
102
+ }, [
103
+ open,
104
+ selectedIndex,
105
+ activeIndex
106
+ ]);
107
+ const sharedProps = __rspack_external_react.useMemo(()=>({
108
+ onKeyDown,
109
+ onBlur
110
+ }), [
111
+ onKeyDown,
112
+ onBlur
113
+ ]);
114
+ return __rspack_external_react.useMemo(()=>enabled ? {
115
+ reference: sharedProps,
116
+ floating: sharedProps
117
+ } : {}, [
118
+ enabled,
119
+ sharedProps
120
+ ]);
121
+ }
122
+ const ESCAPE = 'Escape';
123
+ function doSwitch(orientation, vertical, horizontal) {
124
+ switch(orientation){
125
+ case 'vertical':
126
+ return vertical;
127
+ case 'horizontal':
128
+ return horizontal;
129
+ default:
130
+ return vertical || horizontal;
131
+ }
132
+ }
133
+ function isMainOrientationKey(key, orientation) {
134
+ const vertical = key === ARROW_UP || key === ARROW_DOWN;
135
+ const horizontal = key === ARROW_LEFT || key === ARROW_RIGHT;
136
+ return doSwitch(orientation, vertical, horizontal);
137
+ }
138
+ function isMainOrientationToEndKey(key, orientation, rtl) {
139
+ const vertical = key === ARROW_DOWN;
140
+ const horizontal = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;
141
+ return doSwitch(orientation, vertical, horizontal) || 'Enter' === key || ' ' === key || '' === key;
142
+ }
143
+ function isCrossOrientationOpenKey(key, orientation, rtl) {
144
+ const vertical = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;
145
+ const horizontal = key === ARROW_DOWN;
146
+ return doSwitch(orientation, vertical, horizontal);
147
+ }
148
+ function isCrossOrientationCloseKey(key, orientation, rtl, cols) {
149
+ const vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;
150
+ const horizontal = key === ARROW_UP;
151
+ if ('both' === orientation || 'horizontal' === orientation && cols && cols > 1) return key === ESCAPE;
152
+ return doSwitch(orientation, vertical, horizontal);
153
+ }
154
+ function useListNavigation(context, props) {
155
+ const { listRef, activeIndex, onNavigate: onNavigateProp = ()=>{}, enabled = true, selectedIndex = null, allowEscape = false, loopFocus = false, nested = false, rtl = false, virtual = false, focusItemOnOpen = 'auto', focusItemOnHover = true, openOnArrowKeyDown = true, disabledIndices, orientation = 'vertical', parentOrientation, cols = 1, id, resetOnPointerLeave = true, externalTree } = props;
156
+ if ('production' !== process.env.NODE_ENV) {
157
+ if (allowEscape) {
158
+ if (!loopFocus) console.warn('`useListNavigation` looping must be enabled to allow escaping.');
159
+ if (!virtual) console.warn('`useListNavigation` must be virtual to allow escaping.');
160
+ }
161
+ if ('vertical' === orientation && cols > 1) console.warn('In grid list navigation mode (`cols` > 1), the `orientation` should', 'be either "horizontal" or "both".');
162
+ }
163
+ const store = 'rootStore' in context ? context.rootStore : context;
164
+ const open = store.useState('open');
165
+ const floatingElement = store.useState('floatingElement');
166
+ const domReferenceElement = store.useState('domReferenceElement');
167
+ const dataRef = store.context.dataRef;
168
+ const floatingFocusElement = getFloatingFocusElement(floatingElement);
169
+ const typeableComboboxReference = isTypeableCombobox(domReferenceElement);
170
+ const floatingFocusElementRef = useValueAsRef(floatingFocusElement);
171
+ const parentId = useFloatingParentNodeId();
172
+ const tree = useFloatingTree(externalTree);
173
+ const focusItemOnOpenRef = __rspack_external_react.useRef(focusItemOnOpen);
174
+ const indexRef = __rspack_external_react.useRef(selectedIndex ?? -1);
175
+ const keyRef = __rspack_external_react.useRef(null);
176
+ const isPointerModalityRef = __rspack_external_react.useRef(true);
177
+ const onNavigate = useStableCallback((event)=>{
178
+ onNavigateProp(-1 === indexRef.current ? null : indexRef.current, event);
179
+ });
180
+ const previousOnNavigateRef = __rspack_external_react.useRef(onNavigate);
181
+ const previousMountedRef = __rspack_external_react.useRef(!!floatingElement);
182
+ const previousOpenRef = __rspack_external_react.useRef(open);
183
+ const forceSyncFocusRef = __rspack_external_react.useRef(false);
184
+ const forceScrollIntoViewRef = __rspack_external_react.useRef(false);
185
+ const cancelQueuedFocusRef = __rspack_external_react.useRef(null);
186
+ const disabledIndicesRef = useValueAsRef(disabledIndices);
187
+ const latestOpenRef = useValueAsRef(open);
188
+ const selectedIndexRef = useValueAsRef(selectedIndex);
189
+ const resetOnPointerLeaveRef = useValueAsRef(resetOnPointerLeave);
190
+ const focusFrame = useAnimationFrame();
191
+ const waitForListPopulatedFrame = useAnimationFrame();
192
+ const focusItem = useStableCallback(()=>{
193
+ function runFocus(item) {
194
+ if (virtual) tree?.events.emit('virtualfocus', item);
195
+ else cancelQueuedFocusRef.current = enqueueFocus(item, {
196
+ sync: forceSyncFocusRef.current,
197
+ preventScroll: true
198
+ });
199
+ }
200
+ const initialItem = listRef.current[indexRef.current];
201
+ const forceScrollIntoView = forceScrollIntoViewRef.current;
202
+ if (initialItem) runFocus(initialItem);
203
+ const scheduler = forceSyncFocusRef.current ? (callback)=>callback() : (callback)=>focusFrame.request(callback);
204
+ scheduler(()=>{
205
+ const waitedItem = listRef.current[indexRef.current] || initialItem;
206
+ if (!waitedItem) return;
207
+ if (!initialItem) runFocus(waitedItem);
208
+ const shouldScrollIntoView = item && (forceScrollIntoView || !isPointerModalityRef.current);
209
+ if (shouldScrollIntoView) waitedItem.scrollIntoView?.({
210
+ block: 'nearest',
211
+ inline: 'nearest'
212
+ });
213
+ });
214
+ });
215
+ useIsoLayoutEffect(()=>{
216
+ dataRef.current.orientation = orientation;
217
+ }, [
218
+ dataRef,
219
+ orientation
220
+ ]);
221
+ useIsoLayoutEffect(()=>{
222
+ if (!enabled) return;
223
+ if (open && floatingElement) {
224
+ indexRef.current = selectedIndex ?? -1;
225
+ if (focusItemOnOpenRef.current && null != selectedIndex) {
226
+ forceScrollIntoViewRef.current = true;
227
+ onNavigate();
228
+ }
229
+ } else if (previousMountedRef.current) {
230
+ indexRef.current = -1;
231
+ previousOnNavigateRef.current();
232
+ }
233
+ }, [
234
+ enabled,
235
+ open,
236
+ floatingElement,
237
+ selectedIndex,
238
+ onNavigate
239
+ ]);
240
+ useIsoLayoutEffect(()=>{
241
+ if (!enabled) return;
242
+ if (!open) {
243
+ forceSyncFocusRef.current = false;
244
+ return;
245
+ }
246
+ if (!floatingElement) return;
247
+ if (null == activeIndex) {
248
+ forceSyncFocusRef.current = false;
249
+ if (null != selectedIndexRef.current) return;
250
+ if (previousMountedRef.current) {
251
+ indexRef.current = -1;
252
+ focusItem();
253
+ }
254
+ if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (null != keyRef.current || true === focusItemOnOpenRef.current && null == keyRef.current)) {
255
+ let runs = 0;
256
+ const waitForListPopulated = ()=>{
257
+ if (null == listRef.current[0]) {
258
+ if (runs < 2) {
259
+ const scheduler = runs ? (callback)=>waitForListPopulatedFrame.request(callback) : queueMicrotask;
260
+ scheduler(waitForListPopulated);
261
+ }
262
+ runs += 1;
263
+ } else {
264
+ indexRef.current = null == keyRef.current || isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ? getMinListIndex(listRef) : getMaxListIndex(listRef);
265
+ keyRef.current = null;
266
+ onNavigate();
267
+ }
268
+ };
269
+ waitForListPopulated();
270
+ }
271
+ } else if (!isIndexOutOfListBounds(listRef.current, activeIndex)) {
272
+ indexRef.current = activeIndex;
273
+ focusItem();
274
+ forceScrollIntoViewRef.current = false;
275
+ }
276
+ }, [
277
+ enabled,
278
+ open,
279
+ floatingElement,
280
+ activeIndex,
281
+ selectedIndexRef,
282
+ nested,
283
+ listRef,
284
+ orientation,
285
+ rtl,
286
+ onNavigate,
287
+ focusItem,
288
+ waitForListPopulatedFrame
289
+ ]);
290
+ useIsoLayoutEffect(()=>{
291
+ if (!enabled || floatingElement || !tree || virtual || !previousMountedRef.current) return;
292
+ const nodes = tree.nodesRef.current;
293
+ const parent = nodes.find((node)=>node.id === parentId)?.context?.elements.floating;
294
+ const activeEl = activeElement(ownerDocument(floatingElement));
295
+ const treeContainsActiveEl = nodes.some((node)=>node.context && contains(node.context.elements.floating, activeEl));
296
+ if (parent && !treeContainsActiveEl && isPointerModalityRef.current) parent.focus({
297
+ preventScroll: true
298
+ });
299
+ }, [
300
+ enabled,
301
+ floatingElement,
302
+ tree,
303
+ parentId,
304
+ virtual
305
+ ]);
306
+ useIsoLayoutEffect(()=>{
307
+ previousOnNavigateRef.current = onNavigate;
308
+ previousOpenRef.current = open;
309
+ previousMountedRef.current = !!floatingElement;
310
+ });
311
+ useIsoLayoutEffect(()=>{
312
+ if (!open) {
313
+ keyRef.current = null;
314
+ focusItemOnOpenRef.current = focusItemOnOpen;
315
+ }
316
+ }, [
317
+ open,
318
+ focusItemOnOpen
319
+ ]);
320
+ const hasActiveIndex = null != activeIndex;
321
+ const syncCurrentTarget = useStableCallback((event)=>{
322
+ if (!latestOpenRef.current) return;
323
+ const index = listRef.current.indexOf(event.currentTarget);
324
+ if (-1 !== index && (indexRef.current !== index || activeIndex !== index)) {
325
+ indexRef.current = index;
326
+ onNavigate(event);
327
+ }
328
+ });
329
+ const getParentOrientation = useStableCallback(()=>parentOrientation ?? tree?.nodesRef.current.find((node)=>node.id === parentId)?.context?.dataRef?.current.orientation);
330
+ const getMinEnabledIndex = useStableCallback(()=>getMinListIndex(listRef, disabledIndicesRef.current));
331
+ const commonOnKeyDown = useStableCallback((event)=>{
332
+ isPointerModalityRef.current = false;
333
+ forceSyncFocusRef.current = true;
334
+ if (229 === event.which) return;
335
+ if (!latestOpenRef.current && event.currentTarget === floatingFocusElementRef.current) return;
336
+ if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl, cols)) {
337
+ if (!isMainOrientationKey(event.key, getParentOrientation())) stopEvent(event);
338
+ store.setOpen(false, createChangeEventDetails(listNavigation, event.nativeEvent));
339
+ if (isHTMLElement(domReferenceElement)) if (virtual) tree?.events.emit('virtualfocus', domReferenceElement);
340
+ else domReferenceElement.focus();
341
+ return;
342
+ }
343
+ const currentIndex = indexRef.current;
344
+ const minIndex = getMinListIndex(listRef, disabledIndices);
345
+ const maxIndex = getMaxListIndex(listRef, disabledIndices);
346
+ if (!typeableComboboxReference) {
347
+ if ('Home' === event.key) {
348
+ stopEvent(event);
349
+ indexRef.current = minIndex;
350
+ onNavigate(event);
351
+ }
352
+ if ('End' === event.key) {
353
+ stopEvent(event);
354
+ indexRef.current = maxIndex;
355
+ onNavigate(event);
356
+ }
357
+ }
358
+ if (cols > 1) {
359
+ const sizes = Array.from({
360
+ length: listRef.current.length
361
+ }, ()=>({
362
+ width: 1,
363
+ height: 1
364
+ }));
365
+ const cellMap = createGridCellMap(sizes, cols, false);
366
+ const minGridIndex = cellMap.findIndex((index)=>null != index && !isListIndexDisabled(listRef.current, index, disabledIndices));
367
+ const maxGridIndex = cellMap.reduce((foundIndex, index, cellIndex)=>null == index || isListIndexDisabled(listRef.current, index, disabledIndices) ? foundIndex : cellIndex, -1);
368
+ const index = cellMap[getGridNavigatedIndex(cellMap.map((itemIndex)=>null != itemIndex ? listRef.current[itemIndex] : null), {
369
+ event,
370
+ orientation,
371
+ loopFocus,
372
+ rtl,
373
+ cols,
374
+ disabledIndices: getGridCellIndices([
375
+ ...('function' != typeof disabledIndices ? disabledIndices : null) || listRef.current.map((_, listIndex)=>isListIndexDisabled(listRef.current, listIndex, disabledIndices) ? listIndex : void 0),
376
+ void 0
377
+ ], cellMap),
378
+ minIndex: minGridIndex,
379
+ maxIndex: maxGridIndex,
380
+ prevIndex: getGridCellIndexOfCorner(indexRef.current > maxIndex ? minIndex : indexRef.current, sizes, cellMap, cols, event.key === ARROW_DOWN ? 'bl' : event.key === (rtl ? ARROW_LEFT : ARROW_RIGHT) ? 'tr' : 'tl'),
381
+ stopEvent: true
382
+ })];
383
+ if (null != index) {
384
+ indexRef.current = index;
385
+ onNavigate(event);
386
+ }
387
+ if ('both' === orientation) return;
388
+ }
389
+ if (isMainOrientationKey(event.key, orientation)) {
390
+ stopEvent(event);
391
+ if (open && !virtual && activeElement(event.currentTarget.ownerDocument) === event.currentTarget) {
392
+ indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;
393
+ onNavigate(event);
394
+ return;
395
+ }
396
+ if (isMainOrientationToEndKey(event.key, orientation, rtl)) if (loopFocus) if (currentIndex >= maxIndex) if (allowEscape && currentIndex !== listRef.current.length) indexRef.current = -1;
397
+ else {
398
+ forceSyncFocusRef.current = false;
399
+ indexRef.current = minIndex;
400
+ }
401
+ else indexRef.current = findNonDisabledListIndex(listRef.current, {
402
+ startingIndex: currentIndex,
403
+ disabledIndices
404
+ });
405
+ else indexRef.current = Math.min(maxIndex, findNonDisabledListIndex(listRef.current, {
406
+ startingIndex: currentIndex,
407
+ disabledIndices
408
+ }));
409
+ else if (loopFocus) if (currentIndex <= minIndex) if (allowEscape && -1 !== currentIndex) indexRef.current = listRef.current.length;
410
+ else {
411
+ forceSyncFocusRef.current = false;
412
+ indexRef.current = maxIndex;
413
+ }
414
+ else indexRef.current = findNonDisabledListIndex(listRef.current, {
415
+ startingIndex: currentIndex,
416
+ decrement: true,
417
+ disabledIndices
418
+ });
419
+ else indexRef.current = Math.max(minIndex, findNonDisabledListIndex(listRef.current, {
420
+ startingIndex: currentIndex,
421
+ decrement: true,
422
+ disabledIndices
423
+ }));
424
+ if (isIndexOutOfListBounds(listRef.current, indexRef.current)) indexRef.current = -1;
425
+ onNavigate(event);
426
+ }
427
+ });
428
+ const item = __rspack_external_react.useMemo(()=>{
429
+ const itemProps = {
430
+ onFocus (event) {
431
+ forceSyncFocusRef.current = true;
432
+ syncCurrentTarget(event);
433
+ },
434
+ onClick: ({ currentTarget })=>currentTarget.focus({
435
+ preventScroll: true
436
+ }),
437
+ onMouseMove (event) {
438
+ forceSyncFocusRef.current = true;
439
+ forceScrollIntoViewRef.current = false;
440
+ if (focusItemOnHover) syncCurrentTarget(event);
441
+ },
442
+ onPointerLeave (event) {
443
+ if (!latestOpenRef.current || !isPointerModalityRef.current || 'touch' === event.pointerType) return;
444
+ forceSyncFocusRef.current = true;
445
+ const relatedTarget = event.relatedTarget;
446
+ if (!focusItemOnHover || listRef.current.includes(relatedTarget)) return;
447
+ if (!resetOnPointerLeaveRef.current) return;
448
+ cancelQueuedFocusRef.current?.();
449
+ cancelQueuedFocusRef.current = null;
450
+ indexRef.current = -1;
451
+ onNavigate(event);
452
+ if (!virtual) {
453
+ const floatingFocusEl = floatingFocusElementRef.current;
454
+ const activeEl = activeElement(ownerDocument(floatingFocusEl));
455
+ if (floatingFocusEl && contains(floatingFocusEl, activeEl)) floatingFocusEl.focus({
456
+ preventScroll: true
457
+ });
458
+ }
459
+ }
460
+ };
461
+ return itemProps;
462
+ }, [
463
+ syncCurrentTarget,
464
+ latestOpenRef,
465
+ floatingFocusElementRef,
466
+ focusItemOnHover,
467
+ listRef,
468
+ onNavigate,
469
+ resetOnPointerLeaveRef,
470
+ virtual
471
+ ]);
472
+ const ariaActiveDescendantProp = __rspack_external_react.useMemo(()=>virtual && open && hasActiveIndex && {
473
+ 'aria-activedescendant': `${id}-${activeIndex}`
474
+ }, [
475
+ virtual,
476
+ open,
477
+ hasActiveIndex,
478
+ id,
479
+ activeIndex
480
+ ]);
481
+ const floating = __rspack_external_react.useMemo(()=>({
482
+ 'aria-orientation': 'both' === orientation ? void 0 : orientation,
483
+ ...!typeableComboboxReference ? ariaActiveDescendantProp : {},
484
+ onKeyDown (event) {
485
+ if ('Tab' === event.key && event.shiftKey && open && !virtual) {
486
+ const target = getTarget(event.nativeEvent);
487
+ if (target && !contains(floatingFocusElementRef.current, target)) return;
488
+ stopEvent(event);
489
+ store.setOpen(false, createChangeEventDetails(focusOut, event.nativeEvent));
490
+ if (isHTMLElement(domReferenceElement)) domReferenceElement.focus();
491
+ return;
492
+ }
493
+ commonOnKeyDown(event);
494
+ },
495
+ onPointerMove () {
496
+ isPointerModalityRef.current = true;
497
+ }
498
+ }), [
499
+ ariaActiveDescendantProp,
500
+ commonOnKeyDown,
501
+ floatingFocusElementRef,
502
+ orientation,
503
+ typeableComboboxReference,
504
+ store,
505
+ open,
506
+ virtual,
507
+ domReferenceElement
508
+ ]);
509
+ const trigger = __rspack_external_react.useMemo(()=>{
510
+ function openOnNavigationKeyDown(event) {
511
+ store.setOpen(true, createChangeEventDetails(listNavigation, event.nativeEvent, event.currentTarget));
512
+ }
513
+ function checkVirtualMouse(event) {
514
+ if ('auto' === focusItemOnOpen && isVirtualClick(event.nativeEvent)) focusItemOnOpenRef.current = !virtual;
515
+ }
516
+ function checkVirtualPointer(event) {
517
+ focusItemOnOpenRef.current = focusItemOnOpen;
518
+ if ('auto' === focusItemOnOpen && isVirtualPointerEvent(event.nativeEvent)) focusItemOnOpenRef.current = true;
519
+ }
520
+ return {
521
+ onKeyDown (event) {
522
+ const currentOpen = store.select('open');
523
+ isPointerModalityRef.current = false;
524
+ const isArrowKey = event.key.startsWith('Arrow');
525
+ const isParentCrossOpenKey = isCrossOrientationOpenKey(event.key, getParentOrientation(), rtl);
526
+ const isMainKey = isMainOrientationKey(event.key, orientation);
527
+ const isNavigationKey = (nested ? isParentCrossOpenKey : isMainKey) || 'Enter' === event.key || '' === event.key.trim();
528
+ if (virtual && currentOpen) return commonOnKeyDown(event);
529
+ if (!currentOpen && !openOnArrowKeyDown && isArrowKey) return;
530
+ if (isNavigationKey) {
531
+ const isParentMainKey = isMainOrientationKey(event.key, getParentOrientation());
532
+ keyRef.current = nested && isParentMainKey ? null : event.key;
533
+ }
534
+ if (nested) {
535
+ if (isParentCrossOpenKey) {
536
+ stopEvent(event);
537
+ if (currentOpen) {
538
+ indexRef.current = getMinEnabledIndex();
539
+ onNavigate(event);
540
+ } else openOnNavigationKeyDown(event);
541
+ }
542
+ return;
543
+ }
544
+ if (isMainKey) {
545
+ if (null != selectedIndexRef.current) indexRef.current = selectedIndexRef.current;
546
+ stopEvent(event);
547
+ if (!currentOpen && openOnArrowKeyDown) openOnNavigationKeyDown(event);
548
+ else commonOnKeyDown(event);
549
+ if (currentOpen) onNavigate(event);
550
+ }
551
+ },
552
+ onFocus (event) {
553
+ if (store.select('open') && !virtual) {
554
+ indexRef.current = -1;
555
+ onNavigate(event);
556
+ }
557
+ },
558
+ onPointerDown: checkVirtualPointer,
559
+ onPointerEnter: checkVirtualPointer,
560
+ onMouseDown: checkVirtualMouse,
561
+ onClick: checkVirtualMouse
562
+ };
563
+ }, [
564
+ commonOnKeyDown,
565
+ focusItemOnOpen,
566
+ getMinEnabledIndex,
567
+ nested,
568
+ onNavigate,
569
+ store,
570
+ openOnArrowKeyDown,
571
+ orientation,
572
+ getParentOrientation,
573
+ rtl,
574
+ selectedIndexRef,
575
+ virtual
576
+ ]);
577
+ const reference = __rspack_external_react.useMemo(()=>({
578
+ ...ariaActiveDescendantProp,
579
+ ...trigger
580
+ }), [
581
+ ariaActiveDescendantProp,
582
+ trigger
583
+ ]);
584
+ return __rspack_external_react.useMemo(()=>enabled ? {
585
+ reference,
586
+ floating,
587
+ item,
588
+ trigger
589
+ } : {}, [
590
+ enabled,
591
+ reference,
592
+ floating,
593
+ trigger,
594
+ item
595
+ ]);
596
+ }
597
+ export { useListNavigation, useTypeahead };
package/dist/5659.js ADDED
@@ -0,0 +1,4 @@
1
+ function areArraysEqual(array1, array2, itemComparer = (a, b)=>a === b) {
2
+ return array1.length === array2.length && array1.every((value, index)=>itemComparer(value, array2[index]));
3
+ }
4
+ export { areArraysEqual };
package/dist/5778.js ADDED
@@ -0,0 +1,10 @@
1
+ function serializeValue(value) {
2
+ if (null == value) return '';
3
+ if ('string' == typeof value) return value;
4
+ try {
5
+ return JSON.stringify(value);
6
+ } catch {
7
+ return String(value);
8
+ }
9
+ }
10
+ export { serializeValue };