@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.
@@ -125,11 +125,11 @@
125
125
  node.element.style.zIndex = `${node.payload.priority}`;
126
126
  }
127
127
  updateEdgeShape(edgeId) {
128
- const element = this.edgeIdToElementMap.get(edgeId);
129
- this.container.removeChild(element);
130
- const svg = this.graphStore.getEdge(edgeId).payload.shape.element;
131
- this.edgeIdToElementMap.set(edgeId, svg);
132
- this.container.appendChild(svg);
128
+ const previousElement = this.edgeIdToElementMap.get(edgeId);
129
+ this.container.removeChild(previousElement);
130
+ const { element } = this.graphStore.getEdge(edgeId).payload.shape;
131
+ this.edgeIdToElementMap.set(edgeId, element);
132
+ this.container.appendChild(element);
133
133
  }
134
134
  renderEdge(edgeId) {
135
135
  const edge = this.graphStore.getEdge(edgeId);
@@ -1101,10 +1101,10 @@
1101
1101
  };
1102
1102
  //#endregion
1103
1103
  //#region src/configurators/shared/find-port-at-point/find-port-for-element/find-port-for-element.ts
1104
- var findPortForElement = (graph, element) => {
1104
+ var findPortForElement = (graph, element, portIdResolver) => {
1105
1105
  let elementBuf = element;
1106
1106
  while (elementBuf !== null) {
1107
- const portId = graph.findPortIdsByElement(elementBuf)[0] ?? null;
1107
+ const portId = portIdResolver(graph.findPortIdsByElement(elementBuf));
1108
1108
  if (portId !== null) return {
1109
1109
  status: "portFound",
1110
1110
  portId
@@ -1128,10 +1128,10 @@
1128
1128
  }
1129
1129
  //#endregion
1130
1130
  //#region src/configurators/shared/find-port-at-point/find-port-at-point.ts
1131
- var findPortAtPoint = (graph, point) => {
1131
+ var findPortAtPoint = (graph, point, portIdResolver) => {
1132
1132
  const elements = getElementsAtPoint(document, point);
1133
1133
  for (const element of elements) {
1134
- const result = findPortForElement(graph, element);
1134
+ const result = findPortForElement(graph, element, portIdResolver);
1135
1135
  if (result.status === "portFound") return result.portId;
1136
1136
  if (result.status === "nodeEncountered") return null;
1137
1137
  }
@@ -1667,43 +1667,6 @@
1667
1667
  return createVerticalSourceOrthogonalLine(from, to);
1668
1668
  };
1669
1669
  //#endregion
1670
- //#region src/edges/paths/horizontal-edge-path/horizontal-edge-path.ts
1671
- var HorizontalEdgePath = class {
1672
- path;
1673
- midpoint;
1674
- constructor(params) {
1675
- const { from, to, fromDir, toDir, arrowLength, arrowOffset, roundness, hasSourceArrow, hasTargetArrow } = params;
1676
- const beginArrow = hasSourceArrow ? createRotatedPoint({
1677
- x: from.x + arrowLength,
1678
- y: from.y
1679
- }, fromDir, from) : from;
1680
- const endArrow = hasTargetArrow ? createRotatedPoint({
1681
- x: to.x - arrowLength,
1682
- y: to.y
1683
- }, toDir, to) : to;
1684
- const gap = arrowLength + arrowOffset;
1685
- const beginLine = createRotatedPoint({
1686
- x: from.x + gap,
1687
- y: from.y
1688
- }, fromDir, from);
1689
- const endLine = createRotatedPoint({
1690
- x: to.x - gap,
1691
- y: to.y
1692
- }, toDir, to);
1693
- const line = createHorizontalLine({
1694
- arrowPoint: beginArrow,
1695
- linePoint: beginLine,
1696
- dir: fromDir
1697
- }, {
1698
- arrowPoint: endArrow,
1699
- linePoint: endLine,
1700
- dir: toDir
1701
- });
1702
- this.path = createRoundedPath(line.points, roundness);
1703
- this.midpoint = line.midpoint;
1704
- }
1705
- };
1706
- //#endregion
1707
1670
  //#region src/edges/paths/detour-straight-edge-path/detour-straight-edge-path.ts
1708
1671
  var DetourStraightEdgePath = class {
1709
1672
  path;
@@ -1791,43 +1754,6 @@
1791
1754
  }
1792
1755
  };
1793
1756
  //#endregion
1794
- //#region src/edges/paths/vertical-edge-path/vertical-edge-path.ts
1795
- var VerticalEdgePath = class {
1796
- path;
1797
- midpoint;
1798
- constructor(params) {
1799
- const { from, to, hasSourceArrow, hasTargetArrow, arrowLength, arrowOffset, fromDir, toDir, roundness } = params;
1800
- const beginArrow = hasSourceArrow ? createRotatedPoint({
1801
- x: from.x + arrowLength,
1802
- y: from.y
1803
- }, fromDir, from) : from;
1804
- const endArrow = hasTargetArrow ? createRotatedPoint({
1805
- x: to.x - arrowLength,
1806
- y: to.y
1807
- }, toDir, to) : to;
1808
- const gap = arrowLength + arrowOffset;
1809
- const beginLine = createRotatedPoint({
1810
- x: from.x + gap,
1811
- y: from.y
1812
- }, fromDir, from);
1813
- const endLine = createRotatedPoint({
1814
- x: to.x - gap,
1815
- y: to.y
1816
- }, toDir, to);
1817
- const line = createVerticalLine({
1818
- arrowPoint: beginArrow,
1819
- linePoint: beginLine,
1820
- dir: fromDir
1821
- }, {
1822
- arrowPoint: endArrow,
1823
- linePoint: endLine,
1824
- dir: toDir
1825
- });
1826
- this.path = createRoundedPath(line.points, roundness);
1827
- this.midpoint = line.midpoint;
1828
- }
1829
- };
1830
- //#endregion
1831
1757
  //#region src/edges/paths/orthogonal-edge-path/orthogonal-edge-path.ts
1832
1758
  var OrthogonalEdgePath = class {
1833
1759
  path;
@@ -2136,7 +2062,6 @@
2136
2062
  var PathEdgeShape = class {
2137
2063
  params;
2138
2064
  element;
2139
- svg;
2140
2065
  group = document.createElementNS("http://www.w3.org/2000/svg", "g");
2141
2066
  line;
2142
2067
  sourceArrow = null;
@@ -2149,7 +2074,6 @@
2149
2074
  [this.afterRenderEmitter, this.onAfterRender] = createPair();
2150
2075
  this.arrowRenderer = this.params.arrowRenderer;
2151
2076
  this.element = createEdgeSvg(params.color);
2152
- this.svg = this.element;
2153
2077
  this.element.appendChild(this.group);
2154
2078
  this.line = createEdgePath(params.width);
2155
2079
  this.group.appendChild(this.line);
@@ -2323,7 +2247,6 @@
2323
2247
  //#region src/edges/shapes/bezier-edge-shape/bezier-edge-shape.ts
2324
2248
  var BezierEdgeShape = class {
2325
2249
  element;
2326
- svg;
2327
2250
  group;
2328
2251
  line;
2329
2252
  sourceArrow;
@@ -2390,7 +2313,6 @@
2390
2313
  padding: 50
2391
2314
  });
2392
2315
  this.element = this.pathShape.element;
2393
- this.svg = this.element;
2394
2316
  this.group = this.pathShape.group;
2395
2317
  this.line = this.pathShape.line;
2396
2318
  this.sourceArrow = this.pathShape.sourceArrow;
@@ -2402,113 +2324,9 @@
2402
2324
  }
2403
2325
  };
2404
2326
  //#endregion
2405
- //#region src/edges/shapes/horizontal-edge-shape/horizontalize-directions/horizontalize-direction.ts
2406
- var horizontalizeDirection = (direction) => {
2407
- return Math.cos(direction) > 0 ? 0 : Math.PI;
2408
- };
2409
- //#endregion
2410
- //#region src/edges/shapes/horizontal-edge-shape/horizontal-edge-shape.ts
2411
- /**
2412
- * @deprecated
2413
- * use OrthogonalEdgeShape instead
2414
- */
2415
- var HorizontalEdgeShape = class {
2416
- element;
2417
- svg;
2418
- group;
2419
- line;
2420
- sourceArrow;
2421
- targetArrow;
2422
- onAfterRender;
2423
- arrowLength;
2424
- arrowOffset;
2425
- roundness;
2426
- cycleSquareSide;
2427
- detourDistance;
2428
- hasSourceArrow;
2429
- hasTargetArrow;
2430
- pathShape;
2431
- createCyclePath = (from, _to, fromDir) => new CycleSquareEdgePath({
2432
- origin: from,
2433
- dir: fromDir,
2434
- arrowLength: this.arrowLength,
2435
- side: this.cycleSquareSide,
2436
- arrowOffset: this.arrowOffset,
2437
- roundness: this.roundness,
2438
- hasArrow: this.hasSourceArrow || this.hasTargetArrow
2439
- });
2440
- createDetourPath = (from, to, fromDir, toDir) => new DetourHorizontalEdgePath({
2441
- from,
2442
- to,
2443
- fromDir,
2444
- toDir,
2445
- arrowLength: this.arrowLength,
2446
- arrowOffset: this.arrowOffset,
2447
- roundness: this.roundness,
2448
- detourDistance: this.detourDistance,
2449
- hasSourceArrow: this.hasSourceArrow,
2450
- hasTargetArrow: this.hasTargetArrow
2451
- });
2452
- createLinePath = (from, to, fromDir, toDir) => new HorizontalEdgePath({
2453
- from,
2454
- to,
2455
- fromDir,
2456
- toDir,
2457
- arrowLength: this.arrowLength,
2458
- arrowOffset: this.arrowOffset,
2459
- roundness: this.roundness,
2460
- hasSourceArrow: this.hasSourceArrow,
2461
- hasTargetArrow: this.hasTargetArrow
2462
- });
2463
- constructor(params) {
2464
- this.arrowLength = params?.arrowLength ?? edgeConstants.arrowLength;
2465
- this.arrowOffset = params?.arrowOffset ?? edgeConstants.arrowOffset;
2466
- this.cycleSquareSide = params?.cycleSquareSide ?? edgeConstants.cycleSquareSide;
2467
- const roundness = params?.roundness ?? edgeConstants.roundness;
2468
- this.roundness = Math.min(roundness, this.arrowOffset, this.cycleSquareSide / 2);
2469
- this.detourDistance = params?.detourDistance ?? edgeConstants.detourDistance;
2470
- this.hasSourceArrow = params?.hasSourceArrow ?? edgeConstants.hasSourceArrow;
2471
- this.hasTargetArrow = params?.hasTargetArrow ?? edgeConstants.hasTargetArrow;
2472
- this.pathShape = new PathEdgeShape({
2473
- color: params?.color ?? edgeConstants.color,
2474
- width: params?.width ?? edgeConstants.width,
2475
- arrowRenderer: resolveArrowRenderer(params?.arrowRenderer ?? {}),
2476
- arrowLength: this.arrowLength,
2477
- hasSourceArrow: this.hasSourceArrow,
2478
- hasTargetArrow: this.hasTargetArrow,
2479
- createCyclePath: this.createCyclePath,
2480
- createDetourPath: this.createDetourPath,
2481
- createLinePath: this.createLinePath,
2482
- padding: 50
2483
- });
2484
- this.element = this.pathShape.element;
2485
- this.svg = this.element;
2486
- this.group = this.pathShape.group;
2487
- this.line = this.pathShape.line;
2488
- this.sourceArrow = this.pathShape.sourceArrow;
2489
- this.targetArrow = this.pathShape.targetArrow;
2490
- this.onAfterRender = this.pathShape.onAfterRender;
2491
- }
2492
- render(params) {
2493
- const { from, to, category } = params;
2494
- this.pathShape.render({
2495
- category,
2496
- from: {
2497
- ...from,
2498
- direction: horizontalizeDirection(from.direction)
2499
- },
2500
- to: {
2501
- ...to,
2502
- direction: horizontalizeDirection(to.direction)
2503
- }
2504
- });
2505
- }
2506
- };
2507
- //#endregion
2508
2327
  //#region src/edges/shapes/straight-edge-shape/straight-edge-shape.ts
2509
2328
  var StraightEdgeShape = class {
2510
2329
  element;
2511
- svg;
2512
2330
  group;
2513
2331
  line;
2514
2332
  sourceArrow;
@@ -2579,7 +2397,6 @@
2579
2397
  padding: 50
2580
2398
  });
2581
2399
  this.element = this.pathShape.element;
2582
- this.svg = this.element;
2583
2400
  this.group = this.pathShape.group;
2584
2401
  this.line = this.pathShape.line;
2585
2402
  this.sourceArrow = this.pathShape.sourceArrow;
@@ -2591,110 +2408,6 @@
2591
2408
  }
2592
2409
  };
2593
2410
  //#endregion
2594
- //#region src/edges/shapes/vertical-edge-shape/verticalize-directions/verticalize-direction.ts
2595
- var pi2 = Math.PI / 2;
2596
- var verticalizeDirection = (direction) => {
2597
- return Math.sin(direction) > 0 ? pi2 : -pi2;
2598
- };
2599
- //#endregion
2600
- //#region src/edges/shapes/vertical-edge-shape/vertical-edge-shape.ts
2601
- /**
2602
- * @deprecated
2603
- * use OrthogonalEdgeShape instead
2604
- */
2605
- var VerticalEdgeShape = class {
2606
- element;
2607
- svg;
2608
- group;
2609
- line;
2610
- sourceArrow;
2611
- targetArrow;
2612
- onAfterRender;
2613
- arrowLength;
2614
- arrowOffset;
2615
- roundness;
2616
- cycleSquareSide;
2617
- detourDistance;
2618
- hasSourceArrow;
2619
- hasTargetArrow;
2620
- pathShape;
2621
- createCyclePath = (from, _to, fromDir) => new CycleSquareEdgePath({
2622
- origin: from,
2623
- dir: fromDir,
2624
- arrowLength: this.arrowLength,
2625
- side: this.cycleSquareSide,
2626
- arrowOffset: this.arrowOffset,
2627
- roundness: this.roundness,
2628
- hasArrow: this.hasSourceArrow || this.hasTargetArrow
2629
- });
2630
- createDetourPath = (from, to, fromDir, toDir) => new DetourVerticalEdgePath({
2631
- from,
2632
- to,
2633
- fromDir,
2634
- toDir,
2635
- arrowLength: this.arrowLength,
2636
- arrowOffset: this.arrowOffset,
2637
- roundness: this.roundness,
2638
- detourDistance: this.detourDistance,
2639
- hasSourceArrow: this.hasSourceArrow,
2640
- hasTargetArrow: this.hasTargetArrow
2641
- });
2642
- createLinePath = (from, to, fromDir, toDir) => new VerticalEdgePath({
2643
- from,
2644
- to,
2645
- fromDir,
2646
- toDir,
2647
- arrowLength: this.arrowLength,
2648
- arrowOffset: this.arrowOffset,
2649
- roundness: this.roundness,
2650
- hasSourceArrow: this.hasSourceArrow,
2651
- hasTargetArrow: this.hasTargetArrow
2652
- });
2653
- constructor(params) {
2654
- this.arrowLength = params?.arrowLength ?? edgeConstants.arrowLength;
2655
- this.arrowOffset = params?.arrowOffset ?? edgeConstants.arrowOffset;
2656
- this.cycleSquareSide = params?.cycleSquareSide ?? edgeConstants.cycleSquareSide;
2657
- const roundness = params?.roundness ?? edgeConstants.roundness;
2658
- this.roundness = Math.min(roundness, this.arrowOffset, this.cycleSquareSide / 2);
2659
- this.detourDistance = params?.detourDistance ?? edgeConstants.detourDistance;
2660
- this.hasSourceArrow = params?.hasSourceArrow ?? edgeConstants.hasSourceArrow;
2661
- this.hasTargetArrow = params?.hasTargetArrow ?? edgeConstants.hasTargetArrow;
2662
- this.pathShape = new PathEdgeShape({
2663
- color: params?.color ?? edgeConstants.color,
2664
- width: params?.width ?? edgeConstants.width,
2665
- arrowRenderer: resolveArrowRenderer(params?.arrowRenderer ?? {}),
2666
- arrowLength: this.arrowLength,
2667
- hasSourceArrow: this.hasSourceArrow,
2668
- hasTargetArrow: this.hasTargetArrow,
2669
- createCyclePath: this.createCyclePath,
2670
- createDetourPath: this.createDetourPath,
2671
- createLinePath: this.createLinePath,
2672
- padding: 50
2673
- });
2674
- this.element = this.pathShape.element;
2675
- this.svg = this.element;
2676
- this.group = this.pathShape.group;
2677
- this.line = this.pathShape.line;
2678
- this.sourceArrow = this.pathShape.sourceArrow;
2679
- this.targetArrow = this.pathShape.targetArrow;
2680
- this.onAfterRender = this.pathShape.onAfterRender;
2681
- }
2682
- render(params) {
2683
- const { from, to, category } = params;
2684
- this.pathShape.render({
2685
- category,
2686
- from: {
2687
- ...from,
2688
- direction: verticalizeDirection(from.direction)
2689
- },
2690
- to: {
2691
- ...to,
2692
- direction: verticalizeDirection(to.direction)
2693
- }
2694
- });
2695
- }
2696
- };
2697
- //#endregion
2698
2411
  //#region src/edges/shapes/orthogonal-edge-shape/orthogonalize-direction/orthogonalize-direction.ts
2699
2412
  var orthogonalizeDirection = (direction) => {
2700
2413
  const adjDir = direction + Math.PI / 4;
@@ -2711,7 +2424,6 @@
2711
2424
  //#region src/edges/shapes/orthogonal-edge-shape/orthogonal-edge-shape.ts
2712
2425
  var OrthogonalEdgeShape = class {
2713
2426
  element;
2714
- svg;
2715
2427
  group;
2716
2428
  line;
2717
2429
  sourceArrow;
@@ -2779,7 +2491,6 @@
2779
2491
  padding: 50
2780
2492
  });
2781
2493
  this.element = this.pathShape.element;
2782
- this.svg = this.element;
2783
2494
  this.group = this.pathShape.group;
2784
2495
  this.line = this.pathShape.line;
2785
2496
  this.sourceArrow = this.pathShape.sourceArrow;
@@ -2826,7 +2537,6 @@
2826
2537
  var defaultPortOffset = edgeConstants.portOffset;
2827
2538
  var DirectEdgeShape = class {
2828
2539
  element;
2829
- svg;
2830
2540
  group = document.createElementNS("http://www.w3.org/2000/svg", "g");
2831
2541
  line;
2832
2542
  sourceArrow = null;
@@ -2848,7 +2558,6 @@
2848
2558
  this.sourceOffsetFn = resolvePortOffsetFn(params?.sourceOffset ?? defaultPortOffset);
2849
2559
  this.targetOffsetFn = resolvePortOffsetFn(params?.targetOffset ?? defaultPortOffset);
2850
2560
  this.element = createEdgeSvg(this.color);
2851
- this.svg = this.element;
2852
2561
  this.element.appendChild(this.group);
2853
2562
  this.line = createEdgePath(this.width);
2854
2563
  this.group.appendChild(this.line);
@@ -3029,15 +2738,10 @@
3029
2738
  var InteractiveEdgeShape = class InteractiveEdgeShape {
3030
2739
  baseEdge;
3031
2740
  element;
3032
- svg;
3033
2741
  group;
3034
2742
  line;
3035
2743
  sourceArrow;
3036
2744
  targetArrow;
3037
- /**
3038
- * @deprecated
3039
- * use shape.svg instead
3040
- */
3041
2745
  handle = createEdgeGroup();
3042
2746
  onAfterRender;
3043
2747
  interactiveLine;
@@ -3047,7 +2751,6 @@
3047
2751
  this.baseEdge = baseEdge;
3048
2752
  if (baseEdge instanceof InteractiveEdgeShape) throw new InteractiveEdgeError("interactive edge can be configured only once");
3049
2753
  this.element = this.baseEdge.element;
3050
- this.svg = this.element;
3051
2754
  this.group = this.baseEdge.group;
3052
2755
  this.line = this.baseEdge.line;
3053
2756
  this.sourceArrow = this.baseEdge.sourceArrow;
@@ -3086,12 +2789,10 @@
3086
2789
  targetArrow;
3087
2790
  onAfterRender;
3088
2791
  element;
3089
- svg;
3090
2792
  constructor(baseShape, midpointElement) {
3091
2793
  this.baseShape = baseShape;
3092
2794
  this.midpointElement = midpointElement;
3093
2795
  this.element = this.baseShape.element;
3094
- this.svg = this.element;
3095
2796
  this.group = this.baseShape.group;
3096
2797
  this.line = this.baseShape.line;
3097
2798
  this.sourceArrow = this.baseShape.sourceArrow;
@@ -3391,17 +3092,6 @@
3391
3092
  }
3392
3093
  };
3393
3094
  //#endregion
3394
- //#region src/schedule-fn/macrotask-schedule-fn/macrotask-schedule-fn.ts
3395
- /**
3396
- * @deprecated
3397
- * use macrotaskScheduleFn instead
3398
- */
3399
- var macrotaskScheduleFn = (callback) => {
3400
- setTimeout(() => {
3401
- callback();
3402
- });
3403
- };
3404
- //#endregion
3405
3095
  //#region src/schedule-fn/microtask-schedule-fn/microtask-schedule-fn.ts
3406
3096
  var microtaskScheduleFn = (callback) => {
3407
3097
  queueMicrotask(() => {
@@ -3453,7 +3143,7 @@
3453
3143
  } : {
3454
3144
  minContentScale: config.minContentScale ?? controllerParams.focus.minContentScale,
3455
3145
  nodes: config.nodes ?? [],
3456
- contentPadding: config.contentPadding ?? config.contentOffset ?? controllerParams.focus.contentPadding,
3146
+ contentPadding: config.contentPadding ?? controllerParams.focus.contentPadding,
3457
3147
  animationDuration: config.animationDuration ?? controllerParams.focus.animationDuration
3458
3148
  };
3459
3149
  };
@@ -3647,7 +3337,9 @@
3647
3337
  const mouseEvent = event;
3648
3338
  if (!this.params.mouseDownEventVerifier(mouseEvent)) return;
3649
3339
  const target = event.currentTarget;
3650
- const portId = this.canvas.graph.findPortIdsByElement(target)[0];
3340
+ const portIds = this.canvas.graph.findPortIdsByElement(target);
3341
+ const portId = this.params.grabbedPortIdResolver(portIds);
3342
+ if (portId === null) return;
3651
3343
  if (!this.params.onPointerDownVerifier(portId, {
3652
3344
  x: mouseEvent.clientX,
3653
3345
  y: mouseEvent.clientY
@@ -3948,6 +3640,12 @@
3948
3640
  }
3949
3641
  };
3950
3642
  //#endregion
3643
+ //#region src/configurators/shared/port-id-resolver/default-port-id-resolver/default-port-id-resolver.ts
3644
+ var defaultPortIdResolver = (portIds) => {
3645
+ if (portIds.length > 0) return portIds[0];
3646
+ return null;
3647
+ };
3648
+ //#endregion
3951
3649
  //#region src/configurators/user-draggable-nodes-configurator/user-draggable-nodes-configurator.ts
3952
3650
  var UserDraggableNodesConfigurator = class UserDraggableNodesConfigurator {
3953
3651
  canvas;
@@ -4005,12 +3703,7 @@
4005
3703
  const element = event.currentTarget;
4006
3704
  const nodeId = this.canvas.graph.findNodeIdByElement(element);
4007
3705
  const node = this.graph.getNode(nodeId);
4008
- if (!this.params.nodeDragVerifier({
4009
- nodeId,
4010
- element: node.element,
4011
- x: node.x,
4012
- y: node.y
4013
- })) return;
3706
+ if (!this.params.nodeDragVerifier(nodeId)) return;
4014
3707
  this.eventTagger.tag(event, dragEventHandledTag);
4015
3708
  const cursorContent = this.calculateContentPoint({
4016
3709
  x: touch.clientX,
@@ -4295,8 +3988,10 @@
4295
3988
  const transform = this.params.transformPreprocessor({
4296
3989
  prevTransform,
4297
3990
  nextTransform,
4298
- canvasWidth: width,
4299
- canvasHeight: height
3991
+ viewport: {
3992
+ width,
3993
+ height
3994
+ }
4300
3995
  });
4301
3996
  this.performTransform(transform);
4302
3997
  }
@@ -4307,8 +4002,10 @@
4307
4002
  const transform = this.params.transformPreprocessor({
4308
4003
  prevTransform,
4309
4004
  nextTransform,
4310
- canvasWidth: width,
4311
- canvasHeight: height
4005
+ viewport: {
4006
+ width,
4007
+ height
4008
+ }
4312
4009
  });
4313
4010
  this.performTransform(transform);
4314
4011
  }
@@ -4350,8 +4047,10 @@
4350
4047
  const transform = this.params.transformPreprocessor({
4351
4048
  prevTransform,
4352
4049
  nextTransform: prevTransform,
4353
- canvasWidth: width,
4354
- canvasHeight: height
4050
+ viewport: {
4051
+ width,
4052
+ height
4053
+ }
4355
4054
  });
4356
4055
  this.params.onResizeTransformStarted();
4357
4056
  this.canvas.patchViewportMatrix(transform);
@@ -4612,7 +4311,8 @@
4612
4311
  const params = this.edgeInProgress;
4613
4312
  this.resetDragState();
4614
4313
  this.params.onEdgeCreationInterrupted(params);
4615
- }
4314
+ },
4315
+ grabbedPortIdResolver: this.params.grabbedPortIdResolver
4616
4316
  };
4617
4317
  DraggablePortsConfigurator.configure(this.canvas, this.window, this.pointInsideVerifier, this.eventTagger, draggablePortsParams);
4618
4318
  }
@@ -4666,7 +4366,7 @@
4666
4366
  this.overlayCanvas.clear();
4667
4367
  }
4668
4368
  tryCreateConnection(cursor) {
4669
- const targetPortId = findPortAtPoint(this.canvas.graph, cursor);
4369
+ const targetPortId = findPortAtPoint(this.canvas.graph, cursor, this.params.releasedPortIdResolver);
4670
4370
  if (targetPortId === null) {
4671
4371
  this.params.onEdgeCreationInterrupted(this.edgeInProgress);
4672
4372
  return;
@@ -4747,7 +4447,8 @@
4747
4447
  shape: edge.shape,
4748
4448
  priority: edge.priority
4749
4449
  });
4750
- }
4450
+ },
4451
+ grabbedPortIdResolver: this.params.grabbedPortIdResolver
4751
4452
  };
4752
4453
  DraggablePortsConfigurator.configure(this.canvas, this.window, this.pointInsideVerifier, this.eventTagger, draggablePortsParams);
4753
4454
  }
@@ -4837,7 +4538,7 @@
4837
4538
  }).updatePort(OverlayId.DraggingNodeId, { direction });
4838
4539
  }
4839
4540
  tryCreateConnection(cursor) {
4840
- const draggingPortId = findPortAtPoint(this.canvas.graph, cursor);
4541
+ const draggingPortId = findPortAtPoint(this.canvas.graph, cursor, this.params.releasedPortIdResolver);
4841
4542
  this.overlayCanvas.removeEdge(OverlayId.EdgeId);
4842
4543
  if (draggingPortId === null) {
4843
4544
  const edge = this.draggingEdgePayload;
@@ -5024,19 +4725,17 @@
5024
4725
  //#endregion
5025
4726
  //#region src/configurators/animated-layout-configurator/animated-layout-configurator.ts
5026
4727
  var AnimatedLayoutConfigurator = class AnimatedLayoutConfigurator {
5027
- win;
5028
4728
  applier;
5029
4729
  step = (dt) => {
5030
4730
  this.applier.apply(dt);
5031
4731
  };
5032
4732
  constructor(canvas, params, win) {
5033
- this.win = win;
5034
4733
  this.applier = new AnimatedLayoutApplier(canvas, params.algorithm, {
5035
4734
  staticNodeResolver: params.staticNodeResolver,
5036
4735
  onBeforeApplied: params.onBeforeApplied,
5037
4736
  onAfterApplied: params.onAfterApplied
5038
4737
  });
5039
- new AnimationSeries(this.win, this.step);
4738
+ new AnimationSeries(win, this.step);
5040
4739
  }
5041
4740
  static configure(canvas, params, win) {
5042
4741
  new AnimatedLayoutConfigurator(canvas, params, win);
@@ -5254,9 +4953,9 @@
5254
4953
  //#endregion
5255
4954
  //#region src/canvas-builder/shared/resolve-dragging-port-direction-resolver/resolve-dragging-port-direction-resolver.ts
5256
4955
  var resolveDraggingPortDirectionResolver = (config, graph, connectionAllowedVerifier) => {
5257
- if (config === "closest-connectable-port") return new NearestConnectablePortDraggingPortDirectionResolver(graph, connectionAllowedVerifier);
5258
4956
  if (config === "nearest-connectable-port") return new NearestConnectablePortDraggingPortDirectionResolver(graph, connectionAllowedVerifier);
5259
- return new ConstantDraggingPortDirectionResolver(config);
4957
+ if (typeof config === "number") return new ConstantDraggingPortDirectionResolver(config);
4958
+ return new ConstantDraggingPortDirectionResolver(void 0);
5260
4959
  };
5261
4960
  //#endregion
5262
4961
  //#region src/canvas-builder/shared/resolve-edge-shape-factory/resolve-edge-shape-factory.ts
@@ -5276,30 +4975,6 @@
5276
4975
  detourDistance: config.detourDistance,
5277
4976
  detourDirection: config.detourDirection
5278
4977
  });
5279
- case "horizontal": return () => new HorizontalEdgeShape({
5280
- color: config.color,
5281
- width: config.width,
5282
- arrowLength: config.arrowLength,
5283
- arrowOffset: config.arrowOffset,
5284
- arrowRenderer: config.arrowRenderer,
5285
- hasSourceArrow: config.hasSourceArrow,
5286
- hasTargetArrow: config.hasTargetArrow,
5287
- cycleSquareSide: config.cycleSquareSide,
5288
- roundness: config.roundness,
5289
- detourDistance: config.detourDistance
5290
- });
5291
- case "vertical": return () => new VerticalEdgeShape({
5292
- color: config.color,
5293
- width: config.width,
5294
- arrowLength: config.arrowLength,
5295
- arrowOffset: config.arrowOffset,
5296
- arrowRenderer: config.arrowRenderer,
5297
- hasSourceArrow: config.hasSourceArrow,
5298
- hasTargetArrow: config.hasTargetArrow,
5299
- cycleSquareSide: config.cycleSquareSide,
5300
- roundness: config.roundness,
5301
- detourDistance: config.detourDistance
5302
- });
5303
4978
  case "orthogonal": return () => new OrthogonalEdgeShape({
5304
4979
  color: config.color,
5305
4980
  width: config.width,
@@ -5373,10 +5048,10 @@
5373
5048
  let dx = params.nextTransform.x;
5374
5049
  let dy = params.nextTransform.y;
5375
5050
  if (dx < minX && dx < params.prevTransform.x) dx = Math.min(params.prevTransform.x, minX);
5376
- const maxScreenX = maxX - params.canvasWidth * params.prevTransform.scale;
5051
+ const maxScreenX = maxX - params.viewport.width * params.prevTransform.scale;
5377
5052
  if (dx > maxScreenX && dx > params.prevTransform.x) dx = Math.max(params.prevTransform.x, maxScreenX);
5378
5053
  if (dy < minY && dy < params.prevTransform.y) dy = Math.min(params.prevTransform.y, minY);
5379
- const maxScreenY = maxY - params.canvasHeight * params.prevTransform.scale;
5054
+ const maxScreenY = maxY - params.viewport.height * params.prevTransform.scale;
5380
5055
  if (dy > maxScreenY && dy > params.prevTransform.y) dy = Math.max(params.prevTransform.y, maxScreenY);
5381
5056
  return {
5382
5057
  scale: params.nextTransform.scale,
@@ -5424,8 +5099,7 @@
5424
5099
  return preprocessors.reduce((acc, cur) => cur({
5425
5100
  prevTransform: params.prevTransform,
5426
5101
  nextTransform: acc,
5427
- canvasWidth: params.canvasWidth,
5428
- canvasHeight: params.canvasHeight
5102
+ viewport: params.viewport
5429
5103
  }), params.nextTransform);
5430
5104
  };
5431
5105
  };
@@ -5458,10 +5132,10 @@
5458
5132
  else transformPreprocessor = (params) => {
5459
5133
  return params.nextTransform;
5460
5134
  };
5461
- const shiftCursor = transformConfig?.shift?.cursor !== void 0 ? transformConfig.shift.cursor : "grab";
5462
- const defaultMouseDownEventVerifier = transformConfig?.shift?.mouseDownEventVerifier;
5135
+ const shiftCursor = transformConfig?.pan?.cursor !== void 0 ? transformConfig.pan.cursor : "grab";
5136
+ const defaultMouseDownEventVerifier = transformConfig?.pan?.mouseDownEventVerifier;
5463
5137
  const mouseDownEventVerifier = defaultMouseDownEventVerifier !== void 0 ? defaultMouseDownEventVerifier : (event) => event.button === 0;
5464
- const defaultMouseUpEventVerifier = transformConfig?.shift?.mouseUpEventVerifier;
5138
+ const defaultMouseUpEventVerifier = transformConfig?.pan?.mouseUpEventVerifier;
5465
5139
  const mouseUpEventVerifier = defaultMouseUpEventVerifier !== void 0 ? defaultMouseUpEventVerifier : (event) => event.button === 0;
5466
5140
  const defaultMouseWheelEventVerifier = transformConfig?.scale?.mouseWheelEventVerifier;
5467
5141
  const mouseWheelEventVerifier = defaultMouseWheelEventVerifier !== void 0 ? defaultMouseWheelEventVerifier : () => true;
@@ -5530,7 +5204,9 @@
5530
5204
  mouseUpEventVerifier: config.mouseUpEventVerifier ?? defaults$3.mouseEventVerifier,
5531
5205
  onAfterEdgeCreated: config.events?.onAfterEdgeCreated ?? noopFn,
5532
5206
  onEdgeCreationInterrupted: config.events?.onEdgeCreationInterrupted ?? noopFn,
5533
- onEdgeCreationPrevented: config.events?.onEdgeCreationPrevented ?? noopFn
5207
+ onEdgeCreationPrevented: config.events?.onEdgeCreationPrevented ?? noopFn,
5208
+ grabbedPortIdResolver: config.grabbedPortIdResolver ?? defaultPortIdResolver,
5209
+ releasedPortIdResolver: config.releasedPortIdResolver ?? defaultPortIdResolver
5534
5210
  };
5535
5211
  };
5536
5212
  //#endregion
@@ -5538,7 +5214,7 @@
5538
5214
  var defaults$2 = Object.freeze({
5539
5215
  connectionAllowedVerifier: () => true,
5540
5216
  connectionPreprocessor: (request) => request,
5541
- mouseDownEventVerifier: (event) => event.button === 0 && event.ctrlKey,
5217
+ mouseDownEventVerifier: (event) => event.button === 0,
5542
5218
  mouseUpEventVerifier: (event) => event.button === 0
5543
5219
  });
5544
5220
  //#endregion
@@ -5560,7 +5236,9 @@
5560
5236
  onAfterEdgeReattached: config.events?.onAfterEdgeReattached ?? noopFn,
5561
5237
  onEdgeReattachInterrupted: config.events?.onEdgeReattachInterrupted ?? noopFn,
5562
5238
  onEdgeReattachPrevented: config.events?.onEdgeReattachPrevented ?? noopFn,
5563
- draggingPortDirectionResolver: resolveDraggingPortDirectionResolver(config.dragPortDirection, graph, connectionAllowedVerifier)
5239
+ draggingPortDirectionResolver: resolveDraggingPortDirectionResolver(config.dragPortDirection, graph, connectionAllowedVerifier),
5240
+ grabbedPortIdResolver: config.grabbedPortIdResolver ?? defaultPortIdResolver,
5241
+ releasedPortIdResolver: config.releasedPortIdResolver ?? defaultPortIdResolver
5564
5242
  };
5565
5243
  };
5566
5244
  //#endregion
@@ -6225,7 +5903,7 @@
6225
5903
  this.nodeMass = params.nodeMass;
6226
5904
  this.edgeEquilibriumLength = params.edgeEquilibriumLength;
6227
5905
  this.edgeStiffness = params.edgeStiffness;
6228
- this.convergenceVelocity = params.convergenceVelocity;
5906
+ this.convergenceVelocity = params.stopVelocity;
6229
5907
  this.distanceVectorGenerator = new DistanceVectorGenerator(params.rand);
6230
5908
  this.nodeForcesApplicationStrategy = resolveNodeForcesApplicationStrategy({
6231
5909
  distanceVectorGenerator: this.distanceVectorGenerator,
@@ -6481,7 +6159,7 @@
6481
6159
  edgeStiffness;
6482
6160
  fillerLayoutAlgorithm;
6483
6161
  constructor(params) {
6484
- this.convergenceVelocity = params.convergenceVelocity;
6162
+ this.convergenceVelocity = params.stopVelocity;
6485
6163
  this.maxTimeDeltaSec = params.maxTimeDeltaSec;
6486
6164
  this.nodeMass = params.nodeMass;
6487
6165
  this.edgeEquilibriumLength = params.edgeEquilibriumLength;
@@ -6580,7 +6258,7 @@
6580
6258
  nodeMass: config?.nodeMass ?? forceDirectedDefaults.nodeMass,
6581
6259
  edgeEquilibriumLength: config?.edgeEquilibriumLength ?? forceDirectedDefaults.edgeEquilibriumLength,
6582
6260
  edgeStiffness: config?.edgeStiffness ?? forceDirectedDefaults.edgeStiffness,
6583
- convergenceVelocity: config?.convergenceVelocity ?? forceDirectedDefaults.convergenceVelocity,
6261
+ stopVelocity: config?.stopVelocity ?? forceDirectedDefaults.convergenceVelocity,
6584
6262
  maxForce: config?.maxForce ?? forceDirectedDefaults.maxForce,
6585
6263
  nodeForceCoefficient: config?.nodeForceCoefficient ?? forceDirectedDefaults.nodeForceCoefficient,
6586
6264
  barnesHutTheta: config?.barnesHut?.theta ?? forceDirectedDefaults.barnesHutTheta,
@@ -6609,14 +6287,6 @@
6609
6287
  type: "trigger",
6610
6288
  trigger: applyOn
6611
6289
  };
6612
- if (applyOn === "topologyChangeMicrotask") return {
6613
- type: "topologyChangeSchedule",
6614
- schedule: microtaskScheduleFn
6615
- };
6616
- if (applyOn?.type === "topologyChangeMacrotask") return {
6617
- type: "topologyChangeSchedule",
6618
- schedule: macrotaskScheduleFn
6619
- };
6620
6290
  return {
6621
6291
  type: "topologyChangeSchedule",
6622
6292
  schedule: microtaskScheduleFn
@@ -6812,7 +6482,7 @@
6812
6482
  nodeMass: config?.nodeMass ?? forceDirectedDefaults.nodeMass,
6813
6483
  edgeEquilibriumLength: config?.edgeEquilibriumLength ?? forceDirectedDefaults.edgeEquilibriumLength,
6814
6484
  edgeStiffness: config?.edgeStiffness ?? forceDirectedDefaults.edgeStiffness,
6815
- convergenceVelocity: config?.convergenceVelocity ?? forceDirectedDefaults.convergenceVelocity,
6485
+ stopVelocity: config?.stopVelocity ?? forceDirectedDefaults.convergenceVelocity,
6816
6486
  maxForce: config?.maxForce ?? forceDirectedDefaults.maxForce,
6817
6487
  nodeForceCoefficient: config?.nodeForceCoefficient ?? forceDirectedDefaults.nodeForceCoefficient,
6818
6488
  barnesHutTheta: config?.barnesHut?.theta ?? forceDirectedDefaults.barnesHutTheta,
@@ -6927,7 +6597,7 @@
6927
6597
  const { canvasDefaults } = params;
6928
6598
  const schedule = params.hasLayout ? resolveLayoutFocusSchedule(params.layoutParams) : immediateScheduleFn;
6929
6599
  return { focus: {
6930
- contentPadding: canvasDefaults.focus?.contentPadding ?? canvasDefaults.focus?.contentOffset ?? 100,
6600
+ contentPadding: canvasDefaults.focus?.contentPadding ?? 100,
6931
6601
  minContentScale: canvasDefaults.focus?.minContentScale ?? 0,
6932
6602
  schedule,
6933
6603
  animationDuration: canvasDefaults.focus?.animationDuration ?? 0
@@ -7133,12 +6803,9 @@
7133
6803
  exports.ConnectionCategory = ConnectionCategory;
7134
6804
  exports.DirectEdgeShape = DirectEdgeShape;
7135
6805
  exports.EventSubject = EventSubject;
7136
- exports.HorizontalEdgeShape = HorizontalEdgeShape;
7137
6806
  exports.InteractiveEdgeError = InteractiveEdgeError;
7138
6807
  exports.InteractiveEdgeShape = InteractiveEdgeShape;
7139
6808
  exports.MidpointEdgeShape = MidpointEdgeShape;
7140
6809
  exports.OrthogonalEdgeShape = OrthogonalEdgeShape;
7141
6810
  exports.StraightEdgeShape = StraightEdgeShape;
7142
- exports.VerticalEdgeShape = VerticalEdgeShape;
7143
- exports.boxPortOffsetFn = boxPortOffsetFn;
7144
6811
  });