@cardenelabs/cdl 0.114.0 → 0.116.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/CHANGELOG.md +71 -1
- package/dist/index.cjs +65 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -3
- package/dist/index.d.ts +23 -3
- package/dist/index.js +65 -6
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +28 -4
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +28 -4
- package/dist/react.js.map +1 -1
- package/dist/{render-oEmwYN-q.d.cts → render-A5AKjNuy.d.cts} +1 -1
- package/dist/{render-oEmwYN-q.d.ts → render-A5AKjNuy.d.ts} +1 -1
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/kinds/tree.tsx +127 -4
- package/src/presets.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,74 @@ CDL (Chainome Diagram Language) の主要変更履歴。
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.116.0] - 2026-10-01
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **葉が少ない木の図が札の中で浮いていた** (#970)
|
|
13
|
+
|
|
14
|
+
木の札は種別ごとに 1 つの値 (720x480) で固定されていた。
|
|
15
|
+
必要な幅は葉の数で変わるので、葉が少ない図は札の中で小さく見える。
|
|
16
|
+
#968 で兄弟を近づけた結果これが目立ち、見本帳の `配布物の構成` は
|
|
17
|
+
中身 375 に対して札が 720 で、左右に 172 ずつ余っていた。
|
|
18
|
+
|
|
19
|
+
**札の幅を葉の数から出す**。
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
要る幅 = 葉の数 × (箱の幅 + 隙間) + 左右の余白
|
|
23
|
+
隙間 = 段の高さ - 箱の高さ
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
規則は縦が既に持っているものを横に当てただけになる。
|
|
27
|
+
段は区画の中央に置かれるので、縦の余白は隙間の半分ずつになる。
|
|
28
|
+
同じ形を横に当てると上の式になり、3 段の木では今の高さ (480) をそのまま返す
|
|
29
|
+
= 縦は既にこの値で描かれている。
|
|
30
|
+
|
|
31
|
+
| 図の形 | 札の幅 (直す前 → 後) | 中身 | 割合 |
|
|
32
|
+
|---|---|---|---|
|
|
33
|
+
| 葉 2 枚 / 段 3 つ | 720 → 519 | 375 | 52% → 72% |
|
|
34
|
+
| 葉 3 枚 / 段 3 つ | 720 → 720 (変わらない) | 588 | 82% |
|
|
35
|
+
|
|
36
|
+
**広げる向きには使わない**。 葉が多い図では式の値が既定を超えるが、
|
|
37
|
+
札を広げると並べる側の配置が崩れる。 超える図は今までどおり区画が狭まり、
|
|
38
|
+
箱が小さくなる側で吸収する (葉 10 枚の図は式の値が 2353 で、720 に留まる)。
|
|
39
|
+
|
|
40
|
+
**葉が 1 枚の図は 2 枚として扱う**。 1 枚の木は縦 1 本の鎖で、
|
|
41
|
+
式のまま出すと箱 1 つぶんの幅になり、木ではなく縦書きの字列に見える。
|
|
42
|
+
|
|
43
|
+
`木の札の幅` を公開した。 組み立てる側 (`tree()` preset と記法の側) が
|
|
44
|
+
札を作る前に引く。 規則を呼ぶ側に写さないための口になる。
|
|
45
|
+
|
|
46
|
+
## [0.115.0] - 2026-09-30
|
|
47
|
+
|
|
48
|
+
### Fixed
|
|
49
|
+
|
|
50
|
+
- **木の兄弟どうしが遠くへ離れ、離れた 2 本の列に見えた** (#968)
|
|
51
|
+
|
|
52
|
+
葉は `canvasW / 葉の数` で等分した区画の中央に置かれていた。
|
|
53
|
+
区画は箱より広いので、葉が少ない図では兄弟が区画の幅だけ離れる。
|
|
54
|
+
見本帳の `配布物の構成` は葉が 2 枚で、箱の縁の間が 196 空いていた。
|
|
55
|
+
同じ図の段と段の隙間は 95 なので、横だけが縦の 2 倍になる。
|
|
56
|
+
|
|
57
|
+
横の隙間を **段と段の隙間に揃えた**。
|
|
58
|
+
木は根から下へ辿る図なので、間隔が 1 つの調子で揃っていないと系統が読めない。
|
|
59
|
+
|
|
60
|
+
| 図の形 | 横の隙間 (直す前 → 後) | 縦の隙間 |
|
|
61
|
+
|---|---|---|
|
|
62
|
+
| 葉 2 枚 | 196 → 95 | 95 |
|
|
63
|
+
| 葉 3 枚 | 84 → 84 (変わらない) | 95 |
|
|
64
|
+
|
|
65
|
+
**今より広げない**。 葉が多い図では区画の方が狭いので、そちらが効いて位置は動かない。
|
|
66
|
+
頭打ちを外すと間隔が区画の 3 倍になり、最後の一様縮小が効いて箱まで小さくなる
|
|
67
|
+
(実測 = 葉 10 枚の図で箱の幅が 57.1 から 19.5 に縮んだ)。
|
|
68
|
+
|
|
69
|
+
箱の幅を出す処理を置き場所より先に回した。
|
|
70
|
+
端の葉がどれだけ幅を取るかは、名前と段から決まるので位置より先に出せる。
|
|
71
|
+
|
|
72
|
+
見本帳 (`cardene777/dragon`) の `配布物の構成` は、札に対する中身の割合が
|
|
73
|
+
横 66% から 52% に **下がる**。 兄弟が近づいたぶん中身が小さくなるためで、
|
|
74
|
+
図が札の中で浮くのは札の大きさの話として別に扱う。
|
|
75
|
+
|
|
8
76
|
## [0.114.0] - 2026-09-30
|
|
9
77
|
|
|
10
78
|
### Fixed
|
|
@@ -4550,7 +4618,9 @@ Initial OSS release.
|
|
|
4550
4618
|
使わない = annotated tag を push しても GitHub Release は作られず、 Release を作っていない版で
|
|
4551
4619
|
行き止まりになる。
|
|
4552
4620
|
|
|
4553
|
-
[Unreleased]: https://github.com/cardene777/cdl/compare/v0.
|
|
4621
|
+
[Unreleased]: https://github.com/cardene777/cdl/compare/v0.116.0...HEAD
|
|
4622
|
+
[0.116.0]: https://github.com/cardene777/cdl/compare/v0.115.0...v0.116.0
|
|
4623
|
+
[0.115.0]: https://github.com/cardene777/cdl/compare/v0.114.0...v0.115.0
|
|
4554
4624
|
[0.114.0]: https://github.com/cardene777/cdl/compare/v0.113.0...v0.114.0
|
|
4555
4625
|
[0.113.0]: https://github.com/cardene777/cdl/compare/v0.112.0...v0.113.0
|
|
4556
4626
|
[0.112.0]: https://github.com/cardene777/cdl/compare/v0.111.0...v0.112.0
|
package/dist/index.cjs
CHANGED
|
@@ -15720,6 +15720,43 @@ var PAD_TOP = 40;
|
|
|
15720
15720
|
var PAD_RIGHT = 24;
|
|
15721
15721
|
var PAD_BOTTOM = 40;
|
|
15722
15722
|
var PAD_LEFT = 24;
|
|
15723
|
+
var \u7BB1\u306E\u6700\u5927\u5E45 = 140;
|
|
15724
|
+
var \u7BB1\u306E\u6700\u5927\u9AD8\u3055 = 38;
|
|
15725
|
+
var \u672D\u306E\u65E2\u5B9A\u5E45 = 720;
|
|
15726
|
+
var \u672D\u306E\u65E2\u5B9A\u9AD8\u3055 = 480;
|
|
15727
|
+
function \u6728\u306E\u672D\u306E\u5E45(treeNodes) {
|
|
15728
|
+
const { \u8449\u306E\u6570, \u6BB5\u6570 } = \u6728\u306E\u5F62(treeNodes);
|
|
15729
|
+
const \u6BB5\u306E\u9AD8\u3055 = (\u672D\u306E\u65E2\u5B9A\u9AD8\u3055 - PAD_TOP - PAD_BOTTOM) / Math.max(\u6BB5\u6570, 1);
|
|
15730
|
+
const \u7BB1\u306E\u9AD8\u30553 = Math.min(\u7BB1\u306E\u6700\u5927\u9AD8\u3055, \u6BB5\u306E\u9AD8\u3055 * 0.7);
|
|
15731
|
+
const \u9699\u9593 = \u6BB5\u306E\u9AD8\u3055 - \u7BB1\u306E\u9AD8\u30553;
|
|
15732
|
+
const \u8981\u308B\u5E45 = Math.max(\u8449\u306E\u6570, 2) * (\u7BB1\u306E\u6700\u5927\u5E45 + \u9699\u9593);
|
|
15733
|
+
return Math.ceil(Math.min(\u672D\u306E\u65E2\u5B9A\u5E45, \u8981\u308B\u5E45 + PAD_LEFT + PAD_RIGHT));
|
|
15734
|
+
}
|
|
15735
|
+
function \u6728\u306E\u5F62(treeNodes) {
|
|
15736
|
+
const ids = new Set(treeNodes.map((n) => n.id));
|
|
15737
|
+
const childrenOf = /* @__PURE__ */ new Map();
|
|
15738
|
+
for (const n of treeNodes) {
|
|
15739
|
+
const p = n.parent && ids.has(n.parent) ? n.parent : "__root__";
|
|
15740
|
+
if (!childrenOf.has(p)) childrenOf.set(p, []);
|
|
15741
|
+
childrenOf.get(p).push(n);
|
|
15742
|
+
}
|
|
15743
|
+
const \u898B\u305F = /* @__PURE__ */ new Set();
|
|
15744
|
+
let \u8449\u306E\u6570 = 0;
|
|
15745
|
+
let \u6BB5\u6570 = 0;
|
|
15746
|
+
const \u4E0B\u898B = (n, depth) => {
|
|
15747
|
+
\u898B\u305F.add(n.id);
|
|
15748
|
+
\u6BB5\u6570 = Math.max(\u6BB5\u6570, depth + 1);
|
|
15749
|
+
const kids = (childrenOf.get(n.id) ?? []).filter((k) => !\u898B\u305F.has(k.id));
|
|
15750
|
+
if (kids.length === 0) {
|
|
15751
|
+
\u8449\u306E\u6570 += 1;
|
|
15752
|
+
return;
|
|
15753
|
+
}
|
|
15754
|
+
for (const k of kids) \u4E0B\u898B(k, depth + 1);
|
|
15755
|
+
};
|
|
15756
|
+
for (const r of childrenOf.get("__root__") ?? []) if (!\u898B\u305F.has(r.id)) \u4E0B\u898B(r, 0);
|
|
15757
|
+
for (const n of treeNodes) if (!\u898B\u305F.has(n.id)) \u4E0B\u898B(n, 0);
|
|
15758
|
+
return { \u8449\u306E\u6570, \u6BB5\u6570 };
|
|
15759
|
+
}
|
|
15723
15760
|
var \u6728\u306E\u679D\u306E\u592A\u3055 = (\u6BB5) => Math.max(1.1, 2.6 - \u6BB5 * 0.45);
|
|
15724
15761
|
function \u6728\u306E\u4E2D\u8EAB(node, stateValues = {}) {
|
|
15725
15762
|
const treeNodes = resolveTreeData(node.treeData ?? [], stateValues);
|
|
@@ -15923,14 +15960,36 @@ function computeTreeLayout(treeNodes, canvasW, canvasH) {
|
|
|
15923
15960
|
);
|
|
15924
15961
|
const depthGap = canvasH / Math.max(maxDepth + 1, 1);
|
|
15925
15962
|
const slotW = canvasW / totalLeaves;
|
|
15926
|
-
const nodeH = Math.min(
|
|
15927
|
-
const nodeW = Math.min(
|
|
15963
|
+
const nodeH = Math.min(\u7BB1\u306E\u6700\u5927\u9AD8\u3055, depthGap * 0.7);
|
|
15964
|
+
const nodeW = Math.min(\u7BB1\u306E\u6700\u5927\u5E45, slotW * 0.85);
|
|
15928
15965
|
const \u7BB1\u306E\u5E45 = (n, depth) => {
|
|
15929
15966
|
const \u6750\u6599 = \u6728\u306E\u884C({ ...n, depth });
|
|
15930
15967
|
const \u540D\u524D = \u6750\u6599[0];
|
|
15931
15968
|
const \u8981\u308B = measureTextWidth(\u540D\u524D.text, { fontSize: \u540D\u524D.fontSize}) + (nodeW - \u4F7F\u3048\u308B\u5E45(nodeW));
|
|
15932
15969
|
return Math.min(Math.max(\u8981\u308B, nodeW), slotW * 0.92);
|
|
15933
15970
|
};
|
|
15971
|
+
const \u8449\u306E\u4E26\u3073 = [];
|
|
15972
|
+
const \u6BB5\u306E\u8868 = /* @__PURE__ */ new Map();
|
|
15973
|
+
const \u5E45\u306E\u8868 = /* @__PURE__ */ new Map();
|
|
15974
|
+
{
|
|
15975
|
+
const \u898B\u305F = /* @__PURE__ */ new Set();
|
|
15976
|
+
const \u4E0B\u898B = (n, depth) => {
|
|
15977
|
+
\u898B\u305F.add(n.id);
|
|
15978
|
+
\u6BB5\u306E\u8868.set(n.id, depth);
|
|
15979
|
+
\u5E45\u306E\u8868.set(n.id, \u7BB1\u306E\u5E45(n, depth));
|
|
15980
|
+
const kids = (childrenOf.get(n.id) ?? []).filter((k) => !\u898B\u305F.has(k.id));
|
|
15981
|
+
if (kids.length === 0) {
|
|
15982
|
+
\u8449\u306E\u4E26\u3073.push(n.id);
|
|
15983
|
+
return;
|
|
15984
|
+
}
|
|
15985
|
+
for (const k of kids) \u4E0B\u898B(k, depth + 1);
|
|
15986
|
+
};
|
|
15987
|
+
for (const r of roots) if (!\u898B\u305F.has(r.id)) \u4E0B\u898B(r, 0);
|
|
15988
|
+
}
|
|
15989
|
+
const \u8449\u306E\u6570 = Math.max(\u8449\u306E\u4E26\u3073.length, 1);
|
|
15990
|
+
const \u6BB5\u306E\u9699\u9593 = depthGap - nodeH;
|
|
15991
|
+
const \u8449\u306E\u9593\u9694 = Math.min(slotW, nodeW + \u6BB5\u306E\u9699\u9593);
|
|
15992
|
+
const \u8449\u306Ex = (i) => canvasW / 2 - (\u8449\u306E\u6570 - 1) * \u8449\u306E\u9593\u9694 / 2 + i * \u8449\u306E\u9593\u9694;
|
|
15934
15993
|
const posOf = /* @__PURE__ */ new Map();
|
|
15935
15994
|
const nodes = [];
|
|
15936
15995
|
const placed = /* @__PURE__ */ new Set();
|
|
@@ -15940,7 +15999,7 @@ function computeTreeLayout(treeNodes, canvasW, canvasH) {
|
|
|
15940
15999
|
const kids = (childrenOf.get(n.id) ?? []).filter((k) => !placed.has(k.id));
|
|
15941
16000
|
let x;
|
|
15942
16001
|
if (kids.length === 0) {
|
|
15943
|
-
x = leafCursor
|
|
16002
|
+
x = \u8449\u306Ex(leafCursor);
|
|
15944
16003
|
leafCursor += 1;
|
|
15945
16004
|
} else {
|
|
15946
16005
|
const xs = kids.map((k) => place(k, depth + 1));
|
|
@@ -15954,7 +16013,7 @@ function computeTreeLayout(treeNodes, canvasW, canvasH) {
|
|
|
15954
16013
|
...n.subtitle !== void 0 ? { subtitle: n.subtitle } : {},
|
|
15955
16014
|
x,
|
|
15956
16015
|
y,
|
|
15957
|
-
w: \u7BB1\u306E\u5E45(n, depth),
|
|
16016
|
+
w: \u5E45\u306E\u8868.get(n.id) ?? \u7BB1\u306E\u5E45(n, depth),
|
|
15958
16017
|
h: nodeH,
|
|
15959
16018
|
depth,
|
|
15960
16019
|
...n.unresolved ? { unresolved: true } : {}
|
|
@@ -34487,7 +34546,6 @@ function classDiagram(preset) {
|
|
|
34487
34546
|
return api;
|
|
34488
34547
|
}
|
|
34489
34548
|
function tree(preset) {
|
|
34490
|
-
const canvasW = preset.nodeWidth ? preset.nodeWidth * 2 : 720;
|
|
34491
34549
|
const canvasH = 480;
|
|
34492
34550
|
const b = diagram(preset.id, { topic: preset.topic, type: "tree" });
|
|
34493
34551
|
const treeNodes = [];
|
|
@@ -34497,6 +34555,7 @@ function tree(preset) {
|
|
|
34497
34555
|
return api;
|
|
34498
34556
|
},
|
|
34499
34557
|
build() {
|
|
34558
|
+
const canvasW = preset.nodeWidth ? preset.nodeWidth * 2 : \u6728\u306E\u672D\u306E\u5E45(treeNodes.map((n) => ({ id: n.id, title: n.title, parent: n.parent })));
|
|
34500
34559
|
b.lane("tree", { width: canvasW });
|
|
34501
34560
|
const nodeId = `${preset.id}-tree`;
|
|
34502
34561
|
b.node(nodeId, {
|
|
@@ -35171,5 +35230,6 @@ exports.visualValidateAll = visualValidateAll;
|
|
|
35171
35230
|
exports.visualValidateLaid = visualValidateLaid;
|
|
35172
35231
|
exports.withDerivedValues = withDerivedValues;
|
|
35173
35232
|
exports.worldToPx = worldToPx;
|
|
35233
|
+
exports.木の札の幅 = 木の札の幅;
|
|
35174
35234
|
//# sourceMappingURL=index.cjs.map
|
|
35175
35235
|
//# sourceMappingURL=index.cjs.map
|