@pdfme/ui 5.0.0 → 5.1.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.
- package/dist/index.es.js +143 -163
- package/dist/index.umd.js +8 -8
- package/dist/types/Form.d.ts +3 -0
- package/dist/types/class.d.ts +1 -1
- package/dist/types/contexts.d.ts +4 -1
- package/package.json +3 -2
- package/src/Form.tsx +31 -0
- package/src/class.ts +2 -2
- package/src/i18n.ts +50 -10
package/dist/types/Form.d.ts
CHANGED
package/dist/types/class.d.ts
CHANGED
@@ -17,7 +17,7 @@ export declare abstract class BaseUIClass {
|
|
17
17
|
subset?: boolean | undefined;
|
18
18
|
}>;
|
19
19
|
protected getPluginsRegistry(): Plugins;
|
20
|
-
|
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;
|
package/dist/types/contexts.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
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" | "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
5
|
field: string;
|
6
6
|
fieldName: string;
|
@@ -64,6 +64,9 @@ export declare const I18nContext: import("react").Context<(key: "type" | "width"
|
|
64
64
|
'schemas.table.headStyle': string;
|
65
65
|
'schemas.table.bodyStyle': string;
|
66
66
|
'schemas.table.columnStyle': string;
|
67
|
+
'schemas.date.format': string;
|
68
|
+
'schemas.select.options': string;
|
69
|
+
'schemas.select.optionPlaceholder': string;
|
67
70
|
} | undefined) => string>;
|
68
71
|
export declare const FontContext: import("react").Context<Record<string, {
|
69
72
|
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.
|
3
|
+
"version": "5.1.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
|
-
|
87
|
+
public getOptions() {
|
88
88
|
return this.options;
|
89
89
|
}
|
90
90
|
|
package/src/i18n.ts
CHANGED
@@ -56,7 +56,8 @@ const dictEn: { [key in keyof Dict]: string } = {
|
|
56
56
|
'schemas.text.fit': 'Fit',
|
57
57
|
'schemas.text.dynamicFontSize': 'Dynamic Font Size',
|
58
58
|
'schemas.text.format': 'Format',
|
59
|
-
'schemas.mvt.typingInstructions':
|
59
|
+
'schemas.mvt.typingInstructions':
|
60
|
+
'Add variables by typing words surrounded by curly brackets, e.g.',
|
60
61
|
'schemas.mvt.sampleField': 'name',
|
61
62
|
'schemas.mvt.variablesSampleData': 'Variables Sample Data',
|
62
63
|
'schemas.barcodes.barColor': 'Bar Color',
|
@@ -66,6 +67,9 @@ const dictEn: { [key in keyof Dict]: string } = {
|
|
66
67
|
'schemas.table.headStyle': 'Header Style',
|
67
68
|
'schemas.table.bodyStyle': 'Body Style',
|
68
69
|
'schemas.table.columnStyle': 'Column Style',
|
70
|
+
'schemas.date.format': 'Date Format',
|
71
|
+
'schemas.select.options': 'Options',
|
72
|
+
'schemas.select.optionPlaceholder': 'Enter an option',
|
69
73
|
};
|
70
74
|
|
71
75
|
const dictZh: { [key in keyof Dict]: string } = {
|
@@ -132,6 +136,9 @@ const dictZh: { [key in keyof Dict]: string } = {
|
|
132
136
|
'schemas.table.headStyle': '表头样式',
|
133
137
|
'schemas.table.bodyStyle': '表体样式',
|
134
138
|
'schemas.table.columnStyle': '列样式',
|
139
|
+
'schemas.date.format': '日期格式',
|
140
|
+
'schemas.select.options': '选项',
|
141
|
+
'schemas.select.optionPlaceholder': '请输入选项',
|
135
142
|
};
|
136
143
|
|
137
144
|
const dictJa: { [key in keyof Dict]: string } = {
|
@@ -198,6 +205,9 @@ const dictJa: { [key in keyof Dict]: string } = {
|
|
198
205
|
'schemas.table.headStyle': 'ヘッダースタイル',
|
199
206
|
'schemas.table.bodyStyle': 'ボディスタイル',
|
200
207
|
'schemas.table.columnStyle': 'カラムスタイル',
|
208
|
+
'schemas.date.format': '日付形式',
|
209
|
+
'schemas.select.options': 'オプション',
|
210
|
+
'schemas.select.optionPlaceholder': 'オプションを入力してください',
|
201
211
|
};
|
202
212
|
|
203
213
|
const dictKo: { [key in keyof Dict]: string } = {
|
@@ -264,6 +274,9 @@ const dictKo: { [key in keyof Dict]: string } = {
|
|
264
274
|
'schemas.table.headStyle': '헤더 스타일',
|
265
275
|
'schemas.table.bodyStyle': '본문 스타일',
|
266
276
|
'schemas.table.columnStyle': '열 스타일',
|
277
|
+
'schemas.date.format': '날짜 형식',
|
278
|
+
'schemas.select.options': '옵션',
|
279
|
+
'schemas.select.optionPlaceholder': '옵션을 입력하세요',
|
267
280
|
};
|
268
281
|
|
269
282
|
const dictAr: { [key in keyof Dict]: string } = {
|
@@ -276,7 +289,7 @@ const dictAr: { [key in keyof Dict]: string } = {
|
|
276
289
|
opacity: 'الشفافية',
|
277
290
|
rotate: 'تدوير',
|
278
291
|
required: 'مطلوب',
|
279
|
-
editable:'قابل للتحرير',
|
292
|
+
editable: 'قابل للتحرير',
|
280
293
|
edit: 'تعديل',
|
281
294
|
plsInputName: 'الرجاء إدخال الاسم',
|
282
295
|
fieldMustUniq: 'يجب أن يكون الحقل فريداً',
|
@@ -320,7 +333,8 @@ const dictAr: { [key in keyof Dict]: string } = {
|
|
320
333
|
'schemas.text.fit': 'ملاءمة',
|
321
334
|
'schemas.text.dynamicFontSize': 'حجم الخط الديناميكي',
|
322
335
|
'schemas.text.format': 'تنسيق',
|
323
|
-
'schemas.mvt.typingInstructions':
|
336
|
+
'schemas.mvt.typingInstructions':
|
337
|
+
'قم بإضافة المتغيرات عن طريق كتابة الكلمات المحاطة بأقواس متعرجة، على سبيل المثال:',
|
324
338
|
'schemas.mvt.sampleField': 'اسم',
|
325
339
|
'schemas.mvt.variablesSampleData': 'بيانات عينة المتغيرات',
|
326
340
|
'schemas.barcodes.barColor': 'لون الشريط',
|
@@ -330,6 +344,9 @@ const dictAr: { [key in keyof Dict]: string } = {
|
|
330
344
|
'schemas.table.headStyle': 'أسلوب الرأس',
|
331
345
|
'schemas.table.bodyStyle': 'أسلوب الجسم',
|
332
346
|
'schemas.table.columnStyle': 'أسلوب العمود',
|
347
|
+
'schemas.date.format': 'تنسيق التاريخ',
|
348
|
+
'schemas.select.options': 'خيارات',
|
349
|
+
'schemas.select.optionPlaceholder': 'أدخل خيارًا',
|
333
350
|
};
|
334
351
|
|
335
352
|
const dictTh: { [key in keyof Dict]: string } = {
|
@@ -396,6 +413,9 @@ const dictTh: { [key in keyof Dict]: string } = {
|
|
396
413
|
'schemas.table.headStyle': 'สไตล์หัวข้อ',
|
397
414
|
'schemas.table.bodyStyle': 'สไตล์เนื้อหา',
|
398
415
|
'schemas.table.columnStyle': 'สไตล์คอลัมน์',
|
416
|
+
'schemas.date.format': 'รูปแบบวันที่',
|
417
|
+
'schemas.select.options': 'ตัวเลือก',
|
418
|
+
'schemas.select.optionPlaceholder': 'กรอกตัวเลือก',
|
399
419
|
};
|
400
420
|
|
401
421
|
const dictIt: { [key in keyof Dict]: string } = {
|
@@ -454,7 +474,8 @@ const dictIt: { [key in keyof Dict]: string } = {
|
|
454
474
|
'schemas.text.fit': 'Adatta',
|
455
475
|
'schemas.text.dynamicFontSize': 'Dimensione font dinamica',
|
456
476
|
'schemas.text.format': 'Formato',
|
457
|
-
'schemas.mvt.typingInstructions':
|
477
|
+
'schemas.mvt.typingInstructions':
|
478
|
+
'Aggiungi variabili digitando parole circondate da parentesi graffe, ad es.',
|
458
479
|
'schemas.mvt.sampleField': 'nome',
|
459
480
|
'schemas.mvt.variablesSampleData': 'Dati di esempio variabili',
|
460
481
|
'schemas.barcodes.barColor': 'Colore barra',
|
@@ -464,6 +485,9 @@ const dictIt: { [key in keyof Dict]: string } = {
|
|
464
485
|
'schemas.table.headStyle': "Stile dell'Intestazione",
|
465
486
|
'schemas.table.bodyStyle': 'Stile del Corpo',
|
466
487
|
'schemas.table.columnStyle': 'Stile della Colonna',
|
488
|
+
'schemas.date.format': 'Formato data',
|
489
|
+
'schemas.select.options': 'Opzioni',
|
490
|
+
'schemas.select.optionPlaceholder': 'Inserisci un\'opzione',
|
467
491
|
};
|
468
492
|
|
469
493
|
const dictPl: { [key in keyof Dict]: string } = {
|
@@ -530,6 +554,9 @@ const dictPl: { [key in keyof Dict]: string } = {
|
|
530
554
|
'schemas.table.headStyle': 'Styl nagłówka',
|
531
555
|
'schemas.table.bodyStyle': 'Styl ciała',
|
532
556
|
'schemas.table.columnStyle': 'Styl kolumny',
|
557
|
+
'schemas.date.format': 'Format daty',
|
558
|
+
'schemas.select.options': 'Opcje',
|
559
|
+
'schemas.select.optionPlaceholder': 'Wpisz opcję',
|
533
560
|
};
|
534
561
|
|
535
562
|
const dictDe: { [key in keyof Dict]: string } = {
|
@@ -588,7 +615,8 @@ const dictDe: { [key in keyof Dict]: string } = {
|
|
588
615
|
'schemas.text.fit': 'Anpassen',
|
589
616
|
'schemas.text.dynamicFontSize': 'Dynamische Schriftgröße',
|
590
617
|
'schemas.text.format': 'Format',
|
591
|
-
'schemas.mvt.typingInstructions':
|
618
|
+
'schemas.mvt.typingInstructions':
|
619
|
+
'Fügen Sie Variablen hinzu, indem Sie Wörter in geschweiften Klammern eingeben, z. B.',
|
592
620
|
'schemas.mvt.sampleField': 'Name',
|
593
621
|
'schemas.mvt.variablesSampleData': 'Variablen Beispieldaten',
|
594
622
|
'schemas.barcodes.barColor': 'Strichcodefarbe',
|
@@ -598,6 +626,9 @@ const dictDe: { [key in keyof Dict]: string } = {
|
|
598
626
|
'schemas.table.headStyle': 'Kopfzeilenstil',
|
599
627
|
'schemas.table.bodyStyle': 'Körperstil',
|
600
628
|
'schemas.table.columnStyle': 'Spaltenstil',
|
629
|
+
'schemas.date.format': 'Datumsformat',
|
630
|
+
'schemas.select.options': 'Optionen',
|
631
|
+
'schemas.select.optionPlaceholder': 'Geben Sie eine Option ein',
|
601
632
|
};
|
602
633
|
|
603
634
|
const dictEs: { [key in keyof Dict]: string } = {
|
@@ -666,6 +697,9 @@ const dictEs: { [key in keyof Dict]: string } = {
|
|
666
697
|
'schemas.table.headStyle': 'Estilo de cabecera',
|
667
698
|
'schemas.table.bodyStyle': 'Estilo de cuerpo',
|
668
699
|
'schemas.table.columnStyle': 'Estilo de columna',
|
700
|
+
'schemas.date.format': 'Formato de fecha',
|
701
|
+
'schemas.select.options': 'Opciones',
|
702
|
+
'schemas.select.optionPlaceholder': 'Ingrese una opción',
|
669
703
|
};
|
670
704
|
|
671
705
|
const dictFr: { [key in keyof Dict]: string } = {
|
@@ -681,19 +715,21 @@ const dictFr: { [key in keyof Dict]: string } = {
|
|
681
715
|
editable: 'Modifiable',
|
682
716
|
edit: 'Éditer',
|
683
717
|
plsInputName: 'Veuillez saisir le nom',
|
684
|
-
fieldMustUniq:"Le nom du champ n'est pas unique",
|
718
|
+
fieldMustUniq: "Le nom du champ n'est pas unique",
|
685
719
|
notUniq: '(Nombre non unique)',
|
686
720
|
noKeyName: 'Pas de nom',
|
687
721
|
fieldsList: 'Liste des champs',
|
688
722
|
editField: 'Éditer le champ',
|
689
723
|
type: 'Type',
|
690
724
|
errorOccurred: 'Une erreur est survenue',
|
691
|
-
errorBulkUpdateFieldName:
|
725
|
+
errorBulkUpdateFieldName:
|
726
|
+
"Impossible de confirmer le changement car le nombre d'éléments a changé.",
|
692
727
|
commitBulkUpdateFieldName: 'Confirmer les changements',
|
693
728
|
bulkUpdateFieldName: 'Modifier les noms de champs en masse',
|
694
729
|
addPageAfter: 'Ajouter une page après',
|
695
730
|
removePage: 'Supprimer la page actuelle',
|
696
|
-
removePageConfirm:
|
731
|
+
removePageConfirm:
|
732
|
+
'Êtes-vous sûr de vouloir supprimer cette page ? Cette action est irréversible.',
|
697
733
|
'validation.hexColor': 'Veuillez entrer un code couleur hexadécimal valide.',
|
698
734
|
'validation.uniqueName': 'Veuillez saisir un nom unique.',
|
699
735
|
'schemas.color': 'Couleur',
|
@@ -722,7 +758,8 @@ const dictFr: { [key in keyof Dict]: string } = {
|
|
722
758
|
'schemas.text.fit': 'Ajustement',
|
723
759
|
'schemas.text.dynamicFontSize': 'Taille de police dynamique',
|
724
760
|
'schemas.text.format': 'Format',
|
725
|
-
'schemas.mvt.typingInstructions':
|
761
|
+
'schemas.mvt.typingInstructions':
|
762
|
+
"Ajoutez des variables en tapant des mots entourés d'accolades, par ex.",
|
726
763
|
'schemas.mvt.sampleField': 'nom',
|
727
764
|
'schemas.mvt.variablesSampleData': 'Variables Exemples de données',
|
728
765
|
'schemas.barcodes.barColor': 'Couleur de la barre',
|
@@ -731,7 +768,10 @@ const dictFr: { [key in keyof Dict]: string } = {
|
|
731
768
|
'schemas.table.tableStyle': 'Style de tableau',
|
732
769
|
'schemas.table.headStyle': "Style d'en-tête",
|
733
770
|
'schemas.table.bodyStyle': 'Style de corps',
|
734
|
-
'schemas.table.columnStyle': 'Style de colonne'
|
771
|
+
'schemas.table.columnStyle': 'Style de colonne',
|
772
|
+
'schemas.date.format': 'Format de date',
|
773
|
+
'schemas.select.options': 'Options',
|
774
|
+
'schemas.select.optionPlaceholder': 'Entrez une option',
|
735
775
|
};
|
736
776
|
|
737
777
|
const dictionaries: { [key in Lang]: Dict } = {
|