UNPKG

@curveball/browser

Version:

Automatic API browser generator. A middleware that turns your JSON responses into HTML if accessed by a browser.

29 lines 967 B
import * as React from 'react'; import { parse } from 'csv-parse/sync'; export function CsvBody(props) { const data = parse(props.resourceState.data); const table = []; let first = true; let rowId = 0; for (const row of data) { rowId++; let colId = 0; const cells = []; for (const cell of row) { colId++; if (first) { cells.push(React.createElement("th", { key: colId }, cell)); } else { cells.push(React.createElement("td", { key: colId }, cell)); } } table.push(React.createElement("tr", { key: rowId }, cells)); first = false; } return React.createElement(React.Fragment, null, React.createElement("h2", null, "Contents"), React.createElement("div", { className: "body-csv" }, React.createElement("table", null, table))); } //# sourceMappingURL=csv-body.js.map