@zag-js/toast 2.0.0-next.3 → 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,447 +1,480 @@
1
- import { PropTypes, CommonProperties, Direction, DirectionProperty, Required, RequiredBy } from '@zag-js/types';
2
- import { Service, EventObject, Machine } from '@zag-js/core';
3
- import { AnimationFrame } from '@zag-js/dom-query';
4
-
5
- type Type = "success" | "error" | "loading" | "info" | "warning" | (string & {});
6
- type ToastQueuePriority = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
7
- type Placement = "top-start" | "top" | "top-end" | "bottom-start" | "bottom" | "bottom-end";
8
- type Status = "visible" | "dismissing" | "unmounted";
9
- interface StatusChangeDetails {
10
- /**
11
- * The status of the toast
12
- */
13
- status: Status;
14
- /**
15
- * The reason for the status change
16
- */
17
- src?: string | undefined;
1
+ import { AnimationFrame } from "@zag-js/dom-query";
2
+ import { EventObject, Machine, Service } from "@zag-js/core";
3
+ import { CommonProperties, Direction, DirectionProperty, Point, PropTypes, Required, RequiredBy } from "@zag-js/types";
4
+ export type Type = "success" | "error" | "loading" | "info" | "warning" | (string & {});
5
+ export type ToastQueuePriority = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
6
+ export type Placement = "top-start" | "top" | "top-end" | "bottom-start" | "bottom" | "bottom-end";
7
+ export type Status = "visible" | "dismissing" | "unmounted";
8
+ export type SwipeDirection = "up" | "down" | "left" | "right";
9
+ export interface StatusChangeDetails {
10
+ /**
11
+ * The status of the toast
12
+ */
13
+ status: Status;
14
+ /**
15
+ * The reason for the status change
16
+ */
17
+ src?: string | undefined;
18
18
  }
19
- interface ToastHeight {
20
- /**
21
- * The id of the toast
22
- */
23
- id: string;
24
- /**
25
- * The height of the toast
26
- */
27
- height: number;
19
+ export interface ToastHeight {
20
+ /**
21
+ * The id of the toast
22
+ */
23
+ id: string;
24
+ /**
25
+ * The height of the toast
26
+ */
27
+ height: number;
28
28
  }
29
- interface RootState {
30
- /**
31
- * Whether the toast is visible
32
- */
33
- visible: boolean;
34
- /**
35
- * Whether the toast is paused
36
- */
37
- paused: boolean;
38
- /**
39
- * Whether the toast has mounted into the DOM
40
- */
41
- mounted: boolean;
42
- /**
43
- * Whether the toast is the frontmost (topmost) toast in the group
44
- */
45
- frontmost: boolean;
46
- /**
47
- * Whether the toasts in the group are stacked instead of overlapping
48
- */
49
- stacked: boolean;
50
- /**
51
- * The type of the toast
52
- */
53
- type: Type;
54
- /**
55
- * The placement of the toast
56
- */
57
- placement: Placement;
58
- /**
59
- * The side of the toast placement
60
- */
61
- side: string;
62
- /**
63
- * The horizontal alignment of the toast placement
64
- */
65
- align: string;
29
+ export interface RootState {
30
+ /**
31
+ * Whether the toast is visible
32
+ */
33
+ visible: boolean;
34
+ /**
35
+ * Whether the toast is paused
36
+ */
37
+ paused: boolean;
38
+ /**
39
+ * Whether the toast has mounted into the DOM
40
+ */
41
+ mounted: boolean;
42
+ /**
43
+ * Whether the toast is the frontmost (topmost) toast in the group
44
+ */
45
+ frontmost: boolean;
46
+ /**
47
+ * Whether the toasts in the group are stacked instead of overlapping
48
+ */
49
+ stacked: boolean;
50
+ /**
51
+ * The type of the toast
52
+ */
53
+ type: Type;
54
+ /**
55
+ * The placement of the toast
56
+ */
57
+ placement: Placement;
58
+ /**
59
+ * The side of the toast placement
60
+ */
61
+ side: string;
62
+ /**
63
+ * The horizontal alignment of the toast placement
64
+ */
65
+ align: string;
66
+ /**
67
+ * Whether the toast is being swiped
68
+ */
69
+ swiping: boolean;
70
+ /**
71
+ * The direction the toast is being swiped or was swiped away in
72
+ */
73
+ swipeDirection: SwipeDirection | null;
66
74
  }
67
- interface ActionOptions {
68
- /**
69
- * The label of the action
70
- */
71
- label: string;
72
- /**
73
- * The function to call when the action is clicked
74
- */
75
- onClick: VoidFunction;
75
+ export interface ActionOptions {
76
+ /**
77
+ * The label of the action
78
+ */
79
+ label: string;
80
+ /**
81
+ * The function to call when the action is clicked
82
+ */
83
+ onClick: VoidFunction;
76
84
  }
77
- interface IntlTranslations {
78
- closeTriggerLabel?: string | undefined;
85
+ export interface IntlTranslations {
86
+ closeTriggerLabel?: string | undefined;
79
87
  }
80
- interface Options<T = any> {
81
- /**
82
- * The title of the toast.
83
- */
84
- title?: T | undefined;
85
- /**
86
- * The description of the toast.
87
- */
88
- description?: T | undefined;
89
- /**
90
- * The duration the toast will be visible
91
- */
92
- duration?: number | undefined;
93
- /**
94
- * The duration for the toast to kept alive before it is removed.
95
- * Useful for exit transitions.
96
- */
97
- removeDelay?: number | undefined;
98
- /**
99
- * The unique id of the toast
100
- */
101
- id?: string | undefined;
102
- /**
103
- * The type of the toast
104
- */
105
- type?: Type | undefined;
106
- /**
107
- * The priority of the toast (1 = highest, 8 = lowest)
108
- */
109
- priority?: ToastQueuePriority | undefined;
110
- /**
111
- * Function called when the toast is visible
112
- */
113
- onStatusChange?: ((details: StatusChangeDetails) => void) | undefined;
114
- /**
115
- * The action of the toast
116
- */
117
- action?: ActionOptions | undefined;
118
- /**
119
- * Whether the toast is closable
120
- */
121
- closable?: boolean | undefined;
122
- /**
123
- * The metadata of the toast
124
- */
125
- meta?: Record<string, any> | undefined;
88
+ export interface Options<T = any> {
89
+ /**
90
+ * The title of the toast.
91
+ */
92
+ title?: T | undefined;
93
+ /**
94
+ * The description of the toast.
95
+ */
96
+ description?: T | undefined;
97
+ /**
98
+ * The duration the toast will be visible
99
+ */
100
+ duration?: number | undefined;
101
+ /**
102
+ * The duration for the toast to kept alive before it is removed.
103
+ * Useful for exit transitions.
104
+ */
105
+ removeDelay?: number | undefined;
106
+ /**
107
+ * The unique id of the toast
108
+ */
109
+ id?: string | undefined;
110
+ /**
111
+ * The type of the toast
112
+ */
113
+ type?: Type | undefined;
114
+ /**
115
+ * The priority of the toast (1 = highest, 8 = lowest)
116
+ */
117
+ priority?: ToastQueuePriority | undefined;
118
+ /**
119
+ * Function called when the toast is visible
120
+ */
121
+ onStatusChange?: ((details: StatusChangeDetails) => void) | undefined;
122
+ /**
123
+ * The action of the toast
124
+ */
125
+ action?: ActionOptions | undefined;
126
+ /**
127
+ * Whether the toast is closable
128
+ */
129
+ closable?: boolean | undefined;
130
+ /**
131
+ * The directions the toast can be swiped to dismiss. Pass `[]` to disable swiping.
132
+ * Defaults to the edges nearest the toast's placement, e.g. `["down", "right"]` for `bottom-end`.
133
+ */
134
+ swipeDirections?: SwipeDirection[] | undefined;
135
+ /**
136
+ * The metadata of the toast
137
+ */
138
+ meta?: Record<string, any> | undefined;
126
139
  }
127
- interface ToastProps<T = any> extends Omit<CommonProperties, "id">, Options<T> {
128
- /**
129
- * Specifies the localized strings that identifies the accessibility elements and their states
130
- */
131
- translations?: IntlTranslations | undefined;
132
- /**
133
- * The direction of the toast
134
- */
135
- dir?: Direction | undefined;
136
- /**
137
- * The index of the toast in the group
138
- */
139
- index?: number | undefined;
140
- /**
141
- * The gap of the toast
142
- */
143
- gap?: number | undefined;
144
- /**
145
- * The parent toast group service. Required when using toast as a child of a group.
146
- */
147
- parent: Service<ToastGroupSchema>;
140
+ export interface ToastProps<T = any> extends Omit<CommonProperties, "id">, Options<T> {
141
+ /**
142
+ * Specifies the localized strings that identifies the accessibility elements and their states
143
+ */
144
+ translations?: IntlTranslations | undefined;
145
+ /**
146
+ * The direction of the toast
147
+ */
148
+ dir?: Direction | undefined;
149
+ /**
150
+ * The index of the toast in the group
151
+ */
152
+ index?: number | undefined;
153
+ /**
154
+ * The gap of the toast
155
+ */
156
+ gap?: number | undefined;
157
+ /**
158
+ * The parent toast group service. Required when using toast as a child of a group.
159
+ */
160
+ parent: Service<ToastGroupSchema>;
148
161
  }
149
162
  type ToastPropsWithDefault = "type" | "parent" | "duration" | "id" | "removeDelay";
150
- type ToastSchema<O = any> = {
151
- props: ToastProps<O>;
152
- defaultPropKey: Extract<ToastPropsWithDefault, keyof ToastProps<O>>;
153
- context: {
154
- mounted: boolean;
155
- initialHeight: number;
156
- remainingTime: number;
157
- };
158
- computed: {
159
- height: number;
160
- heightIndex: number;
161
- heightBefore: number;
162
- frontmost: boolean;
163
- zIndex: number;
164
- shouldPersist: boolean;
165
- };
166
- refs: {
167
- closeTimerStartTime: number;
168
- lastCloseStartTimerStartTime: number;
163
+ export type ToastSchema<O = any> = {
164
+ props: ToastProps<O>;
165
+ defaultPropKey: Extract<ToastPropsWithDefault, keyof ToastProps<O>>;
166
+ context: {
167
+ mounted: boolean;
168
+ initialHeight: number;
169
+ remainingTime: number;
170
+ rendered: {
171
+ title: boolean;
172
+ description: boolean;
169
173
  };
170
- state: "visible" | "visible:updating" | "dismissing" | "unmounted" | "visible:persist";
171
- tag: "visible" | "paused" | "updating";
172
- guard: string;
173
- action: string;
174
- effect: string;
175
- event: EventObject;
174
+ swipeOffset: Point;
175
+ swipeDirection: SwipeDirection | null;
176
+ };
177
+ computed: {
178
+ height: number;
179
+ heightIndex: number;
180
+ heightBefore: number;
181
+ frontmost: boolean;
182
+ zIndex: number;
183
+ shouldPersist: boolean;
184
+ swipeDirections: SwipeDirection[];
185
+ };
186
+ refs: {
187
+ closeTimerStartTime: number;
188
+ lastCloseStartTimerStartTime: number;
189
+ swipeStart: {
190
+ point: Point;
191
+ pointerId: number;
192
+ } | null;
193
+ mountFrame: AnimationFrame;
194
+ };
195
+ state: "visible" | "visible:updating" | "visible:swiping" | "dismissing" | "unmounted" | "visible:persist";
196
+ tag: "visible" | "paused" | "updating";
197
+ guard: string;
198
+ action: string;
199
+ effect: string;
200
+ event: EventObject;
176
201
  };
177
- type ToastService = Service<ToastSchema>;
178
- type ToastMachine = Machine<ToastSchema>;
179
- interface ToastStoreProps {
180
- /**
181
- * The placement of the toast
182
- * @default "bottom"
183
- */
184
- placement?: Placement | undefined;
185
- /**
186
- * The maximum number of toasts. When the number of toasts exceeds this limit, the new toasts are queued.
187
- * @default 24
188
- */
189
- max?: number | undefined;
190
- /**
191
- * Whether to overlap the toasts
192
- */
193
- overlap?: boolean | undefined;
194
- /**
195
- * The duration of the toast.
196
- * By default, it is determined by the type of the toast.
197
- */
198
- duration?: number | undefined;
199
- /**
200
- * The gap between the toasts
201
- * @default 16
202
- */
203
- gap?: number | undefined;
204
- /**
205
- * The offset from the safe environment edge of the viewport
206
- * @default "1rem"
207
- */
208
- offsets?: string | Record<"left" | "right" | "bottom" | "top", string> | undefined;
209
- /**
210
- * The hotkey that will move focus to the toast group
211
- * @default '["altKey", "KeyT"]'
212
- */
213
- hotkey?: string[] | undefined;
214
- /**
215
- * The duration for the toast to kept alive before it is removed.
216
- * Useful for exit transitions.
217
- *
218
- * @default 200
219
- */
220
- removeDelay?: number | undefined;
221
- /**
222
- * Whether to pause toast when the user leaves the browser tab
223
- * @default false
224
- */
225
- pauseOnPageIdle?: boolean | undefined;
202
+ export type ToastService = Service<ToastSchema>;
203
+ export type ToastMachine = Machine<ToastSchema>;
204
+ export interface ToastStoreProps {
205
+ /**
206
+ * The placement of the toast
207
+ * @default "bottom"
208
+ */
209
+ placement?: Placement | undefined;
210
+ /**
211
+ * The maximum number of toasts. When the number of toasts exceeds this limit, the new toasts are queued.
212
+ * @default 24
213
+ */
214
+ max?: number | undefined;
215
+ /**
216
+ * Whether to overlap the toasts
217
+ */
218
+ overlap?: boolean | undefined;
219
+ /**
220
+ * The duration of the toast.
221
+ * By default, it is determined by the type of the toast.
222
+ */
223
+ duration?: number | undefined;
224
+ /**
225
+ * The gap between the toasts
226
+ * @default 16
227
+ */
228
+ gap?: number | undefined;
229
+ /**
230
+ * The offset from the safe environment edge of the viewport
231
+ * @default "1rem"
232
+ */
233
+ offsets?: string | Record<"left" | "right" | "bottom" | "top", string> | undefined;
234
+ /**
235
+ * The hotkey that will move focus to the toast group
236
+ * @default '["altKey", "KeyT"]'
237
+ */
238
+ hotkey?: string[] | undefined;
239
+ /**
240
+ * The duration for the toast to kept alive before it is removed.
241
+ * Useful for exit transitions.
242
+ *
243
+ * @default 200
244
+ */
245
+ removeDelay?: number | undefined;
246
+ /**
247
+ * Whether to pause toast when the user leaves the browser tab
248
+ * @default true
249
+ */
250
+ pauseOnPageIdle?: boolean | undefined;
251
+ /**
252
+ * The directions toasts can be swiped to dismiss. Pass `[]` to disable swiping.
253
+ * Defaults to the edges nearest the placement, e.g. `["down", "right"]` for `bottom-end`.
254
+ */
255
+ swipeDirections?: SwipeDirection[] | undefined;
226
256
  }
227
- interface ToastGroupProps extends DirectionProperty, CommonProperties {
228
- /**
229
- * The store of the toast
230
- */
231
- store: ToastStore;
257
+ export interface ToastGroupProps extends DirectionProperty, CommonProperties {
258
+ /**
259
+ * The store of the toast
260
+ */
261
+ store: ToastStore;
232
262
  }
233
- type ToastGroupSchema = {
234
- state: "stack" | "overlap";
235
- props: ToastGroupProps;
236
- defaultPropKey: never;
237
- context: {
238
- toasts: RequiredBy<ToastProps, Extract<ToastPropsWithDefault, keyof ToastProps>>[];
239
- heights: ToastHeight[];
240
- };
241
- computed: {
242
- count: number;
243
- overlap: boolean;
244
- placement: Placement;
245
- };
246
- refs: {
247
- dismissableCleanup?: VoidFunction | undefined;
248
- lastFocusedEl: HTMLElement | null;
249
- isFocusWithin: boolean;
250
- isPointerWithin: boolean;
251
- ignoreMouseTimer: AnimationFrame;
252
- };
253
- guard: string;
254
- effect: string;
255
- action: string;
256
- event: EventObject;
263
+ export type ToastGroupSchema = {
264
+ state: "stack" | "overlap";
265
+ props: ToastGroupProps;
266
+ defaultPropKey: never;
267
+ context: {
268
+ toasts: RequiredBy<ToastProps, Extract<ToastPropsWithDefault, keyof ToastProps>>[];
269
+ heights: ToastHeight[];
270
+ };
271
+ computed: {
272
+ count: number;
273
+ overlap: boolean;
274
+ placement: Placement;
275
+ };
276
+ refs: {
277
+ dismissableCleanup?: VoidFunction | undefined;
278
+ lastFocusedEl: HTMLElement | null;
279
+ isFocusWithin: boolean;
280
+ isPointerWithin: boolean;
281
+ ignoreMouseTimer: AnimationFrame;
282
+ };
283
+ guard: string;
284
+ effect: string;
285
+ action: string;
286
+ event: EventObject;
257
287
  };
258
- type ToastGroupService = Service<ToastGroupSchema>;
259
- type ToastGroupMachine = Machine<ToastGroupSchema>;
260
- interface ToastStore<V = any> {
261
- /**
262
- * The attributes of the toast store
263
- */
264
- attrs: Required<ToastStoreProps>;
265
- /**
266
- * Subscribe to the toast store
267
- */
268
- subscribe: (subscriber: (...args: any[]) => void) => VoidFunction;
269
- /**
270
- * Create a new toast with the given options
271
- */
272
- create: (data: Options<V>) => string;
273
- /**
274
- * Update an existing toast with new properties
275
- */
276
- update: (id: string, data: Partial<ToastProps<V>>) => string;
277
- /**
278
- * Remove a toast by its ID
279
- */
280
- remove: (id?: string) => void;
281
- /**
282
- * Dismiss a toast by its ID. If no ID is provided, dismisses all toasts
283
- */
284
- dismiss: (id?: string) => void;
285
- /**
286
- * Create an error toast with the given options
287
- */
288
- error: (data: Options<V>) => void;
289
- /**
290
- * Create a success toast with the given options
291
- */
292
- success: (data: Options<V>) => void;
293
- /**
294
- * Create an info toast with the given options
295
- */
296
- info: (data: Options<V>) => void;
297
- /**
298
- * Create a warning toast with the given options
299
- */
300
- warning: (data: Options<V>) => void;
301
- /**
302
- * Create a loading toast with the given options
303
- */
304
- loading: (data: Options<V>) => void;
305
- /**
306
- * Get all currently visible toasts
307
- */
308
- getVisibleToasts: () => Partial<ToastProps<V>>[];
309
- /**
310
- * Get the total number of toasts
311
- */
312
- getCount: () => number;
313
- /**
314
- * Create a toast that tracks a promise's state
315
- */
316
- promise: <T>(promise: Promise<T> | (() => Promise<T>), options: PromiseOptions<T, V>, shared?: Omit<Options<V>, "type">) => {
317
- id: string | undefined;
318
- unwrap: () => Promise<T>;
319
- } | undefined;
320
- /**
321
- * Pause a toast's auto-dismiss timer. If no ID is provided, pauses all toasts
322
- */
323
- pause: (id?: string) => void;
324
- /**
325
- * Resume a toast's auto-dismiss timer. If no ID is provided, resumes all toasts
326
- */
327
- resume: (id?: string) => void;
328
- /**
329
- * Check if a toast with the given ID is currently visible
330
- */
331
- isVisible: (id: string) => boolean;
332
- /**
333
- * Check if a toast with the given ID has been dismissed
334
- */
335
- isDismissed: (id: string) => boolean;
336
- /**
337
- * Expand all toasts to show their full content (overlap mode)
338
- */
339
- expand: VoidFunction;
340
- /**
341
- * Collapse all toasts to their compact state (overlap mode)
342
- */
343
- collapse: VoidFunction;
288
+ export type ToastGroupService = Service<ToastGroupSchema>;
289
+ export type ToastGroupMachine = Machine<ToastGroupSchema>;
290
+ export interface ToastStore<V = any> {
291
+ /**
292
+ * The attributes of the toast store
293
+ */
294
+ attrs: Required<ToastStoreProps>;
295
+ /**
296
+ * Subscribe to the toast store
297
+ */
298
+ subscribe: (subscriber: (...args: any[]) => void) => VoidFunction;
299
+ /**
300
+ * Create a toast or update an existing toast with the same ID.
301
+ * Calls targeting closing toasts are ignored.
302
+ */
303
+ create: (data: Options<V>) => string;
304
+ /**
305
+ * Update a toast with new properties or a function of its current properties.
306
+ * Updates to closing toasts are ignored.
307
+ * Functional updates are also ignored when the toast does not exist.
308
+ */
309
+ update: (id: string, data: MaybeFunction<Partial<ToastProps<V>>, Partial<ToastProps<V>>>) => string;
310
+ /**
311
+ * Remove a toast by its ID
312
+ */
313
+ remove: (id?: string) => void;
314
+ /**
315
+ * Dismiss a toast by its ID. If no ID is provided, dismisses all toasts
316
+ */
317
+ dismiss: (id?: string) => void;
318
+ /**
319
+ * Create an error toast with the given options
320
+ */
321
+ error: (data: Options<V>) => void;
322
+ /**
323
+ * Create a success toast with the given options
324
+ */
325
+ success: (data: Options<V>) => void;
326
+ /**
327
+ * Create an info toast with the given options
328
+ */
329
+ info: (data: Options<V>) => void;
330
+ /**
331
+ * Create a warning toast with the given options
332
+ */
333
+ warning: (data: Options<V>) => void;
334
+ /**
335
+ * Create a loading toast with the given options
336
+ */
337
+ loading: (data: Options<V>) => void;
338
+ /**
339
+ * Get all currently visible toasts
340
+ */
341
+ getVisibleToasts: () => Partial<ToastProps<V>>[];
342
+ /**
343
+ * Get the total number of toasts
344
+ */
345
+ getCount: () => number;
346
+ /**
347
+ * Create a toast that tracks a promise's state
348
+ */
349
+ promise: <T>(promise: Promise<T> | (() => Promise<T>), options: PromiseOptions<T, V>, shared?: Omit<Options<V>, "type">) => {
350
+ id: string | undefined;
351
+ unwrap: () => Promise<T>;
352
+ } | undefined;
353
+ /**
354
+ * Pause a toast's auto-dismiss timer. If no ID is provided, pauses all toasts
355
+ */
356
+ pause: (id?: string) => void;
357
+ /**
358
+ * Resume a toast's auto-dismiss timer. If no ID is provided, resumes all toasts
359
+ */
360
+ resume: (id?: string) => void;
361
+ /**
362
+ * Check if a toast with the given ID is currently visible
363
+ */
364
+ isVisible: (id: string) => boolean;
365
+ /**
366
+ * Check if a toast with the given ID has been dismissed
367
+ */
368
+ isDismissed: (id: string) => boolean;
369
+ /**
370
+ * Expand all toasts to show their full content (overlap mode)
371
+ */
372
+ expand: VoidFunction;
373
+ /**
374
+ * Collapse all toasts to their compact state (overlap mode)
375
+ */
376
+ collapse: VoidFunction;
344
377
  }
345
378
  type MaybeFunction<Value, Args> = Value | ((arg: Args) => Value);
346
- interface PromiseOptions<V, O = any> {
347
- loading: Omit<Options<O>, "type">;
348
- success?: MaybeFunction<Omit<Options<O>, "type"> & {
349
- type?: "success" | "warning";
350
- }, V> | undefined;
351
- error?: MaybeFunction<Omit<Options<O>, "type">, unknown> | undefined;
352
- finally?: (() => void | Promise<void>) | undefined;
379
+ export interface PromiseOptions<V, O = any> {
380
+ loading: Omit<Options<O>, "type">;
381
+ success?: MaybeFunction<Omit<Options<O>, "type"> & {
382
+ type?: "success" | "warning";
383
+ }, V> | undefined;
384
+ error?: MaybeFunction<Omit<Options<O>, "type">, unknown> | undefined;
385
+ finally?: (() => void | Promise<void>) | undefined;
353
386
  }
354
- interface GroupProps {
355
- /**
356
- * The human-readable label for the toast region
357
- */
358
- label?: string | undefined;
387
+ export interface GroupProps {
388
+ /**
389
+ * The human-readable label for the toast region
390
+ */
391
+ label?: string | undefined;
359
392
  }
360
- interface GroupState {
361
- /**
362
- * The placement of the toast group
363
- */
364
- placement: Placement;
365
- /**
366
- * The side of the toast group placement
367
- */
368
- side: string;
369
- /**
370
- * The horizontal alignment of the toast group placement
371
- */
372
- align: string;
393
+ export interface GroupState {
394
+ /**
395
+ * The placement of the toast group
396
+ */
397
+ placement: Placement;
398
+ /**
399
+ * The side of the toast group placement
400
+ */
401
+ side: string;
402
+ /**
403
+ * The horizontal alignment of the toast group placement
404
+ */
405
+ align: string;
373
406
  }
374
- interface ToastGroupApi<T extends PropTypes = PropTypes, O = any> {
375
- /**
376
- * The total number of toasts
377
- */
378
- getCount: () => number;
379
- /**
380
- * The toasts
381
- */
382
- getToasts: () => ToastProps[];
383
- /**
384
- * Subscribe to the toast group
385
- */
386
- subscribe: (callback: (toasts: Options<O>[]) => void) => VoidFunction;
387
- /**
388
- * Returns the state of the group
389
- */
390
- getGroupState: () => GroupState;
391
- getGroupProps: (options?: GroupProps) => T["element"];
407
+ export interface ToastGroupApi<T extends PropTypes = PropTypes, O = any> {
408
+ /**
409
+ * The total number of toasts
410
+ */
411
+ getCount: () => number;
412
+ /**
413
+ * The toasts
414
+ */
415
+ getToasts: () => ToastProps[];
416
+ /**
417
+ * Subscribe to the toast group
418
+ */
419
+ subscribe: (callback: (toasts: Options<O>[]) => void) => VoidFunction;
420
+ /**
421
+ * Returns the state of the group
422
+ */
423
+ getGroupState: () => GroupState;
424
+ getGroupProps: (options?: GroupProps) => T["element"];
392
425
  }
393
- interface ToastApi<T extends PropTypes = PropTypes, O = any> {
394
- /**
395
- * The title of the toast.
396
- */
397
- title?: O | undefined;
398
- /**
399
- * The description of the toast.
400
- */
401
- description?: O | undefined;
402
- /**
403
- * The type of the toast.
404
- */
405
- type: Type;
406
- /**
407
- * The current placement of the toast.
408
- */
409
- placement: Placement;
410
- /**
411
- * Whether the toast is visible.
412
- */
413
- visible: boolean;
414
- /**
415
- * Whether the toast should render a close button
416
- */
417
- closable: boolean;
418
- /**
419
- * Whether the toast is paused.
420
- */
421
- paused: boolean;
422
- /**
423
- * Function to pause the toast (keeping it visible).
424
- */
425
- pause: VoidFunction;
426
- /**
427
- * Function to resume the toast dismissing.
428
- */
429
- resume: VoidFunction;
430
- /**
431
- * Function to instantly dismiss the toast.
432
- */
433
- dismiss: VoidFunction;
434
- /**
435
- * Returns the state of the root
436
- */
437
- getRootState: () => RootState;
438
- getRootProps: () => T["element"];
439
- getTitleProps: () => T["element"];
440
- getGhostBeforeProps: () => T["element"];
441
- getGhostAfterProps: () => T["element"];
442
- getDescriptionProps: () => T["element"];
443
- getCloseTriggerProps: () => T["button"];
444
- getActionTriggerProps: () => T["button"];
426
+ export interface ToastApi<T extends PropTypes = PropTypes, O = any> {
427
+ /**
428
+ * The title of the toast.
429
+ */
430
+ title?: O | undefined;
431
+ /**
432
+ * The description of the toast.
433
+ */
434
+ description?: O | undefined;
435
+ /**
436
+ * The type of the toast.
437
+ */
438
+ type: Type;
439
+ /**
440
+ * The current placement of the toast.
441
+ */
442
+ placement: Placement;
443
+ /**
444
+ * Whether the toast is visible.
445
+ */
446
+ visible: boolean;
447
+ /**
448
+ * Whether the toast should render a close button
449
+ */
450
+ closable: boolean;
451
+ /**
452
+ * Whether the toast is paused.
453
+ */
454
+ paused: boolean;
455
+ /**
456
+ * Function to pause the toast (keeping it visible).
457
+ */
458
+ pause: VoidFunction;
459
+ /**
460
+ * Function to resume the toast dismissing.
461
+ */
462
+ resume: VoidFunction;
463
+ /**
464
+ * Function to instantly dismiss the toast.
465
+ */
466
+ dismiss: VoidFunction;
467
+ /**
468
+ * Returns the state of the root
469
+ */
470
+ getRootState: () => RootState;
471
+ getRootProps: () => T["element"];
472
+ getContentProps: () => T["element"];
473
+ getTitleProps: () => T["element"];
474
+ getGhostBeforeProps: () => T["element"];
475
+ getGhostAfterProps: () => T["element"];
476
+ getDescriptionProps: () => T["element"];
477
+ getCloseTriggerProps: () => T["button"];
478
+ getActionTriggerProps: () => T["button"];
445
479
  }
446
-
447
- export type { ActionOptions, GroupProps, GroupState, IntlTranslations, Options, Placement, PromiseOptions, RootState, Status, StatusChangeDetails, ToastApi, ToastGroupApi, ToastGroupMachine, ToastGroupProps, ToastGroupSchema, ToastGroupService, ToastHeight, ToastMachine, ToastProps, ToastQueuePriority, ToastSchema, ToastService, ToastStore, ToastStoreProps, Type };
480
+ export {};