@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.
- package/dist/cjs/Floating.cjs +10 -11
- package/dist/cjs/Floating.native.cjs +37 -0
- package/dist/cjs/Floating.native.js +20 -20
- package/dist/cjs/Floating.native.js.map +1 -1
- package/dist/cjs/index.cjs +45 -46
- package/dist/cjs/index.native.cjs +74 -0
- package/dist/cjs/index.native.js +45 -45
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/interactions/PopupTriggerMap.cjs +36 -39
- package/dist/cjs/interactions/PopupTriggerMap.native.cjs +96 -0
- package/dist/cjs/interactions/PopupTriggerMap.native.js +76 -75
- package/dist/cjs/interactions/PopupTriggerMap.native.js.map +1 -1
- package/dist/cjs/interactions/createFloatingEvents.cjs +36 -39
- package/dist/cjs/interactions/createFloatingEvents.native.cjs +52 -0
- package/dist/cjs/interactions/createFloatingEvents.native.js +39 -41
- package/dist/cjs/interactions/createFloatingEvents.native.js.map +1 -1
- package/dist/cjs/interactions/safePolygon.cjs +263 -252
- package/dist/cjs/interactions/safePolygon.native.cjs +294 -0
- package/dist/cjs/interactions/safePolygon.native.js +271 -259
- package/dist/cjs/interactions/safePolygon.native.js.map +1 -1
- package/dist/cjs/interactions/types.cjs +10 -11
- package/dist/cjs/interactions/types.native.cjs +19 -0
- package/dist/cjs/interactions/types.native.js +10 -10
- package/dist/cjs/interactions/types.native.js.map +1 -1
- package/dist/cjs/interactions/useClick.cjs +96 -105
- package/dist/cjs/interactions/useClick.native.cjs +122 -0
- package/dist/cjs/interactions/useClick.native.js +101 -109
- package/dist/cjs/interactions/useClick.native.js.map +1 -1
- package/dist/cjs/interactions/useDelayGroup.cjs +86 -91
- package/dist/cjs/interactions/useDelayGroup.native.cjs +119 -0
- package/dist/cjs/interactions/useDelayGroup.native.js +92 -96
- package/dist/cjs/interactions/useDelayGroup.native.js.map +1 -1
- package/dist/cjs/interactions/useFocus.cjs +108 -115
- package/dist/cjs/interactions/useFocus.native.cjs +131 -0
- package/dist/cjs/interactions/useFocus.native.js +114 -120
- package/dist/cjs/interactions/useFocus.native.js.map +1 -1
- package/dist/cjs/interactions/useHover.cjs +321 -335
- package/dist/cjs/interactions/useHover.native.cjs +357 -0
- package/dist/cjs/interactions/useHover.native.js +333 -347
- package/dist/cjs/interactions/useHover.native.js.map +1 -1
- package/dist/cjs/interactions/useInnerOffset.cjs +103 -111
- package/dist/cjs/interactions/useInnerOffset.native.cjs +132 -0
- package/dist/cjs/interactions/useInnerOffset.native.js +113 -120
- package/dist/cjs/interactions/useInnerOffset.native.js.map +1 -1
- package/dist/cjs/interactions/useInteractions.cjs +85 -90
- package/dist/cjs/interactions/useInteractions.native.cjs +199 -0
- package/dist/cjs/interactions/useInteractions.native.js +180 -195
- package/dist/cjs/interactions/useInteractions.native.js.map +1 -1
- package/dist/cjs/interactions/useListNavigation.cjs +404 -390
- package/dist/cjs/interactions/useListNavigation.native.cjs +446 -0
- package/dist/cjs/interactions/useListNavigation.native.js +416 -401
- package/dist/cjs/interactions/useListNavigation.native.js.map +1 -1
- package/dist/cjs/interactions/useRole.cjs +92 -106
- package/dist/cjs/interactions/useRole.native.cjs +121 -0
- package/dist/cjs/interactions/useRole.native.js +103 -116
- package/dist/cjs/interactions/useRole.native.js.map +1 -1
- package/dist/cjs/interactions/useTypeahead.cjs +115 -129
- package/dist/cjs/interactions/useTypeahead.native.cjs +144 -0
- package/dist/cjs/interactions/useTypeahead.native.js +128 -141
- package/dist/cjs/interactions/useTypeahead.native.js.map +1 -1
- package/dist/cjs/interactions/utils.cjs +126 -143
- package/dist/cjs/interactions/utils.native.cjs +209 -0
- package/dist/cjs/interactions/utils.native.js +138 -154
- package/dist/cjs/interactions/utils.native.js.map +1 -1
- package/dist/cjs/middleware/inner.cjs +74 -101
- package/dist/cjs/middleware/inner.native.cjs +102 -0
- package/dist/cjs/middleware/inner.native.js +83 -109
- package/dist/cjs/middleware/inner.native.js.map +1 -1
- package/dist/cjs/useFloating.cjs +34 -46
- package/dist/cjs/useFloating.native.cjs +56 -0
- package/dist/cjs/useFloating.native.js +37 -48
- package/dist/cjs/useFloating.native.js.map +1 -1
- package/dist/esm/Floating.mjs +1 -2
- package/dist/esm/Floating.native.js +6 -4
- package/dist/esm/Floating.native.js.map +1 -1
- package/dist/esm/index.js +4 -5
- package/dist/esm/index.mjs +4 -5
- package/dist/esm/index.native.js +4 -5
- package/dist/esm/interactions/PopupTriggerMap.mjs +23 -22
- package/dist/esm/interactions/PopupTriggerMap.mjs.map +1 -1
- package/dist/esm/interactions/PopupTriggerMap.native.js +62 -58
- package/dist/esm/interactions/PopupTriggerMap.native.js.map +1 -1
- package/dist/esm/interactions/createFloatingEvents.mjs +22 -21
- package/dist/esm/interactions/createFloatingEvents.mjs.map +1 -1
- package/dist/esm/interactions/createFloatingEvents.native.js +25 -24
- package/dist/esm/interactions/createFloatingEvents.native.js.map +1 -1
- package/dist/esm/interactions/safePolygon.mjs +250 -234
- package/dist/esm/interactions/safePolygon.mjs.map +1 -1
- package/dist/esm/interactions/safePolygon.native.js +258 -242
- package/dist/esm/interactions/safePolygon.native.js.map +1 -1
- package/dist/esm/interactions/types.mjs +0 -2
- package/dist/esm/interactions/types.native.js +0 -2
- package/dist/esm/interactions/useClick.mjs +83 -87
- package/dist/esm/interactions/useClick.mjs.map +1 -1
- package/dist/esm/interactions/useClick.native.js +88 -92
- package/dist/esm/interactions/useClick.native.js.map +1 -1
- package/dist/esm/interactions/useDelayGroup.mjs +68 -65
- package/dist/esm/interactions/useDelayGroup.mjs.map +1 -1
- package/dist/esm/interactions/useDelayGroup.native.js +74 -71
- package/dist/esm/interactions/useDelayGroup.native.js.map +1 -1
- package/dist/esm/interactions/useFocus.mjs +95 -97
- package/dist/esm/interactions/useFocus.mjs.map +1 -1
- package/dist/esm/interactions/useFocus.native.js +101 -103
- package/dist/esm/interactions/useFocus.native.js.map +1 -1
- package/dist/esm/interactions/useHover.mjs +304 -310
- package/dist/esm/interactions/useHover.mjs.map +1 -1
- package/dist/esm/interactions/useHover.native.js +316 -323
- package/dist/esm/interactions/useHover.native.js.map +1 -1
- package/dist/esm/interactions/useInnerOffset.mjs +87 -85
- package/dist/esm/interactions/useInnerOffset.mjs.map +1 -1
- package/dist/esm/interactions/useInnerOffset.native.js +97 -95
- package/dist/esm/interactions/useInnerOffset.native.js.map +1 -1
- package/dist/esm/interactions/useInteractions.mjs +71 -72
- package/dist/esm/interactions/useInteractions.mjs.map +1 -1
- package/dist/esm/interactions/useInteractions.native.js +166 -178
- package/dist/esm/interactions/useInteractions.native.js.map +1 -1
- package/dist/esm/interactions/useListNavigation.mjs +392 -373
- package/dist/esm/interactions/useListNavigation.mjs.map +1 -1
- package/dist/esm/interactions/useListNavigation.native.js +404 -385
- package/dist/esm/interactions/useListNavigation.native.js.map +1 -1
- package/dist/esm/interactions/useRole.mjs +76 -80
- package/dist/esm/interactions/useRole.mjs.map +1 -1
- package/dist/esm/interactions/useRole.native.js +87 -91
- package/dist/esm/interactions/useRole.native.js.map +1 -1
- package/dist/esm/interactions/useTypeahead.mjs +102 -111
- package/dist/esm/interactions/useTypeahead.mjs.map +1 -1
- package/dist/esm/interactions/useTypeahead.native.js +115 -124
- package/dist/esm/interactions/useTypeahead.native.js.map +1 -1
- package/dist/esm/interactions/utils.mjs +91 -106
- package/dist/esm/interactions/utils.mjs.map +1 -1
- package/dist/esm/interactions/utils.native.js +103 -118
- package/dist/esm/interactions/utils.native.js.map +1 -1
- package/dist/esm/middleware/inner.mjs +58 -75
- package/dist/esm/middleware/inner.mjs.map +1 -1
- package/dist/esm/middleware/inner.native.js +67 -84
- package/dist/esm/middleware/inner.native.js.map +1 -1
- package/dist/esm/useFloating.mjs +17 -21
- package/dist/esm/useFloating.mjs.map +1 -1
- package/dist/esm/useFloating.native.js +19 -23
- package/dist/esm/useFloating.native.js.map +1 -1
- package/package.json +6 -5
- package/types/interactions/PopupTriggerMap.d.ts.map +1 -1
- package/types/interactions/useInteractions.d.ts.map +1 -1
- package/types/middleware/inner.d.ts.map +1 -1
- package/types/useFloating.d.ts.map +1 -1
- package/dist/esm/Floating.mjs.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/interactions/types.mjs.map +0 -1
- package/dist/esm/interactions/types.native.js.map +0 -1
|
@@ -1,31 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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;
|
|
21
22
|
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
24
|
var useListNavigation_exports = {};
|
|
26
|
-
__export(useListNavigation_exports, {
|
|
27
|
-
useListNavigation: () => useListNavigation
|
|
28
|
-
});
|
|
25
|
+
__export(useListNavigation_exports, { useListNavigation: () => useListNavigation });
|
|
29
26
|
module.exports = __toCommonJS(useListNavigation_exports);
|
|
30
27
|
var import_react = require("react");
|
|
31
28
|
var import_use_event = require("@tamagui/use-event");
|
|
@@ -35,399 +32,417 @@ var ARROW_DOWN = "ArrowDown";
|
|
|
35
32
|
var ARROW_LEFT = "ArrowLeft";
|
|
36
33
|
var ARROW_RIGHT = "ArrowRight";
|
|
37
34
|
function doSwitch(orientation, vertical, horizontal) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
default:
|
|
44
|
-
return vertical || horizontal;
|
|
45
|
-
}
|
|
35
|
+
switch (orientation) {
|
|
36
|
+
case "vertical": return vertical;
|
|
37
|
+
case "horizontal": return horizontal;
|
|
38
|
+
default: return vertical || horizontal;
|
|
39
|
+
}
|
|
46
40
|
}
|
|
47
41
|
function isMainOrientationKey(key, orientation) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
var vertical = key === ARROW_UP || key === ARROW_DOWN;
|
|
43
|
+
var horizontal = key === ARROW_LEFT || key === ARROW_RIGHT;
|
|
44
|
+
return doSwitch(orientation, vertical, horizontal);
|
|
51
45
|
}
|
|
52
46
|
function isMainOrientationToEndKey(key, orientation, rtl) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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 === "";
|
|
56
50
|
}
|
|
57
51
|
function isCrossOrientationOpenKey(key, orientation, rtl) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
var vertical = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;
|
|
53
|
+
var horizontal = key === ARROW_DOWN;
|
|
54
|
+
return doSwitch(orientation, vertical, horizontal);
|
|
61
55
|
}
|
|
62
56
|
function isCrossOrientationCloseKey(key, orientation, rtl) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
var vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;
|
|
58
|
+
var horizontal = key === ARROW_UP;
|
|
59
|
+
return doSwitch(orientation, vertical, horizontal);
|
|
66
60
|
}
|
|
67
61
|
function useListNavigation(context, props) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
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
|
+
]);
|
|
432
446
|
}
|
|
447
|
+
|
|
433
448
|
//# sourceMappingURL=useListNavigation.native.js.map
|