import * as React from 'react'; import { cn } from '@/lib/utils'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; const WIDTHS = { sm: 'sm:max-w-sm', default: 'sm:max-w-lg', lg: 'sm:max-w-2xl', xl: 'sm:max-w-4xl', }; /** * Modal — the standard dialog shape: header, scrollable body, footer. * * Owning the scroll boundary here is the point. A dialog that lets its whole * body scroll pushes the title and the confirm button off-screen on a laptop; * this keeps both pinned and scrolls only the middle. */ /** @param {any} props */ /** @param {any} props */ export function Modal({ open, onOpenChange, title, description, icon: Icon, size = 'default', /** Footer content. Omit for a dialog whose body carries its own actions. */ footer, children, className, /** Blocks closing — use while a submit is in flight. */ busy = false, }) { return ( e.preventDefault() : undefined} onEscapeKeyDown={busy ? (e) => e.preventDefault() : undefined} >
{Icon && ( )}
{title} {description && ( {description} )}
{children}
{footer && ( {footer} )}
); } /** * ConfirmModal — a destructive or irreversible confirmation. * * Defaults to the destructive tone because that is what confirmation is almost * always for, and it labels the action with the verb ("Delete") rather than * "OK", so the button says what will happen. */ /** @param {any} props */ export function ConfirmModal({ open, onOpenChange, title = 'Are you sure?', description, confirmLabel = 'Confirm', cancelLabel = 'Cancel', onConfirm, tone = 'destructive', icon = null, busy = false, }) { return ( } > {null} ); }