import type { ReactNode } from 'react'; import type { SxProp } from '../Layout/sx.cjs'; export type ToastVariant = 'default' | 'success' | 'info' | 'warning' | 'danger' | 'loading'; export type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'; /** Declarative action (e.g. Undo). Clicking runs `onClick`, then dismisses the toast. */ export interface ToastActionConfig { label: ReactNode; onClick: () => void; } export interface ToastOptions { /** Visible title. Required unless `description` is supplied. */ title?: ReactNode; /** Optional secondary line under the title. */ description?: ReactNode; /** * Right-side action. A node (typically a Button), or `{ label, onClick }` for * a ready-made action such as Undo that also dismisses the toast. */ action?: ReactNode | ToastActionConfig; /** Override the default icon. Pass `false` to hide the icon. */ icon?: ReactNode | false; /** Variant — drives color, icon, and ARIA role. */ variant?: ToastVariant; /** ms before auto-dismiss. Pass `Infinity` (or a negative number) to keep open until dismissed. */ duration?: number; /** Fires when the toast disappears (auto or manual). */ onDismiss?: () => void; /** Stable identifier — supply when calling `update(id, …)`. */ id?: string; /** Hide the close button. */ dismissible?: boolean; /** * One-off CSS for this toast's root, same as `Box`'s `sx`: each value may be a * scalar or a responsive breakpoint map (`{ base, sm, md, lg, xl }`). * Scalar-only sx merges into inline style; responsive sx injects a scoped class. */ sx?: SxProp; } export interface ToastInstance extends Required> { id: string; title?: ReactNode; description?: ReactNode; action?: ReactNode | ToastActionConfig; icon?: ReactNode | false; onDismiss?: () => void; sx?: SxProp; /** Internal — flips to true when entering exit animation. */ exiting?: boolean; } export interface ToastFunction { (opts: ToastOptions | string): string; success: (title: ReactNode, opts?: Omit) => string; info: (title: ReactNode, opts?: Omit) => string; warning: (title: ReactNode, opts?: Omit) => string; error: (title: ReactNode, opts?: Omit) => string; loading: (title: ReactNode, opts?: Omit) => string; } export interface ToastApi { toast: ToastFunction; dismiss: (id?: string) => void; update: (id: string, opts: Partial) => void; } export interface ToastProviderProps { children: ReactNode; /** Where the toast viewport renders. Default `bottom-right`. */ position?: ToastPosition; /** Default duration (ms) when individual toasts don't specify one. Default 5000. */ defaultDuration?: number; /** Max number of toasts visible at once; older ones drop off. Default 5. */ maxToasts?: number; /** Stack cap — alias of `maxToasts`; wins when both are set. */ limit?: number; /** Distance from the viewport edges. Default `1rem`. */ offset?: string; }