import type { IPortalElementProps } from '../../Primitives/Portal/IPortalElementProps'; import { PortalElement } from '../../Primitives/Portal/PortalElement'; import type { PortalProjectionElement } from '../../Primitives/Portal/PortalProjectionElement'; import type { IToastElementProps } from './IToastElementProps'; import { ToastElement } from './ToastElement'; import type { IToastServiceConfig } from './IToastServiceConfig'; /** * Function type for resolving toast results. * * @public */ export type ToastResolveFunction = (result?: unknown) => void; /** * Represents the `IToastRef` interface. * * @public */ export interface IToastRef { toastId: string; toastElement: ToastElement; portalElement: PortalElement; portalProjectionElement: PortalProjectionElement; options?: IToastOptions; resolve?: ToastResolveFunction; } /** * Represents the `ToastService` options interface. * * @public */ export interface IToastOptions extends Partial, Partial { id?: string; navigateToClose?: boolean; } /** * Represents the `Toast` constant. * * @public */ export declare namespace Toast { namespace Timeout { /** * The duration of a short (1500ms) toast message. * * @public * @readonly * @static */ const SHORT: number; /** * The duration of a medium (3000ms) toast message. * * @public * @readonly * @static */ const MEDIUM: number; /** * The duration of a long (6000ms) toast message. * * @public * @readonly * @static */ const LONG = 6000; } } /** * Service for managing the display and behavior of toast elements. * Provides methods to open and close toast elements within a portal structure. * * Uses a singleton pattern with static configuration. * * @example * ```typescript * // Configure once at app startup * ToastService.configure({ * closeOnNavigation: true, * behaviors: [] * }); * * // Use throughout the app * await ToastService.instance.open({ * header: 'Success', * content: 'Operation completed successfully', * timeout: Toast.Timeout.SHORT * }); * ``` * * @public */ export declare class ToastService { private static _instance; private static _config; private readonly _toastMap; private readonly _behaviors; /** * Constructs a new instance of the `ToastService` class. * Use `ToastService.configure()` and `ToastService.instance` instead of direct instantiation. * * @private */ private constructor(); /** * Gets the singleton instance of `ToastService`. * If not configured, uses default configuration. * * @public * @static */ static get instance(): ToastService; /** * Configures the `ToastService` globally. * Must be called before accessing `instance` if custom configuration is needed. * Can only be called once; subsequent calls will throw an error. * * @public * @static * @param config - The configuration for the toast service. * @throws Error if already configured. * * @example * ```typescript * ToastService.configure({ * closeOnNavigation: true, * behaviors: [myCustomBehavior] * }); * ``` */ static configure(config: Partial): void; /** * Opens a toast within a portal. * * @public * @template TResult - Expected return type of the resolved toast result. * @param options - Properties for portal and toast. * @returns A promise resolving with the toast result. */ open(options?: IToastOptions): Promise; /** * Closes the toast and removes it from the DOM. * * @public * @template TResult - Type of result returned when the toast is closed. * @param toastId - Unique identifier for the toast instance. * @param result - Optional result returned when closing the toast. * @returns A promise resolving once the toast is fully closed. */ close(toastId: string, result?: TResult): Promise; /** * Disposes of the service and cleans up resources. * * @public */ dispose(): void; /** * Extends the toast component by placing it within a portal structure. * * @private * @param element - The element to place within the portal. * @param props - Properties to set on the portal. * @returns The created PortalElement and PortalProjectionElement containing the toast. */ private extendToPortal; /** * Creates a new portal element and appends it to the document body. * * @private * @param props - Optional properties to set on the portal element. * @returns The created PortalElement. */ private createPortal; } //# sourceMappingURL=ToastService.d.ts.map