feat(viewer): add datatable content type — sortable, CSV export + copy to Sheets/Excel#178
Merged
Conversation
…t + copy to Sheets/Excel
A new first-class content type for tabular data the human will read precisely or
pull into a spreadsheet (cost breakdowns, benchmark results, query results).
- **Schema:** `{ title?, columns, rows, note? }` — `columns` is `string[]` or
`{label, align?}[]`; `rows` is `(string|number|boolean|null)[][]`. Columns with
all-numeric cells auto right-align.
- **Renderer** (`datatable.ts`, plain DOM — no React): a sortable table (click a
header to cycle asc→desc→unsorted; numeric collation; nulls last) with a toolbar:
**Copy** writes TSV to the clipboard (pastes cleanly into Excel/Google Sheets) and
**Download CSV** saves an RFC-4180 file. Both reflect the current sort order.
Self-sizing, horizontally scrollable, sticky header, zebra rows.
- **Validation** added to the shared core `validateContent` (path-pointed), so it
flows through every push/patch/restore path and through `panes` recursion, and the
CLI fast-fails offline once republished.
- Registered as a lazy chunk in `registry.ts`; themed in `style.css`.
- Recipe (`cost-table.datatable.json`) + `datatable.md` + SKILL/command decision-guide
entries; gallery image + GALLERY.md row; a seeded `finops/cloud-spend` demo board.
Tests: `datatable.test.ts` (validation + toCSV/toTSV/parse/compareCells, all pure/
node-safe); rich e2e pushes a datatable and asserts render + header-sort + clipboard
TSV round-trip + CSV download.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A new first-class
datatablecontent type: a clean, sortable table for tabular data the human will read precisely or pull into a spreadsheet — with one-click Copy (→ Excel / Google Sheets) and Download CSV.Requested: "add a datatable type, where I can export to CSV (or equivalent) and copy-paste directly to Excel, google sheets, etc." Chosen interactivity: sortable columns (no search/pagination in v1).
Schema
{ "title": "Cloud spend by service", "columns": ["Service", "Region", { "label": "Monthly (USD)", "align": "right" }, "Owner"], "rows": [["Compute Engine", "us-central1", 18420, "platform"], ...], "note": "USD, excludes committed-use discounts." }columns:string[]or{label, align?}[]. A column with all-numeric cells auto right-aligns.rows:(string|number|boolean|null)[][]; short rows render blank cells.Behavior
aria-sort).panes.Wiring (mirrors the
calltreetype)validateContent(validateDataTable, path-pointed) → flows through push/patch/restore + panes recursion; CLI fast-fails offline once republished.registry.ts; themed instyle.css.cost-table.datatable.json+datatable.md+ SKILL/command decision-guide entries.finops/cloud-spenddemo board on/w/demo/.Verification
npx vitest run→ 444/444 (newdatatable.test.ts: validation +toCSV/toTSV/parse/compareCells, all pure).datatable-*.jschunk emits; NUL-byte check clean.test:e2e:nobuild→ rich 62/62 (datatable: render 8 rows + header-sort + clipboard-TSV round-trip + CSV download), board-sort 12/12.Viewer renders it on deploy; recipe-docs reach plugin installs and
--type datatablevia the installed CLI on their (user-gated) republish — pushing via the viewer/raw HTTP works immediately.