@cardenelabs/cdl 0.24.0 → 0.26.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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CdlDiagram, S as Signal, a as CdlInput, b as CdlLane, c as CdlNode, T as Tone, d as Side, E as EdgeStyle, e as EdgeRole, f as EdgeHead, g as EdgeHeadFill, h as CdlState, i as CdlEventTarget, j as Computed, k as CdlDerivedValue, l as CdlScrollTrigger, L as LaidDiagram, m as CdlDiagramViewProps, n as LaidEdge, o as LaidNode, p as CdlEdge, B as BBox, R as RowMark, N as NodeKind, J as JourneyEmotion, Q as QuadrantKey } from './render-CfXUl0Yz.cjs';
2
- export { q as CdlDiagramView, r as CdlEventBinding, s as CdlEventKind, t as CdlFormula, u as CdlPhase, v as EDGE_HEADS, w as EDGE_HEAD_DEFAULT, x as EDGE_HEAD_FILLS, y as EDGE_HEAD_FILL_DEFAULT, z as EDGE_REVEALS, A as EDGE_REVEAL_DEFAULT, D as EDGE_STYLES, F as EdgeReveal, I as InteractiveHandlerMap, G as InteractiveSignalsAccessor, H as LaidLane, K as NODE_KINDS, M as ScrollProgressHandle, O as TONES, P as computeEventBindingKey, U as computeFormulaKey, V as computeInputSignalKey, W as computeScrollTriggerKey, X as computed, Y as createInteractiveSignalsAccessor, Z as createScrollProgressHandle, _ as createScrollProgressSignals, $ as hasInteractivePrimitives, a0 as sequenceBoardMetrics, a1 as sequenceStepId, a2 as signal } from './render-CfXUl0Yz.cjs';
1
+ import { C as CdlDiagram, S as Signal, a as CdlInput, b as CdlLane, c as CdlNode, T as Tone, d as Side, E as EdgeStyle, e as EdgeRole, f as EdgeHead, g as EdgeHeadFill, h as CdlState, i as CdlEventTarget, j as Computed, k as CdlDerivedValue, l as CdlScrollTrigger, L as LaidDiagram, m as CdlDiagramViewProps, n as LaidEdge, o as LaidNode, p as CdlEdge, B as BBox, R as RowMark, N as NodeKind, J as JourneyEmotion, Q as QuadrantKey } from './render-ViWKnlu1.cjs';
2
+ export { q as CdlDiagramView, r as CdlEventBinding, s as CdlEventKind, t as CdlFormula, u as CdlPhase, v as EDGE_HEADS, w as EDGE_HEAD_DEFAULT, x as EDGE_HEAD_FILLS, y as EDGE_HEAD_FILL_DEFAULT, z as EDGE_REVEALS, A as EDGE_REVEAL_DEFAULT, D as EDGE_STYLES, F as EdgeReveal, I as InteractiveHandlerMap, G as InteractiveSignalsAccessor, H as LaidLane, K as NODE_KINDS, M as ScrollProgressHandle, O as TONES, P as computeEventBindingKey, U as computeFormulaKey, V as computeInputSignalKey, W as computeScrollTriggerKey, X as computed, Y as createInteractiveSignalsAccessor, Z as createScrollProgressHandle, _ as createScrollProgressSignals, $ as hasInteractivePrimitives, a0 as sequenceBoardMetrics, a1 as sequenceStepId, a2 as signal } from './render-ViWKnlu1.cjs';
3
3
  import { JSX } from 'react';
4
4
 
5
5
  declare function effect(fn: () => void | (() => void)): () => void;
@@ -1206,6 +1206,10 @@ declare function diagram(id: string, options: {
1206
1206
  * `"exclude"` を付ける。 詳細は `CdlDiagram.structuredData` の doc 参照。
1207
1207
  */
1208
1208
  structuredData?: "extract" | "exclude";
1209
+ /**
1210
+ * この図をどの配色で描くか (#1553)。 詳細は `CdlDiagram.palette` の doc 参照。
1211
+ */
1212
+ palette?: string;
1209
1213
  }): DiagramBuilder;
1210
1214
 
1211
1215
  /**
@@ -3069,6 +3073,22 @@ type ErPreset = {
3069
3073
  * 広げるため、 狭く宣言すると宣言座標と実座標がずれる)。
3070
3074
  */
3071
3075
  entityWidth?: number;
3076
+ /**
3077
+ * 行に 1 行おきの縞を敷くか (#1553、 既定 = 敷く)。
3078
+ *
3079
+ * ER 図は小さい字が密に並ぶので、行を横に追う時の目印が無い。
3080
+ * 色を増やさずに面を 1 行おきに変えて追えるようにする。
3081
+ *
3082
+ * 設計の形 (`columns` を書いた実体) だけが対象。 `rows` を直接書いた古い形は
3083
+ * 行頭の印を持たないので敷かない。
3084
+ */
3085
+ rowStripe?: boolean;
3086
+ /**
3087
+ * この図をどの配色で描くか (#1553)。 書かない図は消費側の既定で描かれる。
3088
+ *
3089
+ * cdl は色の値を持たない。 名前を markup に出すだけで、実際の値は消費側が決める。
3090
+ */
3091
+ palette?: string;
3072
3092
  };
3073
3093
  type ErBuilder = {
3074
3094
  entity: (e: ErEntity) => ErBuilder;
@@ -3339,6 +3359,17 @@ type ClassDiagramPreset = {
3339
3359
  * 帯ではなく **箱** の幅。 帯は `箱の幅 + 余白 × 2` で宣言する。
3340
3360
  */
3341
3361
  classWidth?: number;
3362
+ /**
3363
+ * 行に 1 行おきの縞を敷くか (既定 = 敷く、 #627)。
3364
+ *
3365
+ * クラス図の箱は ER 図と同じ作り (行頭の印 + 左に名前 + 右に型) をしており、名前と型が
3366
+ * 離れて並ぶので行を横に追う目印が要る。 `er()` と同じ既定にする。
3367
+ */
3368
+ rowStripe?: boolean;
3369
+ /**
3370
+ * 図の配色の名前 (#627)。 描き手は色を持たないので、名前をそのまま markup に出す。
3371
+ */
3372
+ palette?: string;
3342
3373
  };
3343
3374
  type ClassDiagramBuilder = {
3344
3375
  class: (c: UmlClass) => ClassDiagramBuilder;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CdlDiagram, S as Signal, a as CdlInput, b as CdlLane, c as CdlNode, T as Tone, d as Side, E as EdgeStyle, e as EdgeRole, f as EdgeHead, g as EdgeHeadFill, h as CdlState, i as CdlEventTarget, j as Computed, k as CdlDerivedValue, l as CdlScrollTrigger, L as LaidDiagram, m as CdlDiagramViewProps, n as LaidEdge, o as LaidNode, p as CdlEdge, B as BBox, R as RowMark, N as NodeKind, J as JourneyEmotion, Q as QuadrantKey } from './render-CfXUl0Yz.js';
2
- export { q as CdlDiagramView, r as CdlEventBinding, s as CdlEventKind, t as CdlFormula, u as CdlPhase, v as EDGE_HEADS, w as EDGE_HEAD_DEFAULT, x as EDGE_HEAD_FILLS, y as EDGE_HEAD_FILL_DEFAULT, z as EDGE_REVEALS, A as EDGE_REVEAL_DEFAULT, D as EDGE_STYLES, F as EdgeReveal, I as InteractiveHandlerMap, G as InteractiveSignalsAccessor, H as LaidLane, K as NODE_KINDS, M as ScrollProgressHandle, O as TONES, P as computeEventBindingKey, U as computeFormulaKey, V as computeInputSignalKey, W as computeScrollTriggerKey, X as computed, Y as createInteractiveSignalsAccessor, Z as createScrollProgressHandle, _ as createScrollProgressSignals, $ as hasInteractivePrimitives, a0 as sequenceBoardMetrics, a1 as sequenceStepId, a2 as signal } from './render-CfXUl0Yz.js';
1
+ import { C as CdlDiagram, S as Signal, a as CdlInput, b as CdlLane, c as CdlNode, T as Tone, d as Side, E as EdgeStyle, e as EdgeRole, f as EdgeHead, g as EdgeHeadFill, h as CdlState, i as CdlEventTarget, j as Computed, k as CdlDerivedValue, l as CdlScrollTrigger, L as LaidDiagram, m as CdlDiagramViewProps, n as LaidEdge, o as LaidNode, p as CdlEdge, B as BBox, R as RowMark, N as NodeKind, J as JourneyEmotion, Q as QuadrantKey } from './render-ViWKnlu1.js';
2
+ export { q as CdlDiagramView, r as CdlEventBinding, s as CdlEventKind, t as CdlFormula, u as CdlPhase, v as EDGE_HEADS, w as EDGE_HEAD_DEFAULT, x as EDGE_HEAD_FILLS, y as EDGE_HEAD_FILL_DEFAULT, z as EDGE_REVEALS, A as EDGE_REVEAL_DEFAULT, D as EDGE_STYLES, F as EdgeReveal, I as InteractiveHandlerMap, G as InteractiveSignalsAccessor, H as LaidLane, K as NODE_KINDS, M as ScrollProgressHandle, O as TONES, P as computeEventBindingKey, U as computeFormulaKey, V as computeInputSignalKey, W as computeScrollTriggerKey, X as computed, Y as createInteractiveSignalsAccessor, Z as createScrollProgressHandle, _ as createScrollProgressSignals, $ as hasInteractivePrimitives, a0 as sequenceBoardMetrics, a1 as sequenceStepId, a2 as signal } from './render-ViWKnlu1.js';
3
3
  import { JSX } from 'react';
4
4
 
5
5
  declare function effect(fn: () => void | (() => void)): () => void;
@@ -1206,6 +1206,10 @@ declare function diagram(id: string, options: {
1206
1206
  * `"exclude"` を付ける。 詳細は `CdlDiagram.structuredData` の doc 参照。
1207
1207
  */
1208
1208
  structuredData?: "extract" | "exclude";
1209
+ /**
1210
+ * この図をどの配色で描くか (#1553)。 詳細は `CdlDiagram.palette` の doc 参照。
1211
+ */
1212
+ palette?: string;
1209
1213
  }): DiagramBuilder;
1210
1214
 
1211
1215
  /**
@@ -3069,6 +3073,22 @@ type ErPreset = {
3069
3073
  * 広げるため、 狭く宣言すると宣言座標と実座標がずれる)。
3070
3074
  */
3071
3075
  entityWidth?: number;
3076
+ /**
3077
+ * 行に 1 行おきの縞を敷くか (#1553、 既定 = 敷く)。
3078
+ *
3079
+ * ER 図は小さい字が密に並ぶので、行を横に追う時の目印が無い。
3080
+ * 色を増やさずに面を 1 行おきに変えて追えるようにする。
3081
+ *
3082
+ * 設計の形 (`columns` を書いた実体) だけが対象。 `rows` を直接書いた古い形は
3083
+ * 行頭の印を持たないので敷かない。
3084
+ */
3085
+ rowStripe?: boolean;
3086
+ /**
3087
+ * この図をどの配色で描くか (#1553)。 書かない図は消費側の既定で描かれる。
3088
+ *
3089
+ * cdl は色の値を持たない。 名前を markup に出すだけで、実際の値は消費側が決める。
3090
+ */
3091
+ palette?: string;
3072
3092
  };
3073
3093
  type ErBuilder = {
3074
3094
  entity: (e: ErEntity) => ErBuilder;
@@ -3339,6 +3359,17 @@ type ClassDiagramPreset = {
3339
3359
  * 帯ではなく **箱** の幅。 帯は `箱の幅 + 余白 × 2` で宣言する。
3340
3360
  */
3341
3361
  classWidth?: number;
3362
+ /**
3363
+ * 行に 1 行おきの縞を敷くか (既定 = 敷く、 #627)。
3364
+ *
3365
+ * クラス図の箱は ER 図と同じ作り (行頭の印 + 左に名前 + 右に型) をしており、名前と型が
3366
+ * 離れて並ぶので行を横に追う目印が要る。 `er()` と同じ既定にする。
3367
+ */
3368
+ rowStripe?: boolean;
3369
+ /**
3370
+ * 図の配色の名前 (#627)。 描き手は色を持たないので、名前をそのまま markup に出す。
3371
+ */
3372
+ palette?: string;
3342
3373
  };
3343
3374
  type ClassDiagramBuilder = {
3344
3375
  class: (c: UmlClass) => ClassDiagramBuilder;
package/dist/index.js CHANGED
@@ -11482,6 +11482,8 @@ function diagram(id, options) {
11482
11482
  topic: options.topic,
11483
11483
  // 既定 (extract) は省略して JSON 形状を変えない。 exclude を明示した図だけ持たせる。
11484
11484
  ...options.structuredData === "exclude" ? { structuredData: "exclude" } : {},
11485
+ // 配色の名前は素通しする。 空文字の遮断は `layout` が持つ (後段が必ず通るため)
11486
+ ...options.palette !== void 0 ? { palette: options.palette } : {},
11485
11487
  // inputs / formulas / scrollTriggers / eventBindings は空なら省略 (static diagram の JSON 形状維持)
11486
11488
  ...inputs.length > 0 ? { inputs: [...inputs] } : {},
11487
11489
  ...formulas.length > 0 ? { formulas: [...formulas] } : {},
@@ -11792,6 +11794,12 @@ function rowBaselineY(kind, index) {
11792
11794
  if (!rendersRows(kind)) return null;
11793
11795
  return kind === "storage" ? ROW_TOP_STORAGE + index * ROW_PITCH_STORAGE : ROW_TOP_GENERIC + genericTextShift(kind) + index * ROW_PITCH_GENERIC;
11794
11796
  }
11797
+ function rowStripeBand(kind, index, shift) {
11798
+ const baseline = rowBaselineY(kind, index);
11799
+ if (baseline === null) return null;
11800
+ const pitch = ROW_PITCH_STORAGE ;
11801
+ return { y: baseline + shift - pitch / 2, h: pitch };
11802
+ }
11795
11803
  function genericTextShift(kind) {
11796
11804
  return KINDS_SHAPE_CYLINDER.has(kind ?? "") ? GENERIC_TEXT_SHIFT_CYLINDER : 0;
11797
11805
  }
@@ -20256,6 +20264,12 @@ function layout(diag) {
20256
20264
  ...diag.derived ? { derived: diag.derived } : {},
20257
20265
  // 矢印をいつ出すか (#582)。 描き手が読む欄なので、そのまま持ち越す
20258
20266
  ...diag.edgeReveal ? { edgeReveal: diag.edgeReveal } : {},
20267
+ // どの配色で描くか (#1553)。 空文字は書かなかった扱いにする = 空の目印を出すと、
20268
+ // 消費側の `[data-cdl-palette]` が配色を書いていない図にも当たる。
20269
+ //
20270
+ // **遮断はここだけに置く**。 描画は必ず組み立てを通り、組み立て API も `er` も
20271
+ // 素通しにしてある。 上流にも置くと、どの入力でも通らない分岐が残る
20272
+ ...diag.palette ? { palette: diag.palette } : {},
20259
20273
  bboxes,
20260
20274
  collisions,
20261
20275
  nearCollisions,
@@ -22750,6 +22764,7 @@ var ROW_GLYPH_CX = ROW_PAD_X_PX + ROW_GLYPH_HALF + 1;
22750
22764
  var ROW_GLYPH_LEAD = 40;
22751
22765
  var ROW_TYPE_FONT = 22;
22752
22766
  var SUBTITLE_BASELINE = 118;
22767
+ var STRIPE_MIN_ROWS = 2;
22753
22768
  var SUBTITLE_FONT = 20;
22754
22769
  var UNDERLINE_DROP = 7;
22755
22770
  function RowGlyph({ mark, x, y, color }) {
@@ -22807,6 +22822,25 @@ function StorageNode({
22807
22822
  strokeWidth: active ? 3 : 1.25
22808
22823
  }
22809
22824
  ),
22825
+ node.rowStripe && rows.length >= STRIPE_MIN_ROWS && rows.map((_, idx) => {
22826
+ if (idx % 2 !== 0) return null;
22827
+ const \u5E2F = rowStripeBand("storage", idx, \u884C\u306E\u4E0B\u3052);
22828
+ if (!\u5E2F) return null;
22829
+ if (\u5E2F.y + \u5E2F.h > node.h) return null;
22830
+ return /* @__PURE__ */ jsx(
22831
+ "rect",
22832
+ {
22833
+ "data-cdl-role": "node-row-stripe",
22834
+ "data-cdl-row-index": idx,
22835
+ x: 1,
22836
+ y: \u5E2F.y,
22837
+ width: node.w - 2,
22838
+ height: \u5E2F.h,
22839
+ fill: "var(--cdl-row-stripe, var(--cdl-label-bg, #f3f4f6))"
22840
+ },
22841
+ `stripe-${idx}`
22842
+ );
22843
+ }),
22810
22844
  node.eyebrow && /* @__PURE__ */ jsx("text", { x: 26, y: 38, fontSize: 18, fontWeight: 700, letterSpacing: 2, fill: accent, children: node.eyebrow }),
22811
22845
  \u5370\u3067\u5206\u3051\u308B && node.subtitle && // 呼び名は **印で分ける箱でだけ** 出す (#578)。 従来の箱は題の下に区切り線が来るので
22812
22846
  // 置き場が無い
@@ -29654,6 +29688,7 @@ function CdlStage({
29654
29688
  "aria-label": buildDiagramAltText(laid.topic, currentPhase),
29655
29689
  "data-cdl-stage": "",
29656
29690
  "data-cdl-scale": diagramScale === 1 ? void 0 : diagramScale,
29691
+ "data-cdl-palette": laid.palette,
29657
29692
  children: [
29658
29693
  /* @__PURE__ */ jsxs("defs", { children: [
29659
29694
  Object.entries(TONE).flatMap(
@@ -30527,7 +30562,8 @@ var ER_CARDINALITY_HEAD = {
30527
30562
  function er(preset) {
30528
30563
  const entityW = resolveStorageBoxW(preset.entityWidth, "er", "entityWidth");
30529
30564
  const tone = preset.defaultTone ?? "info";
30530
- const b = diagram(preset.id, { topic: preset.topic });
30565
+ const \u7E1E\u3092\u6577\u304F = preset.rowStripe ?? true;
30566
+ const b = diagram(preset.id, { topic: preset.topic, palette: preset.palette });
30531
30567
  const entities = [];
30532
30568
  const phaseActivate = [];
30533
30569
  let relIdx = 0;
@@ -30563,7 +30599,10 @@ function er(preset) {
30563
30599
  ...\u8A2D\u8A08\u306E\u5F62 ? {} : { eyebrow: "\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3" },
30564
30600
  ...\u8A2D\u8A08\u306E\u5F62 && e.subtitle ? { subtitle: e.subtitle } : {},
30565
30601
  rows,
30566
- ...\u8A2D\u8A08\u306E\u5F62 ? { rowMarks: \u5370 } : {}
30602
+ ...\u8A2D\u8A08\u306E\u5F62 ? { rowMarks: \u5370 } : {},
30603
+ // 縞は設計の形だけに敷く (#1553)。 `rows` を直接書いた古い形は行頭の印を持たず、
30604
+ // 群の区切りも線で表しているので、縞を足すと手掛かりが 3 つになる
30605
+ ...\u8A2D\u8A08\u306E\u5F62 && \u7E1E\u3092\u6577\u304F ? { rowStripe: true } : {}
30567
30606
  });
30568
30607
  entities.push(e.id);
30569
30608
  phaseActivate.push(e.id);
@@ -30794,7 +30833,8 @@ function stripAccess(row) {
30794
30833
  function classDiagram(preset) {
30795
30834
  const classW = resolveStorageBoxW(preset.classWidth, "classDiagram", "classWidth");
30796
30835
  const tone = preset.defaultTone ?? "info";
30797
- const b = diagram(preset.id, { topic: preset.topic });
30836
+ const \u7E1E\u3092\u6577\u304F = preset.rowStripe ?? true;
30837
+ const b = diagram(preset.id, { topic: preset.topic, palette: preset.palette });
30798
30838
  const classes = [];
30799
30839
  const phaseActivate = [];
30800
30840
  const \u7BB1 = [];
@@ -30842,7 +30882,9 @@ function classDiagram(preset) {
30842
30882
  // 種類の札は **書いた時だけ** 出す (#578)。 「クラス」 と書いた札は箱がクラスで
30843
30883
  // あることしか言わず、図の中の全ての箱に同じ字が並ぶ
30844
30884
  ...m.c.stereotype ? { eyebrow: m.c.stereotype } : {},
30845
- ...m.rows.length > 0 ? { rows: m.rows, rowMarks: m.rowMarks } : {}
30885
+ ...m.rows.length > 0 ? { rows: m.rows, rowMarks: m.rowMarks } : {},
30886
+ // 縞は行を持つ箱にだけ敷く (#627)。 行が無い箱に書いても描き手が読まない
30887
+ ...m.rows.length > 0 && \u7E1E\u3092\u6577\u304F ? { rowStripe: true } : {}
30846
30888
  });
30847
30889
  classes.push(m.c.id);
30848
30890
  phaseActivate.push(m.c.id);