@pdfme/schemas 5.3.6 → 5.3.7-dev.3
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.
- package/dist/cjs/__tests__/multiVariableText.test.js +8 -2
- package/dist/cjs/__tests__/multiVariableText.test.js.map +1 -1
- package/dist/cjs/src/multiVariableText/helper.js +1 -1
- package/dist/cjs/src/multiVariableText/helper.js.map +1 -1
- package/dist/cjs/src/multiVariableText/uiRender.js +1 -1
- package/dist/cjs/src/multiVariableText/uiRender.js.map +1 -1
- package/dist/esm/__tests__/multiVariableText.test.js +8 -2
- package/dist/esm/__tests__/multiVariableText.test.js.map +1 -1
- package/dist/esm/src/multiVariableText/helper.js +1 -1
- package/dist/esm/src/multiVariableText/helper.js.map +1 -1
- package/dist/esm/src/multiVariableText/uiRender.js +1 -1
- package/dist/esm/src/multiVariableText/uiRender.js.map +1 -1
- package/dist/node/__tests__/barcode.test.js +332 -0
- package/dist/node/__tests__/barcode.test.js.map +1 -0
- package/dist/node/__tests__/multiVariableText.test.js +102 -0
- package/dist/node/__tests__/multiVariableText.test.js.map +1 -0
- package/dist/node/__tests__/text.test.js +409 -0
- package/dist/node/__tests__/text.test.js.map +1 -0
- package/dist/node/__tests__/utils.test.js +132 -0
- package/dist/node/__tests__/utils.test.js.map +1 -0
- package/dist/node/src/barcodes/constants.js +20 -0
- package/dist/node/src/barcodes/constants.js.map +1 -0
- package/dist/node/src/barcodes/helper.js +145 -0
- package/dist/node/src/barcodes/helper.js.map +1 -0
- package/dist/node/src/barcodes/index.js +18 -0
- package/dist/node/src/barcodes/index.js.map +1 -0
- package/dist/node/src/barcodes/pdfRender.js +25 -0
- package/dist/node/src/barcodes/pdfRender.js.map +1 -0
- package/dist/node/src/barcodes/propPanel.js +228 -0
- package/dist/node/src/barcodes/propPanel.js.map +1 -0
- package/dist/node/src/barcodes/types.js +3 -0
- package/dist/node/src/barcodes/types.js.map +1 -0
- package/dist/node/src/barcodes/uiRender.js +89 -0
- package/dist/node/src/barcodes/uiRender.js.map +1 -0
- package/dist/node/src/checkbox/index.js +61 -0
- package/dist/node/src/checkbox/index.js.map +1 -0
- package/dist/node/src/constants.js +6 -0
- package/dist/node/src/constants.js.map +1 -0
- package/dist/node/src/date/date.js +9 -0
- package/dist/node/src/date/date.js.map +1 -0
- package/dist/node/src/date/dateTime.js +9 -0
- package/dist/node/src/date/dateTime.js.map +1 -0
- package/dist/node/src/date/helper.js +420 -0
- package/dist/node/src/date/helper.js.map +1 -0
- package/dist/node/src/date/time.js +9 -0
- package/dist/node/src/date/time.js.map +1 -0
- package/dist/node/src/date/types.js +3 -0
- package/dist/node/src/date/types.js.map +1 -0
- package/dist/node/src/graphics/cacheKey.js +6 -0
- package/dist/node/src/graphics/cacheKey.js.map +1 -0
- package/dist/node/src/graphics/image.js +167 -0
- package/dist/node/src/graphics/image.js.map +1 -0
- package/dist/node/src/graphics/imagehelper.js +124 -0
- package/dist/node/src/graphics/imagehelper.js.map +1 -0
- package/dist/node/src/graphics/svg.js +85 -0
- package/dist/node/src/graphics/svg.js.map +1 -0
- package/dist/node/src/index.js +38 -0
- package/dist/node/src/index.js.map +1 -0
- package/dist/node/src/multiVariableText/helper.js +46 -0
- package/dist/node/src/multiVariableText/helper.js.map +1 -0
- package/dist/node/src/multiVariableText/index.js +16 -0
- package/dist/node/src/multiVariableText/index.js.map +1 -0
- package/dist/node/src/multiVariableText/pdfRender.js +20 -0
- package/dist/node/src/multiVariableText/pdfRender.js.map +1 -0
- package/dist/node/src/multiVariableText/propPanel.js +130 -0
- package/dist/node/src/multiVariableText/propPanel.js.map +1 -0
- package/dist/node/src/multiVariableText/types.js +3 -0
- package/dist/node/src/multiVariableText/types.js.map +1 -0
- package/dist/node/src/multiVariableText/uiRender.js +138 -0
- package/dist/node/src/multiVariableText/uiRender.js.map +1 -0
- package/dist/node/src/radioGroup/index.js +93 -0
- package/dist/node/src/radioGroup/index.js.map +1 -0
- package/dist/node/src/select/index.js +164 -0
- package/dist/node/src/select/index.js.map +1 -0
- package/dist/node/src/shapes/line.js +60 -0
- package/dist/node/src/shapes/line.js.map +1 -0
- package/dist/node/src/shapes/rectAndEllipse.js +122 -0
- package/dist/node/src/shapes/rectAndEllipse.js.map +1 -0
- package/dist/node/src/tables/cell.js +126 -0
- package/dist/node/src/tables/cell.js.map +1 -0
- package/dist/node/src/tables/classes.js +467 -0
- package/dist/node/src/tables/classes.js.map +1 -0
- package/dist/node/src/tables/dynamicTemplate.js +17 -0
- package/dist/node/src/tables/dynamicTemplate.js.map +1 -0
- package/dist/node/src/tables/helper.js +189 -0
- package/dist/node/src/tables/helper.js.map +1 -0
- package/dist/node/src/tables/index.js +15 -0
- package/dist/node/src/tables/index.js.map +1 -0
- package/dist/node/src/tables/pdfRender.js +95 -0
- package/dist/node/src/tables/pdfRender.js.map +1 -0
- package/dist/node/src/tables/propPanel.js +101 -0
- package/dist/node/src/tables/propPanel.js.map +1 -0
- package/dist/node/src/tables/tableHelper.js +196 -0
- package/dist/node/src/tables/tableHelper.js.map +1 -0
- package/dist/node/src/tables/types.js +3 -0
- package/dist/node/src/tables/types.js.map +1 -0
- package/dist/node/src/tables/uiRender.js +367 -0
- package/dist/node/src/tables/uiRender.js.map +1 -0
- package/dist/node/src/text/constants.js +97 -0
- package/dist/node/src/text/constants.js.map +1 -0
- package/dist/node/src/text/extraFormatter.js +48 -0
- package/dist/node/src/text/extraFormatter.js.map +1 -0
- package/dist/node/src/text/helper.js +472 -0
- package/dist/node/src/text/helper.js.map +1 -0
- package/dist/node/src/text/icons/index.js +16 -0
- package/dist/node/src/text/icons/index.js.map +1 -0
- package/dist/node/src/text/index.js +15 -0
- package/dist/node/src/text/index.js.map +1 -0
- package/dist/node/src/text/pdfRender.js +156 -0
- package/dist/node/src/text/pdfRender.js.map +1 -0
- package/dist/node/src/text/propPanel.js +161 -0
- package/dist/node/src/text/propPanel.js.map +1 -0
- package/dist/node/src/text/types.js +3 -0
- package/dist/node/src/text/types.js.map +1 -0
- package/dist/node/src/text/uiRender.js +223 -0
- package/dist/node/src/text/uiRender.js.map +1 -0
- package/dist/node/src/utils.js +190 -0
- package/dist/node/src/utils.js.map +1 -0
- package/package.json +11 -4
- package/src/multiVariableText/helper.ts +1 -1
- package/src/multiVariableText/uiRender.ts +1 -1
- package/tsconfig.node.json +10 -0
@@ -0,0 +1,467 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Table = exports.Row = exports.Column = exports.Cell = void 0;
|
4
|
+
const common_1 = require("@pdfme/common");
|
5
|
+
const helper_1 = require("../text/helper");
|
6
|
+
class Cell {
|
7
|
+
constructor(raw, styles, section) {
|
8
|
+
Object.defineProperty(this, "raw", {
|
9
|
+
enumerable: true,
|
10
|
+
configurable: true,
|
11
|
+
writable: true,
|
12
|
+
value: void 0
|
13
|
+
});
|
14
|
+
Object.defineProperty(this, "text", {
|
15
|
+
enumerable: true,
|
16
|
+
configurable: true,
|
17
|
+
writable: true,
|
18
|
+
value: void 0
|
19
|
+
});
|
20
|
+
Object.defineProperty(this, "styles", {
|
21
|
+
enumerable: true,
|
22
|
+
configurable: true,
|
23
|
+
writable: true,
|
24
|
+
value: void 0
|
25
|
+
});
|
26
|
+
Object.defineProperty(this, "section", {
|
27
|
+
enumerable: true,
|
28
|
+
configurable: true,
|
29
|
+
writable: true,
|
30
|
+
value: void 0
|
31
|
+
});
|
32
|
+
Object.defineProperty(this, "contentHeight", {
|
33
|
+
enumerable: true,
|
34
|
+
configurable: true,
|
35
|
+
writable: true,
|
36
|
+
value: 0
|
37
|
+
});
|
38
|
+
Object.defineProperty(this, "contentWidth", {
|
39
|
+
enumerable: true,
|
40
|
+
configurable: true,
|
41
|
+
writable: true,
|
42
|
+
value: 0
|
43
|
+
});
|
44
|
+
Object.defineProperty(this, "wrappedWidth", {
|
45
|
+
enumerable: true,
|
46
|
+
configurable: true,
|
47
|
+
writable: true,
|
48
|
+
value: 0
|
49
|
+
});
|
50
|
+
Object.defineProperty(this, "minReadableWidth", {
|
51
|
+
enumerable: true,
|
52
|
+
configurable: true,
|
53
|
+
writable: true,
|
54
|
+
value: 0
|
55
|
+
});
|
56
|
+
Object.defineProperty(this, "minWidth", {
|
57
|
+
enumerable: true,
|
58
|
+
configurable: true,
|
59
|
+
writable: true,
|
60
|
+
value: 0
|
61
|
+
});
|
62
|
+
Object.defineProperty(this, "width", {
|
63
|
+
enumerable: true,
|
64
|
+
configurable: true,
|
65
|
+
writable: true,
|
66
|
+
value: 0
|
67
|
+
});
|
68
|
+
Object.defineProperty(this, "height", {
|
69
|
+
enumerable: true,
|
70
|
+
configurable: true,
|
71
|
+
writable: true,
|
72
|
+
value: 0
|
73
|
+
});
|
74
|
+
Object.defineProperty(this, "x", {
|
75
|
+
enumerable: true,
|
76
|
+
configurable: true,
|
77
|
+
writable: true,
|
78
|
+
value: 0
|
79
|
+
});
|
80
|
+
Object.defineProperty(this, "y", {
|
81
|
+
enumerable: true,
|
82
|
+
configurable: true,
|
83
|
+
writable: true,
|
84
|
+
value: 0
|
85
|
+
});
|
86
|
+
this.styles = styles;
|
87
|
+
this.section = section;
|
88
|
+
this.raw = raw;
|
89
|
+
const splitRegex = /\r\n|\r|\n/g;
|
90
|
+
this.text = raw.split(splitRegex);
|
91
|
+
}
|
92
|
+
getContentHeight() {
|
93
|
+
const lineCount = Array.isArray(this.text) ? this.text.length : 1;
|
94
|
+
const lineHeight = (0, common_1.pt2mm)(this.styles.fontSize) * this.styles.lineHeight;
|
95
|
+
const vPadding = this.padding('top') + this.padding('bottom');
|
96
|
+
const height = lineCount * lineHeight + vPadding;
|
97
|
+
return Math.max(height, this.styles.minCellHeight);
|
98
|
+
}
|
99
|
+
padding(name) {
|
100
|
+
return this.styles.cellPadding[name];
|
101
|
+
}
|
102
|
+
}
|
103
|
+
exports.Cell = Cell;
|
104
|
+
class Column {
|
105
|
+
constructor(index) {
|
106
|
+
Object.defineProperty(this, "index", {
|
107
|
+
enumerable: true,
|
108
|
+
configurable: true,
|
109
|
+
writable: true,
|
110
|
+
value: void 0
|
111
|
+
});
|
112
|
+
Object.defineProperty(this, "wrappedWidth", {
|
113
|
+
enumerable: true,
|
114
|
+
configurable: true,
|
115
|
+
writable: true,
|
116
|
+
value: 0
|
117
|
+
});
|
118
|
+
Object.defineProperty(this, "minReadableWidth", {
|
119
|
+
enumerable: true,
|
120
|
+
configurable: true,
|
121
|
+
writable: true,
|
122
|
+
value: 0
|
123
|
+
});
|
124
|
+
Object.defineProperty(this, "minWidth", {
|
125
|
+
enumerable: true,
|
126
|
+
configurable: true,
|
127
|
+
writable: true,
|
128
|
+
value: 0
|
129
|
+
});
|
130
|
+
Object.defineProperty(this, "width", {
|
131
|
+
enumerable: true,
|
132
|
+
configurable: true,
|
133
|
+
writable: true,
|
134
|
+
value: 0
|
135
|
+
});
|
136
|
+
this.index = index;
|
137
|
+
}
|
138
|
+
getMaxCustomCellWidth(table) {
|
139
|
+
let max = 0;
|
140
|
+
for (const row of table.allRows()) {
|
141
|
+
const cell = row.cells[this.index];
|
142
|
+
max = Math.max(max, cell.styles.cellWidth);
|
143
|
+
}
|
144
|
+
return max;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
exports.Column = Column;
|
148
|
+
class Row {
|
149
|
+
constructor(raw, index, section, cells) {
|
150
|
+
Object.defineProperty(this, "raw", {
|
151
|
+
enumerable: true,
|
152
|
+
configurable: true,
|
153
|
+
writable: true,
|
154
|
+
value: void 0
|
155
|
+
});
|
156
|
+
Object.defineProperty(this, "index", {
|
157
|
+
enumerable: true,
|
158
|
+
configurable: true,
|
159
|
+
writable: true,
|
160
|
+
value: void 0
|
161
|
+
});
|
162
|
+
Object.defineProperty(this, "section", {
|
163
|
+
enumerable: true,
|
164
|
+
configurable: true,
|
165
|
+
writable: true,
|
166
|
+
value: void 0
|
167
|
+
});
|
168
|
+
Object.defineProperty(this, "cells", {
|
169
|
+
enumerable: true,
|
170
|
+
configurable: true,
|
171
|
+
writable: true,
|
172
|
+
value: void 0
|
173
|
+
});
|
174
|
+
Object.defineProperty(this, "height", {
|
175
|
+
enumerable: true,
|
176
|
+
configurable: true,
|
177
|
+
writable: true,
|
178
|
+
value: 0
|
179
|
+
});
|
180
|
+
this.raw = raw;
|
181
|
+
this.index = index;
|
182
|
+
this.section = section;
|
183
|
+
this.cells = cells;
|
184
|
+
}
|
185
|
+
getMaxCellHeight(columns) {
|
186
|
+
return columns.reduce((acc, column) => Math.max(acc, this.cells[column.index]?.height || 0), 0);
|
187
|
+
}
|
188
|
+
getMinimumRowHeight(columns) {
|
189
|
+
return columns.reduce((acc, column) => {
|
190
|
+
const cell = this.cells[column.index];
|
191
|
+
if (!cell)
|
192
|
+
return 0;
|
193
|
+
const vPadding = cell.padding('top') + cell.padding('bottom');
|
194
|
+
const oneRowHeight = vPadding + cell.styles.lineHeight;
|
195
|
+
return oneRowHeight > acc ? oneRowHeight : acc;
|
196
|
+
}, 0);
|
197
|
+
}
|
198
|
+
}
|
199
|
+
exports.Row = Row;
|
200
|
+
class Table {
|
201
|
+
constructor(input, content) {
|
202
|
+
Object.defineProperty(this, "settings", {
|
203
|
+
enumerable: true,
|
204
|
+
configurable: true,
|
205
|
+
writable: true,
|
206
|
+
value: void 0
|
207
|
+
});
|
208
|
+
Object.defineProperty(this, "styles", {
|
209
|
+
enumerable: true,
|
210
|
+
configurable: true,
|
211
|
+
writable: true,
|
212
|
+
value: void 0
|
213
|
+
});
|
214
|
+
Object.defineProperty(this, "columns", {
|
215
|
+
enumerable: true,
|
216
|
+
configurable: true,
|
217
|
+
writable: true,
|
218
|
+
value: void 0
|
219
|
+
});
|
220
|
+
Object.defineProperty(this, "head", {
|
221
|
+
enumerable: true,
|
222
|
+
configurable: true,
|
223
|
+
writable: true,
|
224
|
+
value: void 0
|
225
|
+
});
|
226
|
+
Object.defineProperty(this, "body", {
|
227
|
+
enumerable: true,
|
228
|
+
configurable: true,
|
229
|
+
writable: true,
|
230
|
+
value: void 0
|
231
|
+
});
|
232
|
+
this.settings = input.settings;
|
233
|
+
this.styles = input.styles;
|
234
|
+
this.columns = content.columns;
|
235
|
+
this.head = content.head;
|
236
|
+
this.body = content.body;
|
237
|
+
}
|
238
|
+
static async create(arg) {
|
239
|
+
const { input, content, font, _cache } = arg;
|
240
|
+
const table = new Table(input, content);
|
241
|
+
await calculateWidths({ table, font, _cache });
|
242
|
+
return table;
|
243
|
+
}
|
244
|
+
getHeadHeight() {
|
245
|
+
return this.head.reduce((acc, row) => acc + row.getMaxCellHeight(this.columns), 0);
|
246
|
+
}
|
247
|
+
getBodyHeight() {
|
248
|
+
return this.body.reduce((acc, row) => acc + row.getMaxCellHeight(this.columns), 0);
|
249
|
+
}
|
250
|
+
allRows() {
|
251
|
+
return this.head.concat(this.body);
|
252
|
+
}
|
253
|
+
getWidth() {
|
254
|
+
return this.settings.tableWidth;
|
255
|
+
}
|
256
|
+
getHeight() {
|
257
|
+
return (this.settings.showHead ? this.getHeadHeight() : 0) + this.getBodyHeight();
|
258
|
+
}
|
259
|
+
}
|
260
|
+
exports.Table = Table;
|
261
|
+
async function calculateWidths(arg) {
|
262
|
+
const { table, font, _cache } = arg;
|
263
|
+
const getFontKitFontByFontName = (fontName) => (0, helper_1.getFontKitFont)(fontName, font, _cache);
|
264
|
+
await calculate(table, getFontKitFontByFontName);
|
265
|
+
const resizableColumns = [];
|
266
|
+
let initialTableWidth = 0;
|
267
|
+
table.columns.forEach((column) => {
|
268
|
+
const customWidth = column.getMaxCustomCellWidth(table);
|
269
|
+
if (customWidth) {
|
270
|
+
// final column width
|
271
|
+
column.width = customWidth;
|
272
|
+
}
|
273
|
+
else {
|
274
|
+
// initial column width (will be resized)
|
275
|
+
column.width = column.wrappedWidth;
|
276
|
+
resizableColumns.push(column);
|
277
|
+
}
|
278
|
+
initialTableWidth += column.width;
|
279
|
+
});
|
280
|
+
// width difference that needs to be distributed
|
281
|
+
let resizeWidth = table.getWidth() - initialTableWidth;
|
282
|
+
// first resize attempt: with respect to minReadableWidth and minWidth
|
283
|
+
if (resizeWidth) {
|
284
|
+
resizeWidth = resizeColumns(resizableColumns, resizeWidth, (column) => Math.max(column.minReadableWidth, column.minWidth));
|
285
|
+
}
|
286
|
+
// second resize attempt: ignore minReadableWidth but respect minWidth
|
287
|
+
if (resizeWidth) {
|
288
|
+
resizeWidth = resizeColumns(resizableColumns, resizeWidth, (column) => column.minWidth);
|
289
|
+
}
|
290
|
+
resizeWidth = Math.abs(resizeWidth);
|
291
|
+
applyColSpans(table);
|
292
|
+
await fitContent(table, getFontKitFontByFontName);
|
293
|
+
applyRowSpans(table);
|
294
|
+
}
|
295
|
+
function applyRowSpans(table) {
|
296
|
+
const rowSpanCells = {};
|
297
|
+
let colRowSpansLeft = 1;
|
298
|
+
const all = table.allRows();
|
299
|
+
for (let rowIndex = 0; rowIndex < all.length; rowIndex++) {
|
300
|
+
const row = all[rowIndex];
|
301
|
+
for (const column of table.columns) {
|
302
|
+
const data = rowSpanCells[column.index];
|
303
|
+
if (colRowSpansLeft > 1) {
|
304
|
+
colRowSpansLeft--;
|
305
|
+
delete row.cells[column.index];
|
306
|
+
}
|
307
|
+
else if (data) {
|
308
|
+
data.cell.height += row.height;
|
309
|
+
colRowSpansLeft = 1;
|
310
|
+
delete row.cells[column.index];
|
311
|
+
data.left--;
|
312
|
+
if (data.left <= 1) {
|
313
|
+
delete rowSpanCells[column.index];
|
314
|
+
}
|
315
|
+
}
|
316
|
+
else {
|
317
|
+
const cell = row.cells[column.index];
|
318
|
+
if (!cell) {
|
319
|
+
continue;
|
320
|
+
}
|
321
|
+
cell.height = row.height;
|
322
|
+
}
|
323
|
+
}
|
324
|
+
}
|
325
|
+
}
|
326
|
+
function applyColSpans(table) {
|
327
|
+
const all = table.allRows();
|
328
|
+
for (let rowIndex = 0; rowIndex < all.length; rowIndex++) {
|
329
|
+
const row = all[rowIndex];
|
330
|
+
let colSpanCell = null;
|
331
|
+
let combinedColSpanWidth = 0;
|
332
|
+
let colSpansLeft = 0;
|
333
|
+
for (let columnIndex = 0; columnIndex < table.columns.length; columnIndex++) {
|
334
|
+
const column = table.columns[columnIndex];
|
335
|
+
// Width and colspan
|
336
|
+
colSpansLeft -= 1;
|
337
|
+
if (colSpansLeft > 1 && table.columns[columnIndex + 1]) {
|
338
|
+
combinedColSpanWidth += column.width;
|
339
|
+
delete row.cells[column.index];
|
340
|
+
}
|
341
|
+
else if (colSpanCell) {
|
342
|
+
const cell = colSpanCell;
|
343
|
+
delete row.cells[column.index];
|
344
|
+
colSpanCell = null;
|
345
|
+
cell.width = column.width + combinedColSpanWidth;
|
346
|
+
}
|
347
|
+
else {
|
348
|
+
const cell = row.cells[column.index];
|
349
|
+
if (!cell)
|
350
|
+
continue;
|
351
|
+
colSpansLeft = 1;
|
352
|
+
combinedColSpanWidth = 0;
|
353
|
+
cell.width = column.width + combinedColSpanWidth;
|
354
|
+
}
|
355
|
+
}
|
356
|
+
}
|
357
|
+
}
|
358
|
+
async function fitContent(table, getFontKitFontByFontName) {
|
359
|
+
const rowSpanHeight = { count: 0, height: 0 };
|
360
|
+
for (const row of table.allRows()) {
|
361
|
+
for (const column of table.columns) {
|
362
|
+
const cell = row.cells[column.index];
|
363
|
+
if (!cell)
|
364
|
+
continue;
|
365
|
+
const fontKitFont = await getFontKitFontByFontName(cell.styles.fontName);
|
366
|
+
cell.text = (0, helper_1.splitTextToSize)({
|
367
|
+
value: cell.raw,
|
368
|
+
characterSpacing: cell.styles.characterSpacing,
|
369
|
+
boxWidthInPt: (0, common_1.mm2pt)(cell.width),
|
370
|
+
fontSize: cell.styles.fontSize,
|
371
|
+
fontKitFont,
|
372
|
+
});
|
373
|
+
cell.contentHeight = cell.getContentHeight();
|
374
|
+
let realContentHeight = cell.contentHeight;
|
375
|
+
if (rowSpanHeight && rowSpanHeight.count > 0) {
|
376
|
+
if (rowSpanHeight.height > realContentHeight) {
|
377
|
+
realContentHeight = rowSpanHeight.height;
|
378
|
+
}
|
379
|
+
}
|
380
|
+
if (realContentHeight > row.height) {
|
381
|
+
row.height = realContentHeight;
|
382
|
+
}
|
383
|
+
}
|
384
|
+
rowSpanHeight.count--;
|
385
|
+
}
|
386
|
+
}
|
387
|
+
function resizeColumns(columns, resizeWidth, getMinWidth) {
|
388
|
+
const initialResizeWidth = resizeWidth;
|
389
|
+
const sumWrappedWidth = columns.reduce((acc, column) => acc + column.wrappedWidth, 0);
|
390
|
+
for (let i = 0; i < columns.length; i++) {
|
391
|
+
const column = columns[i];
|
392
|
+
const ratio = column.wrappedWidth / sumWrappedWidth;
|
393
|
+
const suggestedChange = initialResizeWidth * ratio;
|
394
|
+
const suggestedWidth = column.width + suggestedChange;
|
395
|
+
const minWidth = getMinWidth(column);
|
396
|
+
const newWidth = suggestedWidth < minWidth ? minWidth : suggestedWidth;
|
397
|
+
resizeWidth -= newWidth - column.width;
|
398
|
+
column.width = newWidth;
|
399
|
+
}
|
400
|
+
resizeWidth = Math.round(resizeWidth * 1e10) / 1e10;
|
401
|
+
// Run the resizer again if there's remaining width needs
|
402
|
+
// to be distributed and there're columns that can be resized
|
403
|
+
if (resizeWidth) {
|
404
|
+
const resizableColumns = columns.filter((column) => {
|
405
|
+
return resizeWidth < 0
|
406
|
+
? column.width > getMinWidth(column) // check if column can shrink
|
407
|
+
: true; // check if column can grow
|
408
|
+
});
|
409
|
+
if (resizableColumns.length) {
|
410
|
+
resizeWidth = resizeColumns(resizableColumns, resizeWidth, getMinWidth);
|
411
|
+
}
|
412
|
+
}
|
413
|
+
return resizeWidth;
|
414
|
+
}
|
415
|
+
async function calculate(table, getFontKitFontByFontName) {
|
416
|
+
for (const row of table.allRows()) {
|
417
|
+
for (const column of table.columns) {
|
418
|
+
const cell = row.cells[column.index];
|
419
|
+
if (!cell)
|
420
|
+
continue;
|
421
|
+
const hPadding = cell.padding('right') + cell.padding('left');
|
422
|
+
const fontKitFont = await getFontKitFontByFontName(cell.styles.fontName);
|
423
|
+
cell.contentWidth = getStringWidth(cell, fontKitFont) + hPadding;
|
424
|
+
const longestWordWidth = getStringWidth(Object.assign(cell, { text: cell.text.join(' ').split(/\s+/) }), fontKitFont);
|
425
|
+
cell.minReadableWidth = longestWordWidth + hPadding;
|
426
|
+
cell.minWidth = cell.styles.cellWidth;
|
427
|
+
cell.wrappedWidth = cell.styles.cellWidth;
|
428
|
+
}
|
429
|
+
}
|
430
|
+
for (const row of table.allRows()) {
|
431
|
+
for (const column of table.columns) {
|
432
|
+
const cell = row.cells[column.index];
|
433
|
+
// For now we ignore the minWidth and wrappedWidth of colspan cells when calculating colspan widths.
|
434
|
+
// Could probably be improved upon however.
|
435
|
+
if (cell) {
|
436
|
+
column.wrappedWidth = Math.max(column.wrappedWidth, cell.wrappedWidth);
|
437
|
+
column.minWidth = Math.max(column.minWidth, cell.minWidth);
|
438
|
+
column.minReadableWidth = Math.max(column.minReadableWidth, cell.minReadableWidth);
|
439
|
+
}
|
440
|
+
else {
|
441
|
+
// Respect cellWidth set in columnStyles even if there is no cells for this column
|
442
|
+
// or if the column only have colspan cells. Since the width of colspan cells
|
443
|
+
// does not affect the width of columns, setting columnStyles cellWidth enables the
|
444
|
+
// user to at least do it manually.
|
445
|
+
// Note that this is not perfect for now since for example row and table styles are
|
446
|
+
// not accounted for
|
447
|
+
const columnStyles = table.styles.columnStyles[column.index] || {};
|
448
|
+
const cellWidth = columnStyles.cellWidth || columnStyles.minCellWidth;
|
449
|
+
if (cellWidth) {
|
450
|
+
column.minWidth = cellWidth;
|
451
|
+
column.wrappedWidth = cellWidth;
|
452
|
+
}
|
453
|
+
}
|
454
|
+
}
|
455
|
+
}
|
456
|
+
}
|
457
|
+
function getStringWidth(cell, fontKitFont) {
|
458
|
+
const text = cell.text;
|
459
|
+
const textArr = Array.isArray(text) ? text : [text];
|
460
|
+
const fontSize = cell.styles.fontSize;
|
461
|
+
const characterSpacing = cell.styles.characterSpacing;
|
462
|
+
const widestLineWidth = textArr
|
463
|
+
.map((text) => (0, helper_1.widthOfTextAtSize)(text, fontKitFont, fontSize, characterSpacing))
|
464
|
+
.reduce((a, b) => Math.max(a, b), 0);
|
465
|
+
return widestLineWidth;
|
466
|
+
}
|
467
|
+
//# sourceMappingURL=classes.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"classes.js","sourceRoot":"","sources":["../../../../src/tables/classes.ts"],"names":[],"mappings":";;;AAAA,0CAAmD;AAEnD,2CAAoF;AAKpF,MAAa,IAAI;IAgBf,YAAY,GAAW,EAAE,MAAc,EAAE,OAAgB;QAfzD;;;;;WAAY;QACZ;;;;;WAAe;QACf;;;;;WAAe;QACf;;;;;WAAiB;QACjB;;;;mBAAgB,CAAC;WAAC;QAClB;;;;mBAAe,CAAC;WAAC;QACjB;;;;mBAAe,CAAC;WAAC;QACjB;;;;mBAAmB,CAAC;WAAC;QACrB;;;;mBAAW,CAAC;WAAC;QAEb;;;;mBAAQ,CAAC;WAAC;QACV;;;;mBAAS,CAAC;WAAC;QACX;;;;mBAAI,CAAC;WAAC;QACN;;;;mBAAI,CAAC;WAAC;QAGJ,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,MAAM,UAAU,GAAG,aAAa,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IAED,gBAAgB;QACd,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAClE,MAAM,UAAU,GAAG,IAAA,cAAK,EAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;QACxE,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,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AAC,QAAQ,CAAC;IACtC,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC;IACtD,MAAM,eAAe,GAAG,OAAO;SAC5B,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,0BAAiB,EAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;SAC/E,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAEvC,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getDynamicHeightsForTable = void 0;
|
4
|
+
const tableHelper_1 = require("./tableHelper");
|
5
|
+
const helper_js_1 = require("./helper.js");
|
6
|
+
const getDynamicHeightsForTable = async (value, args) => {
|
7
|
+
if (args.schema.type !== 'table')
|
8
|
+
return Promise.resolve([args.schema.height]);
|
9
|
+
const schema = args.schema;
|
10
|
+
const body = schema.__bodyRange?.start === 0 ? (0, helper_js_1.getBody)(value) : (0, helper_js_1.getBodyWithRange)(value, schema.__bodyRange);
|
11
|
+
const table = await (0, tableHelper_1.createSingleTable)(body, args);
|
12
|
+
return schema.showHead
|
13
|
+
? table.allRows().map((row) => row.height)
|
14
|
+
: [0].concat(table.body.map((row) => row.height));
|
15
|
+
};
|
16
|
+
exports.getDynamicHeightsForTable = getDynamicHeightsForTable;
|
17
|
+
//# sourceMappingURL=dynamicTemplate.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"dynamicTemplate.js","sourceRoot":"","sources":["../../../../src/tables/dynamicTemplate.ts"],"names":[],"mappings":";;;AACA,+CAAkD;AAClD,2CAAwD;AAGjD,MAAM,yBAAyB,GAAG,KAAK,EAC5C,KAAa,EACb,IAKC,EACkB,EAAE;IACrB,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/E,MAAM,MAAM,GAAG,IAAI,CAAC,MAAqB,CAAC;IAC1C,MAAM,IAAI,GACR,MAAM,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAA,4BAAgB,EAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACjG,MAAM,KAAK,GAAG,MAAM,IAAA,+BAAiB,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClD,OAAO,MAAM,CAAC,QAAQ;QACpB,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC;QAC1C,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AACtD,CAAC,CAAC;AAjBW,QAAA,yBAAyB,6BAiBpC"}
|