@zag-js/dom-utils
Advanced tools
Comparing version 0.0.0-dev-20220510084727 to 0.0.0-dev-20220519150040
declare type Booleanish = boolean | "true" | "false"; | ||
export declare const dataAttr: (guard: boolean | undefined) => Booleanish; | ||
export declare const ariaAttr: (guard: boolean | undefined) => boolean; | ||
export declare const ariaAttr: (guard: boolean | undefined) => string; | ||
export declare const matchAttr: (el: Element) => { | ||
@@ -5,0 +5,0 @@ get: (key: string) => string; |
@@ -8,2 +8,3 @@ export * from "./attrs"; | ||
export * from "./dispatch-event"; | ||
export * from "./event-query"; | ||
export * from "./focus-event"; | ||
@@ -24,2 +25,3 @@ export * from "./focusable"; | ||
export * from "./text-selection"; | ||
export * from "./typeahead"; | ||
export * from "./visibility-event"; | ||
@@ -29,3 +31,2 @@ export * from "./visual-viewport"; | ||
export * from "./wait"; | ||
export * from "./typeahead"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -69,2 +69,3 @@ var __create = Object.create; | ||
isHidden: () => isHidden, | ||
isKeyboardClick: () => isKeyboardClick, | ||
isScrollParent: () => isScrollParent, | ||
@@ -108,3 +109,3 @@ isTabbable: () => isTabbable, | ||
var ariaAttr = (guard) => { | ||
return guard ? true : void 0; | ||
return guard ? "true" : void 0; | ||
}; | ||
@@ -464,6 +465,2 @@ var matchAttr = (el) => { | ||
}; | ||
function getNativeEvent(event) { | ||
var _a; | ||
return (_a = event.nativeEvent) != null ? _a : event; | ||
} | ||
function isElementEditable(el) { | ||
@@ -666,2 +663,11 @@ if (el == null) | ||
// src/event-query.ts | ||
function isKeyboardClick(e) { | ||
return e.detail === 0 || e.clientX === 0 && e.clientY === 0; | ||
} | ||
function getNativeEvent(event) { | ||
var _a; | ||
return (_a = event.nativeEvent) != null ? _a : event; | ||
} | ||
// src/focus-event.ts | ||
@@ -1084,2 +1090,32 @@ function validateBlur(event, opts) { | ||
// src/typeahead.ts | ||
function findByTypeahead(_items, options) { | ||
const { state: state2, activeId, key, timeout = 350 } = options; | ||
const search = state2.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 = findByText(items, query2, activeId); | ||
function cleanup() { | ||
clearTimeout(state2.timer); | ||
state2.timer = -1; | ||
} | ||
function update(value) { | ||
state2.keysSoFar = value; | ||
cleanup(); | ||
if (value !== "") { | ||
state2.timer = +setTimeout(() => { | ||
update(""); | ||
cleanup(); | ||
}, timeout); | ||
} | ||
} | ||
update(search); | ||
return next; | ||
} | ||
findByTypeahead.defaultOptions = { | ||
keysSoFar: "", | ||
timer: -1 | ||
}; | ||
// src/visibility-event.ts | ||
@@ -1137,32 +1173,2 @@ function trackDocumentVisibility(_doc, callback) { | ||
} | ||
// src/typeahead.ts | ||
function findByTypeahead(_items, options) { | ||
const { state: state2, activeId, key, timeout = 350 } = options; | ||
const search = state2.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 = findByText(items, query2, activeId); | ||
function cleanup() { | ||
clearTimeout(state2.timer); | ||
state2.timer = -1; | ||
} | ||
function update(value) { | ||
state2.keysSoFar = value; | ||
cleanup(); | ||
if (value !== "") { | ||
state2.timer = +setTimeout(() => { | ||
update(""); | ||
cleanup(); | ||
}, timeout); | ||
} | ||
} | ||
update(search); | ||
return next; | ||
} | ||
findByTypeahead.defaultOptions = { | ||
keysSoFar: "", | ||
timer: -1 | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,1 @@ | ||
/// <reference types="react" /> | ||
export declare function getOwnerDocument(el: HTMLElement | Window): Document; | ||
@@ -13,5 +12,4 @@ export declare function getOwnerWindow(el: HTMLElement): Window & typeof globalThis; | ||
export declare const isDisabled: (el: HTMLElement | null) => boolean; | ||
export declare function getNativeEvent<E>(event: E): React.ChangeEvent<any> extends E ? InputEvent : E extends React.SyntheticEvent<any, infer T> ? T : never; | ||
export declare function isElementEditable(el: HTMLElement | null): boolean; | ||
export {}; | ||
//# sourceMappingURL=query.d.ts.map |
{ | ||
"name": "@zag-js/dom-utils", | ||
"version": "0.0.0-dev-20220510084727", | ||
"version": "0.0.0-dev-20220519150040", | ||
"description": "", | ||
@@ -29,3 +29,3 @@ "keywords": [ | ||
"@types/react": "^18.0.0", | ||
"@zag-js/utils": "0.0.0-dev-20220510084727", | ||
"@zag-js/utils": "0.1.1", | ||
"scroll-into-view-if-needed": "^2.2.29" | ||
@@ -32,0 +32,0 @@ }, |
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
Sorry, the diff of this file is not supported yet
252793
67
2559
+ Added@zag-js/utils@0.1.1(transitive)
- Removed@zag-js/utils@0.0.0-dev-20220510084727(transitive)
Updated@zag-js/utils@0.1.1