@radix-ui/react-menu 2.0.7-rc.8 → 2.1.0-rc.1

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