import React from 'react'; import { Dialog } from '@headlessui/react'; import { Cancel01Icon } from '../icons/index.js'; import Button from './Button.js'; const FORM_ID = 'modal-form-inner'; const Modal = ({ isOpen = true, onClose, title, children, footer, size = 'lg', closable = true, // Form props — when provided, wraps children in a
and shows a standard footer onSubmit, submitLabel = 'Enregistrer', cancelLabel = 'Annuler', submitVariant = 'primary', loading = false, disabled = false, }) => { const sizeClasses = { sm: 'max-w-md', md: 'max-w-lg', lg: 'max-w-2xl', xl: 'max-w-4xl', full: 'max-w-7xl', }; const isForm = typeof onSubmit === 'function'; const handleFormSubmit = (e) => { e.preventDefault(); onSubmit(e); }; const resolvedFooter = footer ?? (isForm ? (
) : null); return ( {}} className="relative z-50" > {/* Backdrop */}
); }; export default Modal;