import { ArrowLeftIcon } from "lucide-react"; import { Dialog } from "radix-ui"; import { forwardRef, type ComponentPropsWithoutRef, type ComponentRef, type ReactNode, } from "react"; import { cn } from "../../../lib/cn"; import { useWindowLayerOpen } from "../../../lib/window-layer"; import { Button } from "../../../ui/button"; import { containedPortal } from "../../../ui/portal-container"; const DialogContainedPortal = containedPortal(Dialog.Portal); /** * The whole-window layer an artifact expands into: a Radix dialog with the * desktop app's window-control clearance, so Escape closes the innermost layer * and focus returns to where it came from. */ export const ArtifactFullWindowDialog = /* @__PURE__ */ forwardRef< ComponentRef, { onClose: () => void; children: ReactNode; } & Omit, "children" | "className"> >(function ArtifactFullWindowDialog({ onClose, children, ...content }, ref) { useWindowLayerOpen(true); return ( !open && onClose()}> {children} ); }); /** The single bar across the top of a full-window artifact; it also drags the desktop window. */ export function ArtifactFullWindowBar({ className, children, }: { className?: string | undefined; children: ReactNode; }) { return (
{children}
); } /** * An artifact shown by itself across the whole window, with one bar: back to * its page, its name and its main action. It matches a Site's full screen, * including the desktop app's window-control clearance, so every artifact * expands the same way. A Radix dialog, so an image lightbox opened from it * stacks above it and Escape closes the innermost layer first. */ export function ArtifactFullView({ title, actions, onBack, children, }: { title: string; actions?: ReactNode | undefined; onBack: () => void; children: ReactNode; }) { return ( event.preventDefault()}>
{title}
{actions ?
{actions}
: null}
{children}
); }