Socket
Socket
Sign inDemoInstall

@zag-js/dom-query

Package Overview
Dependencies
0
Maintainers
1
Versions
638
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.51.2 to 0.52.0

10

dist/index.d.ts

@@ -63,3 +63,8 @@ type Booleanish = boolean | "true" | "false";

declare function getInitialFocus(container: HTMLElement | null, getInitialEl?: () => HTMLElement | null): HTMLElement | undefined;
interface InitialFocusOptions {
root: HTMLElement | null;
getInitialEl?: () => HTMLElement | null;
enabled?: boolean;
}
declare function getInitialFocus(options: InitialFocusOptions): HTMLElement | undefined;
declare function isValidTabEvent(event: Pick<KeyboardEvent, "shiftKey" | "currentTarget">): boolean;

@@ -113,2 +118,3 @@

declare const isWebKit: () => boolean;
declare const isModKey: (event: Pick<KeyboardEvent, "metaKey" | "ctrlKey">) => boolean;

@@ -208,2 +214,2 @@ type MaybeElement = HTMLElement | null;

export { type ItemToId, MAX_Z_INDEX, type ObserveAttributeOptions, type ObserveChildrenOptions, type OverflowAncestor, type ScopeContext, type ScrollOptions, type ScrollPosition, type TypeaheadOptions, type TypeaheadState, ariaAttr, contains, createScope, dataAttr, defaultItemToId, getActiveElement, getBeforeInputValue, getByText, getByTypeahead, getComputedStyle, getDocument, getDocumentElement, getEventTarget, getFirstFocusable, getFirstTabbable, getFocusables, getInitialFocus, getLastTabbable, getNearestOverflowAncestor, getNextTabbable, getNodeName, getOverflowAncestors, getParentNode, getPlatform, getScrollPosition, getTabbableEdges, getTabbables, getWindow, indexOfId, isApple, isComposingEvent, isDocument, isDom, isDownloadingEvent, isEditableElement, isFirefox, isFocusable, isHTMLElement, isHiddenElement, isInView, isIos, isMac, isNode, isOpeningInNewTab, isOverflowElement, isRootElement, isSafari, isSelfTarget, isShadowRoot, isTabbable, isTouchDevice, isValidTabEvent, isVisualViewport, isWebKit, isWindow, itemById, nextById, nextTick, observeAttributes, observeChildren, prevById, proxyTabFocus, query, queryAll, raf, scrollIntoView, set, setAttribute, setProperty, setStyle, visuallyHiddenStyle, waitForElement, waitForElements };
export { type InitialFocusOptions, type ItemToId, MAX_Z_INDEX, type ObserveAttributeOptions, type ObserveChildrenOptions, type OverflowAncestor, type ScopeContext, type ScrollOptions, type ScrollPosition, type TypeaheadOptions, type TypeaheadState, ariaAttr, contains, createScope, dataAttr, defaultItemToId, getActiveElement, getBeforeInputValue, getByText, getByTypeahead, getComputedStyle, getDocument, getDocumentElement, getEventTarget, getFirstFocusable, getFirstTabbable, getFocusables, getInitialFocus, getLastTabbable, getNearestOverflowAncestor, getNextTabbable, getNodeName, getOverflowAncestors, getParentNode, getPlatform, getScrollPosition, getTabbableEdges, getTabbables, getWindow, indexOfId, isApple, isComposingEvent, isDocument, isDom, isDownloadingEvent, isEditableElement, isFirefox, isFocusable, isHTMLElement, isHiddenElement, isInView, isIos, isMac, isModKey, isNode, isOpeningInNewTab, isOverflowElement, isRootElement, isSafari, isSelfTarget, isShadowRoot, isTabbable, isTouchDevice, isValidTabEvent, isVisualViewport, isWebKit, isWindow, itemById, nextById, nextTick, observeAttributes, observeChildren, prevById, proxyTabFocus, query, queryAll, raf, scrollIntoView, set, setAttribute, setProperty, setStyle, visuallyHiddenStyle, waitForElement, waitForElements };

2

dist/index.js

@@ -1,2 +0,2 @@

"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;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);var src_exports={};__export(src_exports,{MAX_Z_INDEX:()=>MAX_Z_INDEX,ariaAttr:()=>ariaAttr,contains:()=>contains,createScope:()=>createScope,dataAttr:()=>dataAttr,defaultItemToId:()=>defaultItemToId,getActiveElement:()=>getActiveElement,getBeforeInputValue:()=>getBeforeInputValue,getByText:()=>getByText,getByTypeahead:()=>getByTypeahead,getComputedStyle:()=>getComputedStyle,getDocument:()=>getDocument,getDocumentElement:()=>getDocumentElement,getEventTarget:()=>getEventTarget,getFirstFocusable:()=>getFirstFocusable,getFirstTabbable:()=>getFirstTabbable,getFocusables:()=>getFocusables,getInitialFocus:()=>getInitialFocus,getLastTabbable:()=>getLastTabbable,getNearestOverflowAncestor:()=>getNearestOverflowAncestor,getNextTabbable:()=>getNextTabbable,getNodeName:()=>getNodeName,getOverflowAncestors:()=>getOverflowAncestors,getParentNode:()=>getParentNode,getPlatform:()=>getPlatform,getScrollPosition:()=>getScrollPosition,getTabbableEdges:()=>getTabbableEdges,getTabbables:()=>getTabbables,getWindow:()=>getWindow,indexOfId:()=>indexOfId,isApple:()=>isApple,isComposingEvent:()=>isComposingEvent,isDocument:()=>isDocument,isDom:()=>isDom,isDownloadingEvent:()=>isDownloadingEvent,isEditableElement:()=>isEditableElement,isFirefox:()=>isFirefox,isFocusable:()=>isFocusable,isHTMLElement:()=>isHTMLElement,isHiddenElement:()=>isHiddenElement,isInView:()=>isInView,isIos:()=>isIos,isMac:()=>isMac,isNode:()=>isNode,isOpeningInNewTab:()=>isOpeningInNewTab,isOverflowElement:()=>isOverflowElement,isRootElement:()=>isRootElement,isSafari:()=>isSafari,isSelfTarget:()=>isSelfTarget,isShadowRoot:()=>isShadowRoot,isTabbable:()=>isTabbable,isTouchDevice:()=>isTouchDevice,isValidTabEvent:()=>isValidTabEvent,isVisualViewport:()=>isVisualViewport,isWebKit:()=>isWebKit,isWindow:()=>isWindow,itemById:()=>itemById,nextById:()=>nextById,nextTick:()=>nextTick,observeAttributes:()=>observeAttributes,observeChildren:()=>observeChildren,prevById:()=>prevById,proxyTabFocus:()=>proxyTabFocus,query:()=>query,queryAll:()=>queryAll,raf:()=>raf,scrollIntoView:()=>scrollIntoView,set:()=>set,setAttribute:()=>setAttribute,setProperty:()=>setProperty,setStyle:()=>setStyle,visuallyHiddenStyle:()=>visuallyHiddenStyle,waitForElement:()=>waitForElement,waitForElements:()=>waitForElements});module.exports=__toCommonJS(src_exports);var dataAttr=guard=>guard?"":void 0;var ariaAttr=guard=>guard?"true":void 0;var MAX_Z_INDEX=2147483647;var isHTMLElement=v=>typeof v==="object"&&v?.nodeType===Node.ELEMENT_NODE&&typeof v?.nodeName==="string";var isDocument=el=>el.nodeType===Node.DOCUMENT_NODE;var isWindow=el=>el!=null&&el===el.window;var isVisualViewport=el=>el!=null&&el.constructor.name==="VisualViewport";var getNodeName=node=>{if(isHTMLElement(node))return node.localName||"";return"#document"};function isRootElement(node){return["html","body","#document"].includes(getNodeName(node))}var isNode=el=>el.nodeType!==void 0;var isShadowRoot=el=>el&&isNode(el)&&el.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in el;function contains(parent,child){if(!parent||!child)return false;if(!isHTMLElement(parent)||!isHTMLElement(child))return false;return parent===child||parent.contains(child)}function getDocument(el){if(isDocument(el))return el;if(isWindow(el))return el.document;return el?.ownerDocument??document}function getDocumentElement(el){return getDocument(el).documentElement}function getWindow(el){if(isShadowRoot(el))return getWindow(el.host);if(isDocument(el))return el.defaultView??window;if(isHTMLElement(el))return el.ownerDocument?.defaultView??window;return window}function getActiveElement(el){const doc=getDocument(el);let activeElement=doc.activeElement;while(activeElement?.shadowRoot){const el2=activeElement.shadowRoot.activeElement;if(el2===activeElement)break;else activeElement=el2}return activeElement}var isDom=()=>typeof document!=="undefined";function getPlatform(){const agent=navigator.userAgentData;return agent?.platform??navigator.platform}var pt=v=>isDom()&&v.test(getPlatform());var ua=v=>isDom()&&v.test(navigator.userAgent);var vn=v=>isDom()&&v.test(navigator.vendor);var isTouchDevice=()=>isDom()&&!!navigator.maxTouchPoints;var isMac=()=>pt(/^Mac/)&&!isTouchDevice();var isSafari=()=>isApple()&&vn(/apple/i);var isFirefox=()=>ua(/firefox\//i);var isApple=()=>pt(/mac|iphone|ipad|ipod/i);var isIos=()=>pt(/iP(hone|ad|od)|iOS/);var isWebKit=()=>ua(/AppleWebKit/);function getBeforeInputValue(event){const{selectionStart,selectionEnd,value}=event.currentTarget;return value.slice(0,selectionStart)+event.data+value.slice(selectionEnd)}function getComposedPath(event){return event.composedPath?.()??event.nativeEvent?.composedPath?.()}function getEventTarget(event){const composedPath=getComposedPath(event);return composedPath?.[0]??event.target}var isSelfTarget=event=>{return contains(event.currentTarget,getEventTarget(event))};function isOpeningInNewTab(event){const element=event.currentTarget;if(!element)return false;const isAppleDevice=isApple();if(isAppleDevice&&!event.metaKey)return false;if(!isAppleDevice&&!event.ctrlKey)return false;const localName=element.localName;if(localName==="a")return true;if(localName==="button"&&element.type==="submit")return true;if(localName==="input"&&element.type==="submit")return true;return false}function isDownloadingEvent(event){const element=event.currentTarget;if(!element)return false;const localName=element.localName;if(!event.altKey)return false;if(localName==="a")return true;if(localName==="button"&&element.type==="submit")return true;if(localName==="input"&&element.type==="submit")return true;return false}function isComposingEvent(event){return event.nativeEvent?.isComposing??event.isComposing}var defaultItemToId=v=>v.id;function itemById(v,id,itemToId=defaultItemToId){return v.find(item=>itemToId(item)===id)}function indexOfId(v,id,itemToId=defaultItemToId){const item=itemById(v,id,itemToId);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]}var sanitize=str=>str.split("").map(char=>{const code=char.charCodeAt(0);if(code>0&&code<128)return char;if(code>=128&&code<=255)return`/x${code.toString(16)}`.replace("/","\\");return""}).join("").trim();var getValueText=item=>sanitize(item.dataset.valuetext??item.textContent??"");var match=(valueText,query2)=>valueText.trim().toLowerCase().startsWith(query2.toLowerCase());var wrap=(v,idx)=>{return v.map((_,index)=>v[(Math.max(idx,0)+index)%v.length])};function getByText(v,text,currentId,itemToId=defaultItemToId){const index=currentId?indexOfId(v,currentId,itemToId):-1;let items=currentId?wrap(v,index):v;const isSingleKey=text.length===1;if(isSingleKey){items=items.filter(item=>itemToId(item)!==currentId)}return items.find(item=>match(getValueText(item),text))}function getByTypeaheadImpl(_items,options){const{state,activeId,key,timeout=350,itemToId}=options;const search=state.keysSoFar+key;const isRepeated=search.length>1&&Array.from(search).every(char=>char===search[0]);const query2=isRepeated?search[0]:search;let items=_items.slice();const next=getByText(items,query2,activeId,itemToId);function cleanup(){clearTimeout(state.timer);state.timer=-1}function update(value){state.keysSoFar=value;cleanup();if(value!==""){state.timer=+setTimeout(()=>{update("");cleanup()},timeout)}}update(search);return next}var getByTypeahead=Object.assign(getByTypeaheadImpl,{defaultOptions:{keysSoFar:"",timer:-1},isValidEvent:isValidTypeaheadEvent});function isValidTypeaheadEvent(event){return event.key.length===1&&!event.ctrlKey&&!event.metaKey}var styleCache=new WeakMap;function getComputedStyle(el){if(!styleCache.has(el)){styleCache.set(el,getWindow(el).getComputedStyle(el))}return styleCache.get(el)}function getParentNode(node){if(getNodeName(node)==="html"){return node}const result=node.assignedSlot||node.parentNode||isShadowRoot(node)&&node.host||getDocumentElement(node);return isShadowRoot(result)?result.host:result}function getScrollPosition(element){if(isHTMLElement(element)){return{scrollLeft:element.scrollLeft,scrollTop:element.scrollTop}}return{scrollLeft:element.scrollX,scrollTop:element.scrollY}}var isHTMLElement2=element=>typeof element==="object"&&element!==null&&element.nodeType===1;var isFrame=element=>isHTMLElement2(element)&&element.tagName==="IFRAME";function isVisible(el){if(!isHTMLElement2(el))return false;return el.offsetWidth>0||el.offsetHeight>0||el.getClientRects().length>0}function hasNegativeTabIndex(element){const tabIndex=parseInt(element.getAttribute("tabindex")||"0",10);return tabIndex<0}var focusableSelector="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), details > summary:first-of-type";var getFocusables=(container,includeContainer=false)=>{if(!container)return[];const elements=Array.from(container.querySelectorAll(focusableSelector));const include=includeContainer==true||includeContainer=="if-empty"&&elements.length===0;if(include&&isHTMLElement2(container)&&isFocusable(container)){elements.unshift(container)}const focusableElements=elements.filter(isFocusable);focusableElements.forEach((element,i)=>{if(isFrame(element)&&element.contentDocument){const frameBody=element.contentDocument.body;focusableElements.splice(i,1,...getFocusables(frameBody))}});return focusableElements};function isFocusable(element){if(!element||element.closest("[inert]"))return false;return element.matches(focusableSelector)&&isVisible(element)}function getFirstFocusable(container,includeContainer){const[first]=getFocusables(container,includeContainer);return first||null}function getTabbables(container,includeContainer){if(!container)return[];const elements=Array.from(container.querySelectorAll(focusableSelector));const tabbableElements=elements.filter(isTabbable);if(includeContainer&&isTabbable(container)){tabbableElements.unshift(container)}tabbableElements.forEach((element,i)=>{if(isFrame(element)&&element.contentDocument){const frameBody=element.contentDocument.body;const allFrameTabbable=getTabbables(frameBody);tabbableElements.splice(i,1,...allFrameTabbable)}});if(!tabbableElements.length&&includeContainer){return elements}return tabbableElements}function isTabbable(el){if(el!=null&&el.tabIndex>0)return true;return isFocusable(el)&&!hasNegativeTabIndex(el)}function getFirstTabbable(container,includeContainer){const[first]=getTabbables(container,includeContainer);return first||null}function getLastTabbable(container,includeContainer){const elements=getTabbables(container,includeContainer);return elements[elements.length-1]||null}function getTabbableEdges(container,includeContainer){const elements=getTabbables(container,includeContainer);const first=elements[0]||null;const last=elements[elements.length-1]||null;return[first,last]}function getNextTabbable(container,current){const tabbables=getTabbables(container);const doc=container?.ownerDocument||document;const currentElement=current??doc.activeElement;if(!currentElement)return null;const index=tabbables.indexOf(currentElement);return tabbables[index+1]||null}function getInitialFocus(container,getInitialEl){let node=null;node||(node=typeof getInitialEl==="function"?getInitialEl():getInitialEl);node||(node=container?.querySelector("[data-autofocus],[autofocus]"));node||(node=getFirstTabbable(container));return node||container||void 0}function isValidTabEvent(event){const container=event.currentTarget;if(!container)return false;const[firstTabbable,lastTabbable]=getTabbableEdges(container);const doc=container.ownerDocument||document;if(doc.activeElement===firstTabbable&&event.shiftKey)return false;if(doc.activeElement===lastTabbable&&!event.shiftKey)return false;if(!firstTabbable&&!lastTabbable)return false;return true}function isEditableElement(el){if(el==null||!isHTMLElement(el)){return false}try{const win=getWindow(el);return el instanceof win.HTMLInputElement&&el.selectionStart!=null||/(textarea|select)/.test(el.localName)||el.isContentEditable}catch{return false}}function isHiddenElement(node){if(node.parentElement&&isHiddenElement(node.parentElement))return true;return node.hidden}var OVERFLOW_RE=/auto|scroll|overlay|hidden|clip/;function isOverflowElement(el){const win=getWindow(el);const{overflow,overflowX,overflowY,display}=win.getComputedStyle(el);return OVERFLOW_RE.test(overflow+overflowY+overflowX)&&!["inline","contents"].includes(display)}function nextTick(fn){const set2=new Set;function raf2(fn2){const id=globalThis.requestAnimationFrame(fn2);set2.add(()=>globalThis.cancelAnimationFrame(id))}raf2(()=>raf2(fn));return function cleanup(){set2.forEach(fn2=>fn2())}}function raf(fn){const id=globalThis.requestAnimationFrame(fn);return()=>{globalThis.cancelAnimationFrame(id)}}function observeAttributesImpl(node,options){if(!node)return;const{attributes,callback:fn}=options;const win=node.ownerDocument.defaultView||window;const obs=new win.MutationObserver(changes=>{for(const change of changes){if(change.type==="attributes"&&change.attributeName&&attributes.includes(change.attributeName)){fn(change)}}});obs.observe(node,{attributes:true,attributeFilter:attributes});return()=>obs.disconnect()}function observeAttributes(nodeOrFn,options){const{defer}=options;const func=defer?raf:v=>v();const cleanups2=[];cleanups2.push(func(()=>{const node=typeof nodeOrFn==="function"?nodeOrFn():nodeOrFn;cleanups2.push(observeAttributesImpl(node,options))}));return()=>{cleanups2.forEach(fn=>fn?.())}}function observeChildrenImpl(node,options){const{callback:fn}=options;if(!node)return;const win=node.ownerDocument.defaultView||window;const obs=new win.MutationObserver(fn);obs.observe(node,{childList:true,subtree:true});return()=>obs.disconnect()}function observeChildren(nodeOrFn,options){const{defer}=options;const func=defer?raf:v=>v();const cleanups2=[];cleanups2.push(func(()=>{const node=typeof nodeOrFn==="function"?nodeOrFn():nodeOrFn;cleanups2.push(observeChildrenImpl(node,options))}));return()=>{cleanups2.forEach(fn=>fn?.())}}function getNearestOverflowAncestor(el){const parentNode=getParentNode(el);if(isRootElement(parentNode)){return getDocument(parentNode).body}if(isHTMLElement(parentNode)&&isOverflowElement(parentNode)){return parentNode}return getNearestOverflowAncestor(parentNode)}function getOverflowAncestors(el,list=[]){const scrollableAncestor=getNearestOverflowAncestor(el);const isBody=scrollableAncestor===el.ownerDocument.body;const win=getWindow(scrollableAncestor);if(isBody){return list.concat(win,win.visualViewport||[],isOverflowElement(scrollableAncestor)?scrollableAncestor:[])}return list.concat(scrollableAncestor,getOverflowAncestors(scrollableAncestor,[]))}var getRect=el=>{if(isHTMLElement(el)){return el.getBoundingClientRect()}if(isVisualViewport(el)){return{top:0,left:0,bottom:el.height,right:el.width}}return{top:0,left:0,bottom:el.innerHeight,right:el.innerWidth}};function isInView(el,ancestor){if(!isHTMLElement(el))return true;const ancestorRect=getRect(ancestor);const elRect=el.getBoundingClientRect();return elRect.top>=ancestorRect.top&&elRect.left>=ancestorRect.left&&elRect.bottom<=ancestorRect.bottom&&elRect.right<=ancestorRect.right}function proxyTabFocusImpl(container,options={}){const{triggerElement,onFocus}=options;const doc=container?.ownerDocument||document;const body=doc.body;function onKeyDown(event){if(event.key!=="Tab")return;let elementToFocus=null;const[firstTabbable,lastTabbable]=getTabbableEdges(container,true);const noTabbableElements=!firstTabbable&&!lastTabbable;if(event.shiftKey&&(doc.activeElement===firstTabbable||noTabbableElements)){elementToFocus=triggerElement}else if(!event.shiftKey&&doc.activeElement===triggerElement){elementToFocus=firstTabbable}else if(!event.shiftKey&&(doc.activeElement===lastTabbable||noTabbableElements)){elementToFocus=getNextTabbable(body,triggerElement)}if(!elementToFocus)return;event.preventDefault();if(typeof onFocus==="function"){onFocus(elementToFocus)}else{elementToFocus.focus()}}doc?.addEventListener("keydown",onKeyDown,true);return()=>{doc?.removeEventListener("keydown",onKeyDown,true)}}function proxyTabFocus(container,options){const{defer,triggerElement,...restOptions}=options;const func=defer?raf:v=>v();const cleanups2=[];cleanups2.push(func(()=>{const node=typeof container==="function"?container():container;const trigger=typeof triggerElement==="function"?triggerElement():triggerElement;cleanups2.push(proxyTabFocusImpl(node,{triggerElement:trigger,...restOptions}))}));return()=>{cleanups2.forEach(fn=>fn?.())}}function queryAll(root,selector){return Array.from(root?.querySelectorAll(selector)??[])}function query(root,selector){return root?.querySelector(selector)??null}function createScope(methods){const screen={getRootNode:ctx=>ctx.getRootNode?.()??document,getDoc:ctx=>getDocument(screen.getRootNode(ctx)),getWin:ctx=>screen.getDoc(ctx).defaultView??window,getActiveElement:ctx=>screen.getDoc(ctx).activeElement,isActiveElement:(ctx,elem)=>elem===screen.getActiveElement(ctx),getById:(ctx,id)=>screen.getRootNode(ctx).getElementById(id),setValue:(elem,value)=>{if(elem==null||value==null)return;const valueAsString=value.toString();if(elem.value===valueAsString)return;elem.value=value.toString()}};return{...screen,...methods}}function isScrollable(el){return el.scrollHeight>el.clientHeight||el.scrollWidth>el.clientWidth}function scrollIntoView(el,options){const{rootEl,...scrollOptions}=options||{};if(!el||!rootEl){return}if(!isOverflowElement(rootEl)||!isScrollable(rootEl)){return}el.scrollIntoView(scrollOptions)}var cleanups=new WeakMap;function set(element,key,setup){if(!cleanups.has(element)){cleanups.set(element,new Map)}const elementCleanups=cleanups.get(element);const prevCleanup=elementCleanups.get(key);if(!prevCleanup){elementCleanups.set(key,setup());return()=>{elementCleanups.get(key)?.();elementCleanups.delete(key)}}const cleanup=setup();const nextCleanup=()=>{cleanup();prevCleanup();elementCleanups.delete(key)};elementCleanups.set(key,nextCleanup);return()=>{const isCurrent=elementCleanups.get(key)===nextCleanup;if(!isCurrent)return;cleanup();elementCleanups.set(key,prevCleanup)}}function setAttribute(element,attr,value){const setup=()=>{const previousValue=element.getAttribute(attr);element.setAttribute(attr,value);return()=>{if(previousValue==null){element.removeAttribute(attr)}else{element.setAttribute(attr,previousValue)}}};return set(element,attr,setup)}function setProperty(element,property,value){const setup=()=>{const exists=property in element;const previousValue=element[property];element[property]=value;return()=>{if(!exists){delete element[property]}else{element[property]=previousValue}}};return set(element,property,setup)}function setStyle(element,style){if(!element)return()=>{};const setup=()=>{const prevStyle=element.style.cssText;Object.assign(element.style,style);return()=>{element.style.cssText=prevStyle}};return set(element,"style",setup)}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"};var fps=1e3/60;function waitForElement(query2,cb){const el=query2();if(isHTMLElement(el)&&el.isConnected){cb(el);return()=>void 0}else{const timerId=setInterval(()=>{const el2=query2();if(isHTMLElement(el2)&&el2.isConnected){cb(el2);clearInterval(timerId)}},fps);return()=>clearInterval(timerId)}}function waitForElements(queries,cb){const cleanups2=[];queries?.forEach(query2=>{const clean=waitForElement(query2,cb);cleanups2.push(clean)});return()=>{cleanups2.forEach(fn=>fn())}}0&&(module.exports={MAX_Z_INDEX,ariaAttr,contains,createScope,dataAttr,defaultItemToId,getActiveElement,getBeforeInputValue,getByText,getByTypeahead,getComputedStyle,getDocument,getDocumentElement,getEventTarget,getFirstFocusable,getFirstTabbable,getFocusables,getInitialFocus,getLastTabbable,getNearestOverflowAncestor,getNextTabbable,getNodeName,getOverflowAncestors,getParentNode,getPlatform,getScrollPosition,getTabbableEdges,getTabbables,getWindow,indexOfId,isApple,isComposingEvent,isDocument,isDom,isDownloadingEvent,isEditableElement,isFirefox,isFocusable,isHTMLElement,isHiddenElement,isInView,isIos,isMac,isNode,isOpeningInNewTab,isOverflowElement,isRootElement,isSafari,isSelfTarget,isShadowRoot,isTabbable,isTouchDevice,isValidTabEvent,isVisualViewport,isWebKit,isWindow,itemById,nextById,nextTick,observeAttributes,observeChildren,prevById,proxyTabFocus,query,queryAll,raf,scrollIntoView,set,setAttribute,setProperty,setStyle,visuallyHiddenStyle,waitForElement,waitForElements});
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;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);var src_exports={};__export(src_exports,{MAX_Z_INDEX:()=>MAX_Z_INDEX,ariaAttr:()=>ariaAttr,contains:()=>contains,createScope:()=>createScope,dataAttr:()=>dataAttr,defaultItemToId:()=>defaultItemToId,getActiveElement:()=>getActiveElement,getBeforeInputValue:()=>getBeforeInputValue,getByText:()=>getByText,getByTypeahead:()=>getByTypeahead,getComputedStyle:()=>getComputedStyle,getDocument:()=>getDocument,getDocumentElement:()=>getDocumentElement,getEventTarget:()=>getEventTarget,getFirstFocusable:()=>getFirstFocusable,getFirstTabbable:()=>getFirstTabbable,getFocusables:()=>getFocusables,getInitialFocus:()=>getInitialFocus,getLastTabbable:()=>getLastTabbable,getNearestOverflowAncestor:()=>getNearestOverflowAncestor,getNextTabbable:()=>getNextTabbable,getNodeName:()=>getNodeName,getOverflowAncestors:()=>getOverflowAncestors,getParentNode:()=>getParentNode,getPlatform:()=>getPlatform,getScrollPosition:()=>getScrollPosition,getTabbableEdges:()=>getTabbableEdges,getTabbables:()=>getTabbables,getWindow:()=>getWindow,indexOfId:()=>indexOfId,isApple:()=>isApple,isComposingEvent:()=>isComposingEvent,isDocument:()=>isDocument,isDom:()=>isDom,isDownloadingEvent:()=>isDownloadingEvent,isEditableElement:()=>isEditableElement,isFirefox:()=>isFirefox,isFocusable:()=>isFocusable,isHTMLElement:()=>isHTMLElement,isHiddenElement:()=>isHiddenElement,isInView:()=>isInView,isIos:()=>isIos,isMac:()=>isMac,isModKey:()=>isModKey,isNode:()=>isNode,isOpeningInNewTab:()=>isOpeningInNewTab,isOverflowElement:()=>isOverflowElement,isRootElement:()=>isRootElement,isSafari:()=>isSafari,isSelfTarget:()=>isSelfTarget,isShadowRoot:()=>isShadowRoot,isTabbable:()=>isTabbable,isTouchDevice:()=>isTouchDevice,isValidTabEvent:()=>isValidTabEvent,isVisualViewport:()=>isVisualViewport,isWebKit:()=>isWebKit,isWindow:()=>isWindow,itemById:()=>itemById,nextById:()=>nextById,nextTick:()=>nextTick,observeAttributes:()=>observeAttributes,observeChildren:()=>observeChildren,prevById:()=>prevById,proxyTabFocus:()=>proxyTabFocus,query:()=>query,queryAll:()=>queryAll,raf:()=>raf,scrollIntoView:()=>scrollIntoView,set:()=>set,setAttribute:()=>setAttribute,setProperty:()=>setProperty,setStyle:()=>setStyle,visuallyHiddenStyle:()=>visuallyHiddenStyle,waitForElement:()=>waitForElement,waitForElements:()=>waitForElements});module.exports=__toCommonJS(src_exports);var dataAttr=guard=>guard?"":void 0;var ariaAttr=guard=>guard?"true":void 0;var MAX_Z_INDEX=2147483647;var isHTMLElement=v=>typeof v==="object"&&v?.nodeType===Node.ELEMENT_NODE&&typeof v?.nodeName==="string";var isDocument=el=>el.nodeType===Node.DOCUMENT_NODE;var isWindow=el=>el!=null&&el===el.window;var isVisualViewport=el=>el!=null&&el.constructor.name==="VisualViewport";var getNodeName=node=>{if(isHTMLElement(node))return node.localName||"";return"#document"};function isRootElement(node){return["html","body","#document"].includes(getNodeName(node))}var isNode=el=>el.nodeType!==void 0;var isShadowRoot=el=>el&&isNode(el)&&el.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in el;function contains(parent,child){if(!parent||!child)return false;if(!isHTMLElement(parent)||!isHTMLElement(child))return false;return parent===child||parent.contains(child)}function getDocument(el){if(isDocument(el))return el;if(isWindow(el))return el.document;return el?.ownerDocument??document}function getDocumentElement(el){return getDocument(el).documentElement}function getWindow(el){if(isShadowRoot(el))return getWindow(el.host);if(isDocument(el))return el.defaultView??window;if(isHTMLElement(el))return el.ownerDocument?.defaultView??window;return window}function getActiveElement(el){const doc=getDocument(el);let activeElement=doc.activeElement;while(activeElement?.shadowRoot){const el2=activeElement.shadowRoot.activeElement;if(el2===activeElement)break;else activeElement=el2}return activeElement}var isDom=()=>typeof document!=="undefined";function getPlatform(){const agent=navigator.userAgentData;return agent?.platform??navigator.platform}if(isDom())console.log(getPlatform());var pt=v=>isDom()&&v.test(getPlatform());var ua=v=>isDom()&&v.test(navigator.userAgent);var vn=v=>isDom()&&v.test(navigator.vendor);var isTouchDevice=()=>isDom()&&!!navigator.maxTouchPoints;var isMac=()=>pt(/^Mac/);var isSafari=()=>isApple()&&vn(/apple/i);var isFirefox=()=>ua(/firefox\//i);var isApple=()=>pt(/mac|iphone|ipad|ipod/i);var isIos=()=>pt(/iP(hone|ad|od)|iOS/);var isWebKit=()=>ua(/AppleWebKit/);var isModKey=event=>isApple()?event.metaKey:event.ctrlKey;function getBeforeInputValue(event){const{selectionStart,selectionEnd,value}=event.currentTarget;return value.slice(0,selectionStart)+event.data+value.slice(selectionEnd)}function getComposedPath(event){return event.composedPath?.()??event.nativeEvent?.composedPath?.()}function getEventTarget(event){const composedPath=getComposedPath(event);return composedPath?.[0]??event.target}var isSelfTarget=event=>{return contains(event.currentTarget,getEventTarget(event))};function isOpeningInNewTab(event){const element=event.currentTarget;if(!element)return false;const isAppleDevice=isApple();if(isAppleDevice&&!event.metaKey)return false;if(!isAppleDevice&&!event.ctrlKey)return false;const localName=element.localName;if(localName==="a")return true;if(localName==="button"&&element.type==="submit")return true;if(localName==="input"&&element.type==="submit")return true;return false}function isDownloadingEvent(event){const element=event.currentTarget;if(!element)return false;const localName=element.localName;if(!event.altKey)return false;if(localName==="a")return true;if(localName==="button"&&element.type==="submit")return true;if(localName==="input"&&element.type==="submit")return true;return false}function isComposingEvent(event){return event.nativeEvent?.isComposing??event.isComposing}var defaultItemToId=v=>v.id;function itemById(v,id,itemToId=defaultItemToId){return v.find(item=>itemToId(item)===id)}function indexOfId(v,id,itemToId=defaultItemToId){const item=itemById(v,id,itemToId);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]}var sanitize=str=>str.split("").map(char=>{const code=char.charCodeAt(0);if(code>0&&code<128)return char;if(code>=128&&code<=255)return`/x${code.toString(16)}`.replace("/","\\");return""}).join("").trim();var getValueText=item=>sanitize(item.dataset.valuetext??item.textContent??"");var match=(valueText,query2)=>valueText.trim().toLowerCase().startsWith(query2.toLowerCase());var wrap=(v,idx)=>{return v.map((_,index)=>v[(Math.max(idx,0)+index)%v.length])};function getByText(v,text,currentId,itemToId=defaultItemToId){const index=currentId?indexOfId(v,currentId,itemToId):-1;let items=currentId?wrap(v,index):v;const isSingleKey=text.length===1;if(isSingleKey){items=items.filter(item=>itemToId(item)!==currentId)}return items.find(item=>match(getValueText(item),text))}function getByTypeaheadImpl(_items,options){const{state,activeId,key,timeout=350,itemToId}=options;const search=state.keysSoFar+key;const isRepeated=search.length>1&&Array.from(search).every(char=>char===search[0]);const query2=isRepeated?search[0]:search;let items=_items.slice();const next=getByText(items,query2,activeId,itemToId);function cleanup(){clearTimeout(state.timer);state.timer=-1}function update(value){state.keysSoFar=value;cleanup();if(value!==""){state.timer=+setTimeout(()=>{update("");cleanup()},timeout)}}update(search);return next}var getByTypeahead=Object.assign(getByTypeaheadImpl,{defaultOptions:{keysSoFar:"",timer:-1},isValidEvent:isValidTypeaheadEvent});function isValidTypeaheadEvent(event){return event.key.length===1&&!event.ctrlKey&&!event.metaKey}var styleCache=new WeakMap;function getComputedStyle(el){if(!styleCache.has(el)){styleCache.set(el,getWindow(el).getComputedStyle(el))}return styleCache.get(el)}function getParentNode(node){if(getNodeName(node)==="html"){return node}const result=node.assignedSlot||node.parentNode||isShadowRoot(node)&&node.host||getDocumentElement(node);return isShadowRoot(result)?result.host:result}function getScrollPosition(element){if(isHTMLElement(element)){return{scrollLeft:element.scrollLeft,scrollTop:element.scrollTop}}return{scrollLeft:element.scrollX,scrollTop:element.scrollY}}var isHTMLElement2=element=>typeof element==="object"&&element!==null&&element.nodeType===1;var isFrame=element=>isHTMLElement2(element)&&element.tagName==="IFRAME";function isVisible(el){if(!isHTMLElement2(el))return false;return el.offsetWidth>0||el.offsetHeight>0||el.getClientRects().length>0}function hasNegativeTabIndex(element){const tabIndex=parseInt(element.getAttribute("tabindex")||"0",10);return tabIndex<0}var focusableSelector="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), details > summary:first-of-type";var getFocusables=(container,includeContainer=false)=>{if(!container)return[];const elements=Array.from(container.querySelectorAll(focusableSelector));const include=includeContainer==true||includeContainer=="if-empty"&&elements.length===0;if(include&&isHTMLElement2(container)&&isFocusable(container)){elements.unshift(container)}const focusableElements=elements.filter(isFocusable);focusableElements.forEach((element,i)=>{if(isFrame(element)&&element.contentDocument){const frameBody=element.contentDocument.body;focusableElements.splice(i,1,...getFocusables(frameBody))}});return focusableElements};function isFocusable(element){if(!element||element.closest("[inert]"))return false;return element.matches(focusableSelector)&&isVisible(element)}function getFirstFocusable(container,includeContainer){const[first]=getFocusables(container,includeContainer);return first||null}function getTabbables(container,includeContainer){if(!container)return[];const elements=Array.from(container.querySelectorAll(focusableSelector));const tabbableElements=elements.filter(isTabbable);if(includeContainer&&isTabbable(container)){tabbableElements.unshift(container)}tabbableElements.forEach((element,i)=>{if(isFrame(element)&&element.contentDocument){const frameBody=element.contentDocument.body;const allFrameTabbable=getTabbables(frameBody);tabbableElements.splice(i,1,...allFrameTabbable)}});if(!tabbableElements.length&&includeContainer){return elements}return tabbableElements}function isTabbable(el){if(el!=null&&el.tabIndex>0)return true;return isFocusable(el)&&!hasNegativeTabIndex(el)}function getFirstTabbable(container,includeContainer){const[first]=getTabbables(container,includeContainer);return first||null}function getLastTabbable(container,includeContainer){const elements=getTabbables(container,includeContainer);return elements[elements.length-1]||null}function getTabbableEdges(container,includeContainer){const elements=getTabbables(container,includeContainer);const first=elements[0]||null;const last=elements[elements.length-1]||null;return[first,last]}function getNextTabbable(container,current){const tabbables=getTabbables(container);const doc=container?.ownerDocument||document;const currentElement=current??doc.activeElement;if(!currentElement)return null;const index=tabbables.indexOf(currentElement);return tabbables[index+1]||null}function getInitialFocus(options){const{root,getInitialEl,enabled=true}=options;if(!enabled)return root||void 0;let node=null;node||(node=typeof getInitialEl==="function"?getInitialEl():getInitialEl);node||(node=root?.querySelector("[data-autofocus],[autofocus]"));node||(node=getFirstTabbable(root));return node||root||void 0}function isValidTabEvent(event){const container=event.currentTarget;if(!container)return false;const[firstTabbable,lastTabbable]=getTabbableEdges(container);const doc=container.ownerDocument||document;if(doc.activeElement===firstTabbable&&event.shiftKey)return false;if(doc.activeElement===lastTabbable&&!event.shiftKey)return false;if(!firstTabbable&&!lastTabbable)return false;return true}function isEditableElement(el){if(el==null||!isHTMLElement(el)){return false}try{const win=getWindow(el);return el instanceof win.HTMLInputElement&&el.selectionStart!=null||/(textarea|select)/.test(el.localName)||el.isContentEditable}catch{return false}}function isHiddenElement(node){if(node.parentElement&&isHiddenElement(node.parentElement))return true;return node.hidden}var OVERFLOW_RE=/auto|scroll|overlay|hidden|clip/;function isOverflowElement(el){const win=getWindow(el);const{overflow,overflowX,overflowY,display}=win.getComputedStyle(el);return OVERFLOW_RE.test(overflow+overflowY+overflowX)&&!["inline","contents"].includes(display)}function nextTick(fn){const set2=new Set;function raf2(fn2){const id=globalThis.requestAnimationFrame(fn2);set2.add(()=>globalThis.cancelAnimationFrame(id))}raf2(()=>raf2(fn));return function cleanup(){set2.forEach(fn2=>fn2())}}function raf(fn){const id=globalThis.requestAnimationFrame(fn);return()=>{globalThis.cancelAnimationFrame(id)}}function observeAttributesImpl(node,options){if(!node)return;const{attributes,callback:fn}=options;const win=node.ownerDocument.defaultView||window;const obs=new win.MutationObserver(changes=>{for(const change of changes){if(change.type==="attributes"&&change.attributeName&&attributes.includes(change.attributeName)){fn(change)}}});obs.observe(node,{attributes:true,attributeFilter:attributes});return()=>obs.disconnect()}function observeAttributes(nodeOrFn,options){const{defer}=options;const func=defer?raf:v=>v();const cleanups2=[];cleanups2.push(func(()=>{const node=typeof nodeOrFn==="function"?nodeOrFn():nodeOrFn;cleanups2.push(observeAttributesImpl(node,options))}));return()=>{cleanups2.forEach(fn=>fn?.())}}function observeChildrenImpl(node,options){const{callback:fn}=options;if(!node)return;const win=node.ownerDocument.defaultView||window;const obs=new win.MutationObserver(fn);obs.observe(node,{childList:true,subtree:true});return()=>obs.disconnect()}function observeChildren(nodeOrFn,options){const{defer}=options;const func=defer?raf:v=>v();const cleanups2=[];cleanups2.push(func(()=>{const node=typeof nodeOrFn==="function"?nodeOrFn():nodeOrFn;cleanups2.push(observeChildrenImpl(node,options))}));return()=>{cleanups2.forEach(fn=>fn?.())}}function getNearestOverflowAncestor(el){const parentNode=getParentNode(el);if(isRootElement(parentNode)){return getDocument(parentNode).body}if(isHTMLElement(parentNode)&&isOverflowElement(parentNode)){return parentNode}return getNearestOverflowAncestor(parentNode)}function getOverflowAncestors(el,list=[]){const scrollableAncestor=getNearestOverflowAncestor(el);const isBody=scrollableAncestor===el.ownerDocument.body;const win=getWindow(scrollableAncestor);if(isBody){return list.concat(win,win.visualViewport||[],isOverflowElement(scrollableAncestor)?scrollableAncestor:[])}return list.concat(scrollableAncestor,getOverflowAncestors(scrollableAncestor,[]))}var getRect=el=>{if(isHTMLElement(el)){return el.getBoundingClientRect()}if(isVisualViewport(el)){return{top:0,left:0,bottom:el.height,right:el.width}}return{top:0,left:0,bottom:el.innerHeight,right:el.innerWidth}};function isInView(el,ancestor){if(!isHTMLElement(el))return true;const ancestorRect=getRect(ancestor);const elRect=el.getBoundingClientRect();return elRect.top>=ancestorRect.top&&elRect.left>=ancestorRect.left&&elRect.bottom<=ancestorRect.bottom&&elRect.right<=ancestorRect.right}function proxyTabFocusImpl(container,options={}){const{triggerElement,onFocus}=options;const doc=container?.ownerDocument||document;const body=doc.body;function onKeyDown(event){if(event.key!=="Tab")return;let elementToFocus=null;const[firstTabbable,lastTabbable]=getTabbableEdges(container,true);const noTabbableElements=!firstTabbable&&!lastTabbable;if(event.shiftKey&&(doc.activeElement===firstTabbable||noTabbableElements)){elementToFocus=triggerElement}else if(!event.shiftKey&&doc.activeElement===triggerElement){elementToFocus=firstTabbable}else if(!event.shiftKey&&(doc.activeElement===lastTabbable||noTabbableElements)){elementToFocus=getNextTabbable(body,triggerElement)}if(!elementToFocus)return;event.preventDefault();if(typeof onFocus==="function"){onFocus(elementToFocus)}else{elementToFocus.focus()}}doc?.addEventListener("keydown",onKeyDown,true);return()=>{doc?.removeEventListener("keydown",onKeyDown,true)}}function proxyTabFocus(container,options){const{defer,triggerElement,...restOptions}=options;const func=defer?raf:v=>v();const cleanups2=[];cleanups2.push(func(()=>{const node=typeof container==="function"?container():container;const trigger=typeof triggerElement==="function"?triggerElement():triggerElement;cleanups2.push(proxyTabFocusImpl(node,{triggerElement:trigger,...restOptions}))}));return()=>{cleanups2.forEach(fn=>fn?.())}}function queryAll(root,selector){return Array.from(root?.querySelectorAll(selector)??[])}function query(root,selector){return root?.querySelector(selector)??null}function createScope(methods){const screen={getRootNode:ctx=>ctx.getRootNode?.()??document,getDoc:ctx=>getDocument(screen.getRootNode(ctx)),getWin:ctx=>screen.getDoc(ctx).defaultView??window,getActiveElement:ctx=>screen.getDoc(ctx).activeElement,isActiveElement:(ctx,elem)=>elem===screen.getActiveElement(ctx),getById:(ctx,id)=>screen.getRootNode(ctx).getElementById(id),setValue:(elem,value)=>{if(elem==null||value==null)return;const valueAsString=value.toString();if(elem.value===valueAsString)return;elem.value=value.toString()}};return{...screen,...methods}}function isScrollable(el){return el.scrollHeight>el.clientHeight||el.scrollWidth>el.clientWidth}function scrollIntoView(el,options){const{rootEl,...scrollOptions}=options||{};if(!el||!rootEl){return}if(!isOverflowElement(rootEl)||!isScrollable(rootEl)){return}el.scrollIntoView(scrollOptions)}var cleanups=new WeakMap;function set(element,key,setup){if(!cleanups.has(element)){cleanups.set(element,new Map)}const elementCleanups=cleanups.get(element);const prevCleanup=elementCleanups.get(key);if(!prevCleanup){elementCleanups.set(key,setup());return()=>{elementCleanups.get(key)?.();elementCleanups.delete(key)}}const cleanup=setup();const nextCleanup=()=>{cleanup();prevCleanup();elementCleanups.delete(key)};elementCleanups.set(key,nextCleanup);return()=>{const isCurrent=elementCleanups.get(key)===nextCleanup;if(!isCurrent)return;cleanup();elementCleanups.set(key,prevCleanup)}}function setAttribute(element,attr,value){const setup=()=>{const previousValue=element.getAttribute(attr);element.setAttribute(attr,value);return()=>{if(previousValue==null){element.removeAttribute(attr)}else{element.setAttribute(attr,previousValue)}}};return set(element,attr,setup)}function setProperty(element,property,value){const setup=()=>{const exists=property in element;const previousValue=element[property];element[property]=value;return()=>{if(!exists){delete element[property]}else{element[property]=previousValue}}};return set(element,property,setup)}function setStyle(element,style){if(!element)return()=>{};const setup=()=>{const prevStyle=element.style.cssText;Object.assign(element.style,style);return()=>{element.style.cssText=prevStyle}};return set(element,"style",setup)}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"};var fps=1e3/60;function waitForElement(query2,cb){const el=query2();if(isHTMLElement(el)&&el.isConnected){cb(el);return()=>void 0}else{const timerId=setInterval(()=>{const el2=query2();if(isHTMLElement(el2)&&el2.isConnected){cb(el2);clearInterval(timerId)}},fps);return()=>clearInterval(timerId)}}function waitForElements(queries,cb){const cleanups2=[];queries?.forEach(query2=>{const clean=waitForElement(query2,cb);cleanups2.push(clean)});return()=>{cleanups2.forEach(fn=>fn())}}0&&(module.exports={MAX_Z_INDEX,ariaAttr,contains,createScope,dataAttr,defaultItemToId,getActiveElement,getBeforeInputValue,getByText,getByTypeahead,getComputedStyle,getDocument,getDocumentElement,getEventTarget,getFirstFocusable,getFirstTabbable,getFocusables,getInitialFocus,getLastTabbable,getNearestOverflowAncestor,getNextTabbable,getNodeName,getOverflowAncestors,getParentNode,getPlatform,getScrollPosition,getTabbableEdges,getTabbables,getWindow,indexOfId,isApple,isComposingEvent,isDocument,isDom,isDownloadingEvent,isEditableElement,isFirefox,isFocusable,isHTMLElement,isHiddenElement,isInView,isIos,isMac,isModKey,isNode,isOpeningInNewTab,isOverflowElement,isRootElement,isSafari,isSelfTarget,isShadowRoot,isTabbable,isTouchDevice,isValidTabEvent,isVisualViewport,isWebKit,isWindow,itemById,nextById,nextTick,observeAttributes,observeChildren,prevById,proxyTabFocus,query,queryAll,raf,scrollIntoView,set,setAttribute,setProperty,setStyle,visuallyHiddenStyle,waitForElement,waitForElements});
//# sourceMappingURL=index.js.map
{
"name": "@zag-js/dom-query",
"version": "0.51.2",
"version": "0.52.0",
"description": "The dom helper library for zag.js machines",

@@ -5,0 +5,0 @@ "keywords": [

import { getFirstTabbable, getTabbableEdges } from "./tabbable"
export function getInitialFocus(
container: HTMLElement | null,
getInitialEl?: () => HTMLElement | null,
): HTMLElement | undefined {
export interface InitialFocusOptions {
root: HTMLElement | null
getInitialEl?: () => HTMLElement | null
enabled?: boolean
}
export function getInitialFocus(options: InitialFocusOptions): HTMLElement | undefined {
const { root, getInitialEl, enabled = true } = options
if (!enabled) return root || undefined
let node: HTMLElement | null | undefined = null
node ||= typeof getInitialEl === "function" ? getInitialEl() : getInitialEl
node ||= container?.querySelector<HTMLElement>("[data-autofocus],[autofocus]")
node ||= getFirstTabbable(container)
return node || container || undefined
node ||= root?.querySelector<HTMLElement>("[data-autofocus],[autofocus]")
node ||= getFirstTabbable(root)
return node || root || undefined
}

@@ -13,0 +22,0 @@

@@ -8,2 +8,4 @@ export const isDom = () => typeof document !== "undefined"

if (isDom()) console.log(getPlatform())
const pt = (v: RegExp) => isDom() && v.test(getPlatform())

@@ -14,3 +16,3 @@ const ua = (v: RegExp) => isDom() && v.test(navigator.userAgent)

export const isTouchDevice = () => isDom() && !!navigator.maxTouchPoints
export const isMac = () => pt(/^Mac/) && !isTouchDevice()
export const isMac = () => pt(/^Mac/)
export const isSafari = () => isApple() && vn(/apple/i)

@@ -21,1 +23,4 @@ export const isFirefox = () => ua(/firefox\//i)

export const isWebKit = () => ua(/AppleWebKit/)
export const isModKey = (event: Pick<KeyboardEvent, "metaKey" | "ctrlKey">) =>
isApple() ? event.metaKey : event.ctrlKey

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc