seat-editor 3.3.2 → 3.3.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/app/new-board/page.jsx +0 -1
- package/dist/app/only-view/page.jsx +1 -1
- package/dist/components/form-tools/shape.d.ts +4 -0
- package/dist/components/form-tools/shape.jsx +42 -42
- package/dist/components/layer-v3/index.jsx +1 -1
- package/dist/components/layer-v4/index.jsx +27 -13
- package/dist/features/board-v3/board-slice.js +2 -2
- package/dist/features/board-v3/index.jsx +82 -61
- package/dist/features/board-v3/utils.js +21 -0
- package/dist/features/package/index.d.ts +1 -1
- package/dist/features/panel/index.jsx +9 -7
- package/dist/features/panel/selected-group.jsx +80 -38
- package/dist/features/panel/table-seat-circle.jsx +8 -3
- package/dist/features/panel/table-seat-square.jsx +8 -3
- package/dist/features/panel/text-tool.jsx +48 -17
- package/dist/features/panel/upload-tool.d.ts +1 -1
- package/dist/features/panel/upload-tool.jsx +9 -3
- package/dist/features/panel/utils.js +3 -1
- package/dist/features/side-tool/index.jsx +20 -13
- package/dist/features/view-only-3/index.jsx +27 -44
- package/package.json +1 -1
|
@@ -1,40 +1,41 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { ColorPicker, Flex, Form, InputNumber, Select } from "antd";
|
|
3
|
+
export const optionsShape = [
|
|
4
|
+
{
|
|
5
|
+
value: "circle",
|
|
6
|
+
label: "Circle",
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
value: "square",
|
|
10
|
+
label: "Square",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
value: "table-seat-circle",
|
|
14
|
+
label: "Type 1",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
value: "table-seat-square",
|
|
18
|
+
label: "Type 2",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
value: "table-seat-half-square",
|
|
22
|
+
label: "Type 3",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
value: "table-seat-rect-square",
|
|
26
|
+
label: "Type 4",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
value: "table-seat-rect-circle",
|
|
30
|
+
label: "Type 5",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: "Image Table",
|
|
34
|
+
value: "image-table",
|
|
35
|
+
},
|
|
36
|
+
];
|
|
3
37
|
const SectionShape = ({ allowChangeShape = true, }) => {
|
|
4
|
-
const
|
|
5
|
-
{
|
|
6
|
-
value: "circle",
|
|
7
|
-
label: "Circle",
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
value: "square",
|
|
11
|
-
label: "Square",
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
value: "table-seat-circle",
|
|
15
|
-
label: "Type 1",
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
value: "table-seat-square",
|
|
19
|
-
label: "Type 2",
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
value: "table-seat-half-square",
|
|
23
|
-
label: "Type 3",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
value: "table-seat-rect-square",
|
|
27
|
-
label: "Type 4",
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
value: "table-seat-rect-circle",
|
|
31
|
-
label: "Type 5",
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
label: "Image Table",
|
|
35
|
-
value: "image-table",
|
|
36
|
-
},
|
|
37
|
-
];
|
|
38
|
+
const shape = Form.useWatch("shape");
|
|
38
39
|
return (<div className="py-2">
|
|
39
40
|
<h1 className="heading-s">Shape</h1>
|
|
40
41
|
{allowChangeShape && (<Flex gap={2} className="w-full">
|
|
@@ -57,7 +58,6 @@ const SectionShape = ({ allowChangeShape = true, }) => {
|
|
|
57
58
|
return onlyNumber === "" ? 1 : Math.max(1, Number(onlyNumber));
|
|
58
59
|
}}/>
|
|
59
60
|
</Form.Item>
|
|
60
|
-
|
|
61
61
|
</Flex>
|
|
62
62
|
<Flex gap={2}>
|
|
63
63
|
<Form.Item label="Position X" name="x" className="w-full">
|
|
@@ -89,13 +89,13 @@ const SectionShape = ({ allowChangeShape = true, }) => {
|
|
|
89
89
|
<Form.Item label="Stroke" name={"strokeWidth"} className="w-full">
|
|
90
90
|
<InputNumber />
|
|
91
91
|
</Form.Item>
|
|
92
|
-
<Form.Item label="Radius" name="radius" className="w-full">
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
92
|
+
{!(shape === null || shape === void 0 ? void 0 : shape.includes("circle")) && (<Form.Item label="Radius" name="radius" className="w-full">
|
|
93
|
+
<InputNumber suffix="px" parser={(value) => {
|
|
94
|
+
var _a;
|
|
95
|
+
const onlyNumber = (_a = value === null || value === void 0 ? void 0 : value.replace(/\D/g, "")) !== null && _a !== void 0 ? _a : "";
|
|
96
|
+
return onlyNumber === "" ? 1 : Math.max(1, Number(onlyNumber));
|
|
97
|
+
}}/>
|
|
98
|
+
</Form.Item>)}
|
|
99
99
|
<Form.Item label="opacity" name={"opacity"} className="w-full">
|
|
100
100
|
<InputNumber step={0.1} max={1} min={0} parser={(value) => {
|
|
101
101
|
if (value === undefined || value === null || value === "")
|
|
@@ -527,7 +527,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
|
|
|
527
527
|
return (<g key={id} data-id={id} transform={`translate(${x}, ${y})`}>
|
|
528
528
|
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
529
529
|
<rect width={width} height={height} fill="transparent" opacity={opacity}/>
|
|
530
|
-
<text x={width / 2} y={height / 2} textAnchor="middle" dominantBaseline="middle" fill={fontColor} fontSize={fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6} opacity={opacity} {...omit(commonProps, ["fill", "opacity"])}>
|
|
530
|
+
<text x={width / 2} y={height / 2} textAnchor="middle" dominantBaseline="middle" fill={fill !== null && fill !== void 0 ? fill : fontColor} fontSize={fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6} opacity={opacity} {...omit(commonProps, ["fill", "opacity"])}>
|
|
531
531
|
{text}
|
|
532
532
|
</text>
|
|
533
533
|
</g>
|
|
@@ -5,7 +5,17 @@ import { PRIVILEGED_TAGS, tagsDummy } from "./constant";
|
|
|
5
5
|
import { useAppSelector } from "../../hooks/use-redux";
|
|
6
6
|
import { RsvpIcons } from "../../features/board-v3/icons";
|
|
7
7
|
const toKebabCase = (str) => str.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
|
|
8
|
-
const iconNames = [
|
|
8
|
+
const iconNames = [
|
|
9
|
+
"upcoming",
|
|
10
|
+
"late",
|
|
11
|
+
"overtime",
|
|
12
|
+
"overlapping",
|
|
13
|
+
"hold",
|
|
14
|
+
"reserved",
|
|
15
|
+
"armchair",
|
|
16
|
+
"cheque",
|
|
17
|
+
"people",
|
|
18
|
+
];
|
|
9
19
|
const dummyIconTags = iconNames === null || iconNames === void 0 ? void 0 : iconNames.map((item) => {
|
|
10
20
|
const Icon = RsvpIcons === null || RsvpIcons === void 0 ? void 0 : RsvpIcons[item];
|
|
11
21
|
return {
|
|
@@ -23,14 +33,20 @@ const getIconFromId = (data) => {
|
|
|
23
33
|
};
|
|
24
34
|
const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighlightGroup, onForceRestoreGroup, selectedTableColor, privilegedTags = [], }) => {
|
|
25
35
|
const { isShowTagType } = useAppSelector((state) => state.board);
|
|
26
|
-
const showLabels = !
|
|
36
|
+
const showLabels = !["type-1", "type-2"].includes(isShowTagType) && !iconTags;
|
|
27
37
|
const renderShape = (item) => {
|
|
28
38
|
var _a, _b, _c, _d, _e, _f;
|
|
29
39
|
const { id, x, y, width, height, fill, opacity, rotate = 0, rotation, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, seatFill, src, tags, gapTags, label, points, seatPositions, radius, } = item;
|
|
30
40
|
const renderTags = (data) => {
|
|
31
41
|
var _a;
|
|
32
42
|
const tags = data !== null && data !== void 0 ? data : tagsDummy(((_a = labels === null || labels === void 0 ? void 0 : labels[0]) === null || _a === void 0 ? void 0 : _a.label) || "Table", getIconFromId(id));
|
|
33
|
-
const privileged = !isEmpty(privilegedTags)
|
|
43
|
+
const privileged = !isEmpty(privilegedTags)
|
|
44
|
+
? privilegedTags
|
|
45
|
+
: isShowTagType === "type-1"
|
|
46
|
+
? PRIVILEGED_TAGS["CURRENT_TIME"]
|
|
47
|
+
: isShowTagType === "type-2"
|
|
48
|
+
? PRIVILEGED_TAGS["NEXT_3_RESERVATION"]
|
|
49
|
+
: undefined;
|
|
34
50
|
if (tags && (tags === null || tags === void 0 ? void 0 : tags.length) > 0) {
|
|
35
51
|
const gapBetweenTags = Number(gapTags || 20);
|
|
36
52
|
const defaultFontSize = Number(fontSize || 12);
|
|
@@ -40,8 +56,7 @@ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighli
|
|
|
40
56
|
const items = tag.items || [];
|
|
41
57
|
const isColumn = (_a = tag.direction) === null || _a === void 0 ? void 0 : _a.includes("column");
|
|
42
58
|
const tagHeight = isColumn
|
|
43
|
-
? items.length * defaultFontSize +
|
|
44
|
-
(2) * (Number(tag.gap) || 2)
|
|
59
|
+
? items.length * defaultFontSize + 2 * (Number(tag.gap) || 2)
|
|
45
60
|
: defaultFontSize; // horizontal = 1 line
|
|
46
61
|
return sum + tagHeight + gapBetweenTags;
|
|
47
62
|
}, 0)) - gapBetweenTags;
|
|
@@ -60,7 +75,7 @@ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighli
|
|
|
60
75
|
const fontSize = Number(defaultFontSize);
|
|
61
76
|
const isColumn = direction === "column";
|
|
62
77
|
const groupHeight = isColumn
|
|
63
|
-
? items.length * fontSize +
|
|
78
|
+
? items.length * fontSize + 2 * gap
|
|
64
79
|
: fontSize;
|
|
65
80
|
const centerX = width / 2;
|
|
66
81
|
const centerY = currentY + groupHeight;
|
|
@@ -74,8 +89,7 @@ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighli
|
|
|
74
89
|
? i * (fontSize + gap) - groupHeight / 2 + fontSize / 2
|
|
75
90
|
: 0;
|
|
76
91
|
const offsetX = !isColumn
|
|
77
|
-
? i * (fontSize + gap) -
|
|
78
|
-
((1) * (fontSize + gap)) / 2
|
|
92
|
+
? i * (fontSize + gap) - (1 * (fontSize + gap)) / 2
|
|
79
93
|
: 0;
|
|
80
94
|
const posX = centerX + offsetX + Number((_a = tag.offsetX) !== null && _a !== void 0 ? _a : 0);
|
|
81
95
|
const posY = centerY + offsetY + Number((_b = tag.offsetY) !== null && _b !== void 0 ? _b : 0);
|
|
@@ -117,8 +131,8 @@ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighli
|
|
|
117
131
|
break;
|
|
118
132
|
}
|
|
119
133
|
return (<tspan {...symbol} key={`symbol-${tagIndex}-${i}`} x={posX + offsetSymbolX} y={posY + offsetSymbolY} textAnchor="middle" dominantBaseline="middle" fontSize={`${sizeFont}px`}>
|
|
120
|
-
|
|
121
|
-
|
|
134
|
+
{symbol.value}
|
|
135
|
+
</tspan>);
|
|
122
136
|
};
|
|
123
137
|
if (item.type === "icon") {
|
|
124
138
|
const icons = iconTags !== null && iconTags !== void 0 ? iconTags : dummyIconTags;
|
|
@@ -137,7 +151,7 @@ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighli
|
|
|
137
151
|
return null;
|
|
138
152
|
});
|
|
139
153
|
return (<g key={`group-${tagIndex}`} pointerEvents="none">
|
|
140
|
-
{elements}
|
|
154
|
+
{elements}
|
|
141
155
|
</g>);
|
|
142
156
|
});
|
|
143
157
|
}
|
|
@@ -961,8 +975,8 @@ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighli
|
|
|
961
975
|
case "text":
|
|
962
976
|
return (<g key={id} onContextMenu={(e) => e.preventDefault()} data-id={id} transform={`translate(${x}, ${y})`}>
|
|
963
977
|
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
964
|
-
<rect
|
|
965
|
-
<text x={
|
|
978
|
+
<rect width={width} height={height} fill="transparent" opacity={opacity}/>
|
|
979
|
+
<text x={width / 2} y={height / 2} textAnchor="middle" dominantBaseline="middle" fill={fill} fontSize={fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6} opacity={opacity} {...omit(commonProps, ["fill", "opacity"])}>
|
|
966
980
|
{text}
|
|
967
981
|
</text>
|
|
968
982
|
</g>
|
|
@@ -212,7 +212,7 @@ const boardSlice = createSlice({
|
|
|
212
212
|
const prev = state.historyChanges[state.pointer];
|
|
213
213
|
state.components = current(prev === null || prev === void 0 ? void 0 : prev.components);
|
|
214
214
|
state.extraComponents = current(prev === null || prev === void 0 ? void 0 : prev.extraComponents);
|
|
215
|
-
state.boundingBox =
|
|
215
|
+
state.boundingBox = prev === null || prev === void 0 ? void 0 : prev.boundingBox;
|
|
216
216
|
state.backgroundColor = prev === null || prev === void 0 ? void 0 : prev.backgroundColor;
|
|
217
217
|
}
|
|
218
218
|
else if (state.pointer === 1) {
|
|
@@ -237,7 +237,7 @@ const boardSlice = createSlice({
|
|
|
237
237
|
setInitialValue: (state, action) => {
|
|
238
238
|
const { components, extraComponents, backgroundColor, boundingBox } = action.payload;
|
|
239
239
|
state.components = components;
|
|
240
|
-
state.extraComponents = extraComponents;
|
|
240
|
+
state.extraComponents = extraComponents === null || extraComponents === void 0 ? void 0 : extraComponents.filter((item) => item.shape);
|
|
241
241
|
state.pointer = 0;
|
|
242
242
|
state.backgroundColor = backgroundColor;
|
|
243
243
|
state.boundingBox = boundingBox;
|
|
@@ -86,53 +86,40 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
86
86
|
}
|
|
87
87
|
}, [selectionLines]);
|
|
88
88
|
useEffect(() => {
|
|
89
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
89
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
90
90
|
if (hasInitialized)
|
|
91
91
|
return;
|
|
92
92
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
93
93
|
// let widthMinX = 0;
|
|
94
94
|
// let heightMinY = 0;
|
|
95
|
-
componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.forEach((_) => {
|
|
96
|
-
var _a, _b, _c, _d;
|
|
95
|
+
componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.forEach((_, i) => {
|
|
97
96
|
let values = _;
|
|
98
|
-
if (
|
|
99
|
-
minX = Math.min(minX, values.x);
|
|
100
|
-
minY = Math.min(minY, values.y);
|
|
101
|
-
maxX = Math.max(maxX, values.x + values.width);
|
|
102
|
-
maxY = Math.max(maxY, values.y + values.height);
|
|
103
|
-
}
|
|
104
|
-
if ((_b = values === null || values === void 0 ? void 0 : values.shape) === null || _b === void 0 ? void 0 : _b.includes("circle")) {
|
|
97
|
+
if (values === null || values === void 0 ? void 0 : values.shape) {
|
|
105
98
|
minX = Math.min(minX, values.x);
|
|
106
99
|
minY = Math.min(minY, values.y);
|
|
107
100
|
maxX = Math.max(maxX, values.x + values.width);
|
|
108
101
|
maxY = Math.max(maxY, values.y + values.height);
|
|
109
102
|
}
|
|
110
|
-
if (
|
|
111
|
-
minX =
|
|
112
|
-
minY =
|
|
113
|
-
maxX =
|
|
114
|
-
maxY =
|
|
115
|
-
}
|
|
116
|
-
if ((_d = values === null || values === void 0 ? void 0 : values.shape) === null || _d === void 0 ? void 0 : _d.includes("image-table")) {
|
|
117
|
-
minX = Math.min(minX, values.x);
|
|
118
|
-
minY = Math.min(minY, values.y);
|
|
119
|
-
maxX = Math.max(maxX, values.x + values.width);
|
|
120
|
-
maxY = Math.max(maxY, values.y + values.height);
|
|
103
|
+
if (i === componentsProps.length - 1) {
|
|
104
|
+
minX = minX > 10 ? minX - 10 : minX;
|
|
105
|
+
minY = minY > 10 ? minY - 10 : minY;
|
|
106
|
+
maxX = maxX + 10;
|
|
107
|
+
maxY = maxY + 10;
|
|
121
108
|
}
|
|
122
109
|
});
|
|
123
|
-
extraComponentsProps === null || extraComponentsProps === void 0 ? void 0 : extraComponentsProps.forEach((values) => {
|
|
124
|
-
var _a, _b;
|
|
125
|
-
if (
|
|
126
|
-
minX = Math.min(minX, values.x);
|
|
127
|
-
minY = Math.min(minY, values.y);
|
|
128
|
-
maxX = Math.max(maxX, values.x + values.width);
|
|
129
|
-
maxY = Math.max(maxY, values.y + values.height);
|
|
110
|
+
extraComponentsProps === null || extraComponentsProps === void 0 ? void 0 : extraComponentsProps.forEach((values, i) => {
|
|
111
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
112
|
+
if (values === null || values === void 0 ? void 0 : values.shape) {
|
|
113
|
+
minX = Math.min(minX, values.x - ((_a = values === null || values === void 0 ? void 0 : values.width) !== null && _a !== void 0 ? _a : 0));
|
|
114
|
+
minY = Math.min(minY, values.y - ((_b = values === null || values === void 0 ? void 0 : values.height) !== null && _b !== void 0 ? _b : 0));
|
|
115
|
+
maxX = Math.max(maxX, values.x + ((_c = values === null || values === void 0 ? void 0 : values.width) !== null && _c !== void 0 ? _c : 0));
|
|
116
|
+
maxY = Math.max(maxY, values.y + ((_d = values === null || values === void 0 ? void 0 : values.height) !== null && _d !== void 0 ? _d : 0));
|
|
130
117
|
}
|
|
131
|
-
if ((
|
|
132
|
-
minX = Math.min(minX, values.x);
|
|
133
|
-
minY = Math.min(minY, values.y);
|
|
134
|
-
maxX = Math.max(maxX, values
|
|
135
|
-
maxY = Math.max(maxY, values
|
|
118
|
+
if ((_e = values === null || values === void 0 ? void 0 : values.shape) === null || _e === void 0 ? void 0 : _e.includes("polygon")) {
|
|
119
|
+
minX = Math.min(minX, (_f = values === null || values === void 0 ? void 0 : values.points) === null || _f === void 0 ? void 0 : _f.reduce((min, point) => Math.min(min, point.x), Infinity));
|
|
120
|
+
minY = Math.min(minY, (_g = values === null || values === void 0 ? void 0 : values.points) === null || _g === void 0 ? void 0 : _g.reduce((min, point) => Math.min(min, point.y), Infinity));
|
|
121
|
+
maxX = Math.max(maxX, (_h = values === null || values === void 0 ? void 0 : values.points) === null || _h === void 0 ? void 0 : _h.reduce((max, point) => Math.max(max, point.x), -Infinity));
|
|
122
|
+
maxY = Math.max(maxY, (_j = values === null || values === void 0 ? void 0 : values.points) === null || _j === void 0 ? void 0 : _j.reduce((max, point) => Math.max(max, point.y), -Infinity));
|
|
136
123
|
}
|
|
137
124
|
});
|
|
138
125
|
let backgroundHasOne = false;
|
|
@@ -144,20 +131,23 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
144
131
|
maxX = (_e = extraComponentsProps === null || extraComponentsProps === void 0 ? void 0 : extraComponentsProps[0]) === null || _e === void 0 ? void 0 : _e.width;
|
|
145
132
|
maxY = (_f = extraComponentsProps === null || extraComponentsProps === void 0 ? void 0 : extraComponentsProps[0]) === null || _f === void 0 ? void 0 : _f.height;
|
|
146
133
|
}
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
134
|
+
// if (
|
|
135
|
+
// extraComponentsProps?.length < 1 &&
|
|
136
|
+
// ["background", "text"].includes(componentsProps?.[0]?.shape)
|
|
137
|
+
// ) {
|
|
138
|
+
// minX = minX;
|
|
139
|
+
// minY = minY;
|
|
140
|
+
// maxX = maxX;
|
|
141
|
+
// maxY = maxY;
|
|
142
|
+
// }
|
|
154
143
|
const hasBoundingBox = !isEmpty(boundingBox);
|
|
155
144
|
if (hasBoundingBox) {
|
|
156
145
|
minX = boundingBox.x;
|
|
157
146
|
minY = boundingBox.y;
|
|
158
147
|
}
|
|
159
148
|
if ((minX !== Infinity || minY !== Infinity) && !activeTool) {
|
|
160
|
-
|
|
149
|
+
// console.log("initialized");
|
|
150
|
+
(_g = transformRef.current) === null || _g === void 0 ? void 0 : _g.setTransform(-minX, -minY, scale);
|
|
161
151
|
setHasInitialzed(true);
|
|
162
152
|
}
|
|
163
153
|
}, [componentsProps, extraComponentsProps]);
|
|
@@ -324,8 +314,11 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
324
314
|
};
|
|
325
315
|
}, [dataElementSelectionGroupRef.current]);
|
|
326
316
|
const handlePointerDown = (e) => {
|
|
327
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
317
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
328
318
|
const shiftActive = e.shiftKey;
|
|
319
|
+
if (activeTool === "grab") {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
329
322
|
const svg = svgRef.current;
|
|
330
323
|
if (!e.isPrimary)
|
|
331
324
|
return;
|
|
@@ -343,6 +336,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
343
336
|
//CREATE ELEMENT
|
|
344
337
|
const isInitialCreateElemente = toolElement.includes(activeTool) && !isCreateElementRef.current;
|
|
345
338
|
const isInitialCreateBoundingBox = activeTool === "bounding-box";
|
|
339
|
+
const isInitialCreateText = activeTool === "text" && !isCreateElementRef.current;
|
|
346
340
|
if (isInitialCreateElemente) {
|
|
347
341
|
const tables = createTableGhost({
|
|
348
342
|
x,
|
|
@@ -368,6 +362,18 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
368
362
|
(_b = svgRef.current) === null || _b === void 0 ? void 0 : _b.appendChild(tables);
|
|
369
363
|
isCreateElementRef.current = true;
|
|
370
364
|
}
|
|
365
|
+
else if (isInitialCreateText) {
|
|
366
|
+
const tables = createTableGhost({
|
|
367
|
+
x,
|
|
368
|
+
y,
|
|
369
|
+
width: 100 * scale,
|
|
370
|
+
height: 50 * scale,
|
|
371
|
+
fill: "#000000",
|
|
372
|
+
shape: activeTool,
|
|
373
|
+
});
|
|
374
|
+
(_c = svgRef.current) === null || _c === void 0 ? void 0 : _c.appendChild(tables);
|
|
375
|
+
isCreateElementRef.current = true;
|
|
376
|
+
}
|
|
371
377
|
const targetSelection = e.target.closest("g[id='selection-lines']");
|
|
372
378
|
//ROTATE
|
|
373
379
|
const targetRotate = e.target.closest("circle[data-role]");
|
|
@@ -380,7 +386,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
380
386
|
const targetPointPolygon = e.target.closest("circle[data-point]");
|
|
381
387
|
// TARGET ELEMENT
|
|
382
388
|
let idTargetElement = JSON.parse((targetGroup === null || targetGroup === void 0 ? void 0 : targetGroup.getAttribute("data-id")) || "{}");
|
|
383
|
-
const selectionTarget = (
|
|
389
|
+
const selectionTarget = (_e = (_d = targetSelection === null || targetSelection === void 0 ? void 0 : targetSelection.dataset) === null || _d === void 0 ? void 0 : _d.selection) === null || _e === void 0 ? void 0 : _e.replace("selection-", "");
|
|
384
390
|
const activeId = selectionTarget !== null && selectionTarget !== void 0 ? selectionTarget : idTargetElement;
|
|
385
391
|
const isInSelectionTarget = !isUndefined(selectionTarget);
|
|
386
392
|
const isInTargetElement = !isPlainObject(idTargetElement);
|
|
@@ -388,7 +394,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
388
394
|
const { g } = getAttributeElement(svg, activeId);
|
|
389
395
|
if (targetGroup && shiftActive) {
|
|
390
396
|
const findById = [...componentsState, ...extraComponentsState].find((comp) => comp.id == activeId);
|
|
391
|
-
const currentSelection = (
|
|
397
|
+
const currentSelection = (_f = dataElementSelectionGroupRef.current) !== null && _f !== void 0 ? _f : [];
|
|
392
398
|
const alreadySelected = currentSelection.some((comp) => comp.id == activeId);
|
|
393
399
|
let newSelection;
|
|
394
400
|
if (alreadySelected) {
|
|
@@ -399,14 +405,13 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
399
405
|
}
|
|
400
406
|
dataElementSelectionGroupRef.current = newSelection;
|
|
401
407
|
}
|
|
402
|
-
const box = getGlobalBBox(svg, g);
|
|
403
408
|
const { x: initialXG, y: initialYG } = getTranslate(g);
|
|
404
409
|
const targetDragPosition = e.target.closest("circle[data-position]");
|
|
405
410
|
const { clientX, clientY } = e;
|
|
406
411
|
const hitPoint = document.elementFromPoint(clientX, clientY);
|
|
407
412
|
// CHECK FOR HIT ON SVG FOR SELECTION BOX
|
|
408
413
|
// MAKE AND UNMAKE SELECTION BOX START ------
|
|
409
|
-
const hadSelectionBox = ((
|
|
414
|
+
const hadSelectionBox = ((_g = dataElementSelectionGroupRef.current) === null || _g === void 0 ? void 0 : _g.length) > 0 && !isSingleSelection;
|
|
410
415
|
const downInSelectionBox = hadSelectionBox && (hitPoint === null || hitPoint === void 0 ? void 0 : hitPoint.nodeName) !== "svg";
|
|
411
416
|
const downOutSelectionBox = hadSelectionBox && (hitPoint === null || hitPoint === void 0 ? void 0 : hitPoint.nodeName) === "svg";
|
|
412
417
|
const downBeforeHasSelectionBox = !downInSelectionBox &&
|
|
@@ -443,7 +448,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
443
448
|
shape: nameShapeSelectionBoxGhost,
|
|
444
449
|
id: idSelectionBoxGhost,
|
|
445
450
|
});
|
|
446
|
-
(
|
|
451
|
+
(_h = svgRef.current) === null || _h === void 0 ? void 0 : _h.appendChild(boxSelection);
|
|
447
452
|
}
|
|
448
453
|
// MAKE AND UNMAKE SELECTION BOX END ------
|
|
449
454
|
// RESIZE SELECTION BOX
|
|
@@ -502,7 +507,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
502
507
|
});
|
|
503
508
|
dispatch({
|
|
504
509
|
type: "panel/setSelectedGroup",
|
|
505
|
-
payload: null
|
|
510
|
+
payload: null,
|
|
506
511
|
});
|
|
507
512
|
isOnMakePolygonRef.current = true;
|
|
508
513
|
}
|
|
@@ -644,7 +649,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
644
649
|
dx,
|
|
645
650
|
dy,
|
|
646
651
|
rotate: 0,
|
|
647
|
-
handle: resizeSide
|
|
652
|
+
handle: resizeSide,
|
|
648
653
|
});
|
|
649
654
|
updateSelectionBox(svg, resultSelection);
|
|
650
655
|
const scaleX = resultSelection.width / oldSel.width;
|
|
@@ -867,7 +872,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
867
872
|
dx,
|
|
868
873
|
dy,
|
|
869
874
|
rotate: 0,
|
|
870
|
-
handle: resizeSide
|
|
875
|
+
handle: resizeSide,
|
|
871
876
|
});
|
|
872
877
|
updateSelectionGuides(svg, resultSelection, {
|
|
873
878
|
vLeft: "v-left",
|
|
@@ -1076,7 +1081,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
1076
1081
|
}
|
|
1077
1082
|
};
|
|
1078
1083
|
const pointerHandleUp = (e) => {
|
|
1079
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
1084
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
1080
1085
|
updateSelectionGuides(svg, {
|
|
1081
1086
|
x: 0,
|
|
1082
1087
|
y: 0,
|
|
@@ -1109,7 +1114,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
1109
1114
|
});
|
|
1110
1115
|
dispatch({
|
|
1111
1116
|
type: "panel/setSelectedGroup",
|
|
1112
|
-
payload: null
|
|
1117
|
+
payload: null,
|
|
1113
1118
|
});
|
|
1114
1119
|
}
|
|
1115
1120
|
//POLYGON
|
|
@@ -1147,7 +1152,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
1147
1152
|
});
|
|
1148
1153
|
dispatch({
|
|
1149
1154
|
type: "panel/setSelectedGroup",
|
|
1150
|
-
payload: null
|
|
1155
|
+
payload: null,
|
|
1151
1156
|
});
|
|
1152
1157
|
polygonElementRef.current = newPoints;
|
|
1153
1158
|
}
|
|
@@ -1172,7 +1177,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
1172
1177
|
});
|
|
1173
1178
|
dispatch({
|
|
1174
1179
|
type: "panel/setSelectedGroup",
|
|
1175
|
-
payload: null
|
|
1180
|
+
payload: null,
|
|
1176
1181
|
});
|
|
1177
1182
|
//LOGIC FOR SET SHOW
|
|
1178
1183
|
dispatch({ type: "panel/setShow", payload: false });
|
|
@@ -1263,7 +1268,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
1263
1268
|
});
|
|
1264
1269
|
dispatch({
|
|
1265
1270
|
type: "panel/setSelectedGroup",
|
|
1266
|
-
payload: null
|
|
1271
|
+
payload: null,
|
|
1267
1272
|
});
|
|
1268
1273
|
}
|
|
1269
1274
|
}
|
|
@@ -1289,7 +1294,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
1289
1294
|
});
|
|
1290
1295
|
dispatch({
|
|
1291
1296
|
type: "panel/setSelectedGroup",
|
|
1292
|
-
payload: null
|
|
1297
|
+
payload: null,
|
|
1293
1298
|
});
|
|
1294
1299
|
updateComponentAttribute(newSelectedComponent);
|
|
1295
1300
|
//LOGIC FOR SET SHOW
|
|
@@ -1341,6 +1346,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
1341
1346
|
});
|
|
1342
1347
|
rotationSelectionRef.current = 0;
|
|
1343
1348
|
(_k = (_j = svgRef.current) === null || _j === void 0 ? void 0 : _j.querySelectorAll("#selection-box-ghost")) === null || _k === void 0 ? void 0 : _k.forEach((el) => el.remove());
|
|
1349
|
+
isCreateElementRef.current = false;
|
|
1344
1350
|
}
|
|
1345
1351
|
if (isInitialCreateBoundingBox) {
|
|
1346
1352
|
const ghost = svg.querySelector("#ghost-element-create");
|
|
@@ -1351,11 +1357,26 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
1351
1357
|
});
|
|
1352
1358
|
(_m = (_l = svgRef.current) === null || _l === void 0 ? void 0 : _l.querySelectorAll("#ghost-element-create")) === null || _m === void 0 ? void 0 : _m.forEach((el) => el.remove());
|
|
1353
1359
|
}
|
|
1360
|
+
if (isInitialCreateText) {
|
|
1361
|
+
const ghost = svg.querySelector("#ghost-element-create");
|
|
1362
|
+
const getBBox = getGlobalBBox(svg, ghost);
|
|
1363
|
+
const text = Object.assign(Object.assign({}, getBBox), { id: `${Date.now()}`, shape: "text", fill: "#000000", text: "Text", fontSize: 14 });
|
|
1364
|
+
addComponents(text);
|
|
1365
|
+
dispatch({
|
|
1366
|
+
type: "panel/setShow",
|
|
1367
|
+
payload: true,
|
|
1368
|
+
});
|
|
1369
|
+
dispatch({
|
|
1370
|
+
type: "panel/setSelectedComponent",
|
|
1371
|
+
payload: text,
|
|
1372
|
+
});
|
|
1373
|
+
(_p = (_o = svgRef.current) === null || _o === void 0 ? void 0 : _o.querySelectorAll("#ghost-element-create")) === null || _p === void 0 ? void 0 : _p.forEach((el) => el.remove());
|
|
1374
|
+
isCreateElementRef.current = false;
|
|
1375
|
+
}
|
|
1354
1376
|
//RESIZE SELECTION BOX UP
|
|
1355
1377
|
if (downAtResizePositionAndHasSelectionBox || isRotateSelectionBox) {
|
|
1356
|
-
const selectionLines = (_o = svgRef.current) === null || _o === void 0 ? void 0 : _o.querySelector("#selection-lines");
|
|
1357
1378
|
isResizeSelectionRef.current = false;
|
|
1358
|
-
const results = (
|
|
1379
|
+
const results = (_q = dataElementSelectionGroupRef.current) === null || _q === void 0 ? void 0 : _q.map((item) => {
|
|
1359
1380
|
const { g, element, inner, points } = getAttributeElement(svg, item.id);
|
|
1360
1381
|
const { x, y } = getTranslate(g);
|
|
1361
1382
|
const { width, height } = getSvgElementSize(element);
|
|
@@ -1403,8 +1424,8 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
1403
1424
|
!shiftActive &&
|
|
1404
1425
|
!isRotateSelectionBox) {
|
|
1405
1426
|
isResizeSelectionRef.current = false;
|
|
1406
|
-
const results = (
|
|
1407
|
-
const { g
|
|
1427
|
+
const results = (_r = dataElementSelectionGroupRef.current) === null || _r === void 0 ? void 0 : _r.map((item) => {
|
|
1428
|
+
const { g } = getAttributeElement(svg, item.id);
|
|
1408
1429
|
const { x, y } = getTranslate(g);
|
|
1409
1430
|
const getBBox = getGlobalBBox(svg, g);
|
|
1410
1431
|
const findComponent = [
|
|
@@ -1445,7 +1466,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
|
|
|
1445
1466
|
hadSelectionRef.current = false;
|
|
1446
1467
|
}
|
|
1447
1468
|
//DELETE GHOST ELEMENT BISA MEMBU
|
|
1448
|
-
(
|
|
1469
|
+
(_s = svgRef.current) === null || _s === void 0 ? void 0 : _s.querySelectorAll("#ghost-element").forEach((el) => el.remove());
|
|
1449
1470
|
//UPDATE DATASET TO STATE IF MOVEk
|
|
1450
1471
|
// if (releaseGroupRef.current) return;
|
|
1451
1472
|
if ((isMightMove &&
|
|
@@ -730,6 +730,27 @@ export function createTableGhost({ x, y, width, height, fill, shape, id = "ghost
|
|
|
730
730
|
rotation: 0,
|
|
731
731
|
}));
|
|
732
732
|
}
|
|
733
|
+
else if (shape === "text") {
|
|
734
|
+
el = document.createElementNS(SVG_NS, "text");
|
|
735
|
+
el.setAttribute("id", id);
|
|
736
|
+
el.setAttribute("x", x);
|
|
737
|
+
el.setAttribute("y", y + height / 2);
|
|
738
|
+
el.setAttribute("fill", "#000000");
|
|
739
|
+
el.setAttribute("data-table", JSON.stringify({
|
|
740
|
+
x,
|
|
741
|
+
y,
|
|
742
|
+
width,
|
|
743
|
+
height,
|
|
744
|
+
shape,
|
|
745
|
+
fill,
|
|
746
|
+
stroke: "blue",
|
|
747
|
+
rotation: 0,
|
|
748
|
+
fontSize: 14,
|
|
749
|
+
}));
|
|
750
|
+
el.textContent = "Text";
|
|
751
|
+
el.setAttribute("color", "white");
|
|
752
|
+
el.setAttribute("fontSize", "14px");
|
|
753
|
+
}
|
|
733
754
|
return el;
|
|
734
755
|
}
|
|
735
756
|
export function updateSelectionBox(svg, boxSelection, id, unFollowCursor) {
|
|
@@ -79,8 +79,9 @@ const ControlPanels = (props) => {
|
|
|
79
79
|
rotation: getValueIfSame(selectedGroup, "rotation"),
|
|
80
80
|
strokeWidth: getValueIfSame(selectedGroup, "strokeWidth"),
|
|
81
81
|
radius: getValueIfSame(selectedGroup, "radius"),
|
|
82
|
+
shape: getValueIfSame(selectedGroup, "shape"),
|
|
83
|
+
labels: getValueIfSame(selectedGroup, "labels"),
|
|
82
84
|
});
|
|
83
|
-
const values = form.getFieldsValue();
|
|
84
85
|
}
|
|
85
86
|
else {
|
|
86
87
|
setOpen(false);
|
|
@@ -92,11 +93,11 @@ const ControlPanels = (props) => {
|
|
|
92
93
|
}
|
|
93
94
|
}, [tool, show]);
|
|
94
95
|
const createShape = (shape, props = {}) => {
|
|
95
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
96
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
96
97
|
const defaults = (_a = SEAT_SHAPES[shape]) !== null && _a !== void 0 ? _a : {};
|
|
97
|
-
return Object.assign(Object.assign(Object.assign({}, defaults), props), { shape, height: (
|
|
98
|
-
? (
|
|
99
|
-
: undefined, text: shape === "text" ? (
|
|
98
|
+
return Object.assign(Object.assign(Object.assign({}, defaults), props), { shape: (_b = props.shape) !== null && _b !== void 0 ? _b : shape, height: (_c = adjustHeightWidthForSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props)) === null || _c === void 0 ? void 0 : _c.height, width: (_d = adjustHeightWidthForSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props)) === null || _d === void 0 ? void 0 : _d.width, fill: props.fill, seatCount: getSeatCount(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props), seatPositions: getSeatPosition(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props), openSpace: isSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape) ? (_e = props.openSpace) !== null && _e !== void 0 ? _e : 0 : undefined, seatFill: isSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape)
|
|
99
|
+
? (_f = props.seatFill) !== null && _f !== void 0 ? _f : "transparent"
|
|
100
|
+
: undefined, text: shape === "text" ? (_g = props.text) !== null && _g !== void 0 ? _g : defaults.text : undefined, fontColor: shape === "text" ? (_h = props.fontColor) !== null && _h !== void 0 ? _h : defaults.fontColor : undefined, radius: props.radius });
|
|
100
101
|
};
|
|
101
102
|
const debouncedSyncComponents = useRef(debounce((data) => {
|
|
102
103
|
dispatch({ type: "board/setFlagChange", payload: true });
|
|
@@ -172,8 +173,8 @@ const ControlPanels = (props) => {
|
|
|
172
173
|
debouncedSyncComponents.current(Object.assign(Object.assign({}, (selectedComponent || {})), newValues));
|
|
173
174
|
}
|
|
174
175
|
if ((selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.length) > 0) {
|
|
175
|
-
const { width, height, x, y, fill, stroke, opacity, rotation, strokeWidth, radius, } = newValues;
|
|
176
|
-
const updatedGroup = selectedGroup.map((comp) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, comp), (width !== undefined ? { width } : {})), (height !== undefined ? { height } : {})), (x !== undefined ? { x } : {})), (y !== undefined ? { y } : {})), (fill !== undefined ? { fill } : {})), (stroke !== undefined ? { stroke } : {})), (opacity !== undefined ? { opacity } : {})), (rotation !== undefined ? { rotation } : {})), (strokeWidth !== undefined ? { strokeWidth } : {})), (radius !== undefined ? { radius } : {}))));
|
|
176
|
+
const { width, height, x, y, fill, stroke, opacity, rotation, strokeWidth, radius, shape, seatCount, seatFill, seatPositions, labels } = newValues;
|
|
177
|
+
const updatedGroup = selectedGroup.map((comp) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, comp), (width !== undefined ? { width } : {})), (height !== undefined ? { height } : {})), (x !== undefined ? { x } : {})), (y !== undefined ? { y } : {})), (fill !== undefined ? { fill } : {})), (stroke !== undefined ? { stroke } : {})), (opacity !== undefined ? { opacity } : {})), (rotation !== undefined ? { rotation } : {})), (strokeWidth !== undefined ? { strokeWidth } : {})), (radius !== undefined ? { radius } : {})), (shape !== undefined ? { shape } : {})), (seatCount !== undefined ? { seatCount } : {})), (seatFill !== undefined ? { seatFill } : {})), (seatPositions !== undefined ? { seatPositions } : {})), (labels !== undefined ? { labels } : {}))));
|
|
177
178
|
let minX = Infinity;
|
|
178
179
|
let minY = Infinity;
|
|
179
180
|
let maxX = -Infinity;
|
|
@@ -210,6 +211,7 @@ const ControlPanels = (props) => {
|
|
|
210
211
|
const renderFormPanel = () => {
|
|
211
212
|
switch (tool.active) {
|
|
212
213
|
case "select":
|
|
214
|
+
case "text":
|
|
213
215
|
return <SelectToolForm action={action} tranform={transform}/>;
|
|
214
216
|
case "square":
|
|
215
217
|
case "circle":
|
|
@@ -1,49 +1,91 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { optionsShape } from "../../components/form-tools/shape";
|
|
3
|
+
import { ColorPicker, Flex, Form, InputNumber, Select } from "antd";
|
|
4
|
+
import SeatCircle from "./table-seat-circle";
|
|
5
|
+
import SeatSquare from "./table-seat-square";
|
|
6
|
+
import { useAppSelector } from "../../hooks/use-redux";
|
|
3
7
|
const SelectedGroup = () => {
|
|
8
|
+
const shape = Form.useWatch("shape");
|
|
9
|
+
const selectedGroup = useAppSelector((state) => state.panel.selectedGroup);
|
|
10
|
+
const sameShape = [
|
|
11
|
+
"table-seat-circle",
|
|
12
|
+
"table-seat-rect-circle",
|
|
13
|
+
"table-seat-square",
|
|
14
|
+
"table-seat-square",
|
|
15
|
+
"table-seat-rect-square",
|
|
16
|
+
"table-seat-half-square"
|
|
17
|
+
].includes(shape);
|
|
18
|
+
const allShapeSelected = selectedGroup.map((item) => item.shape);
|
|
19
|
+
const shapeIncludeImage = ["background", "image-table", "polygon"].some((shape) => allShapeSelected.includes(shape));
|
|
20
|
+
const shapeAllIncludePolygon = allShapeSelected.includes("polygon");
|
|
4
21
|
return (<>
|
|
5
22
|
<div className="py-2">
|
|
6
23
|
<h1 className="heading-s"> Group Selection</h1>
|
|
7
24
|
<div className="py-2">
|
|
25
|
+
{!shapeIncludeImage && (<Flex gap={2} className="w-full">
|
|
26
|
+
<Form.Item label="Name" name="shape" className="w-full">
|
|
27
|
+
<Select options={optionsShape} className="w-full"/>
|
|
28
|
+
</Form.Item>
|
|
29
|
+
</Flex>)}
|
|
8
30
|
<Flex gap={2} className="w-full">
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<InputNumber step={1} max={1} min={0}/>
|
|
17
|
-
</Form.Item>
|
|
18
|
-
</Flex>
|
|
19
|
-
<Flex gap={2}>
|
|
20
|
-
<Form.Item label="Position X" name="x" className="w-full">
|
|
21
|
-
<InputNumber />
|
|
22
|
-
</Form.Item>
|
|
23
|
-
<Form.Item label="Position Y" name="y" className="w-full">
|
|
24
|
-
<InputNumber />
|
|
25
|
-
</Form.Item>
|
|
26
|
-
<Form.Item label="Rotation" name="rotation" className="w-full">
|
|
27
|
-
<InputNumber max={360} min={0}/>
|
|
28
|
-
</Form.Item>
|
|
29
|
-
</Flex>
|
|
30
|
-
<Flex gap={2}>
|
|
31
|
-
<Form.Item label="Fill" name={"fill"} getValueFromEvent={(color) => color.toHexString()} className="w-full ">
|
|
32
|
-
<ColorPicker allowClear format="hex" defaultFormat="hex"/>
|
|
33
|
-
</Form.Item>
|
|
34
|
-
<Form.Item label="Stroke" name={"stroke"} getValueFromEvent={(color) => color.toHexString()} className="w-full ">
|
|
35
|
-
<ColorPicker allowClear format="hex" defaultFormat="hex"/>
|
|
36
|
-
</Form.Item>
|
|
37
|
-
</Flex>
|
|
38
|
-
<Flex>
|
|
39
|
-
<Form.Item label="Stroke Width" name={"strokeWidth"} className="w-full">
|
|
40
|
-
<InputNumber />
|
|
41
|
-
</Form.Item>
|
|
42
|
-
<Form.Item label="opacity" name={"opacity"} className="w-full">
|
|
43
|
-
<InputNumber step={0.1} max={1} min={0}/>
|
|
44
|
-
</Form.Item>
|
|
45
|
-
|
|
31
|
+
{["table-seat-circle", "table-seat-rect-circle"].includes(shape) && <SeatCircle />}
|
|
32
|
+
{[
|
|
33
|
+
"table-seat-square",
|
|
34
|
+
"table-seat-square",
|
|
35
|
+
"table-seat-rect-square",
|
|
36
|
+
"table-seat-half-square"
|
|
37
|
+
].includes(shape) && <SeatSquare />}
|
|
46
38
|
</Flex>
|
|
39
|
+
{!sameShape && (<>
|
|
40
|
+
<Flex gap={2} className="w-full">
|
|
41
|
+
{!shapeAllIncludePolygon && (<>
|
|
42
|
+
<Form.Item label="Width" name="width" className="w-full">
|
|
43
|
+
<InputNumber suffix="px"/>
|
|
44
|
+
</Form.Item>
|
|
45
|
+
<Form.Item label="Height" name="height" className="w-full">
|
|
46
|
+
<InputNumber suffix="px"/>
|
|
47
|
+
</Form.Item>
|
|
48
|
+
</>)}
|
|
49
|
+
{(!(shape === null || shape === void 0 ? void 0 : shape.includes("circle")) && !shapeAllIncludePolygon) && (<Form.Item label="Radius" name={"radius"} className="w-full">
|
|
50
|
+
<InputNumber suffix="px" parser={(value) => {
|
|
51
|
+
var _a;
|
|
52
|
+
const onlyNumber = (_a = value === null || value === void 0 ? void 0 : value.replace(/\D/g, "")) !== null && _a !== void 0 ? _a : "";
|
|
53
|
+
return onlyNumber === ""
|
|
54
|
+
? 1
|
|
55
|
+
: Math.max(1, Number(onlyNumber));
|
|
56
|
+
}}/>
|
|
57
|
+
</Form.Item>)}
|
|
58
|
+
</Flex>
|
|
59
|
+
{!shapeAllIncludePolygon && (<>
|
|
60
|
+
<Flex gap={2}>
|
|
61
|
+
<Form.Item label="Position X" name="x" className="w-full">
|
|
62
|
+
<InputNumber />
|
|
63
|
+
</Form.Item>
|
|
64
|
+
<Form.Item label="Position Y" name="y" className="w-full">
|
|
65
|
+
<InputNumber />
|
|
66
|
+
</Form.Item>
|
|
67
|
+
<Form.Item label="Rotation" name="rotation" className="w-full">
|
|
68
|
+
<InputNumber max={360} min={0}/>
|
|
69
|
+
</Form.Item>
|
|
70
|
+
</Flex>
|
|
71
|
+
</>)}
|
|
72
|
+
<Flex gap={2}>
|
|
73
|
+
<Form.Item label="Fill" name={"fill"} getValueFromEvent={(color) => color.toHexString()} className="w-full ">
|
|
74
|
+
<ColorPicker allowClear format="hex" defaultFormat="hex"/>
|
|
75
|
+
</Form.Item>
|
|
76
|
+
<Form.Item label="Stroke" name={"stroke"} getValueFromEvent={(color) => color.toHexString()} className="w-full ">
|
|
77
|
+
<ColorPicker allowClear format="hex" defaultFormat="hex"/>
|
|
78
|
+
</Form.Item>
|
|
79
|
+
</Flex>
|
|
80
|
+
<Flex>
|
|
81
|
+
<Form.Item label="Stroke Width" name={"strokeWidth"} className="w-full">
|
|
82
|
+
<InputNumber />
|
|
83
|
+
</Form.Item>
|
|
84
|
+
<Form.Item label="opacity" name={"opacity"} className="w-full">
|
|
85
|
+
<InputNumber step={0.1} max={1} min={0}/>
|
|
86
|
+
</Form.Item>
|
|
87
|
+
</Flex>
|
|
88
|
+
</>)}
|
|
47
89
|
</div>
|
|
48
90
|
</div>
|
|
49
91
|
</>);
|
|
@@ -19,9 +19,14 @@ const SeatCircle = () => {
|
|
|
19
19
|
<Form.Item label="Seat Fill" name={"seatFill"} getValueFromEvent={(color) => color.toHexString()} className="w-full ">
|
|
20
20
|
<ColorPicker allowClear format="hex" defaultFormat="hex"/>
|
|
21
21
|
</Form.Item>
|
|
22
|
-
<Form.Item
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
{/* <Form.Item
|
|
23
|
+
label="Table Fill"
|
|
24
|
+
name={"fill"}
|
|
25
|
+
getValueFromEvent={(color) => color.toHexString()}
|
|
26
|
+
className="w-full "
|
|
27
|
+
>
|
|
28
|
+
<ColorPicker allowClear format="hex" defaultFormat="hex" />
|
|
29
|
+
</Form.Item> */}
|
|
25
30
|
</Flex>
|
|
26
31
|
<SectionShape />
|
|
27
32
|
<SectionLabel />
|
|
@@ -34,9 +34,14 @@ const SeatSquare = () => {
|
|
|
34
34
|
<Form.Item label="Seat Fill" name={"seatFill"} getValueFromEvent={(color) => color.toHexString()} className="w-full ">
|
|
35
35
|
<ColorPicker allowClear format="hex" defaultFormat="hex"/>
|
|
36
36
|
</Form.Item>
|
|
37
|
-
<Form.Item
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
{/* <Form.Item
|
|
38
|
+
label="Table Fill"
|
|
39
|
+
name={"fill"}
|
|
40
|
+
getValueFromEvent={(color) => color.toHexString()}
|
|
41
|
+
className="w-full "
|
|
42
|
+
>
|
|
43
|
+
<ColorPicker allowClear format="hex" defaultFormat="hex" />
|
|
44
|
+
</Form.Item> */}
|
|
40
45
|
</Flex>
|
|
41
46
|
<SectionShape />
|
|
42
47
|
<SectionLabel />
|
|
@@ -1,26 +1,57 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { ColorPicker, Form, Input, InputNumber } from "antd";
|
|
2
|
+
import { ColorPicker, Flex, Form, Input, InputNumber } from "antd";
|
|
3
3
|
const TextTool = () => {
|
|
4
4
|
return (<div className="py-2">
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
<Form.Item label="Name" name="shape" className="w-full hidden">
|
|
6
|
+
<Input defaultValue={"text"}/>
|
|
7
|
+
</Form.Item>
|
|
8
|
+
|
|
9
9
|
<Form.Item name="text" label="Text">
|
|
10
10
|
<Input />
|
|
11
11
|
</Form.Item>
|
|
12
|
-
<
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
<Flex className="w-full" gap={2}>
|
|
13
|
+
<Form.Item name={"fontColor"} label="Color" getValueFromEvent={(color) => color.toHexString()}>
|
|
14
|
+
<ColorPicker allowClear format="hex" defaultFormat="hex"/>
|
|
15
|
+
</Form.Item>
|
|
16
|
+
<Form.Item name={"fontSize"} label="Size">
|
|
17
|
+
<InputNumber suffix="px"/>
|
|
18
|
+
</Form.Item>
|
|
19
|
+
</Flex>
|
|
20
|
+
<Flex gap={2} className="w-full">
|
|
21
|
+
<Form.Item label="Width" name="width" className="w-full">
|
|
22
|
+
<InputNumber suffix="px" controls parser={(value) => {
|
|
23
|
+
var _a;
|
|
24
|
+
const onlyNumber = (_a = value === null || value === void 0 ? void 0 : value.replace(/\D/g, "")) !== null && _a !== void 0 ? _a : "";
|
|
25
|
+
return onlyNumber === "" ? 1 : Math.max(1, Number(onlyNumber));
|
|
26
|
+
}}/>
|
|
27
|
+
</Form.Item>
|
|
28
|
+
<Form.Item label="Height" name="height" className="w-full">
|
|
29
|
+
<InputNumber suffix="px" parser={(value) => {
|
|
30
|
+
var _a;
|
|
31
|
+
const onlyNumber = (_a = value === null || value === void 0 ? void 0 : value.replace(/\D/g, "")) !== null && _a !== void 0 ? _a : "";
|
|
32
|
+
return onlyNumber === "" ? 1 : Math.max(1, Number(onlyNumber));
|
|
33
|
+
}}/>
|
|
34
|
+
</Form.Item>
|
|
35
|
+
</Flex>
|
|
36
|
+
<Flex gap={2}>
|
|
37
|
+
<Form.Item label="Position X" name="x" className="w-full">
|
|
38
|
+
<InputNumber />
|
|
39
|
+
</Form.Item>
|
|
40
|
+
<Form.Item label="Position Y" name="y" className="w-full">
|
|
41
|
+
<InputNumber />
|
|
42
|
+
</Form.Item>
|
|
43
|
+
<Form.Item label="Rotation" name="rotation" className="w-full">
|
|
44
|
+
<InputNumber suffix="°" min={0} max={360} parser={(value) => {
|
|
45
|
+
if (!value)
|
|
46
|
+
return 0;
|
|
47
|
+
const num = Number(value.replace(/\D/g, ""));
|
|
48
|
+
if (Number.isNaN(num))
|
|
49
|
+
return 0;
|
|
50
|
+
return Math.min(360, Math.max(0, num));
|
|
51
|
+
}}/>
|
|
52
|
+
</Form.Item>
|
|
53
|
+
</Flex>
|
|
54
|
+
|
|
24
55
|
</div>);
|
|
25
56
|
};
|
|
26
57
|
export default TextTool;
|
|
@@ -9,13 +9,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
import { useState, useEffect } from "react";
|
|
12
|
-
import { Upload, Image, Button } from "antd";
|
|
12
|
+
import { Upload, Image, Button, Form } from "antd";
|
|
13
13
|
import { InboxOutlined, LoadingOutlined } from "@ant-design/icons";
|
|
14
14
|
import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
|
|
15
15
|
import SectionLabel from "../../components/form-tools/label";
|
|
16
16
|
import SectionShape from "../../components/form-tools/shape";
|
|
17
17
|
const { Dragger } = Upload;
|
|
18
18
|
const UploadTool = ({ name, type, action, defaultValue, transform }) => {
|
|
19
|
+
// const src = Form.useWatch("src");
|
|
20
|
+
// const height = Form.useWatch("height");
|
|
21
|
+
// const width = Form.useWatch("width");
|
|
22
|
+
// const x = Form.useWatch("x");
|
|
23
|
+
// const y = Form.useWatch("y");
|
|
24
|
+
// const shape = Form.useWatch("shape");
|
|
19
25
|
var _a, _b, _c;
|
|
20
26
|
const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
|
|
21
27
|
const transformState = (_a = transform === null || transform === void 0 ? void 0 : transform.instance) === null || _a === void 0 ? void 0 : _a.transformState;
|
|
@@ -138,7 +144,7 @@ const UploadTool = ({ name, type, action, defaultValue, transform }) => {
|
|
|
138
144
|
const handleDelete = () => {
|
|
139
145
|
setDefaultSrc(null);
|
|
140
146
|
};
|
|
141
|
-
return (
|
|
147
|
+
return (<Form.Item label="" name="src" className="w-full">
|
|
142
148
|
{defaultSrc ? (<>
|
|
143
149
|
<div className="w-full flex flex-col items-center gap-2 max-h-[200px] overflow-y-auto">
|
|
144
150
|
<Image src={defaultSrc}/>
|
|
@@ -165,6 +171,6 @@ const UploadTool = ({ name, type, action, defaultValue, transform }) => {
|
|
|
165
171
|
|
|
166
172
|
<SectionShape allowChangeShape={type === "component"}/>
|
|
167
173
|
<SectionLabel />
|
|
168
|
-
|
|
174
|
+
</Form.Item>);
|
|
169
175
|
};
|
|
170
176
|
export default UploadTool;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SEAT_SHAPES } from "../../utils/constant";
|
|
2
|
+
import { MIN_HEIGHT, MIN_WIDTH } from "../board-v3/constant";
|
|
2
3
|
export const isSeatShape = (shape) => SEAT_SHAPES.includes(shape);
|
|
3
4
|
export const getSeatCount = (shape, props) => {
|
|
4
5
|
// if (shape === "table-seat-circle") {
|
|
@@ -39,7 +40,8 @@ export const getSeatPosition = (shape, props) => {
|
|
|
39
40
|
export const adjustHeightWidthForSeatShape = (shape, props) => {
|
|
40
41
|
if (shape === null || shape === void 0 ? void 0 : shape.includes("circle")) {
|
|
41
42
|
const sizeDefault = Math.min(props.width, props.height);
|
|
42
|
-
|
|
43
|
+
const sizeFinal = sizeDefault < MIN_WIDTH ? MIN_WIDTH : sizeDefault;
|
|
44
|
+
return Object.assign(Object.assign({}, props), { height: isNaN(sizeFinal) ? MIN_WIDTH : sizeFinal, width: isNaN(sizeFinal) ? MIN_HEIGHT : sizeFinal });
|
|
43
45
|
}
|
|
44
46
|
return props;
|
|
45
47
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Circle, CopyPlus, Eye, EyeOff, Image, Layers2, MousePointer, PaintBucket, Ratio, SquareMousePointer, Trash, Type, Upload, Hand, Layers, Grid, Lock, LockOpen, Undo2, Redo2, PenTool, Scan } from "lucide-react";
|
|
2
|
+
import { Circle, CopyPlus, Eye, EyeOff, Image, Layers2, MousePointer, PaintBucket, Ratio, SquareMousePointer, Trash, Type, Upload, Hand, Layers, Grid, Lock, LockOpen, Undo2, Redo2, PenTool, Scan, } from "lucide-react";
|
|
3
3
|
import ButtonTools from "../../components/button-tools";
|
|
4
4
|
import { Divider, ColorPicker, Button, message, } from "antd";
|
|
5
5
|
import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
|
|
@@ -27,11 +27,11 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
|
|
|
27
27
|
// name: "Ruler",
|
|
28
28
|
// icon: <Ruler />,
|
|
29
29
|
// },
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
30
|
+
// {
|
|
31
|
+
// id: "bounding-box",
|
|
32
|
+
// name: "Bounding Box Tool",
|
|
33
|
+
// icon: <Scan />,
|
|
34
|
+
// }
|
|
35
35
|
// {
|
|
36
36
|
// id: "node",
|
|
37
37
|
// name: "Node Tool",
|
|
@@ -90,7 +90,7 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
|
|
|
90
90
|
id: "polygon",
|
|
91
91
|
name: "Polygon Tool",
|
|
92
92
|
icon: <PenTool />,
|
|
93
|
-
}
|
|
93
|
+
},
|
|
94
94
|
// {
|
|
95
95
|
// id: "background-color",
|
|
96
96
|
// name: "Background Color",
|
|
@@ -166,21 +166,25 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
|
|
|
166
166
|
const exludedShapes = ["background", "text"];
|
|
167
167
|
if (!selectedComponent)
|
|
168
168
|
return;
|
|
169
|
-
if (!exludedShapes.includes(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) &&
|
|
169
|
+
if (!exludedShapes.includes(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) &&
|
|
170
|
+
!(deleteAutorized === null || deleteAutorized === void 0 ? void 0 : deleteAutorized.component)) {
|
|
170
171
|
message.error("You are not authorized to delete this table.");
|
|
171
172
|
return;
|
|
172
173
|
}
|
|
173
|
-
if (exludedShapes.includes(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) &&
|
|
174
|
+
if (exludedShapes.includes(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) &&
|
|
175
|
+
!(deleteAutorized === null || deleteAutorized === void 0 ? void 0 : deleteAutorized.extraComponent)) {
|
|
174
176
|
message.error("You are not authorized to delete this background.");
|
|
175
177
|
return;
|
|
176
178
|
}
|
|
177
|
-
if ((deleteAutorized === null || deleteAutorized === void 0 ? void 0 : deleteAutorized.component) &&
|
|
179
|
+
if ((deleteAutorized === null || deleteAutorized === void 0 ? void 0 : deleteAutorized.component) &&
|
|
180
|
+
!exludedShapes.includes(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape)) {
|
|
178
181
|
dispatch({
|
|
179
182
|
type: "board/removeComponent",
|
|
180
183
|
payload: selectedComponent,
|
|
181
184
|
});
|
|
182
185
|
}
|
|
183
|
-
if ((deleteAutorized === null || deleteAutorized === void 0 ? void 0 : deleteAutorized.extraComponent) &&
|
|
186
|
+
if ((deleteAutorized === null || deleteAutorized === void 0 ? void 0 : deleteAutorized.extraComponent) &&
|
|
187
|
+
exludedShapes.includes(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape)) {
|
|
184
188
|
dispatch({
|
|
185
189
|
type: "board/removeExtraComponent",
|
|
186
190
|
payload: selectedComponent,
|
|
@@ -336,6 +340,7 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
|
|
|
336
340
|
<ColorPicker value={color} onChange={handleChangeColorBackground}>
|
|
337
341
|
<Button icon={<PaintBucket />} type="text" name="Background Color" onClick={() => hanldeSelectTool("background-color")} style={active === "background-color" ? { color: "red" } : {}}/>
|
|
338
342
|
</ColorPicker>
|
|
343
|
+
<Button icon={<Scan />} type="text" name="Preview" onClick={() => hanldeSelectTool("bounding-box")} style={active === "preview" ? { color: "red" } : {}}/>
|
|
339
344
|
<Button icon={preview ? <EyeOff /> : <Eye />} type="text" name="Preview" onClick={handleOpenModalPreview} style={active === "preview" ? { color: "red" } : {}}/>
|
|
340
345
|
<Button icon={<Grid />} type="text" name="Grid" onClick={() => toggleGrid()}/>
|
|
341
346
|
<ButtonTools buttonProps={{
|
|
@@ -348,13 +353,15 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
|
|
|
348
353
|
trigger: "hover",
|
|
349
354
|
placement: "right",
|
|
350
355
|
}}/>
|
|
351
|
-
|
|
356
|
+
<ButtonTools buttonProps={{
|
|
352
357
|
onClick: () => toogleSetLockBackground(),
|
|
353
358
|
icon: lockBackground ? <Lock /> : <LockOpen />,
|
|
354
359
|
type: "text",
|
|
355
360
|
name: "trash",
|
|
356
361
|
}} items={[]} popoverProps={{
|
|
357
|
-
content: <div>
|
|
362
|
+
content: (<div>
|
|
363
|
+
{lockBackground ? "Unlock Background" : "Lock Background"}
|
|
364
|
+
</div>),
|
|
358
365
|
trigger: "hover",
|
|
359
366
|
placement: "right",
|
|
360
367
|
}}/>
|
|
@@ -23,7 +23,7 @@ const LayerView = (props) => {
|
|
|
23
23
|
const [panningGroup, setPanningGroup] = useState(false);
|
|
24
24
|
const [scale, setScale] = useState(1);
|
|
25
25
|
const [selectedTable, setSelectedTable] = useState(null);
|
|
26
|
-
const { components: componentsEditor, extraComponents: extraComponentsEditor, boundingBox: boundingBoxProps } = useAppSelector((state) => state.board);
|
|
26
|
+
const { components: componentsEditor, extraComponents: extraComponentsEditor, boundingBox: boundingBoxProps, } = useAppSelector((state) => state.board);
|
|
27
27
|
const backgroundColor = useAppSelector((state) => state.board.backgroundColor);
|
|
28
28
|
const { loading } = useAppSelector((state) => state.panel);
|
|
29
29
|
useImperativeHandle(refs, () => ({
|
|
@@ -38,7 +38,7 @@ const LayerView = (props) => {
|
|
|
38
38
|
}));
|
|
39
39
|
const dispatch = useAppDispatch();
|
|
40
40
|
useEffect(() => {
|
|
41
|
-
if (
|
|
41
|
+
if (!loading && (loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.state)) {
|
|
42
42
|
dispatch({ type: "panel/setLoading", payload: true });
|
|
43
43
|
}
|
|
44
44
|
if ((componentProps === null || componentProps === void 0 ? void 0 : componentProps.length) > 0) {
|
|
@@ -106,72 +106,53 @@ const LayerView = (props) => {
|
|
|
106
106
|
setSelectedTable(seletedTable);
|
|
107
107
|
};
|
|
108
108
|
const boundingBox = useMemo(() => {
|
|
109
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
109
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
110
110
|
if (!componentsEditor && (componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.length) === 0) {
|
|
111
111
|
return { minX: 0, minY: 0, width: 500, height: 500 };
|
|
112
112
|
}
|
|
113
113
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
114
|
-
componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.forEach((_) => {
|
|
115
|
-
var _a, _b, _c, _d;
|
|
114
|
+
componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.forEach((_, i) => {
|
|
116
115
|
let values = mappingKey ? _[mappingKey] : _;
|
|
117
116
|
if (!values)
|
|
118
117
|
return;
|
|
119
|
-
if (
|
|
118
|
+
if (values === null || values === void 0 ? void 0 : values.shape) {
|
|
120
119
|
minX = Math.min(minX, values.x);
|
|
121
120
|
minY = Math.min(minY, values.y);
|
|
122
121
|
maxX = Math.max(maxX, values.x + values.width);
|
|
123
122
|
maxY = Math.max(maxY, values.y + values.height);
|
|
124
123
|
}
|
|
125
|
-
if ((
|
|
126
|
-
minX =
|
|
127
|
-
minY =
|
|
128
|
-
maxX =
|
|
129
|
-
maxY =
|
|
130
|
-
}
|
|
131
|
-
if ((_c = values === null || values === void 0 ? void 0 : values.shape) === null || _c === void 0 ? void 0 : _c.includes("table-seat-circle")) {
|
|
132
|
-
minX = Math.min(minX, values.x);
|
|
133
|
-
minY = Math.min(minY, values.y);
|
|
134
|
-
maxX = Math.max(maxX, values.x + values.width);
|
|
135
|
-
maxY = Math.max(maxY, values.y + values.height);
|
|
136
|
-
}
|
|
137
|
-
if ((_d = values === null || values === void 0 ? void 0 : values.shape) === null || _d === void 0 ? void 0 : _d.includes("image-table")) {
|
|
138
|
-
minX = Math.min(minX, values.x);
|
|
139
|
-
minY = Math.min(minY, values.y);
|
|
140
|
-
maxX = Math.max(maxX, values.x + values.width);
|
|
141
|
-
maxY = Math.max(maxY, values.y + values.height);
|
|
124
|
+
if ((i === componentsEditor.length - 1) && (extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) === 0) {
|
|
125
|
+
minX = minX > 10 ? minX - 10 : minX;
|
|
126
|
+
minY = minY > 10 ? minY - 10 : minY;
|
|
127
|
+
maxX = maxX + 10;
|
|
128
|
+
maxY = maxY + 10;
|
|
142
129
|
}
|
|
143
130
|
});
|
|
144
131
|
extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.forEach((values) => {
|
|
145
|
-
var _a, _b;
|
|
146
|
-
if (
|
|
132
|
+
var _a, _b, _c, _d, _e;
|
|
133
|
+
if (values === null || values === void 0 ? void 0 : values.shape) {
|
|
147
134
|
minX = Math.min(minX, values.x);
|
|
148
135
|
minY = Math.min(minY, values.y);
|
|
149
136
|
maxX = Math.max(maxX, values.x + values.width);
|
|
150
137
|
maxY = Math.max(maxY, values.y + values.height);
|
|
151
138
|
}
|
|
152
|
-
if ((
|
|
153
|
-
minX = Math.min(minX, values.x);
|
|
154
|
-
minY = Math.min(minY, values.y);
|
|
155
|
-
maxX = Math.max(maxX, values
|
|
156
|
-
maxY = Math.max(maxY, values
|
|
139
|
+
if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("polygon")) {
|
|
140
|
+
minX = Math.min(minX, (_b = values === null || values === void 0 ? void 0 : values.points) === null || _b === void 0 ? void 0 : _b.reduce((min, point) => Math.min(min, point.x), Infinity));
|
|
141
|
+
minY = Math.min(minY, (_c = values === null || values === void 0 ? void 0 : values.points) === null || _c === void 0 ? void 0 : _c.reduce((min, point) => Math.min(min, point.y), Infinity));
|
|
142
|
+
maxX = Math.max(maxX, (_d = values === null || values === void 0 ? void 0 : values.points) === null || _d === void 0 ? void 0 : _d.reduce((max, point) => Math.max(max, point.x), -Infinity));
|
|
143
|
+
maxY = Math.max(maxY, (_e = values === null || values === void 0 ? void 0 : values.points) === null || _e === void 0 ? void 0 : _e.reduce((max, point) => Math.max(max, point.y), -Infinity));
|
|
157
144
|
}
|
|
158
145
|
});
|
|
159
146
|
let backgroundHasOne = false;
|
|
160
147
|
if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) === 1 &&
|
|
161
148
|
((_b = (_a = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _a === void 0 ? void 0 : _a.shape) === null || _b === void 0 ? void 0 : _b.includes("background"))) {
|
|
162
149
|
backgroundHasOne = true;
|
|
150
|
+
// console.log({ backgroundHasOne },"shini")
|
|
163
151
|
minX = (_c = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _c === void 0 ? void 0 : _c.x;
|
|
164
152
|
minY = (_d = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _d === void 0 ? void 0 : _d.y;
|
|
165
153
|
maxX = (_e = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _e === void 0 ? void 0 : _e.width;
|
|
166
154
|
maxY = (_f = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _f === void 0 ? void 0 : _f.height;
|
|
167
155
|
}
|
|
168
|
-
if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) < 1 &&
|
|
169
|
-
["background", "text"].includes((_g = componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor[0]) === null || _g === void 0 ? void 0 : _g.shape)) {
|
|
170
|
-
minX = minX;
|
|
171
|
-
minY = minY;
|
|
172
|
-
maxX = maxX;
|
|
173
|
-
maxY = maxY;
|
|
174
|
-
}
|
|
175
156
|
const hasBoundingBox = boundingBoxProps;
|
|
176
157
|
// const paddingY =
|
|
177
158
|
// maxY * (props?.viewStyles?.paddingY || 0) +
|
|
@@ -194,11 +175,12 @@ const LayerView = (props) => {
|
|
|
194
175
|
// width: maxX + paddingX * 2,
|
|
195
176
|
// height: maxY + paddingY + (maxY + paddingY) * 0.5,
|
|
196
177
|
// };
|
|
178
|
+
// console.log(minX, minY, maxX, maxY,props?.viewStyles, "bounding box");
|
|
197
179
|
return {
|
|
198
|
-
minX: minX - (((
|
|
199
|
-
minY: minY - (((
|
|
200
|
-
width: maxX + (((
|
|
201
|
-
height: maxY + (((
|
|
180
|
+
minX: minX - (((_g = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _g === void 0 ? void 0 : _g.paddingLeft) || 0),
|
|
181
|
+
minY: minY - (((_h = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _h === void 0 ? void 0 : _h.paddingTop) || 0),
|
|
182
|
+
width: maxX + (((_j = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _j === void 0 ? void 0 : _j.paddingRight) || 0),
|
|
183
|
+
height: maxY + (((_k = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _k === void 0 ? void 0 : _k.paddingBottom) || 0),
|
|
202
184
|
};
|
|
203
185
|
}, [componentsEditor, extraComponentsEditor]);
|
|
204
186
|
const renderElements = (elementEditor, mappingKey, tableMatchKey) => {
|
|
@@ -464,6 +446,8 @@ const LayerView = (props) => {
|
|
|
464
446
|
x = bounds.minPositionX;
|
|
465
447
|
setTransform(x, y, scale, 100, "linear");
|
|
466
448
|
};
|
|
449
|
+
// const instance = transformRef.current?.instance;
|
|
450
|
+
// console.log({ instance })
|
|
467
451
|
const getCoords = (e) => {
|
|
468
452
|
var _a;
|
|
469
453
|
const svg = svgRef.current;
|
|
@@ -484,7 +468,7 @@ const LayerView = (props) => {
|
|
|
484
468
|
return null;
|
|
485
469
|
}
|
|
486
470
|
const svgRect = svg.getBoundingClientRect();
|
|
487
|
-
const viewBox = svg.viewBox.baseVal;
|
|
471
|
+
// const viewBox = svg.viewBox.baseVal;
|
|
488
472
|
const xLeft = (clientX - svgRect.left + positionX) / scale;
|
|
489
473
|
const yTop = (clientY - svgRect.top + positionY) / scale;
|
|
490
474
|
const xRight = clientX - svgRect.left + positionX - svgRect.width / scale;
|
|
@@ -543,7 +527,7 @@ const LayerView = (props) => {
|
|
|
543
527
|
wheelPanning: true,
|
|
544
528
|
}} wheel={{
|
|
545
529
|
disabled: false,
|
|
546
|
-
}} onTransformed={({ state: { scale } }) => setScale(scale)} minScale={1} maxScale={1000} initialScale={1} smooth={true} {...props.transformProps}>
|
|
530
|
+
}} onTransformed={({ state: { scale } }) => setScale(scale)} minScale={1} maxScale={1000} initialScale={1} smooth={true} centerOnInit={true} {...props.transformProps}>
|
|
547
531
|
<TransformComponent wrapperStyle={{
|
|
548
532
|
width: "100%",
|
|
549
533
|
height: "100%",
|
|
@@ -563,7 +547,6 @@ const LayerView = (props) => {
|
|
|
563
547
|
touchAction: "none",
|
|
564
548
|
userSelect: "none",
|
|
565
549
|
}} {...props.svgProps}>
|
|
566
|
-
|
|
567
550
|
{hasBoundingBox && (<defs>
|
|
568
551
|
<clipPath id="contentCrop">
|
|
569
552
|
<rect x={boundingBox.minX} y={boundingBox.minY} width={boundingBox.width} height={boundingBox.height}/>
|