@cardenelabs/cdl 0.64.0 → 0.64.1
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 +30 -0
- package/dist/index.cjs +27 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -16
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +27 -16
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +27 -16
- package/dist/react.js.map +1 -1
- package/package.json +9 -12
- package/src/layout/edges.ts +8 -15
- package/src/layout/spec.ts +59 -1
- package/src/visual-validate.ts +12 -21
package/dist/react.js
CHANGED
|
@@ -1139,6 +1139,25 @@ var ARROW_ENDPOINT_CENTER_TOL = 8;
|
|
|
1139
1139
|
var ROW_GAP_VARIANCE_TOL = 40;
|
|
1140
1140
|
var COLUMN_GAP_VARIANCE_TOL = 40;
|
|
1141
1141
|
var LANE_BORDER_CLEARANCE_TOL = 2;
|
|
1142
|
+
function laneVerticalRange(lane, nodes) {
|
|
1143
|
+
const pinnedWithHeight = lane.posX !== void 0 && lane.posY !== void 0 && lane.posH !== void 0;
|
|
1144
|
+
if (!lane.contain && !pinnedWithHeight) return void 0;
|
|
1145
|
+
let top = lane.y;
|
|
1146
|
+
let bottom = lane.y + lane.height;
|
|
1147
|
+
for (const n of nodes) {
|
|
1148
|
+
if (n.lane !== lane.id) continue;
|
|
1149
|
+
top = Math.min(top, n.cy - n.h / 2);
|
|
1150
|
+
bottom = Math.max(bottom, n.cy + n.h / 2);
|
|
1151
|
+
}
|
|
1152
|
+
return { top, bottom };
|
|
1153
|
+
}
|
|
1154
|
+
function rectCrossesLaneBorder(rect, lane, range) {
|
|
1155
|
+
if (range !== void 0 && (rect.y + rect.h <= range.top || rect.y >= range.bottom)) return void 0;
|
|
1156
|
+
const crosses = (lineX) => rect.x < lineX - LANE_BORDER_CLEARANCE_TOL && rect.x + rect.w > lineX + LANE_BORDER_CLEARANCE_TOL;
|
|
1157
|
+
if (crosses(lane.x)) return "left";
|
|
1158
|
+
if (crosses(lane.x + lane.width)) return "right";
|
|
1159
|
+
return void 0;
|
|
1160
|
+
}
|
|
1142
1161
|
var NEAR_COLLISION_POLICY = {
|
|
1143
1162
|
"node|node": 70,
|
|
1144
1163
|
"node|edge-label": 32,
|
|
@@ -6994,6 +7013,7 @@ function runAxes(laid, diag, violations, counts, push, profile, skippedAxes, \u5
|
|
|
6994
7013
|
}
|
|
6995
7014
|
}
|
|
6996
7015
|
{
|
|
7016
|
+
const rangeByLane = new Map(laid.lanes.map((lane) => [lane.id, laneVerticalRange(lane, laid.nodes)]));
|
|
6997
7017
|
for (const e of laid.edges) {
|
|
6998
7018
|
if (!hasRenderedLabel(e)) continue;
|
|
6999
7019
|
const fromNode = nodeById.get(e.from);
|
|
@@ -7002,21 +7022,14 @@ function runAxes(laid, diag, violations, counts, push, profile, skippedAxes, \u5
|
|
|
7002
7022
|
const allowedLanes = /* @__PURE__ */ new Set();
|
|
7003
7023
|
if (fromNode) allowedLanes.add(fromNode.lane);
|
|
7004
7024
|
if (toNode) allowedLanes.add(toNode.lane);
|
|
7005
|
-
const
|
|
7006
|
-
const anchor = e.labelAnchor;
|
|
7007
|
-
const boxLeftX = anchor === "start" ? 0 : anchor === "end" ? -boxW : -boxW / 2;
|
|
7008
|
-
const bx = e.labelX + boxLeftX;
|
|
7009
|
-
const bxRight = bx + boxW;
|
|
7025
|
+
const box = computeLabelBBoxWorld(e);
|
|
7010
7026
|
for (const lane of laid.lanes) {
|
|
7011
7027
|
if (allowedLanes.has(lane.id)) continue;
|
|
7012
|
-
const
|
|
7013
|
-
|
|
7014
|
-
const crossesLeft = bx < laneLeft - LANE_BORDER_CLEARANCE_TOL && bxRight > laneLeft + LANE_BORDER_CLEARANCE_TOL;
|
|
7015
|
-
const crossesRight = bx < laneRight - LANE_BORDER_CLEARANCE_TOL && bxRight > laneRight + LANE_BORDER_CLEARANCE_TOL;
|
|
7016
|
-
if (crossesLeft || crossesRight) {
|
|
7028
|
+
const side = rectCrossesLaneBorder(box, lane, rangeByLane.get(lane.id));
|
|
7029
|
+
if (side !== void 0) {
|
|
7017
7030
|
push(
|
|
7018
7031
|
"lane-border-clearance",
|
|
7019
|
-
`edge "${e.id}" label bbox (${
|
|
7032
|
+
`edge "${e.id}" label bbox (${box.x.toFixed(0)}..${(box.x + box.w).toFixed(0)}) \u304C\u975E\u767A\u7740 lane "${lane.id}" (${lane.x.toFixed(0)}..${(lane.x + lane.width).toFixed(0)}) \u306E ${side === "left" ? "\u5DE6" : "\u53F3"} border \u3092\u8CAB\u901A`
|
|
7020
7033
|
);
|
|
7021
7034
|
break;
|
|
7022
7035
|
}
|
|
@@ -7411,6 +7424,7 @@ function layoutEdges(diag, nodes, lanes = []) {
|
|
|
7411
7424
|
const labelMarginExtra = (diag.viewport?.labelMargin ?? diag.viewport?.gap ?? DEFAULT_LABEL_MARGIN) - DEFAULT_LABEL_MARGIN;
|
|
7412
7425
|
const nmap = new Map(nodes.map((n) => [n.id, n]));
|
|
7413
7426
|
const lmap = new Map(lanes.map((l) => [l.id, l]));
|
|
7427
|
+
const laneRangeById = new Map(lanes.map((l) => [l.id, laneVerticalRange(l, nodes)]));
|
|
7414
7428
|
const positionedEdges = [];
|
|
7415
7429
|
const autoEdges = [];
|
|
7416
7430
|
const selfLoopEdges = [];
|
|
@@ -7635,7 +7649,7 @@ function layoutEdges(diag, nodes, lanes = []) {
|
|
|
7635
7649
|
nodes.filter((n) => n.id === c.from || n.id === c.to).map((n) => n.lane)
|
|
7636
7650
|
);
|
|
7637
7651
|
return lanes.some(
|
|
7638
|
-
(l) => !endpointLanes.has(l.id) && (
|
|
7652
|
+
(l) => !endpointLanes.has(l.id) && rectCrossesLaneBorder(pill, l, laneRangeById.get(l.id)) !== void 0
|
|
7639
7653
|
);
|
|
7640
7654
|
};
|
|
7641
7655
|
const assignDetourSides = () => {
|
|
@@ -7855,7 +7869,7 @@ function layoutEdges(diag, nodes, lanes = []) {
|
|
|
7855
7869
|
);
|
|
7856
7870
|
const crossesLaneBorder = lanes.some((l) => {
|
|
7857
7871
|
if (endpointLanes.has(l.id)) return false;
|
|
7858
|
-
return
|
|
7872
|
+
return rectCrossesLaneBorder(alt, l, laneRangeById.get(l.id)) !== void 0;
|
|
7859
7873
|
});
|
|
7860
7874
|
if (crossesLaneBorder) continue;
|
|
7861
7875
|
r.baseLabelX = r.labelAltX;
|
|
@@ -8146,9 +8160,6 @@ function segmentsBBox2(segs) {
|
|
|
8146
8160
|
}
|
|
8147
8161
|
return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };
|
|
8148
8162
|
}
|
|
8149
|
-
function crossesVerticalLine(rect, lineX) {
|
|
8150
|
-
return rect.x < lineX - LANE_BORDER_CLEARANCE_TOL && rect.x + rect.w > lineX + LANE_BORDER_CLEARANCE_TOL;
|
|
8151
|
-
}
|
|
8152
8163
|
function distributeBySides(list) {
|
|
8153
8164
|
const from = list[0].from;
|
|
8154
8165
|
const tol = 20;
|