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