seat-editor 3.2.3 → 3.2.4
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/constant.js +3 -3
- package/dist/app/new-board/page.jsx +2 -3
- package/dist/components/layer-v3/index.jsx +5 -5
- package/dist/features/board-v3/board-slice.js +79 -9
- package/dist/features/board-v3/index.jsx +73 -25
- package/dist/features/panel/index.jsx +21 -8
- package/dist/features/panel/upload-tool.jsx +3 -0
- package/dist/features/panel/utils.js +1 -1
- package/package.json +1 -1
package/dist/app/constant.js
CHANGED
|
@@ -3372,7 +3372,7 @@ export const data4 = [
|
|
|
3372
3372
|
uuid_table: "axxxxx",
|
|
3373
3373
|
status: 0,
|
|
3374
3374
|
properties: {
|
|
3375
|
-
x:
|
|
3375
|
+
x: 500,
|
|
3376
3376
|
y: 520,
|
|
3377
3377
|
labels: [
|
|
3378
3378
|
{
|
|
@@ -3455,7 +3455,7 @@ export const data4 = [
|
|
|
3455
3455
|
},
|
|
3456
3456
|
],
|
|
3457
3457
|
opacity: 1,
|
|
3458
|
-
rotation:
|
|
3458
|
+
rotation: 0,
|
|
3459
3459
|
seatCount: 10,
|
|
3460
3460
|
openSpace: 0.3,
|
|
3461
3461
|
seatFill: "#ed8989",
|
|
@@ -3725,7 +3725,7 @@ export const data4 = [
|
|
|
3725
3725
|
{
|
|
3726
3726
|
status: 2,
|
|
3727
3727
|
properties: {
|
|
3728
|
-
x:
|
|
3728
|
+
x: 100,
|
|
3729
3729
|
y: 100,
|
|
3730
3730
|
id: "234243242342434",
|
|
3731
3731
|
stroke: "#347ADB", //warna border
|
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import SeatEditor from "../../features/package";
|
|
4
4
|
import { data4 } from "../constant";
|
|
5
|
-
import { dummyImage } from "../only-view/page";
|
|
6
5
|
export default function NewBoard() {
|
|
7
6
|
const [initialValue, setInitialValue] = useState([]);
|
|
8
7
|
const [extraComponents, setExtraComponents] = useState([]);
|
|
9
8
|
const [backgroundColor, setBackgroundColor] = useState("#000000");
|
|
10
|
-
const [viewOnly, setViewOnly] = useState(
|
|
9
|
+
const [viewOnly, setViewOnly] = useState(false);
|
|
11
10
|
useEffect(() => {
|
|
12
11
|
setInitialValue(data4);
|
|
13
|
-
setExtraComponents(
|
|
12
|
+
setExtraComponents([]);
|
|
14
13
|
}, []);
|
|
15
14
|
return (<>
|
|
16
15
|
<div className="w-full h-screen flex flex-col relative justify-center">
|
|
@@ -6,7 +6,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
|
|
|
6
6
|
const hasPoints = selectionLines && !isEmpty(selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.points);
|
|
7
7
|
const renderShape = (item) => {
|
|
8
8
|
var _a, _b, _c, _d, _e, _f;
|
|
9
|
-
const { id, x, y, width, height, fill, opacity, rotation = 0, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, points, seatPositions, radius, } = item;
|
|
9
|
+
const { id, x, y, width, height, fill, opacity, rotation = 0, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, points, seatPositions, radius = 10, } = item;
|
|
10
10
|
const commonProps = {
|
|
11
11
|
fill,
|
|
12
12
|
opacity,
|
|
@@ -440,7 +440,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
|
|
|
440
440
|
const spacingWidth = availableWidth / seatCountTopBottom;
|
|
441
441
|
const spacingHeight = availableHeight / seatCountLeftRight;
|
|
442
442
|
const topSeats = distributeWithSpacing({
|
|
443
|
-
start:
|
|
443
|
+
start: x,
|
|
444
444
|
length: width,
|
|
445
445
|
count: top,
|
|
446
446
|
radius: seatRadius,
|
|
@@ -453,7 +453,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
|
|
|
453
453
|
id: "top",
|
|
454
454
|
}));
|
|
455
455
|
const bottomSeats = distributeWithSpacing({
|
|
456
|
-
start:
|
|
456
|
+
start: x,
|
|
457
457
|
length: width,
|
|
458
458
|
count: bottom,
|
|
459
459
|
radius: seatRadius,
|
|
@@ -472,7 +472,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
|
|
|
472
472
|
radius: seatRadius,
|
|
473
473
|
spacing: spacingHeight,
|
|
474
474
|
}).map((cy) => ({
|
|
475
|
-
x: -seatSizeLR.w,
|
|
475
|
+
x: x - seatSizeLR.w,
|
|
476
476
|
y: y + cy - seatSizeLR.h / 2,
|
|
477
477
|
width: seatSizeLR.w,
|
|
478
478
|
height: seatSizeLR.h,
|
|
@@ -485,7 +485,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
|
|
|
485
485
|
radius: seatRadius,
|
|
486
486
|
spacing: spacingHeight,
|
|
487
487
|
}).map((cy) => ({
|
|
488
|
-
x: width,
|
|
488
|
+
x: x + width,
|
|
489
489
|
y: y + cy - seatSizeLR.h / 2,
|
|
490
490
|
width: seatSizeLR.w,
|
|
491
491
|
height: seatSizeLR.h,
|
|
@@ -18,6 +18,21 @@ const boardSlice = createSlice({
|
|
|
18
18
|
state.updateBy = action.payload;
|
|
19
19
|
},
|
|
20
20
|
addComponent: (state, action) => {
|
|
21
|
+
const currentPointer = state.pointer;
|
|
22
|
+
const totalHistory = state.historyChanges.length;
|
|
23
|
+
if (currentPointer < totalHistory) {
|
|
24
|
+
state.historyChanges = state.historyChanges.slice(0, currentPointer + 1);
|
|
25
|
+
}
|
|
26
|
+
const component = state.components;
|
|
27
|
+
const extraComponent = state.extraComponents;
|
|
28
|
+
state.historyChanges.push({
|
|
29
|
+
component,
|
|
30
|
+
extraComponent
|
|
31
|
+
});
|
|
32
|
+
if (state.historyChanges.length > MAX_HISTORY_CHANGES) {
|
|
33
|
+
state.historyChanges.shift();
|
|
34
|
+
}
|
|
35
|
+
state.pointer += 1;
|
|
21
36
|
state.components.push(action.payload);
|
|
22
37
|
},
|
|
23
38
|
removeComponent: (state, action) => {
|
|
@@ -43,14 +58,47 @@ const boardSlice = createSlice({
|
|
|
43
58
|
state.extraComponents[indexExtra] = Object.assign(Object.assign({}, state.extraComponents[indexExtra]), action.payload);
|
|
44
59
|
}
|
|
45
60
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
61
|
+
updateComponentsBulk: (state, action) => {
|
|
62
|
+
const updates = action.payload; // array of components
|
|
63
|
+
// Simpan snapshot untuk undo (deep clone lebih aman)
|
|
64
|
+
state.historyChanges.push({
|
|
65
|
+
components: [...state.components],
|
|
66
|
+
extraComponents: [...state.extraComponents],
|
|
67
|
+
});
|
|
68
|
+
if (state.historyChanges.length > MAX_HISTORY_CHANGES) {
|
|
69
|
+
state.historyChanges.shift();
|
|
70
|
+
}
|
|
71
|
+
state.pointer += 1;
|
|
72
|
+
updates.forEach((update) => {
|
|
73
|
+
const index = state.components.findIndex((component) => component.id === update.id);
|
|
74
|
+
const indexExtra = state.extraComponents.findIndex((extra) => extra.id === update.id);
|
|
75
|
+
if (index !== -1) {
|
|
76
|
+
state.components[index] = Object.assign(Object.assign({}, state.components[index]), update);
|
|
77
|
+
}
|
|
78
|
+
else if (indexExtra !== -1) {
|
|
79
|
+
state.extraComponents[indexExtra] = Object.assign(Object.assign({}, state.extraComponents[indexExtra]), update);
|
|
51
80
|
}
|
|
52
81
|
});
|
|
53
82
|
},
|
|
83
|
+
// updateAllComponents: (state, action) => {
|
|
84
|
+
// const allComponents = action.payload;
|
|
85
|
+
// forEach(allComponents, (component) => {
|
|
86
|
+
// const index = state.components.findIndex(
|
|
87
|
+
// (c) => c.id === component.id
|
|
88
|
+
// );
|
|
89
|
+
// if (index !== -1) {
|
|
90
|
+
// state.components[index] = {
|
|
91
|
+
// ...state.components[index],
|
|
92
|
+
// ...component,
|
|
93
|
+
// };
|
|
94
|
+
// }
|
|
95
|
+
// });
|
|
96
|
+
// state.historyChanges.push(state.components);
|
|
97
|
+
// if (state.historyChanges.length > MAX_HISTORY_CHANGES) {
|
|
98
|
+
// state.historyChanges.shift();
|
|
99
|
+
// }
|
|
100
|
+
// state.pointer += 1
|
|
101
|
+
// },
|
|
54
102
|
setBackgroundColor: (state, action) => {
|
|
55
103
|
state.backgroundColor = action.payload;
|
|
56
104
|
},
|
|
@@ -61,7 +109,10 @@ const boardSlice = createSlice({
|
|
|
61
109
|
state.historyChanges = state.historyChanges.slice(0, currentPointer + 1);
|
|
62
110
|
}
|
|
63
111
|
state.components = action.payload;
|
|
64
|
-
state.historyChanges.push(
|
|
112
|
+
state.historyChanges.push({
|
|
113
|
+
components: [...state.components],
|
|
114
|
+
extraComponents: [...state.extraComponents],
|
|
115
|
+
});
|
|
65
116
|
if (state.historyChanges.length > MAX_HISTORY_CHANGES) {
|
|
66
117
|
state.historyChanges.shift();
|
|
67
118
|
}
|
|
@@ -71,12 +122,28 @@ const boardSlice = createSlice({
|
|
|
71
122
|
state.extraComponents = action.payload;
|
|
72
123
|
},
|
|
73
124
|
setExtraComponent: (state, action) => {
|
|
125
|
+
const currentPointer = state.pointer;
|
|
126
|
+
const totalHistory = state.historyChanges.length;
|
|
127
|
+
if (currentPointer < totalHistory) {
|
|
128
|
+
state.historyChanges = state.historyChanges.slice(0, currentPointer + 1);
|
|
129
|
+
}
|
|
130
|
+
const component = state.components;
|
|
131
|
+
const extraComponent = state.extraComponents;
|
|
132
|
+
state.historyChanges.push({
|
|
133
|
+
components: [...component],
|
|
134
|
+
extraComponents: [...extraComponent],
|
|
135
|
+
});
|
|
136
|
+
if (state.historyChanges.length > MAX_HISTORY_CHANGES) {
|
|
137
|
+
state.historyChanges.shift();
|
|
138
|
+
}
|
|
139
|
+
state.pointer += 1;
|
|
74
140
|
state.extraComponents.push(action.payload);
|
|
75
141
|
},
|
|
76
142
|
setFlagChange: (state, action) => {
|
|
77
143
|
state.flagChange = action.payload;
|
|
78
144
|
},
|
|
79
145
|
undoHistory: (state) => {
|
|
146
|
+
var _a, _b, _c, _d;
|
|
80
147
|
if (state.pointer > 1) {
|
|
81
148
|
const lengthHistory = state.historyChanges.length;
|
|
82
149
|
if (lengthHistory === state.pointer) {
|
|
@@ -86,17 +153,20 @@ const boardSlice = createSlice({
|
|
|
86
153
|
state.pointer -= 1;
|
|
87
154
|
}
|
|
88
155
|
const prev = state.historyChanges[state.pointer];
|
|
89
|
-
state.components = current(prev);
|
|
156
|
+
state.components = current(prev === null || prev === void 0 ? void 0 : prev.components);
|
|
157
|
+
state.extraComponents = current(prev === null || prev === void 0 ? void 0 : prev.extraComponents);
|
|
90
158
|
}
|
|
91
159
|
else if (state.pointer === 1) {
|
|
92
|
-
state.components = current(state.historyChanges[0]);
|
|
160
|
+
state.components = current((_b = (_a = state.historyChanges) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.components);
|
|
161
|
+
state.components = current((_d = (_c = state.historyChanges) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.extraComponents);
|
|
93
162
|
state.pointer = 0;
|
|
94
163
|
}
|
|
95
164
|
},
|
|
96
165
|
redoHistory: (state) => {
|
|
97
166
|
if (state.pointer < state.historyChanges.length - 1) {
|
|
98
167
|
const next = state.historyChanges[state.pointer + 1];
|
|
99
|
-
state.components = current(next);
|
|
168
|
+
state.components = current(next === null || next === void 0 ? void 0 : next.components);
|
|
169
|
+
state.extraComponents = current(next === null || next === void 0 ? void 0 : next.extraComponents);
|
|
100
170
|
state.pointer += 1;
|
|
101
171
|
}
|
|
102
172
|
},
|
|
@@ -156,14 +156,13 @@ const BoardTemplate = ({ refs }) => {
|
|
|
156
156
|
minY = findBoundingBox.y;
|
|
157
157
|
}
|
|
158
158
|
if ((minX !== Infinity || minY !== Infinity) && !activeTool) {
|
|
159
|
-
console.log("minX", minX, "minY", minY, "maxX", maxX, "maxY", maxY, "Haduhhh");
|
|
160
159
|
(_h = transformRef.current) === null || _h === void 0 ? void 0 : _h.setTransform(-minX, -minY, scale);
|
|
161
160
|
setHasInitialzed(true);
|
|
162
161
|
}
|
|
163
162
|
}, [componentsProps, extraComponentsProps]);
|
|
164
163
|
const queueUpdateComponents = (data) => {
|
|
165
164
|
dispatch({
|
|
166
|
-
type: "board/
|
|
165
|
+
type: "board/updateComponentsBulk",
|
|
167
166
|
payload: data,
|
|
168
167
|
});
|
|
169
168
|
};
|
|
@@ -181,10 +180,6 @@ const BoardTemplate = ({ refs }) => {
|
|
|
181
180
|
}, 1000));
|
|
182
181
|
// Redux → Local
|
|
183
182
|
useEffect(() => {
|
|
184
|
-
console.log({
|
|
185
|
-
flagChange,
|
|
186
|
-
updateBy
|
|
187
|
-
}, "haduuhhh");
|
|
188
183
|
if (flagChange && updateBy === "global") {
|
|
189
184
|
if (!isEqual(selectedComponentProps, selectedComponent)) {
|
|
190
185
|
isSyncingFromRedux.current = true;
|
|
@@ -213,29 +208,31 @@ const BoardTemplate = ({ refs }) => {
|
|
|
213
208
|
const updatedExtra = updateSingleComponent(extraComponentsState, component, setExtraComponentsState);
|
|
214
209
|
if (updatedExtra) {
|
|
215
210
|
dispatch({ type: "board/setUpdateBy", payload: "local" });
|
|
216
|
-
|
|
217
|
-
debouncedSyncExtraComponents.current(updatedExtra);
|
|
211
|
+
queueUpdateComponents(updatedComponents);
|
|
218
212
|
}
|
|
219
213
|
};
|
|
220
214
|
const updateComponentsAttribute = (components) => {
|
|
221
215
|
if (!components.length)
|
|
222
216
|
return;
|
|
223
|
-
const isExtra = components
|
|
224
|
-
if (isExtra) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
217
|
+
// const isExtra = components?.filter((item) => item?.shape === "polygon");
|
|
218
|
+
// if (isExtra) {
|
|
219
|
+
// const nextExtra = updateManyComponents(
|
|
220
|
+
// extraComponentsState,
|
|
221
|
+
// components,
|
|
222
|
+
// setExtraComponentsState
|
|
223
|
+
// );
|
|
224
|
+
// dispatch({ type: "board/setUpdateBy", payload: "local" });
|
|
225
|
+
// queueUpdateComponents(nextExtra);
|
|
226
|
+
// }
|
|
229
227
|
const nextComponents = updateManyComponents(componentsState, components, setComponentsState);
|
|
230
228
|
dispatch({ type: "board/setUpdateBy", payload: "local" });
|
|
231
|
-
queueUpdateExtraComponents(nextComponents);
|
|
229
|
+
// queueUpdateExtraComponents(nextComponents);
|
|
232
230
|
};
|
|
233
231
|
const addComponents = (component) => {
|
|
234
232
|
const index = extraComponentsState.findIndex((c) => (c === null || c === void 0 ? void 0 : c.shape) === "bounding-box");
|
|
235
233
|
const nextExtraComponents = index !== -1
|
|
236
234
|
? extraComponentsState.map((item, i) => i === index ? component : item)
|
|
237
235
|
: [...extraComponentsState, component];
|
|
238
|
-
console.log({ nextExtraComponents });
|
|
239
236
|
setExtraComponentsState(nextExtraComponents);
|
|
240
237
|
dispatch({
|
|
241
238
|
type: "board/setNewExtraComponents",
|
|
@@ -293,8 +290,44 @@ const BoardTemplate = ({ refs }) => {
|
|
|
293
290
|
dispatch({ type: "panel/setShow", payload: false });
|
|
294
291
|
dataElementSelectionGroupRef.current = [];
|
|
295
292
|
};
|
|
293
|
+
const stillHoldShift = useRef(false);
|
|
294
|
+
useEffect(() => {
|
|
295
|
+
var _a, _b;
|
|
296
|
+
if (stillHoldShift.current && dataElementSelectionGroupRef.current) {
|
|
297
|
+
const selectionLines = (_a = svgRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("#selection-lines");
|
|
298
|
+
selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.setAttribute("pointer-events", "none");
|
|
299
|
+
}
|
|
300
|
+
if (!stillHoldShift.current && dataElementSelectionGroupRef.current) {
|
|
301
|
+
const selectionLines = (_b = svgRef.current) === null || _b === void 0 ? void 0 : _b.querySelector("#selection-lines");
|
|
302
|
+
selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.setAttribute("pointer-events", "all");
|
|
303
|
+
}
|
|
304
|
+
}, [stillHoldShift.current, dataElementSelectionGroupRef.current]);
|
|
305
|
+
useEffect(() => {
|
|
306
|
+
const handleKeyDown = (e) => {
|
|
307
|
+
var _a, _b;
|
|
308
|
+
// setPressedKey(e.key);
|
|
309
|
+
const selectionLines = (_a = svgRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("#selection-lines");
|
|
310
|
+
(_b = svgRef.current) === null || _b === void 0 ? void 0 : _b.querySelector("#selection-lines");
|
|
311
|
+
if (e.key === "Shift") {
|
|
312
|
+
stillHoldShift.current = true;
|
|
313
|
+
selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.setAttribute("pointer-events", "none");
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
const handleKeyUp = () => {
|
|
317
|
+
var _a;
|
|
318
|
+
const selectionLines = (_a = svgRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("#selection-lines");
|
|
319
|
+
stillHoldShift.current = false;
|
|
320
|
+
selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.setAttribute("pointer-events", "all");
|
|
321
|
+
};
|
|
322
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
323
|
+
window.addEventListener("keyup", handleKeyUp);
|
|
324
|
+
return () => {
|
|
325
|
+
window.removeEventListener("keydown", handleKeyDown);
|
|
326
|
+
window.removeEventListener("keyup", handleKeyUp);
|
|
327
|
+
};
|
|
328
|
+
}, [dataElementSelectionGroupRef.current]);
|
|
296
329
|
const handlePointerDown = (e) => {
|
|
297
|
-
var _a, _b, _c, _d, _e, _f;
|
|
330
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
298
331
|
const shiftActive = e.shiftKey;
|
|
299
332
|
const svg = svgRef.current;
|
|
300
333
|
if (!e.isPrimary)
|
|
@@ -344,6 +377,7 @@ const BoardTemplate = ({ refs }) => {
|
|
|
344
377
|
if (targetRotate) {
|
|
345
378
|
isRotatingRef.current = true;
|
|
346
379
|
}
|
|
380
|
+
const targetSelectionBox = e.target.closest("g[id='selection-lines']");
|
|
347
381
|
// RESIZE
|
|
348
382
|
const targetGroup = e.target.closest("g[data-id]");
|
|
349
383
|
const targetPointPolygon = e.target.closest("circle[data-point]");
|
|
@@ -357,8 +391,16 @@ const BoardTemplate = ({ refs }) => {
|
|
|
357
391
|
const { g } = getAttributeElement(svg, activeId);
|
|
358
392
|
if (targetGroup && shiftActive) {
|
|
359
393
|
const findById = [...componentsState, ...extraComponentsState].find((comp) => comp.id == activeId);
|
|
360
|
-
const
|
|
361
|
-
|
|
394
|
+
const currentSelection = (_e = dataElementSelectionGroupRef.current) !== null && _e !== void 0 ? _e : [];
|
|
395
|
+
const alreadySelected = currentSelection.some((comp) => comp.id == activeId);
|
|
396
|
+
let newSelection;
|
|
397
|
+
if (alreadySelected) {
|
|
398
|
+
newSelection = currentSelection.filter((comp) => comp.id != activeId);
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
newSelection = [...currentSelection, findById];
|
|
402
|
+
}
|
|
403
|
+
dataElementSelectionGroupRef.current = newSelection;
|
|
362
404
|
}
|
|
363
405
|
const box = getGlobalBBox(svg, g);
|
|
364
406
|
const { x: initialXG, y: initialYG } = getTranslate(g);
|
|
@@ -367,7 +409,7 @@ const BoardTemplate = ({ refs }) => {
|
|
|
367
409
|
const hitPoint = document.elementFromPoint(clientX, clientY);
|
|
368
410
|
// CHECK FOR HIT ON SVG FOR SELECTION BOX
|
|
369
411
|
// MAKE AND UNMAKE SELECTION BOX START ------
|
|
370
|
-
const hadSelectionBox = ((
|
|
412
|
+
const hadSelectionBox = ((_f = dataElementSelectionGroupRef.current) === null || _f === void 0 ? void 0 : _f.length) > 0 && !isSingleSelection;
|
|
371
413
|
const downInSelectionBox = hadSelectionBox && (hitPoint === null || hitPoint === void 0 ? void 0 : hitPoint.nodeName) !== "svg";
|
|
372
414
|
const downOutSelectionBox = hadSelectionBox && (hitPoint === null || hitPoint === void 0 ? void 0 : hitPoint.nodeName) === "svg";
|
|
373
415
|
const downBeforeHasSelectionBox = !downInSelectionBox &&
|
|
@@ -404,7 +446,7 @@ const BoardTemplate = ({ refs }) => {
|
|
|
404
446
|
shape: nameShapeSelectionBoxGhost,
|
|
405
447
|
id: idSelectionBoxGhost,
|
|
406
448
|
});
|
|
407
|
-
(
|
|
449
|
+
(_g = svgRef.current) === null || _g === void 0 ? void 0 : _g.appendChild(boxSelection);
|
|
408
450
|
}
|
|
409
451
|
// MAKE AND UNMAKE SELECTION BOX END ------
|
|
410
452
|
// RESIZE SELECTION BOX
|
|
@@ -417,16 +459,22 @@ const BoardTemplate = ({ refs }) => {
|
|
|
417
459
|
!downOutSelectionBox &&
|
|
418
460
|
isInSelectionTarget &&
|
|
419
461
|
!isSingleSelection &&
|
|
420
|
-
!isInTargetElement &&
|
|
421
|
-
|
|
462
|
+
!isInTargetElement &&
|
|
463
|
+
!isInitialCreateBoundingBox;
|
|
464
|
+
const downAtResizePositionAndHasSelectionBox = downAtResizePosition &&
|
|
465
|
+
hadSelectionBox &&
|
|
466
|
+
!isRotateSelectionBox &&
|
|
467
|
+
!isInitialCreateBoundingBox;
|
|
422
468
|
const isMightResizeElement = !isEmpty(selectedComponent) &&
|
|
423
469
|
downAtResizePosition &&
|
|
424
470
|
downAtResizePosition &&
|
|
425
|
-
!hadSelectionBox &&
|
|
471
|
+
!hadSelectionBox &&
|
|
472
|
+
!isInitialCreateBoundingBox;
|
|
426
473
|
const isMightMove = activeId &&
|
|
427
474
|
!targetPointPolygon &&
|
|
428
475
|
isInTargetElement &&
|
|
429
|
-
!isMightResizeElement &&
|
|
476
|
+
!isMightResizeElement &&
|
|
477
|
+
!isInitialCreateBoundingBox;
|
|
430
478
|
const isMightMoveOneElementSelection = isSingleSelection && !isMightResizeElement && !isInitialCreateBoundingBox;
|
|
431
479
|
if (downOutResizePositionAndInSelectionBox) {
|
|
432
480
|
onMoveSelectionBoxRef.current = true;
|
|
@@ -43,6 +43,7 @@ const ControlPanels = (props) => {
|
|
|
43
43
|
let values = Form.useWatch([], form);
|
|
44
44
|
useEffect(() => {
|
|
45
45
|
if (selectedComponent) {
|
|
46
|
+
console.log("selectedComponent", selectedComponent);
|
|
46
47
|
const isDifferentId = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) !== (values === null || values === void 0 ? void 0 : values.id) || !(values === null || values === void 0 ? void 0 : values.id);
|
|
47
48
|
const isSameIdAndSameDimensions = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) === (values === null || values === void 0 ? void 0 : values.id) &&
|
|
48
49
|
(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.height) === (values === null || values === void 0 ? void 0 : values.height) &&
|
|
@@ -55,6 +56,7 @@ const ControlPanels = (props) => {
|
|
|
55
56
|
form.setFieldsValue(selectedComponent);
|
|
56
57
|
}
|
|
57
58
|
else if (selectedGroup) {
|
|
59
|
+
console.log("selectedGroup", selectedGroup);
|
|
58
60
|
if (show)
|
|
59
61
|
setOpen(true);
|
|
60
62
|
if (!show)
|
|
@@ -74,11 +76,23 @@ const ControlPanels = (props) => {
|
|
|
74
76
|
const isSameOpacity = isSameAllByKey(selectedGroup, "opacity");
|
|
75
77
|
const isSampeRotation = isSameAllByKey(selectedGroup, "rotation");
|
|
76
78
|
const isSameStrokeWidth = isSameAllByKey(selectedGroup, "strokeWidth");
|
|
77
|
-
|
|
79
|
+
console.log({
|
|
80
|
+
isSameAllWidth,
|
|
81
|
+
isSameAllHeight,
|
|
82
|
+
isSameX,
|
|
83
|
+
isSameY,
|
|
84
|
+
isSameFill,
|
|
85
|
+
isSameStroke,
|
|
86
|
+
isSameOpacity,
|
|
87
|
+
isSampeRotation,
|
|
88
|
+
isSameStrokeWidth,
|
|
89
|
+
});
|
|
90
|
+
form.setFieldsValue(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (isSameAllWidth ? { width: selectedGroup[0].width } : undefined)), (isSameAllHeight ? { height: selectedGroup[0].height } : undefined)), (isSameX ? { x: selectedGroup[0].x } : undefined)), (isSameY ? { y: selectedGroup[0].y } : undefined)), (isSameFill ? { fill: selectedGroup[0].fill } : undefined)), (isSameStroke ? { stroke: selectedGroup[0].stroke } : undefined)), (isSameOpacity ? { opacity: selectedGroup[0].opacity } : undefined)), (isSampeRotation ? { rotation: selectedGroup[0].rotation } : undefined)), (isSameStrokeWidth
|
|
78
91
|
? { strokeWidth: selectedGroup[0].strokeWidth }
|
|
79
92
|
: {})));
|
|
80
93
|
}
|
|
81
94
|
else {
|
|
95
|
+
console.log("selectedGroup", selectedGroup);
|
|
82
96
|
setOpen(false);
|
|
83
97
|
}
|
|
84
98
|
}, [selectedComponent, selectedGroup, show]);
|
|
@@ -129,6 +143,8 @@ const ControlPanels = (props) => {
|
|
|
129
143
|
type: "board/updateAllComponents",
|
|
130
144
|
payload: data,
|
|
131
145
|
});
|
|
146
|
+
dispatch({ type: "board/setFlagChange", payload: true });
|
|
147
|
+
dispatch({ type: "board/setUpdateBy", payload: "global" });
|
|
132
148
|
}, 300));
|
|
133
149
|
const debouncedSyncForm = useRef(debounce(() => {
|
|
134
150
|
dispatch({ type: "board/setFlagChange", payload: true });
|
|
@@ -147,11 +163,12 @@ const ControlPanels = (props) => {
|
|
|
147
163
|
const newElement = Object.assign(Object.assign(Object.assign({}, findElement), values), { x: (_a = values.x) !== null && _a !== void 0 ? _a : findElement.x, y: (_b = values.y) !== null && _b !== void 0 ? _b : findElement.y, width: isAdjustSize ? forceSize.width : (_c = values.width) !== null && _c !== void 0 ? _c : findElement.width, height: isAdjustSize
|
|
148
164
|
? forceSize.height
|
|
149
165
|
: (_d = values.height) !== null && _d !== void 0 ? _d : findElement.height });
|
|
150
|
-
const
|
|
166
|
+
const svg = (_f = (_e = svgRef === null || svgRef === void 0 ? void 0 : svgRef.current) === null || _e === void 0 ? void 0 : _e[1]) !== null && _f !== void 0 ? _f : (_g = svgRef === null || svgRef === void 0 ? void 0 : svgRef.current) === null || _g === void 0 ? void 0 : _g[0];
|
|
167
|
+
const { g, element } = getAttributeElement(svg, id);
|
|
151
168
|
applyResizeToSvgElement(element, g, newElement);
|
|
152
|
-
const getBBox = getGlobalBBox(
|
|
169
|
+
const getBBox = getGlobalBBox(svg, g);
|
|
153
170
|
debouncedSyncSelectedSelectionLines.current(Object.assign({}, getBBox));
|
|
154
|
-
updateSelectionBox(
|
|
171
|
+
updateSelectionBox(svg, getBBox);
|
|
155
172
|
};
|
|
156
173
|
const handleChangeComponent = (values, allValues) => {
|
|
157
174
|
const { shape } = allValues, restProps = __rest(allValues, ["shape"]);
|
|
@@ -159,10 +176,6 @@ const ControlPanels = (props) => {
|
|
|
159
176
|
if (selectedComponent) {
|
|
160
177
|
updateElement(allValues.id, values);
|
|
161
178
|
debouncedSyncComponents.current(Object.assign(Object.assign({}, (selectedComponent || {})), newValues));
|
|
162
|
-
// debouncedSyncSelectedComponents.current({
|
|
163
|
-
// ...(selectedComponent || {}),
|
|
164
|
-
// ...newValues,
|
|
165
|
-
// });
|
|
166
179
|
}
|
|
167
180
|
if ((selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.length) > 0) {
|
|
168
181
|
const { width, height, x, y, fill, stroke, opacity, rotation, strokeWidth, } = newValues;
|
|
@@ -74,6 +74,8 @@ const UploadTool = ({ name, type, action, responseMapping, defaultValue, }) => {
|
|
|
74
74
|
payload: Object.assign({}, defaultFormatValue(width, height, srcFromResponse, Number(defaultValue.id))),
|
|
75
75
|
});
|
|
76
76
|
setDefaultSrc(img.src);
|
|
77
|
+
dispatch({ type: "board/setFlagChange", payload: true });
|
|
78
|
+
dispatch({ type: "board/setUpdateBy", payload: "global" });
|
|
77
79
|
}
|
|
78
80
|
else {
|
|
79
81
|
dispatch({
|
|
@@ -84,6 +86,7 @@ const UploadTool = ({ name, type, action, responseMapping, defaultValue, }) => {
|
|
|
84
86
|
});
|
|
85
87
|
}
|
|
86
88
|
dispatch({ type: "board/setFlagChange", payload: true });
|
|
89
|
+
dispatch({ type: "board/setUpdateBy", payload: "global" });
|
|
87
90
|
// message.success(`${info.file.name} uploaded successfully.`);
|
|
88
91
|
};
|
|
89
92
|
// Set img src AFTER onload
|
|
@@ -37,7 +37,7 @@ export const getSeatPosition = (shape, props) => {
|
|
|
37
37
|
return (props === null || props === void 0 ? void 0 : props.seatPositions) || { top: 0, bottom: 0, left: 0, right: 0 };
|
|
38
38
|
};
|
|
39
39
|
export const adjustHeightWidthForSeatShape = (shape, props) => {
|
|
40
|
-
if (shape.includes("circle")) {
|
|
40
|
+
if (shape === null || shape === void 0 ? void 0 : shape.includes("circle")) {
|
|
41
41
|
const sizeDefault = Math.min(props.width, props.height);
|
|
42
42
|
return Object.assign(Object.assign({}, props), { height: sizeDefault, width: sizeDefault });
|
|
43
43
|
}
|