@zoodogood/utils 1.0.7-change.843 → 1.0.7-change.884
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.
|
@@ -60,7 +60,7 @@ declare class TextTableBuilder {
|
|
|
60
60
|
addMultilineRowWithElements(elements: ITableCell["value"][], optionsForEveryElement?: Partial<ICellOptions>, useOnAddingOptions?: ICellBuilderOptions): this;
|
|
61
61
|
addEmptyRow(): this;
|
|
62
62
|
addRowSeparator(setSymbol?: TCellSetSymbolCallback): this;
|
|
63
|
-
addCellAtRow(rowIndex: number, cellValue: ITableCell["value"], cellOptions: ICellOptions): this;
|
|
63
|
+
addCellAtRow(rowIndex: number, cellValue: ITableCell["value"], cellOptions: ICellOptions, useOnAddingOptions: ICellBuilderOptions): this;
|
|
64
64
|
private pushCellToArray;
|
|
65
65
|
private pushRowToTable;
|
|
66
66
|
generateTextContent(): string;
|
|
@@ -5,8 +5,17 @@ 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
|
}
|
|
13
|
+
function emptyCell(value = "#") {
|
|
14
|
+
return {
|
|
15
|
+
value,
|
|
16
|
+
options: DEFAULT_CELL_OPTIONS,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
10
19
|
function addPaddingByCellAlign(original, totalForAdd, align) {
|
|
11
20
|
const addidableGapLeft = align === CellAlignEnum.Right
|
|
12
21
|
? totalForAdd
|
|
@@ -88,9 +97,12 @@ class TextTableGenerator {
|
|
|
88
97
|
.filter((row) => getRowType(row) === SpecialRowTypeEnum.Default)
|
|
89
98
|
.map((row) => row.length));
|
|
90
99
|
for (let index = 0; index < largestCellsCount; index++) {
|
|
91
|
-
const column = rows.map((row) =>
|
|
92
|
-
|
|
93
|
-
|
|
100
|
+
const column = rows.map((row) => {
|
|
101
|
+
var _a;
|
|
102
|
+
return getRowType(row) === SpecialRowTypeEnum.Default
|
|
103
|
+
? (_a = row.at(index)) !== null && _a !== void 0 ? _a : null
|
|
104
|
+
: { row };
|
|
105
|
+
});
|
|
94
106
|
columns.push(column);
|
|
95
107
|
}
|
|
96
108
|
return columns;
|
|
@@ -120,24 +132,25 @@ class TextTableGenerator {
|
|
|
120
132
|
})();
|
|
121
133
|
}
|
|
122
134
|
drawRow(row) {
|
|
123
|
-
var _a, _b, _c, _d, _e, _f;
|
|
135
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
124
136
|
let content = "";
|
|
125
137
|
const context = this.context;
|
|
126
|
-
const
|
|
138
|
+
const { columns } = context.metadata;
|
|
139
|
+
const columnsCount = columns.length;
|
|
127
140
|
if (getRowType(row) === SpecialRowTypeEnum.Default) {
|
|
128
141
|
row = row;
|
|
129
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 : "";
|
|
130
|
-
for (
|
|
131
|
-
const cell = row.at(+cellIndex);
|
|
132
|
-
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;
|
|
133
146
|
content += this.drawCell(cell, expectedWidth);
|
|
134
|
-
if (+cellIndex !==
|
|
147
|
+
if (+cellIndex !== columnsCount - 1) {
|
|
135
148
|
content += !cell.options.removeNextSeparator
|
|
136
149
|
? this.options.separator
|
|
137
150
|
: " ";
|
|
138
151
|
}
|
|
139
152
|
}
|
|
140
|
-
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 : "";
|
|
141
154
|
return content;
|
|
142
155
|
}
|
|
143
156
|
if (getRowType(row) === SpecialRowTypeEnum.Display) {
|
|
@@ -266,15 +279,15 @@ class TextTableBuilder {
|
|
|
266
279
|
this.pushRowToTable(row);
|
|
267
280
|
return this;
|
|
268
281
|
}
|
|
269
|
-
addCellAtRow(rowIndex, cellValue, cellOptions) {
|
|
282
|
+
addCellAtRow(rowIndex, cellValue, cellOptions, useOnAddingOptions) {
|
|
270
283
|
const row = this.rows.at(rowIndex);
|
|
271
284
|
if (!row) {
|
|
272
|
-
throw new RangeError(
|
|
285
|
+
throw new RangeError();
|
|
273
286
|
}
|
|
274
287
|
if (getRowType(row) !== SpecialRowTypeEnum.Default) {
|
|
275
288
|
throw new Error("Is not default row: without cells");
|
|
276
289
|
}
|
|
277
|
-
this.pushCellToArray(row, cellValue, cellOptions);
|
|
290
|
+
this.pushCellToArray(row, cellValue, cellOptions, useOnAddingOptions);
|
|
278
291
|
return this;
|
|
279
292
|
}
|
|
280
293
|
pushCellToArray(array, cellValue, cellOptions = {}, pushOptions) {
|