import type { ReactNode } from "react"; import { cn } from "@/components/ui/cn"; export interface KvItem { label: ReactNode; value: ReactNode; /** hide the row when the value is unknown (default) or show “—” */ keepEmpty?: boolean; } /** * Compact definition list for entity facts (address, tier, cooling, website…). Rows with null / undefined / "" / "—" * values are dropped unless `keepEmpty`, so pages never show a wall of dashes. */ export function KeyValueList({ items, className, columns = 1 }: { items: KvItem[]; className?: string; columns?: 1 | 2 }) { const rows = items.filter((it) => it.keepEmpty || (it.value !== null && it.value !== undefined && it.value !== "" && it.value !== "—")); if (!rows.length) return null; return (
{rows.map((it, i) => (
{it.label}
{it.value ?? —}
))}
); } /** Honest placeholder for a section whose data the source does not publish. */ export function NotPublished({ what, className }: { what: string; className?: string }) { return

{what} — not published by the sources indexed so far.

; } /** External link with safe rel and host-only label by default. */ export function ExtLink({ href, children, className }: { href: string; children?: ReactNode; className?: string }) { let label: ReactNode = children; if (!label) { try { label = new URL(href).host.replace(/^www\./, ""); } catch { label = href; } } return ( {label} ); }