injectHeaderConfig.js 1.1 KB

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.injectHeaderConfig = void 0;
  4. const injectHeaderConfig = (rows, config) => {
  5. var _a;
  6. let spanningCellConfig = (_a = config.spanningCells) !== null && _a !== void 0 ? _a : [];
  7. const headerConfig = config.header;
  8. const adjustedRows = [...rows];
  9. if (headerConfig) {
  10. spanningCellConfig = spanningCellConfig.map(({ row, ...rest }) => {
  11. return { ...rest,
  12. row: row + 1 };
  13. });
  14. const { content, ...headerStyles } = headerConfig;
  15. spanningCellConfig.unshift({ alignment: 'center',
  16. col: 0,
  17. colSpan: rows[0].length,
  18. paddingLeft: 1,
  19. paddingRight: 1,
  20. row: 0,
  21. wrapWord: false,
  22. ...headerStyles });
  23. adjustedRows.unshift([content, ...Array.from({ length: rows[0].length - 1 }).fill('')]);
  24. }
  25. return [adjustedRows,
  26. spanningCellConfig];
  27. };
  28. exports.injectHeaderConfig = injectHeaderConfig;
  29. //# sourceMappingURL=injectHeaderConfig.js.map