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