@cardenelabs/cdl 0.30.3 → 0.31.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/react.js CHANGED
@@ -9885,8 +9885,300 @@ function StateDiffCard({
9885
9885
  }
9886
9886
  );
9887
9887
  }
9888
+ var \u6570\u3092\u66F8\u304F = (value) => value.toLocaleString("en-US", { maximumFractionDigits: 12 });
9889
+ function \u6298\u308C\u7DDA\u306E\u76EE\u76DB(values) {
9890
+ let rawMin = values.length > 0 ? Math.min(...values) : 0;
9891
+ let rawMax = values.length > 0 ? Math.max(...values) : 1;
9892
+ if (rawMin === rawMax) {
9893
+ const room = 10 ** Math.floor(Math.log10(Math.abs(rawMin) || 1) - 1);
9894
+ rawMin -= room;
9895
+ rawMax += room;
9896
+ }
9897
+ const roughStep = (rawMax - rawMin) / 4;
9898
+ const power = 10 ** Math.floor(Math.log10(roughStep));
9899
+ const fraction = roughStep / power;
9900
+ const niceFraction = fraction <= 1 ? 1 : fraction <= 2 ? 2 : fraction <= 2.5 ? 2.5 : fraction <= 5 ? 5 : 10;
9901
+ const step = niceFraction * power;
9902
+ const min = Math.floor(rawMin / step) * step;
9903
+ const max = Math.ceil(rawMax / step) * step;
9904
+ const tickCount = Math.round((max - min) / step);
9905
+ const ticks = Array.from({ length: tickCount + 1 }, (_, i) => {
9906
+ const value = min + step * i;
9907
+ return Math.abs(value) < step * 1e-12 ? 0 : value;
9908
+ });
9909
+ return { min, max, ticks };
9910
+ }
9911
+ function ChartLineNode({
9912
+ node,
9913
+ active,
9914
+ stateValues = {},
9915
+ scale: fixedScale,
9916
+ drawing = false,
9917
+ progress = 1
9918
+ }) {
9919
+ const x0 = node.cx - node.w / 2;
9920
+ const y0 = node.cy - node.h / 2;
9921
+ const data = resolveChartData(node.chartData ?? [], stateValues);
9922
+ const PAD_TOP2 = 36;
9923
+ const PAD_RIGHT2 = 40;
9924
+ const PAD_BOTTOM2 = 56;
9925
+ const PAD_LEFT2 = 72;
9926
+ const canvasW = node.w - PAD_LEFT2 - PAD_RIGHT2;
9927
+ const canvasH = node.h - PAD_TOP2 - PAD_BOTTOM2;
9928
+ const scale = fixedScale ?? \u6298\u308C\u7DDA\u306E\u76EE\u76DB(data.map((d) => d.value));
9929
+ const vRange = scale.max - scale.min;
9930
+ const LABEL_ROOM = 20;
9931
+ const plotTop = PAD_TOP2 + LABEL_ROOM;
9932
+ const plotH = Math.max(canvasH - LABEL_ROOM * 2, 1);
9933
+ const POINT_EDGE_ROOM = 24;
9934
+ const plotW = Math.max(canvasW - POINT_EDGE_ROOM * 2, 1);
9935
+ const xAt = (idx) => PAD_LEFT2 + POINT_EDGE_ROOM + (data.length <= 1 ? plotW / 2 : plotW * idx / (data.length - 1));
9936
+ const yAt = (v) => plotTop + plotH - (v - scale.min) / vRange * plotH;
9937
+ const plotBottom = PAD_TOP2 + canvasH;
9938
+ let \u7DDA\u306E\u5168\u9577 = 0;
9939
+ let \u524D\u306E\u70B9;
9940
+ const \u63CF\u753B\u70B9 = data.map((datum, idx) => {
9941
+ const \u4ECA\u306E\u70B9 = { datum, x: xAt(idx), y: yAt(datum.value), \u3053\u3053\u307E\u3067\u306E\u9577\u3055: 0 };
9942
+ if (\u524D\u306E\u70B9) {
9943
+ \u7DDA\u306E\u5168\u9577 += Math.hypot(\u4ECA\u306E\u70B9.x - \u524D\u306E\u70B9.x, \u4ECA\u306E\u70B9.y - \u524D\u306E\u70B9.y);
9944
+ }
9945
+ \u4ECA\u306E\u70B9.\u3053\u3053\u307E\u3067\u306E\u9577\u3055 = \u7DDA\u306E\u5168\u9577;
9946
+ \u524D\u306E\u70B9 = \u4ECA\u306E\u70B9;
9947
+ return \u4ECA\u306E\u70B9;
9948
+ });
9949
+ const points = \u63CF\u753B\u70B9.map((\u70B9) => `${\u70B9.x},${\u70B9.y}`).join(" ");
9950
+ const \u6BB5\u306E\u9032\u307F = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
9951
+ const \u7C92\u3092\u8D70\u3089\u305B\u308B = drawing && node.chartTrace === true;
9952
+ const \u4F38\u3073 = \u7C92\u3092\u8D70\u3089\u305B\u308B ? Math.min(1, \u6BB5\u306E\u9032\u307F / 0.5) : \u6BB5\u306E\u9032\u307F;
9953
+ const \u7C92\u306E\u9032\u307F = \u7C92\u3092\u8D70\u3089\u305B\u308B ? Math.min(1, Math.max(0, (\u6BB5\u306E\u9032\u307F - 0.55) / 0.45)) : \u4F38\u3073;
9954
+ const \u7C92\u304C\u51FA\u308B = \u7C92\u3092\u8D70\u3089\u305B\u308B && \u6BB5\u306E\u9032\u307F >= 0.55 && \u6BB5\u306E\u9032\u307F < 1;
9955
+ const \u5230\u7740\u7A93 = 0.12;
9956
+ let \u7C92\u306E\u4F4D\u7F6E;
9957
+ const \u6700\u521D\u306E\u70B9 = \u63CF\u753B\u70B9[0];
9958
+ if (\u7C92\u304C\u51FA\u308B && \u6700\u521D\u306E\u70B9) {
9959
+ const \u7C92\u307E\u3067\u306E\u9577\u3055 = \u7C92\u306E\u9032\u307F * \u7DDA\u306E\u5168\u9577;
9960
+ let \u533A\u9593\u306E\u524D = \u6700\u521D\u306E\u70B9;
9961
+ let \u533A\u9593\u306E\u5F8C = \u6700\u521D\u306E\u70B9;
9962
+ for (const \u70B9 of \u63CF\u753B\u70B9.slice(1)) {
9963
+ \u533A\u9593\u306E\u5F8C = \u70B9;
9964
+ if (\u70B9.\u3053\u3053\u307E\u3067\u306E\u9577\u3055 >= \u7C92\u307E\u3067\u306E\u9577\u3055) break;
9965
+ \u533A\u9593\u306E\u524D = \u70B9;
9966
+ }
9967
+ const \u533A\u9593\u306E\u59CB\u3081 = \u533A\u9593\u306E\u524D.\u3053\u3053\u307E\u3067\u306E\u9577\u3055;
9968
+ const \u533A\u9593\u306E\u9577\u3055 = \u533A\u9593\u306E\u5F8C.\u3053\u3053\u307E\u3067\u306E\u9577\u3055 - \u533A\u9593\u306E\u59CB\u3081;
9969
+ const \u533A\u9593\u306E\u9032\u307F = \u533A\u9593\u306E\u9577\u3055 === 0 ? 0 : (\u7C92\u307E\u3067\u306E\u9577\u3055 - \u533A\u9593\u306E\u59CB\u3081) / \u533A\u9593\u306E\u9577\u3055;
9970
+ \u7C92\u306E\u4F4D\u7F6E = {
9971
+ x: \u533A\u9593\u306E\u524D.x + (\u533A\u9593\u306E\u5F8C.x - \u533A\u9593\u306E\u524D.x) * \u533A\u9593\u306E\u9032\u307F,
9972
+ y: \u533A\u9593\u306E\u524D.y + (\u533A\u9593\u306E\u5F8C.y - \u533A\u9593\u306E\u524D.y) * \u533A\u9593\u306E\u9032\u307F
9973
+ };
9974
+ }
9975
+ const gridTicks = scale.ticks.map((value) => ({ y: yAt(value), value }));
9976
+ return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
9977
+ gridTicks.map((t, i) => /* @__PURE__ */ jsxs("g", { children: [
9978
+ /* @__PURE__ */ jsx(
9979
+ "line",
9980
+ {
9981
+ x1: PAD_LEFT2,
9982
+ y1: t.y,
9983
+ x2: PAD_LEFT2 + canvasW,
9984
+ y2: t.y,
9985
+ stroke: "var(--cdl-divider, #d4d4d8)",
9986
+ strokeWidth: 0.75,
9987
+ strokeDasharray: "3 3",
9988
+ opacity: 0.65
9989
+ }
9990
+ ),
9991
+ /* @__PURE__ */ jsx(
9992
+ "text",
9993
+ {
9994
+ x: PAD_LEFT2 - 8,
9995
+ y: t.y + 4,
9996
+ fontSize: 11,
9997
+ textAnchor: "end",
9998
+ fill: "var(--cdl-text-dim, #5a6270)",
9999
+ children: \u6570\u3092\u66F8\u304F(t.value)
10000
+ }
10001
+ )
10002
+ ] }, `grid-${i}`)),
10003
+ node.chartFillUnder && data.length > 1 && /* @__PURE__ */ jsxs(Fragment, { children: [
10004
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs(
10005
+ "linearGradient",
10006
+ {
10007
+ id: `chart-line-fill-${node.id}`,
10008
+ gradientUnits: "userSpaceOnUse",
10009
+ x1: 0,
10010
+ y1: plotTop,
10011
+ x2: 0,
10012
+ y2: plotBottom,
10013
+ children: [
10014
+ /* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: "var(--cdl-tone-accent, #2d6a8f)", stopOpacity: 0.22 }),
10015
+ /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: "var(--cdl-tone-accent, #2d6a8f)", stopOpacity: 0 })
10016
+ ]
10017
+ }
10018
+ ) }),
10019
+ /* @__PURE__ */ jsx(
10020
+ "path",
10021
+ {
10022
+ "data-cdl-role": "chart-line-fill-under",
10023
+ d: `M ${xAt(0)} ${plotBottom} L ${points.replaceAll(",", " ")} L ${xAt(data.length - 1)} ${plotBottom} Z`,
10024
+ fill: `url(#chart-line-fill-${node.id})`,
10025
+ stroke: "none"
10026
+ }
10027
+ )
10028
+ ] }),
10029
+ data.length > 1 && /* @__PURE__ */ jsx(
10030
+ "polyline",
10031
+ {
10032
+ "data-cdl-role": "chart-line",
10033
+ points,
10034
+ fill: "none",
10035
+ stroke: "var(--cdl-tone-accent, #2d6a8f)",
10036
+ strokeWidth: active ? 3 : 2,
10037
+ strokeLinejoin: "round",
10038
+ strokeLinecap: "round",
10039
+ ...\u4F38\u3070\u3059dash(drawing, \u4F38\u3073)
10040
+ }
10041
+ ),
10042
+ \u7C92\u306E\u4F4D\u7F6E && /* @__PURE__ */ jsx(
10043
+ "circle",
10044
+ {
10045
+ "data-cdl-role": "chart-line-trace",
10046
+ cx: \u7C92\u306E\u4F4D\u7F6E.x,
10047
+ cy: \u7C92\u306E\u4F4D\u7F6E.y,
10048
+ r: 4.5,
10049
+ fill: "var(--cdl-now)"
10050
+ }
10051
+ ),
10052
+ \u63CF\u753B\u70B9.map(({ datum: d, x: cx, y: cy, \u3053\u3053\u307E\u3067\u306E\u9577\u3055 }, idx) => {
10053
+ const prev = data[idx - 1]?.value;
10054
+ const next = data[idx + 1]?.value;
10055
+ const isValley = (prev === void 0 || d.value <= prev) && (next === void 0 || d.value <= next);
10056
+ const labelAbove = !isValley;
10057
+ const labelY = labelAbove ? cy - 12 : cy + 18;
10058
+ const \u5230\u7740\u5F8C = \u7DDA\u306E\u5168\u9577 === 0 ? \u7C92\u306E\u9032\u307F : \u7C92\u306E\u9032\u307F - \u3053\u3053\u307E\u3067\u306E\u9577\u3055 / \u7DDA\u306E\u5168\u9577;
10059
+ const \u51FA\u3059 = !drawing || (!\u7C92\u3092\u8D70\u3089\u305B\u308B || \u6BB5\u306E\u9032\u307F >= 0.55) && \u5230\u7740\u5F8C >= 0;
10060
+ const \u5149\u308B = drawing && \u51FA\u3059 && \u5230\u7740\u5F8C < \u5230\u7740\u7A93;
10061
+ const \u5149\u306E\u9032\u307F = \u5149\u308B ? \u5230\u7740\u5F8C / \u5230\u7740\u7A93 : 1;
10062
+ let \u70B9\u3068\u5024;
10063
+ if (\u51FA\u3059) {
10064
+ const \u5149\u306E\u534A\u5F84 = 6 + 16 * \u5149\u306E\u9032\u307F;
10065
+ const \u5024 = /* @__PURE__ */ jsx(
10066
+ "text",
10067
+ {
10068
+ "data-cdl-role": "chart-line-value",
10069
+ x: cx,
10070
+ y: labelY,
10071
+ fontSize: 11,
10072
+ fontWeight: 600,
10073
+ textAnchor: "middle",
10074
+ fill: "var(--cdl-text, #1a1f2a)",
10075
+ children: \u6570\u3092\u66F8\u304F(d.value)
10076
+ }
10077
+ );
10078
+ \u70B9\u3068\u5024 = /* @__PURE__ */ jsxs(Fragment, { children: [
10079
+ \u5149\u308B && // marker の `circle` を数える利用側へ混ぜず、専用 role の等径 ellipse として輪を出す。
10080
+ /* @__PURE__ */ jsx(
10081
+ "ellipse",
10082
+ {
10083
+ "data-cdl-role": "chart-line-arrival-ring",
10084
+ cx,
10085
+ cy,
10086
+ rx: \u5149\u306E\u534A\u5F84,
10087
+ ry: \u5149\u306E\u534A\u5F84,
10088
+ fill: "none",
10089
+ stroke: "var(--cdl-now)",
10090
+ strokeWidth: 2,
10091
+ opacity: 0.85 * (1 - \u5149\u306E\u9032\u307F)
10092
+ }
10093
+ ),
10094
+ /* @__PURE__ */ jsx(
10095
+ "circle",
10096
+ {
10097
+ cx,
10098
+ cy,
10099
+ r: 5,
10100
+ fill: "var(--cdl-node-fill, #ffffff)",
10101
+ stroke: \u5149\u308B ? "var(--cdl-now)" : "var(--cdl-tone-accent, #2d6a8f)",
10102
+ strokeWidth: 2.5
10103
+ }
10104
+ ),
10105
+ /* @__PURE__ */ jsx(
10106
+ "circle",
10107
+ {
10108
+ cx,
10109
+ cy,
10110
+ r: 2.5,
10111
+ fill: \u5149\u308B ? "var(--cdl-now)" : "var(--cdl-tone-accent, #2d6a8f)"
10112
+ }
10113
+ ),
10114
+ node.chartValueRise && \u5149\u308B ? /* @__PURE__ */ jsx(
10115
+ "g",
10116
+ {
10117
+ "data-cdl-role": "chart-line-value-rise",
10118
+ transform: `translate(0 ${8 * (1 - \u5149\u306E\u9032\u307F)})`,
10119
+ children: \u5024
10120
+ }
10121
+ ) : \u5024
10122
+ ] });
10123
+ }
10124
+ return /* @__PURE__ */ jsxs("g", { "data-cdl-unresolved": d.unresolved ? "true" : void 0, children: [
10125
+ \u70B9\u3068\u5024,
10126
+ /* @__PURE__ */ jsx(
10127
+ "text",
10128
+ {
10129
+ x: cx,
10130
+ y: PAD_TOP2 + canvasH + 20,
10131
+ fontSize: 12,
10132
+ textAnchor: "middle",
10133
+ fill: "var(--cdl-text-dim, #5a6270)",
10134
+ children: d.label
10135
+ }
10136
+ )
10137
+ ] }, `pt-${idx}`);
10138
+ })
10139
+ ] });
10140
+ }
10141
+
10142
+ // src/kinds/draw-ratio.ts
10143
+ var DRAW_RATIO_DEFAULT = 1;
10144
+ function \u63CF\u304F\u5272\u5408\u3092\u6B63\u3059(ratio) {
10145
+ if (ratio === void 0) return DRAW_RATIO_DEFAULT;
10146
+ if (!Number.isFinite(ratio)) return DRAW_RATIO_DEFAULT;
10147
+ if (ratio <= 0 || ratio > 1) return DRAW_RATIO_DEFAULT;
10148
+ return ratio;
10149
+ }
10150
+ function \u63CF\u304F\u9032\u307F\u306B\u76F4\u3059(progress, ratio) {
10151
+ const \u5272\u5408 = \u63CF\u304F\u5272\u5408\u3092\u6B63\u3059(ratio);
10152
+ if (\u5272\u5408 === DRAW_RATIO_DEFAULT) return progress;
10153
+ if (!Number.isFinite(progress)) return progress;
10154
+ return Math.min(1, progress / \u5272\u5408);
10155
+ }
10156
+
10157
+ // src/layout/lifeline.ts
10158
+ function lifelineStartYs(nodes) {
10159
+ const topmost = /* @__PURE__ */ new Map();
10160
+ for (const n of nodes) {
10161
+ const cur = topmost.get(n.lane);
10162
+ if (cur === void 0 || n.cy < cur.cy) topmost.set(n.lane, n);
10163
+ }
10164
+ const starts = /* @__PURE__ */ new Map();
10165
+ for (const [laneId, n] of topmost) starts.set(laneId, n.cy + n.h / 2);
10166
+ return starts;
10167
+ }
10168
+ function uniformLifelineEndY(lanes, nodes, starts = lifelineStartYs(nodes)) {
10169
+ const lifelineLanes = lanes.filter((l) => l.lifeline);
10170
+ let deepestStart = Number.NEGATIVE_INFINITY;
10171
+ for (const lane of lifelineLanes) {
10172
+ const start = starts.get(lane.id);
10173
+ if (start !== void 0) deepestStart = Math.max(deepestStart, start);
10174
+ }
10175
+ const footerTops = lifelineFooterNodes(lanes, nodes).map((f) => footerShapeDrawTop(f)).filter((top) => top > deepestStart);
10176
+ if (footerTops.length > 0) return Math.min(...footerTops);
10177
+ return lifelineLanes[0] ? lifelineLanes[0].y + lifelineLanes[0].height : 0;
10178
+ }
9888
10179
 
9889
10180
  // src/render/edge-head.ts
10181
+ var EDGE_HEAD_MUTED_MARKER_ID = "cdl-arrow-muted";
9890
10182
  var EDGE_HEAD_SHAPE = {
9891
10183
  // 何も描かない端。 marker 自体を出さないので `d` は読まれない
9892
10184
  none: { d: "", w: 10, h: 10, refX: 0, filled: false },
@@ -9917,6 +10209,11 @@ function edgeHeadMarkerId(tone, head, small, fill = EDGE_HEAD_FILL_DEFAULT) {
9917
10209
  const \u5857 = fill === EDGE_HEAD_FILL_DEFAULT || !EDGE_HEAD_SHAPE[head].filled ? "" : `-${fill}`;
9918
10210
  return head === EDGE_HEAD_DEFAULT && \u5857 === "" ? `cdl-arrow-${tone}${\u5C0F}` : `cdl-arrow-${tone}-${head}${\u5857}${\u5C0F}`;
9919
10211
  }
10212
+ function edgeHeadMarkerName(tone, head, small, fill) {
10213
+ const \u5B9F\u969B\u306E\u5F62 = head ?? EDGE_HEAD_DEFAULT;
10214
+ if (\u5B9F\u969B\u306E\u5F62 === "none") return void 0;
10215
+ return hasTone(tone) ? edgeHeadMarkerId(tone, \u5B9F\u969B\u306E\u5F62, small, fill ?? EDGE_HEAD_FILL_DEFAULT) : EDGE_HEAD_MUTED_MARKER_ID;
10216
+ }
9920
10217
  function edgeHeadPaint(head, fill, color) {
9921
10218
  const \u5F62 = EDGE_HEAD_SHAPE[head];
9922
10219
  if (!\u5F62.filled) return { fill: "none", stroke: color, strokeWidth: 1.6 };
@@ -9945,13 +10242,8 @@ function CdlEdgeView({
9945
10242
  stateValues
9946
10243
  }) {
9947
10244
  const color = edgeColor(edge);
9948
- const \u7AEF\u306E\u540D\u524D = (h, f) => {
9949
- const \u5F62 = h ?? EDGE_HEAD_DEFAULT;
9950
- if (\u5F62 === "none") return void 0;
9951
- return hasTone(edge.tone) ? edgeHeadMarkerId(edge.tone, \u5F62, !active, f ?? EDGE_HEAD_FILL_DEFAULT) : "cdl-arrow-muted";
9952
- };
9953
- const marker = \u7AEF\u306E\u540D\u524D(edge.head, edge.headFill);
9954
- const tailMarker = edge.tailHead === void 0 ? void 0 : \u7AEF\u306E\u540D\u524D(edge.tailHead, edge.tailHeadFill);
10245
+ const marker = edgeHeadMarkerName(edge.tone, edge.head, !active, edge.headFill);
10246
+ const tailMarker = edge.tailHead === void 0 ? void 0 : edgeHeadMarkerName(edge.tone, edge.tailHead, !active, edge.tailHeadFill);
9955
10247
  const style = edge.style ?? "solid";
9956
10248
  const isDotted = style === "dotted-flow";
9957
10249
  const isPassThrough = isDotted && Boolean(edge.dThrough);
@@ -11524,191 +11816,6 @@ function interpolateColor(template, stateValues, fallback) {
11524
11816
  if (!template) return fallback;
11525
11817
  return interpolate(template, stateValues);
11526
11818
  }
11527
- function ChartLineNode({
11528
- node,
11529
- active,
11530
- stateValues = {},
11531
- drawing = false,
11532
- progress = 1
11533
- }) {
11534
- const x0 = node.cx - node.w / 2;
11535
- const y0 = node.cy - node.h / 2;
11536
- const data = resolveChartData(node.chartData ?? [], stateValues);
11537
- const PAD_TOP2 = 36;
11538
- const PAD_RIGHT2 = 40;
11539
- const PAD_BOTTOM2 = 56;
11540
- const PAD_LEFT2 = 72;
11541
- const canvasW = node.w - PAD_LEFT2 - PAD_RIGHT2;
11542
- const canvasH = node.h - PAD_TOP2 - PAD_BOTTOM2;
11543
- const values = data.map((d) => d.value);
11544
- const vMin = values.length > 0 ? Math.min(...values) : 0;
11545
- const vMax = values.length > 0 ? Math.max(...values) : 1;
11546
- const vRange = vMax - vMin || 1;
11547
- const LABEL_ROOM = 20;
11548
- const plotTop = PAD_TOP2 + LABEL_ROOM;
11549
- const plotH = Math.max(canvasH - LABEL_ROOM * 2, 1);
11550
- const xAt = (idx) => PAD_LEFT2 + (data.length <= 1 ? canvasW / 2 : canvasW * idx / (data.length - 1));
11551
- const yAt = (v) => plotTop + plotH - (v - vMin) / vRange * plotH;
11552
- const points = data.map((d, idx) => `${xAt(idx)},${yAt(d.value)}`).join(" ");
11553
- const \u70B9\u307E\u3067\u306E\u9577\u3055 = [];
11554
- let \u7DDA\u306E\u5168\u9577 = 0;
11555
- let \u524D\u306E\u70B9;
11556
- for (const [idx, datum] of data.entries()) {
11557
- const \u4ECA\u306E\u70B9 = { x: xAt(idx), y: yAt(datum.value) };
11558
- if (\u524D\u306E\u70B9) {
11559
- \u7DDA\u306E\u5168\u9577 += Math.hypot(\u4ECA\u306E\u70B9.x - \u524D\u306E\u70B9.x, \u4ECA\u306E\u70B9.y - \u524D\u306E\u70B9.y);
11560
- }
11561
- \u70B9\u307E\u3067\u306E\u9577\u3055.push(\u7DDA\u306E\u5168\u9577);
11562
- \u524D\u306E\u70B9 = \u4ECA\u306E\u70B9;
11563
- }
11564
- const \u4F38\u3073 = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
11565
- const \u7DDA\u306E\u5148\u304C\u5C4A\u3044\u305F = (idx) => {
11566
- if (!drawing) return true;
11567
- if (data.length <= 1) return true;
11568
- if (\u7DDA\u306E\u5168\u9577 === 0) return true;
11569
- return \u4F38\u3073 >= (\u70B9\u307E\u3067\u306E\u9577\u3055[idx] ?? 0) / \u7DDA\u306E\u5168\u9577;
11570
- };
11571
- const gridCount = 4;
11572
- const gridTicks = Array.from({ length: gridCount + 1 }, (_, i) => {
11573
- const v = vMin + vRange * i / gridCount;
11574
- return { y: yAt(v), value: v };
11575
- });
11576
- return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
11577
- /* @__PURE__ */ jsx(
11578
- "rect",
11579
- {
11580
- "data-cdl-role": "node-body",
11581
- x: 0,
11582
- y: 0,
11583
- width: node.w,
11584
- height: node.h,
11585
- rx: 16,
11586
- fill: "var(--cdl-node-fill, #ffffff)",
11587
- stroke: active ? "var(--cdl-tone-accent, #2d6a8f)" : "var(--cdl-divider, #d4d4d8)",
11588
- strokeWidth: active ? 3 : 1.25
11589
- }
11590
- ),
11591
- gridTicks.map((t, i) => /* @__PURE__ */ jsxs("g", { children: [
11592
- /* @__PURE__ */ jsx(
11593
- "line",
11594
- {
11595
- x1: PAD_LEFT2,
11596
- y1: t.y,
11597
- x2: PAD_LEFT2 + canvasW,
11598
- y2: t.y,
11599
- stroke: "var(--cdl-divider, #d4d4d8)",
11600
- strokeWidth: 0.75,
11601
- strokeDasharray: "3 3",
11602
- opacity: 0.65
11603
- }
11604
- ),
11605
- /* @__PURE__ */ jsx(
11606
- "text",
11607
- {
11608
- x: PAD_LEFT2 - 8,
11609
- y: t.y + 4,
11610
- fontSize: 11,
11611
- textAnchor: "end",
11612
- fill: "var(--cdl-text-dim, #5a6270)",
11613
- children: Math.round(t.value)
11614
- }
11615
- )
11616
- ] }, `grid-${i}`)),
11617
- /* @__PURE__ */ jsx(
11618
- "line",
11619
- {
11620
- x1: PAD_LEFT2,
11621
- y1: plotTop + plotH,
11622
- x2: PAD_LEFT2 + canvasW,
11623
- y2: plotTop + plotH,
11624
- stroke: "var(--cdl-text-mute, #8a8678)",
11625
- strokeWidth: 1.25
11626
- }
11627
- ),
11628
- /* @__PURE__ */ jsx(
11629
- "line",
11630
- {
11631
- x1: PAD_LEFT2,
11632
- y1: plotTop,
11633
- x2: PAD_LEFT2,
11634
- y2: plotTop + plotH,
11635
- stroke: "var(--cdl-text-mute, #8a8678)",
11636
- strokeWidth: 1.25
11637
- }
11638
- ),
11639
- data.length > 1 && /* @__PURE__ */ jsx(
11640
- "polyline",
11641
- {
11642
- "data-cdl-role": "chart-line",
11643
- points,
11644
- fill: "none",
11645
- stroke: "var(--cdl-tone-accent, #2d6a8f)",
11646
- strokeWidth: 2.5,
11647
- strokeLinejoin: "round",
11648
- strokeLinecap: "round",
11649
- ...\u4F38\u3070\u3059dash(drawing, \u4F38\u3073)
11650
- }
11651
- ),
11652
- data.map((d, idx) => {
11653
- const cx = xAt(idx);
11654
- const cy = yAt(d.value);
11655
- const prev = idx > 0 ? data[idx - 1].value : void 0;
11656
- const next = idx < data.length - 1 ? data[idx + 1].value : void 0;
11657
- const isValley = (prev === void 0 || d.value <= prev) && (next === void 0 || d.value <= next);
11658
- const labelAbove = !isValley;
11659
- const labelY = labelAbove ? cy - 12 : cy + 18;
11660
- const \u51FA\u3059 = \u7DDA\u306E\u5148\u304C\u5C4A\u3044\u305F(idx);
11661
- return /* @__PURE__ */ jsxs("g", { "data-cdl-unresolved": d.unresolved ? "true" : void 0, children: [
11662
- \u51FA\u3059 && /* @__PURE__ */ jsxs(Fragment, { children: [
11663
- /* @__PURE__ */ jsx(
11664
- "circle",
11665
- {
11666
- cx,
11667
- cy,
11668
- r: 5,
11669
- fill: "var(--cdl-node-fill, #ffffff)",
11670
- stroke: "var(--cdl-tone-accent, #2d6a8f)",
11671
- strokeWidth: 2.5
11672
- }
11673
- ),
11674
- /* @__PURE__ */ jsx(
11675
- "circle",
11676
- {
11677
- cx,
11678
- cy,
11679
- r: 2.5,
11680
- fill: "var(--cdl-tone-accent, #2d6a8f)"
11681
- }
11682
- ),
11683
- /* @__PURE__ */ jsx(
11684
- "text",
11685
- {
11686
- "data-cdl-role": "chart-line-value",
11687
- x: cx,
11688
- y: labelY,
11689
- fontSize: 11,
11690
- fontWeight: 600,
11691
- textAnchor: "middle",
11692
- fill: "var(--cdl-text, #1a1f2a)",
11693
- children: d.value.toLocaleString()
11694
- }
11695
- )
11696
- ] }),
11697
- /* @__PURE__ */ jsx(
11698
- "text",
11699
- {
11700
- x: cx,
11701
- y: PAD_TOP2 + canvasH + 20,
11702
- fontSize: 12,
11703
- textAnchor: "middle",
11704
- fill: "var(--cdl-text-dim, #5a6270)",
11705
- children: d.label
11706
- }
11707
- )
11708
- ] }, `pt-${idx}`);
11709
- })
11710
- ] });
11711
- }
11712
11819
  function ChartPieNode({
11713
11820
  node,
11714
11821
  active,
@@ -17219,7 +17326,8 @@ function CdlNodeView({
17219
17326
  drawing = false,
17220
17327
  progress,
17221
17328
  stateValues,
17222
- currentPhaseId
17329
+ currentPhaseId,
17330
+ chartLineScale
17223
17331
  }) {
17224
17332
  const value = node.value ? interpolate(node.value, stateValues) : void 0;
17225
17333
  const rows = (node.rows ?? []).map((r) => interpolate(r, stateValues));
@@ -17275,6 +17383,7 @@ function CdlNodeView({
17275
17383
  node: resolvedNode,
17276
17384
  active,
17277
17385
  stateValues,
17386
+ scale: chartLineScale,
17278
17387
  drawing,
17279
17388
  progress
17280
17389
  }
@@ -17516,44 +17625,6 @@ function CdlNodeView({
17516
17625
  }
17517
17626
  );
17518
17627
  }
17519
-
17520
- // src/layout/lifeline.ts
17521
- function lifelineStartYs(nodes) {
17522
- const topmost = /* @__PURE__ */ new Map();
17523
- for (const n of nodes) {
17524
- const cur = topmost.get(n.lane);
17525
- if (cur === void 0 || n.cy < cur.cy) topmost.set(n.lane, n);
17526
- }
17527
- const starts = /* @__PURE__ */ new Map();
17528
- for (const [laneId, n] of topmost) starts.set(laneId, n.cy + n.h / 2);
17529
- return starts;
17530
- }
17531
- function uniformLifelineEndY(lanes, nodes, starts = lifelineStartYs(nodes)) {
17532
- const lifelineLanes = lanes.filter((l) => l.lifeline);
17533
- let deepestStart = Number.NEGATIVE_INFINITY;
17534
- for (const lane of lifelineLanes) {
17535
- const start = starts.get(lane.id);
17536
- if (start !== void 0) deepestStart = Math.max(deepestStart, start);
17537
- }
17538
- const footerTops = lifelineFooterNodes(lanes, nodes).map((f) => footerShapeDrawTop(f)).filter((top) => top > deepestStart);
17539
- if (footerTops.length > 0) return Math.min(...footerTops);
17540
- return lifelineLanes[0] ? lifelineLanes[0].y + lifelineLanes[0].height : 0;
17541
- }
17542
-
17543
- // src/kinds/draw-ratio.ts
17544
- var DRAW_RATIO_DEFAULT = 1;
17545
- function \u63CF\u304F\u5272\u5408\u3092\u6B63\u3059(ratio) {
17546
- if (ratio === void 0) return DRAW_RATIO_DEFAULT;
17547
- if (!Number.isFinite(ratio)) return DRAW_RATIO_DEFAULT;
17548
- if (ratio <= 0 || ratio > 1) return DRAW_RATIO_DEFAULT;
17549
- return ratio;
17550
- }
17551
- function \u63CF\u304F\u9032\u307F\u306B\u76F4\u3059(progress, ratio) {
17552
- const \u5272\u5408 = \u63CF\u304F\u5272\u5408\u3092\u6B63\u3059(ratio);
17553
- if (\u5272\u5408 === DRAW_RATIO_DEFAULT) return progress;
17554
- if (!Number.isFinite(progress)) return progress;
17555
- return Math.min(1, progress / \u5272\u5408);
17556
- }
17557
17628
  function CdlStage({
17558
17629
  laid,
17559
17630
  currentPhase,
@@ -17595,6 +17666,26 @@ function CdlStage({
17595
17666
  };
17596
17667
  }, [laid.phases, currentPhase, laid.edgeReveal]);
17597
17668
  const drawSet = new Set(currentPhase?.draw ?? []);
17669
+ const chartLineScales = useMemo(() => {
17670
+ const nodes = laid.nodes.filter((node) => node.kind === "chart-line");
17671
+ if (nodes.length === 0) return /* @__PURE__ */ new Map();
17672
+ const frames = [
17673
+ // phase index -1 はどの段にも入る前の初期値。
17674
+ computeStateValues(laid, -1, 0),
17675
+ ...laid.phases.flatMap((_, phaseIndex) => [
17676
+ computeStateValues(laid, phaseIndex, 0),
17677
+ computeStateValues(laid, phaseIndex, 1)
17678
+ ])
17679
+ ];
17680
+ const scales = /* @__PURE__ */ new Map();
17681
+ for (const node of nodes) {
17682
+ const values = frames.flatMap(
17683
+ (stateValues2) => resolveChartData(node.chartData ?? [], stateValues2).map((datum) => datum.value)
17684
+ );
17685
+ scales.set(node.id, \u6298\u308C\u7DDA\u306E\u76EE\u76DB(values));
17686
+ }
17687
+ return scales;
17688
+ }, [laid]);
17598
17689
  const \u63CF\u304F\u9032\u307F = \u63CF\u304F\u9032\u307F\u306B\u76F4\u3059(progress, currentPhase?.drawRatio);
17599
17690
  const { lifelineStarts, uniformFooterTop } = useMemo(() => {
17600
17691
  const starts = lifelineStartYs(laid.nodes);
@@ -17603,6 +17694,63 @@ function CdlStage({
17603
17694
  uniformFooterTop: uniformLifelineEndY(laid.lanes, laid.nodes, starts)
17604
17695
  };
17605
17696
  }, [laid]);
17697
+ const edgeHeadMarkers = useMemo(() => {
17698
+ const referenced = /* @__PURE__ */ new Set();
17699
+ const add = (tone, head, fill) => {
17700
+ for (const small of [false, true]) {
17701
+ const id = edgeHeadMarkerName(tone, head, small, fill);
17702
+ if (id !== void 0) referenced.add(id);
17703
+ }
17704
+ };
17705
+ for (const edge of laid.edges) {
17706
+ add(edge.tone, edge.head, edge.headFill);
17707
+ if (edge.tailHead !== void 0) add(edge.tone, edge.tailHead, edge.tailHeadFill);
17708
+ }
17709
+ return Object.entries(TONE).flatMap(
17710
+ ([tone, color]) => [
17711
+ [false, 14],
17712
+ [true, 10]
17713
+ ].flatMap(
17714
+ ([small, size]) => EDGE_HEADS.flatMap(
17715
+ (head) => EDGE_HEAD_FILLS.map((fill) => {
17716
+ const \u5F62 = EDGE_HEAD_SHAPE[head];
17717
+ const id = edgeHeadMarkerId(tone, head, small, fill);
17718
+ if (!referenced.has(id) || \u5F62.d === "") return null;
17719
+ if (fill !== EDGE_HEAD_FILL_DEFAULT && !\u5F62.filled) return null;
17720
+ const \u5857 = edgeHeadPaint(head, fill, color);
17721
+ return /* @__PURE__ */ jsx(
17722
+ "marker",
17723
+ {
17724
+ id,
17725
+ viewBox: `0 0 ${\u5F62.w} ${\u5F62.h}`,
17726
+ refX: \u5F62.refX,
17727
+ refY: \u5F62.h / 2,
17728
+ markerWidth: size * (\u5F62.scale ?? 1) * \u5F62.w / \u5F62.h,
17729
+ markerHeight: size * (\u5F62.scale ?? 1),
17730
+ markerUnits: "userSpaceOnUse",
17731
+ orient: "auto-start-reverse",
17732
+ children: /* @__PURE__ */ jsx(
17733
+ "path",
17734
+ {
17735
+ "data-cdl-role": "edge-arrowhead",
17736
+ "data-cdl-edge-head": head,
17737
+ "data-cdl-edge-head-fill": fill,
17738
+ d: \u5F62.d,
17739
+ fill: \u5857.fill,
17740
+ stroke: \u5857.stroke,
17741
+ strokeWidth: \u5857.strokeWidth,
17742
+ strokeLinecap: \u5857.strokeWidth === void 0 ? void 0 : "round",
17743
+ strokeLinejoin: \u5857.strokeWidth === void 0 ? void 0 : "round"
17744
+ }
17745
+ )
17746
+ },
17747
+ id
17748
+ );
17749
+ })
17750
+ )
17751
+ )
17752
+ );
17753
+ }, [laid]);
17606
17754
  const diagramScale = laid.diagramScale ?? 1;
17607
17755
  return /* @__PURE__ */ jsxs("div", { className: compact ? "px-3 py-3" : "px-6 py-6", style: compact ? void 0 : { minHeight: 460 }, children: [
17608
17756
  /* @__PURE__ */ jsxs(
@@ -17621,55 +17769,11 @@ function CdlStage({
17621
17769
  "data-cdl-type": laid.type,
17622
17770
  children: [
17623
17771
  /* @__PURE__ */ jsxs("defs", { children: [
17624
- Object.entries(TONE).flatMap(
17625
- ([tone, color]) => [["", 14], ["-sm", 10]].flatMap(
17626
- ([suffix, size]) => EDGE_HEADS.flatMap(
17627
- (head) => (
17628
- // 塗り方は形と別の軸 (#578)。 塗らない形では 2 つが同じ名前に畳まれるので、
17629
- // `edgeHeadMarkerId` が返す名前で重複を外す
17630
- EDGE_HEAD_FILLS.map((fill) => {
17631
- const \u5F62 = EDGE_HEAD_SHAPE[head];
17632
- const id = edgeHeadMarkerId(tone, head, suffix === "-sm", fill);
17633
- if (\u5F62.d === "") return null;
17634
- if (fill !== EDGE_HEAD_FILL_DEFAULT && !\u5F62.filled) return null;
17635
- const \u5857 = edgeHeadPaint(head, fill, color);
17636
- return /* @__PURE__ */ jsx(
17637
- "marker",
17638
- {
17639
- id,
17640
- viewBox: `0 0 ${\u5F62.w} ${\u5F62.h}`,
17641
- refX: \u5F62.refX,
17642
- refY: \u5F62.h / 2,
17643
- markerWidth: size * (\u5F62.scale ?? 1) * \u5F62.w / \u5F62.h,
17644
- markerHeight: size * (\u5F62.scale ?? 1),
17645
- markerUnits: "userSpaceOnUse",
17646
- orient: "auto-start-reverse",
17647
- children: /* @__PURE__ */ jsx(
17648
- "path",
17649
- {
17650
- "data-cdl-role": "edge-arrowhead",
17651
- "data-cdl-edge-head": head,
17652
- "data-cdl-edge-head-fill": fill,
17653
- d: \u5F62.d,
17654
- fill: \u5857.fill,
17655
- stroke: \u5857.stroke,
17656
- strokeWidth: \u5857.strokeWidth,
17657
- strokeLinecap: \u5857.strokeWidth === void 0 ? void 0 : "round",
17658
- strokeLinejoin: \u5857.strokeWidth === void 0 ? void 0 : "round"
17659
- }
17660
- )
17661
- },
17662
- id
17663
- );
17664
- })
17665
- )
17666
- )
17667
- )
17668
- ),
17772
+ edgeHeadMarkers,
17669
17773
  /* @__PURE__ */ jsx(
17670
17774
  "marker",
17671
17775
  {
17672
- id: "cdl-arrow-muted",
17776
+ id: EDGE_HEAD_MUTED_MARKER_ID,
17673
17777
  viewBox: "0 0 10 10",
17674
17778
  refX: "9",
17675
17779
  refY: "5",
@@ -17776,7 +17880,8 @@ function CdlStage({
17776
17880
  drawing: \u63CF\u304F,
17777
17881
  progress: \u63CF\u304F ? \u63CF\u304F\u9032\u307F : progress,
17778
17882
  stateValues,
17779
- currentPhaseId: currentPhase?.id
17883
+ currentPhaseId: currentPhase?.id,
17884
+ chartLineScale: chartLineScales.get(node.id)
17780
17885
  }
17781
17886
  );
17782
17887
  return /* @__PURE__ */ jsx("g", { children: view }, node.id);