import React, { ReactNode } from 'react'; import { Box } from './primitives/Box'; import { Stack } from './primitives/Stack'; import { Button } from './Button'; import { Text } from './Text'; import { X } from 'lucide-react'; import { IconButton } from './IconButton'; interface ModalProps { isOpen: boolean; onClose?: () => void; onOpenChange?: (open: boolean) => void; title?: string; description?: string; icon?: React.ReactNode; children: ReactNode; footer?: ReactNode; primaryActionLabel?: string; onPrimaryAction?: () => void; secondaryActionLabel?: string; onSecondaryAction?: () => void; isLoading?: boolean; size?: 'sm' | 'md' | 'lg' | 'xl'; } export function Modal({ isOpen, onClose, onOpenChange, title, description, icon, children, footer, primaryActionLabel, onPrimaryAction, secondaryActionLabel, onSecondaryAction, isLoading = false, size = 'md', }: ModalProps) { if (!isOpen) return null; const sizeMap = { sm: 'max-w-md', md: 'max-w-lg', lg: 'max-w-2xl', xl: 'max-w-4xl', }; const handleClose = () => { if (onClose) onClose(); if (onOpenChange) onOpenChange(false); }; return ( {/* Backdrop click to close */} {/* Header */} {icon && {icon}} {title && ( {title} )} {description && ( {description} )} {/* Content */} {children} {/* Footer */} {(primaryActionLabel || secondaryActionLabel || footer) && ( {footer || ( {secondaryActionLabel && ( )} {primaryActionLabel && ( )} )} )} ); }