@cardenelabs/cdl 0.64.0 → 0.65.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/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
  }
@@ -7364,6 +7377,9 @@ var VERTICAL_DETOUR_CORNER = 14;
7364
7377
  function verticalCornerDir(from, to) {
7365
7378
  return to < from ? -1 : 1;
7366
7379
  }
7380
+ function cornerRadiusFor(\u534A\u5F84, ...\u8D70\u308A) {
7381
+ return Math.min(\u534A\u5F84, ...\u8D70\u308A.map((v) => Math.abs(v)));
7382
+ }
7367
7383
  var VERTICAL_DETOUR_EXIT = 45;
7368
7384
  function nearestBoxDistance(anchorX, dir, verticalTop, verticalBottom, boxes) {
7369
7385
  let nearest = Infinity;
@@ -7413,6 +7429,7 @@ function layoutEdges(diag, nodes, lanes = []) {
7413
7429
  const labelMarginExtra = (diag.viewport?.labelMargin ?? diag.viewport?.gap ?? DEFAULT_LABEL_MARGIN) - DEFAULT_LABEL_MARGIN;
7414
7430
  const nmap = new Map(nodes.map((n) => [n.id, n]));
7415
7431
  const lmap = new Map(lanes.map((l) => [l.id, l]));
7432
+ const laneRangeById = new Map(lanes.map((l) => [l.id, laneVerticalRange(l, nodes)]));
7416
7433
  const positionedEdges = [];
7417
7434
  const autoEdges = [];
7418
7435
  const selfLoopEdges = [];
@@ -7637,7 +7654,7 @@ function layoutEdges(diag, nodes, lanes = []) {
7637
7654
  nodes.filter((n) => n.id === c.from || n.id === c.to).map((n) => n.lane)
7638
7655
  );
7639
7656
  return lanes.some(
7640
- (l) => !endpointLanes.has(l.id) && (crossesVerticalLine(pill, l.x) || crossesVerticalLine(pill, l.x + l.width))
7657
+ (l) => !endpointLanes.has(l.id) && rectCrossesLaneBorder(pill, l, laneRangeById.get(l.id)) !== void 0
7641
7658
  );
7642
7659
  };
7643
7660
  const assignDetourSides = () => {
@@ -7857,7 +7874,7 @@ function layoutEdges(diag, nodes, lanes = []) {
7857
7874
  );
7858
7875
  const crossesLaneBorder = lanes.some((l) => {
7859
7876
  if (endpointLanes.has(l.id)) return false;
7860
- return crossesVerticalLine(alt, l.x) || crossesVerticalLine(alt, l.x + l.width);
7877
+ return rectCrossesLaneBorder(alt, l, laneRangeById.get(l.id)) !== void 0;
7861
7878
  });
7862
7879
  if (crossesLaneBorder) continue;
7863
7880
  r.baseLabelX = r.labelAltX;
@@ -8148,9 +8165,6 @@ function segmentsBBox2(segs) {
8148
8165
  }
8149
8166
  return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };
8150
8167
  }
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
8168
  function distributeBySides(list) {
8155
8169
  const from = list[0].from;
8156
8170
  const tol = 20;
@@ -8373,6 +8387,7 @@ function routePath(from, to, fromSide, toSide, obstacles = [], detourSide, _from
8373
8387
  iter++;
8374
8388
  }
8375
8389
  }
8390
+ const lCorner = cornerRadiusFor(corner, (B.y - A.y) / 2, midX2 - A.x, B.x - midX2);
8376
8391
  let verticalMidY = (A.y + B.y) / 2;
8377
8392
  if (labelHalfW > 0) {
8378
8393
  const labelBoxH = 36;
@@ -8410,10 +8425,10 @@ function routePath(from, to, fromSide, toSide, obstacles = [], detourSide, _from
8410
8425
  }
8411
8426
  }
8412
8427
  if (edge?.overlay) {
8413
- const exitEndX = midX2 - xDir * corner;
8414
- const enterStartX = midX2 + xDir * corner;
8415
- const midStartY = A.y + yDir * corner;
8416
- const midEndY = B.y - yDir * corner;
8428
+ const exitEndX = midX2 - xDir * lCorner;
8429
+ const enterStartX = midX2 + xDir * lCorner;
8430
+ const midStartY = A.y + yDir * lCorner;
8431
+ const midEndY = B.y - yDir * lCorner;
8417
8432
  const segments = [
8418
8433
  { len: Math.abs(exitEndX - A.x), midXVal: (A.x + exitEndX) / 2, midYVal: A.y },
8419
8434
  { len: Math.abs(midEndY - midStartY), midXVal: midX2, midYVal: (midStartY + midEndY) / 2 },
@@ -8422,10 +8437,10 @@ function routePath(from, to, fromSide, toSide, obstacles = [], detourSide, _from
8422
8437
  const longest = segments.reduce((a, b) => b.len > a.len ? b : a);
8423
8438
  return {
8424
8439
  d: `M ${A.x} ${A.y}
8425
- L ${midX2 - xDir * corner} ${A.y}
8426
- Q ${midX2} ${A.y}, ${midX2} ${A.y + yDir * corner}
8427
- L ${midX2} ${B.y - yDir * corner}
8428
- Q ${midX2} ${B.y}, ${midX2 + xDir * corner} ${B.y}
8440
+ L ${midX2 - xDir * lCorner} ${A.y}
8441
+ Q ${midX2} ${A.y}, ${midX2} ${A.y + yDir * lCorner}
8442
+ L ${midX2} ${B.y - yDir * lCorner}
8443
+ Q ${midX2} ${B.y}, ${midX2 + xDir * lCorner} ${B.y}
8429
8444
  L ${B.x} ${B.y}`,
8430
8445
  labelX: longest.midXVal,
8431
8446
  labelY: longest.midYVal,
@@ -8434,10 +8449,10 @@ function routePath(from, to, fromSide, toSide, obstacles = [], detourSide, _from
8434
8449
  }
8435
8450
  return {
8436
8451
  d: `M ${A.x} ${A.y}
8437
- L ${midX2 - xDir * corner} ${A.y}
8438
- Q ${midX2} ${A.y}, ${midX2} ${A.y + yDir * corner}
8439
- L ${midX2} ${B.y - yDir * corner}
8440
- Q ${midX2} ${B.y}, ${midX2 + xDir * corner} ${B.y}
8452
+ L ${midX2 - xDir * lCorner} ${A.y}
8453
+ Q ${midX2} ${A.y}, ${midX2} ${A.y + yDir * lCorner}
8454
+ L ${midX2} ${B.y - yDir * lCorner}
8455
+ Q ${midX2} ${B.y}, ${midX2 + xDir * lCorner} ${B.y}
8441
8456
  L ${B.x} ${B.y}`,
8442
8457
  labelX: midX2,
8443
8458
  labelY: verticalMidY,