@html-graph/html-graph 8.22.0 → 8.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html-graph.d.ts +64 -1
- package/dist/html-graph.js +398 -106
- package/dist/html-graph.min.js +698 -489
- package/dist/html-graph.min.umd.cjs +1 -1
- package/dist/html-graph.umd.cjs +398 -105
- package/package.json +1 -1
package/dist/html-graph.js
CHANGED
|
@@ -1388,13 +1388,13 @@ var createRoundedPath = (path, roundness) => {
|
|
|
1388
1388
|
return parts.join(" ");
|
|
1389
1389
|
};
|
|
1390
1390
|
//#endregion
|
|
1391
|
-
//#region src/edges/paths/
|
|
1392
|
-
var
|
|
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.
|
|
1397
|
-
if (fromPortDir === to.
|
|
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 =
|
|
1689
|
+
const line = createHorizontalLine({
|
|
1498
1690
|
arrowPoint: beginArrow,
|
|
1499
1691
|
linePoint: beginLine,
|
|
1500
|
-
|
|
1692
|
+
dir: fromDir
|
|
1501
1693
|
}, {
|
|
1502
1694
|
arrowPoint: endArrow,
|
|
1503
1695
|
linePoint: endLine,
|
|
1504
|
-
|
|
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 =
|
|
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
|
-
|
|
1853
|
+
dir: fromDir
|
|
1708
1854
|
}, {
|
|
1709
1855
|
arrowPoint: endArrow,
|
|
1710
1856
|
linePoint: endLine,
|
|
1711
|
-
|
|
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",
|
|
@@ -2229,6 +2400,10 @@ var horizontalizeDirection = (direction) => {
|
|
|
2229
2400
|
};
|
|
2230
2401
|
//#endregion
|
|
2231
2402
|
//#region src/edges/shapes/horizontal-edge-shape/horizontal-edge-shape.ts
|
|
2403
|
+
/**
|
|
2404
|
+
* @deprecated
|
|
2405
|
+
* use OrthogonalEdgeShape instead
|
|
2406
|
+
*/
|
|
2232
2407
|
var HorizontalEdgeShape = class {
|
|
2233
2408
|
svg;
|
|
2234
2409
|
group;
|
|
@@ -2411,6 +2586,10 @@ var verticalizeDirection = (direction) => {
|
|
|
2411
2586
|
};
|
|
2412
2587
|
//#endregion
|
|
2413
2588
|
//#region src/edges/shapes/vertical-edge-shape/vertical-edge-shape.ts
|
|
2589
|
+
/**
|
|
2590
|
+
* @deprecated
|
|
2591
|
+
* use OrthogonalEdgeShape instead
|
|
2592
|
+
*/
|
|
2414
2593
|
var VerticalEdgeShape = class {
|
|
2415
2594
|
svg;
|
|
2416
2595
|
group;
|
|
@@ -2502,6 +2681,111 @@ var VerticalEdgeShape = class {
|
|
|
2502
2681
|
}
|
|
2503
2682
|
};
|
|
2504
2683
|
//#endregion
|
|
2684
|
+
//#region src/edges/shapes/orthogonal-edge-shape/orthogonalize-direction/orthogonalize-direction.ts
|
|
2685
|
+
var orthogonalizeDirection = (direction) => {
|
|
2686
|
+
const adjDir = direction + Math.PI / 4;
|
|
2687
|
+
const adjCos = Math.cos(adjDir);
|
|
2688
|
+
const adjSin = Math.sin(adjDir);
|
|
2689
|
+
if (adjCos > 0) {
|
|
2690
|
+
if (adjSin > 0) return 0;
|
|
2691
|
+
return -Math.PI / 2;
|
|
2692
|
+
}
|
|
2693
|
+
if (adjSin > 0) return Math.PI / 2;
|
|
2694
|
+
return Math.PI;
|
|
2695
|
+
};
|
|
2696
|
+
//#endregion
|
|
2697
|
+
//#region src/edges/shapes/orthogonal-edge-shape/orthogonal-edge-shape.ts
|
|
2698
|
+
var OrthogonalEdgeShape = class {
|
|
2699
|
+
svg;
|
|
2700
|
+
group;
|
|
2701
|
+
line;
|
|
2702
|
+
sourceArrow;
|
|
2703
|
+
targetArrow;
|
|
2704
|
+
onAfterRender;
|
|
2705
|
+
arrowLength;
|
|
2706
|
+
arrowOffset;
|
|
2707
|
+
roundness;
|
|
2708
|
+
cycleSquareSide;
|
|
2709
|
+
detourDistance;
|
|
2710
|
+
hasSourceArrow;
|
|
2711
|
+
hasTargetArrow;
|
|
2712
|
+
pathShape;
|
|
2713
|
+
createCyclePath = (from, _to, fromDir) => new CycleSquareEdgePath({
|
|
2714
|
+
origin: from,
|
|
2715
|
+
dir: fromDir,
|
|
2716
|
+
arrowLength: this.arrowLength,
|
|
2717
|
+
side: this.cycleSquareSide,
|
|
2718
|
+
arrowOffset: this.arrowOffset,
|
|
2719
|
+
roundness: this.roundness,
|
|
2720
|
+
hasArrow: this.hasSourceArrow || this.hasTargetArrow
|
|
2721
|
+
});
|
|
2722
|
+
createDetourPath = (from, to, fromDir, toDir) => new DetourOrthogonalEdgePath({
|
|
2723
|
+
from,
|
|
2724
|
+
to,
|
|
2725
|
+
fromDir,
|
|
2726
|
+
toDir,
|
|
2727
|
+
arrowLength: this.arrowLength,
|
|
2728
|
+
arrowOffset: this.arrowOffset,
|
|
2729
|
+
roundness: this.roundness,
|
|
2730
|
+
detourDistance: this.detourDistance,
|
|
2731
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2732
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2733
|
+
});
|
|
2734
|
+
createLinePath = (from, to, fromDir, toDir) => new OrthogonalEdgePath({
|
|
2735
|
+
from,
|
|
2736
|
+
to,
|
|
2737
|
+
fromDir,
|
|
2738
|
+
toDir,
|
|
2739
|
+
arrowLength: this.arrowLength,
|
|
2740
|
+
arrowOffset: this.arrowOffset,
|
|
2741
|
+
roundness: this.roundness,
|
|
2742
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2743
|
+
hasTargetArrow: this.hasTargetArrow
|
|
2744
|
+
});
|
|
2745
|
+
constructor(params) {
|
|
2746
|
+
this.arrowLength = params?.arrowLength ?? edgeConstants.arrowLength;
|
|
2747
|
+
this.arrowOffset = params?.arrowOffset ?? edgeConstants.arrowOffset;
|
|
2748
|
+
this.cycleSquareSide = params?.cycleSquareSide ?? edgeConstants.cycleSquareSide;
|
|
2749
|
+
const roundness = params?.roundness ?? edgeConstants.roundness;
|
|
2750
|
+
this.roundness = Math.min(roundness, this.arrowOffset, this.cycleSquareSide / 2);
|
|
2751
|
+
this.detourDistance = params?.detourDistance ?? edgeConstants.detourDistance;
|
|
2752
|
+
this.hasSourceArrow = params?.hasSourceArrow ?? edgeConstants.hasSourceArrow;
|
|
2753
|
+
this.hasTargetArrow = params?.hasTargetArrow ?? edgeConstants.hasTargetArrow;
|
|
2754
|
+
this.pathShape = new PathEdgeShape({
|
|
2755
|
+
color: params?.color ?? edgeConstants.color,
|
|
2756
|
+
width: params?.width ?? edgeConstants.width,
|
|
2757
|
+
arrowRenderer: resolveArrowRenderer(params?.arrowRenderer ?? {}),
|
|
2758
|
+
arrowLength: this.arrowLength,
|
|
2759
|
+
hasSourceArrow: this.hasSourceArrow,
|
|
2760
|
+
hasTargetArrow: this.hasTargetArrow,
|
|
2761
|
+
createCyclePath: this.createCyclePath,
|
|
2762
|
+
createDetourPath: this.createDetourPath,
|
|
2763
|
+
createLinePath: this.createLinePath,
|
|
2764
|
+
padding: 50
|
|
2765
|
+
});
|
|
2766
|
+
this.svg = this.pathShape.svg;
|
|
2767
|
+
this.group = this.pathShape.group;
|
|
2768
|
+
this.line = this.pathShape.line;
|
|
2769
|
+
this.sourceArrow = this.pathShape.sourceArrow;
|
|
2770
|
+
this.targetArrow = this.pathShape.targetArrow;
|
|
2771
|
+
this.onAfterRender = this.pathShape.onAfterRender;
|
|
2772
|
+
}
|
|
2773
|
+
render(params) {
|
|
2774
|
+
const { from, to, category } = params;
|
|
2775
|
+
this.pathShape.render({
|
|
2776
|
+
category,
|
|
2777
|
+
from: {
|
|
2778
|
+
...from,
|
|
2779
|
+
direction: orthogonalizeDirection(from.direction)
|
|
2780
|
+
},
|
|
2781
|
+
to: {
|
|
2782
|
+
...to,
|
|
2783
|
+
direction: orthogonalizeDirection(to.direction)
|
|
2784
|
+
}
|
|
2785
|
+
});
|
|
2786
|
+
}
|
|
2787
|
+
};
|
|
2788
|
+
//#endregion
|
|
2505
2789
|
//#region src/edges/shapes/direct-edge-shape/resolve-port-offset-fn/box-port-offset-fn/box-port-offset-fn.ts
|
|
2506
2790
|
var boxPortOffsetFn = (params) => {
|
|
2507
2791
|
const { direction, radius } = params;
|
|
@@ -4994,6 +5278,18 @@ var resolveEdgeShapeFactory = (config) => {
|
|
|
4994
5278
|
roundness: config.roundness,
|
|
4995
5279
|
detourDistance: config.detourDistance
|
|
4996
5280
|
});
|
|
5281
|
+
case "orthogonal": return () => new OrthogonalEdgeShape({
|
|
5282
|
+
color: config.color,
|
|
5283
|
+
width: config.width,
|
|
5284
|
+
arrowLength: config.arrowLength,
|
|
5285
|
+
arrowOffset: config.arrowOffset,
|
|
5286
|
+
arrowRenderer: config.arrowRenderer,
|
|
5287
|
+
hasSourceArrow: config.hasSourceArrow,
|
|
5288
|
+
hasTargetArrow: config.hasTargetArrow,
|
|
5289
|
+
cycleSquareSide: config.cycleSquareSide,
|
|
5290
|
+
roundness: config.roundness,
|
|
5291
|
+
detourDistance: config.detourDistance
|
|
5292
|
+
});
|
|
4997
5293
|
case "direct": return () => new DirectEdgeShape({
|
|
4998
5294
|
color: config.color,
|
|
4999
5295
|
width: config.width,
|
|
@@ -5078,28 +5374,24 @@ var createScaleLimitTransformPreprocessor = (preprocessorParams) => {
|
|
|
5078
5374
|
const prev = params.prevTransform;
|
|
5079
5375
|
const next = params.nextTransform;
|
|
5080
5376
|
let nextScale = next.scale;
|
|
5081
|
-
let
|
|
5082
|
-
let
|
|
5377
|
+
let nextX = next.x;
|
|
5378
|
+
let nextY = next.y;
|
|
5083
5379
|
if (next.scale > maxViewScale && next.scale > prev.scale) {
|
|
5084
5380
|
nextScale = Math.max(prev.scale, maxViewScale);
|
|
5085
|
-
nextDx = prev.x;
|
|
5086
|
-
nextDy = prev.y;
|
|
5087
5381
|
const ratio = (nextScale - prev.scale) / (next.scale - prev.scale);
|
|
5088
|
-
|
|
5089
|
-
|
|
5382
|
+
nextX = prev.x + (next.x - prev.x) * ratio;
|
|
5383
|
+
nextY = prev.y + (next.y - prev.y) * ratio;
|
|
5090
5384
|
}
|
|
5091
5385
|
if (next.scale < minViewScale && next.scale < prev.scale) {
|
|
5092
5386
|
nextScale = Math.min(prev.scale, minViewScale);
|
|
5093
|
-
nextDx = prev.x;
|
|
5094
|
-
nextDy = prev.y;
|
|
5095
5387
|
const ratio = (nextScale - prev.scale) / (next.scale - prev.scale);
|
|
5096
|
-
|
|
5097
|
-
|
|
5388
|
+
nextX = prev.x + (next.x - prev.x) * ratio;
|
|
5389
|
+
nextY = prev.y + (next.y - prev.y) * ratio;
|
|
5098
5390
|
}
|
|
5099
5391
|
return {
|
|
5100
5392
|
scale: nextScale,
|
|
5101
|
-
x:
|
|
5102
|
-
y:
|
|
5393
|
+
x: nextX,
|
|
5394
|
+
y: nextY
|
|
5103
5395
|
};
|
|
5104
5396
|
};
|
|
5105
5397
|
};
|
|
@@ -6812,4 +7104,4 @@ var CanvasBuilder = class {
|
|
|
6812
7104
|
}
|
|
6813
7105
|
};
|
|
6814
7106
|
//#endregion
|
|
6815
|
-
export { BezierEdgeShape, CanvasBuilder, CanvasBuilderError, CanvasError, ConnectionCategory, DirectEdgeShape, EventSubject, HorizontalEdgeShape, InteractiveEdgeError, InteractiveEdgeShape, MidpointEdgeShape, StraightEdgeShape, VerticalEdgeShape, boxPortOffsetFn };
|
|
7107
|
+
export { BezierEdgeShape, CanvasBuilder, CanvasBuilderError, CanvasError, ConnectionCategory, DirectEdgeShape, EventSubject, HorizontalEdgeShape, InteractiveEdgeError, InteractiveEdgeShape, MidpointEdgeShape, OrthogonalEdgeShape, StraightEdgeShape, VerticalEdgeShape, boxPortOffsetFn };
|