UNPKG

@progressive-development/pd-page

Version:

Progressive development page helper, teaser, menu, footer.

61 lines 1.98 kB
/** * ToastBus - Simple event bus for toast notifications * * Provides a global singleton for triggering toasts from anywhere * (services, components, effects) without DOM dependencies. * * @example * ```typescript * import { toastBus } from "@progressive-development/pd-page"; * * // Show different toast types * toastBus.success("Saved successfully!"); * toastBus.error("An error occurred"); * toastBus.info("Information", 3000); * * // Or use the generic show method * toastBus.show("Custom message", "info", 5000); * ``` */ /** Toast notification type */ export type ToastType = "success" | "error" | "info"; /** Toast event detail */ export interface ToastDetail { /** Message to display */ message: string; /** Toast type (success, error, info) */ type: ToastType; /** Duration in ms. -1 for persistent (no auto-close) */ duration?: number; } declare class ToastBus extends EventTarget { /** * Show a toast notification * @param message - Message to display * @param type - Toast type (default: "info") * @param duration - Duration in ms (default: component default, -1 for persistent) */ show(message: string, type?: ToastType, duration?: number): void; /** * Show a success toast * @param message - Message to display * @param duration - Duration in ms (optional) */ success(message: string, duration?: number): void; /** * Show an error toast (persistent by default) * @param message - Message to display * @param duration - Duration in ms (default: -1 for persistent) */ error(message: string, duration?: number): void; /** * Show an info toast * @param message - Message to display * @param duration - Duration in ms (optional) */ info(message: string, duration?: number): void; } /** Global toast bus singleton */ export declare const toastBus: ToastBus; export {}; //# sourceMappingURL=toast-bus.d.ts.map