import React from 'react'; import { Dialog } from '@ark-ui/react/dialog'; export interface ModalProps extends Omit< React.HTMLAttributes, 'onChange' | 'title' > { open: boolean; onClose: () => void; title?: React.ReactNode; closeOnBackdrop?: boolean; } const ModalRoot = ({ open, onClose, title, closeOnBackdrop = true, className = '', children, ...rest }: ModalProps) => { const panelClasses = ['modal__panel', className].filter(Boolean).join(' '); return ( { if (!details.open) onClose(); }} closeOnInteractOutside={closeOnBackdrop} lazyMount={false} unmountOnExit > {title !== undefined && (
{title} {'×'}
)} {children}
); }; ModalRoot.displayName = 'Modal'; const ModalHeader = ({ className = '', children, ...rest }: React.HTMLAttributes) => (
{children}
); ModalHeader.displayName = 'Modal.Header'; const ModalBody = ({ className = '', children, ...rest }: React.HTMLAttributes) => (
{children}
); ModalBody.displayName = 'Modal.Body'; const ModalFooter = ({ className = '', children, ...rest }: React.HTMLAttributes) => ( ); ModalFooter.displayName = 'Modal.Footer'; export const Modal = Object.assign(ModalRoot, { Header: ModalHeader, Body: ModalBody, Footer: ModalFooter });