import { type Constructable, type IContainer, type IDisposable, type InterfaceSymbol, type IResolver } from '@aurelia/kernel'; import type { CustomElementType, ICustomElementViewModel } from '@aurelia/runtime-html'; /** * The dialog service for composing template and component into a dialog */ export declare const IDialogService: InterfaceSymbol & { child(key: unknown): IResolver; }; export interface IDialogService { readonly controllers: IDialogController[]; /** * Opens a new dialog. * * @param settings - Dialog settings for this dialog instance. * @returns Promise A promise that settles when the dialog is closed. */ open(settings: IDialogSettings): DialogOpenPromise; /** * Closes all open dialogs at the time of invocation. * * @returns Promise All controllers whose close operation was cancelled. */ closeAll(): Promise; /** * Creates a child dialog service with its own settings. * @returns A child dialog service. */ createChild(baseSettings: IDialogSettings): IDialogService; } /** * The controller associated with every dialog component */ export declare const IDialogController: InterfaceSymbol; export interface IDialogController { readonly settings: IDialogLoadedSettings; /** * A promise that will be fulfilled once this dialog has been closed */ readonly closed: Promise; ok(value?: unknown): Promise>; cancel(value?: unknown): Promise>; error(value?: unknown): Promise; } /** * An interface describing the object responsible for creating the dom structure of a dialog */ export declare const IDialogDomRenderer: InterfaceSymbol>; export interface IDialogDomRenderer { render(dialogHost: HTMLElement, requestor: IDialogController, options?: TOptions): IDialogDom; } /** * An interface describing the DOM structure of a dialog */ export declare const IDialogDom: InterfaceSymbol; export interface IDialogDom extends IDisposable { /** * Host element for the dialog content */ readonly contentHost: HTMLElement; /** * Called when the dialog should be shown. Application can use this for animations */ show?(): void | Promise; /** * Called when the dialog should be hidden. Application can use this for animations */ hide?(): void | Promise; } /** * The promised returned from a dialog composition. */ export interface DialogOpenPromise extends Promise { /** * Add a callback that will be invoked when a dialog has been closed */ whenClosed(): Promise; whenClosed(onfulfilled?: ((value: DialogCloseResult) => TResult1 | PromiseLike) | null): Promise; whenClosed(onfulfilled: ((value: DialogCloseResult) => TResult1 | PromiseLike) | null | undefined, onrejected: (reason: unknown) => TResult2 | PromiseLike): Promise; whenClosed(onfulfilled?: (value: DialogCloseResult) => TResult1 | Promise, onrejected?: (reason: unknown) => TResult2 | Promise): Promise; } export type IDialogSettings = { /** * A custom renderer for the dialog. */ renderer?: Constructable> | IDialogDomRenderer; /** * The component url, constructor or instance for the dialog. */ component?: CustomElementType> | Constructable | (() => (Constructable | TComponent | Promise>)); /** * The template url or template strategy to override the default template location convention. */ template?: string | Element | Promise | (() => string | Element | Promise); /** * Data to be passed to the "activate" hook on the component. */ model?: TModel; /** * The element that will parent the dialog. */ host?: Element; /** * The container for the dialog creation. * One will be created from the root if not provided. */ container?: IContainer; /** * The rendering configuration for the dialog. Different renderers may have different configuration options. */ options?: TOptions; /** * When set to true conveys a cancellation as a rejection. */ rejectOnCancel?: boolean; }; export type IDialogLoadedSettings = Omit, 'component' | 'template' | 'renderer'> & { component?: Constructable | TModel; template?: string | Element; renderer: Constructable> | IDialogDomRenderer; }; /** * Global configuration for the dialog plugin */ export declare const IDialogGlobalSettings: InterfaceSymbol>; export type IDialogGlobalSettings = Pick, 'rejectOnCancel' | 'renderer'> & { options: TOptions; }; /** * Base dialog error interface */ export interface DialogError extends Error { wasCancelled: boolean; value?: T; } /** * The error thrown when a "cancel" occurs and DialogSettings.rejectOnCancel is set to "true". */ export type DialogCancelError = DialogError & { wasCancelled: true; }; /** * The error thrown when the dialog is closed with the `DialogController.prototype.error` method. */ export type DialogCloseError = DialogError & { wasCancelled: false; }; export declare class DialogOpenResult { readonly wasCancelled: boolean; readonly dialog: IDialogController; private constructor(); static create(wasCancelled: boolean, dialog: IDialogController): DialogOpenResult; } export declare class DialogCloseResult { readonly status: T; readonly value?: TVal | undefined; private constructor(); static create(status: T, value?: TVal): DialogCloseResult; } export interface IDialogCustomElementViewModel extends ICustomElementViewModel, IDialogComponent { readonly $dialog: IDialogController; } /** * - `ok`: The dialog is closed intentionally. This denotes the happy path. * - `cancel`: The dialog is closed with an intent to cancel. * - `abort`: The dialog model refused to deactivate in canDeactivate. * - `error`: The dialog is closed due to an error. */ export type DialogDeactivationStatuses = 'ok' | 'error' | 'cancel' | 'abort'; /** * The result received when a dialog opens. */ export interface DialogOpenResult { readonly wasCancelled: boolean; /** * The controller for the open dialog. */ readonly dialog: IDialogController; } export interface IDialogComponent { canActivate?: IDialogComponentCanActivate['canActivate']; activate?: IDialogComponentActivate['activate']; canDeactivate?: IDialogComponentCanDeactivate['canDeactivate']; deactivate?: IDialogComponentDeactivate['deactivate']; } /** * An optional interface describing the dialog canActivate convention. */ export interface IDialogComponentCanActivate { /** * Implement this hook if you want to control whether or not the dialog can be open. * To cancel the opening of the dialog return false or a promise that resolves to false. * Any other returned value is coerced to true. */ canActivate(model?: T): boolean | Promise; } /** * An optional interface describing the dialog activate convention. */ export interface IDialogComponentActivate { /** * Implement this hook if you want to perform custom logic just before the dialog is open. */ activate(model?: T): void | Promise; } /** * An optional interface describing the dialog canDeactivate convention. */ export interface IDialogComponentCanDeactivate { /** * Implement this hook if you want to control whether or not the dialog can be closed. * To cancel the closing of the dialog return false or a promise that resolves to false. * Any other returned value is coerced to true. */ canDeactivate(result: DialogCloseResult): boolean | Promise; } /** * An optional interface describing the dialog deactivate convention. */ export interface IDialogComponentDeactivate { /** * Implement this hook if you want to perform custom logic when the dialog is being closed. */ deactivate(result: DialogCloseResult): void | Promise; } //# sourceMappingURL=dialog-interfaces.d.ts.map