@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.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 boxW = computeLabelBoxW(e.label, e.sub);
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 laneLeft = lane.x;
7013
- const laneRight = lane.x + lane.width;
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 (${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`
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
  }
@@ -7362,6 +7375,9 @@ var VERTICAL_DETOUR_CORNER = 14;
7362
7375
  function verticalCornerDir(from, to) {
7363
7376
  return to < from ? -1 : 1;
7364
7377
  }
7378
+ function cornerRadiusFor(\u534A\u5F84, ...\u8D70\u308A) {
7379
+ return Math.min(\u534A\u5F84, ...\u8D70\u308A.map((v) => Math.abs(v)));
7380
+ }
7365
7381
  var VERTICAL_DETOUR_EXIT = 45;
7366
7382
  function nearestBoxDistance(anchorX, dir, verticalTop, verticalBottom, boxes) {
7367
7383
  let nearest = Infinity;
@@ -7411,6 +7427,7 @@ function layoutEdges(diag, nodes, lanes = []) {
7411
7427
  const labelMarginExtra = (diag.viewport?.labelMargin ?? diag.viewport?.gap ?? DEFAULT_LABEL_MARGIN) - DEFAULT_LABEL_MARGIN;
7412
7428
  const nmap = new Map(nodes.map((n) => [n.id, n]));
7413
7429
  const lmap = new Map(lanes.map((l) => [l.id, l]));
7430
+ const laneRangeById = new Map(lanes.map((l) => [l.id, laneVerticalRange(l, nodes)]));
7414
7431
  const positionedEdges = [];
7415
7432
  const autoEdges = [];
7416
7433
  const selfLoopEdges = [];
@@ -7635,7 +7652,7 @@ function layoutEdges(diag, nodes, lanes = []) {
7635
7652
  nodes.filter((n) => n.id === c.from || n.id === c.to).map((n) => n.lane)
7636
7653
  );
7637
7654
  return lanes.some(
7638
- (l) => !endpointLanes.has(l.id) && (crossesVerticalLine(pill, l.x) || crossesVerticalLine(pill, l.x + l.width))
7655
+ (l) => !endpointLanes.has(l.id) && rectCrossesLaneBorder(pill, l, laneRangeById.get(l.id)) !== void 0
7639
7656
  );
7640
7657
  };
7641
7658
  const assignDetourSides = () => {
@@ -7855,7 +7872,7 @@ function layoutEdges(diag, nodes, lanes = []) {
7855
7872
  );
7856
7873
  const crossesLaneBorder = lanes.some((l) => {
7857
7874
  if (endpointLanes.has(l.id)) return false;
7858
- return crossesVerticalLine(alt, l.x) || crossesVerticalLine(alt, l.x + l.width);
7875
+ return rectCrossesLaneBorder(alt, l, laneRangeById.get(l.id)) !== void 0;
7859
7876
  });
7860
7877
  if (crossesLaneBorder) continue;
7861
7878
  r.baseLabelX = r.labelAltX;
@@ -8146,9 +8163,6 @@ function segmentsBBox2(segs) {
8146
8163
  }
8147
8164
  return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };
8148
8165
  }
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
8166
  function distributeBySides(list) {
8153
8167
  const from = list[0].from;
8154
8168
  const tol = 20;
@@ -8371,6 +8385,7 @@ function routePath(from, to, fromSide, toSide, obstacles = [], detourSide, _from
8371
8385
  iter++;
8372
8386
  }
8373
8387
  }
8388
+ const lCorner = cornerRadiusFor(corner, (B.y - A.y) / 2, midX2 - A.x, B.x - midX2);
8374
8389
  let verticalMidY = (A.y + B.y) / 2;
8375
8390
  if (labelHalfW > 0) {
8376
8391
  const labelBoxH = 36;
@@ -8408,10 +8423,10 @@ function routePath(from, to, fromSide, toSide, obstacles = [], detourSide, _from
8408
8423
  }
8409
8424
  }
8410
8425
  if (edge?.overlay) {
8411
- const exitEndX = midX2 - xDir * corner;
8412
- const enterStartX = midX2 + xDir * corner;
8413
- const midStartY = A.y + yDir * corner;
8414
- const midEndY = B.y - yDir * corner;
8426
+ const exitEndX = midX2 - xDir * lCorner;
8427
+ const enterStartX = midX2 + xDir * lCorner;
8428
+ const midStartY = A.y + yDir * lCorner;
8429
+ const midEndY = B.y - yDir * lCorner;
8415
8430
  const segments = [
8416
8431
  { len: Math.abs(exitEndX - A.x), midXVal: (A.x + exitEndX) / 2, midYVal: A.y },
8417
8432
  { len: Math.abs(midEndY - midStartY), midXVal: midX2, midYVal: (midStartY + midEndY) / 2 },
@@ -8420,10 +8435,10 @@ function routePath(from, to, fromSide, toSide, obstacles = [], detourSide, _from
8420
8435
  const longest = segments.reduce((a, b) => b.len > a.len ? b : a);
8421
8436
  return {
8422
8437
  d: `M ${A.x} ${A.y}
8423
- L ${midX2 - xDir * corner} ${A.y}
8424
- Q ${midX2} ${A.y}, ${midX2} ${A.y + yDir * corner}
8425
- L ${midX2} ${B.y - yDir * corner}
8426
- Q ${midX2} ${B.y}, ${midX2 + xDir * corner} ${B.y}
8438
+ L ${midX2 - xDir * lCorner} ${A.y}
8439
+ Q ${midX2} ${A.y}, ${midX2} ${A.y + yDir * lCorner}
8440
+ L ${midX2} ${B.y - yDir * lCorner}
8441
+ Q ${midX2} ${B.y}, ${midX2 + xDir * lCorner} ${B.y}
8427
8442
  L ${B.x} ${B.y}`,
8428
8443
  labelX: longest.midXVal,
8429
8444
  labelY: longest.midYVal,
@@ -8432,10 +8447,10 @@ function routePath(from, to, fromSide, toSide, obstacles = [], detourSide, _from
8432
8447
  }
8433
8448
  return {
8434
8449
  d: `M ${A.x} ${A.y}
8435
- L ${midX2 - xDir * corner} ${A.y}
8436
- Q ${midX2} ${A.y}, ${midX2} ${A.y + yDir * corner}
8437
- L ${midX2} ${B.y - yDir * corner}
8438
- Q ${midX2} ${B.y}, ${midX2 + xDir * corner} ${B.y}
8450
+ L ${midX2 - xDir * lCorner} ${A.y}
8451
+ Q ${midX2} ${A.y}, ${midX2} ${A.y + yDir * lCorner}
8452
+ L ${midX2} ${B.y - yDir * lCorner}
8453
+ Q ${midX2} ${B.y}, ${midX2 + xDir * lCorner} ${B.y}
8439
8454
  L ${B.x} ${B.y}`,
8440
8455
  labelX: midX2,
8441
8456
  labelY: verticalMidY,