UNPKG

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