@cardenelabs/cdl 0.45.0 → 0.47.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-UGswDfAh.cjs';
2
+ export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-C53-PeJZ.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-UGswDfAh.js';
2
+ export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-C53-PeJZ.js';
package/dist/react.js CHANGED
@@ -2421,6 +2421,7 @@ var EDGE_HEADS = [
2421
2421
  ];
2422
2422
  var EDGE_HEAD_FILL_DEFAULT = "solid";
2423
2423
  var EDGE_HEAD_FILLS = ["solid", "hollow"];
2424
+ var RELATION_FOCUS_DEFAULT = "off";
2424
2425
  var EDGE_REVEAL_DEFAULT = "phase";
2425
2426
 
2426
2427
  // src/kinds/text-width.ts
@@ -6885,6 +6886,9 @@ var LANE_PAD_MIN = 25;
6885
6886
  // src/layout/edges.ts
6886
6887
  var VERTICAL_DETOUR_GAP = 50;
6887
6888
  var VERTICAL_DETOUR_CORNER = 14;
6889
+ function verticalCornerDir(from, to) {
6890
+ return to < from ? -1 : 1;
6891
+ }
6888
6892
  var VERTICAL_DETOUR_EXIT = 45;
6889
6893
  function nearestBoxDistance(anchorX, dir, verticalTop, verticalBottom, boxes) {
6890
6894
  let nearest = Infinity;
@@ -8066,12 +8070,14 @@ function routePath(from, to, fromSide, toSide, obstacles = [], detourSide, _from
8066
8070
  midY2 = retreatBelowMidBlockers(midY2);
8067
8071
  const corner = 14;
8068
8072
  const labelY = midY2 - labelInit;
8073
+ const \u7E26\u306E\u5411\u304DA = verticalCornerDir(A.y, midY2);
8074
+ const \u7E26\u306E\u5411\u304DB = verticalCornerDir(midY2, B.y);
8069
8075
  return {
8070
8076
  d: `M ${A.x} ${A.y}
8071
- L ${A.x} ${midY2 - corner}
8077
+ L ${A.x} ${midY2 - \u7E26\u306E\u5411\u304DA * corner}
8072
8078
  Q ${A.x} ${midY2}, ${A.x + xDir * corner} ${midY2}
8073
8079
  L ${B.x - xDir * corner} ${midY2}
8074
- Q ${B.x} ${midY2}, ${B.x} ${midY2 + corner}
8080
+ Q ${B.x} ${midY2}, ${B.x} ${midY2 + \u7E26\u306E\u5411\u304DB * corner}
8075
8081
  L ${B.x} ${B.y}`,
8076
8082
  labelX: (A.x + B.x) / 2,
8077
8083
  labelY,
@@ -9420,6 +9426,7 @@ function layout(diag) {
9420
9426
  ...diag.derived ? { derived: diag.derived } : {},
9421
9427
  // 矢印をいつ出すか (#582)。 描き手が読む欄なので、そのまま持ち越す
9422
9428
  ...diag.edgeReveal ? { edgeReveal: diag.edgeReveal } : {},
9429
+ ...diag.relationFocus ? { relationFocus: diag.relationFocus } : {},
9423
9430
  // どの配色で描くか (#1553)。 空文字は書かなかった扱いにする = 空の目印を出すと、
9424
9431
  // 消費側の `[data-cdl-palette]` が配色を書いていない図にも当たる。
9425
9432
  //
@@ -10293,7 +10300,8 @@ function CdlEdgeView({
10293
10300
  active,
10294
10301
  drawing,
10295
10302
  progress,
10296
- stateValues
10303
+ stateValues,
10304
+ flowing = false
10297
10305
  }) {
10298
10306
  const color = edgeColor(edge);
10299
10307
  const marker = edgeHeadMarkerName(edge.tone, edge.head, !active, edge.headFill);
@@ -10311,6 +10319,7 @@ function CdlEdgeView({
10311
10319
  "data-cdl-from": edge.from,
10312
10320
  "data-cdl-to": edge.to,
10313
10321
  "data-cdl-active": active ? "true" : "false",
10322
+ "data-cdl-flowing": flowing ? "true" : "false",
10314
10323
  "data-cdl-drawing": drawing ? "true" : "false",
10315
10324
  "data-cdl-path-d": edge.d,
10316
10325
  "data-cdl-label-x": edge.labelX,
@@ -10363,7 +10372,11 @@ function CdlEdgeView({
10363
10372
  strokeWidth: 14,
10364
10373
  strokeLinecap: "round"
10365
10374
  }
10366
- )
10375
+ ),
10376
+ flowing && !isDotted && /* @__PURE__ */ jsxs("g", { "data-cdl-role": "edge-flow", children: [
10377
+ /* @__PURE__ */ jsx("path", { id: glowPathId, d: edge.d, fill: "none", stroke: "none" }),
10378
+ /* @__PURE__ */ jsx(EdgeGlowCircles, { color, edgeId: edge.id })
10379
+ ] })
10367
10380
  ]
10368
10381
  }
10369
10382
  );
@@ -18136,7 +18149,8 @@ function CdlNodeView({
18136
18149
  progress,
18137
18150
  stateValues,
18138
18151
  currentPhaseId,
18139
- chartLineScale
18152
+ chartLineScale,
18153
+ \u95A2\u4FC2\u306E\u53D7\u3051\u53E3
18140
18154
  }) {
18141
18155
  const value = node.value ? interpolate(node.value, stateValues) : void 0;
18142
18156
  const rows = (node.rows ?? []).map((r) => interpolate(r, stateValues));
@@ -18458,6 +18472,23 @@ function CdlNodeView({
18458
18472
  "data-cdl-eyebrow": resolvedNode.eyebrow ?? "",
18459
18473
  "data-cdl-offset-x": offsetX || void 0,
18460
18474
  "data-cdl-offset-y": offsetY || void 0,
18475
+ ...\u95A2\u4FC2\u306E\u53D7\u3051\u53E3 === void 0 ? {} : {
18476
+ // 読み上げに「押せる」 ことを伝え、 tab でも辿れるようにする。
18477
+ role: "button",
18478
+ tabIndex: 0,
18479
+ "aria-pressed": \u95A2\u4FC2\u306E\u53D7\u3051\u53E3.\u7126\u70B9 === node.id,
18480
+ style: { cursor: "pointer" },
18481
+ onPointerEnter: () => \u95A2\u4FC2\u306E\u53D7\u3051\u53E3.\u89E6\u308C\u305F(node.id),
18482
+ onPointerLeave: () => \u95A2\u4FC2\u306E\u53D7\u3051\u53E3.\u96E2\u308C\u305F(),
18483
+ onFocus: () => \u95A2\u4FC2\u306E\u53D7\u3051\u53E3.\u89E6\u308C\u305F(node.id),
18484
+ onBlur: () => \u95A2\u4FC2\u306E\u53D7\u3051\u53E3.\u96E2\u308C\u305F(),
18485
+ onClick: () => \u95A2\u4FC2\u306E\u53D7\u3051\u53E3.\u62BC\u3057\u305F(node.id),
18486
+ onKeyDown: (e) => {
18487
+ if (e.key !== "Enter" && e.key !== " ") return;
18488
+ e.preventDefault();
18489
+ \u95A2\u4FC2\u306E\u53D7\u3051\u53E3.\u62BC\u3057\u305F(node.id);
18490
+ }
18491
+ },
18461
18492
  transform: hasOffset ? `translate(${offsetX}, ${offsetY})` : void 0,
18462
18493
  opacity: boundOpacity,
18463
18494
  "data-cdl-tone": node.tone,
@@ -18481,6 +18512,18 @@ function CdlNodeView({
18481
18512
  }
18482
18513
  );
18483
18514
  }
18515
+
18516
+ // src/render/relation-focus.ts
18517
+ function relatedFocusSet(edges, nodeId) {
18518
+ const \u96C6\u5408 = /* @__PURE__ */ new Set([nodeId]);
18519
+ for (const e of edges) {
18520
+ if (e.from !== nodeId && e.to !== nodeId) continue;
18521
+ \u96C6\u5408.add(e.id);
18522
+ \u96C6\u5408.add(e.from);
18523
+ \u96C6\u5408.add(e.to);
18524
+ }
18525
+ return \u96C6\u5408;
18526
+ }
18484
18527
  function CdlStage({
18485
18528
  laid,
18486
18529
  currentPhase,
@@ -18491,7 +18534,35 @@ function CdlStage({
18491
18534
  compact = false,
18492
18535
  svgRef
18493
18536
  }) {
18494
- const activeSet = new Set(currentPhase?.activate ?? []);
18537
+ const [\u7126\u70B9, set\u7126\u70B9] = useState(null);
18538
+ const \u95A2\u4FC2\u3092\u5149\u3089\u305B\u308B = (laid.relationFocus ?? RELATION_FOCUS_DEFAULT) === "hover";
18539
+ const \u52D5\u304D\u3092\u63A7\u3048\u308B = useReducedMotion();
18540
+ useEffect(() => {
18541
+ if (!\u95A2\u4FC2\u3092\u5149\u3089\u305B\u308B) set\u7126\u70B9(null);
18542
+ }, [\u95A2\u4FC2\u3092\u5149\u3089\u305B\u308B]);
18543
+ useEffect(() => {
18544
+ if (!\u95A2\u4FC2\u3092\u5149\u3089\u305B\u308B || \u7126\u70B9?.\u7559\u3081\u305F !== true) return;
18545
+ const \u62BC\u3057\u305F2 = (e) => {
18546
+ if (e.key === "Escape") set\u7126\u70B9(null);
18547
+ };
18548
+ window.addEventListener("keydown", \u62BC\u3057\u305F2);
18549
+ return () => window.removeEventListener("keydown", \u62BC\u3057\u305F2);
18550
+ }, [\u95A2\u4FC2\u3092\u5149\u3089\u305B\u308B, \u7126\u70B9?.\u7559\u3081\u305F]);
18551
+ const \u89E6\u308C\u305F = useCallback((id) => {
18552
+ set\u7126\u70B9((\u524D) => \u524D?.\u7559\u3081\u305F === true ? \u524D : { id, \u7559\u3081\u305F: false });
18553
+ }, []);
18554
+ const \u96E2\u308C\u305F = useCallback(() => {
18555
+ set\u7126\u70B9((\u524D) => \u524D?.\u7559\u3081\u305F === true ? \u524D : null);
18556
+ }, []);
18557
+ const \u62BC\u3057\u305F = useCallback((id) => {
18558
+ set\u7126\u70B9((\u524D) => \u524D?.id === id && \u524D.\u7559\u3081\u305F ? null : { id, \u7559\u3081\u305F: true });
18559
+ }, []);
18560
+ const \u7126\u70B9\u306E\u96C6\u5408 = useMemo(
18561
+ () => \u95A2\u4FC2\u3092\u5149\u3089\u305B\u308B && \u7126\u70B9 !== null ? relatedFocusSet(laid.edges, \u7126\u70B9.id) : null,
18562
+ [\u95A2\u4FC2\u3092\u5149\u3089\u305B\u308B, \u7126\u70B9, laid.edges]
18563
+ );
18564
+ const activeSet = \u7126\u70B9\u306E\u96C6\u5408 ?? new Set(currentPhase?.activate ?? []);
18565
+ const \u7BB1\u306E\u53D7\u3051\u53E3 = \u95A2\u4FC2\u3092\u5149\u3089\u305B\u308B ? { \u89E6\u308C\u305F, \u96E2\u308C\u305F, \u62BC\u3057\u305F, \u7126\u70B9: \u7126\u70B9?.id ?? null } : void 0;
18495
18566
  const \u77E2\u5370\u306E\u51FA\u756A = useMemo(() => {
18496
18567
  const \u521D\u51FA = /* @__PURE__ */ new Map();
18497
18568
  laid.phases.forEach((p, i) => {
@@ -18722,6 +18793,7 @@ function CdlStage({
18722
18793
  {
18723
18794
  edge,
18724
18795
  active: activeSet.has(edge.id),
18796
+ flowing: \u7126\u70B9\u306E\u96C6\u5408?.has(edge.id) === true && !\u52D5\u304D\u3092\u63A7\u3048\u308B,
18725
18797
  drawing: \u77E2\u5370\u306E\u51FA\u756A.\u4F38\u3070\u3059\u304B(edge.id),
18726
18798
  progress: \u77E2\u5370\u306E\u51FA\u756A.\u4F38\u3070\u3059\u304B(edge.id) ? \u63CF\u304F\u9032\u307F : progress,
18727
18799
  stateValues
@@ -18735,6 +18807,7 @@ function CdlStage({
18735
18807
  {
18736
18808
  node,
18737
18809
  active: activeSet.has(node.id),
18810
+ \u95A2\u4FC2\u306E\u53D7\u3051\u53E3: \u7BB1\u306E\u53D7\u3051\u53E3,
18738
18811
  drawing: \u63CF\u304F,
18739
18812
  progress: \u63CF\u304F ? \u63CF\u304F\u9032\u307F : progress,
18740
18813
  stateValues,