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