@pdfme/ui 4.2.5-dev.4 → 4.2.5-dev.5
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 +264 -151
- package/dist/index.umd.js +8 -8
- package/dist/types/components/Designer/RightSidebar/ListView/Item.d.ts +1 -0
- package/dist/types/contexts.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/Designer/PluginIcon.tsx +2 -2
- package/src/components/Designer/RightSidebar/DetailView/index.tsx +37 -34
- package/src/components/Designer/RightSidebar/ListView/Item.tsx +4 -1
- package/src/components/Designer/RightSidebar/ListView/SelectableSortableContainer.tsx +33 -26
- package/src/components/Designer/RightSidebar/ListView/SelectableSortableItem.tsx +1 -0
- package/src/i18n.ts +11 -0
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" | "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", dict?: {
|
4
4
|
cancel: string;
|
5
5
|
field: string;
|
6
6
|
fieldName: string;
|
@@ -11,6 +11,7 @@ export declare const I18nContext: import("react").Context<(key: "type" | "width"
|
|
11
11
|
rotate: string;
|
12
12
|
edit: string;
|
13
13
|
required: string;
|
14
|
+
editable: string;
|
14
15
|
plsInputName: string;
|
15
16
|
fieldMustUniq: string;
|
16
17
|
notUniq: string;
|
package/package.json
CHANGED
@@ -38,10 +38,10 @@ const PluginIcon = (props: PluginIconProps) => {
|
|
38
38
|
if (size) {
|
39
39
|
return getWithModifiedSize(icon, label, size, iconStyles);
|
40
40
|
}
|
41
|
-
return <div style={iconStyles} title={label}
|
41
|
+
return <div style={iconStyles} title={label} dangerouslySetInnerHTML={{ __html: icon }} />
|
42
42
|
}
|
43
43
|
|
44
|
-
return <div style={{...styles, overflow: 'hidden', fontSize: 10, }}>{label}</div>
|
44
|
+
return <div style={{ ...styles, overflow: 'hidden', fontSize: 10, }} title={label} >{label}</div>
|
45
45
|
};
|
46
46
|
|
47
47
|
export default PluginIcon;
|
@@ -61,13 +61,8 @@ const DetailView = (props: DetailViewProps) => {
|
|
61
61
|
|
62
62
|
useEffect(() => {
|
63
63
|
const values: any = { ...activeSchema };
|
64
|
-
|
65
|
-
values.x = values.position.x;
|
66
|
-
values.y = values.position.y;
|
67
|
-
delete values.position;
|
68
|
-
|
64
|
+
values.editable = !(values.readOnly)
|
69
65
|
form.setValues(values);
|
70
|
-
|
71
66
|
}, [activeSchema, form]);
|
72
67
|
|
73
68
|
useEffect(() => form.resetFields(), [activeSchema.id])
|
@@ -98,23 +93,24 @@ const DetailView = (props: DetailViewProps) => {
|
|
98
93
|
}
|
99
94
|
|
100
95
|
let changes: ChangeSchemaItem[] = [];
|
101
|
-
for (
|
96
|
+
for (const key in formSchema) {
|
102
97
|
if (['id', 'content'].includes(key)) continue;
|
103
98
|
|
104
99
|
let value = formSchema[key];
|
105
|
-
|
106
|
-
|
107
|
-
if (['x', 'y'].includes(key)) {
|
108
|
-
// [position] Return the flattened position to its original form.
|
109
|
-
changed = value !== (activeSchema as any)['position'][key];
|
110
|
-
key = 'position.' + key;
|
111
|
-
} else {
|
112
|
-
changed = formAndSchemaValuesDiffer(value, (activeSchema as any)[key]);
|
113
|
-
}
|
114
|
-
|
115
|
-
if (changed) {
|
100
|
+
if (formAndSchemaValuesDiffer(value, (activeSchema as any)[key])) {
|
116
101
|
// FIXME memo: https://github.com/pdfme/pdfme/pull/367#issuecomment-1857468274
|
117
|
-
if (value === null && ['rotate', 'opacity'].includes(key))
|
102
|
+
if (value === null && ['rotate', 'opacity'].includes(key)) {
|
103
|
+
value = undefined;
|
104
|
+
}
|
105
|
+
|
106
|
+
if (key === 'editable') {
|
107
|
+
const readOnlyValue = !value;
|
108
|
+
changes.push({ key: 'readOnly', value: readOnlyValue, schemaId: activeSchema.id });
|
109
|
+
if (readOnlyValue) {
|
110
|
+
changes.push({ key: 'required', value: false, schemaId: activeSchema.id });
|
111
|
+
}
|
112
|
+
continue;
|
113
|
+
}
|
118
114
|
|
119
115
|
changes.push({ key, value, schemaId: activeSchema.id });
|
120
116
|
}
|
@@ -137,7 +133,7 @@ const DetailView = (props: DetailViewProps) => {
|
|
137
133
|
}
|
138
134
|
});
|
139
135
|
}
|
140
|
-
},
|
136
|
+
}, 100);
|
141
137
|
|
142
138
|
const activePlugin = Object.values(pluginsRegistry).find(
|
143
139
|
(plugin) => plugin?.propPanel.defaultSchema.type === activeSchema.type
|
@@ -178,26 +174,24 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
178
174
|
}],
|
179
175
|
props: { autoComplete: "off" }
|
180
176
|
},
|
181
|
-
|
177
|
+
editable: { title: i18n('editable'), type: 'boolean', span: 8, hidden: defaultSchema?.readOnly !== undefined },
|
178
|
+
required: { title: i18n('required'), type: 'boolean', span: 16, hidden: "{{!formData.editable}}" },
|
182
179
|
'-': { type: 'void', widget: 'Divider' },
|
183
180
|
align: { title: i18n('align'), type: 'void', widget: 'AlignWidget' },
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
max: 360,
|
192
|
-
props: { min: 0 },
|
193
|
-
span: 8,
|
181
|
+
position: {
|
182
|
+
type: 'object',
|
183
|
+
widget: 'card',
|
184
|
+
properties: {
|
185
|
+
x: { title: 'X', type: 'number', widget: 'inputNumber', required: true, span: 8, min: 0 },
|
186
|
+
y: { title: 'Y', type: 'number', widget: 'inputNumber', required: true, span: 8, min: 0 },
|
187
|
+
}
|
194
188
|
},
|
195
189
|
width: {
|
196
190
|
title: i18n('width'),
|
197
191
|
type: 'number',
|
198
192
|
widget: 'inputNumber',
|
199
193
|
required: true,
|
200
|
-
span:
|
194
|
+
span: 6,
|
201
195
|
props: { min: 0 },
|
202
196
|
},
|
203
197
|
height: {
|
@@ -205,8 +199,17 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
205
199
|
type: 'number',
|
206
200
|
widget: 'inputNumber',
|
207
201
|
required: true,
|
208
|
-
span:
|
202
|
+
span: 6,
|
203
|
+
props: { min: 0 },
|
204
|
+
},
|
205
|
+
rotate: {
|
206
|
+
title: i18n('rotate'),
|
207
|
+
type: 'number',
|
208
|
+
widget: 'inputNumber',
|
209
|
+
disabled: defaultSchema?.rotate === undefined,
|
210
|
+
max: 360,
|
209
211
|
props: { min: 0 },
|
212
|
+
span: 6,
|
210
213
|
},
|
211
214
|
opacity: {
|
212
215
|
title: i18n('opacity'),
|
@@ -214,7 +217,7 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
214
217
|
widget: 'inputNumber',
|
215
218
|
disabled: defaultSchema?.opacity === undefined,
|
216
219
|
props: { step: 0.1, min: 0, max: 1 },
|
217
|
-
span:
|
220
|
+
span: 6,
|
218
221
|
},
|
219
222
|
},
|
220
223
|
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React, { useEffect, useContext } from 'react';
|
2
2
|
import { DraggableSyntheticListeners } from '@dnd-kit/core';
|
3
3
|
import { I18nContext } from '../../../../contexts';
|
4
|
-
import { HolderOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
|
4
|
+
import { HolderOutlined, ExclamationCircleOutlined, LockOutlined } from '@ant-design/icons';
|
5
5
|
import { Button, Typography } from 'antd';
|
6
6
|
|
7
7
|
const { Text } = Typography;
|
@@ -13,6 +13,7 @@ interface Props {
|
|
13
13
|
status?: 'is-warning' | 'is-danger';
|
14
14
|
title?: string;
|
15
15
|
required?: boolean;
|
16
|
+
readOnly?: boolean;
|
16
17
|
dragOverlay?: boolean;
|
17
18
|
onClick?: () => void;
|
18
19
|
onMouseEnter?: () => void;
|
@@ -33,6 +34,7 @@ const Item = React.memo(
|
|
33
34
|
status,
|
34
35
|
title,
|
35
36
|
required,
|
37
|
+
readOnly,
|
36
38
|
style,
|
37
39
|
dragOverlay,
|
38
40
|
onClick,
|
@@ -116,6 +118,7 @@ const Item = React.memo(
|
|
116
118
|
{status === 'is-danger' ? i18n('notUniq') : ''}
|
117
119
|
</span>
|
118
120
|
)}
|
121
|
+
{readOnly && <LockOutlined style={{ marginLeft: '0.5rem' }} />}
|
119
122
|
{required && <span style={{ color: 'red', marginLeft: '0.5rem' }}>*</span>}
|
120
123
|
</Text>
|
121
124
|
</div>
|
@@ -58,7 +58,7 @@ const SelectableSortableContainer = (
|
|
58
58
|
}
|
59
59
|
};
|
60
60
|
|
61
|
-
const getPluginIcon = (inSchema: string|SchemaForUI): ReactNode => {
|
61
|
+
const getPluginIcon = (inSchema: string | SchemaForUI): ReactNode => {
|
62
62
|
const thisSchema = (typeof inSchema === 'string') ? schemas.find((schema) => schema.id === inSchema) : inSchema;
|
63
63
|
|
64
64
|
const [pluginLabel, activePlugin] = Object.entries(pluginsRegistry).find(
|
@@ -69,7 +69,7 @@ const SelectableSortableContainer = (
|
|
69
69
|
return <></>
|
70
70
|
}
|
71
71
|
|
72
|
-
return <PluginIcon plugin={activePlugin} label={pluginLabel} size={20} styles={{marginRight: '0.5rem'}}/>
|
72
|
+
return <PluginIcon plugin={activePlugin} label={pluginLabel} size={20} styles={{ marginRight: '0.5rem' }} />
|
73
73
|
};
|
74
74
|
|
75
75
|
return (
|
@@ -133,9 +133,8 @@ const SelectableSortableContainer = (
|
|
133
133
|
<SelectableSortableItem
|
134
134
|
key={schema.id}
|
135
135
|
style={{
|
136
|
-
border: `1px solid ${
|
137
|
-
|
138
|
-
}`,
|
136
|
+
border: `1px solid ${schema.id === hoveringSchemaId ? token.colorPrimary : 'transparent'
|
137
|
+
}`,
|
139
138
|
}}
|
140
139
|
schema={schema}
|
141
140
|
schemas={schemas}
|
@@ -152,31 +151,39 @@ const SelectableSortableContainer = (
|
|
152
151
|
{createPortal(
|
153
152
|
<DragOverlay adjustScale>
|
154
153
|
{activeId ? (
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
style={{ background: token.colorPrimary }}
|
162
|
-
dragOverlay
|
163
|
-
/>
|
164
|
-
</ul>
|
165
|
-
<ul style={{ margin: 0, padding: 0, listStyle: 'none' }}>
|
166
|
-
{selectedSchemas
|
167
|
-
.filter((item) => item.id !== activeId)
|
168
|
-
.map((item) => (
|
154
|
+
(() => {
|
155
|
+
const activeSchema = schemas.find((schema) => schema.id === activeId);
|
156
|
+
if (!activeSchema) return null;
|
157
|
+
return (
|
158
|
+
<>
|
159
|
+
<ul style={{ margin: 0, padding: 0, listStyle: 'none' }}>
|
169
160
|
<Item
|
170
|
-
icon={getPluginIcon(
|
171
|
-
|
172
|
-
|
173
|
-
|
161
|
+
icon={getPluginIcon(activeId)}
|
162
|
+
value={activeSchema.key}
|
163
|
+
required={activeSchema.required}
|
164
|
+
readOnly={activeSchema.readOnly}
|
174
165
|
style={{ background: token.colorPrimary }}
|
175
166
|
dragOverlay
|
176
167
|
/>
|
177
|
-
|
178
|
-
|
179
|
-
|
168
|
+
</ul>
|
169
|
+
<ul style={{ margin: 0, padding: 0, listStyle: 'none' }}>
|
170
|
+
{selectedSchemas
|
171
|
+
.filter((item) => item.id !== activeId)
|
172
|
+
.map((item) => (
|
173
|
+
<Item
|
174
|
+
icon={getPluginIcon(item)}
|
175
|
+
key={item.id}
|
176
|
+
value={item.key}
|
177
|
+
required={item.required}
|
178
|
+
readOnly={item.readOnly}
|
179
|
+
style={{ background: token.colorPrimary }}
|
180
|
+
dragOverlay
|
181
|
+
/>
|
182
|
+
))}
|
183
|
+
</ul>
|
184
|
+
</>
|
185
|
+
);
|
186
|
+
})()
|
180
187
|
) : null}
|
181
188
|
</DragOverlay>,
|
182
189
|
document.body
|
package/src/i18n.ts
CHANGED
@@ -11,6 +11,7 @@ const dictEn: { [key in keyof Dict]: string } = {
|
|
11
11
|
opacity: 'Opacity',
|
12
12
|
rotate: 'Rotate',
|
13
13
|
required: 'Required',
|
14
|
+
editable: 'Editable',
|
14
15
|
edit: 'Edit',
|
15
16
|
plsInputName: 'Please input name',
|
16
17
|
fieldMustUniq: 'Name of field is not unique',
|
@@ -77,6 +78,7 @@ const dictZh: { [key in keyof Dict]: string } = {
|
|
77
78
|
opacity: '透明度',
|
78
79
|
rotate: '旋转',
|
79
80
|
required: '必需的',
|
81
|
+
editable: '可编辑的',
|
80
82
|
edit: '编辑',
|
81
83
|
plsInputName: '请输入名称',
|
82
84
|
fieldMustUniq: '字段名称必须唯一',
|
@@ -142,6 +144,7 @@ const dictJa: { [key in keyof Dict]: string } = {
|
|
142
144
|
opacity: '不透明度',
|
143
145
|
rotate: '回転',
|
144
146
|
required: '必須',
|
147
|
+
editable: '編集可能',
|
145
148
|
edit: '編集する',
|
146
149
|
plsInputName: '項目名を入力してください',
|
147
150
|
fieldMustUniq: '他の入力項目名と被っています',
|
@@ -207,6 +210,7 @@ const dictKo: { [key in keyof Dict]: string } = {
|
|
207
210
|
opacity: '투명도',
|
208
211
|
rotate: '회전',
|
209
212
|
required: '필수의',
|
213
|
+
editable: '편집 가능한',
|
210
214
|
edit: '편집',
|
211
215
|
plsInputName: '이름을 입력하세요',
|
212
216
|
fieldMustUniq: '필드 이름은 유일해야 합니다',
|
@@ -272,6 +276,7 @@ const dictAr: { [key in keyof Dict]: string } = {
|
|
272
276
|
opacity: 'الشفافية',
|
273
277
|
rotate: 'تدوير',
|
274
278
|
required: 'مطلوب',
|
279
|
+
editable:'قابل للتحرير',
|
275
280
|
edit: 'تعديل',
|
276
281
|
plsInputName: 'الرجاء إدخال الاسم',
|
277
282
|
fieldMustUniq: 'يجب أن يكون الحقل فريداً',
|
@@ -337,6 +342,7 @@ const dictTh: { [key in keyof Dict]: string } = {
|
|
337
342
|
opacity: 'ความทึบ',
|
338
343
|
rotate: 'หมุน',
|
339
344
|
required: 'ที่จำเป็น',
|
345
|
+
editable: 'แก้ไขได้',
|
340
346
|
edit: 'แก้ไข',
|
341
347
|
plsInputName: 'กรุณาใส่ชื่อ',
|
342
348
|
fieldMustUniq: 'ชื่อฟิลด์ต้องไม่ซ้ำกัน',
|
@@ -402,6 +408,7 @@ const dictIt: { [key in keyof Dict]: string } = {
|
|
402
408
|
opacity: 'Opacità',
|
403
409
|
rotate: 'Ruota',
|
404
410
|
required: 'Necessaria',
|
411
|
+
editable: 'Modificabile',
|
405
412
|
edit: 'Modifica',
|
406
413
|
plsInputName: 'Inserisci il nome per favore',
|
407
414
|
fieldMustUniq: 'Il nome del campo non è univoco',
|
@@ -469,6 +476,7 @@ const dictPl: { [key in keyof Dict]: string } = {
|
|
469
476
|
opacity: 'przezroczystość',
|
470
477
|
rotate: 'Obrót',
|
471
478
|
required: 'Wymagany',
|
479
|
+
editable: 'Edytowalny',
|
472
480
|
edit: 'Edytuj',
|
473
481
|
plsInputName: 'Wymagane wprowadzenie klucza pola',
|
474
482
|
fieldMustUniq: 'Klucz pola nie jest unikalny',
|
@@ -534,6 +542,7 @@ const dictDe: { [key in keyof Dict]: string } = {
|
|
534
542
|
opacity: 'Opazität',
|
535
543
|
rotate: 'Drehen',
|
536
544
|
required: 'Erforderlich',
|
545
|
+
editable: 'Bearbeitbar',
|
537
546
|
edit: 'Bearbeiten',
|
538
547
|
plsInputName: 'Bitte geben Sie einen Namen ein',
|
539
548
|
fieldMustUniq: 'Feldname ist nicht eindeutig',
|
@@ -601,6 +610,7 @@ const dictEs: { [key in keyof Dict]: string } = {
|
|
601
610
|
opacity: 'Opacidad',
|
602
611
|
rotate: 'Rotar',
|
603
612
|
required: 'Requerido',
|
613
|
+
editable: 'Editable',
|
604
614
|
edit: 'Editar',
|
605
615
|
plsInputName: 'Introduce el nombre',
|
606
616
|
fieldMustUniq: 'El nombre del campo no es único',
|
@@ -668,6 +678,7 @@ const dictFr: { [key in keyof Dict]: string } = {
|
|
668
678
|
opacity: 'Opacité',
|
669
679
|
rotate: 'Rotation',
|
670
680
|
required: 'Requis',
|
681
|
+
editable: 'Modifiable',
|
671
682
|
edit: 'Éditer',
|
672
683
|
plsInputName: 'Veuillez saisir le nom',
|
673
684
|
fieldMustUniq:"Le nom du champ n'est pas unique",
|