@asanchez-sa/abby 0.2.0 → 0.4.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.
Files changed (65) hide show
  1. package/dist/components/alert/alert.d.ts +1 -1
  2. package/dist/components/alert/alert.js +2 -1
  3. package/dist/components/alert-dialog/alert-dialog.d.ts +10 -1
  4. package/dist/components/alert-dialog/alert-dialog.js +80 -3
  5. package/dist/components/badge/badge.d.ts +3 -2
  6. package/dist/components/badge/badge.js +27 -11
  7. package/dist/components/button/button.d.ts +1 -1
  8. package/dist/components/button/button.js +3 -2
  9. package/dist/components/calendar/calendar.d.ts +26 -5
  10. package/dist/components/calendar/calendar.js +387 -72
  11. package/dist/components/chart/chart.d.ts +76 -0
  12. package/dist/components/chart/chart.js +565 -0
  13. package/dist/components/chart/parts/axes.js +126 -0
  14. package/dist/components/chart/parts/frame.d.ts +31 -0
  15. package/dist/components/chart/parts/frame.js +278 -0
  16. package/dist/components/chart/parts/legend.d.ts +16 -0
  17. package/dist/components/chart/parts/legend.js +82 -0
  18. package/dist/components/chart/parts/points.d.ts +1 -0
  19. package/dist/components/chart/parts/points.js +139 -0
  20. package/dist/components/chart/parts/scale.js +139 -0
  21. package/dist/components/chart/parts/table.js +105 -0
  22. package/dist/components/chart/parts/types.d.ts +44 -0
  23. package/dist/components/chart/parts/types.js +8 -0
  24. package/dist/components/dialog/dialog.d.ts +9 -1
  25. package/dist/components/dialog/dialog.js +82 -3
  26. package/dist/components/field/field.d.ts +5 -1
  27. package/dist/components/field/field.js +25 -21
  28. package/dist/components/filter-chip/filter-chip.d.ts +36 -0
  29. package/dist/components/filter-chip/filter-chip.js +97 -0
  30. package/dist/components/graph/graph.d.ts +151 -0
  31. package/dist/components/graph/graph.js +959 -0
  32. package/dist/components/input/input.d.ts +8 -1
  33. package/dist/components/input/input.js +2 -2
  34. package/dist/components/meter/meter.d.ts +52 -3
  35. package/dist/components/meter/meter.js +535 -33
  36. package/dist/components/model-selector/model-selector.d.ts +38 -3
  37. package/dist/components/model-selector/model-selector.js +331 -73
  38. package/dist/components/note-editor/parts/suggestions.js +2 -2
  39. package/dist/components/number-input/number-input.d.ts +14 -3
  40. package/dist/components/number-input/number-input.js +193 -34
  41. package/dist/components/otp-input/otp-input.d.ts +6 -2
  42. package/dist/components/otp-input/otp-input.js +40 -20
  43. package/dist/components/sheet/sheet.js +1 -1
  44. package/dist/components/spinner/spinner.d.ts +7 -1
  45. package/dist/components/spinner/spinner.js +86 -26
  46. package/dist/components/switch/switch.d.ts +9 -2
  47. package/dist/components/switch/switch.js +23 -17
  48. package/dist/components/toast/toast.d.ts +19 -2
  49. package/dist/components/toast/toast.js +211 -49
  50. package/dist/components/toggle/toggle.d.ts +18 -4
  51. package/dist/components/toggle/toggle.js +167 -32
  52. package/dist/components/week-strip/week-strip.d.ts +27 -5
  53. package/dist/components/week-strip/week-strip.js +288 -134
  54. package/package.json +4 -1
  55. package/skills/agent-ready-ui/SKILL.md +1 -1
  56. package/skills/blocks/SKILL.md +1 -1
  57. package/skills/compose-screens/SKILL.md +97 -10
  58. package/skills/compose-screens/references/calendar-week.md +77 -0
  59. package/skills/compose-screens/references/charts-and-maps.md +183 -0
  60. package/skills/compose-screens/references/filter-chips.md +61 -0
  61. package/skills/compose-screens/references/number-units.md +52 -0
  62. package/skills/note-editor/SKILL.md +1 -1
  63. package/skills/note-status/SKILL.md +1 -1
  64. package/skills/setup/SKILL.md +1 -1
  65. package/skills/theming/SKILL.md +1 -1
@@ -0,0 +1,565 @@
1
+ "use client";
2
+ import { cn } from "../../utilities/cn/index.js";
3
+ import { ChartPoint, useRovingPoints } from "./parts/points.js";
4
+ import { ChartFrame } from "./parts/frame.js";
5
+ import { rowId, seriesColor, stackTotal, tintOf } from "./parts/scale.js";
6
+ import { defaultTexts } from "./parts/types.js";
7
+ import { ChartLegend } from "./parts/legend.js";
8
+ import { c } from "react/compiler-runtime";
9
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
+ // src/components/chart/chart.tsx
11
+ /** Alma's bar: it fills 72% of its column when it's alone in it. */
12
+ const lone = .72;
13
+ const shared = .86;
14
+ /** A stacked bar is narrower: about a third of its column, as in Paper. */
15
+ const stackedFill = .32;
16
+ /** The air between two segments of a stack. */
17
+ const segmentGap = 2;
18
+ /** Room for a total over the tallest bar: 6px of air and a 16px line. */
19
+ const totalRoom = 22;
20
+ /** The bar's own look: the full color, its faint tint, or a forecast's outline. */
21
+ function barLook(series, color, faint, empty) {
22
+ if (empty) return { fill: "var(--border)" };
23
+ if (series.variant === "forecast") return {
24
+ fill: tintOf(color),
25
+ stroke: color,
26
+ strokeDasharray: "3 3",
27
+ strokeWidth: 1
28
+ };
29
+ return { fill: faint ? tintOf(color) : color };
30
+ }
31
+ /**
32
+ * Bars by day or by week: one column per category, one bar per series in it,
33
+ * in the order of `series`. `highlight` names the current category (today, this
34
+ * week): its bars take the full color and the rest their faint tint. A series
35
+ * with `variant: "forecast"` is drawn as an outline in the column of the first
36
+ * series.
37
+ *
38
+ * Each bar is an image named "category: value" that shows the same text in a
39
+ * tooltip on hover and focus; the chart is one tab stop and the arrows move
40
+ * between bars. A table for a screen reader holds all the values. The chart's
41
+ * name (`aria-label` or `aria-labelledby`) is required.
42
+ */
43
+ function BarChart(t0) {
44
+ const $ = c(39);
45
+ let data;
46
+ let highlight;
47
+ let note;
48
+ let props;
49
+ let series;
50
+ let t1;
51
+ let t2;
52
+ if ($[0] !== t0) {
53
+ ({series, data, highlight, stacked: t1, totals: t2, note, ...props} = t0);
54
+ $[0] = t0;
55
+ $[1] = data;
56
+ $[2] = highlight;
57
+ $[3] = note;
58
+ $[4] = props;
59
+ $[5] = series;
60
+ $[6] = t1;
61
+ $[7] = t2;
62
+ } else {
63
+ data = $[1];
64
+ highlight = $[2];
65
+ note = $[3];
66
+ props = $[4];
67
+ series = $[5];
68
+ t1 = $[6];
69
+ t2 = $[7];
70
+ }
71
+ const stacked = t1 === void 0 ? false : t1;
72
+ const totals = t2 === void 0 ? false : t2;
73
+ const stack = stacked && series.length > 1;
74
+ let columns;
75
+ let marks;
76
+ let t3;
77
+ if ($[8] !== data || $[9] !== series || $[10] !== stack) {
78
+ const solid = series.filter(_temp);
79
+ columns = stack ? 1 : Math.max(1, solid.length);
80
+ marks = data.flatMap((row, category) => series.flatMap((each_0, index) => {
81
+ const value = row.values[each_0.key];
82
+ if (typeof value !== "number" || !Number.isFinite(value)) return [];
83
+ return [{
84
+ row,
85
+ category,
86
+ series: each_0,
87
+ index,
88
+ value,
89
+ column: each_0.variant === "forecast" ? 0 : solid.indexOf(each_0)
90
+ }];
91
+ }));
92
+ t3 = Array.from(new Set(marks.map(_temp2)));
93
+ $[8] = data;
94
+ $[9] = series;
95
+ $[10] = stack;
96
+ $[11] = columns;
97
+ $[12] = marks;
98
+ $[13] = t3;
99
+ } else {
100
+ columns = $[11];
101
+ marks = $[12];
102
+ t3 = $[13];
103
+ }
104
+ const stacks = t3;
105
+ const roving = useRovingPoints(stack ? stacks.length : marks.length);
106
+ let t4;
107
+ if ($[14] !== data || $[15] !== highlight) {
108
+ t4 = highlight !== void 0 && data.some((row_0) => rowId(row_0) === highlight);
109
+ $[14] = data;
110
+ $[15] = highlight;
111
+ $[16] = t4;
112
+ } else t4 = $[16];
113
+ const highlighted = t4;
114
+ const t5 = totals ? totalRoom : 0;
115
+ let t6;
116
+ if ($[17] !== columns || $[18] !== data || $[19] !== highlighted || $[20] !== marks || $[21] !== note || $[22] !== props || $[23] !== roving.active || $[24] !== roving.onKeyDown || $[25] !== roving.setChosen || $[26] !== series || $[27] !== stack || $[28] !== stacks || $[29] !== totals) {
117
+ t6 = (t7) => {
118
+ const { plot, tooltip, text, highlighted: current } = t7;
119
+ const slot = 1 / data.length / columns;
120
+ const barWidth = slot * (stack ? stackedFill : columns > 1 ? shared : lone);
121
+ const inset = (slot - barWidth) / 2;
122
+ const tops = /* @__PURE__ */ new Map();
123
+ const reach = (category_0, top, middle) => {
124
+ const left = category_0 / data.length + inset;
125
+ const known = tops.get(category_0);
126
+ if (!known || top > known.top) tops.set(category_0, {
127
+ top,
128
+ middle,
129
+ left
130
+ });
131
+ };
132
+ const drawn = stack ? stacks.map((category_1, position) => {
133
+ const row_1 = data[category_1];
134
+ const start = category_1 / data.length;
135
+ let cumulative = 0;
136
+ let shown = 0;
137
+ const segments = [];
138
+ const parts = [];
139
+ series.forEach((each_1, index_0) => {
140
+ const value_0 = row_1.values[each_1.key];
141
+ if (typeof value_0 !== "number" || !Number.isFinite(value_0)) return;
142
+ parts.push(`${each_1.name}: ${text(value_0)}`);
143
+ if (value_0 <= 0) return;
144
+ const bottom = plot.baseline - plot.rise(cumulative) - shown * segmentGap;
145
+ cumulative = cumulative + value_0;
146
+ const height = plot.rise(cumulative) - plot.rise(cumulative - value_0);
147
+ const y = bottom - height;
148
+ segments.push(/* @__PURE__ */ jsx("rect", {
149
+ "aria-hidden": "true",
150
+ x: `${(start + inset) * 100}%`,
151
+ width: `${barWidth * 100}%`,
152
+ y,
153
+ height,
154
+ rx: Math.min(2, height / 2),
155
+ className: "pointer-events-none",
156
+ style: barLook(each_1, seriesColor(each_1, index_0), false, false)
157
+ }, each_1.key));
158
+ reach(category_1, plot.baseline - y, plot.baseline - y - height / 2);
159
+ shown = shown + 1;
160
+ });
161
+ const total = stackTotal(row_1, series);
162
+ if (total <= 0) {
163
+ segments.push(/* @__PURE__ */ jsx("rect", {
164
+ "aria-hidden": "true",
165
+ x: `${(start + inset) * 100}%`,
166
+ width: `${barWidth * 100}%`,
167
+ y: plot.baseline - 4,
168
+ height: 4,
169
+ rx: 2,
170
+ className: "pointer-events-none",
171
+ style: barLook(series[0], "", false, true)
172
+ }, "empty"));
173
+ reach(category_1, 4, 2);
174
+ }
175
+ const name = [
176
+ row_1.label,
177
+ ...parts,
178
+ `${props.totalHeader ?? defaultTexts.totalHeader}: ${text(total)}`
179
+ ];
180
+ return /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx(ChartPoint, {
181
+ controller: tooltip,
182
+ index: position,
183
+ active: roving.active,
184
+ onActivate: roving.setChosen,
185
+ label: name.join(", "),
186
+ x: `${start * 100}%`,
187
+ width: `${slot * 100}%`,
188
+ height: plot.height
189
+ }), segments] }, category_1);
190
+ }) : marks.map((mark_0, position_0) => {
191
+ const start_0 = mark_0.category / data.length + mark_0.column * slot;
192
+ const rise = plot.rise(mark_0.value);
193
+ const height_0 = Math.max(rise, 4);
194
+ const color = seriesColor(mark_0.series, mark_0.index);
195
+ const name_0 = columns > 1 || series.length > 1 ? `${mark_0.row.label}, ${mark_0.series.name}: ${text(mark_0.value)}` : `${mark_0.row.label}: ${text(mark_0.value)}`;
196
+ reach(mark_0.category, height_0, height_0 / 2);
197
+ return /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx(ChartPoint, {
198
+ controller: tooltip,
199
+ index: position_0,
200
+ active: roving.active,
201
+ onActivate: roving.setChosen,
202
+ label: name_0,
203
+ x: `${start_0 * 100}%`,
204
+ width: `${slot * 100}%`,
205
+ height: plot.height
206
+ }), /* @__PURE__ */ jsx("rect", {
207
+ "aria-hidden": "true",
208
+ x: `${(start_0 + inset) * 100}%`,
209
+ width: `${barWidth * 100}%`,
210
+ y: plot.baseline - height_0,
211
+ height: height_0,
212
+ rx: Math.min(6, height_0 / 2),
213
+ className: "pointer-events-none",
214
+ style: barLook(mark_0.series, color, highlighted && mark_0.category !== current, mark_0.value <= 0)
215
+ })] }, `${mark_0.category}-${mark_0.series.key}`);
216
+ });
217
+ const noted = note ? data.findIndex((row_2) => rowId(row_2) === note.category) : -1;
218
+ const noteAt = tops.get(noted);
219
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
220
+ /* @__PURE__ */ jsx("g", {
221
+ onKeyDown: roving.onKeyDown,
222
+ children: drawn
223
+ }),
224
+ totals ? /* @__PURE__ */ jsx("g", {
225
+ "aria-hidden": "true",
226
+ "data-slot": "chart-totals",
227
+ children: data.map((row_3, category_2) => {
228
+ const at = tops.get(category_2);
229
+ if (!at) return null;
230
+ return /* @__PURE__ */ jsx("text", {
231
+ x: `${(category_2 + .5) / data.length * 100}%`,
232
+ y: plot.baseline - at.top - 6,
233
+ textAnchor: "middle",
234
+ className: cn("fill-foreground text-supporting tabular-nums", category_2 === current ? "font-semibold" : "font-medium"),
235
+ children: text(stackTotal(row_3, series))
236
+ }, category_2);
237
+ })
238
+ }) : null,
239
+ note && noteAt ? /* @__PURE__ */ jsx("text", {
240
+ "aria-hidden": "true",
241
+ "data-slot": "chart-note",
242
+ x: `${noteAt.left * 100}%`,
243
+ dx: -8,
244
+ y: plot.baseline - noteAt.middle,
245
+ dominantBaseline: "central",
246
+ textAnchor: "end",
247
+ className: "text-supporting font-medium",
248
+ style: { fill: note.color ? seriesColor({
249
+ key: "",
250
+ name: "",
251
+ color: note.color
252
+ }, 0) : "var(--muted-foreground)" },
253
+ children: note.text
254
+ }) : null
255
+ ] });
256
+ };
257
+ $[17] = columns;
258
+ $[18] = data;
259
+ $[19] = highlighted;
260
+ $[20] = marks;
261
+ $[21] = note;
262
+ $[22] = props;
263
+ $[23] = roving.active;
264
+ $[24] = roving.onKeyDown;
265
+ $[25] = roving.setChosen;
266
+ $[26] = series;
267
+ $[27] = stack;
268
+ $[28] = stacks;
269
+ $[29] = totals;
270
+ $[30] = t6;
271
+ } else t6 = $[30];
272
+ let t7;
273
+ if ($[31] !== data || $[32] !== highlight || $[33] !== props || $[34] !== series || $[35] !== stack || $[36] !== t5 || $[37] !== t6) {
274
+ t7 = /* @__PURE__ */ jsx(ChartFrame, {
275
+ data,
276
+ series,
277
+ highlight,
278
+ stack,
279
+ room: t5,
280
+ ...props,
281
+ children: t6
282
+ });
283
+ $[31] = data;
284
+ $[32] = highlight;
285
+ $[33] = props;
286
+ $[34] = series;
287
+ $[35] = stack;
288
+ $[36] = t5;
289
+ $[37] = t6;
290
+ $[38] = t7;
291
+ } else t7 = $[38];
292
+ return t7;
293
+ }
294
+ function _temp2(mark) {
295
+ return mark.category;
296
+ }
297
+ function _temp(each) {
298
+ return each.variant !== "forecast";
299
+ }
300
+ /** The dot at the end of a line, and the first one. Alma's: 4px with a ring, 3px. */
301
+ const lastDot = 4;
302
+ const firstDot = 3;
303
+ /** Room above the line for the value over a marked point: 4px of air and a 12px line. */
304
+ const valueRoom = 18;
305
+ /** A point's value sits this far over its dot. */
306
+ const valueLift = 11;
307
+ /** What a small chart keeps above and under its line, as in Paper's cards. */
308
+ const smallInset = {
309
+ room: 5,
310
+ bottom: 7
311
+ };
312
+ /** The gap between a small chart's last dot and its value. */
313
+ const valueGap = 10;
314
+ /**
315
+ * A trend by day or by week: one line over one series, one point per
316
+ * category. `mark` dots the first and last points and writes their values;
317
+ * `references` draws lines to compare against; `size="sm"` is the small chart
318
+ * for a grid of them, which get the same scale from `domain`. A missing value
319
+ * breaks the line.
320
+ *
321
+ * Like `BarChart`, each point is an image named "category: value" with the
322
+ * same text in a tooltip on hover and focus, the chart is one tab stop and the
323
+ * arrows move between points, and a table holds all the values. The chart's
324
+ * name (`aria-label` or `aria-labelledby`) is required. Only the first series
325
+ * is drawn: a chart has one line.
326
+ */
327
+ function LineChart(t0) {
328
+ const $ = c(41);
329
+ let data;
330
+ let domain;
331
+ let height;
332
+ let highlight;
333
+ let props;
334
+ let series;
335
+ let t1;
336
+ let t2;
337
+ let t3;
338
+ if ($[0] !== t0) {
339
+ ({series, data, highlight, mark: t1, references: t2, size: t3, domain, height, ...props} = t0);
340
+ $[0] = t0;
341
+ $[1] = data;
342
+ $[2] = domain;
343
+ $[3] = height;
344
+ $[4] = highlight;
345
+ $[5] = props;
346
+ $[6] = series;
347
+ $[7] = t1;
348
+ $[8] = t2;
349
+ $[9] = t3;
350
+ } else {
351
+ data = $[1];
352
+ domain = $[2];
353
+ height = $[3];
354
+ highlight = $[4];
355
+ props = $[5];
356
+ series = $[6];
357
+ t1 = $[7];
358
+ t2 = $[8];
359
+ t3 = $[9];
360
+ }
361
+ const mark = t1 === void 0 ? "ends" : t1;
362
+ let t4;
363
+ if ($[10] !== t2) {
364
+ t4 = t2 === void 0 ? [] : t2;
365
+ $[10] = t2;
366
+ $[11] = t4;
367
+ } else t4 = $[11];
368
+ const references = t4;
369
+ const small = (t3 === void 0 ? "default" : t3) === "sm";
370
+ let line;
371
+ let t5;
372
+ if ($[12] !== series) {
373
+ line = series.slice(0, 1);
374
+ t5 = line[0] ? seriesColor(line[0], 0) : "var(--foreground)";
375
+ $[12] = series;
376
+ $[13] = line;
377
+ $[14] = t5;
378
+ } else {
379
+ line = $[13];
380
+ t5 = $[14];
381
+ }
382
+ const color = t5;
383
+ let t6;
384
+ if ($[15] !== data || $[16] !== line) {
385
+ let t7;
386
+ if ($[18] !== line) {
387
+ t7 = (row, category) => {
388
+ const value = line[0] ? row.values[line[0].key] : void 0;
389
+ return typeof value === "number" && Number.isFinite(value) ? [{
390
+ row,
391
+ category,
392
+ value
393
+ }] : [];
394
+ };
395
+ $[18] = line;
396
+ $[19] = t7;
397
+ } else t7 = $[19];
398
+ t6 = data.flatMap(t7);
399
+ $[15] = data;
400
+ $[16] = line;
401
+ $[17] = t6;
402
+ } else t6 = $[17];
403
+ const points = t6;
404
+ const roving = useRovingPoints(points.length);
405
+ const t7 = highlight !== void 0 && data.some((row_0) => rowId(row_0) === highlight) ? highlight : void 0;
406
+ const t8 = height ?? (small ? 96 : 120);
407
+ const t9 = small ? smallInset.room : mark ? valueRoom : 0;
408
+ const t10 = small ? smallInset.bottom : 7;
409
+ const t11 = small ? false : props.yAxis;
410
+ const t12 = small ? false : props.xAxis;
411
+ const t13 = small ? false : props.grid;
412
+ let t14;
413
+ if ($[20] !== color || $[21] !== data.length || $[22] !== mark || $[23] !== points || $[24] !== references || $[25] !== roving || $[26] !== small) {
414
+ t14 = (t15) => {
415
+ const { plot, tooltip, text, width } = t15;
416
+ const count = data.length;
417
+ const first = points[0];
418
+ const last = points[points.length - 1];
419
+ const lastText = last ? text(last.value) : "";
420
+ const room = small && last ? lastText.length * 7 + valueGap + 4 : 0;
421
+ const span = Math.max(0, width - room);
422
+ const edge = 5;
423
+ const xOf = (category_0) => Math.min(Math.max(edge, span - edge), Math.max(edge, (category_0 + .5) / count * span));
424
+ const yOf = (value_0) => plot.baseline - plot.rise(value_0);
425
+ const slot = (category_1) => width > 0 ? `${category_1 / count * span}` : `${category_1 / count * 100}%`;
426
+ const slotWidth = width > 0 ? `${span / count}` : `${100 / count}%`;
427
+ const runs = [];
428
+ for (const point of points) {
429
+ const run = runs[runs.length - 1];
430
+ const before = run?.[run.length - 1];
431
+ if (run && before && before.category === point.category - 1) run.push(point);
432
+ else runs.push([point]);
433
+ }
434
+ const marked = [...!small && mark === "ends" && first && first !== last ? [first] : [], ...last ? [last] : []];
435
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
436
+ /* @__PURE__ */ jsx("g", {
437
+ "aria-hidden": "true",
438
+ "data-slot": "chart-references",
439
+ children: references.map((reference, index) => {
440
+ const y = yOf(reference.value);
441
+ const label = reference.label ?? text(reference.value);
442
+ const start = Math.max(28, label.length * 7 + 6);
443
+ return /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
444
+ x1: start,
445
+ x2: "100%",
446
+ y1: y + .5,
447
+ y2: y + .5,
448
+ shapeRendering: "crispEdges",
449
+ className: reference.color ? void 0 : "stroke-border",
450
+ style: reference.color ? { stroke: seriesColor({
451
+ key: "",
452
+ name: "",
453
+ color: reference.color
454
+ }, 0) } : void 0
455
+ }), /* @__PURE__ */ jsx("text", {
456
+ x: 0,
457
+ y: y + .5,
458
+ dominantBaseline: "central",
459
+ className: "fill-subtle text-supporting tabular-nums",
460
+ children: label
461
+ })] }, index);
462
+ })
463
+ }),
464
+ /* @__PURE__ */ jsx("g", {
465
+ onKeyDown: roving.onKeyDown,
466
+ children: points.map((point_0, position) => /* @__PURE__ */ jsx(ChartPoint, {
467
+ controller: tooltip,
468
+ index: position,
469
+ active: roving.active,
470
+ onActivate: roving.setChosen,
471
+ label: `${point_0.row.label}: ${text(point_0.value)}`,
472
+ x: slot(point_0.category),
473
+ width: slotWidth,
474
+ height: plot.height
475
+ }, point_0.category))
476
+ }),
477
+ width > 0 ? /* @__PURE__ */ jsxs("g", {
478
+ "aria-hidden": "true",
479
+ className: "pointer-events-none",
480
+ "data-slot": "chart-line",
481
+ children: [runs.map((run_0) => run_0.length > 1 ? /* @__PURE__ */ jsx("polyline", {
482
+ points: run_0.map((p) => `${xOf(p.category)},${yOf(p.value)}`).join(" "),
483
+ fill: "none",
484
+ strokeWidth: 2,
485
+ strokeLinecap: "round",
486
+ strokeLinejoin: "round",
487
+ style: { stroke: color }
488
+ }, run_0[0]?.category) : /* @__PURE__ */ jsx("circle", {
489
+ cx: xOf(run_0[0]?.category ?? 0),
490
+ cy: yOf(run_0[0]?.value ?? 0),
491
+ r: 1,
492
+ style: { fill: color }
493
+ }, run_0[0]?.category)), marked.map((point_1) => {
494
+ const isLast = point_1 === last;
495
+ const x = xOf(point_1.category);
496
+ const y_0 = yOf(point_1.value);
497
+ return /* @__PURE__ */ jsxs("g", {
498
+ "data-slot": isLast ? "chart-last" : "chart-first",
499
+ children: [/* @__PURE__ */ jsx("circle", {
500
+ cx: x,
501
+ cy: y_0,
502
+ r: isLast ? lastDot : firstDot,
503
+ strokeWidth: isLast ? 2 : 0,
504
+ className: "stroke-background",
505
+ style: { fill: color }
506
+ }), small ? /* @__PURE__ */ jsx("text", {
507
+ x: x + valueGap,
508
+ y: y_0,
509
+ dominantBaseline: "central",
510
+ className: "fill-foreground text-supporting tabular-nums",
511
+ children: text(point_1.value)
512
+ }) : /* @__PURE__ */ jsx("text", {
513
+ x,
514
+ y: y_0 - valueLift,
515
+ textAnchor: !isLast && x < 16 ? "start" : isLast && x > width - 16 ? "end" : "middle",
516
+ className: cn("text-supporting tabular-nums", isLast ? "fill-foreground font-semibold" : "fill-muted-foreground"),
517
+ children: text(point_1.value)
518
+ })]
519
+ }, point_1.category);
520
+ })]
521
+ }) : null
522
+ ] });
523
+ };
524
+ $[20] = color;
525
+ $[21] = data.length;
526
+ $[22] = mark;
527
+ $[23] = points;
528
+ $[24] = references;
529
+ $[25] = roving;
530
+ $[26] = small;
531
+ $[27] = t14;
532
+ } else t14 = $[27];
533
+ let t15;
534
+ if ($[28] !== data || $[29] !== domain || $[30] !== line || $[31] !== props || $[32] !== t10 || $[33] !== t11 || $[34] !== t12 || $[35] !== t13 || $[36] !== t14 || $[37] !== t7 || $[38] !== t8 || $[39] !== t9) {
535
+ t15 = /* @__PURE__ */ jsx(ChartFrame, {
536
+ data,
537
+ series: line,
538
+ highlight: t7,
539
+ height: t8,
540
+ domain,
541
+ room: t9,
542
+ bottom: t10,
543
+ ...props,
544
+ yAxis: t11,
545
+ xAxis: t12,
546
+ grid: t13,
547
+ children: t14
548
+ });
549
+ $[28] = data;
550
+ $[29] = domain;
551
+ $[30] = line;
552
+ $[31] = props;
553
+ $[32] = t10;
554
+ $[33] = t11;
555
+ $[34] = t12;
556
+ $[35] = t13;
557
+ $[36] = t14;
558
+ $[37] = t7;
559
+ $[38] = t8;
560
+ $[39] = t9;
561
+ $[40] = t15;
562
+ } else t15 = $[40];
563
+ return t15;
564
+ }
565
+ export { BarChart, ChartLegend, LineChart };
@@ -0,0 +1,126 @@
1
+ "use client";
2
+ import { c } from "react/compiler-runtime";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/chart/parts/axes.tsx
5
+ /** The horizontal lines at each tick, drawn inside the plot's SVG. */
6
+ function ChartGrid(t0) {
7
+ const $ = c(4);
8
+ const { plot } = t0;
9
+ let t1;
10
+ if ($[0] !== plot) {
11
+ t1 = plot.ticks.map((tick) => {
12
+ const y = plot.baseline - plot.rise(tick);
13
+ return /* @__PURE__ */ jsx("line", {
14
+ x1: "0",
15
+ x2: "100%",
16
+ y1: y + .5,
17
+ y2: y + .5
18
+ }, tick);
19
+ });
20
+ $[0] = plot;
21
+ $[1] = t1;
22
+ } else t1 = $[1];
23
+ let t2;
24
+ if ($[2] !== t1) {
25
+ t2 = /* @__PURE__ */ jsx("g", {
26
+ "aria-hidden": "true",
27
+ className: "stroke-border",
28
+ shapeRendering: "crispEdges",
29
+ children: t1
30
+ });
31
+ $[2] = t1;
32
+ $[3] = t2;
33
+ } else t2 = $[3];
34
+ return t2;
35
+ }
36
+ /** The value of each tick, in a column to the left of the plot. */
37
+ function ChartYAxis(t0) {
38
+ const $ = c(12);
39
+ const { plot, format } = t0;
40
+ const t1 = plot.top + .5;
41
+ const t2 = plot.height - plot.baseline - .5;
42
+ let t3;
43
+ if ($[0] !== plot.height || $[1] !== t1 || $[2] !== t2) {
44
+ t3 = {
45
+ height: plot.height,
46
+ paddingTop: t1,
47
+ paddingBottom: t2
48
+ };
49
+ $[0] = plot.height;
50
+ $[1] = t1;
51
+ $[2] = t2;
52
+ $[3] = t3;
53
+ } else t3 = $[3];
54
+ let t4;
55
+ if ($[4] !== format || $[5] !== plot.ticks) {
56
+ let t5;
57
+ if ($[7] !== format) {
58
+ t5 = (tick) => /* @__PURE__ */ jsx("div", {
59
+ className: "flex h-0 items-center justify-end whitespace-nowrap",
60
+ children: format(tick)
61
+ }, tick);
62
+ $[7] = format;
63
+ $[8] = t5;
64
+ } else t5 = $[8];
65
+ t4 = plot.ticks.map(t5);
66
+ $[4] = format;
67
+ $[5] = plot.ticks;
68
+ $[6] = t4;
69
+ } else t4 = $[6];
70
+ let t5;
71
+ if ($[9] !== t3 || $[10] !== t4) {
72
+ t5 = /* @__PURE__ */ jsx("div", {
73
+ "aria-hidden": "true",
74
+ "data-slot": "chart-y-axis",
75
+ className: "flex flex-col-reverse justify-between pe-2 text-supporting text-subtle tabular-nums",
76
+ style: t3,
77
+ children: t4
78
+ });
79
+ $[9] = t3;
80
+ $[10] = t4;
81
+ $[11] = t5;
82
+ } else t5 = $[11];
83
+ return t5;
84
+ }
85
+ /**
86
+ * The category labels under the plot, each centered under its column. `shown`
87
+ * says which categories have one, and `highlighted` which one is the current.
88
+ */
89
+ function ChartXAxis(t0) {
90
+ const $ = c(11);
91
+ const { labels, count, shown, highlighted } = t0;
92
+ let t1;
93
+ if ($[0] !== count || $[1] !== highlighted || $[2] !== labels || $[3] !== shown) {
94
+ let t2;
95
+ if ($[5] !== count || $[6] !== highlighted || $[7] !== labels) {
96
+ t2 = (index) => /* @__PURE__ */ jsx("div", {
97
+ className: index === highlighted ? "absolute top-0 -translate-x-1/2 text-supporting font-medium whitespace-nowrap text-foreground" : "absolute top-0 -translate-x-1/2 text-supporting whitespace-nowrap text-subtle",
98
+ style: { left: `${(index + .5) / count * 100}%` },
99
+ children: labels[index]
100
+ }, index);
101
+ $[5] = count;
102
+ $[6] = highlighted;
103
+ $[7] = labels;
104
+ $[8] = t2;
105
+ } else t2 = $[8];
106
+ t1 = shown.map(t2);
107
+ $[0] = count;
108
+ $[1] = highlighted;
109
+ $[2] = labels;
110
+ $[3] = shown;
111
+ $[4] = t1;
112
+ } else t1 = $[4];
113
+ let t2;
114
+ if ($[9] !== t1) {
115
+ t2 = /* @__PURE__ */ jsx("div", {
116
+ "aria-hidden": "true",
117
+ "data-slot": "chart-x-axis",
118
+ className: "relative h-4",
119
+ children: t1
120
+ });
121
+ $[9] = t1;
122
+ $[10] = t2;
123
+ } else t2 = $[10];
124
+ return t2;
125
+ }
126
+ export { ChartGrid, ChartXAxis, ChartYAxis };