@html-graph/html-graph 8.24.0 → 9.1.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.
@@ -121,11 +121,11 @@ var CoreHtmlView = class {
121
121
  node.element.style.zIndex = `${node.payload.priority}`;
122
122
  }
123
123
  updateEdgeShape(edgeId) {
124
- const element = this.edgeIdToElementMap.get(edgeId);
125
- this.container.removeChild(element);
126
- const svg = this.graphStore.getEdge(edgeId).payload.shape.element;
127
- this.edgeIdToElementMap.set(edgeId, svg);
128
- this.container.appendChild(svg);
124
+ const previousElement = this.edgeIdToElementMap.get(edgeId);
125
+ this.container.removeChild(previousElement);
126
+ const { element } = this.graphStore.getEdge(edgeId).payload.shape;
127
+ this.edgeIdToElementMap.set(edgeId, element);
128
+ this.container.appendChild(element);
129
129
  }
130
130
  renderEdge(edgeId) {
131
131
  const edge = this.graphStore.getEdge(edgeId);
@@ -1097,10 +1097,10 @@ var createAddNodeOverlayRequest = (payload) => {
1097
1097
  };
1098
1098
  //#endregion
1099
1099
  //#region src/configurators/shared/find-port-at-point/find-port-for-element/find-port-for-element.ts
1100
- var findPortForElement = (graph, element) => {
1100
+ var findPortForElement = (graph, element, portIdResolver) => {
1101
1101
  let elementBuf = element;
1102
1102
  while (elementBuf !== null) {
1103
- const portId = graph.findPortIdsByElement(elementBuf)[0] ?? null;
1103
+ const portId = portIdResolver(graph.findPortIdsByElement(elementBuf));
1104
1104
  if (portId !== null) return {
1105
1105
  status: "portFound",
1106
1106
  portId
@@ -1124,10 +1124,10 @@ function* getElementsAtPoint(root, point) {
1124
1124
  }
1125
1125
  //#endregion
1126
1126
  //#region src/configurators/shared/find-port-at-point/find-port-at-point.ts
1127
- var findPortAtPoint = (graph, point) => {
1127
+ var findPortAtPoint = (graph, point, portIdResolver) => {
1128
1128
  const elements = getElementsAtPoint(document, point);
1129
1129
  for (const element of elements) {
1130
- const result = findPortForElement(graph, element);
1130
+ const result = findPortForElement(graph, element, portIdResolver);
1131
1131
  if (result.status === "portFound") return result.portId;
1132
1132
  if (result.status === "nodeEncountered") return null;
1133
1133
  }
@@ -1663,43 +1663,6 @@ var createOrthogonalLine = (from, to) => {
1663
1663
  return createVerticalSourceOrthogonalLine(from, to);
1664
1664
  };
1665
1665
  //#endregion
1666
- //#region src/edges/paths/horizontal-edge-path/horizontal-edge-path.ts
1667
- var HorizontalEdgePath = class {
1668
- path;
1669
- midpoint;
1670
- constructor(params) {
1671
- const { from, to, fromDir, toDir, arrowLength, arrowOffset, roundness, hasSourceArrow, hasTargetArrow } = params;
1672
- const beginArrow = hasSourceArrow ? createRotatedPoint({
1673
- x: from.x + arrowLength,
1674
- y: from.y
1675
- }, fromDir, from) : from;
1676
- const endArrow = hasTargetArrow ? createRotatedPoint({
1677
- x: to.x - arrowLength,
1678
- y: to.y
1679
- }, toDir, to) : to;
1680
- const gap = arrowLength + arrowOffset;
1681
- const beginLine = createRotatedPoint({
1682
- x: from.x + gap,
1683
- y: from.y
1684
- }, fromDir, from);
1685
- const endLine = createRotatedPoint({
1686
- x: to.x - gap,
1687
- y: to.y
1688
- }, toDir, to);
1689
- const line = createHorizontalLine({
1690
- arrowPoint: beginArrow,
1691
- linePoint: beginLine,
1692
- dir: fromDir
1693
- }, {
1694
- arrowPoint: endArrow,
1695
- linePoint: endLine,
1696
- dir: toDir
1697
- });
1698
- this.path = createRoundedPath(line.points, roundness);
1699
- this.midpoint = line.midpoint;
1700
- }
1701
- };
1702
- //#endregion
1703
1666
  //#region src/edges/paths/detour-straight-edge-path/detour-straight-edge-path.ts
1704
1667
  var DetourStraightEdgePath = class {
1705
1668
  path;
@@ -1787,43 +1750,6 @@ var StraightEdgePath = class {
1787
1750
  }
1788
1751
  };
1789
1752
  //#endregion
1790
- //#region src/edges/paths/vertical-edge-path/vertical-edge-path.ts
1791
- var VerticalEdgePath = class {
1792
- path;
1793
- midpoint;
1794
- constructor(params) {
1795
- const { from, to, hasSourceArrow, hasTargetArrow, arrowLength, arrowOffset, fromDir, toDir, roundness } = params;
1796
- const beginArrow = hasSourceArrow ? createRotatedPoint({
1797
- x: from.x + arrowLength,
1798
- y: from.y
1799
- }, fromDir, from) : from;
1800
- const endArrow = hasTargetArrow ? createRotatedPoint({
1801
- x: to.x - arrowLength,
1802
- y: to.y
1803
- }, toDir, to) : to;
1804
- const gap = arrowLength + arrowOffset;
1805
- const beginLine = createRotatedPoint({
1806
- x: from.x + gap,
1807
- y: from.y
1808
- }, fromDir, from);
1809
- const endLine = createRotatedPoint({
1810
- x: to.x - gap,
1811
- y: to.y
1812
- }, toDir, to);
1813
- const line = createVerticalLine({
1814
- arrowPoint: beginArrow,
1815
- linePoint: beginLine,
1816
- dir: fromDir
1817
- }, {
1818
- arrowPoint: endArrow,
1819
- linePoint: endLine,
1820
- dir: toDir
1821
- });
1822
- this.path = createRoundedPath(line.points, roundness);
1823
- this.midpoint = line.midpoint;
1824
- }
1825
- };
1826
- //#endregion
1827
1753
  //#region src/edges/paths/orthogonal-edge-path/orthogonal-edge-path.ts
1828
1754
  var OrthogonalEdgePath = class {
1829
1755
  path;
@@ -2132,7 +2058,6 @@ var createDirectionVector = (dir) => {
2132
2058
  var PathEdgeShape = class {
2133
2059
  params;
2134
2060
  element;
2135
- svg;
2136
2061
  group = document.createElementNS("http://www.w3.org/2000/svg", "g");
2137
2062
  line;
2138
2063
  sourceArrow = null;
@@ -2145,7 +2070,6 @@ var PathEdgeShape = class {
2145
2070
  [this.afterRenderEmitter, this.onAfterRender] = createPair();
2146
2071
  this.arrowRenderer = this.params.arrowRenderer;
2147
2072
  this.element = createEdgeSvg(params.color);
2148
- this.svg = this.element;
2149
2073
  this.element.appendChild(this.group);
2150
2074
  this.line = createEdgePath(params.width);
2151
2075
  this.group.appendChild(this.line);
@@ -2319,7 +2243,6 @@ var resolveArrowRenderer = (config) => {
2319
2243
  //#region src/edges/shapes/bezier-edge-shape/bezier-edge-shape.ts
2320
2244
  var BezierEdgeShape = class {
2321
2245
  element;
2322
- svg;
2323
2246
  group;
2324
2247
  line;
2325
2248
  sourceArrow;
@@ -2386,7 +2309,6 @@ var BezierEdgeShape = class {
2386
2309
  padding: 50
2387
2310
  });
2388
2311
  this.element = this.pathShape.element;
2389
- this.svg = this.element;
2390
2312
  this.group = this.pathShape.group;
2391
2313
  this.line = this.pathShape.line;
2392
2314
  this.sourceArrow = this.pathShape.sourceArrow;
@@ -2398,113 +2320,9 @@ var BezierEdgeShape = class {
2398
2320
  }
2399
2321
  };
2400
2322
  //#endregion
2401
- //#region src/edges/shapes/horizontal-edge-shape/horizontalize-directions/horizontalize-direction.ts
2402
- var horizontalizeDirection = (direction) => {
2403
- return Math.cos(direction) > 0 ? 0 : Math.PI;
2404
- };
2405
- //#endregion
2406
- //#region src/edges/shapes/horizontal-edge-shape/horizontal-edge-shape.ts
2407
- /**
2408
- * @deprecated
2409
- * use OrthogonalEdgeShape instead
2410
- */
2411
- var HorizontalEdgeShape = class {
2412
- element;
2413
- svg;
2414
- group;
2415
- line;
2416
- sourceArrow;
2417
- targetArrow;
2418
- onAfterRender;
2419
- arrowLength;
2420
- arrowOffset;
2421
- roundness;
2422
- cycleSquareSide;
2423
- detourDistance;
2424
- hasSourceArrow;
2425
- hasTargetArrow;
2426
- pathShape;
2427
- createCyclePath = (from, _to, fromDir) => new CycleSquareEdgePath({
2428
- origin: from,
2429
- dir: fromDir,
2430
- arrowLength: this.arrowLength,
2431
- side: this.cycleSquareSide,
2432
- arrowOffset: this.arrowOffset,
2433
- roundness: this.roundness,
2434
- hasArrow: this.hasSourceArrow || this.hasTargetArrow
2435
- });
2436
- createDetourPath = (from, to, fromDir, toDir) => new DetourHorizontalEdgePath({
2437
- from,
2438
- to,
2439
- fromDir,
2440
- toDir,
2441
- arrowLength: this.arrowLength,
2442
- arrowOffset: this.arrowOffset,
2443
- roundness: this.roundness,
2444
- detourDistance: this.detourDistance,
2445
- hasSourceArrow: this.hasSourceArrow,
2446
- hasTargetArrow: this.hasTargetArrow
2447
- });
2448
- createLinePath = (from, to, fromDir, toDir) => new HorizontalEdgePath({
2449
- from,
2450
- to,
2451
- fromDir,
2452
- toDir,
2453
- arrowLength: this.arrowLength,
2454
- arrowOffset: this.arrowOffset,
2455
- roundness: this.roundness,
2456
- hasSourceArrow: this.hasSourceArrow,
2457
- hasTargetArrow: this.hasTargetArrow
2458
- });
2459
- constructor(params) {
2460
- this.arrowLength = params?.arrowLength ?? edgeConstants.arrowLength;
2461
- this.arrowOffset = params?.arrowOffset ?? edgeConstants.arrowOffset;
2462
- this.cycleSquareSide = params?.cycleSquareSide ?? edgeConstants.cycleSquareSide;
2463
- const roundness = params?.roundness ?? edgeConstants.roundness;
2464
- this.roundness = Math.min(roundness, this.arrowOffset, this.cycleSquareSide / 2);
2465
- this.detourDistance = params?.detourDistance ?? edgeConstants.detourDistance;
2466
- this.hasSourceArrow = params?.hasSourceArrow ?? edgeConstants.hasSourceArrow;
2467
- this.hasTargetArrow = params?.hasTargetArrow ?? edgeConstants.hasTargetArrow;
2468
- this.pathShape = new PathEdgeShape({
2469
- color: params?.color ?? edgeConstants.color,
2470
- width: params?.width ?? edgeConstants.width,
2471
- arrowRenderer: resolveArrowRenderer(params?.arrowRenderer ?? {}),
2472
- arrowLength: this.arrowLength,
2473
- hasSourceArrow: this.hasSourceArrow,
2474
- hasTargetArrow: this.hasTargetArrow,
2475
- createCyclePath: this.createCyclePath,
2476
- createDetourPath: this.createDetourPath,
2477
- createLinePath: this.createLinePath,
2478
- padding: 50
2479
- });
2480
- this.element = this.pathShape.element;
2481
- this.svg = this.element;
2482
- this.group = this.pathShape.group;
2483
- this.line = this.pathShape.line;
2484
- this.sourceArrow = this.pathShape.sourceArrow;
2485
- this.targetArrow = this.pathShape.targetArrow;
2486
- this.onAfterRender = this.pathShape.onAfterRender;
2487
- }
2488
- render(params) {
2489
- const { from, to, category } = params;
2490
- this.pathShape.render({
2491
- category,
2492
- from: {
2493
- ...from,
2494
- direction: horizontalizeDirection(from.direction)
2495
- },
2496
- to: {
2497
- ...to,
2498
- direction: horizontalizeDirection(to.direction)
2499
- }
2500
- });
2501
- }
2502
- };
2503
- //#endregion
2504
2323
  //#region src/edges/shapes/straight-edge-shape/straight-edge-shape.ts
2505
2324
  var StraightEdgeShape = class {
2506
2325
  element;
2507
- svg;
2508
2326
  group;
2509
2327
  line;
2510
2328
  sourceArrow;
@@ -2575,7 +2393,6 @@ var StraightEdgeShape = class {
2575
2393
  padding: 50
2576
2394
  });
2577
2395
  this.element = this.pathShape.element;
2578
- this.svg = this.element;
2579
2396
  this.group = this.pathShape.group;
2580
2397
  this.line = this.pathShape.line;
2581
2398
  this.sourceArrow = this.pathShape.sourceArrow;
@@ -2587,110 +2404,6 @@ var StraightEdgeShape = class {
2587
2404
  }
2588
2405
  };
2589
2406
  //#endregion
2590
- //#region src/edges/shapes/vertical-edge-shape/verticalize-directions/verticalize-direction.ts
2591
- var pi2 = Math.PI / 2;
2592
- var verticalizeDirection = (direction) => {
2593
- return Math.sin(direction) > 0 ? pi2 : -pi2;
2594
- };
2595
- //#endregion
2596
- //#region src/edges/shapes/vertical-edge-shape/vertical-edge-shape.ts
2597
- /**
2598
- * @deprecated
2599
- * use OrthogonalEdgeShape instead
2600
- */
2601
- var VerticalEdgeShape = class {
2602
- element;
2603
- svg;
2604
- group;
2605
- line;
2606
- sourceArrow;
2607
- targetArrow;
2608
- onAfterRender;
2609
- arrowLength;
2610
- arrowOffset;
2611
- roundness;
2612
- cycleSquareSide;
2613
- detourDistance;
2614
- hasSourceArrow;
2615
- hasTargetArrow;
2616
- pathShape;
2617
- createCyclePath = (from, _to, fromDir) => new CycleSquareEdgePath({
2618
- origin: from,
2619
- dir: fromDir,
2620
- arrowLength: this.arrowLength,
2621
- side: this.cycleSquareSide,
2622
- arrowOffset: this.arrowOffset,
2623
- roundness: this.roundness,
2624
- hasArrow: this.hasSourceArrow || this.hasTargetArrow
2625
- });
2626
- createDetourPath = (from, to, fromDir, toDir) => new DetourVerticalEdgePath({
2627
- from,
2628
- to,
2629
- fromDir,
2630
- toDir,
2631
- arrowLength: this.arrowLength,
2632
- arrowOffset: this.arrowOffset,
2633
- roundness: this.roundness,
2634
- detourDistance: this.detourDistance,
2635
- hasSourceArrow: this.hasSourceArrow,
2636
- hasTargetArrow: this.hasTargetArrow
2637
- });
2638
- createLinePath = (from, to, fromDir, toDir) => new VerticalEdgePath({
2639
- from,
2640
- to,
2641
- fromDir,
2642
- toDir,
2643
- arrowLength: this.arrowLength,
2644
- arrowOffset: this.arrowOffset,
2645
- roundness: this.roundness,
2646
- hasSourceArrow: this.hasSourceArrow,
2647
- hasTargetArrow: this.hasTargetArrow
2648
- });
2649
- constructor(params) {
2650
- this.arrowLength = params?.arrowLength ?? edgeConstants.arrowLength;
2651
- this.arrowOffset = params?.arrowOffset ?? edgeConstants.arrowOffset;
2652
- this.cycleSquareSide = params?.cycleSquareSide ?? edgeConstants.cycleSquareSide;
2653
- const roundness = params?.roundness ?? edgeConstants.roundness;
2654
- this.roundness = Math.min(roundness, this.arrowOffset, this.cycleSquareSide / 2);
2655
- this.detourDistance = params?.detourDistance ?? edgeConstants.detourDistance;
2656
- this.hasSourceArrow = params?.hasSourceArrow ?? edgeConstants.hasSourceArrow;
2657
- this.hasTargetArrow = params?.hasTargetArrow ?? edgeConstants.hasTargetArrow;
2658
- this.pathShape = new PathEdgeShape({
2659
- color: params?.color ?? edgeConstants.color,
2660
- width: params?.width ?? edgeConstants.width,
2661
- arrowRenderer: resolveArrowRenderer(params?.arrowRenderer ?? {}),
2662
- arrowLength: this.arrowLength,
2663
- hasSourceArrow: this.hasSourceArrow,
2664
- hasTargetArrow: this.hasTargetArrow,
2665
- createCyclePath: this.createCyclePath,
2666
- createDetourPath: this.createDetourPath,
2667
- createLinePath: this.createLinePath,
2668
- padding: 50
2669
- });
2670
- this.element = this.pathShape.element;
2671
- this.svg = this.element;
2672
- this.group = this.pathShape.group;
2673
- this.line = this.pathShape.line;
2674
- this.sourceArrow = this.pathShape.sourceArrow;
2675
- this.targetArrow = this.pathShape.targetArrow;
2676
- this.onAfterRender = this.pathShape.onAfterRender;
2677
- }
2678
- render(params) {
2679
- const { from, to, category } = params;
2680
- this.pathShape.render({
2681
- category,
2682
- from: {
2683
- ...from,
2684
- direction: verticalizeDirection(from.direction)
2685
- },
2686
- to: {
2687
- ...to,
2688
- direction: verticalizeDirection(to.direction)
2689
- }
2690
- });
2691
- }
2692
- };
2693
- //#endregion
2694
2407
  //#region src/edges/shapes/orthogonal-edge-shape/orthogonalize-direction/orthogonalize-direction.ts
2695
2408
  var orthogonalizeDirection = (direction) => {
2696
2409
  const adjDir = direction + Math.PI / 4;
@@ -2707,7 +2420,6 @@ var orthogonalizeDirection = (direction) => {
2707
2420
  //#region src/edges/shapes/orthogonal-edge-shape/orthogonal-edge-shape.ts
2708
2421
  var OrthogonalEdgeShape = class {
2709
2422
  element;
2710
- svg;
2711
2423
  group;
2712
2424
  line;
2713
2425
  sourceArrow;
@@ -2775,7 +2487,6 @@ var OrthogonalEdgeShape = class {
2775
2487
  padding: 50
2776
2488
  });
2777
2489
  this.element = this.pathShape.element;
2778
- this.svg = this.element;
2779
2490
  this.group = this.pathShape.group;
2780
2491
  this.line = this.pathShape.line;
2781
2492
  this.sourceArrow = this.pathShape.sourceArrow;
@@ -2822,7 +2533,6 @@ var resolvePortOffsetFn = (offset) => {
2822
2533
  var defaultPortOffset = edgeConstants.portOffset;
2823
2534
  var DirectEdgeShape = class {
2824
2535
  element;
2825
- svg;
2826
2536
  group = document.createElementNS("http://www.w3.org/2000/svg", "g");
2827
2537
  line;
2828
2538
  sourceArrow = null;
@@ -2844,7 +2554,6 @@ var DirectEdgeShape = class {
2844
2554
  this.sourceOffsetFn = resolvePortOffsetFn(params?.sourceOffset ?? defaultPortOffset);
2845
2555
  this.targetOffsetFn = resolvePortOffsetFn(params?.targetOffset ?? defaultPortOffset);
2846
2556
  this.element = createEdgeSvg(this.color);
2847
- this.svg = this.element;
2848
2557
  this.element.appendChild(this.group);
2849
2558
  this.line = createEdgePath(this.width);
2850
2559
  this.group.appendChild(this.line);
@@ -3025,15 +2734,10 @@ var InteractiveEdgeError = class extends Error {
3025
2734
  var InteractiveEdgeShape = class InteractiveEdgeShape {
3026
2735
  baseEdge;
3027
2736
  element;
3028
- svg;
3029
2737
  group;
3030
2738
  line;
3031
2739
  sourceArrow;
3032
2740
  targetArrow;
3033
- /**
3034
- * @deprecated
3035
- * use shape.svg instead
3036
- */
3037
2741
  handle = createEdgeGroup();
3038
2742
  onAfterRender;
3039
2743
  interactiveLine;
@@ -3043,7 +2747,6 @@ var InteractiveEdgeShape = class InteractiveEdgeShape {
3043
2747
  this.baseEdge = baseEdge;
3044
2748
  if (baseEdge instanceof InteractiveEdgeShape) throw new InteractiveEdgeError("interactive edge can be configured only once");
3045
2749
  this.element = this.baseEdge.element;
3046
- this.svg = this.element;
3047
2750
  this.group = this.baseEdge.group;
3048
2751
  this.line = this.baseEdge.line;
3049
2752
  this.sourceArrow = this.baseEdge.sourceArrow;
@@ -3082,12 +2785,10 @@ var MidpointEdgeShape = class {
3082
2785
  targetArrow;
3083
2786
  onAfterRender;
3084
2787
  element;
3085
- svg;
3086
2788
  constructor(baseShape, midpointElement) {
3087
2789
  this.baseShape = baseShape;
3088
2790
  this.midpointElement = midpointElement;
3089
2791
  this.element = this.baseShape.element;
3090
- this.svg = this.element;
3091
2792
  this.group = this.baseShape.group;
3092
2793
  this.line = this.baseShape.line;
3093
2794
  this.sourceArrow = this.baseShape.sourceArrow;
@@ -3387,17 +3088,6 @@ var GraphController = class {
3387
3088
  }
3388
3089
  };
3389
3090
  //#endregion
3390
- //#region src/schedule-fn/macrotask-schedule-fn/macrotask-schedule-fn.ts
3391
- /**
3392
- * @deprecated
3393
- * use macrotaskScheduleFn instead
3394
- */
3395
- var macrotaskScheduleFn = (callback) => {
3396
- setTimeout(() => {
3397
- callback();
3398
- });
3399
- };
3400
- //#endregion
3401
3091
  //#region src/schedule-fn/microtask-schedule-fn/microtask-schedule-fn.ts
3402
3092
  var microtaskScheduleFn = (callback) => {
3403
3093
  queueMicrotask(() => {
@@ -3449,7 +3139,7 @@ var createFocusParams = (config, controllerParams) => {
3449
3139
  } : {
3450
3140
  minContentScale: config.minContentScale ?? controllerParams.focus.minContentScale,
3451
3141
  nodes: config.nodes ?? [],
3452
- contentPadding: config.contentPadding ?? config.contentOffset ?? controllerParams.focus.contentPadding,
3142
+ contentPadding: config.contentPadding ?? controllerParams.focus.contentPadding,
3453
3143
  animationDuration: config.animationDuration ?? controllerParams.focus.animationDuration
3454
3144
  };
3455
3145
  };
@@ -3643,7 +3333,9 @@ var DraggablePortsConfigurator = class DraggablePortsConfigurator {
3643
3333
  const mouseEvent = event;
3644
3334
  if (!this.params.mouseDownEventVerifier(mouseEvent)) return;
3645
3335
  const target = event.currentTarget;
3646
- const portId = this.canvas.graph.findPortIdsByElement(target)[0];
3336
+ const portIds = this.canvas.graph.findPortIdsByElement(target);
3337
+ const portId = this.params.grabbedPortIdResolver(portIds);
3338
+ if (portId === null) return;
3647
3339
  if (!this.params.onPointerDownVerifier(portId, {
3648
3340
  x: mouseEvent.clientX,
3649
3341
  y: mouseEvent.clientY
@@ -3944,6 +3636,12 @@ var ConstantDraggingPortDirectionResolver = class {
3944
3636
  }
3945
3637
  };
3946
3638
  //#endregion
3639
+ //#region src/configurators/shared/port-id-resolver/default-port-id-resolver/default-port-id-resolver.ts
3640
+ var defaultPortIdResolver = (portIds) => {
3641
+ if (portIds.length > 0) return portIds[0];
3642
+ return null;
3643
+ };
3644
+ //#endregion
3947
3645
  //#region src/configurators/user-draggable-nodes-configurator/user-draggable-nodes-configurator.ts
3948
3646
  var UserDraggableNodesConfigurator = class UserDraggableNodesConfigurator {
3949
3647
  canvas;
@@ -4001,12 +3699,7 @@ var UserDraggableNodesConfigurator = class UserDraggableNodesConfigurator {
4001
3699
  const element = event.currentTarget;
4002
3700
  const nodeId = this.canvas.graph.findNodeIdByElement(element);
4003
3701
  const node = this.graph.getNode(nodeId);
4004
- if (!this.params.nodeDragVerifier({
4005
- nodeId,
4006
- element: node.element,
4007
- x: node.x,
4008
- y: node.y
4009
- })) return;
3702
+ if (!this.params.nodeDragVerifier(nodeId)) return;
4010
3703
  this.eventTagger.tag(event, dragEventHandledTag);
4011
3704
  const cursorContent = this.calculateContentPoint({
4012
3705
  x: touch.clientX,
@@ -4291,8 +3984,10 @@ var UserTransformableViewportConfigurator = class UserTransformableViewportConfi
4291
3984
  const transform = this.params.transformPreprocessor({
4292
3985
  prevTransform,
4293
3986
  nextTransform,
4294
- canvasWidth: width,
4295
- canvasHeight: height
3987
+ viewport: {
3988
+ width,
3989
+ height
3990
+ }
4296
3991
  });
4297
3992
  this.performTransform(transform);
4298
3993
  }
@@ -4303,8 +3998,10 @@ var UserTransformableViewportConfigurator = class UserTransformableViewportConfi
4303
3998
  const transform = this.params.transformPreprocessor({
4304
3999
  prevTransform,
4305
4000
  nextTransform,
4306
- canvasWidth: width,
4307
- canvasHeight: height
4001
+ viewport: {
4002
+ width,
4003
+ height
4004
+ }
4308
4005
  });
4309
4006
  this.performTransform(transform);
4310
4007
  }
@@ -4346,8 +4043,10 @@ var UserTransformableViewportConfigurator = class UserTransformableViewportConfi
4346
4043
  const transform = this.params.transformPreprocessor({
4347
4044
  prevTransform,
4348
4045
  nextTransform: prevTransform,
4349
- canvasWidth: width,
4350
- canvasHeight: height
4046
+ viewport: {
4047
+ width,
4048
+ height
4049
+ }
4351
4050
  });
4352
4051
  this.params.onResizeTransformStarted();
4353
4052
  this.canvas.patchViewportMatrix(transform);
@@ -4608,7 +4307,8 @@ var UserConnectablePortsConfigurator = class UserConnectablePortsConfigurator {
4608
4307
  const params = this.edgeInProgress;
4609
4308
  this.resetDragState();
4610
4309
  this.params.onEdgeCreationInterrupted(params);
4611
- }
4310
+ },
4311
+ grabbedPortIdResolver: this.params.grabbedPortIdResolver
4612
4312
  };
4613
4313
  DraggablePortsConfigurator.configure(this.canvas, this.window, this.pointInsideVerifier, this.eventTagger, draggablePortsParams);
4614
4314
  }
@@ -4662,7 +4362,7 @@ var UserConnectablePortsConfigurator = class UserConnectablePortsConfigurator {
4662
4362
  this.overlayCanvas.clear();
4663
4363
  }
4664
4364
  tryCreateConnection(cursor) {
4665
- const targetPortId = findPortAtPoint(this.canvas.graph, cursor);
4365
+ const targetPortId = findPortAtPoint(this.canvas.graph, cursor, this.params.releasedPortIdResolver);
4666
4366
  if (targetPortId === null) {
4667
4367
  this.params.onEdgeCreationInterrupted(this.edgeInProgress);
4668
4368
  return;
@@ -4743,7 +4443,8 @@ var UserDraggableEdgesConfigurator = class UserDraggableEdgesConfigurator {
4743
4443
  shape: edge.shape,
4744
4444
  priority: edge.priority
4745
4445
  });
4746
- }
4446
+ },
4447
+ grabbedPortIdResolver: this.params.grabbedPortIdResolver
4747
4448
  };
4748
4449
  DraggablePortsConfigurator.configure(this.canvas, this.window, this.pointInsideVerifier, this.eventTagger, draggablePortsParams);
4749
4450
  }
@@ -4833,7 +4534,7 @@ var UserDraggableEdgesConfigurator = class UserDraggableEdgesConfigurator {
4833
4534
  }).updatePort(OverlayId.DraggingNodeId, { direction });
4834
4535
  }
4835
4536
  tryCreateConnection(cursor) {
4836
- const draggingPortId = findPortAtPoint(this.canvas.graph, cursor);
4537
+ const draggingPortId = findPortAtPoint(this.canvas.graph, cursor, this.params.releasedPortIdResolver);
4837
4538
  this.overlayCanvas.removeEdge(OverlayId.EdgeId);
4838
4539
  if (draggingPortId === null) {
4839
4540
  const edge = this.draggingEdgePayload;
@@ -5020,19 +4721,17 @@ var AnimatedLayoutApplier = class {
5020
4721
  //#endregion
5021
4722
  //#region src/configurators/animated-layout-configurator/animated-layout-configurator.ts
5022
4723
  var AnimatedLayoutConfigurator = class AnimatedLayoutConfigurator {
5023
- win;
5024
4724
  applier;
5025
4725
  step = (dt) => {
5026
4726
  this.applier.apply(dt);
5027
4727
  };
5028
4728
  constructor(canvas, params, win) {
5029
- this.win = win;
5030
4729
  this.applier = new AnimatedLayoutApplier(canvas, params.algorithm, {
5031
4730
  staticNodeResolver: params.staticNodeResolver,
5032
4731
  onBeforeApplied: params.onBeforeApplied,
5033
4732
  onAfterApplied: params.onAfterApplied
5034
4733
  });
5035
- new AnimationSeries(this.win, this.step);
4734
+ new AnimationSeries(win, this.step);
5036
4735
  }
5037
4736
  static configure(canvas, params, win) {
5038
4737
  new AnimatedLayoutConfigurator(canvas, params, win);
@@ -5250,9 +4949,9 @@ var noopFn = () => {};
5250
4949
  //#endregion
5251
4950
  //#region src/canvas-builder/shared/resolve-dragging-port-direction-resolver/resolve-dragging-port-direction-resolver.ts
5252
4951
  var resolveDraggingPortDirectionResolver = (config, graph, connectionAllowedVerifier) => {
5253
- if (config === "closest-connectable-port") return new NearestConnectablePortDraggingPortDirectionResolver(graph, connectionAllowedVerifier);
5254
4952
  if (config === "nearest-connectable-port") return new NearestConnectablePortDraggingPortDirectionResolver(graph, connectionAllowedVerifier);
5255
- return new ConstantDraggingPortDirectionResolver(config);
4953
+ if (typeof config === "number") return new ConstantDraggingPortDirectionResolver(config);
4954
+ return new ConstantDraggingPortDirectionResolver(void 0);
5256
4955
  };
5257
4956
  //#endregion
5258
4957
  //#region src/canvas-builder/shared/resolve-edge-shape-factory/resolve-edge-shape-factory.ts
@@ -5272,30 +4971,6 @@ var resolveEdgeShapeFactory = (config) => {
5272
4971
  detourDistance: config.detourDistance,
5273
4972
  detourDirection: config.detourDirection
5274
4973
  });
5275
- case "horizontal": return () => new HorizontalEdgeShape({
5276
- color: config.color,
5277
- width: config.width,
5278
- arrowLength: config.arrowLength,
5279
- arrowOffset: config.arrowOffset,
5280
- arrowRenderer: config.arrowRenderer,
5281
- hasSourceArrow: config.hasSourceArrow,
5282
- hasTargetArrow: config.hasTargetArrow,
5283
- cycleSquareSide: config.cycleSquareSide,
5284
- roundness: config.roundness,
5285
- detourDistance: config.detourDistance
5286
- });
5287
- case "vertical": return () => new VerticalEdgeShape({
5288
- color: config.color,
5289
- width: config.width,
5290
- arrowLength: config.arrowLength,
5291
- arrowOffset: config.arrowOffset,
5292
- arrowRenderer: config.arrowRenderer,
5293
- hasSourceArrow: config.hasSourceArrow,
5294
- hasTargetArrow: config.hasTargetArrow,
5295
- cycleSquareSide: config.cycleSquareSide,
5296
- roundness: config.roundness,
5297
- detourDistance: config.detourDistance
5298
- });
5299
4974
  case "orthogonal": return () => new OrthogonalEdgeShape({
5300
4975
  color: config.color,
5301
4976
  width: config.width,
@@ -5369,10 +5044,10 @@ var createShiftLimitTransformPreprocessor = (preprocessorParams) => {
5369
5044
  let dx = params.nextTransform.x;
5370
5045
  let dy = params.nextTransform.y;
5371
5046
  if (dx < minX && dx < params.prevTransform.x) dx = Math.min(params.prevTransform.x, minX);
5372
- const maxScreenX = maxX - params.canvasWidth * params.prevTransform.scale;
5047
+ const maxScreenX = maxX - params.viewport.width * params.prevTransform.scale;
5373
5048
  if (dx > maxScreenX && dx > params.prevTransform.x) dx = Math.max(params.prevTransform.x, maxScreenX);
5374
5049
  if (dy < minY && dy < params.prevTransform.y) dy = Math.min(params.prevTransform.y, minY);
5375
- const maxScreenY = maxY - params.canvasHeight * params.prevTransform.scale;
5050
+ const maxScreenY = maxY - params.viewport.height * params.prevTransform.scale;
5376
5051
  if (dy > maxScreenY && dy > params.prevTransform.y) dy = Math.max(params.prevTransform.y, maxScreenY);
5377
5052
  return {
5378
5053
  scale: params.nextTransform.scale,
@@ -5420,8 +5095,7 @@ var createCombinedTransformPreprocessor = (preprocessors) => {
5420
5095
  return preprocessors.reduce((acc, cur) => cur({
5421
5096
  prevTransform: params.prevTransform,
5422
5097
  nextTransform: acc,
5423
- canvasWidth: params.canvasWidth,
5424
- canvasHeight: params.canvasHeight
5098
+ viewport: params.viewport
5425
5099
  }), params.nextTransform);
5426
5100
  };
5427
5101
  };
@@ -5454,10 +5128,10 @@ var createTransformableViewportParams = (transformConfig) => {
5454
5128
  else transformPreprocessor = (params) => {
5455
5129
  return params.nextTransform;
5456
5130
  };
5457
- const shiftCursor = transformConfig?.shift?.cursor !== void 0 ? transformConfig.shift.cursor : "grab";
5458
- const defaultMouseDownEventVerifier = transformConfig?.shift?.mouseDownEventVerifier;
5131
+ const shiftCursor = transformConfig?.pan?.cursor !== void 0 ? transformConfig.pan.cursor : "grab";
5132
+ const defaultMouseDownEventVerifier = transformConfig?.pan?.mouseDownEventVerifier;
5459
5133
  const mouseDownEventVerifier = defaultMouseDownEventVerifier !== void 0 ? defaultMouseDownEventVerifier : (event) => event.button === 0;
5460
- const defaultMouseUpEventVerifier = transformConfig?.shift?.mouseUpEventVerifier;
5134
+ const defaultMouseUpEventVerifier = transformConfig?.pan?.mouseUpEventVerifier;
5461
5135
  const mouseUpEventVerifier = defaultMouseUpEventVerifier !== void 0 ? defaultMouseUpEventVerifier : (event) => event.button === 0;
5462
5136
  const defaultMouseWheelEventVerifier = transformConfig?.scale?.mouseWheelEventVerifier;
5463
5137
  const mouseWheelEventVerifier = defaultMouseWheelEventVerifier !== void 0 ? defaultMouseWheelEventVerifier : () => true;
@@ -5526,7 +5200,9 @@ var createConnectablePortsParams = (config, defaultEdgeShapeFactory, graph) => {
5526
5200
  mouseUpEventVerifier: config.mouseUpEventVerifier ?? defaults$3.mouseEventVerifier,
5527
5201
  onAfterEdgeCreated: config.events?.onAfterEdgeCreated ?? noopFn,
5528
5202
  onEdgeCreationInterrupted: config.events?.onEdgeCreationInterrupted ?? noopFn,
5529
- onEdgeCreationPrevented: config.events?.onEdgeCreationPrevented ?? noopFn
5203
+ onEdgeCreationPrevented: config.events?.onEdgeCreationPrevented ?? noopFn,
5204
+ grabbedPortIdResolver: config.grabbedPortIdResolver ?? defaultPortIdResolver,
5205
+ releasedPortIdResolver: config.releasedPortIdResolver ?? defaultPortIdResolver
5530
5206
  };
5531
5207
  };
5532
5208
  //#endregion
@@ -5534,7 +5210,7 @@ var createConnectablePortsParams = (config, defaultEdgeShapeFactory, graph) => {
5534
5210
  var defaults$2 = Object.freeze({
5535
5211
  connectionAllowedVerifier: () => true,
5536
5212
  connectionPreprocessor: (request) => request,
5537
- mouseDownEventVerifier: (event) => event.button === 0 && event.ctrlKey,
5213
+ mouseDownEventVerifier: (event) => event.button === 0,
5538
5214
  mouseUpEventVerifier: (event) => event.button === 0
5539
5215
  });
5540
5216
  //#endregion
@@ -5556,7 +5232,9 @@ var createDraggableEdgeParams = (config, graph) => {
5556
5232
  onAfterEdgeReattached: config.events?.onAfterEdgeReattached ?? noopFn,
5557
5233
  onEdgeReattachInterrupted: config.events?.onEdgeReattachInterrupted ?? noopFn,
5558
5234
  onEdgeReattachPrevented: config.events?.onEdgeReattachPrevented ?? noopFn,
5559
- draggingPortDirectionResolver: resolveDraggingPortDirectionResolver(config.dragPortDirection, graph, connectionAllowedVerifier)
5235
+ draggingPortDirectionResolver: resolveDraggingPortDirectionResolver(config.dragPortDirection, graph, connectionAllowedVerifier),
5236
+ grabbedPortIdResolver: config.grabbedPortIdResolver ?? defaultPortIdResolver,
5237
+ releasedPortIdResolver: config.releasedPortIdResolver ?? defaultPortIdResolver
5560
5238
  };
5561
5239
  };
5562
5240
  //#endregion
@@ -6221,7 +5899,7 @@ var ForceDirectedLayoutAlgorithm = class {
6221
5899
  this.nodeMass = params.nodeMass;
6222
5900
  this.edgeEquilibriumLength = params.edgeEquilibriumLength;
6223
5901
  this.edgeStiffness = params.edgeStiffness;
6224
- this.convergenceVelocity = params.convergenceVelocity;
5902
+ this.convergenceVelocity = params.stopVelocity;
6225
5903
  this.distanceVectorGenerator = new DistanceVectorGenerator(params.rand);
6226
5904
  this.nodeForcesApplicationStrategy = resolveNodeForcesApplicationStrategy({
6227
5905
  distanceVectorGenerator: this.distanceVectorGenerator,
@@ -6477,7 +6155,7 @@ var ForceDirectedAnimatedLayoutAlgorithm = class {
6477
6155
  edgeStiffness;
6478
6156
  fillerLayoutAlgorithm;
6479
6157
  constructor(params) {
6480
- this.convergenceVelocity = params.convergenceVelocity;
6158
+ this.convergenceVelocity = params.stopVelocity;
6481
6159
  this.maxTimeDeltaSec = params.maxTimeDeltaSec;
6482
6160
  this.nodeMass = params.nodeMass;
6483
6161
  this.edgeEquilibriumLength = params.edgeEquilibriumLength;
@@ -6576,7 +6254,7 @@ var resolveAnimatedLayoutAlgorithm = (config) => {
6576
6254
  nodeMass: config?.nodeMass ?? forceDirectedDefaults.nodeMass,
6577
6255
  edgeEquilibriumLength: config?.edgeEquilibriumLength ?? forceDirectedDefaults.edgeEquilibriumLength,
6578
6256
  edgeStiffness: config?.edgeStiffness ?? forceDirectedDefaults.edgeStiffness,
6579
- convergenceVelocity: config?.convergenceVelocity ?? forceDirectedDefaults.convergenceVelocity,
6257
+ stopVelocity: config?.stopVelocity ?? forceDirectedDefaults.convergenceVelocity,
6580
6258
  maxForce: config?.maxForce ?? forceDirectedDefaults.maxForce,
6581
6259
  nodeForceCoefficient: config?.nodeForceCoefficient ?? forceDirectedDefaults.nodeForceCoefficient,
6582
6260
  barnesHutTheta: config?.barnesHut?.theta ?? forceDirectedDefaults.barnesHutTheta,
@@ -6605,14 +6283,6 @@ var resolveLayoutApplyOn = (applyOn) => {
6605
6283
  type: "trigger",
6606
6284
  trigger: applyOn
6607
6285
  };
6608
- if (applyOn === "topologyChangeMicrotask") return {
6609
- type: "topologyChangeSchedule",
6610
- schedule: microtaskScheduleFn
6611
- };
6612
- if (applyOn?.type === "topologyChangeMacrotask") return {
6613
- type: "topologyChangeSchedule",
6614
- schedule: macrotaskScheduleFn
6615
- };
6616
6286
  return {
6617
6287
  type: "topologyChangeSchedule",
6618
6288
  schedule: microtaskScheduleFn
@@ -6808,7 +6478,7 @@ var resolveLayoutAlgorithm = (config) => {
6808
6478
  nodeMass: config?.nodeMass ?? forceDirectedDefaults.nodeMass,
6809
6479
  edgeEquilibriumLength: config?.edgeEquilibriumLength ?? forceDirectedDefaults.edgeEquilibriumLength,
6810
6480
  edgeStiffness: config?.edgeStiffness ?? forceDirectedDefaults.edgeStiffness,
6811
- convergenceVelocity: config?.convergenceVelocity ?? forceDirectedDefaults.convergenceVelocity,
6481
+ stopVelocity: config?.stopVelocity ?? forceDirectedDefaults.convergenceVelocity,
6812
6482
  maxForce: config?.maxForce ?? forceDirectedDefaults.maxForce,
6813
6483
  nodeForceCoefficient: config?.nodeForceCoefficient ?? forceDirectedDefaults.nodeForceCoefficient,
6814
6484
  barnesHutTheta: config?.barnesHut?.theta ?? forceDirectedDefaults.barnesHutTheta,
@@ -6923,7 +6593,7 @@ var createViewportControllerParams = (params) => {
6923
6593
  const { canvasDefaults } = params;
6924
6594
  const schedule = params.hasLayout ? resolveLayoutFocusSchedule(params.layoutParams) : immediateScheduleFn;
6925
6595
  return { focus: {
6926
- contentPadding: canvasDefaults.focus?.contentPadding ?? canvasDefaults.focus?.contentOffset ?? 100,
6596
+ contentPadding: canvasDefaults.focus?.contentPadding ?? 100,
6927
6597
  minContentScale: canvasDefaults.focus?.minContentScale ?? 0,
6928
6598
  schedule,
6929
6599
  animationDuration: canvasDefaults.focus?.animationDuration ?? 0
@@ -7122,4 +6792,4 @@ var CanvasBuilder = class {
7122
6792
  }
7123
6793
  };
7124
6794
  //#endregion
7125
- export { BezierEdgeShape, CanvasBuilder, CanvasBuilderError, CanvasError, ConnectionCategory, DirectEdgeShape, EventSubject, HorizontalEdgeShape, InteractiveEdgeError, InteractiveEdgeShape, MidpointEdgeShape, OrthogonalEdgeShape, StraightEdgeShape, VerticalEdgeShape, boxPortOffsetFn };
6795
+ export { BezierEdgeShape, CanvasBuilder, CanvasBuilderError, CanvasError, ConnectionCategory, DirectEdgeShape, EventSubject, InteractiveEdgeError, InteractiveEdgeShape, MidpointEdgeShape, OrthogonalEdgeShape, StraightEdgeShape };