1 import _ from 'lodash';
2 import calculateCellHeight from './calculateCellHeight';
5 * Calculates the vertical row span index.
7 * @param {Array[]} rows
8 * @param {Object} config
11 export default (rows, config) => {
12 const tableWidth = rows[0].length;
14 const rowSpanIndex = [];
16 rows.forEach((cells) => {
17 const cellHeightIndex = new Array(tableWidth).fill(1);
19 cells.forEach((value, index1) => {
20 if (!_.isNumber(config.columns[index1].width)) {
21 throw new TypeError('column[index].width must be a number.');
24 if (!_.isBoolean(config.columns[index1].wrapWord)) {
25 throw new TypeError('column[index].wrapWord must be a boolean.');
28 cellHeightIndex[index1] = calculateCellHeight(value, config.columns[index1].width, config.columns[index1].wrapWord);
31 rowSpanIndex.push(_.max(cellHeightIndex));