1 import isBoolean from 'is-boolean-object';
2 import isNumber from 'is-number-object';
3 import calculateCellHeight from './calculateCellHeight';
6 * Calculates the vertical row span index.
8 * @param {Array[]} rows
9 * @param {object} config
12 export default (rows, config) => {
13 const tableWidth = rows[0].length;
15 const rowSpanIndex = [];
17 rows.forEach((cells) => {
18 const cellHeightIndex = new Array(tableWidth).fill(1);
20 cells.forEach((value, index1) => {
21 if (!isNumber(config.columns[index1].width)) {
22 throw new TypeError('column[index].width must be a number.');
25 if (!isBoolean(config.columns[index1].wrapWord)) {
26 throw new TypeError('column[index].wrapWord must be a boolean.');
29 cellHeightIndex[index1] = calculateCellHeight(value, config.columns[index1].width, config.columns[index1].wrapWord);
32 rowSpanIndex.push(Math.max(...cellHeightIndex));