/** * The **Toast Service** — the public entry point of Photon Grid's toast * notification system and the orchestrator that ties together the * {@link ToastQueueManager} (visibility scheduling), {@link ToastContainer} * (viewport regions), {@link ToastAnimationManager} (enter/exit) and per-toast * {@link ToastComponent}s. * * It is dependency-free and framework-agnostic: construct it standalone * (`new ToastService()`) or let a grid provide its shared icon renderer and a * scoped host. It is also SSR-safe — with no `document` present, show calls * become inert no-ops that still return a valid (inactive) handle. * * @example * ```ts * const toasts = new ToastService({ position: ToastPosition.BottomRight }); * toasts.success('Saved!'); * const h = toasts.error('Upload failed', { action: { label: 'Retry', onClick: retry } }); * h.update({ message: 'Still trying…' }); * h.dismiss(); * ``` * * @packageDocumentation */ import { IconRenderer } from '../icons/icon-renderer'; import { ToastPosition, type ToastHandle, type ToastOptions, type ToastServiceConfig, type ToastServiceConfigInput } from './toast.types'; /** Built-in defaults, overridable via the constructor or {@link ToastService.configure}. */ export declare const DEFAULT_TOAST_CONFIG: ToastServiceConfig; /** Optional collaborators — a grid passes its shared renderer and a scoped host. */ export interface ToastServiceDeps { /** Icon renderer to reuse (else a default core-icon renderer is created). */ readonly iconRenderer?: IconRenderer; /** Host element for the toast layer (default `document.body`). */ readonly host?: HTMLElement; /** * Any element inside the owning grid — normally its container. When given, the * toast layer mounts into that grid's portal host instead of `document.body`, * so toasts wear the grid's mode and variant on a page with several * differently-themed grids. Resolved lazily on the first toast, because the * host does not exist until the grid's theme has been applied. * * Ignored when {@link host} is set explicitly. */ readonly owner?: HTMLElement; } /** Orchestrates the toast subsystem and exposes the public API. */ export declare class ToastService { private config; private readonly iconRenderer; private readonly host; /** Owning grid element, resolved to a portal host on first use. */ private readonly owner; private readonly queue; private readonly animation; private container; private readonly components; private readonly positions; private readonly dedupe; private idCounter; private destroyed; constructor(config?: ToastServiceConfigInput, deps?: ToastServiceDeps); /** Merges a partial configuration and propagates it to the subsystems. */ configure(patch: ToastServiceConfigInput): void; /** A copy of the current resolved configuration. */ getConfig(): ToastServiceConfig; /** * Shows a toast. * * @param options - The toast content and per-toast overrides. * @returns A handle to control the toast (dismiss/update/isActive). */ show(options: ToastOptions): ToastHandle; /** Shows a success toast. */ success(message: string, options?: Omit): ToastHandle; /** Shows an error toast (assertive by default). */ error(message: string, options?: Omit): ToastHandle; /** Shows a warning toast. */ warning(message: string, options?: Omit): ToastHandle; /** Shows an info toast. */ info(message: string, options?: Omit): ToastHandle; /** * Shows a persistent loading toast (spinner, no auto-dismiss). Update its * handle to a terminal type/duration when the work finishes. */ loading(message: string, options?: Omit): ToastHandle; /** Dismisses a toast by id. */ dismiss(id: string): void; /** * Dismisses every live toast, or every toast at a single position. * * @param position - Restrict to this position; omit to clear all positions. */ dismissAll(position?: ToastPosition): void; /** Tears down the entire subsystem (timers, DOM, bookkeeping). */ destroy(): void; /** Mounts a component and plays its enter animation, then starts its timer. */ private mountAndEnter; /** Shared dismissal path for every reason. */ private dismissInternal; /** Removes any dedupe entry pointing at the given id. */ private dropDedupe; /** Merges options with config defaults into fully-resolved settings. */ private resolve; /** * Lazily creates the container once a DOM host is available. * * The host is resolved here rather than in the constructor: a grid's portal * host is created when its theme is applied, which happens after the service * itself is constructed. */ private ensureContainer; /** Builds a self-contained core-icon renderer for standalone use. */ private static createDefaultIconRenderer; } //# sourceMappingURL=toast-service.d.ts.map