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

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