/**
* 视图块渲染 —— 无业务语义的展示原语(编码规范 §2 packages/ui-kit)。
* DOM 与类名自原型平移(`jc-*`),渲染输出保持 1:1。
*/
import type { ViewBlock } from '@contracts';
export function ViewBlocks({ blocks }: { readonly blocks: readonly ViewBlock[] }) {
return (
<>
{blocks.map((block, i) => (
))}
>
);
}
function Block({ block }: { block: ViewBlock }) {
switch (block.t) {
case 'callout':
return
{block.text}
;
case 'kv':
return (
{block.title !== undefined && {block.title}
}
{block.items.map((item, i) => (
- {item.k}
- {item.v}
))}
);
case 'badges':
return (
{block.title !== undefined && {block.title}
}
{block.items.map((item, i) => (
{item.label}
))}
);
case 'table':
return (
{block.title !== undefined && {block.title}
}
{block.cols.map((c, i) => (
| {c} |
))}
{block.rows.map((row, i) => (
{row.map((cell, j) => (
| {cell} |
))}
))}
);
case 'bars':
return (
{block.title !== undefined && {block.title}
}
{block.items.map((item, i) => (
{item.label}
{item.text ?? item.value}
))}
);
case 'donut':
return (
{block.title !== undefined && {block.title}
}
{block.items.map((item, i) => (
-
{item.value}
{item.label}
))}
);
case 'cards':
return (
{block.title !== undefined && {block.title}
}
{block.items.map((item, i) => (
{item.tag}
{item.title}
{item.swap !== undefined && (
{item.swap.from} → {item.swap.to}
)}
{item.big}
{item.bigLabel !== undefined && {item.bigLabel}}
{item.note !== undefined && {item.note}
}
))}
);
case 'waiting':
return (
{block.label}
{block.hint !== undefined && {block.hint}}
);
case 'mail':
return (
{block.subject}
{block.from} → {block.to}
{block.body}
);
case 'files':
return (
{block.title !== undefined && {block.title}
}
{block.items.map((item, i) => (
{item.label}
{item.desc}
))}
);
}
}