import { X } from "lucide-react"; import { useEffect, useId, useRef, type ReactNode } from "react"; interface Props { title: string; children: ReactNode; onClose: () => void; className?: string; } export function Dialog({ title, children, onClose, className = "" }: Props) { const ref = useRef(null); const titleId = useId(); useEffect(() => { const dialog = ref.current; dialog?.showModal(); return () => { dialog?.close(); }; }, []); return ( { event.preventDefault(); onClose(); }} onClick={(event) => { if (event.target === event.currentTarget) { onClose(); } }} >

{title}

{children}
); }