@tamagui/create-menu 2.7.7 → 3.0.0-beta.643.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/createBaseMenu.cjs +1033 -1247
- package/dist/cjs/createBaseMenu.native.cjs +1217 -0
- package/dist/cjs/createBaseMenu.native.js +1155 -1387
- package/dist/cjs/createBaseMenu.native.js.map +1 -1
- package/dist/cjs/createNativeMenu/createNativeMenu.cjs +346 -377
- package/dist/cjs/createNativeMenu/createNativeMenu.native.cjs +439 -0
- package/dist/cjs/createNativeMenu/createNativeMenu.native.js +405 -439
- package/dist/cjs/createNativeMenu/createNativeMenu.native.js.map +1 -1
- package/dist/cjs/createNativeMenu/createNativeMenuTypes.cjs +10 -11
- package/dist/cjs/createNativeMenu/createNativeMenuTypes.native.cjs +19 -0
- package/dist/cjs/createNativeMenu/createNativeMenuTypes.native.js +10 -10
- package/dist/cjs/createNativeMenu/createNativeMenuTypes.native.js.map +1 -1
- package/dist/cjs/createNativeMenu/utils.cjs +76 -86
- package/dist/cjs/createNativeMenu/utils.native.cjs +107 -0
- package/dist/cjs/createNativeMenu/utils.native.js +82 -92
- package/dist/cjs/createNativeMenu/utils.native.js.map +1 -1
- package/dist/cjs/createNativeMenu/withNativeMenu.cjs +27 -35
- package/dist/cjs/createNativeMenu/withNativeMenu.native.cjs +42 -0
- package/dist/cjs/createNativeMenu/withNativeMenu.native.js +27 -34
- package/dist/cjs/createNativeMenu/withNativeMenu.native.js.map +1 -1
- package/dist/cjs/index.cjs +9 -20
- package/dist/cjs/index.native.cjs +23 -0
- package/dist/cjs/index.native.js +10 -20
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/createBaseMenu.mjs +1021 -1225
- package/dist/esm/createBaseMenu.mjs.map +1 -1
- package/dist/esm/createBaseMenu.native.js +1144 -1367
- package/dist/esm/createBaseMenu.native.js.map +1 -1
- package/dist/esm/createNativeMenu/createNativeMenu.mjs +332 -353
- package/dist/esm/createNativeMenu/createNativeMenu.mjs.map +1 -1
- package/dist/esm/createNativeMenu/createNativeMenu.native.js +392 -417
- package/dist/esm/createNativeMenu/createNativeMenu.native.js.map +1 -1
- package/dist/esm/createNativeMenu/createNativeMenuTypes.mjs +0 -2
- package/dist/esm/createNativeMenu/createNativeMenuTypes.native.js +0 -2
- package/dist/esm/createNativeMenu/utils.mjs +55 -57
- package/dist/esm/createNativeMenu/utils.mjs.map +1 -1
- package/dist/esm/createNativeMenu/utils.native.js +62 -65
- package/dist/esm/createNativeMenu/utils.native.js.map +1 -1
- package/dist/esm/createNativeMenu/withNativeMenu.mjs +14 -17
- package/dist/esm/createNativeMenu/withNativeMenu.mjs.map +1 -1
- package/dist/esm/createNativeMenu/withNativeMenu.native.js +15 -18
- package/dist/esm/createNativeMenu/withNativeMenu.native.js.map +1 -1
- package/dist/esm/index.js +5 -6
- package/dist/esm/index.mjs +5 -6
- package/dist/esm/index.native.js +5 -6
- package/dist/jsx/createBaseMenu.mjs +1021 -1225
- package/dist/jsx/createBaseMenu.mjs.map +1 -1
- package/dist/jsx/createBaseMenu.native.cjs +1217 -0
- package/dist/jsx/createBaseMenu.native.js +1155 -1387
- package/dist/jsx/createBaseMenu.native.js.map +1 -1
- package/dist/jsx/createNativeMenu/createNativeMenu.mjs +332 -353
- package/dist/jsx/createNativeMenu/createNativeMenu.mjs.map +1 -1
- package/dist/jsx/createNativeMenu/createNativeMenu.native.cjs +439 -0
- package/dist/jsx/createNativeMenu/createNativeMenu.native.js +405 -439
- package/dist/jsx/createNativeMenu/createNativeMenu.native.js.map +1 -1
- package/dist/jsx/createNativeMenu/createNativeMenuTypes.mjs +0 -2
- package/dist/jsx/createNativeMenu/createNativeMenuTypes.native.cjs +19 -0
- package/dist/jsx/createNativeMenu/createNativeMenuTypes.native.js +10 -10
- package/dist/jsx/createNativeMenu/createNativeMenuTypes.native.js.map +1 -1
- package/dist/jsx/createNativeMenu/utils.mjs +55 -57
- package/dist/jsx/createNativeMenu/utils.mjs.map +1 -1
- package/dist/jsx/createNativeMenu/utils.native.cjs +107 -0
- package/dist/jsx/createNativeMenu/utils.native.js +82 -92
- package/dist/jsx/createNativeMenu/utils.native.js.map +1 -1
- package/dist/jsx/createNativeMenu/withNativeMenu.mjs +14 -17
- package/dist/jsx/createNativeMenu/withNativeMenu.mjs.map +1 -1
- package/dist/jsx/createNativeMenu/withNativeMenu.native.cjs +42 -0
- package/dist/jsx/createNativeMenu/withNativeMenu.native.js +27 -34
- package/dist/jsx/createNativeMenu/withNativeMenu.native.js.map +1 -1
- package/dist/jsx/index.js +5 -6
- package/dist/jsx/index.mjs +5 -6
- package/dist/jsx/index.native.cjs +23 -0
- package/dist/jsx/index.native.js +10 -20
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +23 -22
- package/src/createBaseMenu.tsx +211 -231
- package/src/createNativeMenu/createNativeMenuTypes.ts +0 -6
- package/src/createNativeMenu/utils.tsx +6 -6
- package/src/createNativeMenu/withNativeMenu.tsx +1 -2
- package/src/index.tsx +0 -1
- package/types/createBaseMenu.d.ts +38 -126
- package/types/createBaseMenu.d.ts.map +1 -1
- package/types/createNativeMenu/createNativeMenu.d.ts +1 -1
- package/types/createNativeMenu/createNativeMenu.d.ts.map +1 -1
- package/types/createNativeMenu/createNativeMenuTypes.d.ts +0 -6
- package/types/createNativeMenu/createNativeMenuTypes.d.ts.map +1 -1
- package/types/createNativeMenu/utils.d.ts +5 -5
- package/types/createNativeMenu/utils.d.ts.map +1 -1
- package/types/createNativeMenu/withNativeMenu.d.ts.map +1 -1
- package/types/index.d.ts +0 -1
- package/types/index.d.ts.map +1 -1
- package/dist/cjs/MenuPredefined.cjs +0 -191
- package/dist/cjs/MenuPredefined.native.js +0 -194
- package/dist/cjs/MenuPredefined.native.js.map +0 -1
- package/dist/esm/MenuPredefined.mjs +0 -166
- package/dist/esm/MenuPredefined.mjs.map +0 -1
- package/dist/esm/MenuPredefined.native.js +0 -166
- package/dist/esm/MenuPredefined.native.js.map +0 -1
- package/dist/esm/createNativeMenu/createNativeMenuTypes.mjs.map +0 -1
- package/dist/esm/createNativeMenu/createNativeMenuTypes.native.js.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/jsx/MenuPredefined.mjs +0 -166
- package/dist/jsx/MenuPredefined.mjs.map +0 -1
- package/dist/jsx/MenuPredefined.native.js +0 -194
- package/dist/jsx/MenuPredefined.native.js.map +0 -1
- package/dist/jsx/createNativeMenu/createNativeMenuTypes.mjs.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
- package/src/MenuPredefined.tsx +0 -204
- package/types/MenuPredefined.d.ts +0 -31
- package/types/MenuPredefined.d.ts.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -5,43 +6,36 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
30
26
|
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
28
|
var createBaseMenu_exports = {};
|
|
35
|
-
__export(createBaseMenu_exports, {
|
|
36
|
-
createBaseMenu: () => createBaseMenu
|
|
37
|
-
});
|
|
29
|
+
__export(createBaseMenu_exports, { createBaseMenu: () => createBaseMenu });
|
|
38
30
|
module.exports = __toCommonJS(createBaseMenu_exports);
|
|
31
|
+
var import_core = require("@tamagui/core");
|
|
39
32
|
var import_animate = require("@tamagui/animate");
|
|
40
33
|
var import_animate_presence = require("@tamagui/animate-presence");
|
|
41
34
|
var import_collection = require("@tamagui/collection");
|
|
42
35
|
var import_dismissable = require("@tamagui/dismissable");
|
|
43
36
|
var import_focus_guard = require("@tamagui/focus-guard");
|
|
44
37
|
var import_focus_scope = require("@tamagui/focus-scope");
|
|
38
|
+
var import_image = require("@tamagui/image");
|
|
45
39
|
var PopperPrimitive = __toESM(require("@tamagui/popper"), 1);
|
|
46
40
|
var import_portal = require("@tamagui/portal");
|
|
47
41
|
var import_remove_scroll = require("@tamagui/remove-scroll");
|
|
@@ -51,1253 +45,1045 @@ var import_use_direction = require("@tamagui/use-direction");
|
|
|
51
45
|
var import_web = require("@tamagui/web");
|
|
52
46
|
var React = __toESM(require("react"), 1);
|
|
53
47
|
var import_react = require("react");
|
|
54
|
-
var import_MenuPredefined = require("./MenuPredefined.cjs");
|
|
55
48
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
56
49
|
function whenMouse(handler) {
|
|
57
|
-
|
|
50
|
+
return (event) => event.pointerType === "mouse" ? handler(event) : void 0;
|
|
58
51
|
}
|
|
59
52
|
const SELECTION_KEYS = ["Enter", " "];
|
|
60
|
-
const FIRST_KEYS = [
|
|
61
|
-
|
|
53
|
+
const FIRST_KEYS = [
|
|
54
|
+
"ArrowDown",
|
|
55
|
+
"PageUp",
|
|
56
|
+
"Home"
|
|
57
|
+
];
|
|
58
|
+
const LAST_KEYS = [
|
|
59
|
+
"ArrowUp",
|
|
60
|
+
"PageDown",
|
|
61
|
+
"End"
|
|
62
|
+
];
|
|
62
63
|
const FIRST_LAST_KEYS = [...FIRST_KEYS, ...LAST_KEYS];
|
|
63
64
|
const SUB_OPEN_KEYS = {
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
ltr: [...SELECTION_KEYS, "ArrowRight"],
|
|
66
|
+
rtl: [...SELECTION_KEYS, "ArrowLeft"]
|
|
66
67
|
};
|
|
67
68
|
const SUB_CLOSE_KEYS = {
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
ltr: ["ArrowLeft"],
|
|
70
|
+
rtl: ["ArrowRight"]
|
|
70
71
|
};
|
|
71
72
|
const MENU_NAME = "Menu";
|
|
72
73
|
const [Collection, useCollection] = (0, import_collection.createCollection)(MENU_NAME);
|
|
73
|
-
const {
|
|
74
|
-
|
|
75
|
-
useStyledContext: useMenuContext
|
|
76
|
-
} = (0, import_web.createStyledContext)();
|
|
77
|
-
const {
|
|
78
|
-
Provider: MenuRootProvider,
|
|
79
|
-
useStyledContext: useMenuRootContext
|
|
80
|
-
} = (0, import_web.createStyledContext)();
|
|
74
|
+
const { Provider: MenuProvider, useStyledContext: useMenuContext } = (0, import_web.createStyledContext)();
|
|
75
|
+
const { Provider: MenuRootProvider, useStyledContext: useMenuRootContext } = (0, import_web.createStyledContext)();
|
|
81
76
|
const MENU_CONTEXT = "MenuContext";
|
|
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
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
} else if (import_web.isWeb && subContext.trigger) {
|
|
1041
|
-
const triggerEl = subContext.trigger;
|
|
1042
|
-
const triggerRect = triggerEl?.getBoundingClientRect();
|
|
1043
|
-
if (triggerRect) {
|
|
1044
|
-
const placementSide = popperContext.placement?.split("-")[0];
|
|
1045
|
-
const side = placementSide === "left" || placementSide === "right" ? placementSide : rootContext.dir === "rtl" ? "left" : "right";
|
|
1046
|
-
const rightSide = side === "right";
|
|
1047
|
-
const bleed = rightSide ? -5 : 5;
|
|
1048
|
-
const nearEdge = rightSide ? triggerRect.right + 4 : triggerRect.left - 4;
|
|
1049
|
-
const farEdge = rightSide ? nearEdge + 200 : nearEdge - 200;
|
|
1050
|
-
const polygon = {
|
|
1051
|
-
area: [{
|
|
1052
|
-
x: event.clientX + bleed,
|
|
1053
|
-
y: event.clientY
|
|
1054
|
-
}, {
|
|
1055
|
-
x: nearEdge,
|
|
1056
|
-
y: triggerRect.top - 50
|
|
1057
|
-
}, {
|
|
1058
|
-
x: farEdge,
|
|
1059
|
-
y: triggerRect.top - 50
|
|
1060
|
-
}, {
|
|
1061
|
-
x: farEdge,
|
|
1062
|
-
y: triggerRect.bottom + 50
|
|
1063
|
-
}, {
|
|
1064
|
-
x: nearEdge,
|
|
1065
|
-
y: triggerRect.bottom + 50
|
|
1066
|
-
}],
|
|
1067
|
-
side
|
|
1068
|
-
};
|
|
1069
|
-
contentContext.onPointerGraceIntentChange(polygon);
|
|
1070
|
-
window.clearTimeout(pointerGraceTimerRef.current);
|
|
1071
|
-
pointerGraceTimerRef.current = window.setTimeout(() => contentContext.onPointerGraceIntentChange(null), 300);
|
|
1072
|
-
}
|
|
1073
|
-
} else {
|
|
1074
|
-
contentContext.onTriggerLeave(event);
|
|
1075
|
-
if (event.defaultPrevented) return;
|
|
1076
|
-
contentContext.onPointerGraceIntentChange(null);
|
|
1077
|
-
}
|
|
1078
|
-
}),
|
|
1079
|
-
...(import_web.isWeb ? {
|
|
1080
|
-
onKeyDown: (0, import_web.composeEventHandlers)(props.onKeyDown, event => {
|
|
1081
|
-
const isTypingAhead = contentContext.searchRef.current !== "";
|
|
1082
|
-
if (props.disabled || isTypingAhead && event.key === " ") return;
|
|
1083
|
-
const willOpen = SUB_OPEN_KEYS[effectiveDir].includes(event.key);
|
|
1084
|
-
if (willOpen) {
|
|
1085
|
-
if (context.open && context.content) {
|
|
1086
|
-
const contentEl = context.content;
|
|
1087
|
-
const firstItem = contentEl.querySelector?.('[role="menuitem"]:not([data-disabled])');
|
|
1088
|
-
if (firstItem) {
|
|
1089
|
-
firstItem.focus({
|
|
1090
|
-
focusVisible: true
|
|
1091
|
-
});
|
|
1092
|
-
event.preventDefault();
|
|
1093
|
-
return;
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
const triggerEl = event.currentTarget;
|
|
1097
|
-
popperContext.refs?.setReference(triggerEl);
|
|
1098
|
-
context.onOpenChange(true);
|
|
1099
|
-
requestAnimationFrame(() => {
|
|
1100
|
-
popperContext.update?.();
|
|
1101
|
-
});
|
|
1102
|
-
context.content?.focus({
|
|
1103
|
-
focusVisible: true
|
|
1104
|
-
});
|
|
1105
|
-
event.preventDefault();
|
|
1106
|
-
}
|
|
1107
|
-
})
|
|
1108
|
-
} : null)
|
|
1109
|
-
})
|
|
1110
|
-
});
|
|
1111
|
-
});
|
|
1112
|
-
MenuSubTrigger.displayName = SUB_TRIGGER_NAME;
|
|
1113
|
-
const SUB_CONTENT_NAME = "MenuSubContent";
|
|
1114
|
-
const MenuSubContentFrame = (0, import_web.styled)(PopperPrimitive.PopperContentFrame, {
|
|
1115
|
-
name: SUB_CONTENT_NAME
|
|
1116
|
-
});
|
|
1117
|
-
const MenuSubContent = MenuSubContentFrame.styleable((props, forwardedRef) => {
|
|
1118
|
-
const scope = props.scope || MENU_CONTEXT;
|
|
1119
|
-
const portalContext = usePortalContext(scope);
|
|
1120
|
-
const {
|
|
1121
|
-
forceMount = portalContext.forceMount,
|
|
1122
|
-
...subContentProps
|
|
1123
|
-
} = props;
|
|
1124
|
-
const context = useMenuContext(scope);
|
|
1125
|
-
const rootContext = useMenuRootContext(scope);
|
|
1126
|
-
const subContext = useMenuSubContext(scope);
|
|
1127
|
-
const popperContext = PopperPrimitive.usePopperContext(scope);
|
|
1128
|
-
const ref = React.useRef(null);
|
|
1129
|
-
const composedRefs = (0, import_web.useComposedRefs)(forwardedRef, ref);
|
|
1130
|
-
const placementSide = popperContext.placement?.split("-")[0];
|
|
1131
|
-
const dataSide = placementSide === "left" || placementSide === "right" ? placementSide : rootContext.dir === "rtl" ? "left" : "right";
|
|
1132
|
-
const effectiveDir = rootContext.dir;
|
|
1133
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Collection.Provider, {
|
|
1134
|
-
scope,
|
|
1135
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(Collection.Slot, {
|
|
1136
|
-
scope,
|
|
1137
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(MenuContentImpl, {
|
|
1138
|
-
id: subContext.contentId,
|
|
1139
|
-
"aria-labelledby": subContext.triggerId,
|
|
1140
|
-
...subContentProps,
|
|
1141
|
-
ref: composedRefs,
|
|
1142
|
-
"data-side": dataSide,
|
|
1143
|
-
disableOutsidePointerEvents: false,
|
|
1144
|
-
disableOutsideScroll: false,
|
|
1145
|
-
trapFocus: false,
|
|
1146
|
-
onOpenAutoFocus: event => {
|
|
1147
|
-
if (rootContext.isUsingKeyboardRef.current) {
|
|
1148
|
-
const root = ref.current;
|
|
1149
|
-
const content = root?.querySelector?.("[data-tamagui-menu-content]");
|
|
1150
|
-
(content || root)?.focus({
|
|
1151
|
-
preventScroll: true
|
|
1152
|
-
});
|
|
1153
|
-
}
|
|
1154
|
-
event.preventDefault();
|
|
1155
|
-
},
|
|
1156
|
-
onCloseAutoFocus: event => event.preventDefault(),
|
|
1157
|
-
onFocusOutside: (0, import_web.composeEventHandlers)(props.onFocusOutside, event => {
|
|
1158
|
-
if (event.target !== subContext.trigger) context.onOpenChange(false);
|
|
1159
|
-
}),
|
|
1160
|
-
onEscapeKeyDown: (0, import_web.composeEventHandlers)(props.onEscapeKeyDown, event => {
|
|
1161
|
-
context.onOpenChange(false);
|
|
1162
|
-
subContext.trigger?.focus({
|
|
1163
|
-
focusVisible: true
|
|
1164
|
-
});
|
|
1165
|
-
event.preventDefault();
|
|
1166
|
-
}),
|
|
1167
|
-
...(import_web.isWeb ? {
|
|
1168
|
-
onKeyDown: (0, import_web.composeEventHandlers)(props.onKeyDown, event => {
|
|
1169
|
-
const isKeyDownInside = event.currentTarget.contains(event.target);
|
|
1170
|
-
const isCloseKey = SUB_CLOSE_KEYS[effectiveDir].includes(event.key);
|
|
1171
|
-
if (isKeyDownInside && isCloseKey) {
|
|
1172
|
-
context.onOpenChange(false);
|
|
1173
|
-
subContext.trigger?.focus({
|
|
1174
|
-
focusVisible: true
|
|
1175
|
-
});
|
|
1176
|
-
event.preventDefault();
|
|
1177
|
-
}
|
|
1178
|
-
})
|
|
1179
|
-
} : null)
|
|
1180
|
-
})
|
|
1181
|
-
})
|
|
1182
|
-
});
|
|
1183
|
-
});
|
|
1184
|
-
MenuSubContent.displayName = SUB_CONTENT_NAME;
|
|
1185
|
-
const Anchor = MenuAnchor;
|
|
1186
|
-
const Portal = MenuPortal;
|
|
1187
|
-
const Content = MenuContent;
|
|
1188
|
-
const Group = _MenuGroup.styleable((props, ref) => {
|
|
1189
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(_MenuGroup, {
|
|
1190
|
-
...props,
|
|
1191
|
-
ref
|
|
1192
|
-
});
|
|
1193
|
-
});
|
|
1194
|
-
Group.displayName = "MenuGroup";
|
|
1195
|
-
const Label = _Label.styleable((props, ref) => {
|
|
1196
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(_Label, {
|
|
1197
|
-
...props,
|
|
1198
|
-
ref
|
|
1199
|
-
});
|
|
1200
|
-
});
|
|
1201
|
-
Label.displayName = "MenuLabel";
|
|
1202
|
-
const Item = MenuItem;
|
|
1203
|
-
const CheckboxItem = MenuCheckboxItem;
|
|
1204
|
-
const RadioGroup = MenuRadioGroup;
|
|
1205
|
-
const RadioItem = MenuRadioItem;
|
|
1206
|
-
const ItemIndicator = MenuItemIndicator;
|
|
1207
|
-
const Separator = _Separator.styleable((props, ref) => {
|
|
1208
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(_Separator, {
|
|
1209
|
-
...props,
|
|
1210
|
-
ref
|
|
1211
|
-
});
|
|
1212
|
-
});
|
|
1213
|
-
Separator.displayName = "MenuSeparator";
|
|
1214
|
-
const Arrow = MenuArrow;
|
|
1215
|
-
const Sub = MenuSub;
|
|
1216
|
-
const SubTrigger = MenuSubTrigger;
|
|
1217
|
-
const SubContent = MenuSubContent;
|
|
1218
|
-
const ItemTitle = MenuItemTitle;
|
|
1219
|
-
const ItemSubtitle = MenuItemSubTitle;
|
|
1220
|
-
const ItemImage = MenuItemImage;
|
|
1221
|
-
const ItemIcon = MenuItemIcon;
|
|
1222
|
-
const Menu = (0, import_web.withStaticProperties)(MenuComp, {
|
|
1223
|
-
Anchor,
|
|
1224
|
-
Portal,
|
|
1225
|
-
Content,
|
|
1226
|
-
Group,
|
|
1227
|
-
Label,
|
|
1228
|
-
Item,
|
|
1229
|
-
CheckboxItem,
|
|
1230
|
-
RadioGroup,
|
|
1231
|
-
RadioItem,
|
|
1232
|
-
ItemIndicator,
|
|
1233
|
-
Separator,
|
|
1234
|
-
Arrow,
|
|
1235
|
-
Sub,
|
|
1236
|
-
SubTrigger,
|
|
1237
|
-
SubContent,
|
|
1238
|
-
ItemTitle,
|
|
1239
|
-
ItemSubtitle,
|
|
1240
|
-
ItemImage,
|
|
1241
|
-
ItemIcon
|
|
1242
|
-
});
|
|
1243
|
-
return {
|
|
1244
|
-
Menu
|
|
1245
|
-
};
|
|
77
|
+
const MenuImageFrame = (0, import_web.styled)(import_image.Image, { displayName: "MenuItemImage" });
|
|
78
|
+
function createBaseMenu() {
|
|
79
|
+
const MenuComp = (props) => {
|
|
80
|
+
const direction = (0, import_use_direction.useDirection)(props.dir);
|
|
81
|
+
const defaultPlacement = direction === "rtl" ? "bottom-end" : "bottom-start";
|
|
82
|
+
const { scope = MENU_CONTEXT, open = false, children, dir, onOpenChange, modal = true, allowFlip = { padding: 10 }, stayInFrame = { padding: 10 }, placement = defaultPlacement, resize = true, offset = 10, ...rest } = props;
|
|
83
|
+
const [content, setContent] = React.useState(null);
|
|
84
|
+
const isUsingKeyboardRef = React.useRef(false);
|
|
85
|
+
const handleOpenChange = (0, import_use_callback_ref.useCallbackRef)(onOpenChange);
|
|
86
|
+
if (import_web.isWeb) {
|
|
87
|
+
React.useEffect(() => {
|
|
88
|
+
const handleKeyDown = () => {
|
|
89
|
+
isUsingKeyboardRef.current = true;
|
|
90
|
+
document.addEventListener("pointerdown", handlePointer, {
|
|
91
|
+
capture: true,
|
|
92
|
+
once: true
|
|
93
|
+
});
|
|
94
|
+
document.addEventListener("pointermove", handlePointer, {
|
|
95
|
+
capture: true,
|
|
96
|
+
once: true
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
const handlePointer = () => isUsingKeyboardRef.current = false;
|
|
100
|
+
document.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
101
|
+
return () => {
|
|
102
|
+
document.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
103
|
+
document.removeEventListener("pointerdown", handlePointer, { capture: true });
|
|
104
|
+
document.removeEventListener("pointermove", handlePointer, { capture: true });
|
|
105
|
+
};
|
|
106
|
+
}, []);
|
|
107
|
+
}
|
|
108
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Popper, {
|
|
109
|
+
scope,
|
|
110
|
+
open,
|
|
111
|
+
placement,
|
|
112
|
+
allowFlip,
|
|
113
|
+
stayInFrame,
|
|
114
|
+
resize,
|
|
115
|
+
offset,
|
|
116
|
+
...rest,
|
|
117
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuProvider, {
|
|
118
|
+
scope,
|
|
119
|
+
open,
|
|
120
|
+
onOpenChange: handleOpenChange,
|
|
121
|
+
content,
|
|
122
|
+
onContentChange: setContent,
|
|
123
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuRootProvider, {
|
|
124
|
+
scope,
|
|
125
|
+
open,
|
|
126
|
+
onClose: React.useCallback(() => handleOpenChange(false), [handleOpenChange]),
|
|
127
|
+
isUsingKeyboardRef,
|
|
128
|
+
dir: direction,
|
|
129
|
+
modal,
|
|
130
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuSubProvider, {
|
|
131
|
+
scope,
|
|
132
|
+
children
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
const RepropagateMenuAndMenuRootProvider = (props) => {
|
|
139
|
+
const { scope = MENU_CONTEXT, menuContext, rootContext, popperContext, menuSubContext, children } = props;
|
|
140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.PopperProvider, {
|
|
141
|
+
...popperContext,
|
|
142
|
+
scope,
|
|
143
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuProvider, {
|
|
144
|
+
scope,
|
|
145
|
+
...menuContext,
|
|
146
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuRootProvider, {
|
|
147
|
+
scope,
|
|
148
|
+
...rootContext,
|
|
149
|
+
children: menuSubContext ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuSubProvider, {
|
|
150
|
+
scope,
|
|
151
|
+
...menuSubContext,
|
|
152
|
+
children
|
|
153
|
+
}) : children
|
|
154
|
+
})
|
|
155
|
+
})
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
MenuComp.displayName = MENU_NAME;
|
|
159
|
+
const ANCHOR_NAME = "MenuAnchor";
|
|
160
|
+
const MenuAnchor = (props) => {
|
|
161
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.PopperAnchor, {
|
|
162
|
+
scope: MENU_CONTEXT,
|
|
163
|
+
...props
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
MenuAnchor.displayName = ANCHOR_NAME;
|
|
167
|
+
const PORTAL_NAME = "MenuPortal";
|
|
168
|
+
const { Provider: PortalProvider, useStyledContext: usePortalContext } = (0, import_web.createStyledContext)(void 0, "Portal");
|
|
169
|
+
const MenuPortal = (props) => {
|
|
170
|
+
const { scope = MENU_CONTEXT, forceMount, zIndex, children } = props;
|
|
171
|
+
const menuContext = useMenuContext(scope);
|
|
172
|
+
const rootContext = useMenuRootContext(scope);
|
|
173
|
+
const popperContext = PopperPrimitive.usePopperContext(scope);
|
|
174
|
+
const menuSubContext = useMenuSubContext(scope);
|
|
175
|
+
const themeName = (0, import_web.useThemeName)();
|
|
176
|
+
const themedChildren = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.Theme, {
|
|
177
|
+
forceClassName: true,
|
|
178
|
+
name: themeName,
|
|
179
|
+
children
|
|
180
|
+
});
|
|
181
|
+
const content = (0, import_portal.needsPortalRepropagation)() ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RepropagateMenuAndMenuRootProvider, {
|
|
182
|
+
menuContext,
|
|
183
|
+
rootContext,
|
|
184
|
+
popperContext,
|
|
185
|
+
menuSubContext,
|
|
186
|
+
scope,
|
|
187
|
+
children: themedChildren
|
|
188
|
+
}) : themedChildren;
|
|
189
|
+
const isPresent = forceMount || rootContext.open && menuContext.open;
|
|
190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate.Animate, {
|
|
191
|
+
type: "presence",
|
|
192
|
+
present: isPresent,
|
|
193
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.Portal, {
|
|
194
|
+
stackZIndex: true,
|
|
195
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalProvider, {
|
|
196
|
+
scope,
|
|
197
|
+
forceMount,
|
|
198
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_web.View, {
|
|
199
|
+
zIndex: zIndex || 100,
|
|
200
|
+
inset: 0,
|
|
201
|
+
position: "absolute",
|
|
202
|
+
children: [!!menuContext.open && !import_web.isWeb && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.View, {
|
|
203
|
+
inset: 0,
|
|
204
|
+
position: "absolute",
|
|
205
|
+
onPress: () => menuContext.onOpenChange(!menuContext.open)
|
|
206
|
+
}), content]
|
|
207
|
+
})
|
|
208
|
+
}) })
|
|
209
|
+
})
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
MenuPortal.displayName = PORTAL_NAME;
|
|
213
|
+
const CONTENT_NAME = "MenuContent";
|
|
214
|
+
const { Provider: MenuContentProvider, useStyledContext: useMenuContentContext } = (0, import_web.createStyledContext)();
|
|
215
|
+
const MenuContentFrame = (0, import_web.styled)(PopperPrimitive.PopperContentFrame, { displayName: CONTENT_NAME });
|
|
216
|
+
const MenuContent = (0, import_core.createStyledHOC)(MenuContentFrame, (props, forwardedRef) => {
|
|
217
|
+
const scope = props.scope || MENU_CONTEXT;
|
|
218
|
+
const portalContext = usePortalContext(scope);
|
|
219
|
+
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
220
|
+
const rootContext = useMenuRootContext(scope);
|
|
221
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Provider, {
|
|
222
|
+
scope,
|
|
223
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Slot, {
|
|
224
|
+
scope,
|
|
225
|
+
children: rootContext.modal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuRootContentModal, {
|
|
226
|
+
...contentProps,
|
|
227
|
+
ref: forwardedRef
|
|
228
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuRootContentNonModal, {
|
|
229
|
+
...contentProps,
|
|
230
|
+
ref: forwardedRef
|
|
231
|
+
})
|
|
232
|
+
})
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
const MenuRootContentModal = (0, import_core.createRefComponent)((props, forwardedRef) => {
|
|
236
|
+
const scope = props.scope || MENU_CONTEXT;
|
|
237
|
+
const context = useMenuContext(scope);
|
|
238
|
+
const ref = React.useRef(null);
|
|
239
|
+
const composedRefs = (0, import_web.useComposedRefs)(forwardedRef, ref);
|
|
240
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuContentImpl, {
|
|
241
|
+
...props,
|
|
242
|
+
scope,
|
|
243
|
+
ref: composedRefs,
|
|
244
|
+
trapFocus: context.open,
|
|
245
|
+
disableOutsidePointerEvents: context.open,
|
|
246
|
+
disableOutsideScroll: false,
|
|
247
|
+
onFocusOutside: (0, import_web.composeEventHandlers)(props.onFocusOutside, (event) => event.cancel(), { checkDefaultPrevented: false }),
|
|
248
|
+
onDismiss: () => context.onOpenChange(false)
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
const MenuRootContentNonModal = (0, import_core.createRefComponent)((props, forwardedRef) => {
|
|
252
|
+
const scope = props.scope || MENU_CONTEXT;
|
|
253
|
+
const context = useMenuContext(scope);
|
|
254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuContentImpl, {
|
|
255
|
+
...props,
|
|
256
|
+
scope,
|
|
257
|
+
ref: forwardedRef,
|
|
258
|
+
trapFocus: false,
|
|
259
|
+
disableOutsidePointerEvents: false,
|
|
260
|
+
disableOutsideScroll: false,
|
|
261
|
+
onDismiss: () => context.onOpenChange(false)
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
const MenuContentImpl = (0, import_core.createRefComponent)((props, forwardedRef) => {
|
|
265
|
+
const { scope = MENU_CONTEXT, loop = false, trapFocus, onOpenAutoFocus, onCloseAutoFocus, disableOutsidePointerEvents, onEntryFocus, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, onDismiss, disableOutsideScroll, disableDismissOnScroll = false, ...contentProps } = props;
|
|
266
|
+
const context = useMenuContext(scope);
|
|
267
|
+
const rootContext = useMenuRootContext(scope);
|
|
268
|
+
const popperContext = PopperPrimitive.usePopperContext(scope);
|
|
269
|
+
const getItems = useCollection(scope);
|
|
270
|
+
const [currentItemId, setCurrentItemId] = React.useState(null);
|
|
271
|
+
const contentRef = React.useRef(null);
|
|
272
|
+
const focusableContentRef = React.useRef(null);
|
|
273
|
+
const composedRefs = (0, import_web.useComposedRefs)(forwardedRef, contentRef, context.onContentChange);
|
|
274
|
+
const timerRef = React.useRef(0);
|
|
275
|
+
const searchRef = React.useRef("");
|
|
276
|
+
const pointerGraceTimerRef = React.useRef(0);
|
|
277
|
+
const pointerGraceIntentRef = React.useRef(null);
|
|
278
|
+
const pointerDirRef = React.useRef("right");
|
|
279
|
+
const lastPointerXRef = React.useRef(0);
|
|
280
|
+
const handleTypeaheadSearch = (key) => {
|
|
281
|
+
const search = searchRef.current + key;
|
|
282
|
+
const items = getItems().filter((item) => !item.disabled);
|
|
283
|
+
const currentItem = document.activeElement;
|
|
284
|
+
const currentMatch = items.find((item) => item.ref.current === currentItem)?.textValue;
|
|
285
|
+
const values = items.map((item) => item.textValue);
|
|
286
|
+
const nextMatch = getNextMatch(values, search, currentMatch);
|
|
287
|
+
const newItem = items.find((item) => item.textValue === nextMatch)?.ref.current;
|
|
288
|
+
(function updateSearch(value) {
|
|
289
|
+
searchRef.current = value;
|
|
290
|
+
clearTimeout(timerRef.current);
|
|
291
|
+
if (value !== "") timerRef.current = setTimeout(() => updateSearch(""), 1e3);
|
|
292
|
+
})(search);
|
|
293
|
+
if (newItem) {
|
|
294
|
+
setTimeout(() => newItem.focus());
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
React.useEffect(() => {
|
|
298
|
+
return () => clearTimeout(timerRef.current);
|
|
299
|
+
}, []);
|
|
300
|
+
React.useEffect(() => {
|
|
301
|
+
if (!import_web.isWeb || !context.open) return;
|
|
302
|
+
const frame = requestAnimationFrame(() => {
|
|
303
|
+
const container = contentRef.current;
|
|
304
|
+
const el = container?.querySelector("[data-tamagui-menu-content]");
|
|
305
|
+
if (el) focusableContentRef.current = el;
|
|
306
|
+
});
|
|
307
|
+
return () => cancelAnimationFrame(frame);
|
|
308
|
+
}, [context.open]);
|
|
309
|
+
React.useEffect(() => {
|
|
310
|
+
if (!import_web.isWeb || disableDismissOnScroll || !context.open) return;
|
|
311
|
+
const handleScroll = (event) => {
|
|
312
|
+
const scrolled = event.target;
|
|
313
|
+
if (!scrolled) return;
|
|
314
|
+
const content2 = contentRef.current;
|
|
315
|
+
if (content2?.contains(scrolled)) return;
|
|
316
|
+
const reference = popperContext.refs?.reference?.current;
|
|
317
|
+
const anchor = reference instanceof Element ? reference : reference?.contextElement ?? null;
|
|
318
|
+
if (anchor && !scrolled.contains(anchor)) return;
|
|
319
|
+
context.onOpenChange(false);
|
|
320
|
+
};
|
|
321
|
+
window.addEventListener("scroll", handleScroll, {
|
|
322
|
+
capture: true,
|
|
323
|
+
passive: true
|
|
324
|
+
});
|
|
325
|
+
return () => {
|
|
326
|
+
window.removeEventListener("scroll", handleScroll, { capture: true });
|
|
327
|
+
};
|
|
328
|
+
}, [
|
|
329
|
+
disableDismissOnScroll,
|
|
330
|
+
context.open,
|
|
331
|
+
context.onOpenChange,
|
|
332
|
+
popperContext.refs
|
|
333
|
+
]);
|
|
334
|
+
if (import_web.isWeb) {
|
|
335
|
+
(0, import_focus_guard.useFocusGuards)();
|
|
336
|
+
}
|
|
337
|
+
const isPointerMovingToSubmenu = React.useCallback((event) => {
|
|
338
|
+
const isMovingTowards = pointerDirRef.current === pointerGraceIntentRef.current?.side;
|
|
339
|
+
const inArea = isPointerInGraceArea(event, pointerGraceIntentRef.current?.area);
|
|
340
|
+
return isMovingTowards && inArea;
|
|
341
|
+
}, []);
|
|
342
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.PopperContent, {
|
|
343
|
+
role: "menu",
|
|
344
|
+
tabIndex: -1,
|
|
345
|
+
"aria-orientation": "vertical",
|
|
346
|
+
"data-state": getOpenState(context.open),
|
|
347
|
+
"data-tamagui-menu-content": "",
|
|
348
|
+
dir: rootContext.dir,
|
|
349
|
+
scope: scope || MENU_CONTEXT,
|
|
350
|
+
...contentProps,
|
|
351
|
+
ref: composedRefs,
|
|
352
|
+
className: contentProps.transition ? void 0 : contentProps.className,
|
|
353
|
+
...import_web.isWeb ? {
|
|
354
|
+
onKeyDown: (0, import_web.composeEventHandlers)(contentProps.onKeyDown, (event) => {
|
|
355
|
+
const target = event.target;
|
|
356
|
+
const isKeyDownInside = target.closest("[data-tamagui-menu-content]") === event.currentTarget;
|
|
357
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
358
|
+
const isCharacterKey = event.key.length === 1;
|
|
359
|
+
if (isKeyDownInside) {
|
|
360
|
+
if (event.key === "Tab") event.preventDefault();
|
|
361
|
+
if (!isModifierKey && isCharacterKey) handleTypeaheadSearch(event.key);
|
|
362
|
+
}
|
|
363
|
+
const isOnContentFrame = event.target.hasAttribute("data-tamagui-menu-content");
|
|
364
|
+
if (!isKeyDownInside || !isOnContentFrame) return;
|
|
365
|
+
if (!FIRST_LAST_KEYS.includes(event.key)) return;
|
|
366
|
+
event.preventDefault();
|
|
367
|
+
const items = getItems().filter((item) => !item.disabled);
|
|
368
|
+
const candidateNodes = items.map((item) => item.ref.current);
|
|
369
|
+
if (LAST_KEYS.includes(event.key)) candidateNodes.reverse();
|
|
370
|
+
focusFirst(candidateNodes, { focusVisible: true });
|
|
371
|
+
}),
|
|
372
|
+
onBlur: (0, import_web.composeEventHandlers)(props.onBlur, (event) => {
|
|
373
|
+
if (!event.currentTarget?.contains(event.target)) {
|
|
374
|
+
clearTimeout(timerRef.current);
|
|
375
|
+
searchRef.current = "";
|
|
376
|
+
}
|
|
377
|
+
}),
|
|
378
|
+
onPointerMove: (0, import_web.composeEventHandlers)(props.onPointerMove, (event) => {
|
|
379
|
+
if (event.pointerType !== "mouse") return;
|
|
380
|
+
const target = event.target;
|
|
381
|
+
const pointerXHasChanged = lastPointerXRef.current !== event.clientX;
|
|
382
|
+
if (event.currentTarget?.contains(target) && pointerXHasChanged) {
|
|
383
|
+
const newDir = event.clientX > lastPointerXRef.current ? "right" : "left";
|
|
384
|
+
pointerDirRef.current = newDir;
|
|
385
|
+
lastPointerXRef.current = event.clientX;
|
|
386
|
+
}
|
|
387
|
+
})
|
|
388
|
+
} : {}
|
|
389
|
+
});
|
|
390
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuContentProvider, {
|
|
391
|
+
scope,
|
|
392
|
+
searchRef,
|
|
393
|
+
onItemEnter: React.useCallback((event) => {
|
|
394
|
+
if (isPointerMovingToSubmenu(event)) event.preventDefault();
|
|
395
|
+
}, [isPointerMovingToSubmenu]),
|
|
396
|
+
onItemLeave: React.useCallback((event) => {
|
|
397
|
+
if (isPointerMovingToSubmenu(event)) return;
|
|
398
|
+
focusableContentRef.current?.focus();
|
|
399
|
+
setCurrentItemId(null);
|
|
400
|
+
}, [isPointerMovingToSubmenu]),
|
|
401
|
+
onTriggerLeave: React.useCallback((event) => {
|
|
402
|
+
if (isPointerMovingToSubmenu(event)) event.preventDefault();
|
|
403
|
+
}, [isPointerMovingToSubmenu]),
|
|
404
|
+
pointerGraceTimerRef,
|
|
405
|
+
onPointerGraceIntentChange: React.useCallback((intent) => {
|
|
406
|
+
pointerGraceIntentRef.current = intent;
|
|
407
|
+
}, []),
|
|
408
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_remove_scroll.RemoveScroll, {
|
|
409
|
+
enabled: disableOutsideScroll,
|
|
410
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_focus_scope.FocusScope, {
|
|
411
|
+
asChild: false,
|
|
412
|
+
trapped: trapFocus,
|
|
413
|
+
onMountAutoFocus: (0, import_web.composeEventHandlers)(onOpenAutoFocus, (event) => {
|
|
414
|
+
event.cancel();
|
|
415
|
+
const content2 = document.querySelector("[data-tamagui-menu-content]");
|
|
416
|
+
content2?.focus({ preventScroll: true });
|
|
417
|
+
}),
|
|
418
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
419
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dismissable.Dismissable, {
|
|
420
|
+
disableOutsidePointerEvents,
|
|
421
|
+
onEscapeKeyDown,
|
|
422
|
+
onPointerDownOutside,
|
|
423
|
+
onFocusOutside,
|
|
424
|
+
onInteractOutside,
|
|
425
|
+
onDismiss,
|
|
426
|
+
asChild: true,
|
|
427
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup, {
|
|
428
|
+
asChild: true,
|
|
429
|
+
__scopeRovingFocusGroup: scope || MENU_CONTEXT,
|
|
430
|
+
dir: rootContext.dir,
|
|
431
|
+
orientation: "vertical",
|
|
432
|
+
loop,
|
|
433
|
+
currentTabStopId: currentItemId,
|
|
434
|
+
onCurrentTabStopIdChange: setCurrentItemId,
|
|
435
|
+
onEntryFocus: (0, import_web.composeEventHandlers)(onEntryFocus, (event) => {
|
|
436
|
+
if (!rootContext.isUsingKeyboardRef.current) {
|
|
437
|
+
event.cancel();
|
|
438
|
+
}
|
|
439
|
+
}),
|
|
440
|
+
children: content
|
|
441
|
+
})
|
|
442
|
+
})
|
|
443
|
+
})
|
|
444
|
+
})
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
MenuContent.displayName = CONTENT_NAME;
|
|
448
|
+
const ITEM_NAME = "MenuItem";
|
|
449
|
+
const ITEM_SELECT = "menu.itemSelect";
|
|
450
|
+
const MenuItem = (0, import_core.createStyledHOC)(import_web.View, (props, forwardedRef) => {
|
|
451
|
+
const { disabled = false, onSelect, preventCloseOnSelect, children, scope = MENU_CONTEXT, destructive, hidden, androidIconName, ...itemProps } = props;
|
|
452
|
+
const ref = React.useRef(null);
|
|
453
|
+
const rootContext = useMenuRootContext(scope);
|
|
454
|
+
const contentContext = useMenuContentContext(scope);
|
|
455
|
+
const composedRefs = (0, import_web.useComposedRefs)(forwardedRef, ref);
|
|
456
|
+
const isPointerDownRef = React.useRef(false);
|
|
457
|
+
const handleSelect = () => {
|
|
458
|
+
const menuItem = ref.current;
|
|
459
|
+
if (!disabled && menuItem) {
|
|
460
|
+
if (import_web.isWeb) {
|
|
461
|
+
const menuItemEl = menuItem;
|
|
462
|
+
const itemSelectEvent = new CustomEvent(ITEM_SELECT, {
|
|
463
|
+
bubbles: true,
|
|
464
|
+
cancelable: true
|
|
465
|
+
});
|
|
466
|
+
menuItemEl.addEventListener(ITEM_SELECT, (event) => onSelect?.(event), { once: true });
|
|
467
|
+
(0, import_dismissable.dispatchDiscreteCustomEvent)(menuItemEl, itemSelectEvent);
|
|
468
|
+
if (itemSelectEvent.defaultPrevented || preventCloseOnSelect) {
|
|
469
|
+
isPointerDownRef.current = false;
|
|
470
|
+
} else {
|
|
471
|
+
rootContext.onClose();
|
|
472
|
+
}
|
|
473
|
+
} else {
|
|
474
|
+
onSelect?.({ target: menuItem });
|
|
475
|
+
isPointerDownRef.current = false;
|
|
476
|
+
if (!preventCloseOnSelect) {
|
|
477
|
+
rootContext.onClose();
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
const content = typeof children === "string" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.Text, { children }) : children;
|
|
483
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuItemImpl, {
|
|
484
|
+
...itemProps,
|
|
485
|
+
scope,
|
|
486
|
+
ref: composedRefs,
|
|
487
|
+
disabled,
|
|
488
|
+
onPress: (0, import_web.composeEventHandlers)(props.onPress, handleSelect),
|
|
489
|
+
onPointerDown: (event) => {
|
|
490
|
+
props.onPointerDown?.(event);
|
|
491
|
+
isPointerDownRef.current = true;
|
|
492
|
+
},
|
|
493
|
+
onPointerUp: (0, import_web.composeEventHandlers)(props.onPointerUp, (event) => {
|
|
494
|
+
if (import_web.isWeb) {
|
|
495
|
+
if (!isPointerDownRef.current) event.currentTarget?.click();
|
|
496
|
+
}
|
|
497
|
+
}),
|
|
498
|
+
...import_web.isWeb ? { onKeyDown: (0, import_web.composeEventHandlers)(props.onKeyDown, (event) => {
|
|
499
|
+
const isTypingAhead = contentContext.searchRef.current !== "";
|
|
500
|
+
if (disabled || isTypingAhead && event.key === " ") return;
|
|
501
|
+
if (SELECTION_KEYS.includes(event.key)) {
|
|
502
|
+
event.currentTarget?.click();
|
|
503
|
+
event.preventDefault();
|
|
504
|
+
}
|
|
505
|
+
}) } : {},
|
|
506
|
+
children: content
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
const MenuItemImpl = (0, import_core.createRefComponent)((props, forwardedRef) => {
|
|
510
|
+
const { scope = MENU_CONTEXT, className, disabled = false, textValue, ...itemProps } = props;
|
|
511
|
+
const contentContext = useMenuContentContext(scope);
|
|
512
|
+
const ref = React.useRef(null);
|
|
513
|
+
const composedRefs = (0, import_web.useComposedRefs)(forwardedRef, ref);
|
|
514
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
515
|
+
const [textContent, setTextContent] = React.useState("");
|
|
516
|
+
if (import_web.isWeb) {
|
|
517
|
+
React.useEffect(() => {
|
|
518
|
+
const menuItem = ref.current;
|
|
519
|
+
if (menuItem) {
|
|
520
|
+
setTextContent((menuItem.textContent ?? "").trim());
|
|
521
|
+
}
|
|
522
|
+
}, [itemProps.children]);
|
|
523
|
+
}
|
|
524
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.ItemSlot, {
|
|
525
|
+
scope,
|
|
526
|
+
disabled,
|
|
527
|
+
textValue: textValue ?? textContent,
|
|
528
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup.Item, {
|
|
529
|
+
asChild: true,
|
|
530
|
+
__scopeRovingFocusGroup: scope,
|
|
531
|
+
tabIndex: disabled ? -1 : 0,
|
|
532
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.View, {
|
|
533
|
+
className: `is_${ITEM_NAME} ${className || ""}`.trim(),
|
|
534
|
+
role: "menuitem",
|
|
535
|
+
"data-highlighted": isFocused ? "" : void 0,
|
|
536
|
+
"aria-disabled": disabled || void 0,
|
|
537
|
+
"data-disabled": disabled ? "" : void 0,
|
|
538
|
+
...itemProps,
|
|
539
|
+
ref: composedRefs,
|
|
540
|
+
onPointerMove: (0, import_web.composeEventHandlers)(props.onPointerMove, (event) => {
|
|
541
|
+
if (event.pointerType !== "mouse") return;
|
|
542
|
+
if (disabled) {
|
|
543
|
+
contentContext.onItemLeave(event);
|
|
544
|
+
} else {
|
|
545
|
+
contentContext.onItemEnter(event);
|
|
546
|
+
if (!event.defaultPrevented) {
|
|
547
|
+
const item = event.currentTarget;
|
|
548
|
+
item.focus({
|
|
549
|
+
preventScroll: true,
|
|
550
|
+
focusVisible: false
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}),
|
|
555
|
+
onPointerLeave: (0, import_web.composeEventHandlers)(props.onPointerLeave, (event) => {
|
|
556
|
+
contentContext.onItemLeave(event);
|
|
557
|
+
}),
|
|
558
|
+
onFocus: (0, import_web.composeEventHandlers)(props.onFocus, () => setIsFocused(true)),
|
|
559
|
+
onBlur: (0, import_web.composeEventHandlers)(props.onBlur, () => setIsFocused(false))
|
|
560
|
+
})
|
|
561
|
+
})
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
MenuItem.displayName = ITEM_NAME;
|
|
565
|
+
const ITEM_TITLE_NAME = "MenuItemTitle";
|
|
566
|
+
const MenuItemTitle = (0, import_core.createStyledHOC)(import_web.Text, (props, forwardedRef) => {
|
|
567
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.Text, {
|
|
568
|
+
...props,
|
|
569
|
+
ref: forwardedRef
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
MenuItemTitle.displayName = ITEM_TITLE_NAME;
|
|
573
|
+
const ITEM_SUB_TITLE_NAME = "MenuItemSubTitle";
|
|
574
|
+
const MenuItemSubTitle = (0, import_core.createStyledHOC)(import_web.Text, (props, forwardedRef) => {
|
|
575
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.Text, {
|
|
576
|
+
...props,
|
|
577
|
+
ref: forwardedRef
|
|
578
|
+
});
|
|
579
|
+
});
|
|
580
|
+
MenuItemSubTitle.displayName = ITEM_SUB_TITLE_NAME;
|
|
581
|
+
const ITEM_IMAGE = "MenuItemImage";
|
|
582
|
+
const MenuItemImage = (0, import_core.createRefComponent)((props, forwardedRef) => {
|
|
583
|
+
const { ios, androidIconName, ...rest } = props;
|
|
584
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuImageFrame, {
|
|
585
|
+
...rest,
|
|
586
|
+
ref: forwardedRef
|
|
587
|
+
});
|
|
588
|
+
});
|
|
589
|
+
MenuItemImage.displayName = ITEM_IMAGE;
|
|
590
|
+
const ITEM_ICON = "MenuItemIcon";
|
|
591
|
+
const MenuItemIcon = (0, import_core.createStyledHOC)(import_web.View, (props, forwardedRef) => {
|
|
592
|
+
const { ios, android, androidIconName, ...rest } = props;
|
|
593
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.View, {
|
|
594
|
+
...rest,
|
|
595
|
+
ref: forwardedRef
|
|
596
|
+
});
|
|
597
|
+
});
|
|
598
|
+
MenuItemIcon.displayName = ITEM_ICON;
|
|
599
|
+
const CHECKBOX_ITEM_NAME = "MenuCheckboxItem";
|
|
600
|
+
const MenuCheckboxItem = (0, import_core.createStyledHOC)(import_web.View, (props, forwardedRef) => {
|
|
601
|
+
const { checked = false, onCheckedChange, scope = MENU_CONTEXT, value, onValueChange, className, ...checkboxItemProps } = props;
|
|
602
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemIndicatorProvider, {
|
|
603
|
+
scope,
|
|
604
|
+
checked,
|
|
605
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuItem, {
|
|
606
|
+
className: `is_${CHECKBOX_ITEM_NAME} ${className || ""}`.trim(),
|
|
607
|
+
role: import_web.isWeb ? "menuitemcheckbox" : "menuitem",
|
|
608
|
+
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
|
609
|
+
...checkboxItemProps,
|
|
610
|
+
scope,
|
|
611
|
+
ref: forwardedRef,
|
|
612
|
+
"data-state": getCheckedState(checked),
|
|
613
|
+
onSelect: (0, import_web.composeEventHandlers)(checkboxItemProps.onSelect, () => onCheckedChange?.(isIndeterminate(checked) ? true : !checked), { checkDefaultPrevented: false })
|
|
614
|
+
})
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
MenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
|
|
618
|
+
const RADIO_GROUP_NAME = "MenuRadioGroup";
|
|
619
|
+
const { Provider: RadioGroupProvider, useStyledContext: useRadioGroupContext } = (0, import_web.createStyledContext)();
|
|
620
|
+
const MenuRadioGroup = (0, import_core.createStyledHOC)(import_web.View, (props, forwardedRef) => {
|
|
621
|
+
const { value, onValueChange, scope = MENU_CONTEXT, className, ...groupProps } = props;
|
|
622
|
+
const handleValueChange = (0, import_use_callback_ref.useCallbackRef)(onValueChange);
|
|
623
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupProvider, {
|
|
624
|
+
scope,
|
|
625
|
+
value,
|
|
626
|
+
onValueChange: handleValueChange,
|
|
627
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.View, {
|
|
628
|
+
className: `is_${RADIO_GROUP_NAME} ${className || ""}`.trim(),
|
|
629
|
+
...groupProps,
|
|
630
|
+
ref: forwardedRef
|
|
631
|
+
})
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
MenuRadioGroup.displayName = RADIO_GROUP_NAME;
|
|
635
|
+
const RADIO_ITEM_NAME = "MenuRadioItem";
|
|
636
|
+
const MenuRadioItem = (0, import_core.createStyledHOC)(import_web.View, (props, forwardedRef) => {
|
|
637
|
+
const { value, scope = MENU_CONTEXT, className, ...radioItemProps } = props;
|
|
638
|
+
const context = useRadioGroupContext(scope);
|
|
639
|
+
const checked = value === context.value;
|
|
640
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemIndicatorProvider, {
|
|
641
|
+
scope,
|
|
642
|
+
checked,
|
|
643
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuItem, {
|
|
644
|
+
className: `is_${RADIO_ITEM_NAME} ${className || ""}`.trim(),
|
|
645
|
+
...radioItemProps,
|
|
646
|
+
scope,
|
|
647
|
+
"aria-checked": checked,
|
|
648
|
+
ref: forwardedRef,
|
|
649
|
+
role: import_web.isWeb ? "menuitemradio" : "menuitem",
|
|
650
|
+
"data-state": getCheckedState(checked),
|
|
651
|
+
onSelect: (0, import_web.composeEventHandlers)(radioItemProps.onSelect, () => context.onValueChange?.(value), { checkDefaultPrevented: false })
|
|
652
|
+
})
|
|
653
|
+
});
|
|
654
|
+
});
|
|
655
|
+
MenuRadioItem.displayName = RADIO_ITEM_NAME;
|
|
656
|
+
const ITEM_INDICATOR_NAME = "MenuItemIndicator";
|
|
657
|
+
const { Provider: ItemIndicatorProvider, useStyledContext: useItemIndicatorContext } = (0, import_web.createStyledContext)();
|
|
658
|
+
const MenuItemIndicator = (0, import_core.createStyledHOC)(import_web.View, (props, forwardedRef) => {
|
|
659
|
+
const { scope = MENU_CONTEXT, className, forceMount, ...itemIndicatorProps } = props;
|
|
660
|
+
const indicatorContext = useItemIndicatorContext(scope);
|
|
661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, { children: forceMount || isIndeterminate(indicatorContext.checked) || indicatorContext.checked === true ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.View, {
|
|
662
|
+
className: `is_${ITEM_INDICATOR_NAME} ${className || ""}`.trim(),
|
|
663
|
+
render: "span",
|
|
664
|
+
...itemIndicatorProps,
|
|
665
|
+
ref: forwardedRef,
|
|
666
|
+
"data-state": getCheckedState(indicatorContext.checked)
|
|
667
|
+
}) : null });
|
|
668
|
+
});
|
|
669
|
+
MenuItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
670
|
+
const MenuArrow = (0, import_core.createRefComponent)(function MenuArrow2(props, forwardedRef) {
|
|
671
|
+
const { scope = MENU_CONTEXT, className, ...rest } = props;
|
|
672
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.PopperArrow, {
|
|
673
|
+
scope,
|
|
674
|
+
className: `is_PopperArrow ${className || ""}`.trim(),
|
|
675
|
+
...rest,
|
|
676
|
+
ref: forwardedRef
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
const SUB_NAME = "MenuSub";
|
|
680
|
+
const { Provider: MenuSubProvider, useStyledContext: useMenuSubContext } = (0, import_web.createStyledContext)();
|
|
681
|
+
const MenuSub = (props) => {
|
|
682
|
+
const isTouchDevice = (0, import_web.useIsTouchDevice)();
|
|
683
|
+
const { scope = MENU_CONTEXT } = props;
|
|
684
|
+
const rootContext = useMenuRootContext(scope);
|
|
685
|
+
const parentPopperContext = PopperPrimitive.usePopperContext(scope);
|
|
686
|
+
const parentSide = parentPopperContext.placement?.split("-")[0];
|
|
687
|
+
const isNestedSubmenu = parentSide === "left" || parentSide === "right";
|
|
688
|
+
const defaultPlacement = isTouchDevice ? "bottom" : isNestedSubmenu ? `${parentSide}-start` : rootContext.dir === "rtl" ? "left-start" : "right-start";
|
|
689
|
+
const { children, open = false, onOpenChange, allowFlip: allowFlipProp = { padding: 10 }, stayInFrame = { padding: 10 }, placement = defaultPlacement, ...rest } = props;
|
|
690
|
+
const allowFlip = React.useMemo(() => {
|
|
691
|
+
if (!isNestedSubmenu || typeof allowFlipProp === "boolean") return allowFlipProp;
|
|
692
|
+
if (allowFlipProp.fallbackPlacements) return allowFlipProp;
|
|
693
|
+
const side = placement.split("-")[0];
|
|
694
|
+
const align = placement.split("-")[1] || "start";
|
|
695
|
+
const otherAlign = align === "start" ? "end" : "start";
|
|
696
|
+
if (side === "left" || side === "right") {
|
|
697
|
+
const oppositeSide = side === "right" ? "left" : "right";
|
|
698
|
+
return {
|
|
699
|
+
...typeof allowFlipProp === "object" ? allowFlipProp : {},
|
|
700
|
+
fallbackPlacements: [
|
|
701
|
+
`${side}-${otherAlign}`,
|
|
702
|
+
`${oppositeSide}-${align}`,
|
|
703
|
+
`${oppositeSide}-${otherAlign}`
|
|
704
|
+
]
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
return allowFlipProp;
|
|
708
|
+
}, [
|
|
709
|
+
isNestedSubmenu,
|
|
710
|
+
allowFlipProp,
|
|
711
|
+
placement
|
|
712
|
+
]);
|
|
713
|
+
const parentMenuContext = useMenuContext(scope);
|
|
714
|
+
const [trigger, setTrigger] = React.useState(null);
|
|
715
|
+
const [content, setContent] = React.useState(null);
|
|
716
|
+
const handleOpenChange = (0, import_use_callback_ref.useCallbackRef)(onOpenChange);
|
|
717
|
+
React.useEffect(() => {
|
|
718
|
+
if (parentMenuContext.open === false) handleOpenChange(false);
|
|
719
|
+
return () => handleOpenChange(false);
|
|
720
|
+
}, [parentMenuContext.open, handleOpenChange]);
|
|
721
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Popper, {
|
|
722
|
+
open,
|
|
723
|
+
placement,
|
|
724
|
+
allowFlip,
|
|
725
|
+
stayInFrame,
|
|
726
|
+
...rest,
|
|
727
|
+
scope,
|
|
728
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuProvider, {
|
|
729
|
+
scope,
|
|
730
|
+
open,
|
|
731
|
+
onOpenChange: handleOpenChange,
|
|
732
|
+
content,
|
|
733
|
+
onContentChange: setContent,
|
|
734
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuSubProvider, {
|
|
735
|
+
scope,
|
|
736
|
+
contentId: (0, import_react.useId)(),
|
|
737
|
+
triggerId: (0, import_react.useId)(),
|
|
738
|
+
trigger,
|
|
739
|
+
onTriggerChange: setTrigger,
|
|
740
|
+
children
|
|
741
|
+
})
|
|
742
|
+
})
|
|
743
|
+
});
|
|
744
|
+
};
|
|
745
|
+
MenuSub.displayName = SUB_NAME;
|
|
746
|
+
const SUB_TRIGGER_NAME = "MenuSubTrigger";
|
|
747
|
+
const MenuSubTrigger = (0, import_core.createRefComponent)((props, forwardedRef) => {
|
|
748
|
+
const scope = props.scope || MENU_CONTEXT;
|
|
749
|
+
const context = useMenuContext(scope);
|
|
750
|
+
const rootContext = useMenuRootContext(scope);
|
|
751
|
+
const subContext = useMenuSubContext(scope);
|
|
752
|
+
const contentContext = useMenuContentContext(scope);
|
|
753
|
+
const popperContext = PopperPrimitive.usePopperContext(scope);
|
|
754
|
+
const openTimerRef = React.useRef(null);
|
|
755
|
+
const { pointerGraceTimerRef, onPointerGraceIntentChange } = contentContext;
|
|
756
|
+
const effectiveDir = rootContext.dir;
|
|
757
|
+
const clearOpenTimer = React.useCallback(() => {
|
|
758
|
+
if (openTimerRef.current) window.clearTimeout(openTimerRef.current);
|
|
759
|
+
openTimerRef.current = null;
|
|
760
|
+
}, []);
|
|
761
|
+
React.useEffect(() => clearOpenTimer, [clearOpenTimer]);
|
|
762
|
+
React.useEffect(() => {
|
|
763
|
+
const pointerGraceTimer = pointerGraceTimerRef.current;
|
|
764
|
+
return () => {
|
|
765
|
+
window.clearTimeout(pointerGraceTimer);
|
|
766
|
+
onPointerGraceIntentChange(null);
|
|
767
|
+
};
|
|
768
|
+
}, [pointerGraceTimerRef, onPointerGraceIntentChange]);
|
|
769
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuAnchor, {
|
|
770
|
+
className: `is_${SUB_TRIGGER_NAME}`,
|
|
771
|
+
asChild: "except-style",
|
|
772
|
+
scope,
|
|
773
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuItemImpl, {
|
|
774
|
+
id: subContext.triggerId,
|
|
775
|
+
"aria-haspopup": "menu",
|
|
776
|
+
"aria-expanded": context.open,
|
|
777
|
+
"aria-controls": subContext.contentId,
|
|
778
|
+
"data-state": getOpenState(context.open),
|
|
779
|
+
...props,
|
|
780
|
+
ref: (0, import_web.composeRefs)(forwardedRef, subContext.onTriggerChange),
|
|
781
|
+
onPress: (event) => {
|
|
782
|
+
props.onPress?.(event);
|
|
783
|
+
if (props.disabled || event.defaultPrevented) return;
|
|
784
|
+
if (import_web.isWeb) {
|
|
785
|
+
event.currentTarget.focus();
|
|
786
|
+
}
|
|
787
|
+
if (!context.open) context.onOpenChange(true);
|
|
788
|
+
},
|
|
789
|
+
onPointerMove: (0, import_web.composeEventHandlers)(props.onPointerMove, whenMouse((event) => {
|
|
790
|
+
contentContext.onItemEnter(event);
|
|
791
|
+
if (event.defaultPrevented) return;
|
|
792
|
+
if (!props.disabled && !context.open && !openTimerRef.current) {
|
|
793
|
+
contentContext.onPointerGraceIntentChange(null);
|
|
794
|
+
openTimerRef.current = window.setTimeout(() => {
|
|
795
|
+
context.onOpenChange(true);
|
|
796
|
+
clearOpenTimer();
|
|
797
|
+
}, 100);
|
|
798
|
+
}
|
|
799
|
+
})),
|
|
800
|
+
onPointerLeave: (0, import_web.composeEventHandlers)(props.onPointerLeave, (eventIn) => {
|
|
801
|
+
const event = eventIn;
|
|
802
|
+
clearOpenTimer();
|
|
803
|
+
const contentRect = context.content?.getBoundingClientRect();
|
|
804
|
+
if (contentRect) {
|
|
805
|
+
const contentEl = context.content;
|
|
806
|
+
const sideEl = contentEl?.dataset?.side ? contentEl : contentEl?.querySelector("[data-side]");
|
|
807
|
+
const side = sideEl?.dataset?.side || "right";
|
|
808
|
+
const rightSide = side === "right";
|
|
809
|
+
const bleed = rightSide ? -5 : 5;
|
|
810
|
+
const contentNearEdge = contentRect[rightSide ? "left" : "right"];
|
|
811
|
+
const contentFarEdge = contentRect[rightSide ? "right" : "left"];
|
|
812
|
+
const polygon = {
|
|
813
|
+
area: [
|
|
814
|
+
{
|
|
815
|
+
x: event.clientX + bleed,
|
|
816
|
+
y: event.clientY
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
x: contentNearEdge,
|
|
820
|
+
y: contentRect.top
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
x: contentFarEdge,
|
|
824
|
+
y: contentRect.top
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
x: contentFarEdge,
|
|
828
|
+
y: contentRect.bottom
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
x: contentNearEdge,
|
|
832
|
+
y: contentRect.bottom
|
|
833
|
+
}
|
|
834
|
+
],
|
|
835
|
+
side
|
|
836
|
+
};
|
|
837
|
+
contentContext.onPointerGraceIntentChange(polygon);
|
|
838
|
+
window.clearTimeout(pointerGraceTimerRef.current);
|
|
839
|
+
pointerGraceTimerRef.current = window.setTimeout(() => contentContext.onPointerGraceIntentChange(null), 300);
|
|
840
|
+
} else if (import_web.isWeb && subContext.trigger) {
|
|
841
|
+
const triggerEl = subContext.trigger;
|
|
842
|
+
const triggerRect = triggerEl?.getBoundingClientRect();
|
|
843
|
+
if (triggerRect) {
|
|
844
|
+
const placementSide = popperContext.placement?.split("-")[0];
|
|
845
|
+
const side = placementSide === "left" || placementSide === "right" ? placementSide : rootContext.dir === "rtl" ? "left" : "right";
|
|
846
|
+
const rightSide = side === "right";
|
|
847
|
+
const bleed = rightSide ? -5 : 5;
|
|
848
|
+
const nearEdge = rightSide ? triggerRect.right + 4 : triggerRect.left - 4;
|
|
849
|
+
const farEdge = rightSide ? nearEdge + 200 : nearEdge - 200;
|
|
850
|
+
const polygon = {
|
|
851
|
+
area: [
|
|
852
|
+
{
|
|
853
|
+
x: event.clientX + bleed,
|
|
854
|
+
y: event.clientY
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
x: nearEdge,
|
|
858
|
+
y: triggerRect.top - 50
|
|
859
|
+
},
|
|
860
|
+
{
|
|
861
|
+
x: farEdge,
|
|
862
|
+
y: triggerRect.top - 50
|
|
863
|
+
},
|
|
864
|
+
{
|
|
865
|
+
x: farEdge,
|
|
866
|
+
y: triggerRect.bottom + 50
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
x: nearEdge,
|
|
870
|
+
y: triggerRect.bottom + 50
|
|
871
|
+
}
|
|
872
|
+
],
|
|
873
|
+
side
|
|
874
|
+
};
|
|
875
|
+
contentContext.onPointerGraceIntentChange(polygon);
|
|
876
|
+
window.clearTimeout(pointerGraceTimerRef.current);
|
|
877
|
+
pointerGraceTimerRef.current = window.setTimeout(() => contentContext.onPointerGraceIntentChange(null), 300);
|
|
878
|
+
}
|
|
879
|
+
} else {
|
|
880
|
+
contentContext.onTriggerLeave(event);
|
|
881
|
+
if (event.defaultPrevented) return;
|
|
882
|
+
contentContext.onPointerGraceIntentChange(null);
|
|
883
|
+
}
|
|
884
|
+
}),
|
|
885
|
+
...import_web.isWeb ? { onKeyDown: (0, import_web.composeEventHandlers)(props.onKeyDown, (event) => {
|
|
886
|
+
const isTypingAhead = contentContext.searchRef.current !== "";
|
|
887
|
+
if (props.disabled || isTypingAhead && event.key === " ") return;
|
|
888
|
+
const willOpen = SUB_OPEN_KEYS[effectiveDir].includes(event.key);
|
|
889
|
+
if (willOpen) {
|
|
890
|
+
if (context.open && context.content) {
|
|
891
|
+
const contentEl = context.content;
|
|
892
|
+
const firstItem = contentEl.querySelector?.("[role=\"menuitem\"]:not([data-disabled])");
|
|
893
|
+
if (firstItem) {
|
|
894
|
+
firstItem.focus({ focusVisible: true });
|
|
895
|
+
event.preventDefault();
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
const triggerEl = event.currentTarget;
|
|
900
|
+
popperContext.refs?.setReference(triggerEl);
|
|
901
|
+
context.onOpenChange(true);
|
|
902
|
+
requestAnimationFrame(() => {
|
|
903
|
+
popperContext.update?.();
|
|
904
|
+
});
|
|
905
|
+
context.content?.focus({ focusVisible: true });
|
|
906
|
+
event.preventDefault();
|
|
907
|
+
}
|
|
908
|
+
}) } : null
|
|
909
|
+
})
|
|
910
|
+
});
|
|
911
|
+
});
|
|
912
|
+
MenuSubTrigger.displayName = SUB_TRIGGER_NAME;
|
|
913
|
+
const SUB_CONTENT_NAME = "MenuSubContent";
|
|
914
|
+
const MenuSubContentFrame = (0, import_web.styled)(PopperPrimitive.PopperContentFrame, { displayName: SUB_CONTENT_NAME });
|
|
915
|
+
const MenuSubContent = (0, import_core.createStyledHOC)(MenuSubContentFrame, (props, forwardedRef) => {
|
|
916
|
+
const scope = props.scope || MENU_CONTEXT;
|
|
917
|
+
const portalContext = usePortalContext(scope);
|
|
918
|
+
const { forceMount = portalContext.forceMount, ...subContentProps } = props;
|
|
919
|
+
const context = useMenuContext(scope);
|
|
920
|
+
const rootContext = useMenuRootContext(scope);
|
|
921
|
+
const subContext = useMenuSubContext(scope);
|
|
922
|
+
const popperContext = PopperPrimitive.usePopperContext(scope);
|
|
923
|
+
const ref = React.useRef(null);
|
|
924
|
+
const composedRefs = (0, import_web.useComposedRefs)(forwardedRef, ref);
|
|
925
|
+
const placementSide = popperContext.placement?.split("-")[0];
|
|
926
|
+
const dataSide = placementSide === "left" || placementSide === "right" ? placementSide : rootContext.dir === "rtl" ? "left" : "right";
|
|
927
|
+
const effectiveDir = rootContext.dir;
|
|
928
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Provider, {
|
|
929
|
+
scope,
|
|
930
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Slot, {
|
|
931
|
+
scope,
|
|
932
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuContentImpl, {
|
|
933
|
+
id: subContext.contentId,
|
|
934
|
+
"aria-labelledby": subContext.triggerId,
|
|
935
|
+
...subContentProps,
|
|
936
|
+
ref: composedRefs,
|
|
937
|
+
"data-side": dataSide,
|
|
938
|
+
disableOutsidePointerEvents: false,
|
|
939
|
+
disableOutsideScroll: false,
|
|
940
|
+
trapFocus: false,
|
|
941
|
+
onOpenAutoFocus: (event) => {
|
|
942
|
+
if (rootContext.isUsingKeyboardRef.current) {
|
|
943
|
+
const root = ref.current;
|
|
944
|
+
const content = root?.querySelector?.("[data-tamagui-menu-content]");
|
|
945
|
+
(content || root)?.focus({ preventScroll: true });
|
|
946
|
+
}
|
|
947
|
+
event.cancel();
|
|
948
|
+
},
|
|
949
|
+
onCloseAutoFocus: (event) => event.cancel(),
|
|
950
|
+
onFocusOutside: (0, import_web.composeEventHandlers)(props.onFocusOutside, (event) => {
|
|
951
|
+
if (event.event?.target !== subContext.trigger) context.onOpenChange(false);
|
|
952
|
+
}),
|
|
953
|
+
onEscapeKeyDown: (0, import_web.composeEventHandlers)(props.onEscapeKeyDown, (event) => {
|
|
954
|
+
context.onOpenChange(false);
|
|
955
|
+
subContext.trigger?.focus({ focusVisible: true });
|
|
956
|
+
event.cancel();
|
|
957
|
+
event.event?.preventDefault?.();
|
|
958
|
+
}),
|
|
959
|
+
...import_web.isWeb ? { onKeyDown: (0, import_web.composeEventHandlers)(props.onKeyDown, (event) => {
|
|
960
|
+
const isKeyDownInside = event.currentTarget.contains(event.target);
|
|
961
|
+
const isCloseKey = SUB_CLOSE_KEYS[effectiveDir].includes(event.key);
|
|
962
|
+
if (isKeyDownInside && isCloseKey) {
|
|
963
|
+
context.onOpenChange(false);
|
|
964
|
+
subContext.trigger?.focus({ focusVisible: true });
|
|
965
|
+
event.preventDefault();
|
|
966
|
+
}
|
|
967
|
+
}) } : null
|
|
968
|
+
})
|
|
969
|
+
})
|
|
970
|
+
});
|
|
971
|
+
});
|
|
972
|
+
MenuSubContent.displayName = SUB_CONTENT_NAME;
|
|
973
|
+
const Anchor = MenuAnchor;
|
|
974
|
+
const Portal = MenuPortal;
|
|
975
|
+
const Content = MenuContent;
|
|
976
|
+
const Group = (0, import_core.createStyledHOC)(import_web.View, (props, ref) => {
|
|
977
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.View, {
|
|
978
|
+
role: "group",
|
|
979
|
+
...props,
|
|
980
|
+
ref
|
|
981
|
+
});
|
|
982
|
+
});
|
|
983
|
+
Group.displayName = "MenuGroup";
|
|
984
|
+
const Label = (0, import_core.createStyledHOC)(import_web.Text, (props, ref) => {
|
|
985
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.Text, {
|
|
986
|
+
...props,
|
|
987
|
+
ref
|
|
988
|
+
});
|
|
989
|
+
});
|
|
990
|
+
Label.displayName = "MenuLabel";
|
|
991
|
+
const Item = MenuItem;
|
|
992
|
+
const CheckboxItem = MenuCheckboxItem;
|
|
993
|
+
const RadioGroup = MenuRadioGroup;
|
|
994
|
+
const RadioItem = MenuRadioItem;
|
|
995
|
+
const ItemIndicator = MenuItemIndicator;
|
|
996
|
+
const Separator = (0, import_core.createStyledHOC)(import_web.View, (props, ref) => {
|
|
997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.View, {
|
|
998
|
+
role: "separator",
|
|
999
|
+
"aria-orientation": "horizontal",
|
|
1000
|
+
...props,
|
|
1001
|
+
ref
|
|
1002
|
+
});
|
|
1003
|
+
});
|
|
1004
|
+
Separator.displayName = "MenuSeparator";
|
|
1005
|
+
const Arrow = MenuArrow;
|
|
1006
|
+
const Sub = MenuSub;
|
|
1007
|
+
const SubTrigger = MenuSubTrigger;
|
|
1008
|
+
const SubContent = MenuSubContent;
|
|
1009
|
+
const ItemTitle = MenuItemTitle;
|
|
1010
|
+
const ItemSubtitle = MenuItemSubTitle;
|
|
1011
|
+
const ItemImage = MenuItemImage;
|
|
1012
|
+
const ItemIcon = MenuItemIcon;
|
|
1013
|
+
const Menu = (0, import_web.withStaticProperties)(MenuComp, {
|
|
1014
|
+
Anchor,
|
|
1015
|
+
Portal,
|
|
1016
|
+
Content,
|
|
1017
|
+
Group,
|
|
1018
|
+
Label,
|
|
1019
|
+
Item,
|
|
1020
|
+
CheckboxItem,
|
|
1021
|
+
RadioGroup,
|
|
1022
|
+
RadioItem,
|
|
1023
|
+
ItemIndicator,
|
|
1024
|
+
Separator,
|
|
1025
|
+
Arrow,
|
|
1026
|
+
Sub,
|
|
1027
|
+
SubTrigger,
|
|
1028
|
+
SubContent,
|
|
1029
|
+
ItemTitle,
|
|
1030
|
+
ItemSubtitle,
|
|
1031
|
+
ItemImage,
|
|
1032
|
+
ItemIcon
|
|
1033
|
+
});
|
|
1034
|
+
return { Menu };
|
|
1246
1035
|
}
|
|
1247
1036
|
function getOpenState(open) {
|
|
1248
|
-
|
|
1037
|
+
return open ? "open" : "closed";
|
|
1249
1038
|
}
|
|
1250
1039
|
function isIndeterminate(checked) {
|
|
1251
|
-
|
|
1040
|
+
return checked === "indeterminate";
|
|
1252
1041
|
}
|
|
1253
1042
|
function getCheckedState(checked) {
|
|
1254
|
-
|
|
1043
|
+
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
1255
1044
|
}
|
|
1256
1045
|
function focusFirst(candidates, options) {
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1046
|
+
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
1047
|
+
for (const candidate of candidates) {
|
|
1048
|
+
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
1049
|
+
candidate.focus({
|
|
1050
|
+
preventScroll: true,
|
|
1051
|
+
focusVisible: options?.focusVisible
|
|
1052
|
+
});
|
|
1053
|
+
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
1054
|
+
}
|
|
1266
1055
|
}
|
|
1267
1056
|
function wrapArray(array, startIndex) {
|
|
1268
|
-
|
|
1057
|
+
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
1269
1058
|
}
|
|
1270
1059
|
function getNextMatch(values, search, currentMatch) {
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1060
|
+
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
|
1061
|
+
const normalizedSearch = isRepeated ? search[0] : search;
|
|
1062
|
+
const currentMatchIndex = currentMatch ? values.indexOf(currentMatch) : -1;
|
|
1063
|
+
let wrappedValues = wrapArray(values, Math.max(currentMatchIndex, 0));
|
|
1064
|
+
const excludeCurrentMatch = normalizedSearch.length === 1;
|
|
1065
|
+
if (excludeCurrentMatch) wrappedValues = wrappedValues.filter((v) => v !== currentMatch);
|
|
1066
|
+
const nextMatch = wrappedValues.find((value) => value.toLowerCase().startsWith(normalizedSearch.toLowerCase()));
|
|
1067
|
+
return nextMatch !== currentMatch ? nextMatch : void 0;
|
|
1279
1068
|
}
|
|
1280
1069
|
function isPointInPolygon(point, polygon) {
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
if (intersect) inside = !inside;
|
|
1293
|
-
}
|
|
1294
|
-
return inside;
|
|
1070
|
+
const { x, y } = point;
|
|
1071
|
+
let inside = false;
|
|
1072
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
1073
|
+
const xi = polygon[i].x;
|
|
1074
|
+
const yi = polygon[i].y;
|
|
1075
|
+
const xj = polygon[j].x;
|
|
1076
|
+
const yj = polygon[j].y;
|
|
1077
|
+
const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
|
|
1078
|
+
if (intersect) inside = !inside;
|
|
1079
|
+
}
|
|
1080
|
+
return inside;
|
|
1295
1081
|
}
|
|
1296
1082
|
function isPointerInGraceArea(event, area) {
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
}
|
|
1083
|
+
if (!area) return false;
|
|
1084
|
+
const cursorPos = {
|
|
1085
|
+
x: event.clientX,
|
|
1086
|
+
y: event.clientY
|
|
1087
|
+
};
|
|
1088
|
+
return isPointInPolygon(cursorPos, area);
|
|
1089
|
+
}
|