@pdfme/ui 4.0.2 → 4.1.0-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/index.es.js +161 -73
- package/dist/index.umd.js +4 -4
- package/dist/types/class.d.ts +1 -1
- package/dist/types/components/Designer/RightSidebar/DetailView/ButtonGroupWidget.d.ts +4 -0
- package/dist/types/contexts.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/Designer/RightSidebar/DetailView/ButtonGroupWidget.tsx +70 -0
- package/src/components/Designer/RightSidebar/DetailView/index.tsx +3 -1
- package/src/i18n.ts +12 -1
package/dist/types/class.d.ts
CHANGED
@@ -77,7 +77,7 @@ export declare abstract class BaseUIClass {
|
|
77
77
|
opacity: import("zod").ZodOptional<import("zod").ZodNumber>;
|
78
78
|
readOnly: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
79
79
|
}, import("zod").ZodTypeAny, "passthrough">>>, "many">;
|
80
|
-
basePdf: import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodType<ArrayBuffer, import("zod").ZodTypeDef, ArrayBuffer>, import("zod").ZodType<Uint8Array, import("zod").ZodTypeDef, Uint8Array>, import("zod").ZodObject<{
|
80
|
+
basePdf: import("zod").ZodUnion<[import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodType<ArrayBuffer, import("zod").ZodTypeDef, ArrayBuffer>, import("zod").ZodType<Uint8Array, import("zod").ZodTypeDef, Uint8Array>]>, import("zod").ZodObject<{
|
81
81
|
width: import("zod").ZodNumber;
|
82
82
|
height: import("zod").ZodNumber;
|
83
83
|
padding: import("zod").ZodTuple<[import("zod").ZodNumber, import("zod").ZodNumber, import("zod").ZodNumber, import("zod").ZodNumber], null>;
|
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" | "cancel" | "field" | "fieldName" | "align" | "edit" | "plsInputName" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "editField" | "errorOccurred" | "errorBulkUpdateFieldName" | "commitBulkUpdateFieldName" | "bulkUpdateFieldName" | "addPageAfter" | "removePage" | "removePageConfirm" | "hexColorPrompt" | "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.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" | "cancel" | "field" | "fieldName" | "align" | "edit" | "plsInputName" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "editField" | "errorOccurred" | "errorBulkUpdateFieldName" | "commitBulkUpdateFieldName" | "bulkUpdateFieldName" | "addPageAfter" | "removePage" | "removePageConfirm" | "hexColorPrompt" | "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.barcodes.barColor" | "schemas.barcodes.includetext" | "schemas.table.alternateBackgroundColor" | "schemas.table.tableStyle" | "schemas.table.headStyle" | "schemas.table.bodyStyle" | "schemas.table.columnStyle", dict?: {
|
4
4
|
cancel: string;
|
5
5
|
field: string;
|
6
6
|
fieldName: string;
|
@@ -50,6 +50,7 @@ export declare const I18nContext: import("react").Context<(key: "type" | "width"
|
|
50
50
|
'schemas.text.max': string;
|
51
51
|
'schemas.text.fit': string;
|
52
52
|
'schemas.text.dynamicFontSize': string;
|
53
|
+
'schemas.text.format': string;
|
53
54
|
'schemas.barcodes.barColor': string;
|
54
55
|
'schemas.barcodes.includetext': string;
|
55
56
|
'schemas.table.alternateBackgroundColor': string;
|
package/package.json
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
import { Button, Form } from 'antd';
|
2
|
+
import React from 'react';
|
3
|
+
import type { PropPanelWidgetProps, SchemaForUI } from '@pdfme/common';
|
4
|
+
|
5
|
+
interface ButtonConfig {
|
6
|
+
key: string;
|
7
|
+
icon: string;
|
8
|
+
type: 'boolean' | 'select';
|
9
|
+
value?: String;
|
10
|
+
}
|
11
|
+
|
12
|
+
const ButtonGroupWidget = (props: PropPanelWidgetProps) => {
|
13
|
+
const { activeElements, changeSchemas, schemas, schema } = props;
|
14
|
+
|
15
|
+
const apply = (btn: ButtonConfig) => {
|
16
|
+
const key = btn.key;
|
17
|
+
const type = btn.type;
|
18
|
+
const ids = activeElements.map((ae) => ae.id);
|
19
|
+
const ass = schemas.filter((s) => ids.includes(s.id)) as SchemaForUI[];
|
20
|
+
changeSchemas(
|
21
|
+
ass.map((s: Record<string, any>) => {
|
22
|
+
const oldValue = s[key] ?? false;
|
23
|
+
const newValue = type === 'boolean' ? !oldValue : btn.value;
|
24
|
+
return { key, value: newValue, schemaId: s.id };
|
25
|
+
})
|
26
|
+
);
|
27
|
+
};
|
28
|
+
|
29
|
+
const isActive = (btn: ButtonConfig) => {
|
30
|
+
const key = btn.key;
|
31
|
+
const type = btn.type;
|
32
|
+
let active = false;
|
33
|
+
const ids = activeElements.map((ae) => ae.id);
|
34
|
+
const ass = schemas.filter((s) => ids.includes(s.id)) as SchemaForUI[];
|
35
|
+
ass.forEach((s: Record<string, any>) => {
|
36
|
+
active = type === 'boolean' ? s[key] ?? false : s[key] === btn.value;
|
37
|
+
});
|
38
|
+
return active;
|
39
|
+
};
|
40
|
+
|
41
|
+
const svgIcon = (svgString: string) => {
|
42
|
+
const svgDataUrl = `data:image/svg+xml;utf8,${encodeURIComponent(svgString)}`;
|
43
|
+
return <img width={17} height={17} src={svgDataUrl} />;
|
44
|
+
};
|
45
|
+
|
46
|
+
return (
|
47
|
+
<Form.Item>
|
48
|
+
<Button.Group>
|
49
|
+
{schema.buttons.map((btn: ButtonConfig, index: number) => {
|
50
|
+
const active = isActive(btn);
|
51
|
+
return (
|
52
|
+
<Button
|
53
|
+
type={active ? 'primary' : undefined}
|
54
|
+
ghost={active}
|
55
|
+
onClick={() => apply(btn)}
|
56
|
+
style={{
|
57
|
+
padding: 7,
|
58
|
+
zIndex: active ? 2 : 0,
|
59
|
+
}}
|
60
|
+
key={index}
|
61
|
+
icon={svgIcon(btn.icon)}
|
62
|
+
/>
|
63
|
+
);
|
64
|
+
})}
|
65
|
+
</Button.Group>
|
66
|
+
</Form.Item>
|
67
|
+
);
|
68
|
+
};
|
69
|
+
|
70
|
+
export default ButtonGroupWidget;
|
@@ -8,6 +8,7 @@ import { getSidebarContentHeight } from '../../../../helper';
|
|
8
8
|
import { theme, Typography, Button, Divider } from 'antd';
|
9
9
|
import AlignWidget from './AlignWidget';
|
10
10
|
import WidgetRenderer from './WidgetRenderer';
|
11
|
+
import ButtonGroupWidget from './ButtonGroupWidget';
|
11
12
|
|
12
13
|
const { Text } = Typography;
|
13
14
|
|
@@ -38,6 +39,7 @@ const DetailView = (
|
|
38
39
|
Divider: () => (
|
39
40
|
<Divider style={{ marginTop: token.marginXS, marginBottom: token.marginXS }} />
|
40
41
|
),
|
42
|
+
ButtonGroup: (p) => <ButtonGroupWidget {...p} {...props} options={options} />,
|
41
43
|
};
|
42
44
|
for (const plugin of Object.values(pluginsRegistry)) {
|
43
45
|
const widgets = plugin?.propPanel.widgets || {};
|
@@ -206,7 +208,7 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
206
208
|
style={{
|
207
209
|
height: getSidebarContentHeight(size.height),
|
208
210
|
overflowY: 'auto',
|
209
|
-
overflowX: 'hidden'
|
211
|
+
overflowX: 'hidden',
|
210
212
|
}}
|
211
213
|
>
|
212
214
|
<FormRender
|
package/src/i18n.ts
CHANGED
@@ -52,6 +52,7 @@ const dictEn: { [key in keyof Dict]: string } = {
|
|
52
52
|
'schemas.text.max': 'Max',
|
53
53
|
'schemas.text.fit': 'Fit',
|
54
54
|
'schemas.text.dynamicFontSize': 'Dynamic Font Size',
|
55
|
+
'schemas.text.format': 'Format',
|
55
56
|
'schemas.barcodes.barColor': 'Bar Color',
|
56
57
|
'schemas.barcodes.includetext': 'Include Text',
|
57
58
|
'schemas.table.alternateBackgroundColor': 'Alternate Background Color',
|
@@ -111,6 +112,7 @@ const dictZh: { [key in keyof Dict]: string } = {
|
|
111
112
|
'schemas.text.max': '最大',
|
112
113
|
'schemas.text.fit': '适应',
|
113
114
|
'schemas.text.dynamicFontSize': '动态字体大小',
|
115
|
+
'schemas.text.format': '格式',
|
114
116
|
'schemas.barcodes.barColor': '条码颜色',
|
115
117
|
'schemas.barcodes.includetext': '包括文本',
|
116
118
|
'schemas.table.alternateBackgroundColor': '交替背景颜色',
|
@@ -170,6 +172,7 @@ const dictJa: { [key in keyof Dict]: string } = {
|
|
170
172
|
'schemas.text.max': '最大',
|
171
173
|
'schemas.text.fit': 'フィット',
|
172
174
|
'schemas.text.dynamicFontSize': '動的フォントサイズ',
|
175
|
+
'schemas.text.format': '書式',
|
173
176
|
'schemas.barcodes.barColor': 'バーの色',
|
174
177
|
'schemas.barcodes.includetext': 'テキストを含める',
|
175
178
|
'schemas.table.alternateBackgroundColor': '交互の背景色',
|
@@ -229,6 +232,7 @@ const dictKo: { [key in keyof Dict]: string } = {
|
|
229
232
|
'schemas.text.max': '최대',
|
230
233
|
'schemas.text.fit': '맞춤',
|
231
234
|
'schemas.text.dynamicFontSize': '동적 폰트 크기',
|
235
|
+
'schemas.text.format': '형식',
|
232
236
|
'schemas.barcodes.barColor': '바코드 색상',
|
233
237
|
'schemas.barcodes.includetext': '텍스트 포함',
|
234
238
|
'schemas.table.alternateBackgroundColor': '대체 배경색',
|
@@ -288,6 +292,7 @@ const dictAr: { [key in keyof Dict]: string } = {
|
|
288
292
|
'schemas.text.max': 'الحد الأقصى',
|
289
293
|
'schemas.text.fit': 'ملاءمة',
|
290
294
|
'schemas.text.dynamicFontSize': 'حجم الخط الديناميكي',
|
295
|
+
'schemas.text.format': 'تنسيق',
|
291
296
|
'schemas.barcodes.barColor': 'لون الشريط',
|
292
297
|
'schemas.barcodes.includetext': 'تضمين النص',
|
293
298
|
'schemas.table.alternateBackgroundColor': 'لون الخلفية البديل',
|
@@ -347,6 +352,7 @@ const dictTh: { [key in keyof Dict]: string } = {
|
|
347
352
|
'schemas.text.max': 'สูงสุด',
|
348
353
|
'schemas.text.fit': 'พอดี',
|
349
354
|
'schemas.text.dynamicFontSize': 'ขนาดตัวอักษรแบบไดนามิก',
|
355
|
+
'schemas.text.format': 'รูปแบบ',
|
350
356
|
'schemas.barcodes.barColor': 'สีบาร์',
|
351
357
|
'schemas.barcodes.includetext': 'รวมข้อความ',
|
352
358
|
'schemas.table.alternateBackgroundColor': 'สีพื้นหลังสลับกัน',
|
@@ -408,6 +414,7 @@ const dictIt: { [key in keyof Dict]: string } = {
|
|
408
414
|
'schemas.text.max': 'Massimo',
|
409
415
|
'schemas.text.fit': 'Adatta',
|
410
416
|
'schemas.text.dynamicFontSize': 'Dimensione font dinamica',
|
417
|
+
'schemas.text.format': 'Formato',
|
411
418
|
'schemas.barcodes.barColor': 'Colore barra',
|
412
419
|
'schemas.barcodes.includetext': 'Includi testo',
|
413
420
|
'schemas.table.alternateBackgroundColor': 'Colore di Sfondo Alternato',
|
@@ -467,6 +474,7 @@ const dictPl: { [key in keyof Dict]: string } = {
|
|
467
474
|
'schemas.text.max': 'Maksimum',
|
468
475
|
'schemas.text.fit': 'Dopasowanie',
|
469
476
|
'schemas.text.dynamicFontSize': 'Dynamiczny rozmiar czcionki',
|
477
|
+
'schemas.text.format': 'Format',
|
470
478
|
'schemas.barcodes.barColor': 'Kolor paska',
|
471
479
|
'schemas.barcodes.includetext': 'Dołącz tekst',
|
472
480
|
'schemas.table.alternateBackgroundColor': 'Alternatywny kolor tła',
|
@@ -528,6 +536,7 @@ const dictDe: { [key in keyof Dict]: string } = {
|
|
528
536
|
'schemas.text.max': 'Max',
|
529
537
|
'schemas.text.fit': 'Anpassen',
|
530
538
|
'schemas.text.dynamicFontSize': 'Dynamische Schriftgröße',
|
539
|
+
'schemas.text.format': 'Format',
|
531
540
|
'schemas.barcodes.barColor': 'Strichcodefarbe',
|
532
541
|
'schemas.barcodes.includetext': 'Text anzeigen',
|
533
542
|
'schemas.table.alternateBackgroundColor': 'Wechselnde Hintergrundfarbe',
|
@@ -589,6 +598,7 @@ const dictEs: { [key in keyof Dict]: string } = {
|
|
589
598
|
'schemas.text.max': 'Máx',
|
590
599
|
'schemas.text.fit': 'Ajustar',
|
591
600
|
'schemas.text.dynamicFontSize': 'Tamaño de fuente dinámico',
|
601
|
+
'schemas.text.format': 'Formato',
|
592
602
|
'schemas.barcodes.barColor': 'Color de la barra',
|
593
603
|
'schemas.barcodes.includetext': 'Incluir texto',
|
594
604
|
'schemas.table.alternateBackgroundColor': 'Color de fondo alternativo',
|
@@ -615,7 +625,7 @@ const dictFr: { [key in keyof Dict]: string } = {
|
|
615
625
|
fieldsList: 'Liste des champs',
|
616
626
|
editField: 'Éditer le champ',
|
617
627
|
type: 'Type',
|
618
|
-
errorOccurred:'
|
628
|
+
errorOccurred:'Une erreur est survenue',
|
619
629
|
errorBulkUpdateFieldName: "Impossible de confirmer le changement car le nombre d'éléments a changé.",
|
620
630
|
commitBulkUpdateFieldName: 'Confirmer les changements',
|
621
631
|
bulkUpdateFieldName: 'Modifier les noms de champs en masse',
|
@@ -648,6 +658,7 @@ const dictFr: { [key in keyof Dict]: string } = {
|
|
648
658
|
'schemas.text.max': 'Max',
|
649
659
|
'schemas.text.fit': 'Ajustement',
|
650
660
|
'schemas.text.dynamicFontSize': 'Taille de police dynamique',
|
661
|
+
'schemas.text.format': 'Format',
|
651
662
|
'schemas.barcodes.barColor': 'Couleur de la barre',
|
652
663
|
'schemas.barcodes.includetext': 'Inclure le texte',
|
653
664
|
'schemas.table.alternateBackgroundColor': 'Couleur de fond alternative',
|