'use client' import * as React from 'react' import { cn } from '../../lib/utils' export type RecordFieldKind = 'text' | 'longtext' | 'url' | 'boolean' | 'json' export interface RecordField { label: string value: string kind?: RecordFieldKind } export interface RecordDetailProps { fields: RecordField[] emptyMessage?: string className?: string /** * Show declared fields even when they have no value — the header stays with a * muted placeholder — instead of hiding them. Lets a reader tell that a field * (e.g. `content`) exists on the record but simply wasn't captured, rather than * wondering whether it's missing from the schema. Default false (hide empties). */ showEmpty?: boolean } const URL_RE = /^https?:\/\//i function hasValue(f: RecordField): boolean { return f.value != null && String(f.value).trim() !== '' } /** * Read-optimized view of a record's fields (startsim-768w.17.4). Renders short * fields as a compact label/value list (auto-linking urls), long-text fields as * readable, newline-preserving prose blocks (right for extracted article bodies), * and json as a scrollable code block. Generic: a consumer maps its own schema to * `fields` and this owns the layout, so every Foundry tenant's detail drawer reads * the same without duplicating the view. */ export function RecordDetail({ fields, emptyMessage = 'No details.', className, showEmpty = false }: RecordDetailProps) { const visible = showEmpty ? fields : fields.filter(hasValue) const shorts = visible.filter((f) => f.kind !== 'longtext' && f.kind !== 'json') const longs = visible.filter((f) => f.kind === 'longtext') const jsons = visible.filter((f) => f.kind === 'json') if (visible.length === 0) { return

{emptyMessage}

} return (
{shorts.length > 0 && (
{shorts.map((f, i) => { const empty = !hasValue(f) const isUrl = !empty && (f.kind === 'url' || URL_RE.test(f.value)) return (
{f.label}
{empty ? ( ) : isUrl ? ( {f.value} ) : ( f.value )}
) })}
)} {longs.map((f, i) => (

{f.label}

{hasValue(f) ? (
{f.value}
) : (

Not captured.

)}
))} {jsons.map((f, i) => (

{f.label}

{hasValue(f) ? (
              {f.value}
            
) : (

Not captured.

)}
))}
) }