@cardenelabs/cdl 0.35.0 → 0.36.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.
@@ -423,6 +423,21 @@ type CdlNode = {
423
423
  * `previous` (cdl#680) が効くのは `ring` だけ。 他の形は内側の輪を描かない。
424
424
  */
425
425
  chartPieForm?: ChartPieForm;
426
+ /**
427
+ * chart-slope の見せ方 (cdl#702)。 右の列に何の数を出すかを決める。
428
+ *
429
+ * - `values` ... 今の値
430
+ * - `delta` ... 増減 (`+40` / `-90`)
431
+ *
432
+ * 左の列は どちらでも前の値。 `前 + 増減 = 今` なので、 `delta` でも今の値は足せば戻る。
433
+ * 3 つ目の数を足さないので、 名札の高さも線を引く幅も変わらない。
434
+ *
435
+ * 型の外の値は `values` として描く = 見せ方が決まらないより、既定の形が出る方がよい。
436
+ *
437
+ * 前の時点を持たない図 (`previous` が 1 件も無い) は右の列そのものが無いため、
438
+ * この欄を書いても絵は変わらない。
439
+ */
440
+ chartSlopeForm?: ChartSlopeForm;
426
441
  /**
427
442
  * gantt-timeline 専用の task payload。 task 全件を 1 node に格納し、
428
443
  * kinds/gantt.tsx が縦軸 task lane + 横軸日付 rect bar で SVG 描画する。
@@ -478,6 +493,8 @@ type BoundEnum<T extends string> = T | (string & {});
478
493
  /** Chart 系 kind の 1 datum payload。 label + value + optional tone (color) */
479
494
  /** chart-pie の見せ方 (cdl#684)。 SSOT は `kinds/chart-pie.tsx` */
480
495
  type ChartPieForm = "ring" | "arcs" | "table";
496
+ /** chart-slope の見せ方 (cdl#702)。 SSOT は `kinds/chart-slope.tsx` */
497
+ type ChartSlopeForm = "values" | "delta";
481
498
  type ChartDatumPayload = {
482
499
  label: string;
483
500
  /** 棒 / 折れ線 / 扇の大きさ。 `{signal}` で状態に追随する */
@@ -2883,4 +2900,4 @@ type CdlDiagramViewProps = {
2883
2900
  };
2884
2901
  declare function CdlDiagramView({ diagram, laid: laidProp, hideHeader, hideMiniPhaseIndicator, focusPhaseId, debug, emitGeometryWarn, headingLevel, interactiveHandlers }: CdlDiagramViewProps): JSX.Element;
2885
2902
 
2886
- export { createScrollProgressSignals as $, EDGE_REVEALS as A, type BBox as B, type CdlDiagram as C, EDGE_REVEAL_DEFAULT as D, type EdgeStyle as E, EDGE_STYLES as F, type EdgeReveal as G, type InteractiveSignalsAccessor as H, type InteractiveHandlerMap as I, type JourneyEmotion as J, type LaidLane as K, type LaidDiagram as L, NODE_KINDS as M, type NodeKind as N, type ScrollProgressHandle as O, TONES as P, type QuadrantKey as Q, type RowMark as R, type Signal as S, type Tone as T, computeEventBindingKey as U, computeFormulaKey as V, computeInputSignalKey as W, computeScrollTriggerKey as X, computed as Y, createInteractiveSignalsAccessor as Z, createScrollProgressHandle as _, type CdlInput as a, hasInteractivePrimitives as a0, sequenceBoardMetrics as a1, sequenceStepId as a2, signal as a3, type CdlLane as b, type CdlNode as c, type Side as d, type EdgeRole as e, type EdgeHead as f, type EdgeHeadFill as g, type CdlState as h, type CdlEventTarget as i, type Computed as j, type CdlDerivedValue as k, type CdlScrollTrigger as l, type CdlDiagramViewProps as m, type LaidEdge as n, type LaidNode as o, type CdlEdge as p, CdlDiagramView as q, type CdlEventBinding as r, type CdlEventKind as s, type CdlFormula as t, type CdlPhase as u, type ChartPieForm as v, EDGE_HEADS as w, EDGE_HEAD_DEFAULT as x, EDGE_HEAD_FILLS as y, EDGE_HEAD_FILL_DEFAULT as z };
2903
+ export { createScrollProgressHandle as $, EDGE_HEAD_FILL_DEFAULT as A, type BBox as B, type CdlDiagram as C, EDGE_REVEALS as D, type EdgeStyle as E, EDGE_REVEAL_DEFAULT as F, EDGE_STYLES as G, type EdgeReveal as H, type InteractiveHandlerMap as I, type JourneyEmotion as J, type InteractiveSignalsAccessor as K, type LaidDiagram as L, type LaidLane as M, type NodeKind as N, NODE_KINDS as O, type ScrollProgressHandle as P, type QuadrantKey as Q, type RowMark as R, type Signal as S, type Tone as T, TONES as U, computeEventBindingKey as V, computeFormulaKey as W, computeInputSignalKey as X, computeScrollTriggerKey as Y, computed as Z, createInteractiveSignalsAccessor as _, type CdlInput as a, createScrollProgressSignals as a0, hasInteractivePrimitives as a1, sequenceBoardMetrics as a2, sequenceStepId as a3, signal as a4, type CdlLane as b, type CdlNode as c, type Side as d, type EdgeRole as e, type EdgeHead as f, type EdgeHeadFill as g, type CdlState as h, type CdlEventTarget as i, type Computed as j, type CdlDerivedValue as k, type CdlScrollTrigger as l, type CdlDiagramViewProps as m, type LaidEdge as n, type LaidNode as o, type CdlEdge as p, CdlDiagramView as q, type CdlEventBinding as r, type CdlEventKind as s, type CdlFormula as t, type CdlPhase as u, type ChartPieForm as v, type ChartSlopeForm as w, EDGE_HEADS as x, EDGE_HEAD_DEFAULT as y, EDGE_HEAD_FILLS as z };
@@ -423,6 +423,21 @@ type CdlNode = {
423
423
  * `previous` (cdl#680) が効くのは `ring` だけ。 他の形は内側の輪を描かない。
424
424
  */
425
425
  chartPieForm?: ChartPieForm;
426
+ /**
427
+ * chart-slope の見せ方 (cdl#702)。 右の列に何の数を出すかを決める。
428
+ *
429
+ * - `values` ... 今の値
430
+ * - `delta` ... 増減 (`+40` / `-90`)
431
+ *
432
+ * 左の列は どちらでも前の値。 `前 + 増減 = 今` なので、 `delta` でも今の値は足せば戻る。
433
+ * 3 つ目の数を足さないので、 名札の高さも線を引く幅も変わらない。
434
+ *
435
+ * 型の外の値は `values` として描く = 見せ方が決まらないより、既定の形が出る方がよい。
436
+ *
437
+ * 前の時点を持たない図 (`previous` が 1 件も無い) は右の列そのものが無いため、
438
+ * この欄を書いても絵は変わらない。
439
+ */
440
+ chartSlopeForm?: ChartSlopeForm;
426
441
  /**
427
442
  * gantt-timeline 専用の task payload。 task 全件を 1 node に格納し、
428
443
  * kinds/gantt.tsx が縦軸 task lane + 横軸日付 rect bar で SVG 描画する。
@@ -478,6 +493,8 @@ type BoundEnum<T extends string> = T | (string & {});
478
493
  /** Chart 系 kind の 1 datum payload。 label + value + optional tone (color) */
479
494
  /** chart-pie の見せ方 (cdl#684)。 SSOT は `kinds/chart-pie.tsx` */
480
495
  type ChartPieForm = "ring" | "arcs" | "table";
496
+ /** chart-slope の見せ方 (cdl#702)。 SSOT は `kinds/chart-slope.tsx` */
497
+ type ChartSlopeForm = "values" | "delta";
481
498
  type ChartDatumPayload = {
482
499
  label: string;
483
500
  /** 棒 / 折れ線 / 扇の大きさ。 `{signal}` で状態に追随する */
@@ -2883,4 +2900,4 @@ type CdlDiagramViewProps = {
2883
2900
  };
2884
2901
  declare function CdlDiagramView({ diagram, laid: laidProp, hideHeader, hideMiniPhaseIndicator, focusPhaseId, debug, emitGeometryWarn, headingLevel, interactiveHandlers }: CdlDiagramViewProps): JSX.Element;
2885
2902
 
2886
- export { createScrollProgressSignals as $, EDGE_REVEALS as A, type BBox as B, type CdlDiagram as C, EDGE_REVEAL_DEFAULT as D, type EdgeStyle as E, EDGE_STYLES as F, type EdgeReveal as G, type InteractiveSignalsAccessor as H, type InteractiveHandlerMap as I, type JourneyEmotion as J, type LaidLane as K, type LaidDiagram as L, NODE_KINDS as M, type NodeKind as N, type ScrollProgressHandle as O, TONES as P, type QuadrantKey as Q, type RowMark as R, type Signal as S, type Tone as T, computeEventBindingKey as U, computeFormulaKey as V, computeInputSignalKey as W, computeScrollTriggerKey as X, computed as Y, createInteractiveSignalsAccessor as Z, createScrollProgressHandle as _, type CdlInput as a, hasInteractivePrimitives as a0, sequenceBoardMetrics as a1, sequenceStepId as a2, signal as a3, type CdlLane as b, type CdlNode as c, type Side as d, type EdgeRole as e, type EdgeHead as f, type EdgeHeadFill as g, type CdlState as h, type CdlEventTarget as i, type Computed as j, type CdlDerivedValue as k, type CdlScrollTrigger as l, type CdlDiagramViewProps as m, type LaidEdge as n, type LaidNode as o, type CdlEdge as p, CdlDiagramView as q, type CdlEventBinding as r, type CdlEventKind as s, type CdlFormula as t, type CdlPhase as u, type ChartPieForm as v, EDGE_HEADS as w, EDGE_HEAD_DEFAULT as x, EDGE_HEAD_FILLS as y, EDGE_HEAD_FILL_DEFAULT as z };
2903
+ export { createScrollProgressHandle as $, EDGE_HEAD_FILL_DEFAULT as A, type BBox as B, type CdlDiagram as C, EDGE_REVEALS as D, type EdgeStyle as E, EDGE_REVEAL_DEFAULT as F, EDGE_STYLES as G, type EdgeReveal as H, type InteractiveHandlerMap as I, type JourneyEmotion as J, type InteractiveSignalsAccessor as K, type LaidDiagram as L, type LaidLane as M, type NodeKind as N, NODE_KINDS as O, type ScrollProgressHandle as P, type QuadrantKey as Q, type RowMark as R, type Signal as S, type Tone as T, TONES as U, computeEventBindingKey as V, computeFormulaKey as W, computeInputSignalKey as X, computeScrollTriggerKey as Y, computed as Z, createInteractiveSignalsAccessor as _, type CdlInput as a, createScrollProgressSignals as a0, hasInteractivePrimitives as a1, sequenceBoardMetrics as a2, sequenceStepId as a3, signal as a4, type CdlLane as b, type CdlNode as c, type Side as d, type EdgeRole as e, type EdgeHead as f, type EdgeHeadFill as g, type CdlState as h, type CdlEventTarget as i, type Computed as j, type CdlDerivedValue as k, type CdlScrollTrigger as l, type CdlDiagramViewProps as m, type LaidEdge as n, type LaidNode as o, type CdlEdge as p, CdlDiagramView as q, type CdlEventBinding as r, type CdlEventKind as s, type CdlFormula as t, type CdlPhase as u, type ChartPieForm as v, type ChartSlopeForm as w, EDGE_HEADS as x, EDGE_HEAD_DEFAULT as y, EDGE_HEAD_FILLS as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cardenelabs/cdl",
3
- "version": "0.35.0",
3
+ "version": "0.36.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",
package/src/index.ts CHANGED
@@ -284,6 +284,7 @@ export type {
284
284
  CdlDiagram,
285
285
  CdlEdge,
286
286
  ChartPieForm,
287
+ ChartSlopeForm,
287
288
  CdlLane,
288
289
  CdlNode,
289
290
  CdlPhase,
@@ -1,5 +1,5 @@
1
1
  import { type JSX } from "react";
2
- import type { LaidNode, Tone } from "../types";
2
+ import type { ChartSlopeForm, LaidNode, Tone } from "../types";
3
3
  import { TONE, chartSeriesColor } from "../render/tone";
4
4
  import { resolveChartData } from "../render/payload-binding";
5
5
  import { textWidth } from "./text-width";
@@ -112,8 +112,32 @@ export function ChartSlopeNode({
112
112
  const yを取る = (v: number): number =>
113
113
  尺の幅 > 0 ? 下端 - ((v - 最小) / 尺の幅) * (下端 - 上端) : (上端 + 下端) / 2;
114
114
 
115
+ /**
116
+ * 見せ方 (cdl#702)。 **型の外の値は `values` に落とす** = 見せ方が決まらないより、
117
+ * 既定の形が出る方がよい (円グラフと同じ判断)。
118
+ *
119
+ * **前の時点を持たない図では `values` に落とす**。 引く相手がいないので、増減を出すと
120
+ * 「0 から増えた」 という書いていない主張になる (前を持たない件を 0 から立ち上げるのは
121
+ * 線を引くための扱いで、前が 0 だったという意味ではない)。
122
+ */
123
+ const 形: ChartSlopeForm = 前あり && node.chartSlopeForm === "delta" ? "delta" : "values";
124
+
125
+ /**
126
+ * 増減の表記。 符号を前に付ける。
127
+ *
128
+ * `0` は `+0` にしない = 動いていないことを「増えた」 と読ませない。
129
+ * 負は `実値表記` が `-` を付けるのでそのまま。
130
+ */
131
+ const 増減表記 = (前: number, 今: number): string => {
132
+ const 差 = 今 - 前;
133
+ return 差 > 0 ? `+${実値表記(差)}` : 実値表記(差);
134
+ };
135
+
115
136
  const 左の字 = 系列たち.map((s) => 実値表記(s.前));
116
- const 右の字 = 系列たち.map((s) => 実値表記(s.今));
137
+ // `delta` は今の値の代わりに増減を出す。 3 つ目の数を足さないので列は 2 つのまま
138
+ const 右の字 = 系列たち.map((s) =>
139
+ 形 === "delta" ? 増減表記(s.前, s.今) : 実値表記(s.今),
140
+ );
117
141
  const 左値幅 = Math.max(0, ...左の字.map((t) => textWidth(t, 値の級)));
118
142
  const 右値幅 = Math.max(0, ...右の字.map((t) => textWidth(t, 値の級)));
119
143
 
@@ -288,7 +312,9 @@ export function ChartSlopeNode({
288
312
  {右を出す && (
289
313
  <>
290
314
  <text
291
- data-cdl-role="chart-slope-value"
315
+ // 増減は今の値と意味が違うので役割を分ける (cdl#702)。
316
+ // 消費側が増減だけに色を当てたくなる経路がある
317
+ data-cdl-role={形 === "delta" ? "chart-slope-delta" : "chart-slope-value"}
292
318
  x={右軸x + 軸から値まで}
293
319
  y={右y + 5}
294
320
  fontSize={値の級}
@@ -58,6 +58,8 @@ type 読まない欄 =
58
58
  | "chartTrace"
59
59
  // 円グラフの見せ方 (#684)。 決まった値のどれかで、字を差し込む先が無い
60
60
  | "chartPieForm"
61
+ // 傾き図の見せ方 (#702)。 同上
62
+ | "chartSlopeForm"
61
63
  | "ganttData"
62
64
  | "ganttAxisMax"
63
65
  | "mindData"
package/src/types.ts CHANGED
@@ -482,6 +482,21 @@ export type CdlNode = {
482
482
  * `previous` (cdl#680) が効くのは `ring` だけ。 他の形は内側の輪を描かない。
483
483
  */
484
484
  chartPieForm?: ChartPieForm;
485
+ /**
486
+ * chart-slope の見せ方 (cdl#702)。 右の列に何の数を出すかを決める。
487
+ *
488
+ * - `values` ... 今の値
489
+ * - `delta` ... 増減 (`+40` / `-90`)
490
+ *
491
+ * 左の列は どちらでも前の値。 `前 + 増減 = 今` なので、 `delta` でも今の値は足せば戻る。
492
+ * 3 つ目の数を足さないので、 名札の高さも線を引く幅も変わらない。
493
+ *
494
+ * 型の外の値は `values` として描く = 見せ方が決まらないより、既定の形が出る方がよい。
495
+ *
496
+ * 前の時点を持たない図 (`previous` が 1 件も無い) は右の列そのものが無いため、
497
+ * この欄を書いても絵は変わらない。
498
+ */
499
+ chartSlopeForm?: ChartSlopeForm;
485
500
  /**
486
501
  * gantt-timeline 専用の task payload。 task 全件を 1 node に格納し、
487
502
  * kinds/gantt.tsx が縦軸 task lane + 横軸日付 rect bar で SVG 描画する。
@@ -541,6 +556,9 @@ export type BoundEnum<T extends string> = T | (string & {});
541
556
  /** chart-pie の見せ方 (cdl#684)。 SSOT は `kinds/chart-pie.tsx` */
542
557
  export type ChartPieForm = "ring" | "arcs" | "table";
543
558
 
559
+ /** chart-slope の見せ方 (cdl#702)。 SSOT は `kinds/chart-slope.tsx` */
560
+ export type ChartSlopeForm = "values" | "delta";
561
+
544
562
  export type ChartDatumPayload = {
545
563
  label: string;
546
564
  /** 棒 / 折れ線 / 扇の大きさ。 `{signal}` で状態に追随する */