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.

calculateRowHeightIndex.js 1.3KB

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