vue-toast-kit 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/LICENSE +21 -0
- package/README.md +1145 -0
- package/dist/composables/useToast.d.ts +28 -0
- package/dist/composables/useToastContext.d.ts +6 -0
- package/dist/composables/useToastState.d.ts +7 -0
- package/dist/core/GroupManager.d.ts +16 -0
- package/dist/core/ToastBuffer.d.ts +19 -0
- package/dist/core/ToastQueue.d.ts +55 -0
- package/dist/core/UndoTimer.d.ts +23 -0
- package/dist/core/types.d.ts +114 -0
- package/dist/index.d.ts +23 -0
- package/dist/module.d.ts +1 -0
- package/dist/nuxt/module.cjs +2 -0
- package/dist/nuxt/module.cjs.map +1 -0
- package/dist/nuxt/module.d.ts +1 -0
- package/dist/nuxt/module.js +34 -0
- package/dist/nuxt/module.js.map +1 -0
- package/dist/plugin.d.ts +6 -0
- package/dist/style.css +1 -0
- package/dist/testing.d.ts +14 -0
- package/dist/vue-toast-kit.cjs +2 -0
- package/dist/vue-toast-kit.cjs.map +1 -0
- package/dist/vue-toast-kit.d.ts +540 -0
- package/dist/vue-toast-kit.js +1000 -0
- package/dist/vue-toast-kit.js.map +1 -0
- package/package.json +89 -0
- package/src/components/Toast.vue +222 -0
- package/src/components/ToastActions.vue +34 -0
- package/src/components/ToastContainer.vue +257 -0
- package/src/components/ToastIcon.vue +53 -0
- package/src/components/ToastProgressBar.vue +18 -0
- package/src/composables/useToast.ts +152 -0
- package/src/composables/useToastContext.ts +63 -0
- package/src/composables/useToastState.ts +18 -0
- package/src/core/GroupManager.ts +105 -0
- package/src/core/ToastBuffer.ts +45 -0
- package/src/core/ToastQueue.ts +377 -0
- package/src/core/UndoTimer.ts +90 -0
- package/src/core/types.ts +142 -0
- package/src/env.d.ts +7 -0
- package/src/index.ts +51 -0
- package/src/nuxt/composables.ts +13 -0
- package/src/nuxt/module.ts +52 -0
- package/src/nuxt/plugin.ts +8 -0
- package/src/plugin.ts +18 -0
- package/src/styles/animations.css +106 -0
- package/src/styles/base.css +201 -0
- package/src/styles/themes/dark.css +30 -0
- package/src/styles/themes/light.css +30 -0
- package/src/styles/themes/system.css +32 -0
- package/src/styles/tokens.css +74 -0
- package/src/testing.ts +81 -0
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
3
|
+
import { ComponentProvideOptions } from 'vue';
|
|
4
|
+
import { ComputedRef } from 'vue';
|
|
5
|
+
import { DefineComponent } from 'vue';
|
|
6
|
+
import { ExtractPropTypes } from 'vue';
|
|
7
|
+
import { Plugin as Plugin_2 } from 'vue';
|
|
8
|
+
import { PropType } from 'vue';
|
|
9
|
+
import { PublicProps } from 'vue';
|
|
10
|
+
import { Ref } from 'vue';
|
|
11
|
+
import { ShallowReactive } from 'vue';
|
|
12
|
+
import { VNode } from 'vue';
|
|
13
|
+
|
|
14
|
+
declare const __VLS_component: DefineComponent<ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
15
|
+
position?: ToastPosition;
|
|
16
|
+
maxVisible?: number;
|
|
17
|
+
gap?: number;
|
|
18
|
+
offsetX?: number;
|
|
19
|
+
offsetY?: number;
|
|
20
|
+
zIndex?: number;
|
|
21
|
+
expand?: boolean;
|
|
22
|
+
teleportTo?: string;
|
|
23
|
+
context?: ToastContext;
|
|
24
|
+
theme?: "light" | "dark" | "system" | ToastDesignTokens;
|
|
25
|
+
stackMode?: boolean;
|
|
26
|
+
}>, {
|
|
27
|
+
position: string;
|
|
28
|
+
maxVisible: number;
|
|
29
|
+
gap: number;
|
|
30
|
+
offsetX: number;
|
|
31
|
+
offsetY: number;
|
|
32
|
+
zIndex: number;
|
|
33
|
+
expand: boolean;
|
|
34
|
+
teleportTo: string;
|
|
35
|
+
stackMode: boolean;
|
|
36
|
+
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
37
|
+
position?: ToastPosition;
|
|
38
|
+
maxVisible?: number;
|
|
39
|
+
gap?: number;
|
|
40
|
+
offsetX?: number;
|
|
41
|
+
offsetY?: number;
|
|
42
|
+
zIndex?: number;
|
|
43
|
+
expand?: boolean;
|
|
44
|
+
teleportTo?: string;
|
|
45
|
+
context?: ToastContext;
|
|
46
|
+
theme?: "light" | "dark" | "system" | ToastDesignTokens;
|
|
47
|
+
stackMode?: boolean;
|
|
48
|
+
}>, {
|
|
49
|
+
position: string;
|
|
50
|
+
maxVisible: number;
|
|
51
|
+
gap: number;
|
|
52
|
+
offsetX: number;
|
|
53
|
+
offsetY: number;
|
|
54
|
+
zIndex: number;
|
|
55
|
+
expand: boolean;
|
|
56
|
+
teleportTo: string;
|
|
57
|
+
stackMode: boolean;
|
|
58
|
+
}>>> & Readonly<{}>, {
|
|
59
|
+
position: ToastPosition;
|
|
60
|
+
maxVisible: number;
|
|
61
|
+
gap: number;
|
|
62
|
+
offsetX: number;
|
|
63
|
+
offsetY: number;
|
|
64
|
+
zIndex: number;
|
|
65
|
+
expand: boolean;
|
|
66
|
+
teleportTo: string;
|
|
67
|
+
stackMode: boolean;
|
|
68
|
+
}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
69
|
+
|
|
70
|
+
declare const __VLS_component_2: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_2<{
|
|
71
|
+
toast: ToastItem;
|
|
72
|
+
onDismiss: (id: string) => void;
|
|
73
|
+
onGroupToggle?: (groupKey: string) => void;
|
|
74
|
+
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_2<{
|
|
75
|
+
toast: ToastItem;
|
|
76
|
+
onDismiss: (id: string) => void;
|
|
77
|
+
onGroupToggle?: (groupKey: string) => void;
|
|
78
|
+
}>>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
79
|
+
|
|
80
|
+
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
81
|
+
|
|
82
|
+
declare type __VLS_NonUndefinedable_2<T> = T extends undefined ? never : T;
|
|
83
|
+
|
|
84
|
+
declare type __VLS_NonUndefinedable_3<T> = T extends undefined ? never : T;
|
|
85
|
+
|
|
86
|
+
declare type __VLS_NonUndefinedable_4<T> = T extends undefined ? never : T;
|
|
87
|
+
|
|
88
|
+
declare type __VLS_NonUndefinedable_5<T> = T extends undefined ? never : T;
|
|
89
|
+
|
|
90
|
+
declare type __VLS_Prettify<T> = {
|
|
91
|
+
[K in keyof T]: T[K];
|
|
92
|
+
} & {};
|
|
93
|
+
|
|
94
|
+
declare function __VLS_template(): Readonly<{
|
|
95
|
+
toast(props: {
|
|
96
|
+
toast: ToastItem;
|
|
97
|
+
dismiss: (id: string) => void;
|
|
98
|
+
}): void;
|
|
99
|
+
'toast-icon'(props: {
|
|
100
|
+
toast: ToastItem;
|
|
101
|
+
}): void;
|
|
102
|
+
'toast-content'(props: {
|
|
103
|
+
toast: ToastItem;
|
|
104
|
+
}): void;
|
|
105
|
+
'toast-action'(props: {
|
|
106
|
+
toast: ToastItem;
|
|
107
|
+
}): void;
|
|
108
|
+
'toast-close'(props: {
|
|
109
|
+
toast: ToastItem;
|
|
110
|
+
dismiss: (id: string) => void;
|
|
111
|
+
}): void;
|
|
112
|
+
'toast-undo'(props: {
|
|
113
|
+
toast: ToastItem;
|
|
114
|
+
remaining: number;
|
|
115
|
+
}): void;
|
|
116
|
+
}> & {
|
|
117
|
+
toast(props: {
|
|
118
|
+
toast: ToastItem;
|
|
119
|
+
dismiss: (id: string) => void;
|
|
120
|
+
}): void;
|
|
121
|
+
'toast-icon'(props: {
|
|
122
|
+
toast: ToastItem;
|
|
123
|
+
}): void;
|
|
124
|
+
'toast-content'(props: {
|
|
125
|
+
toast: ToastItem;
|
|
126
|
+
}): void;
|
|
127
|
+
'toast-action'(props: {
|
|
128
|
+
toast: ToastItem;
|
|
129
|
+
}): void;
|
|
130
|
+
'toast-close'(props: {
|
|
131
|
+
toast: ToastItem;
|
|
132
|
+
dismiss: (id: string) => void;
|
|
133
|
+
}): void;
|
|
134
|
+
'toast-undo'(props: {
|
|
135
|
+
toast: ToastItem;
|
|
136
|
+
remaining: number;
|
|
137
|
+
}): void;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
declare function __VLS_template_2(): {
|
|
141
|
+
"toast-icon"?(_: {
|
|
142
|
+
toast: ToastItem;
|
|
143
|
+
}): any;
|
|
144
|
+
"toast-content"?(_: {
|
|
145
|
+
toast: ToastItem;
|
|
146
|
+
}): any;
|
|
147
|
+
"toast-action"?(_: {
|
|
148
|
+
toast: ToastItem;
|
|
149
|
+
}): any;
|
|
150
|
+
"toast-close"?(_: {
|
|
151
|
+
toast: ToastItem;
|
|
152
|
+
dismiss: typeof dismissWithFocusReturn;
|
|
153
|
+
}): any;
|
|
154
|
+
"toast-undo"?(_: {
|
|
155
|
+
toast: ToastItem;
|
|
156
|
+
remaining: number;
|
|
157
|
+
}): any;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
161
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
162
|
+
type: PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
163
|
+
} : {
|
|
164
|
+
type: PropType<T[K]>;
|
|
165
|
+
required: true;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
declare type __VLS_TypePropsToRuntimeProps_2<T> = {
|
|
170
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
171
|
+
type: PropType<__VLS_NonUndefinedable_2<T[K]>>;
|
|
172
|
+
} : {
|
|
173
|
+
type: PropType<T[K]>;
|
|
174
|
+
required: true;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
declare type __VLS_TypePropsToRuntimeProps_3<T> = {
|
|
179
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
180
|
+
type: PropType<__VLS_NonUndefinedable_3<T[K]>>;
|
|
181
|
+
} : {
|
|
182
|
+
type: PropType<T[K]>;
|
|
183
|
+
required: true;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
declare type __VLS_TypePropsToRuntimeProps_4<T> = {
|
|
188
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
189
|
+
type: PropType<__VLS_NonUndefinedable_4<T[K]>>;
|
|
190
|
+
} : {
|
|
191
|
+
type: PropType<T[K]>;
|
|
192
|
+
required: true;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
declare type __VLS_TypePropsToRuntimeProps_5<T> = {
|
|
197
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
198
|
+
type: PropType<__VLS_NonUndefinedable_5<T[K]>>;
|
|
199
|
+
} : {
|
|
200
|
+
type: PropType<T[K]>;
|
|
201
|
+
required: true;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
declare type __VLS_WithDefaults<P, D> = {
|
|
206
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
207
|
+
default: D[K];
|
|
208
|
+
}> : P[K];
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
212
|
+
new (): {
|
|
213
|
+
$slots: S;
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
declare type __VLS_WithTemplateSlots_2<T, S> = T & {
|
|
218
|
+
new (): {
|
|
219
|
+
$slots: S;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
declare interface BufferedToast {
|
|
224
|
+
message: string | VNode;
|
|
225
|
+
options: ToastOptions;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
declare function buildToastApi(ctx: ToastContext): {
|
|
229
|
+
(message: string, options?: ToastOptions): string;
|
|
230
|
+
success(message: string, options?: ToastOptions): string;
|
|
231
|
+
error(message: string, options?: ToastOptions): string;
|
|
232
|
+
warning(message: string, options?: ToastOptions): string;
|
|
233
|
+
info(message: string, options?: ToastOptions): string;
|
|
234
|
+
loading(message: string, options?: ToastOptions): string;
|
|
235
|
+
custom(component: Component, options?: ToastOptions): string;
|
|
236
|
+
dismiss(id?: string): void;
|
|
237
|
+
update(id: string, partial: Partial<ToastOptions> & {
|
|
238
|
+
message?: string | VNode;
|
|
239
|
+
}): void;
|
|
240
|
+
updateMessage(id: string, message: string | VNode): void;
|
|
241
|
+
isActive(id: string): boolean;
|
|
242
|
+
promise<T>(promise: Promise<T>, messages: PromiseToastMessages<T>, options?: ToastOptions): Promise<T>;
|
|
243
|
+
undo(message: string, options: ToastOptions & {
|
|
244
|
+
undo: NonNullable<ToastOptions["undo"]>;
|
|
245
|
+
}): string;
|
|
246
|
+
dismissAll(position?: ToastPosition): void;
|
|
247
|
+
pauseAll(): void;
|
|
248
|
+
resumeAll(): void;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export declare function createToastContext(opts?: GlobalToastOptions): ToastContext;
|
|
252
|
+
|
|
253
|
+
export declare const DEFAULT_OPTIONS: Required<Omit<ToastOptions, 'id' | 'component' | 'componentProps' | 'icon' | 'action' | 'undo' | 'groupKey' | 'theme' | 'onClose' | 'onAutoClose' | 'ariaLive' | 'position'>>;
|
|
254
|
+
|
|
255
|
+
declare function dismissWithFocusReturn(id: string): void;
|
|
256
|
+
|
|
257
|
+
declare type EventListener_2<T extends unknown[]> = (...args: T) => void;
|
|
258
|
+
|
|
259
|
+
export declare function getOrCreateGlobalContext(opts?: GlobalToastOptions): ToastContext;
|
|
260
|
+
|
|
261
|
+
export declare const globalBuffer: ToastBuffer;
|
|
262
|
+
|
|
263
|
+
export declare interface GlobalToastOptions {
|
|
264
|
+
position?: ToastPosition;
|
|
265
|
+
maxVisible?: number;
|
|
266
|
+
duration?: number;
|
|
267
|
+
theme?: 'light' | 'dark' | 'system';
|
|
268
|
+
ignoreSSR?: boolean;
|
|
269
|
+
pauseOnHover?: boolean;
|
|
270
|
+
pauseOnFocusLoss?: boolean;
|
|
271
|
+
closable?: boolean;
|
|
272
|
+
/** Max toasts added within rateLimitWindowMs before extras are dropped. */
|
|
273
|
+
rateLimit?: number;
|
|
274
|
+
/** Window in ms for rateLimit (default: 1000). */
|
|
275
|
+
rateLimitWindowMs?: number;
|
|
276
|
+
/** Enable automatic localStorage persist/restore for toasts with persist:true. */
|
|
277
|
+
persistStorage?: boolean;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export declare class GroupManager {
|
|
281
|
+
private groups;
|
|
282
|
+
private expandedGroups;
|
|
283
|
+
private getItems;
|
|
284
|
+
private hideItem;
|
|
285
|
+
private showItem;
|
|
286
|
+
constructor(getItems: (ids: string[]) => ToastItem[], hideItem: (id: string) => void, showItem: (id: string) => void);
|
|
287
|
+
add(id: string, groupKey: string): void;
|
|
288
|
+
remove(id: string, groupKey: string): void;
|
|
289
|
+
toggleExpand(groupKey: string): void;
|
|
290
|
+
isExpanded(groupKey: string): boolean;
|
|
291
|
+
getGroupIds(groupKey: string): string[];
|
|
292
|
+
hasGroup(groupKey: string): boolean;
|
|
293
|
+
clear(): void;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export declare const isServer: boolean;
|
|
297
|
+
|
|
298
|
+
export declare const PRIORITY_ORDER: Record<ToastPriority, number>;
|
|
299
|
+
|
|
300
|
+
export declare interface PromiseToastMessages<T = unknown> {
|
|
301
|
+
loading: string;
|
|
302
|
+
success: string | ((data: T) => string);
|
|
303
|
+
error: string | ((err: unknown) => string);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export declare const Toast: __VLS_WithTemplateSlots_2<typeof __VLS_component_2, ReturnType<typeof __VLS_template_2>>;
|
|
307
|
+
|
|
308
|
+
export declare const toast: ToastApi;
|
|
309
|
+
|
|
310
|
+
export declare const TOAST_CONTEXT_KEY: unique symbol;
|
|
311
|
+
|
|
312
|
+
export declare interface ToastAction {
|
|
313
|
+
label: string;
|
|
314
|
+
onClick: () => void;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export declare const ToastActions: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_5<{
|
|
318
|
+
toast: ToastItem;
|
|
319
|
+
onDismiss: (id: string) => void;
|
|
320
|
+
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_5<{
|
|
321
|
+
toast: ToastItem;
|
|
322
|
+
onDismiss: (id: string) => void;
|
|
323
|
+
}>>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
324
|
+
|
|
325
|
+
export declare type ToastApi = ReturnType<typeof buildToastApi>;
|
|
326
|
+
|
|
327
|
+
declare class ToastBuffer {
|
|
328
|
+
private buffer;
|
|
329
|
+
private flushed;
|
|
330
|
+
private flushCallbacks;
|
|
331
|
+
push(message: string | VNode, options: ToastOptions): void;
|
|
332
|
+
onFlush(cb: (items: BufferedToast[]) => void): void;
|
|
333
|
+
flush(): void;
|
|
334
|
+
isFlushed(): boolean;
|
|
335
|
+
get size(): number;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export declare const ToastContainer: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
339
|
+
|
|
340
|
+
export declare interface ToastContext {
|
|
341
|
+
queue: ToastQueue;
|
|
342
|
+
addToast(message: string | VNode, options?: ToastOptions): string;
|
|
343
|
+
dismiss(id?: string): void;
|
|
344
|
+
update(id: string, options: Partial<ToastOptions>): void;
|
|
345
|
+
isActive(id: string): boolean;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export declare interface ToastDesignTokens {
|
|
349
|
+
colorBg?: string;
|
|
350
|
+
colorText?: string;
|
|
351
|
+
colorBorder?: string;
|
|
352
|
+
colorSuccess?: string;
|
|
353
|
+
colorError?: string;
|
|
354
|
+
colorWarning?: string;
|
|
355
|
+
colorInfo?: string;
|
|
356
|
+
colorLoading?: string;
|
|
357
|
+
fontFamily?: string;
|
|
358
|
+
fontSize?: string;
|
|
359
|
+
fontWeight?: string;
|
|
360
|
+
lineHeight?: string;
|
|
361
|
+
borderRadius?: string;
|
|
362
|
+
borderWidth?: string;
|
|
363
|
+
shadow?: string;
|
|
364
|
+
paddingX?: string;
|
|
365
|
+
paddingY?: string;
|
|
366
|
+
iconSize?: string;
|
|
367
|
+
progressHeight?: string;
|
|
368
|
+
maxWidth?: string;
|
|
369
|
+
minWidth?: string;
|
|
370
|
+
transitionDuration?: string;
|
|
371
|
+
transitionEasing?: string;
|
|
372
|
+
zIndex?: string;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export declare const ToastIcon: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_3<{
|
|
376
|
+
type: ToastType;
|
|
377
|
+
icon?: Component | string | false;
|
|
378
|
+
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_3<{
|
|
379
|
+
type: ToastType;
|
|
380
|
+
icon?: Component | string | false;
|
|
381
|
+
}>>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
382
|
+
|
|
383
|
+
export declare interface ToastItem {
|
|
384
|
+
id: string;
|
|
385
|
+
message: string | VNode;
|
|
386
|
+
options: Required<Omit<ToastOptions, 'component' | 'componentProps' | 'icon' | 'action' | 'undo' | 'theme' | 'position'>> & {
|
|
387
|
+
position?: ToastPosition;
|
|
388
|
+
component?: Component;
|
|
389
|
+
componentProps?: Record<string, unknown>;
|
|
390
|
+
icon?: Component | string | false;
|
|
391
|
+
action?: ToastAction;
|
|
392
|
+
undo?: ToastUndo;
|
|
393
|
+
theme?: 'light' | 'dark' | 'system' | ToastDesignTokens;
|
|
394
|
+
};
|
|
395
|
+
createdAt: number;
|
|
396
|
+
remaining: Ref<number>;
|
|
397
|
+
isPaused: Ref<boolean>;
|
|
398
|
+
groupCount: Ref<number>;
|
|
399
|
+
isGrouped: Ref<boolean>;
|
|
400
|
+
pause(): void;
|
|
401
|
+
resume(): void;
|
|
402
|
+
dismiss(): void;
|
|
403
|
+
update(opts: Partial<ToastOptions>): void;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
export declare interface ToastOptions {
|
|
407
|
+
id?: string;
|
|
408
|
+
type?: ToastType;
|
|
409
|
+
priority?: ToastPriority;
|
|
410
|
+
duration?: number;
|
|
411
|
+
position?: ToastPosition;
|
|
412
|
+
closable?: boolean;
|
|
413
|
+
groupKey?: string;
|
|
414
|
+
icon?: Component | string | false;
|
|
415
|
+
action?: ToastAction;
|
|
416
|
+
undo?: ToastUndo;
|
|
417
|
+
onClose?: () => void;
|
|
418
|
+
onAutoClose?: () => void;
|
|
419
|
+
pauseOnHover?: boolean;
|
|
420
|
+
pauseOnFocusLoss?: boolean;
|
|
421
|
+
swipeToDismiss?: boolean;
|
|
422
|
+
persist?: boolean;
|
|
423
|
+
component?: Component;
|
|
424
|
+
componentProps?: Record<string, unknown>;
|
|
425
|
+
ariaLive?: 'assertive' | 'polite';
|
|
426
|
+
theme?: 'light' | 'dark' | 'system' | ToastDesignTokens;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export declare type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
430
|
+
|
|
431
|
+
export declare type ToastPriority = 'critical' | 'high' | 'normal' | 'low';
|
|
432
|
+
|
|
433
|
+
export declare const ToastProgressBar: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_4<{
|
|
434
|
+
remaining: number;
|
|
435
|
+
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_4<{
|
|
436
|
+
remaining: number;
|
|
437
|
+
}>>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
438
|
+
|
|
439
|
+
export declare class ToastQueue {
|
|
440
|
+
active: ShallowReactive<ToastItem[]>;
|
|
441
|
+
pending: ShallowReactive<ToastItem[]>;
|
|
442
|
+
private maxVisible;
|
|
443
|
+
private hiddenItems;
|
|
444
|
+
private timers;
|
|
445
|
+
private groupManager;
|
|
446
|
+
private rateLimit;
|
|
447
|
+
private rateLimitWindowMs;
|
|
448
|
+
private recentAddTimes;
|
|
449
|
+
private persistStorage;
|
|
450
|
+
private addListeners;
|
|
451
|
+
private dismissListeners;
|
|
452
|
+
private updateListeners;
|
|
453
|
+
constructor(maxVisible?: number, options?: {
|
|
454
|
+
rateLimit?: number;
|
|
455
|
+
rateLimitWindowMs?: number;
|
|
456
|
+
persistStorage?: boolean;
|
|
457
|
+
});
|
|
458
|
+
/** Subscribe to toast add events. Returns an unsubscribe function. */
|
|
459
|
+
onAdd(fn: EventListener_2<[ToastItem]>): () => void;
|
|
460
|
+
/** Subscribe to toast dismiss events. Returns an unsubscribe function. */
|
|
461
|
+
onDismiss(fn: EventListener_2<[string]>): () => void;
|
|
462
|
+
/** Subscribe to toast update events. Returns an unsubscribe function. */
|
|
463
|
+
onUpdate(fn: EventListener_2<[string, Partial<ToastOptions>]>): () => void;
|
|
464
|
+
private emit;
|
|
465
|
+
private isRateLimited;
|
|
466
|
+
private restoreFromStorage;
|
|
467
|
+
private saveToStorage;
|
|
468
|
+
private removeFromStorage;
|
|
469
|
+
get visibleActive(): ToastItem[];
|
|
470
|
+
isHidden(id: string): boolean;
|
|
471
|
+
add(message: string | VNode, options?: ToastOptions): string;
|
|
472
|
+
remove(id: string): void;
|
|
473
|
+
update(id: string, partial: Partial<ToastOptions>): void;
|
|
474
|
+
dismiss(id?: string): void;
|
|
475
|
+
dismissAll(position?: ToastPosition): void;
|
|
476
|
+
isActive(id: string): boolean;
|
|
477
|
+
pauseAll(): void;
|
|
478
|
+
resumeAll(): void;
|
|
479
|
+
setMaxVisible(n: number): void;
|
|
480
|
+
toggleGroupExpand(groupKey: string): void;
|
|
481
|
+
isGroupExpanded(groupKey: string): boolean;
|
|
482
|
+
destroy(): void;
|
|
483
|
+
private createItem;
|
|
484
|
+
private startTimer;
|
|
485
|
+
private stopTimer;
|
|
486
|
+
private mergeOptions;
|
|
487
|
+
private findLowestPriorityIndex;
|
|
488
|
+
private sortPending;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export declare type ToastType = 'info' | 'success' | 'warning' | 'error' | 'loading' | 'custom';
|
|
492
|
+
|
|
493
|
+
export declare interface ToastUndo {
|
|
494
|
+
label?: string;
|
|
495
|
+
onUndo: () => void | Promise<void>;
|
|
496
|
+
duration?: number;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
export declare class UndoTimer {
|
|
500
|
+
private timerId;
|
|
501
|
+
private tickId;
|
|
502
|
+
private elapsed;
|
|
503
|
+
private startTime;
|
|
504
|
+
private _remaining;
|
|
505
|
+
private _isPaused;
|
|
506
|
+
private static readonly TICK_INTERVAL;
|
|
507
|
+
readonly duration: number;
|
|
508
|
+
readonly onExpire: () => void;
|
|
509
|
+
readonly onTick?: (remaining: number) => void;
|
|
510
|
+
constructor(duration: number, onExpire: () => void, onTick?: (remaining: number) => void);
|
|
511
|
+
get remaining(): number;
|
|
512
|
+
get isPaused(): boolean;
|
|
513
|
+
start(): void;
|
|
514
|
+
pause(): void;
|
|
515
|
+
resume(): void;
|
|
516
|
+
destroy(): void;
|
|
517
|
+
private scheduleExpiry;
|
|
518
|
+
private clearExpiry;
|
|
519
|
+
private startTick;
|
|
520
|
+
private clearTick;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
export declare function useToast(context?: ToastContext): ToastApi;
|
|
524
|
+
|
|
525
|
+
export declare function useToastContext(): ToastContext;
|
|
526
|
+
|
|
527
|
+
export declare function useToastState(context?: ToastContext): {
|
|
528
|
+
active: ComputedRef<ToastItem[]>;
|
|
529
|
+
pending: ComputedRef<ToastItem[]>;
|
|
530
|
+
count: ComputedRef<number>;
|
|
531
|
+
has: (id: string) => boolean;
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
export declare const VueToastPlugin: Plugin_2<VueToastPluginOptions | void>;
|
|
535
|
+
|
|
536
|
+
export declare interface VueToastPluginOptions extends GlobalToastOptions {
|
|
537
|
+
registerComponent?: boolean;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
export { }
|