@panneau/ui 5.0.0-alpha.36 → 5.0.0-alpha.38

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.
Files changed (53) hide show
  1. package/README.md +8 -2
  2. package/dist/bar-chart/BarChart.css +76 -0
  3. package/dist/bar-chart/BarChart.d.ts +33 -0
  4. package/dist/bar-chart/BarChart.d.ts.map +1 -0
  5. package/dist/bar-chart/BarChart.js +151 -0
  6. package/dist/bar-chart/BarChart.js.map +1 -0
  7. package/dist/bar-chart/BarChart.module.js +26 -0
  8. package/dist/bar-chart/BarChart.module.js.map +1 -0
  9. package/dist/bar-chart/tokens.d.ts +3 -0
  10. package/dist/bar-chart/tokens.d.ts.map +1 -0
  11. package/dist/bar-chart/tokens.js +17 -0
  12. package/dist/bar-chart/tokens.js.map +1 -0
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +4 -2
  16. package/dist/line-chart/LineChart.css +223 -24
  17. package/dist/line-chart/LineChart.d.ts +45 -10
  18. package/dist/line-chart/LineChart.d.ts.map +1 -1
  19. package/dist/line-chart/LineChart.js +580 -265
  20. package/dist/line-chart/LineChart.js.map +1 -1
  21. package/dist/line-chart/LineChart.module.js +42 -5
  22. package/dist/line-chart/LineChart.module.js.map +1 -1
  23. package/dist/line-chart/geometry.d.ts +37 -0
  24. package/dist/line-chart/geometry.d.ts.map +1 -0
  25. package/dist/line-chart/geometry.js +115 -0
  26. package/dist/line-chart/geometry.js.map +1 -0
  27. package/dist/line-chart/tokens.d.ts +1 -1
  28. package/dist/line-chart/tokens.d.ts.map +1 -1
  29. package/dist/line-chart/tokens.js +11 -7
  30. package/dist/line-chart/tokens.js.map +1 -1
  31. package/dist/meter/Meter.css +23 -0
  32. package/dist/meter/Meter.d.ts +26 -0
  33. package/dist/meter/Meter.d.ts.map +1 -0
  34. package/dist/meter/Meter.js +99 -0
  35. package/dist/meter/Meter.js.map +1 -0
  36. package/dist/meter/Meter.module.js +16 -0
  37. package/dist/meter/Meter.module.js.map +1 -0
  38. package/dist/meter/tokens.d.ts +3 -0
  39. package/dist/meter/tokens.d.ts.map +1 -0
  40. package/dist/meter/tokens.js +15 -0
  41. package/dist/meter/tokens.js.map +1 -0
  42. package/dist/stat/Stat.css +4 -0
  43. package/dist/stat/Stat.d.ts +11 -3
  44. package/dist/stat/Stat.d.ts.map +1 -1
  45. package/dist/stat/Stat.js +67 -42
  46. package/dist/stat/Stat.js.map +1 -1
  47. package/dist/stat/Stat.module.js +3 -1
  48. package/dist/stat/Stat.module.js.map +1 -1
  49. package/dist/theme/components.d.ts +3 -1
  50. package/dist/theme/components.d.ts.map +1 -1
  51. package/dist/theme/components.js +4 -0
  52. package/dist/theme/components.js.map +1 -1
  53. package/package.json +3 -3
@@ -1,326 +1,641 @@
1
1
  import { cx } from "../utils/cx.js";
2
+ import { messages } from "../intl/messages.js";
2
3
  import { usePanneauIntl } from "../intl/usePanneauIntl.js";
3
4
  import { Skeleton } from "../skeleton/Skeleton.js";
4
5
  import { chartColors } from "../theme/chartColors.js";
5
6
  import LineChart_module_default from "./LineChart.module.js";
7
+ import { axisLabelIndices, linearPath, monotonePath, niceScale } from "./geometry.js";
6
8
  import { c } from "react/compiler-runtime";
7
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
+ import { useId, useState } from "react";
8
11
  //#region src/line-chart/LineChart.tsx
9
- /** Points get dots up to this count: past it, only the last one has one. */
10
- var MAX_DOTS = 31;
12
+ /** At most this number of labels under the chart, half of them when it is narrow. */
13
+ var MAX_AXIS_LABELS = 7;
14
+ /** Closer than this (in percents of the width), the highest value isn't labeled beside the last one. */
15
+ var LABEL_GAP = 12;
11
16
  /**
12
- * A line of values over time, on the categorical chart colors of the theme: the line, the area
13
- * under it, the top of its scale, and the labels of its first and last points. The plot is hidden
14
- * from assistive technologies, which read the values in a table instead.
17
+ * A line of values over time, on the categorical chart colors of the theme: a curve and the area
18
+ * under it, a scale of round graduations, labels of dates under it, and the last value at the end
19
+ * of the line. The plot is hidden from assistive technologies, which read the values in a table;
20
+ * with `isInteractive`, the pointer and the arrow keys also show the value of each point.
15
21
  */
16
22
  function LineChart(t0) {
17
- const $ = c(91);
18
- const { label, points, formatValue, height, color: t1, className } = t0;
19
- const color = t1 === void 0 ? 0 : t1;
23
+ const $ = c(146);
24
+ const { label, points, formatValue, formatTick, axisLabel, showAxis: t1, showLast: t2, showMax: t3, isInteractive: t4, domain, curve: t5, height, color: t6, className } = t0;
25
+ const showAxis = t1 === void 0 ? true : t1;
26
+ const showLast = t2 === void 0 ? true : t2;
27
+ const showMax = t3 === void 0 ? false : t3;
28
+ const isInteractive = t4 === void 0 ? false : t4;
29
+ const curve = t5 === void 0 ? "monotone" : t5;
30
+ const color = t6 === void 0 ? 0 : t6;
20
31
  const intl = usePanneauIntl();
21
- let t2;
22
- if ($[0] !== formatValue || $[1] !== intl) {
23
- t2 = formatValue ?? ((value) => intl.formatNumber(value));
24
- $[0] = formatValue;
25
- $[1] = intl;
26
- $[2] = t2;
27
- } else t2 = $[2];
28
- const format = t2;
29
- let t3;
30
- if ($[3] !== color) {
31
- t3 = chartColors.categorical(color);
32
- $[3] = color;
33
- $[4] = t3;
34
- } else t3 = $[4];
35
- let t4;
36
- if ($[5] !== height) {
37
- t4 = height !== void 0 ? { "--_panneau-line-chart-height": height } : {};
38
- $[5] = height;
39
- $[6] = t4;
40
- } else t4 = $[6];
41
- let t5;
42
- if ($[7] !== t3 || $[8] !== t4) {
43
- t5 = {
44
- "--_panneau-line-chart-color": t3,
45
- ...t4
32
+ const t7 = useId();
33
+ let t8;
34
+ if ($[0] !== t7) {
35
+ let t9;
36
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
37
+ t9 = /[^\w-]/g;
38
+ $[2] = t9;
39
+ } else t9 = $[2];
40
+ t8 = t7.replace(t9, "");
41
+ $[0] = t7;
42
+ $[1] = t8;
43
+ } else t8 = $[1];
44
+ const gradientId = `panneau-line-chart-${t8}`;
45
+ const [active, setActive] = useState(null);
46
+ let t9;
47
+ if ($[3] !== formatValue || $[4] !== intl) {
48
+ t9 = formatValue ?? ((value) => intl.formatNumber(value));
49
+ $[3] = formatValue;
50
+ $[4] = intl;
51
+ $[5] = t9;
52
+ } else t9 = $[5];
53
+ const format = t9;
54
+ let t10;
55
+ if ($[6] !== color) {
56
+ t10 = chartColors.categorical(color);
57
+ $[6] = color;
58
+ $[7] = t10;
59
+ } else t10 = $[7];
60
+ let t11;
61
+ if ($[8] !== height) {
62
+ t11 = height !== void 0 ? { "--_panneau-line-chart-height": height } : {};
63
+ $[8] = height;
64
+ $[9] = t11;
65
+ } else t11 = $[9];
66
+ let t12;
67
+ if ($[10] !== t10 || $[11] !== t11) {
68
+ t12 = {
69
+ "--_panneau-line-chart-color": t10,
70
+ ...t11
46
71
  };
47
- $[7] = t3;
48
- $[8] = t4;
49
- $[9] = t5;
50
- } else t5 = $[9];
51
- const style = t5;
72
+ $[10] = t10;
73
+ $[11] = t11;
74
+ $[12] = t12;
75
+ } else t12 = $[12];
76
+ const style = t12;
52
77
  if (points === void 0) {
53
- let t6;
54
- if ($[10] !== className) {
55
- t6 = cx("panneau-line-chart", LineChart_module_default.chart, className);
56
- $[10] = className;
57
- $[11] = t6;
58
- } else t6 = $[11];
59
- let t7;
60
- let t8;
61
- if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
62
- t7 = /* @__PURE__ */ jsx("div", {
63
- className: LineChart_module_default.plot,
78
+ let t13;
79
+ if ($[13] !== className) {
80
+ t13 = cx("panneau-line-chart", LineChart_module_default.chart, className);
81
+ $[13] = className;
82
+ $[14] = t13;
83
+ } else t13 = $[14];
84
+ let t14;
85
+ let t15;
86
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
87
+ t14 = /* @__PURE__ */ jsx("div", {
88
+ className: LineChart_module_default.skeleton,
64
89
  children: /* @__PURE__ */ jsx(Skeleton, {
65
90
  shape: "rect",
66
91
  height: "100%"
67
92
  })
68
93
  });
69
- t8 = /* @__PURE__ */ jsx(Skeleton, { width: "100%" });
70
- $[12] = t7;
71
- $[13] = t8;
94
+ t15 = /* @__PURE__ */ jsx(Skeleton, { width: "100%" });
95
+ $[15] = t14;
96
+ $[16] = t15;
72
97
  } else {
73
- t7 = $[12];
74
- t8 = $[13];
98
+ t14 = $[15];
99
+ t15 = $[16];
75
100
  }
76
- let t9;
77
- if ($[14] !== style || $[15] !== t6) {
78
- t9 = /* @__PURE__ */ jsxs("div", {
79
- className: t6,
101
+ let t16;
102
+ if ($[17] !== style || $[18] !== t13) {
103
+ t16 = /* @__PURE__ */ jsxs("div", {
104
+ className: t13,
80
105
  style,
81
- children: [t7, t8]
106
+ children: [t14, t15]
82
107
  });
83
- $[14] = style;
84
- $[15] = t6;
85
- $[16] = t9;
86
- } else t9 = $[16];
87
- return t9;
108
+ $[17] = style;
109
+ $[18] = t13;
110
+ $[19] = t16;
111
+ } else t16 = $[19];
112
+ return t16;
88
113
  }
89
- let first;
90
- let last;
91
- let t10;
92
- let t6;
93
- let t7;
94
- let t8;
95
- let t9;
96
- if ($[17] !== className || $[18] !== format || $[19] !== points || $[20] !== style) {
114
+ let lastIndex;
115
+ let plotted;
116
+ let shortLabel;
117
+ let t13;
118
+ let t14;
119
+ let t15;
120
+ let t16;
121
+ let t17;
122
+ let t18;
123
+ let t19;
124
+ let t20;
125
+ let t21;
126
+ let t22;
127
+ let t23;
128
+ let t24;
129
+ let t25;
130
+ let t26;
131
+ let t27;
132
+ let t28;
133
+ let t29;
134
+ let t30;
135
+ let t31;
136
+ if ($[20] !== active || $[21] !== axisLabel || $[22] !== className || $[23] !== curve || $[24] !== domain || $[25] !== format || $[26] !== formatTick || $[27] !== gradientId || $[28] !== intl || $[29] !== isInteractive || $[30] !== label || $[31] !== points || $[32] !== showAxis || $[33] !== showLast || $[34] !== showMax || $[35] !== style) {
97
137
  const values = points.map(_temp);
98
- const low = Math.min(0, ...values);
99
- const high = Math.max(low + 1, ...values);
100
- const top = high + (high - low) * .08;
101
- let t11;
102
- if ($[28] !== points.length) {
103
- t11 = (index) => points.length === 1 ? 50 : index / (points.length - 1) * 100;
104
- $[28] = points.length;
105
- $[29] = t11;
106
- } else t11 = $[29];
107
- const x = t11;
108
- let t12;
109
- if ($[30] !== low || $[31] !== top) {
110
- t12 = (value_0) => 100 - (value_0 - low) / (top - low) * 100;
111
- $[30] = low;
112
- $[31] = top;
113
- $[32] = t12;
114
- } else t12 = $[32];
115
- const y = t12;
116
- let t13;
117
- if ($[33] !== points || $[34] !== x || $[35] !== y) {
118
- let t14;
119
- if ($[37] !== x || $[38] !== y) {
120
- t14 = (point_0, index_0) => `${index_0 === 0 ? "M" : "L"}${x(index_0)},${y(point_0.value)}`;
121
- $[37] = x;
122
- $[38] = y;
123
- $[39] = t14;
124
- } else t14 = $[39];
125
- t13 = points.map(t14).join(" ");
126
- $[33] = points;
127
- $[34] = x;
128
- $[35] = y;
129
- $[36] = t13;
130
- } else t13 = $[36];
131
- const line = t13;
132
- const zero = y(Math.max(low, 0));
133
- first = points[0];
134
- let t14;
135
- if ($[40] !== points) {
136
- t14 = points.at(-1);
137
- $[40] = points;
138
- $[41] = t14;
139
- } else t14 = $[41];
140
- last = t14;
141
- if ($[42] !== className) {
142
- t9 = cx("panneau-line-chart", LineChart_module_default.chart, className);
143
- $[42] = className;
144
- $[43] = t9;
145
- } else t9 = $[43];
146
- t10 = style;
147
- t6 = LineChart_module_default.plot;
148
- let t15;
149
- if ($[44] !== zero) {
150
- t15 = /* @__PURE__ */ jsx("line", {
138
+ const scale = niceScale(Math.min(...values, 0), Math.max(...values, 0), domain);
139
+ const tick = formatTick ?? ((value_0) => intl.formatNumber(value_0, scale.max >= 1e4 ? { notation: "compact" } : {}));
140
+ const y = (value_1) => 100 - (value_1 - scale.min) / (scale.max - scale.min) * 100;
141
+ let t32;
142
+ if ($[58] !== points.length || $[59] !== y) {
143
+ t32 = (point_0, index) => ({
144
+ x: points.length === 1 ? 50 : index / (points.length - 1) * 100,
145
+ y: y(point_0.value)
146
+ });
147
+ $[58] = points.length;
148
+ $[59] = y;
149
+ $[60] = t32;
150
+ } else t32 = $[60];
151
+ plotted = points.map(t32);
152
+ const line = curve === "linear" ? linearPath(plotted) : monotonePath(plotted);
153
+ const zero = y(Math.min(Math.max(0, scale.min), scale.max));
154
+ const firstPoint = plotted[0];
155
+ lastIndex = points.length - 1;
156
+ const lastPoint = plotted[lastIndex];
157
+ const maxValue = Math.max(...values);
158
+ const maxIndex = values.indexOf(maxValue);
159
+ const maxPoint = plotted[maxIndex];
160
+ const labelLast = showLast && lastPoint !== void 0;
161
+ const labelMax = showMax && maxPoint !== void 0 && maxValue > scale.min && !(labelLast && lastPoint.x - maxPoint.x < LABEL_GAP);
162
+ const activePoint = active !== null ? plotted[active] : void 0;
163
+ const activeData = active !== null ? points[active] : void 0;
164
+ shortLabel = _temp2;
165
+ let t33;
166
+ if ($[61] !== format || $[62] !== intl) {
167
+ t33 = (point_2) => intl.formatMessage(messages.chartPoint, {
168
+ label: point_2.label,
169
+ value: format(point_2.value)
170
+ });
171
+ $[61] = format;
172
+ $[62] = intl;
173
+ $[63] = t33;
174
+ } else t33 = $[63];
175
+ const describe = t33;
176
+ let t34;
177
+ if ($[64] !== lastIndex || $[65] !== points.length) {
178
+ t34 = (event) => {
179
+ const rect = event.currentTarget.getBoundingClientRect();
180
+ if (rect.width > 0 && points.length > 0) {
181
+ const ratio = Math.min(Math.max((event.clientX - rect.left) / rect.width, 0), 1);
182
+ setActive(Math.round(ratio * lastIndex));
183
+ }
184
+ };
185
+ $[64] = lastIndex;
186
+ $[65] = points.length;
187
+ $[66] = t34;
188
+ } else t34 = $[66];
189
+ const point_3 = t34;
190
+ let t35;
191
+ if ($[67] !== active || $[68] !== lastIndex) {
192
+ t35 = (event_0) => {
193
+ const current = active ?? lastIndex;
194
+ const next = event_0.key === "ArrowLeft" || event_0.key === "ArrowDown" ? current - 1 : event_0.key === "ArrowRight" || event_0.key === "ArrowUp" ? current + 1 : event_0.key === "Home" ? 0 : event_0.key === "End" ? lastIndex : null;
195
+ if (next !== null) {
196
+ event_0.preventDefault();
197
+ setActive(Math.min(Math.max(next, 0), lastIndex));
198
+ }
199
+ };
200
+ $[67] = active;
201
+ $[68] = lastIndex;
202
+ $[69] = t35;
203
+ } else t35 = $[69];
204
+ const move = t35;
205
+ const focused = points[active ?? lastIndex];
206
+ let t36;
207
+ if ($[70] !== active || $[71] !== describe || $[72] !== focused || $[73] !== isInteractive || $[74] !== label || $[75] !== lastIndex || $[76] !== move || $[77] !== point_3) {
208
+ t36 = isInteractive && focused !== void 0 ? {
209
+ role: "slider",
210
+ tabIndex: 0,
211
+ "aria-label": label,
212
+ "aria-orientation": "horizontal",
213
+ "aria-valuemin": 0,
214
+ "aria-valuemax": lastIndex,
215
+ "aria-valuenow": active ?? lastIndex,
216
+ "aria-valuetext": describe(focused),
217
+ onPointerMove: point_3,
218
+ onPointerDown: point_3,
219
+ onPointerLeave: () => setActive(null),
220
+ onFocus: () => setActive((current_0) => current_0 ?? lastIndex),
221
+ onBlur: () => setActive(null),
222
+ onKeyDown: move
223
+ } : {};
224
+ $[70] = active;
225
+ $[71] = describe;
226
+ $[72] = focused;
227
+ $[73] = isInteractive;
228
+ $[74] = label;
229
+ $[75] = lastIndex;
230
+ $[76] = move;
231
+ $[77] = point_3;
232
+ $[78] = t36;
233
+ } else t36 = $[78];
234
+ const interaction = t36;
235
+ const widestTick = scale.ticks.map(tick).reduce(_temp3, "");
236
+ let t37;
237
+ if ($[79] !== points) {
238
+ t37 = (index_0) => {
239
+ const previous = points[index_0 - 1];
240
+ const current_1 = points[index_0];
241
+ return previous !== void 0 && current_1 !== void 0 && previous.value > current_1.value ? "below" : "above";
242
+ };
243
+ $[79] = points;
244
+ $[80] = t37;
245
+ } else t37 = $[80];
246
+ const placement = t37;
247
+ let t38;
248
+ if ($[81] !== format || $[82] !== points) {
249
+ t38 = (index_1, where, placedAt) => {
250
+ const data = points[index_1];
251
+ return data !== void 0 ? /* @__PURE__ */ jsx("span", {
252
+ className: LineChart_module_default.valueLabel,
253
+ "data-placement": placedAt,
254
+ style: positionOf(where),
255
+ children: format(data.value)
256
+ }) : null;
257
+ };
258
+ $[81] = format;
259
+ $[82] = points;
260
+ $[83] = t38;
261
+ } else t38 = $[83];
262
+ const valueLabel = t38;
263
+ if ($[84] !== className) {
264
+ t27 = cx("panneau-line-chart", LineChart_module_default.chart, className);
265
+ $[84] = className;
266
+ $[85] = t27;
267
+ } else t27 = $[85];
268
+ t28 = style;
269
+ t29 = showAxis ? "" : void 0;
270
+ t30 = labelLast || labelMax ? "" : void 0;
271
+ if ($[86] !== axisLabel) {
272
+ t31 = axisLabel !== void 0 ? /* @__PURE__ */ jsx("div", {
273
+ className: LineChart_module_default.axisLabel,
274
+ "aria-hidden": "true",
275
+ children: axisLabel
276
+ }) : null;
277
+ $[86] = axisLabel;
278
+ $[87] = t31;
279
+ } else t31 = $[87];
280
+ t25 = LineChart_module_default.body;
281
+ t26 = showAxis ? /* @__PURE__ */ jsxs("div", {
282
+ className: LineChart_module_default.scale,
283
+ "aria-hidden": "true",
284
+ children: [/* @__PURE__ */ jsx("span", {
285
+ className: LineChart_module_default.widest,
286
+ children: widestTick
287
+ }), scale.ticks.map((value_2) => /* @__PURE__ */ jsx("span", {
288
+ className: LineChart_module_default.tick,
289
+ style: { top: `${y(value_2)}%` },
290
+ children: tick(value_2)
291
+ }, value_2))]
292
+ }) : null;
293
+ t21 = LineChart_module_default.plot;
294
+ t22 = interaction;
295
+ let t39;
296
+ let t40;
297
+ if ($[88] === Symbol.for("react.memo_cache_sentinel")) {
298
+ t39 = /* @__PURE__ */ jsx("stop", {
299
+ offset: "0",
300
+ className: LineChart_module_default.areaTop
301
+ });
302
+ t40 = /* @__PURE__ */ jsx("stop", {
303
+ offset: "1",
304
+ className: LineChart_module_default.areaBottom
305
+ });
306
+ $[88] = t39;
307
+ $[89] = t40;
308
+ } else {
309
+ t39 = $[88];
310
+ t40 = $[89];
311
+ }
312
+ let t41;
313
+ if ($[90] !== gradientId) {
314
+ t41 = /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", {
315
+ id: gradientId,
316
+ x1: "0",
317
+ y1: "0",
318
+ x2: "0",
319
+ y2: "1",
320
+ children: [t39, t40]
321
+ }) });
322
+ $[90] = gradientId;
323
+ $[91] = t41;
324
+ } else t41 = $[91];
325
+ const t42 = showAxis ? scale.ticks.map((value_3) => /* @__PURE__ */ jsx("line", {
326
+ className: LineChart_module_default.grid,
327
+ x1: "0",
328
+ x2: "100",
329
+ y1: y(value_3),
330
+ y2: y(value_3)
331
+ }, value_3)) : null;
332
+ let t43;
333
+ if ($[92] !== zero) {
334
+ t43 = /* @__PURE__ */ jsx("line", {
151
335
  className: LineChart_module_default.baseline,
152
336
  x1: "0",
153
337
  x2: "100",
154
338
  y1: zero,
155
339
  y2: zero
156
340
  });
157
- $[44] = zero;
158
- $[45] = t15;
159
- } else t15 = $[45];
160
- let t16;
161
- if ($[46] !== line || $[47] !== points.length || $[48] !== x || $[49] !== zero) {
162
- t16 = points.length > 1 ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("path", {
341
+ $[92] = zero;
342
+ $[93] = t43;
343
+ } else t43 = $[93];
344
+ const t44 = firstPoint !== void 0 && lastPoint !== void 0 && points.length > 1 ? /* @__PURE__ */ jsxs("g", {
345
+ className: LineChart_module_default.reveal,
346
+ children: [/* @__PURE__ */ jsx("path", {
163
347
  className: LineChart_module_default.area,
164
- d: `${line} L${x(points.length - 1)},${zero} L${x(0)},${zero} Z`
348
+ fill: `url(#${gradientId})`,
349
+ d: `${line} L${lastPoint.x},${zero} L${firstPoint.x},${zero} Z`
165
350
  }), /* @__PURE__ */ jsx("path", {
166
351
  className: LineChart_module_default.line,
167
352
  d: line
168
- })] }) : null;
169
- $[46] = line;
170
- $[47] = points.length;
171
- $[48] = x;
172
- $[49] = zero;
173
- $[50] = t16;
174
- } else t16 = $[50];
175
- let t17;
176
- if ($[51] !== format || $[52] !== points || $[53] !== x || $[54] !== y) {
177
- let t18;
178
- if ($[56] !== format || $[57] !== points.length || $[58] !== x || $[59] !== y) {
179
- t18 = (point_1, index_1) => points.length <= MAX_DOTS || index_1 === points.length - 1 ? /* @__PURE__ */ jsx("path", {
180
- className: LineChart_module_default.dot,
181
- d: `M${x(index_1)},${y(point_1.value)} h0`,
182
- children: /* @__PURE__ */ jsx("title", { children: `${point_1.label}: ${format(point_1.value)}` })
183
- }, point_1.label) : null;
184
- $[56] = format;
185
- $[57] = points.length;
186
- $[58] = x;
187
- $[59] = y;
188
- $[60] = t18;
189
- } else t18 = $[60];
190
- t17 = points.map(t18);
191
- $[51] = format;
192
- $[52] = points;
193
- $[53] = x;
194
- $[54] = y;
195
- $[55] = t17;
196
- } else t17 = $[55];
197
- if ($[61] !== t15 || $[62] !== t16 || $[63] !== t17) {
198
- t7 = /* @__PURE__ */ jsxs("svg", {
353
+ })]
354
+ }) : null;
355
+ if ($[94] !== t41 || $[95] !== t42 || $[96] !== t43 || $[97] !== t44) {
356
+ t23 = /* @__PURE__ */ jsxs("svg", {
199
357
  className: LineChart_module_default.svg,
200
358
  viewBox: "0 0 100 100",
201
359
  preserveAspectRatio: "none",
202
360
  "aria-hidden": "true",
203
361
  focusable: "false",
204
362
  children: [
205
- t15,
206
- t16,
207
- t17
363
+ t41,
364
+ t42,
365
+ t43,
366
+ t44
208
367
  ]
209
368
  });
210
- $[61] = t15;
211
- $[62] = t16;
212
- $[63] = t17;
213
- $[64] = t7;
214
- } else t7 = $[64];
215
- t8 = points.length > 0 && Math.max(...values) > low ? /* @__PURE__ */ jsx("span", {
216
- className: LineChart_module_default.max,
217
- "aria-hidden": "true",
218
- children: format(Math.max(...values))
369
+ $[94] = t41;
370
+ $[95] = t42;
371
+ $[96] = t43;
372
+ $[97] = t44;
373
+ $[98] = t23;
374
+ } else t23 = $[98];
375
+ t24 = activePoint !== void 0 ? /* @__PURE__ */ jsx("span", {
376
+ className: LineChart_module_default.crosshair,
377
+ style: { left: `${activePoint.x}%` },
378
+ "aria-hidden": "true"
379
+ }) : null;
380
+ t13 = LineChart_module_default.marks;
381
+ t14 = "true";
382
+ t15 = points.length === 1 && firstPoint !== void 0 && !labelLast ? /* @__PURE__ */ jsx("span", {
383
+ className: LineChart_module_default.dot,
384
+ style: positionOf(firstPoint)
385
+ }) : null;
386
+ t16 = labelMax && maxPoint !== void 0 ? /* @__PURE__ */ jsx("span", {
387
+ className: LineChart_module_default.dot,
388
+ style: positionOf(maxPoint)
389
+ }) : null;
390
+ t17 = labelLast && lastPoint !== void 0 ? /* @__PURE__ */ jsx("span", {
391
+ className: LineChart_module_default.dot,
392
+ style: positionOf(lastPoint)
219
393
  }) : null;
220
- $[17] = className;
221
- $[18] = format;
222
- $[19] = points;
223
- $[20] = style;
224
- $[21] = first;
225
- $[22] = last;
226
- $[23] = t10;
227
- $[24] = t6;
228
- $[25] = t7;
229
- $[26] = t8;
230
- $[27] = t9;
394
+ t18 = activePoint === void 0 && labelMax && maxPoint !== void 0 ? valueLabel(maxIndex, maxPoint, "above") : null;
395
+ t19 = activePoint === void 0 && labelLast && lastPoint !== void 0 ? valueLabel(lastIndex, lastPoint, placement(lastIndex)) : null;
396
+ t20 = activePoint !== void 0 && activeData !== void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
397
+ className: cx(LineChart_module_default.dot, LineChart_module_default.activeDot),
398
+ style: positionOf(activePoint)
399
+ }), /* @__PURE__ */ jsxs("span", {
400
+ className: LineChart_module_default.tooltip,
401
+ "data-placement": activePoint.y < 30 ? "below" : "above",
402
+ style: positionOf(activePoint),
403
+ children: [/* @__PURE__ */ jsx("strong", {
404
+ className: LineChart_module_default.tooltipValue,
405
+ children: format(activeData.value)
406
+ }), /* @__PURE__ */ jsx("span", {
407
+ className: LineChart_module_default.tooltipLabel,
408
+ children: activeData.label
409
+ })]
410
+ })] }) : null;
411
+ $[20] = active;
412
+ $[21] = axisLabel;
413
+ $[22] = className;
414
+ $[23] = curve;
415
+ $[24] = domain;
416
+ $[25] = format;
417
+ $[26] = formatTick;
418
+ $[27] = gradientId;
419
+ $[28] = intl;
420
+ $[29] = isInteractive;
421
+ $[30] = label;
422
+ $[31] = points;
423
+ $[32] = showAxis;
424
+ $[33] = showLast;
425
+ $[34] = showMax;
426
+ $[35] = style;
427
+ $[36] = lastIndex;
428
+ $[37] = plotted;
429
+ $[38] = shortLabel;
430
+ $[39] = t13;
431
+ $[40] = t14;
432
+ $[41] = t15;
433
+ $[42] = t16;
434
+ $[43] = t17;
435
+ $[44] = t18;
436
+ $[45] = t19;
437
+ $[46] = t20;
438
+ $[47] = t21;
439
+ $[48] = t22;
440
+ $[49] = t23;
441
+ $[50] = t24;
442
+ $[51] = t25;
443
+ $[52] = t26;
444
+ $[53] = t27;
445
+ $[54] = t28;
446
+ $[55] = t29;
447
+ $[56] = t30;
448
+ $[57] = t31;
231
449
  } else {
232
- first = $[21];
233
- last = $[22];
234
- t10 = $[23];
235
- t6 = $[24];
236
- t7 = $[25];
237
- t8 = $[26];
238
- t9 = $[27];
450
+ lastIndex = $[36];
451
+ plotted = $[37];
452
+ shortLabel = $[38];
453
+ t13 = $[39];
454
+ t14 = $[40];
455
+ t15 = $[41];
456
+ t16 = $[42];
457
+ t17 = $[43];
458
+ t18 = $[44];
459
+ t19 = $[45];
460
+ t20 = $[46];
461
+ t21 = $[47];
462
+ t22 = $[48];
463
+ t23 = $[49];
464
+ t24 = $[50];
465
+ t25 = $[51];
466
+ t26 = $[52];
467
+ t27 = $[53];
468
+ t28 = $[54];
469
+ t29 = $[55];
470
+ t30 = $[56];
471
+ t31 = $[57];
239
472
  }
240
- let t11;
241
- if ($[65] !== t6 || $[66] !== t7 || $[67] !== t8) {
242
- t11 = /* @__PURE__ */ jsxs("div", {
243
- className: t6,
244
- children: [t7, t8]
473
+ let t32;
474
+ if ($[99] !== t13 || $[100] !== t14 || $[101] !== t15 || $[102] !== t16 || $[103] !== t17 || $[104] !== t18 || $[105] !== t19 || $[106] !== t20) {
475
+ t32 = /* @__PURE__ */ jsxs("div", {
476
+ className: t13,
477
+ "aria-hidden": t14,
478
+ children: [
479
+ t15,
480
+ t16,
481
+ t17,
482
+ t18,
483
+ t19,
484
+ t20
485
+ ]
245
486
  });
246
- $[65] = t6;
247
- $[66] = t7;
248
- $[67] = t8;
249
- $[68] = t11;
250
- } else t11 = $[68];
251
- let t12;
252
- if ($[69] !== first || $[70] !== last || $[71] !== points.length) {
253
- t12 = first !== void 0 && last !== void 0 ? /* @__PURE__ */ jsxs("div", {
254
- className: LineChart_module_default.labels,
487
+ $[99] = t13;
488
+ $[100] = t14;
489
+ $[101] = t15;
490
+ $[102] = t16;
491
+ $[103] = t17;
492
+ $[104] = t18;
493
+ $[105] = t19;
494
+ $[106] = t20;
495
+ $[107] = t32;
496
+ } else t32 = $[107];
497
+ let t33;
498
+ if ($[108] !== t21 || $[109] !== t22 || $[110] !== t23 || $[111] !== t24 || $[112] !== t32) {
499
+ t33 = /* @__PURE__ */ jsxs("div", {
500
+ className: t21,
501
+ ...t22,
502
+ children: [
503
+ t23,
504
+ t24,
505
+ t32
506
+ ]
507
+ });
508
+ $[108] = t21;
509
+ $[109] = t22;
510
+ $[110] = t23;
511
+ $[111] = t24;
512
+ $[112] = t32;
513
+ $[113] = t33;
514
+ } else t33 = $[113];
515
+ let t34;
516
+ if ($[114] !== lastIndex || $[115] !== plotted || $[116] !== points || $[117] !== shortLabel) {
517
+ t34 = axisLabelIndices(points.length, MAX_AXIS_LABELS).map((t35) => {
518
+ const { index: index_2, minor } = t35;
519
+ const data_0 = points[index_2];
520
+ const where_0 = plotted[index_2];
521
+ return data_0 !== void 0 && where_0 !== void 0 ? /* @__PURE__ */ jsx("span", {
522
+ className: cx(LineChart_module_default.date, minor && LineChart_module_default.minor),
523
+ "data-edge": points.length === 1 ? void 0 : index_2 === 0 ? "start" : index_2 === lastIndex ? "end" : void 0,
524
+ style: { left: `${where_0.x}%` },
525
+ children: shortLabel(data_0)
526
+ }, index_2) : null;
527
+ });
528
+ $[114] = lastIndex;
529
+ $[115] = plotted;
530
+ $[116] = points;
531
+ $[117] = shortLabel;
532
+ $[118] = t34;
533
+ } else t34 = $[118];
534
+ let t35;
535
+ if ($[119] !== t34) {
536
+ t35 = /* @__PURE__ */ jsx("div", {
537
+ className: LineChart_module_default.dates,
255
538
  "aria-hidden": "true",
256
- children: [/* @__PURE__ */ jsx("span", { children: first.label }), points.length > 1 ? /* @__PURE__ */ jsx("span", { children: last.label }) : null]
257
- }) : null;
258
- $[69] = first;
259
- $[70] = last;
260
- $[71] = points.length;
261
- $[72] = t12;
262
- } else t12 = $[72];
263
- let t13;
264
- if ($[73] !== label) {
265
- t13 = /* @__PURE__ */ jsx("caption", { children: label });
266
- $[73] = label;
267
- $[74] = t13;
268
- } else t13 = $[74];
269
- let t14;
270
- if ($[75] !== format || $[76] !== points) {
271
- let t15;
272
- if ($[78] !== format) {
273
- t15 = (point_2) => /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
539
+ children: t34
540
+ });
541
+ $[119] = t34;
542
+ $[120] = t35;
543
+ } else t35 = $[120];
544
+ let t36;
545
+ if ($[121] !== t25 || $[122] !== t26 || $[123] !== t33 || $[124] !== t35) {
546
+ t36 = /* @__PURE__ */ jsxs("div", {
547
+ className: t25,
548
+ children: [
549
+ t26,
550
+ t33,
551
+ t35
552
+ ]
553
+ });
554
+ $[121] = t25;
555
+ $[122] = t26;
556
+ $[123] = t33;
557
+ $[124] = t35;
558
+ $[125] = t36;
559
+ } else t36 = $[125];
560
+ let t37;
561
+ if ($[126] !== label) {
562
+ t37 = /* @__PURE__ */ jsx("caption", { children: label });
563
+ $[126] = label;
564
+ $[127] = t37;
565
+ } else t37 = $[127];
566
+ let t38;
567
+ if ($[128] !== format || $[129] !== points) {
568
+ let t39;
569
+ if ($[131] !== format) {
570
+ t39 = (data_1, index_3) => /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
274
571
  scope: "row",
275
- children: point_2.label
276
- }), /* @__PURE__ */ jsx("td", { children: format(point_2.value) })] }, point_2.label);
277
- $[78] = format;
278
- $[79] = t15;
279
- } else t15 = $[79];
280
- t14 = points.map(t15);
281
- $[75] = format;
282
- $[76] = points;
283
- $[77] = t14;
284
- } else t14 = $[77];
285
- let t15;
286
- if ($[80] !== t14) {
287
- t15 = /* @__PURE__ */ jsx("tbody", { children: t14 });
288
- $[80] = t14;
289
- $[81] = t15;
290
- } else t15 = $[81];
291
- let t16;
292
- if ($[82] !== t13 || $[83] !== t15) {
293
- t16 = /* @__PURE__ */ jsx("div", {
572
+ children: data_1.label
573
+ }), /* @__PURE__ */ jsx("td", { children: format(data_1.value) })] }, index_3);
574
+ $[131] = format;
575
+ $[132] = t39;
576
+ } else t39 = $[132];
577
+ t38 = points.map(t39);
578
+ $[128] = format;
579
+ $[129] = points;
580
+ $[130] = t38;
581
+ } else t38 = $[130];
582
+ let t39;
583
+ if ($[133] !== t38) {
584
+ t39 = /* @__PURE__ */ jsx("tbody", { children: t38 });
585
+ $[133] = t38;
586
+ $[134] = t39;
587
+ } else t39 = $[134];
588
+ let t40;
589
+ if ($[135] !== t37 || $[136] !== t39) {
590
+ t40 = /* @__PURE__ */ jsx("div", {
294
591
  className: LineChart_module_default.visuallyHidden,
295
- children: /* @__PURE__ */ jsxs("table", { children: [t13, t15] })
592
+ children: /* @__PURE__ */ jsxs("table", { children: [t37, t39] })
296
593
  });
297
- $[82] = t13;
298
- $[83] = t15;
299
- $[84] = t16;
300
- } else t16 = $[84];
301
- let t17;
302
- if ($[85] !== t10 || $[86] !== t11 || $[87] !== t12 || $[88] !== t16 || $[89] !== t9) {
303
- t17 = /* @__PURE__ */ jsxs("figure", {
304
- className: t9,
305
- style: t10,
594
+ $[135] = t37;
595
+ $[136] = t39;
596
+ $[137] = t40;
597
+ } else t40 = $[137];
598
+ let t41;
599
+ if ($[138] !== t27 || $[139] !== t28 || $[140] !== t29 || $[141] !== t30 || $[142] !== t31 || $[143] !== t36 || $[144] !== t40) {
600
+ t41 = /* @__PURE__ */ jsxs("figure", {
601
+ className: t27,
602
+ style: t28,
603
+ "data-axis": t29,
604
+ "data-labels": t30,
306
605
  children: [
307
- t11,
308
- t12,
309
- t16
606
+ t31,
607
+ t36,
608
+ t40
310
609
  ]
311
610
  });
312
- $[85] = t10;
313
- $[86] = t11;
314
- $[87] = t12;
315
- $[88] = t16;
316
- $[89] = t9;
317
- $[90] = t17;
318
- } else t17 = $[90];
319
- return t17;
611
+ $[138] = t27;
612
+ $[139] = t28;
613
+ $[140] = t29;
614
+ $[141] = t30;
615
+ $[142] = t31;
616
+ $[143] = t36;
617
+ $[144] = t40;
618
+ $[145] = t41;
619
+ } else t41 = $[145];
620
+ return t41;
621
+ }
622
+ /** The position of a mark on the plot, and its place along the width, to keep its label inside. */
623
+ function _temp3(widest, text) {
624
+ return text.length > widest.length ? text : widest;
625
+ }
626
+ function _temp2(point_1) {
627
+ return point_1.shortLabel ?? point_1.label;
320
628
  }
321
629
  function _temp(point) {
322
630
  return point.value;
323
631
  }
632
+ function positionOf(where) {
633
+ return {
634
+ left: `${where.x}%`,
635
+ top: `${where.y}%`,
636
+ "--_x": where.x
637
+ };
638
+ }
324
639
  //#endregion
325
640
  export { LineChart };
326
641