Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@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-20220422172147 to 0.0.0-dev-20220424123138

dist/visual-viewport.d.ts

5

dist/attrs.d.ts
declare type Booleanish = boolean | "true" | "false";
export declare const dataAttr: (guard: boolean | undefined) => Booleanish;
export declare const ariaAttr: (guard: boolean | undefined) => boolean;
export declare const matchAttr: (el: Element) => {
get: (key: string) => string;
set: (key: string, value: string) => void;
is: (key: string, value: string) => boolean;
};
export {};
//# sourceMappingURL=attrs.d.ts.map

2

dist/body-scroll-lock.d.ts

@@ -6,4 +6,4 @@ interface PreventScrollOptions {

}
export declare function preventBodyScroll(opts?: PreventScrollOptions): () => void;
export declare function preventBodyScroll(opts?: PreventScrollOptions): (v: void) => void;
export {};
//# sourceMappingURL=body-scroll-lock.d.ts.map

@@ -24,4 +24,5 @@ export * from "./attrs";

export * from "./visibility-event";
export * from "./visual-viewport";
export * from "./visually-hidden";
export * from "./wait";
//# sourceMappingURL=index.d.ts.map

@@ -71,2 +71,3 @@ var __create = Object.create;

itemById: () => itemById,
matchAttr: () => matchAttr,
nextById: () => nextById,

@@ -92,2 +93,3 @@ nextTick: () => nextTick,

trackPointerMove: () => trackPointerMove,
trackVisualViewport: () => trackVisualViewport,
validateBlur: () => validateBlur,

@@ -107,2 +109,11 @@ visuallyHiddenStyle: () => visuallyHiddenStyle,

};
var matchAttr = (el) => {
return {
get: (key) => el.getAttribute(key),
set: (key, value) => el.setAttribute(key, value),
is: (key, value) => {
return el.getAttribute(key) === value;
}
};
};

@@ -498,6 +509,10 @@ // src/computed-style.ts

function preventScrollStandard() {
const fn = pipe(setStyle(docEl, "paddingRight", `${win.innerWidth - docEl.clientWidth}px`), setStyle(docEl, "overflow", "hidden"));
return () => fn == null ? void 0 : fn();
if (docEl.hasAttribute("scroll-lock"))
return;
const fn = pipe(setStyle(docEl, "paddingRight", `${win.innerWidth - docEl.clientWidth}px`), setStyle(docEl, "overflow", "hidden"), () => docEl.setAttribute("scroll-lock", "true"));
return pipe(fn, () => docEl.removeAttribute("scroll-lock"));
}
function preventScrollMobileSafari() {
if (docEl.hasAttribute("scroll-lock"))
return;
let scrollable;

@@ -566,3 +581,3 @@ let lastY = 0;

win.scrollTo(0, 0);
let removeEvents = pipe(addDomEvent(doc, "touchstart", onTouchStart, { passive: false, capture: true }), addDomEvent(doc, "touchmove", onTouchMove, { passive: false, capture: true }), addDomEvent(doc, "touchend", onTouchEnd, { passive: false, capture: true }), addDomEvent(doc, "focus", onFocus, true), addDomEvent(win, "scroll", onWindowScroll));
let removeEvents = pipe(addDomEvent(doc, "touchstart", onTouchStart, { passive: false, capture: true }), addDomEvent(doc, "touchmove", onTouchMove, { passive: false, capture: true }), addDomEvent(doc, "touchend", onTouchEnd, { passive: false, capture: true }), addDomEvent(doc, "focus", onFocus, true), addDomEvent(win, "scroll", onWindowScroll), () => docEl.setAttribute("scroll-lock", "true"));
return () => {

@@ -572,2 +587,3 @@ restoreStyles();

win.scrollTo(scrollX, scrollY);
docEl.removeAttribute("scroll-lock");
};

@@ -779,15 +795,13 @@ }

var _a;
const { level = "polite", doc: ownerDocument, root, delay: rootDelay = 0 } = opts;
const doc = ownerDocument != null ? ownerDocument : document;
const { level = "polite", document: doc = document, root, delay: _delay = 0 } = opts;
const win = (_a = doc.defaultView) != null ? _a : window;
const parent = root != null ? root : doc.body;
function announce(msg, delay) {
function announce(message, delay) {
const oldRegion = doc.getElementById("__live-region__");
if (!!oldRegion) {
parent.removeChild(oldRegion);
}
delay = delay != null ? delay : rootDelay;
oldRegion == null ? void 0 : oldRegion.remove();
delay = delay != null ? delay : _delay;
const region = doc.createElement("span");
region.id = "__live-region__";
var role = level !== "assertive" ? "status" : "alert";
region.dataset.liveAnnouncer = "true";
const role = level !== "assertive" ? "status" : "alert";
region.setAttribute("aria-live", level);

@@ -798,3 +812,3 @@ region.setAttribute("role", role);

win.setTimeout(() => {
region.textContent = msg;
region.textContent = message;
}, delay);

@@ -804,5 +818,3 @@ }

const oldRegion = doc.getElementById("__live-region__");
if (oldRegion) {
parent.removeChild(oldRegion);
}
oldRegion == null ? void 0 : oldRegion.remove();
}

@@ -1064,2 +1076,19 @@ return { announce, destroy };

// src/visual-viewport.ts
function trackVisualViewport(options) {
var _a;
const { document: doc, resolve } = options;
const win = (doc == null ? void 0 : doc.defaultView) || window;
resolve == null ? void 0 : resolve(getViewportSize(win));
const onResize = () => resolve == null ? void 0 : resolve(getViewportSize(win));
return addDomEvent((_a = win.visualViewport) != null ? _a : win, "resize", onResize);
}
function getViewportSize(win) {
var _a, _b;
return {
width: ((_a = win.visualViewport) == null ? void 0 : _a.width) || win.innerWidth,
height: ((_b = win.visualViewport) == null ? void 0 : _b.height) || win.innerHeight
};
}
// src/wait.ts

@@ -1066,0 +1095,0 @@ function waitFor(predicate) {

export declare type LiveRegionOptions = {
level: "polite" | "assertive";
doc?: Document;
document?: Document;
root?: HTMLElement | null;

@@ -9,5 +9,5 @@ delay?: number;

export declare function createLiveRegion(opts?: Partial<LiveRegionOptions>): {
announce: (msg: string, delay?: number) => void;
announce: (message: string, delay?: number) => void;
destroy: () => void;
};
//# sourceMappingURL=live-region.d.ts.map
{
"name": "@zag-js/dom-utils",
"version": "0.0.0-dev-20220422172147",
"version": "0.0.0-dev-20220424123138",
"description": "",

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

"@types/react": "^18.0.0",
"@zag-js/utils": "^0.0.0-dev-20220422172147",
"@zag-js/utils": "^0.0.0-dev-20220424123138",
"scroll-into-view-if-needed": "^2.2.29"

@@ -32,0 +32,0 @@ },

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

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

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