@cardenelabs/cdl 0.20.0 → 0.21.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
@@ -915,6 +915,7 @@ function footerShapeDrawTop(node) {
915
915
 
916
916
  // src/layout/collisions.ts
917
917
  var LANE_LABEL_CLEARANCE_MARGIN = 2;
918
+ var NEAR_MISS_MARGIN = LANE_LABEL_CLEARANCE_MARGIN;
918
919
  function collectBBoxes(lanes, nodes, edges) {
919
920
  const out = [];
920
921
  for (const lane of lanes) {
@@ -1584,8 +1585,8 @@ function resolveEdgeLabelOverlapsWithChainAndPropagate(edges, obstacles, minClea
1584
1585
  };
1585
1586
  const shift = computeOverlapShift(label, inflated);
1586
1587
  if (!shift) continue;
1587
- const amount = shift.amount - minClearance;
1588
- if (amount <= 0) continue;
1588
+ const amount = shift.amount - minClearance + NEAR_MISS_MARGIN;
1589
+ if (amount <= NEAR_MISS_MARGIN) continue;
1589
1590
  out.push({
1590
1591
  target: { kind: "label", id: label.id },
1591
1592
  axis: shift.axis,
@@ -1626,6 +1627,36 @@ function resolveEdgeLabelOverlapsWithChainAndPropagate(edges, obstacles, minClea
1626
1627
  out.push({ target: { kind: "label", id: moveBox.id }, ...shift });
1627
1628
  }
1628
1629
  }
1630
+ for (let i = 0; i < labels.length; i++) {
1631
+ for (let j = i + 1; j < labels.length; j++) {
1632
+ const a = labels[i];
1633
+ const b = labels[j];
1634
+ if (computeOverlapShift(a, b)) continue;
1635
+ const orderA = edgeOrder.get(a.id);
1636
+ const orderB = edgeOrder.get(b.id);
1637
+ const moveBox = orderA > orderB ? a : b;
1638
+ const staticBox = orderA > orderB ? b : a;
1639
+ const required = requiredNearClearance(moveBox.kind, staticBox.kind);
1640
+ const inflated = {
1641
+ ...staticBox,
1642
+ x: staticBox.x - required,
1643
+ y: staticBox.y - required,
1644
+ w: staticBox.w + required * 2,
1645
+ h: staticBox.h + required * 2
1646
+ };
1647
+ const shift = computeOverlapShift(moveBox, inflated);
1648
+ if (!shift) continue;
1649
+ const amount = shift.amount - minClearance + NEAR_MISS_MARGIN;
1650
+ if (amount <= NEAR_MISS_MARGIN) continue;
1651
+ out.push({
1652
+ target: { kind: "label", id: moveBox.id },
1653
+ axis: shift.axis,
1654
+ sign: shift.sign,
1655
+ amount,
1656
+ chain: false
1657
+ });
1658
+ }
1659
+ }
1629
1660
  for (const label of labels) {
1630
1661
  const currentShift = getLabelChainShift(label.id);
1631
1662
  if (currentShift.dx === 0 && currentShift.dy === 0) continue;
@@ -1721,12 +1752,46 @@ function resolveEdgeLabelOverlapsWithChainAndPropagate(edges, obstacles, minClea
1721
1752
  if (bestSideIdx < 0) continue;
1722
1753
  const amount = pathLabelClearance - gap + pathLabelClearance;
1723
1754
  const ordered = edgeProbes.map((p, idx) => ({ p, idx })).sort((a, b) => probeDist[a.idx] - probeDist[b.idx]);
1755
+ let \u7DDA\u3092\u52D5\u304B\u305B\u305F = false;
1724
1756
  for (const { p } of ordered) {
1725
1757
  const axis = p.axis;
1726
1758
  if (!pathShiftIsSafe(e.id, axis, p.sign, amount)) continue;
1727
1759
  out.push({ target: { kind: "edge-path", id: e.id }, axis, sign: p.sign, amount });
1760
+ \u7DDA\u3092\u52D5\u304B\u305B\u305F = true;
1728
1761
  break;
1729
1762
  }
1763
+ if (!\u7DDA\u3092\u52D5\u304B\u305B\u305F) {
1764
+ const \u82AF = { x: label.x + label.w / 2, y: label.y + label.h / 2 };
1765
+ let \u8FD1\u3044\u70B9 = null;
1766
+ let \u6700\u77ED = Infinity;
1767
+ for (const seg of segs) {
1768
+ for (const \u70B9 of [
1769
+ { x: seg.x1, y: seg.y1 },
1770
+ { x: seg.x2, y: seg.y2 },
1771
+ { x: (seg.x1 + seg.x2) / 2, y: (seg.y1 + seg.y2) / 2 }
1772
+ ]) {
1773
+ const d = Math.hypot(\u70B9.x - \u82AF.x, \u70B9.y - \u82AF.y);
1774
+ if (d < \u6700\u77ED) {
1775
+ \u6700\u77ED = d;
1776
+ \u8FD1\u3044\u70B9 = \u70B9;
1777
+ }
1778
+ }
1779
+ }
1780
+ if (\u8FD1\u3044\u70B9) {
1781
+ const dx = \u82AF.x - \u8FD1\u3044\u70B9.x;
1782
+ const dy = \u82AF.y - \u8FD1\u3044\u70B9.y;
1783
+ const axis = Math.abs(dx) >= Math.abs(dy) ? "x" : "y";
1784
+ const \u5411\u304D = axis === "x" ? dx : dy;
1785
+ const sign = \u5411\u304D >= 0 ? 1 : -1;
1786
+ out.push({
1787
+ target: { kind: "label", id: label.id },
1788
+ axis,
1789
+ sign,
1790
+ amount: pathLabelClearance - gap + NEAR_MISS_MARGIN,
1791
+ chain: false
1792
+ });
1793
+ }
1794
+ }
1730
1795
  }
1731
1796
  }
1732
1797
  for (const label of labels) {
@@ -3914,7 +3979,7 @@ function layoutNodes(diag, lanes) {
3914
3979
  const cx = lane.x + lane.width / 2;
3915
3980
  const \u6BB5\u306E\u82AF = rowCy.get(n.stack);
3916
3981
  const \u6BB5\u306E\u9AD8\u3055 = rowH.get(n.stack);
3917
- const \u81EA\u524D\u306E\u9AD8\u3055 = n.rowMarks !== void 0 || \u6BB5\u3092\u7A4D\u3080\u7BB1\u304B(n.kind, (n.rows?.length ?? 0) > 0);
3982
+ const \u81EA\u524D\u306E\u9AD8\u3055 = n.rowMarks !== void 0;
3918
3983
  const h = n.h ?? (\u81EA\u524D\u306E\u9AD8\u3055 ? \u7BB1\u306E\u9AD8\u3055(n, size.h) : \u6BB5\u306E\u9AD8\u3055);
3919
3984
  const cy = \u6BB5\u306E\u82AF;
3920
3985
  const w = autoRowsWidth(n, size.w);