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