@cardenelabs/cdl 0.6.0 → 0.7.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
@@ -6430,6 +6430,31 @@ function resolveJourneyData(steps, values) {
6430
6430
  return e.ok ? { ...s, emotion: e.value } : { ...s, emotion: e.value, unresolved: true };
6431
6431
  });
6432
6432
  }
6433
+ function resolveBoundText(raw, values) {
6434
+ if (!raw.includes("{")) return { value: raw, ok: true };
6435
+ const resolved = interpolate(raw, values);
6436
+ return hasUnresolvedRef(resolved) ? { value: resolved, ok: false } : { value: resolved, ok: true };
6437
+ }
6438
+ function resolveTreeData(nodes, values) {
6439
+ if (!nodes.some((n) => n.title.includes("{"))) return nodes;
6440
+ return nodes.map((n) => {
6441
+ const title = resolveBoundText(n.title, values);
6442
+ const \u89E3\u6C7A\u5F8C = { ...n, title: title.value };
6443
+ return title.ok ? \u89E3\u6C7A\u5F8C : { ...\u89E3\u6C7A\u5F8C, unresolved: true };
6444
+ });
6445
+ }
6446
+ function resolveMindData(data, values) {
6447
+ const \u8AAD\u3080 = data.rootTitle.includes("{") || data.branches.some((b) => b.title.includes("{"));
6448
+ if (!\u8AAD\u3080) return data;
6449
+ const root = resolveBoundText(data.rootTitle, values);
6450
+ const branches = data.branches.map((b) => {
6451
+ const title = resolveBoundText(b.title, values);
6452
+ const \u89E3\u6C7A\u5F8C2 = { ...b, title: title.value };
6453
+ return title.ok ? \u89E3\u6C7A\u5F8C2 : { ...\u89E3\u6C7A\u5F8C2, unresolved: true };
6454
+ });
6455
+ const \u89E3\u6C7A\u5F8C = { ...data, rootTitle: root.value, branches };
6456
+ return root.ok ? \u89E3\u6C7A\u5F8C : { ...\u89E3\u6C7A\u5F8C, unresolved: true };
6457
+ }
6433
6458
  function ChartLineNode({
6434
6459
  node,
6435
6460
  active,
@@ -6994,10 +7019,14 @@ function toneColor3(tone) {
6994
7019
  }
6995
7020
  var MIND_TONES = ["accent", "teal", "success", "warning", "info", "error"];
6996
7021
  var MIND_BOX_GAP = 24;
6997
- function MindMapNode({ node, active }) {
7022
+ function MindMapNode({
7023
+ node,
7024
+ active,
7025
+ stateValues = {}
7026
+ }) {
6998
7027
  const x0 = node.cx - node.w / 2;
6999
7028
  const y0 = node.cy - node.h / 2;
7000
- const mindData = node.mindData;
7029
+ const mindData = node.mindData ? resolveMindData(node.mindData, stateValues) : void 0;
7001
7030
  if (!mindData) return /* @__PURE__ */ jsxRuntime.jsx("g", { transform: `translate(${x0} ${y0})` });
7002
7031
  const PAD = 40;
7003
7032
  const canvasCx = node.w / 2;
@@ -7033,7 +7062,7 @@ function MindMapNode({ node, active }) {
7033
7062
  },
7034
7063
  `edge-${i}`
7035
7064
  )),
7036
- layout2.nodes.map((n) => /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
7065
+ layout2.nodes.map((n) => /* @__PURE__ */ jsxRuntime.jsxs("g", { "data-cdl-unresolved": n.unresolved ? "true" : void 0, children: [
7037
7066
  /* @__PURE__ */ jsxRuntime.jsx(
7038
7067
  "rect",
7039
7068
  {
@@ -7074,7 +7103,8 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
7074
7103
  y: cy,
7075
7104
  w: rootW,
7076
7105
  h: rootH,
7077
- isRoot: true
7106
+ isRoot: true,
7107
+ ...mindData.unresolved ? { unresolved: true } : {}
7078
7108
  });
7079
7109
  const childrenOf = /* @__PURE__ */ new Map();
7080
7110
  for (const br of mindData.branches) {
@@ -7177,7 +7207,17 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
7177
7207
  );
7178
7208
  y = (ys[0] + ys[ys.length - 1]) / 2;
7179
7209
  }
7180
- nodes.push({ id: node.id, title: node.title, x, y, w, h, tone: myTone, isRoot: false });
7210
+ nodes.push({
7211
+ id: node.id,
7212
+ title: node.title,
7213
+ x,
7214
+ y,
7215
+ w,
7216
+ h,
7217
+ tone: myTone,
7218
+ isRoot: false,
7219
+ ...node.unresolved ? { unresolved: true } : {}
7220
+ });
7181
7221
  nodePos.set(node.id, { x, y });
7182
7222
  nodeSide.set(node.id, isLeft ? "left" : "right");
7183
7223
  nodeHalfW.set(node.id, w / 2);
@@ -7497,10 +7537,14 @@ function QuadrantNode({
7497
7537
  })
7498
7538
  ] });
7499
7539
  }
7500
- function TreeNode({ node, active }) {
7540
+ function TreeNode({
7541
+ node,
7542
+ active,
7543
+ stateValues = {}
7544
+ }) {
7501
7545
  const x0 = node.cx - node.w / 2;
7502
7546
  const y0 = node.cy - node.h / 2;
7503
- const treeNodes = node.treeData ?? [];
7547
+ const treeNodes = resolveTreeData(node.treeData ?? [], stateValues);
7504
7548
  const gradientId = `tree-root-grad-${node.id}`;
7505
7549
  const PAD_TOP = 40;
7506
7550
  const PAD_RIGHT = 24;
@@ -7555,60 +7599,68 @@ function TreeNode({ node, active }) {
7555
7599
  layout2.nodes.map((n) => {
7556
7600
  const accent = depthColors[Math.min(n.depth, depthColors.length - 1)] ?? depthColors[0];
7557
7601
  const isRoot = n.depth === 0;
7558
- return /* @__PURE__ */ jsxRuntime.jsx("g", { transform: `translate(${PAD_LEFT + n.x - n.w / 2} ${PAD_TOP + n.y - n.h / 2})`, children: isRoot ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7559
- /* @__PURE__ */ jsxRuntime.jsx(
7560
- "rect",
7561
- {
7562
- "data-cdl-role": "tree-node",
7563
- x: 0,
7564
- y: 0,
7565
- width: n.w,
7566
- height: n.h,
7567
- rx: 12,
7568
- fill: `url(#${gradientId})`
7569
- }
7570
- ),
7571
- /* @__PURE__ */ jsxRuntime.jsx(
7572
- "text",
7573
- {
7574
- x: n.w / 2,
7575
- y: n.h / 2 + 5,
7576
- fontSize: 13,
7577
- fontWeight: 700,
7578
- textAnchor: "middle",
7579
- fill: "var(--cdl-text-on-tone, #ffffff)",
7580
- children: n.title
7581
- }
7582
- )
7583
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7584
- /* @__PURE__ */ jsxRuntime.jsx(
7585
- "rect",
7586
- {
7587
- "data-cdl-role": "tree-node",
7588
- x: 0,
7589
- y: 0,
7590
- width: n.w,
7591
- height: n.h,
7592
- rx: 9,
7593
- fill: "var(--cdl-chip-fill, #f4f6fb)",
7594
- stroke: accent,
7595
- strokeWidth: 1.5
7596
- }
7597
- ),
7598
- /* @__PURE__ */ jsxRuntime.jsx("rect", { x: 0, y: 0, width: 4, height: n.h, rx: 2, fill: accent }),
7599
- /* @__PURE__ */ jsxRuntime.jsx(
7600
- "text",
7601
- {
7602
- x: n.w / 2 + 2,
7603
- y: n.h / 2 + 4,
7604
- fontSize: 12,
7605
- fontWeight: 600,
7606
- textAnchor: "middle",
7607
- fill: "var(--cdl-chip-text, #1a1f2a)",
7608
- children: n.title
7609
- }
7610
- )
7611
- ] }) }, `n-${n.id}`);
7602
+ return /* @__PURE__ */ jsxRuntime.jsx(
7603
+ "g",
7604
+ {
7605
+ "data-cdl-unresolved": n.unresolved ? "true" : void 0,
7606
+ transform: `translate(${PAD_LEFT + n.x - n.w / 2} ${PAD_TOP + n.y - n.h / 2})`,
7607
+ children: isRoot ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7608
+ /* @__PURE__ */ jsxRuntime.jsx(
7609
+ "rect",
7610
+ {
7611
+ "data-cdl-role": "tree-node",
7612
+ x: 0,
7613
+ y: 0,
7614
+ width: n.w,
7615
+ height: n.h,
7616
+ rx: 12,
7617
+ fill: `url(#${gradientId})`
7618
+ }
7619
+ ),
7620
+ /* @__PURE__ */ jsxRuntime.jsx(
7621
+ "text",
7622
+ {
7623
+ x: n.w / 2,
7624
+ y: n.h / 2 + 5,
7625
+ fontSize: 13,
7626
+ fontWeight: 700,
7627
+ textAnchor: "middle",
7628
+ fill: "var(--cdl-text-on-tone, #ffffff)",
7629
+ children: n.title
7630
+ }
7631
+ )
7632
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7633
+ /* @__PURE__ */ jsxRuntime.jsx(
7634
+ "rect",
7635
+ {
7636
+ "data-cdl-role": "tree-node",
7637
+ x: 0,
7638
+ y: 0,
7639
+ width: n.w,
7640
+ height: n.h,
7641
+ rx: 9,
7642
+ fill: "var(--cdl-chip-fill, #f4f6fb)",
7643
+ stroke: accent,
7644
+ strokeWidth: 1.5
7645
+ }
7646
+ ),
7647
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: 0, y: 0, width: 4, height: n.h, rx: 2, fill: accent }),
7648
+ /* @__PURE__ */ jsxRuntime.jsx(
7649
+ "text",
7650
+ {
7651
+ x: n.w / 2 + 2,
7652
+ y: n.h / 2 + 4,
7653
+ fontSize: 12,
7654
+ fontWeight: 600,
7655
+ textAnchor: "middle",
7656
+ fill: "var(--cdl-chip-text, #1a1f2a)",
7657
+ children: n.title
7658
+ }
7659
+ )
7660
+ ] })
7661
+ },
7662
+ `n-${n.id}`
7663
+ );
7612
7664
  })
7613
7665
  ] });
7614
7666
  }
@@ -7671,7 +7723,16 @@ function computeTreeLayout(treeNodes, canvasW, canvasH) {
7671
7723
  }
7672
7724
  const y = depth * depthGap + depthGap / 2;
7673
7725
  posOf.set(n.id, { x, y });
7674
- nodes.push({ id: n.id, title: n.title, x, y, w: nodeW, h: nodeH, depth });
7726
+ nodes.push({
7727
+ id: n.id,
7728
+ title: n.title,
7729
+ x,
7730
+ y,
7731
+ w: nodeW,
7732
+ h: nodeH,
7733
+ depth,
7734
+ ...n.unresolved ? { unresolved: true } : {}
7735
+ });
7675
7736
  return x;
7676
7737
  };
7677
7738
  for (const r of roots) if (!placed.has(r.id)) place(r, 0);
@@ -11820,9 +11881,10 @@ function CdlNodeView({
11820
11881
  return /* @__PURE__ */ jsxRuntime.jsx(EventNode, { node: resolvedNode, active, progress });
11821
11882
  case "card":
11822
11883
  return /* @__PURE__ */ jsxRuntime.jsx(CardNode, { node: resolvedNode, active });
11823
- // 図表 7 種は payload の数と語が `{signal}` を取れるので stateValues を渡す
11824
- // (`render/payload-binding.ts` が描画直前に解決する)。 動かさない 2 種
11825
- // (mind-map / tree-hierarchy) は構造だけを持つため渡さない。
11884
+ // 図表 9 種は payload `{signal}` を取れるので stateValues を渡す
11885
+ // (`render/payload-binding.ts` が描画直前に解決する)。 取れる欄は種別で違い、
11886
+ // 数と語を取る 7 種に対し、mind-map / tree-hierarchy は **名前だけ** を取る (#467)
11887
+ // 親子の繋がりと、描かれない欄 (補足) は解決しない。
11826
11888
  case "chart-line":
11827
11889
  return /* @__PURE__ */ jsxRuntime.jsx(ChartLineNode, { node: resolvedNode, active, stateValues });
11828
11890
  case "chart-pie":
@@ -11832,13 +11894,13 @@ function CdlNodeView({
11832
11894
  case "gantt-timeline":
11833
11895
  return /* @__PURE__ */ jsxRuntime.jsx(GanttNode, { node: resolvedNode, active, stateValues });
11834
11896
  case "mind-map":
11835
- return /* @__PURE__ */ jsxRuntime.jsx(MindMapNode, { node: resolvedNode, active });
11897
+ return /* @__PURE__ */ jsxRuntime.jsx(MindMapNode, { node: resolvedNode, active, stateValues });
11836
11898
  case "funnel-stages":
11837
11899
  return /* @__PURE__ */ jsxRuntime.jsx(FunnelNode, { node: resolvedNode, active, stateValues });
11838
11900
  case "quadrant-matrix":
11839
11901
  return /* @__PURE__ */ jsxRuntime.jsx(QuadrantNode, { node: resolvedNode, active, stateValues });
11840
11902
  case "tree-hierarchy":
11841
- return /* @__PURE__ */ jsxRuntime.jsx(TreeNode, { node: resolvedNode, active });
11903
+ return /* @__PURE__ */ jsxRuntime.jsx(TreeNode, { node: resolvedNode, active, stateValues });
11842
11904
  case "journey-map":
11843
11905
  return /* @__PURE__ */ jsxRuntime.jsx(UserJourneyNode, { node: resolvedNode, active, stateValues });
11844
11906
  case "shape-file":