@cardenelabs/cdl 0.9.0 → 0.10.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
@@ -4949,7 +4949,7 @@ function validate(diag) {
4949
4949
  ...(diag.formulas ?? []).map((f) => f.id),
4950
4950
  ...(diag.scrollTriggers ?? []).map((t) => t.id)
4951
4951
  ]);
4952
- const suggest = (target, candidates) => {
4952
+ const suggest = (target, candidates, candidateKind = "lane") => {
4953
4953
  const list = [...candidates];
4954
4954
  if (list.length === 0) return "";
4955
4955
  let best = "";
@@ -4961,7 +4961,7 @@ function validate(diag) {
4961
4961
  best = c;
4962
4962
  }
4963
4963
  }
4964
- return bestD <= 2 ? ` (\u3082\u3057\u304B\u3057\u3066 "${best}"?)` : ` (\u5B9A\u7FA9\u6E08 lane: ${list.slice(0, 5).join(", ")}${list.length > 5 ? "..." : ""})`;
4964
+ return bestD <= 2 ? ` (\u3082\u3057\u304B\u3057\u3066 "${best}"?)` : ` (\u5B9A\u7FA9\u6E08 ${candidateKind}: ${list.slice(0, 5).join(", ")}${list.length > 5 ? "..." : ""})`;
4965
4965
  };
4966
4966
  for (const n of diag.nodes) {
4967
4967
  if (!laneIds.has(n.lane)) {
@@ -4974,13 +4974,13 @@ function validate(diag) {
4974
4974
  for (const e of diag.edges) {
4975
4975
  if (!nodeIds.has(e.from)) {
4976
4976
  errors.push(
4977
- `[cdl] unknown-ref: edge "${e.id}" \u306E from "${e.from}" \u304C node \u306B\u5B58\u5728\u3057\u307E\u305B\u3093${suggest(e.from, nodeIds)}
4977
+ `[cdl] unknown-ref: edge "${e.id}" \u306E from "${e.from}" \u304C node \u306B\u5B58\u5728\u3057\u307E\u305B\u3093${suggest(e.from, nodeIds, "node")}
4978
4978
  \u2192 \u4FEE\u6B63\u4F8B: .node("${e.from}", { lane: "...", stack: 0, kind: "actor", title: "..." }) \u3092 edge \u5BA3\u8A00\u524D\u306B\u8FFD\u52A0`
4979
4979
  );
4980
4980
  }
4981
4981
  if (!nodeIds.has(e.to)) {
4982
4982
  errors.push(
4983
- `[cdl] unknown-ref: edge "${e.id}" \u306E to "${e.to}" \u304C node \u306B\u5B58\u5728\u3057\u307E\u305B\u3093${suggest(e.to, nodeIds)}
4983
+ `[cdl] unknown-ref: edge "${e.id}" \u306E to "${e.to}" \u304C node \u306B\u5B58\u5728\u3057\u307E\u305B\u3093${suggest(e.to, nodeIds, "node")}
4984
4984
  \u2192 \u4FEE\u6B63\u4F8B: .node("${e.to}", { lane: "...", stack: 0, kind: "...", title: "..." }) \u3092 edge \u5BA3\u8A00\u524D\u306B\u8FFD\u52A0`
4985
4985
  );
4986
4986
  }
@@ -4997,6 +4997,16 @@ function validate(diag) {
4997
4997
  errors.push(`[cdl] unknown-ref: phase "${p.id}" \u306E activate "${id}" \u306F node \u3067\u3082 edge \u3067\u3082\u306A\u3044 (typo \u306E\u53EF\u80FD\u6027)`);
4998
4998
  }
4999
4999
  }
5000
+ for (const id of p.draw ?? []) {
5001
+ if (!nodeIds.has(id)) {
5002
+ errors.push(`[cdl] unknown-ref: phase "${p.id}" \u306E draw "${id}" \u306F node \u3067\u306F\u306A\u3044 (typo \u306E\u53EF\u80FD\u6027)${suggest(id, nodeIds, "node")}`);
5003
+ continue;
5004
+ }
5005
+ const kind = diag.nodes.find((n) => n.id === id)?.kind;
5006
+ if (kind !== "chart-line") {
5007
+ warnings.push(`phase "${p.id}" \u306E draw "${id}" \u306F kind "${kind}" \u3067\u3001 \u5DE6\u304B\u3089\u63CF\u304F\u52D5\u304D\u3092\u6301\u305F\u306A\u3044 (\u5BFE\u8C61\u306F chart-line)`);
5008
+ }
5009
+ }
5000
5010
  for (const t of p.tweens) {
5001
5011
  if (!stateIds.has(t.stateId)) {
5002
5012
  errors.push(`[cdl] unknown-ref: phase "${p.id}" tween \u5BFE\u8C61 state "${t.stateId}" \u672A\u5B9A\u7FA9`);
@@ -6574,7 +6584,9 @@ function resolveMindData(data, values) {
6574
6584
  function ChartLineNode({
6575
6585
  node,
6576
6586
  active,
6577
- stateValues = {}
6587
+ stateValues = {},
6588
+ drawing = false,
6589
+ progress = 1
6578
6590
  }) {
6579
6591
  const x0 = node.cx - node.w / 2;
6580
6592
  const y0 = node.cy - node.h / 2;
@@ -6595,6 +6607,24 @@ function ChartLineNode({
6595
6607
  const xAt = (idx) => PAD_LEFT + (data.length <= 1 ? canvasW / 2 : canvasW * idx / (data.length - 1));
6596
6608
  const yAt = (v) => plotTop + plotH - (v - vMin) / vRange * plotH;
6597
6609
  const points = data.map((d, idx) => `${xAt(idx)},${yAt(d.value)}`).join(" ");
6610
+ const \u70B9\u307E\u3067\u306E\u9577\u3055 = [];
6611
+ let \u7DDA\u306E\u5168\u9577 = 0;
6612
+ let \u524D\u306E\u70B9;
6613
+ for (const [idx, datum] of data.entries()) {
6614
+ const \u4ECA\u306E\u70B9 = { x: xAt(idx), y: yAt(datum.value) };
6615
+ if (\u524D\u306E\u70B9) {
6616
+ \u7DDA\u306E\u5168\u9577 += Math.hypot(\u4ECA\u306E\u70B9.x - \u524D\u306E\u70B9.x, \u4ECA\u306E\u70B9.y - \u524D\u306E\u70B9.y);
6617
+ }
6618
+ \u70B9\u307E\u3067\u306E\u9577\u3055.push(\u7DDA\u306E\u5168\u9577);
6619
+ \u524D\u306E\u70B9 = \u4ECA\u306E\u70B9;
6620
+ }
6621
+ const \u4F38\u3073 = drawing ? Math.min(1, Math.max(0, Number.isFinite(progress) ? progress : 1)) : 1;
6622
+ const \u7DDA\u306E\u5148\u304C\u5C4A\u3044\u305F = (idx) => {
6623
+ if (!drawing) return true;
6624
+ if (data.length <= 1) return true;
6625
+ if (\u7DDA\u306E\u5168\u9577 === 0) return true;
6626
+ return \u4F38\u3073 >= (\u70B9\u307E\u3067\u306E\u9577\u3055[idx] ?? 0) / \u7DDA\u306E\u5168\u9577;
6627
+ };
6598
6628
  const gridCount = 4;
6599
6629
  const gridTicks = Array.from({ length: gridCount + 1 }, (_, i) => {
6600
6630
  const v = vMin + vRange * i / gridCount;
@@ -6672,7 +6702,8 @@ function ChartLineNode({
6672
6702
  stroke: "var(--cdl-tone-accent, #2d6a8f)",
6673
6703
  strokeWidth: 2.5,
6674
6704
  strokeLinejoin: "round",
6675
- strokeLinecap: "round"
6705
+ strokeLinecap: "round",
6706
+ ...drawing ? { pathLength: 1, strokeDasharray: 1, strokeDashoffset: 1 - \u4F38\u3073 } : {}
6676
6707
  }
6677
6708
  ),
6678
6709
  data.map((d, idx) => {
@@ -6683,40 +6714,43 @@ function ChartLineNode({
6683
6714
  const isValley = (prev === void 0 || d.value <= prev) && (next === void 0 || d.value <= next);
6684
6715
  const labelAbove = !isValley;
6685
6716
  const labelY = labelAbove ? cy - 12 : cy + 18;
6717
+ const \u51FA\u3059 = \u7DDA\u306E\u5148\u304C\u5C4A\u3044\u305F(idx);
6686
6718
  return /* @__PURE__ */ jsxRuntime.jsxs("g", { "data-cdl-unresolved": d.unresolved ? "true" : void 0, children: [
6687
- /* @__PURE__ */ jsxRuntime.jsx(
6688
- "circle",
6689
- {
6690
- cx,
6691
- cy,
6692
- r: 5,
6693
- fill: "var(--cdl-node-fill, #ffffff)",
6694
- stroke: "var(--cdl-tone-accent, #2d6a8f)",
6695
- strokeWidth: 2.5
6696
- }
6697
- ),
6698
- /* @__PURE__ */ jsxRuntime.jsx(
6699
- "circle",
6700
- {
6701
- cx,
6702
- cy,
6703
- r: 2.5,
6704
- fill: "var(--cdl-tone-accent, #2d6a8f)"
6705
- }
6706
- ),
6707
- /* @__PURE__ */ jsxRuntime.jsx(
6708
- "text",
6709
- {
6710
- "data-cdl-role": "chart-line-value",
6711
- x: cx,
6712
- y: labelY,
6713
- fontSize: 11,
6714
- fontWeight: 600,
6715
- textAnchor: "middle",
6716
- fill: "var(--cdl-text, #1a1f2a)",
6717
- children: d.value.toLocaleString()
6718
- }
6719
- ),
6719
+ \u51FA\u3059 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6720
+ /* @__PURE__ */ jsxRuntime.jsx(
6721
+ "circle",
6722
+ {
6723
+ cx,
6724
+ cy,
6725
+ r: 5,
6726
+ fill: "var(--cdl-node-fill, #ffffff)",
6727
+ stroke: "var(--cdl-tone-accent, #2d6a8f)",
6728
+ strokeWidth: 2.5
6729
+ }
6730
+ ),
6731
+ /* @__PURE__ */ jsxRuntime.jsx(
6732
+ "circle",
6733
+ {
6734
+ cx,
6735
+ cy,
6736
+ r: 2.5,
6737
+ fill: "var(--cdl-tone-accent, #2d6a8f)"
6738
+ }
6739
+ ),
6740
+ /* @__PURE__ */ jsxRuntime.jsx(
6741
+ "text",
6742
+ {
6743
+ "data-cdl-role": "chart-line-value",
6744
+ x: cx,
6745
+ y: labelY,
6746
+ fontSize: 11,
6747
+ fontWeight: 600,
6748
+ textAnchor: "middle",
6749
+ fill: "var(--cdl-text, #1a1f2a)",
6750
+ children: d.value.toLocaleString()
6751
+ }
6752
+ )
6753
+ ] }),
6720
6754
  /* @__PURE__ */ jsxRuntime.jsx(
6721
6755
  "text",
6722
6756
  {
@@ -12192,6 +12226,7 @@ function ShapeCustomerServiceNode({ node, active }) {
12192
12226
  function CdlNodeView({
12193
12227
  node,
12194
12228
  active,
12229
+ drawing = false,
12195
12230
  progress,
12196
12231
  stateValues,
12197
12232
  currentPhaseId
@@ -12241,7 +12276,16 @@ function CdlNodeView({
12241
12276
  // 数と語を取る 7 種に対し、mind-map / tree-hierarchy は **名前だけ** を取る (#467)。
12242
12277
  // 親子の繋がりと、描かれない欄 (補足) は解決しない。
12243
12278
  case "chart-line":
12244
- return /* @__PURE__ */ jsxRuntime.jsx(ChartLineNode, { node: resolvedNode, active, stateValues });
12279
+ return /* @__PURE__ */ jsxRuntime.jsx(
12280
+ ChartLineNode,
12281
+ {
12282
+ node: resolvedNode,
12283
+ active,
12284
+ stateValues,
12285
+ drawing,
12286
+ progress
12287
+ }
12288
+ );
12245
12289
  case "chart-pie":
12246
12290
  return /* @__PURE__ */ jsxRuntime.jsx(ChartPieNode, { node: resolvedNode, active, stateValues });
12247
12291
  case "chart-bar":
@@ -12435,6 +12479,7 @@ function CdlStage({
12435
12479
  svgRef
12436
12480
  }) {
12437
12481
  const activeSet = new Set(currentPhase?.activate ?? []);
12482
+ const drawSet = new Set(currentPhase?.draw ?? []);
12438
12483
  const { lifelineStarts, uniformFooterTop } = react.useMemo(() => {
12439
12484
  const starts = lifelineStartYs(laid.nodes);
12440
12485
  return {
@@ -12571,6 +12616,7 @@ function CdlStage({
12571
12616
  {
12572
12617
  node,
12573
12618
  active: activeSet.has(node.id),
12619
+ drawing: drawSet.has(node.id),
12574
12620
  progress,
12575
12621
  stateValues,
12576
12622
  currentPhaseId: currentPhase?.id