import { useId } from 'react'; import { Button } from '../../atoms/button'; import { FlexBox } from '../../atoms/flex-box'; import { Typography } from '../../atoms/typography'; import { Dialog } from '../../atoms/dialog'; import { Element } from '../../primitives/element'; import { cn } from '../../tools/cn'; import type { ModalProps } from './types'; import { modalPanelVariants } from './variants'; /** * A centred dialog for short, blocking decisions on desktop, at most 420px wide. On mobile the * same content is always a bottom Sheet, never a Modal. The panel takes focus when it opens, and * focus returns to the trigger when it closes. * * `size="wide"` is the desktop form dialog (C4 ۷.۳, «پست جدید»): 640px, a header row with the * title and `headerAction`, then the caller's body and footer bar, edge to edge. */ export function Modal({ open, title, children, actions, icon, size = 'default', headerAction, onClose, onExited, closeLabel, dismissible = true, alert, className, }: ModalProps) { const titleId = useId(); return ( {size === 'wide' ? ( {title} {headerAction} {children} ) : ( {closeLabel && dismissible && ( ); }