@html-graph/html-graph 8.15.1 → 8.17.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/html-graph.d.ts +33 -1
- package/dist/html-graph.js +489 -477
- package/dist/html-graph.min.js +977 -954
- package/dist/html-graph.min.umd.cjs +1 -1
- package/dist/html-graph.umd.cjs +489 -477
- package/package.json +1 -1
package/dist/html-graph.umd.cjs
CHANGED
|
@@ -623,6 +623,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
623
623
|
removeNonexistentPort: (portId) => `Failed to remove port with ID ${JSON.stringify(portId)} because it does not exist`,
|
|
624
624
|
accessNonexistentEdge: (edgeId) => `Failed to access edge with ID ${JSON.stringify(edgeId)} because it does not exist`,
|
|
625
625
|
addEdgeWithExistingId: (edgeId) => `Failed to add edge with ID ${JSON.stringify(edgeId)} because an edge with this ID already exists`,
|
|
626
|
+
addEdgeWithElementInUse: (edgeId, useEdgeId) => `Failed to add edge with ID ${JSON.stringify(edgeId)} because its SVG element is already attached to edge with ID ${JSON.stringify(useEdgeId)}`,
|
|
626
627
|
addEdgeFromNonexistentPort: (edgeId, portId) => `Failed to add edge with ID ${JSON.stringify(edgeId)} from port with ID ${JSON.stringify(portId)} because the port does not exist`,
|
|
627
628
|
addEdgeToNonexistentPort: (edgeId, portId) => `Failed to add edge with ID ${JSON.stringify(edgeId)} to port with ID ${JSON.stringify(portId)} because the port does not exist`,
|
|
628
629
|
updateNonexistentEdge: (edgeId) => `Failed to update edge with ID ${JSON.stringify(edgeId)} because it does not exist`,
|
|
@@ -641,6 +642,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
641
642
|
__publicField(this, "portOutgoingEdges", /* @__PURE__ */ new Map());
|
|
642
643
|
__publicField(this, "portCycleEdges", /* @__PURE__ */ new Map());
|
|
643
644
|
__publicField(this, "elementPorts", new OneToManyCollection());
|
|
645
|
+
__publicField(this, "edgesElementsMap", /* @__PURE__ */ new Map());
|
|
644
646
|
__publicField(this, "afterNodeAddedEmitter");
|
|
645
647
|
__publicField(this, "onAfterNodeAdded");
|
|
646
648
|
__publicField(this, "afterNodeUpdatedEmitter");
|
|
@@ -821,6 +823,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
821
823
|
}
|
|
822
824
|
return edge;
|
|
823
825
|
}
|
|
826
|
+
findEdgeIdByElement(element) {
|
|
827
|
+
return this.edgesElementsMap.get(element);
|
|
828
|
+
}
|
|
824
829
|
addEdge(request) {
|
|
825
830
|
if (this.hasEdge(request.id)) {
|
|
826
831
|
throw new CanvasError(canvasErrorText.addEdgeWithExistingId(request.id));
|
|
@@ -835,6 +840,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
835
840
|
canvasErrorText.addEdgeToNonexistentPort(request.id, request.to)
|
|
836
841
|
);
|
|
837
842
|
}
|
|
843
|
+
const useEdgeId = this.findEdgeIdByElement(request.shape.svg);
|
|
844
|
+
if (useEdgeId !== void 0) {
|
|
845
|
+
throw new CanvasError(
|
|
846
|
+
canvasErrorText.addEdgeWithElementInUse(request.id, useEdgeId)
|
|
847
|
+
);
|
|
848
|
+
}
|
|
838
849
|
this.addEdgeInternal(request);
|
|
839
850
|
this.afterEdgeAddedEmitter.emit(request.id);
|
|
840
851
|
}
|
|
@@ -892,6 +903,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
892
903
|
this.portCycleEdges.clear();
|
|
893
904
|
this.elementPorts.clear();
|
|
894
905
|
this.nodesElementsMap.clear();
|
|
906
|
+
this.edgesElementsMap.clear();
|
|
895
907
|
this.edges.clear();
|
|
896
908
|
this.ports.clear();
|
|
897
909
|
this.nodes.clear();
|
|
@@ -1000,6 +1012,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1000
1012
|
priority: request.priority
|
|
1001
1013
|
}
|
|
1002
1014
|
});
|
|
1015
|
+
this.edgesElementsMap.set(request.shape.svg, request.id);
|
|
1003
1016
|
if (request.from !== request.to) {
|
|
1004
1017
|
this.portOutgoingEdges.get(request.from).add(request.id);
|
|
1005
1018
|
this.portIncomingEdges.get(request.to).add(request.id);
|
|
@@ -1008,7 +1021,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1008
1021
|
}
|
|
1009
1022
|
}
|
|
1010
1023
|
removeEdgeInternal(edgeId) {
|
|
1011
|
-
const { from, to } = this.getEdge(edgeId);
|
|
1024
|
+
const { from, to, payload } = this.getEdge(edgeId);
|
|
1012
1025
|
this.portCycleEdges.get(from).delete(edgeId);
|
|
1013
1026
|
this.portCycleEdges.get(to).delete(edgeId);
|
|
1014
1027
|
this.portIncomingEdges.get(from).delete(edgeId);
|
|
@@ -1016,6 +1029,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1016
1029
|
this.portOutgoingEdges.get(from).delete(edgeId);
|
|
1017
1030
|
this.portOutgoingEdges.get(to).delete(edgeId);
|
|
1018
1031
|
this.edges.delete(edgeId);
|
|
1032
|
+
this.edgesElementsMap.delete(payload.shape.svg);
|
|
1019
1033
|
}
|
|
1020
1034
|
}
|
|
1021
1035
|
const calculateReverseMatrix = (matrix) => {
|
|
@@ -2677,6 +2691,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2677
2691
|
__publicField(this, "line");
|
|
2678
2692
|
__publicField(this, "sourceArrow");
|
|
2679
2693
|
__publicField(this, "targetArrow");
|
|
2694
|
+
// TODO: make private
|
|
2695
|
+
/**
|
|
2696
|
+
* @deprecated
|
|
2697
|
+
* do use shape.svg instead
|
|
2698
|
+
*/
|
|
2680
2699
|
__publicField(this, "handle", createEdgeGroup());
|
|
2681
2700
|
__publicField(this, "onAfterRender");
|
|
2682
2701
|
__publicField(this, "interactiveLine");
|
|
@@ -2833,6 +2852,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2833
2852
|
shape: payload.shape
|
|
2834
2853
|
};
|
|
2835
2854
|
}
|
|
2855
|
+
findEdgeIdByElement(element) {
|
|
2856
|
+
return this.graphStore.findEdgeIdByElement(element);
|
|
2857
|
+
}
|
|
2836
2858
|
getPortIncomingEdgeIds(portId) {
|
|
2837
2859
|
return this.graphStore.getPortIncomingEdgeIds(portId);
|
|
2838
2860
|
}
|
|
@@ -3287,11 +3309,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3287
3309
|
}
|
|
3288
3310
|
const target = event.currentTarget;
|
|
3289
3311
|
const portId = this.canvas.graph.findPortIdsByElement(target)[0];
|
|
3290
|
-
const
|
|
3312
|
+
const dragAllowed = this.params.portDragAllowedVerifier(portId, {
|
|
3291
3313
|
x: mouseEvent.clientX,
|
|
3292
3314
|
y: mouseEvent.clientY
|
|
3293
3315
|
});
|
|
3294
|
-
if (!
|
|
3316
|
+
if (!dragAllowed) {
|
|
3295
3317
|
return;
|
|
3296
3318
|
}
|
|
3297
3319
|
event.stopPropagation();
|
|
@@ -3308,8 +3330,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3308
3330
|
event.clientY
|
|
3309
3331
|
);
|
|
3310
3332
|
if (!isInside) {
|
|
3311
|
-
this.
|
|
3312
|
-
this.
|
|
3333
|
+
this.removeWindowMouseListeners();
|
|
3334
|
+
this.params.onPointerOutside();
|
|
3313
3335
|
return;
|
|
3314
3336
|
}
|
|
3315
3337
|
this.params.onPointerMove({ x: event.clientX, y: event.clientY });
|
|
@@ -3318,8 +3340,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3318
3340
|
if (!this.params.mouseUpEventVerifier(event)) {
|
|
3319
3341
|
return;
|
|
3320
3342
|
}
|
|
3343
|
+
this.removeWindowMouseListeners();
|
|
3321
3344
|
this.params.onPointerUp({ x: event.clientX, y: event.clientY });
|
|
3322
|
-
this.stopMouseDrag();
|
|
3323
3345
|
});
|
|
3324
3346
|
__publicField(this, "onPortTouchStart", (event) => {
|
|
3325
3347
|
const touchEvent = event;
|
|
@@ -3329,11 +3351,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3329
3351
|
const touch = touchEvent.touches[0];
|
|
3330
3352
|
const target = event.currentTarget;
|
|
3331
3353
|
const portId = this.canvas.graph.findPortIdsByElement(target)[0];
|
|
3332
|
-
const
|
|
3354
|
+
const dragAllowed = this.params.portDragAllowedVerifier(portId, {
|
|
3333
3355
|
x: touch.clientX,
|
|
3334
3356
|
y: touch.clientY
|
|
3335
3357
|
});
|
|
3336
|
-
if (!
|
|
3358
|
+
if (!dragAllowed) {
|
|
3337
3359
|
return;
|
|
3338
3360
|
}
|
|
3339
3361
|
event.stopPropagation();
|
|
@@ -3354,16 +3376,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3354
3376
|
touch.clientY
|
|
3355
3377
|
);
|
|
3356
3378
|
if (!isInside) {
|
|
3357
|
-
this.
|
|
3358
|
-
this.
|
|
3379
|
+
this.removeWindowTouchListeners();
|
|
3380
|
+
this.params.onPointerOutside();
|
|
3359
3381
|
return;
|
|
3360
3382
|
}
|
|
3361
3383
|
this.params.onPointerMove({ x: touch.clientX, y: touch.clientY });
|
|
3362
3384
|
});
|
|
3363
3385
|
__publicField(this, "onWindowTouchFinish", (event) => {
|
|
3386
|
+
this.removeWindowTouchListeners();
|
|
3364
3387
|
const touch = event.changedTouches[0];
|
|
3365
3388
|
this.params.onPointerUp({ x: touch.clientX, y: touch.clientY });
|
|
3366
|
-
this.stopTouchDrag();
|
|
3367
3389
|
});
|
|
3368
3390
|
__publicField(this, "reset", () => {
|
|
3369
3391
|
this.canvas.graph.getAllPortIds().forEach((portId) => {
|
|
@@ -3372,10 +3394,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3372
3394
|
});
|
|
3373
3395
|
});
|
|
3374
3396
|
__publicField(this, "revert", () => {
|
|
3375
|
-
this.params.onStopDrag();
|
|
3376
|
-
this.reset();
|
|
3377
3397
|
this.removeWindowMouseListeners();
|
|
3378
3398
|
this.removeWindowTouchListeners();
|
|
3399
|
+
this.reset();
|
|
3379
3400
|
});
|
|
3380
3401
|
this.canvas = canvas;
|
|
3381
3402
|
this.window = window2;
|
|
@@ -3401,14 +3422,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3401
3422
|
element.removeEventListener("mousedown", this.onPortMouseDown);
|
|
3402
3423
|
element.removeEventListener("touchstart", this.onPortTouchStart);
|
|
3403
3424
|
}
|
|
3404
|
-
stopMouseDrag() {
|
|
3405
|
-
this.params.onStopDrag();
|
|
3406
|
-
this.removeWindowMouseListeners();
|
|
3407
|
-
}
|
|
3408
|
-
stopTouchDrag() {
|
|
3409
|
-
this.params.onStopDrag();
|
|
3410
|
-
this.removeWindowTouchListeners();
|
|
3411
|
-
}
|
|
3412
3425
|
removeWindowMouseListeners() {
|
|
3413
3426
|
this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
3414
3427
|
this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
@@ -3419,45 +3432,161 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3419
3432
|
this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
3420
3433
|
}
|
|
3421
3434
|
}
|
|
3422
|
-
class
|
|
3423
|
-
constructor(
|
|
3424
|
-
this
|
|
3425
|
-
|
|
3426
|
-
|
|
3435
|
+
class EventTagger {
|
|
3436
|
+
constructor() {
|
|
3437
|
+
__publicField(this, "field", "_htmlGraphTags");
|
|
3438
|
+
}
|
|
3439
|
+
has(event, tag) {
|
|
3440
|
+
const e = event;
|
|
3441
|
+
const tags = e[this.field];
|
|
3442
|
+
return tags !== void 0 && tags.has(tag);
|
|
3443
|
+
}
|
|
3444
|
+
tag(event, tag) {
|
|
3445
|
+
const e = event;
|
|
3446
|
+
const tags = e[this.field];
|
|
3447
|
+
if (tags === void 0) {
|
|
3448
|
+
e[this.field] = /* @__PURE__ */ new Set([tag]);
|
|
3449
|
+
} else {
|
|
3450
|
+
tags.add(tag);
|
|
3451
|
+
}
|
|
3427
3452
|
}
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3453
|
+
}
|
|
3454
|
+
const selectionHandled = Symbol();
|
|
3455
|
+
class UserSelectableElementsConfigurator {
|
|
3456
|
+
constructor(window2, pointInsideVerifier, params) {
|
|
3457
|
+
__publicField(this, "onSelected");
|
|
3458
|
+
__publicField(this, "mouseDownEventVerifier");
|
|
3459
|
+
__publicField(this, "mouseUpEventVerifier");
|
|
3460
|
+
__publicField(this, "movementThreshold");
|
|
3461
|
+
__publicField(this, "selectionCandidate", null);
|
|
3462
|
+
__publicField(this, "previousMouse", null);
|
|
3463
|
+
__publicField(this, "previousTouch", null);
|
|
3464
|
+
__publicField(this, "movedDistance", 0);
|
|
3465
|
+
__publicField(this, "onElementMouseDown", (event) => {
|
|
3466
|
+
const mouseEvent = event;
|
|
3467
|
+
if (!this.mouseDownEventVerifier(mouseEvent)) {
|
|
3468
|
+
return;
|
|
3469
|
+
}
|
|
3470
|
+
this.selectionCandidate = mouseEvent.currentTarget;
|
|
3471
|
+
this.previousMouse = { x: mouseEvent.clientX, y: mouseEvent.clientY };
|
|
3472
|
+
this.movedDistance = 0;
|
|
3473
|
+
this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
3474
|
+
passive: true
|
|
3475
|
+
});
|
|
3476
|
+
this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
3477
|
+
passive: true
|
|
3478
|
+
});
|
|
3432
3479
|
});
|
|
3433
|
-
this
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3480
|
+
__publicField(this, "onElementTouchStart", (event) => {
|
|
3481
|
+
const touchEvent = event;
|
|
3482
|
+
const touches = touchEvent.touches;
|
|
3483
|
+
if (touches.length !== 1) {
|
|
3484
|
+
return;
|
|
3485
|
+
}
|
|
3486
|
+
this.selectionCandidate = touchEvent.currentTarget;
|
|
3487
|
+
this.previousTouch = touches[0];
|
|
3488
|
+
this.movedDistance = 0;
|
|
3489
|
+
this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
3490
|
+
passive: true
|
|
3491
|
+
});
|
|
3492
|
+
this.window.addEventListener("touchend", this.onWindowTouchEnd, {
|
|
3493
|
+
passive: true
|
|
3494
|
+
});
|
|
3495
|
+
this.window.addEventListener("touchcancel", this.onWindowTouchCancel, {
|
|
3496
|
+
passive: true
|
|
3497
|
+
});
|
|
3498
|
+
});
|
|
3499
|
+
__publicField(this, "onWindowMouseMove", (event) => {
|
|
3500
|
+
const mouseEvent = event;
|
|
3501
|
+
const inside = this.pointInsideVerifier.verify(
|
|
3502
|
+
mouseEvent.clientX,
|
|
3503
|
+
mouseEvent.clientY
|
|
3504
|
+
);
|
|
3505
|
+
if (!inside) {
|
|
3506
|
+
this.removeWindowMouseListeners();
|
|
3507
|
+
return;
|
|
3437
3508
|
}
|
|
3509
|
+
const previousMouse = this.previousMouse;
|
|
3510
|
+
const x = mouseEvent.clientX - previousMouse.x;
|
|
3511
|
+
const y = mouseEvent.clientY - previousMouse.y;
|
|
3512
|
+
this.previousMouse = { x: mouseEvent.clientX, y: mouseEvent.clientY };
|
|
3513
|
+
this.processMoveThresholdVerification(x, y, () => {
|
|
3514
|
+
this.removeWindowMouseListeners();
|
|
3515
|
+
});
|
|
3438
3516
|
});
|
|
3439
|
-
this
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
this.params = params;
|
|
3447
|
-
}
|
|
3448
|
-
apply(dt) {
|
|
3449
|
-
const coords = this.layoutAlgorithm.calculateNextCoordinates({
|
|
3450
|
-
graph: this.canvas.graph,
|
|
3451
|
-
viewport: this.canvas.viewport,
|
|
3452
|
-
dt
|
|
3517
|
+
__publicField(this, "onWindowMouseUp", (event) => {
|
|
3518
|
+
const mouseEvent = event;
|
|
3519
|
+
if (!this.mouseUpEventVerifier(mouseEvent)) {
|
|
3520
|
+
return;
|
|
3521
|
+
}
|
|
3522
|
+
this.removeWindowMouseListeners();
|
|
3523
|
+
this.onSelected(this.selectionCandidate, event);
|
|
3453
3524
|
});
|
|
3454
|
-
this
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3525
|
+
__publicField(this, "onWindowTouchMove", (event) => {
|
|
3526
|
+
const touchEvent = event;
|
|
3527
|
+
const touches = touchEvent.touches;
|
|
3528
|
+
if (touches.length !== 1) {
|
|
3529
|
+
this.removeWindowTouchListeners();
|
|
3530
|
+
return;
|
|
3531
|
+
}
|
|
3532
|
+
const touch = touches[0];
|
|
3533
|
+
const inside = this.pointInsideVerifier.verify(
|
|
3534
|
+
touch.clientX,
|
|
3535
|
+
touch.clientY
|
|
3536
|
+
);
|
|
3537
|
+
if (!inside) {
|
|
3538
|
+
this.removeWindowTouchListeners();
|
|
3539
|
+
return;
|
|
3458
3540
|
}
|
|
3541
|
+
const previousTouch = this.previousTouch;
|
|
3542
|
+
const x = touch.clientX - previousTouch.clientX;
|
|
3543
|
+
const y = touch.clientY - previousTouch.clientY;
|
|
3544
|
+
this.previousTouch = touch;
|
|
3545
|
+
this.processMoveThresholdVerification(x, y, () => {
|
|
3546
|
+
this.removeWindowTouchListeners();
|
|
3547
|
+
});
|
|
3459
3548
|
});
|
|
3460
|
-
this
|
|
3549
|
+
__publicField(this, "onWindowTouchEnd", (event) => {
|
|
3550
|
+
this.removeWindowTouchListeners();
|
|
3551
|
+
this.onSelected(this.selectionCandidate, event);
|
|
3552
|
+
});
|
|
3553
|
+
__publicField(this, "onWindowTouchCancel", () => {
|
|
3554
|
+
this.removeWindowTouchListeners();
|
|
3555
|
+
});
|
|
3556
|
+
this.window = window2;
|
|
3557
|
+
this.pointInsideVerifier = pointInsideVerifier;
|
|
3558
|
+
this.mouseDownEventVerifier = params.mouseDownEventVerifier;
|
|
3559
|
+
this.mouseUpEventVerifier = params.mouseUpEventVerifier;
|
|
3560
|
+
this.onSelected = params.onSelected;
|
|
3561
|
+
this.movementThreshold = params.movementThreshold;
|
|
3562
|
+
}
|
|
3563
|
+
enable(element) {
|
|
3564
|
+
element.addEventListener("mousedown", this.onElementMouseDown);
|
|
3565
|
+
element.addEventListener("touchstart", this.onElementTouchStart);
|
|
3566
|
+
}
|
|
3567
|
+
disable(element) {
|
|
3568
|
+
element.removeEventListener("mousedown", this.onElementMouseDown);
|
|
3569
|
+
element.removeEventListener("touchstart", this.onElementTouchStart);
|
|
3570
|
+
if (element === this.selectionCandidate) {
|
|
3571
|
+
this.removeWindowMouseListeners();
|
|
3572
|
+
this.removeWindowTouchListeners();
|
|
3573
|
+
}
|
|
3574
|
+
}
|
|
3575
|
+
removeWindowMouseListeners() {
|
|
3576
|
+
this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
3577
|
+
this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
3578
|
+
}
|
|
3579
|
+
removeWindowTouchListeners() {
|
|
3580
|
+
this.window.removeEventListener("touchmove", this.onWindowTouchMove);
|
|
3581
|
+
this.window.removeEventListener("touchend", this.onWindowTouchEnd);
|
|
3582
|
+
this.window.removeEventListener("touchcancel", this.onWindowTouchCancel);
|
|
3583
|
+
}
|
|
3584
|
+
processMoveThresholdVerification(x, y, thresholdReachedCallback) {
|
|
3585
|
+
const distance = Math.sqrt(x * x + y * y);
|
|
3586
|
+
this.movedDistance += distance;
|
|
3587
|
+
if (this.movedDistance > this.movementThreshold) {
|
|
3588
|
+
thresholdReachedCallback();
|
|
3589
|
+
}
|
|
3461
3590
|
}
|
|
3462
3591
|
}
|
|
3463
3592
|
class UserDraggableNodesConfigurator {
|
|
@@ -4197,34 +4326,39 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4197
4326
|
this.viewportStore,
|
|
4198
4327
|
this.window
|
|
4199
4328
|
);
|
|
4329
|
+
const draggablePortsParams = {
|
|
4330
|
+
mouseDownEventVerifier: this.params.mouseDownEventVerifier,
|
|
4331
|
+
mouseUpEventVerifier: this.params.mouseUpEventVerifier,
|
|
4332
|
+
portDragAllowedVerifier: (portId, cursor) => {
|
|
4333
|
+
const connectionType = this.params.connectionTypeResolver(portId);
|
|
4334
|
+
if (connectionType === null) {
|
|
4335
|
+
return false;
|
|
4336
|
+
}
|
|
4337
|
+
this.grabPort(portId, cursor, connectionType);
|
|
4338
|
+
return true;
|
|
4339
|
+
},
|
|
4340
|
+
onPointerMove: (cursor) => {
|
|
4341
|
+
this.moveDraggingPort(cursor);
|
|
4342
|
+
},
|
|
4343
|
+
onPointerUp: (cursor) => {
|
|
4344
|
+
this.tryCreateConnection(cursor);
|
|
4345
|
+
this.resetDragState();
|
|
4346
|
+
},
|
|
4347
|
+
onPointerOutside: () => {
|
|
4348
|
+
const staticPortId = this.staticPortId;
|
|
4349
|
+
const isTargetDragging = this.isTargetDragging;
|
|
4350
|
+
this.resetDragState();
|
|
4351
|
+
this.params.onEdgeCreationInterrupted({
|
|
4352
|
+
staticPortId,
|
|
4353
|
+
isDirect: isTargetDragging
|
|
4354
|
+
});
|
|
4355
|
+
}
|
|
4356
|
+
};
|
|
4200
4357
|
DraggablePortsConfigurator.configure(
|
|
4201
4358
|
this.canvas,
|
|
4202
4359
|
this.window,
|
|
4203
4360
|
this.pointInsideVerifier,
|
|
4204
|
-
|
|
4205
|
-
mouseDownEventVerifier: this.params.mouseDownEventVerifier,
|
|
4206
|
-
mouseUpEventVerifier: this.params.mouseUpEventVerifier,
|
|
4207
|
-
onStopDrag: () => {
|
|
4208
|
-
this.resetDragState();
|
|
4209
|
-
},
|
|
4210
|
-
onPortPointerDown: (portId, cursor) => {
|
|
4211
|
-
const connectionType = this.params.connectionTypeResolver(portId);
|
|
4212
|
-
if (connectionType === null) {
|
|
4213
|
-
return false;
|
|
4214
|
-
}
|
|
4215
|
-
this.grabPort(portId, cursor, connectionType);
|
|
4216
|
-
return true;
|
|
4217
|
-
},
|
|
4218
|
-
onPointerMove: (cursor) => {
|
|
4219
|
-
this.moveDraggingPort(cursor);
|
|
4220
|
-
},
|
|
4221
|
-
onPointerMoveOutside: () => {
|
|
4222
|
-
this.handleEdgeCreationInterrupted();
|
|
4223
|
-
},
|
|
4224
|
-
onPointerUp: (cursor) => {
|
|
4225
|
-
this.tryCreateConnection(cursor);
|
|
4226
|
-
}
|
|
4227
|
-
}
|
|
4361
|
+
draggablePortsParams
|
|
4228
4362
|
);
|
|
4229
4363
|
}
|
|
4230
4364
|
static configure(canvas, overlayLayer, viewportStore, win, pointInsideVerifier, params) {
|
|
@@ -4280,15 +4414,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4280
4414
|
tryCreateConnection(cursor) {
|
|
4281
4415
|
const draggingPortId = findPortAtPoint(this.canvas.graph, cursor);
|
|
4282
4416
|
if (draggingPortId === null) {
|
|
4283
|
-
this.
|
|
4417
|
+
this.params.onEdgeCreationInterrupted({
|
|
4418
|
+
staticPortId: this.staticPortId,
|
|
4419
|
+
isDirect: this.isTargetDragging
|
|
4420
|
+
});
|
|
4284
4421
|
return;
|
|
4285
4422
|
}
|
|
4286
4423
|
const staticPortId = this.staticPortId;
|
|
4287
4424
|
const sourceId = this.isTargetDragging ? staticPortId : draggingPortId;
|
|
4288
4425
|
const targetId = this.isTargetDragging ? draggingPortId : staticPortId;
|
|
4289
4426
|
const request = { from: sourceId, to: targetId };
|
|
4427
|
+
const connectionAllowed = this.params.connectionAllowedVerifier(request);
|
|
4290
4428
|
const processedRequest = this.params.connectionPreprocessor(request);
|
|
4291
|
-
if (processedRequest !== null) {
|
|
4429
|
+
if (connectionAllowed && processedRequest !== null) {
|
|
4292
4430
|
this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated);
|
|
4293
4431
|
this.canvas.addEdge(processedRequest);
|
|
4294
4432
|
this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated);
|
|
@@ -4307,13 +4445,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4307
4445
|
y: nodeContentCoords.y
|
|
4308
4446
|
});
|
|
4309
4447
|
}
|
|
4310
|
-
handleEdgeCreationInterrupted() {
|
|
4311
|
-
const staticPortId = this.staticPortId;
|
|
4312
|
-
this.params.onEdgeCreationInterrupted({
|
|
4313
|
-
staticPortId,
|
|
4314
|
-
isDirect: this.isTargetDragging
|
|
4315
|
-
});
|
|
4316
|
-
}
|
|
4317
4448
|
}
|
|
4318
4449
|
class UserDraggableEdgesConfigurator {
|
|
4319
4450
|
constructor(canvas, overlayLayer, viewportStore, window2, pointInsideVerifier, params) {
|
|
@@ -4335,38 +4466,36 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4335
4466
|
this.viewportStore,
|
|
4336
4467
|
this.window
|
|
4337
4468
|
);
|
|
4469
|
+
const draggablePortsParams = {
|
|
4470
|
+
mouseDownEventVerifier: this.params.mouseDownEventVerifier,
|
|
4471
|
+
mouseUpEventVerifier: this.params.mouseUpEventVerifier,
|
|
4472
|
+
portDragAllowedVerifier: (portId, cursor) => {
|
|
4473
|
+
return this.tryStartEdgeDragging(portId, cursor);
|
|
4474
|
+
},
|
|
4475
|
+
onPointerMove: (cursor) => {
|
|
4476
|
+
this.moveDraggingPort(cursor);
|
|
4477
|
+
},
|
|
4478
|
+
onPointerUp: (cursor) => {
|
|
4479
|
+
this.tryCreateConnection(cursor);
|
|
4480
|
+
this.resetDragState();
|
|
4481
|
+
},
|
|
4482
|
+
onPointerOutside: () => {
|
|
4483
|
+
const edge = this.draggingEdgePayload;
|
|
4484
|
+
this.resetDragState();
|
|
4485
|
+
this.params.onEdgeReattachInterrupted({
|
|
4486
|
+
id: edge.id,
|
|
4487
|
+
from: edge.from,
|
|
4488
|
+
to: edge.to,
|
|
4489
|
+
shape: edge.shape,
|
|
4490
|
+
priority: edge.priority
|
|
4491
|
+
});
|
|
4492
|
+
}
|
|
4493
|
+
};
|
|
4338
4494
|
DraggablePortsConfigurator.configure(
|
|
4339
4495
|
this.canvas,
|
|
4340
4496
|
this.window,
|
|
4341
4497
|
this.pointInsideVerifier,
|
|
4342
|
-
|
|
4343
|
-
mouseDownEventVerifier: this.params.mouseDownEventVerifier,
|
|
4344
|
-
mouseUpEventVerifier: this.params.mouseUpEventVerifier,
|
|
4345
|
-
onStopDrag: () => {
|
|
4346
|
-
this.resetDragState();
|
|
4347
|
-
},
|
|
4348
|
-
onPortPointerDown: (portId, cursor) => {
|
|
4349
|
-
return this.tryStartEdgeDragging(portId, cursor);
|
|
4350
|
-
},
|
|
4351
|
-
onPointerMove: (cursor) => {
|
|
4352
|
-
this.moveDraggingPort(cursor);
|
|
4353
|
-
},
|
|
4354
|
-
onPointerMoveOutside: () => {
|
|
4355
|
-
const edge = this.draggingEdgePayload;
|
|
4356
|
-
queueMicrotask(() => {
|
|
4357
|
-
this.params.onEdgeReattachInterrupted({
|
|
4358
|
-
id: edge.id,
|
|
4359
|
-
from: edge.from,
|
|
4360
|
-
to: edge.to,
|
|
4361
|
-
shape: edge.shape,
|
|
4362
|
-
priority: edge.priority
|
|
4363
|
-
});
|
|
4364
|
-
});
|
|
4365
|
-
},
|
|
4366
|
-
onPointerUp: (cursor) => {
|
|
4367
|
-
this.tryCreateConnection(cursor);
|
|
4368
|
-
}
|
|
4369
|
-
}
|
|
4498
|
+
draggablePortsParams
|
|
4370
4499
|
);
|
|
4371
4500
|
}
|
|
4372
4501
|
static configure(canvas, overlayLayer, viewportStore, win, pointInsideVerifier, params) {
|
|
@@ -4381,7 +4510,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4381
4510
|
}
|
|
4382
4511
|
tryStartEdgeDragging(portId, cursor) {
|
|
4383
4512
|
const edgeId = this.params.draggingEdgeResolver(portId);
|
|
4384
|
-
if (edgeId === null
|
|
4513
|
+
if (edgeId === null) {
|
|
4385
4514
|
return false;
|
|
4386
4515
|
}
|
|
4387
4516
|
const edge = this.canvas.graph.getEdge(edgeId);
|
|
@@ -4470,8 +4599,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4470
4599
|
shape: edge.shape,
|
|
4471
4600
|
priority: edge.priority
|
|
4472
4601
|
};
|
|
4602
|
+
const connectionAllowed = this.params.connectionAllowedVerifier({
|
|
4603
|
+
from,
|
|
4604
|
+
to
|
|
4605
|
+
});
|
|
4473
4606
|
const processedRequest = this.params.connectionPreprocessor(request);
|
|
4474
|
-
if (processedRequest !== null) {
|
|
4607
|
+
if (connectionAllowed && processedRequest !== null) {
|
|
4475
4608
|
this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeReattached);
|
|
4476
4609
|
this.canvas.addEdge(processedRequest);
|
|
4477
4610
|
this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeReattached);
|
|
@@ -4547,6 +4680,26 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4547
4680
|
this.defererFn(this.apply);
|
|
4548
4681
|
}
|
|
4549
4682
|
}
|
|
4683
|
+
class LayoutApplier {
|
|
4684
|
+
constructor(canvas, layoutAlgorithm, params) {
|
|
4685
|
+
this.canvas = canvas;
|
|
4686
|
+
this.layoutAlgorithm = layoutAlgorithm;
|
|
4687
|
+
this.params = params;
|
|
4688
|
+
}
|
|
4689
|
+
apply() {
|
|
4690
|
+
const coords = this.layoutAlgorithm.calculateCoordinates({
|
|
4691
|
+
graph: this.canvas.graph,
|
|
4692
|
+
viewport: this.canvas.viewport
|
|
4693
|
+
});
|
|
4694
|
+
this.params.onBeforeApplied();
|
|
4695
|
+
coords.forEach((point, nodeId) => {
|
|
4696
|
+
if (!this.params.staticNodeResolver(nodeId)) {
|
|
4697
|
+
this.canvas.updateNode(nodeId, point);
|
|
4698
|
+
}
|
|
4699
|
+
});
|
|
4700
|
+
this.params.onAfterApplied();
|
|
4701
|
+
}
|
|
4702
|
+
}
|
|
4550
4703
|
class LayoutConfigurator {
|
|
4551
4704
|
static configure(canvas, params) {
|
|
4552
4705
|
const strategy = params.applyOn;
|
|
@@ -4592,6 +4745,27 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4592
4745
|
this.win.requestAnimationFrame(this.step);
|
|
4593
4746
|
}
|
|
4594
4747
|
}
|
|
4748
|
+
class AnimatedLayoutApplier {
|
|
4749
|
+
constructor(canvas, layoutAlgorithm, params) {
|
|
4750
|
+
this.canvas = canvas;
|
|
4751
|
+
this.layoutAlgorithm = layoutAlgorithm;
|
|
4752
|
+
this.params = params;
|
|
4753
|
+
}
|
|
4754
|
+
apply(dt) {
|
|
4755
|
+
const coords = this.layoutAlgorithm.calculateNextCoordinates({
|
|
4756
|
+
graph: this.canvas.graph,
|
|
4757
|
+
viewport: this.canvas.viewport,
|
|
4758
|
+
dt
|
|
4759
|
+
});
|
|
4760
|
+
this.params.onBeforeApplied();
|
|
4761
|
+
coords.forEach((point, nodeId) => {
|
|
4762
|
+
if (!this.params.staticNodeResolver(nodeId)) {
|
|
4763
|
+
this.canvas.updateNode(nodeId, point);
|
|
4764
|
+
}
|
|
4765
|
+
});
|
|
4766
|
+
this.params.onAfterApplied();
|
|
4767
|
+
}
|
|
4768
|
+
}
|
|
4595
4769
|
class AnimatedLayoutConfigurator {
|
|
4596
4770
|
constructor(canvas, params, win) {
|
|
4597
4771
|
__publicField(this, "applier");
|
|
@@ -4611,311 +4785,151 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4611
4785
|
}
|
|
4612
4786
|
}
|
|
4613
4787
|
class UserSelectableNodesConfigurator {
|
|
4614
|
-
constructor(canvas, window2, pointInsideVerifier, params) {
|
|
4788
|
+
constructor(canvas, window2, pointInsideVerifier, eventTagger, params) {
|
|
4789
|
+
__publicField(this, "configurator");
|
|
4615
4790
|
__publicField(this, "onNodeSelected");
|
|
4616
|
-
__publicField(this, "
|
|
4617
|
-
__publicField(this, "mouseUpEventVerifier");
|
|
4618
|
-
__publicField(this, "movementThreshold");
|
|
4619
|
-
__publicField(this, "selectionCandidateNodeId", null);
|
|
4620
|
-
__publicField(this, "movedDistance", 0);
|
|
4621
|
-
__publicField(this, "previousMouse", null);
|
|
4622
|
-
__publicField(this, "previousTouch", null);
|
|
4791
|
+
__publicField(this, "selectionHandledTag", selectionHandled);
|
|
4623
4792
|
__publicField(this, "onAfterNodeAdded", (nodeId) => {
|
|
4624
4793
|
const { element } = this.canvas.graph.getNode(nodeId);
|
|
4625
|
-
|
|
4626
|
-
passive: true
|
|
4627
|
-
});
|
|
4628
|
-
element.addEventListener("touchstart", this.onNodeTouchStart, {
|
|
4629
|
-
passive: true
|
|
4630
|
-
});
|
|
4794
|
+
this.configurator.enable(element);
|
|
4631
4795
|
});
|
|
4632
4796
|
__publicField(this, "onBeforeNodeRemoved", (nodeId) => {
|
|
4633
4797
|
const { element } = this.canvas.graph.getNode(nodeId);
|
|
4634
|
-
|
|
4635
|
-
element.removeEventListener("touchstart", this.onNodeTouchStart);
|
|
4798
|
+
this.configurator.disable(element);
|
|
4636
4799
|
});
|
|
4637
4800
|
__publicField(this, "reset", () => {
|
|
4638
4801
|
this.canvas.graph.getAllNodeIds().forEach((nodeId) => {
|
|
4639
4802
|
const { element } = this.canvas.graph.getNode(nodeId);
|
|
4640
|
-
|
|
4641
|
-
element.removeEventListener("touchstart", this.onNodeTouchStart);
|
|
4803
|
+
this.configurator.disable(element);
|
|
4642
4804
|
});
|
|
4643
4805
|
});
|
|
4644
|
-
__publicField(this, "revert", () => {
|
|
4645
|
-
this.reset();
|
|
4646
|
-
this.removeWindowMouseListeners();
|
|
4647
|
-
this.removeWindowTouchListeners();
|
|
4648
|
-
});
|
|
4649
|
-
__publicField(this, "onNodeMouseDown", (event) => {
|
|
4650
|
-
const mouseEvent = event;
|
|
4651
|
-
if (!this.mouseDownEventVerifier(mouseEvent)) {
|
|
4652
|
-
return;
|
|
4653
|
-
}
|
|
4654
|
-
const nodeId = this.canvas.graph.findNodeIdByElement(
|
|
4655
|
-
event.currentTarget
|
|
4656
|
-
);
|
|
4657
|
-
this.selectionCandidateNodeId = nodeId;
|
|
4658
|
-
this.previousMouse = { x: mouseEvent.clientX, y: mouseEvent.clientY };
|
|
4659
|
-
this.movedDistance = 0;
|
|
4660
|
-
this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
4661
|
-
passive: true
|
|
4662
|
-
});
|
|
4663
|
-
this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
4664
|
-
passive: true
|
|
4665
|
-
});
|
|
4666
|
-
});
|
|
4667
|
-
__publicField(this, "onNodeTouchStart", (event) => {
|
|
4668
|
-
const touchEvent = event;
|
|
4669
|
-
if (touchEvent.touches.length !== 1) {
|
|
4670
|
-
return;
|
|
4671
|
-
}
|
|
4672
|
-
const nodeId = this.canvas.graph.findNodeIdByElement(
|
|
4673
|
-
touchEvent.currentTarget
|
|
4674
|
-
);
|
|
4675
|
-
this.selectionCandidateNodeId = nodeId;
|
|
4676
|
-
this.previousTouch = touchEvent.touches[0];
|
|
4677
|
-
this.movedDistance = 0;
|
|
4678
|
-
this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
4679
|
-
passive: true
|
|
4680
|
-
});
|
|
4681
|
-
this.window.addEventListener("touchend", this.onWindowTouchEnd, {
|
|
4682
|
-
passive: true
|
|
4683
|
-
});
|
|
4684
|
-
this.window.addEventListener("touchcancel", this.onWindowTouchCancel, {
|
|
4685
|
-
passive: true
|
|
4686
|
-
});
|
|
4687
|
-
});
|
|
4688
|
-
__publicField(this, "onWindowMouseMove", (event) => {
|
|
4689
|
-
const mouseEvent = event;
|
|
4690
|
-
const previousMouse = this.previousMouse;
|
|
4691
|
-
const x = mouseEvent.clientX - previousMouse.x;
|
|
4692
|
-
const y = mouseEvent.clientY - previousMouse.y;
|
|
4693
|
-
if (!this.pointInsideVerifier.verify(mouseEvent.clientX, mouseEvent.clientY)) {
|
|
4694
|
-
this.removeWindowMouseListeners();
|
|
4695
|
-
return;
|
|
4696
|
-
}
|
|
4697
|
-
this.processMoveThresholdVerification(x, y, () => {
|
|
4698
|
-
this.removeWindowMouseListeners();
|
|
4699
|
-
});
|
|
4700
|
-
this.previousMouse = { x: mouseEvent.clientX, y: mouseEvent.clientY };
|
|
4701
|
-
});
|
|
4702
|
-
__publicField(this, "onWindowTouchMove", (event) => {
|
|
4703
|
-
const touchEvent = event;
|
|
4704
|
-
if (touchEvent.touches.length !== 1) {
|
|
4705
|
-
this.removeWindowTouchListeners();
|
|
4706
|
-
return;
|
|
4707
|
-
}
|
|
4708
|
-
const touch = touchEvent.touches[0];
|
|
4709
|
-
if (!this.pointInsideVerifier.verify(touch.clientX, touch.clientY)) {
|
|
4710
|
-
this.removeWindowTouchListeners();
|
|
4711
|
-
return;
|
|
4712
|
-
}
|
|
4713
|
-
const previousTouch = this.previousTouch;
|
|
4714
|
-
const x = touch.clientX - previousTouch.clientX;
|
|
4715
|
-
const y = touch.clientY - previousTouch.clientY;
|
|
4716
|
-
this.processMoveThresholdVerification(x, y, () => {
|
|
4717
|
-
this.removeWindowTouchListeners();
|
|
4718
|
-
});
|
|
4719
|
-
this.previousTouch = touch;
|
|
4720
|
-
});
|
|
4721
|
-
__publicField(this, "onWindowMouseUp", (event) => {
|
|
4722
|
-
const mouseEvent = event;
|
|
4723
|
-
if (!this.mouseUpEventVerifier(mouseEvent)) {
|
|
4724
|
-
return;
|
|
4725
|
-
}
|
|
4726
|
-
this.removeWindowMouseListeners();
|
|
4727
|
-
this.trySelectNode(event);
|
|
4728
|
-
});
|
|
4729
|
-
__publicField(this, "onWindowTouchEnd", (event) => {
|
|
4730
|
-
this.removeWindowTouchListeners();
|
|
4731
|
-
this.trySelectNode(event);
|
|
4732
|
-
});
|
|
4733
|
-
__publicField(this, "onWindowTouchCancel", () => {
|
|
4734
|
-
this.removeWindowTouchListeners();
|
|
4735
|
-
});
|
|
4736
4806
|
this.canvas = canvas;
|
|
4737
4807
|
this.window = window2;
|
|
4738
4808
|
this.pointInsideVerifier = pointInsideVerifier;
|
|
4739
|
-
this.
|
|
4740
|
-
this.mouseUpEventVerifier = params.mouseUpEventVerifier;
|
|
4809
|
+
this.eventTagger = eventTagger;
|
|
4741
4810
|
this.onNodeSelected = params.onNodeSelected;
|
|
4742
|
-
this.
|
|
4811
|
+
this.configurator = new UserSelectableElementsConfigurator(
|
|
4812
|
+
this.window,
|
|
4813
|
+
this.pointInsideVerifier,
|
|
4814
|
+
{
|
|
4815
|
+
onSelected: (element, event) => {
|
|
4816
|
+
const nodeId = this.canvas.graph.findNodeIdByElement(element);
|
|
4817
|
+
this.eventTagger.tag(event, this.selectionHandledTag);
|
|
4818
|
+
this.onNodeSelected(nodeId);
|
|
4819
|
+
},
|
|
4820
|
+
movementThreshold: params.movementThreshold,
|
|
4821
|
+
mouseDownEventVerifier: params.mouseDownEventVerifier,
|
|
4822
|
+
mouseUpEventVerifier: params.mouseUpEventVerifier
|
|
4823
|
+
}
|
|
4824
|
+
);
|
|
4743
4825
|
this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded);
|
|
4744
4826
|
this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved);
|
|
4745
4827
|
this.canvas.graph.onBeforeClear.subscribe(this.reset);
|
|
4746
|
-
this.canvas.onBeforeDestroy.subscribe(this.
|
|
4828
|
+
this.canvas.onBeforeDestroy.subscribe(this.reset);
|
|
4747
4829
|
}
|
|
4748
|
-
static configure(canvas, window2, pointInsideVerifier, params) {
|
|
4830
|
+
static configure(canvas, window2, pointInsideVerifier, eventTagger, params) {
|
|
4749
4831
|
new UserSelectableNodesConfigurator(
|
|
4750
4832
|
canvas,
|
|
4751
4833
|
window2,
|
|
4752
4834
|
pointInsideVerifier,
|
|
4835
|
+
eventTagger,
|
|
4753
4836
|
params
|
|
4754
4837
|
);
|
|
4755
4838
|
}
|
|
4756
|
-
removeWindowMouseListeners() {
|
|
4757
|
-
this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
4758
|
-
this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
4759
|
-
}
|
|
4760
|
-
removeWindowTouchListeners() {
|
|
4761
|
-
this.window.removeEventListener("touchmove", this.onWindowTouchMove);
|
|
4762
|
-
this.window.removeEventListener("touchend", this.onWindowTouchEnd);
|
|
4763
|
-
this.window.removeEventListener("touchcancel", this.onWindowTouchCancel);
|
|
4764
|
-
}
|
|
4765
|
-
trySelectNode(event) {
|
|
4766
|
-
const nodeId = this.selectionCandidateNodeId;
|
|
4767
|
-
if (this.canvas.graph.hasNode(nodeId)) {
|
|
4768
|
-
this.onNodeSelected(nodeId);
|
|
4769
|
-
event.ignoreCanvasSelection = true;
|
|
4770
|
-
}
|
|
4771
|
-
}
|
|
4772
|
-
processMoveThresholdVerification(x, y, thresholdReachedCallback) {
|
|
4773
|
-
const distance = Math.sqrt(x * x + y * y);
|
|
4774
|
-
this.movedDistance += distance;
|
|
4775
|
-
if (this.movedDistance > this.movementThreshold) {
|
|
4776
|
-
thresholdReachedCallback();
|
|
4777
|
-
}
|
|
4778
|
-
}
|
|
4779
4839
|
}
|
|
4780
|
-
class
|
|
4781
|
-
constructor(canvas,
|
|
4782
|
-
__publicField(this, "
|
|
4783
|
-
__publicField(this, "
|
|
4784
|
-
__publicField(this, "
|
|
4785
|
-
__publicField(this, "
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
__publicField(this, "previousTouch", null);
|
|
4789
|
-
__publicField(this, "onMouseDown", (event) => {
|
|
4790
|
-
const mouseEvent = event;
|
|
4791
|
-
if (!this.mouseDownEventVerifier(mouseEvent)) {
|
|
4792
|
-
return;
|
|
4793
|
-
}
|
|
4794
|
-
this.previousMouseDown = { x: mouseEvent.clientX, y: mouseEvent.clientY };
|
|
4795
|
-
this.movedDistance = 0;
|
|
4796
|
-
this.window.addEventListener("mousemove", this.onWindowMouseMove, {
|
|
4797
|
-
passive: true
|
|
4798
|
-
});
|
|
4799
|
-
this.window.addEventListener("mouseup", this.onWindowMouseUp, {
|
|
4800
|
-
passive: true
|
|
4801
|
-
});
|
|
4802
|
-
});
|
|
4803
|
-
__publicField(this, "onTouchStart", (event) => {
|
|
4804
|
-
const touchEvent = event;
|
|
4805
|
-
if (touchEvent.touches.length !== 1) {
|
|
4806
|
-
return;
|
|
4807
|
-
}
|
|
4808
|
-
const touch = touchEvent.touches[0];
|
|
4809
|
-
this.previousTouch = touch;
|
|
4810
|
-
this.movedDistance = 0;
|
|
4811
|
-
this.window.addEventListener("touchmove", this.onWindowTouchMove, {
|
|
4812
|
-
passive: true
|
|
4813
|
-
});
|
|
4814
|
-
this.window.addEventListener("touchend", this.onWindowTouchEnd, {
|
|
4815
|
-
passive: true
|
|
4816
|
-
});
|
|
4817
|
-
this.window.addEventListener("touchcancel", this.onWindowTouchCancel, {
|
|
4818
|
-
passive: true
|
|
4819
|
-
});
|
|
4840
|
+
class UserSelectableEdgesConfigurator {
|
|
4841
|
+
constructor(canvas, window2, pointInsideVerifier, eventTagger, params) {
|
|
4842
|
+
__publicField(this, "configurator");
|
|
4843
|
+
__publicField(this, "selectionHandledTag", selectionHandled);
|
|
4844
|
+
__publicField(this, "onEdgeSelected");
|
|
4845
|
+
__publicField(this, "onAfterEdgeAdded", (edgeId) => {
|
|
4846
|
+
const { shape } = this.canvas.graph.getEdge(edgeId);
|
|
4847
|
+
this.configurator.enable(shape.svg);
|
|
4820
4848
|
});
|
|
4821
|
-
__publicField(this, "
|
|
4822
|
-
const
|
|
4823
|
-
|
|
4824
|
-
this.removeWindowMouseListeners();
|
|
4825
|
-
return;
|
|
4826
|
-
}
|
|
4827
|
-
const previous = this.previousMouseDown;
|
|
4828
|
-
const dx = mouseEvent.clientX - previous.x;
|
|
4829
|
-
const dy = mouseEvent.clientY - previous.y;
|
|
4830
|
-
this.processMoveThresholdVerification(dx, dy, () => {
|
|
4831
|
-
this.removeWindowMouseListeners();
|
|
4832
|
-
});
|
|
4833
|
-
this.previousMouseDown = { x: mouseEvent.clientX, y: mouseEvent.clientY };
|
|
4849
|
+
__publicField(this, "onBeforeEdgeRemoved", (edgeId) => {
|
|
4850
|
+
const { shape } = this.canvas.graph.getEdge(edgeId);
|
|
4851
|
+
this.configurator.disable(shape.svg);
|
|
4834
4852
|
});
|
|
4835
|
-
__publicField(this, "
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
this.
|
|
4839
|
-
return;
|
|
4840
|
-
}
|
|
4841
|
-
const touch = touchEvent.touches[0];
|
|
4842
|
-
if (!this.pointInsideVerifier.verify(touch.clientX, touch.clientY)) {
|
|
4843
|
-
this.removeWindowTouchListeners();
|
|
4844
|
-
return;
|
|
4845
|
-
}
|
|
4846
|
-
const previous = this.previousTouch;
|
|
4847
|
-
const dx = touch.clientX - previous.clientX;
|
|
4848
|
-
const dy = touch.clientY - previous.clientY;
|
|
4849
|
-
this.processMoveThresholdVerification(dx, dy, () => {
|
|
4850
|
-
this.removeWindowTouchListeners();
|
|
4853
|
+
__publicField(this, "reset", () => {
|
|
4854
|
+
this.canvas.graph.getAllEdgeIds().forEach((edgeId) => {
|
|
4855
|
+
const { shape } = this.canvas.graph.getEdge(edgeId);
|
|
4856
|
+
this.configurator.disable(shape.svg);
|
|
4851
4857
|
});
|
|
4852
|
-
this.previousTouch = touch;
|
|
4853
4858
|
});
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4859
|
+
this.canvas = canvas;
|
|
4860
|
+
this.window = window2;
|
|
4861
|
+
this.pointInsideVerifier = pointInsideVerifier;
|
|
4862
|
+
this.eventTagger = eventTagger;
|
|
4863
|
+
this.onEdgeSelected = params.onEdgeSelected;
|
|
4864
|
+
this.configurator = new UserSelectableElementsConfigurator(
|
|
4865
|
+
this.window,
|
|
4866
|
+
this.pointInsideVerifier,
|
|
4867
|
+
{
|
|
4868
|
+
onSelected: (element, event) => {
|
|
4869
|
+
const edgeId = this.canvas.graph.findEdgeIdByElement(element);
|
|
4870
|
+
this.eventTagger.tag(event, this.selectionHandledTag);
|
|
4871
|
+
this.onEdgeSelected(edgeId);
|
|
4872
|
+
},
|
|
4873
|
+
movementThreshold: params.movementThreshold,
|
|
4874
|
+
mouseDownEventVerifier: params.mouseDownEventVerifier,
|
|
4875
|
+
mouseUpEventVerifier: params.mouseUpEventVerifier
|
|
4862
4876
|
}
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4877
|
+
);
|
|
4878
|
+
this.canvas.graph.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded);
|
|
4879
|
+
this.canvas.graph.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved);
|
|
4880
|
+
this.canvas.graph.onBeforeClear.subscribe(this.reset);
|
|
4881
|
+
this.canvas.onBeforeDestroy.subscribe(this.reset);
|
|
4882
|
+
}
|
|
4883
|
+
static configure(canvas, window2, pointInsideVerifier, eventTagger, params) {
|
|
4884
|
+
new UserSelectableEdgesConfigurator(
|
|
4885
|
+
canvas,
|
|
4886
|
+
window2,
|
|
4887
|
+
pointInsideVerifier,
|
|
4888
|
+
eventTagger,
|
|
4889
|
+
params
|
|
4890
|
+
);
|
|
4891
|
+
}
|
|
4892
|
+
}
|
|
4893
|
+
class UserSelectableCanvasConfigurator {
|
|
4894
|
+
constructor(canvas, element, window2, pointInsideVerifier, eventTagger, params) {
|
|
4895
|
+
__publicField(this, "configurator");
|
|
4896
|
+
__publicField(this, "onCanvasSelected");
|
|
4897
|
+
__publicField(this, "selectionHandledTag", selectionHandled);
|
|
4878
4898
|
this.canvas = canvas;
|
|
4879
4899
|
this.element = element;
|
|
4880
4900
|
this.window = window2;
|
|
4881
4901
|
this.pointInsideVerifier = pointInsideVerifier;
|
|
4902
|
+
this.eventTagger = eventTagger;
|
|
4882
4903
|
this.onCanvasSelected = params.onCanvasSelected;
|
|
4883
|
-
this.
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4904
|
+
this.configurator = new UserSelectableElementsConfigurator(
|
|
4905
|
+
this.window,
|
|
4906
|
+
this.pointInsideVerifier,
|
|
4907
|
+
{
|
|
4908
|
+
onSelected: (_element, event) => {
|
|
4909
|
+
if (!this.eventTagger.has(event, this.selectionHandledTag)) {
|
|
4910
|
+
this.onCanvasSelected();
|
|
4911
|
+
}
|
|
4912
|
+
},
|
|
4913
|
+
movementThreshold: params.movementThreshold,
|
|
4914
|
+
mouseDownEventVerifier: params.mouseDownEventVerifier,
|
|
4915
|
+
mouseUpEventVerifier: params.mouseUpEventVerifier
|
|
4916
|
+
}
|
|
4917
|
+
);
|
|
4918
|
+
this.configurator.enable(this.element);
|
|
4919
|
+
this.canvas.onBeforeDestroy.subscribe(() => {
|
|
4920
|
+
this.configurator.disable(this.element);
|
|
4892
4921
|
});
|
|
4893
4922
|
}
|
|
4894
|
-
static configure(canvas, element, window2, pointInsideVerifier, params) {
|
|
4923
|
+
static configure(canvas, element, window2, pointInsideVerifier, eventTagger, params) {
|
|
4895
4924
|
new UserSelectableCanvasConfigurator(
|
|
4896
4925
|
canvas,
|
|
4897
4926
|
element,
|
|
4898
4927
|
window2,
|
|
4899
4928
|
pointInsideVerifier,
|
|
4929
|
+
eventTagger,
|
|
4900
4930
|
params
|
|
4901
4931
|
);
|
|
4902
4932
|
}
|
|
4903
|
-
removeWindowMouseListeners() {
|
|
4904
|
-
this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
4905
|
-
this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
4906
|
-
}
|
|
4907
|
-
removeWindowTouchListeners() {
|
|
4908
|
-
this.window.removeEventListener("touchmove", this.onWindowTouchMove);
|
|
4909
|
-
this.window.removeEventListener("touchend", this.onWindowTouchEnd);
|
|
4910
|
-
this.window.removeEventListener("touchcancel", this.onWindowTouchCancel);
|
|
4911
|
-
}
|
|
4912
|
-
processMoveThresholdVerification(x, y, thresholdReachedCallback) {
|
|
4913
|
-
const distance = Math.sqrt(x * x + y * y);
|
|
4914
|
-
this.movedDistance += distance;
|
|
4915
|
-
if (this.movedDistance > this.movementThreshold) {
|
|
4916
|
-
thresholdReachedCallback();
|
|
4917
|
-
}
|
|
4918
|
-
}
|
|
4919
4933
|
}
|
|
4920
4934
|
const createHost = () => {
|
|
4921
4935
|
const host = document.createElement("div");
|
|
@@ -4957,22 +4971,38 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4957
4971
|
this.element.removeChild(this.host);
|
|
4958
4972
|
}
|
|
4959
4973
|
}
|
|
4974
|
+
const forceDirectedDefaults = Object.freeze({
|
|
4975
|
+
seed: "HTMLGraph is awesome",
|
|
4976
|
+
maxTimeDeltaSec: 0.01,
|
|
4977
|
+
nodeCharge: 1e5,
|
|
4978
|
+
nodeMass: 1,
|
|
4979
|
+
edgeEquilibriumLength: 300,
|
|
4980
|
+
edgeStiffness: 1e3,
|
|
4981
|
+
dtSec: 0.01,
|
|
4982
|
+
maxIterations: 1e3,
|
|
4983
|
+
convergenceVelocity: 10,
|
|
4984
|
+
maxForce: 1e7,
|
|
4985
|
+
nodeForceCoefficient: 1,
|
|
4986
|
+
barnesHutAreaRadiusThreshold: 0.01,
|
|
4987
|
+
barnesHutTheta: 1
|
|
4988
|
+
});
|
|
4989
|
+
const selectionDefaults = Object.freeze({
|
|
4990
|
+
mouseDownEventVerifier: (event) => event.button === 0,
|
|
4991
|
+
mouseUpEventVerifier: (event) => event.button === 0,
|
|
4992
|
+
movementThreshold: 10
|
|
4993
|
+
});
|
|
4994
|
+
const noopFn = () => {
|
|
4995
|
+
};
|
|
4960
4996
|
const createDraggableNodesParams = (config) => {
|
|
4961
4997
|
var _a, _b, _c, _d, _e, _f;
|
|
4962
|
-
const onNodeDragStarted = ((_a = config.events) == null ? void 0 : _a.onNodeDragStarted) ?? (() => {
|
|
4963
|
-
});
|
|
4964
|
-
const onNodeDrag = ((_b = config.events) == null ? void 0 : _b.onNodeDrag) ?? (() => {
|
|
4965
|
-
});
|
|
4966
4998
|
const nodeDragVerifier = config.nodeDragVerifier ?? (() => true);
|
|
4967
|
-
const onNodeDragFinished = ((_c = config.events) == null ? void 0 : _c.onNodeDragFinished) ?? (() => {
|
|
4968
|
-
});
|
|
4969
4999
|
const moveOnTop = config.moveOnTop !== false;
|
|
4970
5000
|
const moveEdgesOnTop = config.moveEdgesOnTop !== false && moveOnTop;
|
|
4971
|
-
const cursor = (
|
|
5001
|
+
const cursor = (_a = config.mouse) == null ? void 0 : _a.dragCursor;
|
|
4972
5002
|
const dragCursor = cursor !== void 0 ? cursor : "grab";
|
|
4973
|
-
const defaultMouseDownEventVerifier = (
|
|
5003
|
+
const defaultMouseDownEventVerifier = (_b = config.mouse) == null ? void 0 : _b.mouseDownEventVerifier;
|
|
4974
5004
|
const mouseDownEventVerifier = defaultMouseDownEventVerifier !== void 0 ? defaultMouseDownEventVerifier : (event) => event.button === 0;
|
|
4975
|
-
const defaultMouseUpEventVerifier = (
|
|
5005
|
+
const defaultMouseUpEventVerifier = (_c = config.mouse) == null ? void 0 : _c.mouseUpEventVerifier;
|
|
4976
5006
|
const mouseUpEventVerifier = defaultMouseUpEventVerifier !== void 0 ? defaultMouseUpEventVerifier : (event) => event.button === 0;
|
|
4977
5007
|
return {
|
|
4978
5008
|
moveOnTop,
|
|
@@ -4981,10 +5011,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4981
5011
|
gridSize: config.gridSize ?? null,
|
|
4982
5012
|
mouseDownEventVerifier,
|
|
4983
5013
|
mouseUpEventVerifier,
|
|
4984
|
-
onNodeDragStarted,
|
|
4985
|
-
onNodeDrag,
|
|
5014
|
+
onNodeDragStarted: ((_d = config.events) == null ? void 0 : _d.onNodeDragStarted) ?? noopFn,
|
|
5015
|
+
onNodeDrag: ((_e = config.events) == null ? void 0 : _e.onNodeDrag) ?? noopFn,
|
|
4986
5016
|
nodeDragVerifier,
|
|
4987
|
-
onNodeDragFinished
|
|
5017
|
+
onNodeDragFinished: ((_f = config.events) == null ? void 0 : _f.onNodeDragFinished) ?? noopFn
|
|
4988
5018
|
};
|
|
4989
5019
|
};
|
|
4990
5020
|
const createShiftLimitTransformPreprocessor = (preprocessorParams) => {
|
|
@@ -5102,34 +5132,26 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5102
5132
|
};
|
|
5103
5133
|
}
|
|
5104
5134
|
const shiftCursor = ((_b = transformConfig == null ? void 0 : transformConfig.shift) == null ? void 0 : _b.cursor) !== void 0 ? transformConfig.shift.cursor : "grab";
|
|
5105
|
-
const
|
|
5106
|
-
});
|
|
5107
|
-
const onTransformFinished = ((_d = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _d.onTransformChange) ?? (() => {
|
|
5108
|
-
});
|
|
5109
|
-
const defaultMouseDownEventVerifier = (_e = transformConfig == null ? void 0 : transformConfig.shift) == null ? void 0 : _e.mouseDownEventVerifier;
|
|
5135
|
+
const defaultMouseDownEventVerifier = (_c = transformConfig == null ? void 0 : transformConfig.shift) == null ? void 0 : _c.mouseDownEventVerifier;
|
|
5110
5136
|
const mouseDownEventVerifier = defaultMouseDownEventVerifier !== void 0 ? defaultMouseDownEventVerifier : (event) => event.button === 0;
|
|
5111
|
-
const defaultMouseUpEventVerifier = (
|
|
5137
|
+
const defaultMouseUpEventVerifier = (_d = transformConfig == null ? void 0 : transformConfig.shift) == null ? void 0 : _d.mouseUpEventVerifier;
|
|
5112
5138
|
const mouseUpEventVerifier = defaultMouseUpEventVerifier !== void 0 ? defaultMouseUpEventVerifier : (event) => event.button === 0;
|
|
5113
|
-
const defaultMouseWheelEventVerifier = (
|
|
5139
|
+
const defaultMouseWheelEventVerifier = (_e = transformConfig == null ? void 0 : transformConfig.scale) == null ? void 0 : _e.mouseWheelEventVerifier;
|
|
5114
5140
|
const mouseWheelEventVerifier = defaultMouseWheelEventVerifier !== void 0 ? defaultMouseWheelEventVerifier : () => true;
|
|
5115
5141
|
return {
|
|
5116
5142
|
wheelSensitivity,
|
|
5117
|
-
onTransformStarted: ((
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
onBeforeTransformChange: onBeforeTransformStarted,
|
|
5122
|
-
onTransformChange: onTransformFinished,
|
|
5143
|
+
onTransformStarted: ((_f = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _f.onTransformStarted) ?? noopFn,
|
|
5144
|
+
onTransformFinished: ((_g = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _g.onTransformFinished) ?? noopFn,
|
|
5145
|
+
onBeforeTransformChange: ((_h = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _h.onBeforeTransformChange) ?? noopFn,
|
|
5146
|
+
onTransformChange: ((_i = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _i.onTransformChange) ?? noopFn,
|
|
5123
5147
|
transformPreprocessor,
|
|
5124
5148
|
shiftCursor,
|
|
5125
5149
|
mouseDownEventVerifier,
|
|
5126
5150
|
mouseUpEventVerifier,
|
|
5127
5151
|
mouseWheelEventVerifier,
|
|
5128
5152
|
scaleWheelFinishTimeout: ((_j = transformConfig == null ? void 0 : transformConfig.scale) == null ? void 0 : _j.wheelFinishTimeout) ?? 500,
|
|
5129
|
-
onResizeTransformStarted: ((_k = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _k.onResizeTransformStarted) ??
|
|
5130
|
-
|
|
5131
|
-
onResizeTransformFinished: ((_l = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _l.onResizeTransformFinished) ?? (() => {
|
|
5132
|
-
})
|
|
5153
|
+
onResizeTransformStarted: ((_k = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _k.onResizeTransformStarted) ?? noopFn,
|
|
5154
|
+
onResizeTransformFinished: ((_l = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _l.onResizeTransformFinished) ?? noopFn
|
|
5133
5155
|
};
|
|
5134
5156
|
};
|
|
5135
5157
|
const createContent = (radius, color) => {
|
|
@@ -5237,34 +5259,35 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5237
5259
|
});
|
|
5238
5260
|
}
|
|
5239
5261
|
};
|
|
5262
|
+
const defaults$3 = Object.freeze({
|
|
5263
|
+
connectionTypeResolver: () => "direct",
|
|
5264
|
+
connectionPreprocessor: (request) => request,
|
|
5265
|
+
connectionAllowedVerifier: () => true,
|
|
5266
|
+
mouseEventVerifier: (event) => event.button === 0
|
|
5267
|
+
});
|
|
5240
5268
|
const createConnectablePortsParams = (config, defaultEdgeShapeFactory, defaultDragPortDirection) => {
|
|
5241
5269
|
var _a, _b, _c;
|
|
5242
|
-
const defaultConnectionTypeResolver = () => "direct";
|
|
5243
|
-
const defaultConnectionPreprocessor = (request) => request;
|
|
5244
|
-
const defaultMouseEventVerifier = (event) => event.button === 0;
|
|
5245
|
-
const defaultOnAfterEdgeCreated = () => {
|
|
5246
|
-
};
|
|
5247
|
-
const defaultOnAfterEdgeConnectionPrevented = () => {
|
|
5248
|
-
};
|
|
5249
|
-
const defaultOnAfterEdgeConnectionInterrupted = () => {
|
|
5250
|
-
};
|
|
5251
5270
|
return {
|
|
5252
|
-
connectionTypeResolver: config.connectionTypeResolver ??
|
|
5253
|
-
connectionPreprocessor: config.connectionPreprocessor ??
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5271
|
+
connectionTypeResolver: config.connectionTypeResolver ?? defaults$3.connectionTypeResolver,
|
|
5272
|
+
connectionPreprocessor: config.connectionPreprocessor ?? defaults$3.connectionPreprocessor,
|
|
5273
|
+
connectionAllowedVerifier: config.connectionAllowedVerifier ?? defaults$3.connectionAllowedVerifier,
|
|
5274
|
+
mouseDownEventVerifier: config.mouseDownEventVerifier ?? defaults$3.mouseEventVerifier,
|
|
5275
|
+
mouseUpEventVerifier: config.mouseUpEventVerifier ?? defaults$3.mouseEventVerifier,
|
|
5276
|
+
onAfterEdgeCreated: ((_a = config.events) == null ? void 0 : _a.onAfterEdgeCreated) ?? noopFn,
|
|
5277
|
+
onEdgeCreationInterrupted: ((_b = config.events) == null ? void 0 : _b.onEdgeCreationInterrupted) ?? noopFn,
|
|
5278
|
+
onEdgeCreationPrevented: ((_c = config.events) == null ? void 0 : _c.onEdgeCreationPrevented) ?? noopFn,
|
|
5259
5279
|
dragPortDirection: config.dragPortDirection ?? defaultDragPortDirection,
|
|
5260
5280
|
edgeShapeFactory: config.edgeShape !== void 0 ? resolveEdgeShapeFactory(config.edgeShape) : defaultEdgeShapeFactory
|
|
5261
5281
|
};
|
|
5262
5282
|
};
|
|
5283
|
+
const defaults$2 = Object.freeze({
|
|
5284
|
+
connectionAllowedVerifier: () => true,
|
|
5285
|
+
connectionPreprocessor: (request) => request,
|
|
5286
|
+
mouseDownEventVerifier: (event) => event.button === 0 && event.ctrlKey,
|
|
5287
|
+
mouseUpEventVerifier: (event) => event.button === 0
|
|
5288
|
+
});
|
|
5263
5289
|
const createDraggableEdgeParams = (config, graph) => {
|
|
5264
5290
|
var _a, _b, _c;
|
|
5265
|
-
const defaultConnectionPreprocessor = (request) => request;
|
|
5266
|
-
const defaultMouseDownEventVerifier = (event) => event.button === 0 && event.ctrlKey;
|
|
5267
|
-
const defaultMouseUpEventVerifier = (event) => event.button === 0;
|
|
5268
5291
|
const defaultDraggingEdgeResolver = (portId) => {
|
|
5269
5292
|
const edgeIds = graph.getPortAdjacentEdgeIds(portId);
|
|
5270
5293
|
if (edgeIds.length > 0) {
|
|
@@ -5273,21 +5296,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5273
5296
|
return null;
|
|
5274
5297
|
}
|
|
5275
5298
|
};
|
|
5276
|
-
const defaultOnAfterEdgeReattached = () => {
|
|
5277
|
-
};
|
|
5278
|
-
const defaultOnAfterEdgeReattachPrevented = () => {
|
|
5279
|
-
};
|
|
5280
|
-
const defaultOnAfterEdgeReattachInterrupted = () => {
|
|
5281
|
-
};
|
|
5282
5299
|
return {
|
|
5283
|
-
connectionPreprocessor: config.connectionPreprocessor ??
|
|
5284
|
-
|
|
5285
|
-
|
|
5300
|
+
connectionPreprocessor: config.connectionPreprocessor ?? defaults$2.connectionPreprocessor,
|
|
5301
|
+
connectionAllowedVerifier: config.connectionAllowedVerifier ?? defaults$2.connectionAllowedVerifier,
|
|
5302
|
+
mouseDownEventVerifier: config.mouseDownEventVerifier ?? defaults$2.mouseDownEventVerifier,
|
|
5303
|
+
mouseUpEventVerifier: config.mouseUpEventVerifier ?? defaults$2.mouseUpEventVerifier,
|
|
5286
5304
|
draggingEdgeResolver: config.draggingEdgeResolver ?? defaultDraggingEdgeResolver,
|
|
5287
5305
|
draggingEdgeShapeFactory: config.draggingEdgeShape !== void 0 ? resolveEdgeShapeFactory(config.draggingEdgeShape) : null,
|
|
5288
|
-
onAfterEdgeReattached: ((_a = config.events) == null ? void 0 : _a.onAfterEdgeReattached) ??
|
|
5289
|
-
onEdgeReattachInterrupted: ((_b = config.events) == null ? void 0 : _b.onEdgeReattachInterrupted) ??
|
|
5290
|
-
onEdgeReattachPrevented: ((_c = config.events) == null ? void 0 : _c.onEdgeReattachPrevented) ??
|
|
5306
|
+
onAfterEdgeReattached: ((_a = config.events) == null ? void 0 : _a.onAfterEdgeReattached) ?? noopFn,
|
|
5307
|
+
onEdgeReattachInterrupted: ((_b = config.events) == null ? void 0 : _b.onEdgeReattachInterrupted) ?? noopFn,
|
|
5308
|
+
onEdgeReattachPrevented: ((_c = config.events) == null ? void 0 : _c.onEdgeReattachPrevented) ?? noopFn
|
|
5291
5309
|
};
|
|
5292
5310
|
};
|
|
5293
5311
|
const createVirtualScrollParams = (config) => {
|
|
@@ -5299,10 +5317,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5299
5317
|
const createVirtualScrollHtmlViewParams = (config) => {
|
|
5300
5318
|
var _a, _b;
|
|
5301
5319
|
return {
|
|
5302
|
-
onAfterNodeDetached: ((_a = config == null ? void 0 : config.events) == null ? void 0 : _a.onAfterNodeDetached) ??
|
|
5303
|
-
|
|
5304
|
-
onBeforeNodeAttached: ((_b = config == null ? void 0 : config.events) == null ? void 0 : _b.onBeforeNodeAttached) ?? (() => {
|
|
5305
|
-
})
|
|
5320
|
+
onAfterNodeDetached: ((_a = config == null ? void 0 : config.events) == null ? void 0 : _a.onAfterNodeDetached) ?? noopFn,
|
|
5321
|
+
onBeforeNodeAttached: ((_b = config == null ? void 0 : config.events) == null ? void 0 : _b.onBeforeNodeAttached) ?? noopFn
|
|
5306
5322
|
};
|
|
5307
5323
|
};
|
|
5308
5324
|
class CanvasBuilderError extends Error {
|
|
@@ -6313,26 +6329,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6313
6329
|
return (t >>> 0) / 4294967296;
|
|
6314
6330
|
};
|
|
6315
6331
|
};
|
|
6316
|
-
const forceDirectedDefaults = Object.freeze({
|
|
6317
|
-
seed: "HTMLGraph is awesome",
|
|
6318
|
-
maxTimeDeltaSec: 0.01,
|
|
6319
|
-
nodeCharge: 1e5,
|
|
6320
|
-
nodeMass: 1,
|
|
6321
|
-
edgeEquilibriumLength: 300,
|
|
6322
|
-
edgeStiffness: 1e3,
|
|
6323
|
-
dtSec: 0.01,
|
|
6324
|
-
maxIterations: 1e3,
|
|
6325
|
-
convergenceVelocity: 10,
|
|
6326
|
-
maxForce: 1e7,
|
|
6327
|
-
nodeForceCoefficient: 1,
|
|
6328
|
-
barnesHutAreaRadiusThreshold: 0.01,
|
|
6329
|
-
barnesHutTheta: 1
|
|
6330
|
-
});
|
|
6331
|
-
const selectionDefaults = Object.freeze({
|
|
6332
|
-
mouseDownEventVerifier: (event) => event.button === 0,
|
|
6333
|
-
mouseUpEventVerifier: (event) => event.button === 0,
|
|
6334
|
-
movementThreshold: 10
|
|
6335
|
-
});
|
|
6336
6332
|
const resolveAnimatedLayoutAlgorithm = (config) => {
|
|
6337
6333
|
var _a, _b;
|
|
6338
6334
|
switch (config == null ? void 0 : config.type) {
|
|
@@ -6359,11 +6355,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6359
6355
|
}
|
|
6360
6356
|
};
|
|
6361
6357
|
const defaults$1 = {
|
|
6362
|
-
staticNodeResolver: () => false
|
|
6363
|
-
onBeforeApplied: () => {
|
|
6364
|
-
},
|
|
6365
|
-
onAfterApplied: () => {
|
|
6366
|
-
}
|
|
6358
|
+
staticNodeResolver: () => false
|
|
6367
6359
|
};
|
|
6368
6360
|
const createAnimatedLayoutParams = (config) => {
|
|
6369
6361
|
var _a, _b;
|
|
@@ -6371,8 +6363,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6371
6363
|
return {
|
|
6372
6364
|
algorithm,
|
|
6373
6365
|
staticNodeResolver: (config == null ? void 0 : config.staticNodeResolver) ?? defaults$1.staticNodeResolver,
|
|
6374
|
-
onBeforeApplied: ((_a = config == null ? void 0 : config.events) == null ? void 0 : _a.onBeforeApplied) ??
|
|
6375
|
-
onAfterApplied: ((_b = config == null ? void 0 : config.events) == null ? void 0 : _b.onAfterApplied) ??
|
|
6366
|
+
onBeforeApplied: ((_a = config == null ? void 0 : config.events) == null ? void 0 : _a.onBeforeApplied) ?? noopFn,
|
|
6367
|
+
onAfterApplied: ((_b = config == null ? void 0 : config.events) == null ? void 0 : _b.onAfterApplied) ?? noopFn
|
|
6376
6368
|
};
|
|
6377
6369
|
};
|
|
6378
6370
|
const resolveLayoutApplyOn = (applyOn) => {
|
|
@@ -6395,10 +6387,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6395
6387
|
};
|
|
6396
6388
|
const defaults = Object.freeze({
|
|
6397
6389
|
staticNodeResolver: () => false,
|
|
6398
|
-
onBeforeApplied: () => {
|
|
6399
|
-
},
|
|
6400
|
-
onAfterApplied: () => {
|
|
6401
|
-
},
|
|
6402
6390
|
hierarchicalLayout: {
|
|
6403
6391
|
layerWidth: 300,
|
|
6404
6392
|
layerSpace: 300
|
|
@@ -6605,8 +6593,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6605
6593
|
algorithm: resolveLayoutAlgorithm(config.algorithm),
|
|
6606
6594
|
applyOn: resolveLayoutApplyOn(config.applyOn),
|
|
6607
6595
|
staticNodeResolver: config.staticNodeResolver ?? defaults.staticNodeResolver,
|
|
6608
|
-
onBeforeApplied: ((_a = config.events) == null ? void 0 : _a.onBeforeApplied) ??
|
|
6609
|
-
onAfterApplied: ((_b = config.events) == null ? void 0 : _b.onAfterApplied) ??
|
|
6596
|
+
onBeforeApplied: ((_a = config.events) == null ? void 0 : _a.onBeforeApplied) ?? noopFn,
|
|
6597
|
+
onAfterApplied: ((_b = config.events) == null ? void 0 : _b.onAfterApplied) ?? noopFn
|
|
6610
6598
|
};
|
|
6611
6599
|
};
|
|
6612
6600
|
const patchAnimatedLayoutDraggableNodesParams = (params, staticNodes) => {
|
|
@@ -6729,6 +6717,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6729
6717
|
movementThreshold: config.movementThreshold ?? selectionDefaults.movementThreshold
|
|
6730
6718
|
};
|
|
6731
6719
|
};
|
|
6720
|
+
const createUserSelectableEdgesParams = (config) => {
|
|
6721
|
+
return {
|
|
6722
|
+
onEdgeSelected: config.onEdgeSelected,
|
|
6723
|
+
mouseDownEventVerifier: config.mouseDownEventVerifier ?? selectionDefaults.mouseDownEventVerifier,
|
|
6724
|
+
mouseUpEventVerifier: config.mouseUpEventVerifier ?? selectionDefaults.mouseUpEventVerifier,
|
|
6725
|
+
movementThreshold: config.movementThreshold ?? selectionDefaults.movementThreshold
|
|
6726
|
+
};
|
|
6727
|
+
};
|
|
6732
6728
|
class CanvasBuilder {
|
|
6733
6729
|
constructor(element) {
|
|
6734
6730
|
__publicField(this, "used", false);
|
|
@@ -6742,6 +6738,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6742
6738
|
__publicField(this, "layoutConfig", {});
|
|
6743
6739
|
__publicField(this, "animatedLayoutConfig", {});
|
|
6744
6740
|
__publicField(this, "userSelectableNodesConfig");
|
|
6741
|
+
__publicField(this, "userSelectableEdgesConfig");
|
|
6745
6742
|
__publicField(this, "userSelectableCanvasConfig");
|
|
6746
6743
|
__publicField(this, "hasDraggableNodes", false);
|
|
6747
6744
|
__publicField(this, "hasTransformableViewport", false);
|
|
@@ -6755,6 +6752,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6755
6752
|
__publicField(this, "window", window);
|
|
6756
6753
|
__publicField(this, "animationStaticNodes", /* @__PURE__ */ new Set());
|
|
6757
6754
|
__publicField(this, "pointInsideVerifier");
|
|
6755
|
+
__publicField(this, "eventTagger", new EventTagger());
|
|
6758
6756
|
this.element = element;
|
|
6759
6757
|
this.pointInsideVerifier = new PointInsideVerifier(element, this.window);
|
|
6760
6758
|
}
|
|
@@ -6811,6 +6809,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6811
6809
|
this.userSelectableNodesConfig = config;
|
|
6812
6810
|
return this;
|
|
6813
6811
|
}
|
|
6812
|
+
enableUserSelectableEdges(config) {
|
|
6813
|
+
this.userSelectableEdgesConfig = config;
|
|
6814
|
+
return this;
|
|
6815
|
+
}
|
|
6814
6816
|
enableUserSelectableCanvas(config) {
|
|
6815
6817
|
this.userSelectableCanvasConfig = config;
|
|
6816
6818
|
return this;
|
|
@@ -6868,6 +6870,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6868
6870
|
if (this.hasNodeResizeReactiveEdges) {
|
|
6869
6871
|
NodeResizeReactiveEdgesConfigurator.configure(canvas);
|
|
6870
6872
|
}
|
|
6873
|
+
if (this.userSelectableEdgesConfig !== void 0) {
|
|
6874
|
+
const params = createUserSelectableEdgesParams(
|
|
6875
|
+
this.userSelectableEdgesConfig
|
|
6876
|
+
);
|
|
6877
|
+
UserSelectableEdgesConfigurator.configure(
|
|
6878
|
+
canvas,
|
|
6879
|
+
this.window,
|
|
6880
|
+
this.pointInsideVerifier,
|
|
6881
|
+
this.eventTagger,
|
|
6882
|
+
params
|
|
6883
|
+
);
|
|
6884
|
+
}
|
|
6871
6885
|
if (this.userSelectableNodesConfig !== void 0) {
|
|
6872
6886
|
const params = createUserSelectableNodesParams(
|
|
6873
6887
|
this.userSelectableNodesConfig
|
|
@@ -6876,6 +6890,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6876
6890
|
canvas,
|
|
6877
6891
|
this.window,
|
|
6878
6892
|
this.pointInsideVerifier,
|
|
6893
|
+
this.eventTagger,
|
|
6879
6894
|
params
|
|
6880
6895
|
);
|
|
6881
6896
|
}
|
|
@@ -6888,6 +6903,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6888
6903
|
layers.main,
|
|
6889
6904
|
this.window,
|
|
6890
6905
|
this.pointInsideVerifier,
|
|
6906
|
+
this.eventTagger,
|
|
6891
6907
|
params
|
|
6892
6908
|
);
|
|
6893
6909
|
}
|
|
@@ -6959,9 +6975,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6959
6975
|
LayoutConfigurator.configure(canvas, layoutParams);
|
|
6960
6976
|
}
|
|
6961
6977
|
if (this.hasAnimatedLayout) {
|
|
6962
|
-
let config = createAnimatedLayoutParams(
|
|
6963
|
-
this.animatedLayoutConfig
|
|
6964
|
-
);
|
|
6978
|
+
let config = createAnimatedLayoutParams(this.animatedLayoutConfig);
|
|
6965
6979
|
if (this.hasDraggableNodes) {
|
|
6966
6980
|
subscribeAnimatedLayoutStaticNodesUpdate(
|
|
6967
6981
|
canvas,
|
|
@@ -6974,11 +6988,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6974
6988
|
}
|
|
6975
6989
|
AnimatedLayoutConfigurator.configure(canvas, config, this.window);
|
|
6976
6990
|
}
|
|
6977
|
-
|
|
6991
|
+
canvas.onBeforeDestroy.subscribe(() => {
|
|
6978
6992
|
layers.destroy();
|
|
6979
|
-
|
|
6980
|
-
};
|
|
6981
|
-
canvas.onBeforeDestroy.subscribe(onBeforeDestroy);
|
|
6993
|
+
});
|
|
6982
6994
|
return canvas;
|
|
6983
6995
|
}
|
|
6984
6996
|
createHtmlView(host, graphStore, viewportStore) {
|