@pdfme/ui 3.2.3 → 4.0.0-alpha.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.
package/src/helper.ts CHANGED
@@ -1,4 +1,4 @@
1
- // TODO Update pdfjs-dist. (might be able to reduce the bundle size.)
1
+ // Update pdfjs-dist. (might be able to reduce the bundle size.)
2
2
  // @ts-ignore
3
3
  import PDFJSWorker from 'pdfjs-dist/legacy/build/pdf.worker.entry.js';
4
4
  import { getDocument, GlobalWorkerOptions } from 'pdfjs-dist/legacy/build/pdf.js';
@@ -11,9 +11,12 @@ import {
11
11
  b64toUint8Array,
12
12
  pt2mm,
13
13
  Template,
14
+ BasePdf,
14
15
  SchemaForUI,
15
16
  Schema,
16
17
  Size,
18
+ isBlankPdf,
19
+ Plugins,
17
20
  } from '@pdfme/common';
18
21
  import { RULER_HEIGHT } from './constants.js';
19
22
 
@@ -250,39 +253,38 @@ export const b64toBlob = (base64: string) => {
250
253
  return new Blob([uniy8Array.buffer], { type: mimeType });
251
254
  };
252
255
 
253
- const sortSchemasList = (template: Template, pageNum: number): SchemaForUI[][] =>
254
- new Array(pageNum).fill('').reduce((acc, _, i) => {
256
+ const sortSchemasList = (template: Template): SchemaForUI[][] => {
257
+ const { schemas } = template;
258
+ const pageNum = schemas.length;
259
+ const arr = new Array(pageNum).fill('') as SchemaForUI[][];
260
+ return arr.reduce((acc, _, i) => {
255
261
  acc.push(
256
- template.schemas[i]
257
- ? Object.entries(template.schemas[i])
258
- .sort((a, b) => {
259
- const aIndex = (template.columns ?? []).findIndex((c) => c === a[0]);
260
- const bIndex = (template.columns ?? []).findIndex((c) => c === b[0]);
261
-
262
- return aIndex > bIndex ? 1 : -1;
263
- })
264
- .map((e) => {
265
- const [key, value] = e;
266
- const data = template.sampledata?.[0]?.[key] ?? '';
267
-
268
- return Object.assign(value, {
269
- key,
270
- data,
271
- id: uuid(),
272
- });
273
- })
262
+ schemas[i]
263
+ ? Object.entries(schemas[i]).map(([key, schema]) =>
264
+ Object.assign(schema, { key, content: schema.content, id: uuid() })
265
+ )
274
266
  : []
275
267
  );
276
-
277
268
  return acc;
278
269
  }, [] as SchemaForUI[][]);
279
-
280
- export const templateSchemas2SchemasList = async (_template: Template) => {
270
+ };
271
+ export const template2SchemasList = async (_template: Template) => {
281
272
  const template = cloneDeep(_template);
282
- const sortedSchemasList = sortSchemasList(template, template.schemas.length);
283
- const basePdf = await getB64BasePdf(template.basePdf);
284
- const pdfBlob = b64toBlob(basePdf);
285
- const pageSizes = await getPdfPageSizes(pdfBlob);
273
+ const { basePdf, schemas } = template;
274
+ const sortedSchemasList = sortSchemasList(template);
275
+
276
+ let pageSizes: Size[] = [];
277
+ if (isBlankPdf(basePdf)) {
278
+ pageSizes = schemas.map(() => ({
279
+ width: basePdf.width,
280
+ height: basePdf.height,
281
+ }));
282
+ } else {
283
+ const b64BasePdf = await getB64BasePdf(basePdf);
284
+ const pdfBlob = b64toBlob(b64BasePdf);
285
+ pageSizes = await getPdfPageSizes(pdfBlob);
286
+ }
287
+
286
288
  const ssl = sortedSchemasList.length;
287
289
  const psl = pageSizes.length;
288
290
  const schemasList = (
@@ -306,90 +308,24 @@ export const templateSchemas2SchemasList = async (_template: Template) => {
306
308
 
307
309
  return schema;
308
310
  });
309
-
310
311
  return schemasList;
311
312
  };
312
313
 
313
- export const generateColumnsAndSampledataIfNeeded = (template: Template) => {
314
- const { schemas, columns, sampledata } = template;
315
-
316
- const flatSchemaLengthForColumns = schemas
317
- .map((schema) => Object.keys(schema).length)
318
- .reduce((acc, cur) => acc + cur, 0);
319
- const needColumns = !columns || flatSchemaLengthForColumns !== columns.length;
320
-
321
- const flatSchemaLengthForSampleData = schemas
322
- .map((schema) => Object.keys(schema).filter((key) => !schema[key].readOnly).length)
323
- .reduce((acc, cur) => acc + cur, 0);
324
- const needSampledata =
325
- !sampledata || flatSchemaLengthForSampleData !== Object.keys(sampledata[0]).length;
326
-
327
- // columns
328
- if (needColumns) {
329
- template.columns = flatten(schemas.map((schema) => Object.keys(schema)));
330
- }
331
-
332
- // sampledata
333
- if (needSampledata) {
334
- template.sampledata = [
335
- schemas.reduce(
336
- (acc, cur) =>
337
- Object.assign(
338
- acc,
339
- Object.keys(cur).reduce((a, c) => {
340
- const { readOnly } = cur[c];
341
- if (readOnly) {
342
- return a;
343
- }
344
- return Object.assign(a, { [c]: '' });
345
- }, {} as { [key: string]: string })
346
- ),
347
- {} as { [key: string]: string }
348
- ),
349
- ];
350
- }
351
-
352
- return template;
353
- };
354
-
355
- export const fmtTemplate = (template: Template, schemasList: SchemaForUI[][]): Template => {
356
- const schemaAddedTemplate: Template = {
357
- ...template,
358
- schemas: cloneDeep(schemasList).map((schema) =>
359
- schema.reduce((acc, cur) => {
360
- const k = cur.key;
361
- // @ts-ignore
362
- delete cur.id;
363
- // @ts-ignore
364
- delete cur.key;
365
- // @ts-ignore
366
- delete cur.data;
367
- acc[k] = cur;
368
-
369
- return acc;
370
- }, {} as { [key: string]: Schema })
371
- ),
372
- columns: cloneDeep(schemasList).reduce(
373
- (acc, cur) => acc.concat(cur.map((s) => s.key)),
374
- [] as string[]
375
- ),
376
- sampledata: [
377
- cloneDeep(schemasList).reduce((acc, cur) => {
378
- cur.forEach((c) => {
379
- if (c.readOnly) {
380
- return;
381
- }
382
- acc[c.key] = c.data;
383
- });
384
-
385
- return acc;
386
- }, {} as { [key: string]: string }),
387
- ],
388
- basePdf: template.basePdf,
389
- };
390
-
391
- return schemaAddedTemplate;
392
- };
314
+ export const schemasList2template = (schemasList: SchemaForUI[][], basePdf: BasePdf): Template => ({
315
+ schemas: cloneDeep(schemasList).map((schema) =>
316
+ schema.reduce((acc, cur) => {
317
+ const k = cur.key;
318
+ // @ts-ignore
319
+ delete cur.id;
320
+ // @ts-ignore
321
+ delete cur.key;
322
+ acc[k] = cur;
323
+
324
+ return acc;
325
+ }, {} as { [key: string]: Schema })
326
+ ),
327
+ basePdf,
328
+ });
393
329
 
394
330
  export const getUniqSchemaKey = (arg: {
395
331
  copiedSchemaKey: string;
@@ -474,14 +410,7 @@ export const moveCommandToChangeSchemasArg = (props: {
474
410
  });
475
411
  };
476
412
 
477
- export const getPagesScrollTopByIndex = (
478
- pageSizes: {
479
- width: number;
480
- height: number;
481
- }[],
482
- index: number,
483
- scale: number
484
- ) => {
413
+ export const getPagesScrollTopByIndex = (pageSizes: Size[], index: number, scale: number) => {
485
414
  return pageSizes
486
415
  .slice(0, index)
487
416
  .reduce((acc, cur) => acc + (cur.height * ZOOM + RULER_HEIGHT * scale) * scale, 0);
@@ -489,3 +418,70 @@ export const getPagesScrollTopByIndex = (
489
418
 
490
419
  export const getSidebarContentHeight = (sidebarHeight: number) =>
491
420
  sidebarHeight - RULER_HEIGHT - RULER_HEIGHT / 2 - 115;
421
+
422
+ const handlePositionSizeChange = (
423
+ schema: SchemaForUI,
424
+ key: string,
425
+ value: any,
426
+ basePdf: BasePdf,
427
+ pageSize: Size
428
+ ) => {
429
+ const padding = isBlankPdf(basePdf) ? basePdf.padding : [0, 0, 0, 0];
430
+ const [pt, pr, pb, pl] = padding;
431
+ const { width: pw, height: ph } = pageSize;
432
+ const calcBounds = (v: any, min: number, max: number) => Math.min(Math.max(Number(v), min), max);
433
+ if (key === 'position.x') {
434
+ schema.position.x = calcBounds(value, pl, pw - schema.width - pr);
435
+ } else if (key === 'position.y') {
436
+ schema.position.y = calcBounds(value, pt, ph - schema.height - pb);
437
+ } else if (key === 'width') {
438
+ schema.width = calcBounds(value, 0, pw - schema.position.x - pr);
439
+ } else if (key === 'height') {
440
+ schema.height = calcBounds(value, 0, ph - schema.position.y - pb);
441
+ }
442
+ };
443
+
444
+ const handleTypeChange = (
445
+ schema: SchemaForUI,
446
+ key: string,
447
+ value: any,
448
+ pluginsRegistry: Plugins
449
+ ) => {
450
+ if (key !== 'type') return;
451
+ const keysToKeep = ['id', 'key', 'type', 'position'];
452
+ Object.keys(schema).forEach((key) => {
453
+ if (!keysToKeep.includes(key)) {
454
+ delete schema[key as keyof typeof schema];
455
+ }
456
+ });
457
+ const propPanel = Object.values(pluginsRegistry).find(
458
+ (plugin) => plugin?.propPanel.defaultSchema.type === value
459
+ )?.propPanel;
460
+ Object.assign(schema, propPanel?.defaultSchema || {});
461
+ };
462
+
463
+ export const changeSchemas = (args: {
464
+ objs: { key: string; value: any; schemaId: string }[];
465
+ schemas: SchemaForUI[];
466
+ basePdf: BasePdf;
467
+ pluginsRegistry: Plugins;
468
+ pageSize: { width: number; height: number };
469
+ commitSchemas: (newSchemas: SchemaForUI[]) => void;
470
+ }) => {
471
+ const { objs, schemas, basePdf, pluginsRegistry, pageSize, commitSchemas } = args;
472
+ const newSchemas = objs.reduce((acc, { key, value, schemaId }) => {
473
+ const tgt = acc.find((s) => s.id === schemaId);
474
+ if (!tgt) return acc;
475
+ // Assign to reference
476
+ set(tgt, key, value);
477
+
478
+ if (key === 'type') {
479
+ handleTypeChange(tgt, key, value, pluginsRegistry);
480
+ } else if (['position.x', 'position.y', 'width', 'height'].includes(key)) {
481
+ handlePositionSizeChange(tgt, key, value, basePdf, pageSize);
482
+ }
483
+
484
+ return acc;
485
+ }, cloneDeep(schemas));
486
+ commitSchemas(newSchemas);
487
+ };
package/src/hooks.ts CHANGED
@@ -1,8 +1,16 @@
1
1
  import { RefObject, useRef, useState, useCallback, useEffect } from 'react';
2
- import { ZOOM, Template, Size, getB64BasePdf, SchemaForUI, ChangeSchemas } from '@pdfme/common';
2
+ import {
3
+ ZOOM,
4
+ Template,
5
+ Size,
6
+ getB64BasePdf,
7
+ SchemaForUI,
8
+ ChangeSchemas,
9
+ isBlankPdf,
10
+ } from '@pdfme/common';
3
11
 
4
12
  import {
5
- fmtTemplate,
13
+ schemasList2template,
6
14
  uuid,
7
15
  cloneDeep,
8
16
  getUniqSchemaKey,
@@ -36,14 +44,29 @@ export const useUIPreProcessor = ({ template, size, zoomLevel }: UIPreProcessorP
36
44
  const [error, setError] = useState<Error | null>(null);
37
45
 
38
46
  const init = async (prop: { template: Template; size: Size }) => {
39
- const { template, size } = prop;
40
- const _basePdf = await getB64BasePdf(template.basePdf);
41
- const pdfBlob = b64toBlob(_basePdf);
42
- const _pageSizes = await getPdfPageSizes(pdfBlob);
43
- const paperWidth = _pageSizes[0].width * ZOOM;
44
- const paperHeight = _pageSizes[0].height * ZOOM;
45
- const _backgrounds = await pdf2Pngs(pdfBlob, paperWidth);
47
+ const {
48
+ template: { basePdf, schemas },
49
+ size,
50
+ } = prop;
51
+ let paperWidth, paperHeight, _backgrounds, _pageSizes;
46
52
 
53
+ if (isBlankPdf(basePdf)) {
54
+ const { width, height } = basePdf;
55
+ paperWidth = width * ZOOM;
56
+ paperHeight = height * ZOOM;
57
+ _backgrounds = schemas.map(
58
+ () =>
59
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII='
60
+ );
61
+ _pageSizes = schemas.map(() => ({ width, height }));
62
+ } else {
63
+ const _basePdf = await getB64BasePdf(basePdf);
64
+ const pdfBlob = b64toBlob(_basePdf);
65
+ _pageSizes = await getPdfPageSizes(pdfBlob);
66
+ paperWidth = _pageSizes[0].width * ZOOM;
67
+ paperHeight = _pageSizes[0].height * ZOOM;
68
+ _backgrounds = await pdf2Pngs(pdfBlob, paperWidth);
69
+ }
47
70
  const _scale = Math.min(
48
71
  getScale(size.width, paperWidth),
49
72
  getScale(size.height - RULER_HEIGHT, paperHeight)
@@ -51,6 +74,7 @@ export const useUIPreProcessor = ({ template, size, zoomLevel }: UIPreProcessorP
51
74
 
52
75
  return { backgrounds: _backgrounds, pageSizes: _pageSizes, scale: _scale };
53
76
  };
77
+
54
78
  useEffect(() => {
55
79
  init({ template, size })
56
80
  .then(({ pageSizes, scale, backgrounds }) => {
@@ -62,7 +86,16 @@ export const useUIPreProcessor = ({ template, size, zoomLevel }: UIPreProcessorP
62
86
  });
63
87
  }, [template, size]);
64
88
 
65
- return { backgrounds, pageSizes, scale: scale * zoomLevel, error };
89
+ return {
90
+ backgrounds,
91
+ pageSizes,
92
+ scale: scale * zoomLevel,
93
+ error,
94
+ refresh: (template: Template) =>
95
+ init({ template, size }).then(({ pageSizes, scale, backgrounds }) => {
96
+ setPageSizes(pageSizes), setScale(scale), setBackgrounds(backgrounds);
97
+ }),
98
+ };
66
99
  };
67
100
 
68
101
  type ScrollPageCursorProps = {
@@ -163,8 +196,6 @@ export const useInitEvents = ({
163
196
  }: UseInitEventsParams) => {
164
197
  const copiedSchemas = useRef<SchemaForUI[] | null>(null);
165
198
 
166
- const modifiedTemplate = fmtTemplate(template, schemasList);
167
-
168
199
  const initEvents = useCallback(() => {
169
200
  const getActiveSchemas = () => {
170
201
  const ids = activeElements.map((ae) => ae.id);
@@ -215,12 +246,14 @@ export const useInitEvents = ({
215
246
  },
216
247
  redo: () => timeTravel('redo'),
217
248
  undo: () => timeTravel('undo'),
218
- save: () => onSaveTemplate && onSaveTemplate(modifiedTemplate),
249
+ save: () =>
250
+ onSaveTemplate && onSaveTemplate(schemasList2template(schemasList, template.basePdf)),
219
251
  remove: () => removeSchemas(getActiveSchemas().map((s) => s.id)),
220
252
  esc: onEditEnd,
221
253
  selectAll: () => onEdit(schemasList[pageCursor].map((s) => document.getElementById(s.id)!)),
222
254
  });
223
255
  }, [
256
+ template,
224
257
  activeElements,
225
258
  pageCursor,
226
259
  pageSizes,
@@ -228,7 +261,6 @@ export const useInitEvents = ({
228
261
  commitSchemas,
229
262
  schemasList,
230
263
  onSaveTemplate,
231
- modifiedTemplate,
232
264
  removeSchemas,
233
265
  past,
234
266
  future,
package/src/i18n.ts CHANGED
@@ -24,10 +24,14 @@ const dictEn: { [key in keyof Dict]: string } = {
24
24
  'Cannot commit the change because the number of items has been changed.',
25
25
  commitBulkUpdateFieldName: 'Commit Changes',
26
26
  bulkUpdateFieldName: 'Bulk update field names',
27
+ addPageAfter: 'Add Page After',
28
+ removePage: 'Remove Current Page',
29
+ removePageConfirm: 'Are you sure you want to delete this page? This action cannot be undone.',
27
30
  hexColorPrompt: 'Please enter a valid hex color code.',
28
31
  'schemas.color': 'Color',
29
32
  'schemas.borderWidth': 'Border Width',
30
33
  'schemas.borderColor': 'Border Color',
34
+ 'schemas.backgroundColor': 'Background Color',
31
35
  'schemas.textColor': 'Text Color',
32
36
  'schemas.bgColor': 'Background Color',
33
37
  'schemas.horizontal': 'Horizontal',
@@ -38,6 +42,7 @@ const dictEn: { [key in keyof Dict]: string } = {
38
42
  'schemas.top': 'Top',
39
43
  'schemas.middle': 'Middle',
40
44
  'schemas.bottom': 'Bottom',
45
+ 'schemas.padding': 'Padding',
41
46
  'schemas.text.fontName': 'Font Name',
42
47
  'schemas.text.size': 'Size',
43
48
  'schemas.text.spacing': 'Spacing',
@@ -50,6 +55,11 @@ const dictEn: { [key in keyof Dict]: string } = {
50
55
  'schemas.text.dynamicFontSize': 'Dynamic Font Size',
51
56
  'schemas.barcodes.barColor': 'Bar Color',
52
57
  'schemas.barcodes.includetext': 'Include Text',
58
+ 'schemas.table.alternateBackgroundColor': 'Alternate Background Color',
59
+ 'schemas.table.tableStyle': 'Table Style',
60
+ 'schemas.table.headStyle': 'Header Style',
61
+ 'schemas.table.bodyStyle': 'Body Style',
62
+ 'schemas.table.columnStyle': 'Column Style',
53
63
  };
54
64
 
55
65
  const dictJa: { [key in keyof Dict]: string } = {
@@ -74,10 +84,14 @@ const dictJa: { [key in keyof Dict]: string } = {
74
84
  errorBulkUpdateFieldName: '項目数が変更されているため変更をコミットできません。',
75
85
  commitBulkUpdateFieldName: '変更を反映',
76
86
  bulkUpdateFieldName: '項目名を一括変更',
87
+ addPageAfter: '次にページを追加',
88
+ removePage: '現在のページを削除',
89
+ removePageConfirm: 'ページを削除してもよろしいですか?この操作は元に戻せません。',
77
90
  hexColorPrompt: '有効な16進数のカラーコードを入力してください。',
78
91
  'schemas.color': '色',
79
92
  'schemas.borderWidth': '枠線の太さ',
80
93
  'schemas.borderColor': '枠線の色',
94
+ 'schemas.backgroundColor': '背景色',
81
95
  'schemas.textColor': 'テキストの色',
82
96
  'schemas.bgColor': '背景色',
83
97
  'schemas.horizontal': '水平',
@@ -88,6 +102,7 @@ const dictJa: { [key in keyof Dict]: string } = {
88
102
  'schemas.top': '上',
89
103
  'schemas.middle': '中間',
90
104
  'schemas.bottom': '下',
105
+ 'schemas.padding': 'パディング',
91
106
  'schemas.text.fontName': 'フォント名',
92
107
  'schemas.text.size': 'サイズ',
93
108
  'schemas.text.spacing': '間隔',
@@ -100,6 +115,11 @@ const dictJa: { [key in keyof Dict]: string } = {
100
115
  'schemas.text.dynamicFontSize': '動的フォントサイズ',
101
116
  'schemas.barcodes.barColor': 'バーの色',
102
117
  'schemas.barcodes.includetext': 'テキストを含める',
118
+ 'schemas.table.alternateBackgroundColor': '交互の背景色',
119
+ 'schemas.table.tableStyle': 'テーブルスタイル',
120
+ 'schemas.table.headStyle': 'ヘッダースタイル',
121
+ 'schemas.table.bodyStyle': 'ボディスタイル',
122
+ 'schemas.table.columnStyle': 'カラムスタイル',
103
123
  };
104
124
 
105
125
  const dictAr: { [key in keyof Dict]: string } = {
@@ -124,10 +144,14 @@ const dictAr: { [key in keyof Dict]: string } = {
124
144
  errorBulkUpdateFieldName: 'لا يمكن تنفيذ التغيير لأنه تم تغيير عدد العناصر.',
125
145
  commitBulkUpdateFieldName: 'تنفيذ التغييرات',
126
146
  bulkUpdateFieldName: 'تغيير الأسماء',
147
+ addPageAfter: 'إضافة صفحة بعد',
148
+ removePage: 'احذف الصفحة الحالية',
149
+ removePageConfirm: 'هل أنت متأكد من رغبتك في حذف هذه الصفحة؟ لا يمكن التراجع عن هذا الإجراء.',
127
150
  hexColorPrompt: 'الرجاء إدخال رمز لون سداسي عشري صالح.',
128
151
  'schemas.color': 'اللون',
129
152
  'schemas.borderWidth': 'عرض الحدود',
130
153
  'schemas.borderColor': 'لون الحدود',
154
+ 'schemas.backgroundColor': 'لون الخلفية',
131
155
  'schemas.textColor': 'لون الخط',
132
156
  'schemas.bgColor': 'لون الخلفية',
133
157
  'schemas.horizontal': 'أفقي',
@@ -138,6 +162,7 @@ const dictAr: { [key in keyof Dict]: string } = {
138
162
  'schemas.top': 'أعلى',
139
163
  'schemas.middle': 'وسط',
140
164
  'schemas.bottom': 'أسفل',
165
+ 'schemas.padding': 'التبطين',
141
166
  'schemas.text.fontName': 'اسم الخط',
142
167
  'schemas.text.size': 'الحجم',
143
168
  'schemas.text.spacing': 'التباعد',
@@ -150,6 +175,11 @@ const dictAr: { [key in keyof Dict]: string } = {
150
175
  'schemas.text.dynamicFontSize': 'حجم الخط الديناميكي',
151
176
  'schemas.barcodes.barColor': 'لون الشريط',
152
177
  'schemas.barcodes.includetext': 'تضمين النص',
178
+ 'schemas.table.alternateBackgroundColor': 'لون الخلفية البديل',
179
+ 'schemas.table.tableStyle': 'أسلوب الجدول',
180
+ 'schemas.table.headStyle': 'أسلوب الرأس',
181
+ 'schemas.table.bodyStyle': 'أسلوب الجسم',
182
+ 'schemas.table.columnStyle': 'أسلوب العمود',
153
183
  };
154
184
 
155
185
  const dictTh: { [key in keyof Dict]: string } = {
@@ -174,10 +204,14 @@ const dictTh: { [key in keyof Dict]: string } = {
174
204
  errorBulkUpdateFieldName: 'ไม่สามารถยืนยันการแก้ไขได้เนื่องจากจำนวนรายการมีการเปลี่ยนแปลง',
175
205
  commitBulkUpdateFieldName: 'ยืนยันการแก้ไข',
176
206
  bulkUpdateFieldName: 'แก้ไขชื่อฟิลด์เป็นชุด',
207
+ addPageAfter: 'เพิ่มหน้าถัดไป',
208
+ removePage: 'ลบหน้าปัจจุบัน',
209
+ removePageConfirm: 'คุณแน่ใจหรือไม่ว่าต้องการลบหน้านี้? การกระทำนี้ไม่สามารถย้อนกลับได้',
177
210
  hexColorPrompt: 'กรุณาใส่รหัสสีแบบฐานสิบหกที่ถูกต้อง',
178
211
  'schemas.color': 'สี',
179
212
  'schemas.borderWidth': 'ความกว้างของเส้นขอบ',
180
213
  'schemas.borderColor': 'สีขอบ',
214
+ 'schemas.backgroundColor': 'สีพื้นหลัง',
181
215
  'schemas.textColor': 'สีข้อความ',
182
216
  'schemas.bgColor': 'สีพื้นหลัง',
183
217
  'schemas.horizontal': 'แนวนอน',
@@ -188,6 +222,7 @@ const dictTh: { [key in keyof Dict]: string } = {
188
222
  'schemas.top': 'ด้านบน',
189
223
  'schemas.middle': 'ตรงกลาง',
190
224
  'schemas.bottom': 'ด้านล่าง',
225
+ 'schemas.padding': 'การเพิ่มพื้นที่',
191
226
  'schemas.text.fontName': 'ชื่อแบบอักษร',
192
227
  'schemas.text.size': 'ขนาด',
193
228
  'schemas.text.spacing': 'ระยะห่าง',
@@ -200,6 +235,11 @@ const dictTh: { [key in keyof Dict]: string } = {
200
235
  'schemas.text.dynamicFontSize': 'ขนาดตัวอักษรแบบไดนามิก',
201
236
  'schemas.barcodes.barColor': 'สีบาร์',
202
237
  'schemas.barcodes.includetext': 'รวมข้อความ',
238
+ 'schemas.table.alternateBackgroundColor': 'สีพื้นหลังสลับกัน',
239
+ 'schemas.table.tableStyle': 'สไตล์ตาราง',
240
+ 'schemas.table.headStyle': 'สไตล์หัวข้อ',
241
+ 'schemas.table.bodyStyle': 'สไตล์เนื้อหา',
242
+ 'schemas.table.columnStyle': 'สไตล์คอลัมน์',
203
243
  };
204
244
 
205
245
  const dictIt: { [key in keyof Dict]: string } = {
@@ -225,10 +265,15 @@ const dictIt: { [key in keyof Dict]: string } = {
225
265
  'Non è possibile salvare le modifiche perché il numero di elementi è cambiato.',
226
266
  commitBulkUpdateFieldName: 'Salva cambiamenti',
227
267
  bulkUpdateFieldName: 'Modifica nomi campi in blocco',
268
+ addPageAfter: 'Aggiungi pagina dopo',
269
+ removePage: 'Rimuovi la Pagina Corrente',
270
+ removePageConfirm:
271
+ 'Sei sicuro di voler eliminare questa pagina? Questa azione non può essere annullata.',
228
272
  hexColorPrompt: 'Inserisci un codice colore esadecimale valido.',
229
273
  'schemas.color': 'Colore',
230
274
  'schemas.borderWidth': 'Spessore bordo',
231
275
  'schemas.borderColor': 'Colore bordo',
276
+ 'schemas.backgroundColor': 'Colore di Sfondo',
232
277
  'schemas.textColor': 'Colore testo',
233
278
  'schemas.bgColor': 'Colore sfondo',
234
279
  'schemas.horizontal': 'Orizzontale',
@@ -239,6 +284,7 @@ const dictIt: { [key in keyof Dict]: string } = {
239
284
  'schemas.top': 'Sopra',
240
285
  'schemas.middle': 'Medio',
241
286
  'schemas.bottom': 'Sotto',
287
+ 'schemas.padding': 'Padding',
242
288
  'schemas.text.fontName': 'Nome del font',
243
289
  'schemas.text.size': 'Dimensione',
244
290
  'schemas.text.spacing': 'Spaziatura',
@@ -251,6 +297,11 @@ const dictIt: { [key in keyof Dict]: string } = {
251
297
  'schemas.text.dynamicFontSize': 'Dimensione font dinamica',
252
298
  'schemas.barcodes.barColor': 'Colore barra',
253
299
  'schemas.barcodes.includetext': 'Includi testo',
300
+ 'schemas.table.alternateBackgroundColor': 'Colore di Sfondo Alternato',
301
+ 'schemas.table.tableStyle': 'Stile della Tabella',
302
+ 'schemas.table.headStyle': "Stile dell'Intestazione",
303
+ 'schemas.table.bodyStyle': 'Stile del Corpo',
304
+ 'schemas.table.columnStyle': 'Stile della Colonna',
254
305
  };
255
306
 
256
307
  const dictPl: { [key in keyof Dict]: string } = {
@@ -275,10 +326,14 @@ const dictPl: { [key in keyof Dict]: string } = {
275
326
  errorBulkUpdateFieldName: 'Nie można wprowadzić zmian ponieważ liczba elementów uległa zmianie.',
276
327
  commitBulkUpdateFieldName: 'Zaakceptuj zmiany',
277
328
  bulkUpdateFieldName: 'Masowo aktualizuj klucze pól',
329
+ addPageAfter: 'Dodaj stronę po',
330
+ removePage: 'Usuń Bieżącą Stronę',
331
+ removePageConfirm: 'Czy na pewno chcesz usunąć tę stronę? Tej operacji nie można cofnąć.',
278
332
  hexColorPrompt: 'Wprowadź poprawny kod koloru szesnastkowego.',
279
333
  'schemas.color': 'Kolor',
280
334
  'schemas.borderWidth': 'Szerokość obramowania',
281
335
  'schemas.borderColor': 'Kolor obramowania',
336
+ 'schemas.backgroundColor': 'Kolor tła',
282
337
  'schemas.textColor': 'Kolor tekstu',
283
338
  'schemas.bgColor': 'Kolor tła',
284
339
  'schemas.horizontal': 'Poziomo',
@@ -289,6 +344,7 @@ const dictPl: { [key in keyof Dict]: string } = {
289
344
  'schemas.top': 'Góra',
290
345
  'schemas.middle': 'Środek',
291
346
  'schemas.bottom': 'Dół',
347
+ 'schemas.padding': 'Odsadzenie',
292
348
  'schemas.text.fontName': 'Nazwa czcionki',
293
349
  'schemas.text.size': 'Rozmiar',
294
350
  'schemas.text.spacing': 'Odstępy',
@@ -301,6 +357,11 @@ const dictPl: { [key in keyof Dict]: string } = {
301
357
  'schemas.text.dynamicFontSize': 'Dynamiczny rozmiar czcionki',
302
358
  'schemas.barcodes.barColor': 'Kolor paska',
303
359
  'schemas.barcodes.includetext': 'Dołącz tekst',
360
+ 'schemas.table.alternateBackgroundColor': 'Alternatywny kolor tła',
361
+ 'schemas.table.tableStyle': 'Styl tabeli',
362
+ 'schemas.table.headStyle': 'Styl nagłówka',
363
+ 'schemas.table.bodyStyle': 'Styl ciała',
364
+ 'schemas.table.columnStyle': 'Styl kolumny',
304
365
  };
305
366
 
306
367
  const dictDe: { [key in keyof Dict]: string } = {
@@ -326,10 +387,15 @@ const dictDe: { [key in keyof Dict]: string } = {
326
387
  'Die Änderung kann nicht übernommen werden, weil die Anzahl der Elemente geändert wurde.',
327
388
  commitBulkUpdateFieldName: 'Änderungen übernehmen',
328
389
  bulkUpdateFieldName: 'Mehrfachaktualisierung der Feldnamen',
390
+ addPageAfter: 'Seite danach hinzufügen',
391
+ removePage: 'Aktuelle Seite entfernen',
392
+ removePageConfirm:
393
+ 'Sind Sie sicher, dass Sie diese Seite löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.',
329
394
  hexColorPrompt: 'Bitte geben Sie einen gültigen Hex-Farbcode ein.',
330
395
  'schemas.color': 'Farbe',
331
396
  'schemas.borderWidth': 'Rahmenbreite',
332
397
  'schemas.borderColor': 'Rahmenfarbe',
398
+ 'schemas.backgroundColor': 'Hintergrundfarbe',
333
399
  'schemas.textColor': 'Textfarbe',
334
400
  'schemas.bgColor': 'Hintergrundfarbe',
335
401
  'schemas.horizontal': 'Horizontal',
@@ -340,6 +406,7 @@ const dictDe: { [key in keyof Dict]: string } = {
340
406
  'schemas.top': 'Oben',
341
407
  'schemas.middle': 'Mitte',
342
408
  'schemas.bottom': 'Unten',
409
+ 'schemas.padding': 'Polsterung',
343
410
  'schemas.text.fontName': 'Schriftart',
344
411
  'schemas.text.size': 'Größe',
345
412
  'schemas.text.spacing': 'Abstand',
@@ -352,6 +419,11 @@ const dictDe: { [key in keyof Dict]: string } = {
352
419
  'schemas.text.dynamicFontSize': 'Dynamische Schriftgröße',
353
420
  'schemas.barcodes.barColor': 'Strichcodefarbe',
354
421
  'schemas.barcodes.includetext': 'Text anzeigen',
422
+ 'schemas.table.alternateBackgroundColor': 'Wechselnde Hintergrundfarbe',
423
+ 'schemas.table.tableStyle': 'Tabellenstil',
424
+ 'schemas.table.headStyle': 'Kopfzeilenstil',
425
+ 'schemas.table.bodyStyle': 'Körperstil',
426
+ 'schemas.table.columnStyle': 'Spaltenstil',
355
427
  };
356
428
 
357
429
  const dictionaries: { [key in Lang]: Dict } = {
package/vite.config.ts CHANGED
@@ -3,17 +3,20 @@ import react from '@vitejs/plugin-react';
3
3
  import tsconfigPaths from 'vite-tsconfig-paths';
4
4
  import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
5
5
 
6
- export default defineConfig({
7
- plugins: [react(), tsconfigPaths({ root: '.' }), cssInjectedByJsPlugin()],
8
- build: {
9
- lib: {
10
- entry: 'src/index.ts',
11
- name: '@pdfme/ui',
12
- fileName: (format) => `index.${format}.js`,
6
+ export default defineConfig(({ mode }) => {
7
+ return {
8
+ define: { 'process.env.NODE_ENV': JSON.stringify(mode) },
9
+ plugins: [react(), tsconfigPaths({ root: '.' }), cssInjectedByJsPlugin()],
10
+ build: {
11
+ lib: {
12
+ entry: 'src/index.ts',
13
+ name: '@pdfme/ui',
14
+ fileName: (format) => `index.${format}.js`,
15
+ },
13
16
  },
14
- },
15
- optimizeDeps: {
16
- include: ['react', 'react-dom', 'pdfjs-dist', 'antd'],
17
- exclude: ['@pdfme/common', '@pdfme/schemas'],
18
- },
17
+ optimizeDeps: {
18
+ include: ['react', 'react-dom', 'pdfjs-dist', 'antd'],
19
+ exclude: ['@pdfme/common', '@pdfme/schemas'],
20
+ },
21
+ };
19
22
  });