@pdfme/ui 5.5.2 → 5.5.3-dev.2
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 +15528 -15457
- package/dist/index.umd.js +107 -107
- package/dist/types/src/components/Designer/RightSidebar/ListView/index.d.ts +1 -1
- package/dist/types/src/components/Designer/RightSidebar/layout.d.ts +15 -0
- package/dist/types/src/constants.d.ts +2 -0
- package/dist/types/src/helper.d.ts +0 -1
- package/package.json +1 -1
- package/src/components/CtlBar.tsx +18 -9
- package/src/components/Designer/Canvas/index.tsx +4 -2
- package/src/components/Designer/LeftSidebar.tsx +5 -1
- package/src/components/Designer/RightSidebar/DetailView/AlignWidget.tsx +2 -0
- package/src/components/Designer/RightSidebar/DetailView/index.tsx +25 -23
- package/src/components/Designer/RightSidebar/ListView/SelectableSortableContainer.tsx +21 -23
- package/src/components/Designer/RightSidebar/ListView/index.tsx +45 -50
- package/src/components/Designer/RightSidebar/index.tsx +36 -38
- package/src/components/Designer/RightSidebar/layout.tsx +75 -0
- package/src/components/Root.tsx +3 -3
- package/src/constants.ts +4 -0
- package/src/helper.ts +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SidebarProps } from '../../../../types.js';
|
|
3
|
-
declare const ListView: (props: Pick<SidebarProps, "schemas" | "onSortEnd" | "onEdit" | "
|
|
3
|
+
declare const ListView: (props: Pick<SidebarProps, "schemas" | "onSortEnd" | "onEdit" | "hoveringSchemaId" | "onChangeHoveringSchemaId" | "changeSchemas">) => React.JSX.Element;
|
|
4
4
|
export default ListView;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const SIDEBAR_H_PADDING_PX = 16;
|
|
3
|
+
export declare const SIDEBAR_V_PADDING_PX = 8;
|
|
4
|
+
export declare const SIDEBAR_HEADER_HEIGHT = 60;
|
|
5
|
+
type SectionProps = {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
type SidebarFrameProps = SectionProps & {
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const SidebarFrame: ({ children, className }: SidebarFrameProps) => React.JSX.Element;
|
|
12
|
+
export declare const SidebarHeader: ({ children }: SectionProps) => React.JSX.Element;
|
|
13
|
+
export declare const SidebarBody: ({ children }: SectionProps) => React.JSX.Element;
|
|
14
|
+
export declare const SidebarFooter: ({ children }: SectionProps) => React.JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -7,3 +7,5 @@ export declare const LEFT_SIDEBAR_WIDTH = 45;
|
|
|
7
7
|
export declare const RIGHT_SIDEBAR_WIDTH = 400;
|
|
8
8
|
export declare const BACKGROUND_COLOR = "rgb(74, 74, 74)";
|
|
9
9
|
export declare const DEFAULT_MAX_ZOOM = 2;
|
|
10
|
+
export declare const DESIGNER_CLASSNAME = "pdfme-designer-";
|
|
11
|
+
export declare const UI_CLASSNAME = "pdfme-ui-";
|
|
@@ -54,7 +54,6 @@ export declare const moveCommandToChangeSchemasArg: (props: {
|
|
|
54
54
|
schemaId: string;
|
|
55
55
|
}[];
|
|
56
56
|
export declare const getPagesScrollTopByIndex: (pageSizes: Size[], index: number, scale: number) => number;
|
|
57
|
-
export declare const getSidebarContentHeight: (sidebarHeight: number) => number;
|
|
58
57
|
export declare const changeSchemas: (args: {
|
|
59
58
|
objs: {
|
|
60
59
|
key: string;
|
package/package.json
CHANGED
|
@@ -8,6 +8,7 @@ import type { MenuProps } from 'antd';
|
|
|
8
8
|
import { theme, Typography, Button, Dropdown } from 'antd';
|
|
9
9
|
import { I18nContext } from '../contexts.js';
|
|
10
10
|
import { useMaxZoom } from '../helper.js';
|
|
11
|
+
import { UI_CLASSNAME } from '../constants.js';
|
|
11
12
|
|
|
12
13
|
const { Text } = Typography;
|
|
13
14
|
|
|
@@ -29,6 +30,7 @@ const Zoom = ({ zoomLevel, setZoomLevel, style }: ZoomProps) => {
|
|
|
29
30
|
return (
|
|
30
31
|
<div style={{ display: 'flex', alignItems: 'center' }}>
|
|
31
32
|
<Button
|
|
33
|
+
className={UI_CLASSNAME + 'zoom-out'}
|
|
32
34
|
type="text"
|
|
33
35
|
disabled={minZoom >= nextZoomOut}
|
|
34
36
|
onClick={() => setZoomLevel(nextZoomOut)}
|
|
@@ -38,6 +40,7 @@ const Zoom = ({ zoomLevel, setZoomLevel, style }: ZoomProps) => {
|
|
|
38
40
|
{Math.round(zoomLevel * 100)}%
|
|
39
41
|
</Text>
|
|
40
42
|
<Button
|
|
43
|
+
className={UI_CLASSNAME + 'zoom-in'}
|
|
41
44
|
type="text"
|
|
42
45
|
disabled={maxZoom < nextZoomIn}
|
|
43
46
|
onClick={() => setZoomLevel(nextZoomIn)}
|
|
@@ -57,13 +60,14 @@ type PagerProps = {
|
|
|
57
60
|
const Pager = ({ pageCursor, pageNum, setPageCursor, style }: PagerProps) => {
|
|
58
61
|
return (
|
|
59
62
|
<div style={{ display: 'flex', alignItems: 'center' }}>
|
|
60
|
-
<Button type="text" disabled={pageCursor <= 0} onClick={() => setPageCursor(pageCursor - 1)}>
|
|
63
|
+
<Button className={UI_CLASSNAME + 'page-prev'} type="text" disabled={pageCursor <= 0} onClick={() => setPageCursor(pageCursor - 1)}>
|
|
61
64
|
<ChevronLeft size={16} color={style.textStyle.color} />
|
|
62
65
|
</Button>
|
|
63
66
|
<Text strong style={style.textStyle}>
|
|
64
67
|
{pageCursor + 1}/{pageNum}
|
|
65
68
|
</Text>
|
|
66
69
|
<Button
|
|
70
|
+
className={UI_CLASSNAME + 'page-next'}
|
|
67
71
|
type="text"
|
|
68
72
|
disabled={pageCursor + 1 >= pageNum}
|
|
69
73
|
onClick={() => setPageCursor(pageCursor + 1)}
|
|
@@ -80,7 +84,7 @@ type ContextMenuProps = {
|
|
|
80
84
|
};
|
|
81
85
|
const ContextMenu = ({ items, style }: ContextMenuProps) => (
|
|
82
86
|
<Dropdown menu={{ items }} placement="top" arrow trigger={['click']}>
|
|
83
|
-
<Button type="text">
|
|
87
|
+
<Button className={UI_CLASSNAME + 'context-menu'} type="text">
|
|
84
88
|
<Ellipsis size={16} color={style.textStyle.color} />
|
|
85
89
|
</Button>
|
|
86
90
|
</Dropdown>
|
|
@@ -139,6 +143,7 @@ const CtlBar = (props: CtlBarProps) => {
|
|
|
139
143
|
return (
|
|
140
144
|
<div style={{ position: 'absolute', top: 'auto', bottom: '6%', width: size.width }}>
|
|
141
145
|
<div
|
|
146
|
+
className={UI_CLASSNAME + 'control-bar'}
|
|
142
147
|
style={{
|
|
143
148
|
display: 'flex',
|
|
144
149
|
alignItems: 'center',
|
|
@@ -155,14 +160,18 @@ const CtlBar = (props: CtlBarProps) => {
|
|
|
155
160
|
}}
|
|
156
161
|
>
|
|
157
162
|
{pageNum > 1 && (
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
<div className={UI_CLASSNAME + 'pager'}>
|
|
164
|
+
<Pager
|
|
165
|
+
style={{ textStyle }}
|
|
166
|
+
pageCursor={pageCursor}
|
|
167
|
+
pageNum={pageNum}
|
|
168
|
+
setPageCursor={setPageCursor}
|
|
169
|
+
/>
|
|
170
|
+
</div>
|
|
164
171
|
)}
|
|
165
|
-
<
|
|
172
|
+
<div className={UI_CLASSNAME + 'zoom'}>
|
|
173
|
+
<Zoom style={{ textStyle }} zoomLevel={zoomLevel} setZoomLevel={setZoomLevel} />
|
|
174
|
+
</div>
|
|
166
175
|
{contextMenuItems.length > 0 && (
|
|
167
176
|
<ContextMenu items={contextMenuItems} style={{ textStyle }} />
|
|
168
177
|
)}
|
|
@@ -22,9 +22,9 @@ import {
|
|
|
22
22
|
} from '@pdfme/common';
|
|
23
23
|
import { PluginsRegistry } from '../../../contexts.js';
|
|
24
24
|
import { X } from 'lucide-react';
|
|
25
|
-
import { RULER_HEIGHT, RIGHT_SIDEBAR_WIDTH } from '../../../constants.js';
|
|
25
|
+
import { RULER_HEIGHT, RIGHT_SIDEBAR_WIDTH, DESIGNER_CLASSNAME } from '../../../constants.js';
|
|
26
26
|
import { usePrevious } from '../../../hooks.js';
|
|
27
|
-
import {
|
|
27
|
+
import { round, flatten, uuid } from '../../../helper.js';
|
|
28
28
|
import Paper from '../../Paper.js';
|
|
29
29
|
import Renderer from '../../Renderer.js';
|
|
30
30
|
import Selecto from './Selecto.js';
|
|
@@ -52,6 +52,7 @@ const DeleteButton = ({ activeElements: aes }: { activeElements: HTMLElement[] }
|
|
|
52
52
|
return (
|
|
53
53
|
<Button
|
|
54
54
|
id={DELETE_BTN_ID}
|
|
55
|
+
className={DESIGNER_CLASSNAME + 'delete-button'}
|
|
55
56
|
style={{
|
|
56
57
|
position: 'absolute',
|
|
57
58
|
zIndex: 1,
|
|
@@ -350,6 +351,7 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
|
|
|
350
351
|
|
|
351
352
|
return (
|
|
352
353
|
<div
|
|
354
|
+
className={DESIGNER_CLASSNAME + 'canvas'}
|
|
353
355
|
style={{
|
|
354
356
|
position: 'relative',
|
|
355
357
|
overflow: 'auto',
|
|
@@ -4,7 +4,7 @@ import { theme, Button } from 'antd';
|
|
|
4
4
|
import { useDraggable } from '@dnd-kit/core';
|
|
5
5
|
import { CSS } from '@dnd-kit/utilities';
|
|
6
6
|
import Renderer from '../Renderer.js';
|
|
7
|
-
import { LEFT_SIDEBAR_WIDTH } from '../../constants.js';
|
|
7
|
+
import { LEFT_SIDEBAR_WIDTH, DESIGNER_CLASSNAME } from '../../constants.js';
|
|
8
8
|
import { setFontNameRecursively } from '../../helper';
|
|
9
9
|
import { OptionsContext, PluginsRegistry } from '../../contexts.js';
|
|
10
10
|
import PluginIcon from './PluginIcon.js';
|
|
@@ -83,6 +83,7 @@ const LeftSidebar = ({
|
|
|
83
83
|
|
|
84
84
|
return (
|
|
85
85
|
<div
|
|
86
|
+
className={DESIGNER_CLASSNAME + 'left-sidebar'}
|
|
86
87
|
style={{
|
|
87
88
|
left: 0,
|
|
88
89
|
right: 0,
|
|
@@ -98,9 +99,12 @@ const LeftSidebar = ({
|
|
|
98
99
|
{pluginsRegistry.entries().map(([label, plugin]) => {
|
|
99
100
|
if (!plugin?.propPanel.defaultSchema) return null;
|
|
100
101
|
|
|
102
|
+
const pluginType = plugin.propPanel.defaultSchema.type;
|
|
103
|
+
|
|
101
104
|
return (
|
|
102
105
|
<Draggable key={label} scale={scale} basePdf={basePdf} plugin={plugin}>
|
|
103
106
|
<Button
|
|
107
|
+
className={DESIGNER_CLASSNAME + 'plugin-' + pluginType}
|
|
104
108
|
onMouseDown={() => setIsDragging(true)}
|
|
105
109
|
style={{ width: 35, height: 35, marginTop: '0.25rem', padding: '0.25rem' }}
|
|
106
110
|
>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Space, Button, Form } from 'antd';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { PropPanelWidgetProps } from '@pdfme/common';
|
|
4
|
+
import { DESIGNER_CLASSNAME } from '../../../../constants.js';
|
|
4
5
|
import {
|
|
5
6
|
AlignStartVertical,
|
|
6
7
|
AlignStartHorizontal,
|
|
@@ -213,6 +214,7 @@ const AlignWidget = (props: PropPanelWidgetProps) => {
|
|
|
213
214
|
<Space.Compact>
|
|
214
215
|
{layoutBtns.map((btn) => (
|
|
215
216
|
<Button
|
|
217
|
+
className={DESIGNER_CLASSNAME + 'align-' + btn.id}
|
|
216
218
|
key={btn.id}
|
|
217
219
|
style={{ padding: 7 }}
|
|
218
220
|
disabled={activeElements.length <= 2 && ['vertical', 'horizontal'].includes(btn.id)}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useForm } from 'form-render';
|
|
2
|
-
import React, { useRef, useContext, useState, useEffect } from 'react';
|
|
2
|
+
import React, { useRef, useContext, useState, useEffect, useCallback } from 'react';
|
|
3
3
|
import type {
|
|
4
4
|
Dict,
|
|
5
5
|
ChangeSchemaItem,
|
|
@@ -12,12 +12,14 @@ import { isBlankPdf } from '@pdfme/common';
|
|
|
12
12
|
import type { SidebarProps } from '../../../../types.js';
|
|
13
13
|
import { Menu } from 'lucide-react';
|
|
14
14
|
import { I18nContext, PluginsRegistry, OptionsContext } from '../../../../contexts.js';
|
|
15
|
-
import {
|
|
15
|
+
import { debounce } from '../../../../helper.js';
|
|
16
|
+
import { DESIGNER_CLASSNAME } from '../../../../constants.js';
|
|
16
17
|
import { theme, Typography, Button, Divider } from 'antd';
|
|
17
18
|
import AlignWidget from './AlignWidget.js';
|
|
18
19
|
import WidgetRenderer from './WidgetRenderer.js';
|
|
19
20
|
import ButtonGroupWidget from './ButtonGroupWidget.js';
|
|
20
21
|
import { InternalNamePath, ValidateErrorEntity } from 'rc-field-form/es/interface.js';
|
|
22
|
+
import { SidebarBody, SidebarFrame, SidebarHeader, SIDEBAR_H_PADDING_PX } from '../layout.js';
|
|
21
23
|
|
|
22
24
|
// Import FormRender as a default import
|
|
23
25
|
import FormRenderComponent from 'form-render';
|
|
@@ -41,8 +43,7 @@ type DetailViewProps = Pick<
|
|
|
41
43
|
const DetailView = (props: DetailViewProps) => {
|
|
42
44
|
const { token } = theme.useToken();
|
|
43
45
|
|
|
44
|
-
const {
|
|
45
|
-
props;
|
|
46
|
+
const { schemasList, changeSchemas, deselectSchema, activeSchema, pageSize, basePdf } = props;
|
|
46
47
|
const form = useForm();
|
|
47
48
|
|
|
48
49
|
const i18n = useContext(I18nContext);
|
|
@@ -50,10 +51,13 @@ const DetailView = (props: DetailViewProps) => {
|
|
|
50
51
|
const options = useContext(OptionsContext);
|
|
51
52
|
|
|
52
53
|
// Define a type-safe i18n function that accepts string keys
|
|
53
|
-
const typedI18n = (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
const typedI18n = useCallback(
|
|
55
|
+
(key: string): string => {
|
|
56
|
+
// Use a type assertion to handle the union type constraint
|
|
57
|
+
return typeof i18n === 'function' ? i18n(key as keyof Dict) : key;
|
|
58
|
+
},
|
|
59
|
+
[i18n],
|
|
60
|
+
);
|
|
57
61
|
|
|
58
62
|
const [widgets, setWidgets] = useState<{
|
|
59
63
|
[key: string]: (props: PropPanelWidgetProps) => React.JSX.Element;
|
|
@@ -83,7 +87,7 @@ const DetailView = (props: DetailViewProps) => {
|
|
|
83
87
|
});
|
|
84
88
|
}
|
|
85
89
|
setWidgets(newWidgets);
|
|
86
|
-
}, [activeSchema, pluginsRegistry,
|
|
90
|
+
}, [activeSchema, options, pluginsRegistry, props, token, typedI18n]);
|
|
87
91
|
|
|
88
92
|
useEffect(() => {
|
|
89
93
|
// Create a type-safe copy of the schema with editable property
|
|
@@ -94,7 +98,7 @@ const DetailView = (props: DetailViewProps) => {
|
|
|
94
98
|
form.setValues(values);
|
|
95
99
|
}, [activeSchema, form]);
|
|
96
100
|
|
|
97
|
-
useEffect(() => form.resetFields(), [activeSchema.id]);
|
|
101
|
+
useEffect(() => form.resetFields(), [activeSchema.id, form]);
|
|
98
102
|
|
|
99
103
|
useEffect(() => {
|
|
100
104
|
uniqueSchemaName.current = (value: string): boolean => {
|
|
@@ -423,15 +427,20 @@ const DetailView = (props: DetailViewProps) => {
|
|
|
423
427
|
}
|
|
424
428
|
|
|
425
429
|
return (
|
|
426
|
-
<
|
|
427
|
-
<
|
|
430
|
+
<SidebarFrame className={DESIGNER_CLASSNAME + 'detail-view'}>
|
|
431
|
+
<SidebarHeader>
|
|
428
432
|
<Button
|
|
433
|
+
className={DESIGNER_CLASSNAME + 'back-button'}
|
|
429
434
|
style={{
|
|
430
435
|
position: 'absolute',
|
|
436
|
+
left: SIDEBAR_H_PADDING_PX,
|
|
431
437
|
zIndex: 100,
|
|
432
438
|
display: 'flex',
|
|
433
439
|
alignItems: 'center',
|
|
434
440
|
justifyContent: 'center',
|
|
441
|
+
transform: 'translateY(-50%)',
|
|
442
|
+
top: '50%',
|
|
443
|
+
paddingTop: '3px',
|
|
435
444
|
}}
|
|
436
445
|
onClick={deselectSchema}
|
|
437
446
|
icon={<Menu strokeWidth={1.5} size={20} />}
|
|
@@ -439,15 +448,8 @@ const DetailView = (props: DetailViewProps) => {
|
|
|
439
448
|
<Text strong style={{ textAlign: 'center', width: '100%' }}>
|
|
440
449
|
{typedI18n('editField')}
|
|
441
450
|
</Text>
|
|
442
|
-
</
|
|
443
|
-
<
|
|
444
|
-
<div
|
|
445
|
-
style={{
|
|
446
|
-
height: getSidebarContentHeight(size.height),
|
|
447
|
-
overflowY: 'auto',
|
|
448
|
-
overflowX: 'hidden',
|
|
449
|
-
}}
|
|
450
|
-
>
|
|
451
|
+
</SidebarHeader>
|
|
452
|
+
<SidebarBody>
|
|
451
453
|
<FormRenderComponent
|
|
452
454
|
form={form}
|
|
453
455
|
schema={propPanelSchema}
|
|
@@ -455,8 +457,8 @@ const DetailView = (props: DetailViewProps) => {
|
|
|
455
457
|
watch={{ '#': handleWatch }}
|
|
456
458
|
locale="en-US"
|
|
457
459
|
/>
|
|
458
|
-
</
|
|
459
|
-
</
|
|
460
|
+
</SidebarBody>
|
|
461
|
+
</SidebarFrame>
|
|
460
462
|
);
|
|
461
463
|
};
|
|
462
464
|
|
|
@@ -135,29 +135,27 @@ const SelectableSortableContainer = (
|
|
|
135
135
|
}}
|
|
136
136
|
>
|
|
137
137
|
<>
|
|
138
|
-
<
|
|
139
|
-
<
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
</SortableContext>
|
|
160
|
-
</div>
|
|
138
|
+
<SortableContext items={schemas} strategy={verticalListSortingStrategy}>
|
|
139
|
+
<ul style={{ margin: 0, padding: 0, listStyle: 'none', borderRadius: 5 }}>
|
|
140
|
+
{schemas.map((schema) => (
|
|
141
|
+
<SelectableSortableItem
|
|
142
|
+
key={schema.id}
|
|
143
|
+
style={{
|
|
144
|
+
border: `1px solid ${
|
|
145
|
+
schema.id === hoveringSchemaId ? token.colorPrimary : 'transparent'
|
|
146
|
+
}`,
|
|
147
|
+
}}
|
|
148
|
+
schema={schema}
|
|
149
|
+
schemas={schemas}
|
|
150
|
+
isSelected={isItemSelected(schema.id) || activeId === schema.id}
|
|
151
|
+
onEdit={onEdit}
|
|
152
|
+
onSelect={onSelectionChanged}
|
|
153
|
+
onMouseEnter={() => onChangeHoveringSchemaId(schema.id)}
|
|
154
|
+
onMouseLeave={() => onChangeHoveringSchemaId(null)}
|
|
155
|
+
/>
|
|
156
|
+
))}
|
|
157
|
+
</ul>
|
|
158
|
+
</SortableContext>
|
|
161
159
|
{createPortal(
|
|
162
160
|
<DragOverlay adjustScale>
|
|
163
161
|
{activeId
|
|
@@ -1,42 +1,30 @@
|
|
|
1
1
|
import React, { useContext, useState } from 'react';
|
|
2
2
|
import type { SidebarProps } from '../../../../types.js';
|
|
3
|
-
import {
|
|
3
|
+
import { DESIGNER_CLASSNAME } from '../../../../constants.js';
|
|
4
4
|
import { I18nContext } from '../../../../contexts.js';
|
|
5
|
-
import {
|
|
6
|
-
import { theme, Input, Typography, Divider, Button } from 'antd';
|
|
5
|
+
import { Input, Typography, Button } from 'antd';
|
|
7
6
|
import SelectableSortableContainer from './SelectableSortableContainer.js';
|
|
7
|
+
import { SidebarBody, SidebarFooter, SidebarFrame, SidebarHeader } from '../layout.js';
|
|
8
8
|
|
|
9
9
|
const { Text } = Typography;
|
|
10
10
|
const { TextArea } = Input;
|
|
11
11
|
|
|
12
|
-
const headHeight = 40;
|
|
13
|
-
|
|
14
12
|
const ListView = (
|
|
15
13
|
props: Pick<
|
|
16
14
|
SidebarProps,
|
|
17
15
|
| 'schemas'
|
|
18
16
|
| 'onSortEnd'
|
|
19
17
|
| 'onEdit'
|
|
20
|
-
| 'size'
|
|
21
18
|
| 'hoveringSchemaId'
|
|
22
19
|
| 'onChangeHoveringSchemaId'
|
|
23
20
|
| 'changeSchemas'
|
|
24
21
|
>,
|
|
25
22
|
) => {
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
onSortEnd,
|
|
29
|
-
onEdit,
|
|
30
|
-
size,
|
|
31
|
-
hoveringSchemaId,
|
|
32
|
-
onChangeHoveringSchemaId,
|
|
33
|
-
changeSchemas,
|
|
34
|
-
} = props;
|
|
35
|
-
const { token } = theme.useToken();
|
|
23
|
+
const { schemas, onSortEnd, onEdit, hoveringSchemaId, onChangeHoveringSchemaId, changeSchemas } =
|
|
24
|
+
props;
|
|
36
25
|
const i18n = useContext(I18nContext);
|
|
37
26
|
const [isBulkUpdateFieldNamesMode, setIsBulkUpdateFieldNamesMode] = useState(false);
|
|
38
27
|
const [fieldNamesValue, setFieldNamesValue] = useState('');
|
|
39
|
-
const height = getSidebarContentHeight(size.height);
|
|
40
28
|
|
|
41
29
|
const commitBulk = () => {
|
|
42
30
|
const names = fieldNamesValue.split('\n');
|
|
@@ -60,23 +48,22 @@ const ListView = (
|
|
|
60
48
|
};
|
|
61
49
|
|
|
62
50
|
return (
|
|
63
|
-
<
|
|
64
|
-
<
|
|
51
|
+
<SidebarFrame className={DESIGNER_CLASSNAME + 'list-view'}>
|
|
52
|
+
<SidebarHeader>
|
|
65
53
|
<Text strong style={{ textAlign: 'center', width: '100%' }}>
|
|
66
54
|
{i18n('fieldsList')}
|
|
67
55
|
</Text>
|
|
68
|
-
</
|
|
69
|
-
<
|
|
70
|
-
<div style={{ height: height - headHeight }}>
|
|
56
|
+
</SidebarHeader>
|
|
57
|
+
<SidebarBody>
|
|
71
58
|
{isBulkUpdateFieldNamesMode ? (
|
|
72
59
|
<TextArea
|
|
73
60
|
wrap="off"
|
|
74
61
|
value={fieldNamesValue}
|
|
75
62
|
onChange={(e) => setFieldNamesValue(e.target.value)}
|
|
76
63
|
style={{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
64
|
+
height: '100%',
|
|
65
|
+
width: '100%',
|
|
66
|
+
resize: 'none',
|
|
80
67
|
lineHeight: '2.75rem',
|
|
81
68
|
}}
|
|
82
69
|
/>
|
|
@@ -89,32 +76,40 @@ const ListView = (
|
|
|
89
76
|
onEdit={onEdit}
|
|
90
77
|
/>
|
|
91
78
|
)}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
<u> {i18n('bulkUpdateFieldName')}</u>
|
|
79
|
+
</SidebarBody>
|
|
80
|
+
<SidebarFooter>
|
|
81
|
+
{isBulkUpdateFieldNamesMode ? (
|
|
82
|
+
<>
|
|
83
|
+
<Button
|
|
84
|
+
className={DESIGNER_CLASSNAME + 'bulk-commit'}
|
|
85
|
+
size="small"
|
|
86
|
+
type="text"
|
|
87
|
+
onClick={commitBulk}
|
|
88
|
+
>
|
|
89
|
+
<u> {i18n('commitBulkUpdateFieldName')}</u>
|
|
90
|
+
</Button>
|
|
91
|
+
<span>/</span>
|
|
92
|
+
<Button
|
|
93
|
+
className={DESIGNER_CLASSNAME + 'bulk-cancel'}
|
|
94
|
+
size="small"
|
|
95
|
+
type="text"
|
|
96
|
+
onClick={() => setIsBulkUpdateFieldNamesMode(false)}
|
|
97
|
+
>
|
|
98
|
+
<u> {i18n('cancel')}</u>
|
|
113
99
|
</Button>
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
100
|
+
</>
|
|
101
|
+
) : (
|
|
102
|
+
<Button
|
|
103
|
+
className={DESIGNER_CLASSNAME + 'bulk-update'}
|
|
104
|
+
size="small"
|
|
105
|
+
type="text"
|
|
106
|
+
onClick={startBulk}
|
|
107
|
+
>
|
|
108
|
+
<u> {i18n('bulkUpdateFieldName')}</u>
|
|
109
|
+
</Button>
|
|
110
|
+
)}
|
|
111
|
+
</SidebarFooter>
|
|
112
|
+
</SidebarFrame>
|
|
118
113
|
);
|
|
119
114
|
};
|
|
120
115
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { theme, Button } from 'antd';
|
|
3
3
|
import type { SidebarProps } from '../../../types.js';
|
|
4
|
-
import { RIGHT_SIDEBAR_WIDTH } from '../../../constants.js';
|
|
4
|
+
import { RIGHT_SIDEBAR_WIDTH, DESIGNER_CLASSNAME } from '../../../constants.js';
|
|
5
5
|
import { ArrowLeft, ArrowRight } from 'lucide-react';
|
|
6
6
|
import ListView from './ListView/index.js';
|
|
7
7
|
import DetailView from './DetailView/index.js';
|
|
@@ -21,6 +21,7 @@ const Sidebar = (props: SidebarProps) => {
|
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
23
|
<div
|
|
24
|
+
className={DESIGNER_CLASSNAME + 'right-sidebar'}
|
|
24
25
|
style={{
|
|
25
26
|
position: 'absolute',
|
|
26
27
|
right: 0,
|
|
@@ -29,43 +30,40 @@ const Sidebar = (props: SidebarProps) => {
|
|
|
29
30
|
width: sidebarOpen ? RIGHT_SIDEBAR_WIDTH : 0,
|
|
30
31
|
}}
|
|
31
32
|
>
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
)}
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
33
|
+
<Button
|
|
34
|
+
className={DESIGNER_CLASSNAME + 'sidebar-toggle'}
|
|
35
|
+
style={{
|
|
36
|
+
position: 'absolute',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
justifyContent: 'center',
|
|
40
|
+
top: '14px',
|
|
41
|
+
right: '16px',
|
|
42
|
+
paddingTop: '2px',
|
|
43
|
+
zIndex: 100,
|
|
44
|
+
}}
|
|
45
|
+
icon={sidebarOpen ? <ArrowRight {...iconProps} /> : <ArrowLeft {...iconProps} />}
|
|
46
|
+
onClick={() => setSidebarOpen(!sidebarOpen)}
|
|
47
|
+
/>
|
|
48
|
+
<div
|
|
49
|
+
style={{
|
|
50
|
+
width: RIGHT_SIDEBAR_WIDTH,
|
|
51
|
+
height: '100%',
|
|
52
|
+
display: sidebarOpen ? 'flex' : 'none',
|
|
53
|
+
top: 0,
|
|
54
|
+
right: 0,
|
|
55
|
+
position: 'absolute',
|
|
56
|
+
fontFamily: "'Open Sans', sans-serif",
|
|
57
|
+
boxSizing: 'border-box',
|
|
58
|
+
background: token.colorBgLayout,
|
|
59
|
+
borderLeft: `1px solid ${token.colorSplit}`,
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
{getActiveSchemas().length === 0 ? (
|
|
63
|
+
<ListView {...props} />
|
|
64
|
+
) : (
|
|
65
|
+
<DetailView {...props} activeSchema={getLastActiveSchema()} />
|
|
66
|
+
)}
|
|
69
67
|
</div>
|
|
70
68
|
</div>
|
|
71
69
|
);
|