41 lines
851 B
TypeScript
41 lines
851 B
TypeScript
import type { ReactNode } from 'react';
|
|
import { Button } from './Button';
|
|
import { Dialog } from './Dialog';
|
|
export function ConfirmDialog({
|
|
open,
|
|
title,
|
|
children,
|
|
confirmLabel = '确认',
|
|
cancelLabel = '取消',
|
|
danger = false,
|
|
onConfirm,
|
|
onClose,
|
|
}: {
|
|
open: boolean;
|
|
title: string;
|
|
children: ReactNode;
|
|
confirmLabel?: string;
|
|
cancelLabel?: string;
|
|
danger?: boolean;
|
|
onConfirm: () => void;
|
|
onClose: () => void;
|
|
}) {
|
|
return (
|
|
<Dialog
|
|
open={open}
|
|
onClose={onClose}
|
|
title={title}
|
|
footer={
|
|
<div className="flex justify-end gap-2">
|
|
<Button onClick={onClose}>{cancelLabel}</Button>
|
|
<Button variant={danger ? 'danger' : 'primary'} onClick={onConfirm}>
|
|
{confirmLabel}
|
|
</Button>
|
|
</div>
|
|
}
|
|
>
|
|
{children}
|
|
</Dialog>
|
|
);
|
|
}
|