MCPcopy Index your code
hub / github.com/anomalyco/opencode / DataTable

Function DataTable

packages/console/support/src/component/result.tsx:56–85  ·  view source on GitHub ↗
(props: { rows: Record<string, unknown>[] })

Source from the content-addressed store, hash-verified

54}
55
56function DataTable(props: { rows: Record<string, unknown>[] }) {
57 const columns = () => {
58 const cols = new Set<string>()
59 for (const row of props.rows) {
60 for (const key of Object.keys(row)) cols.add(key)
61 }
62 return [...cols]
63 }
64
65 return (
66 <Show when={props.rows.length > 0} fallback={<div data-empty>(no data)</div>}>
67 <table>
68 <thead>
69 <tr>
70 <For each={columns()}>{(col) => <th>{col}</th>}</For>
71 </tr>
72 </thead>
73 <tbody>
74 <For each={props.rows}>
75 {(row) => (
76 <tr>
77 <For each={columns()}>{(col) => <td>{renderCell(row[col])}</td>}</For>
78 </tr>
79 )}
80 </For>
81 </tbody>
82 </table>
83 </Show>
84 )
85}
86
87function renderCell(value: unknown) {
88 if (value === null || value === undefined) return ""

Callers

nothing calls this directly

Calls 2

columnsFunction · 0.85
renderCellFunction · 0.85

Tested by

no test coverage detected