1 line
3.8 KiB
JavaScript
1 line
3.8 KiB
JavaScript
import{N as ae,Z as ne,O as se,P as ue,_ as le,Q as ie,a as w,c as l,R as re,aI as ce,aJ as fe,S as de,a0 as ve,aK as ge,w as M,bo as he,bp as me,bq as Pe,br as R,aN as be,bs as ye,U as A,a3 as Te,G as ke,a1 as Se,bt as Ce,bu as xe,bv as Oe,a5 as qe}from"./index-3a2b6cd5.js";import{u as Be,v as D,a as Ee,b as Fe,c as we,p as K,r as H,s as Me,d as Re}from"./position-engine-4e9b318c.js";const Ke=ae({name:"QMenu",inheritAttrs:!1,props:{...Be,...ne,...se,...ue,persistent:Boolean,autoClose:Boolean,separateClosePopup:Boolean,noRouteDismiss:Boolean,noRefocus:Boolean,noFocus:Boolean,fit:Boolean,cover:Boolean,square:Boolean,anchor:{type:String,validator:D},self:{type:String,validator:D},offset:{type:Array,validator:Ee},scrollTarget:{default:void 0},touchPosition:Boolean,maxHeight:{type:String,default:null},maxWidth:{type:String,default:null}},emits:[...le,"click","escapeKey"],setup(t,{slots:Q,emit:c,attrs:d}){let n=null,f,i,v;const y=ie(),{proxy:g}=y,{$q:o}=g,a=w(null),s=w(!1),W=l(()=>t.persistent!==!0&&t.noRouteDismiss!==!0),_=re(t,o),{registerTick:I,removeTick:N}=ce(),{registerTimeout:T}=fe(),{transitionProps:U,transitionStyle:j}=de(t),{localScrollTarget:k,changeScrollEvent:G,unconfigureScrollTarget:J}=Fe(t,E),{anchorEl:u,canShow:L}=we({showing:s}),{hide:S}=ve({showing:s,canShow:L,handleShow:X,handleHide:Y,hideOnRouteChange:W,processOnMount:!0}),{showPortal:C,hidePortal:x,renderPortal:Z}=ge(y,a,ee),h={anchorEl:u,innerRef:a,onClickOutside(e){if(t.persistent!==!0&&s.value===!0)return S(e),(e.type==="touchstart"||e.target.classList.contains("q-dialog__backdrop"))&&qe(e),!0}},O=l(()=>K(t.anchor||(t.cover===!0?"center middle":"bottom start"),o.lang.rtl)),$=l(()=>t.cover===!0?O.value:K(t.self||"top start",o.lang.rtl)),z=l(()=>(t.square===!0?" q-menu--square":"")+(_.value===!0?" q-menu--dark q-dark":"")),V=l(()=>t.autoClose===!0?{onClick:p}:{}),q=l(()=>s.value===!0&&t.persistent!==!0);M(q,e=>{e===!0?(Ce(P),Re(h)):(R(P),H(h))});function m(){xe(()=>{let e=a.value;e&&e.contains(document.activeElement)!==!0&&(e=e.querySelector("[autofocus][tabindex], [data-autofocus][tabindex]")||e.querySelector("[autofocus] [tabindex], [data-autofocus] [tabindex]")||e.querySelector("[autofocus], [data-autofocus]")||e,e.focus({preventScroll:!0}))})}function X(e){if(n=t.noRefocus===!1?document.activeElement:null,he(F),C(),E(),f=void 0,e!==void 0&&(t.touchPosition||t.contextMenu)){const b=me(e);if(b.left!==void 0){const{top:te,left:oe}=u.value.getBoundingClientRect();f={left:b.left-oe,top:b.top-te}}}i===void 0&&(i=M(()=>o.screen.width+"|"+o.screen.height+"|"+t.self+"|"+t.anchor+"|"+o.lang.rtl,r)),t.noFocus!==!0&&document.activeElement.blur(),I(()=>{r(),t.noFocus!==!0&&m()}),T(()=>{o.platform.is.ios===!0&&(v=t.autoClose,a.value.click()),r(),C(!0),c("show",e)},t.transitionDuration)}function Y(e){N(),x(),B(!0),n!==null&&(e===void 0||e.qClickOutside!==!0)&&(((e&&e.type.indexOf("key")===0?n.closest('[tabindex]:not([tabindex^="-"])'):void 0)||n).focus(),n=null),T(()=>{x(!0),c("hide",e)},t.transitionDuration)}function B(e){f=void 0,i!==void 0&&(i(),i=void 0),(e===!0||s.value===!0)&&(Pe(F),J(),H(h),R(P)),e!==!0&&(n=null)}function E(){(u.value!==null||t.scrollTarget!==void 0)&&(k.value=be(u.value,t.scrollTarget),G(k.value,r))}function p(e){v!==!0?(ye(g,e),c("click",e)):v=!1}function F(e){q.value===!0&&t.noFocus!==!0&&Oe(a.value,e.target)!==!0&&m()}function P(e){c("escapeKey"),S(e)}function r(){const e=a.value;e===null||u.value===null||Me({el:e,offset:t.offset,anchorEl:u.value,anchorOrigin:O.value,selfOrigin:$.value,absoluteOffset:f,fit:t.fit,cover:t.cover,maxHeight:t.maxHeight,maxWidth:t.maxWidth})}function ee(){return A(ke,U.value,()=>s.value===!0?A("div",{role:"menu",...d,ref:a,tabindex:-1,class:["q-menu q-position-engine scroll"+z.value,d.class],style:[d.style,j.value],...V.value},Te(Q.default)):null)}return Se(B),Object.assign(g,{focus:m,updatePosition:r}),Z}});export{Ke as Q};
|