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-rc.14 to 0.1.1-rc.15

6

dist/index.d.ts
import * as React from "react";
import { RemoveScroll } from "react-remove-scroll";
import { DismissableLayer } from "@radix-ui/react-dismissable-layer";

@@ -42,2 +43,3 @@ import { FocusScope } from "@radix-ui/react-focus-scope";

}
type RemoveScrollProps = React.ComponentProps<typeof RemoveScroll>;
type FocusScopeProps = Radix.ComponentPropsWithoutRef<typeof FocusScope>;

@@ -63,2 +65,6 @@ type DismissableLayerProps = Radix.ComponentPropsWithoutRef<typeof DismissableLayer>;

/**
* @see https://github.com/theKashey/react-remove-scroll#usage
*/
allowPinchZoom?: RemoveScrollProps['allowPinchZoom'];
/**
* Whether scrolling outside the `MenuContent` should be prevented

@@ -65,0 +71,0 @@ * (default: `false`)

2

dist/index.js

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

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

@@ -21,14 +21,14 @@ "source": "src/index.ts",

"@radix-ui/primitive": "0.1.0",
"@radix-ui/react-collection": "0.1.1-rc.14",
"@radix-ui/react-collection": "0.1.1-rc.15",
"@radix-ui/react-compose-refs": "0.1.0",
"@radix-ui/react-context": "0.1.0",
"@radix-ui/react-dismissable-layer": "0.1.1-rc.14",
"@radix-ui/react-dismissable-layer": "0.1.1-rc.15",
"@radix-ui/react-focus-guards": "0.1.0",
"@radix-ui/react-focus-scope": "0.1.1-rc.14",
"@radix-ui/react-focus-scope": "0.1.1-rc.15",
"@radix-ui/react-id": "0.1.0",
"@radix-ui/react-popper": "0.1.1-rc.14",
"@radix-ui/react-portal": "0.1.1-rc.14",
"@radix-ui/react-presence": "0.1.1-rc.11",
"@radix-ui/react-primitive": "0.1.1-rc.14",
"@radix-ui/react-roving-focus": "0.1.1-rc.14",
"@radix-ui/react-popper": "0.1.1-rc.15",
"@radix-ui/react-portal": "0.1.1-rc.15",
"@radix-ui/react-presence": "0.1.1-rc.12",
"@radix-ui/react-primitive": "0.1.1-rc.15",
"@radix-ui/react-roving-focus": "0.1.1-rc.15",
"@radix-ui/react-use-callback-ref": "0.1.0",

@@ -35,0 +35,0 @@ "@radix-ui/react-use-direction": "0.1.0",

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