@cardenelabs/cdl 0.51.0 → 0.52.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
@@ -10421,28 +10421,34 @@ var \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 = 8;
10421
10421
  var \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 = EDGE_LABEL_TEXT.sub.fontSize;
10422
10422
  var \u7BB1\u306E\u9AD8\u30552 = Math.round(\u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * 1.2);
10423
10423
  var BASELINE_RATIO = 0.8;
10424
- function \u6700\u5F8C\u306E\u5411\u304D(d) {
10425
- const segs = extractPathSegments(d);
10426
- const last = segs[segs.length - 1];
10427
- if (!last) return null;
10428
- const end = { x: last.x2, y: last.y2 };
10429
- for (let i = segs.length - 1; i >= 0; i--) {
10430
- const s = segs[i];
10431
- const \u5236\u5FA1\u70B9 = s.cmd === "Q" ? s.ctrl?.[0] : s.cmd === "C" ? s.ctrl?.[1] : void 0;
10432
- for (const p of [\u5236\u5FA1\u70B9, { x: s.x1, y: s.y1 }]) {
10433
- if (!p) continue;
10434
- const dx = end.x - p.x;
10435
- const dy = end.y - p.y;
10436
- const len = Math.hypot(dx, dy);
10437
- if (len > 1e-6) return { end, ux: dx / len, uy: dy / len };
10438
- }
10424
+ function \u5411\u304D\u3092\u53D6\u308B(end, \u5019\u88DC) {
10425
+ for (const p of \u5019\u88DC) {
10426
+ if (!p) continue;
10427
+ const dx = end.x - p.x;
10428
+ const dy = end.y - p.y;
10429
+ const len = Math.hypot(dx, dy);
10430
+ if (len > 1e-6) return { end, ux: dx / len, uy: dy / len };
10439
10431
  }
10440
10432
  return null;
10441
10433
  }
10442
- function \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge) {
10443
- const text = edge.headLabel?.trim();
10434
+ function \u7AEF\u3067\u306E\u5411\u304D(d, \u7AEF) {
10435
+ const segs = extractPathSegments(d);
10436
+ if (segs.length === 0) return null;
10437
+ if (\u7AEF === "head") {
10438
+ const last = segs[segs.length - 1];
10439
+ const end2 = { x: last.x2, y: last.y2 };
10440
+ const \u5019\u88DC2 = segs.slice().reverse().flatMap((s) => [s.cmd === "Q" ? s.ctrl?.[0] : s.cmd === "C" ? s.ctrl?.[1] : void 0, { x: s.x1, y: s.y1 }]);
10441
+ return \u5411\u304D\u3092\u53D6\u308B(end2, \u5019\u88DC2);
10442
+ }
10443
+ const first = segs[0];
10444
+ const end = { x: first.x1, y: first.y1 };
10445
+ const \u5019\u88DC = segs.flatMap((s) => [...s.ctrl ?? [], { x: s.x2, y: s.y2 }]);
10446
+ return \u5411\u304D\u3092\u53D6\u308B(end, \u5019\u88DC);
10447
+ }
10448
+ function \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge, \u7AEF = "head") {
10449
+ const text = (\u7AEF === "head" ? edge.headLabel : edge.tailLabel)?.trim();
10444
10450
  if (!text) return null;
10445
- const \u5411\u304D = \u6700\u5F8C\u306E\u5411\u304D(edge.d);
10451
+ const \u5411\u304D = \u7AEF\u3067\u306E\u5411\u304D(edge.d, \u7AEF);
10446
10452
  if (!\u5411\u304D) return null;
10447
10453
  const { end, ux, uy } = \u5411\u304D;
10448
10454
  const bx = end.x - ux * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
@@ -10743,11 +10749,12 @@ function CdlEdgeLabelView({
10743
10749
  }
10744
10750
  );
10745
10751
  }
10746
- function CdlEdgeHeadLabelView({
10752
+ function CdlEdgeEndLabelView({
10747
10753
  edge,
10748
- active
10754
+ active,
10755
+ \u7AEF
10749
10756
  }) {
10750
- const \u7F6E\u304D\u5834\u6240 = \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge);
10757
+ const \u7F6E\u304D\u5834\u6240 = \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge, \u7AEF);
10751
10758
  if (!\u7F6E\u304D\u5834\u6240) return null;
10752
10759
  const color = edgeColor(edge);
10753
10760
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -10755,6 +10762,7 @@ function CdlEdgeHeadLabelView({
10755
10762
  {
10756
10763
  "data-cdl-role": "edge-end-label",
10757
10764
  "data-cdl-edge-end-label-for": edge.id,
10765
+ "data-cdl-edge-end": \u7AEF,
10758
10766
  x: \u7F6E\u304D\u5834\u6240.x,
10759
10767
  y: \u7F6E\u304D\u5834\u6240.y,
10760
10768
  fontSize: \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055,
@@ -10766,7 +10774,7 @@ function CdlEdgeHeadLabelView({
10766
10774
  strokeLinejoin: "round",
10767
10775
  paintOrder: "stroke",
10768
10776
  style: { fontFamily: fontFamilyAttr("sub") },
10769
- children: \u7B49\u5E45\u306E\u5B57(edge.headLabel, \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055)
10777
+ children: \u7B49\u5E45\u306E\u5B57(\u7AEF === "head" ? edge.headLabel : edge.tailLabel, \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055)
10770
10778
  }
10771
10779
  );
10772
10780
  }
@@ -19051,14 +19059,17 @@ function CdlStage({
19051
19059
  },
19052
19060
  `label-${edge.id}`
19053
19061
  )),
19054
- laid.edges.filter((edge) => edge.headLabel && \u77E2\u5370\u306E\u51FA\u756A.\u51FA\u308B\u304B(edge.id)).map((edge) => /* @__PURE__ */ jsxRuntime.jsx(
19055
- CdlEdgeHeadLabelView,
19056
- {
19057
- edge,
19058
- active: activeSet.has(edge.id)
19059
- },
19060
- `head-label-${edge.id}`
19061
- )),
19062
+ laid.edges.filter((edge) => (edge.headLabel || edge.tailLabel) && \u77E2\u5370\u306E\u51FA\u756A.\u51FA\u308B\u304B(edge.id)).flatMap(
19063
+ (edge) => ["head", "tail"].map((\u7AEF) => /* @__PURE__ */ jsxRuntime.jsx(
19064
+ CdlEdgeEndLabelView,
19065
+ {
19066
+ edge,
19067
+ active: activeSet.has(edge.id),
19068
+ \u7AEF
19069
+ },
19070
+ `${\u7AEF}-label-${edge.id}`
19071
+ ))
19072
+ ),
19062
19073
  debug && /* @__PURE__ */ jsxRuntime.jsxs("g", { pointerEvents: "none", children: [
19063
19074
  laid.bboxes.map((bbox, idx) => {
19064
19075
  const color = bbox.kind === "node" ? "#3b82f6" : bbox.kind === "lane-label" ? "#a855f7" : bbox.kind === "edge-label" ? "#10b981" : "#f59e0b";