@zoodogood/utils 1.0.7-change.854 → 1.0.7-change.896
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -64,6 +64,7 @@ declare class TextTableBuilder {
|
|
|
64
64
|
private pushCellToArray;
|
|
65
65
|
private pushRowToTable;
|
|
66
66
|
generateTextContent(): string;
|
|
67
|
+
addRowWithUnwrappedCells(cells: ITableCell[], useOnAddingOptions?: ICellBuilderOptions): this;
|
|
67
68
|
}
|
|
68
69
|
export { TextTableBuilder };
|
|
69
70
|
export { SpecialRowTypeEnum, CellAlignEnum, BorderDirectionEnum };
|
|
@@ -5,11 +5,14 @@ function getRowType(row) {
|
|
|
5
5
|
return row.type;
|
|
6
6
|
}
|
|
7
7
|
function isCell(target) {
|
|
8
|
+
if (!target) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
8
11
|
return "value" in target && "options" in target;
|
|
9
12
|
}
|
|
10
|
-
function emptyCell(
|
|
13
|
+
function emptyCell() {
|
|
11
14
|
return {
|
|
12
|
-
value,
|
|
15
|
+
value: "",
|
|
13
16
|
options: DEFAULT_CELL_OPTIONS,
|
|
14
17
|
};
|
|
15
18
|
}
|
|
@@ -97,7 +100,7 @@ class TextTableGenerator {
|
|
|
97
100
|
const column = rows.map((row) => {
|
|
98
101
|
var _a;
|
|
99
102
|
return getRowType(row) === SpecialRowTypeEnum.Default
|
|
100
|
-
? (_a = row.at(index)) !== null && _a !== void 0 ? _a :
|
|
103
|
+
? (_a = row.at(index)) !== null && _a !== void 0 ? _a : null
|
|
101
104
|
: { row };
|
|
102
105
|
});
|
|
103
106
|
columns.push(column);
|
|
@@ -129,24 +132,25 @@ class TextTableGenerator {
|
|
|
129
132
|
})();
|
|
130
133
|
}
|
|
131
134
|
drawRow(row) {
|
|
132
|
-
var _a, _b, _c, _d, _e, _f;
|
|
135
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
133
136
|
let content = "";
|
|
134
137
|
const context = this.context;
|
|
135
|
-
const
|
|
138
|
+
const { columns } = context.metadata;
|
|
139
|
+
const columnsCount = columns.length;
|
|
136
140
|
if (getRowType(row) === SpecialRowTypeEnum.Default) {
|
|
137
141
|
row = row;
|
|
138
142
|
content += (_c = (_b = (_a = this.options).borderLeft) === null || _b === void 0 ? void 0 : _b.call(_a, context, context.currentRow)) !== null && _c !== void 0 ? _c : "";
|
|
139
|
-
for (
|
|
140
|
-
const cell = row.at(+cellIndex);
|
|
141
|
-
const expectedWidth =
|
|
143
|
+
for (let cellIndex = 0; cellIndex < columnsCount; cellIndex++) {
|
|
144
|
+
const cell = (_d = row.at(+cellIndex)) !== null && _d !== void 0 ? _d : emptyCell();
|
|
145
|
+
const expectedWidth = columns.at(+cellIndex).largestLength;
|
|
142
146
|
content += this.drawCell(cell, expectedWidth);
|
|
143
|
-
if (+cellIndex !==
|
|
147
|
+
if (+cellIndex !== columnsCount - 1) {
|
|
144
148
|
content += !cell.options.removeNextSeparator
|
|
145
149
|
? this.options.separator
|
|
146
150
|
: " ";
|
|
147
151
|
}
|
|
148
152
|
}
|
|
149
|
-
content += (
|
|
153
|
+
content += (_g = (_f = (_e = this.options).borderRight) === null || _f === void 0 ? void 0 : _f.call(_e, context, context.currentRow)) !== null && _g !== void 0 ? _g : "";
|
|
150
154
|
return content;
|
|
151
155
|
}
|
|
152
156
|
if (getRowType(row) === SpecialRowTypeEnum.Display) {
|
|
@@ -302,6 +306,14 @@ class TextTableBuilder {
|
|
|
302
306
|
generateTextContent() {
|
|
303
307
|
return new TextTableGenerator(this.rows, this.options).generateTextContent();
|
|
304
308
|
}
|
|
309
|
+
addRowWithUnwrappedCells(cells, useOnAddingOptions) {
|
|
310
|
+
const row = [];
|
|
311
|
+
for (const cell of cells) {
|
|
312
|
+
this.pushCellToArray(row, cell.value, cell.options, useOnAddingOptions);
|
|
313
|
+
}
|
|
314
|
+
this.pushRowToTable(row);
|
|
315
|
+
return this;
|
|
316
|
+
}
|
|
305
317
|
}
|
|
306
318
|
export { TextTableBuilder };
|
|
307
319
|
export { SpecialRowTypeEnum, CellAlignEnum, BorderDirectionEnum };
|