@aranzatech/diagrams-bpmn 0.3.6 → 0.3.7
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/layout/index.cjs +45 -3
- package/dist/layout/index.cjs.map +1 -1
- package/dist/layout/index.js +45 -3
- package/dist/layout/index.js.map +1 -1
- package/package.json +1 -1
package/dist/layout/index.cjs
CHANGED
|
@@ -1928,11 +1928,39 @@ function routeMidX(sAbs, sW, tAbs, tW) {
|
|
|
1928
1928
|
const rightEdge = Math.max(sAbs.x, tAbs.x);
|
|
1929
1929
|
return leftEdge < rightEdge ? leftEdge + (rightEdge - leftEdge) * 0.35 : sAbs.x + sW / 2;
|
|
1930
1930
|
}
|
|
1931
|
+
var HANDLE_SIDES = ["right", "left", "top", "bottom"];
|
|
1932
|
+
function borderHandle(point, rect, kind) {
|
|
1933
|
+
const dist = {
|
|
1934
|
+
right: Math.abs(point.x - (rect.x + rect.w)),
|
|
1935
|
+
left: Math.abs(point.x - rect.x),
|
|
1936
|
+
top: Math.abs(point.y - rect.y),
|
|
1937
|
+
bottom: Math.abs(point.y - (rect.y + rect.h))
|
|
1938
|
+
};
|
|
1939
|
+
let side = "right";
|
|
1940
|
+
let best = Infinity;
|
|
1941
|
+
for (const s of HANDLE_SIDES) {
|
|
1942
|
+
if (dist[s] < best) {
|
|
1943
|
+
best = dist[s];
|
|
1944
|
+
side = s;
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
return `${kind}-${side}`;
|
|
1948
|
+
}
|
|
1931
1949
|
var SAME_ROW_THRESHOLD = 15;
|
|
1932
1950
|
function routeEdges(edges, layoutNodes, backEdgeIds, laneIds, poolIds) {
|
|
1933
1951
|
const byId = new Map(layoutNodes.map((n) => [n.id, n]));
|
|
1934
1952
|
const cache = /* @__PURE__ */ new Map();
|
|
1935
1953
|
const abs = (id) => absolutePos(id, byId, cache);
|
|
1954
|
+
const handlesFor = (srcId, tgtId, pts) => {
|
|
1955
|
+
if (pts.length < 2) return {};
|
|
1956
|
+
const s = byId.get(srcId), t = byId.get(tgtId);
|
|
1957
|
+
if (!s || !t) return {};
|
|
1958
|
+
const sa = abs(srcId), ta = abs(tgtId);
|
|
1959
|
+
return {
|
|
1960
|
+
sourceHandle: borderHandle(pts[0], { x: sa.x, y: sa.y, w: nW(s), h: nH(s) }, "source"),
|
|
1961
|
+
targetHandle: borderHandle(pts[pts.length - 1], { x: ta.x, y: ta.y, w: nW(t), h: nH(t) }, "target")
|
|
1962
|
+
};
|
|
1963
|
+
};
|
|
1936
1964
|
const sortedLanes = [...laneIds].map((id) => byId.get(id)).filter((n) => !!n).sort((a, b) => abs(a.id).y - abs(b.id).y);
|
|
1937
1965
|
const contentInfos = layoutNodes.filter((n) => !poolIds.has(n.id) && !laneIds.has(n.id)).map((n) => {
|
|
1938
1966
|
const p = abs(n.id);
|
|
@@ -2000,7 +2028,11 @@ function routeEdges(edges, layoutNodes, backEdgeIds, laneIds, poolIds) {
|
|
|
2000
2028
|
if (edgeType === "messageFlow") {
|
|
2001
2029
|
const pts = routeMessageFlow(edge);
|
|
2002
2030
|
if (pts) {
|
|
2003
|
-
return {
|
|
2031
|
+
return {
|
|
2032
|
+
...edge,
|
|
2033
|
+
...handlesFor(edge.source, edge.target, pts),
|
|
2034
|
+
data: { ...edge.data, routingPoints: pts }
|
|
2035
|
+
};
|
|
2004
2036
|
}
|
|
2005
2037
|
}
|
|
2006
2038
|
const d = { ...edge.data };
|
|
@@ -2114,7 +2146,13 @@ function routeEdges(edges, layoutNodes, backEdgeIds, laneIds, poolIds) {
|
|
|
2114
2146
|
} else if (Math.abs(sCY - tCY) <= SAME_ROW_THRESHOLD) {
|
|
2115
2147
|
const d = { ...edge.data };
|
|
2116
2148
|
delete d.routingPoints;
|
|
2117
|
-
|
|
2149
|
+
const goesRight = tCX >= sCX;
|
|
2150
|
+
return {
|
|
2151
|
+
...edge,
|
|
2152
|
+
sourceHandle: goesRight ? "source-right" : "source-left",
|
|
2153
|
+
targetHandle: goesRight ? "target-left" : "target-right",
|
|
2154
|
+
data: d
|
|
2155
|
+
};
|
|
2118
2156
|
} else {
|
|
2119
2157
|
const handle = edge.sourceHandle ?? "";
|
|
2120
2158
|
const exitsTop = handle.includes("top");
|
|
@@ -2151,7 +2189,11 @@ function routeEdges(edges, layoutNodes, backEdgeIds, laneIds, poolIds) {
|
|
|
2151
2189
|
];
|
|
2152
2190
|
}
|
|
2153
2191
|
}
|
|
2154
|
-
return {
|
|
2192
|
+
return {
|
|
2193
|
+
...edge,
|
|
2194
|
+
...handlesFor(edge.source, edge.target, routingPoints),
|
|
2195
|
+
data: { ...edge.data, routingPoints }
|
|
2196
|
+
};
|
|
2155
2197
|
});
|
|
2156
2198
|
return spreadVerticalChannels(routed);
|
|
2157
2199
|
}
|