"use client"; import * as React from "react"; import { XIcon } from "lucide-react"; import { Dialog as DialogPrimitive } from "radix-ui"; import { usePortalContainer } from "../context"; import { cn } from "../lib/cn"; import { Button } from "./button"; import { useCloseLabel } from "./close-label"; import { revealOpeningFocus } from "./reveal-opening-focus"; // The X in a dialog's top right corner, shared with AlertDialog: since // 2026-10-21 every dialog has one, confirmations included. const CORNER_CLOSE = "text-primary-blue-100 hover:bg-primary-electric-blue-5 focus-visible:outline-ring absolute top-4 right-4 inline-flex size-8 items-center justify-center rounded-md transition-colors outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-solid disabled:pointer-events-none disabled:text-primary-blue-40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"; function Dialog({ ...props }: React.ComponentProps) { return ; } function DialogTrigger({ ...props }: React.ComponentProps) { return ; } function DialogPortal({ ...props }: React.ComponentProps) { const container = usePortalContainer(); return ( ); } function DialogClose({ ...props }: React.ComponentProps) { return ; } function DialogOverlay({ className, ...props }: React.ComponentProps) { return ( ); } function DialogContent({ className, children, showCloseButton = true, closeDisabled = false, size = "md", onOpenAutoFocus, ...props }: React.ComponentProps & { showCloseButton?: boolean; /** Holds the X while "Annulla" is held: the answer is being carried out. */ closeDisabled?: boolean; /** The design system's widths: `sm` 400px (a confirmation, as the * AlertDialog), `md` 520px (a form), `lg` 720px (a list, D5), `xl` 1080px * (a table of rows with their controls, D14). */ size?: "sm" | "md" | "lg" | "xl"; }) { const closeLabel = useCloseLabel(); return ( [data-corner-close])_[data-slot=dialog-title]]:pr-10", className, )} {...props} onOpenAutoFocus={revealOpeningFocus(onOpenAutoFocus)} > {children} {showCloseButton && ( {closeLabel} )} ); } function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { return (
); } function DialogFooter({ className, showCloseButton = false, children, ...props }: React.ComponentProps<"div"> & { showCloseButton?: boolean; }) { const closeLabel = useCloseLabel(); return (
:where(a,button)]:h-12 [&>:where(a,button)]:px-5", className, )} {...props} > {children} {showCloseButton && ( )}
); } function DialogTitle({ className, ...props }: React.ComponentProps) { return ( ); } function DialogDescription({ className, ...props }: React.ComponentProps) { return ( ); } export { CORNER_CLOSE, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, };