import type { Activity } from '../core/Activity.js';
import type { Fragment } from '../core/Fragment.js';
import { UiDialogElement } from '../md/dialog/ui-dialog.js';
import '../md/dialog/ui-dialog.js';
export type RenderAs = 'message' | 'error' | 'picker';
export interface ActionOptions {
    /**
     * The label to show on the action button.
     * Default labels are `OK` for the positive action and `Cancel` for the negative action.
     */
    label?: string;
    /**
     * When set it sets the value on the action button.
     */
    value?: string;
    /**
     * The action to call when the action is triggered.
     * @param value Optional value returned by the dialog.
     */
    action?: (value?: unknown) => void;
}
export interface PositiveActionOptions extends ActionOptions {
    /**
     * The type of the button. Default is `submit`.
     * If set to `button`, the dialog will not close on click.
     */
    type?: 'submit' | 'button';
}
/**
 * Options for unsaved changes detection
 */
export interface UnsavedChangesOptions {
    /**
     * Function that returns true if there are unsaved changes
     */
    hasUnsavedChanges: () => boolean;
    /**
     * Title for the unsaved changes warning dialog
     */
    warningTitle?: string;
    /**
     * Message for the unsaved changes warning dialog
     */
    warningMessage?: string;
    /**
     * Label for the "Discard Changes" button
     */
    discardLabel?: string;
    /**
     * Label for the "Keep Editing" button
     */
    keepEditingLabel?: string;
}
/**
 * A programmatic access to the dialog UI.
 * It hook ups to the `Activity` lifecycle methods to control the dialog.
 * When the activity is destroyed, the dialog is destroyed along with it.
 * When the activity is paused, the dialog is hidden, but not removed from the DOM.
 * The dialog then becomes visible again when the activity resumes.
 */
export declare class DialogBuilder {
    private parent?;
    /**
     * The title of the dialog.
     */
    static title: string | undefined;
    /**
     * The title of the dialog.
     * When set, it takes precedence over the static title.
     */
    protected title: string | undefined;
    /**
     * The description of the dialog.
     * It is not used by default, but can be set to add custom content.
     */
    protected description: string | undefined;
    /**
     * The positive action that closes the dialog.
     * It is not used by default, but can be set to add custom actions.
     */
    protected positiveAction: PositiveActionOptions | undefined;
    /**
     * The negative action that closes the dialog.
     * It is not used by default, but can be set to add custom actions.
     */
    protected negativeAction: ActionOptions | undefined;
    /**
     * The body of the dialog. It is not used by default, but can be set to add custom content.
     */
    protected body: HTMLElement | undefined;
    /**
     * The CSS classes to add to the dialog element.
     * It is not used by default, but can be set to add custom classes.
     */
    protected classes: string[] | undefined;
    /**
     * When rendered, it sets the corresponding class name to the dialog.
     */
    protected renderAs: RenderAs;
    /**
     * The root element to render the dialog into.
     * By default the dialog is rendered into the document body.
     */
    protected renderRoot?: HTMLElement | undefined;
    /**
     * When set to true, the dialog will be rendered as a modal dialog.
     */
    protected modal: boolean | undefined;
    /**
     * The dialog element that is created by this builder.
     */
    dialog?: UiDialogElement;
    /**
     * Options for unsaved changes detection
     */
    protected unsavedChangesOptions?: UnsavedChangesOptions;
    /**
     * Reference to the unsaved changes warning dialog
     */
    unsavedChangesDialog?: DialogBuilder;
    /**
     * Creates a new dialog builder.
     * @param parent The parent activity or fragment that the dialog is associated with.
     * It will listen to the activity lifecycle events to control the dialog visibility.
     * When not provided, the dialog will not be controlled by the activity lifecycle.
     */
    constructor(parent?: Activity | Fragment | undefined);
    /**
     * Sets the dialog title.
     * @param title The title of the dialog to set. Undefined/empty to clear.
     * @returns The instance of this class for chaining.
     */
    setTitle(title?: string): this;
    /**
     * Sets the dialog description.
     * @param title The value to to set. Undefined/empty to clear.
     * @returns The instance of this class for chaining.
     */
    setDescription(description: string): this;
    /**
     * Sets the positive action that closes the dialog.
     *
     * @param action The action to call when the positive action is triggered.
     * @param label The label of the positive button. Default to "OK"
     * @returns The instance of this class for chaining.
     */
    setPositiveAction(options?: PositiveActionOptions): this;
    /**
     * Sets the negative action that closes the dialog.
     *
     * @param action The action to call when the negative action is triggered.
     * @param label The label of the negative button. Default to "Cancel"
     * @returns The instance of this class for chaining.
     */
    setNegativeAction(options?: ActionOptions): this;
    /**
     * By default, the dialog is rendered as a message dialog. Set to a different type to
     * change the rendering.
     *
     * @param renderAs The value for the type of the dialog.
     * @returns The instance of this class for chaining.
     */
    setRenderAs(renderAs: RenderAs): this;
    /**
     * Sets up unsaved changes detection for the dialog.
     * When the user tries to close the dialog with unsaved changes, a warning dialog will be shown.
     * @param options Configuration for unsaved changes detection
     * @returns The instance of this class for chaining.
     */
    setUnsavedChangesDetection(options: UnsavedChangesOptions): this;
    /**
     * Adds custom CSS classes to the dialog element.
     * These classes will be added to the dialog element when it is created.
     *
     * @param classes The CSS classes to add to the dialog element.
     * @returns The instance of this class for chaining.
     */
    setClasses(classes: string[]): this;
    /**
     * Sets the body of the dialog. It is not used by default, but can be set to add custom content.
     * The body will be added to the dialog element.
     *
     * @param body The body element to set.
     * @returns The instance of this class for chaining.
     */
    setBody(body: HTMLElement): this;
    /**
     * Sets the root element to render the dialog into.
     * By default the dialog is rendered into the document body.
     *
     * @param renderRoot The root element to render the dialog into.
     * @returns The instance of this class for chaining.
     */
    setRenderRoot(renderRoot: HTMLElement): this;
    /**
     * Sets the dialog to be modal.
     * When set to true, the dialog will be rendered as a modal dialog.
     * The dialog will block interaction with the rest of the page until it is closed.
     *
     * @param modal When true, the dialog will be rendered as a modal dialog.
     * @returns The instance of this class for chaining.
     */
    setModal(modal: boolean): this;
    /**
     * Creates the dialog and returns the instance of it.
     * The dialog is not yet added to the DOM nor it is opened.
     *
     * @returns The instance of the dialog class.
     */
    build(): UiDialogElement;
    /**
     * Creates the dialog by calling the `build()` function,
     * sets the `dialog` property, appends it to the body,
     * and finally opens the dialog as modal.
     *
     * This method does not return `this` as you can't manipulate the dialog anymore.
     */
    open(): void;
    /**
     * Closes the dialog. The dialog behaves like the a negative action was triggered.
     */
    close(): void;
    private handleActivityDestroy;
    private handleActivityPause;
    private handleActivityResume;
    /**
     * Handles the cancelable 'closing' event to check for unsaved changes
     */
    private handleDialogClosing;
    /**
     * Shows a warning dialog when there are unsaved changes
     */
    showUnsavedChangesWarning(): void;
    /**
     * Forces the dialog to close without checking for unsaved changes
     */
    protected forceClose(): void;
    protected handleDialogClosed(event: Event): void;
    /**
     * Removes the dialog from the DOM and removes all listeners.
     * The dialog does not call any lifecycle methods.
     */
    dispose(): void;
}
//# sourceMappingURL=DialogBuilder.d.ts.map