seat-editor 1.6.4 → 1.6.7
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/features/panel/upload-tool.d.ts +1 -1
- package/dist/features/panel/upload-tool.js +1 -1
- package/dist/features/panel/upload-tool.jsx +152 -0
- package/package.json +1 -1
- package/dist/features/board/index.jsx +0 -726
- package/dist/features/package/index.jsx +0 -115
- package/dist/features/view/index.jsx +0 -227
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
import { useState, useEffect } from "react";
|
|
12
|
+
import { Upload, Image, Button } from "antd";
|
|
13
|
+
import { InboxOutlined } from "@ant-design/icons";
|
|
14
|
+
import { useAppDispatch } from "../../hooks/use-redux";
|
|
15
|
+
import SectionLabel from "../../components/form-tools/label";
|
|
16
|
+
import SectionShape from "../../components/form-tools/shape";
|
|
17
|
+
const { Dragger } = Upload;
|
|
18
|
+
// const actionResponseBased = {
|
|
19
|
+
// status: 200,
|
|
20
|
+
// message: "Upload successful",
|
|
21
|
+
// data: {
|
|
22
|
+
// id: "12345",
|
|
23
|
+
// url: "https://example.com/image.png",
|
|
24
|
+
// },
|
|
25
|
+
// };
|
|
26
|
+
const UploadTool = ({ name, type, action, responseMapping, defaultValue, }) => {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
const [defaultSrc, setDefaultSrc] = useState(null);
|
|
29
|
+
const [isEdit, setIsEdit] = useState(false);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (defaultValue) {
|
|
32
|
+
setDefaultSrc(defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.src);
|
|
33
|
+
setIsEdit(true);
|
|
34
|
+
}
|
|
35
|
+
}, [defaultValue]);
|
|
36
|
+
const dispatch = useAppDispatch();
|
|
37
|
+
const widthWorkspace = ((_a = document === null || document === void 0 ? void 0 : document.getElementById("workspace")) === null || _a === void 0 ? void 0 : _a.clientWidth) || 0;
|
|
38
|
+
const heightWorkspace = ((_b = document === null || document === void 0 ? void 0 : document.getElementById("workspace")) === null || _b === void 0 ? void 0 : _b.clientHeight) || 0;
|
|
39
|
+
const defaultFormatValue = (width, height, src, id) => ({
|
|
40
|
+
id: id || new Date().getTime(),
|
|
41
|
+
x: 0,
|
|
42
|
+
y: 0,
|
|
43
|
+
width: width < 1 ? 100 : width,
|
|
44
|
+
height: height < 1 ? 100 : height,
|
|
45
|
+
rotation: 0,
|
|
46
|
+
shape: name,
|
|
47
|
+
src,
|
|
48
|
+
});
|
|
49
|
+
const propsUpload = {
|
|
50
|
+
name: "file",
|
|
51
|
+
multiple: true,
|
|
52
|
+
maxCount: 1,
|
|
53
|
+
showUploadList: false,
|
|
54
|
+
onChange: (info) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
+
const { status } = info.file;
|
|
56
|
+
if (status !== "uploading" && info.file.originFileObj) {
|
|
57
|
+
const file = info.file.originFileObj;
|
|
58
|
+
const img = new window.Image();
|
|
59
|
+
let srcFromResponse = "";
|
|
60
|
+
try {
|
|
61
|
+
// ⬇️ IF ada custom action (upload ke server)
|
|
62
|
+
if (action) {
|
|
63
|
+
yield action(file, type);
|
|
64
|
+
}
|
|
65
|
+
// ⬇️ IF local upload
|
|
66
|
+
// else {
|
|
67
|
+
// img.onload = () => {
|
|
68
|
+
// const scaleX = widthWorkspace / img.width;
|
|
69
|
+
// const scaleY = heightWorkspace / img.height;
|
|
70
|
+
// const scale = Math.min(1, scaleX, scaleY);
|
|
71
|
+
// const width = img.width * scale;
|
|
72
|
+
// const height = img.height * scale;
|
|
73
|
+
// if (isEdit) {
|
|
74
|
+
// dispatch({
|
|
75
|
+
// type:
|
|
76
|
+
// type === "component"
|
|
77
|
+
// ? "board/updateComponent"
|
|
78
|
+
// : "board/updateExtraComponent",
|
|
79
|
+
// payload: {
|
|
80
|
+
// ...defaultFormatValue(
|
|
81
|
+
// width,
|
|
82
|
+
// height,
|
|
83
|
+
// img.src,
|
|
84
|
+
// defaultValue.id
|
|
85
|
+
// ),
|
|
86
|
+
// },
|
|
87
|
+
// });
|
|
88
|
+
// dispatch({
|
|
89
|
+
// type: "panel/setSelectedComponent",
|
|
90
|
+
// payload: {
|
|
91
|
+
// ...defaultFormatValue(
|
|
92
|
+
// width,
|
|
93
|
+
// height,
|
|
94
|
+
// srcFromResponse,
|
|
95
|
+
// defaultValue.id
|
|
96
|
+
// ),
|
|
97
|
+
// },
|
|
98
|
+
// });
|
|
99
|
+
// setDefaultSrc(img.src);
|
|
100
|
+
// } else {
|
|
101
|
+
// dispatch({
|
|
102
|
+
// type:
|
|
103
|
+
// type === "component"
|
|
104
|
+
// ? "board/addComponent"
|
|
105
|
+
// : "board/setExtraComponent",
|
|
106
|
+
// payload: {
|
|
107
|
+
// ...defaultFormatValue(width, height, img.src),
|
|
108
|
+
// },
|
|
109
|
+
// });
|
|
110
|
+
// }
|
|
111
|
+
// dispatch({ type: "board/setFlagChange", payload: true });
|
|
112
|
+
// // message.success(`${info.file.name} uploaded successfully.`);
|
|
113
|
+
// };
|
|
114
|
+
// // Set img src AFTER onload
|
|
115
|
+
// img.src = URL.createObjectURL(file);
|
|
116
|
+
// }
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
// message.error("Upload failed, please try again.");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
};
|
|
124
|
+
const handleDelete = () => {
|
|
125
|
+
setDefaultSrc(null);
|
|
126
|
+
};
|
|
127
|
+
return (<>
|
|
128
|
+
{defaultSrc ? (<>
|
|
129
|
+
<div className="w-full flex flex-col items-center gap-2 max-h-[200px] overflow-y-auto">
|
|
130
|
+
<Image src={defaultSrc}/>
|
|
131
|
+
</div>
|
|
132
|
+
<Button type="primary" onClick={handleDelete}>
|
|
133
|
+
Edit
|
|
134
|
+
</Button>
|
|
135
|
+
</>) : (<Dragger {...propsUpload} action={""}>
|
|
136
|
+
<p className="ant-upload-drag-icon">
|
|
137
|
+
<InboxOutlined />
|
|
138
|
+
</p>
|
|
139
|
+
<p className="ant-upload-text">
|
|
140
|
+
Click or drag file to this area to upload
|
|
141
|
+
</p>
|
|
142
|
+
<p className="ant-upload-hint">
|
|
143
|
+
Support for a single or bulk upload. Strictly prohibited from
|
|
144
|
+
uploading company data or other banned files.
|
|
145
|
+
</p>
|
|
146
|
+
</Dragger>)}
|
|
147
|
+
|
|
148
|
+
<SectionShape />
|
|
149
|
+
<SectionLabel />
|
|
150
|
+
</>);
|
|
151
|
+
};
|
|
152
|
+
export default UploadTool;
|
package/package.json
CHANGED
|
@@ -1,726 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
-
import { TransformWrapper, TransformComponent, MiniMap, } from "react-zoom-pan-pinch";
|
|
4
|
-
import { useAppSelector, useAppDispatch } from "../../hooks/use-redux";
|
|
5
|
-
import Layers from "../../components/layer";
|
|
6
|
-
import { throttle } from "lodash";
|
|
7
|
-
import ModalPreview from "../../components/modal-preview";
|
|
8
|
-
import LayerView from "../view";
|
|
9
|
-
import { isEqual, debounce } from "lodash";
|
|
10
|
-
import { ZoomIn, ZoomOut } from "lucide-react";
|
|
11
|
-
import { Button } from "antd";
|
|
12
|
-
const BoardTemplate = ({ onSelectComponent }) => {
|
|
13
|
-
const dispatch = useAppDispatch();
|
|
14
|
-
const theme = useAppSelector((state) => state.theme);
|
|
15
|
-
const transformRef = useRef(null);
|
|
16
|
-
const containerRef = useRef(null);
|
|
17
|
-
const [widthBoard, setWidthBoard] = useState(0);
|
|
18
|
-
const [heightBoard, setHeightBoard] = useState(0);
|
|
19
|
-
const svgRef = useRef(null);
|
|
20
|
-
const [shadowShape, setShadowShape] = useState([]);
|
|
21
|
-
const [startPoint, setStartPoint] = useState(null);
|
|
22
|
-
const [dragOffset, setDragOffset] = useState({ x: 0, y: 0 });
|
|
23
|
-
// const [moveComponent, setMoveComponent] = useState(false);
|
|
24
|
-
const [scale, setScale] = useState(1);
|
|
25
|
-
const activeTool = useAppSelector((state) => state.tool.active);
|
|
26
|
-
const grid = useAppSelector((state) => state.tool.grid);
|
|
27
|
-
const { components: componentsProps, extraComponents: extraComponentsProps, flagChange, } = useAppSelector((state) => state.board);
|
|
28
|
-
const isTouching = useRef(false);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
var _a;
|
|
31
|
-
if (activeTool !== ((_a = shadowShape[0]) === null || _a === void 0 ? void 0 : _a.shape)) {
|
|
32
|
-
setShadowShape([]);
|
|
33
|
-
}
|
|
34
|
-
}, [activeTool]);
|
|
35
|
-
// const [isDragging, setIsDragging] = useState(false);
|
|
36
|
-
const [resizeDirection, setResizeDirection] = useState(null);
|
|
37
|
-
const backgroundColor = useAppSelector((state) => state.board.backgroundColor);
|
|
38
|
-
const selectedComponentProps = useAppSelector((state) => state.panel.selectedComponent);
|
|
39
|
-
const screenCTMRef = useRef(null);
|
|
40
|
-
const dragIndex = useRef(null);
|
|
41
|
-
const [componentsState, setComponentsState] = useState([]);
|
|
42
|
-
const [extraComponentsState, setExtraComponentsState] = useState([]);
|
|
43
|
-
const [selectedComponent, setSelectedComponent] = useState(null);
|
|
44
|
-
const isSyncingFromRedux = useRef(false);
|
|
45
|
-
const startPos = useRef({ x: 0, y: 0 });
|
|
46
|
-
const isDragging = useRef(false);
|
|
47
|
-
const moveComponent = useRef(false);
|
|
48
|
-
const debouncedSyncToReduxSelected = useRef(debounce((data) => {
|
|
49
|
-
throttledDispatch(data);
|
|
50
|
-
}, 300)).current;
|
|
51
|
-
const debouncedSyncComponents = useRef(debounce((data) => {
|
|
52
|
-
dispatch({
|
|
53
|
-
type: "board/setNewComponents",
|
|
54
|
-
payload: data,
|
|
55
|
-
});
|
|
56
|
-
}, 300));
|
|
57
|
-
const debouncedSyncExtraComponents = useRef(debounce((data) => {
|
|
58
|
-
console.log({ data }, "from board");
|
|
59
|
-
dispatch({
|
|
60
|
-
type: "board/setNewExtraComponents",
|
|
61
|
-
payload: data,
|
|
62
|
-
});
|
|
63
|
-
}, 300));
|
|
64
|
-
// Redux → Local
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
if (flagChange) {
|
|
67
|
-
if (!isEqual(componentsProps, componentsState)) {
|
|
68
|
-
isSyncingFromRedux.current = true;
|
|
69
|
-
setComponentsState(componentsProps !== null && componentsProps !== void 0 ? componentsProps : []);
|
|
70
|
-
}
|
|
71
|
-
if (!isEqual(extraComponentsProps, extraComponentsState)) {
|
|
72
|
-
isSyncingFromRedux.current = true;
|
|
73
|
-
setExtraComponentsState(extraComponentsProps !== null && extraComponentsProps !== void 0 ? extraComponentsProps : []);
|
|
74
|
-
}
|
|
75
|
-
if (!isEqual(selectedComponentProps, selectedComponent)) {
|
|
76
|
-
isSyncingFromRedux.current = true;
|
|
77
|
-
setSelectedComponent(selectedComponentProps !== null && selectedComponentProps !== void 0 ? selectedComponentProps : []);
|
|
78
|
-
}
|
|
79
|
-
dispatch({ type: "board/setFlagChange", payload: false });
|
|
80
|
-
}
|
|
81
|
-
}, [
|
|
82
|
-
componentsProps,
|
|
83
|
-
extraComponentsProps,
|
|
84
|
-
selectedComponentProps,
|
|
85
|
-
flagChange,
|
|
86
|
-
]);
|
|
87
|
-
// Local → Redux
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
if (isSyncingFromRedux.current) {
|
|
90
|
-
isSyncingFromRedux.current = false;
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (!isEqual(componentsState, componentsProps) &&
|
|
94
|
-
!isEqual(componentsState, [])) {
|
|
95
|
-
debouncedSyncComponents.current(componentsState);
|
|
96
|
-
}
|
|
97
|
-
if (!isEqual(extraComponentsState, extraComponentsProps)) {
|
|
98
|
-
console.log("extraComponentsState", extraComponentsState);
|
|
99
|
-
debouncedSyncExtraComponents.current(extraComponentsState);
|
|
100
|
-
}
|
|
101
|
-
}, [componentsState, extraComponentsState]);
|
|
102
|
-
const handleAddComponent = (shape) => {
|
|
103
|
-
dispatch({
|
|
104
|
-
type: activeTool === "text"
|
|
105
|
-
? "board/setExtraComponent"
|
|
106
|
-
: "board/addComponent",
|
|
107
|
-
payload: Object.assign(Object.assign({}, shape), { fill: theme === null || theme === void 0 ? void 0 : theme.primaryColor }),
|
|
108
|
-
});
|
|
109
|
-
const payload = Object.assign(Object.assign({}, shape), { fill: theme === null || theme === void 0 ? void 0 : theme.primaryColor });
|
|
110
|
-
if (activeTool === "text") {
|
|
111
|
-
setExtraComponentsState((prev) => [...prev, payload]);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
setComponentsState((prev) => [...prev, payload]);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
const getSvgCoords = (e) => {
|
|
118
|
-
var _a;
|
|
119
|
-
const svg = svgRef.current;
|
|
120
|
-
const point = svg.createSVGPoint();
|
|
121
|
-
point.x = e.clientX;
|
|
122
|
-
point.y = e.clientY;
|
|
123
|
-
const transformed = point.matrixTransform((_a = svg.getScreenCTM()) === null || _a === void 0 ? void 0 : _a.inverse());
|
|
124
|
-
return { x: transformed.x, y: transformed.y };
|
|
125
|
-
};
|
|
126
|
-
const createShape = (x, y, fill) => ({
|
|
127
|
-
x,
|
|
128
|
-
y,
|
|
129
|
-
width: 50,
|
|
130
|
-
height: 50,
|
|
131
|
-
shape: activeTool,
|
|
132
|
-
id: Date.now(),
|
|
133
|
-
fill,
|
|
134
|
-
rotation: activeTool === "diamond" ? 45 : 0,
|
|
135
|
-
seatCount: activeTool === "table-seat-circle" ? 6 : 0,
|
|
136
|
-
openSpace: activeTool === "table-seat-circle" ? 0 : undefined,
|
|
137
|
-
seatFill: activeTool === "table-seat-circle" ? "#DADADA" : undefined,
|
|
138
|
-
text: activeTool === "text" ? "Text" : "",
|
|
139
|
-
fontColor: activeTool === "text" ? "#DADADA" : undefined,
|
|
140
|
-
});
|
|
141
|
-
const handleMouseDown = (e, item, direction) => {
|
|
142
|
-
if (activeTool === "select" && item && !direction) {
|
|
143
|
-
startPos.current = { x: e.clientX, y: e.clientY };
|
|
144
|
-
const rectBox = (e === null || e === void 0 ? void 0 : e.target).getBoundingClientRect();
|
|
145
|
-
setDragOffset({
|
|
146
|
-
x: e.clientX - rectBox.left + ((item === null || item === void 0 ? void 0 : item.strokeWidth) || 0),
|
|
147
|
-
y: e.clientY - rectBox.top + ((item === null || item === void 0 ? void 0 : item.strokeWidth) || 0),
|
|
148
|
-
});
|
|
149
|
-
const handleMouseMove = (event) => {
|
|
150
|
-
const dx = Math.abs(event.clientX - startPos.current.x);
|
|
151
|
-
const dy = Math.abs(event.clientY - startPos.current.y);
|
|
152
|
-
if (dx > 1 || dy > 1) {
|
|
153
|
-
if (!moveComponent.current && item) {
|
|
154
|
-
dispatch({ type: "panel/setSelectedComponent", payload: item });
|
|
155
|
-
setSelectedComponent(item);
|
|
156
|
-
}
|
|
157
|
-
moveComponent.current = true;
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
const handleMouseUp = () => {
|
|
161
|
-
document.removeEventListener("mousemove", handleMouseMove);
|
|
162
|
-
document.removeEventListener("mouseup", handleMouseUp);
|
|
163
|
-
if (moveComponent.current) {
|
|
164
|
-
moveComponent.current = false;
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
isDragging.current = true;
|
|
168
|
-
moveComponent.current = false;
|
|
169
|
-
setResizeDirection(direction);
|
|
170
|
-
if (item) {
|
|
171
|
-
dispatch({ type: "panel/setSelectedComponent", payload: item });
|
|
172
|
-
dispatch({ type: "panel/setShow", payload: true });
|
|
173
|
-
setSelectedComponent(item);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
// Pasang ke `document` agar global
|
|
178
|
-
document.addEventListener("mousemove", handleMouseMove);
|
|
179
|
-
document.addEventListener("mouseup", handleMouseUp);
|
|
180
|
-
}
|
|
181
|
-
if (activeTool === "select" && direction) {
|
|
182
|
-
setResizeDirection(direction);
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
const handleMouseEnter = () => {
|
|
186
|
-
if (![
|
|
187
|
-
"square",
|
|
188
|
-
"circle",
|
|
189
|
-
"diamond",
|
|
190
|
-
"table-seat-circle",
|
|
191
|
-
"table-seat-square",
|
|
192
|
-
"text",
|
|
193
|
-
].includes(activeTool))
|
|
194
|
-
return;
|
|
195
|
-
};
|
|
196
|
-
const handleMouseLeave = () => {
|
|
197
|
-
if (![
|
|
198
|
-
"square",
|
|
199
|
-
"circle",
|
|
200
|
-
"diamond",
|
|
201
|
-
"table-seat-circle",
|
|
202
|
-
"table-seat-square",
|
|
203
|
-
"text",
|
|
204
|
-
].includes(activeTool))
|
|
205
|
-
return;
|
|
206
|
-
setShadowShape([]);
|
|
207
|
-
};
|
|
208
|
-
const handleMouseClick = (e) => {
|
|
209
|
-
if (activeTool === "select" && selectedComponent) {
|
|
210
|
-
handleUnSelectComponent();
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
if (![
|
|
214
|
-
"square",
|
|
215
|
-
"circle",
|
|
216
|
-
"diamond",
|
|
217
|
-
"table-seat-circle",
|
|
218
|
-
"table-seat-square",
|
|
219
|
-
"text",
|
|
220
|
-
].includes(activeTool)) {
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
const { x, y } = getSvgCoords(e);
|
|
224
|
-
setStartPoint({ x, y });
|
|
225
|
-
handleAddComponent(createShape(x, y, theme === null || theme === void 0 ? void 0 : theme.primaryColor));
|
|
226
|
-
};
|
|
227
|
-
const throttledDispatch = useCallback(throttle((component) => {
|
|
228
|
-
// dispatch({
|
|
229
|
-
// type: "board/updateComponent",
|
|
230
|
-
// payload: component,
|
|
231
|
-
// });
|
|
232
|
-
dispatch({
|
|
233
|
-
type: "panel/updateSelectedComponent",
|
|
234
|
-
payload: component,
|
|
235
|
-
});
|
|
236
|
-
}, 16), // 16ms ≈ 60fps
|
|
237
|
-
[dispatch]);
|
|
238
|
-
const handleMouseMove = (e) => {
|
|
239
|
-
if ([
|
|
240
|
-
"square",
|
|
241
|
-
"circle",
|
|
242
|
-
"diamond",
|
|
243
|
-
"table-seat-circle",
|
|
244
|
-
"table-seat-square",
|
|
245
|
-
"text",
|
|
246
|
-
"ruler",
|
|
247
|
-
].includes(activeTool)) {
|
|
248
|
-
const { x, y } = getSvgCoords(e);
|
|
249
|
-
setShadowShape([createShape(x, y, theme === null || theme === void 0 ? void 0 : theme.primaryColor)]);
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
if (activeTool === "select" &&
|
|
253
|
-
selectedComponent &&
|
|
254
|
-
moveComponent.current &&
|
|
255
|
-
dragOffset &&
|
|
256
|
-
// !isTouching.current &&
|
|
257
|
-
!resizeDirection) {
|
|
258
|
-
const workspaceRect = e.currentTarget.getBoundingClientRect();
|
|
259
|
-
const newX = e.clientX - workspaceRect.left - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.x);
|
|
260
|
-
const newY = e.clientY - workspaceRect.top - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.y);
|
|
261
|
-
let newPosition = {
|
|
262
|
-
x: newX,
|
|
263
|
-
y: newY,
|
|
264
|
-
};
|
|
265
|
-
requestAnimationFrame(() => {
|
|
266
|
-
setComponentsState((prev) => {
|
|
267
|
-
return prev.map((component) => {
|
|
268
|
-
if (component.id === selectedComponent.id) {
|
|
269
|
-
return Object.assign(Object.assign({}, component), { x: newPosition.x, y: newPosition.y });
|
|
270
|
-
}
|
|
271
|
-
return component;
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
setExtraComponentsState((prev) => {
|
|
275
|
-
return prev.map((component) => {
|
|
276
|
-
if (component.id === selectedComponent.id) {
|
|
277
|
-
return Object.assign(Object.assign({}, component), { x: newPosition.x, y: newPosition.y });
|
|
278
|
-
}
|
|
279
|
-
return component;
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
setSelectedComponent((prev) => {
|
|
283
|
-
return Object.assign(Object.assign({}, prev), { x: newPosition.x, y: newPosition.y });
|
|
284
|
-
});
|
|
285
|
-
});
|
|
286
|
-
debouncedSyncToReduxSelected(Object.assign(Object.assign({}, selectedComponent), newPosition));
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
if (activeTool === "select" && resizeDirection) {
|
|
290
|
-
const workspaceRect = e.currentTarget.getBoundingClientRect();
|
|
291
|
-
const currentX = e.clientX - workspaceRect.left;
|
|
292
|
-
const currentY = e.clientY - workspaceRect.top;
|
|
293
|
-
const { x, y, width, height } = selectedComponent;
|
|
294
|
-
let newShape = Object.assign({}, selectedComponent);
|
|
295
|
-
if (!["table-seat-circle", "table-seat-square"].includes(selectedComponent.shape)) {
|
|
296
|
-
switch (resizeDirection) {
|
|
297
|
-
case "top-left":
|
|
298
|
-
newShape.width = width + (x - currentX);
|
|
299
|
-
newShape.height = height + (y - currentY);
|
|
300
|
-
newShape.x = currentX;
|
|
301
|
-
newShape.y = currentY;
|
|
302
|
-
break;
|
|
303
|
-
case "top-right":
|
|
304
|
-
newShape.width = currentX - newShape.x;
|
|
305
|
-
newShape.height = newShape.height + (newShape.y - currentY);
|
|
306
|
-
newShape.y = currentY;
|
|
307
|
-
break;
|
|
308
|
-
case "bottom-left":
|
|
309
|
-
newShape.width += newShape.x - currentX;
|
|
310
|
-
newShape.height = currentY - newShape.y;
|
|
311
|
-
newShape.x = currentX;
|
|
312
|
-
break;
|
|
313
|
-
case "bottom-right":
|
|
314
|
-
newShape.width = currentX - newShape.x;
|
|
315
|
-
newShape.height = currentY - newShape.y;
|
|
316
|
-
break;
|
|
317
|
-
case "left-center":
|
|
318
|
-
newShape.width += newShape.x - currentX;
|
|
319
|
-
newShape.x = currentX;
|
|
320
|
-
break;
|
|
321
|
-
case "right-center":
|
|
322
|
-
newShape.width = currentX - newShape.x;
|
|
323
|
-
break;
|
|
324
|
-
case "top-center":
|
|
325
|
-
newShape.height += newShape.y - currentY;
|
|
326
|
-
newShape.y = currentY;
|
|
327
|
-
break;
|
|
328
|
-
case "bottom-center":
|
|
329
|
-
newShape.height = currentY - newShape.y;
|
|
330
|
-
break;
|
|
331
|
-
default:
|
|
332
|
-
break;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
else if (["table-seat-circle", "table-seat-square"].includes(selectedComponent.shape)) {
|
|
336
|
-
switch (resizeDirection) {
|
|
337
|
-
case "top-left":
|
|
338
|
-
newShape.width = width + (x - currentX);
|
|
339
|
-
newShape.height = height + (y - currentY);
|
|
340
|
-
newShape.x = currentX;
|
|
341
|
-
newShape.y = currentY;
|
|
342
|
-
break;
|
|
343
|
-
case "top-right":
|
|
344
|
-
newShape.width = currentX - newShape.x;
|
|
345
|
-
newShape.height = newShape.height + (newShape.y - currentY);
|
|
346
|
-
newShape.y = currentY;
|
|
347
|
-
break;
|
|
348
|
-
case "bottom-left":
|
|
349
|
-
newShape.width += newShape.x - currentX;
|
|
350
|
-
newShape.height = currentY - newShape.y;
|
|
351
|
-
newShape.x = currentX;
|
|
352
|
-
break;
|
|
353
|
-
case "bottom-right":
|
|
354
|
-
newShape.width = currentX - newShape.x;
|
|
355
|
-
newShape.height = currentY - newShape.y;
|
|
356
|
-
break;
|
|
357
|
-
default:
|
|
358
|
-
break;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
// updateComponentRef({
|
|
362
|
-
// ...(typeof selectedComponent === "object" && selectedComponent !== null
|
|
363
|
-
// ? selectedComponent
|
|
364
|
-
// : {}),
|
|
365
|
-
// ...newShape,
|
|
366
|
-
// });
|
|
367
|
-
requestAnimationFrame(() => {
|
|
368
|
-
setComponentsState((prev) => {
|
|
369
|
-
return prev.map((component) => {
|
|
370
|
-
if (component.id === selectedComponent.id) {
|
|
371
|
-
return Object.assign(Object.assign({}, component), newShape);
|
|
372
|
-
}
|
|
373
|
-
return component;
|
|
374
|
-
});
|
|
375
|
-
});
|
|
376
|
-
setExtraComponentsState((prev) => {
|
|
377
|
-
return prev.map((component) => {
|
|
378
|
-
if (component.id === selectedComponent.id) {
|
|
379
|
-
return Object.assign(Object.assign({}, component), newShape);
|
|
380
|
-
}
|
|
381
|
-
return component;
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
setSelectedComponent(newShape);
|
|
385
|
-
});
|
|
386
|
-
debouncedSyncToReduxSelected(newShape);
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
const handleMouseUp = () => {
|
|
390
|
-
if (activeTool === "select" && selectedComponent && isDragging.current) {
|
|
391
|
-
setResizeDirection(null);
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
useEffect(() => {
|
|
395
|
-
if (containerRef.current) {
|
|
396
|
-
setWidthBoard(containerRef.current.offsetWidth);
|
|
397
|
-
setHeightBoard(containerRef.current.offsetHeight);
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
const handleUnSelectComponent = () => {
|
|
401
|
-
dispatch({ type: "panel/setSelectedComponent", payload: null });
|
|
402
|
-
setSelectedComponent(null);
|
|
403
|
-
};
|
|
404
|
-
const handleTouchStart = (e, items, direction) => {
|
|
405
|
-
var _a, _b, _c, _d;
|
|
406
|
-
if (activeTool === "select" && !direction && items) {
|
|
407
|
-
// dispatch({ type: "panel/setShow", payload: false });
|
|
408
|
-
// setMoveComponent(true);
|
|
409
|
-
moveComponent.current = true;
|
|
410
|
-
isTouching.current = true;
|
|
411
|
-
// dispatch({ type: "panel/setSelectedComponent", payload: item });
|
|
412
|
-
onSelectComponent && onSelectComponent(items);
|
|
413
|
-
dispatch({ type: "panel/setSelectedComponent", payload: items });
|
|
414
|
-
setSelectedComponent(items);
|
|
415
|
-
// selectedComponentRef.current = items;
|
|
416
|
-
const touch = e.touches[0];
|
|
417
|
-
const svg = e.currentTarget.ownerSVGElement;
|
|
418
|
-
const pt = svg.createSVGPoint();
|
|
419
|
-
if (!svg)
|
|
420
|
-
return;
|
|
421
|
-
pt.x = touch.clientX;
|
|
422
|
-
pt.y = touch.clientY;
|
|
423
|
-
const cursorpt = pt.matrixTransform((_a = svg.getScreenCTM()) === null || _a === void 0 ? void 0 : _a.inverse());
|
|
424
|
-
screenCTMRef.current = ((_b = svg.getScreenCTM()) === null || _b === void 0 ? void 0 : _b.inverse()) || null;
|
|
425
|
-
setDragOffset({
|
|
426
|
-
x: cursorpt.x - items.x,
|
|
427
|
-
y: cursorpt.y - items.y,
|
|
428
|
-
});
|
|
429
|
-
// dragOffset.current = {
|
|
430
|
-
// x: cursorpt.x - items.x,
|
|
431
|
-
// y: cursorpt.y - items.y
|
|
432
|
-
// }
|
|
433
|
-
}
|
|
434
|
-
else if (activeTool === "select" && direction) {
|
|
435
|
-
setResizeDirection(direction);
|
|
436
|
-
// setIsDragging(true);
|
|
437
|
-
// setMoveComponent(true);
|
|
438
|
-
moveComponent.current = true;
|
|
439
|
-
isDragging.current = true;
|
|
440
|
-
isTouching.current = true;
|
|
441
|
-
const touch = e.touches[0];
|
|
442
|
-
const svg = e.currentTarget.ownerSVGElement;
|
|
443
|
-
const pt = svg.createSVGPoint();
|
|
444
|
-
if (!svg)
|
|
445
|
-
return;
|
|
446
|
-
pt.x = touch.clientX;
|
|
447
|
-
pt.y = touch.clientY;
|
|
448
|
-
const cursorpt = pt.matrixTransform((_c = svg.getScreenCTM()) === null || _c === void 0 ? void 0 : _c.inverse());
|
|
449
|
-
screenCTMRef.current = ((_d = svg.getScreenCTM()) === null || _d === void 0 ? void 0 : _d.inverse()) || null;
|
|
450
|
-
setDragOffset({
|
|
451
|
-
x: cursorpt.x - items.x,
|
|
452
|
-
y: cursorpt.y - items.y,
|
|
453
|
-
});
|
|
454
|
-
// dragOffset.current = {
|
|
455
|
-
// x: cursorpt.x - items.x,
|
|
456
|
-
// y: cursorpt.y - items.y
|
|
457
|
-
// }
|
|
458
|
-
}
|
|
459
|
-
};
|
|
460
|
-
const handleTouchMove = (e) => {
|
|
461
|
-
if (activeTool === "select" &&
|
|
462
|
-
moveComponent &&
|
|
463
|
-
isTouching.current &&
|
|
464
|
-
!resizeDirection) {
|
|
465
|
-
isDragging.current = true;
|
|
466
|
-
moveComponent.current = true;
|
|
467
|
-
const touch = e.touches[0];
|
|
468
|
-
const svg = e.currentTarget.ownerSVGElement;
|
|
469
|
-
if (!svg)
|
|
470
|
-
return;
|
|
471
|
-
const pt = svg.createSVGPoint();
|
|
472
|
-
pt.x = touch.clientX;
|
|
473
|
-
pt.y = touch.clientY;
|
|
474
|
-
const cursorpt = pt.matrixTransform(screenCTMRef.current);
|
|
475
|
-
requestAnimationFrame(() => {
|
|
476
|
-
if ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) != "background") {
|
|
477
|
-
setComponentsState((prev) => {
|
|
478
|
-
return prev.map((component) => {
|
|
479
|
-
if (component.id === selectedComponent.id) {
|
|
480
|
-
return Object.assign(Object.assign({}, component), { x: cursorpt.x - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.x), y: cursorpt.y - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.y) });
|
|
481
|
-
}
|
|
482
|
-
return component;
|
|
483
|
-
});
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
|
-
if ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) == "background") {
|
|
487
|
-
setExtraComponentsState((prev) => {
|
|
488
|
-
return prev.map((component) => {
|
|
489
|
-
if (component.id === selectedComponent.id) {
|
|
490
|
-
return Object.assign(Object.assign({}, component), { x: cursorpt.x - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.x), y: cursorpt.y - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.y) });
|
|
491
|
-
}
|
|
492
|
-
return component;
|
|
493
|
-
});
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
setSelectedComponent(Object.assign(Object.assign({}, selectedComponent), { x: cursorpt.x - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.x), y: cursorpt.y - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.y) }));
|
|
497
|
-
});
|
|
498
|
-
// updateComponentRef({
|
|
499
|
-
// ...(typeof selectedComponent === "object" && selectedComponent !== null
|
|
500
|
-
// ? selectedComponent
|
|
501
|
-
// : {}),
|
|
502
|
-
// x: cursorpt.x - dragOffset?.current.x,
|
|
503
|
-
// y: cursorpt.y - dragOffset?.current.y,
|
|
504
|
-
// });
|
|
505
|
-
}
|
|
506
|
-
else if (activeTool === "select" &&
|
|
507
|
-
moveComponent.current &&
|
|
508
|
-
isTouching.current &&
|
|
509
|
-
resizeDirection) {
|
|
510
|
-
// setIsDragging(true);
|
|
511
|
-
isDragging.current = true;
|
|
512
|
-
const touch = e.touches[0];
|
|
513
|
-
const svg = e.currentTarget.ownerSVGElement;
|
|
514
|
-
if (!svg)
|
|
515
|
-
return;
|
|
516
|
-
const pt = svg.createSVGPoint();
|
|
517
|
-
pt.x = touch.clientX;
|
|
518
|
-
pt.y = touch.clientY;
|
|
519
|
-
const cursorpt = pt.matrixTransform(screenCTMRef.current);
|
|
520
|
-
let newShape = Object.assign({}, selectedComponent);
|
|
521
|
-
switch (resizeDirection) {
|
|
522
|
-
case "top-left":
|
|
523
|
-
newShape.width = newShape.width + (newShape.x - cursorpt.x);
|
|
524
|
-
newShape.height = newShape.height + (newShape.y - cursorpt.y);
|
|
525
|
-
newShape.x = cursorpt.x;
|
|
526
|
-
newShape.y = cursorpt.y;
|
|
527
|
-
break;
|
|
528
|
-
case "top-right":
|
|
529
|
-
newShape.width = cursorpt.x - newShape.x;
|
|
530
|
-
newShape.height = newShape.height + (newShape.y - cursorpt.y);
|
|
531
|
-
newShape.y = cursorpt.y;
|
|
532
|
-
break;
|
|
533
|
-
case "bottom-left":
|
|
534
|
-
newShape.width = newShape.width + (newShape.x - cursorpt.x);
|
|
535
|
-
newShape.height = cursorpt.y - newShape.y;
|
|
536
|
-
newShape.x = cursorpt.x;
|
|
537
|
-
break;
|
|
538
|
-
case "bottom-right":
|
|
539
|
-
newShape.width = cursorpt.x - newShape.x;
|
|
540
|
-
newShape.height = cursorpt.y - newShape.y;
|
|
541
|
-
break;
|
|
542
|
-
case "top-center":
|
|
543
|
-
newShape.height = newShape.height + (newShape.y - cursorpt.y);
|
|
544
|
-
newShape.y = cursorpt.y;
|
|
545
|
-
break;
|
|
546
|
-
case "bottom-center":
|
|
547
|
-
newShape.height = cursorpt.y - newShape.y;
|
|
548
|
-
break;
|
|
549
|
-
case "right-center":
|
|
550
|
-
newShape.width = cursorpt.x - newShape.x;
|
|
551
|
-
break;
|
|
552
|
-
case "left-center":
|
|
553
|
-
newShape.width = newShape.width + (newShape.x - cursorpt.x);
|
|
554
|
-
newShape.x = cursorpt.x;
|
|
555
|
-
break;
|
|
556
|
-
default:
|
|
557
|
-
break;
|
|
558
|
-
}
|
|
559
|
-
// updateComponentRef({
|
|
560
|
-
// ...(typeof selectedComponent === "object" && selectedComponent !== null
|
|
561
|
-
// ? selectedComponent
|
|
562
|
-
// : {}),
|
|
563
|
-
// ...newShape,
|
|
564
|
-
// });
|
|
565
|
-
requestAnimationFrame(() => {
|
|
566
|
-
setComponentsState((prev) => {
|
|
567
|
-
return prev.map((component) => {
|
|
568
|
-
if (component.id === selectedComponent.id) {
|
|
569
|
-
return Object.assign(Object.assign({}, component), newShape);
|
|
570
|
-
}
|
|
571
|
-
return component;
|
|
572
|
-
});
|
|
573
|
-
});
|
|
574
|
-
setExtraComponentsState((prev) => {
|
|
575
|
-
return prev.map((component) => {
|
|
576
|
-
if (component.id === selectedComponent.id) {
|
|
577
|
-
return Object.assign(Object.assign({}, component), newShape);
|
|
578
|
-
}
|
|
579
|
-
return component;
|
|
580
|
-
});
|
|
581
|
-
});
|
|
582
|
-
setSelectedComponent(Object.assign(Object.assign({}, selectedComponent), newShape));
|
|
583
|
-
});
|
|
584
|
-
debouncedSyncToReduxSelected(newShape);
|
|
585
|
-
}
|
|
586
|
-
};
|
|
587
|
-
const handleTouchEnd = () => {
|
|
588
|
-
// setMoveComponent(false);
|
|
589
|
-
// setIsDragging(false);
|
|
590
|
-
moveComponent.current = false;
|
|
591
|
-
isDragging.current = false;
|
|
592
|
-
isTouching.current = false;
|
|
593
|
-
setResizeDirection(null);
|
|
594
|
-
};
|
|
595
|
-
const getCursorStyle = () => {
|
|
596
|
-
if (activeTool === "select" && moveComponent.current) {
|
|
597
|
-
return "grabbing";
|
|
598
|
-
}
|
|
599
|
-
else if (activeTool === "select" && resizeDirection) {
|
|
600
|
-
return "grab";
|
|
601
|
-
}
|
|
602
|
-
else if (activeTool === "grab") {
|
|
603
|
-
return "grab";
|
|
604
|
-
}
|
|
605
|
-
else if (activeTool === "ruler") {
|
|
606
|
-
return "crosshair";
|
|
607
|
-
}
|
|
608
|
-
};
|
|
609
|
-
const renderMiniMap = () => {
|
|
610
|
-
return (<MiniMap width={250} height={250}>
|
|
611
|
-
<div className="w-full h-full">
|
|
612
|
-
<svg id="workspace" width="100%" height="100%" viewBox={`0 0 ${widthBoard} ${heightBoard}`} className="h-screen w-full" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" style={{
|
|
613
|
-
background: "#f5f5f5",
|
|
614
|
-
display: "block",
|
|
615
|
-
}}>
|
|
616
|
-
<Layers shadowShape={shadowShape} components={[...extraComponentsState, ...componentsState]} activeTool={activeTool}
|
|
617
|
-
// onClick={handleSelectComponent}
|
|
618
|
-
// onMouseDown={handleMouseDown}
|
|
619
|
-
// onMouseUp={handleMouseUp}
|
|
620
|
-
// onBlur={handleUnSelectComponent}
|
|
621
|
-
selectedComponent={selectedComponent}/>
|
|
622
|
-
</svg>
|
|
623
|
-
</div>
|
|
624
|
-
</MiniMap>);
|
|
625
|
-
};
|
|
626
|
-
const handelZoomIn = () => {
|
|
627
|
-
var _a;
|
|
628
|
-
if (activeTool !== "grab") {
|
|
629
|
-
dispatch({
|
|
630
|
-
type: "tool/setActiveTool",
|
|
631
|
-
payload: "grab",
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
(_a = transformRef.current) === null || _a === void 0 ? void 0 : _a.zoomIn();
|
|
635
|
-
};
|
|
636
|
-
const handleZoomOut = () => {
|
|
637
|
-
var _a;
|
|
638
|
-
if (activeTool !== "grab") {
|
|
639
|
-
dispatch({
|
|
640
|
-
type: "tool/setActiveTool",
|
|
641
|
-
payload: "grab",
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
(_a = transformRef.current) === null || _a === void 0 ? void 0 : _a.zoomOut();
|
|
645
|
-
};
|
|
646
|
-
// activeTool === "select" &&
|
|
647
|
-
// moveComponent &&
|
|
648
|
-
// isTouching.current &&
|
|
649
|
-
// !resizeDirection
|
|
650
|
-
return (<>
|
|
651
|
-
<ModalPreview>
|
|
652
|
-
<LayerView statusKey="status"/>
|
|
653
|
-
</ModalPreview>
|
|
654
|
-
<div className="relative w-full h-screen flex-1 overflow-hidden" ref={containerRef}>
|
|
655
|
-
<div className="absolute bottom-5 left-1/2 transform -translate-x-1/2 z-10">
|
|
656
|
-
<div className="flex gap-2">
|
|
657
|
-
<Button icon={<ZoomIn />} onClick={handelZoomIn}/>
|
|
658
|
-
<Button icon={<ZoomOut />} onClick={handleZoomOut}/>
|
|
659
|
-
</div>
|
|
660
|
-
</div>
|
|
661
|
-
<TransformWrapper ref={transformRef} panning={{ disabled: activeTool === "select" }} centerZoomedOut={true} onTransformed={({ state: { scale } }) => setScale(scale)} minScale={1} // sangat kecil = bisa zoom out jauh
|
|
662
|
-
maxScale={1000} initialScale={1} pinch={{ step: 1 }} smooth={true} doubleClick={{ step: 1, disabled: activeTool === "select" }} disablePadding>
|
|
663
|
-
{scale > 1 && (<div className="absolute bottom-[60px] left-1/2 transform -translate-x-1/2 z-10">
|
|
664
|
-
{renderMiniMap()}
|
|
665
|
-
</div>)}
|
|
666
|
-
<TransformComponent wrapperStyle={{
|
|
667
|
-
width: "100%",
|
|
668
|
-
height: "100%",
|
|
669
|
-
overflow: "hidden",
|
|
670
|
-
}} contentStyle={{
|
|
671
|
-
width: "100%",
|
|
672
|
-
height: "100%",
|
|
673
|
-
}}>
|
|
674
|
-
<svg id="workspace" ref={svgRef} width="100%" height="100%" viewBox={`0 0 ${widthBoard} ${heightBoard}`} className="h-screen" onMouseUp={handleMouseUp} onMouseMove={handleMouseMove} onMouseEnter={handleMouseEnter} onClick={(e) => {
|
|
675
|
-
e.stopPropagation();
|
|
676
|
-
handleMouseClick(e);
|
|
677
|
-
}} onMouseLeave={handleMouseLeave} xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" style={{
|
|
678
|
-
background: backgroundColor,
|
|
679
|
-
display: "block",
|
|
680
|
-
cursor: activeTool === "ruler" ? "crosshair" : "auto",
|
|
681
|
-
}}>
|
|
682
|
-
<Layers shadowShape={shadowShape} components={[...extraComponentsState, ...componentsState]} style={{
|
|
683
|
-
cursor: getCursorStyle(),
|
|
684
|
-
}}
|
|
685
|
-
// onClick={handleSelectComponent}
|
|
686
|
-
onMouseDown={handleMouseDown}
|
|
687
|
-
// onMouseUp={handleMouseUp}
|
|
688
|
-
onBlur={handleUnSelectComponent} selectedComponent={selectedComponent} activeTool={activeTool} onTouchStart={(e, item, direction) => handleTouchStart(e, item, direction)} onTouchMove={(e) => handleTouchMove(e)} onTouchEnd={handleTouchEnd}/>
|
|
689
|
-
{activeTool === "ruler" && (<>
|
|
690
|
-
<g id="horizontal-ruler">
|
|
691
|
-
<rect x="0" y="0" width={window.innerWidth} height="30" fill="#e0e0e0"/>
|
|
692
|
-
<g stroke="#888" font-size="10" text-anchor="middle">
|
|
693
|
-
{Array.from({ length: window.innerWidth / 50 }, (_, i) => (<g key={i}>
|
|
694
|
-
<line x1={i * 50} y1="0" x2={i * 50} y2="10"/>
|
|
695
|
-
<text x={i * 50} y="15">
|
|
696
|
-
{i * 50}
|
|
697
|
-
</text>
|
|
698
|
-
</g>))}
|
|
699
|
-
</g>
|
|
700
|
-
</g>
|
|
701
|
-
<g id="vertical-ruler">
|
|
702
|
-
<rect x="0" y="0" width="30" height={window.innerHeight} fill="#e0e0e0"/>
|
|
703
|
-
<g stroke="#888" font-size="10" text-anchor="middle">
|
|
704
|
-
{Array.from({ length: window.innerHeight / 10 }, (_, i) => (<g key={i}>
|
|
705
|
-
<line x1="0" y1={i * 50} x2="10" y2={i * 50}/>
|
|
706
|
-
<text x="15" y={i * 50}>
|
|
707
|
-
{i * 50}
|
|
708
|
-
</text>
|
|
709
|
-
</g>))}
|
|
710
|
-
</g>
|
|
711
|
-
</g>
|
|
712
|
-
</>)}
|
|
713
|
-
{grid && (<g stroke="#ddd" strokeWidth={0.5}>
|
|
714
|
-
{/* Vertical lines */}
|
|
715
|
-
{Array.from({ length: widthBoard / 10 }, (_, i) => (<line key={`v-${i}`} x1={i * 10} y1={0} x2={i * 10} y2={heightBoard}/>))}
|
|
716
|
-
|
|
717
|
-
{/* Horizontal lines */}
|
|
718
|
-
{Array.from({ length: heightBoard / 10 }, (_, i) => (<line key={`h-${i}`} x1={0} y1={i * 10} x2={widthBoard} y2={i * 10}/>))}
|
|
719
|
-
</g>)}
|
|
720
|
-
</svg>
|
|
721
|
-
</TransformComponent>
|
|
722
|
-
</TransformWrapper>
|
|
723
|
-
</div>
|
|
724
|
-
</>);
|
|
725
|
-
};
|
|
726
|
-
export default BoardTemplate;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import Board from "../board";
|
|
4
|
-
import SideTool from "../side-tool";
|
|
5
|
-
import ControlPanels from "../panel";
|
|
6
|
-
import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
|
|
7
|
-
import { isEqual } from "lodash";
|
|
8
|
-
import LayerView from "../view";
|
|
9
|
-
const TableEditor = (props) => {
|
|
10
|
-
const [initialValue, setInitialValue] = useState(null);
|
|
11
|
-
const { componentProps, extraComponentProps, onCurrentStateChange, dragOnly, mappingKey, viewOnly, } = props;
|
|
12
|
-
const { components, extraComponents, backgroundColor } = useAppSelector((state) => state.board);
|
|
13
|
-
const dispatch = useAppDispatch();
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (!viewOnly) {
|
|
16
|
-
dispatch({
|
|
17
|
-
type: "panel/setSelectedComponent",
|
|
18
|
-
payload: null,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}, [viewOnly]);
|
|
22
|
-
const onUpdateCurrentState = () => {
|
|
23
|
-
let matchInitialValueWithComponents = initialValue === null || initialValue === void 0 ? void 0 : initialValue.map((item) => {
|
|
24
|
-
if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
|
|
25
|
-
let findComponent = components === null || components === void 0 ? void 0 : components.find((c) => { var _a; return c.id === ((_a = item === null || item === void 0 ? void 0 : item[mappingKey]) === null || _a === void 0 ? void 0 : _a.id); });
|
|
26
|
-
if (!findComponent)
|
|
27
|
-
return undefined;
|
|
28
|
-
if (findComponent) {
|
|
29
|
-
return Object.assign(Object.assign({}, item), { [mappingKey]: Object.assign({}, findComponent) });
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
let findComponent = components === null || components === void 0 ? void 0 : components.find((c) => c.id === (item === null || item === void 0 ? void 0 : item.id));
|
|
34
|
-
if (!findComponent)
|
|
35
|
-
return undefined;
|
|
36
|
-
if (findComponent) {
|
|
37
|
-
return Object.assign(Object.assign({}, item), findComponent);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
const hasUndefined = matchInitialValueWithComponents === null || matchInitialValueWithComponents === void 0 ? void 0 : matchInitialValueWithComponents.some((item) => item === undefined);
|
|
42
|
-
if (!hasUndefined && !viewOnly) {
|
|
43
|
-
onCurrentStateChange({
|
|
44
|
-
components: matchInitialValueWithComponents,
|
|
45
|
-
extraComponents,
|
|
46
|
-
background: backgroundColor,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (!isEqual(components, convertComponentProps()) ||
|
|
52
|
-
!isEqual(extraComponents, extraComponentProps)) {
|
|
53
|
-
onCurrentStateChange && onUpdateCurrentState();
|
|
54
|
-
}
|
|
55
|
-
}, [components, extraComponents, backgroundColor]);
|
|
56
|
-
const convertComponentProps = () => {
|
|
57
|
-
let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item) => {
|
|
58
|
-
if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
|
|
59
|
-
return Object.assign({}, item === null || item === void 0 ? void 0 : item[mappingKey]);
|
|
60
|
-
}
|
|
61
|
-
return item;
|
|
62
|
-
});
|
|
63
|
-
return mappingData;
|
|
64
|
-
};
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
if (!isEqual(components, convertComponentProps()) && componentProps) {
|
|
67
|
-
let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item) => {
|
|
68
|
-
if (mappingKey && (item === null || item === void 0 ? void 0 : item[props.mappingKey])) {
|
|
69
|
-
return Object.assign({}, item[props.mappingKey]);
|
|
70
|
-
}
|
|
71
|
-
return item;
|
|
72
|
-
});
|
|
73
|
-
if (mappingKey) {
|
|
74
|
-
setInitialValue(componentProps);
|
|
75
|
-
}
|
|
76
|
-
dispatch({
|
|
77
|
-
type: "board/setNewComponents",
|
|
78
|
-
payload: mappingData,
|
|
79
|
-
});
|
|
80
|
-
dispatch({ type: "board/setFlagChange", payload: true });
|
|
81
|
-
}
|
|
82
|
-
if (!isEqual(extraComponents, extraComponentProps) && extraComponentProps) {
|
|
83
|
-
console.log("extraComponentProps from package", extraComponentProps);
|
|
84
|
-
dispatch({
|
|
85
|
-
type: "board/setNewExtraComponents",
|
|
86
|
-
payload: extraComponentProps,
|
|
87
|
-
});
|
|
88
|
-
dispatch({ type: "board/setFlagChange", payload: true });
|
|
89
|
-
}
|
|
90
|
-
if (props === null || props === void 0 ? void 0 : props.defaultBackground) {
|
|
91
|
-
dispatch({
|
|
92
|
-
type: "board/setBackgroundColor",
|
|
93
|
-
payload: props === null || props === void 0 ? void 0 : props.defaultBackground,
|
|
94
|
-
});
|
|
95
|
-
dispatch({ type: "board/setFlagChange", payload: true });
|
|
96
|
-
}
|
|
97
|
-
}, [componentProps, extraComponentProps, props === null || props === void 0 ? void 0 : props.defaultBackground]);
|
|
98
|
-
return (<>
|
|
99
|
-
<div className="w-full h-screen flex relative">
|
|
100
|
-
<div className="w-full h-full flex relative" style={{
|
|
101
|
-
display: !viewOnly ? "none" : "flex",
|
|
102
|
-
}}>
|
|
103
|
-
<LayerView statusKey="status"/>
|
|
104
|
-
</div>
|
|
105
|
-
<div className="w-full h-full flex relative" style={{
|
|
106
|
-
display: viewOnly ? "none" : "flex",
|
|
107
|
-
}}>
|
|
108
|
-
<SideTool dragOnly={dragOnly}/>
|
|
109
|
-
<Board onSelectComponent={props.onSelectComponent}/>
|
|
110
|
-
<ControlPanels action={props.action} responseMapping={props.responseMapping}/>
|
|
111
|
-
</div>
|
|
112
|
-
</div>
|
|
113
|
-
</>);
|
|
114
|
-
};
|
|
115
|
-
export default TableEditor;
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use client";
|
|
3
|
-
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
-
import { TransformWrapper, TransformComponent, } from "react-zoom-pan-pinch";
|
|
5
|
-
import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
|
|
6
|
-
import Layers from "../../components/layer";
|
|
7
|
-
import { isEqual } from "lodash";
|
|
8
|
-
const LayerView = (props) => {
|
|
9
|
-
const { componentProps, extraComponentProps, onSelectComponent, onCurrentStateChange, mappingKey, selectedTableColor, colorMatchKey, statusKey, defaultBackground, } = props;
|
|
10
|
-
const transformRef = useRef(null);
|
|
11
|
-
const containerRef = useRef(null);
|
|
12
|
-
const svgRef = useRef(null);
|
|
13
|
-
const [scale, setScale] = useState(1);
|
|
14
|
-
const [selectedTable, setSelectedTable] = useState(null);
|
|
15
|
-
const { components: componentsEditor, extraComponents: extraComponentsEditor, } = useAppSelector((state) => state.board);
|
|
16
|
-
const backgroundColor = useAppSelector((state) => state.board.backgroundColor);
|
|
17
|
-
const dispatch = useAppDispatch();
|
|
18
|
-
const convertComponentProps = () => {
|
|
19
|
-
let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item) => {
|
|
20
|
-
if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
|
|
21
|
-
return Object.assign({}, item === null || item === void 0 ? void 0 : item[mappingKey]);
|
|
22
|
-
}
|
|
23
|
-
return item;
|
|
24
|
-
});
|
|
25
|
-
return mappingData;
|
|
26
|
-
};
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (componentProps) {
|
|
29
|
-
if (!isEqual(componentsEditor, convertComponentProps())) {
|
|
30
|
-
let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item) => {
|
|
31
|
-
if (mappingKey && (item === null || item === void 0 ? void 0 : item[props.mappingKey])) {
|
|
32
|
-
return Object.assign({}, item[props.mappingKey]);
|
|
33
|
-
}
|
|
34
|
-
return item;
|
|
35
|
-
});
|
|
36
|
-
dispatch({
|
|
37
|
-
type: "board/setNewComponents",
|
|
38
|
-
payload: mappingData,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (extraComponentsEditor) {
|
|
43
|
-
if (!isEqual(extraComponentsEditor, extraComponentProps)) {
|
|
44
|
-
console.log("extraComponentProps from view", extraComponentProps);
|
|
45
|
-
dispatch({
|
|
46
|
-
type: "board/setNewExtraComponents",
|
|
47
|
-
payload: extraComponentProps,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (defaultBackground) {
|
|
52
|
-
dispatch({
|
|
53
|
-
type: "board/setBackgroundColor",
|
|
54
|
-
payload: defaultBackground,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}, [componentProps, extraComponentProps, defaultBackground]);
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
onCurrentStateChange &&
|
|
60
|
-
onCurrentStateChange({
|
|
61
|
-
components: componentsEditor,
|
|
62
|
-
extraComponents: extraComponentsEditor,
|
|
63
|
-
});
|
|
64
|
-
}, [componentsEditor, extraComponentsEditor]);
|
|
65
|
-
const handleSelectComponent = (items) => {
|
|
66
|
-
const find = componentsEditor.find((item) => {
|
|
67
|
-
if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
|
|
68
|
-
return item[mappingKey].id === (items === null || items === void 0 ? void 0 : items.id);
|
|
69
|
-
}
|
|
70
|
-
return (item === null || item === void 0 ? void 0 : item.id) === (items === null || items === void 0 ? void 0 : items.id);
|
|
71
|
-
});
|
|
72
|
-
onSelectComponent && onSelectComponent(find);
|
|
73
|
-
setSelectedTable(find);
|
|
74
|
-
};
|
|
75
|
-
const boundingBox = useMemo(() => {
|
|
76
|
-
var _a, _b, _c, _d, _e, _f;
|
|
77
|
-
if (!componentsEditor && (componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.length) === 0) {
|
|
78
|
-
return { minX: 0, minY: 0, width: 500, height: 500 };
|
|
79
|
-
}
|
|
80
|
-
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
81
|
-
componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.forEach((_) => {
|
|
82
|
-
var _a, _b, _c, _d;
|
|
83
|
-
const hasMappingKey = mappingKey && _[mappingKey];
|
|
84
|
-
let values = hasMappingKey ? _[mappingKey] : _;
|
|
85
|
-
if (!values)
|
|
86
|
-
return;
|
|
87
|
-
if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("square")) {
|
|
88
|
-
minX = Math.min(minX, values.x);
|
|
89
|
-
minY = Math.min(minY, values.y);
|
|
90
|
-
maxX = Math.max(maxX, values.x + values.width);
|
|
91
|
-
maxY = Math.max(maxY, values.y + values.height);
|
|
92
|
-
}
|
|
93
|
-
if ((_b = values === null || values === void 0 ? void 0 : values.shape) === null || _b === void 0 ? void 0 : _b.includes("circle")) {
|
|
94
|
-
minX = Math.min(minX, values.x);
|
|
95
|
-
minY = Math.min(minY, values.y);
|
|
96
|
-
maxX = Math.max(maxX, values.x + values.width);
|
|
97
|
-
maxY = Math.max(maxY, values.y + values.height);
|
|
98
|
-
}
|
|
99
|
-
if ((_c = values === null || values === void 0 ? void 0 : values.shape) === null || _c === void 0 ? void 0 : _c.includes("table-seat-circle")) {
|
|
100
|
-
minX = Math.min(minX, values.x);
|
|
101
|
-
minY = Math.min(minY, values.y);
|
|
102
|
-
maxX = Math.max(maxX, values.x + values.width);
|
|
103
|
-
maxY = Math.max(maxY, values.y + values.height);
|
|
104
|
-
}
|
|
105
|
-
if ((_d = values === null || values === void 0 ? void 0 : values.shape) === null || _d === void 0 ? void 0 : _d.includes("image-table")) {
|
|
106
|
-
minX = Math.min(minX, values.x);
|
|
107
|
-
minY = Math.min(minY, values.y);
|
|
108
|
-
maxX = Math.max(maxX, values.x + values.width);
|
|
109
|
-
maxY = Math.max(maxY, values.y + values.height);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.forEach((values) => {
|
|
113
|
-
var _a, _b;
|
|
114
|
-
if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("background")) {
|
|
115
|
-
minX = Math.min(minX, values.x);
|
|
116
|
-
minY = Math.min(minY, values.y);
|
|
117
|
-
maxX = Math.max(maxX, values.x + values.width);
|
|
118
|
-
maxY = Math.max(maxY, values.y + values.height);
|
|
119
|
-
}
|
|
120
|
-
if ((_b = values === null || values === void 0 ? void 0 : values.shape) === null || _b === void 0 ? void 0 : _b.includes("text")) {
|
|
121
|
-
minX = Math.min(minX, values.x);
|
|
122
|
-
minY = Math.min(minY, values.y);
|
|
123
|
-
maxX = Math.max(maxX, values.x + values.width);
|
|
124
|
-
maxY = Math.max(maxY, values.y + values.height);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) === 1 &&
|
|
128
|
-
((_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"))) {
|
|
129
|
-
minX = (_c = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _c === void 0 ? void 0 : _c.x;
|
|
130
|
-
minY = (_d = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _d === void 0 ? void 0 : _d.y;
|
|
131
|
-
maxX = (_e = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _e === void 0 ? void 0 : _e.width;
|
|
132
|
-
maxY = (_f = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _f === void 0 ? void 0 : _f.height;
|
|
133
|
-
}
|
|
134
|
-
if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) < 1) {
|
|
135
|
-
minX = minX - minX * 0.5;
|
|
136
|
-
minY = minY - minY * 0.5;
|
|
137
|
-
}
|
|
138
|
-
return {
|
|
139
|
-
minX,
|
|
140
|
-
minY,
|
|
141
|
-
width: maxX,
|
|
142
|
-
height: maxY,
|
|
143
|
-
};
|
|
144
|
-
}, [componentsEditor, extraComponentsEditor]);
|
|
145
|
-
const renderElements = (elementEditor, mappingKey, colorMatchKey) => {
|
|
146
|
-
return elementEditor === null || elementEditor === void 0 ? void 0 : elementEditor.map((editorItem, i) => {
|
|
147
|
-
var _a, _b, _c, _d;
|
|
148
|
-
const isUsingMapping = mappingKey &&
|
|
149
|
-
typeof editorItem[mappingKey] === "object" &&
|
|
150
|
-
editorItem[mappingKey] !== null;
|
|
151
|
-
const finalProps = isUsingMapping ? editorItem[mappingKey] : editorItem;
|
|
152
|
-
if (colorMatchKey) {
|
|
153
|
-
if (isUsingMapping) {
|
|
154
|
-
return Object.assign(Object.assign({}, finalProps), { fill: (_b = (_a = colorMatchKey.find((item) => item.key == (editorItem === null || editorItem === void 0 ? void 0 : editorItem[statusKey]))) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : finalProps.fill });
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
return Object.assign(Object.assign({}, finalProps), { fill: (_d = (_c = colorMatchKey.find((item) => item.key == (editorItem === null || editorItem === void 0 ? void 0 : editorItem[statusKey]))) === null || _c === void 0 ? void 0 : _c.color) !== null && _d !== void 0 ? _d : finalProps.fill });
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return finalProps;
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
const [fingerCount, setFingerCount] = useState(0);
|
|
164
|
-
useEffect(() => {
|
|
165
|
-
const container = document.getElementById("workspace");
|
|
166
|
-
const handleTouchStart = (e) => {
|
|
167
|
-
const count = e.touches.length;
|
|
168
|
-
setFingerCount(count);
|
|
169
|
-
};
|
|
170
|
-
const handleTouchEnd = () => {
|
|
171
|
-
setFingerCount(0);
|
|
172
|
-
};
|
|
173
|
-
if (container) {
|
|
174
|
-
container.addEventListener("touchstart", handleTouchStart);
|
|
175
|
-
container.addEventListener("touchend", handleTouchEnd);
|
|
176
|
-
}
|
|
177
|
-
return () => {
|
|
178
|
-
if (container) {
|
|
179
|
-
container.removeEventListener("touchstart", handleTouchStart);
|
|
180
|
-
container.removeEventListener("touchend", handleTouchEnd);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
}, []);
|
|
184
|
-
return (<div className="relative w-full h-full flex-1" ref={containerRef} style={{
|
|
185
|
-
height: "100vh",
|
|
186
|
-
overflow: "auto",
|
|
187
|
-
WebkitOverflowScrolling: "touch",
|
|
188
|
-
touchAction: "pan-y",
|
|
189
|
-
}} {...props.containerProps}>
|
|
190
|
-
<TransformWrapper ref={transformRef} {...props.transformProps} disabled={fingerCount === 1 && scale === 1} disablePadding={true}
|
|
191
|
-
// panning={{
|
|
192
|
-
// disabled: false,
|
|
193
|
-
// velocityDisabled: true,
|
|
194
|
-
// }}
|
|
195
|
-
// limitToBounds={false}
|
|
196
|
-
// doubleClick={{ disabled: true }}
|
|
197
|
-
// pinch={{ disabled: false }}
|
|
198
|
-
// wheel={{ disabled: true }}
|
|
199
|
-
// disabled={true}
|
|
200
|
-
// disablePadding={true}
|
|
201
|
-
centerZoomedOut={true} onTransformed={({ state: { scale } }) => setScale(scale)} minScale={1} maxScale={1000} initialScale={1}
|
|
202
|
-
// pinch={{ step: 1 }}
|
|
203
|
-
smooth={true}>
|
|
204
|
-
<TransformComponent wrapperStyle={{
|
|
205
|
-
width: "100%",
|
|
206
|
-
height: "100%",
|
|
207
|
-
overflow: "visible",
|
|
208
|
-
}} contentStyle={{
|
|
209
|
-
width: "100%",
|
|
210
|
-
height: "100%",
|
|
211
|
-
}}>
|
|
212
|
-
<svg {...props.svgProps} id="workspace" ref={svgRef} width="100%" height="100%" viewBox={`${boundingBox.minX} ${boundingBox.minY} ${boundingBox.width} ${boundingBox.height}`} className="h-full" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" style={{
|
|
213
|
-
background: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : defaultBackground,
|
|
214
|
-
display: "block",
|
|
215
|
-
pointerEvents: "auto",
|
|
216
|
-
// touchAction: "pan-y",
|
|
217
|
-
}}>
|
|
218
|
-
<Layers mode="view" components={[
|
|
219
|
-
...((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) > 0 ? extraComponentsEditor : []),
|
|
220
|
-
...renderElements(componentsEditor, mappingKey, colorMatchKey),
|
|
221
|
-
]} onClick={handleSelectComponent} selectedTable={selectedTable} selectedTableColor={selectedTableColor}/>
|
|
222
|
-
</svg>
|
|
223
|
-
</TransformComponent>
|
|
224
|
-
</TransformWrapper>
|
|
225
|
-
</div>);
|
|
226
|
-
};
|
|
227
|
-
export default LayerView;
|