/** * The following code is borrowed from @react-stately/toast@3.1.2 * Only some type errors (due to less strictness level in the original code) are fixed. * permalink: https://github.com/adobe/react-spectrum/blob/d9292a9ed6c8b7bebdd56bd094f9d1dbe089f83a/packages/%40react-stately/toast/src/useToastState.ts#L86 */ type ToastAction = 'add' | 'remove' | 'clear'; export interface ToastStateProps { /** The maximum number of toasts to display at a time. */ maxVisibleToasts?: number; /** Function to wrap updates in (i.e. document.startViewTransition()). */ wrapUpdate?: (fn: () => void, action: ToastAction) => void; } export interface ToastOptions { /** Handler that is called when the toast is closed, either by the user or after a timeout. */ onClose?: () => void; /** A timeout to automatically close the toast after, in milliseconds. */ timeout?: number; } export interface QueuedToast extends ToastOptions { /** The content of the toast. */ content: T; /** A unique key for the toast. */ key: string; /** A timer for the toast, if a timeout was set. */ timer?: Timer; } export declare class ToastQueue { private queue; private subscriptions; private maxVisibleToasts; private wrapUpdate?; /** The currently visible toasts. */ visibleToasts: QueuedToast[]; constructor(options?: ToastStateProps); private runWithWrapUpdate; /** Subscribes to updates to the visible toasts. */ subscribe(fn: () => void): () => void; /** Adds a new toast to the queue. */ add(content: T, options?: ToastOptions): string; /** * Closes a toast. */ close(key: string): void; private updateVisibleToasts; /** Pauses the timers for all visible toasts. */ pauseAll(): void; /** Resumes the timers for all visible toasts. */ resumeAll(): void; clear(): void; } declare class Timer { private timerId; private startTime; private remaining; private callback; constructor(callback: () => void, delay: number); reset(delay: number): void; pause(): void; resume(): void; } export {};