@cardenelabs/cdl 0.123.0 → 0.124.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/CHANGELOG.md +13 -1
- package/README.md +6 -1
- package/dist/index.cjs +60 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +60 -1
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +60 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +60 -1
- package/dist/react.js.map +1 -1
- package/dist/{render-CVczwfRb.d.cts → render-U6omSNH2.d.cts} +3 -2
- package/dist/{render-CVczwfRb.d.ts → render-U6omSNH2.d.ts} +3 -2
- package/package.json +1 -1
- package/src/layout/edges.ts +103 -4
- package/src/types.ts +3 -2
package/dist/react.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
export { v as CdlDiagramView, q as CdlDiagramViewProps } from './render-
|
|
2
|
+
export { v as CdlDiagramView, q as CdlDiagramViewProps } from './render-U6omSNH2.cjs';
|
package/dist/react.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
export { v as CdlDiagramView, q as CdlDiagramViewProps } from './render-
|
|
2
|
+
export { v as CdlDiagramView, q as CdlDiagramViewProps } from './render-U6omSNH2.js';
|
package/dist/react.js
CHANGED
|
@@ -9105,6 +9105,55 @@ function bowSharedStraightPaths(edges, nodes, skipIds, textMetrics = "proportion
|
|
|
9105
9105
|
function nodeRect(n) {
|
|
9106
9106
|
return { x: n.cx - n.w / 2, y: n.cy - n.h / 2, w: n.w, h: n.h };
|
|
9107
9107
|
}
|
|
9108
|
+
function countPathObstacleCrossings(d, obstacles) {
|
|
9109
|
+
const segments = flattenPathSegments(extractPathSegments(d));
|
|
9110
|
+
return obstacles.filter((obstacle) => segmentsCrossRect(segments, nodeRect(obstacle))).length;
|
|
9111
|
+
}
|
|
9112
|
+
function makeBackDetourCandidate(A, B, from, to, obstacles, detourY, side) {
|
|
9113
|
+
const lowIsA = A.y >= B.y;
|
|
9114
|
+
const low = lowIsA ? A : B;
|
|
9115
|
+
const lowBendY = low.y - VERTICAL_DETOUR_EXIT;
|
|
9116
|
+
const bandTop = Math.min(detourY, lowBendY);
|
|
9117
|
+
const bandBottom = Math.max(detourY, lowBendY);
|
|
9118
|
+
const bandObstacles = obstacles.map(nodeRect).filter((rect) => rect.y + rect.h >= bandTop && rect.y <= bandBottom);
|
|
9119
|
+
let columnX = detourColumnFor([from, to], side);
|
|
9120
|
+
while (true) {
|
|
9121
|
+
const blockers = bandObstacles.filter(
|
|
9122
|
+
(rect) => rect.x - VERTICAL_DETOUR_GAP < columnX && columnX < rect.x + rect.w + VERTICAL_DETOUR_GAP
|
|
9123
|
+
);
|
|
9124
|
+
if (blockers.length === 0) break;
|
|
9125
|
+
columnX = side === "left" ? Math.min(...blockers.map((rect) => rect.x - VERTICAL_DETOUR_GAP)) : Math.max(...blockers.map((rect) => rect.x + rect.w + VERTICAL_DETOUR_GAP));
|
|
9126
|
+
}
|
|
9127
|
+
const bendAY = lowIsA ? lowBendY : detourY;
|
|
9128
|
+
const bendBY = lowIsA ? detourY : lowBendY;
|
|
9129
|
+
const vertices = [
|
|
9130
|
+
A,
|
|
9131
|
+
{ x: A.x, y: bendAY },
|
|
9132
|
+
{ x: columnX, y: bendAY },
|
|
9133
|
+
{ x: columnX, y: bendBY },
|
|
9134
|
+
{ x: B.x, y: bendBY },
|
|
9135
|
+
B
|
|
9136
|
+
];
|
|
9137
|
+
const d = verticesToPath(vertices);
|
|
9138
|
+
const high = lowIsA ? B : A;
|
|
9139
|
+
return {
|
|
9140
|
+
d,
|
|
9141
|
+
labelX: (high.x + columnX) / 2,
|
|
9142
|
+
crossings: countPathObstacleCrossings(d, obstacles),
|
|
9143
|
+
length: vertices.slice(1).reduce((sum, vertex, index) => {
|
|
9144
|
+
const previous = vertices[index];
|
|
9145
|
+
return sum + Math.hypot(vertex.x - previous.x, vertex.y - previous.y);
|
|
9146
|
+
}, 0)
|
|
9147
|
+
};
|
|
9148
|
+
}
|
|
9149
|
+
function chooseBackDetourCandidate(A, B, from, to, obstacles, detourY) {
|
|
9150
|
+
const left = makeBackDetourCandidate(A, B, from, to, obstacles, detourY, "left");
|
|
9151
|
+
const right = makeBackDetourCandidate(A, B, from, to, obstacles, detourY, "right");
|
|
9152
|
+
if (left.crossings !== right.crossings) return left.crossings < right.crossings ? left : right;
|
|
9153
|
+
if (Math.abs(left.length - right.length) >= 0.5) return left.length < right.length ? left : right;
|
|
9154
|
+
const preferred = Math.abs(A.x - B.x) < 0.5 ? "right" : A.x < B.x ? "left" : "right";
|
|
9155
|
+
return preferred === "left" ? left : right;
|
|
9156
|
+
}
|
|
9108
9157
|
function rectGap(a, b) {
|
|
9109
9158
|
const dx = Math.max(0, a.x - (b.x + b.w), b.x - (a.x + a.w));
|
|
9110
9159
|
const dy = Math.max(0, a.y - (b.y + b.h), b.y - (a.y + a.h));
|
|
@@ -9555,7 +9604,7 @@ function routePath(from, to, fromSide, toSide, obstacles = [], detourSide, _from
|
|
|
9555
9604
|
const detourY = Math.min(A.y, B.y) - 100;
|
|
9556
9605
|
const corner = 14;
|
|
9557
9606
|
const xDir = B.x > A.x ? 1 : -1;
|
|
9558
|
-
|
|
9607
|
+
const existing = {
|
|
9559
9608
|
d: `M ${A.x} ${A.y}
|
|
9560
9609
|
L ${A.x} ${detourY + corner}
|
|
9561
9610
|
Q ${A.x} ${detourY}, ${A.x + xDir * corner} ${detourY}
|
|
@@ -9569,6 +9618,16 @@ function routePath(from, to, fromSide, toSide, obstacles = [], detourSide, _from
|
|
|
9569
9618
|
labelY: detourY - labelInit,
|
|
9570
9619
|
labelAnchor: "middle"
|
|
9571
9620
|
};
|
|
9621
|
+
const existingCrossings = countPathObstacleCrossings(existing.d, obstacles);
|
|
9622
|
+
if (existingCrossings === 0) return existing;
|
|
9623
|
+
const candidate = chooseBackDetourCandidate(A, B, from, to, obstacles, detourY);
|
|
9624
|
+
if (candidate.crossings >= existingCrossings) return existing;
|
|
9625
|
+
return {
|
|
9626
|
+
d: candidate.d,
|
|
9627
|
+
labelX: candidate.labelX,
|
|
9628
|
+
labelY: detourY - labelInit,
|
|
9629
|
+
labelAnchor: "middle"
|
|
9630
|
+
};
|
|
9572
9631
|
}
|
|
9573
9632
|
const midX = fromSide === "left" || fromSide === "right" ? B.x : A.x;
|
|
9574
9633
|
const midY = fromSide === "top" || fromSide === "bottom" ? B.y : A.y;
|