/** * lib/render-widgets.ts — shared JSX emission. * * One emitter for every CONTENT-zone stat surface the scaffolders render: * the hub pages (app/module/section home KPI grids) today, the list KPI-row * (`list.stats[]`, plan UI 2.1) next. Lives in lib/ (not in a skill folder) * because cross-skill relative imports break under the installer's folder * flattening — same rationale as lib/ba-screens.ts. * * The emitted markup targets the `StatCard` primitive scaffold-ui-primitives * owns (`@/components/ui/StatCard`) — pages composing this JSX must import it. */ export interface StatCardEmit { /** JSX expression for the label, e.g. `t('contact.widgets.total')`. */ labelExpr: string /** Full attribute value for `value=` — either a braced expression * (`{countData?.totalCount ?? 0}`) or a string literal (`"—"`). */ valueAttr: string /** Lucide component name rendered in the icon slot (already imported by the page). */ iconName?: string /** Braced-expression content for `loading=` (e.g. `countLoading`). */ loadingExpr?: string } /** Emit one `` block at the given indentation. */ export function statCardJsx(w: StatCardEmit, indent: string): string { const icon = w.iconName ? `\n${indent} icon={<${w.iconName} />}` : '' const loading = w.loadingExpr ? `\n${indent} loading={${w.loadingExpr}}` : '' return `${indent}` } /** The import line pages composing statCardJsx must carry. */ export const STAT_CARD_IMPORT = `import { StatCard } from '@/components/ui/StatCard'`