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