You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.4 KiB

4 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _flatten2 = _interopRequireDefault(require("lodash/flatten"));
  7. var _times2 = _interopRequireDefault(require("lodash/times"));
  8. var _wrapCell = _interopRequireDefault(require("./wrapCell"));
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. /**
  11. * @param {Array} unmappedRows
  12. * @param {number[]} rowHeightIndex
  13. * @param {Object} config
  14. * @returns {Array}
  15. */
  16. const mapDataUsingRowHeightIndex = (unmappedRows, rowHeightIndex, config) => {
  17. const tableWidth = unmappedRows[0].length;
  18. const mappedRows = unmappedRows.map((cells, index0) => {
  19. const rowHeight = (0, _times2.default)(rowHeightIndex[index0], () => {
  20. return new Array(tableWidth).fill('');
  21. }); // rowHeight
  22. // [{row index within rowSaw; index2}]
  23. // [{cell index within a virtual row; index1}]
  24. cells.forEach((value, index1) => {
  25. const cellLines = (0, _wrapCell.default)(value, config.columns[index1].width, config.columns[index1].wrapWord);
  26. cellLines.forEach((cellLine, index2) => {
  27. rowHeight[index2][index1] = cellLine;
  28. });
  29. });
  30. return rowHeight;
  31. });
  32. return (0, _flatten2.default)(mappedRows);
  33. };
  34. var _default = mapDataUsingRowHeightIndex;
  35. exports.default = _default;
  36. //# sourceMappingURL=mapDataUsingRowHeightIndex.js.map