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