/* Copyright 2026 Marimo. All rights reserved. */ import { X } from "lucide-react"; import { Dialog as DialogPrimitive } from "radix-ui"; import * as React from "react"; import { StyleNamespace } from "@/theme/namespace"; import { cn } from "@/utils/cn"; import { withFullScreenAsRoot } from "./fullscreen"; import { useRestoreFocus } from "./use-restore-focus"; const Dialog = DialogPrimitive.Root; const DialogTrigger = DialogPrimitive.Trigger; const DialogPortal = withFullScreenAsRoot( ({ className, children, ...props }: DialogPrimitive.DialogPortalProps & { className?: string }) => (
{children}
), ); DialogPortal.displayName = DialogPrimitive.Portal.displayName; const DialogOverlay = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; const DialogContent = React.forwardRef< React.ElementRef, { usePortal?: boolean } & React.ComponentPropsWithoutRef< typeof DialogPrimitive.Content > >(({ className, children, usePortal = true, ...props }, ref) => { // store the last focused element so we can restore it when the dialog closes const restoreFocus = useRestoreFocus(); const content = ( {children} Close ); return usePortal ? ( {content} ) : ( content ); }); DialogContent.displayName = DialogPrimitive.Content.displayName; const DialogHeader = ({ className, ...props }: React.HTMLAttributes) => (
); DialogHeader.displayName = "DialogHeader"; const DialogFooter = ({ className, ...props }: React.HTMLAttributes) => (
); DialogFooter.displayName = "DialogFooter"; const DialogTitle = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); DialogTitle.displayName = DialogPrimitive.Title.displayName; const DialogDescription = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); DialogDescription.displayName = DialogPrimitive.Description.displayName; export { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, };