@cardenelabs/cdl 0.108.0 → 0.109.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cardenelabs/cdl",
3
- "version": "0.108.0",
3
+ "version": "0.109.0",
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",
@@ -10,6 +10,7 @@ export function CdlHeader({
10
10
  states,
11
11
  onJumpPhase,
12
12
  headingLevel = 3,
13
+ showTopic = true,
13
14
  }: {
14
15
  topic: string;
15
16
  phases: CdlPhase[];
@@ -21,12 +22,20 @@ export function CdlHeader({
21
22
  /** phase title 描画時の heading tag level (2 | 3 | 4)、 default 3 で従来動作維持。
22
23
  * downstream で h1 直後に配置する場合は 2、 h2 直後なら 3 (default)、 h3 直後なら 4。 */
23
24
  headingLevel?: 2 | 3 | 4;
25
+ /**
26
+ * 話題を左上に出すか (#955)。 図が同じ字を既に描いている時だけ呼出側が `false` を渡す。
27
+ *
28
+ * 段の印は `ml-auto` で右へ寄せてあるので、話題を落としても並びは動かない。
29
+ */
30
+ showTopic?: boolean;
24
31
  }): JSX.Element {
25
32
  const HeadingTag = (`h${headingLevel}` as "h2" | "h3" | "h4");
26
33
  return (
27
34
  <div className="border-b border-[var(--cdl-divider,#d4d4d8)]/35 px-7 py-6">
28
35
  <div className="mb-5 flex items-center gap-3">
29
- <div className="text-[10px] font-bold uppercase tracking-[0.2em]" style={{ color: "var(--cdl-text-accent, #2d6a8f)" }}>{topic}</div>
36
+ {showTopic && (
37
+ <div className="text-[10px] font-bold uppercase tracking-[0.2em]" style={{ color: "var(--cdl-text-accent, #2d6a8f)" }}>{topic}</div>
38
+ )}
30
39
  <div className="ml-auto flex items-center gap-1.5">
31
40
  {phases.map((p, idx) => {
32
41
  const active = idx === phaseIdx;
package/src/render.tsx CHANGED
@@ -2,6 +2,7 @@ import { useEffect, useMemo } from "react";
2
2
  import type { JSX } from "react";
3
3
  import { useReducedMotion, useTimeline } from "./anim/react";
4
4
  import { compile } from "./compile";
5
+ import { drawsFigureTitle } from "./layout/spec";
5
6
  import { CdlHeader } from "./render/header";
6
7
  import { CdlStage } from "./render/stage";
7
8
  import {
@@ -170,6 +171,21 @@ export function CdlDiagramView({ diagram, laid: laidProp, hideHeader = false, hi
170
171
  // (出し分けと綴りで読む読み出しは値を綴りのまま読む)
171
172
  const 値の名前 = useMemo(() => 値の名前の表を作る(diagram.inputs), [diagram.inputs]);
172
173
 
174
+ /**
175
+ * 図が話題と同じ字を既に描いているか (#955)。
176
+ *
177
+ * 図表 15 種は 0.96.0 (#930) から自分の題を箱の上に描く。 頭の帯も話題を出すので、
178
+ * 話題と題が同じ図では同じ字が 2 か所に並ぶ。 描いている側を残し、帯の 1 行を落とす。
179
+ *
180
+ * 種別の一覧は `drawsFigureTitle` から導く。 手で持つと engine に図表が増えた日にずれる。
181
+ * 箱の題 (`node-label`) は数えない = 箱は図の中の 1 つにすぎず、話題を名乗る場所が他に無い。
182
+ */
183
+ const 図が話題を描く = useMemo(() => {
184
+ const 話題 = laid.topic.trim();
185
+ if (話題 === "") return false;
186
+ return laid.nodes.some((n) => drawsFigureTitle(n.kind) && (n.title ?? "").trim() === 話題);
187
+ }, [laid.nodes, laid.topic]);
188
+
173
189
  return (
174
190
  <div
175
191
  ref={isInteractive ? interactive.containerRef : undefined}
@@ -193,6 +209,7 @@ export function CdlDiagramView({ diagram, laid: laidProp, hideHeader = false, hi
193
209
  timeline.play();
194
210
  }}
195
211
  headingLevel={headingLevel}
212
+ showTopic={!図が話題を描く}
196
213
  />
197
214
  )}
198
215
  {/* interactive panel = input widget / formula readout / scroll readout (SVG の上に配置)、