Ohm-Management - Projektarbeit B-ME
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.

mapDataUsingRowHeightIndex.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _lodash = _interopRequireDefault(require("lodash"));
  7. var _wrapString = _interopRequireDefault(require("./wrapString"));
  8. var _wrapWord = _interopRequireDefault(require("./wrapWord"));
  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 = _lodash.default.times(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. let chunkedValue;
  26. if (config.columns[index1].wrapWord) {
  27. chunkedValue = (0, _wrapWord.default)(value, config.columns[index1].width);
  28. } else {
  29. chunkedValue = (0, _wrapString.default)(value, config.columns[index1].width);
  30. }
  31. chunkedValue.forEach((part, index2) => {
  32. rowHeight[index2][index1] = part;
  33. });
  34. });
  35. return rowHeight;
  36. });
  37. return _lodash.default.flatten(mappedRows);
  38. };
  39. var _default = mapDataUsingRowHeightIndex;
  40. exports.default = _default;
  41. //# sourceMappingURL=mapDataUsingRowHeightIndex.js.map