import { type ReactNode } from "react"; import { cn } from "../lib/utils"; export interface ArtifactPaneProps { eyebrow?: ReactNode; title: ReactNode; subtitle?: ReactNode; meta?: ReactNode; headerActions?: ReactNode; tabs?: ReactNode; toolbar?: ReactNode; footer?: ReactNode; emptyState?: ReactNode; children?: ReactNode; className?: string; contentClassName?: string; /** Extra classes for the header band (e.g. to align its surface with the host chrome). */ headerClassName?: string; /** * Suppress the eyebrow/title/subtitle/meta block. Use when the host already * shows the artifact's identity elsewhere (e.g. a surrounding path row), so the * pane keeps only its tabs, toolbar, and header actions. The whole header row * collapses when nothing else would render in it. */ hideTitleBlock?: boolean; } /** * ArtifactPane — shared frame for files, previews, documents, inspectors, and * other artifact-like surfaces inside sandbox applications. */ export function ArtifactPane({ eyebrow, title, subtitle, meta, headerActions, tabs, toolbar, footer, emptyState, children, className, contentClassName, headerClassName, hideTitleBlock = false, }: ArtifactPaneProps) { const hasContent = children !== undefined && children !== null; // With the title block hidden, still render the top row if there are header // actions to place; the block itself just collapses to empty. const showTitleRow = !hideTitleBlock || Boolean(headerActions); const hasHeader = showTitleRow || Boolean(tabs) || Boolean(toolbar); // The toolbar's top divider only reads as a separator when something sits // above it; as the header's first row it would double the host's own border. const toolbarNeedsDivider = showTitleRow || Boolean(tabs); return (
{hasHeader && (
{showTitleRow && (
{!hideTitleBlock && ( <> {eyebrow && (
{eyebrow}
)}
{title}
{(subtitle || meta) && (
{subtitle && {subtitle}} {meta && {meta}}
)} )}
{headerActions && (
{headerActions}
)}
)} {tabs} {toolbar && (
{toolbar}
)}
)}
{hasContent ? ( children ) : emptyState ? (
{emptyState}
) : null}
{footer && ( )}
); }