Socket
Socket
Sign inDemoInstall

@zag-js/dom-utils

Package Overview
Dependencies
Maintainers
1
Versions
227
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/dom-utils - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

1

dist/attrs.d.ts

@@ -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
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

288

dist/index.js

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

"use strict";
var __defProp = Object.defineProperty;

@@ -46,3 +47,2 @@ var __defProps = Object.defineProperties;

ariaAttr: () => ariaAttr,
autoResizeInput: () => autoResizeInput,
contains: () => contains,

@@ -65,4 +65,6 @@ copyVisualStyles: () => copyVisualStyles,

focusableSelector: () => focusableSelector,
getActiveDescendant: () => getActiveDescendant,
getActiveElement: () => getActiveElement,
getClosestForm: () => getClosestForm,
getComputedStyle: () => getComputedStyle2,
getComputedStyle: () => getComputedStyle,
getDocumentElement: () => getDocumentElement,

@@ -72,2 +74,3 @@ getEventKey: () => getEventKey,

getEventStep: () => getEventStep,
getEventTarget: () => getEventTarget,
getEventWindow: () => getEventWindow,

@@ -96,4 +99,6 @@ getFocusables: () => getFocusables,

isSelfTarget: () => isSelfTarget,
isShadowRoot: () => isShadowRoot,
isTabbable: () => isTabbable,
isWindow: () => isWindow,
isWithinShadowRoot: () => isWithinShadowRoot,
itemById: () => itemById,

@@ -148,89 +153,2 @@ matchAttr: () => matchAttr,

// 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

@@ -247,3 +165,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;

@@ -267,66 +185,2 @@ var isApple = () => pt(/mac|iphone|ipad|ipod/i);

// src/global-listener.ts
function getListenerElements() {
;
globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
return globalThis.__listenerElements__;
}
function getListenerCache() {
;
globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
return globalThis.__listenerCache__;
}
function addGlobalEventListener(node, type, handler, options) {
var _a;
if (!node)
return noop;
const hash = JSON.stringify({ type, options });
const listenerElements = getListenerElements();
const listenerCache = getListenerCache();
const group = listenerElements.get(node);
if (!listenerElements.has(node)) {
const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
listenerElements.set(node, group2);
} else if (group == null ? void 0 : group.has(hash)) {
(_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
} else {
group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
}
function attach(node2) {
var _a2, _b;
function listener(event) {
var _a3;
const group2 = listenerElements.get(node2);
(_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
}
if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
node2.addEventListener(type, listener, options);
return;
}
if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
(_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
node2.addEventListener(type, listener, options);
}
}
attach(node);
return function remove() {
var _a2, _b, _c, _d;
if (!listenerElements.has(node))
return;
const group2 = listenerElements.get(node);
(_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
node.removeEventListener(type, listener, options);
group2 == null ? void 0 : group2.delete(hash);
(_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
if ((group2 == null ? void 0 : group2.size) === 0) {
listenerElements.delete(node);
listenerCache.delete(node);
}
}
};
}
// src/listener.ts

@@ -344,5 +198,8 @@ var isRef = (v) => hasProp(v, "current");

}
function addDomEvent(target, event, listener, options) {
function addDomEvent(target, eventName, handler, options) {
const node = isRef(target) ? target.current : runIfFn(target);
return addGlobalEventListener(node, event, listener, options);
node == null ? void 0 : node.addEventListener(eventName, handler, options);
return () => {
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
};
}

@@ -399,2 +256,30 @@ function addPointerEvent(target, event, listener, options) {

// 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

@@ -460,2 +345,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

@@ -465,2 +377,11 @@ var MAX_Z_INDEX = 2147483647;

// 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) {

@@ -490,2 +411,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) {

@@ -505,5 +449,2 @@ const doc = getOwnerDocument(el);

}
function isWindow(value) {
return (value == null ? void 0 : value.toString()) === "[object Window]";
}
var isDisabled = (el) => {

@@ -515,9 +456,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;
}
}

@@ -607,3 +546,3 @@

function isHidden(el, until) {
const style = getComputedStyle2(el);
const style = getComputedStyle(el);
if (!el || style.getPropertyValue("visibility") === "hidden")

@@ -1070,3 +1009,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);

@@ -1101,3 +1040,3 @@ }

// src/typeahead.ts
function findByTypeahead(_items, options) {
function findByTypeaheadImpl(_items, options) {
const { state: state2, activeId, key, timeout = 350 } = options;

@@ -1126,6 +1065,8 @@ const search = state2.keysSoFar + key;

}
findByTypeahead.defaultOptions = {
keysSoFar: "",
timer: -1
};
var findByTypeahead = /* @__PURE__ */ Object.assign(findByTypeaheadImpl, {
defaultOptions: {
keysSoFar: "",
timer: -1
}
});

@@ -1184,2 +1125,1 @@ // src/visibility-event.ts

}
//# 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

@@ -8,3 +8,3 @@ import { AnyPointerEvent, DOMEventTarget, EventMap, PointerEventInfo } from "./listener.types";

};
export declare function addDomEvent<K extends keyof EventMap>(target: DOMEventTarget, event: K, listener: (event: EventMap[K]) => void, options?: boolean | AddEventListenerOptions): () => void;
export declare function addDomEvent<K extends keyof EventMap>(target: DOMEventTarget, eventName: K, handler: (event: EventMap[K]) => void, options?: boolean | AddEventListenerOptions): () => void;
export declare function addPointerEvent<K extends keyof EventMap>(target: DOMEventTarget, event: K, listener: (event: EventMap[K], info: PointerEventInfo) => void, options?: boolean | AddEventListenerOptions): () => void;

@@ -18,2 +18,1 @@ export declare function extractClientInfo(event: AnyPointerEvent): {

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

@@ -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,9 @@ 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

@@ -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

@@ -11,9 +11,9 @@ 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;
};
}
//# sourceMappingURL=typeahead.d.ts.map
};
export {};
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.1.4",
"version": "0.1.5",
"description": "",

@@ -28,3 +28,3 @@ "keywords": [

"dependencies": {
"@types/react": "^18.0.0",
"@types/react": "18.0.13",
"@zag-js/utils": "0.1.2"

@@ -31,0 +31,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc