2 lines
9.5 KiB
JavaScript
2 lines
9.5 KiB
JavaScript
import{b2 as Y,g as F,r as R,E as C,C as k,j as J,al as Q,w as H,o as X,f as j,z as G,l as T,b3 as z,A as N,Y as U,n as w,b4 as Z,b5 as O}from"./index-GXFLJtQL.js";function tt(){if(window.getSelection!==void 0){const t=window.getSelection();t.empty!==void 0?t.empty():t.removeAllRanges!==void 0&&(t.removeAllRanges(),Y.is.mobile!==!0&&t.addRange(document.createRange()))}else document.selection!==void 0&&document.selection.empty()}const et={target:{type:[Boolean,String,Element],default:!0},noParentEvent:Boolean},dt={...et,contextMenu:Boolean};function ht({showing:t,avoidEmit:e,configureAnchorEl:l}){const{props:n,proxy:i,emit:c}=F(),o=R(null);let a=null;function f(r){return o.value===null?!1:r===void 0||r.touches===void 0||r.touches.length<=1}const s={};l===void 0&&(Object.assign(s,{hide(r){i.hide(r)},toggle(r){i.toggle(r),r.qAnchorHandled=!0},toggleKey(r){Q(r,13)===!0&&s.toggle(r)},contextClick(r){i.hide(r),C(r),J(()=>{i.show(r),r.qAnchorHandled=!0})},prevent:C,mobileTouch(r){if(s.mobileCleanup(r),f(r)!==!0)return;i.hide(r),o.value.classList.add("non-selectable");const u=r.target;k(s,"anchor",[[u,"touchmove","mobileCleanup","passive"],[u,"touchend","mobileCleanup","passive"],[u,"touchcancel","mobileCleanup","passive"],[o.value,"contextmenu","prevent","notPassive"]]),a=setTimeout(()=>{a=null,i.show(r),r.qAnchorHandled=!0},300)},mobileCleanup(r){o.value.classList.remove("non-selectable"),a!==null&&(clearTimeout(a),a=null),t.value===!0&&r!==void 0&&tt()}}),l=function(r=n.contextMenu){if(n.noParentEvent===!0||o.value===null)return;let u;r===!0?i.$q.platform.is.mobile===!0?u=[[o.value,"touchstart","mobileTouch","passive"]]:u=[[o.value,"mousedown","hide","passive"],[o.value,"contextmenu","contextClick","notPassive"]]:u=[[o.value,"click","toggle","passive"],[o.value,"keyup","toggleKey","passive"]],k(s,"anchor",u)});function d(){G(s,"anchor")}function _(r){for(o.value=r;o.value.classList.contains("q-anchor--skip");)o.value=o.value.parentNode;l()}function p(){if(n.target===!1||n.target===""||i.$el.parentNode===null)o.value=null;else if(n.target===!0)_(i.$el.parentNode);else{let r=n.target;if(typeof n.target=="string")try{r=document.querySelector(n.target)}catch{r=void 0}r!=null?(o.value=r.$el||r,l()):(o.value=null,console.error(`Anchor: target "${n.target}" not found`))}}return H(()=>n.contextMenu,r=>{o.value!==null&&(d(),l(r))}),H(()=>n.target,()=>{o.value!==null&&d(),p()}),H(()=>n.noParentEvent,r=>{o.value!==null&&(r===!0?d():l())}),X(()=>{p(),e!==!0&&n.modelValue===!0&&o.value===null&&c("update:modelValue",!1)}),j(()=>{a!==null&&clearTimeout(a),d()}),{anchorEl:o,canShow:f,anchorEvents:s}}function mt(t,e){const l=R(null);let n;function i(a,f){const s=`${f!==void 0?"add":"remove"}EventListener`,d=f!==void 0?f:n;a!==window&&a[s]("scroll",d,T.passive),window[s]("scroll",d,T.passive),n=f}function c(){l.value!==null&&(i(l.value),l.value=null)}const o=H(()=>t.noParentEvent,()=>{l.value!==null&&(c(),e())});return j(o),{localScrollTarget:l,unconfigureScrollTarget:c,changeScrollEvent:i}}const{notPassiveCapture:S}=T,v=[];function W(t){const e=t.target;if(e===void 0||e.nodeType===8||e.classList.contains("no-pointer-events")===!0)return;let l=z.length-1;for(;l>=0;){const n=z[l].$;if(n.type.name==="QTooltip"){l--;continue}if(n.type.name!=="QDialog")break;if(n.props.seamless!==!0)return;l--}for(let n=v.length-1;n>=0;n--){const i=v[n];if((i.anchorEl.value===null||i.anchorEl.value.contains(e)===!1)&&(e===document.body||i.innerRef.value!==null&&i.innerRef.value.contains(e)===!1))t.qClickOutside=!0,i.onClickOutside(t);else return}}function gt(t){v.push(t),v.length===1&&(document.addEventListener("mousedown",W,S),document.addEventListener("touchstart",W,S))}function vt(t){const e=v.findIndex(l=>l===t);e!==-1&&(v.splice(e,1),v.length===0&&(document.removeEventListener("mousedown",W,S),document.removeEventListener("touchstart",W,S)))}let A,B;function pt(t){const e=t.split(" ");return e.length!==2?!1:["top","center","bottom"].includes(e[0])!==!0?(console.error("Anchor/Self position must start with one of top/center/bottom"),!1):["left","middle","right","start","end"].includes(e[1])!==!0?(console.error("Anchor/Self position must end with one of left/middle/right/start/end"),!1):!0}function bt(t){return t?!(t.length!==2||typeof t[0]!="number"||typeof t[1]!="number"):!0}const I={"start#ltr":"left","start#rtl":"right","end#ltr":"right","end#rtl":"left"};["left","middle","right"].forEach(t=>{I[`${t}#ltr`]=t,I[`${t}#rtl`]=t});function xt(t,e){const l=t.split(" ");return{vertical:l[0],horizontal:I[`${l[1]}#${e===!0?"rtl":"ltr"}`]}}function nt(t,e){let{top:l,left:n,right:i,bottom:c,width:o,height:a}=t.getBoundingClientRect();return e!==void 0&&(l-=e[1],n-=e[0],c+=e[1],i+=e[0],o+=e[0],a+=e[1]),{top:l,bottom:c,height:a,left:n,right:i,width:o,middle:n+(i-n)/2,center:l+(c-l)/2}}function lt(t,e,l){let{top:n,left:i}=t.getBoundingClientRect();return n+=e.top,i+=e.left,l!==void 0&&(n+=l[1],i+=l[0]),{top:n,bottom:n+1,height:1,left:i,right:i+1,width:1,middle:i,center:n}}function ot(t,e){return{top:0,center:e/2,bottom:e,left:0,middle:t/2,right:t}}function $(t,e,l,n){return{top:t[l.vertical]-e[n.vertical],left:t[l.horizontal]-e[n.horizontal]}}function it(t,e=0){if(t.targetEl===null||t.anchorEl===null||e>5)return;if(t.targetEl.offsetHeight===0||t.targetEl.offsetWidth===0){setTimeout(()=>{it(t,e+1)},10);return}const{targetEl:l,offset:n,anchorEl:i,anchorOrigin:c,selfOrigin:o,absoluteOffset:a,fit:f,cover:s,maxHeight:d,maxWidth:_}=t;if(N.is.ios===!0&&window.visualViewport!==void 0){const E=document.body.style,{offsetLeft:x,offsetTop:g}=window.visualViewport;x!==A&&(E.setProperty("--q-pe-left",x+"px"),A=x),g!==B&&(E.setProperty("--q-pe-top",g+"px"),B=g)}const{scrollLeft:p,scrollTop:r}=l,u=a===void 0?nt(i,s===!0?[0,0]:n):lt(i,a,n);Object.assign(l.style,{top:0,left:0,minWidth:null,minHeight:null,maxWidth:_,maxHeight:d,visibility:"visible"});const{offsetWidth:L,offsetHeight:M}=l,{elWidth:V,elHeight:D}=f===!0||s===!0?{elWidth:Math.max(u.width,L),elHeight:s===!0?Math.max(u.height,M):M}:{elWidth:L,elHeight:M};let m={maxWidth:_,maxHeight:d};(f===!0||s===!0)&&(m.minWidth=u.width+"px",s===!0&&(m.minHeight=u.height+"px")),Object.assign(l.style,m);const b=ot(V,D);let h=$(u,b,c,o);if(a===void 0||n===void 0)q(h,u,b,c,o);else{const{top:E,left:x}=h;q(h,u,b,c,o);let g=!1;if(h.top!==E){g=!0;const y=2*n[1];u.center=u.top-=y,u.bottom-=y+2}if(h.left!==x){g=!0;const y=2*n[0];u.middle=u.left-=y,u.right-=y+2}g===!0&&(h=$(u,b,c,o),q(h,u,b,c,o))}m={top:h.top+"px",left:h.left+"px"},h.maxHeight!==void 0&&(m.maxHeight=h.maxHeight+"px",u.height>h.maxHeight&&(m.minHeight=m.maxHeight)),h.maxWidth!==void 0&&(m.maxWidth=h.maxWidth+"px",u.width>h.maxWidth&&(m.minWidth=m.maxWidth)),Object.assign(l.style,m),l.scrollTop!==r&&(l.scrollTop=r),l.scrollLeft!==p&&(l.scrollLeft=p)}function q(t,e,l,n,i){const c=l.bottom,o=l.right,a=U(),f=window.innerHeight-a,s=document.body.clientWidth;if(t.top<0||t.top+c>f)if(i.vertical==="center")t.top=e[n.vertical]>f/2?Math.max(0,f-c):0,t.maxHeight=Math.min(c,f);else if(e[n.vertical]>f/2){const d=Math.min(f,n.vertical==="center"?e.center:n.vertical===i.vertical?e.bottom:e.top);t.maxHeight=Math.min(c,d),t.top=Math.max(0,d-c)}else t.top=Math.max(0,n.vertical==="center"?e.center:n.vertical===i.vertical?e.top:e.bottom),t.maxHeight=Math.min(c,f-t.top);if(t.left<0||t.left+o>s)if(t.maxWidth=Math.min(o,s),i.horizontal==="middle")t.left=e[n.horizontal]>s/2?Math.max(0,s-o):0;else if(e[n.horizontal]>s/2){const d=Math.min(s,n.horizontal==="middle"?e.middle:n.horizontal===i.horizontal?e.right:e.left);t.maxWidth=Math.min(o,d),t.left=Math.max(0,d-t.maxWidth)}else t.left=Math.max(0,n.horizontal==="middle"?e.middle:n.horizontal===i.horizontal?e.left:e.right),t.maxWidth=Math.min(o,s-t.left)}const P=["B","KB","MB","GB","TB","PB"];function yt(t,e=1){let l=0;for(;parseInt(t,10)>=1024&&l<P.length-1;)t/=1024,++l;return`${t.toFixed(e)}${P[l]}`}function wt(t,e,l){return l<=e?e:Math.min(l,Math.max(e,t))}function _t(t,e,l){if(l<=e)return e;const n=l-e+1;let i=e+(t-e)%n;return i<e&&(i=n+i),i===0?0:i}function rt(t){return Z(t)===!0?"__q_date|"+t.getTime():O(t)===!0?"__q_expr|"+t.source:typeof t=="number"?"__q_numb|"+t:typeof t=="boolean"?"__q_bool|"+(t?"1":"0"):typeof t=="string"?"__q_strn|"+t:typeof t=="function"?"__q_strn|"+t.toString():t===Object(t)?"__q_objt|"+JSON.stringify(t):t}function at(t){if(t.length<9)return t;const l=t.substring(0,8),n=t.substring(9);switch(l){case"__q_date":const i=Number(n);return new Date(Number.isNaN(i)===!0?n:i);case"__q_expr":return new RegExp(n);case"__q_numb":return Number(n);case"__q_bool":return n==="1";case"__q_strn":return""+n;case"__q_objt":return JSON.parse(n);default:return t}}function st(){const t=()=>null;return{has:()=>!1,hasItem:()=>!1,getLength:()=>0,getItem:t,getIndex:t,getKey:t,getAll:()=>{},getAllKeys:()=>[],set:w,setItem:w,remove:w,removeItem:w,clear:w,isEmpty:()=>!0}}function ut(t){const e=window[t+"Storage"],l=o=>{const a=e.getItem(o);return a?at(a):null},n=o=>e.getItem(o)!==null,i=(o,a)=>{e.setItem(o,rt(a))},c=o=>{e.removeItem(o)};return{has:n,hasItem:n,getLength:()=>e.length,getItem:l,getIndex:o=>o<e.length?l(e.key(o)):null,getKey:o=>o<e.length?e.key(o):null,getAll:()=>{let o;const a={},f=e.length;for(let s=0;s<f;s++)o=e.key(s),a[o]=l(o);return a},getAllKeys:()=>{const o=[],a=e.length;for(let f=0;f<a;f++)o.push(e.key(f));return o},set:i,setItem:i,remove:c,removeItem:c,clear:()=>{e.clear()},isEmpty:()=>e.length===0}}const K=N.has.webStorage===!1?st():ut("local"),ct={install({$q:t}){t.localStorage=K}};Object.assign(ct,K);export{ct as P,pt as a,wt as b,tt as c,mt as d,ht as e,gt as f,et as g,yt as h,_t as n,xt as p,vt as r,it as s,dt as u,bt as v};
|