import { fmtValue, unitLabel } from '@/lib/format'; import { SourceBadge, type ProvenanceInfo } from './source-badge'; import { ClaimBadge, type ClaimKind } from './badge'; /** * Every numeric value on the site renders through : number + unit, source badge with * provenance popover, and a population/period caption (CLAUDE.md UI rules). */ export function Value({ value, unit, provenance, caption, claim, size = 'md', ci, estimateType, className = '', }: { value: number | string | null | undefined; unit?: string | null; provenance?: ProvenanceInfo | null; caption?: string | null; claim?: ClaimKind; size?: 'sm' | 'md' | 'lg'; ci?: [number | null | undefined, number | null | undefined]; estimateType?: string | null; className?: string; }) { const sizeCls = size === 'lg' ? 'text-2xl font-display' : size === 'sm' ? 'text-[13.5px]' : 'text-base'; const hasCi = ci && ci[0] != null && ci[1] != null; return ( {fmtValue(value, unit)} {unit && unit !== 'probability' ? {unitLabel(unit)} : null} {hasCi ? ( ({fmtValue(ci![0], unit)}–{fmtValue(ci![1], unit)}) ) : null} {estimateType && estimateType !== 'observed' ? {estimateType} : null} {provenance ? : null} {claim ? : null} {caption ? {caption} : null} ); }