Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-menu

Package Overview
Dependencies
Maintainers
8
Versions
262
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-menu - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2-rc.1

2

dist/index.js

@@ -1,2 +0,2 @@

var e,n=require("@radix-ui/react-id").useId,t=require("@radix-ui/react-focus-guards").useFocusGuards,r=require("@radix-ui/react-use-callback-ref").useCallbackRef,o=require("@radix-ui/react-use-direction").useDirection,u=require("@radix-ui/react-roving-focus"),c=y({},u),a=u.createRovingFocusGroupScope,i=require("@radix-ui/react-portal").Portal,s=require("@radix-ui/react-popper"),l=y({},s),d=s.createPopperScope,f=require("@radix-ui/react-primitive").Primitive,p=require("@radix-ui/react-presence").Presence,m=require("@radix-ui/react-focus-scope").FocusScope,v=require("@radix-ui/react-dismissable-layer").DismissableLayer,g=require("@radix-ui/react-context").createContextScope,h=require("@radix-ui/react-compose-refs"),C=h.useComposedRefs,E=h.composeRefs,w=require("@radix-ui/react-collection").createCollection,M=require("@radix-ui/primitive").composeEventHandlers,b=require("aria-hidden").hideOthers,x=require("react-remove-scroll").RemoveScroll,R=y({},require("react")),_=(e=require("@babel/runtime/helpers/extends"))&&e.__esModule?e.default:e;function y(e,n){return Object.keys(n).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})),e}const k=["Enter"," "],P=["ArrowUp","PageDown","End"],I=["ArrowDown","PageUp","Home",...P],S={ltr:[...k,"ArrowRight"],rtl:[...k,"ArrowLeft"]},D={ltr:["ArrowLeft"],rtl:["ArrowRight"]},[O,T,F]=w("Menu"),[L,K]=g("Menu",[F,d,a]);exports.createMenuScope=K;const q=d(),A=a(),[G,U]=L("Menu"),V=e=>{const{__scopeMenu:n,open:t=!1,children:u,onOpenChange:c,modal:a=!0}=e,i=q(n),[s,d]=R.useState(null),f=R.useRef(!1),p=r(c),m=o(s,e.dir);return R.useEffect((()=>{const e=()=>f.current=!0,n=()=>f.current=!1;return document.addEventListener("keydown",e,{capture:!0}),document.addEventListener("pointerdown",n,{capture:!0}),document.addEventListener("pointermove",n,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",n,{capture:!0}),document.removeEventListener("pointermove",n,{capture:!0})}}),[]),/*#__PURE__*/R.createElement(l.Root,i,/*#__PURE__*/R.createElement(G,{scope:n,isSubmenu:!1,isUsingKeyboardRef:f,dir:m,open:t,onOpenChange:p,content:s,onContentChange:d,onRootClose:R.useCallback((()=>p(!1)),[p]),modal:a},u))};exports.Menu=V;const X=e=>{const{__scopeMenu:t,children:o,open:u=!1,onOpenChange:c}=e,a=U("MenuSub",t),i=q(t),[s,d]=R.useState(null),[f,p]=R.useState(null),m=r(c);return R.useEffect((()=>(!1===a.open&&m(!1),()=>m(!1))),[a.open,m]),/*#__PURE__*/R.createElement(l.Root,i,/*#__PURE__*/R.createElement(G,{scope:t,isSubmenu:!0,isUsingKeyboardRef:a.isUsingKeyboardRef,dir:a.dir,open:u,onOpenChange:m,content:f,onContentChange:p,onRootClose:a.onRootClose,contentId:n(),trigger:s,onTriggerChange:d,triggerId:n(),modal:!1},o))};exports.MenuSub=X;const B=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:t,...r}=e,o=q(t);/*#__PURE__*/return R.createElement(l.Anchor,_({},o,r,{ref:n}))}));exports.MenuAnchor=B;const[j,H]=L("MenuContent"),Y=/*#__PURE__*/R.forwardRef(((e,n)=>{const{forceMount:t,...r}=e,o=U("MenuContent",e.__scopeMenu);/*#__PURE__*/return R.createElement(O.Provider,{scope:e.__scopeMenu},/*#__PURE__*/R.createElement(p,{present:t||o.open},/*#__PURE__*/R.createElement(O.Slot,{scope:e.__scopeMenu},o.isSubmenu?/*#__PURE__*/R.createElement(J,_({},r,{ref:n})):/*#__PURE__*/R.createElement(Z,_({},r,{ref:n})))))}));exports.MenuContent=Y;const Z=/*#__PURE__*/R.forwardRef(((e,n)=>U("MenuContent",e.__scopeMenu).modal?/*#__PURE__*/R.createElement(z,_({},e,{ref:n})):/*#__PURE__*/R.createElement(W,_({},e,{ref:n})))),z=/*#__PURE__*/R.forwardRef(((e,n)=>{const t=U("MenuContent",e.__scopeMenu),r=R.useRef(null),o=C(n,r);return R.useEffect((()=>{const e=r.current;if(e)return b(e)}),[]),/*#__PURE__*/R.createElement(N,_({},e,{ref:o,trapFocus:t.open,disableOutsidePointerEvents:t.open,disableOutsideScroll:!0,onFocusOutside:M(e.onFocusOutside,(e=>e.preventDefault()),{checkForDefaultPrevented:!1}),onDismiss:()=>t.onOpenChange(!1)}))})),W=/*#__PURE__*/R.forwardRef(((e,n)=>{const t=U("MenuContent",e.__scopeMenu);/*#__PURE__*/return R.createElement(N,_({},e,{ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>t.onOpenChange(!1)}))})),J=/*#__PURE__*/R.forwardRef(((e,n)=>{const t=U("MenuContent",e.__scopeMenu),r=R.useRef(null),o=C(n,r);return t.isSubmenu?/*#__PURE__*/R.createElement(N,_({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=D[t.dir].includes(e.key);var o;n&&r&&(t.onOpenChange(!1),null===(o=t.trigger)||void 0===o||o.focus(),e.preventDefault())}))})):null})),N=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:r,loop:o=!1,trapFocus:u,onOpenAutoFocus:a,onCloseAutoFocus:s,disableOutsidePointerEvents:d,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:g,onInteractOutside:h,onDismiss:E,disableOutsideScroll:w,allowPinchZoom:b,portalled:y,...k}=e,S=U("MenuContent",r),D=q(r),O=A(r),F=T(r),[L,K]=R.useState(null),G=R.useRef(null),V=C(n,G,S.onContentChange),X=R.useRef(0),B=R.useRef(""),H=R.useRef(0),Y=R.useRef(null),Z=R.useRef("right"),z=R.useRef(0),W=y?i:R.Fragment,J=w?x:R.Fragment,N=w?{allowPinchZoom:b}:void 0,Q=e=>{var n,t;const r=B.current+e,o=F().filter((e=>!e.disabled)),u=document.activeElement,c=null===(n=o.find((e=>e.ref.current===u)))||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 u=(c=e,a=Math.max(o,0),c.map(((e,n)=>c[(a+n)%c.length])));var c,a;1===r.length&&(u=u.filter((e=>e!==t)));const i=u.find((e=>e.toLowerCase().startsWith(r.toLowerCase())));return i!==t?i:void 0}(o.map((e=>e.textValue)),r,c),i=null===(t=o.find((e=>e.textValue===a)))||void 0===t?void 0:t.ref.current;!function e(n){B.current=n,window.clearTimeout(X.current),""!==n&&(X.current=window.setTimeout((()=>e("")),1e3))}(r),i&&setTimeout((()=>i.focus()))};R.useEffect((()=>()=>window.clearTimeout(X.current)),[]),t();const $=R.useCallback((e=>{var n,t;return Z.current===(null===(n=Y.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,u=n.length-1;e<n.length;u=e++){const c=n[e].x,a=n[e].y,i=n[u].x,s=n[u].y;a>r!=s>r&&t<(i-c)*(r-a)/(s-a)+c&&(o=!o)}return o}({x:e.clientX,y:e.clientY},n)}(e,null===(t=Y.current)||void 0===t?void 0:t.area)}),[]);/*#__PURE__*/return R.createElement(W,null,/*#__PURE__*/R.createElement(J,N,/*#__PURE__*/R.createElement(j,{scope:r,searchRef:B,onItemEnter:R.useCallback((e=>{$(e)&&e.preventDefault()}),[$]),onItemLeave:R.useCallback((e=>{var n;$(e)||(null===(n=G.current)||void 0===n||n.focus(),K(null))}),[$]),onTriggerLeave:R.useCallback((e=>{$(e)&&e.preventDefault()}),[$]),pointerGraceTimerRef:H,onPointerGraceIntentChange:R.useCallback((e=>{Y.current=e}),[])},/*#__PURE__*/R.createElement(m,{asChild:!0,trapped:u,onMountAutoFocus:M(a,(e=>{var n;e.preventDefault(),null===(n=G.current)||void 0===n||n.focus()})),onUnmountAutoFocus:s},/*#__PURE__*/R.createElement(v,{asChild:!0,disableOutsidePointerEvents:d,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:g,onInteractOutside:h,onDismiss:E},/*#__PURE__*/R.createElement(c.Root,_({asChild:!0},O,{dir:S.dir,orientation:"vertical",loop:o,currentTabStopId:L,onCurrentTabStopIdChange:K,onEntryFocus:e=>{S.isUsingKeyboardRef.current||e.preventDefault()}}),/*#__PURE__*/R.createElement(l.Content,_({role:"menu",dir:S.dir,"data-state":pe(S.open)},D,k,{ref:V,style:{outline:"none",...k.style},onKeyDown:M(k.onKeyDown,(e=>{const n=e.target,t=e.currentTarget.contains(n),r=e.ctrlKey||e.altKey||e.metaKey;t&&!r&&1===e.key.length&&Q(e.key),"Tab"===e.key&&e.preventDefault();const o=G.current;if(e.target!==o)return;if(!I.includes(e.key))return;e.preventDefault();const u=F().filter((e=>!e.disabled)).map((e=>e.ref.current));P.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(X.current),B.current="")})),onPointerMove:M(e.onPointerMove,ve((e=>{const n=e.target,t=z.current!==e.clientX;if(e.currentTarget.contains(n)&&t){const n=e.clientX>z.current?"right":"left";Z.current=n,z.current=e.clientX}})))}))))))))})),Q=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:t,...r}=e;/*#__PURE__*/return R.createElement(f.div,_({role:"group"},r,{ref:n}))}));exports.MenuGroup=Q;const $=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:t,...r}=e;/*#__PURE__*/return R.createElement(f.div,_({},r,{ref:n}))}));exports.MenuLabel=$;const ee=/*#__PURE__*/R.forwardRef(((e,n)=>{const{disabled:t=!1,onSelect:r,...o}=e,u=R.useRef(null),c=U("MenuItem",e.__scopeMenu),a=H("MenuItem",e.__scopeMenu),i=C(n,u),s=R.useRef(!1);/*#__PURE__*/return R.createElement(te,_({},o,{ref:i,disabled:t,onClick:M(e.onClick,(()=>{const e=u.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:c.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||k.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())}))}))}));exports.MenuItem=ee;const ne=/*#__PURE__*/R.forwardRef(((e,n)=>{const t=U("MenuSubTrigger",e.__scopeMenu),r=H("MenuSubTrigger",e.__scopeMenu),o=R.useRef(null),{pointerGraceTimerRef:u,onPointerGraceIntentChange:c}=r,a=R.useCallback((()=>{o.current&&window.clearTimeout(o.current),o.current=null}),[]);return R.useEffect((()=>a),[a]),R.useEffect((()=>{const e=u.current;return()=>{window.clearTimeout(e),c(null)}}),[u,c]),t.isSubmenu?/*#__PURE__*/R.createElement(B,_({asChild:!0},e),/*#__PURE__*/R.createElement(te,_({id:t.triggerId,"aria-haspopup":"menu","aria-expanded":t.open,"aria-controls":t.contentId,"data-state":pe(t.open)},e,{ref:E(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,ve((n=>{r.onItemEnter(n),n.defaultPrevented||e.disabled||t.open||o.current||(r.onPointerGraceIntentChange(null),o.current=window.setTimeout((()=>{t.onOpenChange(!0),a()}),100))}))),onPointerLeave:M(e.onPointerLeave,ve((e=>{var n;a();const o=null===(n=t.content)||void 0===n?void 0:n.getBoundingClientRect();if(o){var c;const n=null===(c=t.content)||void 0===c?void 0:c.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(u.current),u.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 u;e.disabled||o&&" "===n.key||S[t.dir].includes(n.key)&&(t.onOpenChange(!0),null===(u=t.content)||void 0===u||u.focus(),n.preventDefault())}))}))):null}));exports.MenuSubTrigger=ne;const te=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:t,disabled:r=!1,textValue:o,...u}=e,a=H("MenuItem",t),i=A(t),s=R.useRef(null),l=C(n,s),[d,p]=R.useState("");return R.useEffect((()=>{const e=s.current;var n;e&&p((null!==(n=e.textContent)&&void 0!==n?n:"").trim())}),[u.children]),/*#__PURE__*/R.createElement(O.ItemSlot,{scope:t,disabled:r,textValue:null!=o?o:d},/*#__PURE__*/R.createElement(c.Item,_({asChild:!0},i,{focusable:!r}),/*#__PURE__*/R.createElement(f.div,_({role:"menuitem","aria-disabled":r||void 0,"data-disabled":r?"":void 0},u,{ref:l,onPointerMove:M(e.onPointerMove,ve((e=>{if(r)a.onItemLeave(e);else if(a.onItemEnter(e),!e.defaultPrevented){e.currentTarget.focus()}}))),onPointerLeave:M(e.onPointerLeave,ve((e=>a.onItemLeave(e))))}))))})),re=/*#__PURE__*/R.forwardRef(((e,n)=>{const{checked:t=!1,onCheckedChange:r,...o}=e;/*#__PURE__*/return R.createElement(ie,{scope:e.__scopeMenu,checked:t},/*#__PURE__*/R.createElement(ee,_({role:"menuitemcheckbox","aria-checked":t},o,{ref:n,"data-state":me(t),onSelect:M(o.onSelect,(()=>null==r?void 0:r(!t)),{checkForDefaultPrevented:!1})})))}));exports.MenuCheckboxItem=re;const[oe,ue]=L("MenuRadioGroup",{value:void 0,onValueChange:()=>{}}),ce=/*#__PURE__*/R.forwardRef(((e,n)=>{const{value:t,onValueChange:o,...u}=e,c=r(o);/*#__PURE__*/return R.createElement(oe,{scope:e.__scopeMenu,value:t,onValueChange:c},/*#__PURE__*/R.createElement(Q,_({},u,{ref:n})))}));exports.MenuRadioGroup=ce;const ae=/*#__PURE__*/R.forwardRef(((e,n)=>{const{value:t,...r}=e,o=ue("MenuRadioItem",e.__scopeMenu),u=t===o.value;/*#__PURE__*/return R.createElement(ie,{scope:e.__scopeMenu,checked:u},/*#__PURE__*/R.createElement(ee,_({role:"menuitemradio","aria-checked":u},r,{ref:n,"data-state":me(u),onSelect:M(r.onSelect,(()=>{var e;return null===(e=o.onValueChange)||void 0===e?void 0:e.call(o,t)}),{checkForDefaultPrevented:!1})})))}));exports.MenuRadioItem=ae;const[ie,se]=L("MenuItemIndicator",{checked:!1}),le=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:t,forceMount:r,...o}=e,u=se("MenuItemIndicator",t);/*#__PURE__*/return R.createElement(p,{present:r||u.checked},/*#__PURE__*/R.createElement(f.span,_({},o,{ref:n,"data-state":me(u.checked)})))}));exports.MenuItemIndicator=le;const de=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:t,...r}=e;/*#__PURE__*/return R.createElement(f.div,_({role:"separator","aria-orientation":"horizontal"},r,{ref:n}))}));exports.MenuSeparator=de;const fe=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:t,...r}=e,o=q(t);/*#__PURE__*/return R.createElement(l.Arrow,_({},o,r,{ref:n}))}));function pe(e){return e?"open":"closed"}function me(e){return e?"checked":"unchecked"}function ve(e){return n=>"mouse"===n.pointerType?e(n):void 0}exports.MenuArrow=fe;const ge=V;exports.Root=ge;const he=X;exports.Sub=he;const Ce=B;exports.Anchor=Ce;const Ee=ne;exports.SubTrigger=Ee;const we=Y;exports.Content=we;const Me=Q;exports.Group=Me;const be=$;exports.Label=be;const xe=ee;exports.Item=xe;const Re=re;exports.CheckboxItem=Re;const _e=ce;exports.RadioGroup=_e;const ye=ae;exports.RadioItem=ye;const ke=le;exports.ItemIndicator=ke;const Pe=de;exports.Separator=Pe;const Ie=fe;exports.Arrow=Ie;
var e,n=require("@radix-ui/react-id").useId,t=require("@radix-ui/react-focus-guards").useFocusGuards,r=require("@radix-ui/react-use-callback-ref").useCallbackRef,o=require("@radix-ui/react-use-direction").useDirection,u=require("@radix-ui/react-roving-focus"),c=y({},u),a=u.createRovingFocusGroupScope,i=require("@radix-ui/react-portal").Portal,s=require("@radix-ui/react-popper"),l=y({},s),d=s.createPopperScope,f=require("@radix-ui/react-primitive").Primitive,p=require("@radix-ui/react-presence").Presence,m=require("@radix-ui/react-focus-scope").FocusScope,v=require("@radix-ui/react-dismissable-layer").DismissableLayer,g=require("@radix-ui/react-context").createContextScope,h=require("@radix-ui/react-compose-refs"),C=h.useComposedRefs,E=h.composeRefs,w=require("@radix-ui/react-collection").createCollection,M=require("@radix-ui/primitive").composeEventHandlers,b=require("aria-hidden").hideOthers,x=require("react-remove-scroll").RemoveScroll,R=y({},require("react")),_=(e=require("@babel/runtime/helpers/extends"))&&e.__esModule?e.default:e;function y(e,n){return Object.keys(n).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})),e}const k=["Enter"," "],P=["ArrowUp","PageDown","End"],I=["ArrowDown","PageUp","Home",...P],S={ltr:[...k,"ArrowRight"],rtl:[...k,"ArrowLeft"]},D={ltr:["ArrowLeft"],rtl:["ArrowRight"]},[O,T,F]=w("Menu"),[L,K]=g("Menu",[F,d,a]);exports.createMenuScope=K;const q=d(),A=a(),[G,U]=L("Menu"),V=e=>{const{__scopeMenu:n,open:t=!1,children:u,onOpenChange:c,modal:a=!0}=e,i=q(n),[s,d]=R.useState(null),f=R.useRef(!1),p=r(c),m=o(s,e.dir);return R.useEffect((()=>{const e=()=>f.current=!0,n=()=>f.current=!1;return document.addEventListener("keydown",e,{capture:!0}),document.addEventListener("pointerdown",n,{capture:!0}),document.addEventListener("pointermove",n,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",n,{capture:!0}),document.removeEventListener("pointermove",n,{capture:!0})}}),[]),/*#__PURE__*/R.createElement(l.Root,i,/*#__PURE__*/R.createElement(G,{scope:n,isSubmenu:!1,isUsingKeyboardRef:f,dir:m,open:t,onOpenChange:p,content:s,onContentChange:d,onRootClose:R.useCallback((()=>p(!1)),[p]),modal:a},u))};exports.Menu=V;const X=e=>{const{__scopeMenu:t,children:o,open:u=!1,onOpenChange:c}=e,a=U("MenuSub",t),i=q(t),[s,d]=R.useState(null),[f,p]=R.useState(null),m=r(c);return R.useEffect((()=>(!1===a.open&&m(!1),()=>m(!1))),[a.open,m]),/*#__PURE__*/R.createElement(l.Root,i,/*#__PURE__*/R.createElement(G,{scope:t,isSubmenu:!0,isUsingKeyboardRef:a.isUsingKeyboardRef,dir:a.dir,open:u,onOpenChange:m,content:f,onContentChange:p,onRootClose:a.onRootClose,contentId:n(),trigger:s,onTriggerChange:d,triggerId:n(),modal:!1},o))};exports.MenuSub=X;const B=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:t,...r}=e,o=q(t);/*#__PURE__*/return R.createElement(l.Anchor,_({},o,r,{ref:n}))}));exports.MenuAnchor=B;const[j,H]=L("MenuContent"),Y=/*#__PURE__*/R.forwardRef(((e,n)=>{const{forceMount:t,...r}=e,o=U("MenuContent",e.__scopeMenu);/*#__PURE__*/return R.createElement(O.Provider,{scope:e.__scopeMenu},/*#__PURE__*/R.createElement(p,{present:t||o.open},/*#__PURE__*/R.createElement(O.Slot,{scope:e.__scopeMenu},o.isSubmenu?/*#__PURE__*/R.createElement(J,_({},r,{ref:n})):/*#__PURE__*/R.createElement(Z,_({},r,{ref:n})))))}));exports.MenuContent=Y;const Z=/*#__PURE__*/R.forwardRef(((e,n)=>U("MenuContent",e.__scopeMenu).modal?/*#__PURE__*/R.createElement(z,_({},e,{ref:n})):/*#__PURE__*/R.createElement(W,_({},e,{ref:n})))),z=/*#__PURE__*/R.forwardRef(((e,n)=>{const t=U("MenuContent",e.__scopeMenu),r=R.useRef(null),o=C(n,r);return R.useEffect((()=>{const e=r.current;if(e)return b(e)}),[]),/*#__PURE__*/R.createElement(N,_({},e,{ref:o,trapFocus:t.open,disableOutsidePointerEvents:t.open,disableOutsideScroll:!0,onFocusOutside:M(e.onFocusOutside,(e=>e.preventDefault()),{checkForDefaultPrevented:!1}),onDismiss:()=>t.onOpenChange(!1)}))})),W=/*#__PURE__*/R.forwardRef(((e,n)=>{const t=U("MenuContent",e.__scopeMenu);/*#__PURE__*/return R.createElement(N,_({},e,{ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>t.onOpenChange(!1)}))})),J=/*#__PURE__*/R.forwardRef(((e,n)=>{const t=U("MenuContent",e.__scopeMenu),r=R.useRef(null),o=C(n,r);return t.isSubmenu?/*#__PURE__*/R.createElement(N,_({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=D[t.dir].includes(e.key);var o;n&&r&&(t.onOpenChange(!1),null===(o=t.trigger)||void 0===o||o.focus(),e.preventDefault())}))})):null})),N=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:r,loop:o=!1,trapFocus:u,onOpenAutoFocus:a,onCloseAutoFocus:s,disableOutsidePointerEvents:d,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:g,onInteractOutside:h,onDismiss:E,disableOutsideScroll:w,allowPinchZoom:b,portalled:y,...k}=e,S=U("MenuContent",r),D=q(r),O=A(r),F=T(r),[L,K]=R.useState(null),G=R.useRef(null),V=C(n,G,S.onContentChange),X=R.useRef(0),B=R.useRef(""),H=R.useRef(0),Y=R.useRef(null),Z=R.useRef("right"),z=R.useRef(0),W=y?i:R.Fragment,J=w?x:R.Fragment,N=w?{allowPinchZoom:b}:void 0,Q=e=>{var n,t;const r=B.current+e,o=F().filter((e=>!e.disabled)),u=document.activeElement,c=null===(n=o.find((e=>e.ref.current===u)))||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 u=(c=e,a=Math.max(o,0),c.map(((e,n)=>c[(a+n)%c.length])));var c,a;1===r.length&&(u=u.filter((e=>e!==t)));const i=u.find((e=>e.toLowerCase().startsWith(r.toLowerCase())));return i!==t?i:void 0}(o.map((e=>e.textValue)),r,c),i=null===(t=o.find((e=>e.textValue===a)))||void 0===t?void 0:t.ref.current;!function e(n){B.current=n,window.clearTimeout(X.current),""!==n&&(X.current=window.setTimeout((()=>e("")),1e3))}(r),i&&setTimeout((()=>i.focus()))};R.useEffect((()=>()=>window.clearTimeout(X.current)),[]),t();const $=R.useCallback((e=>{var n,t;return Z.current===(null===(n=Y.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,u=n.length-1;e<n.length;u=e++){const c=n[e].x,a=n[e].y,i=n[u].x,s=n[u].y;a>r!=s>r&&t<(i-c)*(r-a)/(s-a)+c&&(o=!o)}return o}({x:e.clientX,y:e.clientY},n)}(e,null===(t=Y.current)||void 0===t?void 0:t.area)}),[]);/*#__PURE__*/return R.createElement(W,null,/*#__PURE__*/R.createElement(J,N,/*#__PURE__*/R.createElement(j,{scope:r,searchRef:B,onItemEnter:R.useCallback((e=>{$(e)&&e.preventDefault()}),[$]),onItemLeave:R.useCallback((e=>{var n;$(e)||(null===(n=G.current)||void 0===n||n.focus(),K(null))}),[$]),onTriggerLeave:R.useCallback((e=>{$(e)&&e.preventDefault()}),[$]),pointerGraceTimerRef:H,onPointerGraceIntentChange:R.useCallback((e=>{Y.current=e}),[])},/*#__PURE__*/R.createElement(m,{asChild:!0,trapped:u,onMountAutoFocus:M(a,(e=>{var n;e.preventDefault(),null===(n=G.current)||void 0===n||n.focus()})),onUnmountAutoFocus:s},/*#__PURE__*/R.createElement(v,{asChild:!0,disableOutsidePointerEvents:d,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:g,onInteractOutside:h,onDismiss:E},/*#__PURE__*/R.createElement(c.Root,_({asChild:!0},O,{dir:S.dir,orientation:"vertical",loop:o,currentTabStopId:L,onCurrentTabStopIdChange:K,onEntryFocus:e=>{S.isUsingKeyboardRef.current||e.preventDefault()}}),/*#__PURE__*/R.createElement(l.Content,_({role:"menu","aria-orientation":"vertical","data-state":pe(S.open),dir:S.dir},D,k,{ref:V,style:{outline:"none",...k.style},onKeyDown:M(k.onKeyDown,(e=>{const n=e.target,t=e.currentTarget.contains(n),r=e.ctrlKey||e.altKey||e.metaKey;t&&!r&&1===e.key.length&&Q(e.key),"Tab"===e.key&&e.preventDefault();const o=G.current;if(e.target!==o)return;if(!I.includes(e.key))return;e.preventDefault();const u=F().filter((e=>!e.disabled)).map((e=>e.ref.current));P.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(X.current),B.current="")})),onPointerMove:M(e.onPointerMove,ve((e=>{const n=e.target,t=z.current!==e.clientX;if(e.currentTarget.contains(n)&&t){const n=e.clientX>z.current?"right":"left";Z.current=n,z.current=e.clientX}})))}))))))))})),Q=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:t,...r}=e;/*#__PURE__*/return R.createElement(f.div,_({role:"group"},r,{ref:n}))}));exports.MenuGroup=Q;const $=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:t,...r}=e;/*#__PURE__*/return R.createElement(f.div,_({},r,{ref:n}))}));exports.MenuLabel=$;const ee=/*#__PURE__*/R.forwardRef(((e,n)=>{const{disabled:t=!1,onSelect:r,...o}=e,u=R.useRef(null),c=U("MenuItem",e.__scopeMenu),a=H("MenuItem",e.__scopeMenu),i=C(n,u),s=R.useRef(!1);/*#__PURE__*/return R.createElement(te,_({},o,{ref:i,disabled:t,onClick:M(e.onClick,(()=>{const e=u.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:c.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||k.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())}))}))}));exports.MenuItem=ee;const ne=/*#__PURE__*/R.forwardRef(((e,n)=>{const t=U("MenuSubTrigger",e.__scopeMenu),r=H("MenuSubTrigger",e.__scopeMenu),o=R.useRef(null),{pointerGraceTimerRef:u,onPointerGraceIntentChange:c}=r,a=R.useCallback((()=>{o.current&&window.clearTimeout(o.current),o.current=null}),[]);return R.useEffect((()=>a),[a]),R.useEffect((()=>{const e=u.current;return()=>{window.clearTimeout(e),c(null)}}),[u,c]),t.isSubmenu?/*#__PURE__*/R.createElement(B,_({asChild:!0},e),/*#__PURE__*/R.createElement(te,_({id:t.triggerId,"aria-haspopup":"menu","aria-expanded":t.open,"aria-controls":t.contentId,"data-state":pe(t.open)},e,{ref:E(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,ve((n=>{r.onItemEnter(n),n.defaultPrevented||e.disabled||t.open||o.current||(r.onPointerGraceIntentChange(null),o.current=window.setTimeout((()=>{t.onOpenChange(!0),a()}),100))}))),onPointerLeave:M(e.onPointerLeave,ve((e=>{var n;a();const o=null===(n=t.content)||void 0===n?void 0:n.getBoundingClientRect();if(o){var c;const n=null===(c=t.content)||void 0===c?void 0:c.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(u.current),u.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 u;e.disabled||o&&" "===n.key||S[t.dir].includes(n.key)&&(t.onOpenChange(!0),null===(u=t.content)||void 0===u||u.focus(),n.preventDefault())}))}))):null}));exports.MenuSubTrigger=ne;const te=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:t,disabled:r=!1,textValue:o,...u}=e,a=H("MenuItem",t),i=A(t),s=R.useRef(null),l=C(n,s),[d,p]=R.useState("");return R.useEffect((()=>{const e=s.current;var n;e&&p((null!==(n=e.textContent)&&void 0!==n?n:"").trim())}),[u.children]),/*#__PURE__*/R.createElement(O.ItemSlot,{scope:t,disabled:r,textValue:null!=o?o:d},/*#__PURE__*/R.createElement(c.Item,_({asChild:!0},i,{focusable:!r}),/*#__PURE__*/R.createElement(f.div,_({role:"menuitem","aria-disabled":r||void 0,"data-disabled":r?"":void 0},u,{ref:l,onPointerMove:M(e.onPointerMove,ve((e=>{if(r)a.onItemLeave(e);else if(a.onItemEnter(e),!e.defaultPrevented){e.currentTarget.focus()}}))),onPointerLeave:M(e.onPointerLeave,ve((e=>a.onItemLeave(e))))}))))})),re=/*#__PURE__*/R.forwardRef(((e,n)=>{const{checked:t=!1,onCheckedChange:r,...o}=e;/*#__PURE__*/return R.createElement(ie,{scope:e.__scopeMenu,checked:t},/*#__PURE__*/R.createElement(ee,_({role:"menuitemcheckbox","aria-checked":t},o,{ref:n,"data-state":me(t),onSelect:M(o.onSelect,(()=>null==r?void 0:r(!t)),{checkForDefaultPrevented:!1})})))}));exports.MenuCheckboxItem=re;const[oe,ue]=L("MenuRadioGroup",{value:void 0,onValueChange:()=>{}}),ce=/*#__PURE__*/R.forwardRef(((e,n)=>{const{value:t,onValueChange:o,...u}=e,c=r(o);/*#__PURE__*/return R.createElement(oe,{scope:e.__scopeMenu,value:t,onValueChange:c},/*#__PURE__*/R.createElement(Q,_({},u,{ref:n})))}));exports.MenuRadioGroup=ce;const ae=/*#__PURE__*/R.forwardRef(((e,n)=>{const{value:t,...r}=e,o=ue("MenuRadioItem",e.__scopeMenu),u=t===o.value;/*#__PURE__*/return R.createElement(ie,{scope:e.__scopeMenu,checked:u},/*#__PURE__*/R.createElement(ee,_({role:"menuitemradio","aria-checked":u},r,{ref:n,"data-state":me(u),onSelect:M(r.onSelect,(()=>{var e;return null===(e=o.onValueChange)||void 0===e?void 0:e.call(o,t)}),{checkForDefaultPrevented:!1})})))}));exports.MenuRadioItem=ae;const[ie,se]=L("MenuItemIndicator",{checked:!1}),le=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:t,forceMount:r,...o}=e,u=se("MenuItemIndicator",t);/*#__PURE__*/return R.createElement(p,{present:r||u.checked},/*#__PURE__*/R.createElement(f.span,_({},o,{ref:n,"data-state":me(u.checked)})))}));exports.MenuItemIndicator=le;const de=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:t,...r}=e;/*#__PURE__*/return R.createElement(f.div,_({role:"separator","aria-orientation":"horizontal"},r,{ref:n}))}));exports.MenuSeparator=de;const fe=/*#__PURE__*/R.forwardRef(((e,n)=>{const{__scopeMenu:t,...r}=e,o=q(t);/*#__PURE__*/return R.createElement(l.Arrow,_({},o,r,{ref:n}))}));function pe(e){return e?"open":"closed"}function me(e){return e?"checked":"unchecked"}function ve(e){return n=>"mouse"===n.pointerType?e(n):void 0}exports.MenuArrow=fe;const ge=V;exports.Root=ge;const he=X;exports.Sub=he;const Ce=B;exports.Anchor=Ce;const Ee=ne;exports.SubTrigger=Ee;const we=Y;exports.Content=we;const Me=Q;exports.Group=Me;const be=$;exports.Label=be;const xe=ee;exports.Item=xe;const Re=re;exports.CheckboxItem=Re;const _e=ce;exports.RadioGroup=_e;const ye=ae;exports.RadioItem=ye;const ke=le;exports.ItemIndicator=ke;const Pe=de;exports.Separator=Pe;const Ie=fe;exports.Arrow=Ie;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import{useId as e}from"@radix-ui/react-id";import{useFocusGuards as t}from"@radix-ui/react-focus-guards";import{useCallbackRef as n}from"@radix-ui/react-use-callback-ref";import{useDirection as r}from"@radix-ui/react-use-direction";import*as o from"@radix-ui/react-roving-focus";import{createRovingFocusGroupScope as u}from"@radix-ui/react-roving-focus";import{Portal as c}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,u]);export{S as createMenuScope};const O=i(),T=u(),[L,A]=D("Menu");export const Menu=e=>{const{__scopeMenu:t,open:o=!1,children:u,onOpenChange:c,modal:i=!0}=e,s=O(t),[l,d]=E.useState(null),p=E.useRef(!1),f=n(c),m=r(l,e.dir);return E.useEffect((()=>{const e=()=>p.current=!0,t=()=>p.current=!1;return document.addEventListener("keydown",e,{capture:!0}),document.addEventListener("pointerdown",t,{capture:!0}),document.addEventListener("pointermove",t,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}}),[]),/*#__PURE__*/E.createElement(a.Root,s,/*#__PURE__*/E.createElement(L,{scope:t,isSubmenu:!1,isUsingKeyboardRef:p,dir:m,open:o,onOpenChange:f,content:l,onContentChange:d,onRootClose:E.useCallback((()=>f(!1)),[f]),modal:i},u))};/*#__PURE__*/export const MenuSub=t=>{const{__scopeMenu:r,children:o,open:u=!1,onOpenChange:c}=t,i=A("MenuSub",r),s=O(r),[l,d]=E.useState(null),[p,f]=E.useState(null),m=n(c);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:u,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,t)=>{const{__scopeMenu:n,...r}=e,o=O(n);/*#__PURE__*/return E.createElement(a.Anchor,w({},o,r,{ref:t}))}));/*#__PURE__*/const[F,K]=D("MenuContent");export const MenuContent=/*#__PURE__*/E.forwardRef(((e,t)=>{const{forceMount:n,...r}=e,o=A("MenuContent",e.__scopeMenu);/*#__PURE__*/return E.createElement(I.Provider,{scope:e.__scopeMenu},/*#__PURE__*/E.createElement(l,{present:n||o.open},/*#__PURE__*/E.createElement(I.Slot,{scope:e.__scopeMenu},o.isSubmenu?/*#__PURE__*/E.createElement(X,w({},r,{ref:t})):/*#__PURE__*/E.createElement(G,w({},r,{ref:t})))))}));const G=/*#__PURE__*/E.forwardRef(((e,t)=>A("MenuContent",e.__scopeMenu).modal?/*#__PURE__*/E.createElement(U,w({},e,{ref:t})):/*#__PURE__*/E.createElement(V,w({},e,{ref:t})))),U=/*#__PURE__*/E.forwardRef(((e,t)=>{const n=A("MenuContent",e.__scopeMenu),r=E.useRef(null),o=m(t,r);return E.useEffect((()=>{const e=r.current;if(e)return h(e)}),[]),/*#__PURE__*/E.createElement(B,w({},e,{ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:M(e.onFocusOutside,(e=>e.preventDefault()),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)}))})),V=/*#__PURE__*/E.forwardRef(((e,t)=>{const n=A("MenuContent",e.__scopeMenu);/*#__PURE__*/return E.createElement(B,w({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)}))})),X=/*#__PURE__*/E.forwardRef(((e,t)=>{const n=A("MenuContent",e.__scopeMenu),r=E.useRef(null),o=m(t,r);return n.isSubmenu?/*#__PURE__*/E.createElement(B,w({id:n.contentId,"aria-labelledby":n.triggerId},e,{ref:o,align:"start",side:"rtl"===n.dir?"left":"right",portalled:!0,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{var t;n.isUsingKeyboardRef.current&&(null===(t=r.current)||void 0===t||t.focus()),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:M(e.onFocusOutside,(e=>{e.target!==n.trigger&&n.onOpenChange(!1)})),onEscapeKeyDown:M(e.onEscapeKeyDown,n.onRootClose),onKeyDown:M(e.onKeyDown,(e=>{const t=e.currentTarget.contains(e.target),r=y[n.dir].includes(e.key);var o;t&&r&&(n.onOpenChange(!1),null===(o=n.trigger)||void 0===o||o.focus(),e.preventDefault())}))})):null})),B=/*#__PURE__*/E.forwardRef(((e,n)=>{const{__scopeMenu:r,loop:u=!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(n,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?c:E.Fragment,Q=y?C:E.Fragment,$=y?{allowPinchZoom:I}:void 0,ee=e=>{var t,n;const r=Z.current+e,o=G().filter((e=>!e.disabled)),u=document.activeElement,c=null===(t=o.find((e=>e.ref.current===u)))||void 0===t?void 0:t.textValue,a=function(e,t,n){const r=t.length>1&&Array.from(t).every((e=>e===t[0]))?t[0]:t,o=n?e.indexOf(n):-1;let u=(c=e,a=Math.max(o,0),c.map(((e,t)=>c[(a+t)%c.length])));var c,a;1===r.length&&(u=u.filter((e=>e!==n)));const i=u.find((e=>e.toLowerCase().startsWith(r.toLowerCase())));return i!==n?i:void 0}(o.map((e=>e.textValue)),r,c),i=null===(n=o.find((e=>e.textValue===a)))||void 0===n?void 0:n.ref.current;!function e(t){Z.current=t,window.clearTimeout(Y.current),""!==t&&(Y.current=window.setTimeout((()=>e("")),1e3))}(r),i&&setTimeout((()=>i.focus()))};E.useEffect((()=>()=>window.clearTimeout(Y.current)),[]),t();const te=E.useCallback((e=>{var t,n;return W.current===(null===(t=H.current)||void 0===t?void 0:t.side)&&function(e,t){if(!t)return!1;return function(e,t){const{x:n,y:r}=e;let o=!1;for(let e=0,u=t.length-1;e<t.length;u=e++){const c=t[e].x,a=t[e].y,i=t[u].x,s=t[u].y;a>r!=s>r&&n<(i-c)*(r-a)/(s-a)+c&&(o=!o)}return o}({x:e.clientX,y:e.clientY},t)}(e,null===(n=H.current)||void 0===n?void 0:n.area)}),[]);/*#__PURE__*/return E.createElement(N,null,/*#__PURE__*/E.createElement(Q,$,/*#__PURE__*/E.createElement(F,{scope:r,searchRef:Z,onItemEnter:E.useCallback((e=>{te(e)&&e.preventDefault()}),[te]),onItemLeave:E.useCallback((e=>{var t;te(e)||(null===(t=X.current)||void 0===t||t.focus(),V(null))}),[te]),onTriggerLeave:E.useCallback((e=>{te(e)&&e.preventDefault()}),[te]),pointerGraceTimerRef:z,onPointerGraceIntentChange:E.useCallback((e=>{H.current=e}),[])},/*#__PURE__*/E.createElement(d,{asChild:!0,trapped:i,onMountAutoFocus:M(s,(e=>{var t;e.preventDefault(),null===(t=X.current)||void 0===t||t.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:u,currentTabStopId:U,onCurrentTabStopIdChange:V,onEntryFocus:e=>{S.isUsingKeyboardRef.current||e.preventDefault()}}),/*#__PURE__*/E.createElement(a.Content,w({role:"menu",dir:S.dir,"data-state":j(S.open)},L,D,{ref:B,style:{outline:"none",...D.style},onKeyDown:M(D.onKeyDown,(e=>{const t=e.target,n=e.currentTarget.contains(t),r=e.ctrlKey||e.altKey||e.metaKey;n&&!r&&1===e.key.length&&ee(e.key),"Tab"===e.key&&e.preventDefault();const o=X.current;if(e.target!==o)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 t=document.activeElement;for(const n of e){if(n===t)return;if(n.focus(),document.activeElement!==t)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 t=e.target,n=q.current!==e.clientX;if(e.currentTarget.contains(t)&&n){const t=e.clientX>q.current?"right":"left";W.current=t,q.current=e.clientX}})))}))))))))}));export const MenuGroup=/*#__PURE__*/E.forwardRef(((e,t)=>{const{__scopeMenu:n,...r}=e;/*#__PURE__*/return E.createElement(s.div,w({role:"group"},r,{ref:t}))}));/*#__PURE__*/export const MenuLabel=/*#__PURE__*/E.forwardRef(((e,t)=>{const{__scopeMenu:n,...r}=e;/*#__PURE__*/return E.createElement(s.div,w({},r,{ref:t}))}));/*#__PURE__*/export const MenuItem=/*#__PURE__*/E.forwardRef(((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,u=E.useRef(null),c=A("MenuItem",e.__scopeMenu),a=K("MenuItem",e.__scopeMenu),i=m(t,u),s=E.useRef(!1);/*#__PURE__*/return E.createElement(Y,w({},o,{ref:i,disabled:n,onClick:M(e.onClick,(()=>{const e=u.current;if(!n&&e){const t=new Event("menu.itemSelect",{bubbles:!0,cancelable:!0});e.addEventListener("menu.itemSelect",(e=>null==r?void 0:r(e)),{once:!0}),e.dispatchEvent(t),t.defaultPrevented?s.current=!1:c.onRootClose()}})),onPointerDown:t=>{var n;null===(n=e.onPointerDown)||void 0===n||n.call(e,t),s.current=!0},onPointerUp:M(e.onPointerUp,(e=>{var t;s.current||null===(t=e.currentTarget)||void 0===t||t.click()})),onKeyDown:M(e.onKeyDown,(e=>{const t=""!==a.searchRef.current;n||t&&" "===e.key||x.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())}))}))}));/*#__PURE__*/export const MenuSubTrigger=/*#__PURE__*/E.forwardRef(((e,t)=>{const n=A("MenuSubTrigger",e.__scopeMenu),r=K("MenuSubTrigger",e.__scopeMenu),o=E.useRef(null),{pointerGraceTimerRef:u,onPointerGraceIntentChange:c}=r,a=E.useCallback((()=>{o.current&&window.clearTimeout(o.current),o.current=null}),[]);return E.useEffect((()=>a),[a]),E.useEffect((()=>{const e=u.current;return()=>{window.clearTimeout(e),c(null)}}),[u,c]),n.isSubmenu?/*#__PURE__*/E.createElement(MenuAnchor,w({asChild:!0},e),/*#__PURE__*/E.createElement(Y,w({id:n.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":j(n.open)},e,{ref:v(t,n.onTriggerChange),onClick:t=>{var r;null===(r=e.onClick)||void 0===r||r.call(e,t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:M(e.onPointerMove,J((t=>{r.onItemEnter(t),t.defaultPrevented||e.disabled||n.open||o.current||(r.onPointerGraceIntentChange(null),o.current=window.setTimeout((()=>{n.onOpenChange(!0),a()}),100))}))),onPointerLeave:M(e.onPointerLeave,J((e=>{var t;a();const o=null===(t=n.content)||void 0===t?void 0:t.getBoundingClientRect();if(o){var c;const t=null===(c=n.content)||void 0===c?void 0:c.dataset.side,a="right"===t,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:t}),window.clearTimeout(u.current),u.current=window.setTimeout((()=>r.onPointerGraceIntentChange(null)),300)}else{if(r.onTriggerLeave(e),e.defaultPrevented)return;r.onPointerGraceIntentChange(null)}}))),onKeyDown:M(e.onKeyDown,(t=>{const o=""!==r.searchRef.current;var u;e.disabled||o&&" "===t.key||_[n.dir].includes(t.key)&&(n.onOpenChange(!0),null===(u=n.content)||void 0===u||u.focus(),t.preventDefault())}))}))):null}));/*#__PURE__*/const Y=/*#__PURE__*/E.forwardRef(((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:u,...c}=e,a=K("MenuItem",n),i=T(n),l=E.useRef(null),d=m(t,l),[p,f]=E.useState("");return E.useEffect((()=>{const e=l.current;var t;e&&f((null!==(t=e.textContent)&&void 0!==t?t:"").trim())}),[c.children]),/*#__PURE__*/E.createElement(I.ItemSlot,{scope:n,disabled:r,textValue:null!=u?u: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},c,{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,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;/*#__PURE__*/return E.createElement(H,{scope:e.__scopeMenu,checked:n},/*#__PURE__*/E.createElement(MenuItem,w({role:"menuitemcheckbox","aria-checked":n},o,{ref:t,"data-state":q(n),onSelect:M(o.onSelect,(()=>null==r?void 0:r(!n)),{checkForDefaultPrevented:!1})})))}));/*#__PURE__*/const[Z,z]=D("MenuRadioGroup",{value:void 0,onValueChange:()=>{}});export const MenuRadioGroup=/*#__PURE__*/E.forwardRef(((e,t)=>{const{value:r,onValueChange:o,...u}=e,c=n(o);/*#__PURE__*/return E.createElement(Z,{scope:e.__scopeMenu,value:r,onValueChange:c},/*#__PURE__*/E.createElement(MenuGroup,w({},u,{ref:t})))}));/*#__PURE__*/export const MenuRadioItem=/*#__PURE__*/E.forwardRef(((e,t)=>{const{value:n,...r}=e,o=z("MenuRadioItem",e.__scopeMenu),u=n===o.value;/*#__PURE__*/return E.createElement(H,{scope:e.__scopeMenu,checked:u},/*#__PURE__*/E.createElement(MenuItem,w({role:"menuitemradio","aria-checked":u},r,{ref:t,"data-state":q(u),onSelect:M(r.onSelect,(()=>{var e;return null===(e=o.onValueChange)||void 0===e?void 0:e.call(o,n)}),{checkForDefaultPrevented:!1})})))}));/*#__PURE__*/const[H,W]=D("MenuItemIndicator",{checked:!1});export const MenuItemIndicator=/*#__PURE__*/E.forwardRef(((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,u=W("MenuItemIndicator",n);/*#__PURE__*/return E.createElement(l,{present:r||u.checked},/*#__PURE__*/E.createElement(s.span,w({},o,{ref:t,"data-state":q(u.checked)})))}));/*#__PURE__*/export const MenuSeparator=/*#__PURE__*/E.forwardRef(((e,t)=>{const{__scopeMenu:n,...r}=e;/*#__PURE__*/return E.createElement(s.div,w({role:"separator","aria-orientation":"horizontal"},r,{ref:t}))}));/*#__PURE__*/export const MenuArrow=/*#__PURE__*/E.forwardRef(((e,t)=>{const{__scopeMenu:n,...r}=e,o=O(n);/*#__PURE__*/return E.createElement(a.Arrow,w({},o,r,{ref:t}))}));/*#__PURE__*/function j(e){return e?"open":"closed"}function q(e){return e?"checked":"unchecked"}function J(e){return t=>"mouse"===t.pointerType?e(t):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;
import{useId as e}from"@radix-ui/react-id";import{useFocusGuards as t}from"@radix-ui/react-focus-guards";import{useCallbackRef as n}from"@radix-ui/react-use-callback-ref";import{useDirection as r}from"@radix-ui/react-use-direction";import*as o from"@radix-ui/react-roving-focus";import{createRovingFocusGroupScope as u}from"@radix-ui/react-roving-focus";import{Portal as c}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,u]);export{S as createMenuScope};const O=i(),T=u(),[L,A]=D("Menu");export const Menu=e=>{const{__scopeMenu:t,open:o=!1,children:u,onOpenChange:c,modal:i=!0}=e,s=O(t),[l,d]=E.useState(null),p=E.useRef(!1),f=n(c),m=r(l,e.dir);return E.useEffect((()=>{const e=()=>p.current=!0,t=()=>p.current=!1;return document.addEventListener("keydown",e,{capture:!0}),document.addEventListener("pointerdown",t,{capture:!0}),document.addEventListener("pointermove",t,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}}),[]),/*#__PURE__*/E.createElement(a.Root,s,/*#__PURE__*/E.createElement(L,{scope:t,isSubmenu:!1,isUsingKeyboardRef:p,dir:m,open:o,onOpenChange:f,content:l,onContentChange:d,onRootClose:E.useCallback((()=>f(!1)),[f]),modal:i},u))};/*#__PURE__*/export const MenuSub=t=>{const{__scopeMenu:r,children:o,open:u=!1,onOpenChange:c}=t,i=A("MenuSub",r),s=O(r),[l,d]=E.useState(null),[p,f]=E.useState(null),m=n(c);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:u,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,t)=>{const{__scopeMenu:n,...r}=e,o=O(n);/*#__PURE__*/return E.createElement(a.Anchor,w({},o,r,{ref:t}))}));/*#__PURE__*/const[F,K]=D("MenuContent");export const MenuContent=/*#__PURE__*/E.forwardRef(((e,t)=>{const{forceMount:n,...r}=e,o=A("MenuContent",e.__scopeMenu);/*#__PURE__*/return E.createElement(I.Provider,{scope:e.__scopeMenu},/*#__PURE__*/E.createElement(l,{present:n||o.open},/*#__PURE__*/E.createElement(I.Slot,{scope:e.__scopeMenu},o.isSubmenu?/*#__PURE__*/E.createElement(X,w({},r,{ref:t})):/*#__PURE__*/E.createElement(G,w({},r,{ref:t})))))}));const G=/*#__PURE__*/E.forwardRef(((e,t)=>A("MenuContent",e.__scopeMenu).modal?/*#__PURE__*/E.createElement(U,w({},e,{ref:t})):/*#__PURE__*/E.createElement(V,w({},e,{ref:t})))),U=/*#__PURE__*/E.forwardRef(((e,t)=>{const n=A("MenuContent",e.__scopeMenu),r=E.useRef(null),o=m(t,r);return E.useEffect((()=>{const e=r.current;if(e)return h(e)}),[]),/*#__PURE__*/E.createElement(B,w({},e,{ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:M(e.onFocusOutside,(e=>e.preventDefault()),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)}))})),V=/*#__PURE__*/E.forwardRef(((e,t)=>{const n=A("MenuContent",e.__scopeMenu);/*#__PURE__*/return E.createElement(B,w({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)}))})),X=/*#__PURE__*/E.forwardRef(((e,t)=>{const n=A("MenuContent",e.__scopeMenu),r=E.useRef(null),o=m(t,r);return n.isSubmenu?/*#__PURE__*/E.createElement(B,w({id:n.contentId,"aria-labelledby":n.triggerId},e,{ref:o,align:"start",side:"rtl"===n.dir?"left":"right",portalled:!0,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{var t;n.isUsingKeyboardRef.current&&(null===(t=r.current)||void 0===t||t.focus()),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:M(e.onFocusOutside,(e=>{e.target!==n.trigger&&n.onOpenChange(!1)})),onEscapeKeyDown:M(e.onEscapeKeyDown,n.onRootClose),onKeyDown:M(e.onKeyDown,(e=>{const t=e.currentTarget.contains(e.target),r=y[n.dir].includes(e.key);var o;t&&r&&(n.onOpenChange(!1),null===(o=n.trigger)||void 0===o||o.focus(),e.preventDefault())}))})):null})),B=/*#__PURE__*/E.forwardRef(((e,n)=>{const{__scopeMenu:r,loop:u=!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(n,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?c:E.Fragment,Q=y?C:E.Fragment,$=y?{allowPinchZoom:I}:void 0,ee=e=>{var t,n;const r=Z.current+e,o=G().filter((e=>!e.disabled)),u=document.activeElement,c=null===(t=o.find((e=>e.ref.current===u)))||void 0===t?void 0:t.textValue,a=function(e,t,n){const r=t.length>1&&Array.from(t).every((e=>e===t[0]))?t[0]:t,o=n?e.indexOf(n):-1;let u=(c=e,a=Math.max(o,0),c.map(((e,t)=>c[(a+t)%c.length])));var c,a;1===r.length&&(u=u.filter((e=>e!==n)));const i=u.find((e=>e.toLowerCase().startsWith(r.toLowerCase())));return i!==n?i:void 0}(o.map((e=>e.textValue)),r,c),i=null===(n=o.find((e=>e.textValue===a)))||void 0===n?void 0:n.ref.current;!function e(t){Z.current=t,window.clearTimeout(Y.current),""!==t&&(Y.current=window.setTimeout((()=>e("")),1e3))}(r),i&&setTimeout((()=>i.focus()))};E.useEffect((()=>()=>window.clearTimeout(Y.current)),[]),t();const te=E.useCallback((e=>{var t,n;return W.current===(null===(t=H.current)||void 0===t?void 0:t.side)&&function(e,t){if(!t)return!1;return function(e,t){const{x:n,y:r}=e;let o=!1;for(let e=0,u=t.length-1;e<t.length;u=e++){const c=t[e].x,a=t[e].y,i=t[u].x,s=t[u].y;a>r!=s>r&&n<(i-c)*(r-a)/(s-a)+c&&(o=!o)}return o}({x:e.clientX,y:e.clientY},t)}(e,null===(n=H.current)||void 0===n?void 0:n.area)}),[]);/*#__PURE__*/return E.createElement(N,null,/*#__PURE__*/E.createElement(Q,$,/*#__PURE__*/E.createElement(F,{scope:r,searchRef:Z,onItemEnter:E.useCallback((e=>{te(e)&&e.preventDefault()}),[te]),onItemLeave:E.useCallback((e=>{var t;te(e)||(null===(t=X.current)||void 0===t||t.focus(),V(null))}),[te]),onTriggerLeave:E.useCallback((e=>{te(e)&&e.preventDefault()}),[te]),pointerGraceTimerRef:z,onPointerGraceIntentChange:E.useCallback((e=>{H.current=e}),[])},/*#__PURE__*/E.createElement(d,{asChild:!0,trapped:i,onMountAutoFocus:M(s,(e=>{var t;e.preventDefault(),null===(t=X.current)||void 0===t||t.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:u,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 t=e.target,n=e.currentTarget.contains(t),r=e.ctrlKey||e.altKey||e.metaKey;n&&!r&&1===e.key.length&&ee(e.key),"Tab"===e.key&&e.preventDefault();const o=X.current;if(e.target!==o)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 t=document.activeElement;for(const n of e){if(n===t)return;if(n.focus(),document.activeElement!==t)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 t=e.target,n=q.current!==e.clientX;if(e.currentTarget.contains(t)&&n){const t=e.clientX>q.current?"right":"left";W.current=t,q.current=e.clientX}})))}))))))))}));export const MenuGroup=/*#__PURE__*/E.forwardRef(((e,t)=>{const{__scopeMenu:n,...r}=e;/*#__PURE__*/return E.createElement(s.div,w({role:"group"},r,{ref:t}))}));/*#__PURE__*/export const MenuLabel=/*#__PURE__*/E.forwardRef(((e,t)=>{const{__scopeMenu:n,...r}=e;/*#__PURE__*/return E.createElement(s.div,w({},r,{ref:t}))}));/*#__PURE__*/export const MenuItem=/*#__PURE__*/E.forwardRef(((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,u=E.useRef(null),c=A("MenuItem",e.__scopeMenu),a=K("MenuItem",e.__scopeMenu),i=m(t,u),s=E.useRef(!1);/*#__PURE__*/return E.createElement(Y,w({},o,{ref:i,disabled:n,onClick:M(e.onClick,(()=>{const e=u.current;if(!n&&e){const t=new Event("menu.itemSelect",{bubbles:!0,cancelable:!0});e.addEventListener("menu.itemSelect",(e=>null==r?void 0:r(e)),{once:!0}),e.dispatchEvent(t),t.defaultPrevented?s.current=!1:c.onRootClose()}})),onPointerDown:t=>{var n;null===(n=e.onPointerDown)||void 0===n||n.call(e,t),s.current=!0},onPointerUp:M(e.onPointerUp,(e=>{var t;s.current||null===(t=e.currentTarget)||void 0===t||t.click()})),onKeyDown:M(e.onKeyDown,(e=>{const t=""!==a.searchRef.current;n||t&&" "===e.key||x.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())}))}))}));/*#__PURE__*/export const MenuSubTrigger=/*#__PURE__*/E.forwardRef(((e,t)=>{const n=A("MenuSubTrigger",e.__scopeMenu),r=K("MenuSubTrigger",e.__scopeMenu),o=E.useRef(null),{pointerGraceTimerRef:u,onPointerGraceIntentChange:c}=r,a=E.useCallback((()=>{o.current&&window.clearTimeout(o.current),o.current=null}),[]);return E.useEffect((()=>a),[a]),E.useEffect((()=>{const e=u.current;return()=>{window.clearTimeout(e),c(null)}}),[u,c]),n.isSubmenu?/*#__PURE__*/E.createElement(MenuAnchor,w({asChild:!0},e),/*#__PURE__*/E.createElement(Y,w({id:n.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":j(n.open)},e,{ref:v(t,n.onTriggerChange),onClick:t=>{var r;null===(r=e.onClick)||void 0===r||r.call(e,t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:M(e.onPointerMove,J((t=>{r.onItemEnter(t),t.defaultPrevented||e.disabled||n.open||o.current||(r.onPointerGraceIntentChange(null),o.current=window.setTimeout((()=>{n.onOpenChange(!0),a()}),100))}))),onPointerLeave:M(e.onPointerLeave,J((e=>{var t;a();const o=null===(t=n.content)||void 0===t?void 0:t.getBoundingClientRect();if(o){var c;const t=null===(c=n.content)||void 0===c?void 0:c.dataset.side,a="right"===t,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:t}),window.clearTimeout(u.current),u.current=window.setTimeout((()=>r.onPointerGraceIntentChange(null)),300)}else{if(r.onTriggerLeave(e),e.defaultPrevented)return;r.onPointerGraceIntentChange(null)}}))),onKeyDown:M(e.onKeyDown,(t=>{const o=""!==r.searchRef.current;var u;e.disabled||o&&" "===t.key||_[n.dir].includes(t.key)&&(n.onOpenChange(!0),null===(u=n.content)||void 0===u||u.focus(),t.preventDefault())}))}))):null}));/*#__PURE__*/const Y=/*#__PURE__*/E.forwardRef(((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:u,...c}=e,a=K("MenuItem",n),i=T(n),l=E.useRef(null),d=m(t,l),[p,f]=E.useState("");return E.useEffect((()=>{const e=l.current;var t;e&&f((null!==(t=e.textContent)&&void 0!==t?t:"").trim())}),[c.children]),/*#__PURE__*/E.createElement(I.ItemSlot,{scope:n,disabled:r,textValue:null!=u?u: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},c,{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,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;/*#__PURE__*/return E.createElement(H,{scope:e.__scopeMenu,checked:n},/*#__PURE__*/E.createElement(MenuItem,w({role:"menuitemcheckbox","aria-checked":n},o,{ref:t,"data-state":q(n),onSelect:M(o.onSelect,(()=>null==r?void 0:r(!n)),{checkForDefaultPrevented:!1})})))}));/*#__PURE__*/const[Z,z]=D("MenuRadioGroup",{value:void 0,onValueChange:()=>{}});export const MenuRadioGroup=/*#__PURE__*/E.forwardRef(((e,t)=>{const{value:r,onValueChange:o,...u}=e,c=n(o);/*#__PURE__*/return E.createElement(Z,{scope:e.__scopeMenu,value:r,onValueChange:c},/*#__PURE__*/E.createElement(MenuGroup,w({},u,{ref:t})))}));/*#__PURE__*/export const MenuRadioItem=/*#__PURE__*/E.forwardRef(((e,t)=>{const{value:n,...r}=e,o=z("MenuRadioItem",e.__scopeMenu),u=n===o.value;/*#__PURE__*/return E.createElement(H,{scope:e.__scopeMenu,checked:u},/*#__PURE__*/E.createElement(MenuItem,w({role:"menuitemradio","aria-checked":u},r,{ref:t,"data-state":q(u),onSelect:M(r.onSelect,(()=>{var e;return null===(e=o.onValueChange)||void 0===e?void 0:e.call(o,n)}),{checkForDefaultPrevented:!1})})))}));/*#__PURE__*/const[H,W]=D("MenuItemIndicator",{checked:!1});export const MenuItemIndicator=/*#__PURE__*/E.forwardRef(((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,u=W("MenuItemIndicator",n);/*#__PURE__*/return E.createElement(l,{present:r||u.checked},/*#__PURE__*/E.createElement(s.span,w({},o,{ref:t,"data-state":q(u.checked)})))}));/*#__PURE__*/export const MenuSeparator=/*#__PURE__*/E.forwardRef(((e,t)=>{const{__scopeMenu:n,...r}=e;/*#__PURE__*/return E.createElement(s.div,w({role:"separator","aria-orientation":"horizontal"},r,{ref:t}))}));/*#__PURE__*/export const MenuArrow=/*#__PURE__*/E.forwardRef(((e,t)=>{const{__scopeMenu:n,...r}=e,o=O(n);/*#__PURE__*/return E.createElement(a.Arrow,w({},o,r,{ref:t}))}));/*#__PURE__*/function j(e){return e?"open":"closed"}function q(e){return e?"checked":"unchecked"}function J(e){return t=>"mouse"===t.pointerType?e(t):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;
//# sourceMappingURL=index.module.js.map
{
"name": "@radix-ui/react-menu",
"version": "0.1.1",
"version": "0.1.2-rc.1",
"license": "MIT",

@@ -29,6 +29,6 @@ "source": "src/index.ts",

"@radix-ui/react-popper": "0.1.1",
"@radix-ui/react-portal": "0.1.1",
"@radix-ui/react-portal": "0.1.2-rc.4",
"@radix-ui/react-presence": "0.1.1",
"@radix-ui/react-primitive": "0.1.1",
"@radix-ui/react-roving-focus": "0.1.1",
"@radix-ui/react-roving-focus": "0.1.2-rc.1",
"@radix-ui/react-use-callback-ref": "0.1.0",

@@ -50,3 +50,4 @@ "@radix-ui/react-use-direction": "0.1.0",

"url": "https://github.com/radix-ui/primitives/issues"
}
},
"stableVersion": "0.1.1"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc