mirror of
https://github.com/ZeroCatDev/Classworks.git
synced 2025-12-08 13:49:37 +00:00
2 lines
3.7 KiB
JavaScript
2 lines
3.7 KiB
JavaScript
import{g as M,p as O,$ as F,aF as K,bj as B,aW as U,ax as H,W as N,bE as W,ca as P,X as j,aX as X,cb as $,a3 as z,cc as T,a2 as J,a4 as V,a1 as q,E as h,c as G,at as x,d as C,aa as Q,ab as Y,ac as Z,bm as _,c8 as ee,cd as p,ce as te,bJ as ae,cf as ne}from"./index-B-g1bwIy.js";const oe=O({id:String,submenu:Boolean,disableInitialFocus:Boolean,...Z(_({closeDelay:250,closeOnContentClick:!0,locationStrategy:"connected",location:void 0,openDelay:300,scrim:!1,scrollStrategy:"reposition",transition:{component:ee}}),["absolute"])},"VMenu"),ue=M()({name:"VMenu",props:oe(),emits:{"update:modelValue":t=>!0},setup(t,D){let{slots:c}=D;const s=F(t,"modelValue"),{scopeId:I}=K(),{isRtl:f}=B(),w=U(),d=H(()=>t.id||`v-menu-${w}`),n=N(),o=W(P,null),v=j(new Set);ae(P,{register(){v.value.add(w)},unregister(){v.value.delete(w)},closeParents(e){setTimeout(()=>{var a;!v.value.size&&!t.persistent&&(e==null||(a=n.value)!=null&&a.contentEl&&!ne(e,n.value.contentEl))&&(s.value=!1,o==null||o.closeParents())},40)}}),X(()=>{o==null||o.unregister(),document.removeEventListener("focusin",g)}),$(()=>s.value=!1);let E=!1,k=-1;async function y(){E=!0,k=window.setTimeout(()=>{E=!1},100)}async function g(e){var u,i,r,b,m;const a=e.relatedTarget,l=e.target;await z(),s.value&&a!==l&&((u=n.value)!=null&&u.rootEl)&&((i=n.value)!=null&&i.contentEl)&&((r=n.value)!=null&&r.localTop)&&![document,n.value.rootEl].includes(l)&&!n.value.rootEl.contains(l)&&(E?!t.openOnHover&&!((b=n.value.activatorEl)!=null&&b.contains(l))&&(s.value=!1):((m=T(n.value.contentEl)[0])==null||m.focus(),document.removeEventListener("pointerdown",y)))}J(s,e=>{e?(o==null||o.register(),V&&!t.disableInitialFocus&&(document.addEventListener("pointerdown",y),document.addEventListener("focusin",g,{once:!0}))):(o==null||o.unregister(),V&&(clearTimeout(k),document.removeEventListener("pointerdown",y),document.removeEventListener("focusin",g)))},{immediate:!0});function L(e){o==null||o.closeParents(e)}function R(e){var a,l,u,i,r;if(!t.disabled)if(e.key==="Tab"||e.key==="Enter"&&!t.closeOnContentClick){if(e.key==="Enter"&&(e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLInputElement&&e.target.closest("form")))return;e.key==="Enter"&&e.preventDefault(),te(T((a=n.value)==null?void 0:a.contentEl,!1),e.shiftKey?"prev":"next",m=>m.tabIndex>=0)||(s.value=!1,(u=(l=n.value)==null?void 0:l.activatorEl)==null||u.focus())}else t.submenu&&e.key===(f.value?"ArrowRight":"ArrowLeft")&&(s.value=!1,(r=(i=n.value)==null?void 0:i.activatorEl)==null||r.focus())}function A(e){var l;if(t.disabled)return;const a=(l=n.value)==null?void 0:l.contentEl;a&&s.value?e.key==="ArrowDown"?(e.preventDefault(),e.stopImmediatePropagation(),p(a,"next")):e.key==="ArrowUp"?(e.preventDefault(),e.stopImmediatePropagation(),p(a,"prev")):t.submenu&&(e.key===(f.value?"ArrowRight":"ArrowLeft")?s.value=!1:e.key===(f.value?"ArrowLeft":"ArrowRight")&&(e.preventDefault(),p(a,"first"))):(t.submenu?e.key===(f.value?"ArrowLeft":"ArrowRight"):["ArrowDown","ArrowUp"].includes(e.key))&&(s.value=!0,e.preventDefault(),setTimeout(()=>setTimeout(()=>A(e))))}const S=q(()=>h({"aria-haspopup":"menu","aria-expanded":String(s.value),"aria-controls":d.value,"aria-owns":d.value,onKeydown:A},t.activatorProps));return G(()=>{const e=x.filterProps(t);return C(x,h({ref:n,id:d.value,class:["v-menu",t.class],style:t.style},e,{modelValue:s.value,"onUpdate:modelValue":a=>s.value=a,absolute:!0,activatorProps:S.value,location:t.location??(t.submenu?"end":"bottom"),"onClick:outside":L,onKeydown:R},I),{activator:c.activator,default:function(){for(var a=arguments.length,l=new Array(a),u=0;u<a;u++)l[u]=arguments[u];return C(Q,{root:"VMenu"},{default:()=>{var i;return[(i=c.default)==null?void 0:i.call(c,...l)]}})}})}),Y({id:d,ΨopenChildren:v},n)}});export{ue as V};
|