@tamagui/floating 2.7.6 → 3.0.0-beta.637.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.
Files changed (151) hide show
  1. package/dist/cjs/Floating.cjs +10 -11
  2. package/dist/cjs/Floating.native.cjs +37 -0
  3. package/dist/cjs/Floating.native.js +20 -20
  4. package/dist/cjs/Floating.native.js.map +1 -1
  5. package/dist/cjs/index.cjs +45 -46
  6. package/dist/cjs/index.native.cjs +74 -0
  7. package/dist/cjs/index.native.js +45 -45
  8. package/dist/cjs/index.native.js.map +1 -1
  9. package/dist/cjs/interactions/PopupTriggerMap.cjs +36 -39
  10. package/dist/cjs/interactions/PopupTriggerMap.native.cjs +96 -0
  11. package/dist/cjs/interactions/PopupTriggerMap.native.js +76 -75
  12. package/dist/cjs/interactions/PopupTriggerMap.native.js.map +1 -1
  13. package/dist/cjs/interactions/createFloatingEvents.cjs +36 -39
  14. package/dist/cjs/interactions/createFloatingEvents.native.cjs +52 -0
  15. package/dist/cjs/interactions/createFloatingEvents.native.js +39 -41
  16. package/dist/cjs/interactions/createFloatingEvents.native.js.map +1 -1
  17. package/dist/cjs/interactions/safePolygon.cjs +263 -252
  18. package/dist/cjs/interactions/safePolygon.native.cjs +294 -0
  19. package/dist/cjs/interactions/safePolygon.native.js +271 -259
  20. package/dist/cjs/interactions/safePolygon.native.js.map +1 -1
  21. package/dist/cjs/interactions/types.cjs +10 -11
  22. package/dist/cjs/interactions/types.native.cjs +19 -0
  23. package/dist/cjs/interactions/types.native.js +10 -10
  24. package/dist/cjs/interactions/types.native.js.map +1 -1
  25. package/dist/cjs/interactions/useClick.cjs +96 -105
  26. package/dist/cjs/interactions/useClick.native.cjs +122 -0
  27. package/dist/cjs/interactions/useClick.native.js +101 -109
  28. package/dist/cjs/interactions/useClick.native.js.map +1 -1
  29. package/dist/cjs/interactions/useDelayGroup.cjs +86 -91
  30. package/dist/cjs/interactions/useDelayGroup.native.cjs +119 -0
  31. package/dist/cjs/interactions/useDelayGroup.native.js +92 -96
  32. package/dist/cjs/interactions/useDelayGroup.native.js.map +1 -1
  33. package/dist/cjs/interactions/useFocus.cjs +108 -115
  34. package/dist/cjs/interactions/useFocus.native.cjs +131 -0
  35. package/dist/cjs/interactions/useFocus.native.js +114 -120
  36. package/dist/cjs/interactions/useFocus.native.js.map +1 -1
  37. package/dist/cjs/interactions/useHover.cjs +321 -335
  38. package/dist/cjs/interactions/useHover.native.cjs +357 -0
  39. package/dist/cjs/interactions/useHover.native.js +333 -347
  40. package/dist/cjs/interactions/useHover.native.js.map +1 -1
  41. package/dist/cjs/interactions/useInnerOffset.cjs +103 -111
  42. package/dist/cjs/interactions/useInnerOffset.native.cjs +132 -0
  43. package/dist/cjs/interactions/useInnerOffset.native.js +113 -120
  44. package/dist/cjs/interactions/useInnerOffset.native.js.map +1 -1
  45. package/dist/cjs/interactions/useInteractions.cjs +85 -90
  46. package/dist/cjs/interactions/useInteractions.native.cjs +199 -0
  47. package/dist/cjs/interactions/useInteractions.native.js +180 -195
  48. package/dist/cjs/interactions/useInteractions.native.js.map +1 -1
  49. package/dist/cjs/interactions/useListNavigation.cjs +404 -390
  50. package/dist/cjs/interactions/useListNavigation.native.cjs +446 -0
  51. package/dist/cjs/interactions/useListNavigation.native.js +416 -401
  52. package/dist/cjs/interactions/useListNavigation.native.js.map +1 -1
  53. package/dist/cjs/interactions/useRole.cjs +92 -106
  54. package/dist/cjs/interactions/useRole.native.cjs +121 -0
  55. package/dist/cjs/interactions/useRole.native.js +103 -116
  56. package/dist/cjs/interactions/useRole.native.js.map +1 -1
  57. package/dist/cjs/interactions/useTypeahead.cjs +115 -129
  58. package/dist/cjs/interactions/useTypeahead.native.cjs +144 -0
  59. package/dist/cjs/interactions/useTypeahead.native.js +128 -141
  60. package/dist/cjs/interactions/useTypeahead.native.js.map +1 -1
  61. package/dist/cjs/interactions/utils.cjs +126 -143
  62. package/dist/cjs/interactions/utils.native.cjs +209 -0
  63. package/dist/cjs/interactions/utils.native.js +138 -154
  64. package/dist/cjs/interactions/utils.native.js.map +1 -1
  65. package/dist/cjs/middleware/inner.cjs +74 -101
  66. package/dist/cjs/middleware/inner.native.cjs +102 -0
  67. package/dist/cjs/middleware/inner.native.js +83 -109
  68. package/dist/cjs/middleware/inner.native.js.map +1 -1
  69. package/dist/cjs/useFloating.cjs +34 -46
  70. package/dist/cjs/useFloating.native.cjs +56 -0
  71. package/dist/cjs/useFloating.native.js +37 -48
  72. package/dist/cjs/useFloating.native.js.map +1 -1
  73. package/dist/esm/Floating.mjs +1 -2
  74. package/dist/esm/Floating.native.js +6 -4
  75. package/dist/esm/Floating.native.js.map +1 -1
  76. package/dist/esm/index.js +4 -5
  77. package/dist/esm/index.mjs +4 -5
  78. package/dist/esm/index.native.js +4 -5
  79. package/dist/esm/interactions/PopupTriggerMap.mjs +23 -22
  80. package/dist/esm/interactions/PopupTriggerMap.mjs.map +1 -1
  81. package/dist/esm/interactions/PopupTriggerMap.native.js +62 -58
  82. package/dist/esm/interactions/PopupTriggerMap.native.js.map +1 -1
  83. package/dist/esm/interactions/createFloatingEvents.mjs +22 -21
  84. package/dist/esm/interactions/createFloatingEvents.mjs.map +1 -1
  85. package/dist/esm/interactions/createFloatingEvents.native.js +25 -24
  86. package/dist/esm/interactions/createFloatingEvents.native.js.map +1 -1
  87. package/dist/esm/interactions/safePolygon.mjs +250 -234
  88. package/dist/esm/interactions/safePolygon.mjs.map +1 -1
  89. package/dist/esm/interactions/safePolygon.native.js +258 -242
  90. package/dist/esm/interactions/safePolygon.native.js.map +1 -1
  91. package/dist/esm/interactions/types.mjs +0 -2
  92. package/dist/esm/interactions/types.native.js +0 -2
  93. package/dist/esm/interactions/useClick.mjs +83 -87
  94. package/dist/esm/interactions/useClick.mjs.map +1 -1
  95. package/dist/esm/interactions/useClick.native.js +88 -92
  96. package/dist/esm/interactions/useClick.native.js.map +1 -1
  97. package/dist/esm/interactions/useDelayGroup.mjs +68 -65
  98. package/dist/esm/interactions/useDelayGroup.mjs.map +1 -1
  99. package/dist/esm/interactions/useDelayGroup.native.js +74 -71
  100. package/dist/esm/interactions/useDelayGroup.native.js.map +1 -1
  101. package/dist/esm/interactions/useFocus.mjs +95 -97
  102. package/dist/esm/interactions/useFocus.mjs.map +1 -1
  103. package/dist/esm/interactions/useFocus.native.js +101 -103
  104. package/dist/esm/interactions/useFocus.native.js.map +1 -1
  105. package/dist/esm/interactions/useHover.mjs +304 -310
  106. package/dist/esm/interactions/useHover.mjs.map +1 -1
  107. package/dist/esm/interactions/useHover.native.js +316 -323
  108. package/dist/esm/interactions/useHover.native.js.map +1 -1
  109. package/dist/esm/interactions/useInnerOffset.mjs +87 -85
  110. package/dist/esm/interactions/useInnerOffset.mjs.map +1 -1
  111. package/dist/esm/interactions/useInnerOffset.native.js +97 -95
  112. package/dist/esm/interactions/useInnerOffset.native.js.map +1 -1
  113. package/dist/esm/interactions/useInteractions.mjs +71 -72
  114. package/dist/esm/interactions/useInteractions.mjs.map +1 -1
  115. package/dist/esm/interactions/useInteractions.native.js +166 -178
  116. package/dist/esm/interactions/useInteractions.native.js.map +1 -1
  117. package/dist/esm/interactions/useListNavigation.mjs +392 -373
  118. package/dist/esm/interactions/useListNavigation.mjs.map +1 -1
  119. package/dist/esm/interactions/useListNavigation.native.js +404 -385
  120. package/dist/esm/interactions/useListNavigation.native.js.map +1 -1
  121. package/dist/esm/interactions/useRole.mjs +76 -80
  122. package/dist/esm/interactions/useRole.mjs.map +1 -1
  123. package/dist/esm/interactions/useRole.native.js +87 -91
  124. package/dist/esm/interactions/useRole.native.js.map +1 -1
  125. package/dist/esm/interactions/useTypeahead.mjs +102 -111
  126. package/dist/esm/interactions/useTypeahead.mjs.map +1 -1
  127. package/dist/esm/interactions/useTypeahead.native.js +115 -124
  128. package/dist/esm/interactions/useTypeahead.native.js.map +1 -1
  129. package/dist/esm/interactions/utils.mjs +91 -106
  130. package/dist/esm/interactions/utils.mjs.map +1 -1
  131. package/dist/esm/interactions/utils.native.js +103 -118
  132. package/dist/esm/interactions/utils.native.js.map +1 -1
  133. package/dist/esm/middleware/inner.mjs +58 -75
  134. package/dist/esm/middleware/inner.mjs.map +1 -1
  135. package/dist/esm/middleware/inner.native.js +67 -84
  136. package/dist/esm/middleware/inner.native.js.map +1 -1
  137. package/dist/esm/useFloating.mjs +17 -21
  138. package/dist/esm/useFloating.mjs.map +1 -1
  139. package/dist/esm/useFloating.native.js +19 -23
  140. package/dist/esm/useFloating.native.js.map +1 -1
  141. package/package.json +6 -5
  142. package/types/interactions/PopupTriggerMap.d.ts.map +1 -1
  143. package/types/interactions/useInteractions.d.ts.map +1 -1
  144. package/types/middleware/inner.d.ts.map +1 -1
  145. package/types/useFloating.d.ts.map +1 -1
  146. package/dist/esm/Floating.mjs.map +0 -1
  147. package/dist/esm/index.js.map +0 -1
  148. package/dist/esm/index.mjs.map +0 -1
  149. package/dist/esm/index.native.js.map +0 -1
  150. package/dist/esm/interactions/types.mjs.map +0 -1
  151. package/dist/esm/interactions/types.native.js.map +0 -1
@@ -0,0 +1,446 @@
1
+ "use strict";
2
+
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var useListNavigation_exports = {};
25
+ __export(useListNavigation_exports, { useListNavigation: () => useListNavigation });
26
+ module.exports = __toCommonJS(useListNavigation_exports);
27
+ var import_react = require("react");
28
+ var import_use_event = require("@tamagui/use-event");
29
+ var import_utils = require("./utils.native.js");
30
+ var ARROW_UP = "ArrowUp";
31
+ var ARROW_DOWN = "ArrowDown";
32
+ var ARROW_LEFT = "ArrowLeft";
33
+ var ARROW_RIGHT = "ArrowRight";
34
+ function doSwitch(orientation, vertical, horizontal) {
35
+ switch (orientation) {
36
+ case "vertical": return vertical;
37
+ case "horizontal": return horizontal;
38
+ default: return vertical || horizontal;
39
+ }
40
+ }
41
+ function isMainOrientationKey(key, orientation) {
42
+ var vertical = key === ARROW_UP || key === ARROW_DOWN;
43
+ var horizontal = key === ARROW_LEFT || key === ARROW_RIGHT;
44
+ return doSwitch(orientation, vertical, horizontal);
45
+ }
46
+ function isMainOrientationToEndKey(key, orientation, rtl) {
47
+ var vertical = key === ARROW_DOWN;
48
+ var horizontal = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;
49
+ return doSwitch(orientation, vertical, horizontal) || key === "Enter" || key === " " || key === "";
50
+ }
51
+ function isCrossOrientationOpenKey(key, orientation, rtl) {
52
+ var vertical = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;
53
+ var horizontal = key === ARROW_DOWN;
54
+ return doSwitch(orientation, vertical, horizontal);
55
+ }
56
+ function isCrossOrientationCloseKey(key, orientation, rtl) {
57
+ var vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;
58
+ var horizontal = key === ARROW_UP;
59
+ return doSwitch(orientation, vertical, horizontal);
60
+ }
61
+ function useListNavigation(context, props) {
62
+ var { open, onOpenChange, elements } = context;
63
+ var { listRef, activeIndex, onNavigate: unstable_onNavigate = function() {}, enabled = true, selectedIndex = null, allowEscape = false, loop = false, nested = false, rtl = false, virtual = false, focusItemOnOpen = "auto", focusItemOnHover = true, openOnArrowKeyDown = true, disabledIndices = void 0, orientation = "vertical", scrollItemIntoView = true } = props;
64
+ var typeableComboboxReference = (0, import_utils.isTypeableCombobox)(elements.domReference);
65
+ var focusItemOnOpenRef = (0, import_react.useRef)(focusItemOnOpen);
66
+ var indexRef = (0, import_react.useRef)(selectedIndex !== null && selectedIndex !== void 0 ? selectedIndex : -1);
67
+ var keyRef = (0, import_react.useRef)(null);
68
+ var isPointerModalityRef = (0, import_react.useRef)(true);
69
+ var previousMountedRef = (0, import_react.useRef)(!!elements.floating);
70
+ var previousOpenRef = (0, import_react.useRef)(open);
71
+ var forceSyncFocusRef = (0, import_react.useRef)(false);
72
+ var forceScrollIntoViewRef = (0, import_react.useRef)(false);
73
+ var disabledIndicesRef = (0, import_react.useRef)(disabledIndices);
74
+ disabledIndicesRef.current = disabledIndices;
75
+ var latestOpenRef = (0, import_react.useRef)(open);
76
+ latestOpenRef.current = open;
77
+ var scrollItemIntoViewRef = (0, import_react.useRef)(scrollItemIntoView);
78
+ scrollItemIntoViewRef.current = scrollItemIntoView;
79
+ var selectedIndexRef = (0, import_react.useRef)(selectedIndex);
80
+ selectedIndexRef.current = selectedIndex;
81
+ var stableOnNavigate = (0, import_use_event.useEvent)(unstable_onNavigate);
82
+ var [activeId, setActiveId] = (0, import_react.useState)();
83
+ var onNavigate = (0, import_use_event.useEvent)(function() {
84
+ stableOnNavigate(indexRef.current === -1 ? null : indexRef.current);
85
+ });
86
+ var previousOnNavigateRef = (0, import_react.useRef)(onNavigate);
87
+ var focusItem = (0, import_use_event.useEvent)(function() {
88
+ function runFocus(item2) {
89
+ if (virtual) {
90
+ setActiveId(item2.id);
91
+ } else {
92
+ (0, import_utils.enqueueFocus)(item2, {
93
+ sync: forceSyncFocusRef.current,
94
+ preventScroll: true
95
+ });
96
+ }
97
+ }
98
+ var initialItem = listRef.current[indexRef.current];
99
+ var forceScrollIntoView = forceScrollIntoViewRef.current;
100
+ if (initialItem) {
101
+ runFocus(initialItem);
102
+ }
103
+ var scheduler = forceSyncFocusRef.current ? function(v) {
104
+ return v();
105
+ } : requestAnimationFrame;
106
+ scheduler(function() {
107
+ var waitedItem = listRef.current[indexRef.current] || initialItem;
108
+ if (!waitedItem) return;
109
+ if (!initialItem) {
110
+ runFocus(waitedItem);
111
+ }
112
+ var scrollIntoViewOptions = scrollItemIntoViewRef.current;
113
+ var shouldScrollIntoView = scrollIntoViewOptions && waitedItem && (forceScrollIntoView || !isPointerModalityRef.current);
114
+ if (shouldScrollIntoView) {
115
+ var _waitedItem_scrollIntoView;
116
+ (_waitedItem_scrollIntoView = waitedItem.scrollIntoView) === null || _waitedItem_scrollIntoView === void 0 ? void 0 : _waitedItem_scrollIntoView.call(waitedItem, typeof scrollIntoViewOptions === "boolean" ? {
117
+ block: "nearest",
118
+ inline: "nearest"
119
+ } : scrollIntoViewOptions);
120
+ }
121
+ });
122
+ });
123
+ (0, import_react.useLayoutEffect)(function() {
124
+ if (!enabled) return;
125
+ if (open && elements.floating) {
126
+ if (focusItemOnOpenRef.current && selectedIndex != null) {
127
+ forceScrollIntoViewRef.current = true;
128
+ indexRef.current = selectedIndex;
129
+ onNavigate();
130
+ }
131
+ } else if (previousMountedRef.current) {
132
+ indexRef.current = -1;
133
+ previousOnNavigateRef.current();
134
+ }
135
+ }, [
136
+ enabled,
137
+ open,
138
+ elements.floating,
139
+ selectedIndex,
140
+ onNavigate
141
+ ]);
142
+ (0, import_react.useLayoutEffect)(function() {
143
+ if (!enabled) return;
144
+ if (!open) return;
145
+ if (!elements.floating) return;
146
+ if (activeIndex == null) {
147
+ forceSyncFocusRef.current = false;
148
+ if (selectedIndexRef.current != null) {
149
+ return;
150
+ }
151
+ if (previousMountedRef.current) {
152
+ indexRef.current = -1;
153
+ focusItem();
154
+ }
155
+ if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) {
156
+ var runs = 0;
157
+ var waitForListPopulated = function() {
158
+ if (listRef.current[0] == null) {
159
+ if (runs < 2) {
160
+ var scheduler = runs ? requestAnimationFrame : queueMicrotask;
161
+ scheduler(waitForListPopulated);
162
+ }
163
+ runs++;
164
+ } else {
165
+ indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ? (0, import_utils.getMinListIndex)(listRef, disabledIndicesRef.current) : (0, import_utils.getMaxListIndex)(listRef, disabledIndicesRef.current);
166
+ keyRef.current = null;
167
+ onNavigate();
168
+ }
169
+ };
170
+ waitForListPopulated();
171
+ }
172
+ } else if (!(0, import_utils.isIndexOutOfListBounds)(listRef, activeIndex)) {
173
+ indexRef.current = activeIndex;
174
+ focusItem();
175
+ forceScrollIntoViewRef.current = false;
176
+ }
177
+ }, [
178
+ enabled,
179
+ open,
180
+ elements.floating,
181
+ activeIndex,
182
+ selectedIndexRef,
183
+ nested,
184
+ listRef,
185
+ orientation,
186
+ rtl,
187
+ onNavigate,
188
+ focusItem,
189
+ disabledIndicesRef
190
+ ]);
191
+ (0, import_react.useLayoutEffect)(function() {
192
+ previousOnNavigateRef.current = onNavigate;
193
+ previousOpenRef.current = open;
194
+ previousMountedRef.current = !!elements.floating;
195
+ });
196
+ (0, import_react.useLayoutEffect)(function() {
197
+ if (!open) {
198
+ keyRef.current = null;
199
+ focusItemOnOpenRef.current = focusItemOnOpen;
200
+ }
201
+ }, [open, focusItemOnOpen]);
202
+ var hasActiveIndex = activeIndex != null;
203
+ var commonOnKeyDown = (0, import_use_event.useEvent)(function(event) {
204
+ isPointerModalityRef.current = false;
205
+ forceSyncFocusRef.current = true;
206
+ if (event.which === 229) {
207
+ return;
208
+ }
209
+ if (!latestOpenRef.current && event.currentTarget === elements.floating) {
210
+ return;
211
+ }
212
+ if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl)) {
213
+ (0, import_utils.stopEvent)(event);
214
+ onOpenChange(false, event.nativeEvent, "list-navigation");
215
+ if ((0, import_utils.isHTMLElement)(elements.domReference)) {
216
+ elements.domReference.focus();
217
+ }
218
+ return;
219
+ }
220
+ var currentIndex = indexRef.current;
221
+ var minIndex = (0, import_utils.getMinListIndex)(listRef, disabledIndices);
222
+ var maxIndex = (0, import_utils.getMaxListIndex)(listRef, disabledIndices);
223
+ if (!typeableComboboxReference) {
224
+ if (event.key === "Home") {
225
+ (0, import_utils.stopEvent)(event);
226
+ indexRef.current = minIndex;
227
+ onNavigate();
228
+ }
229
+ if (event.key === "End") {
230
+ (0, import_utils.stopEvent)(event);
231
+ indexRef.current = maxIndex;
232
+ onNavigate();
233
+ }
234
+ }
235
+ if (isMainOrientationKey(event.key, orientation)) {
236
+ (0, import_utils.stopEvent)(event);
237
+ if (open && !virtual && (0, import_utils.activeElement)(event.currentTarget.ownerDocument) === event.currentTarget) {
238
+ indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;
239
+ onNavigate();
240
+ return;
241
+ }
242
+ if (isMainOrientationToEndKey(event.key, orientation, rtl)) {
243
+ if (loop) {
244
+ indexRef.current = currentIndex >= maxIndex ? allowEscape && currentIndex !== listRef.current.length ? -1 : minIndex : (0, import_utils.findNonDisabledListIndex)(listRef, {
245
+ startingIndex: currentIndex,
246
+ disabledIndices
247
+ });
248
+ } else {
249
+ indexRef.current = Math.min(maxIndex, (0, import_utils.findNonDisabledListIndex)(listRef, {
250
+ startingIndex: currentIndex,
251
+ disabledIndices
252
+ }));
253
+ }
254
+ } else {
255
+ if (loop) {
256
+ indexRef.current = currentIndex <= minIndex ? allowEscape && currentIndex !== -1 ? listRef.current.length : maxIndex : (0, import_utils.findNonDisabledListIndex)(listRef, {
257
+ startingIndex: currentIndex,
258
+ decrement: true,
259
+ disabledIndices
260
+ });
261
+ } else {
262
+ indexRef.current = Math.max(minIndex, (0, import_utils.findNonDisabledListIndex)(listRef, {
263
+ startingIndex: currentIndex,
264
+ decrement: true,
265
+ disabledIndices
266
+ }));
267
+ }
268
+ }
269
+ if ((0, import_utils.isIndexOutOfListBounds)(listRef, indexRef.current)) {
270
+ indexRef.current = -1;
271
+ }
272
+ onNavigate();
273
+ }
274
+ });
275
+ var ariaActiveDescendantProp = (0, import_react.useMemo)(function() {
276
+ return virtual && open && hasActiveIndex && { "aria-activedescendant": activeId };
277
+ }, [
278
+ virtual,
279
+ open,
280
+ hasActiveIndex,
281
+ activeId
282
+ ]);
283
+ var floating = (0, import_react.useMemo)(function() {
284
+ return {
285
+ "aria-orientation": orientation === "both" ? void 0 : orientation,
286
+ ...!typeableComboboxReference ? ariaActiveDescendantProp : {},
287
+ onKeyDown: commonOnKeyDown,
288
+ onPointerMove() {
289
+ isPointerModalityRef.current = true;
290
+ }
291
+ };
292
+ }, [
293
+ ariaActiveDescendantProp,
294
+ commonOnKeyDown,
295
+ orientation,
296
+ typeableComboboxReference
297
+ ]);
298
+ var reference = (0, import_react.useMemo)(function() {
299
+ function checkVirtualMouse(event) {
300
+ if (focusItemOnOpen === "auto" && (0, import_utils.isVirtualClick)(event.nativeEvent)) {
301
+ focusItemOnOpenRef.current = true;
302
+ }
303
+ }
304
+ function checkVirtualPointer(event) {
305
+ focusItemOnOpenRef.current = focusItemOnOpen;
306
+ if (focusItemOnOpen === "auto" && (0, import_utils.isVirtualPointerEvent)(event.nativeEvent)) {
307
+ focusItemOnOpenRef.current = true;
308
+ }
309
+ }
310
+ return {
311
+ ...ariaActiveDescendantProp,
312
+ onKeyDown(event) {
313
+ isPointerModalityRef.current = false;
314
+ var isArrowKey = event.key.startsWith("Arrow");
315
+ var isCrossOpenKey = isCrossOrientationOpenKey(event.key, orientation, rtl);
316
+ var isMainKey = isMainOrientationKey(event.key, orientation);
317
+ var isNavigationKey = (nested ? isCrossOpenKey : isMainKey) || event.key === "Enter" || event.key.trim() === "";
318
+ if (virtual && open) {
319
+ return commonOnKeyDown(event);
320
+ }
321
+ if (!open && !openOnArrowKeyDown && isArrowKey) {
322
+ return;
323
+ }
324
+ if (isNavigationKey) {
325
+ keyRef.current = event.key;
326
+ }
327
+ if (nested) {
328
+ if (isCrossOpenKey) {
329
+ (0, import_utils.stopEvent)(event);
330
+ if (open) {
331
+ indexRef.current = (0, import_utils.getMinListIndex)(listRef, disabledIndicesRef.current);
332
+ onNavigate();
333
+ } else {
334
+ onOpenChange(true, event.nativeEvent, "list-navigation");
335
+ }
336
+ }
337
+ return;
338
+ }
339
+ if (isMainKey) {
340
+ if (selectedIndex != null) {
341
+ indexRef.current = selectedIndex;
342
+ }
343
+ (0, import_utils.stopEvent)(event);
344
+ if (!open && openOnArrowKeyDown) {
345
+ onOpenChange(true, event.nativeEvent, "list-navigation");
346
+ } else {
347
+ commonOnKeyDown(event);
348
+ }
349
+ if (open) {
350
+ onNavigate();
351
+ }
352
+ }
353
+ },
354
+ onFocus() {
355
+ if (open && !virtual) {
356
+ indexRef.current = -1;
357
+ onNavigate();
358
+ }
359
+ },
360
+ onPointerDown: checkVirtualPointer,
361
+ onPointerEnter: checkVirtualPointer,
362
+ onMouseDown: checkVirtualMouse,
363
+ onClick: checkVirtualMouse
364
+ };
365
+ }, [
366
+ ariaActiveDescendantProp,
367
+ commonOnKeyDown,
368
+ disabledIndicesRef,
369
+ focusItemOnOpen,
370
+ listRef,
371
+ nested,
372
+ onNavigate,
373
+ onOpenChange,
374
+ open,
375
+ openOnArrowKeyDown,
376
+ orientation,
377
+ rtl,
378
+ selectedIndex,
379
+ virtual
380
+ ]);
381
+ var item = (0, import_react.useMemo)(function() {
382
+ function syncCurrentTarget(currentTarget) {
383
+ if (!latestOpenRef.current) return;
384
+ var index = listRef.current.indexOf(currentTarget);
385
+ if (index !== -1 && indexRef.current !== index) {
386
+ indexRef.current = index;
387
+ onNavigate();
388
+ }
389
+ }
390
+ var itemProps = {
391
+ onFocus(param) {
392
+ var { currentTarget } = param;
393
+ forceSyncFocusRef.current = true;
394
+ syncCurrentTarget(currentTarget);
395
+ },
396
+ onClick: function(param) {
397
+ var { currentTarget } = param;
398
+ return currentTarget.focus({ preventScroll: true });
399
+ },
400
+ onMouseMove(param) {
401
+ var { currentTarget } = param;
402
+ forceSyncFocusRef.current = true;
403
+ forceScrollIntoViewRef.current = false;
404
+ if (focusItemOnHover) {
405
+ syncCurrentTarget(currentTarget);
406
+ }
407
+ },
408
+ onPointerLeave(param) {
409
+ var { pointerType } = param;
410
+ if (!isPointerModalityRef.current || pointerType === "touch") {
411
+ return;
412
+ }
413
+ forceSyncFocusRef.current = true;
414
+ if (!focusItemOnHover) {
415
+ return;
416
+ }
417
+ indexRef.current = -1;
418
+ onNavigate();
419
+ if (!virtual) {
420
+ var _elements_floating;
421
+ (_elements_floating = elements.floating) === null || _elements_floating === void 0 ? void 0 : _elements_floating.focus({ preventScroll: true });
422
+ }
423
+ }
424
+ };
425
+ return itemProps;
426
+ }, [
427
+ latestOpenRef,
428
+ focusItemOnHover,
429
+ listRef,
430
+ onNavigate,
431
+ virtual,
432
+ elements.floating
433
+ ]);
434
+ return (0, import_react.useMemo)(function() {
435
+ return enabled ? {
436
+ reference,
437
+ floating,
438
+ item
439
+ } : {};
440
+ }, [
441
+ enabled,
442
+ reference,
443
+ floating,
444
+ item
445
+ ]);
446
+ }