@zag-js/dismissable 1.34.1 → 1.35.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.
@@ -0,0 +1,61 @@
1
+ import { InteractOutsideHandlers } from '@zag-js/interact-outside';
2
+ import { MaybeFunction } from '@zag-js/utils';
3
+ import { LayerDismissEvent, LayerType } from './layer-stack.mjs';
4
+
5
+ type MaybeElement = HTMLElement | null;
6
+ type Container = MaybeElement | Array<MaybeElement>;
7
+ type NodeOrFn = MaybeFunction<MaybeElement>;
8
+ interface DismissableElementHandlers extends InteractOutsideHandlers {
9
+ /**
10
+ * Function called when the escape key is pressed
11
+ */
12
+ onEscapeKeyDown?: ((event: KeyboardEvent) => void) | undefined;
13
+ /**
14
+ * Function called when this layer is closed due to a parent layer being closed
15
+ */
16
+ onRequestDismiss?: ((event: LayerDismissEvent) => void) | undefined;
17
+ }
18
+ interface PersistentElementOptions {
19
+ /**
20
+ * Returns the persistent elements that:
21
+ * - should not have pointer-events disabled
22
+ * - should not trigger the dismiss event
23
+ */
24
+ persistentElements?: Array<() => Element | null> | undefined;
25
+ }
26
+ interface DismissableElementOptions extends DismissableElementHandlers, PersistentElementOptions {
27
+ /**
28
+ * Whether to log debug information
29
+ */
30
+ debug?: boolean | undefined;
31
+ /**
32
+ * Whether to block pointer events outside the dismissable element
33
+ */
34
+ pointerBlocking?: boolean | undefined;
35
+ /**
36
+ * Function called when the dismissable element is dismissed
37
+ */
38
+ onDismiss: VoidFunction;
39
+ /**
40
+ * Exclude containers from the interact outside event
41
+ */
42
+ exclude?: MaybeFunction<Container> | undefined;
43
+ /**
44
+ * Defer the interact outside event to the next frame
45
+ */
46
+ defer?: boolean | undefined;
47
+ /**
48
+ * Whether to warn when the node is `null` or `undefined`
49
+ */
50
+ warnOnMissingNode?: boolean | undefined;
51
+ /**
52
+ * The type of layer being tracked
53
+ */
54
+ type?: LayerType | undefined;
55
+ }
56
+ declare function trackDismissableElement(nodeOrFn: NodeOrFn, options: DismissableElementOptions): () => void;
57
+ declare function trackDismissableBranch(nodeOrFn: NodeOrFn, options?: {
58
+ defer?: boolean | undefined;
59
+ }): () => void;
60
+
61
+ export { type DismissableElementHandlers, type DismissableElementOptions, type PersistentElementOptions, trackDismissableBranch, trackDismissableElement };
@@ -0,0 +1,61 @@
1
+ import { InteractOutsideHandlers } from '@zag-js/interact-outside';
2
+ import { MaybeFunction } from '@zag-js/utils';
3
+ import { LayerDismissEvent, LayerType } from './layer-stack.js';
4
+
5
+ type MaybeElement = HTMLElement | null;
6
+ type Container = MaybeElement | Array<MaybeElement>;
7
+ type NodeOrFn = MaybeFunction<MaybeElement>;
8
+ interface DismissableElementHandlers extends InteractOutsideHandlers {
9
+ /**
10
+ * Function called when the escape key is pressed
11
+ */
12
+ onEscapeKeyDown?: ((event: KeyboardEvent) => void) | undefined;
13
+ /**
14
+ * Function called when this layer is closed due to a parent layer being closed
15
+ */
16
+ onRequestDismiss?: ((event: LayerDismissEvent) => void) | undefined;
17
+ }
18
+ interface PersistentElementOptions {
19
+ /**
20
+ * Returns the persistent elements that:
21
+ * - should not have pointer-events disabled
22
+ * - should not trigger the dismiss event
23
+ */
24
+ persistentElements?: Array<() => Element | null> | undefined;
25
+ }
26
+ interface DismissableElementOptions extends DismissableElementHandlers, PersistentElementOptions {
27
+ /**
28
+ * Whether to log debug information
29
+ */
30
+ debug?: boolean | undefined;
31
+ /**
32
+ * Whether to block pointer events outside the dismissable element
33
+ */
34
+ pointerBlocking?: boolean | undefined;
35
+ /**
36
+ * Function called when the dismissable element is dismissed
37
+ */
38
+ onDismiss: VoidFunction;
39
+ /**
40
+ * Exclude containers from the interact outside event
41
+ */
42
+ exclude?: MaybeFunction<Container> | undefined;
43
+ /**
44
+ * Defer the interact outside event to the next frame
45
+ */
46
+ defer?: boolean | undefined;
47
+ /**
48
+ * Whether to warn when the node is `null` or `undefined`
49
+ */
50
+ warnOnMissingNode?: boolean | undefined;
51
+ /**
52
+ * The type of layer being tracked
53
+ */
54
+ type?: LayerType | undefined;
55
+ }
56
+ declare function trackDismissableElement(nodeOrFn: NodeOrFn, options: DismissableElementOptions): () => void;
57
+ declare function trackDismissableBranch(nodeOrFn: NodeOrFn, options?: {
58
+ defer?: boolean | undefined;
59
+ }): () => void;
60
+
61
+ export { type DismissableElementHandlers, type DismissableElementOptions, type PersistentElementOptions, trackDismissableBranch, trackDismissableElement };
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
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/dismissable-layer.ts
21
+ var dismissable_layer_exports = {};
22
+ __export(dismissable_layer_exports, {
23
+ trackDismissableBranch: () => trackDismissableBranch,
24
+ trackDismissableElement: () => trackDismissableElement
25
+ });
26
+ module.exports = __toCommonJS(dismissable_layer_exports);
27
+ var import_dom_query = require("@zag-js/dom-query");
28
+ var import_interact_outside = require("@zag-js/interact-outside");
29
+ var import_utils = require("@zag-js/utils");
30
+ var import_escape_keydown = require("./escape-keydown.cjs");
31
+ var import_layer_stack = require("./layer-stack.cjs");
32
+ var import_pointer_event_outside = require("./pointer-event-outside.cjs");
33
+ function trackDismissableElementImpl(node, options) {
34
+ const { warnOnMissingNode = true } = options;
35
+ if (warnOnMissingNode && !node) {
36
+ (0, import_utils.warn)("[@zag-js/dismissable] node is `null` or `undefined`");
37
+ return;
38
+ }
39
+ if (!node) {
40
+ return;
41
+ }
42
+ const { onDismiss, onRequestDismiss, pointerBlocking, exclude: excludeContainers, debug, type = "dialog" } = options;
43
+ const layer = { dismiss: onDismiss, node, type, pointerBlocking, requestDismiss: onRequestDismiss };
44
+ import_layer_stack.layerStack.add(layer);
45
+ (0, import_pointer_event_outside.assignPointerEventToLayers)();
46
+ function onPointerDownOutside(event) {
47
+ const target = (0, import_dom_query.getEventTarget)(event.detail.originalEvent);
48
+ if (import_layer_stack.layerStack.isBelowPointerBlockingLayer(node) || import_layer_stack.layerStack.isInBranch(target)) return;
49
+ options.onPointerDownOutside?.(event);
50
+ options.onInteractOutside?.(event);
51
+ if (event.defaultPrevented) return;
52
+ if (debug) {
53
+ console.log("onPointerDownOutside:", event.detail.originalEvent);
54
+ }
55
+ onDismiss?.();
56
+ }
57
+ function onFocusOutside(event) {
58
+ const target = (0, import_dom_query.getEventTarget)(event.detail.originalEvent);
59
+ if (import_layer_stack.layerStack.isInBranch(target)) return;
60
+ options.onFocusOutside?.(event);
61
+ options.onInteractOutside?.(event);
62
+ if (event.defaultPrevented) return;
63
+ if (debug) {
64
+ console.log("onFocusOutside:", event.detail.originalEvent);
65
+ }
66
+ onDismiss?.();
67
+ }
68
+ function onEscapeKeyDown(event) {
69
+ if (!import_layer_stack.layerStack.isTopMost(node)) return;
70
+ options.onEscapeKeyDown?.(event);
71
+ if (!event.defaultPrevented && onDismiss) {
72
+ event.preventDefault();
73
+ onDismiss();
74
+ }
75
+ }
76
+ function exclude(target) {
77
+ if (!node) return false;
78
+ const containers = typeof excludeContainers === "function" ? excludeContainers() : excludeContainers;
79
+ const _containers = Array.isArray(containers) ? containers : [containers];
80
+ const persistentElements = options.persistentElements?.map((fn) => fn()).filter(import_dom_query.isHTMLElement);
81
+ if (persistentElements) _containers.push(...persistentElements);
82
+ return _containers.some((node2) => (0, import_dom_query.contains)(node2, target)) || import_layer_stack.layerStack.isInNestedLayer(node, target);
83
+ }
84
+ const cleanups = [
85
+ pointerBlocking ? (0, import_pointer_event_outside.disablePointerEventsOutside)(node, options.persistentElements) : void 0,
86
+ (0, import_escape_keydown.trackEscapeKeydown)(node, onEscapeKeyDown),
87
+ (0, import_interact_outside.trackInteractOutside)(node, { exclude, onFocusOutside, onPointerDownOutside, defer: options.defer })
88
+ ];
89
+ return () => {
90
+ import_layer_stack.layerStack.remove(node);
91
+ (0, import_pointer_event_outside.assignPointerEventToLayers)();
92
+ (0, import_pointer_event_outside.clearPointerEvent)(node);
93
+ cleanups.forEach((fn) => fn?.());
94
+ };
95
+ }
96
+ function trackDismissableElement(nodeOrFn, options) {
97
+ const { defer } = options;
98
+ const func = defer ? import_dom_query.raf : (v) => v();
99
+ const cleanups = [];
100
+ cleanups.push(
101
+ func(() => {
102
+ const node = (0, import_utils.isFunction)(nodeOrFn) ? nodeOrFn() : nodeOrFn;
103
+ cleanups.push(trackDismissableElementImpl(node, options));
104
+ })
105
+ );
106
+ return () => {
107
+ cleanups.forEach((fn) => fn?.());
108
+ };
109
+ }
110
+ function trackDismissableBranch(nodeOrFn, options = {}) {
111
+ const { defer } = options;
112
+ const func = defer ? import_dom_query.raf : (v) => v();
113
+ const cleanups = [];
114
+ cleanups.push(
115
+ func(() => {
116
+ const node = (0, import_utils.isFunction)(nodeOrFn) ? nodeOrFn() : nodeOrFn;
117
+ if (!node) {
118
+ (0, import_utils.warn)("[@zag-js/dismissable] branch node is `null` or `undefined`");
119
+ return;
120
+ }
121
+ import_layer_stack.layerStack.addBranch(node);
122
+ cleanups.push(() => {
123
+ import_layer_stack.layerStack.removeBranch(node);
124
+ });
125
+ })
126
+ );
127
+ return () => {
128
+ cleanups.forEach((fn) => fn?.());
129
+ };
130
+ }
131
+ // Annotate the CommonJS export names for ESM import in node:
132
+ 0 && (module.exports = {
133
+ trackDismissableBranch,
134
+ trackDismissableElement
135
+ });
@@ -0,0 +1,111 @@
1
+ // src/dismissable-layer.ts
2
+ import { contains, getEventTarget, isHTMLElement, raf } from "@zag-js/dom-query";
3
+ import {
4
+ trackInteractOutside
5
+ } from "@zag-js/interact-outside";
6
+ import { isFunction, warn } from "@zag-js/utils";
7
+ import { trackEscapeKeydown } from "./escape-keydown.mjs";
8
+ import { layerStack } from "./layer-stack.mjs";
9
+ import { assignPointerEventToLayers, clearPointerEvent, disablePointerEventsOutside } from "./pointer-event-outside.mjs";
10
+ function trackDismissableElementImpl(node, options) {
11
+ const { warnOnMissingNode = true } = options;
12
+ if (warnOnMissingNode && !node) {
13
+ warn("[@zag-js/dismissable] node is `null` or `undefined`");
14
+ return;
15
+ }
16
+ if (!node) {
17
+ return;
18
+ }
19
+ const { onDismiss, onRequestDismiss, pointerBlocking, exclude: excludeContainers, debug, type = "dialog" } = options;
20
+ const layer = { dismiss: onDismiss, node, type, pointerBlocking, requestDismiss: onRequestDismiss };
21
+ layerStack.add(layer);
22
+ assignPointerEventToLayers();
23
+ function onPointerDownOutside(event) {
24
+ const target = getEventTarget(event.detail.originalEvent);
25
+ if (layerStack.isBelowPointerBlockingLayer(node) || layerStack.isInBranch(target)) return;
26
+ options.onPointerDownOutside?.(event);
27
+ options.onInteractOutside?.(event);
28
+ if (event.defaultPrevented) return;
29
+ if (debug) {
30
+ console.log("onPointerDownOutside:", event.detail.originalEvent);
31
+ }
32
+ onDismiss?.();
33
+ }
34
+ function onFocusOutside(event) {
35
+ const target = getEventTarget(event.detail.originalEvent);
36
+ if (layerStack.isInBranch(target)) return;
37
+ options.onFocusOutside?.(event);
38
+ options.onInteractOutside?.(event);
39
+ if (event.defaultPrevented) return;
40
+ if (debug) {
41
+ console.log("onFocusOutside:", event.detail.originalEvent);
42
+ }
43
+ onDismiss?.();
44
+ }
45
+ function onEscapeKeyDown(event) {
46
+ if (!layerStack.isTopMost(node)) return;
47
+ options.onEscapeKeyDown?.(event);
48
+ if (!event.defaultPrevented && onDismiss) {
49
+ event.preventDefault();
50
+ onDismiss();
51
+ }
52
+ }
53
+ function exclude(target) {
54
+ if (!node) return false;
55
+ const containers = typeof excludeContainers === "function" ? excludeContainers() : excludeContainers;
56
+ const _containers = Array.isArray(containers) ? containers : [containers];
57
+ const persistentElements = options.persistentElements?.map((fn) => fn()).filter(isHTMLElement);
58
+ if (persistentElements) _containers.push(...persistentElements);
59
+ return _containers.some((node2) => contains(node2, target)) || layerStack.isInNestedLayer(node, target);
60
+ }
61
+ const cleanups = [
62
+ pointerBlocking ? disablePointerEventsOutside(node, options.persistentElements) : void 0,
63
+ trackEscapeKeydown(node, onEscapeKeyDown),
64
+ trackInteractOutside(node, { exclude, onFocusOutside, onPointerDownOutside, defer: options.defer })
65
+ ];
66
+ return () => {
67
+ layerStack.remove(node);
68
+ assignPointerEventToLayers();
69
+ clearPointerEvent(node);
70
+ cleanups.forEach((fn) => fn?.());
71
+ };
72
+ }
73
+ function trackDismissableElement(nodeOrFn, options) {
74
+ const { defer } = options;
75
+ const func = defer ? raf : (v) => v();
76
+ const cleanups = [];
77
+ cleanups.push(
78
+ func(() => {
79
+ const node = isFunction(nodeOrFn) ? nodeOrFn() : nodeOrFn;
80
+ cleanups.push(trackDismissableElementImpl(node, options));
81
+ })
82
+ );
83
+ return () => {
84
+ cleanups.forEach((fn) => fn?.());
85
+ };
86
+ }
87
+ function trackDismissableBranch(nodeOrFn, options = {}) {
88
+ const { defer } = options;
89
+ const func = defer ? raf : (v) => v();
90
+ const cleanups = [];
91
+ cleanups.push(
92
+ func(() => {
93
+ const node = isFunction(nodeOrFn) ? nodeOrFn() : nodeOrFn;
94
+ if (!node) {
95
+ warn("[@zag-js/dismissable] branch node is `null` or `undefined`");
96
+ return;
97
+ }
98
+ layerStack.addBranch(node);
99
+ cleanups.push(() => {
100
+ layerStack.removeBranch(node);
101
+ });
102
+ })
103
+ );
104
+ return () => {
105
+ cleanups.forEach((fn) => fn?.());
106
+ };
107
+ }
108
+ export {
109
+ trackDismissableBranch,
110
+ trackDismissableElement
111
+ };
@@ -0,0 +1,3 @@
1
+ declare function trackEscapeKeydown(node: HTMLElement, fn?: (event: KeyboardEvent) => void): () => void;
2
+
3
+ export { trackEscapeKeydown };
@@ -0,0 +1,3 @@
1
+ declare function trackEscapeKeydown(node: HTMLElement, fn?: (event: KeyboardEvent) => void): () => void;
2
+
3
+ export { trackEscapeKeydown };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
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/escape-keydown.ts
21
+ var escape_keydown_exports = {};
22
+ __export(escape_keydown_exports, {
23
+ trackEscapeKeydown: () => trackEscapeKeydown
24
+ });
25
+ module.exports = __toCommonJS(escape_keydown_exports);
26
+ var import_dom_query = require("@zag-js/dom-query");
27
+ function trackEscapeKeydown(node, fn) {
28
+ const handleKeyDown = (event) => {
29
+ if (event.key !== "Escape") return;
30
+ if (event.isComposing) return;
31
+ fn?.(event);
32
+ };
33
+ return (0, import_dom_query.addDomEvent)((0, import_dom_query.getDocument)(node), "keydown", handleKeyDown, { capture: true });
34
+ }
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ trackEscapeKeydown
38
+ });
@@ -0,0 +1,13 @@
1
+ // src/escape-keydown.ts
2
+ import { addDomEvent, getDocument } from "@zag-js/dom-query";
3
+ function trackEscapeKeydown(node, fn) {
4
+ const handleKeyDown = (event) => {
5
+ if (event.key !== "Escape") return;
6
+ if (event.isComposing) return;
7
+ fn?.(event);
8
+ };
9
+ return addDomEvent(getDocument(node), "keydown", handleKeyDown, { capture: true });
10
+ }
11
+ export {
12
+ trackEscapeKeydown
13
+ };
package/dist/index.d.mts CHANGED
@@ -1,70 +1,4 @@
1
- import { InteractOutsideHandlers } from '@zag-js/interact-outside';
2
1
  export { FocusOutsideEvent, InteractOutsideEvent, InteractOutsideHandlers, PointerDownOutsideEvent } from '@zag-js/interact-outside';
3
- import { MaybeFunction } from '@zag-js/utils';
4
-
5
- type LayerType = "dialog" | "popover" | "menu" | "listbox" | (string & {});
6
- type LayerDismissEventDetail = {
7
- originalLayer: HTMLElement;
8
- targetLayer: HTMLElement | undefined;
9
- originalIndex: number;
10
- targetIndex: number;
11
- };
12
- type LayerDismissEvent = CustomEvent<LayerDismissEventDetail>;
13
-
14
- type MaybeElement = HTMLElement | null;
15
- type Container = MaybeElement | Array<MaybeElement>;
16
- type NodeOrFn = MaybeFunction<MaybeElement>;
17
- interface DismissableElementHandlers extends InteractOutsideHandlers {
18
- /**
19
- * Function called when the escape key is pressed
20
- */
21
- onEscapeKeyDown?: ((event: KeyboardEvent) => void) | undefined;
22
- /**
23
- * Function called when this layer is closed due to a parent layer being closed
24
- */
25
- onRequestDismiss?: ((event: LayerDismissEvent) => void) | undefined;
26
- }
27
- interface PersistentElementOptions {
28
- /**
29
- * Returns the persistent elements that:
30
- * - should not have pointer-events disabled
31
- * - should not trigger the dismiss event
32
- */
33
- persistentElements?: Array<() => Element | null> | undefined;
34
- }
35
- interface DismissableElementOptions extends DismissableElementHandlers, PersistentElementOptions {
36
- /**
37
- * Whether to log debug information
38
- */
39
- debug?: boolean | undefined;
40
- /**
41
- * Whether to block pointer events outside the dismissable element
42
- */
43
- pointerBlocking?: boolean | undefined;
44
- /**
45
- * Function called when the dismissable element is dismissed
46
- */
47
- onDismiss: VoidFunction;
48
- /**
49
- * Exclude containers from the interact outside event
50
- */
51
- exclude?: MaybeFunction<Container> | undefined;
52
- /**
53
- * Defer the interact outside event to the next frame
54
- */
55
- defer?: boolean | undefined;
56
- /**
57
- * Whether to warn when the node is `null` or `undefined`
58
- */
59
- warnOnMissingNode?: boolean | undefined;
60
- /**
61
- * The type of layer being tracked
62
- */
63
- type?: LayerType | undefined;
64
- }
65
- declare function trackDismissableElement(nodeOrFn: NodeOrFn, options: DismissableElementOptions): () => void;
66
- declare function trackDismissableBranch(nodeOrFn: NodeOrFn, options?: {
67
- defer?: boolean | undefined;
68
- }): () => void;
69
-
70
- export { type DismissableElementHandlers, type DismissableElementOptions, type LayerType, type PersistentElementOptions, trackDismissableBranch, trackDismissableElement };
2
+ export { DismissableElementHandlers, DismissableElementOptions, PersistentElementOptions, trackDismissableBranch, trackDismissableElement } from './dismissable-layer.mjs';
3
+ export { LayerType } from './layer-stack.mjs';
4
+ import '@zag-js/utils';
package/dist/index.d.ts CHANGED
@@ -1,70 +1,4 @@
1
- import { InteractOutsideHandlers } from '@zag-js/interact-outside';
2
1
  export { FocusOutsideEvent, InteractOutsideEvent, InteractOutsideHandlers, PointerDownOutsideEvent } from '@zag-js/interact-outside';
3
- import { MaybeFunction } from '@zag-js/utils';
4
-
5
- type LayerType = "dialog" | "popover" | "menu" | "listbox" | (string & {});
6
- type LayerDismissEventDetail = {
7
- originalLayer: HTMLElement;
8
- targetLayer: HTMLElement | undefined;
9
- originalIndex: number;
10
- targetIndex: number;
11
- };
12
- type LayerDismissEvent = CustomEvent<LayerDismissEventDetail>;
13
-
14
- type MaybeElement = HTMLElement | null;
15
- type Container = MaybeElement | Array<MaybeElement>;
16
- type NodeOrFn = MaybeFunction<MaybeElement>;
17
- interface DismissableElementHandlers extends InteractOutsideHandlers {
18
- /**
19
- * Function called when the escape key is pressed
20
- */
21
- onEscapeKeyDown?: ((event: KeyboardEvent) => void) | undefined;
22
- /**
23
- * Function called when this layer is closed due to a parent layer being closed
24
- */
25
- onRequestDismiss?: ((event: LayerDismissEvent) => void) | undefined;
26
- }
27
- interface PersistentElementOptions {
28
- /**
29
- * Returns the persistent elements that:
30
- * - should not have pointer-events disabled
31
- * - should not trigger the dismiss event
32
- */
33
- persistentElements?: Array<() => Element | null> | undefined;
34
- }
35
- interface DismissableElementOptions extends DismissableElementHandlers, PersistentElementOptions {
36
- /**
37
- * Whether to log debug information
38
- */
39
- debug?: boolean | undefined;
40
- /**
41
- * Whether to block pointer events outside the dismissable element
42
- */
43
- pointerBlocking?: boolean | undefined;
44
- /**
45
- * Function called when the dismissable element is dismissed
46
- */
47
- onDismiss: VoidFunction;
48
- /**
49
- * Exclude containers from the interact outside event
50
- */
51
- exclude?: MaybeFunction<Container> | undefined;
52
- /**
53
- * Defer the interact outside event to the next frame
54
- */
55
- defer?: boolean | undefined;
56
- /**
57
- * Whether to warn when the node is `null` or `undefined`
58
- */
59
- warnOnMissingNode?: boolean | undefined;
60
- /**
61
- * The type of layer being tracked
62
- */
63
- type?: LayerType | undefined;
64
- }
65
- declare function trackDismissableElement(nodeOrFn: NodeOrFn, options: DismissableElementOptions): () => void;
66
- declare function trackDismissableBranch(nodeOrFn: NodeOrFn, options?: {
67
- defer?: boolean | undefined;
68
- }): () => void;
69
-
70
- export { type DismissableElementHandlers, type DismissableElementOptions, type LayerType, type PersistentElementOptions, trackDismissableBranch, trackDismissableElement };
2
+ export { DismissableElementHandlers, DismissableElementOptions, PersistentElementOptions, trackDismissableBranch, trackDismissableElement } from './dismissable-layer.js';
3
+ export { LayerType } from './layer-stack.js';
4
+ import '@zag-js/utils';