@pdfme/ui 5.3.8-dev.57 → 5.3.8-dev.59
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 +33115 -31437
- package/dist/index.umd.js +427 -387
- package/dist/types/src/components/Designer/LeftSidebar.d.ts +1 -1
- package/dist/types/src/components/Designer/PluginIcon.d.ts +1 -1
- package/package.json +2 -2
- package/src/Designer.tsx +4 -4
- package/src/Form.tsx +1 -3
- package/src/Viewer.tsx +1 -1
- package/src/components/AppContextProvider.tsx +1 -1
- package/src/components/CtlBar.tsx +1 -1
- package/src/components/Designer/Canvas/Guides.tsx +1 -1
- package/src/components/Designer/Canvas/Moveable.tsx +2 -2
- package/src/components/Designer/Canvas/Padding.tsx +10 -8
- package/src/components/Designer/Canvas/index.tsx +27 -14
- package/src/components/Designer/LeftSidebar.tsx +57 -49
- package/src/components/Designer/PluginIcon.tsx +21 -8
- package/src/components/Designer/RightSidebar/DetailView/AlignWidget.tsx +44 -44
- package/src/components/Designer/RightSidebar/DetailView/ButtonGroupWidget.tsx +3 -3
- package/src/components/Designer/RightSidebar/DetailView/index.tsx +51 -23
- package/src/components/Designer/RightSidebar/ListView/Item.tsx +4 -4
- package/src/components/Designer/RightSidebar/ListView/SelectableSortableContainer.tsx +56 -47
- package/src/components/Designer/RightSidebar/ListView/SelectableSortableItem.tsx +2 -3
- package/src/components/Designer/RightSidebar/ListView/index.tsx +10 -3
- package/src/components/Designer/index.tsx +41 -19
- package/src/components/Preview.tsx +25 -14
- package/src/components/Renderer.tsx +35 -22
- package/src/components/Root.tsx +1 -1
- package/src/components/Spinner.tsx +1 -1
- package/src/components/StaticSchema.tsx +39 -21
- package/src/constants.ts +1 -1
- package/src/helper.ts +7 -7
- package/src/hooks.ts +3 -3
- package/src/types/react-guides.d.ts +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pdfme/ui",
|
3
|
-
"version": "5.3.8-dev.
|
3
|
+
"version": "5.3.8-dev.59",
|
4
4
|
"sideEffects": false,
|
5
5
|
"author": "hand-dot",
|
6
6
|
"license": "MIT",
|
@@ -46,7 +46,7 @@
|
|
46
46
|
"lucide-react": "^0.460.0",
|
47
47
|
"react": "^16.14.0",
|
48
48
|
"react-dom": "^16.14.0",
|
49
|
-
"react-moveable": "^0.
|
49
|
+
"react-moveable": "^0.56.0",
|
50
50
|
"react-selecto": "^1.12.0"
|
51
51
|
},
|
52
52
|
"devDependencies": {
|
package/src/Designer.tsx
CHANGED
@@ -47,9 +47,9 @@ class Designer extends BaseUIClass {
|
|
47
47
|
public onChangeTemplate(cb: (template: Template) => void) {
|
48
48
|
this.onChangeTemplateCallback = cb;
|
49
49
|
}
|
50
|
-
|
50
|
+
|
51
51
|
public getPageCursor() {
|
52
|
-
return this.pageCursor
|
52
|
+
return this.pageCursor;
|
53
53
|
}
|
54
54
|
|
55
55
|
protected render() {
|
@@ -78,12 +78,12 @@ class Designer extends BaseUIClass {
|
|
78
78
|
}
|
79
79
|
}}
|
80
80
|
onPageCursorChange={(newPageCursor: number) => {
|
81
|
-
this.pageCursor = newPageCursor
|
81
|
+
this.pageCursor = newPageCursor;
|
82
82
|
}}
|
83
83
|
size={this.size}
|
84
84
|
/>
|
85
85
|
</AppContextProvider>,
|
86
|
-
this.domContainer
|
86
|
+
this.domContainer,
|
87
87
|
);
|
88
88
|
}
|
89
89
|
}
|
package/src/Form.tsx
CHANGED
@@ -46,8 +46,6 @@ class Form extends PreviewUI {
|
|
46
46
|
});
|
47
47
|
}
|
48
48
|
|
49
|
-
|
50
|
-
|
51
49
|
protected render() {
|
52
50
|
if (!this.domContainer) throw Error(DESTROYED_ERR_MSG);
|
53
51
|
ReactDOM.render(
|
@@ -75,7 +73,7 @@ class Form extends PreviewUI {
|
|
75
73
|
}}
|
76
74
|
/>
|
77
75
|
</AppContextProvider>,
|
78
|
-
this.domContainer
|
76
|
+
this.domContainer,
|
79
77
|
);
|
80
78
|
}
|
81
79
|
}
|
package/src/Viewer.tsx
CHANGED
@@ -7,7 +7,7 @@ import { Plus, Minus, ChevronLeft, ChevronRight, Ellipsis } from 'lucide-react';
|
|
7
7
|
import type { MenuProps } from 'antd';
|
8
8
|
import { theme, Typography, Button, Dropdown } from 'antd';
|
9
9
|
import { I18nContext } from '../contexts.js';
|
10
|
-
import { getMaxZoom } from
|
10
|
+
import { getMaxZoom } from '../helper.js';
|
11
11
|
|
12
12
|
const { Text } = Typography;
|
13
13
|
|
@@ -86,12 +86,12 @@ const _Moveable = (props: Props, ref: Ref<any>) => {
|
|
86
86
|
useEffect(() => {
|
87
87
|
const containerElement = document.querySelector(`.${className}`) as HTMLElement | null;
|
88
88
|
const containerElement2 = document.querySelectorAll(
|
89
|
-
`.${className} .moveable-line
|
89
|
+
`.${className} .moveable-line`,
|
90
90
|
) as NodeListOf<HTMLElement>;
|
91
91
|
if (containerElement) {
|
92
92
|
containerElement.style.setProperty('--moveable-color', token.colorPrimary);
|
93
93
|
Array.from(containerElement2).map((e) =>
|
94
|
-
e.style.setProperty('--moveable-color', token.colorPrimary)
|
94
|
+
e.style.setProperty('--moveable-color', token.colorPrimary),
|
95
95
|
);
|
96
96
|
}
|
97
97
|
}, [props.target]);
|
@@ -43,12 +43,14 @@ const getPaddingStyle = (i: number, p: number, color: string): CSS.Properties =>
|
|
43
43
|
};
|
44
44
|
|
45
45
|
const Padding = ({ basePdf }: { basePdf: BasePdf }) => {
|
46
|
-
return
|
47
|
-
|
48
|
-
basePdf
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
46
|
+
return (
|
47
|
+
<>
|
48
|
+
{isBlankPdf(basePdf) &&
|
49
|
+
basePdf.padding.map((p, i) => (
|
50
|
+
<div key={String(i)} style={getPaddingStyle(i, p, theme.useToken().token.colorError)} />
|
51
|
+
))}
|
52
|
+
</>
|
53
|
+
);
|
54
|
+
};
|
53
55
|
|
54
|
-
export default Padding;
|
56
|
+
export default Padding;
|
@@ -10,7 +10,15 @@ import React, {
|
|
10
10
|
useCallback,
|
11
11
|
} from 'react';
|
12
12
|
import { theme, Button } from 'antd';
|
13
|
-
import {
|
13
|
+
import {
|
14
|
+
ZOOM,
|
15
|
+
SchemaForUI,
|
16
|
+
Size,
|
17
|
+
ChangeSchemas,
|
18
|
+
BasePdf,
|
19
|
+
isBlankPdf,
|
20
|
+
replacePlaceholders,
|
21
|
+
} from '@pdfme/common';
|
14
22
|
import { PluginsRegistry } from '../../../contexts.js';
|
15
23
|
import { X } from 'lucide-react';
|
16
24
|
import { RULER_HEIGHT, RIGHT_SIDEBAR_WIDTH } from '../../../constants.js';
|
@@ -81,7 +89,6 @@ interface OnClick {
|
|
81
89
|
|
82
90
|
const mm2px = (mm: number) => mm * 3.7795275591;
|
83
91
|
|
84
|
-
|
85
92
|
const DELETE_BTN_ID = uuid();
|
86
93
|
const fmt4Num = (prop: string) => Number(prop.replace('px', ''));
|
87
94
|
const fmt = (prop: string) => round(fmt4Num(prop) / ZOOM, 2);
|
@@ -373,16 +380,16 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
|
|
373
380
|
|
374
381
|
const rotatable = useMemo(() => {
|
375
382
|
const selectedSchemas = (schemasList[pageCursor] || []).filter((s) =>
|
376
|
-
activeElements.map((ae) => ae.id).includes(s.id)
|
383
|
+
activeElements.map((ae) => ae.id).includes(s.id),
|
377
384
|
);
|
378
385
|
const schemaTypes = selectedSchemas.map((s) => s.type);
|
379
386
|
const uniqueSchemaTypes = [...new Set(schemaTypes)];
|
380
387
|
const defaultSchemas = Object.values(pluginsRegistry).map(
|
381
|
-
(plugin) => plugin?.propPanel.defaultSchema
|
388
|
+
(plugin) => plugin?.propPanel.defaultSchema,
|
382
389
|
);
|
383
390
|
|
384
391
|
return uniqueSchemaTypes.every(
|
385
|
-
(type) => defaultSchemas.find((ds) => ds.type === type)?.rotate !== undefined
|
392
|
+
(type) => defaultSchemas.find((ds) => ds.type === type)?.rotate !== undefined,
|
386
393
|
);
|
387
394
|
}, [activeElements, pageCursor, schemasList, pluginsRegistry]);
|
388
395
|
|
@@ -452,7 +459,7 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
|
|
452
459
|
<StaticSchema
|
453
460
|
template={{ schemas: schemasList, basePdf }}
|
454
461
|
input={Object.fromEntries(
|
455
|
-
schemasList.flat().map(({ name, content = '' }) => [name, content])
|
462
|
+
schemasList.flat().map(({ name, content = '' }) => [name, content]),
|
456
463
|
)}
|
457
464
|
scale={scale}
|
458
465
|
totalPages={schemasList.length}
|
@@ -501,17 +508,20 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
|
|
501
508
|
const mode =
|
502
509
|
editing && activeElements.map((ae) => ae.id).includes(schema.id)
|
503
510
|
? 'designer'
|
504
|
-
: 'viewer'
|
511
|
+
: 'viewer';
|
505
512
|
|
506
513
|
const content = schema.content || '';
|
507
514
|
let value = content;
|
508
515
|
|
509
516
|
if (mode !== 'designer' && schema.readOnly) {
|
510
517
|
const variables = {
|
511
|
-
...schemasList.flat().reduce(
|
512
|
-
acc
|
513
|
-
|
514
|
-
|
518
|
+
...schemasList.flat().reduce(
|
519
|
+
(acc, currSchema) => {
|
520
|
+
acc[currSchema.name] = currSchema.content || '';
|
521
|
+
return acc;
|
522
|
+
},
|
523
|
+
{} as Record<string, string>,
|
524
|
+
),
|
515
525
|
totalPages: schemasList.length,
|
516
526
|
currentPage: index + 1,
|
517
527
|
};
|
@@ -532,11 +542,14 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
|
|
532
542
|
changeSchemas(args.map(({ key, value }) => ({ key, value, schemaId: schema.id })));
|
533
543
|
}}
|
534
544
|
stopEditing={() => setEditing(false)}
|
535
|
-
outline={`1px ${hoveringSchemaId === schema.id ? 'solid' : 'dashed'} ${
|
536
|
-
|
545
|
+
outline={`1px ${hoveringSchemaId === schema.id ? 'solid' : 'dashed'} ${
|
546
|
+
schema.readOnly && hoveringSchemaId !== schema.id
|
547
|
+
? 'transparent'
|
548
|
+
: token.colorPrimary
|
549
|
+
}`}
|
537
550
|
scale={scale}
|
538
551
|
/>
|
539
|
-
)
|
552
|
+
);
|
540
553
|
}}
|
541
554
|
/>
|
542
555
|
</div>
|
@@ -1,49 +1,57 @@
|
|
1
1
|
import React, { useContext, useState, useEffect } from 'react';
|
2
|
-
import {
|
3
|
-
Schema,
|
4
|
-
Plugin,
|
5
|
-
BasePdf,
|
6
|
-
} from '@pdfme/common';
|
2
|
+
import { Schema, Plugin, BasePdf } from '@pdfme/common';
|
7
3
|
import { theme, Button } from 'antd';
|
8
4
|
import { useDraggable } from '@dnd-kit/core';
|
9
|
-
import { CSS } from
|
5
|
+
import { CSS } from '@dnd-kit/utilities';
|
10
6
|
import Renderer from '../Renderer.js';
|
11
7
|
import { LEFT_SIDEBAR_WIDTH } from '../../constants.js';
|
12
8
|
import { PluginsRegistry } from '../../contexts.js';
|
13
|
-
import PluginIcon from
|
9
|
+
import PluginIcon from './PluginIcon.js';
|
14
10
|
|
15
|
-
|
16
|
-
|
11
|
+
const Draggable = (props: {
|
12
|
+
plugin: Plugin<any>;
|
13
|
+
scale: number;
|
14
|
+
basePdf: BasePdf;
|
15
|
+
children: React.ReactNode;
|
16
|
+
}) => {
|
17
17
|
const { scale, basePdf, plugin } = props;
|
18
18
|
const { token } = theme.useToken();
|
19
19
|
const defaultSchema = plugin.propPanel.defaultSchema as Schema;
|
20
20
|
const draggable = useDraggable({ id: defaultSchema.type, data: defaultSchema });
|
21
21
|
const { listeners, setNodeRef, attributes, transform, isDragging } = draggable;
|
22
|
-
const style = { transform: CSS.Translate.toString(transform) }
|
22
|
+
const style = { transform: CSS.Translate.toString(transform) };
|
23
23
|
|
24
24
|
return (
|
25
25
|
<div ref={setNodeRef} style={style} {...listeners} {...attributes}>
|
26
|
-
{isDragging &&
|
26
|
+
{isDragging && (
|
27
27
|
<div style={{ transform: `scale(${scale})` }}>
|
28
28
|
<Renderer
|
29
29
|
schema={{ ...defaultSchema, id: defaultSchema.type }}
|
30
30
|
basePdf={basePdf}
|
31
31
|
value={defaultSchema.content || ''}
|
32
|
-
onChangeHoveringSchemaId={() => {
|
32
|
+
onChangeHoveringSchemaId={() => {
|
33
|
+
void 0;
|
34
|
+
}}
|
33
35
|
mode={'viewer'}
|
34
36
|
outline={`1px solid ${token.colorPrimary}`}
|
35
37
|
scale={scale}
|
36
38
|
/>
|
37
39
|
</div>
|
38
|
-
}
|
39
|
-
<div style={{ visibility: isDragging ? 'hidden' : 'visible' }}>
|
40
|
-
{props.children}
|
41
|
-
</div>
|
40
|
+
)}
|
41
|
+
<div style={{ visibility: isDragging ? 'hidden' : 'visible' }}>{props.children}</div>
|
42
42
|
</div>
|
43
43
|
);
|
44
|
-
}
|
44
|
+
};
|
45
45
|
|
46
|
-
const LeftSidebar = ({
|
46
|
+
const LeftSidebar = ({
|
47
|
+
height,
|
48
|
+
scale,
|
49
|
+
basePdf,
|
50
|
+
}: {
|
51
|
+
height: number;
|
52
|
+
scale: number;
|
53
|
+
basePdf: BasePdf;
|
54
|
+
}) => {
|
47
55
|
const { token } = theme.useToken();
|
48
56
|
const pluginsRegistry = useContext(PluginsRegistry);
|
49
57
|
const [isDragging, setIsDragging] = useState(false);
|
@@ -62,36 +70,36 @@ const LeftSidebar = ({ height, scale, basePdf }: { height: number, scale: number
|
|
62
70
|
};
|
63
71
|
}, [isDragging]);
|
64
72
|
|
65
|
-
return
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
73
|
+
return (
|
74
|
+
<div
|
75
|
+
style={{
|
76
|
+
left: 0,
|
77
|
+
right: 0,
|
78
|
+
position: 'absolute',
|
79
|
+
zIndex: 1,
|
80
|
+
height,
|
81
|
+
width: LEFT_SIDEBAR_WIDTH,
|
82
|
+
background: token.colorBgLayout,
|
83
|
+
textAlign: 'center',
|
84
|
+
overflow: isDragging ? 'visible' : 'auto',
|
85
|
+
}}
|
86
|
+
>
|
87
|
+
{Object.entries(pluginsRegistry).map(([label, plugin]) => {
|
88
|
+
if (!plugin?.propPanel.defaultSchema) return null;
|
80
89
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
}
|
90
|
+
return (
|
91
|
+
<Draggable key={label} scale={scale} basePdf={basePdf} plugin={plugin}>
|
92
|
+
<Button
|
93
|
+
onMouseDown={() => setIsDragging(true)}
|
94
|
+
style={{ width: 35, height: 35, marginTop: '0.25rem', padding: '0.25rem' }}
|
95
|
+
>
|
96
|
+
<PluginIcon plugin={plugin} label={label} />
|
97
|
+
</Button>
|
98
|
+
</Draggable>
|
99
|
+
);
|
100
|
+
})}
|
101
|
+
</div>
|
102
|
+
);
|
103
|
+
};
|
96
104
|
|
97
|
-
export default LeftSidebar
|
105
|
+
export default LeftSidebar;
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import React, { useContext } from 'react';
|
2
|
-
import { Plugin } from
|
2
|
+
import { Plugin } from '@pdfme/common';
|
3
3
|
import { OptionsContext } from '../../contexts.js';
|
4
4
|
import { theme } from 'antd';
|
5
5
|
|
6
|
-
|
7
6
|
interface PluginIconProps {
|
8
7
|
plugin: Plugin<any>;
|
9
8
|
label: string;
|
@@ -11,7 +10,12 @@ interface PluginIconProps {
|
|
11
10
|
styles?: React.CSSProperties;
|
12
11
|
}
|
13
12
|
|
14
|
-
const getWithModifiedSize = (
|
13
|
+
const getWithModifiedSize = (
|
14
|
+
htmlString: string,
|
15
|
+
label: string,
|
16
|
+
size: number,
|
17
|
+
styles?: React.CSSProperties,
|
18
|
+
) => {
|
15
19
|
const parser = new DOMParser();
|
16
20
|
const doc = parser.parseFromString(htmlString, 'text/html');
|
17
21
|
|
@@ -20,10 +24,10 @@ const getWithModifiedSize = (htmlString: string, label: string, size: number, st
|
|
20
24
|
node.setAttribute('width', size.toString());
|
21
25
|
node.setAttribute('height', size.toString());
|
22
26
|
}
|
23
|
-
Array.from(node.children).forEach(child => modifyNode(child as HTMLElement));
|
27
|
+
Array.from(node.children).forEach((child) => modifyNode(child as HTMLElement));
|
24
28
|
};
|
25
29
|
|
26
|
-
Array.from(doc.body.children).forEach(child => modifyNode(child as HTMLElement));
|
30
|
+
Array.from(doc.body.children).forEach((child) => modifyNode(child as HTMLElement));
|
27
31
|
|
28
32
|
return (
|
29
33
|
<div style={styles} title={label} dangerouslySetInnerHTML={{ __html: doc.body.innerHTML }} />
|
@@ -35,16 +39,25 @@ const PluginIcon = (props: PluginIconProps) => {
|
|
35
39
|
const { token } = theme.useToken();
|
36
40
|
const options = useContext(OptionsContext);
|
37
41
|
const icon = options.icons?.[plugin.propPanel.defaultSchema.type] ?? plugin.icon;
|
38
|
-
const iconStyles = {
|
42
|
+
const iconStyles = {
|
43
|
+
...styles,
|
44
|
+
color: token.colorText,
|
45
|
+
display: 'flex',
|
46
|
+
justifyContent: 'center',
|
47
|
+
};
|
39
48
|
|
40
49
|
if (icon) {
|
41
50
|
if (size) {
|
42
51
|
return getWithModifiedSize(icon, label, size, iconStyles);
|
43
52
|
}
|
44
|
-
return <div style={iconStyles} title={label} dangerouslySetInnerHTML={{ __html: icon }}
|
53
|
+
return <div style={iconStyles} title={label} dangerouslySetInnerHTML={{ __html: icon }} />;
|
45
54
|
}
|
46
55
|
|
47
|
-
return
|
56
|
+
return (
|
57
|
+
<div style={{ ...styles, overflow: 'hidden', fontSize: 10 }} title={label}>
|
58
|
+
{label}
|
59
|
+
</div>
|
60
|
+
);
|
48
61
|
};
|
49
62
|
|
50
63
|
export default PluginIcon;
|
@@ -10,7 +10,7 @@ import {
|
|
10
10
|
AlignEndHorizontal,
|
11
11
|
AlignVerticalSpaceAround,
|
12
12
|
AlignHorizontalSpaceAround,
|
13
|
-
} from 'lucide-react'
|
13
|
+
} from 'lucide-react';
|
14
14
|
import { round } from '../../../../helper.js';
|
15
15
|
|
16
16
|
const AlignWidget = (props: PropPanelWidgetProps) => {
|
@@ -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
|
};
|