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.

47 lines
1.5 KiB

4 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _max2 = _interopRequireDefault(require("lodash/max"));
  7. var _isBoolean2 = _interopRequireDefault(require("lodash/isBoolean"));
  8. var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
  9. var _calculateCellHeight = _interopRequireDefault(require("./calculateCellHeight"));
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. /**
  12. * Calculates the vertical row span index.
  13. *
  14. * @param {Array[]} rows
  15. * @param {Object} config
  16. * @returns {number[]}
  17. */
  18. const calculateRowHeightIndex = (rows, config) => {
  19. const tableWidth = rows[0].length;
  20. const rowSpanIndex = [];
  21. rows.forEach(cells => {
  22. const cellHeightIndex = new Array(tableWidth).fill(1);
  23. cells.forEach((value, index1) => {
  24. if (!(0, _isNumber2.default)(config.columns[index1].width)) {
  25. throw new TypeError('column[index].width must be a number.');
  26. }
  27. if (!(0, _isBoolean2.default)(config.columns[index1].wrapWord)) {
  28. throw new TypeError('column[index].wrapWord must be a boolean.');
  29. }
  30. cellHeightIndex[index1] = (0, _calculateCellHeight.default)(value, config.columns[index1].width, config.columns[index1].wrapWord);
  31. });
  32. rowSpanIndex.push((0, _max2.default)(cellHeightIndex));
  33. });
  34. return rowSpanIndex;
  35. };
  36. var _default = calculateRowHeightIndex;
  37. exports.default = _default;
  38. //# sourceMappingURL=calculateRowHeightIndex.js.map