@zag-js/dom-utils
Advanced tools
Comparing version 0.0.0-dev-20220612194202 to 0.0.0-dev-20220615060231
@@ -10,2 +10,1 @@ declare type Booleanish = boolean | "true" | "false"; | ||
export {}; | ||
//# sourceMappingURL=attrs.d.ts.map |
@@ -7,2 +7,1 @@ declare type PointerEventOptions = { | ||
export {}; | ||
//# sourceMappingURL=body-pointer-event.d.ts.map |
@@ -7,2 +7,1 @@ 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 |
@@ -10,2 +10,1 @@ /// <reference types="react" /> | ||
export {}; | ||
//# sourceMappingURL=event.d.ts.map |
@@ -6,2 +6,1 @@ export declare function fireEvent(el: Element, type: string, init?: EventInit): boolean; | ||
export declare function fireClickEvent(el: Element, init?: PointerEventInit): boolean; | ||
//# sourceMappingURL=fire-event.d.ts.map |
@@ -12,2 +12,1 @@ /** | ||
export {}; | ||
//# sourceMappingURL=focus-event.d.ts.map |
@@ -19,2 +19,1 @@ export declare const focusableSelector: string; | ||
export declare const isTabbable: (el: HTMLElement | null) => boolean; | ||
//# sourceMappingURL=focusable.d.ts.map |
@@ -5,2 +5,1 @@ export declare function getClosestForm(el: HTMLElement): HTMLFormElement; | ||
export declare function isNativeDisabled(el: HTMLElement): boolean; | ||
//# sourceMappingURL=form.d.ts.map |
@@ -12,2 +12,1 @@ declare type El = HTMLElement | Document | VisualViewport | Window; | ||
export {}; | ||
//# sourceMappingURL=global-listener.d.ts.map |
export * from "./attrs"; | ||
export * from "./auto-resize"; | ||
export * from "./body-pointer-event"; | ||
@@ -29,2 +28,1 @@ export * from "./computed-style"; | ||
export * from "./wait"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -46,3 +46,2 @@ var __defProp = Object.defineProperty; | ||
ariaAttr: () => ariaAttr, | ||
autoResizeInput: () => autoResizeInput, | ||
contains: () => contains, | ||
@@ -68,3 +67,3 @@ copyVisualStyles: () => copyVisualStyles, | ||
getClosestForm: () => getClosestForm, | ||
getComputedStyle: () => getComputedStyle2, | ||
getComputedStyle: () => getComputedStyle, | ||
getDocumentElement: () => getDocumentElement, | ||
@@ -151,89 +150,2 @@ getEventKey: () => getEventKey, | ||
// src/computed-style.ts | ||
function getStyleCache() { | ||
; | ||
globalThis.__styleCache__ = globalThis.__styleCache__ || /* @__PURE__ */ new WeakMap(); | ||
return globalThis.__styleCache__; | ||
} | ||
function getComputedStyle2(el) { | ||
var _a; | ||
if (!el) | ||
return {}; | ||
const cache = getStyleCache(); | ||
let style = cache.get(el); | ||
if (!style) { | ||
const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window; | ||
style = win.getComputedStyle(el); | ||
cache.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 queueMicrotask(fn) { | ||
if (typeof globalThis.queueMicrotask === "function") { | ||
globalThis.queueMicrotask(fn); | ||
} else { | ||
Promise.resolve().then(fn); | ||
} | ||
} | ||
// 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/dist/index.mjs | ||
@@ -250,3 +162,3 @@ var isDom = () => typeof window !== "undefined"; | ||
var pt = (v) => isDom() && v.test(getPlatform()); | ||
var isTouchDevice = isDom() && !!navigator.maxTouchPoints; | ||
var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints; | ||
var isMac = () => pt(/^Mac/) && !isTouchDevice; | ||
@@ -400,2 +312,30 @@ var isApple = () => pt(/mac|iphone|ipad|ipod/i); | ||
// 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 queueMicrotask(fn) { | ||
if (typeof globalThis.queueMicrotask === "function") { | ||
globalThis.queueMicrotask(fn); | ||
} else { | ||
Promise.resolve().then(fn); | ||
} | ||
} | ||
// src/body-pointer-event.ts | ||
@@ -461,2 +401,29 @@ var changeCount = 0; | ||
// src/computed-style.ts | ||
function getStyleCache() { | ||
; | ||
globalThis.__styleCache__ = globalThis.__styleCache__ || /* @__PURE__ */ new WeakMap(); | ||
return globalThis.__styleCache__; | ||
} | ||
function getComputedStyle(el) { | ||
var _a; | ||
if (!el) | ||
return {}; | ||
const cache = getStyleCache(); | ||
let style = cache.get(el); | ||
if (!style) { | ||
const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window; | ||
style = win.getComputedStyle(el); | ||
cache.set(el, style); | ||
} | ||
return style; | ||
} | ||
function copyVisualStyles(fromEl, toEl) { | ||
if (!fromEl) | ||
return; | ||
const el = getComputedStyle(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/constants.ts | ||
@@ -631,3 +598,3 @@ var MAX_Z_INDEX = 2147483647; | ||
function isHidden(el, until) { | ||
const style = getComputedStyle2(el); | ||
const style = getComputedStyle(el); | ||
if (!el || style.getPropertyValue("visibility") === "hidden") | ||
@@ -1094,3 +1061,3 @@ return true; | ||
function isScrollParent(el) { | ||
const { overflow, overflowX, overflowY } = getComputedStyle2(el); | ||
const { overflow, overflowX, overflowY } = getComputedStyle(el); | ||
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX); | ||
@@ -1208,2 +1175,1 @@ } | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -11,2 +11,1 @@ declare type DescriptorOptions = { | ||
export {}; | ||
//# sourceMappingURL=input-event.d.ts.map |
@@ -17,2 +17,1 @@ import type { KeyboardEvent } from "react"; | ||
export {}; | ||
//# sourceMappingURL=keyboard-event.d.ts.map |
@@ -17,2 +17,1 @@ import { AnyPointerEvent, DOMEventTarget, EventMap, PointerEventInfo } from "./listener.types"; | ||
export declare function getEventName(evt: keyof EventMap): keyof EventMap; | ||
//# sourceMappingURL=listener.d.ts.map |
@@ -27,2 +27,1 @@ export interface EventMap extends DocumentEventMap, WindowEventMap, HTMLElementEventMap { | ||
} | ||
//# sourceMappingURL=listener.types.d.ts.map |
@@ -13,2 +13,1 @@ export declare type LiveRegionOptions = { | ||
}; | ||
//# sourceMappingURL=live-region.d.ts.map |
@@ -5,2 +5,1 @@ 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 queueMicrotask(fn: VoidFunction): void; | ||
//# sourceMappingURL=next-tick.d.ts.map |
@@ -11,2 +11,1 @@ declare type Root = Document | Element | null | undefined; | ||
export {}; | ||
//# sourceMappingURL=nodelist.d.ts.map |
@@ -13,2 +13,1 @@ import type { AnyPointerEvent, PointerEventInfo } from "./listener.types"; | ||
export {}; | ||
//# sourceMappingURL=pointer-event.d.ts.map |
@@ -9,2 +9,1 @@ declare type PointerLockHandlers = { | ||
export {}; | ||
//# sourceMappingURL=pointerlock.d.ts.map |
@@ -17,2 +17,1 @@ export declare function isShadowRoot(el: any): el is ShadowRoot; | ||
export declare function isElementEditable(el: HTMLElement | null): boolean; | ||
//# sourceMappingURL=query.d.ts.map |
@@ -7,2 +7,1 @@ declare type Fn = (rect: DOMRect) => void; | ||
export {}; | ||
//# sourceMappingURL=rect-observer.d.ts.map |
@@ -10,2 +10,1 @@ export declare function isScrollParent(el: HTMLElement): boolean; | ||
export {}; | ||
//# sourceMappingURL=scrollable.d.ts.map |
@@ -9,2 +9,1 @@ export declare function disableTextSelection({ target, doc }?: { | ||
}): void; | ||
//# sourceMappingURL=text-selection.d.ts.map |
@@ -19,2 +19,1 @@ export declare type TypeaheadState = { | ||
export {}; | ||
//# sourceMappingURL=typeahead.d.ts.map |
export declare function trackDocumentVisibility(_doc: Document, callback: (hidden: boolean) => void): () => void; | ||
//# sourceMappingURL=visibility-event.d.ts.map |
@@ -11,2 +11,1 @@ declare type ViewportSize = { | ||
export {}; | ||
//# sourceMappingURL=visual-viewport.d.ts.map |
@@ -14,2 +14,1 @@ 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-20220612194202", | ||
"version": "0.0.0-dev-20220615060231", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
88819
33
2567