@html-graph/html-graph 8.22.0 → 8.24.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.
@@ -81,7 +81,7 @@ var CoreHtmlView = class {
81
81
  this.attachedNodeIds.delete(nodeId);
82
82
  }
83
83
  attachEdge(edgeId) {
84
- const svg = this.graphStore.getEdge(edgeId).payload.shape.svg;
84
+ const svg = this.graphStore.getEdge(edgeId).payload.shape.element;
85
85
  this.edgeIdToElementMap.set(edgeId, svg);
86
86
  this.container.appendChild(svg);
87
87
  this.renderEdge(edgeId);
@@ -123,7 +123,7 @@ var CoreHtmlView = class {
123
123
  updateEdgeShape(edgeId) {
124
124
  const element = this.edgeIdToElementMap.get(edgeId);
125
125
  this.container.removeChild(element);
126
- const svg = this.graphStore.getEdge(edgeId).payload.shape.svg;
126
+ const svg = this.graphStore.getEdge(edgeId).payload.shape.element;
127
127
  this.edgeIdToElementMap.set(edgeId, svg);
128
128
  this.container.appendChild(svg);
129
129
  }
@@ -148,7 +148,7 @@ var CoreHtmlView = class {
148
148
  }
149
149
  updateEdgePriority(edgeId) {
150
150
  const edge = this.graphStore.getEdge(edgeId);
151
- edge.payload.shape.svg.style.zIndex = `${edge.payload.priority}`;
151
+ edge.payload.shape.element.style.zIndex = `${edge.payload.priority}`;
152
152
  }
153
153
  createEdgeRenderPort(port, rectPort, rectCanvas, scale) {
154
154
  const contentPoint = this.viewportStore.createContentCoords({
@@ -757,7 +757,7 @@ var GraphStore = class {
757
757
  if (this.hasEdge(request.id)) throw new CanvasError(canvasErrorText.addEdgeWithExistingId(request.id));
758
758
  if (!this.hasPort(request.from)) throw new CanvasError(canvasErrorText.addEdgeFromNonexistentPort(request.id, request.from));
759
759
  if (!this.hasPort(request.to)) throw new CanvasError(canvasErrorText.addEdgeToNonexistentPort(request.id, request.to));
760
- const useEdgeId = this.findEdgeIdByElement(request.shape.svg);
760
+ const useEdgeId = this.findEdgeIdByElement(request.shape.element);
761
761
  if (useEdgeId !== void 0) throw new CanvasError(canvasErrorText.addEdgeWithElementInUse(request.id, useEdgeId));
762
762
  this.addEdgeInternal(request);
763
763
  this.afterEdgeAddedEmitter.emit(request.id);
@@ -898,7 +898,7 @@ var GraphStore = class {
898
898
  priority: request.priority
899
899
  }
900
900
  });
901
- this.edgesElementsMap.set(request.shape.svg, request.id);
901
+ this.edgesElementsMap.set(request.shape.element, request.id);
902
902
  if (request.from !== request.to) {
903
903
  this.portOutgoingEdges.get(request.from).add(request.id);
904
904
  this.portIncomingEdges.get(request.to).add(request.id);
@@ -913,7 +913,7 @@ var GraphStore = class {
913
913
  this.portOutgoingEdges.get(from).delete(edgeId);
914
914
  this.portOutgoingEdges.get(to).delete(edgeId);
915
915
  this.edges.delete(edgeId);
916
- this.edgesElementsMap.delete(payload.shape.svg);
916
+ this.edgesElementsMap.delete(payload.shape.element);
917
917
  }
918
918
  };
919
919
  //#endregion
@@ -1388,13 +1388,13 @@ var createRoundedPath = (path, roundness) => {
1388
1388
  return parts.join(" ");
1389
1389
  };
1390
1390
  //#endregion
1391
- //#region src/edges/paths/horizontal-edge-path/create-line/create-line.ts
1392
- var createLine$1 = (from, to) => {
1391
+ //#region src/edges/paths/shared/create-horizontal-line/create-horizontal-line.ts
1392
+ var createHorizontalLine = (from, to) => {
1393
1393
  const fromLine = from.linePoint;
1394
1394
  const toLine = to.linePoint;
1395
1395
  const horizontalLineDir = toLine.x - fromLine.x >= 0;
1396
- const fromPortDir = from.dirX >= 0;
1397
- if (fromPortDir === to.dirX >= 0) {
1396
+ const fromPortDir = from.dir.x >= 0;
1397
+ if (fromPortDir === to.dir.x >= 0) {
1398
1398
  const isSameDirLine = fromPortDir === horizontalLineDir;
1399
1399
  const midpoint = {
1400
1400
  x: (fromLine.x + toLine.x) / 2,
@@ -1471,6 +1471,198 @@ var createLine$1 = (from, to) => {
1471
1471
  };
1472
1472
  };
1473
1473
  //#endregion
1474
+ //#region src/edges/paths/shared/shared/transpose-point/transpose-point.ts
1475
+ var transposePoint = (point) => {
1476
+ return {
1477
+ x: point.y,
1478
+ y: point.x
1479
+ };
1480
+ };
1481
+ //#endregion
1482
+ //#region src/edges/paths/shared/create-vertical-line/create-vertical-line.ts
1483
+ var createVerticalLine = (from, to) => {
1484
+ const transposedLine = createHorizontalLine({
1485
+ arrowPoint: transposePoint(from.arrowPoint),
1486
+ linePoint: transposePoint(from.linePoint),
1487
+ dir: transposePoint(from.dir)
1488
+ }, {
1489
+ arrowPoint: transposePoint(to.arrowPoint),
1490
+ linePoint: transposePoint(to.linePoint),
1491
+ dir: transposePoint(to.dir)
1492
+ });
1493
+ return {
1494
+ points: transposedLine.points.map((p) => transposePoint(p)),
1495
+ midpoint: transposePoint(transposedLine.midpoint)
1496
+ };
1497
+ };
1498
+ //#endregion
1499
+ //#region src/edges/paths/shared/create-horizontal-source-orthogonal-line/calculate-midpoint/calculate-midpoint.ts
1500
+ var calculateMidpoint = (points) => {
1501
+ const parts = [];
1502
+ for (let i = 1; i < points.length; i++) {
1503
+ const start = points[i - 1];
1504
+ const end = points[i];
1505
+ const dx = end.x - start.x;
1506
+ const dy = end.y - start.y;
1507
+ const distance = Math.sqrt(dx * dx + dy * dy);
1508
+ parts.push({
1509
+ start,
1510
+ end,
1511
+ distance
1512
+ });
1513
+ }
1514
+ const halfLength = parts.reduce((acc, cur) => acc + cur.distance, 0) / 2;
1515
+ let accLength = 0;
1516
+ for (const part of parts) {
1517
+ const nextAccLength = accLength + part.distance;
1518
+ if (nextAccLength >= halfLength) {
1519
+ const residue = halfLength - accLength;
1520
+ const { start, end, distance } = part;
1521
+ if (distance === 0) continue;
1522
+ const ratio = residue / distance;
1523
+ const dx = end.x - start.x;
1524
+ const dy = end.y - start.y;
1525
+ return {
1526
+ x: start.x + dx * ratio,
1527
+ y: start.y + dy * ratio
1528
+ };
1529
+ }
1530
+ accLength = nextAccLength;
1531
+ }
1532
+ if (accLength === 0 && points.length > 0) return points[0];
1533
+ throw new Error("Failed to calculate midpoint");
1534
+ };
1535
+ //#endregion
1536
+ //#region src/edges/paths/shared/create-horizontal-source-orthogonal-line/create-horizontal-source-orthogonal-line.ts
1537
+ var createHorizontalSourceOrthogonalLine = (from, to) => {
1538
+ const fromLine = from.linePoint;
1539
+ const fromArrow = from.arrowPoint;
1540
+ const toLine = to.linePoint;
1541
+ const toArrow = to.arrowPoint;
1542
+ const targetPortDir = to.dir.y >= 0;
1543
+ const sourcePortDir = from.dir.x >= 0;
1544
+ const verticalLineDir = toLine.y - fromLine.y >= 0;
1545
+ const isSameSourceHorizontal = sourcePortDir === toLine.x - fromLine.x >= 0;
1546
+ const isSameTargetVertical = targetPortDir === verticalLineDir;
1547
+ if (isSameSourceHorizontal) {
1548
+ if (isSameTargetVertical) {
1549
+ const joint = {
1550
+ x: toArrow.x,
1551
+ y: fromArrow.y
1552
+ };
1553
+ return {
1554
+ points: [
1555
+ fromArrow,
1556
+ joint,
1557
+ toArrow
1558
+ ],
1559
+ midpoint: calculateMidpoint([
1560
+ fromLine,
1561
+ joint,
1562
+ toLine
1563
+ ])
1564
+ };
1565
+ }
1566
+ const middleX = (fromLine.x + toLine.x) / 2;
1567
+ const jointStart = {
1568
+ x: middleX,
1569
+ y: fromLine.y
1570
+ };
1571
+ const jointEnd = {
1572
+ x: middleX,
1573
+ y: toLine.y
1574
+ };
1575
+ return {
1576
+ points: [
1577
+ fromArrow,
1578
+ jointStart,
1579
+ jointEnd,
1580
+ toLine,
1581
+ toArrow
1582
+ ],
1583
+ midpoint: calculateMidpoint([
1584
+ fromLine,
1585
+ jointStart,
1586
+ jointEnd,
1587
+ toLine
1588
+ ])
1589
+ };
1590
+ }
1591
+ if (isSameTargetVertical) {
1592
+ const middleY = (fromLine.y + toLine.y) / 2;
1593
+ const jointStart = {
1594
+ x: fromLine.x,
1595
+ y: middleY
1596
+ };
1597
+ const jointEnd = {
1598
+ x: toLine.x,
1599
+ y: middleY
1600
+ };
1601
+ return {
1602
+ points: [
1603
+ fromArrow,
1604
+ fromLine,
1605
+ jointStart,
1606
+ jointEnd,
1607
+ toArrow
1608
+ ],
1609
+ midpoint: calculateMidpoint([
1610
+ fromLine,
1611
+ jointStart,
1612
+ jointEnd,
1613
+ toLine
1614
+ ])
1615
+ };
1616
+ }
1617
+ const joint = {
1618
+ x: fromLine.x,
1619
+ y: toLine.y
1620
+ };
1621
+ return {
1622
+ points: [
1623
+ fromArrow,
1624
+ fromLine,
1625
+ joint,
1626
+ toLine,
1627
+ toArrow
1628
+ ],
1629
+ midpoint: calculateMidpoint([
1630
+ fromLine,
1631
+ joint,
1632
+ toLine
1633
+ ])
1634
+ };
1635
+ };
1636
+ //#endregion
1637
+ //#region src/edges/paths/shared/create-vertical-source-orthogonal-line/create-vertical-source-orthogonal-line.ts
1638
+ var createVerticalSourceOrthogonalLine = (from, to) => {
1639
+ const transposedLine = createHorizontalSourceOrthogonalLine({
1640
+ arrowPoint: transposePoint(from.arrowPoint),
1641
+ linePoint: transposePoint(from.linePoint),
1642
+ dir: transposePoint(from.dir)
1643
+ }, {
1644
+ arrowPoint: transposePoint(to.arrowPoint),
1645
+ linePoint: transposePoint(to.linePoint),
1646
+ dir: transposePoint(to.dir)
1647
+ });
1648
+ return {
1649
+ points: transposedLine.points.map((p) => transposePoint(p)),
1650
+ midpoint: transposePoint(transposedLine.midpoint)
1651
+ };
1652
+ };
1653
+ //#endregion
1654
+ //#region src/edges/paths/shared/create-orthogonal-line/create-orthogonal-line.ts
1655
+ var createOrthogonalLine = (from, to) => {
1656
+ const isSourceHor = Math.abs(from.dir.y) < 1e-10;
1657
+ const isTargetHor = Math.abs(to.dir.y) < 1e-10;
1658
+ if (isSourceHor) {
1659
+ if (isTargetHor) return createHorizontalLine(from, to);
1660
+ return createHorizontalSourceOrthogonalLine(from, to);
1661
+ }
1662
+ if (!isTargetHor) return createVerticalLine(from, to);
1663
+ return createVerticalSourceOrthogonalLine(from, to);
1664
+ };
1665
+ //#endregion
1474
1666
  //#region src/edges/paths/horizontal-edge-path/horizontal-edge-path.ts
1475
1667
  var HorizontalEdgePath = class {
1476
1668
  path;
@@ -1494,14 +1686,14 @@ var HorizontalEdgePath = class {
1494
1686
  x: to.x - gap,
1495
1687
  y: to.y
1496
1688
  }, toDir, to);
1497
- const line = createLine$1({
1689
+ const line = createHorizontalLine({
1498
1690
  arrowPoint: beginArrow,
1499
1691
  linePoint: beginLine,
1500
- dirX: fromDir.x
1692
+ dir: fromDir
1501
1693
  }, {
1502
1694
  arrowPoint: endArrow,
1503
1695
  linePoint: endLine,
1504
- dirX: toDir.x
1696
+ dir: toDir
1505
1697
  });
1506
1698
  this.path = createRoundedPath(line.points, roundness);
1507
1699
  this.midpoint = line.midpoint;
@@ -1595,89 +1787,6 @@ var StraightEdgePath = class {
1595
1787
  }
1596
1788
  };
1597
1789
  //#endregion
1598
- //#region src/edges/paths/vertical-edge-path/create-line/create-line.ts
1599
- var createLine = (from, to) => {
1600
- const fromLine = from.linePoint;
1601
- const toLine = to.linePoint;
1602
- const verticalLineDir = toLine.y - fromLine.y >= 0;
1603
- const fromPortDir = from.dirY >= 0;
1604
- if (fromPortDir === to.dirY >= 0) {
1605
- const isSameDirLine = fromPortDir === verticalLineDir;
1606
- const midpoint = {
1607
- x: (fromLine.x + toLine.x) / 2,
1608
- y: (fromLine.y + toLine.y) / 2
1609
- };
1610
- if (isSameDirLine) return {
1611
- points: [
1612
- from.arrowPoint,
1613
- {
1614
- x: fromLine.x,
1615
- y: midpoint.y
1616
- },
1617
- {
1618
- x: toLine.x,
1619
- y: midpoint.y
1620
- },
1621
- to.arrowPoint
1622
- ],
1623
- midpoint
1624
- };
1625
- return {
1626
- points: [
1627
- from.arrowPoint,
1628
- fromLine,
1629
- {
1630
- x: midpoint.x,
1631
- y: fromLine.y
1632
- },
1633
- {
1634
- x: midpoint.x,
1635
- y: toLine.y
1636
- },
1637
- toLine,
1638
- to.arrowPoint
1639
- ],
1640
- midpoint
1641
- };
1642
- }
1643
- const isSameSourceDir = fromPortDir === verticalLineDir;
1644
- const centerX = (fromLine.x + toLine.x) / 2;
1645
- if (isSameSourceDir) {
1646
- const joint = {
1647
- x: fromLine.x,
1648
- y: toLine.y
1649
- };
1650
- return {
1651
- points: [
1652
- from.arrowPoint,
1653
- joint,
1654
- toLine,
1655
- to.arrowPoint
1656
- ],
1657
- midpoint: {
1658
- x: centerX,
1659
- y: joint.y
1660
- }
1661
- };
1662
- }
1663
- const joint = {
1664
- x: toLine.x,
1665
- y: fromLine.y
1666
- };
1667
- return {
1668
- points: [
1669
- from.arrowPoint,
1670
- fromLine,
1671
- joint,
1672
- to.arrowPoint
1673
- ],
1674
- midpoint: {
1675
- x: centerX,
1676
- y: joint.y
1677
- }
1678
- };
1679
- };
1680
- //#endregion
1681
1790
  //#region src/edges/paths/vertical-edge-path/vertical-edge-path.ts
1682
1791
  var VerticalEdgePath = class {
1683
1792
  path;
@@ -1701,14 +1810,51 @@ var VerticalEdgePath = class {
1701
1810
  x: to.x - gap,
1702
1811
  y: to.y
1703
1812
  }, toDir, to);
1704
- const line = createLine({
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
+ //#region src/edges/paths/orthogonal-edge-path/orthogonal-edge-path.ts
1828
+ var OrthogonalEdgePath = class {
1829
+ path;
1830
+ midpoint;
1831
+ constructor(params) {
1832
+ const { from, to, fromDir, toDir, arrowLength, arrowOffset, roundness, hasSourceArrow, hasTargetArrow } = params;
1833
+ const beginArrow = hasSourceArrow ? createRotatedPoint({
1834
+ x: from.x + arrowLength,
1835
+ y: from.y
1836
+ }, fromDir, from) : from;
1837
+ const endArrow = hasTargetArrow ? createRotatedPoint({
1838
+ x: to.x - arrowLength,
1839
+ y: to.y
1840
+ }, toDir, to) : to;
1841
+ const gap = arrowLength + arrowOffset;
1842
+ const beginLine = createRotatedPoint({
1843
+ x: from.x + gap,
1844
+ y: from.y
1845
+ }, fromDir, from);
1846
+ const endLine = createRotatedPoint({
1847
+ x: to.x - gap,
1848
+ y: to.y
1849
+ }, toDir, to);
1850
+ const line = createOrthogonalLine({
1705
1851
  arrowPoint: beginArrow,
1706
1852
  linePoint: beginLine,
1707
- dirY: fromDir.y
1853
+ dir: fromDir
1708
1854
  }, {
1709
1855
  arrowPoint: endArrow,
1710
1856
  linePoint: endLine,
1711
- dirY: toDir.y
1857
+ dir: toDir
1712
1858
  });
1713
1859
  this.path = createRoundedPath(line.points, roundness);
1714
1860
  this.midpoint = line.midpoint;
@@ -1924,6 +2070,31 @@ var DetourVerticalEdgePath = class {
1924
2070
  }
1925
2071
  };
1926
2072
  //#endregion
2073
+ //#region src/edges/paths/detour-orthogonal-edge-path/detour-orthogonal-edge-shape.ts
2074
+ var DetourOrthogonalEdgePath = class {
2075
+ path;
2076
+ midpoint;
2077
+ constructor(params) {
2078
+ const isSourceHor = Math.abs(params.fromDir.y) < 1e-10;
2079
+ const isTargetHor = Math.abs(params.toDir.y) < 1e-10;
2080
+ if (isSourceHor && isTargetHor) {
2081
+ const path = new DetourHorizontalEdgePath(params);
2082
+ this.path = path.path;
2083
+ this.midpoint = path.midpoint;
2084
+ return;
2085
+ }
2086
+ if (!isSourceHor && !isTargetHor) {
2087
+ const path = new DetourVerticalEdgePath(params);
2088
+ this.path = path.path;
2089
+ this.midpoint = path.midpoint;
2090
+ return;
2091
+ }
2092
+ const path = new OrthogonalEdgePath(params);
2093
+ this.path = path.path;
2094
+ this.midpoint = path.midpoint;
2095
+ }
2096
+ };
2097
+ //#endregion
1927
2098
  //#region src/edges/edge-constants.ts
1928
2099
  var edgeConstants = Object.freeze({
1929
2100
  color: "#777777",
@@ -1960,6 +2131,7 @@ var createDirectionVector = (dir) => {
1960
2131
  //#region src/edges/shapes/path-edge-shape/path-edge-shape.ts
1961
2132
  var PathEdgeShape = class {
1962
2133
  params;
2134
+ element;
1963
2135
  svg;
1964
2136
  group = document.createElementNS("http://www.w3.org/2000/svg", "g");
1965
2137
  line;
@@ -1972,8 +2144,9 @@ var PathEdgeShape = class {
1972
2144
  this.params = params;
1973
2145
  [this.afterRenderEmitter, this.onAfterRender] = createPair();
1974
2146
  this.arrowRenderer = this.params.arrowRenderer;
1975
- this.svg = createEdgeSvg(params.color);
1976
- this.svg.appendChild(this.group);
2147
+ this.element = createEdgeSvg(params.color);
2148
+ this.svg = this.element;
2149
+ this.element.appendChild(this.group);
1977
2150
  this.line = createEdgePath(params.width);
1978
2151
  this.group.appendChild(this.line);
1979
2152
  if (params.hasSourceArrow) {
@@ -1987,7 +2160,7 @@ var PathEdgeShape = class {
1987
2160
  }
1988
2161
  render(params) {
1989
2162
  const { x, y, width, height, from, to } = createEdgeRectangle(params.from, params.to, this.params.padding);
1990
- setSvgRectangle(this.svg, {
2163
+ setSvgRectangle(this.element, {
1991
2164
  x,
1992
2165
  y,
1993
2166
  width,
@@ -2145,6 +2318,7 @@ var resolveArrowRenderer = (config) => {
2145
2318
  //#endregion
2146
2319
  //#region src/edges/shapes/bezier-edge-shape/bezier-edge-shape.ts
2147
2320
  var BezierEdgeShape = class {
2321
+ element;
2148
2322
  svg;
2149
2323
  group;
2150
2324
  line;
@@ -2211,7 +2385,8 @@ var BezierEdgeShape = class {
2211
2385
  createLinePath: this.createLinePath,
2212
2386
  padding: 50
2213
2387
  });
2214
- this.svg = this.pathShape.svg;
2388
+ this.element = this.pathShape.element;
2389
+ this.svg = this.element;
2215
2390
  this.group = this.pathShape.group;
2216
2391
  this.line = this.pathShape.line;
2217
2392
  this.sourceArrow = this.pathShape.sourceArrow;
@@ -2229,7 +2404,12 @@ var horizontalizeDirection = (direction) => {
2229
2404
  };
2230
2405
  //#endregion
2231
2406
  //#region src/edges/shapes/horizontal-edge-shape/horizontal-edge-shape.ts
2407
+ /**
2408
+ * @deprecated
2409
+ * use OrthogonalEdgeShape instead
2410
+ */
2232
2411
  var HorizontalEdgeShape = class {
2412
+ element;
2233
2413
  svg;
2234
2414
  group;
2235
2415
  line;
@@ -2297,7 +2477,8 @@ var HorizontalEdgeShape = class {
2297
2477
  createLinePath: this.createLinePath,
2298
2478
  padding: 50
2299
2479
  });
2300
- this.svg = this.pathShape.svg;
2480
+ this.element = this.pathShape.element;
2481
+ this.svg = this.element;
2301
2482
  this.group = this.pathShape.group;
2302
2483
  this.line = this.pathShape.line;
2303
2484
  this.sourceArrow = this.pathShape.sourceArrow;
@@ -2322,6 +2503,7 @@ var HorizontalEdgeShape = class {
2322
2503
  //#endregion
2323
2504
  //#region src/edges/shapes/straight-edge-shape/straight-edge-shape.ts
2324
2505
  var StraightEdgeShape = class {
2506
+ element;
2325
2507
  svg;
2326
2508
  group;
2327
2509
  line;
@@ -2392,7 +2574,8 @@ var StraightEdgeShape = class {
2392
2574
  createLinePath: this.createLinePath,
2393
2575
  padding: 50
2394
2576
  });
2395
- this.svg = this.pathShape.svg;
2577
+ this.element = this.pathShape.element;
2578
+ this.svg = this.element;
2396
2579
  this.group = this.pathShape.group;
2397
2580
  this.line = this.pathShape.line;
2398
2581
  this.sourceArrow = this.pathShape.sourceArrow;
@@ -2411,7 +2594,12 @@ var verticalizeDirection = (direction) => {
2411
2594
  };
2412
2595
  //#endregion
2413
2596
  //#region src/edges/shapes/vertical-edge-shape/vertical-edge-shape.ts
2597
+ /**
2598
+ * @deprecated
2599
+ * use OrthogonalEdgeShape instead
2600
+ */
2414
2601
  var VerticalEdgeShape = class {
2602
+ element;
2415
2603
  svg;
2416
2604
  group;
2417
2605
  line;
@@ -2479,7 +2667,8 @@ var VerticalEdgeShape = class {
2479
2667
  createLinePath: this.createLinePath,
2480
2668
  padding: 50
2481
2669
  });
2482
- this.svg = this.pathShape.svg;
2670
+ this.element = this.pathShape.element;
2671
+ this.svg = this.element;
2483
2672
  this.group = this.pathShape.group;
2484
2673
  this.line = this.pathShape.line;
2485
2674
  this.sourceArrow = this.pathShape.sourceArrow;
@@ -2502,6 +2691,113 @@ var VerticalEdgeShape = class {
2502
2691
  }
2503
2692
  };
2504
2693
  //#endregion
2694
+ //#region src/edges/shapes/orthogonal-edge-shape/orthogonalize-direction/orthogonalize-direction.ts
2695
+ var orthogonalizeDirection = (direction) => {
2696
+ const adjDir = direction + Math.PI / 4;
2697
+ const adjCos = Math.cos(adjDir);
2698
+ const adjSin = Math.sin(adjDir);
2699
+ if (adjCos > 0) {
2700
+ if (adjSin > 0) return 0;
2701
+ return -Math.PI / 2;
2702
+ }
2703
+ if (adjSin > 0) return Math.PI / 2;
2704
+ return Math.PI;
2705
+ };
2706
+ //#endregion
2707
+ //#region src/edges/shapes/orthogonal-edge-shape/orthogonal-edge-shape.ts
2708
+ var OrthogonalEdgeShape = class {
2709
+ element;
2710
+ svg;
2711
+ group;
2712
+ line;
2713
+ sourceArrow;
2714
+ targetArrow;
2715
+ onAfterRender;
2716
+ arrowLength;
2717
+ arrowOffset;
2718
+ roundness;
2719
+ cycleSquareSide;
2720
+ detourDistance;
2721
+ hasSourceArrow;
2722
+ hasTargetArrow;
2723
+ pathShape;
2724
+ createCyclePath = (from, _to, fromDir) => new CycleSquareEdgePath({
2725
+ origin: from,
2726
+ dir: fromDir,
2727
+ arrowLength: this.arrowLength,
2728
+ side: this.cycleSquareSide,
2729
+ arrowOffset: this.arrowOffset,
2730
+ roundness: this.roundness,
2731
+ hasArrow: this.hasSourceArrow || this.hasTargetArrow
2732
+ });
2733
+ createDetourPath = (from, to, fromDir, toDir) => new DetourOrthogonalEdgePath({
2734
+ from,
2735
+ to,
2736
+ fromDir,
2737
+ toDir,
2738
+ arrowLength: this.arrowLength,
2739
+ arrowOffset: this.arrowOffset,
2740
+ roundness: this.roundness,
2741
+ detourDistance: this.detourDistance,
2742
+ hasSourceArrow: this.hasSourceArrow,
2743
+ hasTargetArrow: this.hasTargetArrow
2744
+ });
2745
+ createLinePath = (from, to, fromDir, toDir) => new OrthogonalEdgePath({
2746
+ from,
2747
+ to,
2748
+ fromDir,
2749
+ toDir,
2750
+ arrowLength: this.arrowLength,
2751
+ arrowOffset: this.arrowOffset,
2752
+ roundness: this.roundness,
2753
+ hasSourceArrow: this.hasSourceArrow,
2754
+ hasTargetArrow: this.hasTargetArrow
2755
+ });
2756
+ constructor(params) {
2757
+ this.arrowLength = params?.arrowLength ?? edgeConstants.arrowLength;
2758
+ this.arrowOffset = params?.arrowOffset ?? edgeConstants.arrowOffset;
2759
+ this.cycleSquareSide = params?.cycleSquareSide ?? edgeConstants.cycleSquareSide;
2760
+ const roundness = params?.roundness ?? edgeConstants.roundness;
2761
+ this.roundness = Math.min(roundness, this.arrowOffset, this.cycleSquareSide / 2);
2762
+ this.detourDistance = params?.detourDistance ?? edgeConstants.detourDistance;
2763
+ this.hasSourceArrow = params?.hasSourceArrow ?? edgeConstants.hasSourceArrow;
2764
+ this.hasTargetArrow = params?.hasTargetArrow ?? edgeConstants.hasTargetArrow;
2765
+ this.pathShape = new PathEdgeShape({
2766
+ color: params?.color ?? edgeConstants.color,
2767
+ width: params?.width ?? edgeConstants.width,
2768
+ arrowRenderer: resolveArrowRenderer(params?.arrowRenderer ?? {}),
2769
+ arrowLength: this.arrowLength,
2770
+ hasSourceArrow: this.hasSourceArrow,
2771
+ hasTargetArrow: this.hasTargetArrow,
2772
+ createCyclePath: this.createCyclePath,
2773
+ createDetourPath: this.createDetourPath,
2774
+ createLinePath: this.createLinePath,
2775
+ padding: 50
2776
+ });
2777
+ this.element = this.pathShape.element;
2778
+ this.svg = this.element;
2779
+ this.group = this.pathShape.group;
2780
+ this.line = this.pathShape.line;
2781
+ this.sourceArrow = this.pathShape.sourceArrow;
2782
+ this.targetArrow = this.pathShape.targetArrow;
2783
+ this.onAfterRender = this.pathShape.onAfterRender;
2784
+ }
2785
+ render(params) {
2786
+ const { from, to, category } = params;
2787
+ this.pathShape.render({
2788
+ category,
2789
+ from: {
2790
+ ...from,
2791
+ direction: orthogonalizeDirection(from.direction)
2792
+ },
2793
+ to: {
2794
+ ...to,
2795
+ direction: orthogonalizeDirection(to.direction)
2796
+ }
2797
+ });
2798
+ }
2799
+ };
2800
+ //#endregion
2505
2801
  //#region src/edges/shapes/direct-edge-shape/resolve-port-offset-fn/box-port-offset-fn/box-port-offset-fn.ts
2506
2802
  var boxPortOffsetFn = (params) => {
2507
2803
  const { direction, radius } = params;
@@ -2525,6 +2821,7 @@ var resolvePortOffsetFn = (offset) => {
2525
2821
  //#region src/edges/shapes/direct-edge-shape/direct-edge-shape.ts
2526
2822
  var defaultPortOffset = edgeConstants.portOffset;
2527
2823
  var DirectEdgeShape = class {
2824
+ element;
2528
2825
  svg;
2529
2826
  group = document.createElementNS("http://www.w3.org/2000/svg", "g");
2530
2827
  line;
@@ -2546,8 +2843,9 @@ var DirectEdgeShape = class {
2546
2843
  this.arrowRenderer = resolveArrowRenderer(params?.arrowRenderer ?? {});
2547
2844
  this.sourceOffsetFn = resolvePortOffsetFn(params?.sourceOffset ?? defaultPortOffset);
2548
2845
  this.targetOffsetFn = resolvePortOffsetFn(params?.targetOffset ?? defaultPortOffset);
2549
- this.svg = createEdgeSvg(this.color);
2550
- this.svg.appendChild(this.group);
2846
+ this.element = createEdgeSvg(this.color);
2847
+ this.svg = this.element;
2848
+ this.element.appendChild(this.group);
2551
2849
  this.line = createEdgePath(this.width);
2552
2850
  this.group.appendChild(this.line);
2553
2851
  if (params?.hasSourceArrow) {
@@ -2561,7 +2859,7 @@ var DirectEdgeShape = class {
2561
2859
  }
2562
2860
  render(params) {
2563
2861
  const { x, y, width, height, from, to } = createEdgeRectangle(params.from, params.to, 50);
2564
- setSvgRectangle(this.svg, {
2862
+ setSvgRectangle(this.element, {
2565
2863
  x,
2566
2864
  y,
2567
2865
  width,
@@ -2726,6 +3024,7 @@ var InteractiveEdgeError = class extends Error {
2726
3024
  //#region src/edges/shapes/interactive-edge-shape/interactive-edge-shape.ts
2727
3025
  var InteractiveEdgeShape = class InteractiveEdgeShape {
2728
3026
  baseEdge;
3027
+ element;
2729
3028
  svg;
2730
3029
  group;
2731
3030
  line;
@@ -2743,7 +3042,8 @@ var InteractiveEdgeShape = class InteractiveEdgeShape {
2743
3042
  constructor(baseEdge, params) {
2744
3043
  this.baseEdge = baseEdge;
2745
3044
  if (baseEdge instanceof InteractiveEdgeShape) throw new InteractiveEdgeError("interactive edge can be configured only once");
2746
- this.svg = this.baseEdge.svg;
3045
+ this.element = this.baseEdge.element;
3046
+ this.svg = this.element;
2747
3047
  this.group = this.baseEdge.group;
2748
3048
  this.line = this.baseEdge.line;
2749
3049
  this.sourceArrow = this.baseEdge.sourceArrow;
@@ -2781,17 +3081,19 @@ var MidpointEdgeShape = class {
2781
3081
  sourceArrow;
2782
3082
  targetArrow;
2783
3083
  onAfterRender;
3084
+ element;
2784
3085
  svg;
2785
3086
  constructor(baseShape, midpointElement) {
2786
3087
  this.baseShape = baseShape;
2787
3088
  this.midpointElement = midpointElement;
2788
- this.svg = this.baseShape.svg;
3089
+ this.element = this.baseShape.element;
3090
+ this.svg = this.element;
2789
3091
  this.group = this.baseShape.group;
2790
3092
  this.line = this.baseShape.line;
2791
3093
  this.sourceArrow = this.baseShape.sourceArrow;
2792
3094
  this.targetArrow = this.baseShape.targetArrow;
2793
3095
  this.onAfterRender = this.baseShape.onAfterRender;
2794
- this.svg.append(this.midpointElement);
3096
+ this.element.append(this.midpointElement);
2795
3097
  this.baseShape.onAfterRender.subscribe((model) => {
2796
3098
  const midpoint = model.edgePath.midpoint;
2797
3099
  const transform = `translate(${midpoint.x}px, ${midpoint.y}px)`;
@@ -4797,16 +5099,16 @@ var UserSelectableEdgesConfigurator = class UserSelectableEdgesConfigurator {
4797
5099
  onEdgeSelected;
4798
5100
  onAfterEdgeAdded = (edgeId) => {
4799
5101
  const { shape } = this.canvas.graph.getEdge(edgeId);
4800
- this.configurator.enable(shape.svg);
5102
+ this.configurator.enable(shape.element);
4801
5103
  };
4802
5104
  onBeforeEdgeRemoved = (edgeId) => {
4803
5105
  const { shape } = this.canvas.graph.getEdge(edgeId);
4804
- this.configurator.disable(shape.svg);
5106
+ this.configurator.disable(shape.element);
4805
5107
  };
4806
5108
  reset = () => {
4807
5109
  this.canvas.graph.getAllEdgeIds().forEach((edgeId) => {
4808
5110
  const { shape } = this.canvas.graph.getEdge(edgeId);
4809
- this.configurator.disable(shape.svg);
5111
+ this.configurator.disable(shape.element);
4810
5112
  });
4811
5113
  };
4812
5114
  constructor(canvas, window, pointInsideVerifier, eventTagger, params) {
@@ -4994,6 +5296,18 @@ var resolveEdgeShapeFactory = (config) => {
4994
5296
  roundness: config.roundness,
4995
5297
  detourDistance: config.detourDistance
4996
5298
  });
5299
+ case "orthogonal": return () => new OrthogonalEdgeShape({
5300
+ color: config.color,
5301
+ width: config.width,
5302
+ arrowLength: config.arrowLength,
5303
+ arrowOffset: config.arrowOffset,
5304
+ arrowRenderer: config.arrowRenderer,
5305
+ hasSourceArrow: config.hasSourceArrow,
5306
+ hasTargetArrow: config.hasTargetArrow,
5307
+ cycleSquareSide: config.cycleSquareSide,
5308
+ roundness: config.roundness,
5309
+ detourDistance: config.detourDistance
5310
+ });
4997
5311
  case "direct": return () => new DirectEdgeShape({
4998
5312
  color: config.color,
4999
5313
  width: config.width,
@@ -5078,28 +5392,24 @@ var createScaleLimitTransformPreprocessor = (preprocessorParams) => {
5078
5392
  const prev = params.prevTransform;
5079
5393
  const next = params.nextTransform;
5080
5394
  let nextScale = next.scale;
5081
- let nextDx = next.x;
5082
- let nextDy = next.y;
5395
+ let nextX = next.x;
5396
+ let nextY = next.y;
5083
5397
  if (next.scale > maxViewScale && next.scale > prev.scale) {
5084
5398
  nextScale = Math.max(prev.scale, maxViewScale);
5085
- nextDx = prev.x;
5086
- nextDy = prev.y;
5087
5399
  const ratio = (nextScale - prev.scale) / (next.scale - prev.scale);
5088
- nextDx = prev.x + (next.x - prev.x) * ratio;
5089
- nextDy = prev.y + (next.y - prev.y) * ratio;
5400
+ nextX = prev.x + (next.x - prev.x) * ratio;
5401
+ nextY = prev.y + (next.y - prev.y) * ratio;
5090
5402
  }
5091
5403
  if (next.scale < minViewScale && next.scale < prev.scale) {
5092
5404
  nextScale = Math.min(prev.scale, minViewScale);
5093
- nextDx = prev.x;
5094
- nextDy = prev.y;
5095
5405
  const ratio = (nextScale - prev.scale) / (next.scale - prev.scale);
5096
- nextDx = prev.x + (next.x - prev.x) * ratio;
5097
- nextDy = prev.y + (next.y - prev.y) * ratio;
5406
+ nextX = prev.x + (next.x - prev.x) * ratio;
5407
+ nextY = prev.y + (next.y - prev.y) * ratio;
5098
5408
  }
5099
5409
  return {
5100
5410
  scale: nextScale,
5101
- x: nextDx,
5102
- y: nextDy
5411
+ x: nextX,
5412
+ y: nextY
5103
5413
  };
5104
5414
  };
5105
5415
  };
@@ -6812,4 +7122,4 @@ var CanvasBuilder = class {
6812
7122
  }
6813
7123
  };
6814
7124
  //#endregion
6815
- export { BezierEdgeShape, CanvasBuilder, CanvasBuilderError, CanvasError, ConnectionCategory, DirectEdgeShape, EventSubject, HorizontalEdgeShape, InteractiveEdgeError, InteractiveEdgeShape, MidpointEdgeShape, StraightEdgeShape, VerticalEdgeShape, boxPortOffsetFn };
7125
+ export { BezierEdgeShape, CanvasBuilder, CanvasBuilderError, CanvasError, ConnectionCategory, DirectEdgeShape, EventSubject, HorizontalEdgeShape, InteractiveEdgeError, InteractiveEdgeShape, MidpointEdgeShape, OrthogonalEdgeShape, StraightEdgeShape, VerticalEdgeShape, boxPortOffsetFn };