2 lines
6.7 KiB
JavaScript
2 lines
6.7 KiB
JavaScript
![]() |
import{c as z}from"./selection.2a17b691.js";import{k as E,as as k,at as w,z as S,an as y,d as f,e as $,f as M,h as q,am as A,l as x,au as H,av as B,p as P}from"./app-014d9ed9.js";const N={target:{default:!0},noParentEvent:Boolean,contextMenu:Boolean};function O({showing:e,avoidEmit:t,configureAnchorEl:a}){const{props:l,proxy:n,emit:s}=q(),i=E(null);let c;function u(o){return i.value===null?!1:o===void 0||o.touches===void 0||o.touches.length<=1}const r={};a===void 0&&(Object.assign(r,{hide(o){n.hide(o)},toggle(o){n.toggle(o),o.qAnchorHandled=!0},toggleKey(o){k(o,13)===!0&&r.toggle(o)},contextClick(o){n.hide(o),w(o),S(()=>{n.show(o),o.qAnchorHandled=!0})},prevent:w,mobileTouch(o){if(r.mobileCleanup(o),u(o)!==!0)return;n.hide(o),i.value.classList.add("non-selectable");const h=o.target;y(r,"anchor",[[h,"touchmove","mobileCleanup","passive"],[h,"touchend","mobileCleanup","passive"],[h,"touchcancel","mobileCleanup","passive"],[i.value,"contextmenu","prevent","notPassive"]]),c=setTimeout(()=>{n.show(o),o.qAnchorHandled=!0},300)},mobileCleanup(o){i.value.classList.remove("non-selectable"),clearTimeout(c),e.value===!0&&o!==void 0&&z()}}),a=function(o=l.contextMenu){if(l.noParentEvent===!0||i.value===null)return;let h;o===!0?n.$q.platform.is.mobile===!0?h=[[i.value,"touchstart","mobileTouch","passive"]]:h=[[i.value,"mousedown","hide","passive"],[i.value,"contextmenu","contextClick","notPassive"]]:h=[[i.value,"click","toggle","passive"],[i.value,"keyup","toggleKey","passive"]],y(r,"anchor",h)});function d(){A(r,"anchor")}function C(o){for(i.value=o;i.value.classList.contains("q-anchor--skip");)i.value=i.value.parentNode;a()}function b(){if(l.target===!1||l.target===""||n.$el.parentNode===null)i.value=null;else if(l.target===!0)C(n.$el.parentNode);else{let o=l.target;if(typeof l.target=="string")try{o=document.querySelector(l.target)}catch{o=void 0}o!=null?(i.value=o.$el||o,a()):(i.value=null,console.error(`Anchor: target "${l.target}" not found`))}}return f(()=>l.contextMenu,o=>{i.value!==null&&(d(),a(o))}),f(()=>l.target,()=>{i.value!==null&&d(),b()}),f(()=>l.noParentEvent,o=>{i.value!==null&&(o===!0?d():a())}),$(()=>{b(),t!==!0&&l.modelValue===!0&&i.value===null&&s("update:modelValue",!1)}),M(()=>{clearTimeout(c),d()}),{anchorEl:i,canShow:u,anchorEvents:r}}function D(e,t){const a=E(null);let l;function n(c,u){const r=`${u!==void 0?"add":"remove"}EventListener`,d=u!==void 0?u:l;c!==window&&c[r]("scroll",d,x.passive),window[r]("scroll",d,x.passive),l=u}function s(){a.value!==null&&(n(a.value),a.value=null)}const i=f(()=>e.noParentEvent,()=>{a.value!==null&&(s(),t())});return M(i),{localScrollTarget:a,unconfigureScrollTarget:s,changeScrollEvent:n}}let L;const{notPassiveCapture:v}=x,m=[];function p(e){clearTimeout(L);const t=e.target;if(t===void 0||t.nodeType===8||t.classList.contains("no-pointer-events")===!0)return;let a=H.length-1;for(;a>=0;){const l=H[a].$;if(l.type.name!=="QDialog")break;if(l.props.seamless!==!0)return;a--}for(let l=m.length-1;l>=0;l--){const n=m[l];if((n.anchorEl.value===null||n.anchorEl.value.contains(t)===!1)&&(t===document.body||n.innerRef.value!==null&&n.innerRef.value.contains(t)===!1))e.qClickOutside=!0,n.onClickOutside(e);else return}}function F(e){m.push(e),m.length===1&&(document.addEventListener("mousedown",p,v),document.addEventListener("touchstart",p,v))}function Q(e){const t=m.findIndex(a=>a===e);t>-1&&(m.splice(t,1),m.length===0&&(clearTimeout(L),document.removeEventListener("mousedown",p,v),document.removeEventListener("touchstart",p,v)))}let W,T;function U(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 X(e){return e?!(e.length!==2||typeof e[0]!="number"||typeof e[1]!="number"):!0}const g={"start#ltr":"left","start#rtl":"right","end#ltr":"right","end#rtl":"left"};["left","middle","right"].forEach(e=>{g[`${e
|