@versini/ui-menu 7.6.6 → 7.6.8
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/index.js +289 -631
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-menu v7.6.
|
|
2
|
+
@versini/ui-menu v7.6.8
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -8,62 +8,15 @@ import { useUniqueId } from "@versini/ui-hooks/use-unique-id";
|
|
|
8
8
|
import { createContext, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
9
9
|
import clsx_0, { clsx } from "clsx";
|
|
10
10
|
import { IconNext } from "@versini/ui-icons";
|
|
11
|
-
|
|
12
11
|
import * as __rspack_external_react from "react";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Returning focus to the trigger without asking for a focus ring.
|
|
20
|
-
*
|
|
21
|
-
* Closing a menu hands focus back to its trigger. Whether such a script-moved
|
|
22
|
-
* focus should be RINGED is a heuristic the spec leaves to the UA, and the
|
|
23
|
-
* engines disagree: measured in Safari 27 / WebKit 605.1.15, `button.focus()`
|
|
24
|
-
* matches `:focus-visible` even from a cold start with nothing focused
|
|
25
|
-
* beforehand, while Chromium declines to. So in WebKit, dismissing a menu with
|
|
26
|
-
* a tap painted a keyboard focus ring on the trigger.
|
|
27
|
-
*
|
|
28
|
-
* SCOPED TO THE TRIGGER on purpose. A menu focuses items constantly -- on
|
|
29
|
-
* hover, on open, on arrow keys -- and none of those needs this: every item
|
|
30
|
-
* carries `outline-hidden` from `getMenuItemClasses`, an author declaration
|
|
31
|
-
* that outranks the UA's `:focus-visible` outline, so an item cannot ring
|
|
32
|
-
* however it is focused. The trigger is the exception because it is supplied by
|
|
33
|
-
* the consumer, typically a `ui-button` carrying `focus-visible:outline-*`.
|
|
34
|
-
*
|
|
35
|
-
* ONLY `false` IS EVER PASSED, and that asymmetry is the design. A
|
|
36
|
-
* pointer-driven dismissal knows the ring is wrong and says so. A
|
|
37
|
-
* keyboard-driven one says NOTHING and calls `focus()` bare, leaving the
|
|
38
|
-
* decision to the UA, because that is the case the heuristic already gets right
|
|
39
|
-
* -- passing `focusVisible: true` would override it rather than agree with it.
|
|
40
|
-
*
|
|
41
|
-
*/ /**
|
|
42
|
-
* Focus `element`, suppressing the ring when we know a pointer caused it.
|
|
43
|
-
*
|
|
44
|
-
* `element` is optional so call sites can pass a ref's `current` straight in
|
|
45
|
-
* without repeating the null check at seven sites.
|
|
46
|
-
*
|
|
47
|
-
*/ const restoreFocus = (element, { viaPointer } = {})=>{
|
|
12
|
+
const restoreFocus = (element, { viaPointer } = {})=>{
|
|
48
13
|
element?.focus(viaPointer ? {
|
|
49
14
|
focusVisible: false
|
|
50
|
-
} :
|
|
15
|
+
} : void 0);
|
|
51
16
|
};
|
|
52
|
-
|
|
53
|
-
* Whether a click came from a pointer rather than from a keypress.
|
|
54
|
-
*
|
|
55
|
-
* `useMenuKeyboard` activates Enter and Space by calling `element.click()`, so
|
|
56
|
-
* a keyboard activation and a real tap arrive at the SAME handler and the call
|
|
57
|
-
* site alone cannot tell them apart. `detail` can: a synthetic click reports 0
|
|
58
|
-
* and a pointer click reports 1 or more. Measured in WebKit rather than
|
|
59
|
-
* assumed.
|
|
60
|
-
*
|
|
61
|
-
*/ const isPointerClick = (event)=>event.detail > 0;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
17
|
+
const isPointerClick = (event)=>event.detail > 0;
|
|
65
18
|
const MenuGroupContext = createContext(false);
|
|
66
|
-
|
|
19
|
+
const MenuRootContext = createContext({
|
|
67
20
|
closeAll: ()=>{}
|
|
68
21
|
});
|
|
69
22
|
const MenuContentContext = createContext({
|
|
@@ -76,111 +29,69 @@ const MenuContentContext = createContext({
|
|
|
76
29
|
setOpenSubMenuId: ()=>{},
|
|
77
30
|
close: ()=>{},
|
|
78
31
|
isSubMenu: false
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
32
|
+
});
|
|
83
33
|
function getNextEnabledIndex(items, currentIndex, direction) {
|
|
84
34
|
const count = items.length;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
/* v8 ignore stop */ let index = currentIndex;
|
|
35
|
+
if (0 === count) return -1;
|
|
36
|
+
let index = currentIndex;
|
|
89
37
|
for(let i = 0; i < count; i++){
|
|
90
38
|
index = (index + direction + count) % count;
|
|
91
|
-
if (!items[index].disabled)
|
|
92
|
-
return index;
|
|
93
|
-
}
|
|
39
|
+
if (!items[index].disabled) return index;
|
|
94
40
|
}
|
|
95
|
-
|
|
96
|
-
|
|
41
|
+
return currentIndex;
|
|
42
|
+
}
|
|
97
43
|
const TYPEAHEAD_TIMEOUT_MS = 500;
|
|
98
44
|
function getTypeaheadMatchIndex(items, searchString, startIndex) {
|
|
99
45
|
const count = items.length;
|
|
100
46
|
const normalized = searchString.toLowerCase();
|
|
101
|
-
|
|
102
|
-
* When the same single character is repeated (e.g. "aaa"), cycle through items
|
|
103
|
-
* starting with that character instead of trying to match the full repeated
|
|
104
|
-
* string.
|
|
105
|
-
*/ const isRepeatedChar = normalized.length > 1 && [
|
|
47
|
+
const isRepeatedChar = normalized.length > 1 && [
|
|
106
48
|
...normalized
|
|
107
49
|
].every((c)=>c === normalized[0]);
|
|
108
50
|
const matchStr = isRepeatedChar ? normalized[0] : normalized;
|
|
109
|
-
|
|
110
|
-
* For a single character (including repeated single-char), start searching
|
|
111
|
-
* from the item *after* the current one so we always advance to the next
|
|
112
|
-
* match. For multi-character strings, start from the current item so the user
|
|
113
|
-
* can refine the match in-place.
|
|
114
|
-
*/ const offset = normalized.length === 1 || isRepeatedChar ? 1 : 0;
|
|
51
|
+
const offset = 1 === normalized.length || isRepeatedChar ? 1 : 0;
|
|
115
52
|
for(let i = 0; i < count; i++){
|
|
116
53
|
const index = (startIndex + offset + i) % count;
|
|
117
|
-
if (items[index].disabled)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
/* v8 ignore start -- textContent is always a string in DOM */ const text = (items[index].element.textContent ?? "").trim().toLowerCase();
|
|
121
|
-
/* v8 ignore stop */ if (text.startsWith(matchStr)) {
|
|
122
|
-
return index;
|
|
123
|
-
}
|
|
54
|
+
if (items[index].disabled) continue;
|
|
55
|
+
const text = (items[index].element.textContent ?? "").trim().toLowerCase();
|
|
56
|
+
if (text.startsWith(matchStr)) return index;
|
|
124
57
|
}
|
|
125
58
|
return -1;
|
|
126
59
|
}
|
|
127
|
-
|
|
128
|
-
for(let i = 0; i < items.length; i++)
|
|
129
|
-
if (!items[i].disabled) {
|
|
130
|
-
return i;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
60
|
+
function getFirstEnabledIndex(items) {
|
|
61
|
+
for(let i = 0; i < items.length; i++)if (!items[i].disabled) return i;
|
|
133
62
|
return -1;
|
|
134
63
|
}
|
|
135
64
|
function getLastEnabledIndex(items) {
|
|
136
|
-
for(let i = items.length - 1; i >= 0; i--)
|
|
137
|
-
if (!items[i].disabled) {
|
|
138
|
-
return i;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
65
|
+
for(let i = items.length - 1; i >= 0; i--)if (!items[i].disabled) return i;
|
|
141
66
|
return -1;
|
|
142
67
|
}
|
|
143
|
-
|
|
68
|
+
function useMenuKeyboard({ menuRef, isOpen, activeIndex, setActiveIndex, getItems, onClose, isSubMenu = false, onOpenSubMenu, onCloseToParent }) {
|
|
144
69
|
const searchBufferRef = useRef("");
|
|
145
|
-
const searchTimeoutRef = useRef(
|
|
146
|
-
// Clear the typeahead buffer when the menu closes.
|
|
70
|
+
const searchTimeoutRef = useRef(void 0);
|
|
147
71
|
useEffect(()=>{
|
|
148
72
|
if (!isOpen) {
|
|
149
73
|
searchBufferRef.current = "";
|
|
150
|
-
if (searchTimeoutRef.current)
|
|
151
|
-
clearTimeout(searchTimeoutRef.current);
|
|
152
|
-
}
|
|
74
|
+
if (searchTimeoutRef.current) clearTimeout(searchTimeoutRef.current);
|
|
153
75
|
}
|
|
154
76
|
}, [
|
|
155
77
|
isOpen
|
|
156
78
|
]);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
clearTimeout(searchTimeoutRef.current);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
}, []);
|
|
165
|
-
/* v8 ignore start - focusItem bounds guard */ const focusItem = useCallback((index)=>{
|
|
79
|
+
useEffect(()=>()=>{
|
|
80
|
+
if (searchTimeoutRef.current) clearTimeout(searchTimeoutRef.current);
|
|
81
|
+
}, []);
|
|
82
|
+
const focusItem = useCallback((index)=>{
|
|
166
83
|
const items = getItems();
|
|
167
|
-
if (index >= 0 && index < items.length)
|
|
168
|
-
items[index].element.focus();
|
|
169
|
-
}
|
|
84
|
+
if (index >= 0 && index < items.length) items[index].element.focus();
|
|
170
85
|
}, [
|
|
171
86
|
getItems
|
|
172
87
|
]);
|
|
173
|
-
|
|
174
|
-
if (!isOpen || !menuRef.current)
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
88
|
+
useEffect(()=>{
|
|
89
|
+
if (!isOpen || !menuRef.current) return;
|
|
177
90
|
const handleKeyDown = (event)=>{
|
|
178
91
|
const items = getItems();
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
/* v8 ignore stop */ /* v8 ignore start - switch internal branch */ switch(event.key){
|
|
183
|
-
/* v8 ignore stop */ case "ArrowDown":
|
|
92
|
+
if (0 === items.length) return;
|
|
93
|
+
switch(event.key){
|
|
94
|
+
case "ArrowDown":
|
|
184
95
|
{
|
|
185
96
|
event.preventDefault();
|
|
186
97
|
event.stopPropagation();
|
|
@@ -218,73 +129,53 @@ function getLastEnabledIndex(items) {
|
|
|
218
129
|
}
|
|
219
130
|
case "Enter":
|
|
220
131
|
case " ":
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
items[activeIndex].element.click();
|
|
226
|
-
}
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
event.stopPropagation();
|
|
134
|
+
if (activeIndex >= 0 && activeIndex < items.length && !items[activeIndex].disabled) items[activeIndex].element.click();
|
|
135
|
+
break;
|
|
229
136
|
case "Escape":
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (activeIndex >= 0 && activeIndex < items.length && onOpenSubMenu) {
|
|
239
|
-
const item = items[activeIndex].element;
|
|
240
|
-
if (item.getAttribute("aria-haspopup") === "menu") {
|
|
241
|
-
event.preventDefault();
|
|
242
|
-
event.stopPropagation();
|
|
243
|
-
onOpenSubMenu(item);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
case "ArrowLeft":
|
|
249
|
-
{
|
|
250
|
-
if (isSubMenu && onCloseToParent) {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
event.stopPropagation();
|
|
139
|
+
onClose();
|
|
140
|
+
break;
|
|
141
|
+
case "ArrowRight":
|
|
142
|
+
if (activeIndex >= 0 && activeIndex < items.length && onOpenSubMenu) {
|
|
143
|
+
const item = items[activeIndex].element;
|
|
144
|
+
if ("menu" === item.getAttribute("aria-haspopup")) {
|
|
251
145
|
event.preventDefault();
|
|
252
146
|
event.stopPropagation();
|
|
253
|
-
|
|
147
|
+
onOpenSubMenu(item);
|
|
254
148
|
}
|
|
255
|
-
break;
|
|
256
149
|
}
|
|
257
|
-
|
|
258
|
-
|
|
150
|
+
break;
|
|
151
|
+
case "ArrowLeft":
|
|
152
|
+
if (isSubMenu && onCloseToParent) {
|
|
259
153
|
event.preventDefault();
|
|
260
154
|
event.stopPropagation();
|
|
261
|
-
|
|
262
|
-
break;
|
|
155
|
+
onCloseToParent();
|
|
263
156
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
focusItem(matchIndex);
|
|
281
|
-
}
|
|
282
|
-
searchTimeoutRef.current = setTimeout(()=>{
|
|
283
|
-
searchBufferRef.current = "";
|
|
284
|
-
}, TYPEAHEAD_TIMEOUT_MS);
|
|
157
|
+
break;
|
|
158
|
+
case "Tab":
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
event.stopPropagation();
|
|
161
|
+
onClose();
|
|
162
|
+
break;
|
|
163
|
+
default:
|
|
164
|
+
if (1 === event.key.length && !event.ctrlKey && !event.metaKey) {
|
|
165
|
+
event.preventDefault();
|
|
166
|
+
event.stopPropagation();
|
|
167
|
+
if (searchTimeoutRef.current) clearTimeout(searchTimeoutRef.current);
|
|
168
|
+
searchBufferRef.current += event.key;
|
|
169
|
+
const matchIndex = getTypeaheadMatchIndex(items, searchBufferRef.current, activeIndex >= 0 ? activeIndex : 0);
|
|
170
|
+
if (matchIndex >= 0) {
|
|
171
|
+
setActiveIndex(matchIndex);
|
|
172
|
+
focusItem(matchIndex);
|
|
285
173
|
}
|
|
286
|
-
|
|
174
|
+
searchTimeoutRef.current = setTimeout(()=>{
|
|
175
|
+
searchBufferRef.current = "";
|
|
176
|
+
}, TYPEAHEAD_TIMEOUT_MS);
|
|
287
177
|
}
|
|
178
|
+
break;
|
|
288
179
|
}
|
|
289
180
|
};
|
|
290
181
|
const menuElement = menuRef.current;
|
|
@@ -308,67 +199,35 @@ function getLastEnabledIndex(items) {
|
|
|
308
199
|
focusItem
|
|
309
200
|
};
|
|
310
201
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Shared classes for the small green "selected" dot, reused by MenuItem (inner
|
|
319
|
-
* dot) and MenuSub (nested-selection indicator) so the success token lives in
|
|
320
|
-
* one place.
|
|
321
|
-
*/ const SELECTED_DOT_CLASS = "size-1.5 rounded-full bg-copy-success-light";
|
|
202
|
+
const SELECTED_DOT_CLASS = "size-1.5 rounded-full bg-copy-success-light";
|
|
322
203
|
const getDisplayName = (element)=>{
|
|
323
|
-
if (typeof element
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
if (typeof element === "function") {
|
|
327
|
-
return element.displayName || element.name || "Component";
|
|
328
|
-
}
|
|
329
|
-
if (typeof element === "object" && element !== null && "type" in element) {
|
|
204
|
+
if ("string" == typeof element) return element;
|
|
205
|
+
if ("function" == typeof element) return element.displayName || element.name || "Component";
|
|
206
|
+
if ("object" == typeof element && null !== element && "type" in element) {
|
|
330
207
|
const type = element.type;
|
|
331
|
-
if (typeof type
|
|
332
|
-
/* v8 ignore start */ return type.displayName || type.name || "Component";
|
|
333
|
-
/* v8 ignore stop */ }
|
|
208
|
+
if ("function" == typeof type || "object" == typeof type) return type.displayName || type.name || "Component";
|
|
334
209
|
}
|
|
335
210
|
return "Element";
|
|
336
211
|
};
|
|
337
|
-
|
|
338
|
-
* Recursively walks a React children tree looking for a selected menu entry.
|
|
339
|
-
* Only `MenuItem`/`MenuSub` elements with `selected === true` count, so an
|
|
340
|
-
* unrelated `selected` prop on other nested content (e.g. a native `<option
|
|
341
|
-
* selected>`) does not produce a false indicator. Traversal still descends
|
|
342
|
-
* through any container (MenuGroup, fragments) to reach those entries.
|
|
343
|
-
*
|
|
344
|
-
* Used by MenuSub to surface a nested selection on its trigger row even while
|
|
345
|
-
* the sub-menu is closed (sub-menu children are conditionally mounted, so they
|
|
346
|
-
* cannot report selection upward via context).
|
|
347
|
-
*
|
|
348
|
-
*/ const hasSelectedDescendant = (node)=>{
|
|
212
|
+
const hasSelectedDescendant = (node)=>{
|
|
349
213
|
let found = false;
|
|
350
214
|
__rspack_external_react.Children.forEach(node, (child)=>{
|
|
351
|
-
if (found || !__rspack_external_react.isValidElement(child))
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
215
|
+
if (found || !__rspack_external_react.isValidElement(child)) return;
|
|
354
216
|
const childProps = child.props;
|
|
355
217
|
const name = getDisplayName(child);
|
|
356
|
-
if ((
|
|
218
|
+
if (("MenuItem" === name || "MenuSub" === name) && true === childProps.selected) {
|
|
357
219
|
found = true;
|
|
358
220
|
return;
|
|
359
221
|
}
|
|
360
|
-
if (childProps.children)
|
|
361
|
-
found = hasSelectedDescendant(childProps.children);
|
|
362
|
-
}
|
|
222
|
+
if (childProps.children) found = hasSelectedDescendant(childProps.children);
|
|
363
223
|
});
|
|
364
224
|
return found;
|
|
365
225
|
};
|
|
366
226
|
const calculatePosition = (triggerRect, menuRect, placement, sideOffset, viewportWidth, viewportHeight)=>{
|
|
367
|
-
|
|
368
|
-
|
|
227
|
+
const side = placement.split("-")[0] || "bottom";
|
|
228
|
+
const alignment = placement.includes("-") ? placement.split("-")[1] : "center";
|
|
369
229
|
let top = 0;
|
|
370
230
|
let left = 0;
|
|
371
|
-
// Calculate base position based on side.
|
|
372
231
|
switch(side){
|
|
373
232
|
case "bottom":
|
|
374
233
|
top = triggerRect.bottom + sideOffset;
|
|
@@ -383,55 +242,41 @@ const calculatePosition = (triggerRect, menuRect, placement, sideOffset, viewpor
|
|
|
383
242
|
left = triggerRect.left - menuRect.width - sideOffset;
|
|
384
243
|
break;
|
|
385
244
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
left = triggerRect.left + (triggerRect.width - menuRect.width) / 2;
|
|
397
|
-
break;
|
|
398
|
-
}
|
|
399
|
-
} else {
|
|
400
|
-
switch(alignment){
|
|
401
|
-
case "start":
|
|
402
|
-
top = triggerRect.top;
|
|
403
|
-
break;
|
|
404
|
-
case "end":
|
|
405
|
-
top = triggerRect.bottom - menuRect.height;
|
|
406
|
-
break;
|
|
407
|
-
default:
|
|
408
|
-
top = triggerRect.top + (triggerRect.height - menuRect.height) / 2;
|
|
409
|
-
break;
|
|
410
|
-
}
|
|
245
|
+
if ("bottom" === side || "top" === side) switch(alignment){
|
|
246
|
+
case "start":
|
|
247
|
+
left = triggerRect.left;
|
|
248
|
+
break;
|
|
249
|
+
case "end":
|
|
250
|
+
left = triggerRect.right - menuRect.width;
|
|
251
|
+
break;
|
|
252
|
+
default:
|
|
253
|
+
left = triggerRect.left + (triggerRect.width - menuRect.width) / 2;
|
|
254
|
+
break;
|
|
411
255
|
}
|
|
412
|
-
|
|
413
|
-
|
|
256
|
+
else switch(alignment){
|
|
257
|
+
case "start":
|
|
258
|
+
top = triggerRect.top;
|
|
259
|
+
break;
|
|
260
|
+
case "end":
|
|
261
|
+
top = triggerRect.bottom - menuRect.height;
|
|
262
|
+
break;
|
|
263
|
+
default:
|
|
264
|
+
top = triggerRect.top + (triggerRect.height - menuRect.height) / 2;
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
if ("bottom" === side && top + menuRect.height > viewportHeight) {
|
|
414
268
|
const flippedTop = triggerRect.top - menuRect.height - sideOffset;
|
|
415
|
-
if (flippedTop >= 0)
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
} else if (side === "top" && top < 0) {
|
|
269
|
+
if (flippedTop >= 0) top = flippedTop;
|
|
270
|
+
} else if ("top" === side && top < 0) {
|
|
419
271
|
const flippedTop = triggerRect.bottom + sideOffset;
|
|
420
|
-
if (flippedTop + menuRect.height <= viewportHeight)
|
|
421
|
-
|
|
422
|
-
}
|
|
423
|
-
} else if (side === "right" && left + menuRect.width > viewportWidth) {
|
|
272
|
+
if (flippedTop + menuRect.height <= viewportHeight) top = flippedTop;
|
|
273
|
+
} else if ("right" === side && left + menuRect.width > viewportWidth) {
|
|
424
274
|
const flippedLeft = triggerRect.left - menuRect.width - sideOffset;
|
|
425
|
-
if (flippedLeft >= 0)
|
|
426
|
-
|
|
427
|
-
}
|
|
428
|
-
} else if (side === "left" && left < 0) {
|
|
275
|
+
if (flippedLeft >= 0) left = flippedLeft;
|
|
276
|
+
} else if ("left" === side && left < 0) {
|
|
429
277
|
const flippedLeft = triggerRect.right + sideOffset;
|
|
430
|
-
if (flippedLeft + menuRect.width <= viewportWidth)
|
|
431
|
-
left = flippedLeft;
|
|
432
|
-
}
|
|
278
|
+
if (flippedLeft + menuRect.width <= viewportWidth) left = flippedLeft;
|
|
433
279
|
}
|
|
434
|
-
/* v8 ignore stop */ // Clamp to viewport bounds.
|
|
435
280
|
left = Math.max(0, Math.min(left, viewportWidth - menuRect.width));
|
|
436
281
|
top = Math.max(0, Math.min(top, viewportHeight - menuRect.height));
|
|
437
282
|
return {
|
|
@@ -439,31 +284,22 @@ const calculatePosition = (triggerRect, menuRect, placement, sideOffset, viewpor
|
|
|
439
284
|
left
|
|
440
285
|
};
|
|
441
286
|
};
|
|
442
|
-
const getMenuItemClasses = ({ isSub })=>{
|
|
443
|
-
return clsx("flex flex-row items-center", "w-full", "m-0 first:mt-0 mt-2 sm:mt-1 px-2 py-1", "rounded-md border border-transparent", "text-left text-base select-none cursor-pointer", "outline-hidden", "disabled:cursor-not-allowed disabled:text-copy-medium", "text-copy-dark", "data-highlighted:bg-surface-darker", "data-highlighted:text-copy-light", "in-data-menu-group:text-copy-light", "in-data-menu-group:data-highlighted:bg-surface-darker", "in-data-menu-group:data-highlighted:border-border-medium", {
|
|
287
|
+
const getMenuItemClasses = ({ isSub })=>clsx("flex flex-row items-center", "w-full", "m-0 first:mt-0 mt-2 sm:mt-1 px-2 py-1", "rounded-md border border-transparent", "text-left text-base select-none cursor-pointer", "outline-hidden", "disabled:cursor-not-allowed disabled:text-copy-medium", "text-copy-dark", "data-highlighted:bg-surface-darker", "data-highlighted:text-copy-light", "in-data-menu-group:text-copy-light", "in-data-menu-group:data-highlighted:bg-surface-darker", "in-data-menu-group:data-highlighted:border-border-medium", {
|
|
444
288
|
"data-[state=open]:bg-surface-darker data-[state=open]:text-copy-light justify-between": isSub,
|
|
445
289
|
"data-disabled:cursor-not-allowed data-disabled:text-copy-medium": !isSub
|
|
446
290
|
});
|
|
447
|
-
}
|
|
448
|
-
const getMenuClasses = ({ isSub, noBackdrop = false })=>{
|
|
449
|
-
return clsx("bg-surface-light", "rounded-md", "outline-hidden", "p-1", {
|
|
291
|
+
const getMenuClasses = ({ isSub, noBackdrop = false })=>clsx("bg-surface-light", "rounded-md", "outline-hidden", "p-1", {
|
|
450
292
|
"z-100 plume plume-dark": !isSub,
|
|
451
293
|
"z-60 mx-3": isSub,
|
|
452
294
|
"av-backdrop-animate": !noBackdrop && !isSub
|
|
453
295
|
});
|
|
454
|
-
};
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
296
|
function useMenuPosition({ triggerRef, menuRef, placement, sideOffset, isOpen }) {
|
|
459
297
|
const positionRef = useRef({
|
|
460
298
|
top: 0,
|
|
461
299
|
left: 0
|
|
462
300
|
});
|
|
463
301
|
const updatePosition = useCallback(()=>{
|
|
464
|
-
|
|
465
|
-
return;
|
|
466
|
-
}
|
|
302
|
+
if (!triggerRef.current || !menuRef.current) return;
|
|
467
303
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
468
304
|
const menuRect = menuRef.current.getBoundingClientRect();
|
|
469
305
|
const viewportWidth = window.innerWidth;
|
|
@@ -474,18 +310,16 @@ function useMenuPosition({ triggerRef, menuRef, placement, sideOffset, isOpen })
|
|
|
474
310
|
menuRef.current.style.top = `${position.top}px`;
|
|
475
311
|
menuRef.current.style.left = `${position.left}px`;
|
|
476
312
|
menuRef.current.style.margin = "0";
|
|
477
|
-
|
|
313
|
+
}, [
|
|
478
314
|
triggerRef,
|
|
479
315
|
menuRef,
|
|
480
316
|
placement,
|
|
481
317
|
sideOffset
|
|
482
318
|
]);
|
|
483
319
|
useEffect(()=>{
|
|
484
|
-
if (isOpen) {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
});
|
|
488
|
-
}
|
|
320
|
+
if (isOpen) requestAnimationFrame(()=>{
|
|
321
|
+
updatePosition();
|
|
322
|
+
});
|
|
489
323
|
}, [
|
|
490
324
|
isOpen,
|
|
491
325
|
updatePosition
|
|
@@ -495,79 +329,49 @@ function useMenuPosition({ triggerRef, menuRef, placement, sideOffset, isOpen })
|
|
|
495
329
|
positionRef
|
|
496
330
|
};
|
|
497
331
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
332
|
const Menu = ({ trigger, children, label = "Open menu", defaultPlacement = "bottom-start", onOpenChange, mode = "system", sideOffset = 10, noBackdrop = false })=>{
|
|
509
333
|
const contentClass = getMenuClasses({
|
|
510
334
|
isSub: false,
|
|
511
335
|
noBackdrop
|
|
512
336
|
});
|
|
513
|
-
const [isOpen, setIsOpen] = (0,__rspack_external_react.useState)(false);
|
|
514
|
-
const [activeIndex, setActiveIndex] = (0,__rspack_external_react.useState)(-1);
|
|
515
|
-
const [openSubMenuId, setOpenSubMenuId] = (0,__rspack_external_react.useState)(null);
|
|
337
|
+
const [isOpen, setIsOpen] = (0, __rspack_external_react.useState)(false);
|
|
338
|
+
const [activeIndex, setActiveIndex] = (0, __rspack_external_react.useState)(-1);
|
|
339
|
+
const [openSubMenuId, setOpenSubMenuId] = (0, __rspack_external_react.useState)(null);
|
|
516
340
|
const menuId = useUniqueId("av-menu-");
|
|
517
|
-
const triggerRef = (0,__rspack_external_react.useRef)(null);
|
|
518
|
-
const menuRef = (0,__rspack_external_react.useRef)(null);
|
|
519
|
-
const itemsRef = (0,__rspack_external_react.useRef)([]);
|
|
520
|
-
const isTogglingRef = (0,__rspack_external_react.useRef)(false);
|
|
341
|
+
const triggerRef = (0, __rspack_external_react.useRef)(null);
|
|
342
|
+
const menuRef = (0, __rspack_external_react.useRef)(null);
|
|
343
|
+
const itemsRef = (0, __rspack_external_react.useRef)([]);
|
|
344
|
+
const isTogglingRef = (0, __rspack_external_react.useRef)(false);
|
|
521
345
|
useMenuPosition({
|
|
522
346
|
triggerRef,
|
|
523
347
|
menuRef,
|
|
524
|
-
|
|
525
|
-
|
|
348
|
+
placement: defaultPlacement || "bottom-start",
|
|
349
|
+
sideOffset,
|
|
526
350
|
isOpen
|
|
527
351
|
});
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
menuRef.current.showPopover();
|
|
533
|
-
} catch {
|
|
534
|
-
// Popover might already be shown.
|
|
535
|
-
}
|
|
536
|
-
}
|
|
352
|
+
(0, __rspack_external_react.useEffect)(()=>{
|
|
353
|
+
if (isOpen && menuRef.current && "function" == typeof menuRef.current.showPopover) try {
|
|
354
|
+
menuRef.current.showPopover();
|
|
355
|
+
} catch {}
|
|
537
356
|
}, [
|
|
538
357
|
isOpen
|
|
539
358
|
]);
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
* reaches this on Escape and Tab, `handleToggle` on a click of the trigger
|
|
544
|
-
* itself, and `MenuItem` on an activation that may be either. Each passes what
|
|
545
|
-
* it knows; see `focusRestore.ts` for why only the pointer case speaks up.
|
|
546
|
-
*/ const handleClose = (0,__rspack_external_react.useCallback)((options)=>{
|
|
547
|
-
/* v8 ignore start - guard against double-close */ if (!isOpen) {
|
|
548
|
-
return;
|
|
549
|
-
}
|
|
550
|
-
/* v8 ignore stop */ setIsOpen(false);
|
|
359
|
+
const handleClose = (0, __rspack_external_react.useCallback)((options)=>{
|
|
360
|
+
if (!isOpen) return;
|
|
361
|
+
setIsOpen(false);
|
|
551
362
|
setActiveIndex(-1);
|
|
552
363
|
setOpenSubMenuId(null);
|
|
553
364
|
onOpenChange?.(false);
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
// Popover might already be hidden.
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
/* v8 ignore stop */ restoreFocus(triggerRef.current, options);
|
|
365
|
+
if (menuRef.current && "function" == typeof menuRef.current.hidePopover) try {
|
|
366
|
+
menuRef.current.hidePopover();
|
|
367
|
+
} catch {}
|
|
368
|
+
restoreFocus(triggerRef.current, options);
|
|
562
369
|
}, [
|
|
563
370
|
isOpen,
|
|
564
371
|
onOpenChange
|
|
565
372
|
]);
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (!isOpen) {
|
|
569
|
-
return;
|
|
570
|
-
}
|
|
373
|
+
(0, __rspack_external_react.useEffect)(()=>{
|
|
374
|
+
if (!isOpen) return;
|
|
571
375
|
const handleClickOutside = (event)=>{
|
|
572
376
|
const target = event.target;
|
|
573
377
|
if (menuRef.current && !menuRef.current.contains(target) && triggerRef.current && !triggerRef.current.contains(target)) {
|
|
@@ -575,13 +379,11 @@ const Menu = ({ trigger, children, label = "Open menu", defaultPlacement = "bott
|
|
|
575
379
|
setActiveIndex(-1);
|
|
576
380
|
setOpenSubMenuId(null);
|
|
577
381
|
onOpenChange?.(false);
|
|
578
|
-
// A mousedown outside is unambiguously a pointer.
|
|
579
382
|
restoreFocus(triggerRef.current, {
|
|
580
383
|
viaPointer: true
|
|
581
384
|
});
|
|
582
385
|
}
|
|
583
386
|
};
|
|
584
|
-
// Use a timeout to avoid catching the opening click itself.
|
|
585
387
|
const timeoutId = setTimeout(()=>{
|
|
586
388
|
document.addEventListener("mousedown", handleClickOutside);
|
|
587
389
|
}, 0);
|
|
@@ -593,33 +395,28 @@ const Menu = ({ trigger, children, label = "Open menu", defaultPlacement = "bott
|
|
|
593
395
|
isOpen,
|
|
594
396
|
onOpenChange
|
|
595
397
|
]);
|
|
596
|
-
|
|
597
|
-
const registerItem = (0,__rspack_external_react.useCallback)((element, disabled)=>{
|
|
598
|
-
// Maintain DOM order by using compareDocumentPosition.
|
|
398
|
+
const getItems = (0, __rspack_external_react.useCallback)(()=>itemsRef.current, []);
|
|
399
|
+
const registerItem = (0, __rspack_external_react.useCallback)((element, disabled)=>{
|
|
599
400
|
const existing = itemsRef.current.findIndex((item)=>item.element === element);
|
|
600
|
-
|
|
401
|
+
if (existing >= 0) {
|
|
601
402
|
itemsRef.current[existing].disabled = disabled;
|
|
602
403
|
return;
|
|
603
404
|
}
|
|
604
|
-
|
|
405
|
+
const newItem = {
|
|
605
406
|
element,
|
|
606
407
|
disabled
|
|
607
408
|
};
|
|
608
|
-
// Insert in DOM order.
|
|
609
409
|
const insertIndex = itemsRef.current.findIndex((item)=>item.element.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_PRECEDING);
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
615
|
-
/* v8 ignore stop */ }, []);
|
|
616
|
-
const unregisterItem = (0,__rspack_external_react.useCallback)((element)=>{
|
|
410
|
+
if (-1 === insertIndex) itemsRef.current.push(newItem);
|
|
411
|
+
else itemsRef.current.splice(insertIndex, 0, newItem);
|
|
412
|
+
}, []);
|
|
413
|
+
const unregisterItem = (0, __rspack_external_react.useCallback)((element)=>{
|
|
617
414
|
itemsRef.current = itemsRef.current.filter((item)=>item.element !== element);
|
|
618
415
|
}, []);
|
|
619
|
-
|
|
416
|
+
const handleOpenSubMenu = (0, __rspack_external_react.useCallback)((element)=>{
|
|
620
417
|
element.click();
|
|
621
418
|
}, []);
|
|
622
|
-
|
|
419
|
+
const { focusItem } = useMenuKeyboard({
|
|
623
420
|
menuRef,
|
|
624
421
|
isOpen,
|
|
625
422
|
activeIndex,
|
|
@@ -628,60 +425,32 @@ const Menu = ({ trigger, children, label = "Open menu", defaultPlacement = "bott
|
|
|
628
425
|
onClose: handleClose,
|
|
629
426
|
onOpenSubMenu: handleOpenSubMenu
|
|
630
427
|
});
|
|
631
|
-
const handleOpen = (0,__rspack_external_react.useCallback)(()=>{
|
|
428
|
+
const handleOpen = (0, __rspack_external_react.useCallback)(()=>{
|
|
632
429
|
setIsOpen(true);
|
|
633
430
|
onOpenChange?.(true);
|
|
634
|
-
|
|
635
|
-
/* v8 ignore start - rAF does not execute in test env */ requestAnimationFrame(()=>{
|
|
431
|
+
requestAnimationFrame(()=>{
|
|
636
432
|
const items = getItems();
|
|
637
|
-
for(let i = 0; i < items.length; i++){
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
break;
|
|
642
|
-
}
|
|
433
|
+
for(let i = 0; i < items.length; i++)if (!items[i].disabled) {
|
|
434
|
+
setActiveIndex(i);
|
|
435
|
+
focusItem(i);
|
|
436
|
+
break;
|
|
643
437
|
}
|
|
644
438
|
});
|
|
645
|
-
|
|
439
|
+
}, [
|
|
646
440
|
onOpenChange,
|
|
647
441
|
getItems,
|
|
648
442
|
focusItem
|
|
649
443
|
]);
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
* not read: forcing this to classify every toggle as a pointer leaves the
|
|
661
|
-
* keyboard tests green, which is only possible if the keyboard never reaches
|
|
662
|
-
* this code.
|
|
663
|
-
*
|
|
664
|
-
* Kept as a classifier rather than hardcoded to `true` because it stays
|
|
665
|
-
* correct if that interception is ever removed or narrowed, where a hardcoded
|
|
666
|
-
* value would silently start lying about a keyboard press.
|
|
667
|
-
*
|
|
668
|
-
*/ const handleToggle = (0,__rspack_external_react.useCallback)((event)=>{
|
|
669
|
-
/* v8 ignore start - re-entrant guard for synthetic click dispatch */ if (isTogglingRef.current) {
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
|
-
/* v8 ignore stop */ isTogglingRef.current = true;
|
|
673
|
-
/* v8 ignore start - toggle close when clicking trigger while menu is open */ const viaPointer = isPointerClick(event);
|
|
674
|
-
if (isOpen) {
|
|
675
|
-
handleClose({
|
|
676
|
-
viaPointer
|
|
677
|
-
});
|
|
678
|
-
} else {
|
|
679
|
-
/* v8 ignore stop */ handleOpen();
|
|
680
|
-
/**
|
|
681
|
-
* Dispatch a click event to parent elements. This ensures that parent
|
|
682
|
-
* components like Tooltip can detect the interaction and respond
|
|
683
|
-
* appropriately (e.g., disable tooltip display).
|
|
684
|
-
*/ /* v8 ignore start */ if (triggerRef.current) {
|
|
444
|
+
const handleToggle = (0, __rspack_external_react.useCallback)((event)=>{
|
|
445
|
+
if (isTogglingRef.current) return;
|
|
446
|
+
isTogglingRef.current = true;
|
|
447
|
+
const viaPointer = isPointerClick(event);
|
|
448
|
+
if (isOpen) handleClose({
|
|
449
|
+
viaPointer
|
|
450
|
+
});
|
|
451
|
+
else {
|
|
452
|
+
handleOpen();
|
|
453
|
+
if (triggerRef.current) {
|
|
685
454
|
const clickEvent = new MouseEvent("click", {
|
|
686
455
|
bubbles: true,
|
|
687
456
|
cancelable: true,
|
|
@@ -689,31 +458,28 @@ const Menu = ({ trigger, children, label = "Open menu", defaultPlacement = "bott
|
|
|
689
458
|
});
|
|
690
459
|
triggerRef.current.dispatchEvent(clickEvent);
|
|
691
460
|
}
|
|
692
|
-
|
|
461
|
+
}
|
|
693
462
|
isTogglingRef.current = false;
|
|
694
463
|
}, [
|
|
695
464
|
isOpen,
|
|
696
465
|
handleClose,
|
|
697
466
|
handleOpen
|
|
698
467
|
]);
|
|
699
|
-
|
|
700
|
-
if (
|
|
468
|
+
const handleTriggerKeyDown = (0, __rspack_external_react.useCallback)((event)=>{
|
|
469
|
+
if ("Enter" === event.key || " " === event.key || "ArrowDown" === event.key) {
|
|
701
470
|
event.preventDefault();
|
|
702
|
-
if (!isOpen)
|
|
703
|
-
handleOpen();
|
|
704
|
-
}
|
|
471
|
+
if (!isOpen) handleOpen();
|
|
705
472
|
}
|
|
706
473
|
}, [
|
|
707
474
|
isOpen,
|
|
708
475
|
handleOpen
|
|
709
476
|
]);
|
|
710
|
-
|
|
711
|
-
const noInternalClick = getDisplayName(trigger) === "Button" || getDisplayName(trigger) === "ButtonIcon";
|
|
477
|
+
const noInternalClick = "Button" === getDisplayName(trigger) || "ButtonIcon" === getDisplayName(trigger);
|
|
712
478
|
const uiButtonsExtraProps = noInternalClick ? {
|
|
713
479
|
noInternalClick,
|
|
714
480
|
mode
|
|
715
481
|
} : {};
|
|
716
|
-
|
|
482
|
+
const triggerElement = __rspack_external_react.isValidElement(trigger) ? __rspack_external_react.cloneElement(trigger, {
|
|
717
483
|
...uiButtonsExtraProps,
|
|
718
484
|
"aria-label": label,
|
|
719
485
|
"aria-haspopup": "menu",
|
|
@@ -724,7 +490,7 @@ const Menu = ({ trigger, children, label = "Open menu", defaultPlacement = "bott
|
|
|
724
490
|
onClick: handleToggle,
|
|
725
491
|
onKeyDown: handleTriggerKeyDown
|
|
726
492
|
}) : null;
|
|
727
|
-
|
|
493
|
+
const contentContextValue = {
|
|
728
494
|
registerItem,
|
|
729
495
|
unregisterItem,
|
|
730
496
|
getItems,
|
|
@@ -735,15 +501,15 @@ const Menu = ({ trigger, children, label = "Open menu", defaultPlacement = "bott
|
|
|
735
501
|
close: handleClose,
|
|
736
502
|
isSubMenu: false
|
|
737
503
|
};
|
|
738
|
-
return
|
|
504
|
+
return jsx(MenuRootContext.Provider, {
|
|
739
505
|
value: {
|
|
740
506
|
closeAll: handleClose
|
|
741
507
|
},
|
|
742
|
-
children:
|
|
508
|
+
children: jsxs(MenuContentContext.Provider, {
|
|
743
509
|
value: contentContextValue,
|
|
744
510
|
children: [
|
|
745
511
|
triggerElement,
|
|
746
|
-
isOpen &&
|
|
512
|
+
isOpen && jsx("div", {
|
|
747
513
|
ref: menuRef,
|
|
748
514
|
id: menuId,
|
|
749
515
|
popover: "manual",
|
|
@@ -756,26 +522,20 @@ const Menu = ({ trigger, children, label = "Open menu", defaultPlacement = "bott
|
|
|
756
522
|
});
|
|
757
523
|
};
|
|
758
524
|
Menu.displayName = "Menu";
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
525
|
const MenuGroup = ({ children, label, className, icon })=>{
|
|
766
526
|
const groupClass = clsx_0("rounded-md", "p-2", "first:mt-0 mt-1", "bg-surface-dark", "text-copy-light", className);
|
|
767
527
|
const labelContainerClass = clsx_0("pt-2 pb-2", "px-3 sm:px-2", "-mx-1 -mt-1", "flex items-center justify-between", "text-xs text-copy-medium uppercase font-bold", "rounded-t-md");
|
|
768
|
-
return
|
|
528
|
+
return jsx(MenuGroupContext.Provider, {
|
|
769
529
|
value: true,
|
|
770
|
-
children:
|
|
771
|
-
role: label ? "group" :
|
|
530
|
+
children: jsxs("div", {
|
|
531
|
+
role: label ? "group" : void 0,
|
|
772
532
|
className: groupClass,
|
|
773
533
|
"data-menu-group": true,
|
|
774
|
-
"aria-label": label ||
|
|
534
|
+
"aria-label": label || void 0,
|
|
775
535
|
children: [
|
|
776
|
-
label &&
|
|
536
|
+
label && jsx("div", {
|
|
777
537
|
className: labelContainerClass,
|
|
778
|
-
children:
|
|
538
|
+
children: jsxs("span", {
|
|
779
539
|
className: "flex items-center gap-1",
|
|
780
540
|
children: [
|
|
781
541
|
icon,
|
|
@@ -789,16 +549,6 @@ const MenuGroup = ({ children, label, className, icon })=>{
|
|
|
789
549
|
});
|
|
790
550
|
};
|
|
791
551
|
MenuGroup.displayName = "MenuGroup";
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
552
|
const ITEM_CLASS = getMenuItemClasses({
|
|
803
553
|
isSub: false
|
|
804
554
|
});
|
|
@@ -809,20 +559,18 @@ const MenuItem = ({ label, disabled, icon, raw = false, children, ignoreClick =
|
|
|
809
559
|
const { registerItem, unregisterItem, getItems, activeIndex, setActiveIndex, setOpenSubMenuId } = useContext(MenuContentContext);
|
|
810
560
|
useEffect(()=>{
|
|
811
561
|
const element = itemRef.current;
|
|
812
|
-
|
|
562
|
+
if (element) {
|
|
813
563
|
registerItem(element, !!disabled);
|
|
814
564
|
return ()=>{
|
|
815
565
|
unregisterItem(element);
|
|
816
566
|
};
|
|
817
567
|
}
|
|
818
|
-
|
|
568
|
+
}, [
|
|
819
569
|
disabled,
|
|
820
570
|
registerItem,
|
|
821
571
|
unregisterItem
|
|
822
572
|
]);
|
|
823
|
-
if (!isInsideMenuGroup)
|
|
824
|
-
throw new Error("MenuItem must be used within a MenuGroup.");
|
|
825
|
-
}
|
|
573
|
+
if (!isInsideMenuGroup) throw new Error("MenuItem must be used within a MenuGroup.");
|
|
826
574
|
const getMyIndex = ()=>{
|
|
827
575
|
const items = getItems();
|
|
828
576
|
return items.findIndex((item)=>item.element === itemRef.current);
|
|
@@ -830,101 +578,82 @@ const MenuItem = ({ label, disabled, icon, raw = false, children, ignoreClick =
|
|
|
830
578
|
const myIndex = getMyIndex();
|
|
831
579
|
const isHighlighted = myIndex >= 0 && activeIndex === myIndex;
|
|
832
580
|
const handleSelect = (event)=>{
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
}
|
|
836
|
-
/* v8 ignore stop */ const syntheticEvent = new Event("select", {
|
|
581
|
+
if (disabled) return;
|
|
582
|
+
const syntheticEvent = new Event("select", {
|
|
837
583
|
bubbles: true,
|
|
838
584
|
cancelable: true
|
|
839
585
|
});
|
|
840
|
-
if (ignoreClick)
|
|
841
|
-
syntheticEvent.preventDefault();
|
|
842
|
-
}
|
|
586
|
+
if (ignoreClick) syntheticEvent.preventDefault();
|
|
843
587
|
onSelect?.(syntheticEvent);
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
});
|
|
849
|
-
}
|
|
588
|
+
onClick?.(event);
|
|
589
|
+
if (!ignoreClick) closeAll({
|
|
590
|
+
viaPointer: isPointerClick(event)
|
|
591
|
+
});
|
|
850
592
|
};
|
|
851
593
|
const handleMouseEnter = (event)=>{
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
/* v8 ignore stop */ const myIndex = getMyIndex();
|
|
856
|
-
/* v8 ignore start - item is always registered when mouse enters */ if (myIndex >= 0) {
|
|
594
|
+
if (disabled) return;
|
|
595
|
+
const myIndex = getMyIndex();
|
|
596
|
+
if (myIndex >= 0) {
|
|
857
597
|
setActiveIndex(myIndex);
|
|
858
598
|
itemRef.current?.focus();
|
|
859
599
|
}
|
|
860
|
-
/* v8 ignore stop */ // Close any open sub-menu when hovering a regular item.
|
|
861
600
|
setOpenSubMenuId(null);
|
|
862
601
|
onMouseEnter?.(event);
|
|
863
602
|
};
|
|
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
|
-
onMouseEnter: handleMouseEnter,
|
|
893
|
-
...props,
|
|
894
|
-
children: children
|
|
895
|
-
});
|
|
896
|
-
}
|
|
897
|
-
/* v8 ignore stop */ let buttonSpanClass = "";
|
|
898
|
-
if (icon) {
|
|
899
|
-
buttonSpanClass = "pl-2";
|
|
900
|
-
}
|
|
603
|
+
if (raw && children) return jsx("div", {
|
|
604
|
+
ref: itemRef,
|
|
605
|
+
role: "menuitem",
|
|
606
|
+
tabIndex: isHighlighted ? 0 : -1,
|
|
607
|
+
className: "outline-hidden",
|
|
608
|
+
"data-highlighted": isHighlighted ? "" : void 0,
|
|
609
|
+
"data-disabled": disabled ? "" : void 0,
|
|
610
|
+
"aria-disabled": disabled || void 0,
|
|
611
|
+
onClick: (event)=>{
|
|
612
|
+
if (disabled) return;
|
|
613
|
+
const syntheticEvent = new Event("select", {
|
|
614
|
+
bubbles: true,
|
|
615
|
+
cancelable: true
|
|
616
|
+
});
|
|
617
|
+
if (ignoreClick) syntheticEvent.preventDefault();
|
|
618
|
+
onSelect?.(syntheticEvent);
|
|
619
|
+
onClick?.(event);
|
|
620
|
+
if (!ignoreClick) closeAll({
|
|
621
|
+
viaPointer: isPointerClick(event)
|
|
622
|
+
});
|
|
623
|
+
},
|
|
624
|
+
onMouseEnter: handleMouseEnter,
|
|
625
|
+
...props,
|
|
626
|
+
children: children
|
|
627
|
+
});
|
|
628
|
+
let buttonSpanClass = "";
|
|
629
|
+
if (icon) buttonSpanClass = "pl-2";
|
|
901
630
|
const itemClass = clsx_0(ITEM_CLASS, {
|
|
902
631
|
"bg-none": !disabled && !selected
|
|
903
632
|
});
|
|
904
|
-
return
|
|
633
|
+
return jsxs("div", {
|
|
905
634
|
ref: itemRef,
|
|
906
635
|
role: "menuitem",
|
|
907
636
|
tabIndex: isHighlighted ? 0 : -1,
|
|
908
637
|
className: itemClass,
|
|
909
|
-
"data-highlighted": isHighlighted ? "" :
|
|
910
|
-
"data-disabled": disabled ? "" :
|
|
911
|
-
"aria-disabled": disabled ||
|
|
638
|
+
"data-highlighted": isHighlighted ? "" : void 0,
|
|
639
|
+
"data-disabled": disabled ? "" : void 0,
|
|
640
|
+
"aria-disabled": disabled || void 0,
|
|
912
641
|
onClick: handleSelect,
|
|
913
642
|
onFocus: onFocus,
|
|
914
643
|
onMouseEnter: handleMouseEnter,
|
|
915
644
|
...props,
|
|
916
645
|
children: [
|
|
917
|
-
|
|
646
|
+
true === selected && jsx("span", {
|
|
918
647
|
className: "mr-2 flex size-4 shrink-0 items-center justify-center rounded-full border border-copy-medium",
|
|
919
|
-
children:
|
|
648
|
+
children: jsx("span", {
|
|
920
649
|
className: SELECTED_DOT_CLASS
|
|
921
650
|
})
|
|
922
651
|
}),
|
|
923
|
-
|
|
652
|
+
false === selected && jsx("span", {
|
|
924
653
|
className: clsx_0("mr-2 size-4 shrink-0", "rounded-full border border-copy-medium")
|
|
925
654
|
}),
|
|
926
655
|
icon,
|
|
927
|
-
label &&
|
|
656
|
+
label && jsx("span", {
|
|
928
657
|
className: buttonSpanClass,
|
|
929
658
|
children: label
|
|
930
659
|
})
|
|
@@ -932,22 +661,17 @@ const MenuItem = ({ label, disabled, icon, raw = false, children, ignoreClick =
|
|
|
932
661
|
});
|
|
933
662
|
};
|
|
934
663
|
MenuItem.displayName = "MenuItem";
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
664
|
const MenuLabel = ({ className, icon, children, ...props })=>{
|
|
941
665
|
const groupLabelClass = clsx_0(className, "pt-1 pb-2", "text-xs text-copy-medium uppercase font-bold", "border-b border-border-medium", {
|
|
942
666
|
"flex items-center": icon
|
|
943
667
|
});
|
|
944
668
|
const labelSpanClass = icon ? "px-2" : "";
|
|
945
|
-
return
|
|
669
|
+
return jsxs("div", {
|
|
946
670
|
className: groupLabelClass,
|
|
947
671
|
...props,
|
|
948
672
|
children: [
|
|
949
673
|
icon,
|
|
950
|
-
|
|
674
|
+
jsx("span", {
|
|
951
675
|
className: labelSpanClass,
|
|
952
676
|
children: children
|
|
953
677
|
})
|
|
@@ -955,33 +679,15 @@ const MenuLabel = ({ className, icon, children, ...props })=>{
|
|
|
955
679
|
});
|
|
956
680
|
};
|
|
957
681
|
MenuLabel.displayName = "MenuLabel";
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
682
|
const MenuSeparator = ({ className, ...props })=>{
|
|
964
683
|
const separatorClass = clsx_0(className, "my-1 border-t border-border-medium");
|
|
965
|
-
return
|
|
684
|
+
return jsx("div", {
|
|
966
685
|
role: "separator",
|
|
967
686
|
className: separatorClass,
|
|
968
687
|
...props
|
|
969
688
|
});
|
|
970
689
|
};
|
|
971
690
|
MenuSeparator.displayName = "MenuSeparator";
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
691
|
const SUB_CONTENT_CLASS = getMenuClasses({
|
|
986
692
|
isSub: true
|
|
987
693
|
});
|
|
@@ -998,35 +704,27 @@ const MenuSub = ({ label, icon, children, disabled = false, sideOffset = 20, sel
|
|
|
998
704
|
const subItemsRef = useRef([]);
|
|
999
705
|
const parentContext = useContext(MenuContentContext);
|
|
1000
706
|
const rootContext = useContext(MenuRootContext);
|
|
1001
|
-
// Register as an item in the parent menu.
|
|
1002
707
|
useEffect(()=>{
|
|
1003
708
|
const element = triggerItemRef.current;
|
|
1004
|
-
|
|
709
|
+
if (element) {
|
|
1005
710
|
parentContext.registerItem(element, !!disabled);
|
|
1006
711
|
return ()=>{
|
|
1007
712
|
parentContext.unregisterItem(element);
|
|
1008
713
|
};
|
|
1009
714
|
}
|
|
1010
|
-
|
|
715
|
+
}, [
|
|
1011
716
|
disabled,
|
|
1012
717
|
parentContext.registerItem,
|
|
1013
718
|
parentContext.unregisterItem
|
|
1014
719
|
]);
|
|
1015
|
-
|
|
1016
|
-
* Close if a sibling sub-menu opens or parent signals close (openSubMenuId set
|
|
1017
|
-
* to null).
|
|
1018
|
-
*/ useEffect(()=>{
|
|
720
|
+
useEffect(()=>{
|
|
1019
721
|
if (isSubOpen && parentContext.openSubMenuId !== subMenuId) {
|
|
1020
722
|
setIsSubOpen(false);
|
|
1021
723
|
setSubActiveIndex(-1);
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
// Already hidden.
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
/* v8 ignore stop */ }
|
|
724
|
+
if (subMenuRef.current && "function" == typeof subMenuRef.current.hidePopover) try {
|
|
725
|
+
subMenuRef.current.hidePopover();
|
|
726
|
+
} catch {}
|
|
727
|
+
}
|
|
1030
728
|
}, [
|
|
1031
729
|
parentContext.openSubMenuId,
|
|
1032
730
|
subMenuId,
|
|
@@ -1039,124 +737,92 @@ const MenuSub = ({ label, icon, children, disabled = false, sideOffset = 20, sel
|
|
|
1039
737
|
sideOffset,
|
|
1040
738
|
isOpen: isSubOpen
|
|
1041
739
|
});
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
subMenuRef.current.showPopover();
|
|
1047
|
-
} catch {
|
|
1048
|
-
// Popover might already be shown.
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
740
|
+
useEffect(()=>{
|
|
741
|
+
if (isSubOpen && subMenuRef.current && "function" == typeof subMenuRef.current.showPopover) try {
|
|
742
|
+
subMenuRef.current.showPopover();
|
|
743
|
+
} catch {}
|
|
1051
744
|
}, [
|
|
1052
745
|
isSubOpen
|
|
1053
746
|
]);
|
|
1054
|
-
|
|
747
|
+
const getSubItems = useCallback(()=>subItemsRef.current, []);
|
|
1055
748
|
const registerSubItem = useCallback((element, itemDisabled)=>{
|
|
1056
749
|
const existing = subItemsRef.current.findIndex((item)=>item.element === element);
|
|
1057
|
-
|
|
750
|
+
if (existing >= 0) {
|
|
1058
751
|
subItemsRef.current[existing].disabled = itemDisabled;
|
|
1059
752
|
return;
|
|
1060
753
|
}
|
|
1061
|
-
|
|
754
|
+
const newItem = {
|
|
1062
755
|
element,
|
|
1063
756
|
disabled: itemDisabled
|
|
1064
757
|
};
|
|
1065
758
|
const insertIndex = subItemsRef.current.findIndex((item)=>item.element.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_PRECEDING);
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
subItemsRef.current.splice(insertIndex, 0, newItem);
|
|
1070
|
-
}
|
|
1071
|
-
/* v8 ignore stop */ }, []);
|
|
759
|
+
if (-1 === insertIndex) subItemsRef.current.push(newItem);
|
|
760
|
+
else subItemsRef.current.splice(insertIndex, 0, newItem);
|
|
761
|
+
}, []);
|
|
1072
762
|
const unregisterSubItem = useCallback((element)=>{
|
|
1073
763
|
subItemsRef.current = subItemsRef.current.filter((item)=>item.element !== element);
|
|
1074
764
|
}, []);
|
|
1075
|
-
|
|
765
|
+
const closeSubMenu = useCallback(()=>{
|
|
1076
766
|
setIsSubOpen(false);
|
|
1077
767
|
setSubActiveIndex(-1);
|
|
1078
768
|
setSubOpenSubMenuId(null);
|
|
1079
|
-
if (subMenuRef.current && typeof subMenuRef.current.hidePopover
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
} catch {
|
|
1083
|
-
// Already hidden.
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
769
|
+
if (subMenuRef.current && "function" == typeof subMenuRef.current.hidePopover) try {
|
|
770
|
+
subMenuRef.current.hidePopover();
|
|
771
|
+
} catch {}
|
|
1086
772
|
triggerItemRef.current?.focus();
|
|
1087
773
|
}, []);
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
}
|
|
1092
|
-
/* v8 ignore stop */ setIsSubOpen(true);
|
|
774
|
+
const openSubMenu = useCallback(()=>{
|
|
775
|
+
if (disabled) return;
|
|
776
|
+
setIsSubOpen(true);
|
|
1093
777
|
parentContext.setOpenSubMenuId(subMenuId);
|
|
1094
|
-
|
|
1095
|
-
/* v8 ignore start - rAF does not execute in test env */ requestAnimationFrame(()=>{
|
|
778
|
+
requestAnimationFrame(()=>{
|
|
1096
779
|
const items = getSubItems();
|
|
1097
|
-
for(let i = 0; i < items.length; i++){
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
break;
|
|
1102
|
-
}
|
|
780
|
+
for(let i = 0; i < items.length; i++)if (!items[i].disabled) {
|
|
781
|
+
setSubActiveIndex(i);
|
|
782
|
+
items[i].element.focus();
|
|
783
|
+
break;
|
|
1103
784
|
}
|
|
1104
785
|
});
|
|
1105
|
-
|
|
786
|
+
}, [
|
|
1106
787
|
disabled,
|
|
1107
788
|
parentContext,
|
|
1108
789
|
subMenuId,
|
|
1109
790
|
getSubItems
|
|
1110
791
|
]);
|
|
1111
|
-
|
|
792
|
+
const handleSubOpenSubMenu = useCallback((element)=>{
|
|
1112
793
|
element.click();
|
|
1113
794
|
}, []);
|
|
1114
|
-
|
|
795
|
+
useMenuKeyboard({
|
|
1115
796
|
menuRef: subMenuRef,
|
|
1116
797
|
isOpen: isSubOpen,
|
|
1117
798
|
activeIndex: subActiveIndex,
|
|
1118
799
|
setActiveIndex: setSubActiveIndex,
|
|
1119
800
|
getItems: getSubItems,
|
|
1120
|
-
|
|
801
|
+
onClose: ()=>{
|
|
1121
802
|
rootContext.closeAll();
|
|
1122
803
|
},
|
|
1123
|
-
|
|
804
|
+
isSubMenu: true,
|
|
1124
805
|
onOpenSubMenu: handleSubOpenSubMenu,
|
|
1125
806
|
onCloseToParent: closeSubMenu
|
|
1126
807
|
});
|
|
1127
808
|
const handleTriggerClick = ()=>{
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
openSubMenu();
|
|
1133
|
-
}
|
|
1134
|
-
/* v8 ignore stop */ };
|
|
1135
|
-
/* v8 ignore start - mouse enter always finds registered item */ const handleTriggerMouseEnter = ()=>{
|
|
809
|
+
if (disabled) return;
|
|
810
|
+
if (!isSubOpen) openSubMenu();
|
|
811
|
+
};
|
|
812
|
+
const handleTriggerMouseEnter = ()=>{
|
|
1136
813
|
const items = parentContext.getItems();
|
|
1137
814
|
const myIndex = items.findIndex((item)=>item.element === triggerItemRef.current);
|
|
1138
815
|
if (myIndex >= 0) {
|
|
1139
816
|
parentContext.setActiveIndex(myIndex);
|
|
1140
817
|
triggerItemRef.current?.focus();
|
|
1141
818
|
}
|
|
1142
|
-
|
|
1143
|
-
* Open sub-menu on hover (WAI-ARIA: hover opens sub-menus when parent menu is
|
|
1144
|
-
* already open).
|
|
1145
|
-
*/ if (!isSubOpen && !disabled) {
|
|
1146
|
-
openSubMenu();
|
|
1147
|
-
}
|
|
819
|
+
if (!isSubOpen && !disabled) openSubMenu();
|
|
1148
820
|
};
|
|
1149
|
-
|
|
821
|
+
const myIndex = parentContext.getItems().findIndex((item)=>item.element === triggerItemRef.current);
|
|
1150
822
|
const isHighlighted = myIndex >= 0 && parentContext.activeIndex === myIndex;
|
|
1151
823
|
const labelSpanClass = icon ? "pl-2" : "";
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
* wins; otherwise auto-detect from the descendant children tree.
|
|
1155
|
-
*/ const showSelectedIndicator = selected ?? hasSelectedDescendant(children);
|
|
1156
|
-
/**
|
|
1157
|
-
* Screen-reader description id. Kept OUTSIDE the menuitem's text content so it
|
|
1158
|
-
* never pollutes typeahead navigation (which reads element.textContent).
|
|
1159
|
-
*/ const selectionDescriptionId = `${subMenuId}-selection`;
|
|
824
|
+
const showSelectedIndicator = selected ?? hasSelectedDescendant(children);
|
|
825
|
+
const selectionDescriptionId = `${subMenuId}-selection`;
|
|
1160
826
|
const subContentContextValue = {
|
|
1161
827
|
registerItem: registerSubItem,
|
|
1162
828
|
unregisterItem: unregisterSubItem,
|
|
@@ -1168,59 +834,59 @@ const MenuSub = ({ label, icon, children, disabled = false, sideOffset = 20, sel
|
|
|
1168
834
|
close: closeSubMenu,
|
|
1169
835
|
isSubMenu: true
|
|
1170
836
|
};
|
|
1171
|
-
return
|
|
837
|
+
return jsxs(Fragment, {
|
|
1172
838
|
children: [
|
|
1173
|
-
|
|
839
|
+
jsxs("div", {
|
|
1174
840
|
ref: triggerItemRef,
|
|
1175
841
|
role: "menuitem",
|
|
1176
842
|
"aria-haspopup": "menu",
|
|
1177
843
|
"aria-expanded": isSubOpen,
|
|
1178
844
|
"aria-controls": subMenuId,
|
|
1179
|
-
"aria-describedby": showSelectedIndicator ? selectionDescriptionId :
|
|
845
|
+
"aria-describedby": showSelectedIndicator ? selectionDescriptionId : void 0,
|
|
1180
846
|
tabIndex: isHighlighted ? 0 : -1,
|
|
1181
847
|
className: SUB_TRIGGER_CLASS,
|
|
1182
848
|
"data-state": isSubOpen ? "open" : "closed",
|
|
1183
|
-
"data-highlighted": isHighlighted ? "" :
|
|
1184
|
-
|
|
1185
|
-
"aria-disabled": disabled ||
|
|
1186
|
-
|
|
849
|
+
"data-highlighted": isHighlighted ? "" : void 0,
|
|
850
|
+
"data-disabled": disabled ? "" : void 0,
|
|
851
|
+
"aria-disabled": disabled || void 0,
|
|
852
|
+
onClick: handleTriggerClick,
|
|
1187
853
|
onMouseEnter: handleTriggerMouseEnter,
|
|
1188
854
|
children: [
|
|
1189
|
-
|
|
855
|
+
jsxs("span", {
|
|
1190
856
|
className: "flex items-center",
|
|
1191
857
|
children: [
|
|
1192
|
-
showSelectedIndicator &&
|
|
858
|
+
showSelectedIndicator && jsx("span", {
|
|
1193
859
|
className: `mr-2 shrink-0 ${SELECTED_DOT_CLASS}`,
|
|
1194
860
|
"aria-hidden": "true"
|
|
1195
861
|
}),
|
|
1196
862
|
icon,
|
|
1197
|
-
|
|
863
|
+
jsx("span", {
|
|
1198
864
|
className: labelSpanClass,
|
|
1199
865
|
children: label
|
|
1200
866
|
})
|
|
1201
867
|
]
|
|
1202
868
|
}),
|
|
1203
|
-
|
|
869
|
+
jsx(IconNext, {
|
|
1204
870
|
className: "ml-2",
|
|
1205
871
|
size: "size-3",
|
|
1206
872
|
monotone: true
|
|
1207
873
|
})
|
|
1208
874
|
]
|
|
1209
875
|
}),
|
|
1210
|
-
showSelectedIndicator &&
|
|
876
|
+
showSelectedIndicator && jsx("span", {
|
|
1211
877
|
id: selectionDescriptionId,
|
|
1212
878
|
className: "sr-only",
|
|
1213
879
|
children: "(contains a selection)"
|
|
1214
880
|
}),
|
|
1215
|
-
isSubOpen &&
|
|
881
|
+
isSubOpen && jsx("div", {
|
|
1216
882
|
ref: subMenuRef,
|
|
1217
883
|
id: subMenuId,
|
|
1218
884
|
popover: "manual",
|
|
1219
885
|
role: "menu",
|
|
1220
886
|
className: SUB_CONTENT_CLASS,
|
|
1221
|
-
children:
|
|
887
|
+
children: jsx(MenuGroupContext.Provider, {
|
|
1222
888
|
value: false,
|
|
1223
|
-
children:
|
|
889
|
+
children: jsx(MenuContentContext.Provider, {
|
|
1224
890
|
value: subContentContextValue,
|
|
1225
891
|
children: children
|
|
1226
892
|
})
|
|
@@ -1230,12 +896,4 @@ const MenuSub = ({ label, icon, children, disabled = false, sideOffset = 20, sel
|
|
|
1230
896
|
});
|
|
1231
897
|
};
|
|
1232
898
|
MenuSub.displayName = "MenuSub";
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
899
|
export { Menu, MenuGroup, MenuItem, MenuLabel, MenuSeparator, MenuSub };
|