@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/index.js
CHANGED
|
@@ -12555,6 +12555,25 @@ var ARROW_ENDPOINT_CENTER_TOL = 8;
|
|
|
12555
12555
|
var ROW_GAP_VARIANCE_TOL = 40;
|
|
12556
12556
|
var COLUMN_GAP_VARIANCE_TOL = 40;
|
|
12557
12557
|
var LANE_BORDER_CLEARANCE_TOL = 2;
|
|
12558
|
+
function laneVerticalRange(lane, nodes) {
|
|
12559
|
+
const pinnedWithHeight = lane.posX !== void 0 && lane.posY !== void 0 && lane.posH !== void 0;
|
|
12560
|
+
if (!lane.contain && !pinnedWithHeight) return void 0;
|
|
12561
|
+
let top = lane.y;
|
|
12562
|
+
let bottom = lane.y + lane.height;
|
|
12563
|
+
for (const n of nodes) {
|
|
12564
|
+
if (n.lane !== lane.id) continue;
|
|
12565
|
+
top = Math.min(top, n.cy - n.h / 2);
|
|
12566
|
+
bottom = Math.max(bottom, n.cy + n.h / 2);
|
|
12567
|
+
}
|
|
12568
|
+
return { top, bottom };
|
|
12569
|
+
}
|
|
12570
|
+
function rectCrossesLaneBorder(rect, lane, range) {
|
|
12571
|
+
if (range !== void 0 && (rect.y + rect.h <= range.top || rect.y >= range.bottom)) return void 0;
|
|
12572
|
+
const crosses = (lineX) => rect.x < lineX - LANE_BORDER_CLEARANCE_TOL && rect.x + rect.w > lineX + LANE_BORDER_CLEARANCE_TOL;
|
|
12573
|
+
if (crosses(lane.x)) return "left";
|
|
12574
|
+
if (crosses(lane.x + lane.width)) return "right";
|
|
12575
|
+
return void 0;
|
|
12576
|
+
}
|
|
12558
12577
|
var NEAR_COLLISION_POLICY = {
|
|
12559
12578
|
"node|node": 70,
|
|
12560
12579
|
"node|edge-label": 32,
|
|
@@ -18146,6 +18165,7 @@ function runAxes(laid, diag, violations, counts, push, profile, skippedAxes, \u5
|
|
|
18146
18165
|
}
|
|
18147
18166
|
}
|
|
18148
18167
|
{
|
|
18168
|
+
const rangeByLane = new Map(laid.lanes.map((lane) => [lane.id, laneVerticalRange(lane, laid.nodes)]));
|
|
18149
18169
|
for (const e of laid.edges) {
|
|
18150
18170
|
if (!hasRenderedLabel(e)) continue;
|
|
18151
18171
|
const fromNode = nodeById.get(e.from);
|
|
@@ -18154,21 +18174,14 @@ function runAxes(laid, diag, violations, counts, push, profile, skippedAxes, \u5
|
|
|
18154
18174
|
const allowedLanes = /* @__PURE__ */ new Set();
|
|
18155
18175
|
if (fromNode) allowedLanes.add(fromNode.lane);
|
|
18156
18176
|
if (toNode) allowedLanes.add(toNode.lane);
|
|
18157
|
-
const
|
|
18158
|
-
const anchor = e.labelAnchor;
|
|
18159
|
-
const boxLeftX = anchor === "start" ? 0 : anchor === "end" ? -boxW : -boxW / 2;
|
|
18160
|
-
const bx = e.labelX + boxLeftX;
|
|
18161
|
-
const bxRight = bx + boxW;
|
|
18177
|
+
const box = computeLabelBBoxWorld(e);
|
|
18162
18178
|
for (const lane of laid.lanes) {
|
|
18163
18179
|
if (allowedLanes.has(lane.id)) continue;
|
|
18164
|
-
const
|
|
18165
|
-
|
|
18166
|
-
const crossesLeft = bx < laneLeft - LANE_BORDER_CLEARANCE_TOL && bxRight > laneLeft + LANE_BORDER_CLEARANCE_TOL;
|
|
18167
|
-
const crossesRight = bx < laneRight - LANE_BORDER_CLEARANCE_TOL && bxRight > laneRight + LANE_BORDER_CLEARANCE_TOL;
|
|
18168
|
-
if (crossesLeft || crossesRight) {
|
|
18180
|
+
const side = rectCrossesLaneBorder(box, lane, rangeByLane.get(lane.id));
|
|
18181
|
+
if (side !== void 0) {
|
|
18169
18182
|
push(
|
|
18170
18183
|
"lane-border-clearance",
|
|
18171
|
-
`edge "${e.id}" label bbox (${
|
|
18184
|
+
`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`
|
|
18172
18185
|
);
|
|
18173
18186
|
break;
|
|
18174
18187
|
}
|
|
@@ -18791,6 +18804,7 @@ function layoutEdges(diag, nodes, lanes = []) {
|
|
|
18791
18804
|
const labelMarginExtra = (diag.viewport?.labelMargin ?? diag.viewport?.gap ?? DEFAULT_LABEL_MARGIN) - DEFAULT_LABEL_MARGIN;
|
|
18792
18805
|
const nmap = new Map(nodes.map((n) => [n.id, n]));
|
|
18793
18806
|
const lmap = new Map(lanes.map((l) => [l.id, l]));
|
|
18807
|
+
const laneRangeById = new Map(lanes.map((l) => [l.id, laneVerticalRange(l, nodes)]));
|
|
18794
18808
|
const positionedEdges = [];
|
|
18795
18809
|
const autoEdges = [];
|
|
18796
18810
|
const selfLoopEdges = [];
|
|
@@ -19015,7 +19029,7 @@ function layoutEdges(diag, nodes, lanes = []) {
|
|
|
19015
19029
|
nodes.filter((n) => n.id === c.from || n.id === c.to).map((n) => n.lane)
|
|
19016
19030
|
);
|
|
19017
19031
|
return lanes.some(
|
|
19018
|
-
(l) => !endpointLanes.has(l.id) && (
|
|
19032
|
+
(l) => !endpointLanes.has(l.id) && rectCrossesLaneBorder(pill, l, laneRangeById.get(l.id)) !== void 0
|
|
19019
19033
|
);
|
|
19020
19034
|
};
|
|
19021
19035
|
const assignDetourSides = () => {
|
|
@@ -19235,7 +19249,7 @@ function layoutEdges(diag, nodes, lanes = []) {
|
|
|
19235
19249
|
);
|
|
19236
19250
|
const crossesLaneBorder = lanes.some((l) => {
|
|
19237
19251
|
if (endpointLanes.has(l.id)) return false;
|
|
19238
|
-
return
|
|
19252
|
+
return rectCrossesLaneBorder(alt, l, laneRangeById.get(l.id)) !== void 0;
|
|
19239
19253
|
});
|
|
19240
19254
|
if (crossesLaneBorder) continue;
|
|
19241
19255
|
r.baseLabelX = r.labelAltX;
|
|
@@ -19526,9 +19540,6 @@ function segmentsBBox2(segs) {
|
|
|
19526
19540
|
}
|
|
19527
19541
|
return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };
|
|
19528
19542
|
}
|
|
19529
|
-
function crossesVerticalLine(rect, lineX) {
|
|
19530
|
-
return rect.x < lineX - LANE_BORDER_CLEARANCE_TOL && rect.x + rect.w > lineX + LANE_BORDER_CLEARANCE_TOL;
|
|
19531
|
-
}
|
|
19532
19543
|
function distributeBySides(list) {
|
|
19533
19544
|
const from = list[0].from;
|
|
19534
19545
|
const tol = 20;
|