mirror of
https://github.com/ZeroCatDev/Classworks.git
synced 2025-09-03 16:19:22 +00:00
2 lines
3.3 KiB
JavaScript
2 lines
3.3 KiB
JavaScript
import{g as M,p,S as L,aU as S,aj as K,aK as O,Y as U,W as B,bu as F,c5 as E,X as N,bh as j,c6 as z,aO as H,c7 as w,Z as W,bM as k,K as Z,E as A,c as $,aE as P,d as V,P as X,aM as Y,$ as q,aZ as G,bT as J,c8 as y,c9 as Q,bz as _,ca as ee}from"./index-DmGr2YjE.js";const te=p({id:String,submenu:Boolean,disableInitialFocus:Boolean,...q(G({closeDelay:250,closeOnContentClick:!0,locationStrategy:"connected",location:void 0,openDelay:300,scrim:!1,scrollStrategy:"reposition",transition:{component:J}}),["absolute"])},"VMenu"),ne=M()({name:"VMenu",props:te(),emits:{"update:modelValue":t=>!0},setup(t,h){let{slots:c}=h;const s=L(t,"modelValue"),{scopeId:C}=S(),{isRtl:f}=K(),v=O(),m=U(()=>t.id||`v-menu-${v}`),o=B(),n=F(E,null),d=N(new Set);_(E,{register(){d.value.add(v)},unregister(){d.value.delete(v)},closeParents(e){setTimeout(()=>{var a;!d.value.size&&!t.persistent&&(e==null||(a=o.value)!=null&&a.contentEl&&!ee(e,o.value.contentEl))&&(s.value=!1,n==null||n.closeParents())},40)}}),j(()=>{n==null||n.unregister(),document.removeEventListener("focusin",g)}),z(()=>s.value=!1);async function g(e){var u,i,r;const a=e.relatedTarget,l=e.target;await H(),s.value&&a!==l&&((u=o.value)!=null&&u.contentEl)&&((i=o.value)!=null&&i.globalTop)&&![document,o.value.contentEl].includes(l)&&!o.value.contentEl.contains(l)&&((r=w(o.value.contentEl)[0])==null||r.focus())}W(s,e=>{e?(n==null||n.register(),k&&!t.disableInitialFocus&&document.addEventListener("focusin",g,{once:!0})):(n==null||n.unregister(),k&&document.removeEventListener("focusin",g))},{immediate:!0});function D(e){n==null||n.closeParents(e)}function I(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(),Q(w((a=o.value)==null?void 0:a.contentEl,!1),e.shiftKey?"prev":"next",x=>x.tabIndex>=0)||(s.value=!1,(u=(l=o.value)==null?void 0:l.activatorEl)==null||u.focus())}else t.submenu&&e.key===(f.value?"ArrowRight":"ArrowLeft")&&(s.value=!1,(r=(i=o.value)==null?void 0:i.activatorEl)==null||r.focus())}function b(e){var l;if(t.disabled)return;const a=(l=o.value)==null?void 0:l.contentEl;a&&s.value?e.key==="ArrowDown"?(e.preventDefault(),e.stopImmediatePropagation(),y(a,"next")):e.key==="ArrowUp"?(e.preventDefault(),e.stopImmediatePropagation(),y(a,"prev")):t.submenu&&(e.key===(f.value?"ArrowRight":"ArrowLeft")?s.value=!1:e.key===(f.value?"ArrowLeft":"ArrowRight")&&(e.preventDefault(),y(a,"first"))):(t.submenu?e.key===(f.value?"ArrowLeft":"ArrowRight"):["ArrowDown","ArrowUp"].includes(e.key))&&(s.value=!0,e.preventDefault(),setTimeout(()=>setTimeout(()=>b(e))))}const R=Z(()=>A({"aria-haspopup":"menu","aria-expanded":String(s.value),"aria-controls":m.value,onKeydown:b},t.activatorProps));return $(()=>{const e=P.filterProps(t);return V(P,A({ref:o,id:m.value,class:["v-menu",t.class],style:t.style},e,{modelValue:s.value,"onUpdate:modelValue":a=>s.value=a,absolute:!0,activatorProps:R.value,location:t.location??(t.submenu?"end":"bottom"),"onClick:outside":D,onKeydown:I},C),{activator:c.activator,default:function(){for(var a=arguments.length,l=new Array(a),u=0;u<a;u++)l[u]=arguments[u];return V(X,{root:"VMenu"},{default:()=>{var i;return[(i=c.default)==null?void 0:i.call(c,...l)]}})}})}),Y({id:m,ΨopenChildren:d},o)}});export{ne as V};
|