@pdfme/ui 5.3.8-dev.6 → 5.3.8-dev.60
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/__mocks__/lucide-react.js +19 -0
- package/dist/index.es.js +110045 -107268
- package/dist/index.umd.js +585 -556
- package/dist/types/__tests__/assets/helper.d.ts +3 -0
- package/dist/types/__tests__/components/Designer.test.d.ts +1 -0
- package/dist/types/__tests__/components/Preview.test.d.ts +1 -0
- package/dist/types/__tests__/helper.test.d.ts +1 -0
- package/dist/types/{Designer.d.ts → src/Designer.d.ts} +1 -1
- package/dist/types/{Form.d.ts → src/Form.d.ts} +1 -1
- package/dist/types/{Viewer.d.ts → src/Viewer.d.ts} +1 -1
- package/dist/types/src/components/Designer/Canvas/Guides.d.ts +15 -0
- package/dist/types/{components → src/components}/Designer/Canvas/Moveable.d.ts +48 -1
- package/dist/types/src/components/Designer/Canvas/Selecto.d.ts +21 -0
- package/dist/types/{components → src/components}/Designer/LeftSidebar.d.ts +1 -1
- package/dist/types/{components → src/components}/Designer/PluginIcon.d.ts +1 -1
- package/dist/types/{components → src/components}/Designer/RightSidebar/DetailView/index.d.ts +1 -1
- package/dist/types/src/components/Designer/RightSidebar/ListView/SelectableSortableContainer.d.ts +4 -0
- package/dist/types/src/components/Designer/RightSidebar/ListView/index.d.ts +4 -0
- package/dist/types/{components → src/components}/Designer/RightSidebar/index.d.ts +1 -1
- package/dist/types/{components → src/components}/Paper.d.ts +1 -1
- package/dist/types/{components → src/components}/Preview.d.ts +2 -2
- package/dist/types/src/contexts.d.ts +10 -0
- package/dist/types/{helper.d.ts → src/helper.d.ts} +2 -4
- package/dist/types/src/index.d.ts +4 -0
- package/eslint.config.mjs +41 -0
- package/package.json +21 -15
- package/src/Designer.tsx +7 -7
- package/src/Form.tsx +4 -6
- package/src/Viewer.tsx +4 -4
- package/src/components/AppContextProvider.tsx +4 -4
- package/src/components/CtlBar.tsx +4 -2
- package/src/components/Designer/Canvas/Guides.tsx +18 -9
- package/src/components/Designer/Canvas/Mask.tsx +1 -1
- package/src/components/Designer/Canvas/Moveable.tsx +66 -7
- package/src/components/Designer/Canvas/Padding.tsx +10 -8
- package/src/components/Designer/Canvas/Selecto.tsx +21 -6
- package/src/components/Designer/Canvas/index.tsx +95 -28
- package/src/components/Designer/LeftSidebar.tsx +60 -52
- package/src/components/Designer/PluginIcon.tsx +22 -9
- package/src/components/Designer/RightSidebar/DetailView/AlignWidget.tsx +45 -45
- package/src/components/Designer/RightSidebar/DetailView/ButtonGroupWidget.tsx +3 -3
- package/src/components/Designer/RightSidebar/DetailView/index.tsx +62 -31
- package/src/components/Designer/RightSidebar/ListView/Item.tsx +5 -5
- package/src/components/Designer/RightSidebar/ListView/SelectableSortableContainer.tsx +60 -51
- package/src/components/Designer/RightSidebar/ListView/SelectableSortableItem.tsx +5 -6
- package/src/components/Designer/RightSidebar/ListView/index.tsx +15 -8
- package/src/components/Designer/RightSidebar/index.tsx +4 -4
- package/src/components/Designer/index.tsx +51 -29
- package/src/components/ErrorScreen.tsx +2 -2
- package/src/components/Paper.tsx +2 -2
- package/src/components/Preview.tsx +35 -24
- package/src/components/Renderer.tsx +42 -29
- package/src/components/Root.tsx +4 -6
- package/src/components/Spinner.tsx +1 -1
- package/src/components/StaticSchema.tsx +41 -23
- package/src/constants.ts +1 -1
- package/src/contexts.ts +2 -2
- package/src/helper.ts +37 -17
- package/src/hooks.ts +16 -8
- package/src/index.ts +3 -3
- package/src/types/react-guides.d.ts +22 -0
- package/src/types/react-selecto.d.ts +35 -0
- package/tsconfig.json +10 -12
- package/.eslintrc.cjs +0 -16
- package/dist/types/components/Designer/Canvas/Guides.d.ts +0 -9
- package/dist/types/components/Designer/Canvas/Selecto.d.ts +0 -10
- package/dist/types/components/Designer/RightSidebar/ListView/SelectableSortableContainer.d.ts +0 -4
- package/dist/types/components/Designer/RightSidebar/ListView/index.d.ts +0 -4
- package/dist/types/contexts.d.ts +0 -85
- package/dist/types/index.d.ts +0 -4
- /package/dist/types/{class.d.ts → src/class.d.ts} +0 -0
- /package/dist/types/{components → src/components}/AppContextProvider.d.ts +0 -0
- /package/dist/types/{components → src/components}/CtlBar.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/Canvas/Mask.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/Canvas/Padding.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/Canvas/index.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/DetailView/AlignWidget.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/DetailView/ButtonGroupWidget.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/DetailView/WidgetRenderer.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/ListView/Item.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/ListView/SelectableSortableItem.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/index.d.ts +0 -0
- /package/dist/types/{components → src/components}/ErrorScreen.d.ts +0 -0
- /package/dist/types/{components → src/components}/Renderer.d.ts +0 -0
- /package/dist/types/{components → src/components}/Root.d.ts +0 -0
- /package/dist/types/{components → src/components}/Spinner.d.ts +0 -0
- /package/dist/types/{components → src/components}/StaticSchema.d.ts +0 -0
- /package/dist/types/{components → src/components}/UnitPager.d.ts +0 -0
- /package/dist/types/{constants.d.ts → src/constants.d.ts} +0 -0
- /package/dist/types/{hooks.d.ts → src/hooks.d.ts} +0 -0
- /package/dist/types/{i18n.d.ts → src/i18n.d.ts} +0 -0
- /package/dist/types/{theme.d.ts → src/theme.d.ts} +0 -0
- /package/dist/types/{types.d.ts → src/types.d.ts} +0 -0
- /package/{vite.config.ts → vite.config.mts} +0 -0
@@ -10,8 +10,8 @@ import {
|
|
10
10
|
AlignEndHorizontal,
|
11
11
|
AlignVerticalSpaceAround,
|
12
12
|
AlignHorizontalSpaceAround,
|
13
|
-
} from 'lucide-react'
|
14
|
-
import { round } from '../../../../helper';
|
13
|
+
} from 'lucide-react';
|
14
|
+
import { round } from '../../../../helper.js';
|
15
15
|
|
16
16
|
const AlignWidget = (props: PropPanelWidgetProps) => {
|
17
17
|
const { activeElements, changeSchemas, schemas, pageSize, schema } = props;
|
@@ -44,7 +44,7 @@ const AlignWidget = (props: PropPanelWidgetProps) => {
|
|
44
44
|
key: `position.${tgtPos}`,
|
45
45
|
value: round(basePos - adjust(as[tgtSize]), 2),
|
46
46
|
schemaId: as.id,
|
47
|
-
}))
|
47
|
+
})),
|
48
48
|
);
|
49
49
|
};
|
50
50
|
|
@@ -72,7 +72,7 @@ const AlignWidget = (props: PropPanelWidgetProps) => {
|
|
72
72
|
prev += index === 0 ? 0 : ass[index - 1][tgtSize] + unit;
|
73
73
|
const value = round(boxPos + prev, 2);
|
74
74
|
return { key: `position.${tgtPos}`, value, schemaId: as.id };
|
75
|
-
})
|
75
|
+
}),
|
76
76
|
);
|
77
77
|
};
|
78
78
|
const layoutBtns: {
|
@@ -80,47 +80,47 @@ const AlignWidget = (props: PropPanelWidgetProps) => {
|
|
80
80
|
icon: React.JSX.Element;
|
81
81
|
onClick: () => void;
|
82
82
|
}[] = [
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
83
|
+
{
|
84
|
+
id: 'left',
|
85
|
+
icon: <AlignStartVertical size={15} />,
|
86
|
+
onClick: () => align('left'),
|
87
|
+
},
|
88
|
+
{
|
89
|
+
id: 'center',
|
90
|
+
icon: <AlignCenterVertical size={15} />,
|
91
|
+
onClick: () => align('center'),
|
92
|
+
},
|
93
|
+
{
|
94
|
+
id: 'right',
|
95
|
+
icon: <AlignEndVertical size={15} />,
|
96
|
+
onClick: () => align('right'),
|
97
|
+
},
|
98
|
+
{
|
99
|
+
id: 'top',
|
100
|
+
icon: <AlignStartHorizontal size={15} />,
|
101
|
+
onClick: () => align('top'),
|
102
|
+
},
|
103
|
+
{
|
104
|
+
id: 'middle',
|
105
|
+
icon: <AlignCenterHorizontal size={15} />,
|
106
|
+
onClick: () => align('middle'),
|
107
|
+
},
|
108
|
+
{
|
109
|
+
id: 'bottom',
|
110
|
+
icon: <AlignEndHorizontal size={15} />,
|
111
|
+
onClick: () => align('bottom'),
|
112
|
+
},
|
113
|
+
{
|
114
|
+
id: 'vertical',
|
115
|
+
icon: <AlignVerticalSpaceAround size={15} />,
|
116
|
+
onClick: () => distribute('vertical'),
|
117
|
+
},
|
118
|
+
{
|
119
|
+
id: 'horizontal',
|
120
|
+
icon: <AlignHorizontalSpaceAround size={15} />,
|
121
|
+
onClick: () => distribute('horizontal'),
|
122
|
+
},
|
123
|
+
];
|
124
124
|
|
125
125
|
return (
|
126
126
|
<Form.Item label={schema.title}>
|
@@ -22,7 +22,7 @@ const ButtonGroupWidget = (props: PropPanelWidgetProps) => {
|
|
22
22
|
const oldValue = s[key] ?? false;
|
23
23
|
const newValue = type === 'boolean' ? !oldValue : btn.value;
|
24
24
|
return { key, value: newValue, schemaId: s.id };
|
25
|
-
})
|
25
|
+
}),
|
26
26
|
);
|
27
27
|
};
|
28
28
|
|
@@ -33,7 +33,7 @@ const ButtonGroupWidget = (props: PropPanelWidgetProps) => {
|
|
33
33
|
const ids = activeElements.map((ae) => ae.id);
|
34
34
|
const ass = schemas.filter((s) => ids.includes(s.id)) as SchemaForUI[];
|
35
35
|
ass.forEach((s: Record<string, any>) => {
|
36
|
-
active = type === 'boolean' ? s[key] ?? false : s[key] === btn.value;
|
36
|
+
active = type === 'boolean' ? (s[key] ?? false) : s[key] === btn.value;
|
37
37
|
});
|
38
38
|
return active;
|
39
39
|
};
|
@@ -43,7 +43,7 @@ const ButtonGroupWidget = (props: PropPanelWidgetProps) => {
|
|
43
43
|
|
44
44
|
const svgIcon = (svgString: string) => {
|
45
45
|
const svgDataUrl = `data:image/svg+xml;utf8,${encodeURIComponent(
|
46
|
-
replaceCurrentColor(svgString, token.colorText)
|
46
|
+
replaceCurrentColor(svgString, token.colorText),
|
47
47
|
)}`;
|
48
48
|
return <img width={17} height={17} src={svgDataUrl} />;
|
49
49
|
};
|
@@ -1,20 +1,36 @@
|
|
1
|
-
import
|
1
|
+
import { useForm } from 'form-render';
|
2
2
|
import React, { useRef, useContext, useState, useEffect } from 'react';
|
3
|
-
import type {
|
4
|
-
|
3
|
+
import type {
|
4
|
+
ChangeSchemaItem,
|
5
|
+
Dict,
|
6
|
+
SchemaForUI,
|
7
|
+
PropPanelWidgetProps,
|
8
|
+
PropPanelSchema,
|
9
|
+
} from '@pdfme/common';
|
10
|
+
import type { SidebarProps } from '../../../../types.js';
|
5
11
|
import { Menu } from 'lucide-react';
|
6
|
-
import { I18nContext, PluginsRegistry, OptionsContext } from '../../../../contexts';
|
7
|
-
import { getSidebarContentHeight, debounce } from '../../../../helper';
|
12
|
+
import { I18nContext, PluginsRegistry, OptionsContext } from '../../../../contexts.js';
|
13
|
+
import { getSidebarContentHeight, debounce } from '../../../../helper.js';
|
8
14
|
import { theme, Typography, Button, Divider } from 'antd';
|
9
|
-
import AlignWidget from './AlignWidget';
|
10
|
-
import WidgetRenderer from './WidgetRenderer';
|
11
|
-
import ButtonGroupWidget from './ButtonGroupWidget';
|
12
|
-
import { InternalNamePath, ValidateErrorEntity } from
|
15
|
+
import AlignWidget from './AlignWidget.js';
|
16
|
+
import WidgetRenderer from './WidgetRenderer.js';
|
17
|
+
import ButtonGroupWidget from './ButtonGroupWidget.js';
|
18
|
+
import { InternalNamePath, ValidateErrorEntity } from 'rc-field-form/es/interface.js';
|
19
|
+
|
20
|
+
// Import FormRender as a default import
|
21
|
+
import FormRenderComponent from 'form-render';
|
13
22
|
|
14
23
|
const { Text } = Typography;
|
15
24
|
|
16
|
-
type DetailViewProps = Pick<
|
17
|
-
|
25
|
+
type DetailViewProps = Pick<
|
26
|
+
SidebarProps,
|
27
|
+
| 'size'
|
28
|
+
| 'schemas'
|
29
|
+
| 'schemasList'
|
30
|
+
| 'pageSize'
|
31
|
+
| 'changeSchemas'
|
32
|
+
| 'activeElements'
|
33
|
+
| 'deselectSchema'
|
18
34
|
> & {
|
19
35
|
activeSchema: SchemaForUI;
|
20
36
|
};
|
@@ -61,11 +77,11 @@ const DetailView = (props: DetailViewProps) => {
|
|
61
77
|
|
62
78
|
useEffect(() => {
|
63
79
|
const values: any = { ...activeSchema };
|
64
|
-
values.editable = !
|
80
|
+
values.editable = !values.readOnly;
|
65
81
|
form.setValues(values);
|
66
82
|
}, [activeSchema, form]);
|
67
83
|
|
68
|
-
useEffect(() => form.resetFields(), [activeSchema.id])
|
84
|
+
useEffect(() => form.resetFields(), [activeSchema.id]);
|
69
85
|
|
70
86
|
useEffect(() => {
|
71
87
|
uniqueSchemaName.current = (value: string): boolean => {
|
@@ -82,7 +98,8 @@ const DetailView = (props: DetailViewProps) => {
|
|
82
98
|
|
83
99
|
const uniqueSchemaName = useRef((value: string): boolean => true);
|
84
100
|
|
85
|
-
const validateUniqueSchemaName = (_: any, value: string): boolean =>
|
101
|
+
const validateUniqueSchemaName = (_: any, value: string): boolean =>
|
102
|
+
uniqueSchemaName.current(value);
|
86
103
|
|
87
104
|
const handleWatch = debounce((formSchema: any) => {
|
88
105
|
const formAndSchemaValuesDiffer = (formValue: any, schemaValue: any): boolean => {
|
@@ -90,7 +107,7 @@ const DetailView = (props: DetailViewProps) => {
|
|
90
107
|
return JSON.stringify(formValue) !== JSON.stringify(schemaValue);
|
91
108
|
}
|
92
109
|
return formValue !== schemaValue;
|
93
|
-
}
|
110
|
+
};
|
94
111
|
|
95
112
|
let changes: ChangeSchemaItem[] = [];
|
96
113
|
for (const key in formSchema) {
|
@@ -118,15 +135,17 @@ const DetailView = (props: DetailViewProps) => {
|
|
118
135
|
|
119
136
|
if (changes.length) {
|
120
137
|
// Only commit these schema changes if they have passed form validation
|
121
|
-
form
|
138
|
+
form
|
139
|
+
.validateFields()
|
122
140
|
.then(() => changeSchemas(changes))
|
123
141
|
.catch((reason: ValidateErrorEntity) => {
|
124
142
|
if (reason.errorFields.length) {
|
125
|
-
changes = changes.filter(
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
143
|
+
changes = changes.filter(
|
144
|
+
(change: ChangeSchemaItem) =>
|
145
|
+
!reason.errorFields.find((field: { name: InternalNamePath; errors: string[] }) =>
|
146
|
+
field.name.includes(change.key),
|
147
|
+
),
|
148
|
+
);
|
130
149
|
}
|
131
150
|
if (changes.length) {
|
132
151
|
changeSchemas(changes);
|
@@ -136,7 +155,7 @@ const DetailView = (props: DetailViewProps) => {
|
|
136
155
|
}, 100);
|
137
156
|
|
138
157
|
const activePlugin = Object.values(pluginsRegistry).find(
|
139
|
-
(plugin) => plugin?.propPanel.defaultSchema.type === activeSchema.type
|
158
|
+
(plugin) => plugin?.propPanel.defaultSchema.type === activeSchema.type,
|
140
159
|
)!;
|
141
160
|
|
142
161
|
const activePropPanelSchema = activePlugin?.propPanel.schema;
|
@@ -168,14 +187,26 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
168
187
|
type: 'string',
|
169
188
|
required: true,
|
170
189
|
span: 12,
|
171
|
-
rules: [
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
190
|
+
rules: [
|
191
|
+
{
|
192
|
+
validator: validateUniqueSchemaName,
|
193
|
+
message: i18n('validation.uniqueName'),
|
194
|
+
},
|
195
|
+
],
|
196
|
+
props: { autoComplete: 'off' },
|
197
|
+
},
|
198
|
+
editable: {
|
199
|
+
title: i18n('editable'),
|
200
|
+
type: 'boolean',
|
201
|
+
span: 8,
|
202
|
+
hidden: defaultSchema?.readOnly !== undefined,
|
203
|
+
},
|
204
|
+
required: {
|
205
|
+
title: i18n('required'),
|
206
|
+
type: 'boolean',
|
207
|
+
span: 16,
|
208
|
+
hidden: '{{!formData.editable}}',
|
176
209
|
},
|
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}}" },
|
179
210
|
'-': { type: 'void', widget: 'Divider' },
|
180
211
|
align: { title: i18n('align'), type: 'void', widget: 'AlignWidget' },
|
181
212
|
position: {
|
@@ -184,7 +215,7 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
184
215
|
properties: {
|
185
216
|
x: { title: 'X', type: 'number', widget: 'inputNumber', required: true, span: 8, min: 0 },
|
186
217
|
y: { title: 'Y', type: 'number', widget: 'inputNumber', required: true, span: 8, min: 0 },
|
187
|
-
}
|
218
|
+
},
|
188
219
|
},
|
189
220
|
width: {
|
190
221
|
title: i18n('width'),
|
@@ -272,7 +303,7 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
272
303
|
overflowX: 'hidden',
|
273
304
|
}}
|
274
305
|
>
|
275
|
-
<
|
306
|
+
<FormRenderComponent
|
276
307
|
form={form}
|
277
308
|
schema={propPanelSchema}
|
278
309
|
widgets={widgets}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React, { useEffect, useContext } from 'react';
|
2
2
|
import { DraggableSyntheticListeners } from '@dnd-kit/core';
|
3
|
-
import { I18nContext } from '../../../../contexts';
|
4
|
-
import { GripVertical, CircleAlert, Lock } from 'lucide-react'
|
3
|
+
import { I18nContext } from '../../../../contexts.js';
|
4
|
+
import { GripVertical, CircleAlert, Lock } from 'lucide-react';
|
5
5
|
import { Button, Typography } from 'antd';
|
6
6
|
|
7
7
|
const { Text } = Typography;
|
@@ -48,7 +48,7 @@ const Item = React.memo(
|
|
48
48
|
transform,
|
49
49
|
...props
|
50
50
|
},
|
51
|
-
ref
|
51
|
+
ref,
|
52
52
|
) => {
|
53
53
|
const i18n = useContext(I18nContext);
|
54
54
|
|
@@ -125,8 +125,8 @@ const Item = React.memo(
|
|
125
125
|
</div>
|
126
126
|
</li>
|
127
127
|
);
|
128
|
-
}
|
129
|
-
)
|
128
|
+
},
|
129
|
+
),
|
130
130
|
);
|
131
131
|
|
132
132
|
export default Item;
|
@@ -16,18 +16,18 @@ import {
|
|
16
16
|
verticalListSortingStrategy,
|
17
17
|
} from '@dnd-kit/sortable';
|
18
18
|
import { SchemaForUI } from '@pdfme/common';
|
19
|
-
import type { SidebarProps } from '../../../../types';
|
20
|
-
import { PluginsRegistry } from '../../../../contexts';
|
21
|
-
import Item from './Item';
|
22
|
-
import SelectableSortableItem from './SelectableSortableItem';
|
19
|
+
import type { SidebarProps } from '../../../../types.js';
|
20
|
+
import { PluginsRegistry } from '../../../../contexts.js';
|
21
|
+
import Item from './Item.js';
|
22
|
+
import SelectableSortableItem from './SelectableSortableItem.js';
|
23
23
|
import { theme } from 'antd';
|
24
|
-
import PluginIcon from
|
24
|
+
import PluginIcon from '../../PluginIcon.js';
|
25
25
|
|
26
26
|
const SelectableSortableContainer = (
|
27
27
|
props: Pick<
|
28
28
|
SidebarProps,
|
29
29
|
'schemas' | 'onEdit' | 'onSortEnd' | 'hoveringSchemaId' | 'onChangeHoveringSchemaId'
|
30
|
-
|
30
|
+
>,
|
31
31
|
) => {
|
32
32
|
const { token } = theme.useToken();
|
33
33
|
const { schemas, onEdit, onSortEnd, hoveringSchemaId, onChangeHoveringSchemaId } = props;
|
@@ -37,7 +37,7 @@ const SelectableSortableContainer = (
|
|
37
37
|
const pluginsRegistry = useContext(PluginsRegistry);
|
38
38
|
const sensors = useSensors(
|
39
39
|
useSensor(PointerSensor, { activationConstraint: { distance: 15 } }),
|
40
|
-
useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates })
|
40
|
+
useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),
|
41
41
|
);
|
42
42
|
|
43
43
|
const isItemSelected = (itemId: string): boolean =>
|
@@ -59,17 +59,25 @@ const SelectableSortableContainer = (
|
|
59
59
|
};
|
60
60
|
|
61
61
|
const getPluginIcon = (inSchema: string | SchemaForUI): ReactNode => {
|
62
|
-
const thisSchema =
|
62
|
+
const thisSchema =
|
63
|
+
typeof inSchema === 'string' ? schemas.find((schema) => schema.id === inSchema) : inSchema;
|
63
64
|
|
64
65
|
const [pluginLabel, activePlugin] = Object.entries(pluginsRegistry).find(
|
65
|
-
([label, plugin]) => plugin?.propPanel.defaultSchema.type === thisSchema?.type
|
66
|
+
([label, plugin]) => plugin?.propPanel.defaultSchema.type === thisSchema?.type,
|
66
67
|
)!;
|
67
68
|
|
68
69
|
if (!activePlugin) {
|
69
|
-
return
|
70
|
+
return <></>;
|
70
71
|
}
|
71
72
|
|
72
|
-
return
|
73
|
+
return (
|
74
|
+
<PluginIcon
|
75
|
+
plugin={activePlugin}
|
76
|
+
label={pluginLabel}
|
77
|
+
size={20}
|
78
|
+
styles={{ marginRight: '0.5rem' }}
|
79
|
+
/>
|
80
|
+
);
|
73
81
|
};
|
74
82
|
|
75
83
|
return (
|
@@ -90,7 +98,7 @@ const SelectableSortableContainer = (
|
|
90
98
|
return ret;
|
91
99
|
}
|
92
100
|
return ret.filter((schema) => schema !== selectedItem);
|
93
|
-
}, schemas)
|
101
|
+
}, schemas),
|
94
102
|
);
|
95
103
|
}
|
96
104
|
}}
|
@@ -106,7 +114,7 @@ const SelectableSortableContainer = (
|
|
106
114
|
newSchemas.splice(
|
107
115
|
overIndex + 1,
|
108
116
|
0,
|
109
|
-
...selectedSchemas.filter((item) => item.id !== activeId)
|
117
|
+
...selectedSchemas.filter((item) => item.id !== activeId),
|
110
118
|
);
|
111
119
|
onSortEnd(newSchemas);
|
112
120
|
setSelectedSchemas([]);
|
@@ -133,8 +141,9 @@ const SelectableSortableContainer = (
|
|
133
141
|
<SelectableSortableItem
|
134
142
|
key={schema.id}
|
135
143
|
style={{
|
136
|
-
border: `1px solid ${
|
137
|
-
|
144
|
+
border: `1px solid ${
|
145
|
+
schema.id === hoveringSchemaId ? token.colorPrimary : 'transparent'
|
146
|
+
}`,
|
138
147
|
}}
|
139
148
|
schema={schema}
|
140
149
|
schemas={schemas}
|
@@ -150,43 +159,43 @@ const SelectableSortableContainer = (
|
|
150
159
|
</div>
|
151
160
|
{createPortal(
|
152
161
|
<DragOverlay adjustScale>
|
153
|
-
{activeId
|
154
|
-
(() => {
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
162
|
+
{activeId
|
163
|
+
? (() => {
|
164
|
+
const activeSchema = schemas.find((schema) => schema.id === activeId);
|
165
|
+
if (!activeSchema) return null;
|
166
|
+
return (
|
167
|
+
<>
|
168
|
+
<ul style={{ margin: 0, padding: 0, listStyle: 'none' }}>
|
169
|
+
<Item
|
170
|
+
icon={getPluginIcon(activeId)}
|
171
|
+
value={activeSchema.name}
|
172
|
+
required={activeSchema.required}
|
173
|
+
readOnly={activeSchema.readOnly}
|
174
|
+
style={{ background: token.colorPrimary }}
|
175
|
+
dragOverlay
|
176
|
+
/>
|
177
|
+
</ul>
|
178
|
+
<ul style={{ margin: 0, padding: 0, listStyle: 'none' }}>
|
179
|
+
{selectedSchemas
|
180
|
+
.filter((item) => item.id !== activeId)
|
181
|
+
.map((item) => (
|
182
|
+
<Item
|
183
|
+
icon={getPluginIcon(item)}
|
184
|
+
key={item.id}
|
185
|
+
value={item.name}
|
186
|
+
required={item.required}
|
187
|
+
readOnly={item.readOnly}
|
188
|
+
style={{ background: token.colorPrimary }}
|
189
|
+
dragOverlay
|
190
|
+
/>
|
191
|
+
))}
|
192
|
+
</ul>
|
193
|
+
</>
|
194
|
+
);
|
195
|
+
})()
|
196
|
+
: null}
|
188
197
|
</DragOverlay>,
|
189
|
-
document.body
|
198
|
+
document.body,
|
190
199
|
)}
|
191
200
|
</>
|
192
201
|
</DndContext>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import React, { useContext } from 'react';
|
2
2
|
import { useSortable } from '@dnd-kit/sortable';
|
3
3
|
import { SchemaForUI } from '@pdfme/common';
|
4
|
-
import { PluginsRegistry, I18nContext } from '../../../../contexts';
|
5
|
-
import Item from './Item';
|
6
|
-
import { useMountStatus } from '../../../../hooks';
|
4
|
+
import { PluginsRegistry, I18nContext } from '../../../../contexts.js';
|
5
|
+
import Item from './Item.js';
|
6
|
+
import { useMountStatus } from '../../../../hooks.js';
|
7
7
|
import { theme } from 'antd';
|
8
|
-
import PluginIcon from
|
8
|
+
import PluginIcon from '../../PluginIcon.js';
|
9
9
|
|
10
10
|
interface Props {
|
11
11
|
isSelected: boolean;
|
@@ -43,10 +43,9 @@ const SelectableSortableItem = ({
|
|
43
43
|
};
|
44
44
|
|
45
45
|
const [pluginLabel, thisPlugin] = Object.entries(pluginsRegistry).find(
|
46
|
-
([label, plugin]) => plugin?.propPanel.defaultSchema.type === schema.type
|
46
|
+
([label, plugin]) => plugin?.propPanel.defaultSchema.type === schema.type,
|
47
47
|
)!;
|
48
48
|
|
49
|
-
|
50
49
|
let status: undefined | 'is-warning' | 'is-danger';
|
51
50
|
if (!schema.name) {
|
52
51
|
status = 'is-warning';
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import React, { useContext, useState } from 'react';
|
2
|
-
import type { SidebarProps } from '../../../../types';
|
3
|
-
import { RIGHT_SIDEBAR_WIDTH } from '../../../../constants';
|
4
|
-
import { I18nContext } from '../../../../contexts';
|
5
|
-
import { getSidebarContentHeight } from '../../../../helper';
|
2
|
+
import type { SidebarProps } from '../../../../types.js';
|
3
|
+
import { RIGHT_SIDEBAR_WIDTH } from '../../../../constants.js';
|
4
|
+
import { I18nContext } from '../../../../contexts.js';
|
5
|
+
import { getSidebarContentHeight } from '../../../../helper.js';
|
6
6
|
import { theme, Input, Typography, Divider, Button } from 'antd';
|
7
|
-
import SelectableSortableContainer from './SelectableSortableContainer';
|
7
|
+
import SelectableSortableContainer from './SelectableSortableContainer.js';
|
8
8
|
|
9
9
|
const { Text } = Typography;
|
10
10
|
const { TextArea } = Input;
|
@@ -21,7 +21,7 @@ const ListView = (
|
|
21
21
|
| 'hoveringSchemaId'
|
22
22
|
| 'onChangeHoveringSchemaId'
|
23
23
|
| 'changeSchemas'
|
24
|
-
|
24
|
+
>,
|
25
25
|
) => {
|
26
26
|
const {
|
27
27
|
schemas,
|
@@ -48,7 +48,7 @@ const ListView = (
|
|
48
48
|
key: 'name',
|
49
49
|
value,
|
50
50
|
schemaId: schemas[index].id,
|
51
|
-
}))
|
51
|
+
})),
|
52
52
|
);
|
53
53
|
setIsBulkUpdateFieldNamesMode(false);
|
54
54
|
}
|
@@ -89,7 +89,14 @@ const ListView = (
|
|
89
89
|
onEdit={onEdit}
|
90
90
|
/>
|
91
91
|
)}
|
92
|
-
<div
|
92
|
+
<div
|
93
|
+
style={{
|
94
|
+
paddingTop: '0.5rem',
|
95
|
+
display: 'flex',
|
96
|
+
alignItems: 'center',
|
97
|
+
justifyContent: 'flex-end',
|
98
|
+
}}
|
99
|
+
>
|
93
100
|
{isBulkUpdateFieldNamesMode ? (
|
94
101
|
<>
|
95
102
|
<Button size="small" type="text" onClick={commitBulk}>
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { theme, Button } from 'antd';
|
3
|
-
import type { SidebarProps } from '../../../types';
|
4
|
-
import { RIGHT_SIDEBAR_WIDTH } from '../../../constants';
|
3
|
+
import type { SidebarProps } from '../../../types.js';
|
4
|
+
import { RIGHT_SIDEBAR_WIDTH } from '../../../constants.js';
|
5
5
|
import { ArrowLeft, ArrowRight } from 'lucide-react';
|
6
|
-
import ListView from './ListView/index';
|
7
|
-
import DetailView from './DetailView/index';
|
6
|
+
import ListView from './ListView/index.js';
|
7
|
+
import DetailView from './DetailView/index.js';
|
8
8
|
|
9
9
|
const Sidebar = (props: SidebarProps) => {
|
10
10
|
const { sidebarOpen, setSidebarOpen, activeElements, schemas } = props;
|