@zag-js/toast 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.
Files changed (41) hide show
  1. package/dist/index.d.mts +10 -17
  2. package/dist/index.d.ts +10 -17
  3. package/dist/index.js +18 -45
  4. package/dist/index.mjs +5 -11
  5. package/dist/toast-group.connect.d.mts +4 -8
  6. package/dist/toast-group.connect.d.ts +4 -8
  7. package/dist/toast-group.connect.js +73 -97
  8. package/dist/toast-group.connect.mjs +68 -61
  9. package/dist/toast-group.machine.d.mts +2 -8
  10. package/dist/toast-group.machine.d.ts +2 -8
  11. package/dist/toast-group.machine.js +294 -302
  12. package/dist/toast-group.machine.mjs +289 -266
  13. package/dist/toast.anatomy.d.mts +2 -6
  14. package/dist/toast.anatomy.d.ts +2 -6
  15. package/dist/toast.anatomy.js +8 -40
  16. package/dist/toast.anatomy.mjs +4 -14
  17. package/dist/toast.connect.d.mts +4 -8
  18. package/dist/toast.connect.d.ts +4 -8
  19. package/dist/toast.connect.js +133 -158
  20. package/dist/toast.connect.mjs +128 -122
  21. package/dist/toast.dom.d.mts +21 -16
  22. package/dist/toast.dom.d.ts +21 -16
  23. package/dist/toast.dom.js +56 -53
  24. package/dist/toast.dom.mjs +42 -20
  25. package/dist/toast.machine.d.mts +2 -8
  26. package/dist/toast.machine.d.ts +2 -8
  27. package/dist/toast.machine.js +272 -311
  28. package/dist/toast.machine.mjs +268 -276
  29. package/dist/toast.store.d.mts +2 -8
  30. package/dist/toast.store.d.ts +2 -8
  31. package/dist/toast.store.js +344 -299
  32. package/dist/toast.store.mjs +340 -274
  33. package/dist/toast.types.d.mts +372 -374
  34. package/dist/toast.types.d.ts +372 -374
  35. package/dist/toast.types.js +4 -18
  36. package/dist/toast.types.mjs +1 -0
  37. package/dist/toast.utils.d.mts +10 -13
  38. package/dist/toast.utils.d.ts +10 -13
  39. package/dist/toast.utils.js +169 -198
  40. package/dist/toast.utils.mjs +159 -168
  41. package/package.json +9 -9
@@ -1,269 +1,292 @@
1
- // src/toast-group.machine.ts
1
+ import { getRegionEl, getToastEls } from "./toast.dom.mjs";
2
+ import { AnimationFrame, addDomEvent, contains, getEventTarget } from "@zag-js/dom-query";
3
+ import { uuid } from "@zag-js/utils";
2
4
  import { setup } from "@zag-js/core";
3
5
  import { trackDismissableBranch } from "@zag-js/dismissable";
4
- import { addDomEvent, AnimationFrame } from "@zag-js/dom-query";
5
- import { uuid } from "@zag-js/utils";
6
- import * as dom from "./toast.dom.mjs";
7
- var { guards, createMachine } = setup();
8
- var { and } = guards;
9
- var groupMachine = createMachine({
10
- props({ props }) {
11
- return {
12
- dir: "ltr",
13
- id: uuid(),
14
- ...props,
15
- store: props.store
16
- };
17
- },
18
- initialState({ prop }) {
19
- return prop("store").attrs.overlap ? "overlap" : "stack";
20
- },
21
- refs() {
22
- return {
23
- lastFocusedEl: null,
24
- isFocusWithin: false,
25
- isPointerWithin: false,
26
- ignoreMouseTimer: AnimationFrame.create(),
27
- dismissableCleanup: void 0
28
- };
29
- },
30
- context({ bindable }) {
31
- return {
32
- toasts: bindable(() => ({
33
- defaultValue: [],
34
- sync: true,
35
- hash: (toasts) => toasts.map((t) => t.id).join(",")
36
- })),
37
- heights: bindable(() => ({
38
- defaultValue: [],
39
- sync: true
40
- }))
41
- };
42
- },
43
- computed: {
44
- count: ({ context }) => context.get("toasts").length,
45
- overlap: ({ prop }) => prop("store").attrs.overlap,
46
- placement: ({ prop }) => prop("store").attrs.placement
47
- },
48
- effects: ["subscribeToStore", "trackDocumentVisibility", "trackHotKeyPress"],
49
- watch({ track, context, action }) {
50
- track([() => context.hash("toasts")], () => {
51
- queueMicrotask(() => {
52
- action(["collapsedIfEmpty", "setDismissableBranch"]);
53
- });
54
- });
55
- },
56
- exit: ["clearDismissableBranch", "clearLastFocusedEl", "clearMouseEventTimer"],
57
- on: {
58
- PAUSE_ALL: {
59
- actions: ["pauseToasts"]
60
- },
61
- RESUME_ALL: {
62
- actions: ["resumeToasts"]
63
- },
64
- "DOC.HOTKEY": {
65
- actions: ["focusRegionEl"]
66
- },
67
- "REGION.BLUR": [
68
- {
69
- guard: and("isOverlapping", "isPointerOut"),
70
- target: "overlap",
71
- actions: ["collapseToasts", "resumeToasts", "restoreFocusIfPointerOut"]
72
- },
73
- {
74
- guard: "isPointerOut",
75
- target: "stack",
76
- actions: ["resumeToasts", "restoreFocusIfPointerOut"]
77
- },
78
- {
79
- actions: ["clearFocusWithin"]
80
- }
81
- ],
82
- "TOAST.REMOVE": {
83
- actions: ["removeToast", "removeHeight", "ignoreMouseEventsTemporarily"]
84
- },
85
- "TOAST.PAUSE": {
86
- actions: ["pauseToasts"]
87
- }
88
- },
89
- states: {
90
- stack: {
91
- on: {
92
- "REGION.POINTER_LEAVE": [
93
- {
94
- guard: "isOverlapping",
95
- target: "overlap",
96
- actions: ["clearPointerWithin", "resumeToasts", "collapseToasts"]
97
- },
98
- {
99
- actions: ["clearPointerWithin", "resumeToasts"]
100
- }
101
- ],
102
- "REGION.OVERLAP": {
103
- target: "overlap",
104
- actions: ["collapseToasts"]
105
- },
106
- "REGION.FOCUS": {
107
- actions: ["setLastFocusedEl", "pauseToasts"]
108
- },
109
- "REGION.POINTER_ENTER": {
110
- actions: ["setPointerWithin", "pauseToasts"]
111
- }
112
- }
113
- },
114
- overlap: {
115
- on: {
116
- "REGION.STACK": {
117
- target: "stack",
118
- actions: ["expandToasts"]
119
- },
120
- "REGION.POINTER_ENTER": {
121
- target: "stack",
122
- actions: ["setPointerWithin", "pauseToasts", "expandToasts"]
123
- },
124
- "REGION.FOCUS": {
125
- target: "stack",
126
- actions: ["setLastFocusedEl", "pauseToasts", "expandToasts"]
127
- }
128
- }
129
- }
130
- },
131
- implementations: {
132
- guards: {
133
- isOverlapping: ({ computed }) => computed("overlap"),
134
- isPointerOut: ({ refs }) => !refs.get("isPointerWithin")
135
- },
136
- effects: {
137
- subscribeToStore({ context, prop }) {
138
- const store = prop("store");
139
- context.set("toasts", store.getVisibleToasts());
140
- return store.subscribe((toast) => {
141
- if (toast.dismiss) {
142
- context.set("toasts", (prev) => prev.filter((t) => t.id !== toast.id));
143
- return;
144
- }
145
- context.set("toasts", (prev) => {
146
- const index = prev.findIndex((t) => t.id === toast.id);
147
- if (index !== -1) {
148
- return [...prev.slice(0, index), { ...prev[index], ...toast }, ...prev.slice(index + 1)];
149
- }
150
- return [toast, ...prev];
151
- });
152
- });
153
- },
154
- trackHotKeyPress({ prop, send }) {
155
- const handleKeyDown = (event) => {
156
- const { hotkey } = prop("store").attrs;
157
- const isHotkeyPressed = hotkey.every((key) => event[key] || event.code === key);
158
- if (!isHotkeyPressed) return;
159
- send({ type: "DOC.HOTKEY" });
160
- };
161
- return addDomEvent(document, "keydown", handleKeyDown, { capture: true });
162
- },
163
- trackDocumentVisibility({ prop, send, scope }) {
164
- const { pauseOnPageIdle } = prop("store").attrs;
165
- if (!pauseOnPageIdle) return;
166
- const doc = scope.getDoc();
167
- if (doc.visibilityState === "hidden") send({ type: "PAUSE_ALL" });
168
- return addDomEvent(doc, "visibilitychange", () => {
169
- const isHidden = doc.visibilityState === "hidden";
170
- send({ type: isHidden ? "PAUSE_ALL" : "RESUME_ALL" });
171
- });
172
- }
173
- },
174
- actions: {
175
- setDismissableBranch({ refs, context, computed, scope }) {
176
- const toasts = context.get("toasts");
177
- const placement = computed("placement");
178
- const hasToasts = toasts.length > 0;
179
- if (!hasToasts) {
180
- refs.get("dismissableCleanup")?.();
181
- refs.set("dismissableCleanup", void 0);
182
- return;
183
- }
184
- if (hasToasts && refs.get("dismissableCleanup")) {
185
- return;
186
- }
187
- const groupEl = () => dom.getRegionEl(scope, placement);
188
- const cleanup = trackDismissableBranch(groupEl, { defer: true });
189
- refs.set("dismissableCleanup", cleanup);
190
- },
191
- clearDismissableBranch({ refs }) {
192
- refs.get("dismissableCleanup")?.();
193
- refs.set("dismissableCleanup", void 0);
194
- },
195
- focusRegionEl({ scope, computed }) {
196
- queueMicrotask(() => {
197
- dom.getRegionEl(scope, computed("placement"))?.focus();
198
- });
199
- },
200
- pauseToasts({ prop }) {
201
- prop("store").pause();
202
- },
203
- resumeToasts({ prop, refs, scope, event }) {
204
- if (event.type === "REGION.BLUR") refs.set("isFocusWithin", false);
205
- const idle = prop("store").attrs.pauseOnPageIdle && scope.getDoc().visibilityState === "hidden";
206
- if (idle || refs.get("isPointerWithin") || refs.get("isFocusWithin")) return;
207
- prop("store").resume();
208
- },
209
- expandToasts({ prop }) {
210
- prop("store").expand();
211
- },
212
- collapseToasts({ prop }) {
213
- prop("store").collapse();
214
- },
215
- removeToast({ prop, event }) {
216
- prop("store").remove(event.id);
217
- },
218
- removeHeight({ event, context }) {
219
- if (event?.id == null) return;
220
- queueMicrotask(() => {
221
- context.set("heights", (heights) => heights.filter((height) => height.id !== event.id));
222
- });
223
- },
224
- collapsedIfEmpty({ send, computed }) {
225
- if (!computed("overlap") || computed("count") > 1) return;
226
- send({ type: "REGION.OVERLAP" });
227
- },
228
- setLastFocusedEl({ refs, event }) {
229
- if (refs.get("isFocusWithin")) return;
230
- refs.set("isFocusWithin", true);
231
- refs.set("lastFocusedEl", event.target ?? null);
232
- },
233
- restoreFocusIfPointerOut({ refs }) {
234
- if (!refs.get("lastFocusedEl") || refs.get("isPointerWithin")) return;
235
- refs.get("lastFocusedEl")?.focus({ preventScroll: true });
236
- refs.set("lastFocusedEl", null);
237
- refs.set("isFocusWithin", false);
238
- },
239
- setPointerWithin({ refs }) {
240
- refs.set("isPointerWithin", true);
241
- },
242
- clearPointerWithin({ refs }) {
243
- refs.set("isPointerWithin", false);
244
- if (refs.get("lastFocusedEl") && !refs.get("isFocusWithin")) {
245
- refs.get("lastFocusedEl")?.focus({ preventScroll: true });
246
- refs.set("lastFocusedEl", null);
247
- }
248
- },
249
- clearFocusWithin({ refs }) {
250
- refs.set("isFocusWithin", false);
251
- },
252
- clearLastFocusedEl({ refs }) {
253
- if (!refs.get("lastFocusedEl")) return;
254
- refs.get("lastFocusedEl")?.focus({ preventScroll: true });
255
- refs.set("lastFocusedEl", null);
256
- refs.set("isFocusWithin", false);
257
- },
258
- ignoreMouseEventsTemporarily({ refs }) {
259
- refs.get("ignoreMouseTimer").request();
260
- },
261
- clearMouseEventTimer({ refs }) {
262
- refs.get("ignoreMouseTimer").cancel();
263
- }
264
- }
265
- }
6
+ // src/toast-group.machine.ts
7
+ const { guards, createMachine } = setup();
8
+ const { and } = guards;
9
+ const groupMachine = createMachine({
10
+ props({ props }) {
11
+ return {
12
+ dir: "ltr",
13
+ id: uuid(),
14
+ ...props,
15
+ store: props.store
16
+ };
17
+ },
18
+ initialState({ prop }) {
19
+ return prop("store").attrs.overlap ? "overlap" : "stack";
20
+ },
21
+ refs() {
22
+ return {
23
+ lastFocusedEl: null,
24
+ isFocusWithin: false,
25
+ isPointerWithin: false,
26
+ ignoreMouseTimer: AnimationFrame.create(),
27
+ dismissableCleanup: void 0
28
+ };
29
+ },
30
+ context({ bindable }) {
31
+ return {
32
+ toasts: bindable(() => ({
33
+ defaultValue: [],
34
+ sync: true,
35
+ hash: (toasts) => toasts.map((t) => t.id).join(",")
36
+ })),
37
+ heights: bindable(() => ({
38
+ defaultValue: [],
39
+ sync: true
40
+ }))
41
+ };
42
+ },
43
+ computed: {
44
+ count: ({ context }) => context.get("toasts").length,
45
+ overlap: ({ prop }) => prop("store").attrs.overlap,
46
+ placement: ({ prop }) => prop("store").attrs.placement
47
+ },
48
+ effects: [
49
+ "subscribeToStore",
50
+ "subscribeToLayout",
51
+ "trackDocumentVisibility",
52
+ "trackHotKeyPress"
53
+ ],
54
+ watch({ track, context, action }) {
55
+ track([() => context.hash("toasts")], () => {
56
+ queueMicrotask(() => {
57
+ action([
58
+ "collapsedIfEmpty",
59
+ "setDismissableBranch",
60
+ "resetInteractionIfEmpty"
61
+ ]);
62
+ });
63
+ });
64
+ },
65
+ exit: [
66
+ "clearDismissableBranch",
67
+ "clearLastFocusedEl",
68
+ "clearMouseEventTimer"
69
+ ],
70
+ on: {
71
+ PAUSE_ALL: { actions: ["pauseToasts"] },
72
+ RESUME_ALL: { actions: ["resumeToasts"] },
73
+ "DOC.HOTKEY": { actions: ["focusRegionEl"] },
74
+ "REGION.BLUR": [
75
+ {
76
+ guard: and("isOverlapping", "isPointerOut"),
77
+ target: "overlap",
78
+ actions: ["resumeToasts", "restoreFocusIfPointerOut"]
79
+ },
80
+ {
81
+ guard: "isPointerOut",
82
+ target: "stack",
83
+ actions: ["resumeToasts", "restoreFocusIfPointerOut"]
84
+ },
85
+ { actions: ["clearFocusWithin"] }
86
+ ],
87
+ "TOAST.DISMISS": { actions: ["moveFocusOnDismiss"] },
88
+ "TOAST.REMOVE": { actions: [
89
+ "removeToast",
90
+ "removeHeight",
91
+ "ignoreMouseEventsTemporarily"
92
+ ] },
93
+ "TOAST.PAUSE": { actions: ["pauseToasts"] }
94
+ },
95
+ states: {
96
+ stack: { on: {
97
+ "REGION.POINTER_LEAVE": [{
98
+ guard: "isOverlapping",
99
+ target: "overlap",
100
+ actions: ["clearPointerWithin", "resumeToasts"]
101
+ }, { actions: ["clearPointerWithin", "resumeToasts"] }],
102
+ "REGION.OVERLAP": { target: "overlap" },
103
+ "REGION.FOCUS": { actions: ["setLastFocusedEl", "pauseToasts"] },
104
+ "REGION.POINTER_ENTER": { actions: ["setPointerWithin", "pauseToasts"] }
105
+ } },
106
+ overlap: { on: {
107
+ "REGION.STACK": { target: "stack" },
108
+ "REGION.POINTER_ENTER": {
109
+ target: "stack",
110
+ actions: ["setPointerWithin", "pauseToasts"]
111
+ },
112
+ "REGION.POINTER_LEAVE": { actions: ["clearPointerWithin", "resumeToasts"] },
113
+ "REGION.FOCUS": {
114
+ target: "stack",
115
+ actions: ["setLastFocusedEl", "pauseToasts"]
116
+ }
117
+ } }
118
+ },
119
+ implementations: {
120
+ guards: {
121
+ isOverlapping: ({ computed }) => computed("overlap"),
122
+ isPointerOut: ({ refs }) => !refs.get("isPointerWithin")
123
+ },
124
+ effects: {
125
+ subscribeToStore({ context, prop }) {
126
+ const store = prop("store");
127
+ context.set("toasts", store.getVisibleToasts());
128
+ return store.subscribe((toast) => {
129
+ if (toast.dismiss) {
130
+ context.set("toasts", (prev) => prev.filter((t) => t.id !== toast.id));
131
+ return;
132
+ }
133
+ context.set("toasts", (prev) => {
134
+ const index = prev.findIndex((t) => t.id === toast.id);
135
+ if (index !== -1) return [
136
+ ...prev.slice(0, index),
137
+ {
138
+ ...prev[index],
139
+ ...toast
140
+ },
141
+ ...prev.slice(index + 1)
142
+ ];
143
+ return [toast, ...prev];
144
+ });
145
+ });
146
+ },
147
+ subscribeToLayout({ prop, send }) {
148
+ return prop("store").subscribeLayout((stacked) => {
149
+ send({ type: stacked ? "REGION.STACK" : "REGION.OVERLAP" });
150
+ });
151
+ },
152
+ trackHotKeyPress({ prop, send }) {
153
+ const handleKeyDown = (event) => {
154
+ const { hotkey } = prop("store").attrs;
155
+ if (!hotkey.every((key) => event[key] || event.code === key)) return;
156
+ send({ type: "DOC.HOTKEY" });
157
+ };
158
+ return addDomEvent(document, "keydown", handleKeyDown, { capture: true });
159
+ },
160
+ trackDocumentVisibility({ prop, send, scope }) {
161
+ const { pauseOnPageIdle } = prop("store").attrs;
162
+ if (!pauseOnPageIdle) return;
163
+ const doc = scope.getDoc();
164
+ if (doc.visibilityState === "hidden") send({ type: "PAUSE_ALL" });
165
+ return addDomEvent(doc, "visibilitychange", () => {
166
+ send({ type: doc.visibilityState === "hidden" ? "PAUSE_ALL" : "RESUME_ALL" });
167
+ });
168
+ }
169
+ },
170
+ actions: {
171
+ setDismissableBranch({ refs, context, computed, scope }) {
172
+ const toasts = context.get("toasts");
173
+ const placement = computed("placement");
174
+ const hasToasts = toasts.length > 0;
175
+ if (!hasToasts) {
176
+ refs.get("dismissableCleanup")?.();
177
+ refs.set("dismissableCleanup", void 0);
178
+ return;
179
+ }
180
+ if (hasToasts && refs.get("dismissableCleanup")) return;
181
+ const groupEl = () => getRegionEl(scope, placement);
182
+ const cleanup = trackDismissableBranch(groupEl, {
183
+ defer: true,
184
+ getRootNode: scope.getRootNode
185
+ });
186
+ refs.set("dismissableCleanup", cleanup);
187
+ },
188
+ clearDismissableBranch({ refs }) {
189
+ refs.get("dismissableCleanup")?.();
190
+ refs.set("dismissableCleanup", void 0);
191
+ },
192
+ focusRegionEl({ scope, computed }) {
193
+ queueMicrotask(() => {
194
+ getRegionEl(scope, computed("placement"))?.focus();
195
+ });
196
+ },
197
+ pauseToasts({ prop }) {
198
+ prop("store").pause();
199
+ },
200
+ resumeToasts({ prop, refs, scope, event }) {
201
+ if (event.type === "REGION.BLUR") refs.set("isFocusWithin", false);
202
+ if (prop("store").attrs.pauseOnPageIdle && scope.getDoc().visibilityState === "hidden" || refs.get("isPointerWithin") || refs.get("isFocusWithin")) return;
203
+ prop("store").resume();
204
+ },
205
+ removeToast({ prop, event }) {
206
+ prop("store").remove(event.id);
207
+ },
208
+ removeHeight({ event, context }) {
209
+ if (event?.id == null) return;
210
+ queueMicrotask(() => {
211
+ context.set("heights", (heights) => heights.filter((height) => height.id !== event.id));
212
+ });
213
+ },
214
+ collapsedIfEmpty({ send, computed }) {
215
+ if (!computed("overlap") || computed("count") > 1) return;
216
+ send({ type: "REGION.OVERLAP" });
217
+ },
218
+ setLastFocusedEl({ refs, event }) {
219
+ if (refs.get("isFocusWithin")) return;
220
+ refs.set("isFocusWithin", true);
221
+ refs.set("lastFocusedEl", event.target ?? null);
222
+ },
223
+ moveFocusOnDismiss({ refs, scope, computed, event }) {
224
+ if (event.focusVisible) {
225
+ const toastEls = getToastEls(scope, computed("placement"));
226
+ const index = toastEls.findIndex((el) => contains(el, scope.getActiveElement()));
227
+ const nextEl = findOpenToast(toastEls, index + 1, 1) ?? findOpenToast(toastEls, index - 1, -1);
228
+ if (nextEl) {
229
+ nextEl.focus({ preventScroll: true });
230
+ return;
231
+ }
232
+ }
233
+ const lastFocusedEl = refs.get("lastFocusedEl");
234
+ if (event.focusVisible && lastFocusedEl) lastFocusedEl.focus({ preventScroll: true });
235
+ else scope.getActiveElement()?.blur();
236
+ },
237
+ resetInteractionIfEmpty({ refs, prop, scope, computed }) {
238
+ if (computed("count") > 0) return;
239
+ refs.set("isFocusWithin", false);
240
+ refs.set("isPointerWithin", false);
241
+ refs.set("lastFocusedEl", null);
242
+ if (!(prop("store").attrs.pauseOnPageIdle && scope.getDoc().visibilityState === "hidden")) prop("store").resume();
243
+ },
244
+ restoreFocusIfPointerOut({ refs }) {
245
+ if (!refs.get("lastFocusedEl") || refs.get("isPointerWithin")) return;
246
+ refs.get("lastFocusedEl")?.focus({ preventScroll: true });
247
+ refs.set("lastFocusedEl", null);
248
+ refs.set("isFocusWithin", false);
249
+ },
250
+ setPointerWithin({ refs }) {
251
+ refs.set("isPointerWithin", true);
252
+ },
253
+ clearPointerWithin({ refs }) {
254
+ refs.set("isPointerWithin", false);
255
+ if (refs.get("lastFocusedEl") && !refs.get("isFocusWithin")) {
256
+ refs.get("lastFocusedEl")?.focus({ preventScroll: true });
257
+ refs.set("lastFocusedEl", null);
258
+ }
259
+ },
260
+ clearFocusWithin({ refs }) {
261
+ refs.set("isFocusWithin", false);
262
+ },
263
+ clearLastFocusedEl({ refs }) {
264
+ if (!refs.get("lastFocusedEl")) return;
265
+ refs.get("lastFocusedEl")?.focus({ preventScroll: true });
266
+ refs.set("lastFocusedEl", null);
267
+ refs.set("isFocusWithin", false);
268
+ },
269
+ ignoreMouseEventsTemporarily({ refs, scope, computed, send }) {
270
+ refs.get("ignoreMouseTimer").request(() => {
271
+ return addDomEvent(scope.getDoc(), "pointermove", (event) => {
272
+ if (!refs.get("isPointerWithin")) return;
273
+ const regionEl = getRegionEl(scope, computed("placement"));
274
+ if (contains(regionEl, getEventTarget(event))) return;
275
+ send({
276
+ type: "REGION.POINTER_LEAVE",
277
+ placement: computed("placement")
278
+ });
279
+ }, { once: true });
280
+ });
281
+ },
282
+ clearMouseEventTimer({ refs }) {
283
+ refs.get("ignoreMouseTimer").cancel();
284
+ }
285
+ }
286
+ }
266
287
  });
267
- export {
268
- groupMachine
269
- };
288
+ function findOpenToast(toastEls, from, step) {
289
+ for (let i = from; i >= 0 && i < toastEls.length; i += step) if (toastEls[i].dataset.state === "open") return toastEls[i];
290
+ return null;
291
+ }
292
+ export { groupMachine };
@@ -1,6 +1,2 @@
1
- import * as _zag_js_anatomy from '@zag-js/anatomy';
2
-
3
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"group" | "title" | "root" | "description" | "actionTrigger" | "closeTrigger">;
4
- declare const parts: Record<"group" | "title" | "root" | "description" | "actionTrigger" | "closeTrigger", _zag_js_anatomy.AnatomyPart>;
5
-
6
- export { anatomy, parts };
1
+ export declare const anatomy: import("@zag-js/anatomy").AnatomyInstance<"actionTrigger" | "closeTrigger" | "description" | "group" | "root" | "title">;
2
+ export declare const parts: Record<"actionTrigger" | "closeTrigger" | "description" | "group" | "root" | "title", import("@zag-js/anatomy").AnatomyPart>;
@@ -1,6 +1,2 @@
1
- import * as _zag_js_anatomy from '@zag-js/anatomy';
2
-
3
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"group" | "title" | "root" | "description" | "actionTrigger" | "closeTrigger">;
4
- declare const parts: Record<"group" | "title" | "root" | "description" | "actionTrigger" | "closeTrigger", _zag_js_anatomy.AnatomyPart>;
5
-
6
- export { anatomy, parts };
1
+ export declare const anatomy: import("@zag-js/anatomy").AnatomyInstance<"actionTrigger" | "closeTrigger" | "description" | "group" | "root" | "title">;
2
+ export declare const parts: Record<"actionTrigger" | "closeTrigger" | "description" | "group" | "root" | "title", import("@zag-js/anatomy").AnatomyPart>;
@@ -1,41 +1,9 @@
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/toast.anatomy.ts
21
- var toast_anatomy_exports = {};
22
- __export(toast_anatomy_exports, {
23
- anatomy: () => anatomy,
24
- parts: () => parts
25
- });
26
- module.exports = __toCommonJS(toast_anatomy_exports);
27
- var import_anatomy = require("@zag-js/anatomy");
28
- var anatomy = (0, import_anatomy.createAnatomy)("toast").parts(
29
- "group",
30
- "root",
31
- "title",
32
- "description",
33
- "actionTrigger",
34
- "closeTrigger"
35
- );
36
- var parts = anatomy.build();
37
- // Annotate the CommonJS export names for ESM import in node:
38
- 0 && (module.exports = {
39
- anatomy,
40
- parts
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
41
4
  });
5
+ // src/toast.anatomy.ts
6
+ const anatomy = (0, require("@zag-js/anatomy").createAnatomy)("toast").parts("group", "root", "title", "description", "actionTrigger", "closeTrigger");
7
+ const parts = anatomy.build();
8
+ exports.anatomy = anatomy;
9
+ exports.parts = parts;