import { AiroButton, buttonVariants } from '@workspace/airo-ui/components/AiroButton'; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogPortal, AlertDialogTitle, } from '@workspace/airo-ui/components/alert-dialog'; import CloseSvg from '@workspace/airo-ui/components/close.svg'; import { cn } from '@workspace/airo-ui/lib/utils'; import { Ref, useImperativeHandle, useState } from 'react'; interface AlertDialogComponentProps { ref: Ref; title: string; description: string; cancelText?: string; confirmText?: string; onConfirm?: () => void; footerClassName?: string; wrapClassName?: string; descriptionClassName?: string; } // 定义ref可以访问的方法类型 export interface AlertDialogRef { show: () => void; } // Defining the AlertDialogComponent with internal state and onShow prop const AlertDialogComponent: React.FC = ({ ref, title, description, cancelText = 'Cancel', confirmText = 'Confirm', onConfirm, footerClassName, wrapClassName, descriptionClassName, }) => { const [open, setOpen] = useState(false); function show() { setOpen(true); } useImperativeHandle( ref, (): AlertDialogRef => ({ show, }), [], ); return (
setOpen(false)}>
{title} {description} {confirmText} {cancelText}
); }; export default AlertDialogComponent;