/** Which of the three canned dialogs an entry is. */ export type DialogsKind = 'alert' | 'confirm' | 'prompt'; /** Options common to alert, confirm and prompt; a bare string is the title. */ export interface DialogsOptions { /** Heading of the dialog, rendered as its title and accessible name. */ title: string; /** * Body text under the title, rendered as the dialog's description. * * @default undefined — no description. */ description?: string | undefined; /** * Label of the confirming button. * * @default 'OK' for alert and prompt, 'Confirm' for confirm */ confirmLabel?: string | undefined; /** * Label of the cancelling button; alerts have none. * * @default 'Cancel' */ cancelLabel?: string | undefined; /** * Severity rung the skin colours the dialog by, mirrored to `data-status`. * * @default undefined — the skin's own default. */ status?: string | undefined; } /** Options for a prompt, which adds a single text field to the confirm shape. */ export interface DialogsPromptOptions extends DialogsOptions { /** * Text the field starts with. * * @default '' */ defaultValue?: string | undefined; /** * Visible label of the text field. * * @default 'Value' */ label?: string | undefined; /** * Placeholder shown in the empty field. * * @default undefined — no placeholder. */ placeholder?: string | undefined; } /** A queued dialog as the host renders it: resolved options plus the settle callback. */ export interface DialogsEntry extends DialogsPromptOptions { /** Stable identity, for keying the rendered dialog. */ id: string; /** Which canned dialog this is. */ kind: DialogsKind; /** Resolved confirming label, never undefined. */ confirmLabel: string; /** Resolved cancelling label, `undefined` for alerts. */ cancelLabel: string | undefined; } /** What settling an entry hands back: nothing for alert, a boolean for confirm, text or null for prompt. */ export type DialogsResult = void | boolean | string | null; /** The queue every host renders from and every caller awaits on. */ export interface DialogsStore { /** Subscribes to queue changes. Returns its own unsubscribe. */ subscribe: (listener: () => void) => () => void; /** The entry currently shown, or `null` — a stable reference until the queue changes. */ getCurrent: () => DialogsEntry | null; /** Shows a message with one button; resolves when it is dismissed. */ alert(options: DialogsOptions | string): Promise; /** Asks a yes/no question; resolves `true` on confirm, `false` on cancel or dismissal. */ confirm(options: DialogsOptions | string): Promise; /** Asks for one line of text; resolves the text on confirm, `null` on cancel or dismissal. */ prompt(options: DialogsPromptOptions | string): Promise; /** Resolves and removes the entry with `id`, then shows the next one. No-ops for an id that is not current. */ settle(id: string, result: DialogsResult): void; } /** * Creates the dialog queue once per app. Hand it to the `Dialogs` host and call * `alert`, `confirm` or `prompt` from anywhere; each returns a promise that * settles with the user's answer. * * @example * ```ts * const dialogs = createDialogs(); * if (await dialogs.confirm({ title: 'Delete the project?', status: 'danger' })) remove(); * ``` */ export declare function createDialogs(): DialogsStore; /** What cancelling or dismissing `entry` resolves with: `false` for confirm, `null` for prompt, nothing for alert. */ export declare function dialogsCancelResult(entry: DialogsEntry): DialogsResult; /** What confirming `entry` resolves with: `true` for confirm, the typed `draft` for prompt, nothing for alert. */ export declare function dialogsConfirmResult(entry: DialogsEntry, draft: string): DialogsResult;