'use client'; import * as React from 'react'; import { cn } from '@/lib/utils'; /* ------------------------------------------------------------------ */ /* DialogContext — auto-wires aria-labelledby / aria-describedby */ /* ------------------------------------------------------------------ */ interface DialogContextValue { titleId: string; descriptionId: string; } const DialogContext = React.createContext(null); function useDialogContext() { return React.useContext(DialogContext); } /* ------------------------------------------------------------------ */ interface DialogProps { open: boolean; onOpenChange: (open: boolean) => void; children: React.ReactNode; } function Dialog({ open, onOpenChange, children }: DialogProps) { const reactId = React.useId(); const titleId = `${reactId}-dialog-title`; const descriptionId = `${reactId}-dialog-desc`; React.useEffect(() => { if (open) { document.body.style.overflow = 'hidden'; } else { document.body.style.overflow = ''; } return () => { document.body.style.overflow = ''; }; }, [open]); if (!open) return null; return (
onOpenChange(false)} />
{children}
); } const DialogContent = React.forwardRef< HTMLDivElement, React.HTMLAttributes >(({ className, children, ...props }, ref) => { const ctx = useDialogContext(); return (
e.stopPropagation()} {...props} > {children}
); }); DialogContent.displayName = 'DialogContent'; function DialogHeader({ className, ...props }: React.HTMLAttributes) { return (
); } function DialogTitle({ className, id, ...props }: React.HTMLAttributes) { const ctx = useDialogContext(); return (

); } function DialogDescription({ className, id, ...props }: React.HTMLAttributes) { const ctx = useDialogContext(); return (

); } function DialogFooter({ className, ...props }: React.HTMLAttributes) { return (

); } export { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter };