Files
bruno/app/dist/spa/assets/QMenu-MNqKCtrf.js
2026-02-19 18:54:57 +01:00

2 lines
3.8 KiB
JavaScript

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