@pdfme/schemas 4.3.2-dev.2 → 4.3.2-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/src/index.js +2 -3
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/tables/dynamicTemplate.js +5 -61
- package/dist/cjs/src/tables/dynamicTemplate.js.map +1 -1
- package/dist/cjs/src/tables/tableHelper.js +10 -50
- package/dist/cjs/src/tables/tableHelper.js.map +1 -1
- package/dist/cjs/src/tables/uiRender.js +16 -15
- package/dist/cjs/src/tables/uiRender.js.map +1 -1
- package/dist/cjs/src/utils.js +1 -3
- package/dist/cjs/src/utils.js.map +1 -1
- package/dist/esm/src/index.js +4 -2
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/tables/dynamicTemplate.js +4 -59
- package/dist/esm/src/tables/dynamicTemplate.js.map +1 -1
- package/dist/esm/src/tables/tableHelper.js +10 -49
- package/dist/esm/src/tables/tableHelper.js.map +1 -1
- package/dist/esm/src/tables/uiRender.js +16 -15
- package/dist/esm/src/tables/uiRender.js.map +1 -1
- package/dist/esm/src/utils.js +0 -1
- package/dist/esm/src/utils.js.map +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/tables/dynamicTemplate.d.ts +3 -9
- package/dist/types/src/tables/tableHelper.d.ts +0 -1
- package/dist/types/src/utils.d.ts +0 -1
- package/package.json +1 -1
- package/src/index.ts +4 -4
- package/src/tables/dynamicTemplate.ts +7 -69
- package/src/tables/tableHelper.ts +11 -62
- package/src/tables/uiRender.ts +18 -16
- package/src/utils.ts +1 -2
package/src/tables/uiRender.ts
CHANGED
@@ -6,6 +6,8 @@ import { getBody, getBodyWithRange } from './helper.js';
|
|
6
6
|
import cell from './cell.js';
|
7
7
|
import { Row } from './classes';
|
8
8
|
|
9
|
+
const buttonSize = 30;
|
10
|
+
|
9
11
|
type RowType = InstanceType<typeof Row>;
|
10
12
|
|
11
13
|
const cellUiRender = cell.ui;
|
@@ -218,11 +220,11 @@ export const uiRender = async (arg: UIRenderProps<TableSchema>) => {
|
|
218
220
|
schema.__bodyRange.end >= (JSON.parse(value || '[]') as string[][]).length
|
219
221
|
) {
|
220
222
|
const addRowButton = document.createElement('button');
|
221
|
-
addRowButton.style.width =
|
222
|
-
addRowButton.style.height =
|
223
|
+
addRowButton.style.width = `${buttonSize}px`;
|
224
|
+
addRowButton.style.height = `${buttonSize}px`;
|
223
225
|
addRowButton.style.position = 'absolute';
|
224
226
|
addRowButton.style.top = `${table.getHeight()}mm`;
|
225
|
-
addRowButton.style.left =
|
227
|
+
addRowButton.style.left = `calc(50% - ${buttonSize / 2}px)`;
|
226
228
|
addRowButton.innerText = '+';
|
227
229
|
addRowButton.onclick = () => {
|
228
230
|
const newRow = Array(schema.head.length).fill('') as string[];
|
@@ -235,11 +237,11 @@ export const uiRender = async (arg: UIRenderProps<TableSchema>) => {
|
|
235
237
|
table.body.forEach((row, i) => {
|
236
238
|
offsetY = offsetY + row.height;
|
237
239
|
const removeRowButton = document.createElement('button');
|
238
|
-
removeRowButton.style.width =
|
239
|
-
removeRowButton.style.height =
|
240
|
+
removeRowButton.style.width = `${buttonSize}px`;
|
241
|
+
removeRowButton.style.height = `${buttonSize}px`;
|
240
242
|
removeRowButton.style.position = 'absolute';
|
241
|
-
removeRowButton.style.top = `${offsetY - px2mm(
|
242
|
-
removeRowButton.style.right =
|
243
|
+
removeRowButton.style.top = `${offsetY - px2mm(buttonSize)}mm`;
|
244
|
+
removeRowButton.style.right = `-${buttonSize}px`;
|
243
245
|
removeRowButton.innerText = '-';
|
244
246
|
removeRowButton.onclick = () => {
|
245
247
|
const newTableBody = body.filter((_, j) => j !== i + (schema.__bodyRange?.start ?? 0));
|
@@ -251,11 +253,11 @@ export const uiRender = async (arg: UIRenderProps<TableSchema>) => {
|
|
251
253
|
|
252
254
|
if (mode === 'designer' && onChange) {
|
253
255
|
const addColumnButton = document.createElement('button');
|
254
|
-
addColumnButton.style.width =
|
255
|
-
addColumnButton.style.height =
|
256
|
+
addColumnButton.style.width = `${buttonSize}px`;
|
257
|
+
addColumnButton.style.height = `${buttonSize}px`;
|
256
258
|
addColumnButton.style.position = 'absolute';
|
257
|
-
addColumnButton.style.top = `${table.getHeadHeight() - px2mm(
|
258
|
-
addColumnButton.style.right =
|
259
|
+
addColumnButton.style.top = `${table.getHeadHeight() - px2mm(buttonSize)}mm`;
|
260
|
+
addColumnButton.style.right = `-${buttonSize}px`;
|
259
261
|
addColumnButton.innerText = '+';
|
260
262
|
addColumnButton.onclick = (e) => {
|
261
263
|
e.preventDefault();
|
@@ -278,11 +280,11 @@ export const uiRender = async (arg: UIRenderProps<TableSchema>) => {
|
|
278
280
|
table.columns.forEach((column, i) => {
|
279
281
|
offsetX = offsetX + column.width;
|
280
282
|
const removeColumnButton = document.createElement('button');
|
281
|
-
removeColumnButton.style.width =
|
282
|
-
removeColumnButton.style.height =
|
283
|
+
removeColumnButton.style.width = `${buttonSize}px`;
|
284
|
+
removeColumnButton.style.height = `${buttonSize}px`;
|
283
285
|
removeColumnButton.style.position = 'absolute';
|
284
|
-
removeColumnButton.style.top =
|
285
|
-
removeColumnButton.style.left = `${offsetX - px2mm(
|
286
|
+
removeColumnButton.style.top = `-${buttonSize}px`;
|
287
|
+
removeColumnButton.style.left = `${offsetX - px2mm(buttonSize)}mm`;
|
286
288
|
removeColumnButton.innerText = '-';
|
287
289
|
removeColumnButton.onclick = (e) => {
|
288
290
|
e.preventDefault();
|
@@ -390,4 +392,4 @@ export const uiRender = async (arg: UIRenderProps<TableSchema>) => {
|
|
390
392
|
if (schema.height !== tableHeight && onChange) {
|
391
393
|
onChange({ key: 'height', value: tableHeight });
|
392
394
|
}
|
393
|
-
};
|
395
|
+
};
|
package/src/utils.ts
CHANGED