@zag-js/dom-query
Advanced tools
Comparing version 0.79.1 to 0.79.2
@@ -0,1 +1,7 @@ | ||
interface EventMap extends DocumentEventMap, WindowEventMap, HTMLElementEventMap { | ||
} | ||
type Node$1 = Document | HTMLElement | EventTarget | null; | ||
type Target$1 = (() => Node$1) | Node$1; | ||
declare const addDomEvent: <K extends keyof EventMap>(target: Target$1, eventName: K, handler: (event: EventMap[K]) => void, options?: boolean | AddEventListenerOptions) => () => void; | ||
type Booleanish = boolean | "true" | "false"; | ||
@@ -209,2 +215,3 @@ | ||
declare function getNextTabbable(container: HTMLElement | null, current?: HTMLElement | null): HTMLElement | null; | ||
declare function getTabIndex(node: HTMLElement | SVGElement): number; | ||
@@ -228,2 +235,2 @@ declare const visuallyHiddenStyle: { | ||
export { type DataUrlOptions, type DataUrlType, type InitialFocusOptions, type ItemToId, MAX_Z_INDEX, type ObserveAttributeOptions, type ObserveChildrenOptions, type OverflowAncestor, type ScopeContext, type ScrollOptions, type ScrollPosition, type SearchableItem, type TypeaheadOptions, type TypeaheadState, ariaAttr, contains, createScope, dataAttr, defaultItemToId, getActiveElement, getBeforeInputValue, getByText, getByTypeahead, getComputedStyle, getDataUrl, 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 DataUrlOptions, type DataUrlType, type InitialFocusOptions, type ItemToId, MAX_Z_INDEX, type ObserveAttributeOptions, type ObserveChildrenOptions, type OverflowAncestor, type ScopeContext, type ScrollOptions, type ScrollPosition, type SearchableItem, type TypeaheadOptions, type TypeaheadState, addDomEvent, ariaAttr, contains, createScope, dataAttr, defaultItemToId, getActiveElement, getBeforeInputValue, getByText, getByTypeahead, getComputedStyle, getDataUrl, getDocument, getDocumentElement, getEventTarget, getFirstFocusable, getFirstTabbable, getFocusables, getInitialFocus, getLastTabbable, getNearestOverflowAncestor, getNextTabbable, getNodeName, getOverflowAncestors, getParentNode, getPlatform, getScrollPosition, getTabIndex, 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'; | ||
// src/add-dom-event.ts | ||
var addDomEvent = (target, eventName, handler, options) => { | ||
const node = typeof target === "function" ? target() : target; | ||
node?.addEventListener(eventName, handler, options); | ||
return () => { | ||
node?.removeEventListener(eventName, handler, options); | ||
}; | ||
}; | ||
// src/attrs.ts | ||
@@ -342,2 +351,15 @@ var dataAttr = (guard) => guard ? "" : void 0; | ||
} | ||
var hasTabIndex = (node) => !Number.isNaN(parseInt(node.getAttribute("tabindex") || "0", 10)); | ||
var isContentEditable = (node) => ( | ||
// @ts-ignore | ||
node.isContentEditable || node.getAttribute("contenteditable") === "true" || node.getAttribute("contenteditable") === "" | ||
); | ||
function getTabIndex(node) { | ||
if (node.tabIndex < 0) { | ||
if ((/^(audio|video|details)$/.test(node.localName) || isContentEditable(node)) && !hasTabIndex(node)) { | ||
return 0; | ||
} | ||
} | ||
return node.tabIndex; | ||
} | ||
@@ -707,2 +729,3 @@ // src/initial-focus.ts | ||
exports.MAX_Z_INDEX = MAX_Z_INDEX; | ||
exports.addDomEvent = addDomEvent; | ||
exports.ariaAttr = ariaAttr; | ||
@@ -734,2 +757,3 @@ exports.contains = contains; | ||
exports.getScrollPosition = getScrollPosition; | ||
exports.getTabIndex = getTabIndex; | ||
exports.getTabbableEdges = getTabbableEdges; | ||
@@ -736,0 +760,0 @@ exports.getTabbables = getTabbables; |
{ | ||
"name": "@zag-js/dom-query", | ||
"version": "0.79.1", | ||
"version": "0.79.2", | ||
"description": "The dom helper library for zag.js machines", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
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
78773
1674