UNPKG

2.13 kBTypeScriptView Raw
1import { Id, IdOpts, ToastContent, ToastOptions, UpdateOptions } from '../types';
2import { isToastActive } from './store';
3declare function toast<TData = unknown>(content: ToastContent<TData>, options?: ToastOptions<TData>): Id;
4declare namespace toast {
5 var loading: <TData = unknown>(content: ToastContent<TData>, options?: ToastOptions<TData> | undefined) => Id;
6 var promise: typeof handlePromise;
7 var success: <TData = unknown>(content: ToastContent<TData>, options?: ToastOptions<TData> | undefined) => Id;
8 var info: <TData = unknown>(content: ToastContent<TData>, options?: ToastOptions<TData> | undefined) => Id;
9 var error: <TData = unknown>(content: ToastContent<TData>, options?: ToastOptions<TData> | undefined) => Id;
10 var warning: <TData = unknown>(content: ToastContent<TData>, options?: ToastOptions<TData> | undefined) => Id;
11 var warn: <TData = unknown>(content: ToastContent<TData>, options?: ToastOptions<TData> | undefined) => Id;
12 var dark: (content: ToastContent, options?: ToastOptions<unknown> | undefined) => Id;
13 var dismiss: {
14 (params: RemoveParams): void;
15 (params?: Id | undefined): void;
16 };
17 var clearWaitingQueue: typeof import("./store").clearWaitingQueue;
18 var isActive: typeof isToastActive;
19 var update: <TData = unknown>(toastId: Id, options?: UpdateOptions<TData>) => void;
20 var done: (id: Id) => void;
21 var onChange: typeof import("./store").onChange;
22 var play: (opts?: IdOpts | undefined) => void;
23 var pause: (opts?: IdOpts | undefined) => void;
24}
25export interface ToastPromiseParams<TData = unknown, TError = unknown, TPending = unknown> {
26 pending?: string | UpdateOptions<TPending>;
27 success?: string | UpdateOptions<TData>;
28 error?: string | UpdateOptions<TError>;
29}
30declare function handlePromise<TData = unknown, TError = unknown, TPending = unknown>(promise: Promise<TData> | (() => Promise<TData>), { pending, error, success }: ToastPromiseParams<TData, TError, TPending>, options?: ToastOptions<TData>): Promise<TData>;
31interface RemoveParams {
32 id?: Id;
33 containerId: Id;
34}
35export { toast };