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.0.0-dev-20221118145623 to 0.0.0-dev-20221228121448

dist/attrs.d.ts

326

dist/index.d.ts

@@ -1,295 +0,31 @@

import { JSX } from '@zag-js/types';
declare type Booleanish = boolean | "true" | "false";
declare const dataAttr: (guard: boolean | undefined) => Booleanish;
declare const ariaAttr: (guard: boolean | undefined) => "true" | undefined;
declare const matchAttr: (el: Element) => {
get: (key: string) => string | null;
set: (key: string, value: string) => void;
is: (key: string, value: string) => boolean;
};
declare const MAX_Z_INDEX = 2147483647;
declare function copyVisualStyles(fromEl: HTMLElement | null, toEl: HTMLElement): void;
declare function isKeyboardClick(e: Pick<MouseEvent, "detail" | "clientX" | "clientY">): boolean;
declare function isPrintableKey(e: Pick<KeyboardEvent, "key" | "ctrlKey" | "metaKey">): boolean;
declare function isVirtualPointerEvent(event: PointerEvent): boolean;
declare function isVirtualClick(event: MouseEvent | PointerEvent): boolean;
declare type NativeEvent<E> = JSX.ChangeEvent<any> extends E ? InputEvent : E extends JSX.SyntheticEvent<any, infer T> ? T : never;
declare function getNativeEvent<E>(e: E): NativeEvent<E>;
declare function isSelfEvent(event: Pick<Event, "currentTarget" | "target">): boolean;
declare const supportsPointerEvent: () => boolean;
declare const supportsTouchEvent: () => boolean;
declare const supportsMouseEvent: () => boolean;
declare const isMouseEvent: (v: any) => v is MouseEvent;
declare const isTouchEvent: (v: any) => v is TouchEvent;
declare const isLeftClick: (v: {
button: number;
}) => boolean;
declare const isContextMenuEvent: (e: Pick<MouseEvent, "button" | "ctrlKey" | "metaKey">) => boolean;
declare const isRightClick: (v: {
button: number;
}) => boolean;
declare const isModifiedEvent: (v: Pick<KeyboardEvent, "ctrlKey" | "metaKey" | "altKey">) => boolean;
declare const isCtrlKey: (v: Pick<KeyboardEvent, "ctrlKey" | "metaKey">) => boolean;
declare function fireCustomEvent(el: HTMLElement | null, type: string, init?: CustomEventInit): boolean | undefined;
declare function fireBlurEvent(el: HTMLElement, init?: FocusEventInit): boolean;
declare function fireKeyboardEvent(el: HTMLElement, type: string, init?: KeyboardEventInit): boolean;
declare function fireClickEvent(el: HTMLElement, init?: PointerEventInit): boolean;
declare type IncludeContainerType = boolean | "if-empty";
declare const focusableSelector: string;
/**
* Returns the focusable elements within the element
*/
declare const getFocusables: (container: Pick<HTMLElement, "querySelectorAll"> | null, includeContainer?: IncludeContainerType) => HTMLElement[];
/**
* Whether this element is focusable
*/
declare function isFocusable(element: HTMLElement | null): element is HTMLElement;
declare function getFirstFocusable(container: HTMLElement, includeContainer?: IncludeContainerType): HTMLElement;
/**
* Returns the tabbable elements within the element
*/
declare function getTabbables(container: HTMLElement | null, includeContainer?: IncludeContainerType): HTMLElement[];
/**
* Whether this element is tabbable
*/
declare function isTabbable(el: HTMLElement | null): el is HTMLElement;
declare function getFirstTabbable(container: HTMLElement | null, includeContainer?: IncludeContainerType): HTMLElement;
declare function getLastTabbable(container: HTMLElement | null, includeContainer?: IncludeContainerType): HTMLElement;
declare type Key = keyof CSSStyleDeclaration | (string & {});
declare type Styles = Record<Key, any>;
declare type El = HTMLElement | null | undefined;
declare function getComputedStyle(el: El): Styles;
declare function getElementOffset(element: HTMLElement): {
top: number;
right: number;
bottom: number;
left: number;
};
declare type PointType = "page" | "client";
declare function getEventPoint(event: MouseEvent | TouchEvent | PointerEvent, type?: PointType): {
x: number;
y: number;
};
declare type Point = {
x: number;
y: number;
};
declare function getPointRelativeToNode(point: Point, element: HTMLElement): {
x: number;
y: number;
};
declare type EventKey = "ArrowDown" | "ArrowUp" | "ArrowLeft" | "ArrowRight" | "Space" | "Enter" | "Comma" | "Escape" | "Backspace" | "Delete" | "Home" | "End" | "Tab" | "PageUp" | "PageDown" | (string & {});
declare type EventKeyMap = Partial<Record<EventKey, (event: JSX.KeyboardEvent) => void>>;
declare type EventKeyOptions = {
dir?: "ltr" | "rtl";
orientation?: "horizontal" | "vertical";
};
/**
* Determine the event key based on text direction.
*/
declare function getEventKey(event: Pick<KeyboardEvent, "key">, options?: EventKeyOptions): string;
/**
* Determine the step factor for keyboard events
*/
declare function getEventStep(event: Pick<KeyboardEvent, "ctrlKey" | "metaKey" | "key" | "shiftKey">): 1 | 10 | 0.1;
interface EventMap extends DocumentEventMap, WindowEventMap, HTMLElementEventMap {
}
declare type DOMTarget = Document | HTMLElement | EventTarget | null;
declare type AnyPointerEvent = MouseEvent | TouchEvent | PointerEvent;
declare type RefTarget = {
current: HTMLElement | null;
};
declare type DOMEventTarget = (() => DOMTarget) | DOMTarget | RefTarget;
interface PointerEventInfo {
point: {
x: number;
y: number;
};
}
declare function extractInfo<T extends AnyPointerEvent = AnyPointerEvent>(event: T, type?: "page" | "client"): {
point: {
x: any;
y: any;
};
};
declare function addDomEvent<K extends keyof EventMap>(target: DOMEventTarget, eventName: K, handler: (event: EventMap[K]) => void, options?: boolean | AddEventListenerOptions): () => void;
declare function addPointerEvent<K extends keyof EventMap>(target: DOMEventTarget, event: K, listener: (event: EventMap[K], info: PointerEventInfo) => void, options?: boolean | AddEventListenerOptions): () => void;
declare function extractClientInfo(event: AnyPointerEvent): {
point: {
x: any;
y: any;
};
};
declare function getEventName(evt: keyof EventMap): keyof EventMap;
declare type Callback = (v: MutationRecord) => void;
declare function observeAttributes(node: Element | null, attributes: string | string[], fn: Callback): (() => void) | undefined;
declare function observeChildren(node: Element | null, fn: (v: MutationRecord[]) => void): (() => void) | undefined;
declare function nextTick(fn: VoidFunction): () => void;
declare function raf(fn: VoidFunction): () => void;
declare type SchedulerFn = (fn: VoidFunction) => VoidFunction;
declare type DisposableVoidFunction = () => VoidFunction | undefined | void;
declare function disposable(type: SchedulerFn | undefined, fn: DisposableVoidFunction): () => void;
declare function disposableRaf(fn: DisposableVoidFunction): () => void;
declare function disposableNextTick(fn: DisposableVoidFunction): () => void;
declare type Root = Document | Element | null | undefined;
declare function queryAll<T extends HTMLElement = HTMLElement>(root: Root, selector: string): T[];
declare function query<T extends HTMLElement = HTMLElement>(root: Root, selector: string): T | null | undefined;
declare function itemById<T extends HTMLElement>(v: T[], id: string): T | undefined;
declare function indexOfId<T extends HTMLElement>(v: T[], id: string): number;
declare function nextById<T extends HTMLElement>(v: T[], id: string, loop?: boolean): T;
declare function prevById<T extends HTMLElement>(v: T[], id: string, loop?: boolean): T | null;
declare function findByText<T extends HTMLElement>(v: T[], text: string, currentId?: string | null): T | undefined;
declare function sortByTreeOrder<T extends HTMLElement>(v: T[]): T[];
declare const isDom: () => boolean;
declare function getPlatform(): any;
declare const isTouchDevice: () => boolean;
declare const isMac: () => false;
declare const isIPhone: () => boolean;
declare const isSafari: () => boolean;
declare const isFirefox: () => boolean;
declare const isApple: () => boolean;
declare const isIos: () => boolean;
declare function trackPointerDown(doc: Document, onPointerDown: (el: HTMLElement) => void): () => void;
declare type TrackPointerMoveOptions = {
onPointerUp: VoidFunction;
onPointerMove: (info: PointerEventInfo, event: AnyPointerEvent) => void;
};
declare function trackPointerMove(doc: Document, opts: TrackPointerMoveOptions): () => void;
declare type PointerLockHandlers = {
onPointerLock?: VoidFunction;
onPointerUnlock?: VoidFunction;
};
declare function addPointerlockChangeListener(doc: Document, fn: VoidFunction): () => void;
declare function addPointerlockErrorListener(doc: Document, fn: (e: Event) => void): () => void;
declare function requestPointerLock(doc: Document, handlers?: PointerLockHandlers): (() => void) | undefined;
declare function isDocument(el: any): el is Document;
declare function isShadowRoot(el: any): el is ShadowRoot;
declare function isWindow(value: any): value is Window;
declare function isFrame(element: Element): element is HTMLIFrameElement;
declare const isWithinShadowRoot: (node: HTMLElement) => boolean;
declare function getDocument(el: Element | Window | Node | Document | null): Document;
declare function getRootNode(el: Node): Document | ShadowRoot;
declare function getWindow(el: HTMLElement): Window & typeof globalThis;
declare function getDocumentElement(el: HTMLElement | Window): HTMLElement;
declare function getNodeName(node: HTMLElement | Window | null): string;
declare function getEventWindow(event: UIEvent): Window;
declare function getEventTarget<T extends EventTarget>(event: Event): T | null;
declare function getActiveElement(el: HTMLElement): HTMLElement | null;
declare function getActiveDescendant(node: HTMLElement | null): HTMLElement | null;
declare function getParent(el: HTMLElement): HTMLElement;
declare type Ctx = {
getRootNode?: () => Document | ShadowRoot | Node;
};
declare function defineDomHelpers<T>(helpers: T): {
getRootNode: (ctx: Ctx) => Document | ShadowRoot;
getDoc: (ctx: Ctx) => Document;
getWin: (ctx: Ctx) => Window & typeof globalThis;
getActiveElement: (ctx: Ctx) => HTMLElement | null;
getById: <T_1 = HTMLElement>(ctx: Ctx, id: string) => T_1 | null;
createEmitter: (ctx: Ctx, target: HTMLElement) => (evt: string, detail: Record<string, any>, options?: EventInit) => void;
createListener: (target: HTMLElement) => <T_2 = any>(evt: string, handler: (e: CustomEvent<T_2>) => void) => () => void;
} & T;
declare function contains(parent: HTMLElement | EventTarget | null | undefined, child: HTMLElement | EventTarget | null): boolean;
declare function isHTMLElement(v: any): v is HTMLElement;
declare const isDisabled: (el: HTMLElement | null) => boolean;
declare function isElementEditable(el: HTMLElement | EventTarget | null): boolean;
declare function isVisible(el: Element): boolean;
declare function queueBeforeEvent(el: Element, type: string, fn: VoidFunction): void;
declare function queueMicrotask(fn: VoidFunction): void;
declare type Fn = (rect: DOMRect) => void;
declare type Measurable = {
getBoundingClientRect(): DOMRect;
};
declare function observeElementRect(el: Measurable, fn: Fn): () => void;
declare function isScrollParent(el: HTMLElement): boolean;
declare function getScrollParent(el: HTMLElement): HTMLElement;
declare type Target = Array<VisualViewport | Window | HTMLElement>;
declare function getScrollParents(el: HTMLElement, list?: Target): Target;
declare function getScrollOffset(el: HTMLElement): {
scrollLeft: number;
scrollTop: number;
};
declare function disableTextSelection({ target, doc }?: {
target?: HTMLElement;
doc?: Document;
}): () => void;
declare function restoreTextSelection({ target, doc }?: {
target?: HTMLElement;
doc?: Document;
}): void;
declare type TypeaheadState = {
keysSoFar: string;
timer: number;
};
declare type TypeaheadOptions = {
state: TypeaheadState;
activeId: string | null;
key: string;
timeout?: number;
};
declare function findByTypeaheadImpl<T extends HTMLElement>(_items: T[], options: TypeaheadOptions): T | undefined;
declare const findByTypeahead: typeof findByTypeaheadImpl & {
defaultOptions: {
keysSoFar: string;
timer: number;
};
isValidEvent: typeof isValidTypeaheadEvent;
};
declare function isValidTypeaheadEvent(event: Pick<KeyboardEvent, "key" | "ctrlKey" | "metaKey">): boolean;
declare function trackDocumentVisibility(_doc: Document, callback: (hidden: boolean) => void): () => void;
declare type ViewportSize = {
width: number;
height: number;
};
declare type Options = {
document?: Document;
resolve?(data: ViewportSize): void;
};
declare function trackVisualViewport(options: Options): () => void;
declare const visuallyHiddenStyle: {
readonly border: "0";
readonly clip: "rect(0 0 0 0)";
readonly height: "1px";
readonly margin: "-1px";
readonly overflow: "hidden";
readonly padding: "0";
readonly position: "absolute";
readonly width: "1px";
readonly whiteSpace: "nowrap";
readonly wordWrap: "normal";
};
declare function setVisuallyHidden(el: HTMLElement): void;
declare function waitFor<T>(predicate: () => T): Promise<T>;
declare function waitForEvent(el: HTMLElement, eventName: string): Promise<void>;
export { EventKeyMap, MAX_Z_INDEX, Measurable, TypeaheadOptions, TypeaheadState, addDomEvent, addPointerEvent, addPointerlockChangeListener, addPointerlockErrorListener, ariaAttr, contains, copyVisualStyles, dataAttr, defineDomHelpers, disableTextSelection, disposable, disposableNextTick, disposableRaf, extractClientInfo, extractInfo, findByText, findByTypeahead, fireBlurEvent, fireClickEvent, fireCustomEvent, fireKeyboardEvent, focusableSelector, getActiveDescendant, getActiveElement, getComputedStyle, getDocument, getDocumentElement, getElementOffset, getEventKey, getEventName, getEventPoint, getEventStep, getEventTarget, getEventWindow, getFirstFocusable, getFirstTabbable, getFocusables, getLastTabbable, getNativeEvent, getNodeName, getParent, getPlatform, getPointRelativeToNode, getRootNode, getScrollOffset, getScrollParent, getScrollParents, getTabbables, getWindow, indexOfId, isApple, isContextMenuEvent, isCtrlKey, isDisabled, isDocument, isDom, isElementEditable, isFirefox, isFocusable, isFrame, isHTMLElement, isIPhone, isIos, isKeyboardClick, isLeftClick, isMac, isModifiedEvent, isMouseEvent, isPrintableKey, isRightClick, isSafari, isScrollParent, isSelfEvent, isShadowRoot, isTabbable, isTouchDevice, isTouchEvent, isVirtualClick, isVirtualPointerEvent, isVisible, isWindow, isWithinShadowRoot, itemById, matchAttr, nextById, nextTick, observeAttributes, observeChildren, observeElementRect, prevById, query, queryAll, queueBeforeEvent, queueMicrotask, raf, requestPointerLock, restoreTextSelection, setVisuallyHidden, sortByTreeOrder, supportsMouseEvent, supportsPointerEvent, supportsTouchEvent, trackDocumentVisibility, trackPointerDown, trackPointerMove, trackVisualViewport, visuallyHiddenStyle, waitFor, waitForEvent };
export { ariaAttr, dataAttr, matchAttr } from './attrs.js';
export { MAX_Z_INDEX } from './constants.js';
export { copyVisualStyles } from './copy-visual-styles.js';
export { getNativeEvent, isContextMenuEvent, isCtrlKey, isKeyboardClick, isLeftClick, isModifiedEvent, isMouseEvent, isPrintableKey, isRightClick, isSelfEvent, isTouchEvent, isVirtualClick, isVirtualPointerEvent, supportsMouseEvent, supportsPointerEvent, supportsTouchEvent } from './event.js';
export { fireBlurEvent, fireClickEvent, fireCustomEvent, fireKeyboardEvent } from './fire-event.js';
export { focusableSelector, getFirstFocusable, getFirstTabbable, getFocusables, getLastTabbable, getTabbables, isFocusable, isTabbable } from './focusable.js';
export { getComputedStyle } from './get-computed-style.js';
export { getElementOffset } from './get-element-offset.js';
export { getEventPoint } from './get-event-point.js';
export { getPointRelativeToNode } from './get-point-relative-to-element.js';
export { EventKeyMap, getEventKey, getEventStep } from './keyboard-event.js';
export { addDomEvent, addPointerEvent, extractClientInfo, extractInfo, getEventName } from './listener.js';
export { observeAttributes, observeChildren } from './mutation-observer.js';
export { disposable, disposableNextTick, disposableRaf, nextTick, raf } from './next-tick.js';
export { findByText, indexOfId, itemById, nextById, prevById, query, queryAll, sortByTreeOrder } from './nodelist.js';
export { getPlatform, isApple, isDom, isFirefox, isIPhone, isIos, isMac, isSafari, isTouchDevice } from './platform.js';
export { trackPointerDown, trackPointerMove } from './pointer-event.js';
export { addPointerlockChangeListener, addPointerlockErrorListener, requestPointerLock } from './pointerlock.js';
export { contains, defineDomHelpers, getActiveDescendant, getActiveElement, getDocument, getDocumentElement, getEventTarget, getEventWindow, getNodeName, getParent, getRootNode, getWindow, isDisabled, isDocument, isElementEditable, isFrame, isHTMLElement, isShadowRoot, isVisible, isWindow, isWithinShadowRoot } from './query.js';
export { queueBeforeEvent } from './queue-before-event.js';
export { queueMicrotask } from './queue-microtask.js';
export { Measurable, observeElementRect } from './rect-observer.js';
export { getScrollOffset, getScrollParent, getScrollParents, isScrollParent } from './scrollable.js';
export { disableTextSelection, restoreTextSelection } from './text-selection.js';
export { TypeaheadOptions, TypeaheadState, findByTypeahead } from './typeahead.js';
export { trackDocumentVisibility } from './visibility-event.js';
export { trackVisualViewport } from './visual-viewport.js';
export { setVisuallyHidden, visuallyHiddenStyle } from './visually-hidden.js';
export { waitFor, waitForEvent } from './wait.js';
import '@zag-js/types';
import './listener.types.js';

@@ -185,3 +185,3 @@ "use strict";

// ../core/dist/index.mjs
// ../core/src/functions.ts
var runIfFn = (v, ...a) => {

@@ -197,2 +197,4 @@ const res = typeof v === "function" ? v(...a) : v;

};
// ../core/src/guard.ts
var isArray = (v) => Array.isArray(v);

@@ -199,0 +201,0 @@ var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));

{
"name": "@zag-js/dom-utils",
"version": "0.0.0-dev-20221118145623",
"version": "0.0.0-dev-20221228121448",
"description": "",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"keywords": [

@@ -28,11 +25,24 @@ "js",

"dependencies": {
"@zag-js/types": "0.0.0-dev-20221118145623"
"@zag-js/types": "0.0.0-dev-20221228121448"
},
"devDependencies": {
"@zag-js/utils": "0.0.0-dev-20221118145623"
"clean-package": "2.2.0",
"@zag-js/utils": "0.0.0-dev-20221228121448"
},
"clean-package": "../../../clean-package.config.json",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"./package.json": "./package.json"
},
"scripts": {
"build-fast": "tsup src/index.ts --format=esm,cjs",
"build-fast": "tsup src",
"start": "pnpm build --watch",
"build": "tsup src/index.ts --format=esm,cjs --dts",
"build": "tsup src --dts",
"test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",

@@ -39,0 +49,0 @@ "lint": "eslint src --ext .ts,.tsx",

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