@cardenelabs/cdl 0.50.0 → 0.51.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.d.cts CHANGED
@@ -1,2 +1,2 @@
1
1
  import 'react';
2
- export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-C53-PeJZ.cjs';
2
+ export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-BoBEyCu-.cjs';
package/dist/react.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import 'react';
2
- export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-C53-PeJZ.js';
2
+ export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-BoBEyCu-.js';
package/dist/react.js CHANGED
@@ -2774,10 +2774,10 @@ function \u66F8\u8A18\u7D20\u306B\u5206\u3051\u308B(text) {
2774
2774
  if (typeof \u533A\u5207\u308A !== "function") return [...text];
2775
2775
  return [...new \u533A\u5207\u308A(void 0, { granularity: "grapheme" }).segment(text)].map((g) => g.segment);
2776
2776
  }
2777
- function \u7BB1\u306B\u7A4D\u3080(\u884C, \u7BB1\u306E\u5E45, \u7BB1\u306E\u9AD8\u30552) {
2777
+ function \u7BB1\u306B\u7A4D\u3080(\u884C, \u7BB1\u306E\u5E45, \u7BB1\u306E\u9AD8\u30553) {
2778
2778
  const \u5019\u88DC = \u884C.filter((r, i) => i === 0 || r.text.trim() !== "");
2779
2779
  if (\u5019\u88DC.length === 0) return [];
2780
- const \u4F7F\u3048\u308B\u9AD8\u3055 = \u7BB1\u306E\u9AD8\u30552 - \u4E0A\u4E0B\u306E\u4F59\u767D * 2;
2780
+ const \u4F7F\u3048\u308B\u9AD8\u3055 = \u7BB1\u306E\u9AD8\u30553 - \u4E0A\u4E0B\u306E\u4F59\u767D * 2;
2781
2781
  const \u9AD8\u3055 = (rs) => rs.reduce((a, r) => a + r.fontSize * \u884C\u9001\u308A\u306E\u6BD4, 0);
2782
2782
  const \u6B8B\u3059 = [...\u5019\u88DC];
2783
2783
  while (\u6B8B\u3059.length > 1 && \u9AD8\u3055(\u6B8B\u3059) > \u4F7F\u3048\u308B\u9AD8\u3055) \u6B8B\u3059.pop();
@@ -3832,7 +3832,7 @@ function \u30D9\u30B8\u30A8\u306E\u7D2F\u7A4D\u5272\u5408(\u70B9, \u5236\u5FA1\u
3832
3832
  function \u7BB1\u306E\u6587\u5B57({
3833
3833
  \u884C,
3834
3834
  x,
3835
- \u7BB1\u306E\u9AD8\u3055: \u7BB1\u306E\u9AD8\u30552,
3835
+ \u7BB1\u306E\u9AD8\u3055: \u7BB1\u306E\u9AD8\u30553,
3836
3836
  fill,
3837
3837
  \u540D\u524D\u306E\u592A\u3055
3838
3838
  }) {
@@ -3841,7 +3841,7 @@ function \u7BB1\u306E\u6587\u5B57({
3841
3841
  {
3842
3842
  "data-cdl-role": r.\u5F79\u5272 === "subtitle" ? "tree-node-subtitle" : void 0,
3843
3843
  x,
3844
- y: \u7BB1\u306E\u9AD8\u30552 / 2 + r.dy,
3844
+ y: \u7BB1\u306E\u9AD8\u30553 / 2 + r.dy,
3845
3845
  fontSize: r.fontSize,
3846
3846
  fontWeight: r.\u5F79\u5272 === "title" ? \u540D\u524D\u306E\u592A\u3055 : 500,
3847
3847
  textAnchor: "middle",
@@ -10412,6 +10412,73 @@ function \u7B49\u5E45\u306E\u5B57(text, fontSize) {
10412
10412
  });
10413
10413
  return out;
10414
10414
  }
10415
+
10416
+ // src/layout/head-label.ts
10417
+ var \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2 = 22;
10418
+ var \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 = 8;
10419
+ var \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 = EDGE_LABEL_TEXT.sub.fontSize;
10420
+ var \u7BB1\u306E\u9AD8\u30552 = Math.round(\u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * 1.2);
10421
+ var BASELINE_RATIO = 0.8;
10422
+ function \u6700\u5F8C\u306E\u5411\u304D(d) {
10423
+ const segs = extractPathSegments(d);
10424
+ const last = segs[segs.length - 1];
10425
+ if (!last) return null;
10426
+ const end = { x: last.x2, y: last.y2 };
10427
+ for (let i = segs.length - 1; i >= 0; i--) {
10428
+ const s = segs[i];
10429
+ const \u5236\u5FA1\u70B9 = s.cmd === "Q" ? s.ctrl?.[0] : s.cmd === "C" ? s.ctrl?.[1] : void 0;
10430
+ for (const p of [\u5236\u5FA1\u70B9, { x: s.x1, y: s.y1 }]) {
10431
+ if (!p) continue;
10432
+ const dx = end.x - p.x;
10433
+ const dy = end.y - p.y;
10434
+ const len = Math.hypot(dx, dy);
10435
+ if (len > 1e-6) return { end, ux: dx / len, uy: dy / len };
10436
+ }
10437
+ }
10438
+ return null;
10439
+ }
10440
+ function \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge) {
10441
+ const text = edge.headLabel?.trim();
10442
+ if (!text) return null;
10443
+ const \u5411\u304D = \u6700\u5F8C\u306E\u5411\u304D(edge.d);
10444
+ if (!\u5411\u304D) return null;
10445
+ const { end, ux, uy } = \u5411\u304D;
10446
+ const bx = end.x - ux * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
10447
+ const by = end.y - uy * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
10448
+ const w = measureTextWidth(text, {
10449
+ fontSize: \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055,
10450
+ fontWeight: EDGE_LABEL_TEXT.sub.fontWeight,
10451
+ fontFamily: "mono"
10452
+ });
10453
+ const h = \u7BB1\u306E\u9AD8\u30552;
10454
+ const \u672D = hasRenderedLabel(edge) && edge.labelX !== void 0 && edge.labelY !== void 0 ? { x: edge.labelX, y: edge.labelY } : null;
10455
+ let anchor;
10456
+ let box;
10457
+ if (Math.abs(ux) >= Math.abs(uy)) {
10458
+ const \u53F3\u3078\u9032\u3080 = ux > 0;
10459
+ const \u4E0A\u306B\u7F6E\u304F = \u672D !== null && \u672D.y > by;
10460
+ anchor = \u53F3\u3078\u9032\u3080 ? "end" : "start";
10461
+ box = {
10462
+ x: \u53F3\u3078\u9032\u3080 ? bx - w : bx,
10463
+ y: \u4E0A\u306B\u7F6E\u304F ? by - \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 - h : by + \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593,
10464
+ w,
10465
+ h
10466
+ };
10467
+ } else {
10468
+ const \u4E0B\u3078\u9032\u3080 = uy > 0;
10469
+ const \u53F3\u306B\u7F6E\u304F = \u672D !== null && \u672D.x < bx;
10470
+ anchor = \u53F3\u306B\u7F6E\u304F ? "start" : "end";
10471
+ box = {
10472
+ x: \u53F3\u306B\u7F6E\u304F ? bx + \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 : bx - \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 - w,
10473
+ y: \u4E0B\u3078\u9032\u3080 ? by - h : by,
10474
+ w,
10475
+ h
10476
+ };
10477
+ }
10478
+ const x = anchor === "start" ? box.x : box.x + box.w;
10479
+ const y = box.y + (h - \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055) / 2 + \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * BASELINE_RATIO;
10480
+ return { x, y, anchor, box };
10481
+ }
10415
10482
  function defaultEdgeWidth(active) {
10416
10483
  return active ? 2.5 : 1.25;
10417
10484
  }
@@ -10674,6 +10741,33 @@ function CdlEdgeLabelView({
10674
10741
  }
10675
10742
  );
10676
10743
  }
10744
+ function CdlEdgeHeadLabelView({
10745
+ edge,
10746
+ active
10747
+ }) {
10748
+ const \u7F6E\u304D\u5834\u6240 = \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge);
10749
+ if (!\u7F6E\u304D\u5834\u6240) return null;
10750
+ const color = edgeColor(edge);
10751
+ return /* @__PURE__ */ jsx(
10752
+ "text",
10753
+ {
10754
+ "data-cdl-role": "edge-end-label",
10755
+ "data-cdl-edge-end-label-for": edge.id,
10756
+ x: \u7F6E\u304D\u5834\u6240.x,
10757
+ y: \u7F6E\u304D\u5834\u6240.y,
10758
+ fontSize: \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055,
10759
+ fontWeight: EDGE_LABEL_TEXT.sub.fontWeight,
10760
+ textAnchor: \u7F6E\u304D\u5834\u6240.anchor,
10761
+ fill: active ? color : "var(--cdl-text-dim, #5a6270)",
10762
+ stroke: "var(--cdl-label-bg, #ffffff)",
10763
+ strokeWidth: 4,
10764
+ strokeLinejoin: "round",
10765
+ paintOrder: "stroke",
10766
+ style: { fontFamily: fontFamilyAttr("sub") },
10767
+ children: \u7B49\u5E45\u306E\u5B57(edge.headLabel, \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055)
10768
+ }
10769
+ );
10770
+ }
10677
10771
 
10678
10772
  // src/kinds/node-tone.ts
10679
10773
  function nodeAccent(node, fallback) {
@@ -18955,6 +19049,14 @@ function CdlStage({
18955
19049
  },
18956
19050
  `label-${edge.id}`
18957
19051
  )),
19052
+ laid.edges.filter((edge) => edge.headLabel && \u77E2\u5370\u306E\u51FA\u756A.\u51FA\u308B\u304B(edge.id)).map((edge) => /* @__PURE__ */ jsx(
19053
+ CdlEdgeHeadLabelView,
19054
+ {
19055
+ edge,
19056
+ active: activeSet.has(edge.id)
19057
+ },
19058
+ `head-label-${edge.id}`
19059
+ )),
18958
19060
  debug && /* @__PURE__ */ jsxs("g", { pointerEvents: "none", children: [
18959
19061
  laid.bboxes.map((bbox, idx) => {
18960
19062
  const color = bbox.kind === "node" ? "#3b82f6" : bbox.kind === "lane-label" ? "#a855f7" : bbox.kind === "edge-label" ? "#10b981" : "#f59e0b";