@cardenelabs/cdl 0.46.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
@@ -9425,6 +9426,7 @@ function layout(diag) {
9425
9426
  ...diag.derived ? { derived: diag.derived } : {},
9426
9427
  // 矢印をいつ出すか (#582)。 描き手が読む欄なので、そのまま持ち越す
9427
9428
  ...diag.edgeReveal ? { edgeReveal: diag.edgeReveal } : {},
9429
+ ...diag.relationFocus ? { relationFocus: diag.relationFocus } : {},
9428
9430
  // どの配色で描くか (#1553)。 空文字は書かなかった扱いにする = 空の目印を出すと、
9429
9431
  // 消費側の `[data-cdl-palette]` が配色を書いていない図にも当たる。
9430
9432
  //
@@ -10298,7 +10300,8 @@ function CdlEdgeView({
10298
10300
  active,
10299
10301
  drawing,
10300
10302
  progress,
10301
- stateValues
10303
+ stateValues,
10304
+ flowing = false
10302
10305
  }) {
10303
10306
  const color = edgeColor(edge);
10304
10307
  const marker = edgeHeadMarkerName(edge.tone, edge.head, !active, edge.headFill);
@@ -10316,6 +10319,7 @@ function CdlEdgeView({
10316
10319
  "data-cdl-from": edge.from,
10317
10320
  "data-cdl-to": edge.to,
10318
10321
  "data-cdl-active": active ? "true" : "false",
10322
+ "data-cdl-flowing": flowing ? "true" : "false",
10319
10323
  "data-cdl-drawing": drawing ? "true" : "false",
10320
10324
  "data-cdl-path-d": edge.d,
10321
10325
  "data-cdl-label-x": edge.labelX,
@@ -10368,7 +10372,11 @@ function CdlEdgeView({
10368
10372
  strokeWidth: 14,
10369
10373
  strokeLinecap: "round"
10370
10374
  }
10371
- )
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
+ ] })
10372
10380
  ]
10373
10381
  }
10374
10382
  );
@@ -18141,7 +18149,8 @@ function CdlNodeView({
18141
18149
  progress,
18142
18150
  stateValues,
18143
18151
  currentPhaseId,
18144
- chartLineScale
18152
+ chartLineScale,
18153
+ \u95A2\u4FC2\u306E\u53D7\u3051\u53E3
18145
18154
  }) {
18146
18155
  const value = node.value ? interpolate(node.value, stateValues) : void 0;
18147
18156
  const rows = (node.rows ?? []).map((r) => interpolate(r, stateValues));
@@ -18463,6 +18472,23 @@ function CdlNodeView({
18463
18472
  "data-cdl-eyebrow": resolvedNode.eyebrow ?? "",
18464
18473
  "data-cdl-offset-x": offsetX || void 0,
18465
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
+ },
18466
18492
  transform: hasOffset ? `translate(${offsetX}, ${offsetY})` : void 0,
18467
18493
  opacity: boundOpacity,
18468
18494
  "data-cdl-tone": node.tone,
@@ -18486,6 +18512,18 @@ function CdlNodeView({
18486
18512
  }
18487
18513
  );
18488
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
+ }
18489
18527
  function CdlStage({
18490
18528
  laid,
18491
18529
  currentPhase,
@@ -18496,7 +18534,35 @@ function CdlStage({
18496
18534
  compact = false,
18497
18535
  svgRef
18498
18536
  }) {
18499
- 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;
18500
18566
  const \u77E2\u5370\u306E\u51FA\u756A = useMemo(() => {
18501
18567
  const \u521D\u51FA = /* @__PURE__ */ new Map();
18502
18568
  laid.phases.forEach((p, i) => {
@@ -18727,6 +18793,7 @@ function CdlStage({
18727
18793
  {
18728
18794
  edge,
18729
18795
  active: activeSet.has(edge.id),
18796
+ flowing: \u7126\u70B9\u306E\u96C6\u5408?.has(edge.id) === true && !\u52D5\u304D\u3092\u63A7\u3048\u308B,
18730
18797
  drawing: \u77E2\u5370\u306E\u51FA\u756A.\u4F38\u3070\u3059\u304B(edge.id),
18731
18798
  progress: \u77E2\u5370\u306E\u51FA\u756A.\u4F38\u3070\u3059\u304B(edge.id) ? \u63CF\u304F\u9032\u307F : progress,
18732
18799
  stateValues
@@ -18740,6 +18807,7 @@ function CdlStage({
18740
18807
  {
18741
18808
  node,
18742
18809
  active: activeSet.has(node.id),
18810
+ \u95A2\u4FC2\u306E\u53D7\u3051\u53E3: \u7BB1\u306E\u53D7\u3051\u53E3,
18743
18811
  drawing: \u63CF\u304F,
18744
18812
  progress: \u63CF\u304F ? \u63CF\u304F\u9032\u307F : progress,
18745
18813
  stateValues,