Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

drawTable.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _drawBorder = require("./drawBorder");
  7. var _drawRow = _interopRequireDefault(require("./drawRow"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. /**
  10. * @param {Array} rows
  11. * @param {Object} border
  12. * @param {Array} columnSizeIndex
  13. * @param {Array} rowSpanIndex
  14. * @param {Function} drawHorizontalLine
  15. * @returns {string}
  16. */
  17. const drawTable = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) => {
  18. let output;
  19. let realRowIndex;
  20. let rowHeight;
  21. const rowCount = rows.length;
  22. realRowIndex = 0;
  23. output = '';
  24. if (drawHorizontalLine(realRowIndex, rowCount)) {
  25. output += (0, _drawBorder.drawBorderTop)(columnSizeIndex, border);
  26. }
  27. rows.forEach((row, index0) => {
  28. output += (0, _drawRow.default)(row, border);
  29. if (!rowHeight) {
  30. rowHeight = rowSpanIndex[realRowIndex];
  31. realRowIndex++;
  32. }
  33. rowHeight--;
  34. if (rowHeight === 0 && index0 !== rowCount - 1 && drawHorizontalLine(realRowIndex, rowCount)) {
  35. output += (0, _drawBorder.drawBorderJoin)(columnSizeIndex, border);
  36. }
  37. });
  38. if (drawHorizontalLine(realRowIndex, rowCount)) {
  39. output += (0, _drawBorder.drawBorderBottom)(columnSizeIndex, border);
  40. }
  41. return output;
  42. };
  43. var _default = drawTable;
  44. exports.default = _default;
  45. //# sourceMappingURL=drawTable.js.map