Socket
Socket
Sign inDemoInstall

@zag-js/dom-query

Package Overview
Dependencies
0
Maintainers
1
Versions
638
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.0-dev-20240611102459 to 0.0.0-dev-20240611130830

140

dist/index.js

@@ -115,4 +115,3 @@ "use strict";

var getNodeName = (node) => {
if (isHTMLElement(node))
return node.localName || "";
if (isHTMLElement(node)) return node.localName || "";
return "#document";

@@ -128,6 +127,4 @@ };

function contains(parent, child) {
if (!parent || !child)
return false;
if (!isHTMLElement(parent) || !isHTMLElement(child))
return false;
if (!parent || !child) return false;
if (!isHTMLElement(parent) || !isHTMLElement(child)) return false;
return parent === child || parent.contains(child);

@@ -138,6 +135,4 @@ }

function getDocument(el) {
if (isDocument(el))
return el;
if (isWindow(el))
return el.document;
if (isDocument(el)) return el;
if (isWindow(el)) return el.document;
return el?.ownerDocument ?? document;

@@ -149,8 +144,5 @@ }

function getWindow(el) {
if (isShadowRoot(el))
return getWindow(el.host);
if (isDocument(el))
return el.defaultView ?? window;
if (isHTMLElement(el))
return el.ownerDocument?.defaultView ?? window;
if (isShadowRoot(el)) return getWindow(el.host);
if (isDocument(el)) return el.defaultView ?? window;
if (isHTMLElement(el)) return el.ownerDocument?.defaultView ?? window;
return window;

@@ -163,6 +155,4 @@ }

const el2 = activeElement.shadowRoot.activeElement;
if (el2 === activeElement)
break;
else
activeElement = el2;
if (el2 === activeElement) break;
else activeElement = el2;
}

@@ -175,4 +165,3 @@ return activeElement;

const { type, quality = 0.92 } = opts;
if (!svg)
throw new Error("[get-data-url]: could not find the svg element");
if (!svg) throw new Error("[get-data-url]: could not find the svg element");
const win = getWindow(svg);

@@ -238,16 +227,10 @@ const doc = win.document;

const element = event.currentTarget;
if (!element)
return false;
if (!element) return false;
const isAppleDevice = isApple();
if (isAppleDevice && !event.metaKey)
return false;
if (!isAppleDevice && !event.ctrlKey)
return false;
if (isAppleDevice && !event.metaKey) return false;
if (!isAppleDevice && !event.ctrlKey) return false;
const localName = element.localName;
if (localName === "a")
return true;
if (localName === "button" && element.type === "submit")
return true;
if (localName === "input" && element.type === "submit")
return true;
if (localName === "a") return true;
if (localName === "button" && element.type === "submit") return true;
if (localName === "input" && element.type === "submit") return true;
return false;

@@ -257,13 +240,8 @@ }

const element = event.currentTarget;
if (!element)
return false;
if (!element) return false;
const localName = element.localName;
if (!event.altKey)
return false;
if (localName === "a")
return true;
if (localName === "button" && element.type === "submit")
return true;
if (localName === "input" && element.type === "submit")
return true;
if (!event.altKey) return false;
if (localName === "a") return true;
if (localName === "button" && element.type === "submit") return true;
if (localName === "input" && element.type === "submit") return true;
return false;

@@ -291,4 +269,3 @@ }

let idx = indexOfId(v, id);
if (idx === -1)
return loop ? v[v.length - 1] : null;
if (idx === -1) return loop ? v[v.length - 1] : null;
idx = loop ? (idx - 1 + v.length) % v.length : Math.max(0, idx - 1);

@@ -301,6 +278,4 @@ return v[idx];

const code = char.charCodeAt(0);
if (code > 0 && code < 128)
return char;
if (code >= 128 && code <= 255)
return `/x${code.toString(16)}`.replace("/", "\\");
if (code > 0 && code < 128) return char;
if (code >= 128 && code <= 255) return `/x${code.toString(16)}`.replace("/", "\\");
return "";

@@ -394,4 +369,3 @@ }).join("").trim();

function isVisible(el) {
if (!isHTMLElement2(el))
return false;
if (!isHTMLElement2(el)) return false;
return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0;

@@ -405,4 +379,3 @@ }

var getFocusables = (container, includeContainer = false) => {
if (!container)
return [];
if (!container) return [];
const elements = Array.from(container.querySelectorAll(focusableSelector));

@@ -423,4 +396,3 @@ const include = includeContainer == true || includeContainer == "if-empty" && elements.length === 0;

function isFocusable(element) {
if (!element || element.closest("[inert]"))
return false;
if (!element || element.closest("[inert]")) return false;
return element.matches(focusableSelector) && isVisible(element);

@@ -433,4 +405,3 @@ }

function getTabbables(container, includeContainer) {
if (!container)
return [];
if (!container) return [];
const elements = Array.from(container.querySelectorAll(focusableSelector));

@@ -454,4 +425,3 @@ const tabbableElements = elements.filter(isTabbable);

function isTabbable(el) {
if (el != null && el.tabIndex > 0)
return true;
if (el != null && el.tabIndex > 0) return true;
return isFocusable(el) && !hasNegativeTabIndex(el);

@@ -477,4 +447,3 @@ }

const currentElement = current ?? doc.activeElement;
if (!currentElement)
return null;
if (!currentElement) return null;
const index = tabbables.indexOf(currentElement);

@@ -487,4 +456,3 @@ return tabbables[index + 1] || null;

const { root, getInitialEl, filter, enabled = true } = options;
if (!enabled)
return;
if (!enabled) return;
let node = null;

@@ -501,12 +469,8 @@ node || (node = typeof getInitialEl === "function" ? getInitialEl() : getInitialEl);

const container = event.currentTarget;
if (!container)
return false;
if (!container) return false;
const [firstTabbable, lastTabbable] = getTabbableEdges(container);
const doc = container.ownerDocument || document;
if (doc.activeElement === firstTabbable && event.shiftKey)
return false;
if (doc.activeElement === lastTabbable && !event.shiftKey)
return false;
if (!firstTabbable && !lastTabbable)
return false;
if (doc.activeElement === firstTabbable && event.shiftKey) return false;
if (doc.activeElement === lastTabbable && !event.shiftKey) return false;
if (!firstTabbable && !lastTabbable) return false;
return true;

@@ -530,4 +494,3 @@ }

function isHiddenElement(node) {
if (node.parentElement && isHiddenElement(node.parentElement))
return true;
if (node.parentElement && isHiddenElement(node.parentElement)) return true;
return node.hidden;

@@ -565,4 +528,3 @@ }

function observeAttributesImpl(node, options) {
if (!node)
return;
if (!node) return;
const { attributes, callback: fn } = options;

@@ -598,4 +560,3 @@ const win = node.ownerDocument.defaultView || window;

const { callback: fn } = options;
if (!node)
return;
if (!node) return;
const win = node.ownerDocument.defaultView || window;

@@ -651,4 +612,3 @@ const obs = new win.MutationObserver(fn);

function isInView(el, ancestor) {
if (!isHTMLElement(el))
return true;
if (!isHTMLElement(el)) return true;
const ancestorRect = getRect(ancestor);

@@ -665,4 +625,3 @@ const elRect = el.getBoundingClientRect();

function onKeyDown(event) {
if (event.key !== "Tab")
return;
if (event.key !== "Tab") return;
let elementToFocus = null;

@@ -678,4 +637,3 @@ const [firstTabbable, lastTabbable] = getTabbableEdges(container, true);

}
if (!elementToFocus)
return;
if (!elementToFocus) return;
event.preventDefault();

@@ -727,7 +685,5 @@ if (typeof onFocus === "function") {

setValue: (elem, value) => {
if (elem == null || value == null)
return;
if (elem == null || value == null) return;
const valueAsString = value.toString();
if (elem.value === valueAsString)
return;
if (elem.value === valueAsString) return;
elem.value = value.toString();

@@ -778,4 +734,3 @@ }

const isCurrent = elementCleanups.get(key) === nextCleanup;
if (!isCurrent)
return;
if (!isCurrent) return;
cleanup();

@@ -815,5 +770,4 @@ elementCleanups.set(key, prevCleanup);

function setStyle(element, style) {
if (!element)
return () => {
};
if (!element) return () => {
};
const setup = () => {

@@ -820,0 +774,0 @@ const prevStyle = element.style.cssText;

{
"name": "@zag-js/dom-query",
"version": "0.0.0-dev-20240611102459",
"version": "0.0.0-dev-20240611130830",
"description": "The dom helper library for zag.js machines",

@@ -5,0 +5,0 @@ "keywords": [

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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc