1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.drawContent = void 0;
|
4 | const drawContent = (parameters) => {
|
5 | const { contents, separatorGetter, drawSeparator, spanningCellManager, rowIndex, elementType } = parameters;
|
6 | const contentSize = contents.length;
|
7 | const result = [];
|
8 | if (drawSeparator(0, contentSize)) {
|
9 | result.push(separatorGetter(0, contentSize));
|
10 | }
|
11 | contents.forEach((content, contentIndex) => {
|
12 | if (!elementType || elementType === 'border' || elementType === 'row') {
|
13 | result.push(content);
|
14 | }
|
15 | if (elementType === 'cell' && rowIndex === undefined) {
|
16 | result.push(content);
|
17 | }
|
18 | if (elementType === 'cell' && rowIndex !== undefined) {
|
19 |
|
20 | const containingRange = spanningCellManager === null || spanningCellManager === void 0 ? void 0 : spanningCellManager.getContainingRange({ col: contentIndex,
|
21 | row: rowIndex });
|
22 |
|
23 |
|
24 | if (!containingRange || contentIndex === containingRange.topLeft.col) {
|
25 | result.push(content);
|
26 | }
|
27 | }
|
28 |
|
29 | if (contentIndex + 1 < contentSize && drawSeparator(contentIndex + 1, contentSize)) {
|
30 | const separator = separatorGetter(contentIndex + 1, contentSize);
|
31 | if (elementType === 'cell' && rowIndex !== undefined) {
|
32 | const currentCell = { col: contentIndex + 1,
|
33 | row: rowIndex };
|
34 |
|
35 | const containingRange = spanningCellManager === null || spanningCellManager === void 0 ? void 0 : spanningCellManager.getContainingRange(currentCell);
|
36 | if (!containingRange || containingRange.topLeft.col === currentCell.col) {
|
37 | result.push(separator);
|
38 | }
|
39 | }
|
40 | else {
|
41 | result.push(separator);
|
42 | }
|
43 | }
|
44 | });
|
45 | if (drawSeparator(contentSize, contentSize)) {
|
46 | result.push(separatorGetter(contentSize, contentSize));
|
47 | }
|
48 | return result.join('');
|
49 | };
|
50 | exports.drawContent = drawContent;
|
51 |
|
\ | No newline at end of file |