@cardenelabs/cdl 0.6.1 → 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/index.cjs +129 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +129 -67
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +129 -67
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +129 -67
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/src/kinds/mind-map.tsx +27 -4
- package/src/kinds/tree.tsx +29 -4
- package/src/render/nodes.tsx +6 -5
- package/src/render/payload-binding.ts +65 -3
package/dist/index.js
CHANGED
|
@@ -20926,6 +20926,31 @@ function resolveJourneyData(steps, values) {
|
|
|
20926
20926
|
return e.ok ? { ...s, emotion: e.value } : { ...s, emotion: e.value, unresolved: true };
|
|
20927
20927
|
});
|
|
20928
20928
|
}
|
|
20929
|
+
function resolveBoundText(raw, values) {
|
|
20930
|
+
if (!raw.includes("{")) return { value: raw, ok: true };
|
|
20931
|
+
const resolved = interpolate(raw, values);
|
|
20932
|
+
return hasUnresolvedRef(resolved) ? { value: resolved, ok: false } : { value: resolved, ok: true };
|
|
20933
|
+
}
|
|
20934
|
+
function resolveTreeData(nodes, values) {
|
|
20935
|
+
if (!nodes.some((n) => n.title.includes("{"))) return nodes;
|
|
20936
|
+
return nodes.map((n) => {
|
|
20937
|
+
const title = resolveBoundText(n.title, values);
|
|
20938
|
+
const \u89E3\u6C7A\u5F8C = { ...n, title: title.value };
|
|
20939
|
+
return title.ok ? \u89E3\u6C7A\u5F8C : { ...\u89E3\u6C7A\u5F8C, unresolved: true };
|
|
20940
|
+
});
|
|
20941
|
+
}
|
|
20942
|
+
function resolveMindData(data, values) {
|
|
20943
|
+
const \u8AAD\u3080 = data.rootTitle.includes("{") || data.branches.some((b) => b.title.includes("{"));
|
|
20944
|
+
if (!\u8AAD\u3080) return data;
|
|
20945
|
+
const root = resolveBoundText(data.rootTitle, values);
|
|
20946
|
+
const branches = data.branches.map((b) => {
|
|
20947
|
+
const title = resolveBoundText(b.title, values);
|
|
20948
|
+
const \u89E3\u6C7A\u5F8C2 = { ...b, title: title.value };
|
|
20949
|
+
return title.ok ? \u89E3\u6C7A\u5F8C2 : { ...\u89E3\u6C7A\u5F8C2, unresolved: true };
|
|
20950
|
+
});
|
|
20951
|
+
const \u89E3\u6C7A\u5F8C = { ...data, rootTitle: root.value, branches };
|
|
20952
|
+
return root.ok ? \u89E3\u6C7A\u5F8C : { ...\u89E3\u6C7A\u5F8C, unresolved: true };
|
|
20953
|
+
}
|
|
20929
20954
|
function ChartLineNode({
|
|
20930
20955
|
node,
|
|
20931
20956
|
active,
|
|
@@ -21490,10 +21515,14 @@ function toneColor3(tone) {
|
|
|
21490
21515
|
}
|
|
21491
21516
|
var MIND_TONES = ["accent", "teal", "success", "warning", "info", "error"];
|
|
21492
21517
|
var MIND_BOX_GAP = 24;
|
|
21493
|
-
function MindMapNode({
|
|
21518
|
+
function MindMapNode({
|
|
21519
|
+
node,
|
|
21520
|
+
active,
|
|
21521
|
+
stateValues = {}
|
|
21522
|
+
}) {
|
|
21494
21523
|
const x0 = node.cx - node.w / 2;
|
|
21495
21524
|
const y0 = node.cy - node.h / 2;
|
|
21496
|
-
const mindData = node.mindData;
|
|
21525
|
+
const mindData = node.mindData ? resolveMindData(node.mindData, stateValues) : void 0;
|
|
21497
21526
|
if (!mindData) return /* @__PURE__ */ jsx("g", { transform: `translate(${x0} ${y0})` });
|
|
21498
21527
|
const PAD = 40;
|
|
21499
21528
|
const canvasCx = node.w / 2;
|
|
@@ -21529,7 +21558,7 @@ function MindMapNode({ node, active }) {
|
|
|
21529
21558
|
},
|
|
21530
21559
|
`edge-${i}`
|
|
21531
21560
|
)),
|
|
21532
|
-
layout2.nodes.map((n) => /* @__PURE__ */ jsxs("g", { children: [
|
|
21561
|
+
layout2.nodes.map((n) => /* @__PURE__ */ jsxs("g", { "data-cdl-unresolved": n.unresolved ? "true" : void 0, children: [
|
|
21533
21562
|
/* @__PURE__ */ jsx(
|
|
21534
21563
|
"rect",
|
|
21535
21564
|
{
|
|
@@ -21570,7 +21599,8 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
|
|
|
21570
21599
|
y: cy,
|
|
21571
21600
|
w: rootW,
|
|
21572
21601
|
h: rootH,
|
|
21573
|
-
isRoot: true
|
|
21602
|
+
isRoot: true,
|
|
21603
|
+
...mindData.unresolved ? { unresolved: true } : {}
|
|
21574
21604
|
});
|
|
21575
21605
|
const childrenOf = /* @__PURE__ */ new Map();
|
|
21576
21606
|
for (const br of mindData.branches) {
|
|
@@ -21673,7 +21703,17 @@ function computeMindMapLayout(mindData, cx, cy, canvasW, canvasH) {
|
|
|
21673
21703
|
);
|
|
21674
21704
|
y = (ys[0] + ys[ys.length - 1]) / 2;
|
|
21675
21705
|
}
|
|
21676
|
-
nodes.push({
|
|
21706
|
+
nodes.push({
|
|
21707
|
+
id: node.id,
|
|
21708
|
+
title: node.title,
|
|
21709
|
+
x,
|
|
21710
|
+
y,
|
|
21711
|
+
w,
|
|
21712
|
+
h,
|
|
21713
|
+
tone: myTone,
|
|
21714
|
+
isRoot: false,
|
|
21715
|
+
...node.unresolved ? { unresolved: true } : {}
|
|
21716
|
+
});
|
|
21677
21717
|
nodePos.set(node.id, { x, y });
|
|
21678
21718
|
nodeSide.set(node.id, isLeft ? "left" : "right");
|
|
21679
21719
|
nodeHalfW.set(node.id, w / 2);
|
|
@@ -21993,10 +22033,14 @@ function QuadrantNode({
|
|
|
21993
22033
|
})
|
|
21994
22034
|
] });
|
|
21995
22035
|
}
|
|
21996
|
-
function TreeNode({
|
|
22036
|
+
function TreeNode({
|
|
22037
|
+
node,
|
|
22038
|
+
active,
|
|
22039
|
+
stateValues = {}
|
|
22040
|
+
}) {
|
|
21997
22041
|
const x0 = node.cx - node.w / 2;
|
|
21998
22042
|
const y0 = node.cy - node.h / 2;
|
|
21999
|
-
const treeNodes = node.treeData ?? [];
|
|
22043
|
+
const treeNodes = resolveTreeData(node.treeData ?? [], stateValues);
|
|
22000
22044
|
const gradientId = `tree-root-grad-${node.id}`;
|
|
22001
22045
|
const PAD_TOP = 40;
|
|
22002
22046
|
const PAD_RIGHT = 24;
|
|
@@ -22051,60 +22095,68 @@ function TreeNode({ node, active }) {
|
|
|
22051
22095
|
layout2.nodes.map((n) => {
|
|
22052
22096
|
const accent = depthColors[Math.min(n.depth, depthColors.length - 1)] ?? depthColors[0];
|
|
22053
22097
|
const isRoot = n.depth === 0;
|
|
22054
|
-
return /* @__PURE__ */ jsx(
|
|
22055
|
-
|
|
22056
|
-
|
|
22057
|
-
|
|
22058
|
-
|
|
22059
|
-
|
|
22060
|
-
|
|
22061
|
-
|
|
22062
|
-
|
|
22063
|
-
|
|
22064
|
-
|
|
22065
|
-
|
|
22066
|
-
|
|
22067
|
-
|
|
22068
|
-
|
|
22069
|
-
|
|
22070
|
-
|
|
22071
|
-
|
|
22072
|
-
|
|
22073
|
-
|
|
22074
|
-
|
|
22075
|
-
|
|
22076
|
-
|
|
22077
|
-
|
|
22078
|
-
|
|
22079
|
-
|
|
22080
|
-
|
|
22081
|
-
|
|
22082
|
-
|
|
22083
|
-
|
|
22084
|
-
|
|
22085
|
-
|
|
22086
|
-
|
|
22087
|
-
|
|
22088
|
-
|
|
22089
|
-
|
|
22090
|
-
|
|
22091
|
-
|
|
22092
|
-
|
|
22093
|
-
|
|
22094
|
-
|
|
22095
|
-
|
|
22096
|
-
|
|
22097
|
-
|
|
22098
|
-
|
|
22099
|
-
y: n.h
|
|
22100
|
-
|
|
22101
|
-
|
|
22102
|
-
|
|
22103
|
-
|
|
22104
|
-
|
|
22105
|
-
|
|
22106
|
-
|
|
22107
|
-
|
|
22098
|
+
return /* @__PURE__ */ jsx(
|
|
22099
|
+
"g",
|
|
22100
|
+
{
|
|
22101
|
+
"data-cdl-unresolved": n.unresolved ? "true" : void 0,
|
|
22102
|
+
transform: `translate(${PAD_LEFT + n.x - n.w / 2} ${PAD_TOP + n.y - n.h / 2})`,
|
|
22103
|
+
children: isRoot ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
22104
|
+
/* @__PURE__ */ jsx(
|
|
22105
|
+
"rect",
|
|
22106
|
+
{
|
|
22107
|
+
"data-cdl-role": "tree-node",
|
|
22108
|
+
x: 0,
|
|
22109
|
+
y: 0,
|
|
22110
|
+
width: n.w,
|
|
22111
|
+
height: n.h,
|
|
22112
|
+
rx: 12,
|
|
22113
|
+
fill: `url(#${gradientId})`
|
|
22114
|
+
}
|
|
22115
|
+
),
|
|
22116
|
+
/* @__PURE__ */ jsx(
|
|
22117
|
+
"text",
|
|
22118
|
+
{
|
|
22119
|
+
x: n.w / 2,
|
|
22120
|
+
y: n.h / 2 + 5,
|
|
22121
|
+
fontSize: 13,
|
|
22122
|
+
fontWeight: 700,
|
|
22123
|
+
textAnchor: "middle",
|
|
22124
|
+
fill: "var(--cdl-text-on-tone, #ffffff)",
|
|
22125
|
+
children: n.title
|
|
22126
|
+
}
|
|
22127
|
+
)
|
|
22128
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
22129
|
+
/* @__PURE__ */ jsx(
|
|
22130
|
+
"rect",
|
|
22131
|
+
{
|
|
22132
|
+
"data-cdl-role": "tree-node",
|
|
22133
|
+
x: 0,
|
|
22134
|
+
y: 0,
|
|
22135
|
+
width: n.w,
|
|
22136
|
+
height: n.h,
|
|
22137
|
+
rx: 9,
|
|
22138
|
+
fill: "var(--cdl-chip-fill, #f4f6fb)",
|
|
22139
|
+
stroke: accent,
|
|
22140
|
+
strokeWidth: 1.5
|
|
22141
|
+
}
|
|
22142
|
+
),
|
|
22143
|
+
/* @__PURE__ */ jsx("rect", { x: 0, y: 0, width: 4, height: n.h, rx: 2, fill: accent }),
|
|
22144
|
+
/* @__PURE__ */ jsx(
|
|
22145
|
+
"text",
|
|
22146
|
+
{
|
|
22147
|
+
x: n.w / 2 + 2,
|
|
22148
|
+
y: n.h / 2 + 4,
|
|
22149
|
+
fontSize: 12,
|
|
22150
|
+
fontWeight: 600,
|
|
22151
|
+
textAnchor: "middle",
|
|
22152
|
+
fill: "var(--cdl-chip-text, #1a1f2a)",
|
|
22153
|
+
children: n.title
|
|
22154
|
+
}
|
|
22155
|
+
)
|
|
22156
|
+
] })
|
|
22157
|
+
},
|
|
22158
|
+
`n-${n.id}`
|
|
22159
|
+
);
|
|
22108
22160
|
})
|
|
22109
22161
|
] });
|
|
22110
22162
|
}
|
|
@@ -22167,7 +22219,16 @@ function computeTreeLayout(treeNodes, canvasW, canvasH) {
|
|
|
22167
22219
|
}
|
|
22168
22220
|
const y = depth * depthGap + depthGap / 2;
|
|
22169
22221
|
posOf.set(n.id, { x, y });
|
|
22170
|
-
nodes.push({
|
|
22222
|
+
nodes.push({
|
|
22223
|
+
id: n.id,
|
|
22224
|
+
title: n.title,
|
|
22225
|
+
x,
|
|
22226
|
+
y,
|
|
22227
|
+
w: nodeW,
|
|
22228
|
+
h: nodeH,
|
|
22229
|
+
depth,
|
|
22230
|
+
...n.unresolved ? { unresolved: true } : {}
|
|
22231
|
+
});
|
|
22171
22232
|
return x;
|
|
22172
22233
|
};
|
|
22173
22234
|
for (const r of roots) if (!placed.has(r.id)) place(r, 0);
|
|
@@ -26316,9 +26377,10 @@ function CdlNodeView({
|
|
|
26316
26377
|
return /* @__PURE__ */ jsx(EventNode, { node: resolvedNode, active, progress });
|
|
26317
26378
|
case "card":
|
|
26318
26379
|
return /* @__PURE__ */ jsx(CardNode, { node: resolvedNode, active });
|
|
26319
|
-
// 図表
|
|
26320
|
-
// (`render/payload-binding.ts` が描画直前に解決する)。
|
|
26321
|
-
//
|
|
26380
|
+
// 図表 9 種は payload が `{signal}` を取れるので stateValues を渡す
|
|
26381
|
+
// (`render/payload-binding.ts` が描画直前に解決する)。 取れる欄は種別で違い、
|
|
26382
|
+
// 数と語を取る 7 種に対し、mind-map / tree-hierarchy は **名前だけ** を取る (#467)。
|
|
26383
|
+
// 親子の繋がりと、描かれない欄 (補足) は解決しない。
|
|
26322
26384
|
case "chart-line":
|
|
26323
26385
|
return /* @__PURE__ */ jsx(ChartLineNode, { node: resolvedNode, active, stateValues });
|
|
26324
26386
|
case "chart-pie":
|
|
@@ -26328,13 +26390,13 @@ function CdlNodeView({
|
|
|
26328
26390
|
case "gantt-timeline":
|
|
26329
26391
|
return /* @__PURE__ */ jsx(GanttNode, { node: resolvedNode, active, stateValues });
|
|
26330
26392
|
case "mind-map":
|
|
26331
|
-
return /* @__PURE__ */ jsx(MindMapNode, { node: resolvedNode, active });
|
|
26393
|
+
return /* @__PURE__ */ jsx(MindMapNode, { node: resolvedNode, active, stateValues });
|
|
26332
26394
|
case "funnel-stages":
|
|
26333
26395
|
return /* @__PURE__ */ jsx(FunnelNode, { node: resolvedNode, active, stateValues });
|
|
26334
26396
|
case "quadrant-matrix":
|
|
26335
26397
|
return /* @__PURE__ */ jsx(QuadrantNode, { node: resolvedNode, active, stateValues });
|
|
26336
26398
|
case "tree-hierarchy":
|
|
26337
|
-
return /* @__PURE__ */ jsx(TreeNode, { node: resolvedNode, active });
|
|
26399
|
+
return /* @__PURE__ */ jsx(TreeNode, { node: resolvedNode, active, stateValues });
|
|
26338
26400
|
case "journey-map":
|
|
26339
26401
|
return /* @__PURE__ */ jsx(UserJourneyNode, { node: resolvedNode, active, stateValues });
|
|
26340
26402
|
case "shape-file":
|