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-20220714091855 to 0.0.0-dev-20220823075909

17

dist/index.d.ts

@@ -67,7 +67,2 @@ import { JSX } from '@zag-js/types';

declare function getClosestForm(el: HTMLElement): HTMLFormElement | null;
declare function trackFormReset(el: HTMLElement | null | undefined, callback: () => void): (() => void) | undefined;
declare function trackFieldsetDisabled(el: HTMLElement | null | undefined, callback: (disabled: boolean) => void): (() => void) | undefined;
declare function isNativeDisabled(el: HTMLElement): boolean;
declare type Key = keyof CSSStyleDeclaration | (string & {});

@@ -100,12 +95,2 @@ declare type Styles = Record<Key, any>;

declare type DescriptorOptions = {
type: "HTMLInputElement" | "HTMLTextAreaElement" | "HTMLSelectElement";
property: "value" | "checked";
};
declare function dispatchInputValueEvent(el: HTMLElement | null, value: string | number): void;
declare function dispatchInputCheckedEvent(el: HTMLElement | null, checked: boolean): void;
declare function trackInputPropertyMutation(el: HTMLInputElement | null, options: DescriptorOptions & {
fn?: (value: string) => void;
}): (() => void) | undefined;
declare type EventKey = "ArrowDown" | "ArrowUp" | "ArrowLeft" | "ArrowRight" | "Space" | "Enter" | "Comma" | "Escape" | "Backspace" | "Delete" | "Home" | "End" | "Tab" | "PageUp" | "PageDown" | (string & {});

@@ -310,2 +295,2 @@ declare type EventKeyMap = Partial<Record<EventKey, (event: JSX.KeyboardEvent) => void>>;

export { EventKeyMap, MAX_Z_INDEX, Measurable, TypeaheadOptions, TypeaheadState, addDomEvent, addPointerEvent, addPointerlockChangeListener, addPointerlockErrorListener, ariaAttr, contains, copyVisualStyles, dataAttr, defineDomHelpers, disableTextSelection, dispatchInputCheckedEvent, dispatchInputValueEvent, disposable, disposableNextTick, disposableRaf, extractClientInfo, extractInfo, findByText, findByTypeahead, fireBlurEvent, fireClickEvent, fireCustomEvent, fireKeyboardEvent, focusableSelector, getActiveDescendant, getActiveElement, getClosestForm, 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, isNativeDisabled, 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, trackFieldsetDisabled, trackFormReset, trackInputPropertyMutation, trackPointerDown, trackPointerMove, trackVisualViewport, visuallyHiddenStyle, waitFor, waitForEvent, whenMouse, whenTouchOrPen };
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, whenMouse, whenTouchOrPen };

162

dist/index.js

@@ -34,4 +34,2 @@ "use strict";

disableTextSelection: () => disableTextSelection,
dispatchInputCheckedEvent: () => dispatchInputCheckedEvent,
dispatchInputValueEvent: () => dispatchInputValueEvent,
disposable: () => disposable,

@@ -51,3 +49,2 @@ disposableNextTick: () => disposableNextTick,

getActiveElement: () => getActiveElement,
getClosestForm: () => getClosestForm,
getComputedStyle: () => getComputedStyle,

@@ -97,3 +94,2 @@ getDocument: () => getDocument,

isMouseEvent: () => isMouseEvent,
isNativeDisabled: () => isNativeDisabled,
isPrintableKey: () => isPrintableKey,

@@ -134,5 +130,2 @@ isRightClick: () => isRightClick,

trackDocumentVisibility: () => trackDocumentVisibility,
trackFieldsetDisabled: () => trackFieldsetDisabled,
trackFormReset: () => trackFormReset,
trackInputPropertyMutation: () => trackInputPropertyMutation,
trackPointerDown: () => trackPointerDown,

@@ -475,57 +468,2 @@ trackPointerMove: () => trackPointerMove,

// src/mutation-observer.ts
function observeAttributes(node, attributes, fn) {
if (!node)
return;
const attrs = Array.isArray(attributes) ? attributes : [attributes];
const win = node.ownerDocument.defaultView || window;
const obs = new win.MutationObserver((changes) => {
for (const change of changes) {
if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) {
fn(change);
}
}
});
obs.observe(node, { attributes: true, attributeFilter: attrs });
return () => obs.disconnect();
}
function observeChildren(node, fn) {
if (!node)
return;
const win = node.ownerDocument.defaultView || window;
const obs = new win.MutationObserver(fn);
obs.observe(node, { childList: true, subtree: true });
return () => obs.disconnect();
}
// src/form.ts
function getClosestForm(el) {
if (isFormElement(el))
return el.form;
else
return el.closest("form");
}
function isFormElement(el) {
return el.matches("textarea, input, select, button");
}
function trackFormReset(el, callback) {
if (!el)
return;
const form = getClosestForm(el);
form == null ? void 0 : form.addEventListener("reset", callback, { passive: true });
return () => {
form == null ? void 0 : form.removeEventListener("reset", callback);
};
}
function trackFieldsetDisabled(el, callback) {
const fieldset = el == null ? void 0 : el.closest("fieldset");
if (!fieldset)
return;
callback(fieldset.disabled);
return observeAttributes(fieldset, ["disabled"], () => callback(fieldset.disabled));
}
function isNativeDisabled(el) {
return el.matches(":disabled");
}
// src/get-element-offset.ts

@@ -575,59 +513,6 @@ function getElementOffset(element) {

// src/input-event.ts
function getDescriptor(el, options) {
const { type, property } = options;
const proto = getWindow(el)[type].prototype;
return Object.getOwnPropertyDescriptor(proto, property) ?? {};
}
function dispatchInputValueEvent(el, value) {
var _a;
if (!el)
return;
const win = getWindow(el);
if (!(el instanceof win.HTMLInputElement))
return;
const desc = getDescriptor(el, { type: "HTMLInputElement", property: "value" });
(_a = desc.set) == null ? void 0 : _a.call(el, value);
const event = new win.Event("input", { bubbles: true });
el.dispatchEvent(event);
}
function dispatchInputCheckedEvent(el, checked) {
var _a;
if (!el)
return;
const win = getWindow(el);
if (!(el instanceof win.HTMLInputElement))
return;
const desc = getDescriptor(el, { type: "HTMLInputElement", property: "checked" });
(_a = desc.set) == null ? void 0 : _a.call(el, checked);
const event = new win.Event("click", { bubbles: true });
el.dispatchEvent(event);
}
function trackInputPropertyMutation(el, options) {
const { fn, property, type } = options;
if (!fn || !el)
return;
const { get, set } = getDescriptor(el, { property, type });
let run = true;
Object.defineProperty(el, property, {
get() {
return get == null ? void 0 : get.call(this);
},
set(value) {
if (run)
fn(value);
return set == null ? void 0 : set.call(this, value);
}
});
return () => {
run = false;
};
}
// src/keyboard-event.ts
var rtlKeyMap = {
ArrowLeft: "ArrowRight",
ArrowRight: "ArrowLeft",
Home: "End",
End: "Home"
ArrowRight: "ArrowLeft"
};

@@ -732,2 +617,27 @@ var sameKeyMap = {

// src/mutation-observer.ts
function observeAttributes(node, attributes, fn) {
if (!node)
return;
const attrs = Array.isArray(attributes) ? attributes : [attributes];
const win = node.ownerDocument.defaultView || window;
const obs = new win.MutationObserver((changes) => {
for (const change of changes) {
if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) {
fn(change);
}
}
});
obs.observe(node, { attributes: true, attributeFilter: attrs });
return () => obs.disconnect();
}
function observeChildren(node, fn) {
if (!node)
return;
const win = node.ownerDocument.defaultView || window;
const obs = new win.MutationObserver(fn);
obs.observe(node, { childList: true, subtree: true });
return () => obs.disconnect();
}
// src/next-tick.ts

@@ -892,3 +802,9 @@ function nextTick(fn) {

};
return callAll(addPointerEvent(doc, "pointermove", handlePointerMove, false), addPointerEvent(doc, "pointerup", onPointerUp, false), addPointerEvent(doc, "pointercancel", onPointerUp, false), addPointerEvent(doc, "contextmenu", onPointerUp, false), disableTextSelection({ doc }));
return callAll(
addPointerEvent(doc, "pointermove", handlePointerMove, false),
addPointerEvent(doc, "pointerup", onPointerUp, false),
addPointerEvent(doc, "pointercancel", onPointerUp, false),
addPointerEvent(doc, "contextmenu", onPointerUp, false),
disableTextSelection({ doc })
);
}

@@ -929,3 +845,6 @@

body.requestPointerLock();
const cleanup = callAll(addPointerlockChangeListener(doc, onPointerChange), addPointerlockErrorListener(doc, onPointerError));
const cleanup = callAll(
addPointerlockChangeListener(doc, onPointerChange),
addPointerlockErrorListener(doc, onPointerError)
);
return function dispose() {

@@ -1159,4 +1078,2 @@ if (!supported)

disableTextSelection,
dispatchInputCheckedEvent,
dispatchInputValueEvent,
disposable,

@@ -1176,3 +1093,2 @@ disposableNextTick,

getActiveElement,
getClosestForm,
getComputedStyle,

@@ -1222,3 +1138,2 @@ getDocument,

isMouseEvent,
isNativeDisabled,
isPrintableKey,

@@ -1259,5 +1174,2 @@ isRightClick,

trackDocumentVisibility,
trackFieldsetDisabled,
trackFormReset,
trackInputPropertyMutation,
trackPointerDown,

@@ -1264,0 +1176,0 @@ trackPointerMove,

{
"name": "@zag-js/dom-utils",
"version": "0.0.0-dev-20220714091855",
"version": "0.0.0-dev-20220823075909",
"description": "",

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

"dependencies": {
"@zag-js/types": "0.0.0-dev-20220714091855"
"@zag-js/types": "0.2.4"
},
"devDependencies": {
"@zag-js/utils": "0.0.0-dev-20220714091855"
"@zag-js/utils": "0.1.3"
},

@@ -34,0 +34,0 @@ "scripts": {

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