@zag-js/dom-utils
Advanced tools
Comparing version 0.0.0-dev-20220413091534 to 0.0.0-dev-20220413174154
@@ -5,1 +5,2 @@ declare type Booleanish = boolean | "true" | "false"; | ||
export {}; | ||
//# sourceMappingURL=attrs.d.ts.map |
export declare function autoResizeInput(input: HTMLInputElement | null): () => void; | ||
//# sourceMappingURL=auto-resize.d.ts.map |
@@ -7,1 +7,2 @@ declare type PointerEventOptions = { | ||
export {}; | ||
//# sourceMappingURL=body-pointer-event.d.ts.map |
@@ -8,1 +8,2 @@ interface PreventScrollOptions { | ||
export {}; | ||
//# sourceMappingURL=body-scroll-lock.d.ts.map |
@@ -7,1 +7,2 @@ declare type Key = keyof CSSStyleDeclaration | (string & {}); | ||
export {}; | ||
//# sourceMappingURL=computed-style.d.ts.map |
export declare const MAX_Z_INDEX = 2147483647; | ||
//# sourceMappingURL=constants.d.ts.map |
@@ -11,1 +11,2 @@ declare type DescriptorOptions = { | ||
export {}; | ||
//# sourceMappingURL=dispatch-event.d.ts.map |
@@ -12,1 +12,2 @@ declare type El = HTMLElement | Document | VisualViewport | Window; | ||
export {}; | ||
//# sourceMappingURL=event-bus.d.ts.map |
@@ -12,1 +12,2 @@ /** | ||
export {}; | ||
//# sourceMappingURL=focus-event.d.ts.map |
@@ -19,1 +19,2 @@ export declare const focusableSelector: string; | ||
export declare const isTabbable: (el: HTMLElement | null) => boolean; | ||
//# sourceMappingURL=focusable.d.ts.map |
export declare function getClosestFormElement(el: HTMLElement): HTMLFormElement; | ||
export declare function trackFormReset(el: HTMLElement | null | undefined, callback: () => void): () => void; | ||
//# sourceMappingURL=form.d.ts.map |
@@ -26,1 +26,2 @@ export * from "./attrs"; | ||
export * from "./wait"; | ||
//# sourceMappingURL=index.d.ts.map |
1165
dist/index.js
@@ -1,2 +0,1165 @@ | ||
var Ee=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var at=Object.prototype.hasOwnProperty;var lt=(e,t)=>{for(var n in t)Ee(e,n,{get:t[n],enumerable:!0})},ct=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of st(t))!at.call(e,o)&&o!==n&&Ee(e,o,{get:()=>t[o],enumerable:!(r=it(t,o))||r.enumerable});return e};var ut=e=>ct(Ee({},"__esModule",{value:!0}),e);var bn={};lt(bn,{MAX_Z_INDEX:()=>Qn,addDomEvent:()=>y,addPointerEvent:()=>V,addPointerlockChangeListener:()=>tt,addPointerlockErrorListener:()=>nt,ariaAttr:()=>dt,autoResizeInput:()=>Et,contains:()=>Kt,copyVisualStyles:()=>ye,createLiveRegion:()=>tn,dataAttr:()=>ft,disableTextSelection:()=>Oe,dispatchInputCheckedEvent:()=>jt,dispatchInputValueEvent:()=>_t,extractClientInfo:()=>Pt,extractInfo:()=>be,findByText:()=>ln,focusableSelector:()=>Pe,forceReflow:()=>pt,getClosestFormElement:()=>$e,getComputedStyle:()=>I,getDocumentElement:()=>Ft,getEventKey:()=>Qt,getEventName:()=>Ne,getEventStep:()=>en,getEventWindow:()=>Wt,getFocusables:()=>Ue,getNativeEvent:()=>Nt,getNodeName:()=>ie,getOwnerDocument:()=>F,getOwnerWindow:()=>M,getParent:()=>se,getPointerlockElement:()=>mn,getScrollOffset:()=>zt,getScrollParent:()=>q,getScrollParents:()=>qe,getTabbables:()=>Ut,indexOfId:()=>Ae,isDisabled:()=>ae,isFocusable:()=>ke,isHTMLElement:()=>L,isHidden:()=>le,isScrollParent:()=>Me,isTabbable:()=>Xe,isWindow:()=>j,itemById:()=>Ge,nextById:()=>Je,nextTick:()=>B,observeAttributes:()=>nn,observeChildren:()=>on,observeElementRect:()=>yn,prevById:()=>an,preventBodyPointerEvents:()=>Rt,preventBodyScroll:()=>Bt,query:()=>sn,queryAll:()=>rn,raf:()=>ve,requestPointerLock:()=>En,restoreTextSelection:()=>et,setVisuallyHidden:()=>Se,sortByTreeOrder:()=>cn,trackDocumentVisibility:()=>hn,trackFormReset:()=>$t,trackInputPropertyMutation:()=>qt,trackPointerDown:()=>un,trackPointerMove:()=>fn,validateBlur:()=>Yt,visuallyHiddenStyle:()=>Qe,waitFor:()=>gn,waitForEvent:()=>wn});module.exports=ut(bn);var ft=e=>e?"":void 0,dt=e=>e?!0:void 0;var Ve=new WeakMap;function I(e){var n;if(!e)return{};let t=Ve.get(e);return t||(t=((n=e==null?void 0:e.ownerDocument.defaultView)!=null?n:window).getComputedStyle(e),Ve.set(e,t)),t}function ye(e,t){if(!e)return;let n=I(e),r="box-sizing:"+n.boxSizing+";border-left:"+n.borderLeftWidth+" solid red;border-right:"+n.borderRightWidth+" solid red;font-family:"+n.fontFamily+";font-feature-settings:"+n.fontFeatureSettings+";font-kerning:"+n.fontKerning+";font-size:"+n.fontSize+";font-stretch:"+n.fontStretch+";font-style:"+n.fontStyle+";font-variant:"+n.fontVariant+";font-variant-caps:"+n.fontVariantCaps+";font-variant-ligatures:"+n.fontVariantLigatures+";font-variant-numeric:"+n.fontVariantNumeric+";font-weight:"+n.fontWeight+";letter-spacing:"+n.letterSpacing+";margin-left:"+n.marginLeft+";margin-right:"+n.marginRight+";padding-left:"+n.paddingLeft+";padding-right:"+n.paddingRight+";text-indent:"+n.textIndent+";text-transform:"+n.textTransform;t.style.cssText+=r}function B(e){let t=new Set;function n(r){let o=globalThis.requestAnimationFrame(r);t.add(()=>globalThis.cancelAnimationFrame(o))}return n(()=>n(e)),function(){t.forEach(function(o){o()})}}function ve(e){let t=globalThis.requestAnimationFrame(e);return function(){globalThis.cancelAnimationFrame(t)}}function pt(){return document.body.offsetHeight}function mt(e){var t=e.createElement("div");return t.id="ghost",t.style.cssText="display:inline-block;height:0;overflow:hidden;position:absolute;top:0;visibility:hidden;white-space:nowrap;",e.body.appendChild(t),t}function Et(e){var o;if(!e)return;let t=(o=e.ownerDocument)!=null?o:document,n=mt(t);ye(e,n);function r(){ve(()=>{n.innerHTML=e.value;let i=getComputedStyle(n);e==null||e.style.setProperty("width",i.width)})}return r(),e==null||e.addEventListener("input",r),e==null||e.addEventListener("change",r),()=>{t.body.removeChild(n),e==null||e.removeEventListener("input",r),e==null||e.removeEventListener("change",r)}}var Fe=e=>e,D=()=>{},x=(...e)=>t=>e.reduce((n,r)=>r(n),t);var Sn=(()=>{let e=0;return()=>(e++,e.toString(36))})();var he=e=>ge()&&e.test(navigator.platform);var ge=()=>typeof window<"u",yt=()=>he(/^Mac/),vt=()=>he(/^iPhone/),ht=()=>he(/^iPad/)||yt()&&navigator.maxTouchPoints>1,_=()=>vt()||ht();var gt=e=>Array.isArray(e);var wt=e=>!(e==null||typeof e!="object"||gt(e));var We=e=>wt(e)&&"button"in e;var ne=e=>e.button===0;var O=new Map,b=new Map;function Ke(e,t,n,r){var l;if(!e)return D;let o=JSON.stringify({type:t,options:r}),i=O.get(e);if(O.has(e))i!=null&&i.has(o)?(l=i==null?void 0:i.get(o))==null||l.add(n):i==null||i.set(o,new Set([n]));else{let u=new Map([[o,new Set([n])]]);O.set(e,u)}function s(u){var d,a;function c(m){var p;let E=O.get(u);(p=E==null?void 0:E.get(o))==null||p.forEach(w=>w(m))}if(!(b!=null&&b.has(u))){b.set(u,new Map([[o,c]])),u.addEventListener(t,c,r);return}(d=b==null?void 0:b.get(u))!=null&&d.has(o)||((a=b.get(u))==null||a.set(o,c),u.addEventListener(t,c,r))}return s(e),function(){var d,a,m,E;if(!O.has(e))return;let c=O.get(e);if((d=c==null?void 0:c.get(o))==null||d.delete(n),((a=c==null?void 0:c.get(o))==null?void 0:a.size)===0){let p=(m=b.get(e))==null?void 0:m.get(o);e.removeEventListener(t,p,r),c==null||c.delete(o),(E=b.get(e))==null||E.delete(o),(c==null?void 0:c.size)===0&&(O.delete(e),b.delete(e))}}}var we=e=>Object.prototype.toString.call(e).slice(8,-1),bt=e=>we(e)==="Object"&&"current"in e,Tt=e=>we(e)==="Function"?e():e,xt=e=>we(e)==="Object"&&!!e.touches,Lt={pageX:0,pageY:0,clientX:0,clientY:0};function be(e,t="page"){let n=xt(e)?e.touches[0]||e.changedTouches[0]||Lt:e;return{point:{x:n[`${t}X`],y:n[`${t}Y`]}}}function y(e,t,n,r){let o=bt(e)?e.current:Tt(e);return Ke(o,t,n,r)}function V(e,t,n,r){var i;let o=(i=Ne(t))!=null?i:t;return y(e,o,Mt(n,t==="pointerdown"),r)}function Mt(e,t=!1){let n=r=>{e(r,be(r))};return t?Ht(n):n}function Ht(e){return t=>{var i;let n=(i=t.view)!=null?i:window,r=t instanceof n.MouseEvent;(!r||r&&t.button===0)&&e(t)}}function Pt(e){return be(e,"client")}var kt=()=>typeof window!="undefined"&&window.onpointerdown===null,St=()=>typeof window!="undefined"&&window.ontouchstart===null,At=()=>typeof window!="undefined"&&window.onmousedown===null,Dt={pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointercancel:"mousecancel",pointerover:"mouseover",pointerout:"mouseout",pointerenter:"mouseenter",pointerleave:"mouseleave"},Ot={pointerdown:"touchstart",pointermove:"touchmove",pointerup:"touchend",pointercancel:"touchcancel"};function Ne(e){return kt()?e:St()?Ot[e]:At()?Dt[e]:e}var oe=0,ze;function Rt(e,t={}){let{disabled:n=!1,document:r}=t,o=r||document,i=!1,s=!1;function l(){let a=E=>{let p=E.pointerType==="mouse";i=!p,s=p&&ne(E)},m=()=>{i=!1,s=!1};return x(y(o,"pointerdown",a),y(o,"pointerup",m))}function u(){oe--,oe===0&&(o.body.style.pointerEvents=ze),e&&(e.style.pointerEvents="")}function c(){if(!n)return oe===0&&(ze=o.body.style.pointerEvents),o.body.style.pointerEvents="none",e&&(e.style.pointerEvents="auto"),oe++,function(){i?y(o,"click",u,{once:!0}):s?y(o,"pointerup",u,{once:!0}):u()}}let d=[];return d.push(c()),B(()=>{d.push(l())}),function(){d.forEach(a=>a==null?void 0:a())}}function Be(e){return typeof e=="object"&&e!=null&&e.nodeType===1}function _e(e,t){return(!t||e!=="hidden")&&e!=="visible"&&e!=="clip"}function Te(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return _e(n.overflowY,t)||_e(n.overflowX,t)||function(r){var o=function(i){if(!i.ownerDocument||!i.ownerDocument.defaultView)return null;try{return i.ownerDocument.defaultView.frameElement}catch{return null}}(r);return!!o&&(o.clientHeight<r.scrollHeight||o.clientWidth<r.scrollWidth)}(e)}return!1}function re(e,t,n,r,o,i,s,l){return i<e&&s>t||i>e&&s<t?0:i<=e&&l<=n||s>=t&&l>=n?i-e-r:s>t&&l<n||i<e&&l>n?s-t+o:0}function xe(e,t){var n=window,r=t.scrollMode,o=t.block,i=t.inline,s=t.boundary,l=t.skipOverflowHiddenElements,u=typeof s=="function"?s:function(rt){return rt!==s};if(!Be(e))throw new TypeError("Invalid target");for(var c=document.scrollingElement||document.documentElement,d=[],a=e;Be(a)&&u(a);){if((a=a.parentElement)===c){d.push(a);break}a!=null&&a===document.body&&Te(a)&&!Te(document.documentElement)||a!=null&&Te(a,l)&&d.push(a)}for(var m=n.visualViewport?n.visualViewport.width:innerWidth,E=n.visualViewport?n.visualViewport.height:innerHeight,p=window.scrollX||pageXOffset,w=window.scrollY||pageYOffset,T=e.getBoundingClientRect(),H=T.height,P=T.width,k=T.top,K=T.right,N=T.bottom,v=T.left,f=o==="start"||o==="nearest"?k:o==="end"?N:k+H/2,h=i==="center"?v+P/2:i==="end"?K:v,z=[],ue=0;ue<d.length;ue++){var g=d[ue],C=g.getBoundingClientRect(),fe=C.height,de=C.width,U=C.top,pe=C.right,me=C.bottom,X=C.left;if(r==="if-needed"&&k>=0&&v>=0&&N<=E&&K<=m&&k>=U&&N<=me&&v>=X&&K<=pe)return z;var $=getComputedStyle(g),Z=parseInt($.borderLeftWidth,10),Q=parseInt($.borderTopWidth,10),G=parseInt($.borderRightWidth,10),J=parseInt($.borderBottomWidth,10),S=0,A=0,ee="offsetWidth"in g?g.offsetWidth-g.clientWidth-Z-G:0,te="offsetHeight"in g?g.offsetHeight-g.clientHeight-Q-J:0;if(c===g)S=o==="start"?f:o==="end"?f-E:o==="nearest"?re(w,w+E,E,Q,J,w+f,w+f+H,H):f-E/2,A=i==="start"?h:i==="center"?h-m/2:i==="end"?h-m:re(p,p+m,m,Z,G,p+h,p+h+P,P),S=Math.max(0,S+w),A=Math.max(0,A+p);else{S=o==="start"?f-U-Q:o==="end"?f-me+J+te:o==="nearest"?re(U,me,fe,Q,J+te,f,f+H,H):f-(U+fe/2)+te/2,A=i==="start"?h-X-Z:i==="center"?h-(X+de/2)+ee/2:i==="end"?h-pe+G+ee:re(X,pe,de,Z,G+ee,h,h+P,P);var Ce=g.scrollLeft,Ie=g.scrollTop;f+=Ie-(S=Math.max(0,Math.min(Ie+S,g.scrollHeight-fe+te))),h+=Ce-(A=Math.max(0,Math.min(Ce+A,g.scrollWidth-de+ee)))}z.push({el:g,top:S,left:A})}return z}function je(e){return e===Object(e)&&Object.keys(e).length!==0}function Ct(e,t){t===void 0&&(t="auto");var n="scrollBehavior"in document.body.style;e.forEach(function(r){var o=r.el,i=r.top,s=r.left;o.scroll&&n?o.scroll({top:i,left:s,behavior:t}):(o.scrollTop=i,o.scrollLeft=s)})}function It(e){return e===!1?{block:"end",inline:"nearest"}:je(e)?e:{block:"start",inline:"nearest"}}function Vt(e,t){var n=e.isConnected||e.ownerDocument.documentElement.contains(e);if(je(t)&&typeof t.behavior=="function")return t.behavior(n?xe(e,t):[]);if(!!n){var r=It(t);return Ct(xe(e,r),r.behavior)}}var Le=Vt;function F(e){var t;return j(e)?e.document:(t=e==null?void 0:e.ownerDocument)!=null?t:document}function M(e){var t;return(t=e==null?void 0:e.ownerDocument.defaultView)!=null?t:window}function Ft(e){return F(e).documentElement}function ie(e){return j(e)?"":e&&e.localName||""}function Wt(e){if(e.view)return e.view;let t=e.currentTarget;return t!=null?M(t):window}function se(e){let t=F(e);return ie(e)==="html"?e:e.assignedSlot||e.parentElement||t.documentElement}function Kt(e,t){return e?e===t||L(e)&&L(t)&&e.contains(t):!1}function L(e){return typeof e=="object"&&(e==null?void 0:e.nodeType)===Node.ELEMENT_NODE&&typeof(e==null?void 0:e.nodeName)=="string"}function j(e){return(e==null?void 0:e.toString())==="[object Window]"}var ae=e=>(e==null?void 0:e.getAttribute("disabled"))!=null||!!(e!=null&&e.getAttribute("aria-disabled"));function Nt(e){var t;return(t=e.nativeEvent)!=null?t:e}function Me(e){let{overflow:t,overflowX:n,overflowY:r}=I(e);return/auto|scroll|overlay|hidden/.test(t+r+n)}function q(e){return["html","body","#document"].includes(ie(e))?F(e).body:L(e)&&Me(e)?e:q(se(e))}function qe(e,t=[]){let n=q(e),r=n===F(e).body,o=M(n),i=r?[o].concat(o.visualViewport||[],Me(n)?n:[]):n,s=t.concat(i);return r?s:s.concat(qe(se(i)))}function zt(e){return j(e)?{scrollLeft:e.scrollX,scrollTop:e.scrollY}:{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}var Ye=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function Bt(e){var d;let{document:t,disabled:n=!1,allowPinchZoom:r}=e!=null?e:{},o=t!=null?t:document,i=(d=o==null?void 0:o.defaultView)!=null?d:window,s=ge()?i.visualViewport:null,l=o.documentElement;function u(){let a=x(Y(l,"paddingRight",`${i.innerWidth-l.clientWidth}px`),Y(l,"overflow","hidden"));return()=>a==null?void 0:a()}function c(){let a,m=0,E=v=>{a=q(v.target),!(a===l&&a===o.body)&&(m=v.changedTouches[0].pageY)},p=v=>{if(v.touches.length===2&&r)return;if(!a||a===l||a===o.body){v.preventDefault();return}let f=v.changedTouches[0].pageY,h=a.scrollTop,z=a.scrollHeight-a.clientHeight;(h<=0&&f>m||h>=z&&f<m)&&v.preventDefault(),m=f},w=v=>{let f=v.target;f instanceof i.HTMLInputElement&&!Ye.has(f.type)&&(v.preventDefault(),f.style.transform="translateY(-2000px)",f.focus(),i.requestAnimationFrame(()=>{f.style.transform=""}))},T=v=>{let f=v.target;f instanceof i.HTMLInputElement&&!Ye.has(f.type)&&(f.style.transform="translateY(-2000px)",i.requestAnimationFrame(()=>{f.style.transform="",s&&(s.height<i.innerHeight?i.requestAnimationFrame(function(){Le(f,{scrollMode:"if-needed"})}):y(s,"resize",()=>{Le(f,{scrollMode:"if-needed"})},{once:!0}))}))},H=()=>{i.scrollTo(0,0)},P=i.scrollX,k=i.scrollY,K=x(Y(l,"paddingRight",`${i.innerWidth-l.clientWidth}px`),Y(l,"overflow","hidden"),Y(o.body,"marginTop",`-${k}px`));i.scrollTo(0,0);let N=x(y(o,"touchstart",E,{passive:!1,capture:!0}),y(o,"touchmove",p,{passive:!1,capture:!0}),y(o,"touchend",w,{passive:!1,capture:!0}),y(o,"focus",T,!0),y(i,"scroll",H));return()=>{K(),N(),i.scrollTo(P,k)}}return n?D:_()?c():u()}function Y(e,t,n){let r=e.style[t];return e.style[t]=n,()=>{e.style[t]=r}}var Qn=2147483647;function He(e,t){var l;let{type:n,property:r}=t,s=M(e)[n==="input"?"HTMLInputElement":"HTMLTextAreaElement"].prototype;return(l=Object.getOwnPropertyDescriptor(s,r))!=null?l:{}}function _t(e,t){var i;let n=M(e);if(!(e instanceof n.HTMLInputElement))return;(i=He(e,{type:"input",property:"value"}).set)==null||i.call(e,t);let o=new n.Event("input",{bubbles:!0});e.dispatchEvent(o)}function jt(e,t){var i;let n=M(e);if(!(e instanceof n.HTMLInputElement))return;(i=He(e,{type:"input",property:"checked"}).set)==null||i.call(e,t);let o=new n.Event("click",{bubbles:!0});e.dispatchEvent(o)}function qt(e,t){let{fn:n,property:r,type:o}=t;if(!n||!e)return;let{get:i,set:s}=He(e,{property:r,type:o}),l=!0;return Object.defineProperty(e,r,{get(){return i==null?void 0:i.call(this)},set(u){return l&&n(u),s==null?void 0:s.call(this,u)}}),function(){l=!1}}function Yt(e,t){var o;let n=Array.isArray(t.exclude)?t.exclude:[t.exclude],r=(o=e.relatedTarget)!=null?o:t.fallback;return n.every(i=>!(i!=null&&i.contains(r)))}var Pe=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","embed","iframe","object","a[href]","area[href]","[tabindex]","audio[controls]","video[controls]","*[tabindex]:not([aria-disabled])","[contenteditable]:not([contenteditable=false])","details > summary:first-of-type"].join(",");function le(e,t){let n=I(e);if(!e||n.getPropertyValue("visibility")==="hidden")return!0;for(;e;){if(t!=null&&e===t)return!1;if(n.getPropertyValue("display")==="none")return!0;e=e.parentElement}return!1}var Ue=(e,t=!1)=>{if(!e)return[];let n=Array.from(e.querySelectorAll(Pe));return t&&L(e)&&n.unshift(e),n.filter(r=>ke(r)&&!le(r))},ke=e=>!L(e)||le(e)||ae(e)?!1:e==null?void 0:e.matches(Pe),Ut=(e,t=!1)=>Ue(e,t).filter(Xe),Xe=e=>ke(e)&&!ae(e)&&!le(e);function $e(e){return Xt(e)?e.form:e.closest("form")}function Xt(e){return["textarea","input","select","button"].includes(e.localName)}function $t(e,t){if(!e)return;let n=$e(e);return n==null||n.addEventListener("reset",t,{passive:!0}),()=>{n==null||n.removeEventListener("reset",t)}}var Ze={ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft",Home:"End",End:"Home"},Zt={Up:"ArrowUp",Down:"ArrowDown",Esc:"Escape"," ":"Space",",":"Comma",Left:"ArrowLeft",Right:"ArrowRight"};function Qt(e,t={}){var s;let{dir:n="ltr",orientation:r="horizontal"}=t,{key:o}=e;return o=(s=Zt[o])!=null?s:o,n==="rtl"&&r==="horizontal"&&o in Ze&&(o=Ze[o]),o}var Gt=new Set(["PageUp","PageDown"]),Jt=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function en(e){return e.ctrlKey||e.metaKey?.1:Gt.has(e.key)||e.shiftKey&&Jt.has(e.key)?10:1}var Qe={border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"};function Se(e){Object.assign(e.style,Qe)}function tn(e={}){var d;let{level:t="polite",doc:n,root:r,delay:o=0}=e,i=n!=null?n:document,s=(d=i.defaultView)!=null?d:window,l=r!=null?r:i.body;function u(a,m){let E=i.getElementById("__live-region__");E&&l.removeChild(E),m=m!=null?m:o;let p=i.createElement("span");p.id="__live-region__";var w=t!=="assertive"?"status":"alert";p.setAttribute("aria-live",t),p.setAttribute("role",w),Se(p),l.appendChild(p),s.setTimeout(()=>{p.textContent=a},m)}function c(){let a=i.getElementById("__live-region__");a&&l.removeChild(a)}return{announce:u,destroy:c}}function nn(e,t,n){if(!e)return D;let r=Array.isArray(t)?t:[t],o=e.ownerDocument.defaultView||window,i=new o.MutationObserver(s=>{for(let l of s)l.type==="attributes"&&l.attributeName&&r.includes(l.attributeName)&&n(l)});return i.observe(e,{attributes:!0,attributeFilter:r}),()=>i.disconnect()}function on(e,t,n=!1){if(!e)return D;let r=e.ownerDocument.defaultView||window,o=new r.MutationObserver(i=>{for(let s of i)s.type==="childList"&&t(s)});return o.observe(e,{childList:!0,subtree:n}),()=>o.disconnect()}function rn(e,t){var n;return Array.from((n=e==null?void 0:e.querySelectorAll(t))!=null?n:[])}function sn(e,t){return e==null?void 0:e.querySelector(t)}function Ge(e,t){return e.find(n=>n.id===t)}function Ae(e,t){let n=Ge(e,t);return n?e.indexOf(n):-1}function Je(e,t,n=!0){let r=Ae(e,t);return r=n?(r+1)%e.length:Math.min(r+1,e.length-1),e[r]}function an(e,t,n=!0){let r=Ae(e,t);return r===-1?n?e[e.length-1]:null:(r=n?(r-1+e.length)%e.length:Math.max(0,r-1),e[r])}function ln(e,t,n){let r=e.filter(o=>{var s;let i=(s=o.dataset.valuetext)!=null?s:o.textContent;return!!(i!=null&&i.toLowerCase().startsWith(t.toLowerCase()))});return n?Je(r,n):null}function cn(e){return e.sort((t,n)=>t.compareDocumentPosition(n)&2?1:-1)}var W="default",De="",ce=new WeakMap;function Oe({target:e,doc:t}={}){let n=t!=null?t:document;return _()?(W==="default"&&(De=n.documentElement.style.webkitUserSelect,n.documentElement.style.webkitUserSelect="none"),W="disabled"):e&&(ce.set(e,e.style.userSelect),e.style.userSelect="none"),()=>et({target:e,doc:n})}function et({target:e,doc:t}={}){let n=t!=null?t:document;if(_()){if(W!=="disabled")return;W="restoring",setTimeout(()=>{B(()=>{W==="restoring"&&(n.documentElement.style.webkitUserSelect==="none"&&(n.documentElement.style.webkitUserSelect=De||""),De="",W="default")})},300)}else if(e&&ce.has(e)){let r=ce.get(e);e.style.userSelect==="none"&&(e.style.userSelect=r!=null?r:""),e.getAttribute("style")===""&&e.removeAttribute("style"),ce.delete(e)}}function un(e,t){var o;let n=(o=e.defaultView)!=null?o:window;return y(e,"pointerdown",i=>{i.target instanceof n.HTMLElement&&t(i.target)})}function fn(e){let{onPointerMove:t,onPointerUp:n,ctx:r}=e,{doc:o=document,threshold:i=5}=r;return x(V(o,"pointermove",(l,u)=>{let{point:c}=u;if(!(Math.sqrt(c.x**2+c.y**2)<i)){if(We(l)&&ne(l)){n();return}t(u,l)}},!1),V(o,"pointerup",n,!1),V(o,"pointercancel",n,!1),V(o,"contextmenu",n,!1),Oe({doc:o}))}function tt(e,t){return e.addEventListener("webkitpointerlockchange",t,!1),e.addEventListener("mozpointerlockchange",t,!1),e.addEventListener("pointerlockchange",t,!1),function(){e.removeEventListener("mozpointerlockchange",t,!1),e.removeEventListener("pointerlockchange",t,!1)}}function nt(e,t){return e.addEventListener("webkitpointerlockerror",t,!1),e.addEventListener("mozpointerlockerror",t,!1),e.addEventListener("pointerlockerror",t,!1),function(){e.removeEventListener("webkitpointerlockerror",t,!1),e.removeEventListener("mozpointerlockerror",t,!1),e.removeEventListener("pointerlockerror",t,!1)}}function dn(e){return e.requestPointerLock||e.mozRequestPointerLock||e.webkitRequestPointerLock}function pn(e){return e.exitPointerLock||e.mozExitPointerLock||e.webkitExitPointerLock}function mn(e){return e.pointerLockElement||e.mozPointerLockElement||e.webkitPointerLockElement}function En(e,t={}){let{onPointerLock:n,onPointerUnlock:r}=t,o=e.body;function i(){return"pointerLockElement"in e||"mozPointerLockElement"in e||"webkitPointerLockElement"in e}function s(){return!!e.pointerLockElement}function l(){s()?n==null||n():r==null||r()}function u(p){s()&&(r==null||r()),console.error("PointerLock error occured:",p),c()}function c(){e.exitPointerLock=pn(e),e.exitPointerLock()}let d=new Set;function a(){d.add(tt(e,l)),d.add(nt(e,u))}function m(){!i()||(d.forEach(p=>p()),d.clear(),c())}function E(){!i()||!s()||(o.requestPointerLock=dn(o),o.requestPointerLock(),a())}return E(),m}var R=new Map;function yn(e,t){let n=R.get(e);return n?(n.callbacks.push(t),t(e.getBoundingClientRect())):(R.set(e,{rect:{},callbacks:[t]}),R.size===1&&(Re=requestAnimationFrame(ot))),function(){let o=R.get(e);if(!o)return;let i=o.callbacks.indexOf(t);i>-1&&o.callbacks.splice(i,1),o.callbacks.length===0&&(R.delete(e),R.size===0&&cancelAnimationFrame(Re))}}var Re;function ot(){let e=[];R.forEach((t,n)=>{let r=n.getBoundingClientRect();vn(t.rect,r)||(t.rect=r,e.push(t))}),e.forEach(t=>{t.callbacks.forEach(n=>n(t.rect))}),Re=requestAnimationFrame(ot)}function vn(e,t){return e.width===t.width&&e.height===t.height&&e.top===t.top&&e.right===t.right&&e.bottom===t.bottom&&e.left===t.left}function hn(e,t){let n=Fe(e);return y(n,"visibilitychange",()=>{let r=n.hidden||n.msHidden||n.webkitHidden;t(!!r)})}function gn(e){let t=e();return t?Promise.resolve(t):new Promise(n=>{let r=globalThis.setInterval(function(){let o=e();o&&(globalThis.clearInterval(r),n(o))},0)})}function wn(e,t){return new Promise(n=>{function r(o){o.target===e&&(e.removeEventListener(t,r),n())}e.addEventListener(t,r)})} | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __pow = Math.pow; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
MAX_Z_INDEX: () => MAX_Z_INDEX, | ||
addDomEvent: () => addDomEvent, | ||
addPointerEvent: () => addPointerEvent, | ||
addPointerlockChangeListener: () => addPointerlockChangeListener, | ||
addPointerlockErrorListener: () => addPointerlockErrorListener, | ||
ariaAttr: () => ariaAttr, | ||
autoResizeInput: () => autoResizeInput, | ||
contains: () => contains, | ||
copyVisualStyles: () => copyVisualStyles, | ||
createLiveRegion: () => createLiveRegion, | ||
dataAttr: () => dataAttr, | ||
disableTextSelection: () => disableTextSelection, | ||
dispatchInputCheckedEvent: () => dispatchInputCheckedEvent, | ||
dispatchInputValueEvent: () => dispatchInputValueEvent, | ||
extractClientInfo: () => extractClientInfo, | ||
extractInfo: () => extractInfo, | ||
findByText: () => findByText, | ||
focusableSelector: () => focusableSelector, | ||
forceReflow: () => forceReflow, | ||
getClosestFormElement: () => getClosestFormElement, | ||
getComputedStyle: () => getComputedStyle2, | ||
getDocumentElement: () => getDocumentElement, | ||
getEventKey: () => getEventKey, | ||
getEventName: () => getEventName, | ||
getEventStep: () => getEventStep, | ||
getEventWindow: () => getEventWindow, | ||
getFocusables: () => getFocusables, | ||
getNativeEvent: () => getNativeEvent, | ||
getNodeName: () => getNodeName, | ||
getOwnerDocument: () => getOwnerDocument, | ||
getOwnerWindow: () => getOwnerWindow, | ||
getParent: () => getParent, | ||
getScrollOffset: () => getScrollOffset, | ||
getScrollParent: () => getScrollParent, | ||
getScrollParents: () => getScrollParents, | ||
getTabbables: () => getTabbables, | ||
indexOfId: () => indexOfId, | ||
isDisabled: () => isDisabled, | ||
isFocusable: () => isFocusable, | ||
isHTMLElement: () => isHTMLElement, | ||
isHidden: () => isHidden, | ||
isScrollParent: () => isScrollParent, | ||
isTabbable: () => isTabbable, | ||
isWindow: () => isWindow, | ||
itemById: () => itemById, | ||
nextById: () => nextById, | ||
nextTick: () => nextTick, | ||
observeAttributes: () => observeAttributes, | ||
observeChildren: () => observeChildren, | ||
observeElementRect: () => observeElementRect, | ||
prevById: () => prevById, | ||
preventBodyPointerEvents: () => preventBodyPointerEvents, | ||
preventBodyScroll: () => preventBodyScroll, | ||
query: () => query, | ||
queryAll: () => queryAll, | ||
raf: () => raf, | ||
requestPointerLock: () => requestPointerLock, | ||
restoreTextSelection: () => restoreTextSelection, | ||
setVisuallyHidden: () => setVisuallyHidden, | ||
sortByTreeOrder: () => sortByTreeOrder, | ||
trackDocumentVisibility: () => trackDocumentVisibility, | ||
trackFormReset: () => trackFormReset, | ||
trackInputPropertyMutation: () => trackInputPropertyMutation, | ||
trackPointerDown: () => trackPointerDown, | ||
trackPointerMove: () => trackPointerMove, | ||
validateBlur: () => validateBlur, | ||
visuallyHiddenStyle: () => visuallyHiddenStyle, | ||
waitFor: () => waitFor, | ||
waitForEvent: () => waitForEvent | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
// src/attrs.ts | ||
var dataAttr = (guard) => { | ||
return guard ? "" : void 0; | ||
}; | ||
var ariaAttr = (guard) => { | ||
return guard ? true : void 0; | ||
}; | ||
// src/computed-style.ts | ||
var styleCache = /* @__PURE__ */ new WeakMap(); | ||
function getComputedStyle2(el) { | ||
var _a; | ||
if (!el) | ||
return {}; | ||
let style = styleCache.get(el); | ||
if (!style) { | ||
const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window; | ||
style = win.getComputedStyle(el); | ||
styleCache.set(el, style); | ||
} | ||
return style; | ||
} | ||
function copyVisualStyles(fromEl, toEl) { | ||
if (!fromEl) | ||
return; | ||
const el = getComputedStyle2(fromEl); | ||
const cssText = "box-sizing:" + el.boxSizing + ";border-left:" + el.borderLeftWidth + " solid red;border-right:" + el.borderRightWidth + " solid red;font-family:" + el.fontFamily + ";font-feature-settings:" + el.fontFeatureSettings + ";font-kerning:" + el.fontKerning + ";font-size:" + el.fontSize + ";font-stretch:" + el.fontStretch + ";font-style:" + el.fontStyle + ";font-variant:" + el.fontVariant + ";font-variant-caps:" + el.fontVariantCaps + ";font-variant-ligatures:" + el.fontVariantLigatures + ";font-variant-numeric:" + el.fontVariantNumeric + ";font-weight:" + el.fontWeight + ";letter-spacing:" + el.letterSpacing + ";margin-left:" + el.marginLeft + ";margin-right:" + el.marginRight + ";padding-left:" + el.paddingLeft + ";padding-right:" + el.paddingRight + ";text-indent:" + el.textIndent + ";text-transform:" + el.textTransform; | ||
toEl.style.cssText += cssText; | ||
} | ||
// src/next-tick.ts | ||
function nextTick(fn) { | ||
const set = /* @__PURE__ */ new Set(); | ||
function raf2(fn2) { | ||
const id = globalThis.requestAnimationFrame(fn2); | ||
set.add(() => globalThis.cancelAnimationFrame(id)); | ||
} | ||
raf2(() => raf2(fn)); | ||
return function cleanup() { | ||
set.forEach(function(fn2) { | ||
fn2(); | ||
}); | ||
}; | ||
} | ||
function raf(fn) { | ||
const id = globalThis.requestAnimationFrame(fn); | ||
return function cleanup() { | ||
globalThis.cancelAnimationFrame(id); | ||
}; | ||
} | ||
function forceReflow() { | ||
return document.body.offsetHeight; | ||
} | ||
// src/auto-resize.ts | ||
function createGhostElement(doc) { | ||
var el = doc.createElement("div"); | ||
el.id = "ghost"; | ||
el.style.cssText = "display:inline-block;height:0;overflow:hidden;position:absolute;top:0;visibility:hidden;white-space:nowrap;"; | ||
doc.body.appendChild(el); | ||
return el; | ||
} | ||
function autoResizeInput(input) { | ||
var _a; | ||
if (!input) | ||
return; | ||
const doc = (_a = input.ownerDocument) != null ? _a : document; | ||
const ghost = createGhostElement(doc); | ||
copyVisualStyles(input, ghost); | ||
function resize() { | ||
raf(() => { | ||
ghost.innerHTML = input.value; | ||
const rect = getComputedStyle(ghost); | ||
input == null ? void 0 : input.style.setProperty("width", rect.width); | ||
}); | ||
} | ||
resize(); | ||
input == null ? void 0 : input.addEventListener("input", resize); | ||
input == null ? void 0 : input.addEventListener("change", resize); | ||
return () => { | ||
doc.body.removeChild(ghost); | ||
input == null ? void 0 : input.removeEventListener("input", resize); | ||
input == null ? void 0 : input.removeEventListener("change", resize); | ||
}; | ||
} | ||
// ../core/src/functions.ts | ||
var cast = (v) => v; | ||
var noop = () => { | ||
}; | ||
var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v); | ||
// ../core/src/guard.ts | ||
var platform = (v) => isDom() && v.test(navigator.platform); | ||
var isDom = () => !!(typeof window !== "undefined"); | ||
var isMac = () => platform(/^Mac/); | ||
var isIPhone = () => platform(/^iPhone/); | ||
var isIPad = () => platform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1; | ||
var isIos = () => isIPhone() || isIPad(); | ||
var isArray = (v) => Array.isArray(v); | ||
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v)); | ||
var isMouseEvent = (v) => isObject(v) && "button" in v; | ||
var isLeftClick = (v) => v.button === 0; | ||
// src/event-bus.ts | ||
var listenerElements = /* @__PURE__ */ new Map(); | ||
var listenerCache = /* @__PURE__ */ new Map(); | ||
function globalEventBus(node, type, handler, options) { | ||
var _a; | ||
if (!node) | ||
return noop; | ||
const hash = JSON.stringify({ type, options }); | ||
const group = listenerElements.get(node); | ||
if (!listenerElements.has(node)) { | ||
const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]); | ||
listenerElements.set(node, group2); | ||
} else if (group == null ? void 0 : group.has(hash)) { | ||
(_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler); | ||
} else { | ||
group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler])); | ||
} | ||
function attach(node2) { | ||
var _a2, _b; | ||
function listener(event) { | ||
var _a3; | ||
const group2 = listenerElements.get(node2); | ||
(_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event)); | ||
} | ||
if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) { | ||
listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]])); | ||
node2.addEventListener(type, listener, options); | ||
return; | ||
} | ||
if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) { | ||
(_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener); | ||
node2.addEventListener(type, listener, options); | ||
} | ||
} | ||
attach(node); | ||
return function remove() { | ||
var _a2, _b, _c, _d; | ||
if (!listenerElements.has(node)) | ||
return; | ||
const group2 = listenerElements.get(node); | ||
(_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler); | ||
if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) { | ||
const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash); | ||
node.removeEventListener(type, listener, options); | ||
group2 == null ? void 0 : group2.delete(hash); | ||
(_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash); | ||
if ((group2 == null ? void 0 : group2.size) === 0) { | ||
listenerElements.delete(node); | ||
listenerCache.delete(node); | ||
} | ||
} | ||
}; | ||
} | ||
// src/listener.ts | ||
var t = (v) => Object.prototype.toString.call(v).slice(8, -1); | ||
var isRef = (v) => t(v) === "Object" && "current" in v; | ||
var runIfFn = (fn) => t(fn) === "Function" ? fn() : fn; | ||
var isTouchEvent = (v) => t(v) === "Object" && !!v.touches; | ||
var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 }; | ||
function extractInfo(event, type = "page") { | ||
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback : event; | ||
return { | ||
point: { | ||
x: point[`${type}X`], | ||
y: point[`${type}Y`] | ||
} | ||
}; | ||
} | ||
function addDomEvent(target, event, listener, options) { | ||
const node = isRef(target) ? target.current : runIfFn(target); | ||
return globalEventBus(node, event, listener, options); | ||
} | ||
function addPointerEvent(target, event, listener, options) { | ||
var _a; | ||
const type = (_a = getEventName(event)) != null ? _a : event; | ||
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options); | ||
} | ||
function wrapHandler(fn, filter = false) { | ||
const listener = (event) => { | ||
fn(event, extractInfo(event)); | ||
}; | ||
return filter ? filterPrimaryPointer(listener) : listener; | ||
} | ||
function filterPrimaryPointer(fn) { | ||
return (event) => { | ||
var _a; | ||
const win = (_a = event.view) != null ? _a : window; | ||
const isMouseEvent2 = event instanceof win.MouseEvent; | ||
const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0; | ||
if (isPrimary) | ||
fn(event); | ||
}; | ||
} | ||
function extractClientInfo(event) { | ||
return extractInfo(event, "client"); | ||
} | ||
var supportsPointerEvent = () => typeof window !== "undefined" && window.onpointerdown === null; | ||
var supportsTouchEvent = () => typeof window !== "undefined" && window.ontouchstart === null; | ||
var supportsMouseEvent = () => typeof window !== "undefined" && window.onmousedown === null; | ||
var mouseEventNames = { | ||
pointerdown: "mousedown", | ||
pointermove: "mousemove", | ||
pointerup: "mouseup", | ||
pointercancel: "mousecancel", | ||
pointerover: "mouseover", | ||
pointerout: "mouseout", | ||
pointerenter: "mouseenter", | ||
pointerleave: "mouseleave" | ||
}; | ||
var touchEventNames = { | ||
pointerdown: "touchstart", | ||
pointermove: "touchmove", | ||
pointerup: "touchend", | ||
pointercancel: "touchcancel" | ||
}; | ||
function getEventName(evt) { | ||
if (supportsPointerEvent()) | ||
return evt; | ||
if (supportsTouchEvent()) | ||
return touchEventNames[evt]; | ||
if (supportsMouseEvent()) | ||
return mouseEventNames[evt]; | ||
return evt; | ||
} | ||
// src/body-pointer-event.ts | ||
var changeCount = 0; | ||
var originalBodyPointerEvents; | ||
function preventBodyPointerEvents(el, opts = {}) { | ||
const { disabled = false, document: docProp } = opts; | ||
const doc = docProp || document; | ||
let isTouchOrPenPressed = false; | ||
let isLeftClickPressed = false; | ||
function listen() { | ||
const onPointerDown = (event) => { | ||
const isMouse = event.pointerType === "mouse"; | ||
isTouchOrPenPressed = !isMouse; | ||
isLeftClickPressed = isMouse && isLeftClick(event); | ||
}; | ||
const onPointerUp = () => { | ||
isTouchOrPenPressed = false; | ||
isLeftClickPressed = false; | ||
}; | ||
return pipe(addDomEvent(doc, "pointerdown", onPointerDown), addDomEvent(doc, "pointerup", onPointerUp)); | ||
} | ||
function reset() { | ||
changeCount--; | ||
if (changeCount === 0) { | ||
doc.body.style.pointerEvents = originalBodyPointerEvents; | ||
} | ||
if (el) { | ||
el.style.pointerEvents = ""; | ||
} | ||
} | ||
function apply() { | ||
if (disabled) | ||
return; | ||
if (changeCount === 0) { | ||
originalBodyPointerEvents = doc.body.style.pointerEvents; | ||
} | ||
doc.body.style.pointerEvents = "none"; | ||
if (el) { | ||
el.style.pointerEvents = "auto"; | ||
} | ||
changeCount++; | ||
return function() { | ||
if (isTouchOrPenPressed) { | ||
addDomEvent(doc, "click", reset, { once: true }); | ||
} else if (isLeftClickPressed) { | ||
addDomEvent(doc, "pointerup", reset, { once: true }); | ||
} else { | ||
reset(); | ||
} | ||
}; | ||
} | ||
const cleanups = []; | ||
cleanups.push(apply()); | ||
nextTick(() => { | ||
cleanups.push(listen()); | ||
}); | ||
return function() { | ||
cleanups.forEach((cleanup) => cleanup == null ? void 0 : cleanup()); | ||
}; | ||
} | ||
// ../../../node_modules/compute-scroll-into-view/dist/index.module.js | ||
function t2(t3) { | ||
return typeof t3 == "object" && t3 != null && t3.nodeType === 1; | ||
} | ||
function e(t3, e2) { | ||
return (!e2 || t3 !== "hidden") && t3 !== "visible" && t3 !== "clip"; | ||
} | ||
function n(t3, n2) { | ||
if (t3.clientHeight < t3.scrollHeight || t3.clientWidth < t3.scrollWidth) { | ||
var r2 = getComputedStyle(t3, null); | ||
return e(r2.overflowY, n2) || e(r2.overflowX, n2) || function(t4) { | ||
var e2 = function(t5) { | ||
if (!t5.ownerDocument || !t5.ownerDocument.defaultView) | ||
return null; | ||
try { | ||
return t5.ownerDocument.defaultView.frameElement; | ||
} catch (t6) { | ||
return null; | ||
} | ||
}(t4); | ||
return !!e2 && (e2.clientHeight < t4.scrollHeight || e2.clientWidth < t4.scrollWidth); | ||
}(t3); | ||
} | ||
return false; | ||
} | ||
function r(t3, e2, n2, r2, i, o, l, d) { | ||
return o < t3 && l > e2 || o > t3 && l < e2 ? 0 : o <= t3 && d <= n2 || l >= e2 && d >= n2 ? o - t3 - r2 : l > e2 && d < n2 || o < t3 && d > n2 ? l - e2 + i : 0; | ||
} | ||
function index_module_default(e2, i) { | ||
var o = window, l = i.scrollMode, d = i.block, u = i.inline, h = i.boundary, a = i.skipOverflowHiddenElements, c = typeof h == "function" ? h : function(t3) { | ||
return t3 !== h; | ||
}; | ||
if (!t2(e2)) | ||
throw new TypeError("Invalid target"); | ||
for (var f = document.scrollingElement || document.documentElement, s = [], p = e2; t2(p) && c(p); ) { | ||
if ((p = p.parentElement) === f) { | ||
s.push(p); | ||
break; | ||
} | ||
p != null && p === document.body && n(p) && !n(document.documentElement) || p != null && n(p, a) && s.push(p); | ||
} | ||
for (var m = o.visualViewport ? o.visualViewport.width : innerWidth, g = o.visualViewport ? o.visualViewport.height : innerHeight, w = window.scrollX || pageXOffset, v = window.scrollY || pageYOffset, W = e2.getBoundingClientRect(), b = W.height, H = W.width, y = W.top, E = W.right, M = W.bottom, V = W.left, x = d === "start" || d === "nearest" ? y : d === "end" ? M : y + b / 2, I = u === "center" ? V + H / 2 : u === "end" ? E : V, C = [], T = 0; T < s.length; T++) { | ||
var k = s[T], B = k.getBoundingClientRect(), D = B.height, O = B.width, R = B.top, X = B.right, Y = B.bottom, L = B.left; | ||
if (l === "if-needed" && y >= 0 && V >= 0 && M <= g && E <= m && y >= R && M <= Y && V >= L && E <= X) | ||
return C; | ||
var S = getComputedStyle(k), j = parseInt(S.borderLeftWidth, 10), q = parseInt(S.borderTopWidth, 10), z = parseInt(S.borderRightWidth, 10), A = parseInt(S.borderBottomWidth, 10), F = 0, G = 0, J = "offsetWidth" in k ? k.offsetWidth - k.clientWidth - j - z : 0, K = "offsetHeight" in k ? k.offsetHeight - k.clientHeight - q - A : 0; | ||
if (f === k) | ||
F = d === "start" ? x : d === "end" ? x - g : d === "nearest" ? r(v, v + g, g, q, A, v + x, v + x + b, b) : x - g / 2, G = u === "start" ? I : u === "center" ? I - m / 2 : u === "end" ? I - m : r(w, w + m, m, j, z, w + I, w + I + H, H), F = Math.max(0, F + v), G = Math.max(0, G + w); | ||
else { | ||
F = d === "start" ? x - R - q : d === "end" ? x - Y + A + K : d === "nearest" ? r(R, Y, D, q, A + K, x, x + b, b) : x - (R + D / 2) + K / 2, G = u === "start" ? I - L - j : u === "center" ? I - (L + O / 2) + J / 2 : u === "end" ? I - X + z + J : r(L, X, O, j, z + J, I, I + H, H); | ||
var N = k.scrollLeft, P = k.scrollTop; | ||
x += P - (F = Math.max(0, Math.min(P + F, k.scrollHeight - D + K))), I += N - (G = Math.max(0, Math.min(N + G, k.scrollWidth - O + J))); | ||
} | ||
C.push({ el: k, top: F, left: G }); | ||
} | ||
return C; | ||
} | ||
// node_modules/scroll-into-view-if-needed/es/index.js | ||
function isOptionsObject(options) { | ||
return options === Object(options) && Object.keys(options).length !== 0; | ||
} | ||
function defaultBehavior(actions, behavior) { | ||
if (behavior === void 0) { | ||
behavior = "auto"; | ||
} | ||
var canSmoothScroll = "scrollBehavior" in document.body.style; | ||
actions.forEach(function(_ref) { | ||
var el = _ref.el, top = _ref.top, left = _ref.left; | ||
if (el.scroll && canSmoothScroll) { | ||
el.scroll({ | ||
top, | ||
left, | ||
behavior | ||
}); | ||
} else { | ||
el.scrollTop = top; | ||
el.scrollLeft = left; | ||
} | ||
}); | ||
} | ||
function getOptions(options) { | ||
if (options === false) { | ||
return { | ||
block: "end", | ||
inline: "nearest" | ||
}; | ||
} | ||
if (isOptionsObject(options)) { | ||
return options; | ||
} | ||
return { | ||
block: "start", | ||
inline: "nearest" | ||
}; | ||
} | ||
function scrollIntoView(target, options) { | ||
var isTargetAttached = target.isConnected || target.ownerDocument.documentElement.contains(target); | ||
if (isOptionsObject(options) && typeof options.behavior === "function") { | ||
return options.behavior(isTargetAttached ? index_module_default(target, options) : []); | ||
} | ||
if (!isTargetAttached) { | ||
return; | ||
} | ||
var computeOptions = getOptions(options); | ||
return defaultBehavior(index_module_default(target, computeOptions), computeOptions.behavior); | ||
} | ||
var es_default = scrollIntoView; | ||
// src/query.ts | ||
function getOwnerDocument(el) { | ||
var _a; | ||
if (isWindow(el)) | ||
return el.document; | ||
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document; | ||
} | ||
function getOwnerWindow(el) { | ||
var _a; | ||
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window; | ||
} | ||
function getDocumentElement(el) { | ||
return getOwnerDocument(el).documentElement; | ||
} | ||
function getNodeName(node) { | ||
return isWindow(node) ? "" : node ? node.localName || "" : ""; | ||
} | ||
function getEventWindow(event) { | ||
if (event.view) | ||
return event.view; | ||
let target = event.currentTarget; | ||
if (target != null) | ||
return getOwnerWindow(target); | ||
return window; | ||
} | ||
function getParent(el) { | ||
const doc = getOwnerDocument(el); | ||
if (getNodeName(el) === "html") | ||
return el; | ||
return el.assignedSlot || el.parentElement || doc.documentElement; | ||
} | ||
function contains(parent, child) { | ||
if (!parent) | ||
return false; | ||
return parent === child || isHTMLElement(parent) && isHTMLElement(child) && parent.contains(child); | ||
} | ||
function isHTMLElement(v) { | ||
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string"; | ||
} | ||
function isWindow(value) { | ||
return (value == null ? void 0 : value.toString()) === "[object Window]"; | ||
} | ||
var isDisabled = (el) => { | ||
return (el == null ? void 0 : el.getAttribute("disabled")) != null || !!(el == null ? void 0 : el.getAttribute("aria-disabled")) === true; | ||
}; | ||
function getNativeEvent(event) { | ||
var _a; | ||
return (_a = event.nativeEvent) != null ? _a : event; | ||
} | ||
// src/scrollable.ts | ||
function isScrollParent(el) { | ||
const { overflow, overflowX, overflowY } = getComputedStyle2(el); | ||
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX); | ||
} | ||
function getScrollParent(el) { | ||
if (["html", "body", "#document"].includes(getNodeName(el))) { | ||
return getOwnerDocument(el).body; | ||
} | ||
if (isHTMLElement(el) && isScrollParent(el)) { | ||
return el; | ||
} | ||
return getScrollParent(getParent(el)); | ||
} | ||
function getScrollParents(el, list = []) { | ||
const scrollParent = getScrollParent(el); | ||
const isBody = scrollParent === getOwnerDocument(el).body; | ||
const win = getOwnerWindow(scrollParent); | ||
const target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent; | ||
const parents = list.concat(target); | ||
if (isBody) | ||
return parents; | ||
return parents.concat(getScrollParents(getParent(target))); | ||
} | ||
function getScrollOffset(el) { | ||
if (isWindow(el)) { | ||
return { scrollLeft: el.scrollX, scrollTop: el.scrollY }; | ||
} | ||
return { scrollLeft: el.scrollLeft, scrollTop: el.scrollTop }; | ||
} | ||
// src/body-scroll-lock.ts | ||
var nonTextInputTypes = /* @__PURE__ */ new Set(["checkbox", "radio", "range", "color", "file", "image", "button", "submit", "reset"]); | ||
function preventBodyScroll(opts) { | ||
var _a; | ||
const { document: docProp, disabled = false, allowPinchZoom } = opts != null ? opts : {}; | ||
const doc = docProp != null ? docProp : document; | ||
const win = (_a = doc == null ? void 0 : doc.defaultView) != null ? _a : window; | ||
const viewport = isDom() ? win.visualViewport : null; | ||
const docEl = doc.documentElement; | ||
function preventScrollStandard() { | ||
const fn = pipe(setStyle(docEl, "paddingRight", `${win.innerWidth - docEl.clientWidth}px`), setStyle(docEl, "overflow", "hidden")); | ||
return () => fn == null ? void 0 : fn(); | ||
} | ||
function preventScrollMobileSafari() { | ||
let scrollable; | ||
let lastY = 0; | ||
let onTouchStart = (e2) => { | ||
scrollable = getScrollParent(e2.target); | ||
if (scrollable === docEl && scrollable === doc.body) { | ||
return; | ||
} | ||
lastY = e2.changedTouches[0].pageY; | ||
}; | ||
let onTouchMove = (e2) => { | ||
if (e2.touches.length === 2 && allowPinchZoom) | ||
return; | ||
if (!scrollable || scrollable === docEl || scrollable === doc.body) { | ||
e2.preventDefault(); | ||
return; | ||
} | ||
let y = e2.changedTouches[0].pageY; | ||
let scrollTop = scrollable.scrollTop; | ||
let bottom = scrollable.scrollHeight - scrollable.clientHeight; | ||
if (scrollTop <= 0 && y > lastY || scrollTop >= bottom && y < lastY) { | ||
e2.preventDefault(); | ||
} | ||
lastY = y; | ||
}; | ||
let onTouchEnd = (e2) => { | ||
let target = e2.target; | ||
if (target instanceof win.HTMLInputElement && !nonTextInputTypes.has(target.type)) { | ||
e2.preventDefault(); | ||
target.style.transform = "translateY(-2000px)"; | ||
target.focus(); | ||
win.requestAnimationFrame(() => { | ||
target.style.transform = ""; | ||
}); | ||
} | ||
}; | ||
let onFocus = (e2) => { | ||
let target = e2.target; | ||
if (target instanceof win.HTMLInputElement && !nonTextInputTypes.has(target.type)) { | ||
target.style.transform = "translateY(-2000px)"; | ||
win.requestAnimationFrame(() => { | ||
target.style.transform = ""; | ||
if (!viewport) | ||
return; | ||
if (viewport.height < win.innerHeight) { | ||
win.requestAnimationFrame(function() { | ||
es_default(target, { scrollMode: "if-needed" }); | ||
}); | ||
} else { | ||
const onResize = () => { | ||
es_default(target, { scrollMode: "if-needed" }); | ||
}; | ||
addDomEvent(viewport, "resize", onResize, { once: true }); | ||
} | ||
}); | ||
} | ||
}; | ||
let onWindowScroll = () => { | ||
win.scrollTo(0, 0); | ||
}; | ||
let scrollX = win.scrollX; | ||
let scrollY = win.scrollY; | ||
let restoreStyles = pipe(setStyle(docEl, "paddingRight", `${win.innerWidth - docEl.clientWidth}px`), setStyle(docEl, "overflow", "hidden"), setStyle(doc.body, "marginTop", `-${scrollY}px`)); | ||
win.scrollTo(0, 0); | ||
let removeEvents = pipe(addDomEvent(doc, "touchstart", onTouchStart, { passive: false, capture: true }), addDomEvent(doc, "touchmove", onTouchMove, { passive: false, capture: true }), addDomEvent(doc, "touchend", onTouchEnd, { passive: false, capture: true }), addDomEvent(doc, "focus", onFocus, true), addDomEvent(win, "scroll", onWindowScroll)); | ||
return () => { | ||
restoreStyles(); | ||
removeEvents(); | ||
win.scrollTo(scrollX, scrollY); | ||
}; | ||
} | ||
if (disabled) | ||
return noop; | ||
return isIos() ? preventScrollMobileSafari() : preventScrollStandard(); | ||
} | ||
function setStyle(el, key, value) { | ||
let cur = el.style[key]; | ||
el.style[key] = value; | ||
return () => { | ||
el.style[key] = cur; | ||
}; | ||
} | ||
// src/constants.ts | ||
var MAX_Z_INDEX = 2147483647; | ||
// src/dispatch-event.ts | ||
function getDescriptor(el, options) { | ||
var _a; | ||
const { type, property } = options; | ||
const win = getOwnerWindow(el); | ||
const _type = type === "input" ? "HTMLInputElement" : "HTMLTextAreaElement"; | ||
const proto = win[_type].prototype; | ||
return (_a = Object.getOwnPropertyDescriptor(proto, property)) != null ? _a : {}; | ||
} | ||
function dispatchInputValueEvent(el, value) { | ||
var _a; | ||
const win = getOwnerWindow(el); | ||
if (!(el instanceof win.HTMLInputElement)) | ||
return; | ||
const desc = getDescriptor(el, { type: "input", property: "value" }); | ||
(_a = desc.set) == null ? void 0 : _a.call(el, value); | ||
const event = new win.Event("input", { bubbles: true }); | ||
el.dispatchEvent(event); | ||
} | ||
function dispatchInputCheckedEvent(el, checked) { | ||
var _a; | ||
const win = getOwnerWindow(el); | ||
if (!(el instanceof win.HTMLInputElement)) | ||
return; | ||
const desc = getDescriptor(el, { type: "input", property: "checked" }); | ||
(_a = desc.set) == null ? void 0 : _a.call(el, checked); | ||
const event = new win.Event("click", { bubbles: true }); | ||
el.dispatchEvent(event); | ||
} | ||
function trackInputPropertyMutation(el, options) { | ||
const { fn, property, type } = options; | ||
if (!fn || !el) | ||
return; | ||
const { get, set } = getDescriptor(el, { property, type }); | ||
let run = true; | ||
Object.defineProperty(el, property, { | ||
get() { | ||
return get == null ? void 0 : get.call(this); | ||
}, | ||
set(value) { | ||
if (run) | ||
fn(value); | ||
return set == null ? void 0 : set.call(this, value); | ||
} | ||
}); | ||
return function() { | ||
run = false; | ||
}; | ||
} | ||
// src/focus-event.ts | ||
function validateBlur(event, opts) { | ||
var _a; | ||
const exclude = Array.isArray(opts.exclude) ? opts.exclude : [opts.exclude]; | ||
const relatedTarget = (_a = event.relatedTarget) != null ? _a : opts.fallback; | ||
return exclude.every((el) => !(el == null ? void 0 : el.contains(relatedTarget))); | ||
} | ||
// src/focusable.ts | ||
var focusableSelector = /* @__PURE__ */ [ | ||
"input:not([disabled]):not([type=hidden])", | ||
"select:not([disabled])", | ||
"textarea:not([disabled])", | ||
"button:not([disabled])", | ||
"embed", | ||
"iframe", | ||
"object", | ||
"a[href]", | ||
"area[href]", | ||
"[tabindex]", | ||
"audio[controls]", | ||
"video[controls]", | ||
"*[tabindex]:not([aria-disabled])", | ||
"[contenteditable]:not([contenteditable=false])", | ||
"details > summary:first-of-type" | ||
].join(","); | ||
function isHidden(el, until) { | ||
const style = getComputedStyle2(el); | ||
if (!el || style.getPropertyValue("visibility") === "hidden") | ||
return true; | ||
while (el) { | ||
if (until != null && el === until) | ||
return false; | ||
if (style.getPropertyValue("display") === "none") | ||
return true; | ||
el = el.parentElement; | ||
} | ||
return false; | ||
} | ||
var getFocusables = (el, includeContainer = false) => { | ||
if (!el) | ||
return []; | ||
let els = Array.from(el.querySelectorAll(focusableSelector)); | ||
if (includeContainer && isHTMLElement(el)) { | ||
els.unshift(el); | ||
} | ||
return els.filter((el2) => isFocusable(el2) && !isHidden(el2)); | ||
}; | ||
var isFocusable = (el) => { | ||
if (!isHTMLElement(el) || isHidden(el) || isDisabled(el)) | ||
return false; | ||
return el == null ? void 0 : el.matches(focusableSelector); | ||
}; | ||
var getTabbables = (el, includeContainer = false) => { | ||
return getFocusables(el, includeContainer).filter(isTabbable); | ||
}; | ||
var isTabbable = (el) => { | ||
return isFocusable(el) && !isDisabled(el) && !isHidden(el); | ||
}; | ||
// src/form.ts | ||
function getClosestFormElement(el) { | ||
if (isFormElement(el)) | ||
return el.form; | ||
else | ||
return el.closest("form"); | ||
} | ||
function isFormElement(el) { | ||
return ["textarea", "input", "select", "button"].includes(el.localName); | ||
} | ||
function trackFormReset(el, callback) { | ||
if (!el) | ||
return; | ||
const form = getClosestFormElement(el); | ||
form == null ? void 0 : form.addEventListener("reset", callback, { passive: true }); | ||
return () => { | ||
form == null ? void 0 : form.removeEventListener("reset", callback); | ||
}; | ||
} | ||
// src/keyboard-event.ts | ||
var rtlKeyMap = { | ||
ArrowLeft: "ArrowRight", | ||
ArrowRight: "ArrowLeft", | ||
Home: "End", | ||
End: "Home" | ||
}; | ||
var sameKeyMap = { | ||
Up: "ArrowUp", | ||
Down: "ArrowDown", | ||
Esc: "Escape", | ||
" ": "Space", | ||
",": "Comma", | ||
Left: "ArrowLeft", | ||
Right: "ArrowRight" | ||
}; | ||
function getEventKey(event, options = {}) { | ||
var _a; | ||
const { dir = "ltr", orientation = "horizontal" } = options; | ||
let { key } = event; | ||
key = (_a = sameKeyMap[key]) != null ? _a : key; | ||
const isRtl = dir === "rtl" && orientation === "horizontal"; | ||
if (isRtl && key in rtlKeyMap) { | ||
key = rtlKeyMap[key]; | ||
} | ||
return key; | ||
} | ||
var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]); | ||
var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]); | ||
function getEventStep(event) { | ||
if (event.ctrlKey || event.metaKey) { | ||
return 0.1; | ||
} else { | ||
const isPageKey = PAGE_KEYS.has(event.key); | ||
const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.has(event.key); | ||
return isSkipKey ? 10 : 1; | ||
} | ||
} | ||
// src/visually-hidden.ts | ||
var visuallyHiddenStyle = { | ||
border: "0", | ||
clip: "rect(0 0 0 0)", | ||
height: "1px", | ||
margin: "-1px", | ||
overflow: "hidden", | ||
padding: "0", | ||
position: "absolute", | ||
width: "1px", | ||
whiteSpace: "nowrap", | ||
wordWrap: "normal" | ||
}; | ||
function setVisuallyHidden(el) { | ||
Object.assign(el.style, visuallyHiddenStyle); | ||
} | ||
// src/live-region.ts | ||
function createLiveRegion(opts = {}) { | ||
var _a; | ||
const { level = "polite", doc: ownerDocument, root, delay: rootDelay = 0 } = opts; | ||
const doc = ownerDocument != null ? ownerDocument : document; | ||
const win = (_a = doc.defaultView) != null ? _a : window; | ||
const parent = root != null ? root : doc.body; | ||
function announce(msg, delay) { | ||
const oldRegion = doc.getElementById("__live-region__"); | ||
if (!!oldRegion) { | ||
parent.removeChild(oldRegion); | ||
} | ||
delay = delay != null ? delay : rootDelay; | ||
const region = doc.createElement("span"); | ||
region.id = "__live-region__"; | ||
var role = level !== "assertive" ? "status" : "alert"; | ||
region.setAttribute("aria-live", level); | ||
region.setAttribute("role", role); | ||
setVisuallyHidden(region); | ||
parent.appendChild(region); | ||
win.setTimeout(() => { | ||
region.textContent = msg; | ||
}, delay); | ||
} | ||
function destroy() { | ||
const oldRegion = doc.getElementById("__live-region__"); | ||
if (oldRegion) { | ||
parent.removeChild(oldRegion); | ||
} | ||
} | ||
return { announce, destroy }; | ||
} | ||
// src/mutation-observer.ts | ||
function observeAttributes(node, attributes, fn) { | ||
if (!node) | ||
return noop; | ||
const attrs = Array.isArray(attributes) ? attributes : [attributes]; | ||
const win = node.ownerDocument.defaultView || window; | ||
const obs = new win.MutationObserver((changes) => { | ||
for (const change of changes) { | ||
if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) { | ||
fn(change); | ||
} | ||
} | ||
}); | ||
obs.observe(node, { attributes: true, attributeFilter: attrs }); | ||
return () => obs.disconnect(); | ||
} | ||
function observeChildren(node, fn, subtree = false) { | ||
if (!node) | ||
return noop; | ||
const win = node.ownerDocument.defaultView || window; | ||
const obs = new win.MutationObserver((changes) => { | ||
for (const change of changes) { | ||
if (change.type === "childList") { | ||
fn(change); | ||
} | ||
} | ||
}); | ||
obs.observe(node, { childList: true, subtree }); | ||
return () => obs.disconnect(); | ||
} | ||
// src/nodelist.ts | ||
function queryAll(root, selector) { | ||
var _a; | ||
return Array.from((_a = root == null ? void 0 : root.querySelectorAll(selector)) != null ? _a : []); | ||
} | ||
function query(root, selector) { | ||
return root == null ? void 0 : root.querySelector(selector); | ||
} | ||
function itemById(v, id) { | ||
return v.find((node) => node.id === id); | ||
} | ||
function indexOfId(v, id) { | ||
const item = itemById(v, id); | ||
return item ? v.indexOf(item) : -1; | ||
} | ||
function nextById(v, id, loop = true) { | ||
let idx = indexOfId(v, id); | ||
idx = loop ? (idx + 1) % v.length : Math.min(idx + 1, v.length - 1); | ||
return v[idx]; | ||
} | ||
function prevById(v, id, loop = true) { | ||
let idx = indexOfId(v, id); | ||
if (idx === -1) | ||
return loop ? v[v.length - 1] : null; | ||
idx = loop ? (idx - 1 + v.length) % v.length : Math.max(0, idx - 1); | ||
return v[idx]; | ||
} | ||
function findByText(v, text, currentId) { | ||
const filtered = v.filter((item) => { | ||
var _a; | ||
const str = (_a = item.dataset.valuetext) != null ? _a : item.textContent; | ||
return !!(str == null ? void 0 : str.toLowerCase().startsWith(text.toLowerCase())); | ||
}); | ||
return currentId ? nextById(filtered, currentId) : null; | ||
} | ||
function sortByTreeOrder(v) { | ||
return v.sort((a, b) => a.compareDocumentPosition(b) & 2 ? 1 : -1); | ||
} | ||
// src/text-selection.ts | ||
var state = "default"; | ||
var savedUserSelect = ""; | ||
var modifiedElementMap = /* @__PURE__ */ new WeakMap(); | ||
function disableTextSelection({ target, doc } = {}) { | ||
const _document = doc != null ? doc : document; | ||
if (isIos()) { | ||
if (state === "default") { | ||
savedUserSelect = _document.documentElement.style.webkitUserSelect; | ||
_document.documentElement.style.webkitUserSelect = "none"; | ||
} | ||
state = "disabled"; | ||
} else if (target) { | ||
modifiedElementMap.set(target, target.style.userSelect); | ||
target.style.userSelect = "none"; | ||
} | ||
return () => restoreTextSelection({ target, doc: _document }); | ||
} | ||
function restoreTextSelection({ target, doc } = {}) { | ||
const _document = doc != null ? doc : document; | ||
if (isIos()) { | ||
if (state !== "disabled") | ||
return; | ||
state = "restoring"; | ||
setTimeout(() => { | ||
nextTick(() => { | ||
if (state === "restoring") { | ||
if (_document.documentElement.style.webkitUserSelect === "none") { | ||
_document.documentElement.style.webkitUserSelect = savedUserSelect || ""; | ||
} | ||
savedUserSelect = ""; | ||
state = "default"; | ||
} | ||
}); | ||
}, 300); | ||
} else { | ||
if (target && modifiedElementMap.has(target)) { | ||
let targetOldUserSelect = modifiedElementMap.get(target); | ||
if (target.style.userSelect === "none") { | ||
target.style.userSelect = targetOldUserSelect != null ? targetOldUserSelect : ""; | ||
} | ||
if (target.getAttribute("style") === "") { | ||
target.removeAttribute("style"); | ||
} | ||
modifiedElementMap.delete(target); | ||
} | ||
} | ||
} | ||
// src/pointer-event.ts | ||
function trackPointerDown(doc, onPointerDown) { | ||
var _a; | ||
const win = (_a = doc.defaultView) != null ? _a : window; | ||
const fn = (event) => { | ||
if (event.target instanceof win.HTMLElement) { | ||
onPointerDown(event.target); | ||
} | ||
}; | ||
return addDomEvent(doc, "pointerdown", fn); | ||
} | ||
function trackPointerMove(opts) { | ||
const { onPointerMove, onPointerUp, ctx } = opts; | ||
const { doc = document, threshold = 5 } = ctx; | ||
const handlePointerMove = (event, info) => { | ||
const { point: p } = info; | ||
const distance = Math.sqrt(__pow(p.x, 2) + __pow(p.y, 2)); | ||
if (distance < threshold) | ||
return; | ||
if (isMouseEvent(event) && isLeftClick(event)) { | ||
onPointerUp(); | ||
return; | ||
} | ||
onPointerMove(info, event); | ||
}; | ||
return pipe(addPointerEvent(doc, "pointermove", handlePointerMove, false), addPointerEvent(doc, "pointerup", onPointerUp, false), addPointerEvent(doc, "pointercancel", onPointerUp, false), addPointerEvent(doc, "contextmenu", onPointerUp, false), disableTextSelection({ doc })); | ||
} | ||
// src/pointerlock.ts | ||
function addPointerlockChangeListener(doc, fn) { | ||
return addDomEvent(doc, "pointerlockchange", fn, false); | ||
} | ||
function addPointerlockErrorListener(doc, fn) { | ||
doc.addEventListener("pointerlockerror", fn, false); | ||
return function cleanup() { | ||
doc.removeEventListener("pointerlockerror", fn, false); | ||
}; | ||
} | ||
function requestPointerLock(doc, handlers = {}) { | ||
const { onPointerLock, onPointerUnlock } = handlers; | ||
const body = doc.body; | ||
const supported = "pointerLockElement" in doc || "mozPointerLockElement" in doc; | ||
const locked = !!doc.pointerLockElement; | ||
function onPointerChange() { | ||
if (locked) | ||
onPointerLock == null ? void 0 : onPointerLock(); | ||
else | ||
onPointerUnlock == null ? void 0 : onPointerUnlock(); | ||
} | ||
function onPointerError(event) { | ||
if (locked) | ||
onPointerUnlock == null ? void 0 : onPointerUnlock(); | ||
console.error("PointerLock error occured:", event); | ||
exit(); | ||
} | ||
function exit() { | ||
doc.exitPointerLock(); | ||
} | ||
if (!supported) | ||
return; | ||
body.requestPointerLock(); | ||
const cleanup = pipe(addPointerlockChangeListener(doc, onPointerChange), addPointerlockErrorListener(doc, onPointerError)); | ||
return function dispose() { | ||
if (!supported) | ||
return; | ||
cleanup(); | ||
exit(); | ||
}; | ||
} | ||
// src/rect-observer.ts | ||
var observedElements = /* @__PURE__ */ new Map(); | ||
function observeElementRect(el, fn) { | ||
const data = observedElements.get(el); | ||
if (!data) { | ||
observedElements.set(el, { rect: {}, callbacks: [fn] }); | ||
if (observedElements.size === 1) { | ||
rafId = requestAnimationFrame(runLoop); | ||
} | ||
} else { | ||
data.callbacks.push(fn); | ||
fn(el.getBoundingClientRect()); | ||
} | ||
return function unobserve() { | ||
const data2 = observedElements.get(el); | ||
if (!data2) | ||
return; | ||
const index = data2.callbacks.indexOf(fn); | ||
if (index > -1) { | ||
data2.callbacks.splice(index, 1); | ||
} | ||
if (data2.callbacks.length === 0) { | ||
observedElements.delete(el); | ||
if (observedElements.size === 0) { | ||
cancelAnimationFrame(rafId); | ||
} | ||
} | ||
}; | ||
} | ||
var rafId; | ||
function runLoop() { | ||
const changedRectsData = []; | ||
observedElements.forEach((data, element) => { | ||
const newRect = element.getBoundingClientRect(); | ||
if (!isEqual(data.rect, newRect)) { | ||
data.rect = newRect; | ||
changedRectsData.push(data); | ||
} | ||
}); | ||
changedRectsData.forEach((data) => { | ||
data.callbacks.forEach((callback) => callback(data.rect)); | ||
}); | ||
rafId = requestAnimationFrame(runLoop); | ||
} | ||
function isEqual(rect1, rect2) { | ||
return rect1.width === rect2.width && rect1.height === rect2.height && rect1.top === rect2.top && rect1.right === rect2.right && rect1.bottom === rect2.bottom && rect1.left === rect2.left; | ||
} | ||
// src/visibility-event.ts | ||
function trackDocumentVisibility(_doc, callback) { | ||
const doc = cast(_doc); | ||
return addDomEvent(doc, "visibilitychange", () => { | ||
const hidden = doc.hidden || doc.msHidden || doc.webkitHidden; | ||
callback(!!hidden); | ||
}); | ||
} | ||
// src/wait.ts | ||
function waitFor(predicate) { | ||
let value = predicate(); | ||
if (!!value) | ||
return Promise.resolve(value); | ||
return new Promise((resolve) => { | ||
const id = globalThis.setInterval(function() { | ||
let value2 = predicate(); | ||
if (value2) { | ||
globalThis.clearInterval(id); | ||
resolve(value2); | ||
} | ||
}, 0); | ||
}); | ||
} | ||
function waitForEvent(el, eventName) { | ||
return new Promise((resolve) => { | ||
function done(event) { | ||
if (event.target === el) { | ||
el.removeEventListener(eventName, done); | ||
resolve(); | ||
} | ||
} | ||
el.addEventListener(eventName, done); | ||
}); | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -17,1 +17,2 @@ import type { KeyboardEvent } from "react"; | ||
export {}; | ||
//# sourceMappingURL=keyboard-event.d.ts.map |
@@ -17,1 +17,2 @@ import { AnyPointerEvent, DOMEventTarget, EventMap, PointerEventInfo } from "./listener.types"; | ||
export declare function getEventName(evt: keyof EventMap): keyof EventMap; | ||
//# sourceMappingURL=listener.d.ts.map |
@@ -27,1 +27,2 @@ export interface EventMap extends DocumentEventMap, WindowEventMap, HTMLElementEventMap { | ||
} | ||
//# sourceMappingURL=listener.types.d.ts.map |
@@ -12,1 +12,2 @@ export declare type LiveRegionOptions = { | ||
}; | ||
//# sourceMappingURL=live-region.d.ts.map |
@@ -5,1 +5,2 @@ declare type Callback = (v: MutationRecord) => void; | ||
export {}; | ||
//# sourceMappingURL=mutation-observer.d.ts.map |
export declare function nextTick(fn: VoidFunction): () => void; | ||
export declare function raf(fn: VoidFunction): () => void; | ||
export declare function forceReflow(): number; | ||
//# sourceMappingURL=next-tick.d.ts.map |
@@ -11,1 +11,2 @@ declare type Root = Document | Element | null | undefined; | ||
export {}; | ||
//# sourceMappingURL=nodelist.d.ts.map |
@@ -13,1 +13,2 @@ import type { AnyPointerEvent, PointerEventInfo } from "./listener.types"; | ||
export {}; | ||
//# sourceMappingURL=pointer-event.d.ts.map |
@@ -7,4 +7,4 @@ declare type PointerLockHandlers = { | ||
export declare function addPointerlockErrorListener(doc: Document, fn: (e: Event) => void): () => void; | ||
export declare function getPointerlockElement(doc: Document): any; | ||
export declare function requestPointerLock(doc: Document, handlers?: PointerLockHandlers): () => void; | ||
export {}; | ||
//# sourceMappingURL=pointerlock.d.ts.map |
@@ -15,1 +15,2 @@ /// <reference types="react" /> | ||
export {}; | ||
//# sourceMappingURL=query.d.ts.map |
@@ -7,1 +7,2 @@ declare type Fn = (rect: DOMRect) => void; | ||
export {}; | ||
//# sourceMappingURL=rect-observer.d.ts.map |
@@ -10,1 +10,2 @@ export declare function isScrollParent(el: HTMLElement): boolean; | ||
export {}; | ||
//# sourceMappingURL=scrollable.d.ts.map |
@@ -9,1 +9,2 @@ export declare function disableTextSelection({ target, doc }?: { | ||
}): void; | ||
//# sourceMappingURL=text-selection.d.ts.map |
export declare function trackDocumentVisibility(_doc: Document, callback: (hidden: boolean) => void): () => void; | ||
//# sourceMappingURL=visibility-event.d.ts.map |
@@ -14,1 +14,2 @@ export declare const visuallyHiddenStyle: { |
export declare function setVisuallyHidden(el: HTMLElement): void; |
//# sourceMappingURL=visually-hidden.d.ts.map |
export declare function waitFor<T>(predicate: () => T): Promise<T>; | ||
export declare function waitForEvent(el: HTMLElement, eventName: string): Promise<void>; | ||
//# sourceMappingURL=wait.d.ts.map |
{ | ||
"name": "@zag-js/dom-utils", | ||
"version": "0.0.0-dev-20220413091534", | ||
"version": "0.0.0-dev-20220413174154", | ||
"description": "", | ||
@@ -19,3 +19,3 @@ "keywords": [ | ||
"files": [ | ||
"dist" | ||
"dist/**/*" | ||
], | ||
@@ -30,5 +30,14 @@ "publishConfig": { | ||
"@types/react": "^18.0.0", | ||
"@zag-js/utils": "^0.0.0-dev-20220413091534", | ||
"@zag-js/utils": "^0.0.0-dev-20220413174154", | ||
"scroll-into-view-if-needed": "^2.2.29" | ||
}, | ||
"scripts": { | ||
"build:fast": "zag build", | ||
"start": "zag build --watch", | ||
"build": "zag build --prod", | ||
"test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests", | ||
"lint": "eslint src --ext .ts,.tsx", | ||
"test:ci": "yarn test --ci --runInBand", | ||
"test:watch": "yarn test --watch --updateSnapshot" | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
286780
61
2521
1