import type { ReactNode } from 'react'; import { type ModalProps, type ModalSize } from './Modal.js'; export interface ConfirmModalProps { open: boolean; onClose: () => void; /** The question, which names the dialog: "Delete cluster?" */ title: string; /** What follows from confirming, which describes the dialog. */ description?: ReactNode; /** More to read or to choose before confirming, such as a field. */ children?: ReactNode; /** The verb that confirms, such as "Delete"; never "OK". */ confirmLabel: string; /** An async handler keeps both buttons disabled until it settles. One that * rejects leaves the dialog open and rethrows, so report the error in the * handler, or pass it back as `error` to show it in the dialog. */ onConfirm: () => void | Promise; confirmDisabled?: boolean | undefined; /** An action that can't be undone: the confirm button reads as dangerous, and * the dialog is an alertdialog that waits for an answer. */ destructive?: boolean | undefined; align?: 'top' | 'center' | undefined; cancelLabel?: string | undefined; /** When false, the dialog stays open after a successful confirm. */ closeOnConfirm?: boolean | undefined; /** What has focus as it opens. With a field in the body, such as a name to type, the first * of them (`first-control`), so the reader types at once. Without one, Cancel for a * destructive dialog, so a stray Enter destroys nothing, and the confirm button otherwise, * so the keyboard answers at once. */ initialFocus?: 'cancel' | 'confirm' | 'first-control' | undefined; /** What confirming may remove, such as the row it was asked from. Once that is gone, focus * moves to the same control in the row that took its place, else in the row before it, else * in the next group's rows when its group went with it, else to the list, rather than to the * page. While it's still there, as after Cancel, focus returns to what opened it. Resolve * `onConfirm` once the removal has rendered, by awaiting the refetch or removing the row at * once. A row that goes only after the dialog has closed still moves focus on, unless the * reader has moved it. */ removes?: Element | null | undefined; /** What has focus once it closes, and when set, it decides rather than `removes`: by default * what opened it, or, once that is gone, the last thing focused that is still there. */ finalFocus?: ModalProps['finalFocus'] | undefined; /** Work the host runs for it, such as a mutation already under way: the buttons wait, and * the dialog can't be dismissed, as while its own handler runs. */ pending?: boolean | undefined; /** Why the last confirm failed, under the body, so the reader can try again. */ error?: ReactNode; size?: ModalSize | undefined; } /** Asks before an action: its title the question, its description what follows, * and Cancel beside a confirm button named for the action. */ export declare function ConfirmModal({ open, onClose, title, description, children, confirmLabel, onConfirm, confirmDisabled, destructive, align, cancelLabel, closeOnConfirm, initialFocus, removes, finalFocus, pending: pendingProp, error, size, }: ConfirmModalProps): import("react").JSX.Element; /** What `confirm` asks: a ConfirmModal's props without the ones the hook manages. */ export interface ConfirmRequest extends Omit { /** Turns a rejected `onConfirm` into the line the dialog shows, and the dialog stays open * for another try. Without it, a rejection still keeps the dialog open, silently. */ errorMessage?: ((error: unknown) => ReactNode) | undefined; } /** Asks from anywhere, such as a menu row, without keeping a dialog's state by hand: * `const { confirm, dialog } = useConfirm()`, render `dialog` once, then * `confirm({ title, confirmLabel, destructive, onConfirm })`. It resolves true once * confirmed and `onConfirm` has settled, and false when the reader cancels. */ export declare function useConfirm(): { confirm: (request: ConfirmRequest) => Promise; dialog: ReactNode; };