2 lines
20 KiB
JavaScript
2 lines
20 KiB
JavaScript
|
import{u as yr,S as Dr,c as Sr,a as Ir,d as c,e as d,m as p,v as Ar,n as kr,b as v,t as $,f as m,r as Pr}from"./index-Bq12SwZr.js";import{a as n,b as a,f as r,h as f,k as l,p as x,d as i,l as s,i as Hn,m as t,v as Vr}from"./lifecycle-DxKVJJp3.js";import{w as Lr}from"./index-DvU2gOtW.js";import{d as Tr}from"./XPro-BeAjQCpI.js";import{P as Gn,i as br,j as _r,B as Mr,R as qr,f as Er,k as Nr,l as zn,m as Ur,n as Fr,G as jr,o as Or,p as Br,q as Rr,L as Hr,r as Gr,s as zr,t as Qr,g as Wr,M as Kr,u as Xr,v as Yr}from"./ZoomOut24-DEQR2-6L.js";import"./runtime-5BIk_n0E.js";const Jr=Lr(void 0);function Zr(h,o){const{computePosition:S,autoUpdate:E,offset:L,shift:pe,flip:j,arrow:Ie,size:ve,autoPlacement:I,hide:Z,inline:T}=yr(Jr),w={open:!1,autoUpdateCleanup:()=>{}},Ct=':is(a[href], button, input, textarea, select, details, [tabindex]):not([tabindex="-1"])';let M;const O="https://www.skeleton.dev/utilities/popups";let u,q;function N(){u=document.querySelector(`[data-popup="${o.target}"]`)??document.createElement("div"),q=u.querySelector(".arrow")??document.createElement("div")}N();function k(){var C,U,F,Ae,$e,nt,A,B;if(!u)throw new Error(`The data-popup="${o.target}" element was not found. ${O}`);if(!S)throw new Error(`Floating UI 'computePosition' not found for data-popup="${o.target}". ${O}`);if(!L)throw new Error(`Floating UI 'offset' not found for data-popup="${o.target}". ${O}`);if(!pe)throw new Error(`Floating UI 'shift' not found for data-popup="${o.target}". ${O}`);if(!j)throw new Error(`Floating UI 'flip' not found for data-popup="${o.target}". ${O}`);if(!Ie)throw new Error(`Floating UI 'arrow' not found for data-popup="${o.target}". ${O}`);const g=[];ve&&g.push(ve((C=o.middleware)==null?void 0:C.size)),I&&g.push(I((U=o.middleware)==null?void 0:U.autoPlacement)),Z&&g.push(Z((F=o.middleware)==null?void 0:F.hide)),T&&g.push(T((Ae=o.middleware)==null?void 0:Ae.inline)),S(h,u,{placement:o.placement??"bottom",middleware:[L((($e=o.middleware)==null?void 0:$e.offset)??8),pe(((nt=o.middleware)==null?void 0:nt.shift)??{padding:8}),j((A=o.middleware)==null?void 0:A.flip),Ie(((B=o.middleware)==null?void 0:B.arrow)??{element:q||null}),...g]}).then(({x:ke,y:rt,placement:Ve,middlewareData:Pe})=>{if(Object.assign(u.style,{left:`${ke}px`,top:`${rt}px`}),q){const{x:R,y:me}=Pe.arrow,at={top:"bottom",right:"left",bottom:"top",left:"right"}[Ve.split("-")[0]];Object.assign(q.style,{left:R!=null?`${R}px`:"",top:me!=null?`${me}px`:"",right:"",bottom:"",[at]:"-4px"})}})}function tt(){u&&(w.open=!0,o.state&&o.state({state:w.open}),k(),u.style.display="block",u.style.opacity="1",u.style.pointerEvents="auto",u.removeAttribute("inert"),w.autoUpdateCleanup=E(h,u,k),M=Array.from(u==null?void 0:u.querySelectorAll(Ct)))}function _(g){if(!u)return;const C=parseFloat(window.getComputedStyle(u).transitionDuration.replace("s",""))*1e3;setTimeout(()=>{w.open=!1,o.state&&o.state({state:w.open}),u.style.opacity="0",u.setAttribute("inert",""),w.autoUpdateCleanup&&w.autoUpdateCleanup(),g&&g()},C)}function bt(){w.open===!1?tt():_()}function _t(g){if(w.open===!1||h.contains(g.target))return;if(u&&u.contains(g.target)===!1){_();return}const C=o.closeQuery===void 0?"a[href], button":o.closeQuery;if(C==="")return;const U=u==null?void 0:u.querySelectorAll(C);U==null||U.forEach(F=>{F.contains(g.target)&&_()})}const et=g=>{if(w.open===!1)return;const C=g.key;if(C==="Escape"){g.preventDefault(),h.focus(),_();return}M=Array.from(u==null?void 0:u.querySelectorAll(Ct)),w.open&&document.activeElement===h&&(C==="ArrowDown"||C==="Tab")&&Ct.length>0&&M.length>0&&(g.preventDefault(),M[0].focus())};switch(o.event){case"click":h.addEventListener("click",bt,!0),window.addEventListener("click",_t,!0);break;case"hover":h.addEventListener("mouseover",tt,!0),h.addEventListener("mouseleave",()=>_(),!0);break;case"focus-blur":h.addEventListener("focus",bt,!0),h.addEventListener("blur",()=>_(),!0);break;case"focus-click":h.addEventListener("focus",tt,!0),window.addEventListener("click",_t,!0);break;default:throw new Error(`Event value of '${o.event}' is not supported. ${O}`)}return window.a
|