@pdfme/ui 5.0.0 → 5.1.1-dev.1

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.
@@ -8,6 +8,9 @@ declare class Form extends PreviewUI {
8
8
  value: string;
9
9
  name: string;
10
10
  }) => void): void;
11
+ setInputs(inputs: {
12
+ [key: string]: string;
13
+ }[]): void;
11
14
  protected render(): void;
12
15
  }
13
16
  export default Form;
@@ -17,7 +17,7 @@ export declare abstract class BaseUIClass {
17
17
  subset?: boolean | undefined;
18
18
  }>;
19
19
  protected getPluginsRegistry(): Plugins;
20
- protected getOptions(): {};
20
+ getOptions(): UIOptions;
21
21
  getTemplate(): import("zod").objectOutputType<{
22
22
  schemas: import("zod").ZodArray<import("zod").ZodArray<import("zod").ZodObject<{
23
23
  name: import("zod").ZodString;
@@ -1,7 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { Plugins, UIOptions } from '@pdfme/common';
3
- export declare const I18nContext: import("react").Context<(key: "type" | "width" | "height" | "rotate" | "opacity" | "required" | "cancel" | "field" | "fieldName" | "align" | "edit" | "editable" | "plsInputName" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "editField" | "errorOccurred" | "errorBulkUpdateFieldName" | "commitBulkUpdateFieldName" | "bulkUpdateFieldName" | "addPageAfter" | "removePage" | "removePageConfirm" | "validation.uniqueName" | "validation.hexColor" | "schemas.color" | "schemas.borderWidth" | "schemas.borderColor" | "schemas.backgroundColor" | "schemas.textColor" | "schemas.bgColor" | "schemas.horizontal" | "schemas.vertical" | "schemas.left" | "schemas.center" | "schemas.right" | "schemas.top" | "schemas.middle" | "schemas.bottom" | "schemas.padding" | "schemas.text.fontName" | "schemas.text.size" | "schemas.text.spacing" | "schemas.text.textAlign" | "schemas.text.verticalAlign" | "schemas.text.lineHeight" | "schemas.text.min" | "schemas.text.max" | "schemas.text.fit" | "schemas.text.dynamicFontSize" | "schemas.text.format" | "schemas.mvt.typingInstructions" | "schemas.mvt.sampleField" | "schemas.mvt.variablesSampleData" | "schemas.barcodes.barColor" | "schemas.barcodes.includetext" | "schemas.table.alternateBackgroundColor" | "schemas.table.tableStyle" | "schemas.table.headStyle" | "schemas.table.bodyStyle" | "schemas.table.columnStyle", dict?: {
3
+ export declare const I18nContext: import("react").Context<(key: "type" | "width" | "height" | "rotate" | "opacity" | "required" | "cancel" | "close" | "field" | "fieldName" | "align" | "edit" | "editable" | "plsInputName" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "editField" | "errorOccurred" | "errorBulkUpdateFieldName" | "commitBulkUpdateFieldName" | "bulkUpdateFieldName" | "addPageAfter" | "removePage" | "removePageConfirm" | "validation.uniqueName" | "validation.hexColor" | "schemas.color" | "schemas.borderWidth" | "schemas.borderColor" | "schemas.backgroundColor" | "schemas.textColor" | "schemas.bgColor" | "schemas.horizontal" | "schemas.vertical" | "schemas.left" | "schemas.center" | "schemas.right" | "schemas.top" | "schemas.middle" | "schemas.bottom" | "schemas.padding" | "schemas.text.fontName" | "schemas.text.size" | "schemas.text.spacing" | "schemas.text.textAlign" | "schemas.text.verticalAlign" | "schemas.text.lineHeight" | "schemas.text.min" | "schemas.text.max" | "schemas.text.fit" | "schemas.text.dynamicFontSize" | "schemas.text.format" | "schemas.mvt.typingInstructions" | "schemas.mvt.sampleField" | "schemas.mvt.variablesSampleData" | "schemas.barcodes.barColor" | "schemas.barcodes.includetext" | "schemas.table.alternateBackgroundColor" | "schemas.table.tableStyle" | "schemas.table.headStyle" | "schemas.table.bodyStyle" | "schemas.table.columnStyle" | "schemas.date.format" | "schemas.select.options" | "schemas.select.optionPlaceholder", dict?: {
4
4
  cancel: string;
5
+ close: string;
5
6
  field: string;
6
7
  fieldName: string;
7
8
  align: string;
@@ -64,6 +65,9 @@ export declare const I18nContext: import("react").Context<(key: "type" | "width"
64
65
  'schemas.table.headStyle': string;
65
66
  'schemas.table.bodyStyle': string;
66
67
  'schemas.table.columnStyle': string;
68
+ 'schemas.date.format': string;
69
+ 'schemas.select.options': string;
70
+ 'schemas.select.optionPlaceholder': string;
67
71
  } | undefined) => string>;
68
72
  export declare const FontContext: import("react").Context<Record<string, {
69
73
  data: (string | ArrayBuffer | Uint8Array) & (string | ArrayBuffer | Uint8Array | undefined);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/ui",
3
- "version": "5.0.0",
3
+ "version": "5.1.1-dev.1",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
@@ -87,7 +87,8 @@
87
87
  "^rc-picker/es/": "rc-picker/lib/",
88
88
  "^lodash-es$": "lodash",
89
89
  "^pdfjs-dist/legacy/build/pdf.js$": "<rootDir>/__mocks__/pdfjs-dist.js",
90
- "^pdfjs-dist/legacy/build/pdf.worker.entry.js$": "<rootDir>/__mocks__/pdfjs-dist.js"
90
+ "^pdfjs-dist/legacy/build/pdf.worker.entry.js$": "<rootDir>/__mocks__/pdfjs-dist.js",
91
+ "^date-fns/locale": "date-fns/locale.cjs"
91
92
  },
92
93
  "resolver": "ts-jest-resolver",
93
94
  "moduleFileExtensions": [
package/src/Form.tsx CHANGED
@@ -17,6 +17,37 @@ class Form extends PreviewUI {
17
17
  this.onChangeInputCallback = cb;
18
18
  }
19
19
 
20
+ public setInputs(inputs: { [key: string]: string }[]): void {
21
+ const previousInputs = this.getInputs();
22
+
23
+ super.setInputs(inputs);
24
+
25
+ const changedInputs: Array<{ index: number; name: string; value: string }> = [];
26
+
27
+ inputs.forEach((input, index) => {
28
+ const prevInput = previousInputs[index] || {};
29
+
30
+ const allKeys = new Set([...Object.keys(input), ...Object.keys(prevInput)]);
31
+
32
+ allKeys.forEach((name) => {
33
+ const newValue = input[name];
34
+ const oldValue = prevInput[name];
35
+
36
+ if (newValue !== oldValue) {
37
+ changedInputs.push({ index, name, value: newValue });
38
+ }
39
+ });
40
+ });
41
+
42
+ changedInputs.forEach((input) => {
43
+ if (this.onChangeInputCallback) {
44
+ this.onChangeInputCallback(input);
45
+ }
46
+ });
47
+ }
48
+
49
+
50
+
20
51
  protected render() {
21
52
  if (!this.domContainer) throw Error(DESTROYED_ERR_MSG);
22
53
  ReactDOM.render(
package/src/class.ts CHANGED
@@ -33,7 +33,7 @@ export abstract class BaseUIClass {
33
33
 
34
34
  private pluginsRegistry: Plugins = builtInPlugins;
35
35
 
36
- private options = {};
36
+ private options: UIOptions = {};
37
37
 
38
38
  private readonly setSize = debounce(() => {
39
39
  if (!this.domContainer) throw Error(DESTROYED_ERR_MSG);
@@ -84,7 +84,7 @@ export abstract class BaseUIClass {
84
84
  return this.pluginsRegistry;
85
85
  }
86
86
 
87
- protected getOptions() {
87
+ public getOptions() {
88
88
  return this.options;
89
89
  }
90
90
 
package/src/i18n.ts CHANGED
@@ -3,6 +3,7 @@ import { DEFAULT_LANG } from './constants.js';
3
3
 
4
4
  const dictEn: { [key in keyof Dict]: string } = {
5
5
  cancel: 'Cancel',
6
+ close: 'Close',
6
7
  field: 'field',
7
8
  fieldName: 'Name',
8
9
  align: 'Align',
@@ -56,7 +57,8 @@ const dictEn: { [key in keyof Dict]: string } = {
56
57
  'schemas.text.fit': 'Fit',
57
58
  'schemas.text.dynamicFontSize': 'Dynamic Font Size',
58
59
  'schemas.text.format': 'Format',
59
- 'schemas.mvt.typingInstructions': 'Add variables by typing words surrounded by curly brackets, e.g.',
60
+ 'schemas.mvt.typingInstructions':
61
+ 'Add variables by typing words surrounded by curly brackets, e.g.',
60
62
  'schemas.mvt.sampleField': 'name',
61
63
  'schemas.mvt.variablesSampleData': 'Variables Sample Data',
62
64
  'schemas.barcodes.barColor': 'Bar Color',
@@ -66,10 +68,14 @@ const dictEn: { [key in keyof Dict]: string } = {
66
68
  'schemas.table.headStyle': 'Header Style',
67
69
  'schemas.table.bodyStyle': 'Body Style',
68
70
  'schemas.table.columnStyle': 'Column Style',
71
+ 'schemas.date.format': 'Date Format',
72
+ 'schemas.select.options': 'Options',
73
+ 'schemas.select.optionPlaceholder': 'Enter an option',
69
74
  };
70
75
 
71
76
  const dictZh: { [key in keyof Dict]: string } = {
72
77
  cancel: '取消',
78
+ close: '关闭',
73
79
  field: '字段',
74
80
  fieldName: '名称',
75
81
  align: '对齐',
@@ -132,10 +138,14 @@ const dictZh: { [key in keyof Dict]: string } = {
132
138
  'schemas.table.headStyle': '表头样式',
133
139
  'schemas.table.bodyStyle': '表体样式',
134
140
  'schemas.table.columnStyle': '列样式',
141
+ 'schemas.date.format': '日期格式',
142
+ 'schemas.select.options': '选项',
143
+ 'schemas.select.optionPlaceholder': '请输入选项',
135
144
  };
136
145
 
137
146
  const dictJa: { [key in keyof Dict]: string } = {
138
147
  cancel: 'キャンセル',
148
+ close: '閉じる',
139
149
  field: '入力項目',
140
150
  fieldName: '項目名',
141
151
  align: '整列',
@@ -198,10 +208,14 @@ const dictJa: { [key in keyof Dict]: string } = {
198
208
  'schemas.table.headStyle': 'ヘッダースタイル',
199
209
  'schemas.table.bodyStyle': 'ボディスタイル',
200
210
  'schemas.table.columnStyle': 'カラムスタイル',
211
+ 'schemas.date.format': '日付形式',
212
+ 'schemas.select.options': 'オプション',
213
+ 'schemas.select.optionPlaceholder': 'オプションを入力してください',
201
214
  };
202
215
 
203
216
  const dictKo: { [key in keyof Dict]: string } = {
204
217
  cancel: '취소',
218
+ close: '닫기',
205
219
  field: '필드',
206
220
  fieldName: '이름',
207
221
  align: '정렬',
@@ -264,10 +278,14 @@ const dictKo: { [key in keyof Dict]: string } = {
264
278
  'schemas.table.headStyle': '헤더 스타일',
265
279
  'schemas.table.bodyStyle': '본문 스타일',
266
280
  'schemas.table.columnStyle': '열 스타일',
281
+ 'schemas.date.format': '날짜 형식',
282
+ 'schemas.select.options': '옵션',
283
+ 'schemas.select.optionPlaceholder': '옵션을 입력하세요',
267
284
  };
268
285
 
269
286
  const dictAr: { [key in keyof Dict]: string } = {
270
287
  cancel: 'إلغاء',
288
+ close: 'إغلاق',
271
289
  field: 'الحقل',
272
290
  fieldName: 'اسم الحقل',
273
291
  align: 'محاذاة',
@@ -276,7 +294,7 @@ const dictAr: { [key in keyof Dict]: string } = {
276
294
  opacity: 'الشفافية',
277
295
  rotate: 'تدوير',
278
296
  required: 'مطلوب',
279
- editable:'قابل للتحرير',
297
+ editable: 'قابل للتحرير',
280
298
  edit: 'تعديل',
281
299
  plsInputName: 'الرجاء إدخال الاسم',
282
300
  fieldMustUniq: 'يجب أن يكون الحقل فريداً',
@@ -320,7 +338,8 @@ const dictAr: { [key in keyof Dict]: string } = {
320
338
  'schemas.text.fit': 'ملاءمة',
321
339
  'schemas.text.dynamicFontSize': 'حجم الخط الديناميكي',
322
340
  'schemas.text.format': 'تنسيق',
323
- 'schemas.mvt.typingInstructions': 'قم بإضافة المتغيرات عن طريق كتابة الكلمات المحاطة بأقواس متعرجة، على سبيل المثال:',
341
+ 'schemas.mvt.typingInstructions':
342
+ 'قم بإضافة المتغيرات عن طريق كتابة الكلمات المحاطة بأقواس متعرجة، على سبيل المثال:',
324
343
  'schemas.mvt.sampleField': 'اسم',
325
344
  'schemas.mvt.variablesSampleData': 'بيانات عينة المتغيرات',
326
345
  'schemas.barcodes.barColor': 'لون الشريط',
@@ -330,10 +349,14 @@ const dictAr: { [key in keyof Dict]: string } = {
330
349
  'schemas.table.headStyle': 'أسلوب الرأس',
331
350
  'schemas.table.bodyStyle': 'أسلوب الجسم',
332
351
  'schemas.table.columnStyle': 'أسلوب العمود',
352
+ 'schemas.date.format': 'تنسيق التاريخ',
353
+ 'schemas.select.options': 'خيارات',
354
+ 'schemas.select.optionPlaceholder': 'أدخل خيارًا',
333
355
  };
334
356
 
335
357
  const dictTh: { [key in keyof Dict]: string } = {
336
358
  cancel: 'ยกเลิก',
359
+ close: 'ปิด',
337
360
  field: 'ฟิลด์',
338
361
  fieldName: 'ชื่อฟิลด์',
339
362
  align: 'จัดเรียง',
@@ -396,10 +419,14 @@ const dictTh: { [key in keyof Dict]: string } = {
396
419
  'schemas.table.headStyle': 'สไตล์หัวข้อ',
397
420
  'schemas.table.bodyStyle': 'สไตล์เนื้อหา',
398
421
  'schemas.table.columnStyle': 'สไตล์คอลัมน์',
422
+ 'schemas.date.format': 'รูปแบบวันที่',
423
+ 'schemas.select.options': 'ตัวเลือก',
424
+ 'schemas.select.optionPlaceholder': 'กรอกตัวเลือก',
399
425
  };
400
426
 
401
427
  const dictIt: { [key in keyof Dict]: string } = {
402
428
  cancel: 'Annulla',
429
+ close: 'Chiudi',
403
430
  field: 'Campo',
404
431
  fieldName: 'Nome',
405
432
  align: 'Allinea',
@@ -454,7 +481,8 @@ const dictIt: { [key in keyof Dict]: string } = {
454
481
  'schemas.text.fit': 'Adatta',
455
482
  'schemas.text.dynamicFontSize': 'Dimensione font dinamica',
456
483
  'schemas.text.format': 'Formato',
457
- 'schemas.mvt.typingInstructions': 'Aggiungi variabili digitando parole circondate da parentesi graffe, ad es.',
484
+ 'schemas.mvt.typingInstructions':
485
+ 'Aggiungi variabili digitando parole circondate da parentesi graffe, ad es.',
458
486
  'schemas.mvt.sampleField': 'nome',
459
487
  'schemas.mvt.variablesSampleData': 'Dati di esempio variabili',
460
488
  'schemas.barcodes.barColor': 'Colore barra',
@@ -464,10 +492,14 @@ const dictIt: { [key in keyof Dict]: string } = {
464
492
  'schemas.table.headStyle': "Stile dell'Intestazione",
465
493
  'schemas.table.bodyStyle': 'Stile del Corpo',
466
494
  'schemas.table.columnStyle': 'Stile della Colonna',
495
+ 'schemas.date.format': 'Formato data',
496
+ 'schemas.select.options': 'Opzioni',
497
+ 'schemas.select.optionPlaceholder': 'Inserisci un\'opzione',
467
498
  };
468
499
 
469
500
  const dictPl: { [key in keyof Dict]: string } = {
470
501
  cancel: 'Anuluj',
502
+ close: 'Zamknij',
471
503
  field: 'pole',
472
504
  fieldName: 'Klucz pola',
473
505
  align: 'Wyrównanie',
@@ -530,10 +562,14 @@ const dictPl: { [key in keyof Dict]: string } = {
530
562
  'schemas.table.headStyle': 'Styl nagłówka',
531
563
  'schemas.table.bodyStyle': 'Styl ciała',
532
564
  'schemas.table.columnStyle': 'Styl kolumny',
565
+ 'schemas.date.format': 'Format daty',
566
+ 'schemas.select.options': 'Opcje',
567
+ 'schemas.select.optionPlaceholder': 'Wpisz opcję',
533
568
  };
534
569
 
535
570
  const dictDe: { [key in keyof Dict]: string } = {
536
571
  cancel: 'Abbrechen',
572
+ close: 'Schließen',
537
573
  field: 'Feld',
538
574
  fieldName: 'Name',
539
575
  align: 'Ausrichten',
@@ -588,7 +624,8 @@ const dictDe: { [key in keyof Dict]: string } = {
588
624
  'schemas.text.fit': 'Anpassen',
589
625
  'schemas.text.dynamicFontSize': 'Dynamische Schriftgröße',
590
626
  'schemas.text.format': 'Format',
591
- 'schemas.mvt.typingInstructions': 'Fügen Sie Variablen hinzu, indem Sie Wörter in geschweiften Klammern eingeben, z. B.',
627
+ 'schemas.mvt.typingInstructions':
628
+ 'Fügen Sie Variablen hinzu, indem Sie Wörter in geschweiften Klammern eingeben, z. B.',
592
629
  'schemas.mvt.sampleField': 'Name',
593
630
  'schemas.mvt.variablesSampleData': 'Variablen Beispieldaten',
594
631
  'schemas.barcodes.barColor': 'Strichcodefarbe',
@@ -598,10 +635,14 @@ const dictDe: { [key in keyof Dict]: string } = {
598
635
  'schemas.table.headStyle': 'Kopfzeilenstil',
599
636
  'schemas.table.bodyStyle': 'Körperstil',
600
637
  'schemas.table.columnStyle': 'Spaltenstil',
638
+ 'schemas.date.format': 'Datumsformat',
639
+ 'schemas.select.options': 'Optionen',
640
+ 'schemas.select.optionPlaceholder': 'Geben Sie eine Option ein',
601
641
  };
602
642
 
603
643
  const dictEs: { [key in keyof Dict]: string } = {
604
644
  cancel: 'Cancelar',
645
+ close: 'Cerrar',
605
646
  field: 'campo',
606
647
  fieldName: 'Nombre',
607
648
  align: 'Alinear',
@@ -666,10 +707,14 @@ const dictEs: { [key in keyof Dict]: string } = {
666
707
  'schemas.table.headStyle': 'Estilo de cabecera',
667
708
  'schemas.table.bodyStyle': 'Estilo de cuerpo',
668
709
  'schemas.table.columnStyle': 'Estilo de columna',
710
+ 'schemas.date.format': 'Formato de fecha',
711
+ 'schemas.select.options': 'Opciones',
712
+ 'schemas.select.optionPlaceholder': 'Ingrese una opción',
669
713
  };
670
714
 
671
715
  const dictFr: { [key in keyof Dict]: string } = {
672
716
  cancel: 'Annuler',
717
+ close: 'Fermer',
673
718
  field: 'Champ',
674
719
  fieldName: 'Nom',
675
720
  align: 'Aligner',
@@ -681,19 +726,21 @@ const dictFr: { [key in keyof Dict]: string } = {
681
726
  editable: 'Modifiable',
682
727
  edit: 'Éditer',
683
728
  plsInputName: 'Veuillez saisir le nom',
684
- fieldMustUniq:"Le nom du champ n'est pas unique",
729
+ fieldMustUniq: "Le nom du champ n'est pas unique",
685
730
  notUniq: '(Nombre non unique)',
686
731
  noKeyName: 'Pas de nom',
687
732
  fieldsList: 'Liste des champs',
688
733
  editField: 'Éditer le champ',
689
734
  type: 'Type',
690
735
  errorOccurred: 'Une erreur est survenue',
691
- errorBulkUpdateFieldName: "Impossible de confirmer le changement car le nombre d'éléments a changé.",
736
+ errorBulkUpdateFieldName:
737
+ "Impossible de confirmer le changement car le nombre d'éléments a changé.",
692
738
  commitBulkUpdateFieldName: 'Confirmer les changements',
693
739
  bulkUpdateFieldName: 'Modifier les noms de champs en masse',
694
740
  addPageAfter: 'Ajouter une page après',
695
741
  removePage: 'Supprimer la page actuelle',
696
- removePageConfirm: 'Êtes-vous sûr de vouloir supprimer cette page ? Cette action est irréversible.',
742
+ removePageConfirm:
743
+ 'Êtes-vous sûr de vouloir supprimer cette page ? Cette action est irréversible.',
697
744
  'validation.hexColor': 'Veuillez entrer un code couleur hexadécimal valide.',
698
745
  'validation.uniqueName': 'Veuillez saisir un nom unique.',
699
746
  'schemas.color': 'Couleur',
@@ -722,7 +769,8 @@ const dictFr: { [key in keyof Dict]: string } = {
722
769
  'schemas.text.fit': 'Ajustement',
723
770
  'schemas.text.dynamicFontSize': 'Taille de police dynamique',
724
771
  'schemas.text.format': 'Format',
725
- 'schemas.mvt.typingInstructions': 'Ajoutez des variables en tapant des mots entourés d\'accolades, par ex.',
772
+ 'schemas.mvt.typingInstructions':
773
+ "Ajoutez des variables en tapant des mots entourés d'accolades, par ex.",
726
774
  'schemas.mvt.sampleField': 'nom',
727
775
  'schemas.mvt.variablesSampleData': 'Variables Exemples de données',
728
776
  'schemas.barcodes.barColor': 'Couleur de la barre',
@@ -731,7 +779,10 @@ const dictFr: { [key in keyof Dict]: string } = {
731
779
  'schemas.table.tableStyle': 'Style de tableau',
732
780
  'schemas.table.headStyle': "Style d'en-tête",
733
781
  'schemas.table.bodyStyle': 'Style de corps',
734
- 'schemas.table.columnStyle': 'Style de colonne'
782
+ 'schemas.table.columnStyle': 'Style de colonne',
783
+ 'schemas.date.format': 'Format de date',
784
+ 'schemas.select.options': 'Options',
785
+ 'schemas.select.optionPlaceholder': 'Entrez une option',
735
786
  };
736
787
 
737
788
  const dictionaries: { [key in Lang]: Dict } = {