@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/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CdlDiagram, S as Signal, a as CdlInput, b as CdlLane, c as CdlNode, T as Tone, d as Side, E as EdgeStyle, e as CdlState, f as CdlEventTarget, g as Computed, h as CdlDerivedValue, i as CdlScrollTrigger, L as LaidDiagram, j as CdlDiagramViewProps, k as LaidEdge, l as LaidNode, m as CdlEdge, B as BBox, N as NodeKind, J as JourneyEmotion, Q as QuadrantKey } from './render-hmFRAabt.cjs';
2
- export { n as CdlDiagramView, o as CdlEventBinding, p as CdlEventKind, q as CdlFormula, r as CdlPhase, I as InteractiveHandlerMap, s as InteractiveSignalsAccessor, t as LaidLane, u as NODE_KINDS, v as ScrollProgressHandle, w as TONES, x as computeEventBindingKey, y as computeFormulaKey, z as computeInputSignalKey, A as computeScrollTriggerKey, D as computed, F as createInteractiveSignalsAccessor, G as createScrollProgressHandle, H as createScrollProgressSignals, K as hasInteractivePrimitives, M as signal } from './render-hmFRAabt.cjs';
1
+ import { C as CdlDiagram, S as Signal, a as CdlInput, b as CdlLane, c as CdlNode, T as Tone, d as Side, E as EdgeStyle, e as CdlState, f as CdlEventTarget, g as Computed, h as CdlDerivedValue, i as CdlScrollTrigger, L as LaidDiagram, j as CdlDiagramViewProps, k as LaidEdge, l as LaidNode, m as CdlEdge, B as BBox, N as NodeKind, J as JourneyEmotion, Q as QuadrantKey } from './render-CH1Qn3Jv.cjs';
2
+ export { n as CdlDiagramView, o as CdlEventBinding, p as CdlEventKind, q as CdlFormula, r as CdlPhase, I as InteractiveHandlerMap, s as InteractiveSignalsAccessor, t as LaidLane, u as NODE_KINDS, v as ScrollProgressHandle, w as TONES, x as computeEventBindingKey, y as computeFormulaKey, z as computeInputSignalKey, A as computeScrollTriggerKey, D as computed, F as createInteractiveSignalsAccessor, G as createScrollProgressHandle, H as createScrollProgressSignals, K as hasInteractivePrimitives, M as signal } from './render-CH1Qn3Jv.cjs';
3
3
  import { JSX } from 'react';
4
4
 
5
5
  declare function effect(fn: () => void | (() => void)): () => void;
@@ -997,6 +997,11 @@ type InputChain = {
997
997
  };
998
998
  type PhaseBuilder = {
999
999
  activate: (...ids: string[]) => PhaseBuilder;
1000
+ /**
1001
+ * この phase で左の起点から描き始める node を指定する (cdl#512)。
1002
+ * 対象は phase の進み (0→1) に合わせて描かれる。 現在の対象種別は `chart-line`。
1003
+ */
1004
+ draw: (...ids: string[]) => PhaseBuilder;
1000
1005
  /** 数値 state の線形補間 (write phase で 100→90 等) */
1001
1006
  tween: (stateId: string, from: number, to: number) => PhaseBuilder;
1002
1007
  /** 任意型 state を即時切替 (この phase 到達で value 上書き、 lerp なし) */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CdlDiagram, S as Signal, a as CdlInput, b as CdlLane, c as CdlNode, T as Tone, d as Side, E as EdgeStyle, e as CdlState, f as CdlEventTarget, g as Computed, h as CdlDerivedValue, i as CdlScrollTrigger, L as LaidDiagram, j as CdlDiagramViewProps, k as LaidEdge, l as LaidNode, m as CdlEdge, B as BBox, N as NodeKind, J as JourneyEmotion, Q as QuadrantKey } from './render-hmFRAabt.js';
2
- export { n as CdlDiagramView, o as CdlEventBinding, p as CdlEventKind, q as CdlFormula, r as CdlPhase, I as InteractiveHandlerMap, s as InteractiveSignalsAccessor, t as LaidLane, u as NODE_KINDS, v as ScrollProgressHandle, w as TONES, x as computeEventBindingKey, y as computeFormulaKey, z as computeInputSignalKey, A as computeScrollTriggerKey, D as computed, F as createInteractiveSignalsAccessor, G as createScrollProgressHandle, H as createScrollProgressSignals, K as hasInteractivePrimitives, M as signal } from './render-hmFRAabt.js';
1
+ import { C as CdlDiagram, S as Signal, a as CdlInput, b as CdlLane, c as CdlNode, T as Tone, d as Side, E as EdgeStyle, e as CdlState, f as CdlEventTarget, g as Computed, h as CdlDerivedValue, i as CdlScrollTrigger, L as LaidDiagram, j as CdlDiagramViewProps, k as LaidEdge, l as LaidNode, m as CdlEdge, B as BBox, N as NodeKind, J as JourneyEmotion, Q as QuadrantKey } from './render-CH1Qn3Jv.js';
2
+ export { n as CdlDiagramView, o as CdlEventBinding, p as CdlEventKind, q as CdlFormula, r as CdlPhase, I as InteractiveHandlerMap, s as InteractiveSignalsAccessor, t as LaidLane, u as NODE_KINDS, v as ScrollProgressHandle, w as TONES, x as computeEventBindingKey, y as computeFormulaKey, z as computeInputSignalKey, A as computeScrollTriggerKey, D as computed, F as createInteractiveSignalsAccessor, G as createScrollProgressHandle, H as createScrollProgressSignals, K as hasInteractivePrimitives, M as signal } from './render-CH1Qn3Jv.js';
3
3
  import { JSX } from 'react';
4
4
 
5
5
  declare function effect(fn: () => void | (() => void)): () => void;
@@ -997,6 +997,11 @@ type InputChain = {
997
997
  };
998
998
  type PhaseBuilder = {
999
999
  activate: (...ids: string[]) => PhaseBuilder;
1000
+ /**
1001
+ * この phase で左の起点から描き始める node を指定する (cdl#512)。
1002
+ * 対象は phase の進み (0→1) に合わせて描かれる。 現在の対象種別は `chart-line`。
1003
+ */
1004
+ draw: (...ids: string[]) => PhaseBuilder;
1000
1005
  /** 数値 state の線形補間 (write phase で 100→90 等) */
1001
1006
  tween: (stateId: string, from: number, to: number) => PhaseBuilder;
1002
1007
  /** 任意型 state を即時切替 (この phase 到達で value 上書き、 lerp なし) */
package/dist/index.js CHANGED
@@ -9361,6 +9361,10 @@ function makePhaseBuilder(acc) {
9361
9361
  acc.activate.push(...ids);
9362
9362
  return api;
9363
9363
  },
9364
+ draw(...ids) {
9365
+ acc.draw.push(...ids);
9366
+ return api;
9367
+ },
9364
9368
  tween(stateId, from, to) {
9365
9369
  acc.tweens.push({ stateId, from, to });
9366
9370
  return api;
@@ -11440,7 +11444,7 @@ function diagram(id, options) {
11440
11444
  }
11441
11445
  },
11442
11446
  phase(phaseId, opts, build) {
11443
- const acc = { activate: [], tweens: [], sets: [] };
11447
+ const acc = { activate: [], draw: [], tweens: [], sets: [] };
11444
11448
  build(makePhaseBuilder(acc));
11445
11449
  phases.push({
11446
11450
  id: phaseId,
@@ -11448,6 +11452,8 @@ function diagram(id, options) {
11448
11452
  title: opts.title,
11449
11453
  body: opts.body,
11450
11454
  activate: acc.activate,
11455
+ // 空なら欄ごと置かない。 置くと `draw` を使わない図の JSON の形が変わる
11456
+ ...acc.draw.length > 0 ? { draw: acc.draw } : {},
11451
11457
  tweens: acc.tweens,
11452
11458
  sets: acc.sets,
11453
11459
  badge: acc.badge
@@ -15919,7 +15925,7 @@ function validate(diag) {
15919
15925
  ...(diag.formulas ?? []).map((f) => f.id),
15920
15926
  ...(diag.scrollTriggers ?? []).map((t) => t.id)
15921
15927
  ]);
15922
- const suggest = (target, candidates) => {
15928
+ const suggest = (target, candidates, candidateKind = "lane") => {
15923
15929
  const list = [...candidates];
15924
15930
  if (list.length === 0) return "";
15925
15931
  let best = "";
@@ -15931,7 +15937,7 @@ function validate(diag) {
15931
15937
  best = c;
15932
15938
  }
15933
15939
  }
15934
- return bestD <= 2 ? ` (\u3082\u3057\u304B\u3057\u3066 "${best}"?)` : ` (\u5B9A\u7FA9\u6E08 lane: ${list.slice(0, 5).join(", ")}${list.length > 5 ? "..." : ""})`;
15940
+ return bestD <= 2 ? ` (\u3082\u3057\u304B\u3057\u3066 "${best}"?)` : ` (\u5B9A\u7FA9\u6E08 ${candidateKind}: ${list.slice(0, 5).join(", ")}${list.length > 5 ? "..." : ""})`;
15935
15941
  };
15936
15942
  for (const n of diag.nodes) {
15937
15943
  if (!laneIds.has(n.lane)) {
@@ -15944,13 +15950,13 @@ function validate(diag) {
15944
15950
  for (const e of diag.edges) {
15945
15951
  if (!nodeIds.has(e.from)) {
15946
15952
  errors.push(
15947
- `[cdl] unknown-ref: edge "${e.id}" \u306E from "${e.from}" \u304C node \u306B\u5B58\u5728\u3057\u307E\u305B\u3093${suggest(e.from, nodeIds)}
15953
+ `[cdl] unknown-ref: edge "${e.id}" \u306E from "${e.from}" \u304C node \u306B\u5B58\u5728\u3057\u307E\u305B\u3093${suggest(e.from, nodeIds, "node")}
15948
15954
  \u2192 \u4FEE\u6B63\u4F8B: .node("${e.from}", { lane: "...", stack: 0, kind: "actor", title: "..." }) \u3092 edge \u5BA3\u8A00\u524D\u306B\u8FFD\u52A0`
15949
15955
  );
15950
15956
  }
15951
15957
  if (!nodeIds.has(e.to)) {
15952
15958
  errors.push(
15953
- `[cdl] unknown-ref: edge "${e.id}" \u306E to "${e.to}" \u304C node \u306B\u5B58\u5728\u3057\u307E\u305B\u3093${suggest(e.to, nodeIds)}
15959
+ `[cdl] unknown-ref: edge "${e.id}" \u306E to "${e.to}" \u304C node \u306B\u5B58\u5728\u3057\u307E\u305B\u3093${suggest(e.to, nodeIds, "node")}
15954
15960
  \u2192 \u4FEE\u6B63\u4F8B: .node("${e.to}", { lane: "...", stack: 0, kind: "...", title: "..." }) \u3092 edge \u5BA3\u8A00\u524D\u306B\u8FFD\u52A0`
15955
15961
  );
15956
15962
  }
@@ -15967,6 +15973,16 @@ function validate(diag) {
15967
15973
  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)`);
15968
15974
  }
15969
15975
  }
15976
+ for (const id of p.draw ?? []) {
15977
+ if (!nodeIds.has(id)) {
15978
+ 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")}`);
15979
+ continue;
15980
+ }
15981
+ const kind = diag.nodes.find((n) => n.id === id)?.kind;
15982
+ if (kind !== "chart-line") {
15983
+ 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)`);
15984
+ }
15985
+ }
15970
15986
  for (const t of p.tweens) {
15971
15987
  if (!stateIds.has(t.stateId)) {
15972
15988
  errors.push(`[cdl] unknown-ref: phase "${p.id}" tween \u5BFE\u8C61 state "${t.stateId}" \u672A\u5B9A\u7FA9`);
@@ -21264,7 +21280,9 @@ function resolveMindData(data, values) {
21264
21280
  function ChartLineNode({
21265
21281
  node,
21266
21282
  active,
21267
- stateValues = {}
21283
+ stateValues = {},
21284
+ drawing = false,
21285
+ progress = 1
21268
21286
  }) {
21269
21287
  const x0 = node.cx - node.w / 2;
21270
21288
  const y0 = node.cy - node.h / 2;
@@ -21285,6 +21303,24 @@ function ChartLineNode({
21285
21303
  const xAt = (idx) => PAD_LEFT + (data.length <= 1 ? canvasW / 2 : canvasW * idx / (data.length - 1));
21286
21304
  const yAt = (v) => plotTop + plotH - (v - vMin) / vRange * plotH;
21287
21305
  const points = data.map((d, idx) => `${xAt(idx)},${yAt(d.value)}`).join(" ");
21306
+ const \u70B9\u307E\u3067\u306E\u9577\u3055 = [];
21307
+ let \u7DDA\u306E\u5168\u9577 = 0;
21308
+ let \u524D\u306E\u70B9;
21309
+ for (const [idx, datum] of data.entries()) {
21310
+ const \u4ECA\u306E\u70B9 = { x: xAt(idx), y: yAt(datum.value) };
21311
+ if (\u524D\u306E\u70B9) {
21312
+ \u7DDA\u306E\u5168\u9577 += Math.hypot(\u4ECA\u306E\u70B9.x - \u524D\u306E\u70B9.x, \u4ECA\u306E\u70B9.y - \u524D\u306E\u70B9.y);
21313
+ }
21314
+ \u70B9\u307E\u3067\u306E\u9577\u3055.push(\u7DDA\u306E\u5168\u9577);
21315
+ \u524D\u306E\u70B9 = \u4ECA\u306E\u70B9;
21316
+ }
21317
+ const \u4F38\u3073 = drawing ? Math.min(1, Math.max(0, Number.isFinite(progress) ? progress : 1)) : 1;
21318
+ const \u7DDA\u306E\u5148\u304C\u5C4A\u3044\u305F = (idx) => {
21319
+ if (!drawing) return true;
21320
+ if (data.length <= 1) return true;
21321
+ if (\u7DDA\u306E\u5168\u9577 === 0) return true;
21322
+ return \u4F38\u3073 >= (\u70B9\u307E\u3067\u306E\u9577\u3055[idx] ?? 0) / \u7DDA\u306E\u5168\u9577;
21323
+ };
21288
21324
  const gridCount = 4;
21289
21325
  const gridTicks = Array.from({ length: gridCount + 1 }, (_, i) => {
21290
21326
  const v = vMin + vRange * i / gridCount;
@@ -21362,7 +21398,8 @@ function ChartLineNode({
21362
21398
  stroke: "var(--cdl-tone-accent, #2d6a8f)",
21363
21399
  strokeWidth: 2.5,
21364
21400
  strokeLinejoin: "round",
21365
- strokeLinecap: "round"
21401
+ strokeLinecap: "round",
21402
+ ...drawing ? { pathLength: 1, strokeDasharray: 1, strokeDashoffset: 1 - \u4F38\u3073 } : {}
21366
21403
  }
21367
21404
  ),
21368
21405
  data.map((d, idx) => {
@@ -21373,40 +21410,43 @@ function ChartLineNode({
21373
21410
  const isValley = (prev === void 0 || d.value <= prev) && (next === void 0 || d.value <= next);
21374
21411
  const labelAbove = !isValley;
21375
21412
  const labelY = labelAbove ? cy - 12 : cy + 18;
21413
+ const \u51FA\u3059 = \u7DDA\u306E\u5148\u304C\u5C4A\u3044\u305F(idx);
21376
21414
  return /* @__PURE__ */ jsxs("g", { "data-cdl-unresolved": d.unresolved ? "true" : void 0, children: [
21377
- /* @__PURE__ */ jsx(
21378
- "circle",
21379
- {
21380
- cx,
21381
- cy,
21382
- r: 5,
21383
- fill: "var(--cdl-node-fill, #ffffff)",
21384
- stroke: "var(--cdl-tone-accent, #2d6a8f)",
21385
- strokeWidth: 2.5
21386
- }
21387
- ),
21388
- /* @__PURE__ */ jsx(
21389
- "circle",
21390
- {
21391
- cx,
21392
- cy,
21393
- r: 2.5,
21394
- fill: "var(--cdl-tone-accent, #2d6a8f)"
21395
- }
21396
- ),
21397
- /* @__PURE__ */ jsx(
21398
- "text",
21399
- {
21400
- "data-cdl-role": "chart-line-value",
21401
- x: cx,
21402
- y: labelY,
21403
- fontSize: 11,
21404
- fontWeight: 600,
21405
- textAnchor: "middle",
21406
- fill: "var(--cdl-text, #1a1f2a)",
21407
- children: d.value.toLocaleString()
21408
- }
21409
- ),
21415
+ \u51FA\u3059 && /* @__PURE__ */ jsxs(Fragment, { children: [
21416
+ /* @__PURE__ */ jsx(
21417
+ "circle",
21418
+ {
21419
+ cx,
21420
+ cy,
21421
+ r: 5,
21422
+ fill: "var(--cdl-node-fill, #ffffff)",
21423
+ stroke: "var(--cdl-tone-accent, #2d6a8f)",
21424
+ strokeWidth: 2.5
21425
+ }
21426
+ ),
21427
+ /* @__PURE__ */ jsx(
21428
+ "circle",
21429
+ {
21430
+ cx,
21431
+ cy,
21432
+ r: 2.5,
21433
+ fill: "var(--cdl-tone-accent, #2d6a8f)"
21434
+ }
21435
+ ),
21436
+ /* @__PURE__ */ jsx(
21437
+ "text",
21438
+ {
21439
+ "data-cdl-role": "chart-line-value",
21440
+ x: cx,
21441
+ y: labelY,
21442
+ fontSize: 11,
21443
+ fontWeight: 600,
21444
+ textAnchor: "middle",
21445
+ fill: "var(--cdl-text, #1a1f2a)",
21446
+ children: d.value.toLocaleString()
21447
+ }
21448
+ )
21449
+ ] }),
21410
21450
  /* @__PURE__ */ jsx(
21411
21451
  "text",
21412
21452
  {
@@ -26701,6 +26741,7 @@ function ShapeCustomerServiceNode({ node, active }) {
26701
26741
  function CdlNodeView({
26702
26742
  node,
26703
26743
  active,
26744
+ drawing = false,
26704
26745
  progress,
26705
26746
  stateValues,
26706
26747
  currentPhaseId
@@ -26750,7 +26791,16 @@ function CdlNodeView({
26750
26791
  // 数と語を取る 7 種に対し、mind-map / tree-hierarchy は **名前だけ** を取る (#467)。
26751
26792
  // 親子の繋がりと、描かれない欄 (補足) は解決しない。
26752
26793
  case "chart-line":
26753
- return /* @__PURE__ */ jsx(ChartLineNode, { node: resolvedNode, active, stateValues });
26794
+ return /* @__PURE__ */ jsx(
26795
+ ChartLineNode,
26796
+ {
26797
+ node: resolvedNode,
26798
+ active,
26799
+ stateValues,
26800
+ drawing,
26801
+ progress
26802
+ }
26803
+ );
26754
26804
  case "chart-pie":
26755
26805
  return /* @__PURE__ */ jsx(ChartPieNode, { node: resolvedNode, active, stateValues });
26756
26806
  case "chart-bar":
@@ -26944,6 +26994,7 @@ function CdlStage({
26944
26994
  svgRef
26945
26995
  }) {
26946
26996
  const activeSet = new Set(currentPhase?.activate ?? []);
26997
+ const drawSet = new Set(currentPhase?.draw ?? []);
26947
26998
  const { lifelineStarts, uniformFooterTop } = useMemo(() => {
26948
26999
  const starts = lifelineStartYs(laid.nodes);
26949
27000
  return {
@@ -27080,6 +27131,7 @@ function CdlStage({
27080
27131
  {
27081
27132
  node,
27082
27133
  active: activeSet.has(node.id),
27134
+ drawing: drawSet.has(node.id),
27083
27135
  progress,
27084
27136
  stateValues,
27085
27137
  currentPhaseId: currentPhase?.id