@zag-js/toast 0.45.0 → 0.47.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 +88 -74
- package/dist/index.d.ts +88 -74
- package/dist/index.js +566 -177
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +569 -180
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -7
- package/src/index.ts +5 -3
- package/src/toast-group.connect.ts +63 -29
- package/src/toast-group.machine.ts +281 -67
- package/src/toast.anatomy.ts +9 -1
- package/src/toast.connect.ts +40 -32
- package/src/toast.dom.ts +5 -2
- package/src/toast.machine.ts +105 -44
- package/src/toast.types.ts +190 -110
- package/src/toast.utils.ts +136 -24
package/dist/index.d.mts
CHANGED
|
@@ -3,36 +3,23 @@ import * as _zag_js_core from '@zag-js/core';
|
|
|
3
3
|
import { Machine, StateMachine } from '@zag-js/core';
|
|
4
4
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
5
5
|
|
|
6
|
-
type Type = "success" | "error" | "loading" | "info" |
|
|
6
|
+
type Type = "success" | "error" | "loading" | "info" | (string & {});
|
|
7
7
|
type Placement = "top-start" | "top" | "top-end" | "bottom-start" | "bottom" | "bottom-end";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
title?: any;
|
|
11
|
-
description?: any;
|
|
12
|
-
}
|
|
13
|
-
interface DefaultGenericOptions {
|
|
14
|
-
/**
|
|
15
|
-
* Custom function to render the toast element.
|
|
16
|
-
*/
|
|
17
|
-
render?: (api: MachineApi<any, DefaultGenericOptions>) => any;
|
|
8
|
+
type Status = "visible" | "dismissing" | "unmounted";
|
|
9
|
+
interface GenericOptions<T = string> {
|
|
18
10
|
/**
|
|
19
11
|
* The title of the toast.
|
|
20
12
|
*/
|
|
21
|
-
title?:
|
|
13
|
+
title?: T;
|
|
22
14
|
/**
|
|
23
15
|
* The description of the toast.
|
|
24
16
|
*/
|
|
25
|
-
description?:
|
|
17
|
+
description?: T;
|
|
26
18
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
pauseOnPageIdle?: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Whether to pause the toast when interacted with
|
|
34
|
-
*/
|
|
35
|
-
pauseOnInteraction?: boolean;
|
|
19
|
+
interface StatusChangeDetails {
|
|
20
|
+
status: Status;
|
|
21
|
+
}
|
|
22
|
+
interface Options<T> extends GenericOptions<T> {
|
|
36
23
|
/**
|
|
37
24
|
* The duration the toast will be visible
|
|
38
25
|
*/
|
|
@@ -46,35 +33,24 @@ type GlobalToastOptions<T extends GenericOptions> = Pick<T, "render"> & {
|
|
|
46
33
|
* The placement of the toast
|
|
47
34
|
*/
|
|
48
35
|
placement?: Placement;
|
|
49
|
-
};
|
|
50
|
-
type ToastOptions<T extends GenericOptions = DefaultGenericOptions> = T & {
|
|
51
36
|
/**
|
|
52
37
|
* The unique id of the toast
|
|
53
38
|
*/
|
|
54
|
-
id
|
|
39
|
+
id?: string;
|
|
55
40
|
/**
|
|
56
41
|
* The type of the toast
|
|
57
42
|
*/
|
|
58
|
-
type
|
|
59
|
-
/**
|
|
60
|
-
* Function called when the toast has been closed and removed
|
|
61
|
-
*/
|
|
62
|
-
onClose?: VoidFunction;
|
|
43
|
+
type?: Type;
|
|
63
44
|
/**
|
|
64
|
-
* Function called when the toast is
|
|
45
|
+
* Function called when the toast is visible
|
|
65
46
|
*/
|
|
66
|
-
|
|
47
|
+
onStatusChange?(details: StatusChangeDetails): void;
|
|
67
48
|
/**
|
|
68
|
-
*
|
|
49
|
+
* The metadata of the toast
|
|
69
50
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*/
|
|
74
|
-
onUpdate?: VoidFunction;
|
|
75
|
-
};
|
|
76
|
-
type Options<T extends GenericOptions> = Partial<ToastOptions<T> & GlobalToastOptions<T>>;
|
|
77
|
-
type MachineContext<T extends GenericOptions = DefaultGenericOptions> = GlobalToastOptions<T> & CommonProperties & Omit<ToastOptions<T>, "removeDelay"> & {
|
|
51
|
+
meta?: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
interface MachineContext<T = any> extends Omit<CommonProperties, "id">, MachinePrivateContext, Omit<Options<T>, "removeDelay"> {
|
|
78
54
|
/**
|
|
79
55
|
* The duration for the toast to kept alive before it is removed.
|
|
80
56
|
* Useful for exit transitions.
|
|
@@ -92,23 +68,25 @@ type MachineContext<T extends GenericOptions = DefaultGenericOptions> = GlobalTo
|
|
|
92
68
|
* The time left before the toast is removed
|
|
93
69
|
*/
|
|
94
70
|
remaining: number;
|
|
95
|
-
}
|
|
71
|
+
}
|
|
72
|
+
interface MachinePrivateContext {
|
|
73
|
+
}
|
|
96
74
|
interface MachineState {
|
|
97
|
-
value: "
|
|
75
|
+
value: "visible" | "visible:updating" | "dismissing" | "unmounted" | "visible:persist";
|
|
98
76
|
tags: "visible" | "paused" | "updating";
|
|
99
77
|
}
|
|
100
|
-
type State<T
|
|
78
|
+
type State<T = any> = StateMachine.State<MachineContext<T>, MachineState>;
|
|
101
79
|
type Send = StateMachine.Send;
|
|
102
|
-
type Service<T
|
|
103
|
-
|
|
80
|
+
type Service<T = any> = Machine<MachineContext<T>, MachineState>;
|
|
81
|
+
interface GroupPublicContext extends DirectionProperty, CommonProperties {
|
|
104
82
|
/**
|
|
105
|
-
*
|
|
83
|
+
* Whether to pause toast when the user leaves the browser tab
|
|
106
84
|
*/
|
|
107
|
-
|
|
85
|
+
pauseOnPageIdle: boolean;
|
|
108
86
|
/**
|
|
109
|
-
* The
|
|
87
|
+
* The gap or spacing between toasts
|
|
110
88
|
*/
|
|
111
|
-
|
|
89
|
+
gap: number;
|
|
112
90
|
/**
|
|
113
91
|
* The maximum number of toasts that can be shown at once
|
|
114
92
|
*/
|
|
@@ -117,8 +95,30 @@ type GroupPublicContext<T extends GenericOptions> = GlobalToastOptions<T> & Dire
|
|
|
117
95
|
* The offset from the safe environment edge of the viewport
|
|
118
96
|
*/
|
|
119
97
|
offsets: string | Record<"left" | "right" | "bottom" | "top", string>;
|
|
120
|
-
|
|
121
|
-
|
|
98
|
+
/**
|
|
99
|
+
* The hotkey that will move focus to the toast group
|
|
100
|
+
*/
|
|
101
|
+
hotkey: string[];
|
|
102
|
+
/**
|
|
103
|
+
* Whether the toasts should overlap each other
|
|
104
|
+
*/
|
|
105
|
+
overlap?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* The placement of the toast
|
|
108
|
+
*/
|
|
109
|
+
placement: Placement;
|
|
110
|
+
/**
|
|
111
|
+
* The duration for the toast to kept alive before it is removed.
|
|
112
|
+
* Useful for exit transitions.
|
|
113
|
+
*/
|
|
114
|
+
removeDelay: number;
|
|
115
|
+
/**
|
|
116
|
+
* The duration the toast will be visible
|
|
117
|
+
*/
|
|
118
|
+
duration?: number;
|
|
119
|
+
}
|
|
120
|
+
interface UserDefinedGroupContext extends RequiredBy<GroupPublicContext, "id"> {
|
|
121
|
+
}
|
|
122
122
|
type GroupComputedContext = Readonly<{
|
|
123
123
|
/**
|
|
124
124
|
* @computed
|
|
@@ -126,35 +126,46 @@ type GroupComputedContext = Readonly<{
|
|
|
126
126
|
*/
|
|
127
127
|
count: number;
|
|
128
128
|
}>;
|
|
129
|
-
interface GroupPrivateContext<T extends GenericOptions> {
|
|
129
|
+
interface GroupPrivateContext<T> extends GenericOptions<T> {
|
|
130
|
+
}
|
|
131
|
+
interface GroupMachineContext<T = any> extends GroupPublicContext, GroupPrivateContext<T>, GroupComputedContext {
|
|
130
132
|
}
|
|
131
|
-
interface
|
|
133
|
+
interface GroupMachineState {
|
|
134
|
+
value: "stack" | "overlap";
|
|
132
135
|
}
|
|
133
|
-
type GroupState<T
|
|
136
|
+
type GroupState<T = any> = StateMachine.State<GroupMachineContext<T>>;
|
|
134
137
|
type GroupSend = StateMachine.Send;
|
|
138
|
+
type GroupService<T = any> = Machine<GroupMachineContext<T>, GroupMachineState>;
|
|
135
139
|
type MaybeFunction<Value, Args> = Value | ((arg: Args) => Value);
|
|
136
|
-
interface PromiseOptions<V, O
|
|
137
|
-
loading:
|
|
138
|
-
success: MaybeFunction<
|
|
139
|
-
error: MaybeFunction<
|
|
140
|
+
interface PromiseOptions<V, O = any> {
|
|
141
|
+
loading: Options<O>;
|
|
142
|
+
success: MaybeFunction<Options<O>, V>;
|
|
143
|
+
error: MaybeFunction<Options<O>, Error>;
|
|
144
|
+
finally?: () => void | Promise<void>;
|
|
140
145
|
}
|
|
141
146
|
interface GroupProps {
|
|
147
|
+
/**
|
|
148
|
+
* The placement of the toast region
|
|
149
|
+
*/
|
|
142
150
|
placement: Placement;
|
|
151
|
+
/**
|
|
152
|
+
* The human-readable label for the toast region
|
|
153
|
+
*/
|
|
143
154
|
label?: string;
|
|
144
155
|
}
|
|
145
|
-
interface GroupMachineApi<T extends PropTypes = PropTypes, O
|
|
156
|
+
interface GroupMachineApi<T extends PropTypes = PropTypes, O = any> {
|
|
146
157
|
/**
|
|
147
158
|
* The total number of toasts
|
|
148
159
|
*/
|
|
149
|
-
|
|
160
|
+
getCount(): number;
|
|
150
161
|
/**
|
|
151
|
-
* The active toasts
|
|
162
|
+
* The placements of the active toasts
|
|
152
163
|
*/
|
|
153
|
-
|
|
164
|
+
getPlacements(): Placement[];
|
|
154
165
|
/**
|
|
155
166
|
* The active toasts by placement
|
|
156
167
|
*/
|
|
157
|
-
|
|
168
|
+
getToastsByPlacement(placement: Placement): Service<O>[];
|
|
158
169
|
/**
|
|
159
170
|
* Returns whether the toast id is visible
|
|
160
171
|
*/
|
|
@@ -210,14 +221,14 @@ interface GroupMachineApi<T extends PropTypes = PropTypes, O extends GenericOpti
|
|
|
210
221
|
* - When the promise resolves, the toast will be updated with the success options.
|
|
211
222
|
* - When the promise rejects, the toast will be updated with the error options.
|
|
212
223
|
*/
|
|
213
|
-
promise<T>(promise: Promise<T
|
|
224
|
+
promise<T>(promise: Promise<T> | (() => Promise<T>), options: PromiseOptions<T, O>, shared?: Partial<Options<O>>): string;
|
|
214
225
|
/**
|
|
215
226
|
* Function to subscribe to the toast group.
|
|
216
227
|
*/
|
|
217
|
-
subscribe(callback: (toasts:
|
|
228
|
+
subscribe(callback: (toasts: Options<O>[]) => void): VoidFunction;
|
|
218
229
|
getGroupProps(options: GroupProps): T["element"];
|
|
219
230
|
}
|
|
220
|
-
|
|
231
|
+
interface MachineApi<T extends PropTypes = PropTypes, O = any> extends GenericOptions<O> {
|
|
221
232
|
/**
|
|
222
233
|
* The type of the toast.
|
|
223
234
|
*/
|
|
@@ -252,23 +263,26 @@ type MachineApi<T extends PropTypes = PropTypes, O extends GenericOptions = Defa
|
|
|
252
263
|
dismiss(): void;
|
|
253
264
|
rootProps: T["element"];
|
|
254
265
|
titleProps: T["element"];
|
|
266
|
+
ghostBeforeProps: T["element"];
|
|
267
|
+
ghostAfterProps: T["element"];
|
|
255
268
|
descriptionProps: T["element"];
|
|
256
269
|
closeTriggerProps: T["button"];
|
|
257
|
-
|
|
270
|
+
actionTriggerProps: T["button"];
|
|
271
|
+
}
|
|
258
272
|
|
|
259
|
-
declare function groupConnect<T extends PropTypes, O
|
|
273
|
+
declare function groupConnect<T extends PropTypes, O = any>(serviceOrState: GroupState<O> | GroupService<O>, send: GroupSend, normalize: NormalizeProps<T>): GroupMachineApi<T, O>;
|
|
260
274
|
|
|
261
|
-
declare function groupMachine<T
|
|
275
|
+
declare function groupMachine<T = any>(userContext: UserDefinedGroupContext): _zag_js_core.Machine<GroupMachineContext<T>, GroupMachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
262
276
|
|
|
263
|
-
declare function createToastMachine<T
|
|
277
|
+
declare function createToastMachine<T>(options: Options<T>): _zag_js_core.Machine<MachineContext<T>, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
264
278
|
|
|
265
|
-
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"
|
|
279
|
+
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"title" | "group" | "root" | "description" | "actionTrigger" | "closeTrigger">;
|
|
266
280
|
|
|
267
|
-
declare function connect<T extends PropTypes, O
|
|
281
|
+
declare function connect<T extends PropTypes, O>(state: State<O>, send: Send, normalize: NormalizeProps<T>): MachineApi<T, O>;
|
|
268
282
|
|
|
269
283
|
declare const group: {
|
|
270
284
|
connect: typeof groupConnect;
|
|
271
285
|
machine: typeof groupMachine;
|
|
272
286
|
};
|
|
273
287
|
|
|
274
|
-
export { type MachineApi as Api, type
|
|
288
|
+
export { type MachineApi as Api, type GenericOptions, type GroupMachineApi as GroupApi, type GroupMachineContext, type GroupProps, type GroupService, type GroupState, type MachineContext, type Options, type Placement, type PromiseOptions, type Service, type Status, type StatusChangeDetails, type Type, anatomy, connect, createToastMachine as createMachine, group };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,36 +3,23 @@ import * as _zag_js_core from '@zag-js/core';
|
|
|
3
3
|
import { Machine, StateMachine } from '@zag-js/core';
|
|
4
4
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
5
5
|
|
|
6
|
-
type Type = "success" | "error" | "loading" | "info" |
|
|
6
|
+
type Type = "success" | "error" | "loading" | "info" | (string & {});
|
|
7
7
|
type Placement = "top-start" | "top" | "top-end" | "bottom-start" | "bottom" | "bottom-end";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
title?: any;
|
|
11
|
-
description?: any;
|
|
12
|
-
}
|
|
13
|
-
interface DefaultGenericOptions {
|
|
14
|
-
/**
|
|
15
|
-
* Custom function to render the toast element.
|
|
16
|
-
*/
|
|
17
|
-
render?: (api: MachineApi<any, DefaultGenericOptions>) => any;
|
|
8
|
+
type Status = "visible" | "dismissing" | "unmounted";
|
|
9
|
+
interface GenericOptions<T = string> {
|
|
18
10
|
/**
|
|
19
11
|
* The title of the toast.
|
|
20
12
|
*/
|
|
21
|
-
title?:
|
|
13
|
+
title?: T;
|
|
22
14
|
/**
|
|
23
15
|
* The description of the toast.
|
|
24
16
|
*/
|
|
25
|
-
description?:
|
|
17
|
+
description?: T;
|
|
26
18
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
pauseOnPageIdle?: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Whether to pause the toast when interacted with
|
|
34
|
-
*/
|
|
35
|
-
pauseOnInteraction?: boolean;
|
|
19
|
+
interface StatusChangeDetails {
|
|
20
|
+
status: Status;
|
|
21
|
+
}
|
|
22
|
+
interface Options<T> extends GenericOptions<T> {
|
|
36
23
|
/**
|
|
37
24
|
* The duration the toast will be visible
|
|
38
25
|
*/
|
|
@@ -46,35 +33,24 @@ type GlobalToastOptions<T extends GenericOptions> = Pick<T, "render"> & {
|
|
|
46
33
|
* The placement of the toast
|
|
47
34
|
*/
|
|
48
35
|
placement?: Placement;
|
|
49
|
-
};
|
|
50
|
-
type ToastOptions<T extends GenericOptions = DefaultGenericOptions> = T & {
|
|
51
36
|
/**
|
|
52
37
|
* The unique id of the toast
|
|
53
38
|
*/
|
|
54
|
-
id
|
|
39
|
+
id?: string;
|
|
55
40
|
/**
|
|
56
41
|
* The type of the toast
|
|
57
42
|
*/
|
|
58
|
-
type
|
|
59
|
-
/**
|
|
60
|
-
* Function called when the toast has been closed and removed
|
|
61
|
-
*/
|
|
62
|
-
onClose?: VoidFunction;
|
|
43
|
+
type?: Type;
|
|
63
44
|
/**
|
|
64
|
-
* Function called when the toast is
|
|
45
|
+
* Function called when the toast is visible
|
|
65
46
|
*/
|
|
66
|
-
|
|
47
|
+
onStatusChange?(details: StatusChangeDetails): void;
|
|
67
48
|
/**
|
|
68
|
-
*
|
|
49
|
+
* The metadata of the toast
|
|
69
50
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*/
|
|
74
|
-
onUpdate?: VoidFunction;
|
|
75
|
-
};
|
|
76
|
-
type Options<T extends GenericOptions> = Partial<ToastOptions<T> & GlobalToastOptions<T>>;
|
|
77
|
-
type MachineContext<T extends GenericOptions = DefaultGenericOptions> = GlobalToastOptions<T> & CommonProperties & Omit<ToastOptions<T>, "removeDelay"> & {
|
|
51
|
+
meta?: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
interface MachineContext<T = any> extends Omit<CommonProperties, "id">, MachinePrivateContext, Omit<Options<T>, "removeDelay"> {
|
|
78
54
|
/**
|
|
79
55
|
* The duration for the toast to kept alive before it is removed.
|
|
80
56
|
* Useful for exit transitions.
|
|
@@ -92,23 +68,25 @@ type MachineContext<T extends GenericOptions = DefaultGenericOptions> = GlobalTo
|
|
|
92
68
|
* The time left before the toast is removed
|
|
93
69
|
*/
|
|
94
70
|
remaining: number;
|
|
95
|
-
}
|
|
71
|
+
}
|
|
72
|
+
interface MachinePrivateContext {
|
|
73
|
+
}
|
|
96
74
|
interface MachineState {
|
|
97
|
-
value: "
|
|
75
|
+
value: "visible" | "visible:updating" | "dismissing" | "unmounted" | "visible:persist";
|
|
98
76
|
tags: "visible" | "paused" | "updating";
|
|
99
77
|
}
|
|
100
|
-
type State<T
|
|
78
|
+
type State<T = any> = StateMachine.State<MachineContext<T>, MachineState>;
|
|
101
79
|
type Send = StateMachine.Send;
|
|
102
|
-
type Service<T
|
|
103
|
-
|
|
80
|
+
type Service<T = any> = Machine<MachineContext<T>, MachineState>;
|
|
81
|
+
interface GroupPublicContext extends DirectionProperty, CommonProperties {
|
|
104
82
|
/**
|
|
105
|
-
*
|
|
83
|
+
* Whether to pause toast when the user leaves the browser tab
|
|
106
84
|
*/
|
|
107
|
-
|
|
85
|
+
pauseOnPageIdle: boolean;
|
|
108
86
|
/**
|
|
109
|
-
* The
|
|
87
|
+
* The gap or spacing between toasts
|
|
110
88
|
*/
|
|
111
|
-
|
|
89
|
+
gap: number;
|
|
112
90
|
/**
|
|
113
91
|
* The maximum number of toasts that can be shown at once
|
|
114
92
|
*/
|
|
@@ -117,8 +95,30 @@ type GroupPublicContext<T extends GenericOptions> = GlobalToastOptions<T> & Dire
|
|
|
117
95
|
* The offset from the safe environment edge of the viewport
|
|
118
96
|
*/
|
|
119
97
|
offsets: string | Record<"left" | "right" | "bottom" | "top", string>;
|
|
120
|
-
|
|
121
|
-
|
|
98
|
+
/**
|
|
99
|
+
* The hotkey that will move focus to the toast group
|
|
100
|
+
*/
|
|
101
|
+
hotkey: string[];
|
|
102
|
+
/**
|
|
103
|
+
* Whether the toasts should overlap each other
|
|
104
|
+
*/
|
|
105
|
+
overlap?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* The placement of the toast
|
|
108
|
+
*/
|
|
109
|
+
placement: Placement;
|
|
110
|
+
/**
|
|
111
|
+
* The duration for the toast to kept alive before it is removed.
|
|
112
|
+
* Useful for exit transitions.
|
|
113
|
+
*/
|
|
114
|
+
removeDelay: number;
|
|
115
|
+
/**
|
|
116
|
+
* The duration the toast will be visible
|
|
117
|
+
*/
|
|
118
|
+
duration?: number;
|
|
119
|
+
}
|
|
120
|
+
interface UserDefinedGroupContext extends RequiredBy<GroupPublicContext, "id"> {
|
|
121
|
+
}
|
|
122
122
|
type GroupComputedContext = Readonly<{
|
|
123
123
|
/**
|
|
124
124
|
* @computed
|
|
@@ -126,35 +126,46 @@ type GroupComputedContext = Readonly<{
|
|
|
126
126
|
*/
|
|
127
127
|
count: number;
|
|
128
128
|
}>;
|
|
129
|
-
interface GroupPrivateContext<T extends GenericOptions> {
|
|
129
|
+
interface GroupPrivateContext<T> extends GenericOptions<T> {
|
|
130
|
+
}
|
|
131
|
+
interface GroupMachineContext<T = any> extends GroupPublicContext, GroupPrivateContext<T>, GroupComputedContext {
|
|
130
132
|
}
|
|
131
|
-
interface
|
|
133
|
+
interface GroupMachineState {
|
|
134
|
+
value: "stack" | "overlap";
|
|
132
135
|
}
|
|
133
|
-
type GroupState<T
|
|
136
|
+
type GroupState<T = any> = StateMachine.State<GroupMachineContext<T>>;
|
|
134
137
|
type GroupSend = StateMachine.Send;
|
|
138
|
+
type GroupService<T = any> = Machine<GroupMachineContext<T>, GroupMachineState>;
|
|
135
139
|
type MaybeFunction<Value, Args> = Value | ((arg: Args) => Value);
|
|
136
|
-
interface PromiseOptions<V, O
|
|
137
|
-
loading:
|
|
138
|
-
success: MaybeFunction<
|
|
139
|
-
error: MaybeFunction<
|
|
140
|
+
interface PromiseOptions<V, O = any> {
|
|
141
|
+
loading: Options<O>;
|
|
142
|
+
success: MaybeFunction<Options<O>, V>;
|
|
143
|
+
error: MaybeFunction<Options<O>, Error>;
|
|
144
|
+
finally?: () => void | Promise<void>;
|
|
140
145
|
}
|
|
141
146
|
interface GroupProps {
|
|
147
|
+
/**
|
|
148
|
+
* The placement of the toast region
|
|
149
|
+
*/
|
|
142
150
|
placement: Placement;
|
|
151
|
+
/**
|
|
152
|
+
* The human-readable label for the toast region
|
|
153
|
+
*/
|
|
143
154
|
label?: string;
|
|
144
155
|
}
|
|
145
|
-
interface GroupMachineApi<T extends PropTypes = PropTypes, O
|
|
156
|
+
interface GroupMachineApi<T extends PropTypes = PropTypes, O = any> {
|
|
146
157
|
/**
|
|
147
158
|
* The total number of toasts
|
|
148
159
|
*/
|
|
149
|
-
|
|
160
|
+
getCount(): number;
|
|
150
161
|
/**
|
|
151
|
-
* The active toasts
|
|
162
|
+
* The placements of the active toasts
|
|
152
163
|
*/
|
|
153
|
-
|
|
164
|
+
getPlacements(): Placement[];
|
|
154
165
|
/**
|
|
155
166
|
* The active toasts by placement
|
|
156
167
|
*/
|
|
157
|
-
|
|
168
|
+
getToastsByPlacement(placement: Placement): Service<O>[];
|
|
158
169
|
/**
|
|
159
170
|
* Returns whether the toast id is visible
|
|
160
171
|
*/
|
|
@@ -210,14 +221,14 @@ interface GroupMachineApi<T extends PropTypes = PropTypes, O extends GenericOpti
|
|
|
210
221
|
* - When the promise resolves, the toast will be updated with the success options.
|
|
211
222
|
* - When the promise rejects, the toast will be updated with the error options.
|
|
212
223
|
*/
|
|
213
|
-
promise<T>(promise: Promise<T
|
|
224
|
+
promise<T>(promise: Promise<T> | (() => Promise<T>), options: PromiseOptions<T, O>, shared?: Partial<Options<O>>): string;
|
|
214
225
|
/**
|
|
215
226
|
* Function to subscribe to the toast group.
|
|
216
227
|
*/
|
|
217
|
-
subscribe(callback: (toasts:
|
|
228
|
+
subscribe(callback: (toasts: Options<O>[]) => void): VoidFunction;
|
|
218
229
|
getGroupProps(options: GroupProps): T["element"];
|
|
219
230
|
}
|
|
220
|
-
|
|
231
|
+
interface MachineApi<T extends PropTypes = PropTypes, O = any> extends GenericOptions<O> {
|
|
221
232
|
/**
|
|
222
233
|
* The type of the toast.
|
|
223
234
|
*/
|
|
@@ -252,23 +263,26 @@ type MachineApi<T extends PropTypes = PropTypes, O extends GenericOptions = Defa
|
|
|
252
263
|
dismiss(): void;
|
|
253
264
|
rootProps: T["element"];
|
|
254
265
|
titleProps: T["element"];
|
|
266
|
+
ghostBeforeProps: T["element"];
|
|
267
|
+
ghostAfterProps: T["element"];
|
|
255
268
|
descriptionProps: T["element"];
|
|
256
269
|
closeTriggerProps: T["button"];
|
|
257
|
-
|
|
270
|
+
actionTriggerProps: T["button"];
|
|
271
|
+
}
|
|
258
272
|
|
|
259
|
-
declare function groupConnect<T extends PropTypes, O
|
|
273
|
+
declare function groupConnect<T extends PropTypes, O = any>(serviceOrState: GroupState<O> | GroupService<O>, send: GroupSend, normalize: NormalizeProps<T>): GroupMachineApi<T, O>;
|
|
260
274
|
|
|
261
|
-
declare function groupMachine<T
|
|
275
|
+
declare function groupMachine<T = any>(userContext: UserDefinedGroupContext): _zag_js_core.Machine<GroupMachineContext<T>, GroupMachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
262
276
|
|
|
263
|
-
declare function createToastMachine<T
|
|
277
|
+
declare function createToastMachine<T>(options: Options<T>): _zag_js_core.Machine<MachineContext<T>, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
264
278
|
|
|
265
|
-
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"
|
|
279
|
+
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"title" | "group" | "root" | "description" | "actionTrigger" | "closeTrigger">;
|
|
266
280
|
|
|
267
|
-
declare function connect<T extends PropTypes, O
|
|
281
|
+
declare function connect<T extends PropTypes, O>(state: State<O>, send: Send, normalize: NormalizeProps<T>): MachineApi<T, O>;
|
|
268
282
|
|
|
269
283
|
declare const group: {
|
|
270
284
|
connect: typeof groupConnect;
|
|
271
285
|
machine: typeof groupMachine;
|
|
272
286
|
};
|
|
273
287
|
|
|
274
|
-
export { type MachineApi as Api, type
|
|
288
|
+
export { type MachineApi as Api, type GenericOptions, type GroupMachineApi as GroupApi, type GroupMachineContext, type GroupProps, type GroupService, type GroupState, type MachineContext, type Options, type Placement, type PromiseOptions, type Service, type Status, type StatusChangeDetails, type Type, anatomy, connect, createToastMachine as createMachine, group };
|