jingcai-html-dist/public/buyer/assets/QMenu.94ee8153.js

2 lines
11 KiB
JavaScript

import{r as p,aJ as xe,a1 as Q,O as be,$ as V,w as y,L as ye,o as P,g as G,a4 as Te,M as W,aK as j,X as pe,k as we,c as Ce,aL as ke,aC as Se,aM as Ee,aN as Me,a as b,aD as He,aO as We,aP as qe,aQ as Pe,aR as Le,aS as Oe,aT as Be,a3 as Ae,aU as ze,aV as N,S as $e,aW as Fe,h as X,b as Re,aX as De,aY as Ke,ax as Qe,aZ as Ve,a5 as je}from"./index.7df25f12.js";import{c as Ne}from"./selection.c52745bf.js";const Xe={target:{default:!0},noParentEvent:Boolean,contextMenu:Boolean};function Ie({showing:e,avoidEmit:n,configureAnchorEl:i}){const{props:t,proxy:l,emit:c}=G(),o=p(null);let d=null;function f(a){return o.value===null?!1:a===void 0||a.touches===void 0||a.touches.length<=1}const r={};i===void 0&&(Object.assign(r,{hide(a){l.hide(a)},toggle(a){l.toggle(a),a.qAnchorHandled=!0},toggleKey(a){xe(a,13)===!0&&r.toggle(a)},contextClick(a){l.hide(a),Q(a),be(()=>{l.show(a),a.qAnchorHandled=!0})},prevent:Q,mobileTouch(a){if(r.mobileCleanup(a),f(a)!==!0)return;l.hide(a),o.value.classList.add("non-selectable");const h=a.target;V(r,"anchor",[[h,"touchmove","mobileCleanup","passive"],[h,"touchend","mobileCleanup","passive"],[h,"touchcancel","mobileCleanup","passive"],[o.value,"contextmenu","prevent","notPassive"]]),d=setTimeout(()=>{d=null,l.show(a),a.qAnchorHandled=!0},300)},mobileCleanup(a){o.value.classList.remove("non-selectable"),d!==null&&(clearTimeout(d),d=null),e.value===!0&&a!==void 0&&Ne()}}),i=function(a=t.contextMenu){if(t.noParentEvent===!0||o.value===null)return;let h;a===!0?l.$q.platform.is.mobile===!0?h=[[o.value,"touchstart","mobileTouch","passive"]]:h=[[o.value,"mousedown","hide","passive"],[o.value,"contextmenu","contextClick","notPassive"]]:h=[[o.value,"click","toggle","passive"],[o.value,"keyup","toggleKey","passive"]],V(r,"anchor",h)});function s(){Te(r,"anchor")}function v(a){for(o.value=a;o.value.classList.contains("q-anchor--skip");)o.value=o.value.parentNode;i()}function m(){if(t.target===!1||t.target===""||l.$el.parentNode===null)o.value=null;else if(t.target===!0)v(l.$el.parentNode);else{let a=t.target;if(typeof t.target=="string")try{a=document.querySelector(t.target)}catch{a=void 0}a!=null?(o.value=a.$el||a,i()):(o.value=null,console.error(`Anchor: target "${t.target}" not found`))}}return y(()=>t.contextMenu,a=>{o.value!==null&&(s(),i(a))}),y(()=>t.target,()=>{o.value!==null&&s(),m()}),y(()=>t.noParentEvent,a=>{o.value!==null&&(a===!0?s():i())}),ye(()=>{m(),n!==!0&&t.modelValue===!0&&o.value===null&&c("update:modelValue",!1)}),P(()=>{d!==null&&clearTimeout(d),s()}),{anchorEl:o,canShow:f,anchorEvents:r}}function Ye(e,n){const i=p(null);let t;function l(d,f){const r=`${f!==void 0?"add":"remove"}EventListener`,s=f!==void 0?f:t;d!==window&&d[r]("scroll",s,W.passive),window[r]("scroll",s,W.passive),t=f}function c(){i.value!==null&&(l(i.value),i.value=null)}const o=y(()=>e.noParentEvent,()=>{i.value!==null&&(c(),n())});return P(o),{localScrollTarget:i,unconfigureScrollTarget:c,changeScrollEvent:l}}const{notPassiveCapture:w}=W,g=[];function C(e){const n=e.target;if(n===void 0||n.nodeType===8||n.classList.contains("no-pointer-events")===!0)return;let i=j.length-1;for(;i>=0;){const t=j[i].$;if(t.type.name!=="QDialog")break;if(t.props.seamless!==!0)return;i--}for(let t=g.length-1;t>=0;t--){const l=g[t];if((l.anchorEl.value===null||l.anchorEl.value.contains(n)===!1)&&(n===document.body||l.innerRef.value!==null&&l.innerRef.value.contains(n)===!1))e.qClickOutside=!0,l.onClickOutside(e);else return}}function Ue(e){g.push(e),g.length===1&&(document.addEventListener("mousedown",C,w),document.addEventListener("touchstart",C,w))}function I(e){const n=g.findIndex(i=>i===e);n>-1&&(g.splice(n,1),g.length===0&&(document.removeEventListener("mousedown",C,w),document.removeEventListener("touchstart",C,w)))}let Y,U;function _(e){const n=e.split(" ");return n.length!==2?!1:["top","center","bottom"].includes(n[0])!==!0?(console.error("Anchor/Self position must start with one of top/center/bottom"),!1):["left","middle","right","start","end"].includes(n[1])!==!0?(console.error("Anchor/Self position must end with one of left/middle/right/start/end"),!1):!0}function _e(e){return e?!(e.length!==2||typeof e[0]!="number"||typeof e[1]!="number"):!0}const q={"start#ltr":"left","start#rtl":"right","end#ltr":"right","end#rtl":"left"};["left","middle","right"].forEach(e=>{q[`${e}#ltr`]=e,q[`${e}#rtl`]=e});function J(e,n){const i=e.split(" ");return{vertical:i[0],horizontal:q[`${i[1]}#${n===!0?"rtl":"ltr"}`]}}function Je(e,n){let{top:i,left:t,right:l,bottom:c,width:o,height:d}=e.getBoundingClientRect();return n!==void 0&&(i-=n[1],t-=n[0],c+=n[1],l+=n[0],o+=n[0],d+=n[1]),{top:i,bottom:c,height:d,left:t,right:l,width:o,middle:t+(l-t)/2,center:i+(c-i)/2}}function Ze(e,n,i){let{top:t,left:l}=e.getBoundingClientRect();return t+=n.top,l+=n.left,i!==void 0&&(t+=i[1],l+=i[0]),{top:t,bottom:t+1,height:1,left:l,right:l+1,width:1,middle:l,center:t}}function Ge(e){return{top:0,center:e.offsetHeight/2,bottom:e.offsetHeight,left:0,middle:e.offsetWidth/2,right:e.offsetWidth}}function Z(e,n,i){return{top:e[i.anchorOrigin.vertical]-n[i.selfOrigin.vertical],left:e[i.anchorOrigin.horizontal]-n[i.selfOrigin.horizontal]}}function et(e){if(pe.is.ios===!0&&window.visualViewport!==void 0){const d=document.body.style,{offsetLeft:f,offsetTop:r}=window.visualViewport;f!==Y&&(d.setProperty("--q-pe-left",f+"px"),Y=f),r!==U&&(d.setProperty("--q-pe-top",r+"px"),U=r)}const{scrollLeft:n,scrollTop:i}=e.el,t=e.absoluteOffset===void 0?Je(e.anchorEl,e.cover===!0?[0,0]:e.offset):Ze(e.anchorEl,e.absoluteOffset,e.offset);let l={maxHeight:e.maxHeight,maxWidth:e.maxWidth,visibility:"visible"};(e.fit===!0||e.cover===!0)&&(l.minWidth=t.width+"px",e.cover===!0&&(l.minHeight=t.height+"px")),Object.assign(e.el.style,l);const c=Ge(e.el);let o=Z(t,c,e);if(e.absoluteOffset===void 0||e.offset===void 0)H(o,t,c,e.anchorOrigin,e.selfOrigin);else{const{top:d,left:f}=o;H(o,t,c,e.anchorOrigin,e.selfOrigin);let r=!1;if(o.top!==d){r=!0;const s=2*e.offset[1];t.center=t.top-=s,t.bottom-=s+2}if(o.left!==f){r=!0;const s=2*e.offset[0];t.middle=t.left-=s,t.right-=s+2}r===!0&&(o=Z(t,c,e),H(o,t,c,e.anchorOrigin,e.selfOrigin))}l={top:o.top+"px",left:o.left+"px"},o.maxHeight!==void 0&&(l.maxHeight=o.maxHeight+"px",t.height>o.maxHeight&&(l.minHeight=l.maxHeight)),o.maxWidth!==void 0&&(l.maxWidth=o.maxWidth+"px",t.width>o.maxWidth&&(l.minWidth=l.maxWidth)),Object.assign(e.el.style,l),e.el.scrollTop!==i&&(e.el.scrollTop=i),e.el.scrollLeft!==n&&(e.el.scrollLeft=n)}function H(e,n,i,t,l){const c=i.bottom,o=i.right,d=we(),f=window.innerHeight-d,r=document.body.clientWidth;if(e.top<0||e.top+c>f)if(l.vertical==="center")e.top=n[t.vertical]>f/2?Math.max(0,f-c):0,e.maxHeight=Math.min(c,f);else if(n[t.vertical]>f/2){const s=Math.min(f,t.vertical==="center"?n.center:t.vertical===l.vertical?n.bottom:n.top);e.maxHeight=Math.min(c,s),e.top=Math.max(0,s-c)}else e.top=Math.max(0,t.vertical==="center"?n.center:t.vertical===l.vertical?n.top:n.bottom),e.maxHeight=Math.min(c,f-e.top);if(e.left<0||e.left+o>r)if(e.maxWidth=Math.min(o,r),l.horizontal==="middle")e.left=n[t.horizontal]>r/2?Math.max(0,r-o):0;else if(n[t.horizontal]>r/2){const s=Math.min(r,t.horizontal==="middle"?n.middle:t.horizontal===l.horizontal?n.right:n.left);e.maxWidth=Math.min(o,s),e.left=Math.max(0,s-e.maxWidth)}else e.left=Math.max(0,t.horizontal==="middle"?n.middle:t.horizontal===l.horizontal?n.left:n.right),e.maxWidth=Math.min(o,r-e.left)}var ot=Ce({name:"QMenu",inheritAttrs:!1,props:{...Xe,...ke,...Se,...Ee,persistent:Boolean,autoClose:Boolean,separateClosePopup:Boolean,noRouteDismiss:Boolean,noRefocus:Boolean,noFocus:Boolean,fit:Boolean,cover:Boolean,square:Boolean,anchor:{type:String,validator:_},self:{type:String,validator:_},offset:{type:Array,validator:_e},scrollTarget:{default:void 0},touchPosition:Boolean,maxHeight:{type:String,default:null},maxWidth:{type:String,default:null}},emits:[...Me,"click","escapeKey"],setup(e,{slots:n,emit:i,attrs:t}){let l=null,c,o,d;const f=G(),{proxy:r}=f,{$q:s}=r,v=p(null),m=p(!1),a=b(()=>e.persistent!==!0&&e.noRouteDismiss!==!0),h=He(e,s),{registerTick:ee,removeTick:te}=We(),{registerTimeout:L}=qe(),{transitionProps:ne,transitionStyle:oe}=Pe(e),{localScrollTarget:O,changeScrollEvent:le,unconfigureScrollTarget:ie}=Ye(e,D),{anchorEl:x,canShow:ae}=Ie({showing:m}),{hide:B}=Le({showing:m,canShow:ae,handleShow:de,handleHide:fe,hideOnRouteChange:a,processOnMount:!0}),{showPortal:A,hidePortal:z,renderPortal:ue}=Oe(f,v,ve,"menu"),k={anchorEl:x,innerRef:v,onClickOutside(u){if(e.persistent!==!0&&m.value===!0)return B(u),(u.type==="touchstart"||u.target.classList.contains("q-dialog__backdrop"))&&je(u),!0}},$=b(()=>J(e.anchor||(e.cover===!0?"center middle":"bottom start"),s.lang.rtl)),re=b(()=>e.cover===!0?$.value:J(e.self||"top start",s.lang.rtl)),se=b(()=>(e.square===!0?" q-menu--square":"")+(h.value===!0?" q-menu--dark q-dark":"")),ce=b(()=>e.autoClose===!0?{onClick:he}:{}),F=b(()=>m.value===!0&&e.persistent!==!0);y(F,u=>{u===!0?(Ke(E),Ue(k)):(N(E),I(k))});function S(){Qe(()=>{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 de(u){if(l=e.noRefocus===!1?document.activeElement:null,Be(K),A(),D(),c=void 0,u!==void 0&&(e.touchPosition||e.contextMenu)){const M=Ae(u);if(M.left!==void 0){const{top:me,left:ge}=x.value.getBoundingClientRect();c={left:M.left-ge,top:M.top-me}}}o===void 0&&(o=y(()=>s.screen.width+"|"+s.screen.height+"|"+e.self+"|"+e.anchor+"|"+s.lang.rtl,T)),e.noFocus!==!0&&document.activeElement.blur(),ee(()=>{T(),e.noFocus!==!0&&S()}),L(()=>{s.platform.is.ios===!0&&(d=e.autoClose,v.value.click()),T(),A(!0),i("show",u)},e.transitionDuration)}function fe(u){te(),z(),R(!0),l!==null&&(u===void 0||u.qClickOutside!==!0)&&(((u&&u.type.indexOf("key")===0?l.closest('[tabindex]:not([tabindex^="-"])'):void 0)||l).focus(),l=null),L(()=>{z(!0),i("hide",u)},e.transitionDuration)}function R(u){c=void 0,o!==void 0&&(o(),o=void 0),(u===!0||m.value===!0)&&(ze(K),ie(),I(k),N(E)),u!==!0&&(l=null)}function D(){(x.value!==null||e.scrollTarget!==void 0)&&(O.value=$e(x.value,e.scrollTarget),le(O.value,T))}function he(u){d!==!0?(Fe(r,u),i("click",u)):d=!1}function K(u){F.value===!0&&e.noFocus!==!0&&Ve(v.value,u.target)!==!0&&S()}function E(u){i("escapeKey"),B(u)}function T(){const u=v.value;u===null||x.value===null||et({el:u,offset:e.offset,anchorEl:x.value,anchorOrigin:$.value,selfOrigin:re.value,absoluteOffset:c,fit:e.fit,cover:e.cover,maxHeight:e.maxHeight,maxWidth:e.maxWidth})}function ve(){return X(De,ne.value,()=>m.value===!0?X("div",{role:"menu",...t,ref:v,tabindex:-1,class:["q-menu q-position-engine scroll"+se.value,t.class],style:[t.style,oe.value],...ce.value},Re(n.default)):null)}return P(R),Object.assign(r,{focus:S,updatePosition:T}),ue}});export{ot as Q,Ie as a,Xe as u};