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