@cardenelabs/cdl 0.51.0 → 0.52.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-BoBEyCu-.cjs';
2
- export { q as CdlDiagramView, r as CdlEventBinding, s as CdlEventKind, t as CdlFormula, u as CdlPhase, v as ChartPieForm, w as ChartSlopeForm, x as EDGE_HEADS, y as EDGE_HEAD_DEFAULT, z as EDGE_HEAD_FILLS, A as EDGE_HEAD_FILL_DEFAULT, D as EDGE_REVEALS, F as EDGE_REVEAL_DEFAULT, G as EDGE_STYLES, H as EdgeReveal, I as InteractiveHandlerMap, K as InteractiveSignalsAccessor, M as LaidLane, O as NODE_KINDS, P as RELATION_FOCUSES, U as RELATION_FOCUS_DEFAULT, V as RelationFocus, W as ScrollProgressHandle, X as TONES, Y as computeEventBindingKey, Z as computeFormulaKey, _ as computeInputSignalKey, $ as computeScrollTriggerKey, a0 as computed, a1 as createInteractiveSignalsAccessor, a2 as createScrollProgressHandle, a3 as createScrollProgressSignals, a4 as hasInteractivePrimitives, a5 as sequenceBoardMetrics, a6 as sequenceStepId, a7 as signal } from './render-BoBEyCu-.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-C0PJ2weJ.cjs';
2
+ export { q as CdlDiagramView, r as CdlEventBinding, s as CdlEventKind, t as CdlFormula, u as CdlPhase, v as ChartPieForm, w as ChartSlopeForm, x as EDGE_HEADS, y as EDGE_HEAD_DEFAULT, z as EDGE_HEAD_FILLS, A as EDGE_HEAD_FILL_DEFAULT, D as EDGE_REVEALS, F as EDGE_REVEAL_DEFAULT, G as EDGE_STYLES, H as EdgeReveal, I as InteractiveHandlerMap, K as InteractiveSignalsAccessor, M as LaidLane, O as NODE_KINDS, P as RELATION_FOCUSES, U as RELATION_FOCUS_DEFAULT, V as RelationFocus, W as ScrollProgressHandle, X as TONES, Y as computeEventBindingKey, Z as computeFormulaKey, _ as computeInputSignalKey, $ as computeScrollTriggerKey, a0 as computed, a1 as createInteractiveSignalsAccessor, a2 as createScrollProgressHandle, a3 as createScrollProgressSignals, a4 as hasInteractivePrimitives, a5 as sequenceBoardMetrics, a6 as sequenceStepId, a7 as signal } from './render-C0PJ2weJ.cjs';
3
3
  import { JSX } from 'react';
4
4
 
5
5
  declare function effect(fn: () => void | (() => void)): () => void;
@@ -1048,6 +1048,8 @@ type DiagramBuilder = {
1048
1048
  cardinality?: string;
1049
1049
  /** 行き先の端に添える字 (#821)。 クラス図の多重度に使う */
1050
1050
  headLabel?: string;
1051
+ /** 出どころの端に添える字 (#825)。 クラス図の出どころ側の多重度に使う */
1052
+ tailLabel?: string;
1051
1053
  labelOffsetX?: number;
1052
1054
  labelOffsetY?: number;
1053
1055
  routing?: "default" | "back-detour";
@@ -1140,6 +1142,8 @@ type DiagramBuilder = {
1140
1142
  cardinality?: string;
1141
1143
  /** 行き先の端に添える字 (#821)。 クラス図の多重度に使う */
1142
1144
  headLabel?: string;
1145
+ /** 出どころの端に添える字 (#825)。 クラス図の出どころ側の多重度に使う */
1146
+ tailLabel?: string;
1143
1147
  labelOffsetX?: number;
1144
1148
  labelOffsetY?: number;
1145
1149
  routing?: "default" | "back-detour";
@@ -3412,6 +3416,8 @@ type UmlRelation = {
3412
3416
  label?: string;
3413
3417
  /** 多重度 (例 "1..*" / "0..1")。 行き先 (`to`) の端に添える (#821) */
3414
3418
  cardinality?: string;
3419
+ /** 出どころ (`from`) 側の多重度 (例 "1")。 出どころの端に添える (#825) */
3420
+ tailCardinality?: string;
3415
3421
  tone?: Tone;
3416
3422
  /**
3417
3423
  * 矢印の先の形 (cdl#574)。 書かなければ種類から決まる (`CLASS_RELATION_LOOK`)。
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-BoBEyCu-.js';
2
- export { q as CdlDiagramView, r as CdlEventBinding, s as CdlEventKind, t as CdlFormula, u as CdlPhase, v as ChartPieForm, w as ChartSlopeForm, x as EDGE_HEADS, y as EDGE_HEAD_DEFAULT, z as EDGE_HEAD_FILLS, A as EDGE_HEAD_FILL_DEFAULT, D as EDGE_REVEALS, F as EDGE_REVEAL_DEFAULT, G as EDGE_STYLES, H as EdgeReveal, I as InteractiveHandlerMap, K as InteractiveSignalsAccessor, M as LaidLane, O as NODE_KINDS, P as RELATION_FOCUSES, U as RELATION_FOCUS_DEFAULT, V as RelationFocus, W as ScrollProgressHandle, X as TONES, Y as computeEventBindingKey, Z as computeFormulaKey, _ as computeInputSignalKey, $ as computeScrollTriggerKey, a0 as computed, a1 as createInteractiveSignalsAccessor, a2 as createScrollProgressHandle, a3 as createScrollProgressSignals, a4 as hasInteractivePrimitives, a5 as sequenceBoardMetrics, a6 as sequenceStepId, a7 as signal } from './render-BoBEyCu-.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-C0PJ2weJ.js';
2
+ export { q as CdlDiagramView, r as CdlEventBinding, s as CdlEventKind, t as CdlFormula, u as CdlPhase, v as ChartPieForm, w as ChartSlopeForm, x as EDGE_HEADS, y as EDGE_HEAD_DEFAULT, z as EDGE_HEAD_FILLS, A as EDGE_HEAD_FILL_DEFAULT, D as EDGE_REVEALS, F as EDGE_REVEAL_DEFAULT, G as EDGE_STYLES, H as EdgeReveal, I as InteractiveHandlerMap, K as InteractiveSignalsAccessor, M as LaidLane, O as NODE_KINDS, P as RELATION_FOCUSES, U as RELATION_FOCUS_DEFAULT, V as RelationFocus, W as ScrollProgressHandle, X as TONES, Y as computeEventBindingKey, Z as computeFormulaKey, _ as computeInputSignalKey, $ as computeScrollTriggerKey, a0 as computed, a1 as createInteractiveSignalsAccessor, a2 as createScrollProgressHandle, a3 as createScrollProgressSignals, a4 as hasInteractivePrimitives, a5 as sequenceBoardMetrics, a6 as sequenceStepId, a7 as signal } from './render-C0PJ2weJ.js';
3
3
  import { JSX } from 'react';
4
4
 
5
5
  declare function effect(fn: () => void | (() => void)): () => void;
@@ -1048,6 +1048,8 @@ type DiagramBuilder = {
1048
1048
  cardinality?: string;
1049
1049
  /** 行き先の端に添える字 (#821)。 クラス図の多重度に使う */
1050
1050
  headLabel?: string;
1051
+ /** 出どころの端に添える字 (#825)。 クラス図の出どころ側の多重度に使う */
1052
+ tailLabel?: string;
1051
1053
  labelOffsetX?: number;
1052
1054
  labelOffsetY?: number;
1053
1055
  routing?: "default" | "back-detour";
@@ -1140,6 +1142,8 @@ type DiagramBuilder = {
1140
1142
  cardinality?: string;
1141
1143
  /** 行き先の端に添える字 (#821)。 クラス図の多重度に使う */
1142
1144
  headLabel?: string;
1145
+ /** 出どころの端に添える字 (#825)。 クラス図の出どころ側の多重度に使う */
1146
+ tailLabel?: string;
1143
1147
  labelOffsetX?: number;
1144
1148
  labelOffsetY?: number;
1145
1149
  routing?: "default" | "back-detour";
@@ -3412,6 +3416,8 @@ type UmlRelation = {
3412
3416
  label?: string;
3413
3417
  /** 多重度 (例 "1..*" / "0..1")。 行き先 (`to`) の端に添える (#821) */
3414
3418
  cardinality?: string;
3419
+ /** 出どころ (`from`) 側の多重度 (例 "1")。 出どころの端に添える (#825) */
3420
+ tailCardinality?: string;
3415
3421
  tone?: Tone;
3416
3422
  /**
3417
3423
  * 矢印の先の形 (cdl#574)。 書かなければ種類から決まる (`CLASS_RELATION_LOOK`)。
package/dist/index.js CHANGED
@@ -9500,6 +9500,7 @@ function diagram(id, options) {
9500
9500
  guard: opts.guard,
9501
9501
  cardinality: opts.cardinality,
9502
9502
  headLabel: opts.headLabel,
9503
+ tailLabel: opts.tailLabel,
9503
9504
  labelOffsetX: opts.labelOffsetX,
9504
9505
  labelOffsetY: opts.labelOffsetY,
9505
9506
  routing: opts.routing,
@@ -9627,6 +9628,7 @@ function diagram(id, options) {
9627
9628
  guard: d.guard,
9628
9629
  cardinality: d.cardinality,
9629
9630
  headLabel: d.headLabel,
9631
+ tailLabel: d.tailLabel,
9630
9632
  labelOffsetX: d.labelOffsetX,
9631
9633
  labelOffsetY: d.labelOffsetY,
9632
9634
  routing: d.routing,
@@ -22938,28 +22940,34 @@ var \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 = 8;
22938
22940
  var \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 = EDGE_LABEL_TEXT.sub.fontSize;
22939
22941
  var \u7BB1\u306E\u9AD8\u30552 = Math.round(\u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * 1.2);
22940
22942
  var BASELINE_RATIO = 0.8;
22941
- function \u6700\u5F8C\u306E\u5411\u304D(d) {
22942
- const segs = extractPathSegments(d);
22943
- const last = segs[segs.length - 1];
22944
- if (!last) return null;
22945
- const end = { x: last.x2, y: last.y2 };
22946
- for (let i = segs.length - 1; i >= 0; i--) {
22947
- const s = segs[i];
22948
- const \u5236\u5FA1\u70B9 = s.cmd === "Q" ? s.ctrl?.[0] : s.cmd === "C" ? s.ctrl?.[1] : void 0;
22949
- for (const p of [\u5236\u5FA1\u70B9, { x: s.x1, y: s.y1 }]) {
22950
- if (!p) continue;
22951
- const dx = end.x - p.x;
22952
- const dy = end.y - p.y;
22953
- const len = Math.hypot(dx, dy);
22954
- if (len > 1e-6) return { end, ux: dx / len, uy: dy / len };
22955
- }
22943
+ function \u5411\u304D\u3092\u53D6\u308B(end, \u5019\u88DC) {
22944
+ for (const p of \u5019\u88DC) {
22945
+ if (!p) continue;
22946
+ const dx = end.x - p.x;
22947
+ const dy = end.y - p.y;
22948
+ const len = Math.hypot(dx, dy);
22949
+ if (len > 1e-6) return { end, ux: dx / len, uy: dy / len };
22956
22950
  }
22957
22951
  return null;
22958
22952
  }
22959
- function \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge) {
22960
- const text = edge.headLabel?.trim();
22953
+ function \u7AEF\u3067\u306E\u5411\u304D(d, \u7AEF) {
22954
+ const segs = extractPathSegments(d);
22955
+ if (segs.length === 0) return null;
22956
+ if (\u7AEF === "head") {
22957
+ const last = segs[segs.length - 1];
22958
+ const end2 = { x: last.x2, y: last.y2 };
22959
+ const \u5019\u88DC2 = segs.slice().reverse().flatMap((s) => [s.cmd === "Q" ? s.ctrl?.[0] : s.cmd === "C" ? s.ctrl?.[1] : void 0, { x: s.x1, y: s.y1 }]);
22960
+ return \u5411\u304D\u3092\u53D6\u308B(end2, \u5019\u88DC2);
22961
+ }
22962
+ const first = segs[0];
22963
+ const end = { x: first.x1, y: first.y1 };
22964
+ const \u5019\u88DC = segs.flatMap((s) => [...s.ctrl ?? [], { x: s.x2, y: s.y2 }]);
22965
+ return \u5411\u304D\u3092\u53D6\u308B(end, \u5019\u88DC);
22966
+ }
22967
+ function \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge, \u7AEF = "head") {
22968
+ const text = (\u7AEF === "head" ? edge.headLabel : edge.tailLabel)?.trim();
22961
22969
  if (!text) return null;
22962
- const \u5411\u304D = \u6700\u5F8C\u306E\u5411\u304D(edge.d);
22970
+ const \u5411\u304D = \u7AEF\u3067\u306E\u5411\u304D(edge.d, \u7AEF);
22963
22971
  if (!\u5411\u304D) return null;
22964
22972
  const { end, ux, uy } = \u5411\u304D;
22965
22973
  const bx = end.x - ux * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
@@ -23260,11 +23268,12 @@ function CdlEdgeLabelView({
23260
23268
  }
23261
23269
  );
23262
23270
  }
23263
- function CdlEdgeHeadLabelView({
23271
+ function CdlEdgeEndLabelView({
23264
23272
  edge,
23265
- active
23273
+ active,
23274
+ \u7AEF
23266
23275
  }) {
23267
- const \u7F6E\u304D\u5834\u6240 = \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge);
23276
+ const \u7F6E\u304D\u5834\u6240 = \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge, \u7AEF);
23268
23277
  if (!\u7F6E\u304D\u5834\u6240) return null;
23269
23278
  const color = edgeColor(edge);
23270
23279
  return /* @__PURE__ */ jsx(
@@ -23272,6 +23281,7 @@ function CdlEdgeHeadLabelView({
23272
23281
  {
23273
23282
  "data-cdl-role": "edge-end-label",
23274
23283
  "data-cdl-edge-end-label-for": edge.id,
23284
+ "data-cdl-edge-end": \u7AEF,
23275
23285
  x: \u7F6E\u304D\u5834\u6240.x,
23276
23286
  y: \u7F6E\u304D\u5834\u6240.y,
23277
23287
  fontSize: \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055,
@@ -23283,7 +23293,7 @@ function CdlEdgeHeadLabelView({
23283
23293
  strokeLinejoin: "round",
23284
23294
  paintOrder: "stroke",
23285
23295
  style: { fontFamily: fontFamilyAttr("sub") },
23286
- children: \u7B49\u5E45\u306E\u5B57(edge.headLabel, \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055)
23296
+ children: \u7B49\u5E45\u306E\u5B57(\u7AEF === "head" ? edge.headLabel : edge.tailLabel, \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055)
23287
23297
  }
23288
23298
  );
23289
23299
  }
@@ -31571,14 +31581,17 @@ function CdlStage({
31571
31581
  },
31572
31582
  `label-${edge.id}`
31573
31583
  )),
31574
- laid.edges.filter((edge) => edge.headLabel && \u77E2\u5370\u306E\u51FA\u756A.\u51FA\u308B\u304B(edge.id)).map((edge) => /* @__PURE__ */ jsx(
31575
- CdlEdgeHeadLabelView,
31576
- {
31577
- edge,
31578
- active: activeSet.has(edge.id)
31579
- },
31580
- `head-label-${edge.id}`
31581
- )),
31584
+ laid.edges.filter((edge) => (edge.headLabel || edge.tailLabel) && \u77E2\u5370\u306E\u51FA\u756A.\u51FA\u308B\u304B(edge.id)).flatMap(
31585
+ (edge) => ["head", "tail"].map((\u7AEF) => /* @__PURE__ */ jsx(
31586
+ CdlEdgeEndLabelView,
31587
+ {
31588
+ edge,
31589
+ active: activeSet.has(edge.id),
31590
+ \u7AEF
31591
+ },
31592
+ `${\u7AEF}-label-${edge.id}`
31593
+ ))
31594
+ ),
31582
31595
  debug && /* @__PURE__ */ jsxs("g", { pointerEvents: "none", children: [
31583
31596
  laid.bboxes.map((bbox, idx) => {
31584
31597
  const color = bbox.kind === "node" ? "#3b82f6" : bbox.kind === "lane-label" ? "#a855f7" : bbox.kind === "edge-label" ? "#10b981" : "#f59e0b";
@@ -32626,6 +32639,7 @@ function classDiagram(preset) {
32626
32639
  // 多重度は行き先の端に添える (#821)。 札の下の行に入れると語と続けて読まれ
32627
32640
  // (英字の頃は「HAS 1..*」 が「HAS1」)、 どちらの端の数かも読めない
32628
32641
  ...r.cardinality ? { headLabel: r.cardinality } : {},
32642
+ ...r.tailCardinality ? { tailLabel: r.tailCardinality } : {},
32629
32643
  tone: r.tone ?? \u56F3\u306E\u65E2\u5B9A ?? CLASS_RELATION_TONE[r.type],
32630
32644
  // 関係の種類から線と端の形を決める (cdl#574 / #578)。 書いた値が勝つ
32631
32645
  style: r.style ?? \u898B\u305F\u76EE.style,