import React, { useEffect } from 'react'; import { X } from 'lucide-react'; export interface ModalProps { isOpen: boolean; onClose: () => void; title: React.ReactNode; icon?: React.ComponentType<{ className?: string }>; children: React.ReactNode; footer?: React.ReactNode; maxWidth?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | 'full'; className?: string; bodyClassName?: string; } const maxWidthClasses: Record, string> = { sm: 'max-w-sm', md: 'max-w-md', lg: 'max-w-lg', xl: 'max-w-xl', '2xl': 'max-w-2xl', '3xl': 'max-w-3xl', '4xl': 'max-w-4xl', '5xl': 'max-w-5xl', full: 'max-w-[95vw]', }; export default function Modal({ isOpen, onClose, title, icon: Icon, children, footer, maxWidth = '2xl', className = '', bodyClassName = '', }: ModalProps) { useEffect(() => { if (isOpen) { document.body.style.overflow = 'hidden'; } else { document.body.style.overflow = ''; } return () => { document.body.style.overflow = ''; }; }, [isOpen]); useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape' && isOpen) { onClose(); } }; window.addEventListener('keydown', handleKeyDown); return () => window.removeEventListener('keydown', handleKeyDown); }, [isOpen, onClose]); if (!isOpen) return null; return (
e.stopPropagation()} > {/* Fixed Header */}
{Icon && (
)}

{title}

{/* Scrollable Body */}
{children}
{/* Fixed Footer */} {footer && (
{footer}
)}
); }