@radix-ui/react-menu 2.0.7-rc.9 → 2.1.0-rc.2
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.d.mts +82 -70
- package/dist/index.d.ts +82 -70
- package/dist/index.js +807 -974
- package/dist/index.js.map +7 -1
- package/dist/index.mjs +802 -926
- package/dist/index.mjs.map +7 -1
- package/package.json +17 -18
- package/dist/index.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,1032 +1,865 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
$parcel$export(module.exports, "MenuPortal", () => $213e4d2df823067d$export$793392f970497feb);
|
|
33
|
-
$parcel$export(module.exports, "MenuContent", () => $213e4d2df823067d$export$479f0f2f71193efe);
|
|
34
|
-
$parcel$export(module.exports, "MenuGroup", () => $213e4d2df823067d$export$22a631d1f72787bb);
|
|
35
|
-
$parcel$export(module.exports, "MenuLabel", () => $213e4d2df823067d$export$dd37bec0e8a99143);
|
|
36
|
-
$parcel$export(module.exports, "MenuItem", () => $213e4d2df823067d$export$2ce376c2cc3355c8);
|
|
37
|
-
$parcel$export(module.exports, "MenuCheckboxItem", () => $213e4d2df823067d$export$f6f243521332502d);
|
|
38
|
-
$parcel$export(module.exports, "MenuRadioGroup", () => $213e4d2df823067d$export$ea2200c9eee416b3);
|
|
39
|
-
$parcel$export(module.exports, "MenuRadioItem", () => $213e4d2df823067d$export$69bd225e9817f6d0);
|
|
40
|
-
$parcel$export(module.exports, "MenuItemIndicator", () => $213e4d2df823067d$export$a2593e23056970a3);
|
|
41
|
-
$parcel$export(module.exports, "MenuSeparator", () => $213e4d2df823067d$export$1cec7dcdd713e220);
|
|
42
|
-
$parcel$export(module.exports, "MenuArrow", () => $213e4d2df823067d$export$bcdda4773debf5fa);
|
|
43
|
-
$parcel$export(module.exports, "MenuSub", () => $213e4d2df823067d$export$71bdb9d1e2909932);
|
|
44
|
-
$parcel$export(module.exports, "MenuSubTrigger", () => $213e4d2df823067d$export$5fbbb3ba7297405f);
|
|
45
|
-
$parcel$export(module.exports, "MenuSubContent", () => $213e4d2df823067d$export$e7142ab31822bde6);
|
|
46
|
-
$parcel$export(module.exports, "Root", () => $213e4d2df823067d$export$be92b6f5f03c0fe9);
|
|
47
|
-
$parcel$export(module.exports, "Anchor", () => $213e4d2df823067d$export$b688253958b8dfe7);
|
|
48
|
-
$parcel$export(module.exports, "Portal", () => $213e4d2df823067d$export$602eac185826482c);
|
|
49
|
-
$parcel$export(module.exports, "Content", () => $213e4d2df823067d$export$7c6e2c02157bb7d2);
|
|
50
|
-
$parcel$export(module.exports, "Group", () => $213e4d2df823067d$export$eb2fcfdbd7ba97d4);
|
|
51
|
-
$parcel$export(module.exports, "Label", () => $213e4d2df823067d$export$b04be29aa201d4f5);
|
|
52
|
-
$parcel$export(module.exports, "Item", () => $213e4d2df823067d$export$6d08773d2e66f8f2);
|
|
53
|
-
$parcel$export(module.exports, "CheckboxItem", () => $213e4d2df823067d$export$16ce288f89fa631c);
|
|
54
|
-
$parcel$export(module.exports, "RadioGroup", () => $213e4d2df823067d$export$a98f0dcb43a68a25);
|
|
55
|
-
$parcel$export(module.exports, "RadioItem", () => $213e4d2df823067d$export$371ab307eab489c0);
|
|
56
|
-
$parcel$export(module.exports, "ItemIndicator", () => $213e4d2df823067d$export$c3468e2714d175fa);
|
|
57
|
-
$parcel$export(module.exports, "Separator", () => $213e4d2df823067d$export$1ff3c3f08ae963c0);
|
|
58
|
-
$parcel$export(module.exports, "Arrow", () => $213e4d2df823067d$export$21b07c8f274aebd5);
|
|
59
|
-
$parcel$export(module.exports, "Sub", () => $213e4d2df823067d$export$d7a01e11500dfb6f);
|
|
60
|
-
$parcel$export(module.exports, "SubTrigger", () => $213e4d2df823067d$export$2ea8a7a591ac5eac);
|
|
61
|
-
$parcel$export(module.exports, "SubContent", () => $213e4d2df823067d$export$6d4de93b380beddf);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
(() => {
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
11
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
12
|
+
}) : x)(function(x) {
|
|
13
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
|
+
});
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
83
32
|
|
|
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
|
-
const
|
|
132
|
-
const
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
capture: true,
|
|
151
|
-
once: true
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
const handlePointer = ()=>isUsingKeyboardRef.current = false
|
|
155
|
-
;
|
|
156
|
-
document.addEventListener('keydown', handleKeyDown, {
|
|
157
|
-
capture: true
|
|
158
|
-
});
|
|
159
|
-
return ()=>{
|
|
160
|
-
document.removeEventListener('keydown', handleKeyDown, {
|
|
161
|
-
capture: true
|
|
162
|
-
});
|
|
163
|
-
document.removeEventListener('pointerdown', handlePointer, {
|
|
164
|
-
capture: true
|
|
165
|
-
});
|
|
166
|
-
document.removeEventListener('pointermove', handlePointer, {
|
|
167
|
-
capture: true
|
|
168
|
-
});
|
|
169
|
-
};
|
|
33
|
+
// packages/react/menu/src/Menu.tsx
|
|
34
|
+
var React = __toESM(__require("react"));
|
|
35
|
+
var import_primitive = __require("@radix-ui/primitive");
|
|
36
|
+
var import_react_collection = __require("@radix-ui/react-collection");
|
|
37
|
+
var import_react_compose_refs = __require("@radix-ui/react-compose-refs");
|
|
38
|
+
var import_react_context = __require("@radix-ui/react-context");
|
|
39
|
+
var import_react_direction = __require("@radix-ui/react-direction");
|
|
40
|
+
var import_react_dismissable_layer = __require("@radix-ui/react-dismissable-layer");
|
|
41
|
+
var import_react_focus_guards = __require("@radix-ui/react-focus-guards");
|
|
42
|
+
var import_react_focus_scope = __require("@radix-ui/react-focus-scope");
|
|
43
|
+
var import_react_id = __require("@radix-ui/react-id");
|
|
44
|
+
var PopperPrimitive = __toESM(__require("@radix-ui/react-popper"));
|
|
45
|
+
var import_react_popper = __require("@radix-ui/react-popper");
|
|
46
|
+
var import_react_portal = __require("@radix-ui/react-portal");
|
|
47
|
+
var import_react_presence = __require("@radix-ui/react-presence");
|
|
48
|
+
var import_react_primitive = __require("@radix-ui/react-primitive");
|
|
49
|
+
var RovingFocusGroup = __toESM(__require("@radix-ui/react-roving-focus"));
|
|
50
|
+
var import_react_roving_focus = __require("@radix-ui/react-roving-focus");
|
|
51
|
+
var import_react_slot = __require("@radix-ui/react-slot");
|
|
52
|
+
var import_react_use_callback_ref = __require("@radix-ui/react-use-callback-ref");
|
|
53
|
+
var import_aria_hidden = __require("aria-hidden");
|
|
54
|
+
var import_react_remove_scroll = __require("react-remove-scroll");
|
|
55
|
+
var import_jsx_runtime = __require("react/jsx-runtime");
|
|
56
|
+
var SELECTION_KEYS = ["Enter", " "];
|
|
57
|
+
var FIRST_KEYS = ["ArrowDown", "PageUp", "Home"];
|
|
58
|
+
var LAST_KEYS = ["ArrowUp", "PageDown", "End"];
|
|
59
|
+
var FIRST_LAST_KEYS = [...FIRST_KEYS, ...LAST_KEYS];
|
|
60
|
+
var SUB_OPEN_KEYS = {
|
|
61
|
+
ltr: [...SELECTION_KEYS, "ArrowRight"],
|
|
62
|
+
rtl: [...SELECTION_KEYS, "ArrowLeft"]
|
|
63
|
+
};
|
|
64
|
+
var SUB_CLOSE_KEYS = {
|
|
65
|
+
ltr: ["ArrowLeft"],
|
|
66
|
+
rtl: ["ArrowRight"]
|
|
67
|
+
};
|
|
68
|
+
var MENU_NAME = "Menu";
|
|
69
|
+
var [Collection, useCollection, createCollectionScope] = (0, import_react_collection.createCollection)(MENU_NAME);
|
|
70
|
+
var [createMenuContext, createMenuScope] = (0, import_react_context.createContextScope)(MENU_NAME, [
|
|
71
|
+
createCollectionScope,
|
|
72
|
+
import_react_popper.createPopperScope,
|
|
73
|
+
import_react_roving_focus.createRovingFocusGroupScope
|
|
74
|
+
]);
|
|
75
|
+
var usePopperScope = (0, import_react_popper.createPopperScope)();
|
|
76
|
+
var useRovingFocusGroupScope = (0, import_react_roving_focus.createRovingFocusGroupScope)();
|
|
77
|
+
var [MenuProvider, useMenuContext] = createMenuContext(MENU_NAME);
|
|
78
|
+
var [MenuRootProvider, useMenuRootContext] = createMenuContext(MENU_NAME);
|
|
79
|
+
var Menu = (props) => {
|
|
80
|
+
const { __scopeMenu, open = false, children, dir, onOpenChange, modal = true } = props;
|
|
81
|
+
const popperScope = usePopperScope(__scopeMenu);
|
|
82
|
+
const [content, setContent] = React.useState(null);
|
|
83
|
+
const isUsingKeyboardRef = React.useRef(false);
|
|
84
|
+
const handleOpenChange = (0, import_react_use_callback_ref.useCallbackRef)(onOpenChange);
|
|
85
|
+
const direction = (0, import_react_direction.useDirection)(dir);
|
|
86
|
+
React.useEffect(() => {
|
|
87
|
+
const handleKeyDown = () => {
|
|
88
|
+
isUsingKeyboardRef.current = true;
|
|
89
|
+
document.addEventListener("pointerdown", handlePointer, { capture: true, once: true });
|
|
90
|
+
document.addEventListener("pointermove", handlePointer, { capture: true, once: true });
|
|
91
|
+
};
|
|
92
|
+
const handlePointer = () => isUsingKeyboardRef.current = false;
|
|
93
|
+
document.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
94
|
+
return () => {
|
|
95
|
+
document.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
96
|
+
document.removeEventListener("pointerdown", handlePointer, { capture: true });
|
|
97
|
+
document.removeEventListener("pointermove", handlePointer, { capture: true });
|
|
98
|
+
};
|
|
170
99
|
}, []);
|
|
171
|
-
return
|
|
100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
101
|
+
MenuProvider,
|
|
102
|
+
{
|
|
172
103
|
scope: __scopeMenu,
|
|
173
|
-
open
|
|
104
|
+
open,
|
|
174
105
|
onOpenChange: handleOpenChange,
|
|
175
|
-
content
|
|
176
|
-
onContentChange: setContent
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
handleOpenChange
|
|
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
|
-
const
|
|
208
|
-
forceMount:
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
* -----------------------------------------------------------------------------------------------*/ const $213e4d2df823067d$var$CONTENT_NAME = 'MenuContent';
|
|
229
|
-
const [$213e4d2df823067d$var$MenuContentProvider, $213e4d2df823067d$var$useMenuContentContext] = $213e4d2df823067d$var$createMenuContext($213e4d2df823067d$var$CONTENT_NAME);
|
|
230
|
-
const $213e4d2df823067d$export$479f0f2f71193efe = /*#__PURE__*/ $cnSS2$react.forwardRef((props, forwardedRef)=>{
|
|
231
|
-
const portalContext = $213e4d2df823067d$var$usePortalContext($213e4d2df823067d$var$CONTENT_NAME, props.__scopeMenu);
|
|
232
|
-
const { forceMount: forceMount = portalContext.forceMount , ...contentProps } = props;
|
|
233
|
-
const context = $213e4d2df823067d$var$useMenuContext($213e4d2df823067d$var$CONTENT_NAME, props.__scopeMenu);
|
|
234
|
-
const rootContext = $213e4d2df823067d$var$useMenuRootContext($213e4d2df823067d$var$CONTENT_NAME, props.__scopeMenu);
|
|
235
|
-
return /*#__PURE__*/ $cnSS2$react.createElement($213e4d2df823067d$var$Collection.Provider, {
|
|
236
|
-
scope: props.__scopeMenu
|
|
237
|
-
}, /*#__PURE__*/ $cnSS2$react.createElement($cnSS2$radixuireactpresence.Presence, {
|
|
238
|
-
present: forceMount || context.open
|
|
239
|
-
}, /*#__PURE__*/ $cnSS2$react.createElement($213e4d2df823067d$var$Collection.Slot, {
|
|
240
|
-
scope: props.__scopeMenu
|
|
241
|
-
}, rootContext.modal ? /*#__PURE__*/ $cnSS2$react.createElement($213e4d2df823067d$var$MenuRootContentModal, ($parcel$interopDefault($cnSS2$babelruntimehelpersextends))({}, contentProps, {
|
|
242
|
-
ref: forwardedRef
|
|
243
|
-
})) : /*#__PURE__*/ $cnSS2$react.createElement($213e4d2df823067d$var$MenuRootContentNonModal, ($parcel$interopDefault($cnSS2$babelruntimehelpersextends))({}, contentProps, {
|
|
244
|
-
ref: forwardedRef
|
|
245
|
-
})))));
|
|
246
|
-
});
|
|
247
|
-
/* ---------------------------------------------------------------------------------------------- */ const $213e4d2df823067d$var$MenuRootContentModal = /*#__PURE__*/ $cnSS2$react.forwardRef((props, forwardedRef)=>{
|
|
248
|
-
const context = $213e4d2df823067d$var$useMenuContext($213e4d2df823067d$var$CONTENT_NAME, props.__scopeMenu);
|
|
249
|
-
const ref = $cnSS2$react.useRef(null);
|
|
250
|
-
const composedRefs = $cnSS2$radixuireactcomposerefs.useComposedRefs(forwardedRef, ref); // Hide everything from ARIA except the `MenuContent`
|
|
251
|
-
$cnSS2$react.useEffect(()=>{
|
|
106
|
+
content,
|
|
107
|
+
onContentChange: setContent,
|
|
108
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
109
|
+
MenuRootProvider,
|
|
110
|
+
{
|
|
111
|
+
scope: __scopeMenu,
|
|
112
|
+
onClose: React.useCallback(() => handleOpenChange(false), [handleOpenChange]),
|
|
113
|
+
isUsingKeyboardRef,
|
|
114
|
+
dir: direction,
|
|
115
|
+
modal,
|
|
116
|
+
children
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
) });
|
|
121
|
+
};
|
|
122
|
+
Menu.displayName = MENU_NAME;
|
|
123
|
+
var ANCHOR_NAME = "MenuAnchor";
|
|
124
|
+
var MenuAnchor = React.forwardRef(
|
|
125
|
+
(props, forwardedRef) => {
|
|
126
|
+
const { __scopeMenu, ...anchorProps } = props;
|
|
127
|
+
const popperScope = usePopperScope(__scopeMenu);
|
|
128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
MenuAnchor.displayName = ANCHOR_NAME;
|
|
132
|
+
var PORTAL_NAME = "MenuPortal";
|
|
133
|
+
var [PortalProvider, usePortalContext] = createMenuContext(PORTAL_NAME, {
|
|
134
|
+
forceMount: void 0
|
|
135
|
+
});
|
|
136
|
+
var MenuPortal = (props) => {
|
|
137
|
+
const { __scopeMenu, forceMount, children, container } = props;
|
|
138
|
+
const context = useMenuContext(PORTAL_NAME, __scopeMenu);
|
|
139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalProvider, { scope: __scopeMenu, forceMount, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_portal.Portal, { asChild: true, container, children }) }) });
|
|
140
|
+
};
|
|
141
|
+
MenuPortal.displayName = PORTAL_NAME;
|
|
142
|
+
var CONTENT_NAME = "MenuContent";
|
|
143
|
+
var [MenuContentProvider, useMenuContentContext] = createMenuContext(CONTENT_NAME);
|
|
144
|
+
var MenuContent = React.forwardRef(
|
|
145
|
+
(props, forwardedRef) => {
|
|
146
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeMenu);
|
|
147
|
+
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
148
|
+
const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
|
|
149
|
+
const rootContext = useMenuRootContext(CONTENT_NAME, props.__scopeMenu);
|
|
150
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Provider, { scope: props.__scopeMenu, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Slot, { scope: props.__scopeMenu, children: rootContext.modal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuRootContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuRootContentNonModal, { ...contentProps, ref: forwardedRef }) }) }) });
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
var MenuRootContentModal = React.forwardRef(
|
|
154
|
+
(props, forwardedRef) => {
|
|
155
|
+
const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
|
|
156
|
+
const ref = React.useRef(null);
|
|
157
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
158
|
+
React.useEffect(() => {
|
|
252
159
|
const content = ref.current;
|
|
253
|
-
if (content) return
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
160
|
+
if (content) return (0, import_aria_hidden.hideOthers)(content);
|
|
161
|
+
}, []);
|
|
162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
163
|
+
MenuContentImpl,
|
|
164
|
+
{
|
|
165
|
+
...props,
|
|
166
|
+
ref: composedRefs,
|
|
167
|
+
trapFocus: context.open,
|
|
168
|
+
disableOutsidePointerEvents: context.open,
|
|
169
|
+
disableOutsideScroll: true,
|
|
170
|
+
onFocusOutside: (0, import_primitive.composeEventHandlers)(
|
|
171
|
+
props.onFocusOutside,
|
|
172
|
+
(event) => event.preventDefault(),
|
|
173
|
+
{ checkForDefaultPrevented: false }
|
|
174
|
+
),
|
|
175
|
+
onDismiss: () => context.onOpenChange(false)
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
var MenuRootContentNonModal = React.forwardRef((props, forwardedRef) => {
|
|
181
|
+
const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
|
|
182
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
183
|
+
MenuContentImpl,
|
|
184
|
+
{
|
|
185
|
+
...props,
|
|
273
186
|
ref: forwardedRef,
|
|
274
187
|
trapFocus: false,
|
|
275
188
|
disableOutsidePointerEvents: false,
|
|
276
189
|
disableOutsideScroll: false,
|
|
277
|
-
onDismiss: ()=>context.onOpenChange(false)
|
|
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
|
-
|
|
190
|
+
onDismiss: () => context.onOpenChange(false)
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
});
|
|
194
|
+
var MenuContentImpl = React.forwardRef(
|
|
195
|
+
(props, forwardedRef) => {
|
|
196
|
+
const {
|
|
197
|
+
__scopeMenu,
|
|
198
|
+
loop = false,
|
|
199
|
+
trapFocus,
|
|
200
|
+
onOpenAutoFocus,
|
|
201
|
+
onCloseAutoFocus,
|
|
202
|
+
disableOutsidePointerEvents,
|
|
203
|
+
onEntryFocus,
|
|
204
|
+
onEscapeKeyDown,
|
|
205
|
+
onPointerDownOutside,
|
|
206
|
+
onFocusOutside,
|
|
207
|
+
onInteractOutside,
|
|
208
|
+
onDismiss,
|
|
209
|
+
disableOutsideScroll,
|
|
210
|
+
...contentProps
|
|
211
|
+
} = props;
|
|
212
|
+
const context = useMenuContext(CONTENT_NAME, __scopeMenu);
|
|
213
|
+
const rootContext = useMenuRootContext(CONTENT_NAME, __scopeMenu);
|
|
214
|
+
const popperScope = usePopperScope(__scopeMenu);
|
|
215
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
|
|
216
|
+
const getItems = useCollection(__scopeMenu);
|
|
217
|
+
const [currentItemId, setCurrentItemId] = React.useState(null);
|
|
218
|
+
const contentRef = React.useRef(null);
|
|
219
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, contentRef, context.onContentChange);
|
|
220
|
+
const timerRef = React.useRef(0);
|
|
221
|
+
const searchRef = React.useRef("");
|
|
222
|
+
const pointerGraceTimerRef = React.useRef(0);
|
|
223
|
+
const pointerGraceIntentRef = React.useRef(null);
|
|
224
|
+
const pointerDirRef = React.useRef("right");
|
|
225
|
+
const lastPointerXRef = React.useRef(0);
|
|
226
|
+
const ScrollLockWrapper = disableOutsideScroll ? import_react_remove_scroll.RemoveScroll : React.Fragment;
|
|
227
|
+
const scrollLockWrapperProps = disableOutsideScroll ? { as: import_react_slot.Slot, allowPinchZoom: true } : void 0;
|
|
228
|
+
const handleTypeaheadSearch = (key) => {
|
|
303
229
|
const search = searchRef.current + key;
|
|
304
|
-
const items = getItems().filter((item)
|
|
305
|
-
);
|
|
230
|
+
const items = getItems().filter((item) => !item.disabled);
|
|
306
231
|
const currentItem = document.activeElement;
|
|
307
|
-
const currentMatch =
|
|
308
|
-
|
|
309
|
-
const
|
|
310
|
-
);
|
|
311
|
-
const nextMatch = $213e4d2df823067d$var$getNextMatch(values, search, currentMatch);
|
|
312
|
-
const newItem = (_items$find2 = items.find((item)=>item.textValue === nextMatch
|
|
313
|
-
)) === null || _items$find2 === void 0 ? void 0 : _items$find2.ref.current; // Reset `searchRef` 1 second after it was last updated
|
|
232
|
+
const currentMatch = items.find((item) => item.ref.current === currentItem)?.textValue;
|
|
233
|
+
const values = items.map((item) => item.textValue);
|
|
234
|
+
const nextMatch = getNextMatch(values, search, currentMatch);
|
|
235
|
+
const newItem = items.find((item) => item.textValue === nextMatch)?.ref.current;
|
|
314
236
|
(function updateSearch(value) {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
, 1000);
|
|
237
|
+
searchRef.current = value;
|
|
238
|
+
window.clearTimeout(timerRef.current);
|
|
239
|
+
if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
|
|
319
240
|
})(search);
|
|
320
|
-
if (newItem)
|
|
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
|
-
onPointerGraceIntentChange: $cnSS2$react.useCallback((intent)=>{
|
|
241
|
+
if (newItem) {
|
|
242
|
+
setTimeout(() => newItem.focus());
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
React.useEffect(() => {
|
|
246
|
+
return () => window.clearTimeout(timerRef.current);
|
|
247
|
+
}, []);
|
|
248
|
+
(0, import_react_focus_guards.useFocusGuards)();
|
|
249
|
+
const isPointerMovingToSubmenu = React.useCallback((event) => {
|
|
250
|
+
const isMovingTowards = pointerDirRef.current === pointerGraceIntentRef.current?.side;
|
|
251
|
+
return isMovingTowards && isPointerInGraceArea(event, pointerGraceIntentRef.current?.area);
|
|
252
|
+
}, []);
|
|
253
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
254
|
+
MenuContentProvider,
|
|
255
|
+
{
|
|
256
|
+
scope: __scopeMenu,
|
|
257
|
+
searchRef,
|
|
258
|
+
onItemEnter: React.useCallback(
|
|
259
|
+
(event) => {
|
|
260
|
+
if (isPointerMovingToSubmenu(event)) event.preventDefault();
|
|
261
|
+
},
|
|
262
|
+
[isPointerMovingToSubmenu]
|
|
263
|
+
),
|
|
264
|
+
onItemLeave: React.useCallback(
|
|
265
|
+
(event) => {
|
|
266
|
+
if (isPointerMovingToSubmenu(event)) return;
|
|
267
|
+
contentRef.current?.focus();
|
|
268
|
+
setCurrentItemId(null);
|
|
269
|
+
},
|
|
270
|
+
[isPointerMovingToSubmenu]
|
|
271
|
+
),
|
|
272
|
+
onTriggerLeave: React.useCallback(
|
|
273
|
+
(event) => {
|
|
274
|
+
if (isPointerMovingToSubmenu(event)) event.preventDefault();
|
|
275
|
+
},
|
|
276
|
+
[isPointerMovingToSubmenu]
|
|
277
|
+
),
|
|
278
|
+
pointerGraceTimerRef,
|
|
279
|
+
onPointerGraceIntentChange: React.useCallback((intent) => {
|
|
360
280
|
pointerGraceIntentRef.current = intent;
|
|
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
|
-
|
|
281
|
+
}, []),
|
|
282
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ScrollLockWrapper, { ...scrollLockWrapperProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
283
|
+
import_react_focus_scope.FocusScope,
|
|
284
|
+
{
|
|
285
|
+
asChild: true,
|
|
286
|
+
trapped: trapFocus,
|
|
287
|
+
onMountAutoFocus: (0, import_primitive.composeEventHandlers)(onOpenAutoFocus, (event) => {
|
|
288
|
+
event.preventDefault();
|
|
289
|
+
contentRef.current?.focus({ preventScroll: true });
|
|
290
|
+
}),
|
|
291
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
292
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
293
|
+
import_react_dismissable_layer.DismissableLayer,
|
|
294
|
+
{
|
|
295
|
+
asChild: true,
|
|
296
|
+
disableOutsidePointerEvents,
|
|
297
|
+
onEscapeKeyDown,
|
|
298
|
+
onPointerDownOutside,
|
|
299
|
+
onFocusOutside,
|
|
300
|
+
onInteractOutside,
|
|
301
|
+
onDismiss,
|
|
302
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
303
|
+
RovingFocusGroup.Root,
|
|
304
|
+
{
|
|
305
|
+
asChild: true,
|
|
306
|
+
...rovingFocusGroupScope,
|
|
307
|
+
dir: rootContext.dir,
|
|
308
|
+
orientation: "vertical",
|
|
309
|
+
loop,
|
|
310
|
+
currentTabStopId: currentItemId,
|
|
311
|
+
onCurrentTabStopIdChange: setCurrentItemId,
|
|
312
|
+
onEntryFocus: (0, import_primitive.composeEventHandlers)(onEntryFocus, (event) => {
|
|
313
|
+
if (!rootContext.isUsingKeyboardRef.current) event.preventDefault();
|
|
314
|
+
}),
|
|
315
|
+
preventScrollOnEntryFocus: true,
|
|
316
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
317
|
+
PopperPrimitive.Content,
|
|
318
|
+
{
|
|
319
|
+
role: "menu",
|
|
320
|
+
"aria-orientation": "vertical",
|
|
321
|
+
"data-state": getOpenState(context.open),
|
|
322
|
+
"data-radix-menu-content": "",
|
|
323
|
+
dir: rootContext.dir,
|
|
324
|
+
...popperScope,
|
|
325
|
+
...contentProps,
|
|
326
|
+
ref: composedRefs,
|
|
327
|
+
style: { outline: "none", ...contentProps.style },
|
|
328
|
+
onKeyDown: (0, import_primitive.composeEventHandlers)(contentProps.onKeyDown, (event) => {
|
|
329
|
+
const target = event.target;
|
|
330
|
+
const isKeyDownInside = target.closest("[data-radix-menu-content]") === event.currentTarget;
|
|
331
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
332
|
+
const isCharacterKey = event.key.length === 1;
|
|
333
|
+
if (isKeyDownInside) {
|
|
334
|
+
if (event.key === "Tab") event.preventDefault();
|
|
335
|
+
if (!isModifierKey && isCharacterKey) handleTypeaheadSearch(event.key);
|
|
336
|
+
}
|
|
337
|
+
const content = contentRef.current;
|
|
338
|
+
if (event.target !== content) return;
|
|
339
|
+
if (!FIRST_LAST_KEYS.includes(event.key)) return;
|
|
340
|
+
event.preventDefault();
|
|
341
|
+
const items = getItems().filter((item) => !item.disabled);
|
|
342
|
+
const candidateNodes = items.map((item) => item.ref.current);
|
|
343
|
+
if (LAST_KEYS.includes(event.key)) candidateNodes.reverse();
|
|
344
|
+
focusFirst(candidateNodes);
|
|
345
|
+
}),
|
|
346
|
+
onBlur: (0, import_primitive.composeEventHandlers)(props.onBlur, (event) => {
|
|
347
|
+
if (!event.currentTarget.contains(event.target)) {
|
|
348
|
+
window.clearTimeout(timerRef.current);
|
|
349
|
+
searchRef.current = "";
|
|
350
|
+
}
|
|
351
|
+
}),
|
|
352
|
+
onPointerMove: (0, import_primitive.composeEventHandlers)(
|
|
353
|
+
props.onPointerMove,
|
|
354
|
+
whenMouse((event) => {
|
|
355
|
+
const target = event.target;
|
|
356
|
+
const pointerXHasChanged = lastPointerXRef.current !== event.clientX;
|
|
357
|
+
if (event.currentTarget.contains(target) && pointerXHasChanged) {
|
|
358
|
+
const newDir = event.clientX > lastPointerXRef.current ? "right" : "left";
|
|
359
|
+
pointerDirRef.current = newDir;
|
|
360
|
+
lastPointerXRef.current = event.clientX;
|
|
361
|
+
}
|
|
362
|
+
})
|
|
363
|
+
)
|
|
364
|
+
}
|
|
365
|
+
)
|
|
366
|
+
}
|
|
367
|
+
)
|
|
368
|
+
}
|
|
369
|
+
)
|
|
445
370
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
* MenuItem
|
|
480
|
-
* -----------------------------------------------------------------------------------------------*/ const $213e4d2df823067d$var$ITEM_NAME = 'MenuItem';
|
|
481
|
-
const $213e4d2df823067d$var$ITEM_SELECT = 'menu.itemSelect';
|
|
482
|
-
const $213e4d2df823067d$export$2ce376c2cc3355c8 = /*#__PURE__*/ $cnSS2$react.forwardRef((props, forwardedRef)=>{
|
|
483
|
-
const { disabled: disabled = false , onSelect: onSelect , ...itemProps } = props;
|
|
484
|
-
const ref = $cnSS2$react.useRef(null);
|
|
485
|
-
const rootContext = $213e4d2df823067d$var$useMenuRootContext($213e4d2df823067d$var$ITEM_NAME, props.__scopeMenu);
|
|
486
|
-
const contentContext = $213e4d2df823067d$var$useMenuContentContext($213e4d2df823067d$var$ITEM_NAME, props.__scopeMenu);
|
|
487
|
-
const composedRefs = $cnSS2$radixuireactcomposerefs.useComposedRefs(forwardedRef, ref);
|
|
488
|
-
const isPointerDownRef = $cnSS2$react.useRef(false);
|
|
489
|
-
const handleSelect = ()=>{
|
|
371
|
+
) })
|
|
372
|
+
}
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
);
|
|
376
|
+
MenuContent.displayName = CONTENT_NAME;
|
|
377
|
+
var GROUP_NAME = "MenuGroup";
|
|
378
|
+
var MenuGroup = React.forwardRef(
|
|
379
|
+
(props, forwardedRef) => {
|
|
380
|
+
const { __scopeMenu, ...groupProps } = props;
|
|
381
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.div, { role: "group", ...groupProps, ref: forwardedRef });
|
|
382
|
+
}
|
|
383
|
+
);
|
|
384
|
+
MenuGroup.displayName = GROUP_NAME;
|
|
385
|
+
var LABEL_NAME = "MenuLabel";
|
|
386
|
+
var MenuLabel = React.forwardRef(
|
|
387
|
+
(props, forwardedRef) => {
|
|
388
|
+
const { __scopeMenu, ...labelProps } = props;
|
|
389
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.div, { ...labelProps, ref: forwardedRef });
|
|
390
|
+
}
|
|
391
|
+
);
|
|
392
|
+
MenuLabel.displayName = LABEL_NAME;
|
|
393
|
+
var ITEM_NAME = "MenuItem";
|
|
394
|
+
var ITEM_SELECT = "menu.itemSelect";
|
|
395
|
+
var MenuItem = React.forwardRef(
|
|
396
|
+
(props, forwardedRef) => {
|
|
397
|
+
const { disabled = false, onSelect, ...itemProps } = props;
|
|
398
|
+
const ref = React.useRef(null);
|
|
399
|
+
const rootContext = useMenuRootContext(ITEM_NAME, props.__scopeMenu);
|
|
400
|
+
const contentContext = useMenuContentContext(ITEM_NAME, props.__scopeMenu);
|
|
401
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
402
|
+
const isPointerDownRef = React.useRef(false);
|
|
403
|
+
const handleSelect = () => {
|
|
490
404
|
const menuItem = ref.current;
|
|
491
405
|
if (!disabled && menuItem) {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
$cnSS2$radixuireactprimitive.dispatchDiscreteCustomEvent(menuItem, itemSelectEvent);
|
|
501
|
-
if (itemSelectEvent.defaultPrevented) isPointerDownRef.current = false;
|
|
502
|
-
else rootContext.onClose();
|
|
406
|
+
const itemSelectEvent = new CustomEvent(ITEM_SELECT, { bubbles: true, cancelable: true });
|
|
407
|
+
menuItem.addEventListener(ITEM_SELECT, (event) => onSelect?.(event), { once: true });
|
|
408
|
+
(0, import_react_primitive.dispatchDiscreteCustomEvent)(menuItem, itemSelectEvent);
|
|
409
|
+
if (itemSelectEvent.defaultPrevented) {
|
|
410
|
+
isPointerDownRef.current = false;
|
|
411
|
+
} else {
|
|
412
|
+
rootContext.onClose();
|
|
413
|
+
}
|
|
503
414
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
415
|
+
};
|
|
416
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
417
|
+
MenuItemImpl,
|
|
418
|
+
{
|
|
419
|
+
...itemProps,
|
|
420
|
+
ref: composedRefs,
|
|
421
|
+
disabled,
|
|
422
|
+
onClick: (0, import_primitive.composeEventHandlers)(props.onClick, handleSelect),
|
|
423
|
+
onPointerDown: (event) => {
|
|
424
|
+
props.onPointerDown?.(event);
|
|
512
425
|
isPointerDownRef.current = true;
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
if (
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
if (disabled || isTypingAhead && event.key === ' ') return;
|
|
524
|
-
if ($213e4d2df823067d$var$SELECTION_KEYS.includes(event.key)) {
|
|
525
|
-
event.currentTarget.click();
|
|
526
|
-
/**
|
|
527
|
-
* We prevent default browser behaviour for selection keys as they should trigger
|
|
528
|
-
* a selection only:
|
|
529
|
-
* - prevents space from scrolling the page.
|
|
530
|
-
* - if keydown causes focus to move, prevents keydown from firing on the new target.
|
|
531
|
-
*/ event.preventDefault();
|
|
426
|
+
},
|
|
427
|
+
onPointerUp: (0, import_primitive.composeEventHandlers)(props.onPointerUp, (event) => {
|
|
428
|
+
if (!isPointerDownRef.current) event.currentTarget?.click();
|
|
429
|
+
}),
|
|
430
|
+
onKeyDown: (0, import_primitive.composeEventHandlers)(props.onKeyDown, (event) => {
|
|
431
|
+
const isTypingAhead = contentContext.searchRef.current !== "";
|
|
432
|
+
if (disabled || isTypingAhead && event.key === " ") return;
|
|
433
|
+
if (SELECTION_KEYS.includes(event.key)) {
|
|
434
|
+
event.currentTarget.click();
|
|
435
|
+
event.preventDefault();
|
|
532
436
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
437
|
+
})
|
|
438
|
+
}
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
);
|
|
442
|
+
MenuItem.displayName = ITEM_NAME;
|
|
443
|
+
var MenuItemImpl = React.forwardRef(
|
|
444
|
+
(props, forwardedRef) => {
|
|
445
|
+
const { __scopeMenu, disabled = false, textValue, ...itemProps } = props;
|
|
446
|
+
const contentContext = useMenuContentContext(ITEM_NAME, __scopeMenu);
|
|
447
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
|
|
448
|
+
const ref = React.useRef(null);
|
|
449
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
450
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
451
|
+
const [textContent, setTextContent] = React.useState("");
|
|
452
|
+
React.useEffect(() => {
|
|
548
453
|
const menuItem = ref.current;
|
|
549
454
|
if (menuItem) {
|
|
550
|
-
|
|
551
|
-
setTextContent(((_menuItem$textContent = menuItem.textContent) !== null && _menuItem$textContent !== void 0 ? _menuItem$textContent : '').trim());
|
|
455
|
+
setTextContent((menuItem.textContent ?? "").trim());
|
|
552
456
|
}
|
|
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
|
-
|
|
457
|
+
}, [itemProps.children]);
|
|
458
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
459
|
+
Collection.ItemSlot,
|
|
460
|
+
{
|
|
461
|
+
scope: __scopeMenu,
|
|
462
|
+
disabled,
|
|
463
|
+
textValue: textValue ?? textContent,
|
|
464
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RovingFocusGroup.Item, { asChild: true, ...rovingFocusGroupScope, focusable: !disabled, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
465
|
+
import_react_primitive.Primitive.div,
|
|
466
|
+
{
|
|
467
|
+
role: "menuitem",
|
|
468
|
+
"data-highlighted": isFocused ? "" : void 0,
|
|
469
|
+
"aria-disabled": disabled || void 0,
|
|
470
|
+
"data-disabled": disabled ? "" : void 0,
|
|
471
|
+
...itemProps,
|
|
472
|
+
ref: composedRefs,
|
|
473
|
+
onPointerMove: (0, import_primitive.composeEventHandlers)(
|
|
474
|
+
props.onPointerMove,
|
|
475
|
+
whenMouse((event) => {
|
|
476
|
+
if (disabled) {
|
|
477
|
+
contentContext.onItemLeave(event);
|
|
478
|
+
} else {
|
|
479
|
+
contentContext.onItemEnter(event);
|
|
480
|
+
if (!event.defaultPrevented) {
|
|
481
|
+
const item = event.currentTarget;
|
|
482
|
+
item.focus();
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
})
|
|
486
|
+
),
|
|
487
|
+
onPointerLeave: (0, import_primitive.composeEventHandlers)(
|
|
488
|
+
props.onPointerLeave,
|
|
489
|
+
whenMouse((event) => contentContext.onItemLeave(event))
|
|
490
|
+
),
|
|
491
|
+
onFocus: (0, import_primitive.composeEventHandlers)(props.onFocus, () => setIsFocused(true)),
|
|
492
|
+
onBlur: (0, import_primitive.composeEventHandlers)(props.onBlur, () => setIsFocused(false))
|
|
579
493
|
}
|
|
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
|
-
const
|
|
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
|
-
const
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
const { __scopeMenu: __scopeMenu , children: children , open: open = false , onOpenChange: onOpenChange } = props;
|
|
713
|
-
const parentMenuContext = $213e4d2df823067d$var$useMenuContext($213e4d2df823067d$var$SUB_NAME, __scopeMenu);
|
|
714
|
-
const popperScope = $213e4d2df823067d$var$usePopperScope(__scopeMenu);
|
|
715
|
-
const [trigger, setTrigger] = $cnSS2$react.useState(null);
|
|
716
|
-
const [content, setContent] = $cnSS2$react.useState(null);
|
|
717
|
-
const handleOpenChange = $cnSS2$radixuireactusecallbackref.useCallbackRef(onOpenChange); // Prevent the parent menu from reopening with open submenus.
|
|
718
|
-
$cnSS2$react.useEffect(()=>{
|
|
719
|
-
if (parentMenuContext.open === false) handleOpenChange(false);
|
|
720
|
-
return ()=>handleOpenChange(false)
|
|
721
|
-
;
|
|
722
|
-
}, [
|
|
723
|
-
parentMenuContext.open,
|
|
724
|
-
handleOpenChange
|
|
725
|
-
]);
|
|
726
|
-
return /*#__PURE__*/ $cnSS2$react.createElement($cnSS2$radixuireactpopper.Root, popperScope, /*#__PURE__*/ $cnSS2$react.createElement($213e4d2df823067d$var$MenuProvider, {
|
|
494
|
+
) })
|
|
495
|
+
}
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
);
|
|
499
|
+
var CHECKBOX_ITEM_NAME = "MenuCheckboxItem";
|
|
500
|
+
var MenuCheckboxItem = React.forwardRef(
|
|
501
|
+
(props, forwardedRef) => {
|
|
502
|
+
const { checked = false, onCheckedChange, ...checkboxItemProps } = props;
|
|
503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemIndicatorProvider, { scope: props.__scopeMenu, checked, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
504
|
+
MenuItem,
|
|
505
|
+
{
|
|
506
|
+
role: "menuitemcheckbox",
|
|
507
|
+
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
|
508
|
+
...checkboxItemProps,
|
|
509
|
+
ref: forwardedRef,
|
|
510
|
+
"data-state": getCheckedState(checked),
|
|
511
|
+
onSelect: (0, import_primitive.composeEventHandlers)(
|
|
512
|
+
checkboxItemProps.onSelect,
|
|
513
|
+
() => onCheckedChange?.(isIndeterminate(checked) ? true : !checked),
|
|
514
|
+
{ checkForDefaultPrevented: false }
|
|
515
|
+
)
|
|
516
|
+
}
|
|
517
|
+
) });
|
|
518
|
+
}
|
|
519
|
+
);
|
|
520
|
+
MenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
|
|
521
|
+
var RADIO_GROUP_NAME = "MenuRadioGroup";
|
|
522
|
+
var [RadioGroupProvider, useRadioGroupContext] = createMenuContext(
|
|
523
|
+
RADIO_GROUP_NAME,
|
|
524
|
+
{ value: void 0, onValueChange: () => {
|
|
525
|
+
} }
|
|
526
|
+
);
|
|
527
|
+
var MenuRadioGroup = React.forwardRef(
|
|
528
|
+
(props, forwardedRef) => {
|
|
529
|
+
const { value, onValueChange, ...groupProps } = props;
|
|
530
|
+
const handleValueChange = (0, import_react_use_callback_ref.useCallbackRef)(onValueChange);
|
|
531
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupProvider, { scope: props.__scopeMenu, value, onValueChange: handleValueChange, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuGroup, { ...groupProps, ref: forwardedRef }) });
|
|
532
|
+
}
|
|
533
|
+
);
|
|
534
|
+
MenuRadioGroup.displayName = RADIO_GROUP_NAME;
|
|
535
|
+
var RADIO_ITEM_NAME = "MenuRadioItem";
|
|
536
|
+
var MenuRadioItem = React.forwardRef(
|
|
537
|
+
(props, forwardedRef) => {
|
|
538
|
+
const { value, ...radioItemProps } = props;
|
|
539
|
+
const context = useRadioGroupContext(RADIO_ITEM_NAME, props.__scopeMenu);
|
|
540
|
+
const checked = value === context.value;
|
|
541
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemIndicatorProvider, { scope: props.__scopeMenu, checked, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
542
|
+
MenuItem,
|
|
543
|
+
{
|
|
544
|
+
role: "menuitemradio",
|
|
545
|
+
"aria-checked": checked,
|
|
546
|
+
...radioItemProps,
|
|
547
|
+
ref: forwardedRef,
|
|
548
|
+
"data-state": getCheckedState(checked),
|
|
549
|
+
onSelect: (0, import_primitive.composeEventHandlers)(
|
|
550
|
+
radioItemProps.onSelect,
|
|
551
|
+
() => context.onValueChange?.(value),
|
|
552
|
+
{ checkForDefaultPrevented: false }
|
|
553
|
+
)
|
|
554
|
+
}
|
|
555
|
+
) });
|
|
556
|
+
}
|
|
557
|
+
);
|
|
558
|
+
MenuRadioItem.displayName = RADIO_ITEM_NAME;
|
|
559
|
+
var ITEM_INDICATOR_NAME = "MenuItemIndicator";
|
|
560
|
+
var [ItemIndicatorProvider, useItemIndicatorContext] = createMenuContext(
|
|
561
|
+
ITEM_INDICATOR_NAME,
|
|
562
|
+
{ checked: false }
|
|
563
|
+
);
|
|
564
|
+
var MenuItemIndicator = React.forwardRef(
|
|
565
|
+
(props, forwardedRef) => {
|
|
566
|
+
const { __scopeMenu, forceMount, ...itemIndicatorProps } = props;
|
|
567
|
+
const indicatorContext = useItemIndicatorContext(ITEM_INDICATOR_NAME, __scopeMenu);
|
|
568
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
569
|
+
import_react_presence.Presence,
|
|
570
|
+
{
|
|
571
|
+
present: forceMount || isIndeterminate(indicatorContext.checked) || indicatorContext.checked === true,
|
|
572
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
573
|
+
import_react_primitive.Primitive.span,
|
|
574
|
+
{
|
|
575
|
+
...itemIndicatorProps,
|
|
576
|
+
ref: forwardedRef,
|
|
577
|
+
"data-state": getCheckedState(indicatorContext.checked)
|
|
578
|
+
}
|
|
579
|
+
)
|
|
580
|
+
}
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
);
|
|
584
|
+
MenuItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
585
|
+
var SEPARATOR_NAME = "MenuSeparator";
|
|
586
|
+
var MenuSeparator = React.forwardRef(
|
|
587
|
+
(props, forwardedRef) => {
|
|
588
|
+
const { __scopeMenu, ...separatorProps } = props;
|
|
589
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
590
|
+
import_react_primitive.Primitive.div,
|
|
591
|
+
{
|
|
592
|
+
role: "separator",
|
|
593
|
+
"aria-orientation": "horizontal",
|
|
594
|
+
...separatorProps,
|
|
595
|
+
ref: forwardedRef
|
|
596
|
+
}
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
);
|
|
600
|
+
MenuSeparator.displayName = SEPARATOR_NAME;
|
|
601
|
+
var ARROW_NAME = "MenuArrow";
|
|
602
|
+
var MenuArrow = React.forwardRef(
|
|
603
|
+
(props, forwardedRef) => {
|
|
604
|
+
const { __scopeMenu, ...arrowProps } = props;
|
|
605
|
+
const popperScope = usePopperScope(__scopeMenu);
|
|
606
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
|
|
607
|
+
}
|
|
608
|
+
);
|
|
609
|
+
MenuArrow.displayName = ARROW_NAME;
|
|
610
|
+
var SUB_NAME = "MenuSub";
|
|
611
|
+
var [MenuSubProvider, useMenuSubContext] = createMenuContext(SUB_NAME);
|
|
612
|
+
var MenuSub = (props) => {
|
|
613
|
+
const { __scopeMenu, children, open = false, onOpenChange } = props;
|
|
614
|
+
const parentMenuContext = useMenuContext(SUB_NAME, __scopeMenu);
|
|
615
|
+
const popperScope = usePopperScope(__scopeMenu);
|
|
616
|
+
const [trigger, setTrigger] = React.useState(null);
|
|
617
|
+
const [content, setContent] = React.useState(null);
|
|
618
|
+
const handleOpenChange = (0, import_react_use_callback_ref.useCallbackRef)(onOpenChange);
|
|
619
|
+
React.useEffect(() => {
|
|
620
|
+
if (parentMenuContext.open === false) handleOpenChange(false);
|
|
621
|
+
return () => handleOpenChange(false);
|
|
622
|
+
}, [parentMenuContext.open, handleOpenChange]);
|
|
623
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
624
|
+
MenuProvider,
|
|
625
|
+
{
|
|
727
626
|
scope: __scopeMenu,
|
|
728
|
-
open
|
|
627
|
+
open,
|
|
729
628
|
onOpenChange: handleOpenChange,
|
|
730
|
-
content
|
|
731
|
-
onContentChange: setContent
|
|
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
|
-
|
|
629
|
+
content,
|
|
630
|
+
onContentChange: setContent,
|
|
631
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
632
|
+
MenuSubProvider,
|
|
633
|
+
{
|
|
634
|
+
scope: __scopeMenu,
|
|
635
|
+
contentId: (0, import_react_id.useId)(),
|
|
636
|
+
triggerId: (0, import_react_id.useId)(),
|
|
637
|
+
trigger,
|
|
638
|
+
onTriggerChange: setTrigger,
|
|
639
|
+
children
|
|
640
|
+
}
|
|
641
|
+
)
|
|
642
|
+
}
|
|
643
|
+
) });
|
|
644
|
+
};
|
|
645
|
+
MenuSub.displayName = SUB_NAME;
|
|
646
|
+
var SUB_TRIGGER_NAME = "MenuSubTrigger";
|
|
647
|
+
var MenuSubTrigger = React.forwardRef(
|
|
648
|
+
(props, forwardedRef) => {
|
|
649
|
+
const context = useMenuContext(SUB_TRIGGER_NAME, props.__scopeMenu);
|
|
650
|
+
const rootContext = useMenuRootContext(SUB_TRIGGER_NAME, props.__scopeMenu);
|
|
651
|
+
const subContext = useMenuSubContext(SUB_TRIGGER_NAME, props.__scopeMenu);
|
|
652
|
+
const contentContext = useMenuContentContext(SUB_TRIGGER_NAME, props.__scopeMenu);
|
|
653
|
+
const openTimerRef = React.useRef(null);
|
|
654
|
+
const { pointerGraceTimerRef, onPointerGraceIntentChange } = contentContext;
|
|
655
|
+
const scope = { __scopeMenu: props.__scopeMenu };
|
|
656
|
+
const clearOpenTimer = React.useCallback(() => {
|
|
757
657
|
if (openTimerRef.current) window.clearTimeout(openTimerRef.current);
|
|
758
658
|
openTimerRef.current = null;
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
clearOpenTimer
|
|
763
|
-
]);
|
|
764
|
-
$cnSS2$react.useEffect(()=>{
|
|
659
|
+
}, []);
|
|
660
|
+
React.useEffect(() => clearOpenTimer, [clearOpenTimer]);
|
|
661
|
+
React.useEffect(() => {
|
|
765
662
|
const pointerGraceTimer = pointerGraceTimerRef.current;
|
|
766
|
-
return ()=>{
|
|
767
|
-
|
|
768
|
-
|
|
663
|
+
return () => {
|
|
664
|
+
window.clearTimeout(pointerGraceTimer);
|
|
665
|
+
onPointerGraceIntentChange(null);
|
|
769
666
|
};
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
ref: $cnSS2$radixuireactcomposerefs.composeRefs(forwardedRef, subContext.onTriggerChange) // This is redundant for mouse users but we cannot determine pointer type from
|
|
784
|
-
,
|
|
785
|
-
onClick: (event)=>{
|
|
786
|
-
var _props$onClick;
|
|
787
|
-
(_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, event);
|
|
667
|
+
}, [pointerGraceTimerRef, onPointerGraceIntentChange]);
|
|
668
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuAnchor, { asChild: true, ...scope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
669
|
+
MenuItemImpl,
|
|
670
|
+
{
|
|
671
|
+
id: subContext.triggerId,
|
|
672
|
+
"aria-haspopup": "menu",
|
|
673
|
+
"aria-expanded": context.open,
|
|
674
|
+
"aria-controls": subContext.contentId,
|
|
675
|
+
"data-state": getOpenState(context.open),
|
|
676
|
+
...props,
|
|
677
|
+
ref: (0, import_react_compose_refs.composeRefs)(forwardedRef, subContext.onTriggerChange),
|
|
678
|
+
onClick: (event) => {
|
|
679
|
+
props.onClick?.(event);
|
|
788
680
|
if (props.disabled || event.defaultPrevented) return;
|
|
789
|
-
|
|
790
|
-
* We manually focus because iOS Safari doesn't always focus on click (e.g. buttons)
|
|
791
|
-
* and we rely heavily on `onFocusOutside` for submenus to close when switching
|
|
792
|
-
* between separate submenus.
|
|
793
|
-
*/ event.currentTarget.focus();
|
|
681
|
+
event.currentTarget.focus();
|
|
794
682
|
if (!context.open) context.onOpenChange(true);
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
683
|
+
},
|
|
684
|
+
onPointerMove: (0, import_primitive.composeEventHandlers)(
|
|
685
|
+
props.onPointerMove,
|
|
686
|
+
whenMouse((event) => {
|
|
687
|
+
contentContext.onItemEnter(event);
|
|
688
|
+
if (event.defaultPrevented) return;
|
|
689
|
+
if (!props.disabled && !context.open && !openTimerRef.current) {
|
|
800
690
|
contentContext.onPointerGraceIntentChange(null);
|
|
801
|
-
openTimerRef.current = window.setTimeout(()=>{
|
|
802
|
-
|
|
803
|
-
|
|
691
|
+
openTimerRef.current = window.setTimeout(() => {
|
|
692
|
+
context.onOpenChange(true);
|
|
693
|
+
clearOpenTimer();
|
|
804
694
|
}, 100);
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
const side =
|
|
815
|
-
const rightSide = side ===
|
|
695
|
+
}
|
|
696
|
+
})
|
|
697
|
+
),
|
|
698
|
+
onPointerLeave: (0, import_primitive.composeEventHandlers)(
|
|
699
|
+
props.onPointerLeave,
|
|
700
|
+
whenMouse((event) => {
|
|
701
|
+
clearOpenTimer();
|
|
702
|
+
const contentRect = context.content?.getBoundingClientRect();
|
|
703
|
+
if (contentRect) {
|
|
704
|
+
const side = context.content?.dataset.side;
|
|
705
|
+
const rightSide = side === "right";
|
|
816
706
|
const bleed = rightSide ? -5 : 5;
|
|
817
|
-
const contentNearEdge = contentRect[rightSide ?
|
|
818
|
-
const contentFarEdge = contentRect[rightSide ?
|
|
707
|
+
const contentNearEdge = contentRect[rightSide ? "left" : "right"];
|
|
708
|
+
const contentFarEdge = contentRect[rightSide ? "right" : "left"];
|
|
819
709
|
contentContext.onPointerGraceIntentChange({
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
{
|
|
831
|
-
x: contentFarEdge,
|
|
832
|
-
y: contentRect.top
|
|
833
|
-
},
|
|
834
|
-
{
|
|
835
|
-
x: contentFarEdge,
|
|
836
|
-
y: contentRect.bottom
|
|
837
|
-
},
|
|
838
|
-
{
|
|
839
|
-
x: contentNearEdge,
|
|
840
|
-
y: contentRect.bottom
|
|
841
|
-
}
|
|
842
|
-
],
|
|
843
|
-
side: side
|
|
710
|
+
area: [
|
|
711
|
+
// Apply a bleed on clientX to ensure that our exit point is
|
|
712
|
+
// consistently within polygon bounds
|
|
713
|
+
{ x: event.clientX + bleed, y: event.clientY },
|
|
714
|
+
{ x: contentNearEdge, y: contentRect.top },
|
|
715
|
+
{ x: contentFarEdge, y: contentRect.top },
|
|
716
|
+
{ x: contentFarEdge, y: contentRect.bottom },
|
|
717
|
+
{ x: contentNearEdge, y: contentRect.bottom }
|
|
718
|
+
],
|
|
719
|
+
side
|
|
844
720
|
});
|
|
845
721
|
window.clearTimeout(pointerGraceTimerRef.current);
|
|
846
|
-
pointerGraceTimerRef.current = window.setTimeout(
|
|
847
|
-
|
|
848
|
-
|
|
722
|
+
pointerGraceTimerRef.current = window.setTimeout(
|
|
723
|
+
() => contentContext.onPointerGraceIntentChange(null),
|
|
724
|
+
300
|
|
725
|
+
);
|
|
726
|
+
} else {
|
|
849
727
|
contentContext.onTriggerLeave(event);
|
|
850
|
-
if (event.defaultPrevented) return;
|
|
728
|
+
if (event.defaultPrevented) return;
|
|
851
729
|
contentContext.onPointerGraceIntentChange(null);
|
|
730
|
+
}
|
|
731
|
+
})
|
|
732
|
+
),
|
|
733
|
+
onKeyDown: (0, import_primitive.composeEventHandlers)(props.onKeyDown, (event) => {
|
|
734
|
+
const isTypingAhead = contentContext.searchRef.current !== "";
|
|
735
|
+
if (props.disabled || isTypingAhead && event.key === " ") return;
|
|
736
|
+
if (SUB_OPEN_KEYS[rootContext.dir].includes(event.key)) {
|
|
737
|
+
context.onOpenChange(true);
|
|
738
|
+
context.content?.focus();
|
|
739
|
+
event.preventDefault();
|
|
852
740
|
}
|
|
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
|
-
}, /*#__PURE__*/ $cnSS2$react.createElement($cnSS2$radixuireactpresence.Presence, {
|
|
884
|
-
present: forceMount || context.open
|
|
885
|
-
}, /*#__PURE__*/ $cnSS2$react.createElement($213e4d2df823067d$var$Collection.Slot, {
|
|
886
|
-
scope: props.__scopeMenu
|
|
887
|
-
}, /*#__PURE__*/ $cnSS2$react.createElement($213e4d2df823067d$var$MenuContentImpl, ($parcel$interopDefault($cnSS2$babelruntimehelpersextends))({
|
|
888
|
-
id: subContext.contentId,
|
|
889
|
-
"aria-labelledby": subContext.triggerId
|
|
890
|
-
}, subContentProps, {
|
|
891
|
-
ref: composedRefs,
|
|
892
|
-
align: "start",
|
|
893
|
-
side: rootContext.dir === 'rtl' ? 'left' : 'right',
|
|
894
|
-
disableOutsidePointerEvents: false,
|
|
895
|
-
disableOutsideScroll: false,
|
|
896
|
-
trapFocus: false,
|
|
897
|
-
onOpenAutoFocus: (event)=>{
|
|
898
|
-
var _ref$current;
|
|
899
|
-
// when opening a submenu, focus content for keyboard users only
|
|
900
|
-
if (rootContext.isUsingKeyboardRef.current) (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.focus();
|
|
741
|
+
})
|
|
742
|
+
}
|
|
743
|
+
) });
|
|
744
|
+
}
|
|
745
|
+
);
|
|
746
|
+
MenuSubTrigger.displayName = SUB_TRIGGER_NAME;
|
|
747
|
+
var SUB_CONTENT_NAME = "MenuSubContent";
|
|
748
|
+
var MenuSubContent = React.forwardRef(
|
|
749
|
+
(props, forwardedRef) => {
|
|
750
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeMenu);
|
|
751
|
+
const { forceMount = portalContext.forceMount, ...subContentProps } = props;
|
|
752
|
+
const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
|
|
753
|
+
const rootContext = useMenuRootContext(CONTENT_NAME, props.__scopeMenu);
|
|
754
|
+
const subContext = useMenuSubContext(SUB_CONTENT_NAME, props.__scopeMenu);
|
|
755
|
+
const ref = React.useRef(null);
|
|
756
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
757
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Provider, { scope: props.__scopeMenu, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Slot, { scope: props.__scopeMenu, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
758
|
+
MenuContentImpl,
|
|
759
|
+
{
|
|
760
|
+
id: subContext.contentId,
|
|
761
|
+
"aria-labelledby": subContext.triggerId,
|
|
762
|
+
...subContentProps,
|
|
763
|
+
ref: composedRefs,
|
|
764
|
+
align: "start",
|
|
765
|
+
side: rootContext.dir === "rtl" ? "left" : "right",
|
|
766
|
+
disableOutsidePointerEvents: false,
|
|
767
|
+
disableOutsideScroll: false,
|
|
768
|
+
trapFocus: false,
|
|
769
|
+
onOpenAutoFocus: (event) => {
|
|
770
|
+
if (rootContext.isUsingKeyboardRef.current) ref.current?.focus();
|
|
901
771
|
event.preventDefault();
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
,
|
|
906
|
-
onFocusOutside: $cnSS2$radixuiprimitive.composeEventHandlers(props.onFocusOutside, (event)=>{
|
|
907
|
-
// We prevent closing when the trigger is focused to avoid triggering a re-open animation
|
|
908
|
-
// on pointer interaction.
|
|
772
|
+
},
|
|
773
|
+
onCloseAutoFocus: (event) => event.preventDefault(),
|
|
774
|
+
onFocusOutside: (0, import_primitive.composeEventHandlers)(props.onFocusOutside, (event) => {
|
|
909
775
|
if (event.target !== subContext.trigger) context.onOpenChange(false);
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
rootContext.onClose();
|
|
776
|
+
}),
|
|
777
|
+
onEscapeKeyDown: (0, import_primitive.composeEventHandlers)(props.onEscapeKeyDown, (event) => {
|
|
778
|
+
rootContext.onClose();
|
|
913
779
|
event.preventDefault();
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
// Submenu key events bubble through portals. We only care about keys in this menu.
|
|
780
|
+
}),
|
|
781
|
+
onKeyDown: (0, import_primitive.composeEventHandlers)(props.onKeyDown, (event) => {
|
|
917
782
|
const isKeyDownInside = event.currentTarget.contains(event.target);
|
|
918
|
-
const isCloseKey =
|
|
783
|
+
const isCloseKey = SUB_CLOSE_KEYS[rootContext.dir].includes(event.key);
|
|
919
784
|
if (isKeyDownInside && isCloseKey) {
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
event.preventDefault();
|
|
785
|
+
context.onOpenChange(false);
|
|
786
|
+
subContext.trigger?.focus();
|
|
787
|
+
event.preventDefault();
|
|
924
788
|
}
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
});
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
return open ?
|
|
933
|
-
}
|
|
934
|
-
function
|
|
935
|
-
return checked ===
|
|
936
|
-
}
|
|
937
|
-
function
|
|
938
|
-
return
|
|
939
|
-
}
|
|
940
|
-
function
|
|
789
|
+
})
|
|
790
|
+
}
|
|
791
|
+
) }) }) });
|
|
792
|
+
}
|
|
793
|
+
);
|
|
794
|
+
MenuSubContent.displayName = SUB_CONTENT_NAME;
|
|
795
|
+
function getOpenState(open) {
|
|
796
|
+
return open ? "open" : "closed";
|
|
797
|
+
}
|
|
798
|
+
function isIndeterminate(checked) {
|
|
799
|
+
return checked === "indeterminate";
|
|
800
|
+
}
|
|
801
|
+
function getCheckedState(checked) {
|
|
802
|
+
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
803
|
+
}
|
|
804
|
+
function focusFirst(candidates) {
|
|
941
805
|
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
942
|
-
for (const candidate of candidates){
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
806
|
+
for (const candidate of candidates) {
|
|
807
|
+
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
808
|
+
candidate.focus();
|
|
809
|
+
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
947
810
|
}
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
);
|
|
955
|
-
}
|
|
956
|
-
/**
|
|
957
|
-
* This is the "meat" of the typeahead matching logic. It takes in all the values,
|
|
958
|
-
* the search and the current match, and returns the next match (or `undefined`).
|
|
959
|
-
*
|
|
960
|
-
* We normalize the search because if a user has repeatedly pressed a character,
|
|
961
|
-
* we want the exact same behavior as if we only had that one character
|
|
962
|
-
* (ie. cycle through options starting with that character)
|
|
963
|
-
*
|
|
964
|
-
* We also reorder the values by wrapping the array around the current match.
|
|
965
|
-
* This is so we always look forward from the current match, and picking the first
|
|
966
|
-
* match will always be the correct one.
|
|
967
|
-
*
|
|
968
|
-
* Finally, if the normalized search is exactly one character, we exclude the
|
|
969
|
-
* current match from the values because otherwise it would be the first to match always
|
|
970
|
-
* and focus would never move. This is as opposed to the regular case, where we
|
|
971
|
-
* don't want focus to move if the current match still matches.
|
|
972
|
-
*/ function $213e4d2df823067d$var$getNextMatch(values, search, currentMatch) {
|
|
973
|
-
const isRepeated = search.length > 1 && Array.from(search).every((char)=>char === search[0]
|
|
974
|
-
);
|
|
811
|
+
}
|
|
812
|
+
function wrapArray(array, startIndex) {
|
|
813
|
+
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
814
|
+
}
|
|
815
|
+
function getNextMatch(values, search, currentMatch) {
|
|
816
|
+
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
|
975
817
|
const normalizedSearch = isRepeated ? search[0] : search;
|
|
976
818
|
const currentMatchIndex = currentMatch ? values.indexOf(currentMatch) : -1;
|
|
977
|
-
let wrappedValues =
|
|
819
|
+
let wrappedValues = wrapArray(values, Math.max(currentMatchIndex, 0));
|
|
978
820
|
const excludeCurrentMatch = normalizedSearch.length === 1;
|
|
979
|
-
if (excludeCurrentMatch) wrappedValues = wrappedValues.filter((v)=>v !== currentMatch
|
|
980
|
-
|
|
981
|
-
|
|
821
|
+
if (excludeCurrentMatch) wrappedValues = wrappedValues.filter((v) => v !== currentMatch);
|
|
822
|
+
const nextMatch = wrappedValues.find(
|
|
823
|
+
(value) => value.toLowerCase().startsWith(normalizedSearch.toLowerCase())
|
|
982
824
|
);
|
|
983
|
-
return nextMatch !== currentMatch ? nextMatch :
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
function $213e4d2df823067d$var$isPointInPolygon(point, polygon) {
|
|
988
|
-
const { x: x , y: y } = point;
|
|
825
|
+
return nextMatch !== currentMatch ? nextMatch : void 0;
|
|
826
|
+
}
|
|
827
|
+
function isPointInPolygon(point, polygon) {
|
|
828
|
+
const { x, y } = point;
|
|
989
829
|
let inside = false;
|
|
990
|
-
for(let i = 0, j = polygon.length - 1; i < polygon.length; j = i++){
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
830
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
831
|
+
const xi = polygon[i].x;
|
|
832
|
+
const yi = polygon[i].y;
|
|
833
|
+
const xj = polygon[j].x;
|
|
834
|
+
const yj = polygon[j].y;
|
|
835
|
+
const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
|
|
836
|
+
if (intersect) inside = !inside;
|
|
997
837
|
}
|
|
998
838
|
return inside;
|
|
999
|
-
}
|
|
1000
|
-
function
|
|
839
|
+
}
|
|
840
|
+
function isPointerInGraceArea(event, area) {
|
|
1001
841
|
if (!area) return false;
|
|
1002
|
-
const cursorPos = {
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
return
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
const $213e4d2df823067d$export$d7a01e11500dfb6f = $213e4d2df823067d$export$71bdb9d1e2909932;
|
|
1026
|
-
const $213e4d2df823067d$export$2ea8a7a591ac5eac = $213e4d2df823067d$export$5fbbb3ba7297405f;
|
|
1027
|
-
const $213e4d2df823067d$export$6d4de93b380beddf = $213e4d2df823067d$export$e7142ab31822bde6;
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
842
|
+
const cursorPos = { x: event.clientX, y: event.clientY };
|
|
843
|
+
return isPointInPolygon(cursorPos, area);
|
|
844
|
+
}
|
|
845
|
+
function whenMouse(handler) {
|
|
846
|
+
return (event) => event.pointerType === "mouse" ? handler(event) : void 0;
|
|
847
|
+
}
|
|
848
|
+
var Root3 = Menu;
|
|
849
|
+
var Anchor2 = MenuAnchor;
|
|
850
|
+
var Portal = MenuPortal;
|
|
851
|
+
var Content2 = MenuContent;
|
|
852
|
+
var Group = MenuGroup;
|
|
853
|
+
var Label = MenuLabel;
|
|
854
|
+
var Item2 = MenuItem;
|
|
855
|
+
var CheckboxItem = MenuCheckboxItem;
|
|
856
|
+
var RadioGroup = MenuRadioGroup;
|
|
857
|
+
var RadioItem = MenuRadioItem;
|
|
858
|
+
var ItemIndicator = MenuItemIndicator;
|
|
859
|
+
var Separator = MenuSeparator;
|
|
860
|
+
var Arrow2 = MenuArrow;
|
|
861
|
+
var Sub = MenuSub;
|
|
862
|
+
var SubTrigger = MenuSubTrigger;
|
|
863
|
+
var SubContent = MenuSubContent;
|
|
864
|
+
})();
|
|
1032
865
|
//# sourceMappingURL=index.js.map
|