seat-editor 3.6.6 → 3.6.8
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/graph-view/page.d.ts +1 -1
- package/dist/app/graph-view-new/page.d.ts +1 -1
- package/dist/app/graph-view-new/page.js +100 -12
- package/dist/app/graph-view-new/page.jsx +105 -19
- package/dist/app/graph-view-new/test.d.ts +0 -0
- package/dist/app/graph-view-new/test.js +0 -0
- package/dist/app/graph-view-new/test.jsx +0 -0
- package/dist/app/layout.d.ts +1 -1
- package/dist/app/new-board/page.d.ts +1 -1
- package/dist/app/new-board/page.js +1 -1
- package/dist/app/new-board/page.jsx +1 -1
- package/dist/app/old-board/page.d.ts +1 -2
- package/dist/app/only-view/chair.d.ts +1 -1
- package/dist/app/only-view/chair.js +2 -10
- package/dist/app/only-view/page.d.ts +1 -1
- package/dist/app/only-view/user.d.ts +1 -1
- package/dist/app/only-view/user.js +2 -10
- package/dist/app/page.d.ts +1 -1
- package/dist/app/test/page.d.ts +1 -2
- package/dist/app/v2/page.d.ts +1 -1
- package/dist/components/button-radio/index.d.ts +1 -1
- package/dist/components/button-tools/index.d.ts +1 -1
- package/dist/components/form-tools/label.d.ts +1 -1
- package/dist/components/form-tools/shape.d.ts +2 -2
- package/dist/components/icons/camera.d.ts +1 -2
- package/dist/components/icons/circle.d.ts +1 -2
- package/dist/components/icons/square.d.ts +1 -2
- package/dist/components/icons/type-1.d.ts +1 -2
- package/dist/components/icons/type-2.d.ts +1 -2
- package/dist/components/icons/type-3.d.ts +1 -2
- package/dist/components/icons/type-4.d.ts +1 -2
- package/dist/components/icons/type-5.d.ts +1 -2
- package/dist/components/input/number-indicator.d.ts +1 -1
- package/dist/components/joystick/index.d.ts +1 -2
- package/dist/components/layer/index.d.ts +1 -1
- package/dist/components/layer-v2/index.d.ts +1 -1
- package/dist/components/layer-v3/index.d.ts +2 -3
- package/dist/components/layer-v4/index.d.ts +1 -1
- package/dist/components/layer-v5/icons.d.ts +1 -0
- package/dist/components/layer-v5/icons.js +2 -0
- package/dist/components/layer-v5/icons.jsx +3 -0
- package/dist/components/layer-v5/index.d.ts +4 -1
- package/dist/components/layer-v5/index.js +203 -228
- package/dist/components/layer-v5/index.jsx +234 -272
- package/dist/components/lib/index.d.ts +1 -1
- package/dist/components/modal-preview/index.d.ts +1 -1
- package/dist/features/board/index.d.ts +1 -1
- package/dist/features/board-v2/index.d.ts +1 -2
- package/dist/features/board-v3/icons.d.ts +1 -1
- package/dist/features/board-v3/index.d.ts +2 -2
- package/dist/features/board-v3/index.js +3 -3
- package/dist/features/board-v3/index.jsx +3 -3
- package/dist/features/navbar/index.d.ts +1 -1
- package/dist/features/package/index.d.ts +2 -2
- package/dist/features/package/index.js +1 -1
- package/dist/features/package/index.jsx +2 -2
- package/dist/features/panel/index.d.ts +1 -1
- package/dist/features/panel/polygon.d.ts +1 -1
- package/dist/features/panel/select-tool.d.ts +1 -1
- package/dist/features/panel/selected-group.d.ts +1 -1
- package/dist/features/panel/square-circle-tool.d.ts +1 -1
- package/dist/features/panel/table-seat-circle.d.ts +1 -1
- package/dist/features/panel/table-seat-square.d.ts +1 -1
- package/dist/features/panel/text-tool.d.ts +1 -1
- package/dist/features/panel/upload-group-tool.d.ts +1 -1
- package/dist/features/panel/upload-tool.d.ts +1 -1
- package/dist/features/side-tool/icons.d.ts +1 -1
- package/dist/features/side-tool/index.d.ts +3 -3
- package/dist/features/side-tool/index.js +2 -2
- package/dist/features/side-tool/index.jsx +2 -2
- package/dist/features/view-only/index.d.ts +1 -1
- package/dist/features/view-only-2/index.d.ts +1 -1
- package/dist/features/view-only-3/index.d.ts +1 -1
- package/dist/features/view-only-4/index.d.ts +1 -1
- package/dist/features/view-only-5/connect-handle.d.ts +7 -0
- package/dist/features/view-only-5/connect-handle.js +10 -7
- package/dist/features/view-only-5/connect-handle.jsx +11 -7
- package/dist/features/view-only-5/connection-layer.d.ts +0 -1
- package/dist/features/view-only-5/connection-layer.js +7 -5
- package/dist/features/view-only-5/connection-layer.jsx +7 -5
- package/dist/features/view-only-5/index.d.ts +14 -5
- package/dist/features/view-only-5/index.js +168 -123
- package/dist/features/view-only-5/index.jsx +169 -124
- package/dist/features/view-only-5/use-connection-graph.js +1 -1
- package/dist/features/view-only-5/utils.d.ts +7 -1
- package/dist/features/view-only-5/utils.js +15 -7
- package/dist/features/view-only-6/index.d.ts +1 -1
- package/dist/features/view-only-7/index.d.ts +1 -1
- package/dist/provider/redux-provider.d.ts +1 -1
- package/dist/provider/store-provider.d.ts +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import React, { useEffect, useMemo, useRef, useState, useImperativeHandle, useCa
|
|
|
3
3
|
import { TransformWrapper, TransformComponent, } from "react-zoom-pan-pinch";
|
|
4
4
|
import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
|
|
5
5
|
import Layers from "../../components/layer-v5";
|
|
6
|
-
import { createTableGhost, getGlobalBBox, } from "../board-v3/utils";
|
|
6
|
+
import { createTableGhost, getGlobalBBox, getTranslate, } from "../board-v3/utils";
|
|
7
7
|
import { Spin } from "antd";
|
|
8
8
|
import { rotatePoint, renderElements } from "./utils";
|
|
9
9
|
import { useConnectionGraph } from "./use-connection-graph";
|
|
@@ -12,14 +12,22 @@ import { ConnectHandle } from "./connect-handle";
|
|
|
12
12
|
import { getAttributeElement } from "../board-v3/resize-element";
|
|
13
13
|
const LayerView = (props) => {
|
|
14
14
|
var _a, _b, _c, _d;
|
|
15
|
-
const { componentProps, extraComponentProps, onSelectComponent, onDoubleClick, mappingKey, statusKey, defaultBackground, defaultBoundingBox,
|
|
15
|
+
const { componentProps, extraComponentProps, onSelectComponent, onDoubleClick, mappingKey, statusKey, defaultBackground, defaultBoundingBox,
|
|
16
|
+
// iconTags,
|
|
17
|
+
tooltipProps, onRightClick, allowTooltip = true, tableMatchKey, eventMatchTable, ghostAttributes, onDrop, onSwitch, refs, privilegedTags, loadingRender, actionPrivileged = {
|
|
16
18
|
select: true,
|
|
17
19
|
move: true,
|
|
18
20
|
switch: true,
|
|
19
21
|
drop: true,
|
|
20
22
|
rightClick: true,
|
|
21
23
|
double: true,
|
|
22
|
-
|
|
24
|
+
selection: true,
|
|
25
|
+
grapConnection: true,
|
|
26
|
+
viewGraph: true,
|
|
27
|
+
dragTable: true,
|
|
28
|
+
selectNode: true,
|
|
29
|
+
connectingNode: true
|
|
30
|
+
}, onMakeSelection, } = props;
|
|
23
31
|
const widthTooltip = (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.minWidth) || 168;
|
|
24
32
|
const tableGhost = useRef(null);
|
|
25
33
|
const hoverUnderghostId = useRef(null);
|
|
@@ -37,6 +45,7 @@ const LayerView = (props) => {
|
|
|
37
45
|
const [scale, setScale] = useState(1);
|
|
38
46
|
const [selectedTable, setSelectedTable] = useState(null);
|
|
39
47
|
const dataElementSelectionGroupRef = useRef([]);
|
|
48
|
+
const [selectedLines, setSelectedLines] = useState(null);
|
|
40
49
|
const { components: componentsEditor, extraComponents: extraComponentsEditor, boundingBox: boundingBoxProps, } = useAppSelector((state) => state.board);
|
|
41
50
|
const backgroundColor = useAppSelector((state) => state.board.backgroundColor);
|
|
42
51
|
const { loading } = useAppSelector((state) => state.panel);
|
|
@@ -108,6 +117,10 @@ const LayerView = (props) => {
|
|
|
108
117
|
}
|
|
109
118
|
return data;
|
|
110
119
|
};
|
|
120
|
+
const handleUnSelectComponent = () => {
|
|
121
|
+
setSelectedLines(null);
|
|
122
|
+
dataElementSelectionGroupRef.current = [];
|
|
123
|
+
};
|
|
111
124
|
const handleDoubleClick = (items, e) => {
|
|
112
125
|
const find = componentsEditor.find((item) => {
|
|
113
126
|
var _a;
|
|
@@ -203,46 +216,31 @@ const LayerView = (props) => {
|
|
|
203
216
|
height: maxY,
|
|
204
217
|
};
|
|
205
218
|
}, [componentsEditor, extraComponentsEditor, boundingBoxProps]);
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
try {
|
|
232
|
-
const tableId = JSON.parse(group.getAttribute("data-id") || "{}");
|
|
233
|
-
const dragEvent = event;
|
|
234
|
-
const dataTransfer = JSON.parse(((_a = dragEvent.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData("application/json")) || "{}");
|
|
235
|
-
const data = {
|
|
236
|
-
targetTable: originalData({ id: tableId, type: "find" }),
|
|
237
|
-
sourceTable: originalData({ dataParams: dataTransfer, type: "get" }),
|
|
238
|
-
};
|
|
239
|
-
if (type === "drop")
|
|
240
|
-
onDrop && (actionPrivileged === null || actionPrivileged === void 0 ? void 0 : actionPrivileged.drop) && onDrop(event, data);
|
|
241
|
-
}
|
|
242
|
-
catch (err) {
|
|
243
|
-
console.error("Invalid data-id JSON:", err);
|
|
244
|
-
}
|
|
245
|
-
};
|
|
219
|
+
// const handleTableEvent = (
|
|
220
|
+
// event: React.MouseEvent<SVGSVGElement>,
|
|
221
|
+
// type: EventHandleType
|
|
222
|
+
// ) => {
|
|
223
|
+
// event.preventDefault();
|
|
224
|
+
// const elementTarget = event.target as SVGElement | null;
|
|
225
|
+
// if (!elementTarget) return;
|
|
226
|
+
// const group = elementTarget.closest("g[data-id]");
|
|
227
|
+
// if (!group) return;
|
|
228
|
+
// try {
|
|
229
|
+
// const tableId = JSON.parse(group.getAttribute("data-id") || "{}");
|
|
230
|
+
// const dragEvent = event as React.DragEvent<SVGSVGElement>;
|
|
231
|
+
// const dataTransfer = JSON.parse(
|
|
232
|
+
// dragEvent.dataTransfer?.getData("application/json") || "{}"
|
|
233
|
+
// );
|
|
234
|
+
// // const data = {
|
|
235
|
+
// // targetTable: originalData({ id: tableId, type: "find" }),
|
|
236
|
+
// // sourceTable: originalData({ dataParams: dataTransfer, type: "get" }),
|
|
237
|
+
// // };
|
|
238
|
+
// // if (type === "drop")
|
|
239
|
+
// // onDrop && actionPrivileged?.drop && onDrop(event, data);
|
|
240
|
+
// } catch (err) {
|
|
241
|
+
// console.error("Invalid data-id JSON:", err);
|
|
242
|
+
// }
|
|
243
|
+
// };
|
|
246
244
|
const getSvgCoords = (e) => {
|
|
247
245
|
var _a;
|
|
248
246
|
const svg = svgRef.current;
|
|
@@ -256,9 +254,13 @@ const LayerView = (props) => {
|
|
|
256
254
|
const clickTimerRef = useRef(null);
|
|
257
255
|
const ignoreNextRef = useRef(false);
|
|
258
256
|
const DOUBLE_DELAY = 250;
|
|
257
|
+
useEffect(() => {
|
|
258
|
+
if (!(actionPrivileged === null || actionPrivileged === void 0 ? void 0 : actionPrivileged.selection)) {
|
|
259
|
+
setSelectedLines(null);
|
|
260
|
+
}
|
|
261
|
+
}, [actionPrivileged]);
|
|
259
262
|
const handlePointerDown = (e) => {
|
|
260
|
-
var _a;
|
|
261
|
-
console.log("handlePointerDown", e);
|
|
263
|
+
var _a, _b, _c;
|
|
262
264
|
const svg = svgRef.current;
|
|
263
265
|
if (!e.isPrimary || !svg)
|
|
264
266
|
return;
|
|
@@ -270,7 +272,15 @@ const LayerView = (props) => {
|
|
|
270
272
|
const targetGroup = e.target.closest("g[data-id]");
|
|
271
273
|
const { clientX, clientY } = e;
|
|
272
274
|
const hitPoint = document.elementFromPoint(clientX, clientY);
|
|
273
|
-
const
|
|
275
|
+
const downOutTable = (hitPoint === null || hitPoint === void 0 ? void 0 : hitPoint.nodeName) === "svg";
|
|
276
|
+
const makeSelection = downOutTable && (actionPrivileged === null || actionPrivileged === void 0 ? void 0 : actionPrivileged.selection);
|
|
277
|
+
const hadSelection = dataElementSelectionGroupRef.current.length > 0;
|
|
278
|
+
const downInOutSelection = hadSelection && makeSelection;
|
|
279
|
+
if (downOutTable) {
|
|
280
|
+
if (graph.connecting) {
|
|
281
|
+
graph.cancelConnect();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
274
284
|
if (makeSelection) {
|
|
275
285
|
const boxSelection = createTableGhost({
|
|
276
286
|
x,
|
|
@@ -283,78 +293,72 @@ const LayerView = (props) => {
|
|
|
283
293
|
});
|
|
284
294
|
(_a = svgRef.current) === null || _a === void 0 ? void 0 : _a.appendChild(boxSelection);
|
|
285
295
|
}
|
|
296
|
+
if (downInOutSelection) {
|
|
297
|
+
handleUnSelectComponent();
|
|
298
|
+
}
|
|
286
299
|
setPanningGroup(true);
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
300
|
+
if (!targetGroup) {
|
|
301
|
+
setTooltip((prev) => (Object.assign(Object.assign({}, prev), { visible: false })));
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
let ghost = targetGroup.cloneNode(true);
|
|
305
|
+
const ghostId = JSON.parse(targetGroup.getAttribute("data-id") || "{}");
|
|
306
|
+
const allowedDrag = (!(props === null || props === void 0 ? void 0 : props.dragTableBlockKey)
|
|
307
|
+
? true
|
|
308
|
+
: !((_b = props === null || props === void 0 ? void 0 : props.dragTableBlockKey) === null || _b === void 0 ? void 0 : _b.some((_) => {
|
|
309
|
+
const dataRaw = originalData({ id: ghostId, type: "find" });
|
|
310
|
+
return _.value === (dataRaw === null || dataRaw === void 0 ? void 0 : dataRaw[_.key]);
|
|
311
|
+
}))) &&
|
|
312
|
+
(actionPrivileged === null || actionPrivileged === void 0 ? void 0 : actionPrivileged.dragTable);
|
|
313
|
+
if (ghostAttributes) {
|
|
314
|
+
Object.keys(ghostAttributes).forEach((key) => ghost.setAttribute(key, ghostAttributes[key]));
|
|
315
|
+
}
|
|
316
|
+
if (allowedDrag) {
|
|
317
|
+
(_c = e.dataTransfer) === null || _c === void 0 ? void 0 : _c.setData("application/json", JSON.stringify(ghostId));
|
|
318
|
+
const dataRaw = originalData({ id: ghostId, type: "find" });
|
|
319
|
+
(actionPrivileged === null || actionPrivileged === void 0 ? void 0 : actionPrivileged.dragTable) && (props === null || props === void 0 ? void 0 : props.onDragTable) && props.onDragTable(e, dataRaw);
|
|
320
|
+
}
|
|
321
|
+
ghost.setAttribute("opacity", "0.5");
|
|
322
|
+
ghost.setAttribute("pointer-events", "none");
|
|
323
|
+
ghost.setAttribute("stroke-width", "1");
|
|
324
|
+
svg.appendChild(ghost);
|
|
325
|
+
tableGhost.current = ghost;
|
|
326
|
+
const startBox = getTranslate(targetGroup);
|
|
327
|
+
const groupCTM = targetGroup.getCTM();
|
|
328
|
+
if (!groupCTM) {
|
|
329
|
+
setTooltip((prev) => (Object.assign(Object.assign({}, prev), { visible: false })));
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const offset = { x: x - startBox.x, y: y - startBox.y };
|
|
319
333
|
const pointerMoveGhost = (ev) => {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
// );
|
|
344
|
-
// const dataGhostId = JSON.parse(ghost.getAttribute("data-id") || "{}");
|
|
345
|
-
// if (dataHoveredGhostId !== dataGhostId)
|
|
346
|
-
// hoverUnderghostId.current = dataHoveredGhostId;
|
|
347
|
-
// const posSVG = p.matrixTransform(svg.getScreenCTM()?.inverse());
|
|
348
|
-
// ghost.setAttribute(
|
|
349
|
-
// "transform",
|
|
350
|
-
// `translate(${posSVG.x - offset.x}, ${posSVG.y - offset.y})`
|
|
351
|
-
// );
|
|
352
|
-
// }
|
|
334
|
+
var _a;
|
|
335
|
+
if (allowedDrag) {
|
|
336
|
+
isDragging.current = true;
|
|
337
|
+
const p = svg.createSVGPoint();
|
|
338
|
+
p.x = ev.clientX;
|
|
339
|
+
p.y = ev.clientY;
|
|
340
|
+
const dx = ev.clientX - startX;
|
|
341
|
+
const dy = ev.clientY - startY;
|
|
342
|
+
onPanning(ev);
|
|
343
|
+
if (!hasMoved && Math.sqrt(dx * dx + dy * dy) > 0) {
|
|
344
|
+
hasMoved = true;
|
|
345
|
+
}
|
|
346
|
+
ghost.style.display = "none";
|
|
347
|
+
const elemUnderPointer = document.elementFromPoint(ev.clientX, ev.clientY);
|
|
348
|
+
ghost.style.display = "";
|
|
349
|
+
const hoveredGroup = elemUnderPointer === null || elemUnderPointer === void 0 ? void 0 : elemUnderPointer.closest("g[data-id]");
|
|
350
|
+
const dataHoveredGhostId = JSON.parse((hoveredGroup === null || hoveredGroup === void 0 ? void 0 : hoveredGroup.getAttribute("data-id")) || "{}");
|
|
351
|
+
const dataGhostId = JSON.parse(ghost.getAttribute("data-id") || "{}");
|
|
352
|
+
if (dataHoveredGhostId !== dataGhostId)
|
|
353
|
+
hoverUnderghostId.current = dataHoveredGhostId;
|
|
354
|
+
const posSVG = p.matrixTransform((_a = svg.getScreenCTM()) === null || _a === void 0 ? void 0 : _a.inverse());
|
|
355
|
+
ghost.setAttribute("transform", `translate(${posSVG.x - offset.x}, ${posSVG.y - offset.y})`);
|
|
356
|
+
}
|
|
353
357
|
const pt = svg.createSVGPoint();
|
|
354
358
|
pt.x = ev.clientX;
|
|
355
359
|
pt.y = ev.clientY;
|
|
356
360
|
const pos = pt.matrixTransform(svg.getScreenCTM().inverse());
|
|
357
|
-
const onMakeSelectionBox = (
|
|
361
|
+
const onMakeSelectionBox = () => {
|
|
358
362
|
var _a, _b;
|
|
359
363
|
let selectionBoxGhost = svg.querySelector("#selection-box-ghost");
|
|
360
364
|
const selX = Math.min(pos.x, x);
|
|
@@ -395,11 +399,11 @@ const LayerView = (props) => {
|
|
|
395
399
|
dataElementSelectionGroupRef.current = selectedComps;
|
|
396
400
|
};
|
|
397
401
|
if (makeSelection)
|
|
398
|
-
onMakeSelectionBox(
|
|
402
|
+
onMakeSelectionBox();
|
|
399
403
|
};
|
|
400
404
|
pointerMoveGhost(e.nativeEvent);
|
|
401
405
|
const pointerHandleUp = (e) => {
|
|
402
|
-
var _a, _b;
|
|
406
|
+
var _a, _b, _c;
|
|
403
407
|
if (targetGroup) {
|
|
404
408
|
const dataId = JSON.parse(targetGroup.getAttribute("data-id") || "{}");
|
|
405
409
|
isDragging.current = false;
|
|
@@ -435,11 +439,46 @@ const LayerView = (props) => {
|
|
|
435
439
|
clickTimerRef.current = null;
|
|
436
440
|
}, DOUBLE_DELAY);
|
|
437
441
|
}
|
|
438
|
-
if (makeSelection) {
|
|
439
|
-
const allTableInSelection = (
|
|
440
|
-
const filterTableInSelection = componentProps === null || componentProps === void 0 ? void 0 : componentProps.filter((item) => {
|
|
442
|
+
if (makeSelection && ((_a = dataElementSelectionGroupRef.current) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
443
|
+
const allTableInSelection = (_b = dataElementSelectionGroupRef.current) === null || _b === void 0 ? void 0 : _b.map((d) => d.id);
|
|
444
|
+
const filterTableInSelection = componentProps === null || componentProps === void 0 ? void 0 : componentProps.filter((item) => {
|
|
445
|
+
var _a, _b;
|
|
446
|
+
return ((_a = item === null || item === void 0 ? void 0 : item[mappingKey]) === null || _a === void 0 ? void 0 : _a.id) &&
|
|
447
|
+
(allTableInSelection === null || allTableInSelection === void 0 ? void 0 : allTableInSelection.includes((_b = item === null || item === void 0 ? void 0 : item[mappingKey]) === null || _b === void 0 ? void 0 : _b.id));
|
|
448
|
+
});
|
|
441
449
|
onMakeSelection && onMakeSelection(filterTableInSelection);
|
|
442
|
-
|
|
450
|
+
let xs = [];
|
|
451
|
+
let ys = [];
|
|
452
|
+
let x2 = [];
|
|
453
|
+
let y2 = [];
|
|
454
|
+
dataElementSelectionGroupRef.current.forEach((element) => {
|
|
455
|
+
const activeId = element.id;
|
|
456
|
+
const { g } = getAttributeElement(svg, String(activeId));
|
|
457
|
+
const { x, y } = getTranslate(g);
|
|
458
|
+
const { width, height } = getGlobalBBox(svg, g);
|
|
459
|
+
xs.push(x);
|
|
460
|
+
ys.push(y);
|
|
461
|
+
x2.push(x + width);
|
|
462
|
+
y2.push(y + height);
|
|
463
|
+
});
|
|
464
|
+
const selectionBox = {
|
|
465
|
+
x: Math.min(...xs),
|
|
466
|
+
y: Math.min(...ys),
|
|
467
|
+
width: Math.max(...x2) - Math.min(...xs),
|
|
468
|
+
height: Math.max(...y2) - Math.min(...ys),
|
|
469
|
+
stroke: "red",
|
|
470
|
+
shape: "selection-box",
|
|
471
|
+
fill: "transparent",
|
|
472
|
+
id: `${Date.now()}`,
|
|
473
|
+
rotation: 0,
|
|
474
|
+
};
|
|
475
|
+
function hasInvalidNumber(obj) {
|
|
476
|
+
return Object.values(obj).some((v) => typeof v === "number" && !Number.isFinite(v));
|
|
477
|
+
}
|
|
478
|
+
if (!hasInvalidNumber(selectionBox)) {
|
|
479
|
+
setSelectedLines(selectionBox);
|
|
480
|
+
}
|
|
481
|
+
(_c = svg.querySelector("#selection-box-ghost")) === null || _c === void 0 ? void 0 : _c.remove();
|
|
443
482
|
}
|
|
444
483
|
setPanningGroup(false);
|
|
445
484
|
tableGhost.current = null;
|
|
@@ -562,7 +601,7 @@ const LayerView = (props) => {
|
|
|
562
601
|
const viewBox = isValidBoundingBox
|
|
563
602
|
? `${boundingBox.minX - (((_a = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _a === void 0 ? void 0 : _a.paddingLeft) || 0)} ${boundingBox.minY - (((_b = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _b === void 0 ? void 0 : _b.paddingTop) || 0)} ${boundingBox.width + (((_c = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _c === void 0 ? void 0 : _c.paddingRight) || 0)} ${boundingBox.height + (((_d = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _d === void 0 ? void 0 : _d.paddingBottom) || 0)}`
|
|
564
603
|
: "0 0 1000 1000";
|
|
565
|
-
const renderedElements = useMemo(() => renderElements(componentsEditor, mappingKey, tableMatchKey,
|
|
604
|
+
const renderedElements = useMemo(() => renderElements(componentsEditor, mappingKey, tableMatchKey, graph.connecting), [componentsEditor, mappingKey, tableMatchKey, statusKey, graph.connecting]);
|
|
566
605
|
return (<div className="relative w-full h-full flex-1" ref={containerRef} style={{ overflow: "auto", WebkitOverflowScrolling: "touch" }} {...props.containerProps}>
|
|
567
606
|
{loading && (<div className="absolute z-10 top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-opacity-50 bg-white w-full h-full flex items-center justify-center">
|
|
568
607
|
{(loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.element) || <Spin />}
|
|
@@ -570,7 +609,9 @@ const LayerView = (props) => {
|
|
|
570
609
|
|
|
571
610
|
<TransformWrapper ref={transformRef} disablePadding={true} centerZoomedOut={true} panning={{ disabled: panningGroup, wheelPanning: true }} wheel={{ disabled: false }} onTransformed={({ state: { scale } }) => setScale(scale)} minScale={1} maxScale={1000} initialScale={1} smooth={true} centerOnInit={true} {...props.transformProps}>
|
|
572
611
|
<TransformComponent wrapperStyle={{ width: "100%", height: "100%" }} contentStyle={{ width: "100%", height: "100%" }}>
|
|
573
|
-
<svg id="workspace" ref={svgRef} width="100%" height="100%" overflow="hidden" viewBox={viewBox} className="h-full" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" onContextMenu={(e) => e.preventDefault()}
|
|
612
|
+
<svg id="workspace" ref={svgRef} width="100%" height="100%" overflow="hidden" viewBox={viewBox} className="h-full" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" onContextMenu={(e) => e.preventDefault()}
|
|
613
|
+
// onDrop={(e) => handleTableEvent(e, "drop")}
|
|
614
|
+
onPointerDown={handlePointerDown} onPointerUp={handleMouseUp} onMouseMove={(e) => graph.onMouseMove(e)} onMouseUp={() => graph.onMouseUp()} onClick={(e) => {
|
|
574
615
|
// if (!graph.draggingAnchor) graph.clearSelection();
|
|
575
616
|
// if (graph.connecting) graph.cancelConnect();
|
|
576
617
|
}} style={{
|
|
@@ -588,20 +629,24 @@ const LayerView = (props) => {
|
|
|
588
629
|
</defs>)}
|
|
589
630
|
|
|
590
631
|
<g id="main-layer" clipPath="url(#contentCrop)">
|
|
591
|
-
<Layers components={[...extraComponentsEditor, ...renderedElements]} selectedTable={selectedTable}
|
|
632
|
+
<Layers components={[...extraComponentsEditor, ...renderedElements]} selectedTable={selectedTable}
|
|
633
|
+
// iconTags={iconTags}
|
|
634
|
+
eventMatchTable={eventMatchTable} privilegedTags={privilegedTags} selectionLines={selectedLines}/>
|
|
592
635
|
</g>
|
|
593
636
|
|
|
594
|
-
<ConnectionLayer edges={graph.edges} selectedEdge={graph.selectedEdge} connecting={graph.connecting} draggingAnchor={graph.draggingAnchor} mousePos={graph.mousePos} getNodeById={getNodeById} onSelectEdge={graph.selectEdge} onDeleteEdge={graph.deleteEdge} onStartDragWaypoint={graph.startDragWaypoint} onInsertWaypoint={graph.insertWaypoint} onRemoveWaypoint={graph.removeWaypoint} onStartDragAnchor={graph.startDragAnchor} isConnectEdge={
|
|
637
|
+
<ConnectionLayer edges={graph.edges} selectedEdge={graph.selectedEdge} connecting={graph.connecting} draggingAnchor={graph.draggingAnchor} mousePos={graph.mousePos} getNodeById={getNodeById} onSelectEdge={graph.selectEdge} onDeleteEdge={graph.deleteEdge} onStartDragWaypoint={graph.startDragWaypoint} onInsertWaypoint={graph.insertWaypoint} onRemoveWaypoint={graph.removeWaypoint} onStartDragAnchor={graph.startDragAnchor} isConnectEdge={actionPrivileged.connectingNode} selectedNodeId={graph.selectedNode}/>
|
|
595
638
|
|
|
596
639
|
{renderedElements.map((item) => {
|
|
597
640
|
var _a, _b, _c, _d;
|
|
598
641
|
const rotated = rotatePoint(item.width / 2, item.height / 2, (_a = item.rotation) !== null && _a !== void 0 ? _a : 0);
|
|
599
|
-
return (<ConnectHandle key={item.id}
|
|
642
|
+
return (<ConnectHandle key={item.id}
|
|
643
|
+
// isAnchor={true}
|
|
644
|
+
connecting={graph.connecting} cx={item.x + rotated.x} cy={item.y + rotated.y} width={(_b = item.width) !== null && _b !== void 0 ? _b : 100} height={(_c = item.height) !== null && _c !== void 0 ? _c : 50} rotation={(_d = item.rotation) !== null && _d !== void 0 ? _d : 0} nodeId={String(item.id)} isConnecting={!!graph.connecting} isDraggingAnchor={!!graph.draggingAnchor} onStartConnect={(nodeId, clickPos) => graph.startConnect(nodeId, clickPos)} onEndConnect={(nodeId, clickPos) => {
|
|
600
645
|
if (graph.draggingAnchor)
|
|
601
646
|
graph.updateAnchor(nodeId, clickPos);
|
|
602
647
|
else
|
|
603
648
|
graph.endConnect(nodeId, clickPos);
|
|
604
|
-
}} isConnectEdge={
|
|
649
|
+
}} isConnectEdge={actionPrivileged.connectingNode} onSelectNode={graph.selectNode} isSelectNode={actionPrivileged.selectNode} onSelectEdge={graph.selectEdge} edges={graph.edges}/>);
|
|
605
650
|
})}
|
|
606
651
|
</svg>
|
|
607
652
|
|
|
@@ -49,7 +49,7 @@ export const useConnectionGraph = ({ svgRef, getNodeById, onEdgesChange, keyNode
|
|
|
49
49
|
},
|
|
50
50
|
];
|
|
51
51
|
});
|
|
52
|
-
setConnecting(null);
|
|
52
|
+
// setConnecting(null);
|
|
53
53
|
}, [connecting]);
|
|
54
54
|
const cancelConnect = useCallback(() => setConnecting(null), []);
|
|
55
55
|
// ── Drag endpoint ────────────────────────────────────────────────
|
|
@@ -49,4 +49,10 @@ export declare const buildPath: (points: {
|
|
|
49
49
|
x: number;
|
|
50
50
|
y: number;
|
|
51
51
|
}[]) => string;
|
|
52
|
-
export declare const renderElements: (elementEditor: ComponentProps[], mappingKey?: string, tableMatchKey?: TableMatchKey[],
|
|
52
|
+
export declare const renderElements: (elementEditor: ComponentProps[], mappingKey?: string, tableMatchKey?: TableMatchKey[], connecting?: {
|
|
53
|
+
fromId: string;
|
|
54
|
+
fromPos: {
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
};
|
|
58
|
+
} | null) => ComponentProps[];
|
|
@@ -38,13 +38,15 @@ export const buildPath = (points) => {
|
|
|
38
38
|
if (points.length < 2)
|
|
39
39
|
return "";
|
|
40
40
|
const start = points[0];
|
|
41
|
+
if (!start)
|
|
42
|
+
return "";
|
|
41
43
|
const end = points[points.length - 1];
|
|
42
44
|
if (points.length === 2) {
|
|
43
45
|
// Quadratic bezier — 1 control point di tengah, digeser tegak lurus
|
|
44
|
-
const mx = (start.x + end.x) / 2;
|
|
45
|
-
const my = (start.y + end.y) / 2;
|
|
46
|
-
const dx = end.x - start.x;
|
|
47
|
-
const dy = end.y - start.y;
|
|
46
|
+
const mx = ((start === null || start === void 0 ? void 0 : start.x) + (end === null || end === void 0 ? void 0 : end.x)) / 2;
|
|
47
|
+
const my = ((start === null || start === void 0 ? void 0 : start.y) + (end === null || end === void 0 ? void 0 : end.y)) / 2;
|
|
48
|
+
const dx = end.x - (start === null || start === void 0 ? void 0 : start.x);
|
|
49
|
+
const dy = end.y - (start === null || start === void 0 ? void 0 : start.y);
|
|
48
50
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
49
51
|
const bend = Math.min(dist * 0.35, 80);
|
|
50
52
|
// Control point tegak lurus dari midpoint
|
|
@@ -65,15 +67,21 @@ export const buildPath = (points) => {
|
|
|
65
67
|
return d;
|
|
66
68
|
};
|
|
67
69
|
// ─── renderElements ──────────────────────────────────────────────────────────
|
|
68
|
-
export const renderElements = (elementEditor, mappingKey, tableMatchKey,
|
|
70
|
+
export const renderElements = (elementEditor, mappingKey, tableMatchKey, connecting) => {
|
|
69
71
|
return elementEditor.map((editorItem) => {
|
|
70
72
|
const isUsingMapping = mappingKey &&
|
|
71
73
|
typeof editorItem[mappingKey] === "object" &&
|
|
72
74
|
editorItem[mappingKey] !== null;
|
|
73
75
|
let finalProps = isUsingMapping ? editorItem[mappingKey] : editorItem;
|
|
74
76
|
if (tableMatchKey) {
|
|
75
|
-
const tableMatch = tableMatchKey.find((item) =>
|
|
76
|
-
|
|
77
|
+
const tableMatch = tableMatchKey.find((item) => {
|
|
78
|
+
const hasKey = Object.keys(editorItem).some((key) => key == item.key);
|
|
79
|
+
if (hasKey)
|
|
80
|
+
return item.value == (editorItem === null || editorItem === void 0 ? void 0 : editorItem[item.key]);
|
|
81
|
+
});
|
|
82
|
+
// console.log({finalProps},{ connecting},connecting?.fromId == finalProps?.id)
|
|
83
|
+
const fill = (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) == (finalProps === null || finalProps === void 0 ? void 0 : finalProps.id) ? "#7239EA" : finalProps === null || finalProps === void 0 ? void 0 : finalProps.fill;
|
|
84
|
+
finalProps = Object.assign(Object.assign(Object.assign({}, finalProps), tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.properties), { fill: fill, className: tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.className, element: tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.element });
|
|
77
85
|
}
|
|
78
86
|
return finalProps;
|
|
79
87
|
});
|
|
@@ -95,5 +95,5 @@ export interface LayerViewProps<TMeta = undefined> {
|
|
|
95
95
|
onEdgesChange?: (edges: EdgeType[], table: PropertiesProps[]) => void;
|
|
96
96
|
keyNode: string;
|
|
97
97
|
}
|
|
98
|
-
declare const LayerView: <TMeta>(props: LayerViewProps<TMeta>) =>
|
|
98
|
+
declare const LayerView: <TMeta>(props: LayerViewProps<TMeta>) => import("react/jsx-runtime").JSX.Element;
|
|
99
99
|
export default LayerView;
|
|
@@ -95,5 +95,5 @@ export interface LayerViewProps<TMeta = undefined> {
|
|
|
95
95
|
onEdgesChange?: (edges: EdgeType[], table: PropertiesProps[]) => void;
|
|
96
96
|
keyNode: string;
|
|
97
97
|
}
|
|
98
|
-
declare const LayerView: <TMeta>(props: LayerViewProps<TMeta>) =>
|
|
98
|
+
declare const LayerView: <TMeta>(props: LayerViewProps<TMeta>) => import("react/jsx-runtime").JSX.Element;
|
|
99
99
|
export default LayerView;
|