seat-editor 1.4.21 → 1.4.22
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/package/index.js +7 -2
- package/dist/features/view/index.js +1 -1
- package/package.json +1 -1
- package/dist/app/layout.jsx +0 -27
- package/dist/app/new-board/page.jsx +0 -53
- package/dist/app/old-board/page.jsx +0 -510
- package/dist/app/only-view/page.jsx +0 -40
- package/dist/app/page.jsx +0 -13
- package/dist/components/button-tools/index.jsx +0 -17
- package/dist/components/form-tools/label.jsx +0 -44
- package/dist/components/form-tools/shape.jsx +0 -66
- package/dist/components/input/number-indicator.jsx +0 -36
- package/dist/components/joystick/index.jsx +0 -49
- package/dist/components/layer/index.jsx +0 -361
- package/dist/components/lib/index.jsx +0 -33
- package/dist/components/modal-preview/index.jsx +0 -11
- package/dist/features/board/index.jsx +0 -654
- package/dist/features/navbar/index.jsx +0 -5
- package/dist/features/package/index.jsx +0 -107
- package/dist/features/panel/index.jsx +0 -105
- package/dist/features/panel/select-tool.jsx +0 -53
- package/dist/features/panel/square-circle-tool.jsx +0 -10
- package/dist/features/panel/table-seat-circle.jsx +0 -31
- package/dist/features/panel/text-tool.jsx +0 -22
- package/dist/features/panel/upload-tool.jsx +0 -177
- package/dist/features/side-tool/index.jsx +0 -261
- package/dist/features/view/index.jsx +0 -220
- package/dist/provider/antd-provider.jsx +0 -46
- package/dist/provider/redux-provider.jsx +0 -6
- package/dist/provider/store-provider.jsx +0 -10
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { Circle, CopyPlus, Eye, EyeOff, Image, Layers2, MousePointer, PaintBucket, Ratio, SquareMousePointer, Trash, Type, Upload, Hand, Layers } from "lucide-react";
|
|
3
|
-
import ButtonTools from "../../components/button-tools";
|
|
4
|
-
import { Divider, ColorPicker, Button, } from "antd";
|
|
5
|
-
import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
|
|
6
|
-
import { useState } from "react";
|
|
7
|
-
const SideTool = ({ dragOnly }) => {
|
|
8
|
-
const [color, setColor] = useState("#000000");
|
|
9
|
-
const dispatch = useAppDispatch();
|
|
10
|
-
const { active } = useAppSelector((state) => state.tool);
|
|
11
|
-
const { selectedComponent } = useAppSelector((state) => state.panel);
|
|
12
|
-
const { components, extraComponents } = useAppSelector((state) => state.board);
|
|
13
|
-
const [preview, setPreview] = useState(false);
|
|
14
|
-
const tools = [
|
|
15
|
-
{
|
|
16
|
-
id: "select",
|
|
17
|
-
name: "Select Tool",
|
|
18
|
-
icon: <MousePointer />,
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
id: "grab",
|
|
22
|
-
name: "Grab Tool",
|
|
23
|
-
icon: <Hand />,
|
|
24
|
-
}
|
|
25
|
-
];
|
|
26
|
-
const actionsTools = [
|
|
27
|
-
// {
|
|
28
|
-
// id: "table-split",
|
|
29
|
-
// name: "Table Split",
|
|
30
|
-
// icon: <TableCellsSplit />,
|
|
31
|
-
// },
|
|
32
|
-
{
|
|
33
|
-
id: "square",
|
|
34
|
-
name: "Square",
|
|
35
|
-
icon: <SquareMousePointer />,
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
id: "circle",
|
|
39
|
-
name: "Circle",
|
|
40
|
-
icon: <Circle />,
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
id: "table-seat-circle",
|
|
44
|
-
name: "Table Seat Circle",
|
|
45
|
-
icon: <Ratio />,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
id: "image-table",
|
|
49
|
-
name: "Image Table",
|
|
50
|
-
icon: <Upload />,
|
|
51
|
-
},
|
|
52
|
-
// {
|
|
53
|
-
// id: "table-seat-square",
|
|
54
|
-
// name: "Table Seat Square",
|
|
55
|
-
// icon: <Dock />,
|
|
56
|
-
// },
|
|
57
|
-
// {
|
|
58
|
-
// id: "diamond",
|
|
59
|
-
// name: "Diamond",
|
|
60
|
-
// icon: <Diamond />,
|
|
61
|
-
// },
|
|
62
|
-
];
|
|
63
|
-
const controlTools = [
|
|
64
|
-
{
|
|
65
|
-
id: "background",
|
|
66
|
-
name: "Background",
|
|
67
|
-
icon: <Image />,
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
id: "text",
|
|
71
|
-
name: "Text",
|
|
72
|
-
icon: <Type />,
|
|
73
|
-
},
|
|
74
|
-
// {
|
|
75
|
-
// id: "background-color",
|
|
76
|
-
// name: "Background Color",
|
|
77
|
-
// icon: <PaintBucket/>
|
|
78
|
-
// }
|
|
79
|
-
];
|
|
80
|
-
const hanldeSelectTool = (id) => {
|
|
81
|
-
if (id === "background" || id === "text" || id === "image-table") {
|
|
82
|
-
dispatch({
|
|
83
|
-
type: "panel/setShow",
|
|
84
|
-
payload: true,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
dispatch({
|
|
88
|
-
type: "tool/setActiveTool",
|
|
89
|
-
payload: id,
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
const handleChangeColorBackground = (color) => {
|
|
93
|
-
setColor(color.toHexString());
|
|
94
|
-
dispatch({
|
|
95
|
-
type: "board/setBackgroundColor",
|
|
96
|
-
payload: color.toHexString(),
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
const handleOpenModalPreview = () => {
|
|
100
|
-
dispatch({
|
|
101
|
-
type: "tool/setTooglePreview",
|
|
102
|
-
payload: true,
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
const handleRemoveComponent = () => {
|
|
106
|
-
dispatch({
|
|
107
|
-
type: "board/removeComponent",
|
|
108
|
-
payload: selectedComponent,
|
|
109
|
-
});
|
|
110
|
-
dispatch({
|
|
111
|
-
type: "board/removeExtraComponent",
|
|
112
|
-
payload: selectedComponent,
|
|
113
|
-
});
|
|
114
|
-
dispatch({ type: "board/setFlagChange", payload: true });
|
|
115
|
-
};
|
|
116
|
-
const handleDuplicateComponent = () => {
|
|
117
|
-
const newComponent = Object.assign(Object.assign({}, selectedComponent), { x: selectedComponent.x + 20, y: selectedComponent.y + 20, id: Date.now() });
|
|
118
|
-
dispatch({
|
|
119
|
-
type: "board/addComponent",
|
|
120
|
-
payload: newComponent,
|
|
121
|
-
});
|
|
122
|
-
dispatch({
|
|
123
|
-
type: "panel/setSelectedComponent",
|
|
124
|
-
payload: newComponent,
|
|
125
|
-
});
|
|
126
|
-
dispatch({ type: "board/setFlagChange", payload: true });
|
|
127
|
-
};
|
|
128
|
-
function swapOneStepById(arr, id, direction) {
|
|
129
|
-
const index = arr.findIndex((item) => (item === null || item === void 0 ? void 0 : item.id) === id);
|
|
130
|
-
if (index === -1)
|
|
131
|
-
return arr; // id tidak ditemukan
|
|
132
|
-
const newArr = [...arr];
|
|
133
|
-
if (direction === "left" && index > 0) {
|
|
134
|
-
[newArr[index - 1], newArr[index]] = [newArr[index], newArr[index - 1]];
|
|
135
|
-
}
|
|
136
|
-
if (direction === "right" && index < arr.length - 1) {
|
|
137
|
-
[newArr[index + 1], newArr[index]] = [newArr[index], newArr[index + 1]];
|
|
138
|
-
}
|
|
139
|
-
return newArr;
|
|
140
|
-
}
|
|
141
|
-
const handleOverride = () => {
|
|
142
|
-
if ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) === "background") {
|
|
143
|
-
const setNewExtraComponents = swapOneStepById(extraComponents, selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id, "right");
|
|
144
|
-
dispatch({
|
|
145
|
-
type: "board/setNewExtraComponents",
|
|
146
|
-
payload: setNewExtraComponents,
|
|
147
|
-
});
|
|
148
|
-
dispatch({ type: "board/setFlagChange", payload: true });
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
const newArr = swapOneStepById(components, selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id, "right");
|
|
152
|
-
dispatch({
|
|
153
|
-
type: "board/setNewComponents",
|
|
154
|
-
payload: newArr,
|
|
155
|
-
});
|
|
156
|
-
dispatch({ type: "board/setFlagChange", payload: true });
|
|
157
|
-
};
|
|
158
|
-
const handleOverrideLeft = () => {
|
|
159
|
-
if ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) === "background") {
|
|
160
|
-
const setNewExtraComponents = swapOneStepById(extraComponents, selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id, "left");
|
|
161
|
-
dispatch({
|
|
162
|
-
type: "board/setNewExtraComponents",
|
|
163
|
-
payload: setNewExtraComponents,
|
|
164
|
-
});
|
|
165
|
-
dispatch({ type: "board/setFlagChange", payload: true });
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
const newArr = swapOneStepById(components, selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id, "left");
|
|
169
|
-
dispatch({
|
|
170
|
-
type: "board/setNewComponents",
|
|
171
|
-
payload: newArr,
|
|
172
|
-
});
|
|
173
|
-
dispatch({ type: "board/setFlagChange", payload: true });
|
|
174
|
-
};
|
|
175
|
-
return (<div className="h-full left-0 flex flex-col items-center border-r-2 border-gray-300 bg-white px-2 pt-4">
|
|
176
|
-
{tools === null || tools === void 0 ? void 0 : tools.map((tool) => (<ButtonTools key={tool.id} buttonProps={{
|
|
177
|
-
icon: tool.icon,
|
|
178
|
-
type: "text",
|
|
179
|
-
name: tool.name,
|
|
180
|
-
onClick: () => hanldeSelectTool(tool.id),
|
|
181
|
-
style: active === tool.id ? { color: "red" } : {},
|
|
182
|
-
}} popoverProps={{
|
|
183
|
-
content: <div>{tool.name}</div>,
|
|
184
|
-
trigger: "hover",
|
|
185
|
-
placement: "right",
|
|
186
|
-
}} items={[]}/>))}
|
|
187
|
-
{!dragOnly && (<>
|
|
188
|
-
<ButtonTools buttonProps={{
|
|
189
|
-
icon: <CopyPlus />,
|
|
190
|
-
type: "text",
|
|
191
|
-
name: "duplicate",
|
|
192
|
-
onClick: () => handleDuplicateComponent(),
|
|
193
|
-
}} items={[]} popoverProps={{
|
|
194
|
-
content: <div>Duplicate</div>,
|
|
195
|
-
trigger: "hover",
|
|
196
|
-
placement: "right",
|
|
197
|
-
}}/>
|
|
198
|
-
<ButtonTools buttonProps={{
|
|
199
|
-
onClick: () => handleRemoveComponent(),
|
|
200
|
-
icon: <Trash />,
|
|
201
|
-
type: "text",
|
|
202
|
-
name: "trash",
|
|
203
|
-
}} items={[]} popoverProps={{
|
|
204
|
-
content: <div>Trash</div>,
|
|
205
|
-
trigger: "hover",
|
|
206
|
-
placement: "right",
|
|
207
|
-
}}/>
|
|
208
|
-
<ButtonTools buttonProps={{
|
|
209
|
-
onClick: () => handleOverride(),
|
|
210
|
-
icon: <Layers2 />,
|
|
211
|
-
type: "text",
|
|
212
|
-
name: "override",
|
|
213
|
-
}} items={[]} popoverProps={{
|
|
214
|
-
content: <div>Override Right</div>,
|
|
215
|
-
trigger: "hover",
|
|
216
|
-
placement: "right",
|
|
217
|
-
}}/>
|
|
218
|
-
<ButtonTools buttonProps={{
|
|
219
|
-
onClick: () => handleOverrideLeft(),
|
|
220
|
-
icon: <Layers />,
|
|
221
|
-
type: "text",
|
|
222
|
-
name: "override",
|
|
223
|
-
}} items={[]} popoverProps={{
|
|
224
|
-
content: <div>Override Left</div>,
|
|
225
|
-
trigger: "hover",
|
|
226
|
-
placement: "right",
|
|
227
|
-
}}/>
|
|
228
|
-
|
|
229
|
-
<Divider />
|
|
230
|
-
{actionsTools === null || actionsTools === void 0 ? void 0 : actionsTools.map((tool) => (<ButtonTools key={tool.id} buttonProps={{
|
|
231
|
-
icon: tool.icon,
|
|
232
|
-
type: "text",
|
|
233
|
-
name: tool.name,
|
|
234
|
-
onClick: () => hanldeSelectTool(tool.id),
|
|
235
|
-
style: active === tool.id ? { color: "red" } : {},
|
|
236
|
-
}} popoverProps={{
|
|
237
|
-
content: <div>{tool.name}</div>,
|
|
238
|
-
trigger: "hover",
|
|
239
|
-
placement: "right",
|
|
240
|
-
}} items={[]}/>))}
|
|
241
|
-
|
|
242
|
-
<Divider />
|
|
243
|
-
</>)}
|
|
244
|
-
{controlTools === null || controlTools === void 0 ? void 0 : controlTools.map((tool) => (<ButtonTools key={tool.id} buttonProps={{
|
|
245
|
-
icon: tool.icon,
|
|
246
|
-
type: "text",
|
|
247
|
-
name: tool.name,
|
|
248
|
-
onClick: () => hanldeSelectTool(tool.id),
|
|
249
|
-
style: active === tool.id ? { color: "red" } : {},
|
|
250
|
-
}} popoverProps={{
|
|
251
|
-
content: <div>{tool.name}</div>,
|
|
252
|
-
trigger: "hover",
|
|
253
|
-
placement: "right",
|
|
254
|
-
}} items={[]}/>))}
|
|
255
|
-
<ColorPicker value={color} onChange={handleChangeColorBackground}>
|
|
256
|
-
<Button icon={<PaintBucket />} type="text" name="Background Color" onClick={() => hanldeSelectTool("background-color")} style={active === "background-color" ? { color: "red" } : {}}/>
|
|
257
|
-
</ColorPicker>
|
|
258
|
-
<Button icon={preview ? <EyeOff /> : <Eye />} type="text" name="Preview" onClick={handleOpenModalPreview} style={active === "preview" ? { color: "red" } : {}}/>
|
|
259
|
-
</div>);
|
|
260
|
-
};
|
|
261
|
-
export default SideTool;
|
|
@@ -1,220 +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[mappingKey]);
|
|
22
|
-
}
|
|
23
|
-
return item;
|
|
24
|
-
});
|
|
25
|
-
return mappingData;
|
|
26
|
-
};
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (!isEqual(componentsEditor, convertComponentProps())) {
|
|
29
|
-
let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item) => {
|
|
30
|
-
if (mappingKey && (item === null || item === void 0 ? void 0 : item[props.mappingKey])) {
|
|
31
|
-
return Object.assign({}, item[props.mappingKey]);
|
|
32
|
-
}
|
|
33
|
-
return item;
|
|
34
|
-
});
|
|
35
|
-
dispatch({
|
|
36
|
-
type: "board/setNewComponents",
|
|
37
|
-
payload: mappingData,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
if (!isEqual(extraComponentsEditor, extraComponentProps)) {
|
|
41
|
-
dispatch({
|
|
42
|
-
type: "board/setNewExtraComponents",
|
|
43
|
-
payload: extraComponentProps,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
if (defaultBackground) {
|
|
47
|
-
dispatch({
|
|
48
|
-
type: "board/setBackgroundColor",
|
|
49
|
-
payload: defaultBackground,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}, [componentProps, extraComponentProps, defaultBackground]);
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
onCurrentStateChange &&
|
|
55
|
-
onCurrentStateChange({
|
|
56
|
-
components: componentsEditor,
|
|
57
|
-
extraComponents: extraComponentsEditor,
|
|
58
|
-
});
|
|
59
|
-
}, [componentsEditor, extraComponentsEditor]);
|
|
60
|
-
const handleSelectComponent = (items) => {
|
|
61
|
-
const find = componentsEditor.find((item) => {
|
|
62
|
-
if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
|
|
63
|
-
return item[mappingKey].id === (items === null || items === void 0 ? void 0 : items.id);
|
|
64
|
-
}
|
|
65
|
-
return (item === null || item === void 0 ? void 0 : item.id) === (items === null || items === void 0 ? void 0 : items.id);
|
|
66
|
-
});
|
|
67
|
-
onSelectComponent && onSelectComponent(find);
|
|
68
|
-
setSelectedTable(find);
|
|
69
|
-
};
|
|
70
|
-
const boundingBox = useMemo(() => {
|
|
71
|
-
var _a, _b, _c, _d, _e, _f;
|
|
72
|
-
if (!componentsEditor && (componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.length) === 0) {
|
|
73
|
-
return { minX: 0, minY: 0, width: 500, height: 500 };
|
|
74
|
-
}
|
|
75
|
-
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
76
|
-
componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.forEach((_) => {
|
|
77
|
-
var _a, _b, _c, _d;
|
|
78
|
-
let values = mappingKey ? _[mappingKey] : _;
|
|
79
|
-
if (!values)
|
|
80
|
-
return;
|
|
81
|
-
if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("square")) {
|
|
82
|
-
minX = Math.min(minX, values.x);
|
|
83
|
-
minY = Math.min(minY, values.y);
|
|
84
|
-
maxX = Math.max(maxX, values.x + values.width);
|
|
85
|
-
maxY = Math.max(maxY, values.y + values.height);
|
|
86
|
-
}
|
|
87
|
-
if ((_b = values === null || values === void 0 ? void 0 : values.shape) === null || _b === void 0 ? void 0 : _b.includes("circle")) {
|
|
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 ((_c = values === null || values === void 0 ? void 0 : values.shape) === null || _c === void 0 ? void 0 : _c.includes("table-seat-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 ((_d = values === null || values === void 0 ? void 0 : values.shape) === null || _d === void 0 ? void 0 : _d.includes("image-table")) {
|
|
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
|
-
});
|
|
106
|
-
extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.forEach((values) => {
|
|
107
|
-
var _a, _b;
|
|
108
|
-
if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("background")) {
|
|
109
|
-
minX = Math.min(minX, values.x);
|
|
110
|
-
minY = Math.min(minY, values.y);
|
|
111
|
-
maxX = Math.max(maxX, values.x + values.width);
|
|
112
|
-
maxY = Math.max(maxY, values.y + values.height);
|
|
113
|
-
}
|
|
114
|
-
if ((_b = values === null || values === void 0 ? void 0 : values.shape) === null || _b === void 0 ? void 0 : _b.includes("text")) {
|
|
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
|
-
});
|
|
121
|
-
if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) === 1 && ((_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"))) {
|
|
122
|
-
minX = (_c = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _c === void 0 ? void 0 : _c.x;
|
|
123
|
-
minY = (_d = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _d === void 0 ? void 0 : _d.y;
|
|
124
|
-
maxX = (_e = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _e === void 0 ? void 0 : _e.width;
|
|
125
|
-
maxY = (_f = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _f === void 0 ? void 0 : _f.height;
|
|
126
|
-
}
|
|
127
|
-
if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) < 1) {
|
|
128
|
-
minX = minX - minX * 0.5;
|
|
129
|
-
minY = minY - minY * 0.5;
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
minX,
|
|
133
|
-
minY,
|
|
134
|
-
width: maxX,
|
|
135
|
-
height: maxY,
|
|
136
|
-
};
|
|
137
|
-
}, [componentsEditor, extraComponentsEditor]);
|
|
138
|
-
const renderElements = (elementEditor, mappingKey, colorMatchKey) => {
|
|
139
|
-
return elementEditor.map((editorItem, i) => {
|
|
140
|
-
var _a, _b, _c, _d;
|
|
141
|
-
const isUsingMapping = mappingKey &&
|
|
142
|
-
typeof editorItem[mappingKey] === "object" &&
|
|
143
|
-
editorItem[mappingKey] !== null;
|
|
144
|
-
const finalProps = isUsingMapping ? editorItem[mappingKey] : editorItem;
|
|
145
|
-
if (colorMatchKey) {
|
|
146
|
-
if (isUsingMapping) {
|
|
147
|
-
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 });
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
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 });
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return finalProps;
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
const [fingerCount, setFingerCount] = useState(0);
|
|
157
|
-
useEffect(() => {
|
|
158
|
-
const container = document.getElementById("workspace");
|
|
159
|
-
const handleTouchStart = (e) => {
|
|
160
|
-
const count = e.touches.length;
|
|
161
|
-
setFingerCount(count);
|
|
162
|
-
};
|
|
163
|
-
const handleTouchEnd = () => {
|
|
164
|
-
setFingerCount(0);
|
|
165
|
-
};
|
|
166
|
-
if (container) {
|
|
167
|
-
container.addEventListener("touchstart", handleTouchStart);
|
|
168
|
-
container.addEventListener("touchend", handleTouchEnd);
|
|
169
|
-
}
|
|
170
|
-
return () => {
|
|
171
|
-
if (container) {
|
|
172
|
-
container.removeEventListener("touchstart", handleTouchStart);
|
|
173
|
-
container.removeEventListener("touchend", handleTouchEnd);
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
}, []);
|
|
177
|
-
return (<div className="relative w-full h-full flex-1" ref={containerRef} style={{
|
|
178
|
-
height: "100vh",
|
|
179
|
-
overflow: "auto",
|
|
180
|
-
WebkitOverflowScrolling: "touch",
|
|
181
|
-
touchAction: "pan-y",
|
|
182
|
-
}} {...props.containerProps}>
|
|
183
|
-
<TransformWrapper ref={transformRef} {...props.transformProps} disabled={fingerCount === 1 && scale === 1} disablePadding={true}
|
|
184
|
-
// panning={{
|
|
185
|
-
// disabled: false,
|
|
186
|
-
// velocityDisabled: true,
|
|
187
|
-
// }}
|
|
188
|
-
// limitToBounds={false}
|
|
189
|
-
// doubleClick={{ disabled: true }}
|
|
190
|
-
// pinch={{ disabled: false }}
|
|
191
|
-
// wheel={{ disabled: true }}
|
|
192
|
-
// disabled={true}
|
|
193
|
-
// disablePadding={true}
|
|
194
|
-
centerZoomedOut={true} onTransformed={({ state: { scale } }) => setScale(scale)} minScale={1} maxScale={1000} initialScale={1}
|
|
195
|
-
// pinch={{ step: 1 }}
|
|
196
|
-
smooth={true}>
|
|
197
|
-
<TransformComponent wrapperStyle={{
|
|
198
|
-
width: "100%",
|
|
199
|
-
height: "100%",
|
|
200
|
-
overflow: "visible",
|
|
201
|
-
}} contentStyle={{
|
|
202
|
-
width: "100%",
|
|
203
|
-
height: "100%",
|
|
204
|
-
}}>
|
|
205
|
-
<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={{
|
|
206
|
-
background: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : defaultBackground,
|
|
207
|
-
display: "block",
|
|
208
|
-
pointerEvents: "auto",
|
|
209
|
-
// touchAction: "pan-y",
|
|
210
|
-
}}>
|
|
211
|
-
<Layers mode="view" components={[
|
|
212
|
-
...extraComponentsEditor,
|
|
213
|
-
...renderElements(componentsEditor, mappingKey, colorMatchKey),
|
|
214
|
-
]} onClick={handleSelectComponent} selectedTable={selectedTable} selectedTableColor={selectedTableColor}/>
|
|
215
|
-
</svg>
|
|
216
|
-
</TransformComponent>
|
|
217
|
-
</TransformWrapper>
|
|
218
|
-
</div>);
|
|
219
|
-
};
|
|
220
|
-
export default LayerView;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { ConfigProvider } from "antd";
|
|
4
|
-
import { AntdRegistry } from "@ant-design/nextjs-registry";
|
|
5
|
-
import { useAppSelector, useAppDispatch } from "../hooks/use-redux";
|
|
6
|
-
export const AntdProvider = ({ children, themeColor }) => {
|
|
7
|
-
const dispatch = useAppDispatch();
|
|
8
|
-
const theme = useAppSelector((state) => state.theme);
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
if (themeColor !== theme.primaryColor) {
|
|
11
|
-
dispatch({
|
|
12
|
-
type: "theme/setPrimaryColor",
|
|
13
|
-
payload: themeColor
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}, [themeColor]);
|
|
17
|
-
return (<AntdRegistry>
|
|
18
|
-
<ConfigProvider theme={{
|
|
19
|
-
token: {
|
|
20
|
-
colorPrimary: themeColor,
|
|
21
|
-
},
|
|
22
|
-
// token: {
|
|
23
|
-
// colorPrimary: theme.theme["--primary-color"],
|
|
24
|
-
// colorPrimaryBorderHover: theme.theme["--primary-color"],
|
|
25
|
-
// fontFamily: "var(--font-inter), sans-serif",
|
|
26
|
-
// colorError: theme.theme["--danger"],
|
|
27
|
-
// controlOutlineWidth: 4,
|
|
28
|
-
// controlOutline: theme.theme["--surface-color"],
|
|
29
|
-
// colorBgContainerDisabled: "var(--netral-03)",
|
|
30
|
-
// colorTextPlaceholder: "var(--netral-06)",
|
|
31
|
-
// },
|
|
32
|
-
components: {
|
|
33
|
-
Form: {
|
|
34
|
-
labelFontSize: 14,
|
|
35
|
-
fontWeightStrong: 500,
|
|
36
|
-
itemMarginBottom: 12,
|
|
37
|
-
},
|
|
38
|
-
Button: {
|
|
39
|
-
colorPrimary: themeColor
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
}}>
|
|
43
|
-
{children}
|
|
44
|
-
</ConfigProvider>
|
|
45
|
-
</AntdRegistry>);
|
|
46
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { ReduxProvider } from "./redux-provider";
|
|
3
|
-
import { AntdProvider } from "./antd-provider";
|
|
4
|
-
import { injectSeatEditorCSS } from "../utils/injectCss";
|
|
5
|
-
export const StoreProvider = ({ children, themeColor = "red", }) => {
|
|
6
|
-
injectSeatEditorCSS();
|
|
7
|
-
return (<ReduxProvider>
|
|
8
|
-
<AntdProvider themeColor={themeColor}>{children}</AntdProvider>
|
|
9
|
-
</ReduxProvider>);
|
|
10
|
-
};
|