@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.
@@ -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 = '30px';
222
- addRowButton.style.height = '30px';
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 = 'calc(50% - 15px)';
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 = '30px';
239
- removeRowButton.style.height = '30px';
240
+ removeRowButton.style.width = `${buttonSize}px`;
241
+ removeRowButton.style.height = `${buttonSize}px`;
240
242
  removeRowButton.style.position = 'absolute';
241
- removeRowButton.style.top = `${offsetY - px2mm(30)}mm`;
242
- removeRowButton.style.right = '-30px';
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 = '30px';
255
- addColumnButton.style.height = '30px';
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(30)}mm`;
258
- addColumnButton.style.right = '-30px';
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 = '30px';
282
- removeColumnButton.style.height = '30px';
283
+ removeColumnButton.style.width = `${buttonSize}px`;
284
+ removeColumnButton.style.height = `${buttonSize}px`;
283
285
  removeColumnButton.style.position = 'absolute';
284
- removeColumnButton.style.top = '-30px';
285
- removeColumnButton.style.left = `${offsetX - px2mm(30)}mm`;
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
@@ -202,5 +202,4 @@ export const createErrorElm = () => {
202
202
  container.appendChild(span);
203
203
 
204
204
  return container;
205
- };
206
- export const cloneDeep = <T>(value: T): T => JSON.parse(JSON.stringify(value));
205
+ };