table.js 1.4 KB

1234567891011121314151617181920212223242526
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.table = void 0;
  4. const alignTableData_1 = require("./alignTableData");
  5. const calculateCellWidths_1 = require("./calculateCellWidths");
  6. const calculateRowHeights_1 = require("./calculateRowHeights");
  7. const drawTable_1 = require("./drawTable");
  8. const makeTableConfig_1 = require("./makeTableConfig");
  9. const mapDataUsingRowHeights_1 = require("./mapDataUsingRowHeights");
  10. const padTableData_1 = require("./padTableData");
  11. const stringifyTableData_1 = require("./stringifyTableData");
  12. const truncateTableData_1 = require("./truncateTableData");
  13. const validateTableData_1 = require("./validateTableData");
  14. const table = (data, userConfig = {}) => {
  15. validateTableData_1.validateTableData(data);
  16. let rows = stringifyTableData_1.stringifyTableData(data);
  17. const config = makeTableConfig_1.makeTableConfig(rows, userConfig);
  18. rows = truncateTableData_1.truncateTableData(rows, config);
  19. const rowHeights = calculateRowHeights_1.calculateRowHeights(rows, config);
  20. rows = mapDataUsingRowHeights_1.mapDataUsingRowHeights(rows, rowHeights, config);
  21. rows = alignTableData_1.alignTableData(rows, config);
  22. rows = padTableData_1.padTableData(rows, config);
  23. const cellWidths = calculateCellWidths_1.calculateCellWidths(rows[0]);
  24. return drawTable_1.drawTable(rows, cellWidths, rowHeights, config);
  25. };
  26. exports.table = table;