@zag-js/dom-utils
Advanced tools
Comparing version 0.0.0-dev-20220605192656 to 0.0.0-dev-20220611135023
@@ -64,2 +64,4 @@ var __defProp = Object.defineProperty; | ||
focusableSelector: () => focusableSelector, | ||
getActiveDescendant: () => getActiveDescendant, | ||
getActiveElement: () => getActiveElement, | ||
getClosestForm: () => getClosestForm, | ||
@@ -71,2 +73,3 @@ getComputedStyle: () => getComputedStyle2, | ||
getEventStep: () => getEventStep, | ||
getEventTarget: () => getEventTarget, | ||
getEventWindow: () => getEventWindow, | ||
@@ -95,4 +98,6 @@ getFocusables: () => getFocusables, | ||
isSelfTarget: () => isSelfTarget, | ||
isShadowRoot: () => isShadowRoot, | ||
isTabbable: () => isTabbable, | ||
isWindow: () => isWindow, | ||
isWithinShadowRoot: () => isWithinShadowRoot, | ||
itemById: () => itemById, | ||
@@ -458,2 +463,11 @@ matchAttr: () => matchAttr, | ||
// src/query.ts | ||
function isShadowRoot(el) { | ||
return (el == null ? void 0 : el.toString()) === "[object ShadowRoot]"; | ||
} | ||
function isWindow(value) { | ||
return (value == null ? void 0 : value.toString()) === "[object Window]"; | ||
} | ||
var isWithinShadowRoot = (node) => { | ||
return isShadowRoot(node.getRootNode()); | ||
}; | ||
function getOwnerDocument(el) { | ||
@@ -483,2 +497,25 @@ var _a; | ||
} | ||
function getEventTarget(event) { | ||
var _a, _b; | ||
return (_b = (_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) != null ? _b : event.target; | ||
} | ||
function getActiveElement(el) { | ||
let activeElement = getOwnerDocument(el).activeElement; | ||
while (activeElement && activeElement.shadowRoot) { | ||
const el2 = activeElement.shadowRoot.activeElement; | ||
if (el2 === activeElement) | ||
break; | ||
else | ||
activeElement = el2; | ||
} | ||
return activeElement; | ||
} | ||
function getActiveDescendant(node) { | ||
if (!node) | ||
return null; | ||
const id = node.getAttribute("aria-activedescendant"); | ||
if (!id) | ||
return null; | ||
return getOwnerDocument(node).getElementById(id); | ||
} | ||
function getParent(el) { | ||
@@ -498,5 +535,2 @@ const doc = getOwnerDocument(el); | ||
} | ||
function isWindow(value) { | ||
return (value == null ? void 0 : value.toString()) === "[object Window]"; | ||
} | ||
var isDisabled = (el) => { | ||
@@ -508,9 +542,7 @@ return (el == null ? void 0 : el.getAttribute("disabled")) != null || !!(el == null ? void 0 : el.getAttribute("aria-disabled")) === true; | ||
return false; | ||
const selectors = [ | ||
"input:not([readonly])", | ||
"textarea:not([readonly])", | ||
"[contenteditable]", | ||
"select:not([readonly])" | ||
].join(", "); | ||
return el.matches(selectors) || el.isContentEditable; | ||
try { | ||
return el instanceof getOwnerWindow(el).HTMLInputElement && el.selectionStart != null || /(textarea|select)/.test(el.localName) || el.isContentEditable; | ||
} catch (error) { | ||
return false; | ||
} | ||
} | ||
@@ -1092,3 +1124,3 @@ | ||
// src/typeahead.ts | ||
function findByTypeahead(_items, options) { | ||
function findByTypeaheadImpl(_items, options) { | ||
const { state: state2, activeId, key, timeout = 350 } = options; | ||
@@ -1117,6 +1149,8 @@ const search = state2.keysSoFar + key; | ||
} | ||
findByTypeahead.defaultOptions = { | ||
keysSoFar: "", | ||
timer: -1 | ||
}; | ||
var findByTypeahead = /* @__PURE__ */ Object.assign(findByTypeaheadImpl, { | ||
defaultOptions: { | ||
keysSoFar: "", | ||
timer: -1 | ||
} | ||
}); | ||
@@ -1123,0 +1157,0 @@ // src/visibility-event.ts |
@@ -1,2 +0,5 @@ | ||
export declare function getOwnerDocument(el: HTMLElement | Window): Document; | ||
export declare function isShadowRoot(el: any): el is ShadowRoot; | ||
export declare function isWindow(value: any): value is Window; | ||
export declare const isWithinShadowRoot: (node: HTMLElement) => boolean; | ||
export declare function getOwnerDocument(el: Element | Window | null): Document; | ||
export declare function getOwnerWindow(el: HTMLElement): Window & typeof globalThis; | ||
@@ -6,10 +9,10 @@ export declare function getDocumentElement(el: HTMLElement | Window): HTMLElement; | ||
export declare function getEventWindow(event: UIEvent): Window; | ||
export declare function getEventTarget<T extends EventTarget>(event: Event): T | null; | ||
export declare function getActiveElement(el: HTMLElement): HTMLElement | null; | ||
export declare function getActiveDescendant(node: HTMLElement | null): HTMLElement | null; | ||
export declare function getParent(el: HTMLElement): HTMLElement; | ||
declare type Node = HTMLElement | EventTarget | null; | ||
export declare function contains(parent: Node | undefined, child: Node): boolean; | ||
export declare function contains(parent: HTMLElement | EventTarget | null | undefined, child: HTMLElement | EventTarget | null): boolean; | ||
export declare function isHTMLElement(v: any): v is HTMLElement; | ||
export declare function isWindow(value: any): value is Window; | ||
export declare const isDisabled: (el: HTMLElement | null) => boolean; | ||
export declare function isElementEditable(el: HTMLElement | null): boolean; | ||
export {}; | ||
//# sourceMappingURL=query.d.ts.map |
@@ -11,9 +11,10 @@ export declare type TypeaheadState = { | ||
}; | ||
export declare function findByTypeahead<T extends HTMLElement>(_items: T[], options: TypeaheadOptions): T; | ||
export declare namespace findByTypeahead { | ||
var defaultOptions: { | ||
declare function findByTypeaheadImpl<T extends HTMLElement>(_items: T[], options: TypeaheadOptions): T; | ||
export declare const findByTypeahead: typeof findByTypeaheadImpl & { | ||
defaultOptions: { | ||
keysSoFar: string; | ||
timer: number; | ||
}; | ||
} | ||
}; | ||
export {}; | ||
//# sourceMappingURL=typeahead.d.ts.map |
{ | ||
"name": "@zag-js/dom-utils", | ||
"version": "0.0.0-dev-20220605192656", | ||
"version": "0.0.0-dev-20220611135023", | ||
"description": "", | ||
@@ -29,3 +29,3 @@ "keywords": [ | ||
"@types/react": "^18.0.0", | ||
"@zag-js/utils": "0.0.0-dev-20220605192656" | ||
"@zag-js/utils": "0.1.2" | ||
}, | ||
@@ -32,0 +32,0 @@ "scripts": { |
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
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
253158
2635
+ Added@zag-js/utils@0.1.2(transitive)
- Removed@zag-js/utils@0.0.0-dev-20220605192656(transitive)
Updated@zag-js/utils@0.1.2