/** @jsxRuntime automatic */ /** @jsxImportSource @alchemy.run/sigil */ import type { ReactNode } from "react"; import { Box } from "./Layout.tsx"; import { Text } from "./Typography.tsx"; export interface DescriptionItem { readonly label: ReactNode; readonly value: ReactNode; } type DescriptionListProps = { readonly items: ReadonlyArray; readonly labelWidth?: number; /** Put values on their own line when horizontal space must not truncate them. */ readonly stacked?: boolean; }; export function DescriptionList({ items, labelWidth = 16, stacked = false }: DescriptionListProps) { return ( {items.map((item, index) => ( {item.label} {/* Element values render bare: a Box (e.g. multi-line AnsiText output) cannot nest inside Text. */} {typeof item.value === "string" || typeof item.value === "number" ? ( {item.value} ) : ( item.value )} ))} ); }