@radix-ui/react-menu 0.1.7-rc.3 → 0.1.7-rc.30

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