1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.Table = void 0;
|
19 | const common = require("../../../../../common");
|
20 | const toColumnProperties = (columns) => columns.map(column => typeof column === 'string'
|
21 | ? {
|
22 | header: column,
|
23 | }
|
24 | : {
|
25 | header: column.header,
|
26 | horizontalAlignment: column.horizontalAlignment || column.align,
|
27 | });
|
28 | class Table {
|
29 |
|
30 | constructor(options) {
|
31 | this.title = options.title;
|
32 | this.subtitle = options.subtitle;
|
33 | this.image = options.image;
|
34 | this.rows = options.rows.map(row => Array.isArray(row)
|
35 | ? {
|
36 | cells: row.map(text => ({ text })),
|
37 | dividerAfter: options.dividers,
|
38 | }
|
39 | : {
|
40 | cells: row.cells.map(cell => typeof cell === 'string' ? { text: cell } : cell),
|
41 | dividerAfter: typeof row.dividerAfter === 'undefined'
|
42 | ? options.dividers
|
43 | : row.dividerAfter,
|
44 | });
|
45 | const { columnProperties, columns, buttons } = options;
|
46 | if (columnProperties) {
|
47 | this.columnProperties = toColumnProperties(columnProperties);
|
48 | }
|
49 | if (typeof columns !== 'undefined') {
|
50 | if (!this.columnProperties) {
|
51 | this.columnProperties = [];
|
52 | }
|
53 | const properties = typeof columns === 'number'
|
54 | ? new Array(columns).fill({})
|
55 | : toColumnProperties(columns);
|
56 | properties.forEach((v, i) => {
|
57 | if (!this.columnProperties[i]) {
|
58 | this.columnProperties[i] = properties[i];
|
59 | }
|
60 | });
|
61 | }
|
62 | if (buttons) {
|
63 | this.buttons = common.toArray(buttons);
|
64 | }
|
65 | }
|
66 | }
|
67 | exports.Table = Table;
|
68 |
|
\ | No newline at end of file |