import type { IPortalElementProps } from '../../Primitives/Portal/IPortalElementProps'; import type { PortalProjectionElement } from '../../Primitives/Portal/PortalProjectionElement'; import { DialogElement } from './DialogElement'; import type { IDialogElementProps } from './IDialogElementProps'; import { type IDialogServiceConfig, type IDialogBehavior } from './IDialogServiceConfig'; /** * Function type for resolving dialog results. * * @public */ export type DialogResolveFunction = (result: unknown) => void; /** * Represents the `IDialogRef` interface. * * @public */ export interface IDialogRef { readonly dialogId: string; readonly dialogElement: DialogElement; readonly portalProjectionElement: PortalProjectionElement; readonly wrapperElement: HTMLElement; readonly stackLevel: number; readonly computedWidth: string; readonly computedHeight: string; readonly options?: IDialogOptions; resolve?: DialogResolveFunction; } /** * Represents the properties of a dialog element. * * @public */ export interface IDialogOptions extends Partial, Partial { /** * Whether to close the dialog when navigating away. */ navigateToClose?: boolean; } /** * Service for managing the display and behavior of dialog elements. * Provides methods to open and close dialog elements within a portal structure. * Supports extensible behavior pattern for customizing dialog interactions. * * @example * ```typescript * // Configure service globally before use * DialogService.configure({ * behaviors: [withDialogStackBehavior({ baseWidth: '80%', baseHeight: '60%' })], * closeOnNavigation: true * }); * * // Use the singleton instance * const result = await DialogService.instance.open('myDialog', MyDialogWrapper, options); * ``` * * @public */ export declare class DialogService { private static _instance; private static _config; private readonly _dialogMap; private readonly _dialogStack; private readonly _behaviors; private _portalElement?; /** * Constructs a new instance of the `DialogService` class. * Use `DialogService.instance` to access the singleton instance. * * @private */ private constructor(); /** * Returns the singleton instance of the DialogService. * Creates the instance on first access using the current configuration. * * @public * @readonly */ static get instance(): DialogService; /** * Returns the current number of open dialogs in the stack. * * @public * @readonly */ get stackSize(): number; /** * Returns an array of all dialog references in stack order (oldest first). * * @public * @readonly */ get stack(): ReadonlyArray; /** * Returns the registered behaviors for this service instance. * * @public * @readonly */ get behaviors(): ReadonlyArray; /** * Configures the dialog service globally. * Must be called before accessing the singleton instance. * * @public * @static * @param config - Configuration options for the dialog service. * @returns The DialogService class for chaining. * @throws Error if called after the instance has already been created. * * @example * ```typescript * DialogService.configure({ * behaviors: [withDialogStackBehavior({ baseWidth: '80%' })], * closeOnNavigation: true * }); * ``` */ static configure(config: Partial): typeof DialogService; /** * Opens a custom wrapper component containing a dialog within a portal. * * @public * @template T - Type of the wrapper component extending HTMLElement. * @template TResult - Expected return type of the resolved dialog result. * @param dialogId - Unique identifier for the dialog instance. * @param wrapperClass - Class of the wrapper component containing the dialog. * @param options - Properties for portal and dialog. * @returns A promise resolving with the dialog result. */ open(dialogId: string, wrapperClass: new () => T, options?: IDialogOptions): Promise; /** * Opens a custom wrapper component containing a dialog within a portal. * * @public * @template T - Type of the wrapper component extending HTMLElement. * @template TData - Type of data provided to the wrapper component. * @template TResult - Expected return type of the resolved dialog result. * @param dialogId - Unique identifier for the dialog instance. * @param wrapperClass - Class of the wrapper component containing the dialog. * @param data - Data passed to the wrapper component. * @param options - Properties for portal and dialog. * @returns A promise resolving with the dialog result. */ open(dialogId: string, wrapperClass: new (args: TData) => T, data: TData, options?: IDialogOptions): Promise; /** * Closes the dialog in the wrapper component and optionally removes the wrapper from the DOM. * * @public * @template TResult - Type of result returned when the dialog is closed. * @param dialogId - Unique identifier for the dialog instance. * @param result - Optional result returned when closing the dialog. * @returns A promise resolving once the dialog is fully closed. */ close(dialogId: string, result?: TResult): Promise; /** * Closes the topmost dialog in the stack. * * @public * @template TResult - Type of result returned when the dialog is closed. * @param result - Optional result returned when closing the dialog. * @returns A promise resolving once the dialog is fully closed. */ closeTop(result?: TResult): Promise; /** * Closes all open dialogs in the stack, from top to bottom. * * @public * @returns A promise resolving once all dialogs are closed. */ closeAll(): Promise; /** * Creates a new dialog reference. * * @private */ private createDialogRef; /** * Extends the dialog 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 containing the dialog. */ private extendToPortal; } //# sourceMappingURL=DialogService.d.ts.map