@pdfme/schemas 3.4.3 → 4.0.0

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.
Files changed (138) hide show
  1. package/dist/cjs/__tests__/text.test.js +5 -4
  2. package/dist/cjs/__tests__/text.test.js.map +1 -1
  3. package/dist/cjs/__tests__/utils.test.js +3 -0
  4. package/dist/cjs/__tests__/utils.test.js.map +1 -1
  5. package/dist/cjs/src/barcodes/propPanel.js +23 -11
  6. package/dist/cjs/src/barcodes/propPanel.js.map +1 -1
  7. package/dist/cjs/src/barcodes/uiRender.js +1 -1
  8. package/dist/cjs/src/barcodes/uiRender.js.map +1 -1
  9. package/dist/cjs/src/graphics/image.js +8 -11
  10. package/dist/cjs/src/graphics/image.js.map +1 -1
  11. package/dist/cjs/src/graphics/svg.js +4 -3
  12. package/dist/cjs/src/graphics/svg.js.map +1 -1
  13. package/dist/cjs/src/index.js +7 -1
  14. package/dist/cjs/src/index.js.map +1 -1
  15. package/dist/cjs/src/shapes/line.js +5 -8
  16. package/dist/cjs/src/shapes/line.js.map +1 -1
  17. package/dist/cjs/src/shapes/rectAndEllipse.js +12 -5
  18. package/dist/cjs/src/shapes/rectAndEllipse.js.map +1 -1
  19. package/dist/cjs/src/tables/cell.js +125 -0
  20. package/dist/cjs/src/tables/cell.js.map +1 -0
  21. package/dist/cjs/src/tables/classes.js +467 -0
  22. package/dist/cjs/src/tables/classes.js.map +1 -0
  23. package/dist/cjs/src/tables/dynamicTemplate.js +71 -0
  24. package/dist/cjs/src/tables/dynamicTemplate.js.map +1 -0
  25. package/dist/cjs/src/tables/helper.js +171 -0
  26. package/dist/cjs/src/tables/helper.js.map +1 -0
  27. package/dist/cjs/src/tables/index.js +12 -0
  28. package/dist/cjs/src/tables/index.js.map +1 -0
  29. package/dist/cjs/src/tables/pdfRender.js +93 -0
  30. package/dist/cjs/src/tables/pdfRender.js.map +1 -0
  31. package/dist/cjs/src/tables/propPanel.js +88 -0
  32. package/dist/cjs/src/tables/propPanel.js.map +1 -0
  33. package/dist/cjs/src/tables/tableHelper.js +231 -0
  34. package/dist/cjs/src/tables/tableHelper.js.map +1 -0
  35. package/dist/cjs/src/tables/types.js +3 -0
  36. package/dist/cjs/src/tables/types.js.map +1 -0
  37. package/dist/cjs/src/tables/uiRender.js +342 -0
  38. package/dist/cjs/src/tables/uiRender.js.map +1 -0
  39. package/dist/cjs/src/text/helper.js +21 -6
  40. package/dist/cjs/src/text/helper.js.map +1 -1
  41. package/dist/cjs/src/text/index.js +1 -1
  42. package/dist/cjs/src/text/index.js.map +1 -1
  43. package/dist/cjs/src/text/pdfRender.js +6 -9
  44. package/dist/cjs/src/text/pdfRender.js.map +1 -1
  45. package/dist/cjs/src/text/propPanel.js +7 -4
  46. package/dist/cjs/src/text/propPanel.js.map +1 -1
  47. package/dist/cjs/src/text/uiRender.js +18 -17
  48. package/dist/cjs/src/text/uiRender.js.map +1 -1
  49. package/dist/cjs/src/utils.js +3 -1
  50. package/dist/cjs/src/utils.js.map +1 -1
  51. package/dist/esm/__tests__/text.test.js +5 -4
  52. package/dist/esm/__tests__/text.test.js.map +1 -1
  53. package/dist/esm/__tests__/utils.test.js +3 -0
  54. package/dist/esm/__tests__/utils.test.js.map +1 -1
  55. package/dist/esm/src/barcodes/propPanel.js +23 -11
  56. package/dist/esm/src/barcodes/propPanel.js.map +1 -1
  57. package/dist/esm/src/barcodes/uiRender.js +1 -1
  58. package/dist/esm/src/barcodes/uiRender.js.map +1 -1
  59. package/dist/esm/src/graphics/image.js +6 -9
  60. package/dist/esm/src/graphics/image.js.map +1 -1
  61. package/dist/esm/src/graphics/svg.js +4 -3
  62. package/dist/esm/src/graphics/svg.js.map +1 -1
  63. package/dist/esm/src/index.js +4 -1
  64. package/dist/esm/src/index.js.map +1 -1
  65. package/dist/esm/src/shapes/line.js +5 -8
  66. package/dist/esm/src/shapes/line.js.map +1 -1
  67. package/dist/esm/src/shapes/rectAndEllipse.js +12 -5
  68. package/dist/esm/src/shapes/rectAndEllipse.js.map +1 -1
  69. package/dist/esm/src/tables/cell.js +120 -0
  70. package/dist/esm/src/tables/cell.js.map +1 -0
  71. package/dist/esm/src/tables/classes.js +460 -0
  72. package/dist/esm/src/tables/classes.js.map +1 -0
  73. package/dist/esm/src/tables/dynamicTemplate.js +66 -0
  74. package/dist/esm/src/tables/dynamicTemplate.js.map +1 -0
  75. package/dist/esm/src/tables/helper.js +163 -0
  76. package/dist/esm/src/tables/helper.js.map +1 -0
  77. package/dist/esm/src/tables/index.js +10 -0
  78. package/dist/esm/src/tables/index.js.map +1 -0
  79. package/dist/esm/src/tables/pdfRender.js +86 -0
  80. package/dist/esm/src/tables/pdfRender.js.map +1 -0
  81. package/dist/esm/src/tables/propPanel.js +85 -0
  82. package/dist/esm/src/tables/propPanel.js.map +1 -0
  83. package/dist/esm/src/tables/tableHelper.js +226 -0
  84. package/dist/esm/src/tables/tableHelper.js.map +1 -0
  85. package/dist/esm/src/tables/types.js +2 -0
  86. package/dist/esm/src/tables/types.js.map +1 -0
  87. package/dist/esm/src/tables/uiRender.js +335 -0
  88. package/dist/esm/src/tables/uiRender.js.map +1 -0
  89. package/dist/esm/src/text/helper.js +19 -5
  90. package/dist/esm/src/text/helper.js.map +1 -1
  91. package/dist/esm/src/text/index.js +1 -1
  92. package/dist/esm/src/text/index.js.map +1 -1
  93. package/dist/esm/src/text/pdfRender.js +7 -10
  94. package/dist/esm/src/text/pdfRender.js.map +1 -1
  95. package/dist/esm/src/text/propPanel.js +7 -4
  96. package/dist/esm/src/text/propPanel.js.map +1 -1
  97. package/dist/esm/src/text/uiRender.js +19 -18
  98. package/dist/esm/src/text/uiRender.js.map +1 -1
  99. package/dist/esm/src/utils.js +1 -0
  100. package/dist/esm/src/utils.js.map +1 -1
  101. package/dist/types/src/index.d.ts +3 -1
  102. package/dist/types/src/shapes/rectAndEllipse.d.ts +19 -27
  103. package/dist/types/src/tables/cell.d.ts +4 -0
  104. package/dist/types/src/tables/classes.d.ts +68 -0
  105. package/dist/types/src/tables/dynamicTemplate.d.ts +13 -0
  106. package/dist/types/src/tables/helper.d.ts +252 -0
  107. package/dist/types/src/tables/index.d.ts +4 -0
  108. package/dist/types/src/tables/pdfRender.d.ts +3 -0
  109. package/dist/types/src/tables/propPanel.d.ts +3 -0
  110. package/dist/types/src/tables/tableHelper.d.ts +11 -0
  111. package/dist/types/src/tables/types.d.ts +91 -0
  112. package/dist/types/src/tables/uiRender.d.ts +3 -0
  113. package/dist/types/src/text/helper.d.ts +8 -1
  114. package/dist/types/src/utils.d.ts +1 -0
  115. package/package.json +1 -1
  116. package/src/barcodes/propPanel.ts +26 -12
  117. package/src/barcodes/uiRender.ts +1 -1
  118. package/src/graphics/image.ts +8 -11
  119. package/src/graphics/svg.ts +4 -3
  120. package/src/index.ts +7 -0
  121. package/src/shapes/line.ts +4 -8
  122. package/src/shapes/rectAndEllipse.ts +16 -7
  123. package/src/tables/cell.ts +157 -0
  124. package/src/tables/classes.ts +398 -0
  125. package/src/tables/dynamicTemplate.ts +81 -0
  126. package/src/tables/helper.ts +198 -0
  127. package/src/tables/index.ts +12 -0
  128. package/src/tables/pdfRender.ts +113 -0
  129. package/src/tables/propPanel.ts +91 -0
  130. package/src/tables/tableHelper.ts +322 -0
  131. package/src/tables/types.ts +88 -0
  132. package/src/tables/uiRender.ts +393 -0
  133. package/src/text/helper.ts +29 -6
  134. package/src/text/index.ts +1 -1
  135. package/src/text/pdfRender.ts +9 -13
  136. package/src/text/propPanel.ts +7 -4
  137. package/src/text/uiRender.ts +18 -18
  138. package/src/utils.ts +1 -0
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createMultiTables = exports.createSingleTable = void 0;
4
+ const common_1 = require("@pdfme/common");
5
+ const utils_1 = require("../utils");
6
+ const classes_1 = require("./classes");
7
+ function parseSection(sectionName, sectionRows, columns, styleProps, fallbackFontName) {
8
+ const rowSpansLeftForColumn = {};
9
+ const result = sectionRows.map((rawRow, rowIndex) => {
10
+ let skippedRowForRowSpans = 0;
11
+ const cells = {};
12
+ let colSpansAdded = 0;
13
+ let columnSpansLeft = 0;
14
+ for (const column of columns) {
15
+ if (rowSpansLeftForColumn[column.index] == null ||
16
+ rowSpansLeftForColumn[column.index].left === 0) {
17
+ if (columnSpansLeft === 0) {
18
+ let rawCell;
19
+ if (Array.isArray(rawRow)) {
20
+ rawCell = rawRow[column.index - colSpansAdded - skippedRowForRowSpans];
21
+ }
22
+ else {
23
+ rawCell = rawRow[column.index];
24
+ }
25
+ const styles = cellStyles(sectionName, column, rowIndex, styleProps, fallbackFontName);
26
+ const cell = new classes_1.Cell(rawCell, styles, sectionName);
27
+ cells[column.index] = cell;
28
+ columnSpansLeft = 0;
29
+ rowSpansLeftForColumn[column.index] = {
30
+ left: 0,
31
+ times: columnSpansLeft,
32
+ };
33
+ }
34
+ else {
35
+ columnSpansLeft--;
36
+ colSpansAdded++;
37
+ }
38
+ }
39
+ else {
40
+ rowSpansLeftForColumn[column.index].left--;
41
+ columnSpansLeft = rowSpansLeftForColumn[column.index].times;
42
+ skippedRowForRowSpans++;
43
+ }
44
+ }
45
+ return new classes_1.Row(rawRow, rowIndex, sectionName, cells);
46
+ });
47
+ return result;
48
+ }
49
+ function parseContent4Table(input, fallbackFontName) {
50
+ const content = input.content;
51
+ const columns = content.columns.map((index) => new classes_1.Column(index));
52
+ const styles = input.styles;
53
+ return {
54
+ columns,
55
+ head: parseSection('head', content.head, columns, styles, fallbackFontName),
56
+ body: parseSection('body', content.body, columns, styles, fallbackFontName),
57
+ };
58
+ }
59
+ function cellStyles(sectionName, column, rowIndex, styles, fallbackFontName) {
60
+ let sectionStyles;
61
+ if (sectionName === 'head') {
62
+ sectionStyles = styles.headStyles;
63
+ }
64
+ else if (sectionName === 'body') {
65
+ sectionStyles = styles.bodyStyles;
66
+ }
67
+ const otherStyles = Object.assign({}, styles.styles, sectionStyles);
68
+ const colStyles = styles.columnStyles[column.index] || styles.columnStyles[column.index] || {};
69
+ const rowStyles = sectionName === 'body' && rowIndex % 2 === 0
70
+ ? Object.assign({}, styles.alternateRowStyles)
71
+ : {};
72
+ const defaultStyle = {
73
+ fontName: fallbackFontName,
74
+ backgroundColor: '',
75
+ textColor: '#000000',
76
+ lineHeight: 1,
77
+ characterSpacing: 0,
78
+ alignment: 'left',
79
+ verticalAlignment: 'middle',
80
+ fontSize: 10,
81
+ cellPadding: 5,
82
+ lineColor: '#000000',
83
+ lineWidth: 0,
84
+ minCellHeight: 0,
85
+ minCellWidth: 0,
86
+ };
87
+ return Object.assign(defaultStyle, otherStyles, rowStyles, colStyles);
88
+ }
89
+ function mapCellStyle(style) {
90
+ return {
91
+ fontName: style.fontName,
92
+ alignment: style.alignment,
93
+ verticalAlignment: style.verticalAlignment,
94
+ fontSize: style.fontSize,
95
+ lineHeight: style.lineHeight,
96
+ characterSpacing: style.characterSpacing,
97
+ backgroundColor: style.backgroundColor,
98
+ // ---
99
+ textColor: style.fontColor,
100
+ lineColor: style.borderColor,
101
+ lineWidth: style.borderWidth,
102
+ cellPadding: style.padding,
103
+ };
104
+ }
105
+ function createTableWithAvailableHeight(tableBody, availableHeight, args) {
106
+ let limit = availableHeight;
107
+ const newTableBody = [];
108
+ let index = 0;
109
+ while (limit > 0 && index < tableBody.length) {
110
+ const row = tableBody.slice(0, index + 1).pop();
111
+ if (!row)
112
+ break;
113
+ const rowHeight = row.height;
114
+ if (limit - rowHeight < 0) {
115
+ break;
116
+ }
117
+ newTableBody.push(row.raw);
118
+ limit -= rowHeight;
119
+ index++;
120
+ }
121
+ return createSingleTable(newTableBody, args);
122
+ }
123
+ function getTableOptions(schema, body) {
124
+ const columnStylesWidth = schema.headWidthPercentages.reduce((acc, cur, i) => ({ ...acc, [i]: { cellWidth: schema.width * (cur / 100) } }), {});
125
+ const columnStylesAlignment = Object.entries(schema.columnStyles.alignment || {}).reduce((acc, [key, value]) => ({ ...acc, [key]: { alignment: value } }), {});
126
+ const allKeys = new Set([
127
+ ...Object.keys(columnStylesWidth).map(Number),
128
+ ...Object.keys(columnStylesAlignment).map(Number),
129
+ ]);
130
+ const columnStyles = Array.from(allKeys).reduce((acc, key) => {
131
+ const widthStyle = columnStylesWidth[key] || {};
132
+ const alignmentStyle = columnStylesAlignment[key] || {};
133
+ return { ...acc, [key]: { ...widthStyle, ...alignmentStyle } };
134
+ }, {});
135
+ return {
136
+ head: [schema.head],
137
+ body,
138
+ showHead: schema.showHead,
139
+ startY: schema.position.y,
140
+ tableWidth: schema.width,
141
+ tableLineColor: schema.tableStyles.borderColor,
142
+ tableLineWidth: schema.tableStyles.borderWidth,
143
+ headStyles: mapCellStyle(schema.headStyles),
144
+ bodyStyles: mapCellStyle(schema.bodyStyles),
145
+ alternateRowStyles: { backgroundColor: schema.bodyStyles.alternateBackgroundColor },
146
+ columnStyles,
147
+ margin: { top: 0, right: 0, left: schema.position.x, bottom: 0 },
148
+ };
149
+ }
150
+ function parseStyles(cInput) {
151
+ const styleOptions = {
152
+ styles: {},
153
+ headStyles: {},
154
+ bodyStyles: {},
155
+ alternateRowStyles: {},
156
+ columnStyles: {},
157
+ };
158
+ for (const prop of Object.keys(styleOptions)) {
159
+ if (prop === 'columnStyles') {
160
+ const current = cInput[prop];
161
+ styleOptions.columnStyles = Object.assign({}, current);
162
+ }
163
+ else {
164
+ const allOptions = [cInput];
165
+ const styles = allOptions.map((opts) => opts[prop] || {});
166
+ styleOptions[prop] = Object.assign({}, styles[0], styles[1], styles[2]);
167
+ }
168
+ }
169
+ return styleOptions;
170
+ }
171
+ function parseContent4Input(options) {
172
+ const head = options.head || [];
173
+ const body = options.body || [];
174
+ const columns = (head[0] || body[0] || []).map((_, index) => index);
175
+ return { columns, head, body };
176
+ }
177
+ function parseInput(schema, body) {
178
+ const options = getTableOptions(schema, body);
179
+ const styles = parseStyles(options);
180
+ const settings = {
181
+ startY: options.startY,
182
+ margin: options.margin,
183
+ tableWidth: options.tableWidth,
184
+ showHead: options.showHead,
185
+ tableLineWidth: options.tableLineWidth ?? 0,
186
+ tableLineColor: options.tableLineColor ?? '',
187
+ };
188
+ const content = parseContent4Input(options);
189
+ return { content, styles, settings };
190
+ }
191
+ function createSingleTable(body, args) {
192
+ const { options, _cache, basePdf } = args;
193
+ if (!(0, common_1.isBlankPdf)(basePdf))
194
+ throw new Error('[@pdfme/schema/table] Blank PDF is not supported');
195
+ const input = parseInput(args.schema, body);
196
+ const font = options.font || (0, common_1.getDefaultFont)();
197
+ const fallbackFontName = (0, common_1.getFallbackFontName)(font);
198
+ const content = parseContent4Table(input, fallbackFontName);
199
+ return classes_1.Table.create({ input, content, font, _cache });
200
+ }
201
+ exports.createSingleTable = createSingleTable;
202
+ async function createMultiTables(body, args) {
203
+ const { basePdf, schema } = args;
204
+ if (!(0, common_1.isBlankPdf)(basePdf))
205
+ throw new Error('[@pdfme/schema/table] Blank PDF is not supported');
206
+ const pageHeight = basePdf.height;
207
+ const paddingBottom = basePdf.padding[2];
208
+ const paddingTop = basePdf.padding[0];
209
+ let availableHeight = pageHeight - paddingBottom - schema.position.y;
210
+ const testTable = await createSingleTable(body, args);
211
+ let remainingBody = testTable.body;
212
+ const tables = [];
213
+ while (remainingBody.length > 0) {
214
+ const tableHeight = tables.length === 0
215
+ ? availableHeight - testTable.getHeadHeight()
216
+ : availableHeight - paddingTop;
217
+ const table = await createTableWithAvailableHeight(remainingBody, tableHeight, args);
218
+ tables.push(table);
219
+ remainingBody = remainingBody.slice(table.body.length);
220
+ if (remainingBody.length > 0) {
221
+ const _schema = (0, utils_1.cloneDeep)(schema);
222
+ _schema.showHead = false;
223
+ _schema.position.y = paddingTop;
224
+ args.schema = _schema;
225
+ availableHeight = pageHeight - paddingTop - paddingBottom;
226
+ }
227
+ }
228
+ return tables;
229
+ }
230
+ exports.createMultiTables = createMultiTables;
231
+ //# sourceMappingURL=tableHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tableHelper.js","sourceRoot":"","sources":["../../../../src/tables/tableHelper.ts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,GAAG,MAAM,8BAA8B,CAAC,aAAa,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;QAErF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEnB,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEvD,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;YAC5B,MAAM,OAAO,GAAG,IAAA,iBAAS,EAAC,MAAM,CAAC,CAAC;YAClC,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;YACzB,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,UAAU,CAAC;YAChC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;YAEtB,eAAe,GAAG,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC;SAC3D;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AApCD,8CAoCC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/tables/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,342 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.uiRender = void 0;
7
+ const common_1 = require("@pdfme/common");
8
+ const tableHelper_js_1 = require("./tableHelper.js");
9
+ const helper_js_1 = require("./helper.js");
10
+ const cell_js_1 = __importDefault(require("./cell.js"));
11
+ const cellUiRender = cell_js_1.default.ui;
12
+ const convertToCellStyle = (styles) => ({
13
+ fontName: styles.fontName,
14
+ alignment: styles.alignment,
15
+ verticalAlignment: styles.verticalAlignment,
16
+ fontSize: styles.fontSize,
17
+ lineHeight: styles.lineHeight,
18
+ characterSpacing: styles.characterSpacing,
19
+ backgroundColor: styles.backgroundColor,
20
+ // ---
21
+ fontColor: styles.textColor,
22
+ borderColor: styles.lineColor,
23
+ borderWidth: styles.lineWidth,
24
+ padding: styles.cellPadding,
25
+ });
26
+ const calcResizedHeadWidthPercentages = (arg) => {
27
+ const { currentHeadWidthPercentages, currentHeadWidths, changedHeadWidth, changedHeadIndex } = arg;
28
+ const headWidthPercentages = [...currentHeadWidthPercentages];
29
+ const totalWidth = currentHeadWidths.reduce((a, b) => a + b, 0);
30
+ const changedWidthPercentage = (changedHeadWidth / totalWidth) * 100;
31
+ const originalNextWidthPercentage = headWidthPercentages[changedHeadIndex + 1] ?? 0;
32
+ const adjustment = headWidthPercentages[changedHeadIndex] - changedWidthPercentage;
33
+ headWidthPercentages[changedHeadIndex] = changedWidthPercentage;
34
+ if (changedHeadIndex + 1 < headWidthPercentages.length) {
35
+ headWidthPercentages[changedHeadIndex + 1] = originalNextWidthPercentage + adjustment;
36
+ }
37
+ return headWidthPercentages;
38
+ };
39
+ const setBorder = (div, borderPosition, arg) => {
40
+ div.style[`border${borderPosition}`] = `${String(arg.schema.tableStyles.borderWidth)}mm solid ${arg.schema.tableStyles.borderColor}`;
41
+ };
42
+ const drawBorder = (div, row, colIndex, rowIndex, rowsLength, arg) => {
43
+ const isFirstColumn = colIndex === 0;
44
+ const isLastColumn = colIndex === Object.values(row.cells).length - 1;
45
+ const isLastRow = rowIndex === rowsLength - 1;
46
+ if (row.section === 'head') {
47
+ setBorder(div, 'Top', arg);
48
+ if (isFirstColumn)
49
+ setBorder(div, 'Left', arg);
50
+ if (isLastColumn)
51
+ setBorder(div, 'Right', arg);
52
+ if (JSON.parse(arg.value || '[]').length === 0) {
53
+ setBorder(div, 'Bottom', arg);
54
+ }
55
+ }
56
+ else if (row.section === 'body') {
57
+ if (!arg.schema.showHead && rowIndex === 0) {
58
+ setBorder(div, 'Top', arg);
59
+ }
60
+ if (isFirstColumn)
61
+ setBorder(div, 'Left', arg);
62
+ if (isLastColumn)
63
+ setBorder(div, 'Right', arg);
64
+ if (isLastRow)
65
+ setBorder(div, 'Bottom', arg);
66
+ }
67
+ };
68
+ const renderRowUi = (args) => {
69
+ const { rows, arg, onChangeEditingPosition, offsetY = 0, editingPosition } = args;
70
+ const value = JSON.parse(arg.value || '[]');
71
+ let rowOffsetY = offsetY;
72
+ rows.forEach((row, rowIndex) => {
73
+ const { cells, height, section } = row;
74
+ let colOffsetX = 0;
75
+ Object.values(cells).forEach((cell, colIndex) => {
76
+ const div = document.createElement('div');
77
+ div.style.position = 'absolute';
78
+ div.style.top = `${rowOffsetY}mm`;
79
+ div.style.left = `${colOffsetX}mm`;
80
+ div.style.width = `${cell.width}mm`;
81
+ div.style.height = `${cell.height}mm`;
82
+ div.style.boxSizing = 'border-box';
83
+ drawBorder(div, row, colIndex, rowIndex, rows.length, arg);
84
+ div.style.cursor =
85
+ arg.mode === 'designer' || (arg.mode === 'form' && section === 'body') ? 'text' : 'default';
86
+ div.addEventListener('click', () => {
87
+ if (arg.mode === 'viewer')
88
+ return;
89
+ onChangeEditingPosition({ rowIndex, colIndex });
90
+ });
91
+ arg.rootElement.appendChild(div);
92
+ const isEditing = editingPosition.rowIndex === rowIndex && editingPosition.colIndex === colIndex;
93
+ let mode = 'viewer';
94
+ if (arg.mode === 'form') {
95
+ mode = section === 'body' && isEditing ? 'designer' : 'viewer';
96
+ }
97
+ else if (arg.mode === 'designer') {
98
+ mode = isEditing ? 'designer' : 'form';
99
+ }
100
+ void cellUiRender({
101
+ ...arg,
102
+ stopEditing: () => {
103
+ if (arg.mode === 'form') {
104
+ resetEditingPosition();
105
+ }
106
+ },
107
+ mode,
108
+ onChange: (v) => {
109
+ if (!arg.onChange)
110
+ return;
111
+ const newValue = (Array.isArray(v) ? v[0].value : v.value);
112
+ if (section === 'body') {
113
+ const startRange = arg.schema.__bodyRange?.start ?? 0;
114
+ value[rowIndex + startRange][colIndex] = newValue;
115
+ arg.onChange({ key: 'content', value: JSON.stringify(value) });
116
+ }
117
+ else {
118
+ const newHead = [...arg.schema.head];
119
+ newHead[colIndex] = newValue;
120
+ arg.onChange({ key: 'head', value: newHead });
121
+ }
122
+ },
123
+ value: cell.raw,
124
+ placeholder: '',
125
+ rootElement: div,
126
+ schema: {
127
+ type: 'cell',
128
+ content: cell.raw,
129
+ position: { x: colOffsetX, y: rowOffsetY },
130
+ width: cell.width,
131
+ height: cell.height,
132
+ ...convertToCellStyle(cell.styles),
133
+ },
134
+ });
135
+ colOffsetX += cell.width;
136
+ });
137
+ rowOffsetY += height;
138
+ });
139
+ };
140
+ const headEditingPosition = { rowIndex: -1, colIndex: -1 };
141
+ const bodyEditingPosition = { rowIndex: -1, colIndex: -1 };
142
+ const resetEditingPosition = () => {
143
+ headEditingPosition.rowIndex = -1;
144
+ headEditingPosition.colIndex = -1;
145
+ bodyEditingPosition.rowIndex = -1;
146
+ bodyEditingPosition.colIndex = -1;
147
+ };
148
+ const uiRender = async (arg) => {
149
+ const { rootElement, onChange, schema, value, mode } = arg;
150
+ const body = (0, helper_js_1.getBody)(value);
151
+ const bodyWidthRange = (0, helper_js_1.getBodyWithRange)(value, schema.__bodyRange);
152
+ const table = await (0, tableHelper_js_1.createSingleTable)(bodyWidthRange, arg);
153
+ rootElement.innerHTML = '';
154
+ const handleChangeEditingPosition = (newPosition, editingPosition) => {
155
+ resetEditingPosition();
156
+ editingPosition.rowIndex = newPosition.rowIndex;
157
+ editingPosition.colIndex = newPosition.colIndex;
158
+ void (0, exports.uiRender)(arg);
159
+ };
160
+ if (schema.showHead) {
161
+ renderRowUi({
162
+ rows: table.head,
163
+ arg,
164
+ editingPosition: headEditingPosition,
165
+ onChangeEditingPosition: (p) => handleChangeEditingPosition(p, headEditingPosition),
166
+ });
167
+ }
168
+ const offsetY = schema.showHead ? table.getHeadHeight() : 0;
169
+ renderRowUi({
170
+ rows: table.body,
171
+ arg,
172
+ editingPosition: bodyEditingPosition,
173
+ onChangeEditingPosition: (p) => {
174
+ handleChangeEditingPosition(p, bodyEditingPosition);
175
+ },
176
+ offsetY,
177
+ });
178
+ if (mode === 'form' && onChange) {
179
+ if (schema.__bodyRange?.end === undefined ||
180
+ schema.__bodyRange.end >= JSON.parse(value || '[]').length) {
181
+ const addRowButton = document.createElement('button');
182
+ addRowButton.style.width = '30px';
183
+ addRowButton.style.height = '30px';
184
+ addRowButton.style.position = 'absolute';
185
+ addRowButton.style.top = `${table.getHeight()}mm`;
186
+ addRowButton.style.left = 'calc(50% - 15px)';
187
+ addRowButton.innerText = '+';
188
+ addRowButton.onclick = () => {
189
+ const newRow = Array(schema.head.length).fill('');
190
+ onChange({ key: 'content', value: JSON.stringify(body.concat([newRow])) });
191
+ };
192
+ rootElement.appendChild(addRowButton);
193
+ }
194
+ let offsetY = schema.showHead ? table.getHeadHeight() : 0;
195
+ table.body.forEach((row, i) => {
196
+ offsetY = offsetY + row.height;
197
+ const removeRowButton = document.createElement('button');
198
+ removeRowButton.style.width = '30px';
199
+ removeRowButton.style.height = '30px';
200
+ removeRowButton.style.position = 'absolute';
201
+ removeRowButton.style.top = `${offsetY - (0, common_1.px2mm)(30)}mm`;
202
+ removeRowButton.style.right = '-30px';
203
+ removeRowButton.innerText = '-';
204
+ removeRowButton.onclick = () => {
205
+ const newTableBody = body.filter((_, j) => j !== i + (schema.__bodyRange?.start ?? 0));
206
+ onChange({ key: 'content', value: JSON.stringify(newTableBody) });
207
+ };
208
+ rootElement.appendChild(removeRowButton);
209
+ });
210
+ }
211
+ if (mode === 'designer' && onChange) {
212
+ const addColumnButton = document.createElement('button');
213
+ addColumnButton.style.width = '30px';
214
+ addColumnButton.style.height = '30px';
215
+ addColumnButton.style.position = 'absolute';
216
+ addColumnButton.style.top = `${table.getHeadHeight() - (0, common_1.px2mm)(30)}mm`;
217
+ addColumnButton.style.right = '-30px';
218
+ addColumnButton.innerText = '+';
219
+ addColumnButton.onclick = (e) => {
220
+ e.preventDefault();
221
+ const newColumnWidthPercentage = 25;
222
+ const totalCurrentWidth = schema.headWidthPercentages.reduce((acc, width) => acc + width, 0);
223
+ const scalingRatio = (100 - newColumnWidthPercentage) / totalCurrentWidth;
224
+ const scaledWidths = schema.headWidthPercentages.map((width) => width * scalingRatio);
225
+ onChange([
226
+ { key: 'head', value: schema.head.concat(`Head ${schema.head.length + 1}`) },
227
+ { key: 'headWidthPercentages', value: scaledWidths.concat(newColumnWidthPercentage) },
228
+ {
229
+ key: 'content',
230
+ value: JSON.stringify(bodyWidthRange.map((row, i) => row.concat(`Row ${i + 1}`))),
231
+ },
232
+ ]);
233
+ };
234
+ rootElement.appendChild(addColumnButton);
235
+ let offsetX = 0;
236
+ table.columns.forEach((column, i) => {
237
+ offsetX = offsetX + column.width;
238
+ const removeColumnButton = document.createElement('button');
239
+ removeColumnButton.style.width = '30px';
240
+ removeColumnButton.style.height = '30px';
241
+ removeColumnButton.style.position = 'absolute';
242
+ removeColumnButton.style.top = '-30px';
243
+ removeColumnButton.style.left = `${offsetX - (0, common_1.px2mm)(30)}mm`;
244
+ removeColumnButton.innerText = '-';
245
+ removeColumnButton.onclick = (e) => {
246
+ e.preventDefault();
247
+ const totalWidthMinusRemoved = schema.headWidthPercentages.reduce((sum, width, j) => (j !== i ? sum + width : sum), 0);
248
+ // TODO Should also remove the deleted columnStyles when deleting
249
+ onChange([
250
+ { key: 'head', value: schema.head.filter((_, j) => j !== i) },
251
+ {
252
+ key: 'headWidthPercentages',
253
+ value: schema.headWidthPercentages
254
+ .filter((_, j) => j !== i)
255
+ .map((width) => (width / totalWidthMinusRemoved) * 100),
256
+ },
257
+ {
258
+ key: 'content',
259
+ value: JSON.stringify(bodyWidthRange.map((row) => row.filter((_, j) => j !== i))),
260
+ },
261
+ ]);
262
+ };
263
+ rootElement.appendChild(removeColumnButton);
264
+ if (i === table.columns.length - 1)
265
+ return;
266
+ const dragHandle = document.createElement('div');
267
+ const lineWidth = 5;
268
+ dragHandle.style.width = `${lineWidth}px`;
269
+ dragHandle.style.height = '100%';
270
+ dragHandle.style.backgroundColor = '#eee';
271
+ dragHandle.style.opacity = '0.5';
272
+ dragHandle.style.cursor = 'col-resize';
273
+ dragHandle.style.position = 'absolute';
274
+ dragHandle.style.zIndex = '10';
275
+ dragHandle.style.left = `${offsetX - (0, common_1.px2mm)(lineWidth) / 2}mm`;
276
+ dragHandle.style.top = '0';
277
+ const setColor = (e) => {
278
+ const handle = e.target;
279
+ handle.style.backgroundColor = '#2196f3';
280
+ };
281
+ const resetColor = (e) => {
282
+ const handle = e.target;
283
+ handle.style.backgroundColor = '#eee';
284
+ };
285
+ dragHandle.addEventListener('mouseover', setColor);
286
+ dragHandle.addEventListener('mouseout', resetColor);
287
+ const prevColumnLeft = offsetX - column.width;
288
+ const nextColumnRight = offsetX - (0, common_1.px2mm)(lineWidth) + table.columns[i + 1].width;
289
+ dragHandle.addEventListener('mousedown', (e) => {
290
+ resetEditingPosition();
291
+ const handle = e.target;
292
+ dragHandle.removeEventListener('mouseover', setColor);
293
+ dragHandle.removeEventListener('mouseout', resetColor);
294
+ let move = 0;
295
+ const mouseMove = (e) => {
296
+ // TODO There is an issue where newLeft gets displaced with drag & drop
297
+ let moveX = e.movementX;
298
+ const currentLeft = Number(handle.style.left.replace('mm', ''));
299
+ let newLeft = currentLeft + moveX;
300
+ if (newLeft < prevColumnLeft) {
301
+ newLeft = prevColumnLeft;
302
+ moveX = newLeft - currentLeft;
303
+ }
304
+ if (newLeft >= nextColumnRight) {
305
+ newLeft = nextColumnRight;
306
+ moveX = newLeft - currentLeft;
307
+ }
308
+ handle.style.left = `${newLeft}mm`;
309
+ move += moveX;
310
+ };
311
+ rootElement.addEventListener('mousemove', mouseMove);
312
+ const commitResize = () => {
313
+ if (move !== 0) {
314
+ const newHeadWidthPercentages = calcResizedHeadWidthPercentages({
315
+ currentHeadWidthPercentages: schema.headWidthPercentages,
316
+ currentHeadWidths: table.columns.map((column) => column.width),
317
+ changedHeadWidth: table.columns[i].width + move,
318
+ changedHeadIndex: i,
319
+ });
320
+ onChange({ key: 'headWidthPercentages', value: newHeadWidthPercentages });
321
+ }
322
+ move = 0;
323
+ dragHandle.addEventListener('mouseover', setColor);
324
+ dragHandle.addEventListener('mouseout', resetColor);
325
+ rootElement.removeEventListener('mousemove', mouseMove);
326
+ rootElement.removeEventListener('mouseup', commitResize);
327
+ };
328
+ rootElement.addEventListener('mouseup', commitResize);
329
+ });
330
+ rootElement.appendChild(dragHandle);
331
+ });
332
+ }
333
+ if (mode === 'viewer') {
334
+ resetEditingPosition();
335
+ }
336
+ const tableHeight = schema.showHead ? table.getHeight() : table.getBodyHeight();
337
+ if (schema.height !== tableHeight && onChange) {
338
+ onChange({ key: 'height', value: tableHeight });
339
+ }
340
+ };
341
+ exports.uiRender = uiRender;
342
+ //# sourceMappingURL=uiRender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uiRender.js","sourceRoot":"","sources":["../../../../src/tables/uiRender.ts"],"names":[],"mappings":";;;;;;AAEA,0CAAsC;AACtC,qDAAqD;AACrD,2CAAwD;AACxD,wDAA6B;AAK7B,MAAM,YAAY,GAAG,iBAAI,CAAC,EAAE,CAAC;AAE7B,MAAM,kBAAkB,GAAG,CAAC,MAAc,EAAa,EAAE,CAAC,CAAC;IACzD,QAAQ,EAAE,MAAM,CAAC,QAAQ;IACzB,SAAS,EAAE,MAAM,CAAC,SAAS;IAC3B,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;IAC3C,QAAQ,EAAE,MAAM,CAAC,QAAQ;IACzB,UAAU,EAAE,MAAM,CAAC,UAAU;IAC7B,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;IACzC,eAAe,EAAE,MAAM,CAAC,eAAe;IACvC,MAAM;IACN,SAAS,EAAE,MAAM,CAAC,SAAS;IAC3B,WAAW,EAAE,MAAM,CAAC,SAAS;IAC7B,WAAW,EAAE,MAAM,CAAC,SAAS;IAC7B,OAAO,EAAE,MAAM,CAAC,WAAW;CAC5B,CAAC,CAAC;AAEH,MAAM,+BAA+B,GAAG,CAAC,GAKxC,EAAE,EAAE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