1 import flatten from 'lodash.flatten';
2 import wrapCell from './wrapCell';
5 * @param {Array} unmappedRows
6 * @param {number[]} rowHeightIndex
7 * @param {object} config
10 export default (unmappedRows, rowHeightIndex, config) => {
11 const tableWidth = unmappedRows[0].length;
13 const mappedRows = unmappedRows.map((cells, index0) => {
14 const rowHeight = Array.from(new Array(rowHeightIndex[index0]), () => {
15 return new Array(tableWidth).fill('');
19 // [{row index within rowSaw; index2}]
20 // [{cell index within a virtual row; index1}]
22 cells.forEach((value, index1) => {
23 const cellLines = wrapCell(value, config.columns[index1].width, config.columns[index1].wrapWord);
25 cellLines.forEach((cellLine, index2) => {
26 rowHeight[index2][index1] = cellLine;
33 return flatten(mappedRows);