@cardenelabs/cdl 0.11.0 → 0.12.1

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.js CHANGED
@@ -15862,7 +15862,16 @@ function nodeTemplateTexts(node) {
15862
15862
 
15863
15863
  // src/validate.ts
15864
15864
  var TONES2 = new Set(TONES);
15865
- var DRAW_KINDS = /* @__PURE__ */ new Set(["chart-line", "chart-bar", "chart-pie"]);
15865
+ var DRAW_KINDS = /* @__PURE__ */ new Set([
15866
+ "chart-line",
15867
+ "chart-bar",
15868
+ "chart-pie",
15869
+ "journey-map",
15870
+ "mind-map",
15871
+ "tree-hierarchy",
15872
+ "gantt-timeline",
15873
+ "funnel-stages"
15874
+ ]);
15866
15875
  var KINDS = new Set(NODE_KINDS);
15867
15876
  var ENG_BANNED = /\b(FUNCTION|STORAGE|EVENT LOG|BALANCES MAPPING|READ|WRITE|EMIT|CALL)\b/;
15868
15877
  function validate(diag) {
@@ -21280,6 +21289,44 @@ function resolveMindData(data, values) {
21280
21289
  const \u89E3\u6C7A\u5F8C = { ...data, rootTitle: root.value, branches };
21281
21290
  return root.ok ? \u89E3\u6C7A\u5F8C : { ...\u89E3\u6C7A\u5F8C, unresolved: true };
21282
21291
  }
21292
+
21293
+ // src/kinds/draw-progress.ts
21294
+ function \u9032\u307F\u3092\u7573\u3080(drawing, progress) {
21295
+ if (!drawing) return 1;
21296
+ return Math.min(1, Math.max(0, Number.isFinite(progress) ? progress : 1));
21297
+ }
21298
+ function \u4F38\u3070\u3059dash(drawing, \u4F38\u3073) {
21299
+ if (!drawing) return {};
21300
+ return { pathLength: 1, strokeDasharray: 1, strokeDashoffset: 1 - \u4F38\u3073 };
21301
+ }
21302
+ function \u6BB5\u306E\u4F38\u3073(\u4F38\u3073, \u6DF1\u3055, \u6700\u5927\u6DF1\u3055) {
21303
+ if (\u6700\u5927\u6DF1\u3055 <= 0 || \u6DF1\u3055 <= 0) return 1;
21304
+ const \u5E45 = 1 / \u6700\u5927\u6DF1\u3055;
21305
+ const \u59CB\u307E\u308A = (\u6DF1\u3055 - 1) * \u5E45;
21306
+ return Math.min(1, Math.max(0, (\u4F38\u3073 - \u59CB\u307E\u308A) / \u5E45));
21307
+ }
21308
+ function \u30D9\u30B8\u30A8\u306E\u7D2F\u7A4D\u5272\u5408(\u70B9, \u5236\u5FA1\u70B9, \u5206\u5272\u6570 = 16) {
21309
+ if (\u70B9.length <= 1) return \u70B9.map(() => 0);
21310
+ const \u9577\u3055 = [0];
21311
+ let \u5408\u8A08 = 0;
21312
+ for (let i = 1; i < \u70B9.length; i++) {
21313
+ const p0 = \u70B9[i - 1];
21314
+ const p3 = \u70B9[i];
21315
+ const [p1, p2] = \u5236\u5FA1\u70B9(p0, p3);
21316
+ let \u524D = p0;
21317
+ for (let s = 1; s <= \u5206\u5272\u6570; s++) {
21318
+ const t = s / \u5206\u5272\u6570;
21319
+ const u = 1 - t;
21320
+ const x = u * u * u * p0.x + 3 * u * u * t * p1.x + 3 * u * t * t * p2.x + t * t * t * p3.x;
21321
+ const y = u * u * u * p0.y + 3 * u * u * t * p1.y + 3 * u * t * t * p2.y + t * t * t * p3.y;
21322
+ \u5408\u8A08 += Math.hypot(x - \u524D.x, y - \u524D.y);
21323
+ \u524D = { x, y };
21324
+ }
21325
+ \u9577\u3055.push(\u5408\u8A08);
21326
+ }
21327
+ if (\u5408\u8A08 === 0) return \u70B9.map(() => 0);
21328
+ return \u9577\u3055.map((l) => l / \u5408\u8A08);
21329
+ }
21283
21330
  function ChartLineNode({
21284
21331
  node,
21285
21332
  active,
@@ -21317,7 +21364,7 @@ function ChartLineNode({
21317
21364
  \u70B9\u307E\u3067\u306E\u9577\u3055.push(\u7DDA\u306E\u5168\u9577);
21318
21365
  \u524D\u306E\u70B9 = \u4ECA\u306E\u70B9;
21319
21366
  }
21320
- const \u4F38\u3073 = drawing ? Math.min(1, Math.max(0, Number.isFinite(progress) ? progress : 1)) : 1;
21367
+ const \u4F38\u3073 = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
21321
21368
  const \u7DDA\u306E\u5148\u304C\u5C4A\u3044\u305F = (idx) => {
21322
21369
  if (!drawing) return true;
21323
21370
  if (data.length <= 1) return true;
@@ -21402,7 +21449,7 @@ function ChartLineNode({
21402
21449
  strokeWidth: 2.5,
21403
21450
  strokeLinejoin: "round",
21404
21451
  strokeLinecap: "round",
21405
- ...drawing ? { pathLength: 1, strokeDasharray: 1, strokeDashoffset: 1 - \u4F38\u3073 } : {}
21452
+ ...\u4F38\u3070\u3059dash(drawing, \u4F38\u3073)
21406
21453
  }
21407
21454
  ),
21408
21455
  data.map((d, idx) => {
@@ -21502,7 +21549,7 @@ function ChartPieNode({
21502
21549
  const path = `M ${cx} ${cy} L ${x1} ${y1} A ${radius} ${radius} 0 ${large} 1 ${x2} ${y2} Z`;
21503
21550
  return { d, frac, path, startFrac };
21504
21551
  });
21505
- const \u958B\u304D = drawing ? Math.min(1, Math.max(0, Number.isFinite(progress) ? progress : 1)) : 1;
21552
+ const \u958B\u304D = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
21506
21553
  const \u5207\u308A\u629C\u304Did = `cdl-pie-draw-${instanceId}`;
21507
21554
  const \u958B\u304D\u59CB\u3081\u305F = (startFrac) => !drawing || \u958B\u304D > startFrac;
21508
21555
  const legendX = pieAreaW + 8;
@@ -21617,7 +21664,7 @@ function ChartBarNode({
21617
21664
  const v = vMax * i / gridCount;
21618
21665
  return { y: yAt(v), value: v };
21619
21666
  });
21620
- const \u4F38\u3073 = drawing ? Math.min(1, Math.max(0, Number.isFinite(progress) ? progress : 1)) : 1;
21667
+ const \u4F38\u3073 = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
21621
21668
  const \u6A2A\u8EF8\u306Ey = PAD_TOP + canvasH;
21622
21669
  return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
21623
21670
  /* @__PURE__ */ jsx(
@@ -21721,7 +21768,9 @@ function ChartBarNode({
21721
21768
  function GanttNode({
21722
21769
  node,
21723
21770
  active,
21724
- stateValues = {}
21771
+ stateValues = {},
21772
+ drawing = false,
21773
+ progress = 1
21725
21774
  }) {
21726
21775
  const x0 = node.cx - node.w / 2;
21727
21776
  const y0 = node.cy - node.h / 2;
@@ -21780,6 +21829,7 @@ function GanttNode({
21780
21829
  const \u5E2F\u306E\u4F59\u767D = Math.min(6, cellW / 2);
21781
21830
  const \u5E2F\u306E\u5DE6 = (idx) => xAt(idx) + \u5E2F\u306E\u4F59\u767D / 2;
21782
21831
  const \u5E2F\u306E\u53F3 = (idx) => xAt(idx) + cellW - \u5E2F\u306E\u4F59\u767D / 2;
21832
+ const \u4F38\u3073 = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
21783
21833
  const taskById = new Map(\u6574\u3048\u305F.map((t) => [t.id, t]));
21784
21834
  const rowOf = new Map(\u6574\u3048\u305F.map((t, i) => [t.id, i]));
21785
21835
  return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
@@ -21854,34 +21904,41 @@ function GanttNode({
21854
21904
  const bx = \u5E2F\u306E\u5DE6(t.startIdx);
21855
21905
  const by = yAt(row);
21856
21906
  const bw = Math.max(0, \u5E2F\u306E\u53F3(t.endIdx) - bx);
21857
- return /* @__PURE__ */ jsxs("g", { children: [
21858
- /* @__PURE__ */ jsx(
21859
- "rect",
21860
- {
21861
- "data-cdl-role": "gantt-bar",
21862
- "data-cdl-unresolved": t.unresolved ? "true" : void 0,
21863
- "data-cdl-clipped": "clipped" in t && t.clipped ? "true" : void 0,
21864
- x: bx,
21865
- y: by,
21866
- width: bw,
21867
- height: rowH,
21868
- rx: 4,
21869
- fill: toneColor3(t.tone),
21870
- fillOpacity: 0.9
21871
- }
21872
- ),
21873
- t.owner && rowH >= 22 && /* @__PURE__ */ jsx(
21874
- "text",
21875
- {
21876
- x: bx + 8,
21877
- y: by + rowH / 2 + 4,
21878
- fontSize: 11,
21879
- fill: "var(--cdl-node-fill, #ffffff)",
21880
- fontWeight: 600,
21881
- children: t.owner
21882
- }
21883
- )
21884
- ] }, `bar-${t.id}`);
21907
+ return /* @__PURE__ */ jsxs(
21908
+ "g",
21909
+ {
21910
+ ...drawing ? { transform: `translate(${bx} 0) scale(${\u4F38\u3073} 1) translate(${-bx} 0)` } : {},
21911
+ children: [
21912
+ /* @__PURE__ */ jsx(
21913
+ "rect",
21914
+ {
21915
+ "data-cdl-role": "gantt-bar",
21916
+ "data-cdl-unresolved": t.unresolved ? "true" : void 0,
21917
+ "data-cdl-clipped": "clipped" in t && t.clipped ? "true" : void 0,
21918
+ x: bx,
21919
+ y: by,
21920
+ width: bw,
21921
+ height: rowH,
21922
+ rx: 4,
21923
+ fill: toneColor3(t.tone),
21924
+ fillOpacity: 0.9
21925
+ }
21926
+ ),
21927
+ t.owner && rowH >= 22 && /* @__PURE__ */ jsx(
21928
+ "text",
21929
+ {
21930
+ x: bx + 8,
21931
+ y: by + rowH / 2 + 4,
21932
+ fontSize: 11,
21933
+ fill: "var(--cdl-node-fill, #ffffff)",
21934
+ fontWeight: 600,
21935
+ children: t.owner
21936
+ }
21937
+ )
21938
+ ]
21939
+ },
21940
+ `bar-${t.id}`
21941
+ );
21885
21942
  }),
21886
21943
  \u6574\u3048\u305F.filter((t) => t.dependsOn && taskById.has(t.dependsOn)).map((t) => {
21887
21944
  const parent = taskById.get(t.dependsOn);
@@ -21901,29 +21958,33 @@ function GanttNode({
21901
21958
  const hasRoom = enterX - startX >= elbowGap;
21902
21959
  const path = hasRoom ? `M ${startX} ${parentMidY} L ${enterX} ${parentMidY} L ${enterX} ${tipY} L ${tipX} ${tipY}` : `M ${startX} ${parentMidY} L ${startX + elbowGap} ${parentMidY} L ${startX + elbowGap} ${(parentMidY + tipY) / 2} L ${enterX} ${(parentMidY + tipY) / 2} L ${enterX} ${tipY} L ${tipX} ${tipY}`;
21903
21960
  const arrowHeadPath = `M ${tipX + arrowHeadSize} ${tipY} L ${tipX} ${tipY - arrowHeadSize / 2} L ${tipX} ${tipY + arrowHeadSize / 2} Z`;
21904
- return /* @__PURE__ */ jsxs("g", { "data-cdl-role": "gantt-arrow", children: [
21905
- /* @__PURE__ */ jsx(
21906
- "path",
21907
- {
21908
- d: path,
21909
- fill: "none",
21910
- stroke: "var(--cdl-text-mute, #8a8678)",
21911
- strokeWidth: 1.75,
21912
- strokeLinejoin: "round",
21913
- strokeLinecap: "round"
21914
- }
21915
- ),
21916
- /* @__PURE__ */ jsx(
21917
- "path",
21918
- {
21919
- d: arrowHeadPath,
21920
- fill: "var(--cdl-text-mute, #8a8678)",
21921
- stroke: "var(--cdl-text-mute, #8a8678)",
21922
- strokeWidth: 0.5,
21923
- strokeLinejoin: "round"
21924
- }
21925
- )
21926
- ] }, `dep-${parent.id}-${t.id}`);
21961
+ return (
21962
+ // 矢印は両端の帯が出てから描く。 帯が無い場所へ矢印だけが伸びると、
21963
+ // 指す先の無い線になる (cdl#521)
21964
+ drawing && \u4F38\u3073 < 1 ? null : /* @__PURE__ */ jsxs("g", { "data-cdl-role": "gantt-arrow", children: [
21965
+ /* @__PURE__ */ jsx(
21966
+ "path",
21967
+ {
21968
+ d: path,
21969
+ fill: "none",
21970
+ stroke: "var(--cdl-text-mute, #8a8678)",
21971
+ strokeWidth: 1.75,
21972
+ strokeLinejoin: "round",
21973
+ strokeLinecap: "round"
21974
+ }
21975
+ ),
21976
+ /* @__PURE__ */ jsx(
21977
+ "path",
21978
+ {
21979
+ d: arrowHeadPath,
21980
+ fill: "var(--cdl-text-mute, #8a8678)",
21981
+ stroke: "var(--cdl-text-mute, #8a8678)",
21982
+ strokeWidth: 0.5,
21983
+ strokeLinejoin: "round"
21984
+ }
21985
+ )
21986
+ ] }, `dep-${parent.id}-${t.id}`)
21987
+ );
21927
21988
  })
21928
21989
  ] });
21929
21990
  }
@@ -21937,17 +21998,20 @@ var \u884C\u9001\u308A\u306E\u6BD4 = 1.15;
21937
21998
  var \u5B57\u306E\u9AD8\u3055\u306E\u6BD4 = 0.72;
21938
21999
  var \u4E0A\u4E0B\u306E\u4F59\u767D = 2;
21939
22000
  var \u5DE6\u53F3\u306E\u4F59\u767D = 8;
21940
- function \u5E45\u3067\u5207\u308B(text, fontSize, \u4F7F\u3048\u308B\u5E45, \u6E2C\u308B = textWidth) {
21941
- if (\u4F7F\u3048\u308B\u5E45 <= 0) return "";
21942
- if (\u6E2C\u308B(text, fontSize) <= \u4F7F\u3048\u308B\u5E45) return text;
22001
+ function \u4F7F\u3048\u308B\u5E45(\u7BB1\u306E\u5E45) {
22002
+ return \u7BB1\u306E\u5E45 - \u5DE6\u53F3\u306E\u4F59\u767D * 2;
22003
+ }
22004
+ function \u5E45\u3067\u5207\u308B(text, fontSize, \u4F7F\u3048\u308B\u5E452, \u6E2C\u308B = textWidth) {
22005
+ if (\u4F7F\u3048\u308B\u5E452 <= 0) return "";
22006
+ if (\u6E2C\u308B(text, fontSize) <= \u4F7F\u3048\u308B\u5E452) return text;
21943
22007
  const \u7701\u7565 = "\u2026";
21944
22008
  const \u7701\u7565\u306E\u5E45 = \u6E2C\u308B(\u7701\u7565, fontSize);
21945
- if (\u7701\u7565\u306E\u5E45 > \u4F7F\u3048\u308B\u5E45) return "";
22009
+ if (\u7701\u7565\u306E\u5E45 > \u4F7F\u3048\u308B\u5E452) return "";
21946
22010
  let \u51FA = "";
21947
22011
  let \u5E45 = 0;
21948
22012
  for (const c of \u66F8\u8A18\u7D20\u306B\u5206\u3051\u308B(text)) {
21949
22013
  const \u5B57\u306E\u5E452 = \u6E2C\u308B(c, fontSize);
21950
- if (\u5E45 + \u5B57\u306E\u5E452 + \u7701\u7565\u306E\u5E45 > \u4F7F\u3048\u308B\u5E45) break;
22014
+ if (\u5E45 + \u5B57\u306E\u5E452 + \u7701\u7565\u306E\u5E45 > \u4F7F\u3048\u308B\u5E452) break;
21951
22015
  \u5E45 += \u5B57\u306E\u5E452;
21952
22016
  \u51FA += c;
21953
22017
  }
@@ -21965,13 +22029,13 @@ function \u7BB1\u306B\u7A4D\u3080(\u884C, \u7BB1\u306E\u5E45, \u7BB1\u306E\u9AD8
21965
22029
  const \u9AD8\u3055 = (rs) => rs.reduce((a, r) => a + r.fontSize * \u884C\u9001\u308A\u306E\u6BD4, 0);
21966
22030
  const \u6B8B\u3059 = [...\u5019\u88DC];
21967
22031
  while (\u6B8B\u3059.length > 1 && \u9AD8\u3055(\u6B8B\u3059) > \u4F7F\u3048\u308B\u9AD8\u3055) \u6B8B\u3059.pop();
21968
- const \u4F7F\u3048\u308B\u5E45 = \u7BB1\u306E\u5E45 - \u5DE6\u53F3\u306E\u4F59\u767D * 2;
22032
+ const \u5E45 = \u4F7F\u3048\u308B\u5E45(\u7BB1\u306E\u5E45);
21969
22033
  const \u7DCF\u9AD8 = \u9AD8\u3055(\u6B8B\u3059);
21970
22034
  let \u7A4D\u307F = -\u7DCF\u9AD8 / 2;
21971
22035
  return \u6B8B\u3059.map((r) => {
21972
22036
  const dy = \u7A4D\u307F + (\u884C\u9001\u308A\u306E\u6BD4 + \u5B57\u306E\u9AD8\u3055\u306E\u6BD4) / 2 * r.fontSize;
21973
22037
  \u7A4D\u307F += r.fontSize * \u884C\u9001\u308A\u306E\u6BD4;
21974
- return { ...r, text: \u5E45\u3067\u5207\u308B(r.text, r.fontSize, \u4F7F\u3048\u308B\u5E45), dy };
22038
+ return { ...r, text: \u5E45\u3067\u5207\u308B(r.text, r.fontSize, \u5E45), dy };
21975
22039
  });
21976
22040
  }
21977
22041
  var MIND_TONES = ["accent", "teal", "success", "warning", "info", "error"];
@@ -21979,7 +22043,9 @@ var MIND_BOX_GAP = 24;
21979
22043
  function MindMapNode({
21980
22044
  node,
21981
22045
  active,
21982
- stateValues = {}
22046
+ stateValues = {},
22047
+ drawing = false,
22048
+ progress = 1
21983
22049
  }) {
21984
22050
  const x0 = node.cx - node.w / 2;
21985
22051
  const y0 = node.cy - node.h / 2;
@@ -21991,6 +22057,9 @@ function MindMapNode({
21991
22057
  const canvasW = node.w - PAD * 2;
21992
22058
  const canvasH = node.h - PAD * 2;
21993
22059
  const layout2 = computeMindMapLayout(mindData, canvasCx, canvasCy, canvasW, canvasH);
22060
+ const \u4F38\u3073 = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
22061
+ const \u6700\u5927\u6DF1\u3055 = layout2.nodes.reduce((m, n) => Math.max(m, n.depth), 0);
22062
+ const \u7BB1\u304C\u51FA\u308B = (\u6DF1\u3055) => !drawing || \u6BB5\u306E\u4F38\u3073(\u4F38\u3073, \u6DF1\u3055, \u6700\u5927\u6DF1\u3055) >= 1;
21994
22063
  return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
21995
22064
  /* @__PURE__ */ jsx(
21996
22065
  "rect",
@@ -22006,20 +22075,25 @@ function MindMapNode({
22006
22075
  strokeWidth: active ? 3 : 1.25
22007
22076
  }
22008
22077
  ),
22009
- layout2.edges.map((e, i) => /* @__PURE__ */ jsx(
22010
- "path",
22011
- {
22012
- "data-cdl-role": "mind-edge",
22013
- d: e.d,
22014
- fill: "none",
22015
- stroke: toneColor4(e.tone),
22016
- strokeWidth: 2.5,
22017
- strokeOpacity: 0.55,
22018
- strokeLinecap: "round"
22019
- },
22020
- `edge-${i}`
22021
- )),
22078
+ layout2.edges.map((e, i) => {
22079
+ const \u679D\u306E\u4F38\u3073 = e.deferUntilComplete ? \u4F38\u3073 >= 1 ? 1 : 0 : \u6BB5\u306E\u4F38\u3073(\u4F38\u3073, e.depth, \u6700\u5927\u6DF1\u3055);
22080
+ return /* @__PURE__ */ jsx(
22081
+ "path",
22082
+ {
22083
+ "data-cdl-role": "mind-edge",
22084
+ d: e.d,
22085
+ fill: "none",
22086
+ stroke: toneColor4(e.tone),
22087
+ strokeWidth: 2.5,
22088
+ strokeOpacity: 0.55,
22089
+ strokeLinecap: "round",
22090
+ ...\u4F38\u3070\u3059dash(drawing, \u679D\u306E\u4F38\u3073)
22091
+ },
22092
+ `edge-${i}`
22093
+ );
22094
+ }),
22022
22095
  layout2.nodes.map((n) => {
22096
+ if (!\u7BB1\u304C\u51FA\u308B(n.depth)) return null;
22023
22097
  const \u884C = \u7BB1\u306B\u7A4D\u3080(
22024
22098
  [
22025
22099
  { \u5F79\u5272: "title", text: n.title, fontSize: n.isRoot ? 15 : 13 },
@@ -22058,17 +22132,22 @@ function MindMapNode({
22058
22132
  children: r.text
22059
22133
  },
22060
22134
  r.\u5F79\u5272
22061
- )) : /* @__PURE__ */ jsx(
22062
- "text",
22063
- {
22064
- x: n.x,
22065
- y: n.y + 5,
22066
- fontSize: n.isRoot ? 15 : 13,
22067
- fontWeight: n.isRoot ? 700 : 600,
22068
- textAnchor: "middle",
22069
- fill: \u6587\u5B57\u306E\u8272,
22070
- children: n.title
22071
- }
22135
+ )) : (
22136
+ // 補足が無くても **幅に収める** (#526)。 `箱に積む` を通らないこの経路だけが
22137
+ // 幅を見ておらず、長い名前がそのまま箱の外へ出て枝の線と重なっていた
22138
+ // (実測 = 中心の箱で文字 163px に対し箱 120px)
22139
+ /* @__PURE__ */ jsx(
22140
+ "text",
22141
+ {
22142
+ x: n.x,
22143
+ y: n.y + 5,
22144
+ fontSize: n.isRoot ? 15 : 13,
22145
+ fontWeight: n.isRoot ? 700 : 600,
22146
+ textAnchor: "middle",
22147
+ fill: \u6587\u5B57\u306E\u8272,
22148
+ children: \u5E45\u3067\u5207\u308B(n.title, n.isRoot ? 15 : 13, \u4F7F\u3048\u308B\u5E45(n.w))
22149
+ }
22150
+ )
22072
22151
  )
22073
22152
  ] }, `n-${n.id}`);
22074
22153
  })
@@ -22087,6 +22166,8 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
22087
22166
  w: rootW,
22088
22167
  h: rootH,
22089
22168
  isRoot: true,
22169
+ // 中心は起点なので段数 0 (cdl#520)
22170
+ depth: 0,
22090
22171
  ...mindData.unresolved ? { unresolved: true } : {}
22091
22172
  });
22092
22173
  const childrenOf = /* @__PURE__ */ new Map();
@@ -22198,6 +22279,8 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
22198
22279
  y,
22199
22280
  w,
22200
22281
  h,
22282
+ // 第 1 階層が段数 1 (`subDepth` は 0 始まり、 cdl#520)
22283
+ depth: subDepth + 1,
22201
22284
  tone: myTone,
22202
22285
  isRoot: false,
22203
22286
  ...node.unresolved ? { unresolved: true } : {}
@@ -22239,23 +22322,36 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
22239
22322
  }
22240
22323
  }
22241
22324
  }
22325
+ const \u6BB5\u6570 = new Map(nodes.map((n) => [n.id, n.depth]));
22242
22326
  for (const br of mindData.branches) {
22243
22327
  const childPos = nodePos.get(br.id);
22244
22328
  if (!childPos) continue;
22245
22329
  const isLeft = nodeSide.get(br.id) === "left";
22246
22330
  const childHalfW = nodeHalfW.get(br.id) ?? subBranchW / 2;
22247
22331
  const tone = nodeTone.get(br.id);
22332
+ const childDepth = \u6BB5\u6570.get(br.id) ?? 1;
22333
+ const parentDepth = \u6BB5\u6570.get(br.parent) ?? 0;
22248
22334
  if (br.parent === mindData.rootId) {
22249
22335
  const startX = rootEdgeXFor(isLeft);
22250
22336
  const endX = childPos.x + (isLeft ? childHalfW : -childHalfW);
22251
- edges.push({ d: makeCurve(startX, cy, endX, childPos.y), tone });
22337
+ edges.push({
22338
+ d: makeCurve(startX, cy, endX, childPos.y),
22339
+ tone,
22340
+ depth: childDepth,
22341
+ deferUntilComplete: false
22342
+ });
22252
22343
  } else {
22253
22344
  const parentPos = nodePos.get(br.parent);
22254
22345
  if (!parentPos) continue;
22255
22346
  const parentHalfW = nodeHalfW.get(br.parent) ?? branchW / 2;
22256
22347
  const startX = parentPos.x + (isLeft ? -parentHalfW : parentHalfW);
22257
22348
  const endX = childPos.x + (isLeft ? childHalfW : -childHalfW);
22258
- edges.push({ d: makeCurve(startX, parentPos.y, endX, childPos.y), tone });
22349
+ edges.push({
22350
+ d: makeCurve(startX, parentPos.y, endX, childPos.y),
22351
+ tone,
22352
+ depth: Math.max(parentDepth, childDepth),
22353
+ deferUntilComplete: parentDepth >= childDepth
22354
+ });
22259
22355
  }
22260
22356
  }
22261
22357
  return { nodes, edges };
@@ -22275,7 +22371,9 @@ function toneColor4(tone, alpha = 1) {
22275
22371
  function FunnelNode({
22276
22372
  node,
22277
22373
  active,
22278
- stateValues = {}
22374
+ stateValues = {},
22375
+ drawing = false,
22376
+ progress = 1
22279
22377
  }) {
22280
22378
  const x0 = node.cx - node.w / 2;
22281
22379
  const y0 = node.cy - node.h / 2;
@@ -22290,12 +22388,79 @@ function FunnelNode({
22290
22388
  const stageCount = stages.length || 1;
22291
22389
  const gap = 4;
22292
22390
  const stageH = (canvasH - gap * (stageCount - 1)) / stageCount;
22391
+ const \u4F38\u3073 = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
22392
+ const \u5207\u308A\u629C\u304Did = `cdl-funnel-draw-${useId().replace(/[^A-Za-z0-9_-]/g, "")}`;
22393
+ const \u6BB5\u306E\u4E0B\u7AEF\u306E\u5272\u5408 = (idx) => {
22394
+ if (canvasH <= 0) return 0;
22395
+ return ((idx + 1) * stageH + idx * gap) / canvasH;
22396
+ };
22397
+ const \u6BB5\u304C\u51FA\u5207\u3063\u305F = (idx) => !drawing || \u4F38\u3073 >= \u6BB5\u306E\u4E0B\u7AEF\u306E\u5272\u5408(idx);
22293
22398
  const widthAtStep = (step) => {
22294
22399
  const topRatio = 1;
22295
22400
  const bottomRatio = 0.35;
22296
22401
  const t = step / stageCount;
22297
22402
  return canvasW * (topRatio + (bottomRatio - topRatio) * t);
22298
22403
  };
22404
+ const \u6BB5 = stages.map((s, idx) => {
22405
+ const prev = idx > 0 ? stages[idx - 1] : null;
22406
+ const dropRate = prev && prev.count > 0 ? (prev.count - s.count) / prev.count * 100 : 0;
22407
+ const y = PAD_TOP + idx * (stageH + gap);
22408
+ const topW = widthAtStep(idx);
22409
+ const bottomW = widthAtStep(idx + 1);
22410
+ const cx = PAD_LEFT + canvasW / 2;
22411
+ const topX = cx - topW / 2;
22412
+ const bottomX = cx - bottomW / 2;
22413
+ const points = `${topX},${y} ${topX + topW},${y} ${bottomX + bottomW},${y + stageH} ${bottomX},${y + stageH}`;
22414
+ const tone = toneByIndex(idx);
22415
+ const legendX = PAD_LEFT + canvasW + 24;
22416
+ return /* @__PURE__ */ jsxs("g", { children: [
22417
+ /* @__PURE__ */ jsx(
22418
+ "polygon",
22419
+ {
22420
+ "data-cdl-role": "funnel-stage",
22421
+ "data-cdl-unresolved": s.unresolved ? "true" : void 0,
22422
+ points,
22423
+ fill: tone,
22424
+ fillOpacity: 0.9,
22425
+ stroke: tone,
22426
+ strokeWidth: 0
22427
+ }
22428
+ ),
22429
+ /* @__PURE__ */ jsx(
22430
+ "text",
22431
+ {
22432
+ x: cx,
22433
+ y: y + stageH / 2 + 5,
22434
+ fontSize: 14,
22435
+ fontWeight: 700,
22436
+ textAnchor: "middle",
22437
+ fill: "var(--cdl-node-fill, #ffffff)",
22438
+ children: s.title
22439
+ }
22440
+ ),
22441
+ \u6BB5\u304C\u51FA\u5207\u3063\u305F(idx) && /* @__PURE__ */ jsx(
22442
+ "text",
22443
+ {
22444
+ x: legendX,
22445
+ y: y + stageH / 2 - 2,
22446
+ fontSize: 13,
22447
+ fontWeight: 700,
22448
+ fill: "var(--cdl-text, #1a1f2a)",
22449
+ children: s.count.toLocaleString()
22450
+ }
22451
+ ),
22452
+ \u6BB5\u304C\u51FA\u5207\u3063\u305F(idx) && prev && /* @__PURE__ */ jsx(
22453
+ "text",
22454
+ {
22455
+ x: legendX,
22456
+ y: y + stageH / 2 + 14,
22457
+ fontSize: 11,
22458
+ fill: dropRate > 0 ? "var(--cdl-text-dim, #5a6270)" : "var(--cdl-text-mute, #8a8678)",
22459
+ children: dropRate > 0 ? `\u2193 ${dropRate.toFixed(1)}%` : "\xB10%"
22460
+ }
22461
+ )
22462
+ ] }, `stage-${s.id}`);
22463
+ });
22299
22464
  return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
22300
22465
  /* @__PURE__ */ jsx(
22301
22466
  "rect",
@@ -22311,66 +22476,8 @@ function FunnelNode({
22311
22476
  strokeWidth: active ? 3 : 1.25
22312
22477
  }
22313
22478
  ),
22314
- stages.map((s, idx) => {
22315
- const prev = idx > 0 ? stages[idx - 1] : null;
22316
- const dropRate = prev && prev.count > 0 ? (prev.count - s.count) / prev.count * 100 : 0;
22317
- const y = PAD_TOP + idx * (stageH + gap);
22318
- const topW = widthAtStep(idx);
22319
- const bottomW = widthAtStep(idx + 1);
22320
- const cx = PAD_LEFT + canvasW / 2;
22321
- const topX = cx - topW / 2;
22322
- const bottomX = cx - bottomW / 2;
22323
- const points = `${topX},${y} ${topX + topW},${y} ${bottomX + bottomW},${y + stageH} ${bottomX},${y + stageH}`;
22324
- const tone = toneByIndex(idx);
22325
- const legendX = PAD_LEFT + canvasW + 24;
22326
- return /* @__PURE__ */ jsxs("g", { children: [
22327
- /* @__PURE__ */ jsx(
22328
- "polygon",
22329
- {
22330
- "data-cdl-role": "funnel-stage",
22331
- "data-cdl-unresolved": s.unresolved ? "true" : void 0,
22332
- points,
22333
- fill: tone,
22334
- fillOpacity: 0.9,
22335
- stroke: tone,
22336
- strokeWidth: 0
22337
- }
22338
- ),
22339
- /* @__PURE__ */ jsx(
22340
- "text",
22341
- {
22342
- x: cx,
22343
- y: y + stageH / 2 + 5,
22344
- fontSize: 14,
22345
- fontWeight: 700,
22346
- textAnchor: "middle",
22347
- fill: "var(--cdl-node-fill, #ffffff)",
22348
- children: s.title
22349
- }
22350
- ),
22351
- /* @__PURE__ */ jsx(
22352
- "text",
22353
- {
22354
- x: legendX,
22355
- y: y + stageH / 2 - 2,
22356
- fontSize: 13,
22357
- fontWeight: 700,
22358
- fill: "var(--cdl-text, #1a1f2a)",
22359
- children: s.count.toLocaleString()
22360
- }
22361
- ),
22362
- prev && /* @__PURE__ */ jsx(
22363
- "text",
22364
- {
22365
- x: legendX,
22366
- y: y + stageH / 2 + 14,
22367
- fontSize: 11,
22368
- fill: dropRate > 0 ? "var(--cdl-text-dim, #5a6270)" : "var(--cdl-text-mute, #8a8678)",
22369
- children: dropRate > 0 ? `\u2193 ${dropRate.toFixed(1)}%` : "\xB10%"
22370
- }
22371
- )
22372
- ] }, `stage-${s.id}`);
22373
- })
22479
+ drawing && /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: \u5207\u308A\u629C\u304Did, children: /* @__PURE__ */ jsx("rect", { x: 0, y: 0, width: node.w, height: PAD_TOP + canvasH * \u4F38\u3073 }) }) }),
22480
+ drawing ? /* @__PURE__ */ jsx("g", { clipPath: `url(#${\u5207\u308A\u629C\u304Did})`, children: \u6BB5 }) : \u6BB5
22374
22481
  ] });
22375
22482
  }
22376
22483
  var TONE_ORDER = [
@@ -22556,7 +22663,9 @@ function \u7BB1\u306E\u6587\u5B57({
22556
22663
  function TreeNode({
22557
22664
  node,
22558
22665
  active,
22559
- stateValues = {}
22666
+ stateValues = {},
22667
+ drawing = false,
22668
+ progress = 1
22560
22669
  }) {
22561
22670
  const x0 = node.cx - node.w / 2;
22562
22671
  const y0 = node.cy - node.h / 2;
@@ -22569,6 +22678,9 @@ function TreeNode({
22569
22678
  const canvasW = node.w - PAD_LEFT - PAD_RIGHT;
22570
22679
  const canvasH = node.h - PAD_TOP - PAD_BOTTOM;
22571
22680
  const layout2 = computeTreeLayout(treeNodes, canvasW, canvasH);
22681
+ const \u4F38\u3073 = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
22682
+ const \u6700\u5927\u6DF1\u3055 = layout2.nodes.reduce((m, n) => Math.max(m, n.depth), 0);
22683
+ const \u7BB1\u304C\u51FA\u308B = (\u6DF1\u3055) => !drawing || \u6BB5\u306E\u4F38\u3073(\u4F38\u3073, \u6DF1\u3055, \u6700\u5927\u6DF1\u3055) >= 1;
22572
22684
  const depthColors = [TONE.accent, TONE.teal, TONE.success, TONE.warning, TONE.info];
22573
22685
  return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
22574
22686
  /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: gradientId, x1: "0%", y1: "0%", x2: "0%", y2: "100%", children: [
@@ -22596,6 +22708,7 @@ function TreeNode({
22596
22708
  const y2 = PAD_TOP + e.y2;
22597
22709
  const midY = (y1 + y2) / 2;
22598
22710
  const path = `M ${x1} ${y1} L ${x1} ${midY} L ${x2} ${midY} L ${x2} ${y2}`;
22711
+ const \u679D\u306E\u4F38\u3073 = e.deferUntilComplete ? \u4F38\u3073 >= 1 ? 1 : 0 : \u6BB5\u306E\u4F38\u3073(\u4F38\u3073, e.depth, \u6700\u5927\u6DF1\u3055);
22599
22712
  return /* @__PURE__ */ jsxs("g", { children: [
22600
22713
  /* @__PURE__ */ jsx(
22601
22714
  "path",
@@ -22606,13 +22719,15 @@ function TreeNode({
22606
22719
  stroke: TONE.accent,
22607
22720
  strokeOpacity: 0.55,
22608
22721
  strokeWidth: 1.5,
22609
- strokeLinejoin: "round"
22722
+ strokeLinejoin: "round",
22723
+ ...\u4F38\u3070\u3059dash(drawing, \u679D\u306E\u4F38\u3073)
22610
22724
  }
22611
22725
  ),
22612
- /* @__PURE__ */ jsx("circle", { cx: x1, cy: midY, r: 2.5, fill: TONE.accent, fillOpacity: 0.75 })
22726
+ (!drawing || \u679D\u306E\u4F38\u3073 >= 1) && /* @__PURE__ */ jsx("circle", { cx: x1, cy: midY, r: 2.5, fill: TONE.accent, fillOpacity: 0.75 })
22613
22727
  ] }, `edge-${i}`);
22614
22728
  }),
22615
22729
  layout2.nodes.map((n) => {
22730
+ if (!\u7BB1\u304C\u51FA\u308B(n.depth)) return null;
22616
22731
  const accent = depthColors[Math.min(n.depth, depthColors.length - 1)] ?? depthColors[0];
22617
22732
  const isRoot = n.depth === 0;
22618
22733
  const \u884C = \u7BB1\u306B\u7A4D\u3080(
@@ -22648,17 +22763,21 @@ function TreeNode({
22648
22763
  \u7BB1\u306E\u9AD8\u3055: n.h,
22649
22764
  fill: "var(--cdl-text-on-tone, #ffffff)",
22650
22765
  \u540D\u524D\u306E\u592A\u3055: 700
22651
- }) : /* @__PURE__ */ jsx(
22652
- "text",
22653
- {
22654
- x: n.w / 2,
22655
- y: n.h / 2 + 5,
22656
- fontSize: 13,
22657
- fontWeight: 700,
22658
- textAnchor: "middle",
22659
- fill: "var(--cdl-text-on-tone, #ffffff)",
22660
- children: n.title
22661
- }
22766
+ }) : (
22767
+ // 補足が無くても幅に収める (#526)。 `箱の文字` を通らないこの経路だけが
22768
+ // 幅を見ておらず、長い名前が箱の外へ出ていた
22769
+ /* @__PURE__ */ jsx(
22770
+ "text",
22771
+ {
22772
+ x: n.w / 2,
22773
+ y: n.h / 2 + 5,
22774
+ fontSize: 13,
22775
+ fontWeight: 700,
22776
+ textAnchor: "middle",
22777
+ fill: "var(--cdl-text-on-tone, #ffffff)",
22778
+ children: \u5E45\u3067\u5207\u308B(n.title, 13, \u4F7F\u3048\u308B\u5E45(n.w))
22779
+ }
22780
+ )
22662
22781
  )
22663
22782
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
22664
22783
  /* @__PURE__ */ jsx(
@@ -22691,7 +22810,7 @@ function TreeNode({
22691
22810
  fontWeight: 600,
22692
22811
  textAnchor: "middle",
22693
22812
  fill: "var(--cdl-chip-text, #1a1f2a)",
22694
- children: n.title
22813
+ children: \u5E45\u3067\u5207\u308B(n.title, 12, \u4F7F\u3048\u308B\u5E45(n.w))
22695
22814
  }
22696
22815
  )
22697
22816
  ] })
@@ -22793,6 +22912,7 @@ function computeTreeLayout(treeNodes, canvasW, canvasH) {
22793
22912
  }
22794
22913
  }
22795
22914
  const hById = new Map(nodes.map((n) => [n.id, n.h]));
22915
+ const \u6BB5\u6570 = new Map(nodes.map((n) => [n.id, n.depth]));
22796
22916
  const edges = [];
22797
22917
  for (const n of treeNodes) {
22798
22918
  if (!n.parent) continue;
@@ -22801,14 +22921,25 @@ function computeTreeLayout(treeNodes, canvasW, canvasH) {
22801
22921
  if (!parent || !child) continue;
22802
22922
  const parentH = hById.get(n.parent) ?? nodeH;
22803
22923
  const childH = hById.get(n.id) ?? nodeH;
22804
- edges.push({ x1: parent.x, y1: parent.y + parentH / 2, x2: child.x, y2: child.y - childH / 2 });
22924
+ const parentDepth = \u6BB5\u6570.get(n.parent) ?? 0;
22925
+ const childDepth = \u6BB5\u6570.get(n.id) ?? 1;
22926
+ edges.push({
22927
+ x1: parent.x,
22928
+ y1: parent.y + parentH / 2,
22929
+ x2: child.x,
22930
+ y2: child.y - childH / 2,
22931
+ depth: Math.max(parentDepth, childDepth),
22932
+ deferUntilComplete: parentDepth >= childDepth
22933
+ });
22805
22934
  }
22806
22935
  return { nodes, edges };
22807
22936
  }
22808
22937
  function UserJourneyNode({
22809
22938
  node,
22810
22939
  active,
22811
- stateValues = {}
22940
+ stateValues = {},
22941
+ drawing = false,
22942
+ progress = 1
22812
22943
  }) {
22813
22944
  const x0 = node.cx - node.w / 2;
22814
22945
  const y0 = node.cy - node.h / 2;
@@ -22846,6 +22977,12 @@ function UserJourneyNode({
22846
22977
  const xAt = (idx) => PAD_LEFT + (steps.length <= 1 ? canvasW / 2 : colW / 2 + colW * idx);
22847
22978
  const yAt = (emotion) => PAD_TOP + rowH / 2 + (4 - emotionScore[emotion]) * rowH;
22848
22979
  const pts = steps.map((s, i) => ({ x: xAt(i), y: yAt(s.emotion) }));
22980
+ const \u4F38\u3073 = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
22981
+ const \u6BB5\u307E\u3067\u306E\u5272\u5408 = \u30D9\u30B8\u30A8\u306E\u7D2F\u7A4D\u5272\u5408(pts, (\u524D, \u5F8C) => {
22982
+ const midX = (\u524D.x + \u5F8C.x) / 2;
22983
+ return [{ x: midX, y: \u524D.y }, { x: midX, y: \u5F8C.y }];
22984
+ });
22985
+ const \u7DDA\u306E\u5148\u304C\u5C4A\u3044\u305F = (idx) => !drawing || \u4F38\u3073 >= (\u6BB5\u307E\u3067\u306E\u5272\u5408[idx] ?? 0);
22849
22986
  const smoothPath = pts.length > 1 ? pts.reduce((acc, p, i) => {
22850
22987
  if (i === 0) return `M ${p.x} ${p.y}`;
22851
22988
  const prev = pts[i - 1];
@@ -22926,7 +23063,8 @@ function UserJourneyNode({
22926
23063
  stroke: "var(--cdl-tone-accent, #2d6a8f)",
22927
23064
  strokeOpacity: 0.18,
22928
23065
  strokeWidth: 10,
22929
- strokeLinecap: "round"
23066
+ strokeLinecap: "round",
23067
+ ...\u4F38\u3070\u3059dash(drawing, \u4F38\u3073)
22930
23068
  }
22931
23069
  ),
22932
23070
  /* @__PURE__ */ jsx(
@@ -22938,11 +23076,12 @@ function UserJourneyNode({
22938
23076
  stroke: "var(--cdl-tone-accent, #2d6a8f)",
22939
23077
  strokeWidth: 2.75,
22940
23078
  strokeLinejoin: "round",
22941
- strokeLinecap: "round"
23079
+ strokeLinecap: "round",
23080
+ ...\u4F38\u3070\u3059dash(drawing, \u4F38\u3073)
22942
23081
  }
22943
23082
  )
22944
23083
  ] }),
22945
- steps.map((s, idx) => /* @__PURE__ */ jsxs(
23084
+ steps.map((s, idx) => !\u7DDA\u306E\u5148\u304C\u5C4A\u3044\u305F(idx) ? null : /* @__PURE__ */ jsxs(
22946
23085
  "g",
22947
23086
  {
22948
23087
  "data-cdl-role": "journey-step",
@@ -26852,17 +26991,62 @@ function CdlNodeView({
26852
26991
  }
26853
26992
  );
26854
26993
  case "gantt-timeline":
26855
- return /* @__PURE__ */ jsx(GanttNode, { node: resolvedNode, active, stateValues });
26994
+ return /* @__PURE__ */ jsx(
26995
+ GanttNode,
26996
+ {
26997
+ node: resolvedNode,
26998
+ active,
26999
+ stateValues,
27000
+ drawing,
27001
+ progress
27002
+ }
27003
+ );
26856
27004
  case "mind-map":
26857
- return /* @__PURE__ */ jsx(MindMapNode, { node: resolvedNode, active, stateValues });
27005
+ return /* @__PURE__ */ jsx(
27006
+ MindMapNode,
27007
+ {
27008
+ node: resolvedNode,
27009
+ active,
27010
+ stateValues,
27011
+ drawing,
27012
+ progress
27013
+ }
27014
+ );
26858
27015
  case "funnel-stages":
26859
- return /* @__PURE__ */ jsx(FunnelNode, { node: resolvedNode, active, stateValues });
27016
+ return /* @__PURE__ */ jsx(
27017
+ FunnelNode,
27018
+ {
27019
+ node: resolvedNode,
27020
+ active,
27021
+ stateValues,
27022
+ drawing,
27023
+ progress
27024
+ }
27025
+ );
26860
27026
  case "quadrant-matrix":
26861
27027
  return /* @__PURE__ */ jsx(QuadrantNode, { node: resolvedNode, active, stateValues });
26862
27028
  case "tree-hierarchy":
26863
- return /* @__PURE__ */ jsx(TreeNode, { node: resolvedNode, active, stateValues });
27029
+ return /* @__PURE__ */ jsx(
27030
+ TreeNode,
27031
+ {
27032
+ node: resolvedNode,
27033
+ active,
27034
+ stateValues,
27035
+ drawing,
27036
+ progress
27037
+ }
27038
+ );
26864
27039
  case "journey-map":
26865
- return /* @__PURE__ */ jsx(UserJourneyNode, { node: resolvedNode, active, stateValues });
27040
+ return /* @__PURE__ */ jsx(
27041
+ UserJourneyNode,
27042
+ {
27043
+ node: resolvedNode,
27044
+ active,
27045
+ stateValues,
27046
+ drawing,
27047
+ progress
27048
+ }
27049
+ );
26866
27050
  case "shape-file":
26867
27051
  return /* @__PURE__ */ jsx(ShapeFileNode, { node: resolvedNode, active });
26868
27052
  case "shape-folder":