UNPKG

1.35 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 _wrapCell = _interopRequireDefault(require("./wrapCell"));
11
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14/**
15 * @param {Array} unmappedRows
16 * @param {number[]} rowHeightIndex
17 * @param {Object} config
18 * @returns {Array}
19 */
20const mapDataUsingRowHeightIndex = (unmappedRows, rowHeightIndex, config) => {
21 const tableWidth = unmappedRows[0].length;
22 const mappedRows = unmappedRows.map((cells, index0) => {
23 const rowHeight = _lodash.default.times(rowHeightIndex[index0], () => {
24 return new Array(tableWidth).fill('');
25 }); // rowHeight
26 // [{row index within rowSaw; index2}]
27 // [{cell index within a virtual row; index1}]
28
29
30 cells.forEach((value, index1) => {
31 const cellLines = (0, _wrapCell.default)(value, config.columns[index1].width, config.columns[index1].wrapWord);
32 cellLines.forEach((cellLine, index2) => {
33 rowHeight[index2][index1] = cellLine;
34 });
35 });
36 return rowHeight;
37 });
38 return _lodash.default.flatten(mappedRows);
39};
40
41var _default = mapDataUsingRowHeightIndex;
42exports.default = _default;
43//# sourceMappingURL=mapDataUsingRowHeightIndex.js.map
\No newline at end of file