INNER CODE UNIT · JavaScript
tally
rootSunc/CNEquity · frontend/src/main.js:178
const tally = (counts) => chipRow(Object.entries(counts || {}).map(([k, n]) => chip(statusText(k), TONE[k], n)));
/** A zero is a result, not an absence. */
const num = (n, cls = "") => (n ? (cls ? `<span class="${cls}">${fmt(n)}</span>` : fmt(n)) : '<span class="muted">0</span>');
/** One table, one shape.
*
* Every report table below was hand-rolling `<table><tr><th>` with no
* thead/tbody and its own empty-row markup, so right-alignment and the empty
* state drifted panel by panel. Columns are declared once: a bare string is a
* plain header, `{h, n: true}` right-aligns the header the way the tabular
* numbers underneath it already are. */
function dataTable(cols, rows, empty, cls = "") {
const head = cols
.map((c) => (typeof c === "string" ? { h: c } : c))
.map((c) => `<th${c.n ? ' class="n"' : ""}>${esc(c.h)}</th>`)
.join("");
const body = rows.length