toastflow-core 0.0.3 → 1.0.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/package.json +7 -1
- package/src/store.ts +7 -16
- package/dist/index.d.mts +0 -270
- package/dist/index.d.ts +0 -270
- package/dist/index.js +0 -549
- package/dist/index.mjs +0 -522
package/package.json
CHANGED
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
"name": "toastflow-core",
|
|
3
3
|
"author": "adrianjanocko",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"
|
|
5
|
+
"homepage": "https://toastflow.vercel.app/",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/adrianjanocko/toastflow.git",
|
|
9
|
+
"directory": "packages/core"
|
|
10
|
+
},
|
|
11
|
+
"version": "1.0.0",
|
|
6
12
|
"main": "src/index.ts",
|
|
7
13
|
"module": "src/index.ts",
|
|
8
14
|
"types": "src/index.ts",
|
package/src/store.ts
CHANGED
|
@@ -673,27 +673,18 @@ function pickOverflowToast(
|
|
|
673
673
|
return null;
|
|
674
674
|
}
|
|
675
675
|
|
|
676
|
-
const
|
|
676
|
+
const first = samePos[0];
|
|
677
677
|
if (!first) {
|
|
678
678
|
return null;
|
|
679
679
|
}
|
|
680
680
|
|
|
681
681
|
if (order === "newest") {
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
oldest = t;
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
return oldest;
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
let newest = first;
|
|
692
|
-
for (const t of rest) {
|
|
693
|
-
if (t.createdAt > newest.createdAt) {
|
|
694
|
-
newest = t;
|
|
695
|
-
}
|
|
682
|
+
return samePos.slice(1).reduce((oldest, toast) => {
|
|
683
|
+
return toast.createdAt < oldest.createdAt ? toast : oldest;
|
|
684
|
+
}, first);
|
|
696
685
|
}
|
|
697
686
|
|
|
698
|
-
return newest
|
|
687
|
+
return samePos.slice(1).reduce((newest, toast) => {
|
|
688
|
+
return toast.createdAt > newest.createdAt ? toast : newest;
|
|
689
|
+
}, first);
|
|
699
690
|
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unique identifier assigned to each toast instance.
|
|
3
|
-
*/
|
|
4
|
-
type ToastId = string;
|
|
5
|
-
/**
|
|
6
|
-
* Supported viewport anchors where toasts can stack.
|
|
7
|
-
*/
|
|
8
|
-
type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
9
|
-
/**
|
|
10
|
-
* Order to display and evict toasts in a stack.
|
|
11
|
-
*/
|
|
12
|
-
type ToastOrder = "newest" | "oldest";
|
|
13
|
-
/**
|
|
14
|
-
* Determines how the timer behaves after an interaction pause.
|
|
15
|
-
*/
|
|
16
|
-
type PauseStrategy = "resume" | "reset";
|
|
17
|
-
/**
|
|
18
|
-
* Semantic type that controls the toast's appearance.
|
|
19
|
-
*/
|
|
20
|
-
type ToastType = "loading" | "default" | "success" | "error" | "info" | "warning";
|
|
21
|
-
/**
|
|
22
|
-
* Internal lifecycle markers used for animations and cleanup.
|
|
23
|
-
*/
|
|
24
|
-
type ToastPhase = "enter" | "leaving" | "clear-all";
|
|
25
|
-
/**
|
|
26
|
-
* Event kinds emitted to event subscribers.
|
|
27
|
-
*/
|
|
28
|
-
type ToastEventKind = "duplicate" | "timer-reset" | "update";
|
|
29
|
-
/**
|
|
30
|
-
* Payload emitted whenever the store dispatches a toast event.
|
|
31
|
-
*/
|
|
32
|
-
interface ToastEvent {
|
|
33
|
-
id: ToastId;
|
|
34
|
-
kind: ToastEventKind;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Async work passed to the loading helper.
|
|
38
|
-
*/
|
|
39
|
-
type ToastLoadingInput<T> = Promise<T> | (() => Promise<T>);
|
|
40
|
-
/**
|
|
41
|
-
* Text and rendering options for the loading helper phases.
|
|
42
|
-
*/
|
|
43
|
-
interface ToastLoadingConfig<T> {
|
|
44
|
-
loading: ToastContentInput;
|
|
45
|
-
success: ToastLoadingRender<T>;
|
|
46
|
-
error: ToastLoadingRender<unknown>;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* CSS class names used to animate toasts.
|
|
50
|
-
*/
|
|
51
|
-
interface ToastAnimation {
|
|
52
|
-
name: string;
|
|
53
|
-
bump: string;
|
|
54
|
-
clearAll: string;
|
|
55
|
-
update: string;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Minimal context shared with lifecycle and click callbacks.
|
|
59
|
-
*/
|
|
60
|
-
interface ToastContext {
|
|
61
|
-
id: ToastId;
|
|
62
|
-
position: ToastPosition;
|
|
63
|
-
type: ToastType;
|
|
64
|
-
title: string;
|
|
65
|
-
description: string;
|
|
66
|
-
createdAt: number;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Global configuration that shapes how toasts look and behave.
|
|
70
|
-
*/
|
|
71
|
-
interface ToastConfig {
|
|
72
|
-
/**
|
|
73
|
-
* Distance from the viewport edge where toasts start.
|
|
74
|
-
*/
|
|
75
|
-
offset: string;
|
|
76
|
-
/**
|
|
77
|
-
* Gap between toasts stacked at the same position.
|
|
78
|
-
*/
|
|
79
|
-
gap: string;
|
|
80
|
-
/**
|
|
81
|
-
* z-index applied to the toast container.
|
|
82
|
-
*/
|
|
83
|
-
zIndex: number;
|
|
84
|
-
/**
|
|
85
|
-
* Fixed width applied to each toast.
|
|
86
|
-
*/
|
|
87
|
-
width: string;
|
|
88
|
-
/**
|
|
89
|
-
* Time in milliseconds before a toast auto-dismisses.
|
|
90
|
-
* Use Infinity or 0 to keep it visible until manually dismissed.
|
|
91
|
-
*/
|
|
92
|
-
duration: number;
|
|
93
|
-
/**
|
|
94
|
-
* Maximum number of visible toasts per position; extra items are evicted.
|
|
95
|
-
*/
|
|
96
|
-
maxVisible: number;
|
|
97
|
-
/**
|
|
98
|
-
* Default stack position used when none is provided.
|
|
99
|
-
*/
|
|
100
|
-
position: ToastPosition;
|
|
101
|
-
/**
|
|
102
|
-
* When true, skip showing identical toasts that are still visible.
|
|
103
|
-
*/
|
|
104
|
-
preventDuplicates: boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Controls whether new toasts appear before or after older ones.
|
|
107
|
-
*/
|
|
108
|
-
order: ToastOrder;
|
|
109
|
-
/**
|
|
110
|
-
* When enabled, render a progress bar for finite durations.
|
|
111
|
-
*/
|
|
112
|
-
progressBar: boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Pause the timer while the toast is hovered.
|
|
115
|
-
*/
|
|
116
|
-
pauseOnHover: boolean;
|
|
117
|
-
/**
|
|
118
|
-
* Whether resuming should continue the remaining time or restart it.
|
|
119
|
-
*/
|
|
120
|
-
pauseStrategy: PauseStrategy;
|
|
121
|
-
/**
|
|
122
|
-
* CSS animation class overrides for various toast transitions.
|
|
123
|
-
*/
|
|
124
|
-
animation: Partial<ToastAnimation>;
|
|
125
|
-
/**
|
|
126
|
-
* Show a close button inside each toast.
|
|
127
|
-
*/
|
|
128
|
-
closeButton: boolean;
|
|
129
|
-
/**
|
|
130
|
-
* Allow closing a toast by clicking anywhere on it.
|
|
131
|
-
*/
|
|
132
|
-
closeOnClick: boolean;
|
|
133
|
-
/**
|
|
134
|
-
* When true, title/description may contain HTML.
|
|
135
|
-
*/
|
|
136
|
-
supportHtml: boolean;
|
|
137
|
-
/**
|
|
138
|
-
* Show the createdAt timestamp in the rendered toast.
|
|
139
|
-
*/
|
|
140
|
-
showCreatedAt: boolean;
|
|
141
|
-
/**
|
|
142
|
-
* Format the createdAt timestamp when displayed.
|
|
143
|
-
*/
|
|
144
|
-
createdAtFormatter: (createdAt: number) => string;
|
|
145
|
-
/**
|
|
146
|
-
* Called after the toast is added to state.
|
|
147
|
-
*/
|
|
148
|
-
onMount?(ctx: ToastContext): void;
|
|
149
|
-
/**
|
|
150
|
-
* Called after the toast is removed from state.
|
|
151
|
-
*/
|
|
152
|
-
onUnmount?(ctx: ToastContext): void;
|
|
153
|
-
/**
|
|
154
|
-
* Called when the toast is clicked.
|
|
155
|
-
*/
|
|
156
|
-
onClick?(ctx: ToastContext, event: MouseEvent): void;
|
|
157
|
-
/**
|
|
158
|
-
* Called right before a toast starts leaving.
|
|
159
|
-
*/
|
|
160
|
-
onClose?(ctx: ToastContext): void;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Fully resolved options applied to a toast instance.
|
|
164
|
-
*/
|
|
165
|
-
interface ToastOptions extends ToastConfig {
|
|
166
|
-
type: ToastType;
|
|
167
|
-
title: string;
|
|
168
|
-
description: string;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Minimal text payload required to render a toast.
|
|
172
|
-
*/
|
|
173
|
-
type ToastTextInput = {
|
|
174
|
-
title: string;
|
|
175
|
-
description?: string;
|
|
176
|
-
} | {
|
|
177
|
-
title?: string;
|
|
178
|
-
description: string;
|
|
179
|
-
};
|
|
180
|
-
/**
|
|
181
|
-
* Text payload with optional configuration overrides.
|
|
182
|
-
*/
|
|
183
|
-
type ToastContentInput = ToastTextInput & Partial<Omit<ToastOptions, "type" | "title" | "description">>;
|
|
184
|
-
/**
|
|
185
|
-
* Payload required to create a toast.
|
|
186
|
-
*/
|
|
187
|
-
type ToastShowInput = {
|
|
188
|
-
type: ToastType;
|
|
189
|
-
} & ToastContentInput;
|
|
190
|
-
/**
|
|
191
|
-
* Allowed fields when updating an existing toast.
|
|
192
|
-
*/
|
|
193
|
-
type ToastUpdateInput = ToastContentInput & Partial<Omit<ToastOptions, "title" | "description">>;
|
|
194
|
-
/**
|
|
195
|
-
* Render instructions for the loading helper's success/error states.
|
|
196
|
-
*/
|
|
197
|
-
type ToastLoadingRender<T> = ToastContentInput | ((value: T) => ToastContentInput);
|
|
198
|
-
/**
|
|
199
|
-
* Promise returned from the loading helper that also exposes the toast id.
|
|
200
|
-
*/
|
|
201
|
-
type ToastLoadingResult<T> = Promise<T> & {
|
|
202
|
-
toastId: ToastId;
|
|
203
|
-
};
|
|
204
|
-
/**
|
|
205
|
-
* Concrete toast stored in state, including timing metadata.
|
|
206
|
-
*/
|
|
207
|
-
interface ToastInstance extends ToastOptions {
|
|
208
|
-
id: ToastId;
|
|
209
|
-
createdAt: number;
|
|
210
|
-
phase?: ToastPhase;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Shape of the store's current state.
|
|
214
|
-
*/
|
|
215
|
-
interface ToastState {
|
|
216
|
-
toasts: ToastInstance[];
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Public API for interacting with the toast store.
|
|
220
|
-
*/
|
|
221
|
-
interface ToastStore {
|
|
222
|
-
/**
|
|
223
|
-
* Return the current toast state snapshot.
|
|
224
|
-
*/
|
|
225
|
-
getState(): ToastState;
|
|
226
|
-
/**
|
|
227
|
-
* Subscribe to state changes; immediately emits the current state.
|
|
228
|
-
*/
|
|
229
|
-
subscribe(listener: (state: ToastState) => void): () => void;
|
|
230
|
-
/**
|
|
231
|
-
* Subscribe to one-off toast events such as duplicates or timer resets.
|
|
232
|
-
*/
|
|
233
|
-
subscribeEvents(listener: (event: ToastEvent) => void): () => void;
|
|
234
|
-
/**
|
|
235
|
-
* Create and show a toast; returns its id.
|
|
236
|
-
*/
|
|
237
|
-
show(options: ToastShowInput): ToastId;
|
|
238
|
-
/**
|
|
239
|
-
* Update an existing toast by id.
|
|
240
|
-
*/
|
|
241
|
-
update(id: ToastId, options: ToastUpdateInput): void;
|
|
242
|
-
/**
|
|
243
|
-
* Dismiss a single toast by id.
|
|
244
|
-
*/
|
|
245
|
-
dismiss(id: ToastId): void;
|
|
246
|
-
/**
|
|
247
|
-
* Dismiss all toasts at once.
|
|
248
|
-
*/
|
|
249
|
-
dismissAll(): void;
|
|
250
|
-
/**
|
|
251
|
-
* Pause the auto-dismiss timer for a toast.
|
|
252
|
-
*/
|
|
253
|
-
pause(id: ToastId): void;
|
|
254
|
-
/**
|
|
255
|
-
* Resume the auto-dismiss timer using the configured strategy.
|
|
256
|
-
*/
|
|
257
|
-
resume(id: ToastId): void;
|
|
258
|
-
/**
|
|
259
|
-
* Return the resolved global configuration.
|
|
260
|
-
*/
|
|
261
|
-
getConfig(): ToastConfig;
|
|
262
|
-
/**
|
|
263
|
-
* Wrap an async task with a loading toast that updates on completion.
|
|
264
|
-
*/
|
|
265
|
-
loading<T>(input: ToastLoadingInput<T>, config: ToastLoadingConfig<T>): ToastLoadingResult<T>;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
declare function createToastStore(globalConfig?: Partial<ToastConfig>): ToastStore;
|
|
269
|
-
|
|
270
|
-
export { type PauseStrategy, type ToastAnimation, type ToastConfig, type ToastContentInput, type ToastContext, type ToastEvent, type ToastEventKind, type ToastId, type ToastInstance, type ToastLoadingConfig, type ToastLoadingInput, type ToastLoadingRender, type ToastLoadingResult, type ToastOptions, type ToastOrder, type ToastPhase, type ToastPosition, type ToastShowInput, type ToastState, type ToastStore, type ToastTextInput, type ToastType, type ToastUpdateInput, createToastStore };
|
package/dist/index.d.ts
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unique identifier assigned to each toast instance.
|
|
3
|
-
*/
|
|
4
|
-
type ToastId = string;
|
|
5
|
-
/**
|
|
6
|
-
* Supported viewport anchors where toasts can stack.
|
|
7
|
-
*/
|
|
8
|
-
type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
9
|
-
/**
|
|
10
|
-
* Order to display and evict toasts in a stack.
|
|
11
|
-
*/
|
|
12
|
-
type ToastOrder = "newest" | "oldest";
|
|
13
|
-
/**
|
|
14
|
-
* Determines how the timer behaves after an interaction pause.
|
|
15
|
-
*/
|
|
16
|
-
type PauseStrategy = "resume" | "reset";
|
|
17
|
-
/**
|
|
18
|
-
* Semantic type that controls the toast's appearance.
|
|
19
|
-
*/
|
|
20
|
-
type ToastType = "loading" | "default" | "success" | "error" | "info" | "warning";
|
|
21
|
-
/**
|
|
22
|
-
* Internal lifecycle markers used for animations and cleanup.
|
|
23
|
-
*/
|
|
24
|
-
type ToastPhase = "enter" | "leaving" | "clear-all";
|
|
25
|
-
/**
|
|
26
|
-
* Event kinds emitted to event subscribers.
|
|
27
|
-
*/
|
|
28
|
-
type ToastEventKind = "duplicate" | "timer-reset" | "update";
|
|
29
|
-
/**
|
|
30
|
-
* Payload emitted whenever the store dispatches a toast event.
|
|
31
|
-
*/
|
|
32
|
-
interface ToastEvent {
|
|
33
|
-
id: ToastId;
|
|
34
|
-
kind: ToastEventKind;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Async work passed to the loading helper.
|
|
38
|
-
*/
|
|
39
|
-
type ToastLoadingInput<T> = Promise<T> | (() => Promise<T>);
|
|
40
|
-
/**
|
|
41
|
-
* Text and rendering options for the loading helper phases.
|
|
42
|
-
*/
|
|
43
|
-
interface ToastLoadingConfig<T> {
|
|
44
|
-
loading: ToastContentInput;
|
|
45
|
-
success: ToastLoadingRender<T>;
|
|
46
|
-
error: ToastLoadingRender<unknown>;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* CSS class names used to animate toasts.
|
|
50
|
-
*/
|
|
51
|
-
interface ToastAnimation {
|
|
52
|
-
name: string;
|
|
53
|
-
bump: string;
|
|
54
|
-
clearAll: string;
|
|
55
|
-
update: string;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Minimal context shared with lifecycle and click callbacks.
|
|
59
|
-
*/
|
|
60
|
-
interface ToastContext {
|
|
61
|
-
id: ToastId;
|
|
62
|
-
position: ToastPosition;
|
|
63
|
-
type: ToastType;
|
|
64
|
-
title: string;
|
|
65
|
-
description: string;
|
|
66
|
-
createdAt: number;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Global configuration that shapes how toasts look and behave.
|
|
70
|
-
*/
|
|
71
|
-
interface ToastConfig {
|
|
72
|
-
/**
|
|
73
|
-
* Distance from the viewport edge where toasts start.
|
|
74
|
-
*/
|
|
75
|
-
offset: string;
|
|
76
|
-
/**
|
|
77
|
-
* Gap between toasts stacked at the same position.
|
|
78
|
-
*/
|
|
79
|
-
gap: string;
|
|
80
|
-
/**
|
|
81
|
-
* z-index applied to the toast container.
|
|
82
|
-
*/
|
|
83
|
-
zIndex: number;
|
|
84
|
-
/**
|
|
85
|
-
* Fixed width applied to each toast.
|
|
86
|
-
*/
|
|
87
|
-
width: string;
|
|
88
|
-
/**
|
|
89
|
-
* Time in milliseconds before a toast auto-dismisses.
|
|
90
|
-
* Use Infinity or 0 to keep it visible until manually dismissed.
|
|
91
|
-
*/
|
|
92
|
-
duration: number;
|
|
93
|
-
/**
|
|
94
|
-
* Maximum number of visible toasts per position; extra items are evicted.
|
|
95
|
-
*/
|
|
96
|
-
maxVisible: number;
|
|
97
|
-
/**
|
|
98
|
-
* Default stack position used when none is provided.
|
|
99
|
-
*/
|
|
100
|
-
position: ToastPosition;
|
|
101
|
-
/**
|
|
102
|
-
* When true, skip showing identical toasts that are still visible.
|
|
103
|
-
*/
|
|
104
|
-
preventDuplicates: boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Controls whether new toasts appear before or after older ones.
|
|
107
|
-
*/
|
|
108
|
-
order: ToastOrder;
|
|
109
|
-
/**
|
|
110
|
-
* When enabled, render a progress bar for finite durations.
|
|
111
|
-
*/
|
|
112
|
-
progressBar: boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Pause the timer while the toast is hovered.
|
|
115
|
-
*/
|
|
116
|
-
pauseOnHover: boolean;
|
|
117
|
-
/**
|
|
118
|
-
* Whether resuming should continue the remaining time or restart it.
|
|
119
|
-
*/
|
|
120
|
-
pauseStrategy: PauseStrategy;
|
|
121
|
-
/**
|
|
122
|
-
* CSS animation class overrides for various toast transitions.
|
|
123
|
-
*/
|
|
124
|
-
animation: Partial<ToastAnimation>;
|
|
125
|
-
/**
|
|
126
|
-
* Show a close button inside each toast.
|
|
127
|
-
*/
|
|
128
|
-
closeButton: boolean;
|
|
129
|
-
/**
|
|
130
|
-
* Allow closing a toast by clicking anywhere on it.
|
|
131
|
-
*/
|
|
132
|
-
closeOnClick: boolean;
|
|
133
|
-
/**
|
|
134
|
-
* When true, title/description may contain HTML.
|
|
135
|
-
*/
|
|
136
|
-
supportHtml: boolean;
|
|
137
|
-
/**
|
|
138
|
-
* Show the createdAt timestamp in the rendered toast.
|
|
139
|
-
*/
|
|
140
|
-
showCreatedAt: boolean;
|
|
141
|
-
/**
|
|
142
|
-
* Format the createdAt timestamp when displayed.
|
|
143
|
-
*/
|
|
144
|
-
createdAtFormatter: (createdAt: number) => string;
|
|
145
|
-
/**
|
|
146
|
-
* Called after the toast is added to state.
|
|
147
|
-
*/
|
|
148
|
-
onMount?(ctx: ToastContext): void;
|
|
149
|
-
/**
|
|
150
|
-
* Called after the toast is removed from state.
|
|
151
|
-
*/
|
|
152
|
-
onUnmount?(ctx: ToastContext): void;
|
|
153
|
-
/**
|
|
154
|
-
* Called when the toast is clicked.
|
|
155
|
-
*/
|
|
156
|
-
onClick?(ctx: ToastContext, event: MouseEvent): void;
|
|
157
|
-
/**
|
|
158
|
-
* Called right before a toast starts leaving.
|
|
159
|
-
*/
|
|
160
|
-
onClose?(ctx: ToastContext): void;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Fully resolved options applied to a toast instance.
|
|
164
|
-
*/
|
|
165
|
-
interface ToastOptions extends ToastConfig {
|
|
166
|
-
type: ToastType;
|
|
167
|
-
title: string;
|
|
168
|
-
description: string;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Minimal text payload required to render a toast.
|
|
172
|
-
*/
|
|
173
|
-
type ToastTextInput = {
|
|
174
|
-
title: string;
|
|
175
|
-
description?: string;
|
|
176
|
-
} | {
|
|
177
|
-
title?: string;
|
|
178
|
-
description: string;
|
|
179
|
-
};
|
|
180
|
-
/**
|
|
181
|
-
* Text payload with optional configuration overrides.
|
|
182
|
-
*/
|
|
183
|
-
type ToastContentInput = ToastTextInput & Partial<Omit<ToastOptions, "type" | "title" | "description">>;
|
|
184
|
-
/**
|
|
185
|
-
* Payload required to create a toast.
|
|
186
|
-
*/
|
|
187
|
-
type ToastShowInput = {
|
|
188
|
-
type: ToastType;
|
|
189
|
-
} & ToastContentInput;
|
|
190
|
-
/**
|
|
191
|
-
* Allowed fields when updating an existing toast.
|
|
192
|
-
*/
|
|
193
|
-
type ToastUpdateInput = ToastContentInput & Partial<Omit<ToastOptions, "title" | "description">>;
|
|
194
|
-
/**
|
|
195
|
-
* Render instructions for the loading helper's success/error states.
|
|
196
|
-
*/
|
|
197
|
-
type ToastLoadingRender<T> = ToastContentInput | ((value: T) => ToastContentInput);
|
|
198
|
-
/**
|
|
199
|
-
* Promise returned from the loading helper that also exposes the toast id.
|
|
200
|
-
*/
|
|
201
|
-
type ToastLoadingResult<T> = Promise<T> & {
|
|
202
|
-
toastId: ToastId;
|
|
203
|
-
};
|
|
204
|
-
/**
|
|
205
|
-
* Concrete toast stored in state, including timing metadata.
|
|
206
|
-
*/
|
|
207
|
-
interface ToastInstance extends ToastOptions {
|
|
208
|
-
id: ToastId;
|
|
209
|
-
createdAt: number;
|
|
210
|
-
phase?: ToastPhase;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Shape of the store's current state.
|
|
214
|
-
*/
|
|
215
|
-
interface ToastState {
|
|
216
|
-
toasts: ToastInstance[];
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Public API for interacting with the toast store.
|
|
220
|
-
*/
|
|
221
|
-
interface ToastStore {
|
|
222
|
-
/**
|
|
223
|
-
* Return the current toast state snapshot.
|
|
224
|
-
*/
|
|
225
|
-
getState(): ToastState;
|
|
226
|
-
/**
|
|
227
|
-
* Subscribe to state changes; immediately emits the current state.
|
|
228
|
-
*/
|
|
229
|
-
subscribe(listener: (state: ToastState) => void): () => void;
|
|
230
|
-
/**
|
|
231
|
-
* Subscribe to one-off toast events such as duplicates or timer resets.
|
|
232
|
-
*/
|
|
233
|
-
subscribeEvents(listener: (event: ToastEvent) => void): () => void;
|
|
234
|
-
/**
|
|
235
|
-
* Create and show a toast; returns its id.
|
|
236
|
-
*/
|
|
237
|
-
show(options: ToastShowInput): ToastId;
|
|
238
|
-
/**
|
|
239
|
-
* Update an existing toast by id.
|
|
240
|
-
*/
|
|
241
|
-
update(id: ToastId, options: ToastUpdateInput): void;
|
|
242
|
-
/**
|
|
243
|
-
* Dismiss a single toast by id.
|
|
244
|
-
*/
|
|
245
|
-
dismiss(id: ToastId): void;
|
|
246
|
-
/**
|
|
247
|
-
* Dismiss all toasts at once.
|
|
248
|
-
*/
|
|
249
|
-
dismissAll(): void;
|
|
250
|
-
/**
|
|
251
|
-
* Pause the auto-dismiss timer for a toast.
|
|
252
|
-
*/
|
|
253
|
-
pause(id: ToastId): void;
|
|
254
|
-
/**
|
|
255
|
-
* Resume the auto-dismiss timer using the configured strategy.
|
|
256
|
-
*/
|
|
257
|
-
resume(id: ToastId): void;
|
|
258
|
-
/**
|
|
259
|
-
* Return the resolved global configuration.
|
|
260
|
-
*/
|
|
261
|
-
getConfig(): ToastConfig;
|
|
262
|
-
/**
|
|
263
|
-
* Wrap an async task with a loading toast that updates on completion.
|
|
264
|
-
*/
|
|
265
|
-
loading<T>(input: ToastLoadingInput<T>, config: ToastLoadingConfig<T>): ToastLoadingResult<T>;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
declare function createToastStore(globalConfig?: Partial<ToastConfig>): ToastStore;
|
|
269
|
-
|
|
270
|
-
export { type PauseStrategy, type ToastAnimation, type ToastConfig, type ToastContentInput, type ToastContext, type ToastEvent, type ToastEventKind, type ToastId, type ToastInstance, type ToastLoadingConfig, type ToastLoadingInput, type ToastLoadingRender, type ToastLoadingResult, type ToastOptions, type ToastOrder, type ToastPhase, type ToastPosition, type ToastShowInput, type ToastState, type ToastStore, type ToastTextInput, type ToastType, type ToastUpdateInput, createToastStore };
|