@zag-js/dismissable 2.0.0-next.2 → 2.0.0-next.3
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/dismissable-layer.d.mts +2 -0
- package/dist/dismissable-layer.d.ts +2 -0
- package/dist/dismissable-layer.js +2 -0
- package/dist/dismissable-layer.mjs +2 -0
- package/dist/layer-stack.d.mts +4 -0
- package/dist/layer-stack.d.ts +4 -0
- package/dist/layer-stack.js +9 -1
- package/dist/layer-stack.mjs +9 -1
- package/package.json +4 -4
|
@@ -56,6 +56,8 @@ interface DismissableElementOptions extends DismissableElementHandlers, Persiste
|
|
|
56
56
|
* The type of layer being tracked
|
|
57
57
|
*/
|
|
58
58
|
type?: LayerType | undefined;
|
|
59
|
+
/** Groups this layer with its peers, so closing one does not dismiss the other. */
|
|
60
|
+
group?: string | undefined;
|
|
59
61
|
}
|
|
60
62
|
declare function trackDismissableElement(nodeOrFn: NodeOrFn, options: DismissableElementOptions): (args_0?: TeardownReason | undefined) => void;
|
|
61
63
|
declare function trackDismissableBranch(nodeOrFn: NodeOrFn, options?: {
|
|
@@ -56,6 +56,8 @@ interface DismissableElementOptions extends DismissableElementHandlers, Persiste
|
|
|
56
56
|
* The type of layer being tracked
|
|
57
57
|
*/
|
|
58
58
|
type?: LayerType | undefined;
|
|
59
|
+
/** Groups this layer with its peers, so closing one does not dismiss the other. */
|
|
60
|
+
group?: string | undefined;
|
|
59
61
|
}
|
|
60
62
|
declare function trackDismissableElement(nodeOrFn: NodeOrFn, options: DismissableElementOptions): (args_0?: TeardownReason | undefined) => void;
|
|
61
63
|
declare function trackDismissableBranch(nodeOrFn: NodeOrFn, options?: {
|
|
@@ -38,12 +38,14 @@ function trackDismissableElementImpl(node, options) {
|
|
|
38
38
|
exclude: excludeContainers,
|
|
39
39
|
debug,
|
|
40
40
|
type = "dialog",
|
|
41
|
+
group,
|
|
41
42
|
onLayerChange
|
|
42
43
|
} = options;
|
|
43
44
|
const layer = {
|
|
44
45
|
dismiss: onDismiss,
|
|
45
46
|
node,
|
|
46
47
|
type,
|
|
48
|
+
group,
|
|
47
49
|
pointerBlocking,
|
|
48
50
|
requestDismiss: onRequestDismiss,
|
|
49
51
|
onLayerChange
|
|
@@ -18,12 +18,14 @@ function trackDismissableElementImpl(node, options) {
|
|
|
18
18
|
exclude: excludeContainers,
|
|
19
19
|
debug,
|
|
20
20
|
type = "dialog",
|
|
21
|
+
group,
|
|
21
22
|
onLayerChange
|
|
22
23
|
} = options;
|
|
23
24
|
const layer = {
|
|
24
25
|
dismiss: onDismiss,
|
|
25
26
|
node,
|
|
26
27
|
type,
|
|
28
|
+
group,
|
|
27
29
|
pointerBlocking,
|
|
28
30
|
requestDismiss: onRequestDismiss,
|
|
29
31
|
onLayerChange
|
package/dist/layer-stack.d.mts
CHANGED
|
@@ -20,6 +20,8 @@ interface Layer {
|
|
|
20
20
|
id?: string | undefined;
|
|
21
21
|
/** The layer this one opened inside. Captured once and kept across re-registration. */
|
|
22
22
|
parentId?: string | undefined;
|
|
23
|
+
/** Layers sharing a group are peers, not ancestors. Used by menubar menus. */
|
|
24
|
+
group?: string | undefined;
|
|
23
25
|
dismiss: VoidFunction;
|
|
24
26
|
node: HTMLElement;
|
|
25
27
|
type: LayerType;
|
|
@@ -46,6 +48,8 @@ declare const layerStack: {
|
|
|
46
48
|
isBelowPointerBlockingLayer(node: HTMLElement): boolean;
|
|
47
49
|
isTopMost(node: HTMLElement | null): boolean;
|
|
48
50
|
layerFor(node: HTMLElement | null): Layer | undefined;
|
|
51
|
+
/** The most recently added layer in the same group, if any. */
|
|
52
|
+
peerFor(group: string): Layer | undefined;
|
|
49
53
|
isDescendantOf(layer: Layer, ancestorId: string | undefined): boolean;
|
|
50
54
|
depthOf(layer: Layer): number;
|
|
51
55
|
/** Descendants, shallowest first, so a cascade dismisses parents before their own children. */
|
package/dist/layer-stack.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ interface Layer {
|
|
|
20
20
|
id?: string | undefined;
|
|
21
21
|
/** The layer this one opened inside. Captured once and kept across re-registration. */
|
|
22
22
|
parentId?: string | undefined;
|
|
23
|
+
/** Layers sharing a group are peers, not ancestors. Used by menubar menus. */
|
|
24
|
+
group?: string | undefined;
|
|
23
25
|
dismiss: VoidFunction;
|
|
24
26
|
node: HTMLElement;
|
|
25
27
|
type: LayerType;
|
|
@@ -46,6 +48,8 @@ declare const layerStack: {
|
|
|
46
48
|
isBelowPointerBlockingLayer(node: HTMLElement): boolean;
|
|
47
49
|
isTopMost(node: HTMLElement | null): boolean;
|
|
48
50
|
layerFor(node: HTMLElement | null): Layer | undefined;
|
|
51
|
+
/** The most recently added layer in the same group, if any. */
|
|
52
|
+
peerFor(group: string): Layer | undefined;
|
|
49
53
|
isDescendantOf(layer: Layer, ancestorId: string | undefined): boolean;
|
|
50
54
|
depthOf(layer: Layer): number;
|
|
51
55
|
/** Descendants, shallowest first, so a cascade dismisses parents before their own children. */
|
package/dist/layer-stack.js
CHANGED
|
@@ -61,6 +61,13 @@ var layerStack = {
|
|
|
61
61
|
layerFor(node) {
|
|
62
62
|
return this.layers.find((layer) => layer.node === node);
|
|
63
63
|
},
|
|
64
|
+
/** The most recently added layer in the same group, if any. */
|
|
65
|
+
peerFor(group) {
|
|
66
|
+
for (let i = this.count() - 1; i >= 0; i--) {
|
|
67
|
+
if (this.layers[i].group === group) return this.layers[i];
|
|
68
|
+
}
|
|
69
|
+
return void 0;
|
|
70
|
+
},
|
|
64
71
|
isDescendantOf(layer, ancestorId) {
|
|
65
72
|
if (!ancestorId) return false;
|
|
66
73
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -131,7 +138,8 @@ var layerStack = {
|
|
|
131
138
|
layer.parentId = pending.parentId;
|
|
132
139
|
} else {
|
|
133
140
|
layer.id ?? (layer.id = `layer-${++layerId}`);
|
|
134
|
-
|
|
141
|
+
const peer = layer.group ? this.peerFor(layer.group) : void 0;
|
|
142
|
+
layer.parentId = peer ? peer.parentId : layer.parentId ?? this.layers[this.count() - 1]?.id;
|
|
135
143
|
}
|
|
136
144
|
if (existingIndex !== -1) {
|
|
137
145
|
this.layers.splice(existingIndex, 1);
|
package/dist/layer-stack.mjs
CHANGED
|
@@ -36,6 +36,13 @@ var layerStack = {
|
|
|
36
36
|
layerFor(node) {
|
|
37
37
|
return this.layers.find((layer) => layer.node === node);
|
|
38
38
|
},
|
|
39
|
+
/** The most recently added layer in the same group, if any. */
|
|
40
|
+
peerFor(group) {
|
|
41
|
+
for (let i = this.count() - 1; i >= 0; i--) {
|
|
42
|
+
if (this.layers[i].group === group) return this.layers[i];
|
|
43
|
+
}
|
|
44
|
+
return void 0;
|
|
45
|
+
},
|
|
39
46
|
isDescendantOf(layer, ancestorId) {
|
|
40
47
|
if (!ancestorId) return false;
|
|
41
48
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -106,7 +113,8 @@ var layerStack = {
|
|
|
106
113
|
layer.parentId = pending.parentId;
|
|
107
114
|
} else {
|
|
108
115
|
layer.id ?? (layer.id = `layer-${++layerId}`);
|
|
109
|
-
|
|
116
|
+
const peer = layer.group ? this.peerFor(layer.group) : void 0;
|
|
117
|
+
layer.parentId = peer ? peer.parentId : layer.parentId ?? this.layers[this.count() - 1]?.id;
|
|
110
118
|
}
|
|
111
119
|
if (existingIndex !== -1) {
|
|
112
120
|
this.layers.splice(existingIndex, 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/dismissable",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.3",
|
|
4
4
|
"description": "Dismissable layer utilities for the DOM",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@zag-js/interact-outside": "2.0.0-next.
|
|
30
|
-
"@zag-js/
|
|
31
|
-
"@zag-js/
|
|
29
|
+
"@zag-js/interact-outside": "2.0.0-next.3",
|
|
30
|
+
"@zag-js/dom-query": "2.0.0-next.3",
|
|
31
|
+
"@zag-js/utils": "2.0.0-next.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"clean-package": "2.2.0"
|