import React, { useEffect, useCallback } from 'react'; interface ModalProps { isOpen: boolean; onClose: () => void; title?: string; children: React.ReactNode; maxWidth?: string; } export function Modal({ isOpen, onClose, title, children, maxWidth = 'max-w-md' }: ModalProps) { const handleKeyDown = useCallback((e: KeyboardEvent) => { if (e.key === 'Escape') { onClose(); } }, [onClose]); useEffect(() => { if (isOpen) { document.addEventListener('keydown', handleKeyDown); return () => document.removeEventListener('keydown', handleKeyDown); } }, [isOpen, handleKeyDown]); if (!isOpen) return null; return (
{title && (

{title}

)}
{children}
); }