Interface IDialogWrapper

A simple interface for dialog wrappers that can be used to abstract away the browser's built-in dialog methods or custom implementations.

interface IDialogWrapper {
    alert: (message?: string) => Promise<void>;
    choose?: (
        message?: string,
        options?: IDialogChooseOption[],
    ) => Promise<null | string>;
    confirm: (message?: string) => Promise<boolean>;
    confirmSync: (message?: string) => boolean;
    prompt: (
        message?: string,
        _default?: string,
        cancel?: boolean,
    ) => Promise<null | string>;
    toast?: (message: string, options?: IDialogToastOptions) => void;
}

Properties

alert: (message?: string) => Promise<void>
choose?: (
    message?: string,
    options?: IDialogChooseOption[],
) => Promise<null | string>

Multi-button dialog. Resolves with the clicked option's id, or null if the user dismisses it with Escape. The first option flagged primary: true (or the first option, when none is flagged) is the default action and is bound to Enter. Optional, so existing implementations of this interface stay valid.

confirm: (message?: string) => Promise<boolean>
confirmSync: (message?: string) => boolean
prompt: (
    message?: string,
    _default?: string,
    cancel?: boolean,
) => Promise<null | string>
toast?: (message: string, options?: IDialogToastOptions) => void

A short message that goes away by itself, like "Link copied" or an error of an action. It does not wait for the person and takes no focus. Optional, so existing implementations of this interface stay valid.