seat-editor 3.4.7 → 3.5.0
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.d.ts +1 -1
- package/dist/app/graph-view/page.d.ts +1 -0
- package/dist/app/graph-view/page.js +343 -0
- package/dist/app/graph-view/page.jsx +445 -0
- package/dist/app/graph-view-new/constant.d.ts +581 -0
- package/dist/app/graph-view-new/constant.js +6973 -0
- package/dist/app/graph-view-new/page.d.ts +1 -0
- package/dist/app/graph-view-new/page.js +71 -0
- package/dist/app/graph-view-new/page.jsx +98 -0
- package/dist/app/new-board/page.js +43 -7
- package/dist/app/new-board/page.jsx +45 -12
- package/dist/components/button-tools/index.js +7 -5
- package/dist/components/button-tools/index.jsx +21 -9
- package/dist/components/form-tools/label.js +9 -20
- package/dist/components/form-tools/label.jsx +38 -28
- package/dist/components/form-tools/shape.js +5 -5
- package/dist/components/form-tools/shape.jsx +8 -8
- package/dist/components/layer-v3/index.js +44 -3
- package/dist/components/layer-v3/index.jsx +120 -3
- package/dist/components/layer-v4/index.js +3 -2
- package/dist/components/layer-v4/index.jsx +3 -2
- package/dist/components/layer-v5/constant.d.ts +60 -0
- package/dist/components/layer-v5/constant.js +93 -0
- package/dist/components/layer-v5/index.d.ts +24 -0
- package/dist/components/layer-v5/index.js +927 -0
- package/dist/components/layer-v5/index.jsx +1049 -0
- package/dist/features/board-v3/index.js +350 -72
- package/dist/features/board-v3/index.jsx +369 -75
- package/dist/features/board-v3/resize-element.js +5 -0
- package/dist/features/board-v3/utils.d.ts +8 -0
- package/dist/features/board-v3/utils.js +23 -7
- package/dist/features/package/index.d.ts +2 -0
- package/dist/features/package/index.js +1 -1
- package/dist/features/package/index.jsx +6 -1
- package/dist/features/panel/index.d.ts +8 -0
- package/dist/features/panel/index.js +160 -38
- package/dist/features/panel/index.jsx +173 -46
- package/dist/features/panel/polygon.d.ts +2 -0
- package/dist/features/panel/polygon.js +44 -0
- package/dist/features/panel/polygon.jsx +70 -0
- package/dist/features/panel/select-tool.js +3 -0
- package/dist/features/panel/select-tool.jsx +3 -0
- package/dist/features/panel/selected-group.js +24 -26
- package/dist/features/panel/selected-group.jsx +56 -51
- package/dist/features/panel/text-tool.js +17 -2
- package/dist/features/panel/text-tool.jsx +19 -2
- package/dist/features/panel/upload-tool.js +17 -3
- package/dist/features/panel/upload-tool.jsx +23 -4
- package/dist/features/side-tool/index.js +43 -6
- package/dist/features/side-tool/index.jsx +47 -10
- package/dist/features/view-only-4/connect-handle.d.ts +13 -0
- package/dist/features/view-only-4/connect-handle.js +23 -0
- package/dist/features/view-only-4/connect-handle.jsx +30 -0
- package/dist/features/view-only-4/connection-layer.d.ts +21 -0
- package/dist/features/view-only-4/connection-layer.js +219 -0
- package/dist/features/view-only-4/connection-layer.jsx +291 -0
- package/dist/features/view-only-4/index.d.ts +99 -0
- package/dist/features/view-only-4/index.js +684 -0
- package/dist/features/view-only-4/index.jsx +722 -0
- package/dist/features/view-only-4/integration-guide.d.ts +0 -0
- package/dist/features/view-only-4/integration-guide.js +0 -0
- package/dist/features/view-only-4/use-connection-graph.d.ts +41 -0
- package/dist/features/view-only-4/use-connection-graph.js +182 -0
- package/dist/features/view-only-4/utils.d.ts +74 -0
- package/dist/features/view-only-4/utils.js +106 -0
- package/dist/features/view-only-5/connect-handle.d.ts +30 -0
- package/dist/features/view-only-5/connect-handle.js +88 -0
- package/dist/features/view-only-5/connect-handle.jsx +96 -0
- package/dist/features/view-only-5/connection-layer.d.ts +34 -0
- package/dist/features/view-only-5/connection-layer.js +182 -0
- package/dist/features/view-only-5/connection-layer.jsx +265 -0
- package/dist/features/view-only-5/index.d.ts +102 -0
- package/dist/features/view-only-5/index.js +585 -0
- package/dist/features/view-only-5/index.jsx +614 -0
- package/dist/features/view-only-5/use-connection-graph.d.ts +57 -0
- package/dist/features/view-only-5/use-connection-graph.js +196 -0
- package/dist/features/view-only-5/utils.d.ts +52 -0
- package/dist/features/view-only-5/utils.js +80 -0
- package/dist/features/view-only-6/connect-handle.d.ts +13 -0
- package/dist/features/view-only-6/connect-handle.js +20 -0
- package/dist/features/view-only-6/connect-handle.jsx +21 -0
- package/dist/features/view-only-6/connection-layer.d.ts +22 -0
- package/dist/features/view-only-6/connection-layer.js +191 -0
- package/dist/features/view-only-6/connection-layer.jsx +244 -0
- package/dist/features/view-only-6/index.d.ts +99 -0
- package/dist/features/view-only-6/index.js +687 -0
- package/dist/features/view-only-6/index.jsx +724 -0
- package/dist/features/view-only-6/use-connection-graph.d.ts +26 -0
- package/dist/features/view-only-6/use-connection-graph.js +103 -0
- package/dist/features/view-only-6/utils.d.ts +66 -0
- package/dist/features/view-only-6/utils.js +96 -0
- package/dist/features/view-only-7/connect-handle.d.ts +13 -0
- package/dist/features/view-only-7/connect-handle.js +23 -0
- package/dist/features/view-only-7/connect-handle.jsx +30 -0
- package/dist/features/view-only-7/connection-layer.d.ts +22 -0
- package/dist/features/view-only-7/connection-layer.js +165 -0
- package/dist/features/view-only-7/connection-layer.jsx +217 -0
- package/dist/features/view-only-7/index.d.ts +99 -0
- package/dist/features/view-only-7/index.js +687 -0
- package/dist/features/view-only-7/index.jsx +724 -0
- package/dist/features/view-only-7/use-connection-graph.d.ts +26 -0
- package/dist/features/view-only-7/use-connection-graph.js +104 -0
- package/dist/features/view-only-7/utils.d.ts +69 -0
- package/dist/features/view-only-7/utils.js +144 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/seat-editor.css +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import React, { useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
2
|
+
import React, { useEffect, useImperativeHandle, useMemo, useRef, useState, } from "react";
|
|
3
3
|
import { TransformWrapper, TransformComponent, } from "react-zoom-pan-pinch";
|
|
4
4
|
import { useAppSelector, useAppDispatch } from "../../hooks/use-redux";
|
|
5
5
|
import Layers from "../../components/layer-v3";
|
|
@@ -7,8 +7,8 @@ import { isEmpty, isPlainObject, isUndefined } from "lodash";
|
|
|
7
7
|
import ModalPreview from "../../components/modal-preview";
|
|
8
8
|
import LayerView from "../view-only-3";
|
|
9
9
|
import { isEqual, debounce } from "lodash";
|
|
10
|
-
import { ZoomIn, ZoomOut } from "lucide-react";
|
|
11
|
-
import { Button, Radio } from "antd";
|
|
10
|
+
import { Command, ZoomIn, ZoomOut } from "lucide-react";
|
|
11
|
+
import { Button, Flex, Radio, Tag } from "antd";
|
|
12
12
|
import { getAttributeElement, getAttributeElements } from "./resize-element";
|
|
13
13
|
import { applyResizeToSvgElement, arrayToSvgPointsAttr, createTableGhost, getGlobalBBox, getRotation, getSvgElementSize, getTranslate, isClosingPolygon, normalizeAngle, pointsStringToArray, resizeBox, resizeSeatCircle, resizeSeatRectCircle, resizeSeatRectSquare, resizeSeatSide, resizeSeatSquare, stabilizeRotation, stabilizeTranslateOnRotate, updateManyComponents, updateSelectionBox, updateSelectionGuides, updateSingleComponent, } from "./utils";
|
|
14
14
|
const toolElement = ["square", "circle", "table-seat-circle"];
|
|
@@ -69,24 +69,94 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
69
69
|
//boundingbox
|
|
70
70
|
const isInialBoundingBox = useRef(false);
|
|
71
71
|
const { components: componentsProps, extraComponents: extraComponentsProps, boundingBox, flagChange, updateBy, isShowTagType, } = useAppSelector((state) => state.board);
|
|
72
|
+
const selectedGroup = useAppSelector((state) => state.panel.selectedGroup);
|
|
72
73
|
const { selectionLines } = useAppSelector((state) => state.panel);
|
|
73
74
|
const [selectedLines, setSelectedLines] = useState(null);
|
|
74
75
|
useEffect(() => {
|
|
75
76
|
if (activeTool === "select" || activeTool !== "select") {
|
|
76
77
|
handleUnSelectComponent();
|
|
77
78
|
}
|
|
79
|
+
if (activeTool !== "polygon") {
|
|
80
|
+
isOnMakePolygonRef.current = false;
|
|
81
|
+
polygonElementRef.current = [];
|
|
82
|
+
}
|
|
78
83
|
}, [activeTool]);
|
|
84
|
+
// useEffect(() => {
|
|
85
|
+
// if (selectionLines) {
|
|
86
|
+
// setSelectedLines(selectionLines);
|
|
87
|
+
// const idSelected = dataElementSelectionGroupRef.current.map(
|
|
88
|
+
// (item) => item.id
|
|
89
|
+
// );
|
|
90
|
+
// const newSelectionData = [
|
|
91
|
+
// ...componentsState,
|
|
92
|
+
// ...extraComponentsState,
|
|
93
|
+
// ].filter((comp) => idSelected.includes(comp.id));
|
|
94
|
+
// dataElementSelectionGroupRef.current = newSelectionData;
|
|
95
|
+
// }
|
|
96
|
+
// }, [selectionLines]);
|
|
79
97
|
useEffect(() => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
var _a;
|
|
99
|
+
if (selectedLines === null || selectedLines === void 0 ? void 0 : selectedLines.id) {
|
|
100
|
+
const boxCurrentLines = {
|
|
101
|
+
x: selectedLines.x,
|
|
102
|
+
y: selectedLines.y,
|
|
103
|
+
width: selectedLines.width,
|
|
104
|
+
height: selectedLines.height,
|
|
105
|
+
};
|
|
106
|
+
const singleIdSelection = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id;
|
|
107
|
+
if (singleIdSelection) {
|
|
108
|
+
const { g } = (_a = getAttributeElements(svgRef.current, [
|
|
109
|
+
String(singleIdSelection),
|
|
110
|
+
])) === null || _a === void 0 ? void 0 : _a[0];
|
|
111
|
+
const size = getGlobalBBox(svgRef.current, g);
|
|
112
|
+
const box = Object.assign({}, size);
|
|
113
|
+
if (!isEqual(box, boxCurrentLines)) {
|
|
114
|
+
setSelectedLines((prev) => (Object.assign(Object.assign({}, prev), box)));
|
|
115
|
+
updateSelectionBox(svgRef.current, box);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const groupIdSelection = selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.map((item) => item.id);
|
|
119
|
+
if ((groupIdSelection === null || groupIdSelection === void 0 ? void 0 : groupIdSelection.length) > 0) {
|
|
120
|
+
const allBox = groupIdSelection === null || groupIdSelection === void 0 ? void 0 : groupIdSelection.map((id) => {
|
|
121
|
+
var _a;
|
|
122
|
+
const { g } = (_a = getAttributeElements(svgRef.current, [String(id)])) === null || _a === void 0 ? void 0 : _a[0];
|
|
123
|
+
const translate = getTranslate(g);
|
|
124
|
+
const size = getGlobalBBox(svgRef.current, g);
|
|
125
|
+
return Object.assign({}, size);
|
|
126
|
+
});
|
|
127
|
+
const boxGroup = {
|
|
128
|
+
x: Math.min(...allBox.map((b) => b.x)),
|
|
129
|
+
y: Math.min(...allBox.map((b) => b.y)),
|
|
130
|
+
width: Math.max(...allBox.map((b) => b.x + b.width)) -
|
|
131
|
+
Math.min(...allBox.map((b) => b.x)),
|
|
132
|
+
height: Math.max(...allBox.map((b) => b.y + b.height)) -
|
|
133
|
+
Math.min(...allBox.map((b) => b.y)),
|
|
134
|
+
};
|
|
135
|
+
if (!isEqual(boxGroup, boxCurrentLines)) {
|
|
136
|
+
setSelectedLines((prev) => (Object.assign(Object.assign({}, prev), boxGroup)));
|
|
137
|
+
updateSelectionBox(svgRef.current, boxGroup);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// console.log("haduhhh kenak lagi");
|
|
141
|
+
// const selection = svgRef.current?.querySelector(
|
|
142
|
+
// `g[data-selection="selection-${selectedLines.id}"]`
|
|
143
|
+
// );
|
|
144
|
+
// const rect = selection?.querySelector("rect");
|
|
145
|
+
// const g = getTranslate(selection as SVGGElement);
|
|
146
|
+
// const { width, height } = getSvgElementSize(rect as SVGRectElement);
|
|
147
|
+
// const getBBox = {
|
|
148
|
+
// x: g.x,
|
|
149
|
+
// y: g.y,
|
|
150
|
+
// width,
|
|
151
|
+
// height,
|
|
152
|
+
// };
|
|
153
|
+
// console.log({ getBBox, selectedLines });
|
|
154
|
+
// if (!isEqual(getBBox, selectedLines)) {
|
|
155
|
+
// setSelectedLines(getBBox);
|
|
156
|
+
// updateSelectionBox(svgRef.current, getBBox);
|
|
157
|
+
// }
|
|
88
158
|
}
|
|
89
|
-
}, [
|
|
159
|
+
}, [componentsState, extraComponentsState, selectedLines]);
|
|
90
160
|
useEffect(() => {
|
|
91
161
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
92
162
|
if (hasInitialized)
|
|
@@ -187,6 +257,9 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
187
257
|
isSyncingFromRedux.current = true;
|
|
188
258
|
setExtraComponentsState(extraComponentsProps !== null && extraComponentsProps !== void 0 ? extraComponentsProps : []);
|
|
189
259
|
}
|
|
260
|
+
if (!isEqual(selectedGroup, dataElementSelectionGroupRef.current)) {
|
|
261
|
+
dataElementSelectionGroupRef.current = selectedGroup !== null && selectedGroup !== void 0 ? selectedGroup : [];
|
|
262
|
+
}
|
|
190
263
|
dispatch({ type: "board/setFlagChange", payload: false });
|
|
191
264
|
}
|
|
192
265
|
}, [componentsProps, extraComponentsProps, selectedComponentProps]);
|
|
@@ -236,7 +309,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
236
309
|
point.x = e.clientX;
|
|
237
310
|
point.y = e.clientY;
|
|
238
311
|
const transformed = point.matrixTransform((_a = svg.getScreenCTM()) === null || _a === void 0 ? void 0 : _a.inverse());
|
|
239
|
-
return { x: transformed.x, y: transformed.y };
|
|
312
|
+
return { x: Math.round(transformed.x), y: Math.round(transformed.y) };
|
|
240
313
|
};
|
|
241
314
|
const getCursorStyle = () => {
|
|
242
315
|
if (activeTool === "select" && moveComponent.current) {
|
|
@@ -274,6 +347,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
274
347
|
};
|
|
275
348
|
const handleUnSelectComponent = () => {
|
|
276
349
|
dispatch({ type: "panel/setSelectedComponent", payload: null });
|
|
350
|
+
dispatch({ type: "panel/setSelectedGroup", payload: null });
|
|
277
351
|
setSelectedComponent(null);
|
|
278
352
|
setSelectedLines(null);
|
|
279
353
|
dispatch({ type: "panel/setShow", payload: false });
|
|
@@ -316,7 +390,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
316
390
|
};
|
|
317
391
|
}, [dataElementSelectionGroupRef.current]);
|
|
318
392
|
const handlePointerDown = (e) => {
|
|
319
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
393
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
320
394
|
const shiftActive = e.shiftKey;
|
|
321
395
|
if (activeTool === "grab") {
|
|
322
396
|
return;
|
|
@@ -383,13 +457,16 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
383
457
|
if (targetRotate) {
|
|
384
458
|
isRotatingRef.current = true;
|
|
385
459
|
}
|
|
386
|
-
|
|
460
|
+
let positionSelection = null;
|
|
461
|
+
if (activeTool === "select") {
|
|
462
|
+
positionSelection = (_e = (_d = e.target.closest(`polyline[data-position]`)) === null || _d === void 0 ? void 0 : _d.dataset) === null || _e === void 0 ? void 0 : _e.position;
|
|
463
|
+
}
|
|
387
464
|
// RESIZE
|
|
388
465
|
const targetGroup = e.target.closest("g[data-id]");
|
|
389
466
|
const targetPointPolygon = e.target.closest("circle[data-point]");
|
|
390
467
|
// TARGET ELEMENT
|
|
391
468
|
let idTargetElement = JSON.parse((targetGroup === null || targetGroup === void 0 ? void 0 : targetGroup.getAttribute("data-id")) || "{}");
|
|
392
|
-
const selectionTarget = (
|
|
469
|
+
const selectionTarget = (_g = (_f = targetSelection === null || targetSelection === void 0 ? void 0 : targetSelection.dataset) === null || _f === void 0 ? void 0 : _f.selection) === null || _g === void 0 ? void 0 : _g.replace("selection-", "");
|
|
393
470
|
const activeId = selectionTarget !== null && selectionTarget !== void 0 ? selectionTarget : idTargetElement;
|
|
394
471
|
const isInSelectionTarget = !isUndefined(selectionTarget);
|
|
395
472
|
const isInTargetElement = !isPlainObject(idTargetElement);
|
|
@@ -397,7 +474,10 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
397
474
|
const { g } = getAttributeElement(svg, activeId);
|
|
398
475
|
if (targetGroup && shiftActive) {
|
|
399
476
|
const findById = [...componentsState, ...extraComponentsState].find((comp) => comp.id == activeId);
|
|
400
|
-
const currentSelection = (
|
|
477
|
+
const currentSelection = (_h = dataElementSelectionGroupRef.current) !== null && _h !== void 0 ? _h : [];
|
|
478
|
+
if (currentSelection.length == 0 && selectedComponent) {
|
|
479
|
+
currentSelection.push(selectedComponent);
|
|
480
|
+
}
|
|
401
481
|
const alreadySelected = currentSelection.some((comp) => comp.id == activeId);
|
|
402
482
|
let newSelection;
|
|
403
483
|
if (alreadySelected) {
|
|
@@ -414,7 +494,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
414
494
|
const hitPoint = document.elementFromPoint(clientX, clientY);
|
|
415
495
|
// CHECK FOR HIT ON SVG FOR SELECTION BOX
|
|
416
496
|
// MAKE AND UNMAKE SELECTION BOX START ------
|
|
417
|
-
const hadSelectionBox = ((
|
|
497
|
+
const hadSelectionBox = ((_j = dataElementSelectionGroupRef.current) === null || _j === void 0 ? void 0 : _j.length) > 0 && !isSingleSelection;
|
|
418
498
|
const downInSelectionBox = hadSelectionBox && (hitPoint === null || hitPoint === void 0 ? void 0 : hitPoint.nodeName) !== "svg";
|
|
419
499
|
const downOutSelectionBox = hadSelectionBox && (hitPoint === null || hitPoint === void 0 ? void 0 : hitPoint.nodeName) === "svg";
|
|
420
500
|
const downBeforeHasSelectionBox = !downInSelectionBox &&
|
|
@@ -452,7 +532,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
452
532
|
shape: nameShapeSelectionBoxGhost,
|
|
453
533
|
id: idSelectionBoxGhost,
|
|
454
534
|
});
|
|
455
|
-
(
|
|
535
|
+
(_k = svgRef.current) === null || _k === void 0 ? void 0 : _k.appendChild(boxSelection);
|
|
456
536
|
}
|
|
457
537
|
// MAKE AND UNMAKE SELECTION BOX END ------
|
|
458
538
|
// RESIZE SELECTION BOX
|
|
@@ -498,7 +578,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
498
578
|
const newPolygon = {
|
|
499
579
|
id: `${Date.now()}`,
|
|
500
580
|
shape: "polygon",
|
|
501
|
-
fill: "
|
|
581
|
+
fill: "#ef0606",
|
|
502
582
|
points: [{ x, y }],
|
|
503
583
|
rotation: 0,
|
|
504
584
|
};
|
|
@@ -515,6 +595,19 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
515
595
|
});
|
|
516
596
|
isOnMakePolygonRef.current = true;
|
|
517
597
|
}
|
|
598
|
+
if (activeTool !== "polygon" && isOnMakePolygonRef.current) {
|
|
599
|
+
isOnMakePolygonRef.current = false;
|
|
600
|
+
setSelectedComponent(null);
|
|
601
|
+
dispatch({
|
|
602
|
+
type: "panel/setSelectedComponent",
|
|
603
|
+
payload: null,
|
|
604
|
+
});
|
|
605
|
+
dispatch({
|
|
606
|
+
type: "panel/setSelectedGroup",
|
|
607
|
+
payload: null,
|
|
608
|
+
});
|
|
609
|
+
polygonElementRef.current = null;
|
|
610
|
+
}
|
|
518
611
|
// const selectionLines = svgRef.current?.querySelector(
|
|
519
612
|
// "#selection-lines"
|
|
520
613
|
// ) as SVGGElement;
|
|
@@ -531,9 +624,51 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
531
624
|
pt.x = ev.clientX;
|
|
532
625
|
pt.y = ev.clientY;
|
|
533
626
|
const pos = pt.matrixTransform(svg.getScreenCTM().inverse());
|
|
627
|
+
// RESIZE BOUNDARIES
|
|
628
|
+
const onResizeBoundaries = (pos) => {
|
|
629
|
+
var _a, _b;
|
|
630
|
+
const dx = pos.x - x;
|
|
631
|
+
const dy = pos.y - y;
|
|
632
|
+
const rectBoundaries = (_a = svgRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("#bounding-box");
|
|
633
|
+
const rect = (_b = rectBoundaries === null || rectBoundaries === void 0 ? void 0 : rectBoundaries.children) === null || _b === void 0 ? void 0 : _b[0];
|
|
634
|
+
const oldSel = {
|
|
635
|
+
x: boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.x,
|
|
636
|
+
y: boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.y,
|
|
637
|
+
width: boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.width,
|
|
638
|
+
height: boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.height,
|
|
639
|
+
};
|
|
640
|
+
let newWidth = oldSel.width;
|
|
641
|
+
let newHeight = oldSel.height;
|
|
642
|
+
let newX = oldSel.x;
|
|
643
|
+
let newY = oldSel.y;
|
|
644
|
+
if (positionSelection === "right-boundaries") {
|
|
645
|
+
newWidth = oldSel.width + dx;
|
|
646
|
+
newHeight = oldSel.height;
|
|
647
|
+
}
|
|
648
|
+
else if (positionSelection === "bottom-boundaries") {
|
|
649
|
+
newWidth = oldSel.width;
|
|
650
|
+
newHeight = oldSel.height + dy;
|
|
651
|
+
}
|
|
652
|
+
else if (positionSelection === "left-boundaries") {
|
|
653
|
+
newWidth = oldSel.width - dx;
|
|
654
|
+
newHeight = oldSel.height;
|
|
655
|
+
newX = oldSel.x + dx;
|
|
656
|
+
}
|
|
657
|
+
else if (positionSelection === "top-boundaries") {
|
|
658
|
+
newWidth = oldSel.width;
|
|
659
|
+
newHeight = oldSel.height - dy;
|
|
660
|
+
newY = oldSel.y + dy;
|
|
661
|
+
}
|
|
662
|
+
rect === null || rect === void 0 ? void 0 : rect.setAttribute("width", `${Math.round(newWidth)}`);
|
|
663
|
+
rect === null || rect === void 0 ? void 0 : rect.setAttribute("height", `${Math.round(newHeight)}`);
|
|
664
|
+
rectBoundaries === null || rectBoundaries === void 0 ? void 0 : rectBoundaries.setAttribute("transform", `translate(${Math.round(newX)}, ${Math.round(newY)})`);
|
|
665
|
+
};
|
|
666
|
+
if (positionSelection) {
|
|
667
|
+
onResizeBoundaries(pos);
|
|
668
|
+
}
|
|
534
669
|
//RESIZE POLYGON
|
|
535
670
|
const onResizePolygon = (pos) => {
|
|
536
|
-
var _a, _b;
|
|
671
|
+
var _a, _b, _c, _d;
|
|
537
672
|
const dx = pos.x - x;
|
|
538
673
|
const dy = pos.y - y;
|
|
539
674
|
const { inner, element } = getAttributeElement(svg, activeId);
|
|
@@ -547,10 +682,21 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
547
682
|
const points = element === null || element === void 0 ? void 0 : element.getAttribute("points");
|
|
548
683
|
let arrayPoints = pointsStringToArray(points);
|
|
549
684
|
const pointsStart = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.points) || [];
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
685
|
+
const isLastOrStartingPoint = index === 0 || index === arrayPoints.length - 1;
|
|
686
|
+
if (isLastOrStartingPoint) {
|
|
687
|
+
const newPoint = {
|
|
688
|
+
x: Math.round(((_a = pointsStart[index]) === null || _a === void 0 ? void 0 : _a.x) + localDx),
|
|
689
|
+
y: Math.round(((_b = pointsStart[index]) === null || _b === void 0 ? void 0 : _b.y) + localDy),
|
|
690
|
+
};
|
|
691
|
+
arrayPoints[0] = newPoint;
|
|
692
|
+
arrayPoints[arrayPoints.length - 1] = newPoint;
|
|
693
|
+
}
|
|
694
|
+
else {
|
|
695
|
+
arrayPoints[index] = {
|
|
696
|
+
x: Math.round(((_c = pointsStart[index]) === null || _c === void 0 ? void 0 : _c.x) + localDx),
|
|
697
|
+
y: Math.round(((_d = pointsStart[index]) === null || _d === void 0 ? void 0 : _d.y) + localDy),
|
|
698
|
+
};
|
|
699
|
+
}
|
|
554
700
|
const newPointsAttr = arrayToSvgPointsAttr(arrayPoints);
|
|
555
701
|
element === null || element === void 0 ? void 0 : element.setAttribute("points", newPointsAttr);
|
|
556
702
|
};
|
|
@@ -601,7 +747,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
601
747
|
circleHelper === null || circleHelper === void 0 ? void 0 : circleHelper.setAttribute("cy", `${y2}`);
|
|
602
748
|
(_c = selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.children) === null || _c === void 0 ? void 0 : _c[0].setAttribute("transform", `rotate(${newAngle}, 0, 0)`);
|
|
603
749
|
const { tx, ty } = stabilizeRotation(x0, y0, w0, h0, 0, newAngle);
|
|
604
|
-
selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.setAttribute("transform", `translate(${tx}, ${ty}) `);
|
|
750
|
+
selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.setAttribute("transform", `translate(${Math.round(tx)}, ${Math.round(ty)}) `);
|
|
605
751
|
// ROTATE ALL ELEMENT IN SELECTION
|
|
606
752
|
const allID = (_d = dataElementSelectionGroupRef.current) === null || _d === void 0 ? void 0 : _d.map((el) => String(el.id));
|
|
607
753
|
const deltaAngle = newAngle - 0;
|
|
@@ -623,8 +769,8 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
623
769
|
const nx = cx + dx * cosA - dy * sinA;
|
|
624
770
|
const ny = cy + dx * sinA + dy * cosA;
|
|
625
771
|
g.setAttribute("data-is-rotating", "1");
|
|
626
|
-
inner.setAttribute("transform", `rotate(${normalizeAngle(rotateBefore + deltaAngle)}, 0, 0)`);
|
|
627
|
-
g.setAttribute("transform", `translate(${nx}, ${ny})`);
|
|
772
|
+
inner.setAttribute("transform", `rotate(${Math.round(normalizeAngle(rotateBefore + deltaAngle))}, 0, 0)`);
|
|
773
|
+
g.setAttribute("transform", `translate(${Math.round(nx)}, ${Math.round(ny)})`);
|
|
628
774
|
});
|
|
629
775
|
};
|
|
630
776
|
if (isRotateSelectionBox) {
|
|
@@ -710,6 +856,36 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
710
856
|
seatGroup,
|
|
711
857
|
});
|
|
712
858
|
}
|
|
859
|
+
else if ((elementOld === null || elementOld === void 0 ? void 0 : elementOld.shape) === "table-seat-half-square") {
|
|
860
|
+
resizeSeatSide({
|
|
861
|
+
seatsPositions: elementOld.seatPositions,
|
|
862
|
+
r: 10,
|
|
863
|
+
newElement,
|
|
864
|
+
openSpace: elementOld.openSpace,
|
|
865
|
+
seats,
|
|
866
|
+
seatGroup,
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
else if ((elementOld === null || elementOld === void 0 ? void 0 : elementOld.shape) === "table-seat-rect-square") {
|
|
870
|
+
resizeSeatRectSquare({
|
|
871
|
+
seatsPositions: elementOld.seatPositions,
|
|
872
|
+
r: 10,
|
|
873
|
+
newElement,
|
|
874
|
+
openSpace: elementOld.openSpace,
|
|
875
|
+
seats,
|
|
876
|
+
seatGroup,
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
else if ((elementOld === null || elementOld === void 0 ? void 0 : elementOld.shape) === "table-seat-rect-circle") {
|
|
880
|
+
resizeSeatRectCircle({
|
|
881
|
+
seatsPositions: elementOld.seatPositions,
|
|
882
|
+
r: 10,
|
|
883
|
+
newElement,
|
|
884
|
+
openSpace: elementOld.openSpace,
|
|
885
|
+
seats,
|
|
886
|
+
seatGroup,
|
|
887
|
+
});
|
|
888
|
+
}
|
|
713
889
|
}
|
|
714
890
|
applyResizeToSvgElement(element, g, newElement);
|
|
715
891
|
});
|
|
@@ -728,7 +904,9 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
728
904
|
const { g } = getAttributeElement(svg, String(item.id));
|
|
729
905
|
const newX = pos.x - x;
|
|
730
906
|
const newY = pos.y - y;
|
|
731
|
-
|
|
907
|
+
const translateX = Math.round(item.x + newX);
|
|
908
|
+
const translateY = Math.round(item.y + newY);
|
|
909
|
+
g.setAttribute("transform", `translate(${translateX}, ${translateY})`);
|
|
732
910
|
});
|
|
733
911
|
const newX = pos.x - x;
|
|
734
912
|
const newY = pos.y - y;
|
|
@@ -802,10 +980,10 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
802
980
|
const selY = Math.min(pos.y, y);
|
|
803
981
|
const selW = Math.abs(pos.x - x);
|
|
804
982
|
const selH = Math.abs(pos.y - y);
|
|
805
|
-
selectionBoxGhost === null || selectionBoxGhost === void 0 ? void 0 : selectionBoxGhost.setAttribute("x", String(selX));
|
|
806
|
-
selectionBoxGhost === null || selectionBoxGhost === void 0 ? void 0 : selectionBoxGhost.setAttribute("y", String(selY));
|
|
807
|
-
selectionBoxGhost === null || selectionBoxGhost === void 0 ? void 0 : selectionBoxGhost.setAttribute("width", String(selW));
|
|
808
|
-
selectionBoxGhost === null || selectionBoxGhost === void 0 ? void 0 : selectionBoxGhost.setAttribute("height", String(selH));
|
|
983
|
+
selectionBoxGhost === null || selectionBoxGhost === void 0 ? void 0 : selectionBoxGhost.setAttribute("x", String(Math.round(selX)));
|
|
984
|
+
selectionBoxGhost === null || selectionBoxGhost === void 0 ? void 0 : selectionBoxGhost.setAttribute("y", String(Math.round(selY)));
|
|
985
|
+
selectionBoxGhost === null || selectionBoxGhost === void 0 ? void 0 : selectionBoxGhost.setAttribute("width", String(Math.round(selW)));
|
|
986
|
+
selectionBoxGhost === null || selectionBoxGhost === void 0 ? void 0 : selectionBoxGhost.setAttribute("height", String(Math.round(selH)));
|
|
809
987
|
};
|
|
810
988
|
if (isInitialCreateBoundingBox) {
|
|
811
989
|
onCreateBoudingBox();
|
|
@@ -853,7 +1031,8 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
853
1031
|
const activeId = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id;
|
|
854
1032
|
const svg = svgRef.current;
|
|
855
1033
|
const { g, element, seats, seatGroup } = getAttributeElement(svg, activeId);
|
|
856
|
-
const isZeroRotate = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.rotation) === 0 &&
|
|
1034
|
+
const isZeroRotate = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.rotation) === 0 &&
|
|
1035
|
+
!(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape.includes("circle"));
|
|
857
1036
|
const elementSelect = {
|
|
858
1037
|
x: selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.x,
|
|
859
1038
|
y: selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.y,
|
|
@@ -1041,7 +1220,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1041
1220
|
circleHelper === null || circleHelper === void 0 ? void 0 : circleHelper.setAttribute("cx", `${x2}`);
|
|
1042
1221
|
circleHelper === null || circleHelper === void 0 ? void 0 : circleHelper.setAttribute("cy", `${y2}`);
|
|
1043
1222
|
// rotate di local space
|
|
1044
|
-
inner.setAttribute("transform", `rotate(${newAngle}, 0, 0)`);
|
|
1223
|
+
inner.setAttribute("transform", `rotate(${Math.round(newAngle)}, 0, 0)`);
|
|
1045
1224
|
// stabilize translate
|
|
1046
1225
|
const { tx, ty } = selectedComponent.shape === "polygon"
|
|
1047
1226
|
? stabilizeTranslateOnRotate({
|
|
@@ -1052,7 +1231,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1052
1231
|
ty: selectedComponent.y,
|
|
1053
1232
|
})
|
|
1054
1233
|
: stabilizeRotation(selectedComponent.x, selectedComponent.y, selectedComponent.width, selectedComponent.height, selectedComponent.rotation, newAngle);
|
|
1055
|
-
g.setAttribute("transform", `translate(${tx}, ${ty})`);
|
|
1234
|
+
g.setAttribute("transform", `translate(${Math.round(tx)}, ${Math.round(ty)})`);
|
|
1056
1235
|
updateSelectionGuides(svg, boxSelection, {
|
|
1057
1236
|
vLeft: "v-left",
|
|
1058
1237
|
vCenter: "v-center",
|
|
@@ -1061,7 +1240,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1061
1240
|
hCenter: "h-center",
|
|
1062
1241
|
hBottom: "h-bottom",
|
|
1063
1242
|
});
|
|
1064
|
-
ghostRotateElement.current = newAngle;
|
|
1243
|
+
ghostRotateElement.current = Math.round(newAngle);
|
|
1065
1244
|
updateSelectionBox(svg, boxSelection, selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id, true);
|
|
1066
1245
|
};
|
|
1067
1246
|
if (targetRotate && !isRotateSelectionBox)
|
|
@@ -1082,7 +1261,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1082
1261
|
const isMatchWithSelection = activeId === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id);
|
|
1083
1262
|
const { g } = getAttributeElement(svg, activeId);
|
|
1084
1263
|
const boxSelection = getGlobalBBox(svg, g);
|
|
1085
|
-
g === null || g === void 0 ? void 0 : g.setAttribute("transform", `translate(${newX}, ${newY})`);
|
|
1264
|
+
g === null || g === void 0 ? void 0 : g.setAttribute("transform", `translate(${Math.round(newX)}, ${Math.round(newY)})`);
|
|
1086
1265
|
updateSelectionGuides(svg, boxSelection, {
|
|
1087
1266
|
vLeft: "v-left",
|
|
1088
1267
|
vCenter: "v-center",
|
|
@@ -1105,7 +1284,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1105
1284
|
}
|
|
1106
1285
|
};
|
|
1107
1286
|
const pointerHandleUp = (e) => {
|
|
1108
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
1287
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
1109
1288
|
updateSelectionGuides(svg, {
|
|
1110
1289
|
x: 0,
|
|
1111
1290
|
y: 0,
|
|
@@ -1124,26 +1303,15 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1124
1303
|
//show
|
|
1125
1304
|
dispatch({ type: "panel/setShow", payload: true });
|
|
1126
1305
|
}
|
|
1127
|
-
if (targetPointPolygon && targetGroup) {
|
|
1128
|
-
const { element } = getAttributeElement(svg, targetGroup.dataset.id);
|
|
1129
|
-
const points = element === null || element === void 0 ? void 0 : element.getAttribute("points");
|
|
1130
|
-
const pointsArray = pointsStringToArray(points);
|
|
1131
|
-
const findById = [...componentsState, ...extraComponentsState].find((c) => c.id == targetGroup.dataset.id);
|
|
1132
|
-
const newDataComponent = Object.assign(Object.assign({}, findById), { points: pointsArray });
|
|
1133
|
-
updateComponentAttribute(newDataComponent);
|
|
1134
|
-
setSelectedComponent(newDataComponent);
|
|
1135
|
-
dispatch({
|
|
1136
|
-
type: "panel/setSelectedComponent",
|
|
1137
|
-
payload: newDataComponent,
|
|
1138
|
-
});
|
|
1139
|
-
dispatch({
|
|
1140
|
-
type: "panel/setSelectedGroup",
|
|
1141
|
-
payload: null,
|
|
1142
|
-
});
|
|
1143
|
-
}
|
|
1144
1306
|
//POLYGON
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1307
|
+
const isInitialPolygon = activeTool === "polygon" && (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) === "polygon";
|
|
1308
|
+
// console.log({ isInitialPolygon})
|
|
1309
|
+
// if(!isInitialPolygon){
|
|
1310
|
+
// polygonElementRef.current = [];
|
|
1311
|
+
// setSelectedComponent(null);
|
|
1312
|
+
// svg.querySelector("#polyline-helper")?.setAttribute("opacity", "0");
|
|
1313
|
+
// }
|
|
1314
|
+
if (isInitialPolygon) {
|
|
1147
1315
|
const closing = isClosingPolygon(x, y, selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.points);
|
|
1148
1316
|
const newCoord = closing
|
|
1149
1317
|
? {
|
|
@@ -1154,7 +1322,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1154
1322
|
const newPoints = Object.assign(Object.assign({}, selectedComponent), { points: [...selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.points, newCoord] });
|
|
1155
1323
|
(_c = svg.querySelector("#polyline-helper")) === null || _c === void 0 ? void 0 : _c.setAttribute("opacity", "1");
|
|
1156
1324
|
if (closing && ((_d = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.points) === null || _d === void 0 ? void 0 : _d.length) > 2) {
|
|
1157
|
-
const {
|
|
1325
|
+
const { inner } = getAttributeElement(svg, String(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id));
|
|
1158
1326
|
const { height, width } = getGlobalBBox(svg, inner);
|
|
1159
1327
|
isOnMakePolygonRef.current = false;
|
|
1160
1328
|
setSelectedComponent(null);
|
|
@@ -1165,10 +1333,10 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1165
1333
|
polygonElementRef.current = [];
|
|
1166
1334
|
addComponents(Object.assign(Object.assign({}, newPoints), { x: 0, y: 0, width, height }));
|
|
1167
1335
|
(_e = svg.querySelector("#selection-box-ghost")) === null || _e === void 0 ? void 0 : _e.remove();
|
|
1168
|
-
const polyline = svg.querySelector("#polyline-helper");
|
|
1169
1336
|
(_f = svg.querySelector("#polyline-helper")) === null || _f === void 0 ? void 0 : _f.setAttribute("opacity", "0");
|
|
1170
1337
|
}
|
|
1171
1338
|
else {
|
|
1339
|
+
console.log("gak closing");
|
|
1172
1340
|
setSelectedComponent(newPoints);
|
|
1173
1341
|
dispatch({
|
|
1174
1342
|
type: "panel/setSelectedComponent",
|
|
@@ -1223,7 +1391,6 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1223
1391
|
(_h = svgRef.current) === null || _h === void 0 ? void 0 : _h.querySelectorAll("#ghost-element-create").forEach((el) => el.remove());
|
|
1224
1392
|
isCreateElementRef.current = false;
|
|
1225
1393
|
}
|
|
1226
|
-
// CREATE POLYGON
|
|
1227
1394
|
const hasSelectedOneElement = !isEmpty(selectedComponent) &&
|
|
1228
1395
|
onResizeSelectionRef.current &&
|
|
1229
1396
|
downAtResizePosition;
|
|
@@ -1299,6 +1466,24 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1299
1466
|
//LOGIC FOR SET SHOW
|
|
1300
1467
|
dispatch({ type: "panel/setShow", payload: true });
|
|
1301
1468
|
}
|
|
1469
|
+
// CREATE POLYGON
|
|
1470
|
+
if (targetPointPolygon && targetGroup) {
|
|
1471
|
+
const { element } = getAttributeElement(svg, targetGroup.dataset.id);
|
|
1472
|
+
const points = element === null || element === void 0 ? void 0 : element.getAttribute("points");
|
|
1473
|
+
const pointsArray = pointsStringToArray(points);
|
|
1474
|
+
const findById = [...componentsState, ...extraComponentsState].find((c) => c.id == targetGroup.dataset.id);
|
|
1475
|
+
const newDataComponent = Object.assign(Object.assign({}, findById), { points: pointsArray });
|
|
1476
|
+
updateComponentAttribute(newDataComponent);
|
|
1477
|
+
setSelectedComponent(newDataComponent);
|
|
1478
|
+
dispatch({
|
|
1479
|
+
type: "panel/setSelectedComponent",
|
|
1480
|
+
payload: newDataComponent,
|
|
1481
|
+
});
|
|
1482
|
+
dispatch({
|
|
1483
|
+
type: "panel/setSelectedGroup",
|
|
1484
|
+
payload: null,
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1302
1487
|
//UPDATE DATASET TO STATE IF RESIZE
|
|
1303
1488
|
if (isMightResizeElement) {
|
|
1304
1489
|
const activeId = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id;
|
|
@@ -1335,8 +1520,9 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1335
1520
|
let y2 = [];
|
|
1336
1521
|
allElementSelectionGroup.forEach((element) => {
|
|
1337
1522
|
const activeId = element.id;
|
|
1338
|
-
const { g
|
|
1339
|
-
const { x, y
|
|
1523
|
+
const { g } = getAttributeElement(svg, String(activeId));
|
|
1524
|
+
const { x, y } = getTranslate(g);
|
|
1525
|
+
const { width, height } = getGlobalBBox(svg, g);
|
|
1340
1526
|
xs.push(x);
|
|
1341
1527
|
ys.push(y);
|
|
1342
1528
|
x2.push(x + width);
|
|
@@ -1400,10 +1586,29 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1400
1586
|
(_p = (_o = svgRef.current) === null || _o === void 0 ? void 0 : _o.querySelectorAll("#ghost-element-create")) === null || _p === void 0 ? void 0 : _p.forEach((el) => el.remove());
|
|
1401
1587
|
isCreateElementRef.current = false;
|
|
1402
1588
|
}
|
|
1589
|
+
// RESIZE BOUNDARIES
|
|
1590
|
+
if (positionSelection) {
|
|
1591
|
+
const boundariesRectElement = (_q = svgRef.current) === null || _q === void 0 ? void 0 : _q.querySelector("#bounding-box");
|
|
1592
|
+
const { g, element } = getAttributeElement(svg, String(boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.id));
|
|
1593
|
+
const { x, y } = getTranslate(g);
|
|
1594
|
+
const { width, height } = getGlobalBBox(svg, element);
|
|
1595
|
+
dispatch({
|
|
1596
|
+
type: "board/setBoundingBox",
|
|
1597
|
+
payload: {
|
|
1598
|
+
x,
|
|
1599
|
+
y,
|
|
1600
|
+
width,
|
|
1601
|
+
height,
|
|
1602
|
+
id: `${Date.now()}`,
|
|
1603
|
+
shape: "bounding-box",
|
|
1604
|
+
fill: "transparent",
|
|
1605
|
+
},
|
|
1606
|
+
});
|
|
1607
|
+
}
|
|
1403
1608
|
//RESIZE SELECTION BOX UP
|
|
1404
1609
|
if (downAtResizePositionAndHasSelectionBox || isRotateSelectionBox) {
|
|
1405
1610
|
isResizeSelectionRef.current = false;
|
|
1406
|
-
const results = (
|
|
1611
|
+
const results = (_r = dataElementSelectionGroupRef.current) === null || _r === void 0 ? void 0 : _r.map((item) => {
|
|
1407
1612
|
const { g, element, inner, points } = getAttributeElement(svg, String(item.id));
|
|
1408
1613
|
const { x, y } = getTranslate(g);
|
|
1409
1614
|
const { width, height } = getSvgElementSize(element);
|
|
@@ -1451,7 +1656,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1451
1656
|
!shiftActive &&
|
|
1452
1657
|
!isRotateSelectionBox) {
|
|
1453
1658
|
isResizeSelectionRef.current = false;
|
|
1454
|
-
const results = (
|
|
1659
|
+
const results = (_s = dataElementSelectionGroupRef.current) === null || _s === void 0 ? void 0 : _s.map((item) => {
|
|
1455
1660
|
const { g } = getAttributeElement(svg, String(item.id));
|
|
1456
1661
|
const { x, y } = getTranslate(g);
|
|
1457
1662
|
const getBBox = getGlobalBBox(svg, g);
|
|
@@ -1493,7 +1698,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1493
1698
|
hadSelectionRef.current = false;
|
|
1494
1699
|
}
|
|
1495
1700
|
//DELETE GHOST ELEMENT BISA MEMBU
|
|
1496
|
-
(
|
|
1701
|
+
(_t = svgRef.current) === null || _t === void 0 ? void 0 : _t.querySelectorAll("#ghost-element").forEach((el) => el.remove());
|
|
1497
1702
|
//UPDATE DATASET TO STATE IF MOVEk
|
|
1498
1703
|
// if (releaseGroupRef.current) return;
|
|
1499
1704
|
if ((isMightMove &&
|
|
@@ -1525,7 +1730,6 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1525
1730
|
window.addEventListener("pointermove", pointerHandleMove);
|
|
1526
1731
|
window.addEventListener("pointerup", pointerHandleUp);
|
|
1527
1732
|
};
|
|
1528
|
-
const positionRef = useRef({ x: 0, y: 0 });
|
|
1529
1733
|
const handlePointerMove = (e) => {
|
|
1530
1734
|
const svg = svgRef.current;
|
|
1531
1735
|
const pt = svg.createSVGPoint();
|
|
@@ -1545,10 +1749,12 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1545
1749
|
if (isOnMakePolygonRef === null || isOnMakePolygonRef === void 0 ? void 0 : isOnMakePolygonRef.current) {
|
|
1546
1750
|
const polylineHelper = svg === null || svg === void 0 ? void 0 : svg.querySelector("#polyline-helper");
|
|
1547
1751
|
// const startPoint =
|
|
1752
|
+
if (selectedComponent) {
|
|
1753
|
+
const newPoints = [...selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.points, { x: pos.x, y: pos.y }];
|
|
1754
|
+
const points = newPoints.map((item) => `${item.x},${item.y}`).join(" ");
|
|
1755
|
+
polylineHelper === null || polylineHelper === void 0 ? void 0 : polylineHelper.setAttribute("points", points);
|
|
1756
|
+
}
|
|
1548
1757
|
// selectedComponent?.points[selectedComponent?.points?.length - 1];
|
|
1549
|
-
const newPoints = [...selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.points, { x: pos.x, y: pos.y }];
|
|
1550
|
-
const points = newPoints.map((item) => `${item.x},${item.y}`).join(" ");
|
|
1551
|
-
polylineHelper === null || polylineHelper === void 0 ? void 0 : polylineHelper.setAttribute("points", points);
|
|
1552
1758
|
//lin helper from start to move
|
|
1553
1759
|
}
|
|
1554
1760
|
};
|
|
@@ -1573,6 +1779,78 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1573
1779
|
});
|
|
1574
1780
|
}
|
|
1575
1781
|
};
|
|
1782
|
+
const singleSelectionTable = useAppSelector((state) => state.panel.selectedComponent);
|
|
1783
|
+
const groupSelection = useAppSelector((state) => state.panel.selectedGroup);
|
|
1784
|
+
const footerInfoList = useMemo(() => {
|
|
1785
|
+
return [
|
|
1786
|
+
{
|
|
1787
|
+
key: "none",
|
|
1788
|
+
title: "Click & Drag",
|
|
1789
|
+
desc: "to select, move, or resize objects",
|
|
1790
|
+
active: 1,
|
|
1791
|
+
},
|
|
1792
|
+
{
|
|
1793
|
+
title: "Shift + Click",
|
|
1794
|
+
desc: "to add/remove objects from selection",
|
|
1795
|
+
value: 1,
|
|
1796
|
+
},
|
|
1797
|
+
];
|
|
1798
|
+
}, []);
|
|
1799
|
+
const [isShiftPressed, setIsShiftPressed] = useState(false);
|
|
1800
|
+
const handleUndo = () => {
|
|
1801
|
+
dispatch({ type: "board/undoHistory" });
|
|
1802
|
+
dispatch({ type: "board/setFlagChange", payload: true });
|
|
1803
|
+
dispatch({ type: "board/setUpdateBy", payload: "global" });
|
|
1804
|
+
dispatch({ type: "panel/setShow", payload: false });
|
|
1805
|
+
};
|
|
1806
|
+
const handleRedo = () => {
|
|
1807
|
+
dispatch({ type: "board/redoHistory" });
|
|
1808
|
+
dispatch({ type: "board/setFlagChange", payload: true });
|
|
1809
|
+
dispatch({ type: "board/setUpdateBy", payload: "global" });
|
|
1810
|
+
dispatch({ type: "panel/setShow", payload: false });
|
|
1811
|
+
};
|
|
1812
|
+
useEffect(() => {
|
|
1813
|
+
const handleKeyDown = (e) => {
|
|
1814
|
+
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "d") {
|
|
1815
|
+
e.preventDefault(); // 🔥 ini penting
|
|
1816
|
+
e.stopPropagation();
|
|
1817
|
+
handleUnSelectComponent();
|
|
1818
|
+
}
|
|
1819
|
+
if (e.key === "Shift") {
|
|
1820
|
+
setIsShiftPressed(true);
|
|
1821
|
+
}
|
|
1822
|
+
const isModifier = e.metaKey || e.ctrlKey;
|
|
1823
|
+
const key = e.key.toLowerCase();
|
|
1824
|
+
// UNDO
|
|
1825
|
+
if (isModifier && key === "z" && !e.shiftKey) {
|
|
1826
|
+
e.preventDefault();
|
|
1827
|
+
handleUndo();
|
|
1828
|
+
}
|
|
1829
|
+
// REDO (Cmd+Shift+Z / Ctrl+Shift+Z)
|
|
1830
|
+
if (isModifier && key === "z" && e.shiftKey) {
|
|
1831
|
+
e.preventDefault();
|
|
1832
|
+
handleRedo();
|
|
1833
|
+
}
|
|
1834
|
+
// REDO alternative (Ctrl+Y - Windows)
|
|
1835
|
+
if (e.ctrlKey && key === "y") {
|
|
1836
|
+
e.preventDefault();
|
|
1837
|
+
handleRedo();
|
|
1838
|
+
}
|
|
1839
|
+
};
|
|
1840
|
+
const handleKeyUp = (e) => {
|
|
1841
|
+
if (e.key === "Shift") {
|
|
1842
|
+
setIsShiftPressed(false);
|
|
1843
|
+
}
|
|
1844
|
+
};
|
|
1845
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
1846
|
+
window.addEventListener("keyup", handleKeyUp);
|
|
1847
|
+
return () => {
|
|
1848
|
+
window.removeEventListener("keydown", handleKeyDown);
|
|
1849
|
+
window.removeEventListener("keyup", handleKeyUp);
|
|
1850
|
+
};
|
|
1851
|
+
}, []);
|
|
1852
|
+
const hasSelectionBox = !isEmpty(selectedLines);
|
|
1853
|
+
// console.log({ selectedComponent, polygonElementRef, componentsState,selectedComponent})
|
|
1576
1854
|
return (<>
|
|
1577
1855
|
<ModalPreview>
|
|
1578
1856
|
<LayerView statusKey="status" loadingRender={loadingRender} actionPrivileged={{
|
|
@@ -1584,19 +1862,35 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1584
1862
|
}} defaultBoundingBox={boundingBox}/>
|
|
1585
1863
|
<div className="flex gap-2 mt-2">
|
|
1586
1864
|
<Radio.Group value={isShowTagType} onChange={handleCheckPreview}>
|
|
1587
|
-
<Radio value="default">
|
|
1588
|
-
<Radio value="type-1">
|
|
1589
|
-
<Radio value="type-2">
|
|
1865
|
+
<Radio value="default">Event Layout</Radio>
|
|
1866
|
+
<Radio value="type-1">Layout View</Radio>
|
|
1867
|
+
<Radio value="type-2">Next 3 Reservation</Radio>
|
|
1590
1868
|
</Radio.Group>
|
|
1591
1869
|
</div>
|
|
1592
1870
|
</ModalPreview>
|
|
1593
1871
|
<div className="relative w-full h-screen flex-1 overflow-hidden" ref={containerRef}>
|
|
1594
|
-
<div className="absolute bottom-
|
|
1872
|
+
<div className="absolute bottom-10 left-1/2 transform -translate-x-1/2 z-10">
|
|
1595
1873
|
<div className="flex gap-2">
|
|
1596
1874
|
<Button icon={<ZoomIn />} onClick={handelZoomIn}/>
|
|
1597
1875
|
<Button icon={<ZoomOut />} onClick={handleZoomOut}/>
|
|
1598
1876
|
</div>
|
|
1599
1877
|
</div>
|
|
1878
|
+
<div className="w-full bg-white absolute bottom-0 left-1/2 transform -translate-x-1/2 z-10 p-1 flex justify-start items-center gap-2 border-t border-gray-300">
|
|
1879
|
+
Select{" "}
|
|
1880
|
+
<Tag color={isShiftPressed ? "red" : "lime"}>
|
|
1881
|
+
{footerInfoList[hasSelectionBox ? 1 : 0]["title"]}
|
|
1882
|
+
</Tag>{" "}
|
|
1883
|
+
{footerInfoList[hasSelectionBox ? 1 : 0]["desc"]}
|
|
1884
|
+
{hasSelectionBox && (<>
|
|
1885
|
+
<Tag color="lime">
|
|
1886
|
+
<Flex>
|
|
1887
|
+
<Command size={16}/>D
|
|
1888
|
+
</Flex>
|
|
1889
|
+
</Tag>
|
|
1890
|
+
to deselect
|
|
1891
|
+
</>)}{" "}
|
|
1892
|
+
| Table Total <Tag color="volcano">{componentsState === null || componentsState === void 0 ? void 0 : componentsState.length}</Tag>
|
|
1893
|
+
</div>
|
|
1600
1894
|
<TransformWrapper ref={transformRef}
|
|
1601
1895
|
// limitToBounds={true}
|
|
1602
1896
|
panning={{
|
|
@@ -1614,7 +1908,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
|
|
|
1614
1908
|
// centerZoomedOut={true}
|
|
1615
1909
|
// onTransformed={handleTransformed}
|
|
1616
1910
|
minScale={0.1} // sangat kecil = bisa zoom out jauh
|
|
1617
|
-
maxScale={
|
|
1911
|
+
maxScale={2} initialScale={scale} pinch={{ step: 1 }} wheel={{ disabled: true }} smooth={true} doubleClick={{ step: 1, disabled: activeTool === "select" }} disablePadding centerOnInit>
|
|
1618
1912
|
{/* {scale !== 1 && ( */}
|
|
1619
1913
|
{/* <div className="absolute bottom-[60px] left-1/2 transform -translate-x-1/2 z-10"> */}
|
|
1620
1914
|
{/* {renderMiniMap()} */}
|