1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2025-07-02 00:59:23 +00:00
Classworks/assets/VMenu-RF_tVNBL.js

2 lines
3.3 KiB
JavaScript

import{g as T,p as L,a7 as M,aU as O,al as S,aL as K,t as U,r as B,bo as N,c0 as E,s as j,bf as F,c1 as H,ae as Z,c2 as b,a9 as z,bI as k,f as W,Z as A,j as $,aE as V,k as P,a4 as q,aO as G,aa as J,aZ as Q,bO as X,c3 as y,c4 as Y,bv as _,c5 as ee}from"./index-ByVcHmHP.js";const te=L({id:String,submenu:Boolean,...J(Q({closeDelay:250,closeOnContentClick:!0,locationStrategy:"connected",location:void 0,openDelay:300,scrim:!1,scrollStrategy:"reposition",transition:{component:X}}),["absolute"])},"VMenu"),ne=T()({name:"VMenu",props:te(),emits:{"update:modelValue":a=>!0},setup(a,h){let{slots:c}=h;const s=M(a,"modelValue"),{scopeId:C}=O(),{isRtl:f}=S(),d=K(),m=U(()=>a.id||`v-menu-${d}`),o=B(),n=N(E,null),v=j(new Set);_(E,{register(){v.value.add(d)},unregister(){v.value.delete(d)},closeParents(e){setTimeout(()=>{var t;!v.value.size&&!a.persistent&&(e==null||(t=o.value)!=null&&t.contentEl&&!ee(e,o.value.contentEl))&&(s.value=!1,n==null||n.closeParents())},40)}}),F(()=>{n==null||n.unregister(),document.removeEventListener("focusin",g)}),H(()=>s.value=!1);async function g(e){var u,r,i;const t=e.relatedTarget,l=e.target;await Z(),s.value&&t!==l&&((u=o.value)!=null&&u.contentEl)&&((r=o.value)!=null&&r.globalTop)&&![document,o.value.contentEl].includes(l)&&!o.value.contentEl.contains(l)&&((i=b(o.value.contentEl)[0])==null||i.focus())}z(s,e=>{e?(n==null||n.register(),k&&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 R(e){var t,l,u,r,i;if(!a.disabled)if(e.key==="Tab"||e.key==="Enter"&&!a.closeOnContentClick){if(e.key==="Enter"&&(e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLInputElement&&e.target.closest("form")))return;e.key==="Enter"&&e.preventDefault(),Y(b((t=o.value)==null?void 0:t.contentEl,!1),e.shiftKey?"prev":"next",I=>I.tabIndex>=0)||(s.value=!1,(u=(l=o.value)==null?void 0:l.activatorEl)==null||u.focus())}else a.submenu&&e.key===(f.value?"ArrowRight":"ArrowLeft")&&(s.value=!1,(i=(r=o.value)==null?void 0:r.activatorEl)==null||i.focus())}function w(e){var l;if(a.disabled)return;const t=(l=o.value)==null?void 0:l.contentEl;t&&s.value?e.key==="ArrowDown"?(e.preventDefault(),e.stopImmediatePropagation(),y(t,"next")):e.key==="ArrowUp"?(e.preventDefault(),e.stopImmediatePropagation(),y(t,"prev")):a.submenu&&(e.key===(f.value?"ArrowRight":"ArrowLeft")?s.value=!1:e.key===(f.value?"ArrowLeft":"ArrowRight")&&(e.preventDefault(),y(t,"first"))):(a.submenu?e.key===(f.value?"ArrowLeft":"ArrowRight"):["ArrowDown","ArrowUp"].includes(e.key))&&(s.value=!0,e.preventDefault(),setTimeout(()=>setTimeout(()=>w(e))))}const p=W(()=>A({"aria-haspopup":"menu","aria-expanded":String(s.value),"aria-controls":m.value,onKeydown:w},a.activatorProps));return $(()=>{const e=V.filterProps(a);return P(V,A({ref:o,id:m.value,class:["v-menu",a.class],style:a.style},e,{modelValue:s.value,"onUpdate:modelValue":t=>s.value=t,absolute:!0,activatorProps:p.value,location:a.location??(a.submenu?"end":"bottom"),"onClick:outside":D,onKeydown:R},C),{activator:c.activator,default:function(){for(var t=arguments.length,l=new Array(t),u=0;u<t;u++)l[u]=arguments[u];return P(q,{root:"VMenu"},{default:()=>{var r;return[(r=c.default)==null?void 0:r.call(c,...l)]}})}})}),G({id:m,ΨopenChildren:v},o)}});export{ne as V};