seat-editor 3.6.7 → 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-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/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/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 +13 -4
- 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/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { useEffect, useMemo, useRef, useState, useImperativeHandle, useCallback,
|
|
|
4
4
|
import { TransformWrapper, TransformComponent, } from "react-zoom-pan-pinch";
|
|
5
5
|
import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
|
|
6
6
|
import Layers from "../../components/layer-v5";
|
|
7
|
-
import { createTableGhost, getGlobalBBox, } from "../board-v3/utils";
|
|
7
|
+
import { createTableGhost, getGlobalBBox, getTranslate, } from "../board-v3/utils";
|
|
8
8
|
import { Spin } from "antd";
|
|
9
9
|
import { rotatePoint, renderElements } from "./utils";
|
|
10
10
|
import { useConnectionGraph } from "./use-connection-graph";
|
|
@@ -13,14 +13,22 @@ import { ConnectHandle } from "./connect-handle";
|
|
|
13
13
|
import { getAttributeElement } from "../board-v3/resize-element";
|
|
14
14
|
const LayerView = (props) => {
|
|
15
15
|
var _a, _b, _c, _d;
|
|
16
|
-
const { componentProps, extraComponentProps, onSelectComponent, onDoubleClick, mappingKey, statusKey, defaultBackground, defaultBoundingBox,
|
|
16
|
+
const { componentProps, extraComponentProps, onSelectComponent, onDoubleClick, mappingKey, statusKey, defaultBackground, defaultBoundingBox,
|
|
17
|
+
// iconTags,
|
|
18
|
+
tooltipProps, onRightClick, allowTooltip = true, tableMatchKey, eventMatchTable, ghostAttributes, onDrop, onSwitch, refs, privilegedTags, loadingRender, actionPrivileged = {
|
|
17
19
|
select: true,
|
|
18
20
|
move: true,
|
|
19
21
|
switch: true,
|
|
20
22
|
drop: true,
|
|
21
23
|
rightClick: true,
|
|
22
24
|
double: true,
|
|
23
|
-
|
|
25
|
+
selection: true,
|
|
26
|
+
grapConnection: true,
|
|
27
|
+
viewGraph: true,
|
|
28
|
+
dragTable: true,
|
|
29
|
+
selectNode: true,
|
|
30
|
+
connectingNode: true
|
|
31
|
+
}, onMakeSelection, } = props;
|
|
24
32
|
const widthTooltip = (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.minWidth) || 168;
|
|
25
33
|
const tableGhost = useRef(null);
|
|
26
34
|
const hoverUnderghostId = useRef(null);
|
|
@@ -38,6 +46,7 @@ const LayerView = (props) => {
|
|
|
38
46
|
const [scale, setScale] = useState(1);
|
|
39
47
|
const [selectedTable, setSelectedTable] = useState(null);
|
|
40
48
|
const dataElementSelectionGroupRef = useRef([]);
|
|
49
|
+
const [selectedLines, setSelectedLines] = useState(null);
|
|
41
50
|
const { components: componentsEditor, extraComponents: extraComponentsEditor, boundingBox: boundingBoxProps, } = useAppSelector((state) => state.board);
|
|
42
51
|
const backgroundColor = useAppSelector((state) => state.board.backgroundColor);
|
|
43
52
|
const { loading } = useAppSelector((state) => state.panel);
|
|
@@ -109,6 +118,10 @@ const LayerView = (props) => {
|
|
|
109
118
|
}
|
|
110
119
|
return data;
|
|
111
120
|
};
|
|
121
|
+
const handleUnSelectComponent = () => {
|
|
122
|
+
setSelectedLines(null);
|
|
123
|
+
dataElementSelectionGroupRef.current = [];
|
|
124
|
+
};
|
|
112
125
|
const handleDoubleClick = (items, e) => {
|
|
113
126
|
const find = componentsEditor.find((item) => {
|
|
114
127
|
var _a;
|
|
@@ -204,46 +217,31 @@ const LayerView = (props) => {
|
|
|
204
217
|
height: maxY,
|
|
205
218
|
};
|
|
206
219
|
}, [componentsEditor, extraComponentsEditor, boundingBoxProps]);
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
try {
|
|
233
|
-
const tableId = JSON.parse(group.getAttribute("data-id") || "{}");
|
|
234
|
-
const dragEvent = event;
|
|
235
|
-
const dataTransfer = JSON.parse(((_a = dragEvent.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData("application/json")) || "{}");
|
|
236
|
-
const data = {
|
|
237
|
-
targetTable: originalData({ id: tableId, type: "find" }),
|
|
238
|
-
sourceTable: originalData({ dataParams: dataTransfer, type: "get" }),
|
|
239
|
-
};
|
|
240
|
-
if (type === "drop")
|
|
241
|
-
onDrop && (actionPrivileged === null || actionPrivileged === void 0 ? void 0 : actionPrivileged.drop) && onDrop(event, data);
|
|
242
|
-
}
|
|
243
|
-
catch (err) {
|
|
244
|
-
console.error("Invalid data-id JSON:", err);
|
|
245
|
-
}
|
|
246
|
-
};
|
|
220
|
+
// const handleTableEvent = (
|
|
221
|
+
// event: React.MouseEvent<SVGSVGElement>,
|
|
222
|
+
// type: EventHandleType
|
|
223
|
+
// ) => {
|
|
224
|
+
// event.preventDefault();
|
|
225
|
+
// const elementTarget = event.target as SVGElement | null;
|
|
226
|
+
// if (!elementTarget) return;
|
|
227
|
+
// const group = elementTarget.closest("g[data-id]");
|
|
228
|
+
// if (!group) return;
|
|
229
|
+
// try {
|
|
230
|
+
// const tableId = JSON.parse(group.getAttribute("data-id") || "{}");
|
|
231
|
+
// const dragEvent = event as React.DragEvent<SVGSVGElement>;
|
|
232
|
+
// const dataTransfer = JSON.parse(
|
|
233
|
+
// dragEvent.dataTransfer?.getData("application/json") || "{}"
|
|
234
|
+
// );
|
|
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?.drop && onDrop(event, data);
|
|
241
|
+
// } catch (err) {
|
|
242
|
+
// console.error("Invalid data-id JSON:", err);
|
|
243
|
+
// }
|
|
244
|
+
// };
|
|
247
245
|
const getSvgCoords = (e) => {
|
|
248
246
|
var _a;
|
|
249
247
|
const svg = svgRef.current;
|
|
@@ -257,9 +255,13 @@ const LayerView = (props) => {
|
|
|
257
255
|
const clickTimerRef = useRef(null);
|
|
258
256
|
const ignoreNextRef = useRef(false);
|
|
259
257
|
const DOUBLE_DELAY = 250;
|
|
258
|
+
useEffect(() => {
|
|
259
|
+
if (!(actionPrivileged === null || actionPrivileged === void 0 ? void 0 : actionPrivileged.selection)) {
|
|
260
|
+
setSelectedLines(null);
|
|
261
|
+
}
|
|
262
|
+
}, [actionPrivileged]);
|
|
260
263
|
const handlePointerDown = (e) => {
|
|
261
|
-
var _a;
|
|
262
|
-
console.log("handlePointerDown", e);
|
|
264
|
+
var _a, _b, _c;
|
|
263
265
|
const svg = svgRef.current;
|
|
264
266
|
if (!e.isPrimary || !svg)
|
|
265
267
|
return;
|
|
@@ -271,7 +273,15 @@ const LayerView = (props) => {
|
|
|
271
273
|
const targetGroup = e.target.closest("g[data-id]");
|
|
272
274
|
const { clientX, clientY } = e;
|
|
273
275
|
const hitPoint = document.elementFromPoint(clientX, clientY);
|
|
274
|
-
const
|
|
276
|
+
const downOutTable = (hitPoint === null || hitPoint === void 0 ? void 0 : hitPoint.nodeName) === "svg";
|
|
277
|
+
const makeSelection = downOutTable && (actionPrivileged === null || actionPrivileged === void 0 ? void 0 : actionPrivileged.selection);
|
|
278
|
+
const hadSelection = dataElementSelectionGroupRef.current.length > 0;
|
|
279
|
+
const downInOutSelection = hadSelection && makeSelection;
|
|
280
|
+
if (downOutTable) {
|
|
281
|
+
if (graph.connecting) {
|
|
282
|
+
graph.cancelConnect();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
275
285
|
if (makeSelection) {
|
|
276
286
|
const boxSelection = createTableGhost({
|
|
277
287
|
x,
|
|
@@ -284,78 +294,72 @@ const LayerView = (props) => {
|
|
|
284
294
|
});
|
|
285
295
|
(_a = svgRef.current) === null || _a === void 0 ? void 0 : _a.appendChild(boxSelection);
|
|
286
296
|
}
|
|
297
|
+
if (downInOutSelection) {
|
|
298
|
+
handleUnSelectComponent();
|
|
299
|
+
}
|
|
287
300
|
setPanningGroup(true);
|
|
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
|
-
|
|
319
|
-
|
|
301
|
+
if (!targetGroup) {
|
|
302
|
+
setTooltip((prev) => (Object.assign(Object.assign({}, prev), { visible: false })));
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
let ghost = targetGroup.cloneNode(true);
|
|
306
|
+
const ghostId = JSON.parse(targetGroup.getAttribute("data-id") || "{}");
|
|
307
|
+
const allowedDrag = (!(props === null || props === void 0 ? void 0 : props.dragTableBlockKey)
|
|
308
|
+
? true
|
|
309
|
+
: !((_b = props === null || props === void 0 ? void 0 : props.dragTableBlockKey) === null || _b === void 0 ? void 0 : _b.some((_) => {
|
|
310
|
+
const dataRaw = originalData({ id: ghostId, type: "find" });
|
|
311
|
+
return _.value === (dataRaw === null || dataRaw === void 0 ? void 0 : dataRaw[_.key]);
|
|
312
|
+
}))) &&
|
|
313
|
+
(actionPrivileged === null || actionPrivileged === void 0 ? void 0 : actionPrivileged.dragTable);
|
|
314
|
+
if (ghostAttributes) {
|
|
315
|
+
Object.keys(ghostAttributes).forEach((key) => ghost.setAttribute(key, ghostAttributes[key]));
|
|
316
|
+
}
|
|
317
|
+
if (allowedDrag) {
|
|
318
|
+
(_c = e.dataTransfer) === null || _c === void 0 ? void 0 : _c.setData("application/json", JSON.stringify(ghostId));
|
|
319
|
+
const dataRaw = originalData({ id: ghostId, type: "find" });
|
|
320
|
+
(actionPrivileged === null || actionPrivileged === void 0 ? void 0 : actionPrivileged.dragTable) && (props === null || props === void 0 ? void 0 : props.onDragTable) && props.onDragTable(e, dataRaw);
|
|
321
|
+
}
|
|
322
|
+
ghost.setAttribute("opacity", "0.5");
|
|
323
|
+
ghost.setAttribute("pointer-events", "none");
|
|
324
|
+
ghost.setAttribute("stroke-width", "1");
|
|
325
|
+
svg.appendChild(ghost);
|
|
326
|
+
tableGhost.current = ghost;
|
|
327
|
+
const startBox = getTranslate(targetGroup);
|
|
328
|
+
const groupCTM = targetGroup.getCTM();
|
|
329
|
+
if (!groupCTM) {
|
|
330
|
+
setTooltip((prev) => (Object.assign(Object.assign({}, prev), { visible: false })));
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
const offset = { x: x - startBox.x, y: y - startBox.y };
|
|
320
334
|
const pointerMoveGhost = (ev) => {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
// );
|
|
345
|
-
// const dataGhostId = JSON.parse(ghost.getAttribute("data-id") || "{}");
|
|
346
|
-
// if (dataHoveredGhostId !== dataGhostId)
|
|
347
|
-
// hoverUnderghostId.current = dataHoveredGhostId;
|
|
348
|
-
// const posSVG = p.matrixTransform(svg.getScreenCTM()?.inverse());
|
|
349
|
-
// ghost.setAttribute(
|
|
350
|
-
// "transform",
|
|
351
|
-
// `translate(${posSVG.x - offset.x}, ${posSVG.y - offset.y})`
|
|
352
|
-
// );
|
|
353
|
-
// }
|
|
335
|
+
var _a;
|
|
336
|
+
if (allowedDrag) {
|
|
337
|
+
isDragging.current = true;
|
|
338
|
+
const p = svg.createSVGPoint();
|
|
339
|
+
p.x = ev.clientX;
|
|
340
|
+
p.y = ev.clientY;
|
|
341
|
+
const dx = ev.clientX - startX;
|
|
342
|
+
const dy = ev.clientY - startY;
|
|
343
|
+
onPanning(ev);
|
|
344
|
+
if (!hasMoved && Math.sqrt(dx * dx + dy * dy) > 0) {
|
|
345
|
+
hasMoved = true;
|
|
346
|
+
}
|
|
347
|
+
ghost.style.display = "none";
|
|
348
|
+
const elemUnderPointer = document.elementFromPoint(ev.clientX, ev.clientY);
|
|
349
|
+
ghost.style.display = "";
|
|
350
|
+
const hoveredGroup = elemUnderPointer === null || elemUnderPointer === void 0 ? void 0 : elemUnderPointer.closest("g[data-id]");
|
|
351
|
+
const dataHoveredGhostId = JSON.parse((hoveredGroup === null || hoveredGroup === void 0 ? void 0 : hoveredGroup.getAttribute("data-id")) || "{}");
|
|
352
|
+
const dataGhostId = JSON.parse(ghost.getAttribute("data-id") || "{}");
|
|
353
|
+
if (dataHoveredGhostId !== dataGhostId)
|
|
354
|
+
hoverUnderghostId.current = dataHoveredGhostId;
|
|
355
|
+
const posSVG = p.matrixTransform((_a = svg.getScreenCTM()) === null || _a === void 0 ? void 0 : _a.inverse());
|
|
356
|
+
ghost.setAttribute("transform", `translate(${posSVG.x - offset.x}, ${posSVG.y - offset.y})`);
|
|
357
|
+
}
|
|
354
358
|
const pt = svg.createSVGPoint();
|
|
355
359
|
pt.x = ev.clientX;
|
|
356
360
|
pt.y = ev.clientY;
|
|
357
361
|
const pos = pt.matrixTransform(svg.getScreenCTM().inverse());
|
|
358
|
-
const onMakeSelectionBox = (
|
|
362
|
+
const onMakeSelectionBox = () => {
|
|
359
363
|
var _a, _b;
|
|
360
364
|
let selectionBoxGhost = svg.querySelector("#selection-box-ghost");
|
|
361
365
|
const selX = Math.min(pos.x, x);
|
|
@@ -396,11 +400,11 @@ const LayerView = (props) => {
|
|
|
396
400
|
dataElementSelectionGroupRef.current = selectedComps;
|
|
397
401
|
};
|
|
398
402
|
if (makeSelection)
|
|
399
|
-
onMakeSelectionBox(
|
|
403
|
+
onMakeSelectionBox();
|
|
400
404
|
};
|
|
401
405
|
pointerMoveGhost(e.nativeEvent);
|
|
402
406
|
const pointerHandleUp = (e) => {
|
|
403
|
-
var _a, _b;
|
|
407
|
+
var _a, _b, _c;
|
|
404
408
|
if (targetGroup) {
|
|
405
409
|
const dataId = JSON.parse(targetGroup.getAttribute("data-id") || "{}");
|
|
406
410
|
isDragging.current = false;
|
|
@@ -436,11 +440,46 @@ const LayerView = (props) => {
|
|
|
436
440
|
clickTimerRef.current = null;
|
|
437
441
|
}, DOUBLE_DELAY);
|
|
438
442
|
}
|
|
439
|
-
if (makeSelection) {
|
|
440
|
-
const allTableInSelection = (
|
|
441
|
-
const filterTableInSelection = componentProps === null || componentProps === void 0 ? void 0 : componentProps.filter((item) => {
|
|
443
|
+
if (makeSelection && ((_a = dataElementSelectionGroupRef.current) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
444
|
+
const allTableInSelection = (_b = dataElementSelectionGroupRef.current) === null || _b === void 0 ? void 0 : _b.map((d) => d.id);
|
|
445
|
+
const filterTableInSelection = componentProps === null || componentProps === void 0 ? void 0 : componentProps.filter((item) => {
|
|
446
|
+
var _a, _b;
|
|
447
|
+
return ((_a = item === null || item === void 0 ? void 0 : item[mappingKey]) === null || _a === void 0 ? void 0 : _a.id) &&
|
|
448
|
+
(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));
|
|
449
|
+
});
|
|
442
450
|
onMakeSelection && onMakeSelection(filterTableInSelection);
|
|
443
|
-
|
|
451
|
+
let xs = [];
|
|
452
|
+
let ys = [];
|
|
453
|
+
let x2 = [];
|
|
454
|
+
let y2 = [];
|
|
455
|
+
dataElementSelectionGroupRef.current.forEach((element) => {
|
|
456
|
+
const activeId = element.id;
|
|
457
|
+
const { g } = getAttributeElement(svg, String(activeId));
|
|
458
|
+
const { x, y } = getTranslate(g);
|
|
459
|
+
const { width, height } = getGlobalBBox(svg, g);
|
|
460
|
+
xs.push(x);
|
|
461
|
+
ys.push(y);
|
|
462
|
+
x2.push(x + width);
|
|
463
|
+
y2.push(y + height);
|
|
464
|
+
});
|
|
465
|
+
const selectionBox = {
|
|
466
|
+
x: Math.min(...xs),
|
|
467
|
+
y: Math.min(...ys),
|
|
468
|
+
width: Math.max(...x2) - Math.min(...xs),
|
|
469
|
+
height: Math.max(...y2) - Math.min(...ys),
|
|
470
|
+
stroke: "red",
|
|
471
|
+
shape: "selection-box",
|
|
472
|
+
fill: "transparent",
|
|
473
|
+
id: `${Date.now()}`,
|
|
474
|
+
rotation: 0,
|
|
475
|
+
};
|
|
476
|
+
function hasInvalidNumber(obj) {
|
|
477
|
+
return Object.values(obj).some((v) => typeof v === "number" && !Number.isFinite(v));
|
|
478
|
+
}
|
|
479
|
+
if (!hasInvalidNumber(selectionBox)) {
|
|
480
|
+
setSelectedLines(selectionBox);
|
|
481
|
+
}
|
|
482
|
+
(_c = svg.querySelector("#selection-box-ghost")) === null || _c === void 0 ? void 0 : _c.remove();
|
|
444
483
|
}
|
|
445
484
|
setPanningGroup(false);
|
|
446
485
|
tableGhost.current = null;
|
|
@@ -563,8 +602,10 @@ const LayerView = (props) => {
|
|
|
563
602
|
const viewBox = isValidBoundingBox
|
|
564
603
|
? `${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)}`
|
|
565
604
|
: "0 0 1000 1000";
|
|
566
|
-
const renderedElements = useMemo(() => renderElements(componentsEditor, mappingKey, tableMatchKey,
|
|
567
|
-
return (_jsxs("div", Object.assign({ className: "relative w-full h-full flex-1", ref: containerRef, style: { overflow: "auto", WebkitOverflowScrolling: "touch" } }, props.containerProps, { children: [loading && (_jsx("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", children: (loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.element) || _jsx(Spin, {}) })), _jsx(TransformWrapper, Object.assign({ 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, { children: _jsxs(TransformComponent, { wrapperStyle: { width: "100%", height: "100%" }, contentStyle: { width: "100%", height: "100%" }, children: [_jsxs("svg", Object.assign({ 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(),
|
|
605
|
+
const renderedElements = useMemo(() => renderElements(componentsEditor, mappingKey, tableMatchKey, graph.connecting), [componentsEditor, mappingKey, tableMatchKey, statusKey, graph.connecting]);
|
|
606
|
+
return (_jsxs("div", Object.assign({ className: "relative w-full h-full flex-1", ref: containerRef, style: { overflow: "auto", WebkitOverflowScrolling: "touch" } }, props.containerProps, { children: [loading && (_jsx("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", children: (loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.element) || _jsx(Spin, {}) })), _jsx(TransformWrapper, Object.assign({ 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, { children: _jsxs(TransformComponent, { wrapperStyle: { width: "100%", height: "100%" }, contentStyle: { width: "100%", height: "100%" }, children: [_jsxs("svg", Object.assign({ 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(),
|
|
607
|
+
// onDrop={(e) => handleTableEvent(e, "drop")}
|
|
608
|
+
onPointerDown: handlePointerDown, onPointerUp: handleMouseUp, onMouseMove: (e) => graph.onMouseMove(e), onMouseUp: () => graph.onMouseUp(), onClick: (e) => {
|
|
568
609
|
// if (!graph.draggingAnchor) graph.clearSelection();
|
|
569
610
|
// if (graph.connecting) graph.cancelConnect();
|
|
570
611
|
}, style: {
|
|
@@ -572,15 +613,19 @@ const LayerView = (props) => {
|
|
|
572
613
|
display: "block",
|
|
573
614
|
touchAction: "none",
|
|
574
615
|
userSelect: "none",
|
|
575
|
-
} }, props.svgProps, { children: [_jsx("rect", { width: "100%", height: "100%", fill: "url(#biggrid)" }), hasBoundingBox && (_jsx("defs", { children: _jsx("clipPath", { id: "contentCrop", children: _jsx("rect", { x: boundingBox.minX, y: boundingBox.minY, width: boundingBox.width, height: boundingBox.height }) }) })), _jsx("g", { id: "main-layer", clipPath: "url(#contentCrop)", children: _jsx(Layers, { components: [...extraComponentsEditor, ...renderedElements], selectedTable: selectedTable,
|
|
616
|
+
} }, props.svgProps, { children: [_jsx("rect", { width: "100%", height: "100%", fill: "url(#biggrid)" }), hasBoundingBox && (_jsx("defs", { children: _jsx("clipPath", { id: "contentCrop", children: _jsx("rect", { x: boundingBox.minX, y: boundingBox.minY, width: boundingBox.width, height: boundingBox.height }) }) })), _jsx("g", { id: "main-layer", clipPath: "url(#contentCrop)", children: _jsx(Layers, { components: [...extraComponentsEditor, ...renderedElements], selectedTable: selectedTable,
|
|
617
|
+
// iconTags={iconTags}
|
|
618
|
+
eventMatchTable: eventMatchTable, privilegedTags: privilegedTags, selectionLines: selectedLines }) }), _jsx(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 }), renderedElements.map((item) => {
|
|
576
619
|
var _a, _b, _c, _d;
|
|
577
620
|
const rotated = rotatePoint(item.width / 2, item.height / 2, (_a = item.rotation) !== null && _a !== void 0 ? _a : 0);
|
|
578
|
-
return (_jsx(ConnectHandle, {
|
|
621
|
+
return (_jsx(ConnectHandle, {
|
|
622
|
+
// isAnchor={true}
|
|
623
|
+
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) => {
|
|
579
624
|
if (graph.draggingAnchor)
|
|
580
625
|
graph.updateAnchor(nodeId, clickPos);
|
|
581
626
|
else
|
|
582
627
|
graph.endConnect(nodeId, clickPos);
|
|
583
|
-
}, isConnectEdge:
|
|
628
|
+
}, isConnectEdge: actionPrivileged.connectingNode, onSelectNode: graph.selectNode, isSelectNode: actionPrivileged.selectNode, onSelectEdge: graph.selectEdge, edges: graph.edges }, item.id));
|
|
584
629
|
})] })), tooltip.visible && (_jsx("div", { className: `seat-editor tooltip-container ${tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.className}`, style: Object.assign({ top: tooltip.y, left: tooltip.x, transform: `scale(${1 / scale})`, transformOrigin: "top left", minWidth: widthTooltip + "px" }, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.style), children: tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.children }))] }) }))] })));
|
|
585
630
|
};
|
|
586
631
|
export default LayerView;
|