@cardenelabs/cdl 0.24.0 → 0.25.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 +45 -0
- package/dist/index.cjs +40 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +40 -2
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +32 -0
- 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 +32 -0
- package/dist/react.js.map +1 -1
- package/dist/{render-CfXUl0Yz.d.cts → render-ViWKnlu1.d.cts} +23 -0
- package/dist/{render-CfXUl0Yz.d.ts → render-ViWKnlu1.d.ts} +23 -0
- package/package.json +1 -1
- package/src/builder.ts +6 -0
- package/src/kinds/storage.tsx +32 -0
- package/src/layout/spec.ts +23 -0
- package/src/layout.ts +6 -0
- package/src/presets.ts +22 -1
- package/src/render/stage.tsx +7 -0
- package/src/render/template-fields.ts +2 -0
- package/src/types.ts +23 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,51 @@ CDL (Chainome Diagram Language) の主要変更履歴。
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.25.0] - 2026-09-03
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **表の箱に 1 行おきの縞を敷けるようにした** (#1553)
|
|
13
|
+
|
|
14
|
+
ER 図は小さい字が密に並ぶので、行を横に追う時の目印が無い。
|
|
15
|
+
`id` の右端にある `bigint` がどの行のものか、目で辿り直すことになる。
|
|
16
|
+
|
|
17
|
+
色を増やさずに、面を 1 行おきに変えて追えるようにする。
|
|
18
|
+
色数を足して分ける形は 9 回試して全て外れており、増やすほど図が散らかった。
|
|
19
|
+
|
|
20
|
+
`rowStripe` を `CdlNode` に足し、`er` が設計の形 (`columns` を書いた実体) で立てた
|
|
21
|
+
実体に既定で敷く。 `er({ rowStripe: false })` で切れる。
|
|
22
|
+
|
|
23
|
+
**クラス図には敷かない**。 同じ `storage` を使うが、持ち物と振る舞いは行頭の印
|
|
24
|
+
(四角と山形) で既に分かれている。 縞を足すと手掛かりが 3 つになる。
|
|
25
|
+
|
|
26
|
+
縞の位置は `rowStripeBand` が行の baseline から導く。
|
|
27
|
+
縞だけが自前の定数を持つと、行送りを変えた時に字だけ動いて縞が取り残される。
|
|
28
|
+
呼び名で行の塊が下がる箱では、描画側が行に足すのと同じ値を帯にも足す。
|
|
29
|
+
|
|
30
|
+
帯は baseline を挟む。 上端を baseline に置くと字が帯の上へはみ出す。
|
|
31
|
+
|
|
32
|
+
箱の下端をまたぐ縞は描かない。 行数と箱の高さは独立に決まるので、行が多い図では
|
|
33
|
+
最後の行が箱の外に来る。
|
|
34
|
+
|
|
35
|
+
色は `--cdl-row-stripe` を読み、無ければ `--cdl-label-bg` に落ちる。
|
|
36
|
+
消費側が縞と札の下地を別に決めたくなった時に、engine を変えずに分けられる。
|
|
37
|
+
|
|
38
|
+
- **図に別の配色を名指しできるようにした** (#1553)
|
|
39
|
+
|
|
40
|
+
`palette` を `CdlDiagram` と `diagram()` と `er()` に足し、
|
|
41
|
+
`data-cdl-palette` として舞台の `<svg>` に出す。
|
|
42
|
+
|
|
43
|
+
**cdl は色の値を持たない**。 名前を markup に出すだけで、実際の値は消費側
|
|
44
|
+
(dragon の theme 等) が名前を見て決める。 値を engine に持たせると、
|
|
45
|
+
消費側が配色を変えるたびに engine の release が要る。
|
|
46
|
+
|
|
47
|
+
空文字は書かなかった扱いにする = 空の目印を出すと、消費側の `[data-cdl-palette]` が
|
|
48
|
+
配色を書いていない図にも当たる。
|
|
49
|
+
|
|
50
|
+
遮断は `layout` 1 箇所に置く。 描画は必ず組み立てを通るので、
|
|
51
|
+
組み立て API と `er` は素通しにしてある。 上流にも置くと、どの入力でも通らない分岐が残る。
|
|
52
|
+
|
|
8
53
|
## [0.24.0] - 2026-09-02
|
|
9
54
|
|
|
10
55
|
### Added
|
package/dist/index.cjs
CHANGED
|
@@ -11484,6 +11484,8 @@ function diagram(id, options) {
|
|
|
11484
11484
|
topic: options.topic,
|
|
11485
11485
|
// 既定 (extract) は省略して JSON 形状を変えない。 exclude を明示した図だけ持たせる。
|
|
11486
11486
|
...options.structuredData === "exclude" ? { structuredData: "exclude" } : {},
|
|
11487
|
+
// 配色の名前は素通しする。 空文字の遮断は `layout` が持つ (後段が必ず通るため)
|
|
11488
|
+
...options.palette !== void 0 ? { palette: options.palette } : {},
|
|
11487
11489
|
// inputs / formulas / scrollTriggers / eventBindings は空なら省略 (static diagram の JSON 形状維持)
|
|
11488
11490
|
...inputs.length > 0 ? { inputs: [...inputs] } : {},
|
|
11489
11491
|
...formulas.length > 0 ? { formulas: [...formulas] } : {},
|
|
@@ -11794,6 +11796,12 @@ function rowBaselineY(kind, index) {
|
|
|
11794
11796
|
if (!rendersRows(kind)) return null;
|
|
11795
11797
|
return kind === "storage" ? ROW_TOP_STORAGE + index * ROW_PITCH_STORAGE : ROW_TOP_GENERIC + genericTextShift(kind) + index * ROW_PITCH_GENERIC;
|
|
11796
11798
|
}
|
|
11799
|
+
function rowStripeBand(kind, index, shift) {
|
|
11800
|
+
const baseline = rowBaselineY(kind, index);
|
|
11801
|
+
if (baseline === null) return null;
|
|
11802
|
+
const pitch = ROW_PITCH_STORAGE ;
|
|
11803
|
+
return { y: baseline + shift - pitch / 2, h: pitch };
|
|
11804
|
+
}
|
|
11797
11805
|
function genericTextShift(kind) {
|
|
11798
11806
|
return KINDS_SHAPE_CYLINDER.has(kind ?? "") ? GENERIC_TEXT_SHIFT_CYLINDER : 0;
|
|
11799
11807
|
}
|
|
@@ -20258,6 +20266,12 @@ function layout(diag) {
|
|
|
20258
20266
|
...diag.derived ? { derived: diag.derived } : {},
|
|
20259
20267
|
// 矢印をいつ出すか (#582)。 描き手が読む欄なので、そのまま持ち越す
|
|
20260
20268
|
...diag.edgeReveal ? { edgeReveal: diag.edgeReveal } : {},
|
|
20269
|
+
// どの配色で描くか (#1553)。 空文字は書かなかった扱いにする = 空の目印を出すと、
|
|
20270
|
+
// 消費側の `[data-cdl-palette]` が配色を書いていない図にも当たる。
|
|
20271
|
+
//
|
|
20272
|
+
// **遮断はここだけに置く**。 描画は必ず組み立てを通り、組み立て API も `er` も
|
|
20273
|
+
// 素通しにしてある。 上流にも置くと、どの入力でも通らない分岐が残る
|
|
20274
|
+
...diag.palette ? { palette: diag.palette } : {},
|
|
20261
20275
|
bboxes,
|
|
20262
20276
|
collisions,
|
|
20263
20277
|
nearCollisions,
|
|
@@ -22809,6 +22823,25 @@ function StorageNode({
|
|
|
22809
22823
|
strokeWidth: active ? 3 : 1.25
|
|
22810
22824
|
}
|
|
22811
22825
|
),
|
|
22826
|
+
node.rowStripe && rows.map((_, idx) => {
|
|
22827
|
+
if (idx % 2 !== 0) return null;
|
|
22828
|
+
const \u5E2F = rowStripeBand("storage", idx, \u884C\u306E\u4E0B\u3052);
|
|
22829
|
+
if (!\u5E2F) return null;
|
|
22830
|
+
if (\u5E2F.y + \u5E2F.h > node.h) return null;
|
|
22831
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
22832
|
+
"rect",
|
|
22833
|
+
{
|
|
22834
|
+
"data-cdl-role": "node-row-stripe",
|
|
22835
|
+
"data-cdl-row-index": idx,
|
|
22836
|
+
x: 1,
|
|
22837
|
+
y: \u5E2F.y,
|
|
22838
|
+
width: node.w - 2,
|
|
22839
|
+
height: \u5E2F.h,
|
|
22840
|
+
fill: "var(--cdl-row-stripe, var(--cdl-label-bg, #f3f4f6))"
|
|
22841
|
+
},
|
|
22842
|
+
`stripe-${idx}`
|
|
22843
|
+
);
|
|
22844
|
+
}),
|
|
22812
22845
|
node.eyebrow && /* @__PURE__ */ jsxRuntime.jsx("text", { x: 26, y: 38, fontSize: 18, fontWeight: 700, letterSpacing: 2, fill: accent, children: node.eyebrow }),
|
|
22813
22846
|
\u5370\u3067\u5206\u3051\u308B && node.subtitle && // 呼び名は **印で分ける箱でだけ** 出す (#578)。 従来の箱は題の下に区切り線が来るので
|
|
22814
22847
|
// 置き場が無い
|
|
@@ -29656,6 +29689,7 @@ function CdlStage({
|
|
|
29656
29689
|
"aria-label": buildDiagramAltText(laid.topic, currentPhase),
|
|
29657
29690
|
"data-cdl-stage": "",
|
|
29658
29691
|
"data-cdl-scale": diagramScale === 1 ? void 0 : diagramScale,
|
|
29692
|
+
"data-cdl-palette": laid.palette,
|
|
29659
29693
|
children: [
|
|
29660
29694
|
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
29661
29695
|
Object.entries(TONE).flatMap(
|
|
@@ -30529,7 +30563,8 @@ var ER_CARDINALITY_HEAD = {
|
|
|
30529
30563
|
function er(preset) {
|
|
30530
30564
|
const entityW = resolveStorageBoxW(preset.entityWidth, "er", "entityWidth");
|
|
30531
30565
|
const tone = preset.defaultTone ?? "info";
|
|
30532
|
-
const
|
|
30566
|
+
const \u7E1E\u3092\u6577\u304F = preset.rowStripe ?? true;
|
|
30567
|
+
const b = diagram(preset.id, { topic: preset.topic, palette: preset.palette });
|
|
30533
30568
|
const entities = [];
|
|
30534
30569
|
const phaseActivate = [];
|
|
30535
30570
|
let relIdx = 0;
|
|
@@ -30565,7 +30600,10 @@ function er(preset) {
|
|
|
30565
30600
|
...\u8A2D\u8A08\u306E\u5F62 ? {} : { eyebrow: "\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3" },
|
|
30566
30601
|
...\u8A2D\u8A08\u306E\u5F62 && e.subtitle ? { subtitle: e.subtitle } : {},
|
|
30567
30602
|
rows,
|
|
30568
|
-
...\u8A2D\u8A08\u306E\u5F62 ? { rowMarks: \u5370 } : {}
|
|
30603
|
+
...\u8A2D\u8A08\u306E\u5F62 ? { rowMarks: \u5370 } : {},
|
|
30604
|
+
// 縞は設計の形だけに敷く (#1553)。 `rows` を直接書いた古い形は行頭の印を持たず、
|
|
30605
|
+
// 群の区切りも線で表しているので、縞を足すと手掛かりが 3 つになる
|
|
30606
|
+
...\u8A2D\u8A08\u306E\u5F62 && \u7E1E\u3092\u6577\u304F ? { rowStripe: true } : {}
|
|
30569
30607
|
});
|
|
30570
30608
|
entities.push(e.id);
|
|
30571
30609
|
phaseActivate.push(e.id);
|