@zag-js/toast 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.
Files changed (45) 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 +82 -103
  8. package/dist/toast-group.connect.mjs +77 -67
  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 +295 -290
  12. package/dist/toast-group.machine.mjs +290 -254
  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 +176 -160
  20. package/dist/toast.connect.mjs +171 -124
  21. package/dist/toast.dom.d.mts +21 -14
  22. package/dist/toast.dom.d.ts +21 -14
  23. package/dist/toast.dom.js +50 -48
  24. package/dist/toast.dom.mjs +35 -17
  25. package/dist/toast.machine.d.mts +2 -8
  26. package/dist/toast.machine.d.ts +2 -8
  27. package/dist/toast.machine.js +404 -288
  28. package/dist/toast.machine.mjs +400 -253
  29. package/dist/toast.store.d.mts +2 -8
  30. package/dist/toast.store.d.ts +2 -8
  31. package/dist/toast.store.js +345 -263
  32. package/dist/toast.store.mjs +341 -238
  33. package/dist/toast.types.d.mts +460 -427
  34. package/dist/toast.types.d.ts +460 -427
  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 +185 -198
  40. package/dist/toast.utils.mjs +175 -168
  41. package/dist/utils/swipe.d.mts +16 -0
  42. package/dist/utils/swipe.d.ts +16 -0
  43. package/dist/utils/swipe.js +100 -0
  44. package/dist/utils/swipe.mjs +93 -0
  45. package/package.json +8 -8
@@ -1,8 +1,2 @@
1
- import { ToastStoreProps, ToastStore } from './toast.types.mjs';
2
- import '@zag-js/types';
3
- import '@zag-js/core';
4
- import '@zag-js/dom-query';
5
-
6
- declare function createToastStore<V = any>(props?: ToastStoreProps): ToastStore<V>;
7
-
8
- export { createToastStore };
1
+ import { ToastStore, ToastStoreProps } from "./toast.types.mjs";
2
+ export declare function createToastStore<V = any>(props?: ToastStoreProps): ToastStore<V>;
@@ -1,8 +1,2 @@
1
- import { ToastStoreProps, ToastStore } from './toast.types.js';
2
- import '@zag-js/types';
3
- import '@zag-js/core';
4
- import '@zag-js/dom-query';
5
-
6
- declare function createToastStore<V = any>(props?: ToastStoreProps): ToastStore<V>;
7
-
8
- export { createToastStore };
1
+ import { ToastStore, ToastStoreProps } from "./toast.types.js";
2
+ export declare function createToastStore<V = any>(props?: ToastStoreProps): ToastStore<V>;
@@ -1,271 +1,353 @@
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.store.ts
21
- var toast_store_exports = {};
22
- __export(toast_store_exports, {
23
- createToastStore: () => createToastStore
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
24
4
  });
25
- module.exports = __toCommonJS(toast_store_exports);
26
- var import_utils = require("@zag-js/utils");
27
- var withDefaults = (options, defaults) => {
28
- return { ...defaults, ...(0, import_utils.compact)(options) };
5
+ let _zag_js_utils = require("@zag-js/utils");
6
+ // src/toast.store.ts
7
+ const withDefaults = (options, defaults) => {
8
+ return {
9
+ ...defaults,
10
+ ...(0, _zag_js_utils.compact)(options)
11
+ };
29
12
  };
30
- var priorities = {
31
- error: [1, 2],
32
- warning: [3, 6],
33
- loading: [4, 5],
34
- success: [5, 7],
35
- info: [6, 8]
13
+ const priorities = {
14
+ error: [1, 2],
15
+ warning: [3, 6],
16
+ loading: [4, 5],
17
+ success: [5, 7],
18
+ info: [6, 8]
36
19
  };
37
- var DEFAULT_TYPE = "info";
38
- var getPriorityForType = (type, hasAction) => {
39
- const [actionable, nonActionable] = priorities[type ?? DEFAULT_TYPE];
40
- return hasAction ? actionable : nonActionable;
20
+ const DEFAULT_TYPE = "info";
21
+ const getPriorityForType = (type, hasAction) => {
22
+ const key = type ?? DEFAULT_TYPE;
23
+ const [actionable, nonActionable] = (0, _zag_js_utils.hasProp)(priorities, key) ? priorities[key] : priorities[DEFAULT_TYPE];
24
+ return hasAction ? actionable : nonActionable;
41
25
  };
42
- var sortToastsByPriority = (toastArray) => {
43
- return toastArray.sort((a, b) => {
44
- const priorityA = a.priority ?? getPriorityForType(a.type, !!a.action);
45
- const priorityB = b.priority ?? getPriorityForType(b.type, !!b.action);
46
- return priorityA - priorityB;
47
- });
26
+ const sortToastsByPriority = (toastArray) => {
27
+ return toastArray.sort((a, b) => {
28
+ return (a.priority ?? getPriorityForType(a.type, !!a.action)) - (b.priority ?? getPriorityForType(b.type, !!b.action));
29
+ });
48
30
  };
49
31
  function createToastStore(props = {}) {
50
- const attrs = withDefaults(props, {
51
- placement: "bottom",
52
- overlap: false,
53
- max: 24,
54
- gap: 16,
55
- offsets: "1rem",
56
- hotkey: ["altKey", "KeyT"],
57
- removeDelay: 200,
58
- pauseOnPageIdle: true
59
- });
60
- let subscribers = [];
61
- let toasts = [];
62
- let dismissedToasts = /* @__PURE__ */ new Set();
63
- let toastQueue = [];
64
- const subscribe = (subscriber) => {
65
- subscribers.push(subscriber);
66
- return () => {
67
- const index = subscribers.indexOf(subscriber);
68
- subscribers.splice(index, 1);
69
- };
70
- };
71
- const publish = (data) => {
72
- subscribers.forEach((subscriber) => subscriber(data));
73
- return data;
74
- };
75
- const addToast = (data) => {
76
- if (toasts.length >= attrs.max) {
77
- toastQueue.push(data);
78
- return;
79
- }
80
- publish(data);
81
- toasts.unshift(data);
82
- };
83
- const processQueue = () => {
84
- toastQueue = sortToastsByPriority(toastQueue);
85
- while (toastQueue.length > 0 && toasts.length < attrs.max) {
86
- const nextToast = toastQueue.shift();
87
- if (nextToast) {
88
- publish(nextToast);
89
- toasts.unshift(nextToast);
90
- }
91
- }
92
- };
93
- const create = (data) => {
94
- const id = data.id ?? `toast:${(0, import_utils.uuid)()}`;
95
- const exists = toasts.find((toast) => toast.id === id);
96
- if (dismissedToasts.has(id)) dismissedToasts.delete(id);
97
- if (exists) {
98
- toasts = toasts.map((toast) => {
99
- if (toast.id === id) {
100
- return publish({ ...toast, ...data, id });
101
- }
102
- return toast;
103
- });
104
- } else {
105
- const newToast = {
106
- id,
107
- duration: attrs.duration,
108
- removeDelay: attrs.removeDelay,
109
- type: DEFAULT_TYPE,
110
- ...data,
111
- stacked: !attrs.overlap,
112
- gap: attrs.gap
113
- };
114
- const priority = newToast.priority ?? getPriorityForType(newToast.type, !!newToast.action);
115
- addToast({ ...newToast, priority });
116
- }
117
- return id;
118
- };
119
- const remove = (id) => {
120
- dismissedToasts.add(id);
121
- if (!id) {
122
- toasts.forEach((toast) => {
123
- subscribers.forEach((subscriber) => subscriber({ id: toast.id, dismiss: true }));
124
- });
125
- toasts = [];
126
- toastQueue = [];
127
- } else {
128
- subscribers.forEach((subscriber) => subscriber({ id, dismiss: true }));
129
- toasts = toasts.filter((toast) => toast.id !== id);
130
- processQueue();
131
- }
132
- return id;
133
- };
134
- const error = (data) => {
135
- return create({ ...data, type: "error" });
136
- };
137
- const success = (data) => {
138
- return create({ ...data, type: "success" });
139
- };
140
- const info = (data) => {
141
- return create({ ...data, type: "info" });
142
- };
143
- const warning = (data) => {
144
- return create({ ...data, type: "warning" });
145
- };
146
- const loading = (data) => {
147
- return create({ ...data, type: "loading" });
148
- };
149
- const getVisibleToasts = () => {
150
- return toasts.filter((toast) => !dismissedToasts.has(toast.id));
151
- };
152
- const getCount = () => {
153
- return toasts.length;
154
- };
155
- const promise = (promise2, options, shared = {}) => {
156
- if (!options || !options.loading) {
157
- (0, import_utils.warn)("[zag-js > toast] toaster.promise() requires at least a 'loading' option to be specified");
158
- return;
159
- }
160
- const id = create({
161
- ...shared,
162
- ...options.loading,
163
- promise: promise2,
164
- type: "loading"
165
- });
166
- let removable = true;
167
- let result;
168
- const prom = (0, import_utils.runIfFn)(promise2).then(async (response) => {
169
- result = ["resolve", response];
170
- if (isHttpResponse(response) && !response.ok) {
171
- removable = false;
172
- const errorOptions = (0, import_utils.runIfFn)(options.error, `HTTP Error! status: ${response.status}`);
173
- create({ ...shared, ...errorOptions, id, type: "error" });
174
- } else if (options.success !== void 0) {
175
- removable = false;
176
- const successOptions = (0, import_utils.runIfFn)(options.success, response);
177
- create({ ...shared, ...successOptions, id, type: successOptions.type ?? "success" });
178
- }
179
- }).catch(async (error2) => {
180
- result = ["reject", error2];
181
- if (options.error !== void 0) {
182
- removable = false;
183
- const errorOptions = (0, import_utils.runIfFn)(options.error, error2);
184
- create({ ...shared, ...errorOptions, id, type: "error" });
185
- }
186
- }).finally(() => {
187
- if (removable) {
188
- remove(id);
189
- }
190
- options.finally?.();
191
- });
192
- const unwrap = () => new Promise(
193
- (resolve, reject) => prom.then(() => result[0] === "reject" ? reject(result[1]) : resolve(result[1])).catch(reject)
194
- );
195
- return { id, unwrap };
196
- };
197
- const update = (id, data) => {
198
- return create({ id, ...data });
199
- };
200
- const pause = (id) => {
201
- if (id != null) {
202
- toasts = toasts.map((toast) => {
203
- if (toast.id === id) return publish({ ...toast, message: "PAUSE" });
204
- return toast;
205
- });
206
- } else {
207
- toasts = toasts.map((toast) => publish({ ...toast, message: "PAUSE" }));
208
- }
209
- };
210
- const resume = (id) => {
211
- if (id != null) {
212
- toasts = toasts.map((toast) => {
213
- if (toast.id === id) return publish({ ...toast, message: "RESUME" });
214
- return toast;
215
- });
216
- } else {
217
- toasts = toasts.map((toast) => publish({ ...toast, message: "RESUME" }));
218
- }
219
- };
220
- const dismiss = (id) => {
221
- if (id != null) {
222
- toasts = toasts.map((toast) => {
223
- if (toast.id === id) return publish({ ...toast, message: "DISMISS" });
224
- return toast;
225
- });
226
- } else {
227
- toasts = toasts.map((toast) => publish({ ...toast, message: "DISMISS" }));
228
- }
229
- };
230
- const isVisible = (id) => {
231
- return !dismissedToasts.has(id) && !!toasts.find((toast) => toast.id === id);
232
- };
233
- const isDismissed = (id) => {
234
- return dismissedToasts.has(id);
235
- };
236
- const expand = () => {
237
- toasts = toasts.map((toast) => publish({ ...toast, stacked: true }));
238
- };
239
- const collapse = () => {
240
- toasts = toasts.map((toast) => publish({ ...toast, stacked: false }));
241
- };
242
- return {
243
- attrs,
244
- subscribe,
245
- create,
246
- update,
247
- remove,
248
- dismiss,
249
- error,
250
- success,
251
- info,
252
- warning,
253
- loading,
254
- getVisibleToasts,
255
- getCount,
256
- promise,
257
- pause,
258
- resume,
259
- isVisible,
260
- isDismissed,
261
- expand,
262
- collapse
263
- };
32
+ const attrs = withDefaults(props, {
33
+ placement: "bottom",
34
+ overlap: false,
35
+ max: 24,
36
+ gap: 16,
37
+ offsets: "1rem",
38
+ hotkey: ["altKey", "KeyT"],
39
+ removeDelay: 200,
40
+ pauseOnPageIdle: true
41
+ });
42
+ let subscribers = [];
43
+ let toasts = [];
44
+ let dismissedToasts = /* @__PURE__ */ new Set();
45
+ let toastQueue = [];
46
+ const closingToasts = /* @__PURE__ */ new Set();
47
+ const promiseTokens = /* @__PURE__ */ new Map();
48
+ let paused = false;
49
+ const layoutSubscribers = /* @__PURE__ */ new Set();
50
+ const subscribe = (subscriber) => {
51
+ subscribers.push(subscriber);
52
+ let active = true;
53
+ return () => {
54
+ if (!active) return;
55
+ active = false;
56
+ const index = subscribers.indexOf(subscriber);
57
+ if (index !== -1) subscribers.splice(index, 1);
58
+ };
59
+ };
60
+ const notifications = [];
61
+ let publishing = false;
62
+ const publish = (...data) => {
63
+ notifications.push(...data);
64
+ if (publishing) return data;
65
+ publishing = true;
66
+ try {
67
+ while (notifications.length) {
68
+ const next = notifications.shift();
69
+ subscribers.slice().forEach((subscriber) => subscriber(next));
70
+ }
71
+ } finally {
72
+ publishing = false;
73
+ notifications.length = 0;
74
+ }
75
+ return data;
76
+ };
77
+ const addToast = (data) => {
78
+ if (toasts.length >= attrs.max) {
79
+ toastQueue.push(data);
80
+ return;
81
+ }
82
+ toasts.unshift(data);
83
+ publish(data);
84
+ };
85
+ const processQueue = () => {
86
+ toastQueue = sortToastsByPriority(toastQueue);
87
+ while (toastQueue.length > 0 && toasts.length < attrs.max) {
88
+ const nextToast = toastQueue.shift();
89
+ if (nextToast) {
90
+ const toast = {
91
+ ...nextToast,
92
+ paused: paused || nextToast.paused
93
+ };
94
+ toasts.unshift(toast);
95
+ publish(toast);
96
+ }
97
+ }
98
+ };
99
+ const create = (data) => {
100
+ const id = data.id ?? `toast:${(0, _zag_js_utils.uuid)()}`;
101
+ const exists = toasts.find((toast) => toast.id === id) ?? toastQueue.find((toast) => toast.id === id);
102
+ if (closingToasts.has(id)) return id;
103
+ if ((0, _zag_js_utils.hasProp)(data, "promise") && data.promise !== exists?.promise) promiseTokens.delete(id);
104
+ dismissedToasts.delete(id);
105
+ if (exists) {
106
+ const next = {
107
+ ...exists,
108
+ ...data,
109
+ id
110
+ };
111
+ if (toasts.some((toast) => toast.id === id)) {
112
+ toasts = toasts.map((toast) => toast.id === id ? next : toast);
113
+ publish(next);
114
+ } else toastQueue = toastQueue.map((toast) => toast.id === id ? next : toast);
115
+ } else {
116
+ const newToast = {
117
+ id,
118
+ duration: attrs.duration,
119
+ removeDelay: attrs.removeDelay,
120
+ swipeDirections: attrs.swipeDirections,
121
+ type: DEFAULT_TYPE,
122
+ ...data,
123
+ gap: attrs.gap,
124
+ paused
125
+ };
126
+ const priority = newToast.priority ?? getPriorityForType(newToast.type, !!newToast.action);
127
+ addToast({
128
+ ...newToast,
129
+ priority
130
+ });
131
+ }
132
+ return id;
133
+ };
134
+ const remove = (id) => {
135
+ const removed = id == null ? [...toasts, ...toastQueue] : [...toasts, ...toastQueue].filter((toast) => toast.id === id);
136
+ const visible = id == null ? toasts : toasts.filter((toast) => toast.id === id);
137
+ removed.forEach((toast) => {
138
+ dismissedToasts.add(toast.id);
139
+ closingToasts.delete(toast.id);
140
+ promiseTokens.delete(toast.id);
141
+ });
142
+ if (id != null) dismissedToasts.add(id);
143
+ toasts = id == null ? [] : toasts.filter((toast) => toast.id !== id);
144
+ toastQueue = id == null ? [] : toastQueue.filter((toast) => toast.id !== id);
145
+ if (id != null && !visible.length) publish({
146
+ id,
147
+ dismiss: true
148
+ });
149
+ publish(...visible.map((toast) => ({
150
+ id: toast.id,
151
+ dismiss: true
152
+ })));
153
+ processQueue();
154
+ return id;
155
+ };
156
+ const error = (data) => {
157
+ return create({
158
+ ...data,
159
+ type: "error"
160
+ });
161
+ };
162
+ const success = (data) => {
163
+ return create({
164
+ ...data,
165
+ type: "success"
166
+ });
167
+ };
168
+ const info = (data) => {
169
+ return create({
170
+ ...data,
171
+ type: "info"
172
+ });
173
+ };
174
+ const warning = (data) => {
175
+ return create({
176
+ ...data,
177
+ type: "warning"
178
+ });
179
+ };
180
+ const loading = (data) => {
181
+ return create({
182
+ ...data,
183
+ type: "loading"
184
+ });
185
+ };
186
+ const getVisibleToasts = () => {
187
+ return toasts.filter((toast) => !dismissedToasts.has(toast.id));
188
+ };
189
+ const getCount = () => {
190
+ return toasts.length;
191
+ };
192
+ const promise = (promise, options, shared = {}) => {
193
+ if (!options || !options.loading) {
194
+ (0, _zag_js_utils.warn)("[zag-js > toast] toaster.promise() requires at least a 'loading' option to be specified");
195
+ return;
196
+ }
197
+ const id = create({
198
+ ...shared,
199
+ ...options.loading,
200
+ promise,
201
+ type: "loading"
202
+ });
203
+ const token = Symbol();
204
+ if ((toasts.find((toast) => toast.id === id) ?? toastQueue.find((toast) => toast.id === id))?.promise === promise && !closingToasts.has(id)) promiseTokens.set(id, token);
205
+ const isCurrent = () => promiseTokens.get(id) === token && !closingToasts.has(id);
206
+ let removable = true;
207
+ let result;
208
+ const prom = (0, _zag_js_utils.runIfFn)(promise).then(async (response) => {
209
+ result = ["resolve", response];
210
+ if (isHttpResponse(response) && !response.ok) {
211
+ removable = false;
212
+ const errorOptions = (0, _zag_js_utils.runIfFn)(options.error, `HTTP Error! status: ${response.status}`);
213
+ if (isCurrent()) create({
214
+ ...shared,
215
+ ...errorOptions,
216
+ id,
217
+ type: "error"
218
+ });
219
+ } else if (options.success !== void 0) {
220
+ removable = false;
221
+ const successOptions = (0, _zag_js_utils.runIfFn)(options.success, response);
222
+ if (isCurrent()) create({
223
+ ...shared,
224
+ ...successOptions,
225
+ id,
226
+ type: successOptions.type ?? "success"
227
+ });
228
+ }
229
+ }).catch(async (error) => {
230
+ result = ["reject", error];
231
+ if (options.error !== void 0) {
232
+ removable = false;
233
+ const errorOptions = (0, _zag_js_utils.runIfFn)(options.error, error);
234
+ if (isCurrent()) create({
235
+ ...shared,
236
+ ...errorOptions,
237
+ id,
238
+ type: "error"
239
+ });
240
+ }
241
+ }).finally(() => {
242
+ if (removable && isCurrent()) remove(id);
243
+ if (promiseTokens.get(id) === token) promiseTokens.delete(id);
244
+ options.finally?.();
245
+ });
246
+ const unwrap = () => new Promise((resolve, reject) => prom.then(() => result[0] === "reject" ? reject(result[1]) : resolve(result[1])).catch(reject));
247
+ return {
248
+ id,
249
+ unwrap
250
+ };
251
+ };
252
+ const update = (id, data) => {
253
+ if (closingToasts.has(id)) return id;
254
+ if (typeof data !== "function") return create({
255
+ ...data,
256
+ id
257
+ });
258
+ const current = toasts.find((toast) => toast.id === id) ?? toastQueue.find((toast) => toast.id === id);
259
+ if (!current) return id;
260
+ const next = {
261
+ ...data({ ...current }),
262
+ id
263
+ };
264
+ if (closingToasts.has(id)) return id;
265
+ if (toasts.some((toast) => toast.id === id)) return create(next);
266
+ if (!toastQueue.some((toast) => toast.id === id)) return id;
267
+ return create(next);
268
+ };
269
+ const changeToasts = (data, id) => {
270
+ const changed = [];
271
+ toasts = toasts.map((toast) => {
272
+ if (id != null && toast.id !== id || closingToasts.has(toast.id)) return toast;
273
+ const next = {
274
+ ...toast,
275
+ ...data
276
+ };
277
+ changed.push(next);
278
+ return next;
279
+ });
280
+ toastQueue = toastQueue.map((toast) => id == null || toast.id === id ? {
281
+ ...toast,
282
+ ...data
283
+ } : toast);
284
+ publish(...changed);
285
+ };
286
+ const pause = (id) => {
287
+ if (id == null) paused = true;
288
+ changeToasts({ paused: true }, id);
289
+ };
290
+ const resume = (id) => {
291
+ if (id == null) paused = false;
292
+ changeToasts({ paused: false }, id);
293
+ };
294
+ const dismiss = (id) => {
295
+ const queued = toastQueue.filter((toast) => id == null || toast.id === id);
296
+ toastQueue = toastQueue.filter((toast) => id != null && toast.id !== id);
297
+ queued.forEach((toast) => {
298
+ dismissedToasts.add(toast.id);
299
+ promiseTokens.delete(toast.id);
300
+ });
301
+ const changed = toasts.filter((toast) => (id == null || toast.id === id) && !closingToasts.has(toast.id));
302
+ changed.forEach((toast) => closingToasts.add(toast.id));
303
+ toasts = toasts.map((toast) => closingToasts.has(toast.id) ? {
304
+ ...toast,
305
+ message: "DISMISS"
306
+ } : toast);
307
+ publish(...changed.map((toast) => ({
308
+ ...toast,
309
+ message: "DISMISS"
310
+ })));
311
+ };
312
+ const isVisible = (id) => {
313
+ return !dismissedToasts.has(id) && !!toasts.find((toast) => toast.id === id);
314
+ };
315
+ const isDismissed = (id) => {
316
+ return dismissedToasts.has(id);
317
+ };
318
+ const subscribeLayout = (subscriber) => {
319
+ layoutSubscribers.add(subscriber);
320
+ return () => {
321
+ layoutSubscribers.delete(subscriber);
322
+ };
323
+ };
324
+ const expand = () => layoutSubscribers.forEach((subscriber) => subscriber(true));
325
+ const collapse = () => layoutSubscribers.forEach((subscriber) => subscriber(false));
326
+ return {
327
+ attrs,
328
+ subscribe,
329
+ create,
330
+ update,
331
+ remove,
332
+ dismiss,
333
+ error,
334
+ success,
335
+ info,
336
+ warning,
337
+ loading,
338
+ getVisibleToasts,
339
+ getCount,
340
+ promise,
341
+ pause,
342
+ resume,
343
+ isVisible,
344
+ isDismissed,
345
+ expand,
346
+ collapse,
347
+ subscribeLayout
348
+ };
264
349
  }
265
- var isHttpResponse = (data) => {
266
- return data && typeof data === "object" && "ok" in data && typeof data.ok === "boolean" && "status" in data && typeof data.status === "number";
350
+ const isHttpResponse = (data) => {
351
+ return data && typeof data === "object" && "ok" in data && typeof data.ok === "boolean" && "status" in data && typeof data.status === "number";
267
352
  };
268
- // Annotate the CommonJS export names for ESM import in node:
269
- 0 && (module.exports = {
270
- createToastStore
271
- });
353
+ exports.createToastStore = createToastStore;