@radix-ui/react-menu 0.1.7-rc.4 → 0.1.7-rc.42

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