drawTable.js 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.drawTable = void 0;
  4. const drawBorder_1 = require("./drawBorder");
  5. const drawContent_1 = require("./drawContent");
  6. const drawRow_1 = require("./drawRow");
  7. const utils_1 = require("./utils");
  8. const drawTable = (rows, outputColumnWidths, rowHeights, config) => {
  9. const { drawHorizontalLine, singleLine, } = config;
  10. const contents = (0, utils_1.groupBySizes)(rows, rowHeights).map((group, groupIndex) => {
  11. return group.map((row) => {
  12. return (0, drawRow_1.drawRow)(row, { ...config,
  13. rowIndex: groupIndex });
  14. }).join('');
  15. });
  16. return (0, drawContent_1.drawContent)({ contents,
  17. drawSeparator: (index, size) => {
  18. // Top/bottom border
  19. if (index === 0 || index === size) {
  20. return drawHorizontalLine(index, size);
  21. }
  22. return !singleLine && drawHorizontalLine(index, size);
  23. },
  24. elementType: 'row',
  25. rowIndex: -1,
  26. separatorGetter: (0, drawBorder_1.createTableBorderGetter)(outputColumnWidths, { ...config,
  27. rowCount: contents.length }),
  28. spanningCellManager: config.spanningCellManager });
  29. };
  30. exports.drawTable = drawTable;
  31. //# sourceMappingURL=drawTable.js.map