@cardenelabs/cdl 0.20.0 → 0.21.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 +38 -1
- package/dist/index.cjs +68 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +68 -3
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +68 -3
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +68 -3
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/src/layout/collisions.ts +100 -2
- package/src/layout/nodes.ts +8 -5
package/dist/index.js
CHANGED
|
@@ -12091,6 +12091,7 @@ function footerShapeDrawTop(node) {
|
|
|
12091
12091
|
|
|
12092
12092
|
// src/layout/collisions.ts
|
|
12093
12093
|
var LANE_LABEL_CLEARANCE_MARGIN = 2;
|
|
12094
|
+
var NEAR_MISS_MARGIN = LANE_LABEL_CLEARANCE_MARGIN;
|
|
12094
12095
|
function collectBBoxes(lanes, nodes, edges) {
|
|
12095
12096
|
const out = [];
|
|
12096
12097
|
for (const lane of lanes) {
|
|
@@ -12918,8 +12919,8 @@ function resolveEdgeLabelOverlapsWithChainAndPropagate(edges, obstacles, minClea
|
|
|
12918
12919
|
};
|
|
12919
12920
|
const shift = computeOverlapShift(label, inflated);
|
|
12920
12921
|
if (!shift) continue;
|
|
12921
|
-
const amount = shift.amount - minClearance;
|
|
12922
|
-
if (amount <=
|
|
12922
|
+
const amount = shift.amount - minClearance + NEAR_MISS_MARGIN;
|
|
12923
|
+
if (amount <= NEAR_MISS_MARGIN) continue;
|
|
12923
12924
|
out.push({
|
|
12924
12925
|
target: { kind: "label", id: label.id },
|
|
12925
12926
|
axis: shift.axis,
|
|
@@ -12960,6 +12961,36 @@ function resolveEdgeLabelOverlapsWithChainAndPropagate(edges, obstacles, minClea
|
|
|
12960
12961
|
out.push({ target: { kind: "label", id: moveBox.id }, ...shift });
|
|
12961
12962
|
}
|
|
12962
12963
|
}
|
|
12964
|
+
for (let i = 0; i < labels.length; i++) {
|
|
12965
|
+
for (let j = i + 1; j < labels.length; j++) {
|
|
12966
|
+
const a = labels[i];
|
|
12967
|
+
const b = labels[j];
|
|
12968
|
+
if (computeOverlapShift(a, b)) continue;
|
|
12969
|
+
const orderA = edgeOrder.get(a.id);
|
|
12970
|
+
const orderB = edgeOrder.get(b.id);
|
|
12971
|
+
const moveBox = orderA > orderB ? a : b;
|
|
12972
|
+
const staticBox = orderA > orderB ? b : a;
|
|
12973
|
+
const required = requiredNearClearance(moveBox.kind, staticBox.kind);
|
|
12974
|
+
const inflated = {
|
|
12975
|
+
...staticBox,
|
|
12976
|
+
x: staticBox.x - required,
|
|
12977
|
+
y: staticBox.y - required,
|
|
12978
|
+
w: staticBox.w + required * 2,
|
|
12979
|
+
h: staticBox.h + required * 2
|
|
12980
|
+
};
|
|
12981
|
+
const shift = computeOverlapShift(moveBox, inflated);
|
|
12982
|
+
if (!shift) continue;
|
|
12983
|
+
const amount = shift.amount - minClearance + NEAR_MISS_MARGIN;
|
|
12984
|
+
if (amount <= NEAR_MISS_MARGIN) continue;
|
|
12985
|
+
out.push({
|
|
12986
|
+
target: { kind: "label", id: moveBox.id },
|
|
12987
|
+
axis: shift.axis,
|
|
12988
|
+
sign: shift.sign,
|
|
12989
|
+
amount,
|
|
12990
|
+
chain: false
|
|
12991
|
+
});
|
|
12992
|
+
}
|
|
12993
|
+
}
|
|
12963
12994
|
for (const label of labels) {
|
|
12964
12995
|
const currentShift = getLabelChainShift(label.id);
|
|
12965
12996
|
if (currentShift.dx === 0 && currentShift.dy === 0) continue;
|
|
@@ -13055,12 +13086,46 @@ function resolveEdgeLabelOverlapsWithChainAndPropagate(edges, obstacles, minClea
|
|
|
13055
13086
|
if (bestSideIdx < 0) continue;
|
|
13056
13087
|
const amount = pathLabelClearance - gap + pathLabelClearance;
|
|
13057
13088
|
const ordered = edgeProbes.map((p, idx) => ({ p, idx })).sort((a, b) => probeDist[a.idx] - probeDist[b.idx]);
|
|
13089
|
+
let \u7DDA\u3092\u52D5\u304B\u305B\u305F = false;
|
|
13058
13090
|
for (const { p } of ordered) {
|
|
13059
13091
|
const axis = p.axis;
|
|
13060
13092
|
if (!pathShiftIsSafe(e.id, axis, p.sign, amount)) continue;
|
|
13061
13093
|
out.push({ target: { kind: "edge-path", id: e.id }, axis, sign: p.sign, amount });
|
|
13094
|
+
\u7DDA\u3092\u52D5\u304B\u305B\u305F = true;
|
|
13062
13095
|
break;
|
|
13063
13096
|
}
|
|
13097
|
+
if (!\u7DDA\u3092\u52D5\u304B\u305B\u305F) {
|
|
13098
|
+
const \u82AF = { x: label.x + label.w / 2, y: label.y + label.h / 2 };
|
|
13099
|
+
let \u8FD1\u3044\u70B9 = null;
|
|
13100
|
+
let \u6700\u77ED = Infinity;
|
|
13101
|
+
for (const seg of segs) {
|
|
13102
|
+
for (const \u70B9 of [
|
|
13103
|
+
{ x: seg.x1, y: seg.y1 },
|
|
13104
|
+
{ x: seg.x2, y: seg.y2 },
|
|
13105
|
+
{ x: (seg.x1 + seg.x2) / 2, y: (seg.y1 + seg.y2) / 2 }
|
|
13106
|
+
]) {
|
|
13107
|
+
const d = Math.hypot(\u70B9.x - \u82AF.x, \u70B9.y - \u82AF.y);
|
|
13108
|
+
if (d < \u6700\u77ED) {
|
|
13109
|
+
\u6700\u77ED = d;
|
|
13110
|
+
\u8FD1\u3044\u70B9 = \u70B9;
|
|
13111
|
+
}
|
|
13112
|
+
}
|
|
13113
|
+
}
|
|
13114
|
+
if (\u8FD1\u3044\u70B9) {
|
|
13115
|
+
const dx = \u82AF.x - \u8FD1\u3044\u70B9.x;
|
|
13116
|
+
const dy = \u82AF.y - \u8FD1\u3044\u70B9.y;
|
|
13117
|
+
const axis = Math.abs(dx) >= Math.abs(dy) ? "x" : "y";
|
|
13118
|
+
const \u5411\u304D = axis === "x" ? dx : dy;
|
|
13119
|
+
const sign = \u5411\u304D >= 0 ? 1 : -1;
|
|
13120
|
+
out.push({
|
|
13121
|
+
target: { kind: "label", id: label.id },
|
|
13122
|
+
axis,
|
|
13123
|
+
sign,
|
|
13124
|
+
amount: pathLabelClearance - gap + NEAR_MISS_MARGIN,
|
|
13125
|
+
chain: false
|
|
13126
|
+
});
|
|
13127
|
+
}
|
|
13128
|
+
}
|
|
13064
13129
|
}
|
|
13065
13130
|
}
|
|
13066
13131
|
for (const label of labels) {
|
|
@@ -15248,7 +15313,7 @@ function layoutNodes(diag, lanes) {
|
|
|
15248
15313
|
const cx = lane.x + lane.width / 2;
|
|
15249
15314
|
const \u6BB5\u306E\u82AF = rowCy.get(n.stack);
|
|
15250
15315
|
const \u6BB5\u306E\u9AD8\u3055 = rowH.get(n.stack);
|
|
15251
|
-
const \u81EA\u524D\u306E\u9AD8\u3055 = n.rowMarks !== void 0
|
|
15316
|
+
const \u81EA\u524D\u306E\u9AD8\u3055 = n.rowMarks !== void 0;
|
|
15252
15317
|
const h = n.h ?? (\u81EA\u524D\u306E\u9AD8\u3055 ? \u7BB1\u306E\u9AD8\u3055(n, size.h) : \u6BB5\u306E\u9AD8\u3055);
|
|
15253
15318
|
const cy = \u6BB5\u306E\u82AF;
|
|
15254
15319
|
const w = autoRowsWidth(n, size.w);
|