import { useEffect } from 'react'; import { X } from 'lucide-react'; interface ModalProps { title: string; onClose: () => void; children: React.ReactNode; /** Optional override for the max-width of the modal panel (default: max-w-md) */ maxWidth?: string; } /** * Generic modal overlay with a header and close button. * Closes on Escape key or backdrop click. * Render form content (or any JSX) as children. * * @example * *
...
*
*/ export function Modal({ title, onClose, children, maxWidth = 'max-w-md' }: ModalProps) { useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; document.addEventListener('keydown', handleKeyDown); return () => document.removeEventListener('keydown', handleKeyDown); }, [onClose]); return (
{ if (e.target === e.currentTarget) onClose(); }} >

{title}

{children}
); }