reablocks
Version:
Component library for React
62 lines (61 loc) • 2.04 kB
TypeScript
import { default as React, ReactElement, ReactNode } from 'react';
import { ConfirmDialogActionsProps } from './ConfirmDialogActions';
export interface ConfirmDialogProps {
/**
* Whether the dialog is open or not
*/
open: boolean;
/**
* The header of the dialog
*/
header: string | ReactNode;
/**
* The content of the dialog
*/
content: string | ReactNode;
/**
* The label for the confirm button
* @default 'Confirm'
*/
confirmLabel?: string;
/**
* The label for the cancel button
* @default 'Cancel'
*/
cancelLabel?: string;
/**
* Callback when the confirm button is clicked. May return a Promise;
* while it is pending the dialog shows a loading state and disables
* its action buttons.
*/
onConfirm?: () => void | Promise<void>;
/**
* Callback when the cancel button is clicked
*/
onCancel?: () => void;
/**
* The visual variant of the dialog. Use `destructive` for actions like delete.
* @default 'default'
*/
variant?: 'default' | 'destructive';
/**
* Controlled loading state for the confirm action. When provided, takes
* precedence over the dialog's internal async tracking — use this when
* the loading state lives outside the dialog (e.g. driven by a mutation
* hook). When omitted, the dialog automatically enters the loading state
* if `onConfirm` returns a Promise.
*/
loading?: boolean;
/**
* Whether the confirm button is disabled.
*/
confirmDisabled?: boolean;
/**
* Optional slot children. Pass a `<ConfirmDialogActions>` element to
* replace the default Confirm/Cancel buttons. Action children can read
* the managed state via `useConfirmDialogContext()`. Other React nodes
* are not rendered — use `header`/`content` props for those.
*/
children?: ReactElement<ConfirmDialogActionsProps>;
}
export declare const ConfirmDialog: React.FC<ConfirmDialogProps>;