UNPKG

infinity-ui-elements

Version:

A React TypeScript component library with Tailwind CSS design system

79 lines 2.13 kB
import * as React from "react"; import { ToastProps } from "./Toast"; export interface ToastOptions extends Omit<ToastProps, "isVisible" | "id"> { /** * Unique identifier for the toast (auto-generated if not provided) */ id?: string; } export interface ToastInstance extends ToastOptions { id: string; isVisible: boolean; } interface ToastContextType { /** * Show an information toast */ showToast: (options: ToastOptions) => string; /** * Show a success toast (shorthand for positive intent) */ success: (message: string, options?: Partial<ToastOptions>) => string; /** * Show an error toast (shorthand for negative intent) */ error: (message: string, options?: Partial<ToastOptions>) => string; /** * Show a warning toast (shorthand for notice intent) */ warning: (message: string, options?: Partial<ToastOptions>) => string; /** * Show an info toast (shorthand for info intent) */ info: (message: string, options?: Partial<ToastOptions>) => string; /** * Show a promotional toast */ promotional: (heading: string, description: string, options?: Partial<ToastOptions>) => string; /** * Dismiss a specific toast by ID */ dismiss: (id: string) => void; /** * Dismiss all toasts */ dismissAll: () => void; } export interface ToastProviderProps { children: React.ReactNode; /** * Maximum number of toasts to display at once * @default 5 */ maxToasts?: number; /** * Default duration for information toasts in milliseconds * @default 5000 */ defaultDuration?: number; } export declare const ToastProvider: React.FC<ToastProviderProps>; /** * Hook to access toast functionality * * @example * ```tsx * function MyComponent() { * const toast = useToast(); * * return ( * <button onClick={() => toast.success("Saved successfully!")}> * Save * </button> * ); * } * ``` */ export declare const useToast: () => ToastContextType; export {}; //# sourceMappingURL=ToastProvider.d.ts.map