@zag-js/aria-hidden 1.46.0 → 1.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aria-hidden.d.mts +3 -5
- package/dist/aria-hidden.d.ts +3 -5
- package/dist/aria-hidden.js +29 -56
- package/dist/aria-hidden.mjs +23 -29
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.js +20 -46
- package/dist/index.mjs +16 -21
- package/dist/walk-tree-outside.d.mts +6 -7
- package/dist/walk-tree-outside.d.ts +6 -7
- package/dist/walk-tree-outside.js +156 -191
- package/dist/walk-tree-outside.mjs +152 -166
- package/package.json +4 -4
package/dist/aria-hidden.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
declare const hideOthers: (originalTarget: Element | Element[], parentNode?: HTMLElement | null, markerName?: string, followControlledElements?: boolean) => VoidFunction | undefined;
|
|
2
|
-
declare const inertOthers: (originalTarget: Element | Element[], parentNode?: HTMLElement | null, markerName?: string, followControlledElements?: boolean) => VoidFunction | undefined;
|
|
3
|
-
declare const suppressOthers: (originalTarget: Element | Element[], parentNode?: HTMLElement, markerName?: string, followControlledElements?: boolean) => VoidFunction | undefined;
|
|
4
|
-
|
|
5
|
-
export { hideOthers, inertOthers, suppressOthers };
|
|
1
|
+
export declare const hideOthers: (originalTarget: Element | Element[], parentNode?: HTMLElement | null, markerName?: string, followControlledElements?: boolean) => VoidFunction | undefined;
|
|
2
|
+
export declare const inertOthers: (originalTarget: Element | Element[], parentNode?: HTMLElement | null, markerName?: string, followControlledElements?: boolean) => VoidFunction | undefined;
|
|
3
|
+
export declare const suppressOthers: (originalTarget: Element | Element[], parentNode?: HTMLElement, markerName?: string, followControlledElements?: boolean) => VoidFunction | undefined;
|
package/dist/aria-hidden.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
declare const hideOthers: (originalTarget: Element | Element[], parentNode?: HTMLElement | null, markerName?: string, followControlledElements?: boolean) => VoidFunction | undefined;
|
|
2
|
-
declare const inertOthers: (originalTarget: Element | Element[], parentNode?: HTMLElement | null, markerName?: string, followControlledElements?: boolean) => VoidFunction | undefined;
|
|
3
|
-
declare const suppressOthers: (originalTarget: Element | Element[], parentNode?: HTMLElement, markerName?: string, followControlledElements?: boolean) => VoidFunction | undefined;
|
|
4
|
-
|
|
5
|
-
export { hideOthers, inertOthers, suppressOthers };
|
|
1
|
+
export declare const hideOthers: (originalTarget: Element | Element[], parentNode?: HTMLElement | null, markerName?: string, followControlledElements?: boolean) => VoidFunction | undefined;
|
|
2
|
+
export declare const inertOthers: (originalTarget: Element | Element[], parentNode?: HTMLElement | null, markerName?: string, followControlledElements?: boolean) => VoidFunction | undefined;
|
|
3
|
+
export declare const suppressOthers: (originalTarget: Element | Element[], parentNode?: HTMLElement, markerName?: string, followControlledElements?: boolean) => VoidFunction | undefined;
|
package/dist/aria-hidden.js
CHANGED
|
@@ -1,61 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/aria-hidden.ts
|
|
21
|
-
var aria_hidden_exports = {};
|
|
22
|
-
__export(aria_hidden_exports, {
|
|
23
|
-
hideOthers: () => hideOthers,
|
|
24
|
-
inertOthers: () => inertOthers,
|
|
25
|
-
suppressOthers: () => suppressOthers
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
26
4
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return target.ownerDocument.body;
|
|
5
|
+
const require_walk_tree_outside = require("./walk-tree-outside.js");
|
|
6
|
+
// src/aria-hidden.ts
|
|
7
|
+
const getParentNode = (originalTarget) => {
|
|
8
|
+
return (Array.isArray(originalTarget) ? originalTarget[0] : originalTarget).ownerDocument.body;
|
|
32
9
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
10
|
+
const hideOthers = (originalTarget, parentNode = getParentNode(originalTarget), markerName = "data-aria-hidden", followControlledElements = true) => {
|
|
11
|
+
if (!parentNode) return;
|
|
12
|
+
return require_walk_tree_outside.walkTreeOutside(originalTarget, {
|
|
13
|
+
parentNode,
|
|
14
|
+
markerName,
|
|
15
|
+
attribute: "aria-hidden",
|
|
16
|
+
followControlledElements
|
|
17
|
+
});
|
|
41
18
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
19
|
+
const inertOthers = (originalTarget, parentNode = getParentNode(originalTarget), markerName = "data-inerted", followControlledElements = true) => {
|
|
20
|
+
if (!parentNode) return;
|
|
21
|
+
return require_walk_tree_outside.walkTreeOutside(originalTarget, {
|
|
22
|
+
parentNode,
|
|
23
|
+
markerName,
|
|
24
|
+
attribute: "inert",
|
|
25
|
+
followControlledElements
|
|
26
|
+
});
|
|
50
27
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return fn(originalTarget, parentNode, markerName, followControlledElements);
|
|
28
|
+
const supportsInert = () => typeof HTMLElement !== "undefined" && HTMLElement.prototype.hasOwnProperty("inert");
|
|
29
|
+
const suppressOthers = (originalTarget, parentNode, markerName = "data-suppressed", followControlledElements = true) => {
|
|
30
|
+
return (supportsInert() ? inertOthers : hideOthers)(originalTarget, parentNode, markerName, followControlledElements);
|
|
55
31
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
inertOthers,
|
|
60
|
-
suppressOthers
|
|
61
|
-
});
|
|
32
|
+
exports.hideOthers = hideOthers;
|
|
33
|
+
exports.inertOthers = inertOthers;
|
|
34
|
+
exports.suppressOthers = suppressOthers;
|
package/dist/aria-hidden.mjs
CHANGED
|
@@ -1,34 +1,28 @@
|
|
|
1
|
-
// src/aria-hidden.ts
|
|
2
1
|
import { walkTreeOutside } from "./walk-tree-outside.mjs";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
var hideOthers = (originalTarget, parentNode = getParentNode(originalTarget), markerName = "data-aria-hidden", followControlledElements = true) => {
|
|
8
|
-
if (!parentNode) return;
|
|
9
|
-
return walkTreeOutside(originalTarget, {
|
|
10
|
-
parentNode,
|
|
11
|
-
markerName,
|
|
12
|
-
attribute: "aria-hidden",
|
|
13
|
-
followControlledElements
|
|
14
|
-
});
|
|
2
|
+
// src/aria-hidden.ts
|
|
3
|
+
const getParentNode = (originalTarget) => {
|
|
4
|
+
return (Array.isArray(originalTarget) ? originalTarget[0] : originalTarget).ownerDocument.body;
|
|
15
5
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
const hideOthers = (originalTarget, parentNode = getParentNode(originalTarget), markerName = "data-aria-hidden", followControlledElements = true) => {
|
|
7
|
+
if (!parentNode) return;
|
|
8
|
+
return walkTreeOutside(originalTarget, {
|
|
9
|
+
parentNode,
|
|
10
|
+
markerName,
|
|
11
|
+
attribute: "aria-hidden",
|
|
12
|
+
followControlledElements
|
|
13
|
+
});
|
|
24
14
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
const inertOthers = (originalTarget, parentNode = getParentNode(originalTarget), markerName = "data-inerted", followControlledElements = true) => {
|
|
16
|
+
if (!parentNode) return;
|
|
17
|
+
return walkTreeOutside(originalTarget, {
|
|
18
|
+
parentNode,
|
|
19
|
+
markerName,
|
|
20
|
+
attribute: "inert",
|
|
21
|
+
followControlledElements
|
|
22
|
+
});
|
|
29
23
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
suppressOthers
|
|
24
|
+
const supportsInert = () => typeof HTMLElement !== "undefined" && HTMLElement.prototype.hasOwnProperty("inert");
|
|
25
|
+
const suppressOthers = (originalTarget, parentNode, markerName = "data-suppressed", followControlledElements = true) => {
|
|
26
|
+
return (supportsInert() ? inertOthers : hideOthers)(originalTarget, parentNode, markerName, followControlledElements);
|
|
34
27
|
};
|
|
28
|
+
export { hideOthers, inertOthers, suppressOthers };
|
package/dist/index.d.mts
CHANGED
|
@@ -2,8 +2,7 @@ type MaybeElement = HTMLElement | null;
|
|
|
2
2
|
type Targets = Array<MaybeElement>;
|
|
3
3
|
type TargetsOrFn = Targets | (() => Targets);
|
|
4
4
|
type Options = {
|
|
5
|
-
|
|
5
|
+
defer?: boolean | undefined;
|
|
6
6
|
};
|
|
7
|
-
declare function ariaHidden(targetsOrFn: TargetsOrFn, options?: Options): () => void;
|
|
8
|
-
|
|
9
|
-
export { ariaHidden };
|
|
7
|
+
export declare function ariaHidden(targetsOrFn: TargetsOrFn, options?: Options): () => void;
|
|
8
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ type MaybeElement = HTMLElement | null;
|
|
|
2
2
|
type Targets = Array<MaybeElement>;
|
|
3
3
|
type TargetsOrFn = Targets | (() => Targets);
|
|
4
4
|
type Options = {
|
|
5
|
-
|
|
5
|
+
defer?: boolean | undefined;
|
|
6
6
|
};
|
|
7
|
-
declare function ariaHidden(targetsOrFn: TargetsOrFn, options?: Options): () => void;
|
|
8
|
-
|
|
9
|
-
export { ariaHidden };
|
|
7
|
+
export declare function ariaHidden(targetsOrFn: TargetsOrFn, options?: Options): () => void;
|
|
8
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,50 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
ariaHidden: () => ariaHidden
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
4
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
const require_aria_hidden = require("./aria-hidden.js");
|
|
6
|
+
// src/index.ts
|
|
7
|
+
const raf = (fn) => {
|
|
8
|
+
const frameId = requestAnimationFrame(() => fn());
|
|
9
|
+
return () => cancelAnimationFrame(frameId);
|
|
30
10
|
};
|
|
31
11
|
function ariaHidden(targetsOrFn, options = {}) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return () => {
|
|
44
|
-
cleanups.forEach((fn) => fn?.());
|
|
45
|
-
};
|
|
12
|
+
const { defer = true } = options;
|
|
13
|
+
const func = defer ? raf : (v) => v();
|
|
14
|
+
const cleanups = [];
|
|
15
|
+
cleanups.push(func(() => {
|
|
16
|
+
const elements = (typeof targetsOrFn === "function" ? targetsOrFn() : targetsOrFn).filter(Boolean);
|
|
17
|
+
if (elements.length === 0) return;
|
|
18
|
+
cleanups.push(require_aria_hidden.hideOthers(elements));
|
|
19
|
+
}));
|
|
20
|
+
return () => {
|
|
21
|
+
cleanups.forEach((fn) => fn?.());
|
|
22
|
+
};
|
|
46
23
|
}
|
|
47
|
-
|
|
48
|
-
0 && (module.exports = {
|
|
49
|
-
ariaHidden
|
|
50
|
-
});
|
|
24
|
+
exports.ariaHidden = ariaHidden;
|
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
1
|
import { hideOthers } from "./aria-hidden.mjs";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
// src/index.ts
|
|
3
|
+
const raf = (fn) => {
|
|
4
|
+
const frameId = requestAnimationFrame(() => fn());
|
|
5
|
+
return () => cancelAnimationFrame(frameId);
|
|
6
6
|
};
|
|
7
7
|
function ariaHidden(targetsOrFn, options = {}) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return () => {
|
|
20
|
-
cleanups.forEach((fn) => fn?.());
|
|
21
|
-
};
|
|
8
|
+
const { defer = true } = options;
|
|
9
|
+
const func = defer ? raf : (v) => v();
|
|
10
|
+
const cleanups = [];
|
|
11
|
+
cleanups.push(func(() => {
|
|
12
|
+
const elements = (typeof targetsOrFn === "function" ? targetsOrFn() : targetsOrFn).filter(Boolean);
|
|
13
|
+
if (elements.length === 0) return;
|
|
14
|
+
cleanups.push(hideOthers(elements));
|
|
15
|
+
}));
|
|
16
|
+
return () => {
|
|
17
|
+
cleanups.forEach((fn) => fn?.());
|
|
18
|
+
};
|
|
22
19
|
}
|
|
23
|
-
export {
|
|
24
|
-
ariaHidden
|
|
25
|
-
};
|
|
20
|
+
export { ariaHidden };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
interface WalkTreeOutsideOptions {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
parentNode: HTMLElement;
|
|
3
|
+
markerName: string;
|
|
4
|
+
attribute: "aria-hidden" | "inert";
|
|
5
|
+
followControlledElements?: boolean;
|
|
6
6
|
}
|
|
7
|
-
declare const walkTreeOutside: (originalTarget: Element | Element[], props: WalkTreeOutsideOptions) => VoidFunction;
|
|
8
|
-
|
|
9
|
-
export { walkTreeOutside };
|
|
7
|
+
export declare const walkTreeOutside: (originalTarget: Element | Element[], props: WalkTreeOutsideOptions) => VoidFunction;
|
|
8
|
+
export {};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
interface WalkTreeOutsideOptions {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
parentNode: HTMLElement;
|
|
3
|
+
markerName: string;
|
|
4
|
+
attribute: "aria-hidden" | "inert";
|
|
5
|
+
followControlledElements?: boolean;
|
|
6
6
|
}
|
|
7
|
-
declare const walkTreeOutside: (originalTarget: Element | Element[], props: WalkTreeOutsideOptions) => VoidFunction;
|
|
8
|
-
|
|
9
|
-
export { walkTreeOutside };
|
|
7
|
+
export declare const walkTreeOutside: (originalTarget: Element | Element[], props: WalkTreeOutsideOptions) => VoidFunction;
|
|
8
|
+
export {};
|
|
@@ -1,199 +1,164 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/walk-tree-outside.ts
|
|
21
|
-
var walk_tree_outside_exports = {};
|
|
22
|
-
__export(walk_tree_outside_exports, {
|
|
23
|
-
walkTreeOutside: () => walkTreeOutside
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
4
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
console.error("[zag-js > ariaHidden] target", target, "in not contained inside", parent, ". Doing nothing");
|
|
39
|
-
return null;
|
|
5
|
+
let _zag_js_dom_query = require("@zag-js/dom-query");
|
|
6
|
+
// src/walk-tree-outside.ts
|
|
7
|
+
let counterMap = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
let uncontrolledNodes = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
let markerMap = {};
|
|
10
|
+
let lockCount = 0;
|
|
11
|
+
const unwrapHost = (node) => node && (node.host || unwrapHost(node.parentNode));
|
|
12
|
+
const correctTargets = (parent, targets) => targets.map((target) => {
|
|
13
|
+
if (parent.contains(target)) return target;
|
|
14
|
+
const correctedTarget = unwrapHost(target);
|
|
15
|
+
if (correctedTarget && parent.contains(correctedTarget)) return correctedTarget;
|
|
16
|
+
console.error("[zag-js > ariaHidden] target", target, "in not contained inside", parent, ". Doing nothing");
|
|
17
|
+
return null;
|
|
40
18
|
}).filter((x) => Boolean(x));
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
19
|
+
const ignoreableNodes = /* @__PURE__ */ new Set([
|
|
20
|
+
"script",
|
|
21
|
+
"output",
|
|
22
|
+
"status",
|
|
23
|
+
"next-route-announcer"
|
|
24
|
+
]);
|
|
25
|
+
const isIgnoredNode = (node) => {
|
|
26
|
+
if (ignoreableNodes.has(node.localName)) return true;
|
|
27
|
+
if (node.role === "status") return true;
|
|
28
|
+
if (node.hasAttribute("aria-live")) return true;
|
|
29
|
+
return node.matches("[data-live-announcer]");
|
|
47
30
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (!counterValue) {
|
|
114
|
-
if (!uncontrolledNodes.has(node)) {
|
|
115
|
-
node.removeAttribute(attribute);
|
|
116
|
-
}
|
|
117
|
-
uncontrolledNodes.delete(node);
|
|
118
|
-
}
|
|
119
|
-
if (!markerValue) {
|
|
120
|
-
node.removeAttribute(markerName);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
lockCount--;
|
|
124
|
-
if (!lockCount) {
|
|
125
|
-
counterMap = /* @__PURE__ */ new WeakMap();
|
|
126
|
-
uncontrolledNodes = /* @__PURE__ */ new WeakMap();
|
|
127
|
-
markerMap = {};
|
|
128
|
-
}
|
|
129
|
-
};
|
|
31
|
+
const applyAttributeToOthers = (allTargets, props) => {
|
|
32
|
+
var _markerMap;
|
|
33
|
+
const { parentNode, markerName, attribute, followControlledElements = true } = props;
|
|
34
|
+
const attributeValue = attribute === "aria-hidden" ? "true" : "";
|
|
35
|
+
const targets = allTargets.filter((target) => parentNode.contains(target));
|
|
36
|
+
if (!targets.length) return () => {};
|
|
37
|
+
(_markerMap = markerMap)[markerName] || (_markerMap[markerName] = /* @__PURE__ */ new WeakMap());
|
|
38
|
+
const markerCounter = markerMap[markerName];
|
|
39
|
+
const hiddenNodes = [];
|
|
40
|
+
const elementsToKeep = /* @__PURE__ */ new Set();
|
|
41
|
+
const elementsToStop = new Set(targets);
|
|
42
|
+
const keep = (el) => {
|
|
43
|
+
if (!el || elementsToKeep.has(el)) return;
|
|
44
|
+
elementsToKeep.add(el);
|
|
45
|
+
keep(el.parentNode);
|
|
46
|
+
};
|
|
47
|
+
targets.forEach((target) => {
|
|
48
|
+
keep(target);
|
|
49
|
+
if (followControlledElements && (0, _zag_js_dom_query.isHTMLElement)(target)) (0, _zag_js_dom_query.findControlledElements)(target, (controlledElement) => {
|
|
50
|
+
keep(controlledElement);
|
|
51
|
+
elementsToStop.add(controlledElement);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
const deep = (parent) => {
|
|
55
|
+
if (!parent || elementsToStop.has(parent)) return;
|
|
56
|
+
Array.prototype.forEach.call(parent.children, (node) => {
|
|
57
|
+
if (elementsToKeep.has(node)) deep(node);
|
|
58
|
+
else try {
|
|
59
|
+
if (isIgnoredNode(node)) return;
|
|
60
|
+
const alreadyHidden = attribute === "aria-hidden" ? node.getAttribute(attribute) === "true" : node.hasAttribute(attribute);
|
|
61
|
+
const counterValue = (counterMap.get(node) || 0) + 1;
|
|
62
|
+
const markerValue = (markerCounter.get(node) || 0) + 1;
|
|
63
|
+
counterMap.set(node, counterValue);
|
|
64
|
+
markerCounter.set(node, markerValue);
|
|
65
|
+
hiddenNodes.push(node);
|
|
66
|
+
if (counterValue === 1 && alreadyHidden) uncontrolledNodes.set(node, true);
|
|
67
|
+
if (markerValue === 1) node.setAttribute(markerName, "");
|
|
68
|
+
if (!alreadyHidden) node.setAttribute(attribute, attributeValue);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
console.error("[zag-js > ariaHidden] cannot operate on ", node, e);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
deep(parentNode);
|
|
75
|
+
elementsToKeep.clear();
|
|
76
|
+
lockCount++;
|
|
77
|
+
return () => {
|
|
78
|
+
hiddenNodes.forEach((node) => {
|
|
79
|
+
const counterValue = counterMap.get(node) - 1;
|
|
80
|
+
const markerValue = markerCounter.get(node) - 1;
|
|
81
|
+
counterMap.set(node, counterValue);
|
|
82
|
+
markerCounter.set(node, markerValue);
|
|
83
|
+
if (!counterValue) {
|
|
84
|
+
if (!uncontrolledNodes.has(node)) node.removeAttribute(attribute);
|
|
85
|
+
uncontrolledNodes.delete(node);
|
|
86
|
+
}
|
|
87
|
+
if (!markerValue) node.removeAttribute(markerName);
|
|
88
|
+
});
|
|
89
|
+
lockCount--;
|
|
90
|
+
if (!lockCount) {
|
|
91
|
+
counterMap = /* @__PURE__ */ new WeakMap();
|
|
92
|
+
uncontrolledNodes = /* @__PURE__ */ new WeakMap();
|
|
93
|
+
markerMap = {};
|
|
94
|
+
}
|
|
95
|
+
};
|
|
130
96
|
};
|
|
131
97
|
function createLockStack() {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
98
|
+
const locks = [];
|
|
99
|
+
return {
|
|
100
|
+
add(lock) {
|
|
101
|
+
locks[locks.length - 1]?.pause();
|
|
102
|
+
locks.push(lock);
|
|
103
|
+
lock.resume();
|
|
104
|
+
},
|
|
105
|
+
remove(lock) {
|
|
106
|
+
const index = locks.indexOf(lock);
|
|
107
|
+
if (index === -1) return;
|
|
108
|
+
const isTop = index === locks.length - 1;
|
|
109
|
+
locks.splice(index, 1);
|
|
110
|
+
if (!isTop) return;
|
|
111
|
+
lock.pause();
|
|
112
|
+
locks[locks.length - 1]?.resume();
|
|
113
|
+
}
|
|
114
|
+
};
|
|
149
115
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
116
|
+
const lockStacks = /* @__PURE__ */ new WeakMap();
|
|
117
|
+
const getLockStack = (doc) => {
|
|
118
|
+
let stack = lockStacks.get(doc);
|
|
119
|
+
if (!stack) {
|
|
120
|
+
stack = createLockStack();
|
|
121
|
+
lockStacks.set(doc, stack);
|
|
122
|
+
}
|
|
123
|
+
return stack;
|
|
158
124
|
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
125
|
+
const walkTreeOutside = (originalTarget, props) => {
|
|
126
|
+
const { parentNode, attribute, followControlledElements = true } = props;
|
|
127
|
+
const targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
128
|
+
if (!targets.length) return () => {};
|
|
129
|
+
const hiddenSelector = attribute === "aria-hidden" ? "[aria-hidden=\"true\"]" : "[inert]";
|
|
130
|
+
let undo;
|
|
131
|
+
let observer;
|
|
132
|
+
const apply = () => {
|
|
133
|
+
const prevUndo = undo;
|
|
134
|
+
undo = applyAttributeToOthers(targets, props);
|
|
135
|
+
prevUndo?.();
|
|
136
|
+
};
|
|
137
|
+
const release = () => {
|
|
138
|
+
undo?.();
|
|
139
|
+
undo = void 0;
|
|
140
|
+
};
|
|
141
|
+
const lock = {
|
|
142
|
+
pause() {
|
|
143
|
+
observer?.disconnect();
|
|
144
|
+
observer = void 0;
|
|
145
|
+
release();
|
|
146
|
+
},
|
|
147
|
+
resume() {
|
|
148
|
+
apply();
|
|
149
|
+
if (!followControlledElements) return;
|
|
150
|
+
observer = new ((0, _zag_js_dom_query.getWindow)(parentNode)).MutationObserver((records) => {
|
|
151
|
+
if (records.some(({ target }) => (0, _zag_js_dom_query.isElement)(target) && !target.closest(hiddenSelector))) apply();
|
|
152
|
+
});
|
|
153
|
+
observer.observe(parentNode, {
|
|
154
|
+
attributes: true,
|
|
155
|
+
attributeFilter: ["aria-expanded"],
|
|
156
|
+
subtree: true
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
const lockStack = getLockStack(parentNode.ownerDocument);
|
|
161
|
+
lockStack.add(lock);
|
|
162
|
+
return () => lockStack.remove(lock);
|
|
195
163
|
};
|
|
196
|
-
|
|
197
|
-
0 && (module.exports = {
|
|
198
|
-
walkTreeOutside
|
|
199
|
-
});
|
|
164
|
+
exports.walkTreeOutside = walkTreeOutside;
|
|
@@ -1,174 +1,160 @@
|
|
|
1
|
-
// src/walk-tree-outside.ts
|
|
2
1
|
import { findControlledElements, getWindow, isElement, isHTMLElement } from "@zag-js/dom-query";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return null;
|
|
2
|
+
// src/walk-tree-outside.ts
|
|
3
|
+
let counterMap = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
let uncontrolledNodes = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
let markerMap = {};
|
|
6
|
+
let lockCount = 0;
|
|
7
|
+
const unwrapHost = (node) => node && (node.host || unwrapHost(node.parentNode));
|
|
8
|
+
const correctTargets = (parent, targets) => targets.map((target) => {
|
|
9
|
+
if (parent.contains(target)) return target;
|
|
10
|
+
const correctedTarget = unwrapHost(target);
|
|
11
|
+
if (correctedTarget && parent.contains(correctedTarget)) return correctedTarget;
|
|
12
|
+
console.error("[zag-js > ariaHidden] target", target, "in not contained inside", parent, ". Doing nothing");
|
|
13
|
+
return null;
|
|
16
14
|
}).filter((x) => Boolean(x));
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
const ignoreableNodes = /* @__PURE__ */ new Set([
|
|
16
|
+
"script",
|
|
17
|
+
"output",
|
|
18
|
+
"status",
|
|
19
|
+
"next-route-announcer"
|
|
20
|
+
]);
|
|
21
|
+
const isIgnoredNode = (node) => {
|
|
22
|
+
if (ignoreableNodes.has(node.localName)) return true;
|
|
23
|
+
if (node.role === "status") return true;
|
|
24
|
+
if (node.hasAttribute("aria-live")) return true;
|
|
25
|
+
return node.matches("[data-live-announcer]");
|
|
23
26
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (!counterValue) {
|
|
90
|
-
if (!uncontrolledNodes.has(node)) {
|
|
91
|
-
node.removeAttribute(attribute);
|
|
92
|
-
}
|
|
93
|
-
uncontrolledNodes.delete(node);
|
|
94
|
-
}
|
|
95
|
-
if (!markerValue) {
|
|
96
|
-
node.removeAttribute(markerName);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
lockCount--;
|
|
100
|
-
if (!lockCount) {
|
|
101
|
-
counterMap = /* @__PURE__ */ new WeakMap();
|
|
102
|
-
uncontrolledNodes = /* @__PURE__ */ new WeakMap();
|
|
103
|
-
markerMap = {};
|
|
104
|
-
}
|
|
105
|
-
};
|
|
27
|
+
const applyAttributeToOthers = (allTargets, props) => {
|
|
28
|
+
var _markerMap;
|
|
29
|
+
const { parentNode, markerName, attribute, followControlledElements = true } = props;
|
|
30
|
+
const attributeValue = attribute === "aria-hidden" ? "true" : "";
|
|
31
|
+
const targets = allTargets.filter((target) => parentNode.contains(target));
|
|
32
|
+
if (!targets.length) return () => {};
|
|
33
|
+
(_markerMap = markerMap)[markerName] || (_markerMap[markerName] = /* @__PURE__ */ new WeakMap());
|
|
34
|
+
const markerCounter = markerMap[markerName];
|
|
35
|
+
const hiddenNodes = [];
|
|
36
|
+
const elementsToKeep = /* @__PURE__ */ new Set();
|
|
37
|
+
const elementsToStop = new Set(targets);
|
|
38
|
+
const keep = (el) => {
|
|
39
|
+
if (!el || elementsToKeep.has(el)) return;
|
|
40
|
+
elementsToKeep.add(el);
|
|
41
|
+
keep(el.parentNode);
|
|
42
|
+
};
|
|
43
|
+
targets.forEach((target) => {
|
|
44
|
+
keep(target);
|
|
45
|
+
if (followControlledElements && isHTMLElement(target)) findControlledElements(target, (controlledElement) => {
|
|
46
|
+
keep(controlledElement);
|
|
47
|
+
elementsToStop.add(controlledElement);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
const deep = (parent) => {
|
|
51
|
+
if (!parent || elementsToStop.has(parent)) return;
|
|
52
|
+
Array.prototype.forEach.call(parent.children, (node) => {
|
|
53
|
+
if (elementsToKeep.has(node)) deep(node);
|
|
54
|
+
else try {
|
|
55
|
+
if (isIgnoredNode(node)) return;
|
|
56
|
+
const alreadyHidden = attribute === "aria-hidden" ? node.getAttribute(attribute) === "true" : node.hasAttribute(attribute);
|
|
57
|
+
const counterValue = (counterMap.get(node) || 0) + 1;
|
|
58
|
+
const markerValue = (markerCounter.get(node) || 0) + 1;
|
|
59
|
+
counterMap.set(node, counterValue);
|
|
60
|
+
markerCounter.set(node, markerValue);
|
|
61
|
+
hiddenNodes.push(node);
|
|
62
|
+
if (counterValue === 1 && alreadyHidden) uncontrolledNodes.set(node, true);
|
|
63
|
+
if (markerValue === 1) node.setAttribute(markerName, "");
|
|
64
|
+
if (!alreadyHidden) node.setAttribute(attribute, attributeValue);
|
|
65
|
+
} catch (e) {
|
|
66
|
+
console.error("[zag-js > ariaHidden] cannot operate on ", node, e);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
deep(parentNode);
|
|
71
|
+
elementsToKeep.clear();
|
|
72
|
+
lockCount++;
|
|
73
|
+
return () => {
|
|
74
|
+
hiddenNodes.forEach((node) => {
|
|
75
|
+
const counterValue = counterMap.get(node) - 1;
|
|
76
|
+
const markerValue = markerCounter.get(node) - 1;
|
|
77
|
+
counterMap.set(node, counterValue);
|
|
78
|
+
markerCounter.set(node, markerValue);
|
|
79
|
+
if (!counterValue) {
|
|
80
|
+
if (!uncontrolledNodes.has(node)) node.removeAttribute(attribute);
|
|
81
|
+
uncontrolledNodes.delete(node);
|
|
82
|
+
}
|
|
83
|
+
if (!markerValue) node.removeAttribute(markerName);
|
|
84
|
+
});
|
|
85
|
+
lockCount--;
|
|
86
|
+
if (!lockCount) {
|
|
87
|
+
counterMap = /* @__PURE__ */ new WeakMap();
|
|
88
|
+
uncontrolledNodes = /* @__PURE__ */ new WeakMap();
|
|
89
|
+
markerMap = {};
|
|
90
|
+
}
|
|
91
|
+
};
|
|
106
92
|
};
|
|
107
93
|
function createLockStack() {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
94
|
+
const locks = [];
|
|
95
|
+
return {
|
|
96
|
+
add(lock) {
|
|
97
|
+
locks[locks.length - 1]?.pause();
|
|
98
|
+
locks.push(lock);
|
|
99
|
+
lock.resume();
|
|
100
|
+
},
|
|
101
|
+
remove(lock) {
|
|
102
|
+
const index = locks.indexOf(lock);
|
|
103
|
+
if (index === -1) return;
|
|
104
|
+
const isTop = index === locks.length - 1;
|
|
105
|
+
locks.splice(index, 1);
|
|
106
|
+
if (!isTop) return;
|
|
107
|
+
lock.pause();
|
|
108
|
+
locks[locks.length - 1]?.resume();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
125
111
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
};
|
|
135
|
-
var walkTreeOutside = (originalTarget, props) => {
|
|
136
|
-
const { parentNode, attribute, followControlledElements = true } = props;
|
|
137
|
-
const targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
138
|
-
if (!targets.length) return () => {
|
|
139
|
-
};
|
|
140
|
-
const hiddenSelector = attribute === "aria-hidden" ? '[aria-hidden="true"]' : "[inert]";
|
|
141
|
-
let undo;
|
|
142
|
-
let observer;
|
|
143
|
-
const apply = () => {
|
|
144
|
-
const prevUndo = undo;
|
|
145
|
-
undo = applyAttributeToOthers(targets, props);
|
|
146
|
-
prevUndo?.();
|
|
147
|
-
};
|
|
148
|
-
const release = () => {
|
|
149
|
-
undo?.();
|
|
150
|
-
undo = void 0;
|
|
151
|
-
};
|
|
152
|
-
const lock = {
|
|
153
|
-
pause() {
|
|
154
|
-
observer?.disconnect();
|
|
155
|
-
observer = void 0;
|
|
156
|
-
release();
|
|
157
|
-
},
|
|
158
|
-
resume() {
|
|
159
|
-
apply();
|
|
160
|
-
if (!followControlledElements) return;
|
|
161
|
-
const win = getWindow(parentNode);
|
|
162
|
-
observer = new win.MutationObserver((records) => {
|
|
163
|
-
if (records.some(({ target }) => isElement(target) && !target.closest(hiddenSelector))) apply();
|
|
164
|
-
});
|
|
165
|
-
observer.observe(parentNode, { attributes: true, attributeFilter: ["aria-expanded"], subtree: true });
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
const lockStack = getLockStack(parentNode.ownerDocument);
|
|
169
|
-
lockStack.add(lock);
|
|
170
|
-
return () => lockStack.remove(lock);
|
|
112
|
+
const lockStacks = /* @__PURE__ */ new WeakMap();
|
|
113
|
+
const getLockStack = (doc) => {
|
|
114
|
+
let stack = lockStacks.get(doc);
|
|
115
|
+
if (!stack) {
|
|
116
|
+
stack = createLockStack();
|
|
117
|
+
lockStacks.set(doc, stack);
|
|
118
|
+
}
|
|
119
|
+
return stack;
|
|
171
120
|
};
|
|
172
|
-
|
|
173
|
-
|
|
121
|
+
const walkTreeOutside = (originalTarget, props) => {
|
|
122
|
+
const { parentNode, attribute, followControlledElements = true } = props;
|
|
123
|
+
const targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
124
|
+
if (!targets.length) return () => {};
|
|
125
|
+
const hiddenSelector = attribute === "aria-hidden" ? "[aria-hidden=\"true\"]" : "[inert]";
|
|
126
|
+
let undo;
|
|
127
|
+
let observer;
|
|
128
|
+
const apply = () => {
|
|
129
|
+
const prevUndo = undo;
|
|
130
|
+
undo = applyAttributeToOthers(targets, props);
|
|
131
|
+
prevUndo?.();
|
|
132
|
+
};
|
|
133
|
+
const release = () => {
|
|
134
|
+
undo?.();
|
|
135
|
+
undo = void 0;
|
|
136
|
+
};
|
|
137
|
+
const lock = {
|
|
138
|
+
pause() {
|
|
139
|
+
observer?.disconnect();
|
|
140
|
+
observer = void 0;
|
|
141
|
+
release();
|
|
142
|
+
},
|
|
143
|
+
resume() {
|
|
144
|
+
apply();
|
|
145
|
+
if (!followControlledElements) return;
|
|
146
|
+
observer = new (getWindow(parentNode)).MutationObserver((records) => {
|
|
147
|
+
if (records.some(({ target }) => isElement(target) && !target.closest(hiddenSelector))) apply();
|
|
148
|
+
});
|
|
149
|
+
observer.observe(parentNode, {
|
|
150
|
+
attributes: true,
|
|
151
|
+
attributeFilter: ["aria-expanded"],
|
|
152
|
+
subtree: true
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const lockStack = getLockStack(parentNode.ownerDocument);
|
|
157
|
+
lockStack.add(lock);
|
|
158
|
+
return () => lockStack.remove(lock);
|
|
174
159
|
};
|
|
160
|
+
export { walkTreeOutside };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/aria-hidden",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.48.0",
|
|
4
4
|
"description": "Hide targets from screen readers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"clean-package": "../../../clean-package.config.json",
|
|
28
28
|
"main": "dist/index.js",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@zag-js/dom-query": "1.
|
|
30
|
+
"@zag-js/dom-query": "1.48.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"clean-package": "2.2.0"
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"./package.json": "./package.json"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
|
-
"build": "
|
|
51
|
+
"build": "tsdown",
|
|
52
52
|
"test": "vitest",
|
|
53
|
-
"lint": "
|
|
53
|
+
"lint": "oxlint src",
|
|
54
54
|
"test-ci": "pnpm test --ci --runInBand -u",
|
|
55
55
|
"test-watch": "pnpm test --watchAll"
|
|
56
56
|
}
|