UNPKG

1.08 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.injectHeaderConfig = void 0;
4const 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};
28exports.injectHeaderConfig = injectHeaderConfig;
29//# sourceMappingURL=injectHeaderConfig.js.map
\No newline at end of file