Files
Hackathon_2025/ready/public/assets/QMenu-DcITW98M.js
2025-09-14 19:34:53 +02:00

2 lines
14 KiB
JavaScript

import{g as V,r as M,a3 as oe,a1 as le,e as he,X as me,w as S,o as qe,d as Q,_ as We,l as G,au as A,c as ve,B as $e,a6 as Le,h as D,av as Be,aw as Ae,ax as De,a as E,ae as Fe,ay as ze,$ as X,a2 as Qe,b as Oe,T as Re,aj as Ke,q as _e}from"./index-CoQ-x5A8.js";import{c as je}from"./selection-BGkpRqCo.js";import{i as Ie,u as Ge,s as Ne,a as Ve,e as Xe,b as Ue,g as Ye}from"./use-timeout-RziKd5AU.js";import{u as Je,a as Ze}from"./use-dark-dqtTUvyg.js";import{r as ie,b as et,a as tt}from"./focus-manager-BJWzFvJg.js";const nt={target:{type:[Boolean,String,Element],default:!0},noParentEvent:Boolean},ot={...nt,contextMenu:Boolean};function lt({showing:e,avoidEmit:t,configureAnchorEl:o}){const{props:n,proxy:l,emit:s}=V(),i=M(null);let f=null;function h(a){return i.value===null?!1:a===void 0||a.touches===void 0||a.touches.length<=1}const r={};o===void 0&&(Object.assign(r,{hide(a){l.hide(a)},toggle(a){l.toggle(a),a.qAnchorHandled=!0},toggleKey(a){me(a,13)===!0&&r.toggle(a)},contextClick(a){l.hide(a),oe(a),he(()=>{l.show(a),a.qAnchorHandled=!0})},prevent:oe,mobileTouch(a){if(r.mobileCleanup(a),h(a)!==!0)return;l.hide(a),i.value.classList.add("non-selectable");const c=a.target;le(r,"anchor",[[c,"touchmove","mobileCleanup","passive"],[c,"touchend","mobileCleanup","passive"],[c,"touchcancel","mobileCleanup","passive"],[i.value,"contextmenu","prevent","notPassive"]]),f=setTimeout(()=>{f=null,l.show(a),a.qAnchorHandled=!0},300)},mobileCleanup(a){i.value.classList.remove("non-selectable"),f!==null&&(clearTimeout(f),f=null),e.value===!0&&a!==void 0&&je()}}),o=function(a=n.contextMenu){if(n.noParentEvent===!0||i.value===null)return;let c;a===!0?l.$q.platform.is.mobile===!0?c=[[i.value,"touchstart","mobileTouch","passive"]]:c=[[i.value,"mousedown","hide","passive"],[i.value,"contextmenu","contextClick","notPassive"]]:c=[[i.value,"click","toggle","passive"],[i.value,"keyup","toggleKey","passive"]],le(r,"anchor",c)});function d(){We(r,"anchor")}function v(a){for(i.value=a;i.value.classList.contains("q-anchor--skip");)i.value=i.value.parentNode;o()}function g(){if(n.target===!1||n.target===""||l.$el.parentNode===null)i.value=null;else if(n.target===!0)v(l.$el.parentNode);else{let a=n.target;if(typeof n.target=="string")try{a=document.querySelector(n.target)}catch{a=void 0}a!=null?(i.value=a.$el||a,o()):(i.value=null,console.error(`Anchor: target "${n.target}" not found`))}}return S(()=>n.contextMenu,a=>{i.value!==null&&(d(),o(a))}),S(()=>n.target,()=>{i.value!==null&&d(),g()}),S(()=>n.noParentEvent,a=>{i.value!==null&&(a===!0?d():o())}),qe(()=>{g(),t!==!0&&n.modelValue===!0&&i.value===null&&s("update:modelValue",!1)}),Q(()=>{f!==null&&clearTimeout(f),d()}),{anchorEl:i,canShow:h,anchorEvents:r}}function it(e,t){const o=M(null);let n;function l(f,h){const r=`${h!==void 0?"add":"remove"}EventListener`,d=h!==void 0?h:n;f!==window&&f[r]("scroll",d,G.passive),window[r]("scroll",d,G.passive),n=h}function s(){o.value!==null&&(l(o.value),o.value=null)}const i=S(()=>e.noParentEvent,()=>{o.value!==null&&(s(),t())});return Q(i),{localScrollTarget:o,unconfigureScrollTarget:s,changeScrollEvent:l}}const H=[];function Ht(e){return H.find(t=>t.contentEl!==null&&t.contentEl.contains(e))}function ge(e,t){do{if(e.$options.name==="QMenu"){if(e.hide(t),e.$props.separateClosePopup===!0)return A(e)}else if(e.__qPortal===!0){const o=A(e);return o?.$options.name==="QPopupProxy"?(e.hide(t),o):e}e=A(e)}while(e!=null)}function Mt(e,t,o){for(;o!==0&&e!==void 0&&e!==null;){if(e.__qPortal===!0){if(o--,e.$options.name==="QMenu"){e=ge(e,t);continue}e.hide(t)}e=A(e)}}const at=ve({name:"QPortal",setup(e,{slots:t}){return()=>t.default()}});function ut(e){for(e=e.parent;e!=null;){if(e.type.name==="QGlobalDialog")return!0;if(e.type.name==="QDialog"||e.type.name==="QMenu")return!1;e=e.parent}return!1}function st(e,t,o,n){const l=M(!1),s=M(!1);let i=null;const f={},h=n==="dialog"&&ut(e);function r(v){if(v===!0){ie(f),s.value=!0;return}s.value=!1,l.value===!1&&(h===!1&&i===null&&(i=Ae(!1,n)),l.value=!0,H.push(e.proxy),et(f))}function d(v){if(s.value=!1,v!==!0)return;ie(f),l.value=!1;const g=H.indexOf(e.proxy);g!==-1&&H.splice(g,1),i!==null&&(De(i),i=null)}return $e(()=>{d(!0)}),e.proxy.__qPortal=!0,Le(e.proxy,"contentEl",()=>t.value),{showPortal:r,hidePortal:d,portalIsActive:l,portalIsAccessible:s,renderPortal:()=>h===!0?o():l.value===!0?[D(Be,{to:i},D(at,o))]:void 0}}const rt={transitionShow:{type:String,default:"fade"},transitionHide:{type:String,default:"fade"},transitionDuration:{type:[String,Number],default:300}};function ct(e,t=()=>{},o=()=>{}){return{transitionProps:E(()=>{const n=`q-transition--${e.transitionShow||t()}`,l=`q-transition--${e.transitionHide||o()}`;return{appear:!0,enterFromClass:`${n}-enter-from`,enterActiveClass:`${n}-enter-active`,enterToClass:`${n}-enter-to`,leaveFromClass:`${l}-leave-from`,leaveActiveClass:`${l}-leave-active`,leaveToClass:`${l}-leave-to`}}),transitionStyle:E(()=>`--q-transition-duration: ${e.transitionDuration}ms`)}}function ft(){let e;const t=V();function o(){e=void 0}return Fe(o),Q(o),{removeTick:o,registerTick(n){e=n,he(()=>{e===n&&(ze(t)===!1&&e(),e=void 0)})}}}const T=[];let q;function dt(e){q=e.keyCode===27}function ht(){q===!0&&(q=!1)}function mt(e){q===!0&&(q=!1,me(e,27)===!0&&T[T.length-1](e))}function be(e){window[e]("keydown",dt),window[e]("blur",ht),window[e]("keyup",mt),q=!1}function vt(e){X.is.desktop===!0&&(T.push(e),T.length===1&&be("addEventListener"))}function ae(e){const t=T.indexOf(e);t!==-1&&(T.splice(t,1),T.length===0&&be("removeEventListener"))}const P=[];function xe(e){P[P.length-1](e)}function gt(e){X.is.desktop===!0&&(P.push(e),P.length===1&&document.body.addEventListener("focusin",xe))}function bt(e){const t=P.indexOf(e);t!==-1&&(P.splice(t,1),P.length===0&&document.body.removeEventListener("focusin",xe))}const{notPassiveCapture:F}=G,C=[];function z(e){const t=e.target;if(t===void 0||t.nodeType===8||t.classList.contains("no-pointer-events")===!0)return;let o=H.length-1;for(;o>=0;){const n=H[o].$;if(n.type.name==="QTooltip"){o--;continue}if(n.type.name!=="QDialog")break;if(n.props.seamless!==!0)return;o--}for(let n=C.length-1;n>=0;n--){const l=C[n];if((l.anchorEl.value===null||l.anchorEl.value.contains(t)===!1)&&(t===document.body||l.innerRef.value!==null&&l.innerRef.value.contains(t)===!1))e.qClickOutside=!0,l.onClickOutside(e);else return}}function xt(e){C.push(e),C.length===1&&(document.addEventListener("mousedown",z,F),document.addEventListener("touchstart",z,F))}function ue(e){const t=C.findIndex(o=>o===e);t!==-1&&(C.splice(t,1),C.length===0&&(document.removeEventListener("mousedown",z,F),document.removeEventListener("touchstart",z,F)))}let se,re;function ce(e){const t=e.split(" ");return t.length!==2?!1:["top","center","bottom"].includes(t[0])!==!0?(console.error("Anchor/Self position must start with one of top/center/bottom"),!1):["left","middle","right","start","end"].includes(t[1])!==!0?(console.error("Anchor/Self position must end with one of left/middle/right/start/end"),!1):!0}function pt(e){return e?!(e.length!==2||typeof e[0]!="number"||typeof e[1]!="number"):!0}const N={"start#ltr":"left","start#rtl":"right","end#ltr":"right","end#rtl":"left"};["left","middle","right"].forEach(e=>{N[`${e}#ltr`]=e,N[`${e}#rtl`]=e});function fe(e,t){const o=e.split(" ");return{vertical:o[0],horizontal:N[`${o[1]}#${t===!0?"rtl":"ltr"}`]}}function wt(e,t){let{top:o,left:n,right:l,bottom:s,width:i,height:f}=e.getBoundingClientRect();return t!==void 0&&(o-=t[1],n-=t[0],s+=t[1],l+=t[0],i+=t[0],f+=t[1]),{top:o,bottom:s,height:f,left:n,right:l,width:i,middle:n+(l-n)/2,center:o+(s-o)/2}}function yt(e,t,o){let{top:n,left:l}=e.getBoundingClientRect();return n+=t.top,l+=t.left,o!==void 0&&(n+=o[1],l+=o[0]),{top:n,bottom:n+1,height:1,left:l,right:l+1,width:1,middle:l,center:n}}function Et(e,t){return{top:0,center:t/2,bottom:t,left:0,middle:e/2,right:e}}function de(e,t,o,n){return{top:e[o.vertical]-t[n.vertical],left:e[o.horizontal]-t[n.horizontal]}}function pe(e,t=0){if(e.targetEl===null||e.anchorEl===null||t>5)return;if(e.targetEl.offsetHeight===0||e.targetEl.offsetWidth===0){setTimeout(()=>{pe(e,t+1)},10);return}const{targetEl:o,offset:n,anchorEl:l,anchorOrigin:s,selfOrigin:i,absoluteOffset:f,fit:h,cover:r,maxHeight:d,maxWidth:v}=e;if(X.is.ios===!0&&window.visualViewport!==void 0){const k=document.body.style,{offsetLeft:x,offsetTop:p}=window.visualViewport;x!==se&&(k.setProperty("--q-pe-left",x+"px"),se=x),p!==re&&(k.setProperty("--q-pe-top",p+"px"),re=p)}const{scrollLeft:g,scrollTop:a}=o,c=f===void 0?wt(l,r===!0?[0,0]:n):yt(l,f,n);Object.assign(o.style,{top:0,left:0,minWidth:null,minHeight:null,maxWidth:v,maxHeight:d,visibility:"visible"});const{offsetWidth:L,offsetHeight:W}=o,{elWidth:B,elHeight:O}=h===!0||r===!0?{elWidth:Math.max(c.width,L),elHeight:r===!0?Math.max(c.height,W):W}:{elWidth:L,elHeight:W};let b={maxWidth:v,maxHeight:d};(h===!0||r===!0)&&(b.minWidth=c.width+"px",r===!0&&(b.minHeight=c.height+"px")),Object.assign(o.style,b);const w=Et(B,O);let m=de(c,w,s,i);if(f===void 0||n===void 0)I(m,c,w,s,i);else{const{top:k,left:x}=m;I(m,c,w,s,i);let p=!1;if(m.top!==k){p=!0;const y=2*n[1];c.center=c.top-=y,c.bottom-=y+2}if(m.left!==x){p=!0;const y=2*n[0];c.middle=c.left-=y,c.right-=y+2}p===!0&&(m=de(c,w,s,i),I(m,c,w,s,i))}b={top:m.top+"px",left:m.left+"px"},m.maxHeight!==void 0&&(b.maxHeight=m.maxHeight+"px",c.height>m.maxHeight&&(b.minHeight=b.maxHeight)),m.maxWidth!==void 0&&(b.maxWidth=m.maxWidth+"px",c.width>m.maxWidth&&(b.minWidth=b.maxWidth)),Object.assign(o.style,b),o.scrollTop!==a&&(o.scrollTop=a),o.scrollLeft!==g&&(o.scrollLeft=g)}function I(e,t,o,n,l){const s=o.bottom,i=o.right,f=Ie(),h=window.innerHeight-f,r=document.body.clientWidth;if(e.top<0||e.top+s>h)if(l.vertical==="center")e.top=t[n.vertical]>h/2?Math.max(0,h-s):0,e.maxHeight=Math.min(s,h);else if(t[n.vertical]>h/2){const d=Math.min(h,n.vertical==="center"?t.center:n.vertical===l.vertical?t.bottom:t.top);e.maxHeight=Math.min(s,d),e.top=Math.max(0,d-s)}else e.top=Math.max(0,n.vertical==="center"?t.center:n.vertical===l.vertical?t.top:t.bottom),e.maxHeight=Math.min(s,h-e.top);if(e.left<0||e.left+i>r)if(e.maxWidth=Math.min(i,r),l.horizontal==="middle")e.left=t[n.horizontal]>r/2?Math.max(0,r-i):0;else if(t[n.horizontal]>r/2){const d=Math.min(r,n.horizontal==="middle"?t.middle:n.horizontal===l.horizontal?t.right:t.left);e.maxWidth=Math.min(i,d),e.left=Math.max(0,d-e.maxWidth)}else e.left=Math.max(0,n.horizontal==="middle"?t.middle:n.horizontal===l.horizontal?t.left:t.right),e.maxWidth=Math.min(i,r-e.left)}const qt=ve({name:"QMenu",inheritAttrs:!1,props:{...ot,...Ve,...Je,...rt,persistent:Boolean,autoClose:Boolean,separateClosePopup:Boolean,noEscDismiss:Boolean,noRouteDismiss:Boolean,noRefocus:Boolean,noFocus:Boolean,fit:Boolean,cover:Boolean,square:Boolean,anchor:{type:String,validator:ce},self:{type:String,validator:ce},offset:{type:Array,validator:pt},scrollTarget:Ne,touchPosition:Boolean,maxHeight:{type:String,default:null},maxWidth:{type:String,default:null}},emits:[...Ge,"click","escapeKey"],setup(e,{slots:t,emit:o,attrs:n}){let l=null,s,i,f;const h=V(),{proxy:r}=h,{$q:d}=r,v=M(null),g=M(!1),a=E(()=>e.persistent!==!0&&e.noRouteDismiss!==!0),c=Ze(e,d),{registerTick:L,removeTick:W}=ft(),{registerTimeout:B}=Xe(),{transitionProps:O,transitionStyle:b}=ct(e),{localScrollTarget:w,changeScrollEvent:m,unconfigureScrollTarget:k}=it(e,te),{anchorEl:x,canShow:p}=lt({showing:g}),{hide:y}=Ue({showing:g,canShow:p,handleShow:Pe,handleHide:Ce,hideOnRouteChange:a,processOnMount:!0}),{showPortal:U,hidePortal:Y,renderPortal:we}=st(h,v,Se,"menu"),R={anchorEl:x,innerRef:v,onClickOutside(u){if(e.persistent!==!0&&g.value===!0)return y(u),(u.type==="touchstart"||u.target.classList.contains("q-dialog__backdrop"))&&_e(u),!0}},J=E(()=>fe(e.anchor||(e.cover===!0?"center middle":"bottom start"),d.lang.rtl)),ye=E(()=>e.cover===!0?J.value:fe(e.self||"top start",d.lang.rtl)),Ee=E(()=>(e.square===!0?" q-menu--square":"")+(c.value===!0?" q-menu--dark q-dark":"")),Te=E(()=>e.autoClose===!0?{onClick:ke}:{}),Z=E(()=>g.value===!0&&e.persistent!==!0);S(Z,u=>{u===!0?(vt(_),xt(R)):(ae(_),ue(R))});function K(){tt(()=>{let u=v.value;u&&u.contains(document.activeElement)!==!0&&(u=u.querySelector("[autofocus][tabindex], [data-autofocus][tabindex]")||u.querySelector("[autofocus] [tabindex], [data-autofocus] [tabindex]")||u.querySelector("[autofocus], [data-autofocus]")||u,u.focus({preventScroll:!0}))})}function Pe(u){if(l=e.noRefocus===!1?document.activeElement:null,gt(ne),U(),te(),s=void 0,u!==void 0&&(e.touchPosition||e.contextMenu)){const j=Qe(u);if(j.left!==void 0){const{top:He,left:Me}=x.value.getBoundingClientRect();s={left:j.left-Me,top:j.top-He}}}i===void 0&&(i=S(()=>d.screen.width+"|"+d.screen.height+"|"+e.self+"|"+e.anchor+"|"+d.lang.rtl,$)),e.noFocus!==!0&&document.activeElement.blur(),L(()=>{$(),e.noFocus!==!0&&K()}),B(()=>{d.platform.is.ios===!0&&(f=e.autoClose,v.value.click()),$(),U(!0),o("show",u)},e.transitionDuration)}function Ce(u){W(),Y(),ee(!0),l!==null&&(u===void 0||u.qClickOutside!==!0)&&(((u?.type.indexOf("key")===0?l.closest('[tabindex]:not([tabindex^="-"])'):void 0)||l).focus(),l=null),B(()=>{Y(!0),o("hide",u)},e.transitionDuration)}function ee(u){s=void 0,i!==void 0&&(i(),i=void 0),(u===!0||g.value===!0)&&(bt(ne),k(),ue(R),ae(_)),u!==!0&&(l=null)}function te(){(x.value!==null||e.scrollTarget!==void 0)&&(w.value=Ye(x.value,e.scrollTarget),m(w.value,$))}function ke(u){f!==!0?(ge(r,u),o("click",u)):f=!1}function ne(u){Z.value===!0&&e.noFocus!==!0&&Ke(v.value,u.target)!==!0&&K()}function _(u){e.noEscDismiss!==!0&&(o("escapeKey"),y(u))}function $(){pe({targetEl:v.value,offset:e.offset,anchorEl:x.value,anchorOrigin:J.value,selfOrigin:ye.value,absoluteOffset:s,fit:e.fit,cover:e.cover,maxHeight:e.maxHeight,maxWidth:e.maxWidth})}function Se(){return D(Re,O.value,()=>g.value===!0?D("div",{role:"menu",...n,ref:v,tabindex:-1,class:["q-menu q-position-engine scroll"+Ee.value,n.class],style:[n.style,b.value],...Te.value},Oe(t.default)):null)}return Q(ee),Object.assign(r,{focus:K,updatePosition:$}),we}});export{qt as Q,ft as a,ct as b,Mt as c,st as d,gt as e,vt as f,Ht as g,ae as h,bt as r,rt as u};