@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.
- 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 +82 -103
- package/dist/toast-group.connect.mjs +77 -67
- package/dist/toast-group.machine.d.mts +2 -8
- package/dist/toast-group.machine.d.ts +2 -8
- package/dist/toast-group.machine.js +295 -290
- package/dist/toast-group.machine.mjs +290 -254
- 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 +176 -160
- package/dist/toast.connect.mjs +171 -124
- package/dist/toast.dom.d.mts +21 -14
- package/dist/toast.dom.d.ts +21 -14
- package/dist/toast.dom.js +50 -48
- package/dist/toast.dom.mjs +35 -17
- package/dist/toast.machine.d.mts +2 -8
- package/dist/toast.machine.d.ts +2 -8
- package/dist/toast.machine.js +404 -288
- package/dist/toast.machine.mjs +400 -253
- package/dist/toast.store.d.mts +2 -8
- package/dist/toast.store.d.ts +2 -8
- package/dist/toast.store.js +345 -263
- package/dist/toast.store.mjs +341 -238
- package/dist/toast.types.d.mts +460 -427
- package/dist/toast.types.d.ts +460 -427
- 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 +185 -198
- package/dist/toast.utils.mjs +175 -168
- package/dist/utils/swipe.d.mts +16 -0
- package/dist/utils/swipe.d.ts +16 -0
- package/dist/utils/swipe.js +100 -0
- package/dist/utils/swipe.mjs +93 -0
- package/package.json +8 -8
package/dist/toast.types.d.ts
CHANGED
|
@@ -1,447 +1,480 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { AnimationFrame } from
|
|
4
|
-
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
type
|
|
9
|
-
interface StatusChangeDetails {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { CommonProperties, Direction, DirectionProperty, Point, PropTypes, Required, RequiredBy } from "@zag-js/types";
|
|
2
|
+
import { EventObject, Machine, Service } from "@zag-js/core";
|
|
3
|
+
import { AnimationFrame } from "@zag-js/dom-query";
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
85
|
+
export interface IntlTranslations {
|
|
86
|
+
closeTriggerLabel?: string | undefined;
|
|
79
87
|
}
|
|
80
|
-
interface Options<T = any> {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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
|
-
|
|
230
|
-
|
|
231
|
-
|
|
257
|
+
export interface ToastGroupProps extends DirectionProperty, CommonProperties {
|
|
258
|
+
/**
|
|
259
|
+
* The store of the toast
|
|
260
|
+
*/
|
|
261
|
+
store: ToastStore;
|
|
232
262
|
}
|
|
233
|
-
type ToastGroupSchema = {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
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
|
-
|
|
357
|
-
|
|
358
|
-
|
|
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
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
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
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
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 {};
|