import type { ReactElement, ReactNode } from "react"; /** The reversible route offered beside Cancel and the destructive Confirm. */ export interface ConfirmDialogAlternative { /** Button text, e.g. "Deactivate instead". */ label: string; /** What choosing it keeps, shown in a hint box above the buttons. */ description?: ReactNode; /** Fires when the alternative button is clicked; does not close the dialog. */ onSelect: () => void; /** Spinner on the alternative; Cancel and Confirm are disabled meanwhile. */ isLoading?: boolean; } interface ConfirmDialogBaseProps { /** Controlled visibility; the dialog never opens or closes itself. */ isOpen: boolean; /** Fires on Cancel, the close button, Esc and overlay click; the caller must then set `isOpen` to false. */ onClose: () => void; /** Fires on Confirm click; does not close the dialog — call onClose yourself. */ onConfirm: () => void; /** Body content rendered above the action row (a Text, a description + quote block, ...). Optional when `entityName` builds the body. */ children?: ReactNode; /** Rendered inside the header swatch. Defaults to a warning triangle. */ icon?: ReactNode; /** Header swatch background; derived from `tone` (a soft tint) when omitted. */ iconBg?: string; /** Header swatch icon/text color; derived from `tone` when omitted, so pass it together with `iconBg`. */ iconColor?: string; /** The exact record being destroyed, e.g. "Sabbatical". Switches on the consequence-first body and builds the default title. */ entityName?: string; /** What kind of record, e.g. "leave type"; the default title reads Delete leave type "Sabbatical"? */ entityKind?: string; /** Dependents already counted by the caller ("4 people hold a balance"), joined with " · " on one line. */ dependents?: string[]; /** What survives and what stays broken. With `entityName` it defaults to "This cannot be undone."; otherwise it renders only when passed. */ consequence?: ReactNode; /** A calmer reversible choice, drawn as the solid button while Confirm turns outline. Focus still opens on Cancel. */ alternative?: ConfirmDialogAlternative; /** Holds Confirm disabled until a precondition in `children` (an acknowledgement checkbox) is met. */ isConfirmDisabled?: boolean; /** "destructive" fills Confirm red; "neutral" leaves it primary. Defaults to "destructive". */ tone?: "destructive" | "neutral"; /** Defaults to "Cancel". */ cancelLabel?: string; /** Defaults to "Confirm". */ confirmLabel?: string; /** Left icon on the Confirm button. */ confirmIcon?: ReactElement; /** Shows a spinner on Confirm and disables it. */ isConfirmLoading?: boolean; /** Also disables Cancel while `isConfirmLoading`. Defaults to true. */ disableCancelWhilePending?: boolean; /** Requires typing this exact string before Confirm enables. Omit to skip the field entirely. */ confirmationText?: string; /** Label for the typed-confirmation field; only used when `confirmationText` is set. */ confirmationLabel?: string; /** "flush": children + action row as direct siblings (default). "stack": both in a spaced VStack. */ bodyLayout?: "flush" | "stack"; /** VStack spacing in "stack" layout. Defaults to 4. */ bodySpacing?: number; /** Extra top padding on the action row. Defaults to 0. */ actionsPt?: number; /** Pins initial focus to Cancel (never the destructive button) via Chakra's `initialFocusRef`. Defaults to true. */ focusCancelOnOpen?: boolean; /** Defaults to true. */ isCentered?: boolean; /** Whether Esc closes the dialog; unset keeps Chakra's default (true). */ closeOnEsc?: boolean; /** Whether clicking the overlay closes the dialog; unset keeps Chakra's default (true). */ closeOnOverlayClick?: boolean; } /** Reusable Cancel/Confirm modal for delete/deactivate-style prompts; pass `title`, or `entityName` to get a title and a consequence body. */ export type ConfirmDialogProps = ConfirmDialogBaseProps & ({ title: string; } | { title?: string; entityName: string; }); export {};