@zag-js/dismissable 2.0.0-next.2 → 2.0.0-next.4
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/dismiss-reason.d.mts +4 -0
- package/dist/dismiss-reason.d.ts +4 -0
- package/dist/dismiss-reason.js +12 -0
- package/dist/dismiss-reason.mjs +8 -0
- package/dist/dismissable-layer.d.mts +63 -59
- package/dist/dismissable-layer.d.ts +63 -59
- package/dist/dismissable-layer.js +96 -118
- package/dist/dismissable-layer.mjs +89 -96
- package/dist/escape-keydown.d.mts +1 -3
- package/dist/escape-keydown.d.ts +1 -3
- package/dist/escape-keydown.js +12 -35
- package/dist/escape-keydown.mjs +8 -10
- package/dist/index.d.mts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +14 -34
- package/dist/index.mjs +4 -6
- package/dist/layer-props.d.mts +17 -27
- package/dist/layer-props.d.ts +17 -27
- package/dist/layer-props.js +17 -44
- package/dist/layer-props.mjs +12 -18
- package/dist/layer-stack.d.mts +72 -67
- package/dist/layer-stack.d.ts +72 -67
- package/dist/layer-stack.js +219 -222
- package/dist/layer-stack.mjs +213 -195
- package/dist/pointer-event-outside.d.mts +2 -4
- package/dist/pointer-event-outside.d.ts +2 -4
- package/dist/pointer-event-outside.js +53 -75
- package/dist/pointer-event-outside.mjs +48 -49
- package/package.json +5 -5
package/dist/layer-stack.d.mts
CHANGED
|
@@ -1,71 +1,76 @@
|
|
|
1
|
-
type LayerType = "dialog" | "popover" | "menu" | "listbox" | (string & {});
|
|
2
|
-
type LayerDismissEventDetail = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export type LayerType = "dialog" | "popover" | "menu" | "listbox" | (string & {});
|
|
2
|
+
export type LayerDismissEventDetail = {
|
|
3
|
+
originalLayer: HTMLElement;
|
|
4
|
+
targetLayer: HTMLElement | undefined;
|
|
5
|
+
originalIndex: number;
|
|
6
|
+
targetIndex: number;
|
|
7
7
|
};
|
|
8
|
-
type LayerDismissEvent = CustomEvent<LayerDismissEventDetail>;
|
|
9
|
-
interface LayerSnapshot {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
export type LayerDismissEvent = CustomEvent<LayerDismissEventDetail>;
|
|
9
|
+
export interface LayerSnapshot {
|
|
10
|
+
active: boolean;
|
|
11
|
+
type: LayerType;
|
|
12
|
+
index: number;
|
|
13
|
+
nested: boolean;
|
|
14
|
+
hasNested: boolean;
|
|
15
|
+
nestedCount: number;
|
|
16
|
+
blocked: boolean;
|
|
17
17
|
}
|
|
18
|
-
interface Layer {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
export interface Layer {
|
|
19
|
+
/** Assigned on first registration. */
|
|
20
|
+
id?: string | undefined;
|
|
21
|
+
/** The layer this one opened inside. Captured once and kept across re-registration. */
|
|
22
|
+
parentId?: string | undefined;
|
|
23
|
+
/** Layers sharing a group are peers, not ancestors. Used by menubar menus. */
|
|
24
|
+
group?: string | undefined;
|
|
25
|
+
/** Elements the layer opened from. When set, it nests only in a layer containing one. */
|
|
26
|
+
origins?: Array<Element | null | undefined> | undefined;
|
|
27
|
+
dismiss: VoidFunction;
|
|
28
|
+
node: HTMLElement;
|
|
29
|
+
type: LayerType;
|
|
30
|
+
pointerBlocking?: boolean | (() => boolean) | undefined;
|
|
31
|
+
requestDismiss?: ((event: LayerDismissEvent) => void) | undefined;
|
|
32
|
+
onLayerChange?: ((snapshot: LayerSnapshot) => void) | undefined;
|
|
33
|
+
snapshot?: LayerSnapshot | undefined;
|
|
30
34
|
}
|
|
31
35
|
/** Resolved on read, so a layer's blocking can change without re-registering it. */
|
|
32
|
-
declare function isPointerBlocking(layer: Pick<Layer, "pointerBlocking">): boolean;
|
|
33
|
-
declare const layerStack: {
|
|
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
|
-
|
|
36
|
+
export declare function isPointerBlocking(layer: Pick<Layer, "pointerBlocking">): boolean;
|
|
37
|
+
export declare const layerStack: {
|
|
38
|
+
layers: Layer[];
|
|
39
|
+
branches: HTMLElement[];
|
|
40
|
+
/** Ids of layers whose descendant just closed. */
|
|
41
|
+
closingAncestors: Set<string>;
|
|
42
|
+
/** Descendants queued to close with their ancestor. A new layer can't nest in them. */
|
|
43
|
+
dismissing: WeakSet<HTMLElement>;
|
|
44
|
+
pendingReattach: Map<HTMLElement, {
|
|
45
|
+
id: string | undefined;
|
|
46
|
+
parentId: string | undefined;
|
|
47
|
+
index: number;
|
|
48
|
+
}>;
|
|
49
|
+
count(): number;
|
|
50
|
+
topMostPointerBlockingIndex(): number;
|
|
51
|
+
topMostPointerBlockingLayer(): Layer | undefined;
|
|
52
|
+
hasPointerBlockingLayer(): boolean;
|
|
53
|
+
isBelowPointerBlockingLayer(node: HTMLElement): boolean;
|
|
54
|
+
isTopMost(node: HTMLElement | null): boolean;
|
|
55
|
+
layerFor(node: HTMLElement | null): Layer | undefined;
|
|
56
|
+
parentFor(layer: Layer): Layer | undefined;
|
|
57
|
+
/** Top-level layers that opened from inside the new layer become its children. */
|
|
58
|
+
adopt(layer: Layer): Layer[];
|
|
59
|
+
/** The most recently added layer in the same group, if any. */
|
|
60
|
+
peerFor(group: string): Layer | undefined;
|
|
61
|
+
/** Descendants, shallowest first, so a cascade dismisses parents before their own children. */
|
|
62
|
+
getNestedLayers(node: HTMLElement): Layer[];
|
|
63
|
+
isInNestedLayer(node: HTMLElement, target: HTMLElement | EventTarget | null): boolean;
|
|
64
|
+
/** Focus leaving a closing descendant shouldn't dismiss its ancestors. */
|
|
65
|
+
isClosingAncestor(node: HTMLElement): boolean;
|
|
66
|
+
isInBranch(target: HTMLElement | EventTarget | null): boolean;
|
|
67
|
+
add(layer: Layer): void;
|
|
68
|
+
addBranch(node: HTMLElement): void;
|
|
69
|
+
remove(node: HTMLElement, options?: {
|
|
70
|
+
reattach?: boolean;
|
|
71
|
+
}): void;
|
|
72
|
+
removeBranch(node: HTMLElement): void;
|
|
73
|
+
syncLayers(): void;
|
|
74
|
+
indexOf(node: HTMLElement | undefined): number;
|
|
75
|
+
dismiss(node: HTMLElement, parent?: HTMLElement): void;
|
|
76
|
+
};
|
package/dist/layer-stack.d.ts
CHANGED
|
@@ -1,71 +1,76 @@
|
|
|
1
|
-
type LayerType = "dialog" | "popover" | "menu" | "listbox" | (string & {});
|
|
2
|
-
type LayerDismissEventDetail = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export type LayerType = "dialog" | "popover" | "menu" | "listbox" | (string & {});
|
|
2
|
+
export type LayerDismissEventDetail = {
|
|
3
|
+
originalLayer: HTMLElement;
|
|
4
|
+
targetLayer: HTMLElement | undefined;
|
|
5
|
+
originalIndex: number;
|
|
6
|
+
targetIndex: number;
|
|
7
7
|
};
|
|
8
|
-
type LayerDismissEvent = CustomEvent<LayerDismissEventDetail>;
|
|
9
|
-
interface LayerSnapshot {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
export type LayerDismissEvent = CustomEvent<LayerDismissEventDetail>;
|
|
9
|
+
export interface LayerSnapshot {
|
|
10
|
+
active: boolean;
|
|
11
|
+
type: LayerType;
|
|
12
|
+
index: number;
|
|
13
|
+
nested: boolean;
|
|
14
|
+
hasNested: boolean;
|
|
15
|
+
nestedCount: number;
|
|
16
|
+
blocked: boolean;
|
|
17
17
|
}
|
|
18
|
-
interface Layer {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
export interface Layer {
|
|
19
|
+
/** Assigned on first registration. */
|
|
20
|
+
id?: string | undefined;
|
|
21
|
+
/** The layer this one opened inside. Captured once and kept across re-registration. */
|
|
22
|
+
parentId?: string | undefined;
|
|
23
|
+
/** Layers sharing a group are peers, not ancestors. Used by menubar menus. */
|
|
24
|
+
group?: string | undefined;
|
|
25
|
+
/** Elements the layer opened from. When set, it nests only in a layer containing one. */
|
|
26
|
+
origins?: Array<Element | null | undefined> | undefined;
|
|
27
|
+
dismiss: VoidFunction;
|
|
28
|
+
node: HTMLElement;
|
|
29
|
+
type: LayerType;
|
|
30
|
+
pointerBlocking?: boolean | (() => boolean) | undefined;
|
|
31
|
+
requestDismiss?: ((event: LayerDismissEvent) => void) | undefined;
|
|
32
|
+
onLayerChange?: ((snapshot: LayerSnapshot) => void) | undefined;
|
|
33
|
+
snapshot?: LayerSnapshot | undefined;
|
|
30
34
|
}
|
|
31
35
|
/** Resolved on read, so a layer's blocking can change without re-registering it. */
|
|
32
|
-
declare function isPointerBlocking(layer: Pick<Layer, "pointerBlocking">): boolean;
|
|
33
|
-
declare const layerStack: {
|
|
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
|
-
|
|
36
|
+
export declare function isPointerBlocking(layer: Pick<Layer, "pointerBlocking">): boolean;
|
|
37
|
+
export declare const layerStack: {
|
|
38
|
+
layers: Layer[];
|
|
39
|
+
branches: HTMLElement[];
|
|
40
|
+
/** Ids of layers whose descendant just closed. */
|
|
41
|
+
closingAncestors: Set<string>;
|
|
42
|
+
/** Descendants queued to close with their ancestor. A new layer can't nest in them. */
|
|
43
|
+
dismissing: WeakSet<HTMLElement>;
|
|
44
|
+
pendingReattach: Map<HTMLElement, {
|
|
45
|
+
id: string | undefined;
|
|
46
|
+
parentId: string | undefined;
|
|
47
|
+
index: number;
|
|
48
|
+
}>;
|
|
49
|
+
count(): number;
|
|
50
|
+
topMostPointerBlockingIndex(): number;
|
|
51
|
+
topMostPointerBlockingLayer(): Layer | undefined;
|
|
52
|
+
hasPointerBlockingLayer(): boolean;
|
|
53
|
+
isBelowPointerBlockingLayer(node: HTMLElement): boolean;
|
|
54
|
+
isTopMost(node: HTMLElement | null): boolean;
|
|
55
|
+
layerFor(node: HTMLElement | null): Layer | undefined;
|
|
56
|
+
parentFor(layer: Layer): Layer | undefined;
|
|
57
|
+
/** Top-level layers that opened from inside the new layer become its children. */
|
|
58
|
+
adopt(layer: Layer): Layer[];
|
|
59
|
+
/** The most recently added layer in the same group, if any. */
|
|
60
|
+
peerFor(group: string): Layer | undefined;
|
|
61
|
+
/** Descendants, shallowest first, so a cascade dismisses parents before their own children. */
|
|
62
|
+
getNestedLayers(node: HTMLElement): Layer[];
|
|
63
|
+
isInNestedLayer(node: HTMLElement, target: HTMLElement | EventTarget | null): boolean;
|
|
64
|
+
/** Focus leaving a closing descendant shouldn't dismiss its ancestors. */
|
|
65
|
+
isClosingAncestor(node: HTMLElement): boolean;
|
|
66
|
+
isInBranch(target: HTMLElement | EventTarget | null): boolean;
|
|
67
|
+
add(layer: Layer): void;
|
|
68
|
+
addBranch(node: HTMLElement): void;
|
|
69
|
+
remove(node: HTMLElement, options?: {
|
|
70
|
+
reattach?: boolean;
|
|
71
|
+
}): void;
|
|
72
|
+
removeBranch(node: HTMLElement): void;
|
|
73
|
+
syncLayers(): void;
|
|
74
|
+
indexOf(node: HTMLElement | undefined): number;
|
|
75
|
+
dismiss(node: HTMLElement, parent?: HTMLElement): void;
|
|
76
|
+
};
|