@cardenelabs/cdl 0.12.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/CHANGELOG.md +20 -1
- package/dist/index.cjs +42 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +42 -30
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +42 -30
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +42 -30
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/src/kinds/box-lines.ts +12 -2
- package/src/kinds/mind-map.tsx +5 -2
- package/src/kinds/tree.tsx +5 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cardenelabs/cdl",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "CDL (Chainome Diagram Language). Mermaid-like declarative DSL that compiles to animated SVG diagrams. Built for blockchain / Solidity flows, generic enough for sequence / flow / state / ER / topology diagrams.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "cardene777",
|
package/src/kinds/box-lines.ts
CHANGED
|
@@ -28,6 +28,16 @@ const 上下の余白 = 2;
|
|
|
28
28
|
/** 箱の左右に空ける余白 (片側) */
|
|
29
29
|
const 左右の余白 = 8;
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* その箱で文字に使える幅。
|
|
33
|
+
*
|
|
34
|
+
* **余白を呼出側に写さない**。 写すと余白を変えた時に片方だけ古くなり、`箱に積む` を通る
|
|
35
|
+
* 経路と通らない経路で収まる幅が変わる (cdl#526 で 1 行だけの経路が幅を見ていなかった)。
|
|
36
|
+
*/
|
|
37
|
+
export function 使える幅(箱の幅: number): number {
|
|
38
|
+
return 箱の幅 - 左右の余白 * 2;
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
export type 積む行 = {
|
|
32
42
|
役割: "title" | "subtitle";
|
|
33
43
|
text: string;
|
|
@@ -109,12 +119,12 @@ export function 箱に積む(行: 積む行[], 箱の幅: number, 箱の高さ:
|
|
|
109
119
|
const 残す = [...候補];
|
|
110
120
|
while (残す.length > 1 && 高さ(残す) > 使える高さ) 残す.pop();
|
|
111
121
|
|
|
112
|
-
const
|
|
122
|
+
const 幅 = 使える幅(箱の幅);
|
|
113
123
|
const 総高 = 高さ(残す);
|
|
114
124
|
let 積み = -総高 / 2;
|
|
115
125
|
return 残す.map((r) => {
|
|
116
126
|
const dy = 積み + ((行送りの比 + 字の高さの比) / 2) * r.fontSize;
|
|
117
127
|
積み += r.fontSize * 行送りの比;
|
|
118
|
-
return { ...r, text: 幅で切る(r.text, r.fontSize,
|
|
128
|
+
return { ...r, text: 幅で切る(r.text, r.fontSize, 幅), dy };
|
|
119
129
|
});
|
|
120
130
|
}
|
package/src/kinds/mind-map.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JSX } from "react";
|
|
2
|
-
import { 箱に積む } from "./box-lines";
|
|
2
|
+
import { 使える幅, 幅で切る, 箱に積む } from "./box-lines";
|
|
3
3
|
import type { LaidNode, Tone, MindBranchNode } from "../types";
|
|
4
4
|
import { TONE } from "../render/tone";
|
|
5
5
|
import { resolveMindData } from "../render/payload-binding";
|
|
@@ -147,6 +147,9 @@ export function MindMapNode({
|
|
|
147
147
|
</text>
|
|
148
148
|
))
|
|
149
149
|
) : (
|
|
150
|
+
// 補足が無くても **幅に収める** (#526)。 `箱に積む` を通らないこの経路だけが
|
|
151
|
+
// 幅を見ておらず、長い名前がそのまま箱の外へ出て枝の線と重なっていた
|
|
152
|
+
// (実測 = 中心の箱で文字 163px に対し箱 120px)
|
|
150
153
|
<text
|
|
151
154
|
x={n.x}
|
|
152
155
|
y={n.y + 5}
|
|
@@ -155,7 +158,7 @@ export function MindMapNode({
|
|
|
155
158
|
textAnchor="middle"
|
|
156
159
|
fill={文字の色}
|
|
157
160
|
>
|
|
158
|
-
{n.title}
|
|
161
|
+
{幅で切る(n.title, n.isRoot ? 15 : 13, 使える幅(n.w))}
|
|
159
162
|
</text>
|
|
160
163
|
)}
|
|
161
164
|
</g>
|
package/src/kinds/tree.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import type { JSX } from "react";
|
|
|
2
2
|
import type { LaidNode, TreeNodePayload } from "../types";
|
|
3
3
|
import { TONE } from "../render/tone";
|
|
4
4
|
import { resolveTreeData } from "../render/payload-binding";
|
|
5
|
-
import { 箱に積む, type 積んだ行 } from "../kinds/box-lines";
|
|
5
|
+
import { 使える幅, 幅で切る, 箱に積む, type 積んだ行 } from "../kinds/box-lines";
|
|
6
6
|
import { 進みを畳む, 伸ばすdash, 段の伸び } from "./draw-progress";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -190,6 +190,8 @@ export function TreeNode({
|
|
|
190
190
|
名前の太さ: 700,
|
|
191
191
|
})
|
|
192
192
|
) : (
|
|
193
|
+
// 補足が無くても幅に収める (#526)。 `箱の文字` を通らないこの経路だけが
|
|
194
|
+
// 幅を見ておらず、長い名前が箱の外へ出ていた
|
|
193
195
|
<text
|
|
194
196
|
x={n.w / 2}
|
|
195
197
|
y={n.h / 2 + 5}
|
|
@@ -198,7 +200,7 @@ export function TreeNode({
|
|
|
198
200
|
textAnchor="middle"
|
|
199
201
|
fill="var(--cdl-text-on-tone, #ffffff)"
|
|
200
202
|
>
|
|
201
|
-
{n.title}
|
|
203
|
+
{幅で切る(n.title, 13, 使える幅(n.w))}
|
|
202
204
|
</text>
|
|
203
205
|
)}
|
|
204
206
|
</>
|
|
@@ -233,7 +235,7 @@ export function TreeNode({
|
|
|
233
235
|
textAnchor="middle"
|
|
234
236
|
fill="var(--cdl-chip-text, #1a1f2a)"
|
|
235
237
|
>
|
|
236
|
-
{n.title}
|
|
238
|
+
{幅で切る(n.title, 12, 使える幅(n.w))}
|
|
237
239
|
</text>
|
|
238
240
|
)}
|
|
239
241
|
</>
|