@six-vallees/ui-react 0.1.1 → 0.2.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 (53) hide show
  1. package/dist/charts/area-chart.d.ts +7 -2
  2. package/dist/charts/area-chart.js +3 -2
  3. package/dist/charts/bar-chart.js +2 -2
  4. package/dist/charts/lib/path.d.ts +9 -1
  5. package/dist/charts/lib/path.js +5 -1
  6. package/dist/charts/lib/series.d.ts +14 -1
  7. package/dist/charts/lib/series.js +7 -3
  8. package/dist/charts/ring.d.ts +2 -1
  9. package/dist/charts/ring.js +2 -2
  10. package/dist/charts/segmented-bar.js +2 -2
  11. package/dist/charts/sparkline.d.ts +13 -2
  12. package/dist/charts/sparkline.js +3 -2
  13. package/dist/charts/stat.js +1 -1
  14. package/dist/chunk-27MWE4F5.js +24 -0
  15. package/dist/chunk-27MWE4F5.js.map +1 -0
  16. package/dist/{chunk-YSUYAW4O.js → chunk-5DZPPT7X.js} +6 -2
  17. package/dist/chunk-5DZPPT7X.js.map +1 -0
  18. package/dist/chunk-64YDZRCU.js +45 -0
  19. package/dist/chunk-64YDZRCU.js.map +1 -0
  20. package/dist/{chunk-NYHHTSX4.js → chunk-AOULEGMT.js} +10 -1
  21. package/dist/chunk-AOULEGMT.js.map +1 -0
  22. package/dist/{chunk-35UH66I7.js → chunk-IVQKYAL6.js} +5 -3
  23. package/dist/chunk-IVQKYAL6.js.map +1 -0
  24. package/dist/{chunk-SC5A4Q7G.js → chunk-L62UZTWJ.js} +23 -15
  25. package/dist/chunk-L62UZTWJ.js.map +1 -0
  26. package/dist/{chunk-UM6DTEFE.js → chunk-OY6MO6QQ.js} +25 -11
  27. package/dist/chunk-OY6MO6QQ.js.map +1 -0
  28. package/dist/chunk-PJRCDPG5.js +89 -0
  29. package/dist/chunk-PJRCDPG5.js.map +1 -0
  30. package/dist/{chunk-LKIXZUNS.js → chunk-QZYA5GS2.js} +5 -3
  31. package/dist/chunk-QZYA5GS2.js.map +1 -0
  32. package/dist/{chunk-YE4P3T6M.js → chunk-X3LG535W.js} +5 -4
  33. package/dist/chunk-X3LG535W.js.map +1 -0
  34. package/dist/index.d.ts +1 -1
  35. package/dist/index.js +18 -14
  36. package/dist/logo/logo-mark.d.ts +1 -4
  37. package/dist/logo/logo-mark.js +1 -1
  38. package/dist/logo/logo.d.ts +1 -4
  39. package/dist/logo/logo.js +1 -1
  40. package/package.json +1 -1
  41. package/dist/chunk-35UH66I7.js.map +0 -1
  42. package/dist/chunk-GD6IYLWY.js +0 -30
  43. package/dist/chunk-GD6IYLWY.js.map +0 -1
  44. package/dist/chunk-LKIXZUNS.js.map +0 -1
  45. package/dist/chunk-NYHHTSX4.js.map +0 -1
  46. package/dist/chunk-RV75OH74.js +0 -81
  47. package/dist/chunk-RV75OH74.js.map +0 -1
  48. package/dist/chunk-SC5A4Q7G.js.map +0 -1
  49. package/dist/chunk-T7ESUAJU.js +0 -14
  50. package/dist/chunk-T7ESUAJU.js.map +0 -1
  51. package/dist/chunk-UM6DTEFE.js.map +0 -1
  52. package/dist/chunk-YE4P3T6M.js.map +0 -1
  53. package/dist/chunk-YSUYAW4O.js.map +0 -1
@@ -10,16 +10,21 @@ interface AreaChartProps {
10
10
  /** Index of the point to mark with a guideline + callout. */
11
11
  markerIndex?: number;
12
12
  markerLabel?: string;
13
+ /** Mono tone of the line/fill: `ink` (default), `muted`, or `accent`. From `sys.chart.*`. */
14
+ tone?: 'ink' | 'muted' | 'accent';
15
+ /** Explicit colour (a token / CSS colour), overrides `tone`. */
16
+ color?: string;
13
17
  className?: string;
14
18
  }
15
19
  /**
16
- * Cairn AreaChart, a smooth line with a flat fill. Colour follows `currentColor`.
20
+ * Cairn AreaChart, a smooth line with a flat fill. Grayscale-first: colour comes from the
21
+ * chart tokens (`tone`), never ambient `currentColor`, so the family reads as one system.
17
22
  * Zero-dependency SVG: renders server-side (Astro-safe), no client JS. The horizontal
18
23
  * axis stretches to the container (non-scaling strokes keep the line crisp); the marker
19
24
  * dot + callout are HTML overlays so they never distort. An interactive tier (hover
20
25
  * tooltips) belongs to the visx layer, this is the static SSR tier.
21
26
  */
22
- declare function AreaChart({ data, height, markerIndex, markerLabel, className }: AreaChartProps): React.JSX.Element | null;
27
+ declare function AreaChart({ data, height, markerIndex, markerLabel, tone, color, className }: AreaChartProps): React.JSX.Element | null;
23
28
  declare namespace AreaChart {
24
29
  var displayName: string;
25
30
  }
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  AreaChart
3
- } from "../chunk-SC5A4Q7G.js";
4
- import "../chunk-T7ESUAJU.js";
3
+ } from "../chunk-L62UZTWJ.js";
4
+ import "../chunk-27MWE4F5.js";
5
+ import "../chunk-AOULEGMT.js";
5
6
  import "../chunk-DXRY7AS4.js";
6
7
  export {
7
8
  AreaChart
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import {
3
3
  BarChart
4
- } from "../chunk-RV75OH74.js";
5
- import "../chunk-NYHHTSX4.js";
4
+ } from "../chunk-PJRCDPG5.js";
5
+ import "../chunk-AOULEGMT.js";
6
6
  import "../chunk-DXRY7AS4.js";
7
7
  export {
8
8
  BarChart
@@ -1,4 +1,12 @@
1
1
  /** Build a smooth path (cubic beziers through midpoints) from points. */
2
2
  declare function smooth(pts: readonly (readonly [number, number])[]): string;
3
+ /** Coerce non-finite values (NaN/Infinity) to 0 so a stray value can't poison the geometry. */
4
+ declare function finite(values: readonly number[]): number[];
5
+ /** Min / max / non-zero range of a series (range falls back to 1 when the series is flat). */
6
+ declare function extent(values: readonly number[]): {
7
+ min: number;
8
+ max: number;
9
+ range: number;
10
+ };
3
11
 
4
- export { smooth };
12
+ export { extent, finite, smooth };
@@ -1,7 +1,11 @@
1
1
  import {
2
+ extent,
3
+ finite,
2
4
  smooth
3
- } from "../../chunk-T7ESUAJU.js";
5
+ } from "../../chunk-27MWE4F5.js";
4
6
  export {
7
+ extent,
8
+ finite,
5
9
  smooth
6
10
  };
7
11
  //# sourceMappingURL=path.js.map
@@ -13,12 +13,25 @@
13
13
  declare const chartToken: {
14
14
  readonly ink: "var(--sv-sys-chart-ink)";
15
15
  readonly muted: "var(--sv-sys-chart-muted)";
16
+ readonly markEdge: "var(--sv-sys-chart-mark-edge)";
16
17
  readonly accent: "var(--sv-sys-chart-categorical-2)";
17
18
  readonly grid: "var(--sv-sys-chart-grid)";
18
19
  readonly axis: "var(--sv-sys-chart-axis)";
19
20
  readonly track: "var(--sv-sys-chart-track)";
20
21
  };
21
22
  declare const CATEGORICAL_MAX: 4;
23
+ /** Chart line-mark weights, in px. The single stroke scale for the family: every line mark
24
+ * (sparkline, area line, trend line) uses `line`; reference/guide lines use `guide`. Radial
25
+ * gauges (Ring) set their own arc thickness. Lives here beside `chartToken` so the whole
26
+ * chart visual language (colour + stroke) has one home. */
27
+ declare const chartStroke: {
28
+ readonly line: 2;
29
+ readonly guide: 1;
30
+ };
31
+ /** The mono tone of a chart mark → its `sys.chart.*` colour. `ink` = the single/active series,
32
+ * `muted` = a comparison/secondary series, `accent` = the one opt-in hue (categorical blue).
33
+ * The single definition of the `tone` option, shared by every chart in the family. */
34
+ declare function toneFill(tone: 'ink' | 'muted' | 'accent'): string;
22
35
  /** Colour for category `i` (0-based). Wraps past the cap, pair with a label/pattern. */
23
36
  declare function categorical(i: number): string;
24
37
  /** WCAG-AA foreground for text drawn on `categorical(i)`. */
@@ -28,4 +41,4 @@ declare function sequential(i: number, n: number): string;
28
41
  /** WCAG-AA foreground for text drawn on `sequential(i, n)`. */
29
42
  declare function sequentialOn(i: number, n: number): string;
30
43
 
31
- export { CATEGORICAL_MAX, categorical, categoricalOn, chartToken, sequential, sequentialOn };
44
+ export { CATEGORICAL_MAX, categorical, categoricalOn, chartStroke, chartToken, sequential, sequentialOn, toneFill };
@@ -2,16 +2,20 @@ import {
2
2
  CATEGORICAL_MAX,
3
3
  categorical,
4
4
  categoricalOn,
5
+ chartStroke,
5
6
  chartToken,
6
7
  sequential,
7
- sequentialOn
8
- } from "../../chunk-NYHHTSX4.js";
8
+ sequentialOn,
9
+ toneFill
10
+ } from "../../chunk-AOULEGMT.js";
9
11
  export {
10
12
  CATEGORICAL_MAX,
11
13
  categorical,
12
14
  categoricalOn,
15
+ chartStroke,
13
16
  chartToken,
14
17
  sequential,
15
- sequentialOn
18
+ sequentialOn,
19
+ toneFill
16
20
  };
17
21
  //# sourceMappingURL=series.js.map
@@ -33,7 +33,8 @@ interface RingProps {
33
33
  * Cairn Ring, single-value radial progress. Grayscale by default (ink arc on a
34
34
  * neutral track); `tone="accent"` opts into the categorical blue, or pass an explicit
35
35
  * `color`. The arc fills from empty on mount (rounded cap, 12 o'clock, clockwise).
36
- * Zero-dependency SVG, renders server-side (Astro-safe).
36
+ * Zero-dependency SVG. A client component (`'use client'`): the mount animation uses state;
37
+ * pass `animate={false}` to render it statically.
37
38
  */
38
39
  declare function Ring({ value, size, thickness, tone, color, casing, animate, children, className, 'aria-label': ariaLabel, }: RingProps): React.JSX.Element;
39
40
  declare namespace Ring {
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import {
3
3
  Ring
4
- } from "../chunk-YE4P3T6M.js";
5
- import "../chunk-NYHHTSX4.js";
4
+ } from "../chunk-X3LG535W.js";
5
+ import "../chunk-AOULEGMT.js";
6
6
  import "../chunk-DXRY7AS4.js";
7
7
  export {
8
8
  Ring
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SegmentedBar
3
- } from "../chunk-UM6DTEFE.js";
4
- import "../chunk-NYHHTSX4.js";
3
+ } from "../chunk-OY6MO6QQ.js";
4
+ import "../chunk-AOULEGMT.js";
5
5
  import "../chunk-DXRY7AS4.js";
6
6
  export {
7
7
  SegmentedBar
@@ -7,11 +7,22 @@ interface SparklineProps {
7
7
  height?: number;
8
8
  /** `line` or filled `area`. */
9
9
  type?: 'line' | 'area';
10
+ /**
11
+ * Mono tone of the mark: `ink` (single series, default), `muted` (secondary/trailing, e.g.
12
+ * inside a Stat), or `accent` (the one opt-in hue). Resolves from `sys.chart.*`.
13
+ */
14
+ tone?: 'ink' | 'muted' | 'accent';
15
+ /** Explicit colour (a token / CSS colour), overrides `tone`. */
16
+ color?: string;
17
+ /** Stroke weight in px. Defaults to the shared chart line weight. */
10
18
  strokeWidth?: number;
11
19
  className?: string;
12
20
  }
13
- /** Cairn Sparkline, a compact, axis-less trend line. Colour follows currentColor. */
14
- declare function Sparkline({ data, width, height, type, strokeWidth, className }: SparklineProps): React.JSX.Element | null;
21
+ /**
22
+ * Cairn Sparkline, a compact, axis-less trend line. Grayscale-first: colour comes from the
23
+ * chart tokens (`tone`), never ambient `currentColor`, so it reads the same in any context.
24
+ */
25
+ declare function Sparkline({ data, width, height, type, tone, color, strokeWidth, className, }: SparklineProps): React.JSX.Element | null;
15
26
  declare namespace Sparkline {
16
27
  var displayName: string;
17
28
  }
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  Sparkline
3
- } from "../chunk-GD6IYLWY.js";
4
- import "../chunk-T7ESUAJU.js";
3
+ } from "../chunk-64YDZRCU.js";
4
+ import "../chunk-27MWE4F5.js";
5
+ import "../chunk-AOULEGMT.js";
5
6
  import "../chunk-DXRY7AS4.js";
6
7
  export {
7
8
  Sparkline
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Stat
3
- } from "../chunk-YSUYAW4O.js";
3
+ } from "../chunk-5DZPPT7X.js";
4
4
  import "../chunk-DXRY7AS4.js";
5
5
  export {
6
6
  Stat
@@ -0,0 +1,24 @@
1
+ // src/charts/lib/path.ts
2
+ function smooth(pts) {
3
+ return pts.reduce((acc, [x, y], i, arr) => {
4
+ if (i === 0) return `M ${x},${y}`;
5
+ const [px, py] = arr[i - 1];
6
+ const cx = (px + x) / 2;
7
+ return `${acc} C ${cx},${py} ${cx},${y} ${x},${y}`;
8
+ }, "");
9
+ }
10
+ function finite(values) {
11
+ return values.map((v) => Number.isFinite(v) ? v : 0);
12
+ }
13
+ function extent(values) {
14
+ const min = Math.min(...values);
15
+ const max = Math.max(...values);
16
+ return { min, max, range: max - min || 1 };
17
+ }
18
+
19
+ export {
20
+ smooth,
21
+ finite,
22
+ extent
23
+ };
24
+ //# sourceMappingURL=chunk-27MWE4F5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/lib/path.ts"],"sourcesContent":["/** Build a smooth path (cubic beziers through midpoints) from points. */\nexport function smooth(pts: readonly (readonly [number, number])[]): string {\n return pts.reduce((acc, [x, y], i, arr) => {\n if (i === 0) return `M ${x},${y}`;\n const [px, py] = arr[i - 1];\n const cx = (px + x) / 2;\n return `${acc} C ${cx},${py} ${cx},${y} ${x},${y}`;\n }, '');\n}\n\n/** Coerce non-finite values (NaN/Infinity) to 0 so a stray value can't poison the geometry. */\nexport function finite(values: readonly number[]): number[] {\n return values.map((v) => (Number.isFinite(v) ? v : 0));\n}\n\n/** Min / max / non-zero range of a series (range falls back to 1 when the series is flat). */\nexport function extent(values: readonly number[]): { min: number; max: number; range: number } {\n const min = Math.min(...values);\n const max = Math.max(...values);\n return { min, max, range: max - min || 1 };\n}\n"],"mappings":";AACO,SAAS,OAAO,KAAqD;AAC1E,SAAO,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,GAAG,QAAQ;AACzC,QAAI,MAAM,EAAG,QAAO,KAAK,CAAC,IAAI,CAAC;AAC/B,UAAM,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC;AAC1B,UAAM,MAAM,KAAK,KAAK;AACtB,WAAO,GAAG,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AAAA,EAClD,GAAG,EAAE;AACP;AAGO,SAAS,OAAO,QAAqC;AAC1D,SAAO,OAAO,IAAI,CAAC,MAAO,OAAO,SAAS,CAAC,IAAI,IAAI,CAAE;AACvD;AAGO,SAAS,OAAO,QAAwE;AAC7F,QAAM,MAAM,KAAK,IAAI,GAAG,MAAM;AAC9B,QAAM,MAAM,KAAK,IAAI,GAAG,MAAM;AAC9B,SAAO,EAAE,KAAK,KAAK,OAAO,MAAM,OAAO,EAAE;AAC3C;","names":[]}
@@ -7,12 +7,16 @@ import { jsx, jsxs } from "react/jsx-runtime";
7
7
  function Stat({ value, label, delta, children, className }) {
8
8
  const tone = delta?.tone ?? "neutral";
9
9
  const toneCls = tone === "success" ? "bg-success-container text-on-success-container" : tone === "error" ? "bg-error-container text-on-error-container" : "bg-surface-muted text-on-surface-variant";
10
+ const arrow = tone === "success" ? "\u2191" : tone === "error" ? "\u2193" : null;
10
11
  return /* @__PURE__ */ jsxs("div", { className: cn("rounded-card border border-outline p-5", className), children: [
11
12
  label && /* @__PURE__ */ jsx("p", { className: "sv-body-sm text-on-surface-variant", children: label }),
12
13
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex items-end justify-between gap-4", children: [
13
14
  /* @__PURE__ */ jsxs("div", { children: [
14
15
  /* @__PURE__ */ jsx("div", { className: "sv-metric tabular-nums text-on-surface", children: value }),
15
- delta && /* @__PURE__ */ jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsx("span", { className: cn("inline-flex items-center rounded-pill px-2 py-0.5 sv-body-sm font-medium", toneCls), children: delta.value }) })
16
+ delta && /* @__PURE__ */ jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsxs("span", { className: cn("inline-flex items-center gap-1 rounded-pill px-2 py-0.5 sv-body-sm font-medium", toneCls), children: [
17
+ arrow && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: arrow }),
18
+ delta.value
19
+ ] }) })
16
20
  ] }),
17
21
  children && /* @__PURE__ */ jsx("div", { className: "shrink-0 text-on-surface-variant", children })
18
22
  ] })
@@ -23,4 +27,4 @@ Stat.displayName = "Stat";
23
27
  export {
24
28
  Stat
25
29
  };
26
- //# sourceMappingURL=chunk-YSUYAW4O.js.map
30
+ //# sourceMappingURL=chunk-5DZPPT7X.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/stat.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '@/lib/utils';\n\nexport interface StatProps {\n /** The metric, pre-formatted (e.g. \"3,484\" or \"118 lbs\"). */\n value: string;\n label?: string;\n /** Change indicator. `tone` colours it (success / error / neutral). */\n delta?: { value: string; tone?: 'success' | 'error' | 'neutral' };\n /** Trailing visual, e.g. a `<Sparkline />`. */\n children?: React.ReactNode;\n className?: string;\n}\n\n/** Cairn Stat, a metric with an optional coloured delta and a trailing sparkline. */\nexport function Stat({ value, label, delta, children, className }: StatProps) {\n const tone = delta?.tone ?? 'neutral';\n // Message-as-meaning lives in a status container with its paired on-* text (AGENTS.md\n // rule 4), never as bare coloured text — so the delta is a small container pill.\n const toneCls =\n tone === 'success'\n ? 'bg-success-container text-on-success-container'\n : tone === 'error'\n ? 'bg-error-container text-on-error-container'\n : 'bg-surface-muted text-on-surface-variant';\n // A directional glyph so the up/down meaning never rests on hue alone (rule 4).\n const arrow = tone === 'success' ? '↑' : tone === 'error' ? '↓' : null;\n return (\n <div className={cn('rounded-card border border-outline p-5', className)}>\n {label && <p className=\"sv-body-sm text-on-surface-variant\">{label}</p>}\n <div className=\"mt-2 flex items-end justify-between gap-4\">\n <div>\n <div className=\"sv-metric tabular-nums text-on-surface\">{value}</div>\n {delta && (\n <div className=\"mt-2\">\n <span className={cn('inline-flex items-center gap-1 rounded-pill px-2 py-0.5 sv-body-sm font-medium', toneCls)}>\n {arrow && <span aria-hidden=\"true\">{arrow}</span>}\n {delta.value}\n </span>\n </div>\n )}\n </div>\n {children && <div className=\"shrink-0 text-on-surface-variant\">{children}</div>}\n </div>\n </div>\n );\n}\nStat.displayName = 'Stat';\n"],"mappings":";;;;;AA6BgB,cAMF,YANE;AAdT,SAAS,KAAK,EAAE,OAAO,OAAO,OAAO,UAAU,UAAU,GAAc;AAC5E,QAAM,OAAO,OAAO,QAAQ;AAG5B,QAAM,UACJ,SAAS,YACL,mDACA,SAAS,UACP,+CACA;AAER,QAAM,QAAQ,SAAS,YAAY,WAAM,SAAS,UAAU,WAAM;AAClE,SACE,qBAAC,SAAI,WAAW,GAAG,0CAA0C,SAAS,GACnE;AAAA,aAAS,oBAAC,OAAE,WAAU,sCAAsC,iBAAM;AAAA,IACnE,qBAAC,SAAI,WAAU,6CACb;AAAA,2BAAC,SACC;AAAA,4BAAC,SAAI,WAAU,0CAA0C,iBAAM;AAAA,QAC9D,SACC,oBAAC,SAAI,WAAU,QACb,+BAAC,UAAK,WAAW,GAAG,kFAAkF,OAAO,GAC1G;AAAA,mBAAS,oBAAC,UAAK,eAAY,QAAQ,iBAAM;AAAA,UACzC,MAAM;AAAA,WACT,GACF;AAAA,SAEJ;AAAA,MACC,YAAY,oBAAC,SAAI,WAAU,oCAAoC,UAAS;AAAA,OAC3E;AAAA,KACF;AAEJ;AACA,KAAK,cAAc;","names":[]}
@@ -0,0 +1,45 @@
1
+ import {
2
+ extent,
3
+ finite,
4
+ smooth
5
+ } from "./chunk-27MWE4F5.js";
6
+ import {
7
+ chartStroke,
8
+ toneFill
9
+ } from "./chunk-AOULEGMT.js";
10
+ import {
11
+ cn
12
+ } from "./chunk-DXRY7AS4.js";
13
+
14
+ // src/charts/sparkline.tsx
15
+ import { jsx, jsxs } from "react/jsx-runtime";
16
+ function Sparkline({
17
+ data,
18
+ width = 120,
19
+ height = 34,
20
+ type = "line",
21
+ tone = "ink",
22
+ color,
23
+ strokeWidth = chartStroke.line,
24
+ className
25
+ }) {
26
+ if (data.length < 2) return null;
27
+ const values = finite(data);
28
+ const { min, range } = extent(values);
29
+ const step = width / (values.length - 1);
30
+ const pad = strokeWidth;
31
+ const pts = values.map((v, i) => [i * step, pad + (1 - (v - min) / range) * (height - pad * 2)]);
32
+ const line = smooth(pts);
33
+ const area = `${line} L ${width},${height} L 0,${height} Z`;
34
+ const stroke = color ?? toneFill(tone);
35
+ return /* @__PURE__ */ jsxs("svg", { viewBox: `0 0 ${width} ${height}`, width, height, fill: "none", className: cn("overflow-visible", className), "aria-hidden": "true", children: [
36
+ type === "area" && /* @__PURE__ */ jsx("path", { d: area, fill: stroke, opacity: "0.12" }),
37
+ /* @__PURE__ */ jsx("path", { d: line, stroke, strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" })
38
+ ] });
39
+ }
40
+ Sparkline.displayName = "Sparkline";
41
+
42
+ export {
43
+ Sparkline
44
+ };
45
+ //# sourceMappingURL=chunk-64YDZRCU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/sparkline.tsx"],"sourcesContent":["import { cn } from '@/lib/utils';\nimport { smooth, finite, extent } from './lib/path';\nimport { toneFill, chartStroke } from './lib/series';\n\nexport interface SparklineProps {\n /** The series of values. */\n data: number[];\n width?: number;\n height?: number;\n /** `line` or filled `area`. */\n type?: 'line' | 'area';\n /**\n * Mono tone of the mark: `ink` (single series, default), `muted` (secondary/trailing, e.g.\n * inside a Stat), or `accent` (the one opt-in hue). Resolves from `sys.chart.*`.\n */\n tone?: 'ink' | 'muted' | 'accent';\n /** Explicit colour (a token / CSS colour), overrides `tone`. */\n color?: string;\n /** Stroke weight in px. Defaults to the shared chart line weight. */\n strokeWidth?: number;\n className?: string;\n}\n\n/**\n * Cairn Sparkline, a compact, axis-less trend line. Grayscale-first: colour comes from the\n * chart tokens (`tone`), never ambient `currentColor`, so it reads the same in any context.\n */\nexport function Sparkline({\n data,\n width = 120,\n height = 34,\n type = 'line',\n tone = 'ink',\n color,\n strokeWidth = chartStroke.line,\n className,\n}: SparklineProps) {\n if (data.length < 2) return null;\n const values = finite(data);\n const { min, range } = extent(values);\n const step = width / (values.length - 1);\n const pad = strokeWidth;\n const pts = values.map((v, i) => [i * step, pad + (1 - (v - min) / range) * (height - pad * 2)] as const);\n const line = smooth(pts);\n const area = `${line} L ${width},${height} L 0,${height} Z`;\n const stroke = color ?? toneFill(tone);\n return (\n <svg viewBox={`0 0 ${width} ${height}`} width={width} height={height} fill=\"none\" className={cn('overflow-visible', className)} aria-hidden=\"true\">\n {type === 'area' && <path d={area} fill={stroke} opacity=\"0.12\" />}\n <path d={line} stroke={stroke} strokeWidth={strokeWidth} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n );\n}\nSparkline.displayName = 'Sparkline';\n"],"mappings":";;;;;;;;;;;;;;AA+CI,SACsB,KADtB;AApBG,SAAS,UAAU;AAAA,EACxB;AAAA,EACA,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AAAA,EACP;AAAA,EACA,cAAc,YAAY;AAAA,EAC1B;AACF,GAAmB;AACjB,MAAI,KAAK,SAAS,EAAG,QAAO;AAC5B,QAAM,SAAS,OAAO,IAAI;AAC1B,QAAM,EAAE,KAAK,MAAM,IAAI,OAAO,MAAM;AACpC,QAAM,OAAO,SAAS,OAAO,SAAS;AACtC,QAAM,MAAM;AACZ,QAAM,MAAM,OAAO,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,MAAM,OAAO,KAAK,IAAI,OAAO,UAAU,SAAS,MAAM,EAAE,CAAU;AACxG,QAAM,OAAO,OAAO,GAAG;AACvB,QAAM,OAAO,GAAG,IAAI,MAAM,KAAK,IAAI,MAAM,QAAQ,MAAM;AACvD,QAAM,SAAS,SAAS,SAAS,IAAI;AACrC,SACE,qBAAC,SAAI,SAAS,OAAO,KAAK,IAAI,MAAM,IAAI,OAAc,QAAgB,MAAK,QAAO,WAAW,GAAG,oBAAoB,SAAS,GAAG,eAAY,QACzI;AAAA,aAAS,UAAU,oBAAC,UAAK,GAAG,MAAM,MAAM,QAAQ,SAAQ,QAAO;AAAA,IAChE,oBAAC,UAAK,GAAG,MAAM,QAAgB,aAA0B,eAAc,SAAQ,gBAAe,SAAQ;AAAA,KACxG;AAEJ;AACA,UAAU,cAAc;","names":[]}
@@ -2,6 +2,7 @@
2
2
  var chartToken = {
3
3
  ink: "var(--sv-sys-chart-ink)",
4
4
  muted: "var(--sv-sys-chart-muted)",
5
+ markEdge: "var(--sv-sys-chart-mark-edge)",
5
6
  accent: "var(--sv-sys-chart-categorical-2)",
6
7
  grid: "var(--sv-sys-chart-grid)",
7
8
  axis: "var(--sv-sys-chart-axis)",
@@ -43,6 +44,12 @@ var SEQUENTIAL_ON = [
43
44
  "var(--sv-sys-color-on-primary)"
44
45
  // white, on blue.900
45
46
  ];
47
+ var chartStroke = { line: 2, guide: 1 };
48
+ function toneFill(tone) {
49
+ if (tone === "accent") return chartToken.accent;
50
+ if (tone === "muted") return chartToken.muted;
51
+ return chartToken.ink;
52
+ }
46
53
  var wrap = (i, n) => (i % n + n) % n;
47
54
  var rampIndex = (i, n) => n <= 1 ? SEQUENTIAL.length - 1 : Math.round(Math.min(Math.max(i / (n - 1), 0), 1) * (SEQUENTIAL.length - 1));
48
55
  function categorical(i) {
@@ -61,9 +68,11 @@ function sequentialOn(i, n) {
61
68
  export {
62
69
  chartToken,
63
70
  CATEGORICAL_MAX,
71
+ chartStroke,
72
+ toneFill,
64
73
  categorical,
65
74
  categoricalOn,
66
75
  sequential,
67
76
  sequentialOn
68
77
  };
69
- //# sourceMappingURL=chunk-NYHHTSX4.js.map
78
+ //# sourceMappingURL=chunk-AOULEGMT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/lib/series.ts"],"sourcesContent":["/**\n * Cairn data-viz colour, the single place a series gets a colour.\n *\n * Rule: grayscale first. A single series is `ink`; a comparison series is `muted`.\n * Reach for hue only when categories are genuinely unordered (`categorical`, capped\n * at 4) or encode magnitude (`sequential`, single-hue). Never hand-pick a hex, every\n * value here is a `sys.chart.*` token resolved at runtime via its CSS variable, so a\n * theme swap (light↔dark) recolours the charts for free.\n */\n\n/** Semantic chart roles → their CSS variable. The single place a chart hue is named;\n * components consume these, never the raw `--sv-sys-chart-*` var. `accent` is the one\n * opt-in hue (categorical blue) a fixed-shape chart may promote a value to. */\nexport const chartToken = {\n ink: 'var(--sv-sys-chart-ink)',\n muted: 'var(--sv-sys-chart-muted)',\n markEdge: 'var(--sv-sys-chart-mark-edge)',\n accent: 'var(--sv-sys-chart-categorical-2)',\n grid: 'var(--sv-sys-chart-grid)',\n axis: 'var(--sv-sys-chart-axis)',\n track: 'var(--sv-sys-chart-track)',\n} as const;\n\n/** The unordered-category palette. HARD CAP at 4, a 5th category needs a pattern or\n * label, never a 5th hue. Indices wrap so a longer series degrades loudly, not silently. */\nconst CATEGORICAL = [\n 'var(--sv-sys-chart-categorical-1)',\n 'var(--sv-sys-chart-categorical-2)',\n 'var(--sv-sys-chart-categorical-3)',\n 'var(--sv-sys-chart-categorical-4)',\n] as const;\n\n/** Single-hue magnitude ramp (low → high). */\nconst SEQUENTIAL = [\n 'var(--sv-sys-chart-sequential-1)',\n 'var(--sv-sys-chart-sequential-2)',\n 'var(--sv-sys-chart-sequential-3)',\n 'var(--sv-sys-chart-sequential-4)',\n 'var(--sv-sys-chart-sequential-5)',\n] as const;\n\nexport const CATEGORICAL_MAX = CATEGORICAL.length;\n\n/** Accessible foreground for text/marks laid ON each categorical fill. Every pair below\n * clears WCAG AA (≥4.5:1): white on the dark fills (ink, blue.600), ink on the light ones\n * (acid.400, neutral.400). Index-matched to CATEGORICAL, never guess contrast at runtime. */\nconst CATEGORICAL_ON = [\n 'var(--sv-sys-color-on-primary)', // white, on ink\n 'var(--sv-sys-color-on-primary)', // white, on blue.600 (5.2:1)\n 'var(--sv-sys-color-on-surface)', // ink, on acid.400 (16:1)\n 'var(--sv-sys-color-on-surface)', // ink, on neutral.400 (5.6:1)\n] as const;\n\n/** Accessible foreground per sequential step. Light steps (blue.100/300) take ink; the\n * darker half (blue.500/700/900) takes white. Index-matched to SEQUENTIAL. */\nconst SEQUENTIAL_ON = [\n 'var(--sv-sys-color-on-surface)', // ink, on blue.100\n 'var(--sv-sys-color-on-surface)', // ink, on blue.300\n 'var(--sv-sys-color-on-primary)', // white, on blue.500 (4.8:1)\n 'var(--sv-sys-color-on-primary)', // white, on blue.700\n 'var(--sv-sys-color-on-primary)', // white, on blue.900\n] as const;\n\n/** Chart line-mark weights, in px. The single stroke scale for the family: every line mark\n * (sparkline, area line, trend line) uses `line`; reference/guide lines use `guide`. Radial\n * gauges (Ring) set their own arc thickness. Lives here beside `chartToken` so the whole\n * chart visual language (colour + stroke) has one home. */\nexport const chartStroke = { line: 2, guide: 1 } as const;\n\n/** The mono tone of a chart mark → its `sys.chart.*` colour. `ink` = the single/active series,\n * `muted` = a comparison/secondary series, `accent` = the one opt-in hue (categorical blue).\n * The single definition of the `tone` option, shared by every chart in the family. */\nexport function toneFill(tone: 'ink' | 'muted' | 'accent'): string {\n if (tone === 'accent') return chartToken.accent;\n if (tone === 'muted') return chartToken.muted;\n return chartToken.ink;\n}\n\nconst wrap = (i: number, n: number) => ((i % n) + n) % n;\nconst rampIndex = (i: number, n: number) =>\n n <= 1 ? SEQUENTIAL.length - 1 : Math.round(Math.min(Math.max(i / (n - 1), 0), 1) * (SEQUENTIAL.length - 1));\n\n/** Colour for category `i` (0-based). Wraps past the cap, pair with a label/pattern. */\nexport function categorical(i: number): string {\n return CATEGORICAL[wrap(i, CATEGORICAL_MAX)];\n}\n\n/** WCAG-AA foreground for text drawn on `categorical(i)`. */\nexport function categoricalOn(i: number): string {\n return CATEGORICAL_ON[wrap(i, CATEGORICAL_MAX)];\n}\n\n/** Colour for the `i`-th of `n` steps on the single-hue magnitude ramp. */\nexport function sequential(i: number, n: number): string {\n return SEQUENTIAL[rampIndex(i, n)];\n}\n\n/** WCAG-AA foreground for text drawn on `sequential(i, n)`. */\nexport function sequentialOn(i: number, n: number): string {\n return SEQUENTIAL_ON[rampIndex(i, n)];\n}\n"],"mappings":";AAaO,IAAM,aAAa;AAAA,EACxB,KAAK;AAAA,EACL,OAAO;AAAA,EACP,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT;AAIA,IAAM,cAAc;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,IAAM,aAAa;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,kBAAkB,YAAY;AAK3C,IAAM,iBAAiB;AAAA,EACrB;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACF;AAIA,IAAM,gBAAgB;AAAA,EACpB;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACF;AAMO,IAAM,cAAc,EAAE,MAAM,GAAG,OAAO,EAAE;AAKxC,SAAS,SAAS,MAA0C;AACjE,MAAI,SAAS,SAAU,QAAO,WAAW;AACzC,MAAI,SAAS,QAAS,QAAO,WAAW;AACxC,SAAO,WAAW;AACpB;AAEA,IAAM,OAAO,CAAC,GAAW,OAAgB,IAAI,IAAK,KAAK;AACvD,IAAM,YAAY,CAAC,GAAW,MAC5B,KAAK,IAAI,WAAW,SAAS,IAAI,KAAK,MAAM,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,WAAW,SAAS,EAAE;AAGtG,SAAS,YAAY,GAAmB;AAC7C,SAAO,YAAY,KAAK,GAAG,eAAe,CAAC;AAC7C;AAGO,SAAS,cAAc,GAAmB;AAC/C,SAAO,eAAe,KAAK,GAAG,eAAe,CAAC;AAChD;AAGO,SAAS,WAAW,GAAW,GAAmB;AACvD,SAAO,WAAW,UAAU,GAAG,CAAC,CAAC;AACnC;AAGO,SAAS,aAAa,GAAW,GAAmB;AACzD,SAAO,cAAc,UAAU,GAAG,CAAC,CAAC;AACtC;","names":[]}
@@ -1,9 +1,11 @@
1
1
  // src/logo/logo-mark.tsx
2
+ import * as React from "react";
2
3
  import { jsx, jsxs } from "react/jsx-runtime";
3
- function LogoMark({ title = "Six Vall\xE9es", className, ...props }) {
4
+ var LogoMark = React.forwardRef(function LogoMark2({ title = "Six Vall\xE9es", className, ...props }, ref) {
4
5
  return /* @__PURE__ */ jsx(
5
6
  "svg",
6
7
  {
8
+ ref,
7
9
  viewBox: "0 0 1042 648",
8
10
  fill: "currentColor",
9
11
  xmlns: "http://www.w3.org/2000/svg",
@@ -19,10 +21,10 @@ function LogoMark({ title = "Six Vall\xE9es", className, ...props }) {
19
21
  ] })
20
22
  }
21
23
  );
22
- }
24
+ });
23
25
  LogoMark.displayName = "LogoMark";
24
26
 
25
27
  export {
26
28
  LogoMark
27
29
  };
28
- //# sourceMappingURL=chunk-35UH66I7.js.map
30
+ //# sourceMappingURL=chunk-IVQKYAL6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/logo/logo-mark.tsx"],"sourcesContent":["import * as React from 'react';\n\nexport interface LogoMarkProps extends React.SVGProps<SVGSVGElement> {\n /** Accessible name. Pass an empty string for a purely decorative mark. */\n title?: string;\n}\n\n/**\n * Six Vallées symbol (compact mark). Colour follows `currentColor`; size with `className`.\n */\nexport const LogoMark = React.forwardRef<SVGSVGElement, LogoMarkProps>(function LogoMark(\n { title = 'Six Vallées', className, ...props },\n ref\n) {\n return (\n <svg\n ref={ref}\n viewBox=\"0 0 1042 648\"\n fill=\"currentColor\"\n xmlns=\"http://www.w3.org/2000/svg\"\n role={title ? 'img' : undefined}\n aria-label={title || undefined}\n aria-hidden={title ? undefined : true}\n className={className}\n {...props}\n >\n <g transform=\"matrix(1,0,0,1,-21444.579167,-1926.130417)\">\n <g transform=\"matrix(4.166667,0,0,4.166667,21444.579167,2147.084583)\">\n <path fillRule=\"nonzero\" d=\"M0,49.399L30.241,42.796C32.086,54.442 35.102,62.856 39.287,68.037C43.481,73.219 50.326,75.81 59.84,75.81C67.933,75.81 74.388,74.354 79.215,71.443C84.041,68.531 86.458,64.233 86.458,58.558C86.458,52.596 84.154,48.013 79.535,44.824C74.925,41.627 64.38,37.476 47.917,32.364C32.441,27.537 21.472,21.68 15.016,14.8C8.552,7.911 5.329,-0.572 5.329,-10.649C5.329,-22.286 9.826,-32.268 18.846,-40.569C27.858,-48.878 40.11,-53.029 55.577,-53.029C69.64,-53.029 81.736,-49.624 91.891,-42.804C102.038,-35.994 108.389,-25.838 110.945,-12.356L83.053,-5.329C78.651,-19.383 69.493,-26.41 55.577,-26.41C48.194,-26.41 42.701,-24.989 39.079,-22.147C35.457,-19.305 33.646,-15.545 33.646,-10.865C33.646,-6.464 35.699,-3.093 39.824,-0.745C43.94,1.595 54.52,5.676 71.555,11.499C88.018,17.174 99.309,23.318 105.409,29.92C111.517,36.514 114.567,45.43 114.567,56.643C114.567,69.848 109.594,80.775 99.664,89.44C89.725,98.096 76.451,102.428 59.84,102.428C42.943,102.428 29.279,97.992 18.846,89.119C8.414,80.246 2.132,67.006 0,49.399\" />\n </g>\n <g transform=\"matrix(4.166667,0,0,4.166667,22212.97625,2119.575)\">\n <path fillRule=\"nonzero\" d=\"M0,62.604L35.777,-43.229L65.585,-43.229L12.347,105.833L-13.838,105.833L0,62.604Z\" />\n </g>\n <g transform=\"matrix(0,-4.166667,-4.166667,0,22020.05375,1939.45375)\">\n <path fillRule=\"nonzero\" d=\"M-14.987,-14.987C-23.264,-14.987 -29.974,-8.277 -29.974,0C-29.974,8.277 -23.264,14.987 -14.987,14.987C-6.71,14.987 0,8.277 0,0C0,-8.277 -6.71,-14.987 -14.987,-14.987\" />\n </g>\n </g>\n </svg>\n );\n});\nLogoMark.displayName = 'LogoMark';\n"],"mappings":";AAAA,YAAY,WAAW;AA0BjB,SAEI,KAFJ;AAhBC,IAAM,WAAiB,iBAAyC,SAASA,UAC9E,EAAE,QAAQ,kBAAe,WAAW,GAAG,MAAM,GAC7C,KACA;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,OAAM;AAAA,MACN,MAAM,QAAQ,QAAQ;AAAA,MACtB,cAAY,SAAS;AAAA,MACrB,eAAa,QAAQ,SAAY;AAAA,MACjC;AAAA,MACC,GAAG;AAAA,MAEJ,+BAAC,OAAE,WAAU,8CACX;AAAA,4BAAC,OAAE,WAAU,0DACX,8BAAC,UAAK,UAAS,WAAU,GAAE,++BAA8+B,GAC3gC;AAAA,QACA,oBAAC,OAAE,WAAU,sDACX,8BAAC,UAAK,UAAS,WAAU,GAAE,oFAAmF,GAChH;AAAA,QACA,oBAAC,OAAE,WAAU,0DACX,8BAAC,UAAK,UAAS,WAAU,GAAE,yKAAwK,GACrM;AAAA,SACF;AAAA;AAAA,EACF;AAEJ,CAAC;AACD,SAAS,cAAc;","names":["LogoMark"]}
@@ -1,6 +1,13 @@
1
1
  import {
2
+ extent,
3
+ finite,
2
4
  smooth
3
- } from "./chunk-T7ESUAJU.js";
5
+ } from "./chunk-27MWE4F5.js";
6
+ import {
7
+ chartStroke,
8
+ chartToken,
9
+ toneFill
10
+ } from "./chunk-AOULEGMT.js";
4
11
  import {
5
12
  cn
6
13
  } from "./chunk-DXRY7AS4.js";
@@ -10,20 +17,21 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
17
  var W = 1e3;
11
18
  var TOP = 26;
12
19
  var BOTTOM = 8;
13
- function AreaChart({ data, height = 240, markerIndex, markerLabel, className }) {
14
- const values = data.map((d) => typeof d === "number" ? d : d.value);
20
+ function AreaChart({ data, height = 240, markerIndex, markerLabel, tone = "ink", color, className }) {
21
+ const values = finite(data.map((d) => typeof d === "number" ? d : d.value));
15
22
  if (values.length < 2) return null;
16
- const min = Math.min(...values);
17
- const max = Math.max(...values);
18
- const range = max - min || 1;
23
+ const stroke = color ?? toneFill(tone);
24
+ const { min, max, range } = extent(values);
19
25
  const stepX = W / (values.length - 1);
26
+ const labelled = data.filter((d) => typeof d !== "number" && d.label);
27
+ const ariaLabel = labelled.length ? data.map((d, i) => typeof d === "number" ? `${values[i]}` : `${d.label} ${d.value}`).join(", ") : `Trend across ${values.length} points, from ${min} to ${max}`;
20
28
  const y = (v) => TOP + (1 - (v - min) / range) * (height - TOP - BOTTOM);
21
29
  const pts = values.map((v, i) => [i * stepX, y(v)]);
22
30
  const line = smooth(pts);
23
31
  const area = `${line} L ${W},${height} L 0,${height} Z`;
24
32
  const marked = markerIndex != null && markerIndex >= 0 && markerIndex < values.length;
25
33
  const markLeft = marked ? markerIndex / (values.length - 1) * 100 : 0;
26
- return /* @__PURE__ */ jsxs("div", { className: cn("relative w-full", className), style: { height }, children: [
34
+ return /* @__PURE__ */ jsxs("div", { className: cn("relative w-full", className), style: { height }, role: "img", "aria-label": ariaLabel, children: [
27
35
  /* @__PURE__ */ jsxs(
28
36
  "svg",
29
37
  {
@@ -34,13 +42,13 @@ function AreaChart({ data, height = 240, markerIndex, markerLabel, className })
34
42
  fill: "none",
35
43
  "aria-hidden": "true",
36
44
  children: [
37
- /* @__PURE__ */ jsx("path", { d: area, fill: "currentColor", fillOpacity: 0.1 }),
45
+ /* @__PURE__ */ jsx("path", { d: area, fill: stroke, fillOpacity: 0.1 }),
38
46
  /* @__PURE__ */ jsx(
39
47
  "path",
40
48
  {
41
49
  d: line,
42
- stroke: "currentColor",
43
- strokeWidth: 2.5,
50
+ stroke,
51
+ strokeWidth: chartStroke.line,
44
52
  strokeLinecap: "round",
45
53
  strokeLinejoin: "round",
46
54
  vectorEffect: "non-scaling-stroke"
@@ -53,8 +61,8 @@ function AreaChart({ data, height = 240, markerIndex, markerLabel, className })
53
61
  y1: TOP,
54
62
  x2: markerIndex * stepX,
55
63
  y2: height,
56
- stroke: "var(--sv-sys-color-outline-strong)",
57
- strokeWidth: 1,
64
+ stroke: chartToken.axis,
65
+ strokeWidth: chartStroke.guide,
58
66
  vectorEffect: "non-scaling-stroke"
59
67
  }
60
68
  )
@@ -65,8 +73,8 @@ function AreaChart({ data, height = 240, markerIndex, markerLabel, className })
65
73
  /* @__PURE__ */ jsx(
66
74
  "span",
67
75
  {
68
- className: "pointer-events-none absolute size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-[2.5px] border-current bg-surface",
69
- style: { left: `${markLeft}%`, top: y(values[markerIndex]) },
76
+ className: "pointer-events-none absolute size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 bg-surface",
77
+ style: { left: `${markLeft}%`, top: y(values[markerIndex]), borderColor: stroke },
70
78
  "aria-hidden": "true"
71
79
  }
72
80
  ),
@@ -86,4 +94,4 @@ AreaChart.displayName = "AreaChart";
86
94
  export {
87
95
  AreaChart
88
96
  };
89
- //# sourceMappingURL=chunk-SC5A4Q7G.js.map
97
+ //# sourceMappingURL=chunk-L62UZTWJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/area-chart.tsx"],"sourcesContent":["import { cn } from '@/lib/utils';\nimport { smooth, finite, extent } from './lib/path';\nimport { toneFill, chartToken, chartStroke } from './lib/series';\n\nexport interface AreaChartProps {\n /** Values, or `{ label, value }` points. */\n data: (number | { label?: string; value: number })[];\n height?: number;\n /** Index of the point to mark with a guideline + callout. */\n markerIndex?: number;\n markerLabel?: string;\n /** Mono tone of the line/fill: `ink` (default), `muted`, or `accent`. From `sys.chart.*`. */\n tone?: 'ink' | 'muted' | 'accent';\n /** Explicit colour (a token / CSS colour), overrides `tone`. */\n color?: string;\n className?: string;\n}\n\n/** Internal coordinate width; the SVG stretches to the container (see preserveAspectRatio). */\nconst W = 1000;\n/** Top room (px) reserved for the marker callout so it never clips. */\nconst TOP = 26;\nconst BOTTOM = 8;\n\n/**\n * Cairn AreaChart, a smooth line with a flat fill. Grayscale-first: colour comes from the\n * chart tokens (`tone`), never ambient `currentColor`, so the family reads as one system.\n * Zero-dependency SVG: renders server-side (Astro-safe), no client JS. The horizontal\n * axis stretches to the container (non-scaling strokes keep the line crisp); the marker\n * dot + callout are HTML overlays so they never distort. An interactive tier (hover\n * tooltips) belongs to the visx layer, this is the static SSR tier.\n */\nexport function AreaChart({ data, height = 240, markerIndex, markerLabel, tone = 'ink', color, className }: AreaChartProps) {\n const values = finite(data.map((d) => (typeof d === 'number' ? d : d.value)));\n if (values.length < 2) return null;\n const stroke = color ?? toneFill(tone);\n\n const { min, max, range } = extent(values);\n const stepX = W / (values.length - 1);\n\n // Expose the series to assistive tech: labelled points when given, else a plain range summary.\n const labelled = data.filter((d) => typeof d !== 'number' && d.label);\n const ariaLabel = labelled.length\n ? (data.map((d, i) => (typeof d === 'number' ? `${values[i]}` : `${d.label} ${d.value}`)).join(', '))\n : `Trend across ${values.length} points, from ${min} to ${max}`;\n const y = (v: number) => TOP + (1 - (v - min) / range) * (height - TOP - BOTTOM);\n\n const pts = values.map((v, i) => [i * stepX, y(v)] as const);\n const line = smooth(pts);\n const area = `${line} L ${W},${height} L 0,${height} Z`;\n\n const marked = markerIndex != null && markerIndex >= 0 && markerIndex < values.length;\n const markLeft = marked ? (markerIndex! / (values.length - 1)) * 100 : 0;\n\n return (\n <div className={cn('relative w-full', className)} style={{ height }} role=\"img\" aria-label={ariaLabel}>\n <svg\n viewBox={`0 0 ${W} ${height}`}\n width=\"100%\"\n height={height}\n preserveAspectRatio=\"none\"\n fill=\"none\"\n aria-hidden=\"true\"\n >\n <path d={area} fill={stroke} fillOpacity={0.1} />\n <path\n d={line}\n stroke={stroke}\n strokeWidth={chartStroke.line}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n vectorEffect=\"non-scaling-stroke\"\n />\n {marked && (\n <line\n x1={markerIndex! * stepX}\n y1={TOP}\n x2={markerIndex! * stepX}\n y2={height}\n stroke={chartToken.axis}\n strokeWidth={chartStroke.guide}\n vectorEffect=\"non-scaling-stroke\"\n />\n )}\n </svg>\n\n {marked && (\n <>\n {/* HTML overlays: undistorted regardless of the horizontal stretch. */}\n <span\n className=\"pointer-events-none absolute size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 bg-surface\"\n style={{ left: `${markLeft}%`, top: y(values[markerIndex!]), borderColor: stroke }}\n aria-hidden=\"true\"\n />\n {markerLabel && (\n <span\n className=\"pointer-events-none absolute top-0 -translate-x-1/2 whitespace-nowrap sv-body-sm font-medium text-on-surface\"\n style={{ left: `${markLeft}%` }}\n >\n {markerLabel}\n </span>\n )}\n </>\n )}\n </div>\n );\n}\nAreaChart.displayName = 'AreaChart';\n"],"mappings":";;;;;;;;;;;;;;;AAwDM,SA+BE,UAvBA,KARF;AArCN,IAAM,IAAI;AAEV,IAAM,MAAM;AACZ,IAAM,SAAS;AAUR,SAAS,UAAU,EAAE,MAAM,SAAS,KAAK,aAAa,aAAa,OAAO,OAAO,OAAO,UAAU,GAAmB;AAC1H,QAAM,SAAS,OAAO,KAAK,IAAI,CAAC,MAAO,OAAO,MAAM,WAAW,IAAI,EAAE,KAAM,CAAC;AAC5E,MAAI,OAAO,SAAS,EAAG,QAAO;AAC9B,QAAM,SAAS,SAAS,SAAS,IAAI;AAErC,QAAM,EAAE,KAAK,KAAK,MAAM,IAAI,OAAO,MAAM;AACzC,QAAM,QAAQ,KAAK,OAAO,SAAS;AAGnC,QAAM,WAAW,KAAK,OAAO,CAAC,MAAM,OAAO,MAAM,YAAY,EAAE,KAAK;AACpE,QAAM,YAAY,SAAS,SACtB,KAAK,IAAI,CAAC,GAAG,MAAO,OAAO,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,KAAK,GAAG,EAAE,KAAK,IAAI,EAAE,KAAK,EAAG,EAAE,KAAK,IAAI,IACjG,gBAAgB,OAAO,MAAM,iBAAiB,GAAG,OAAO,GAAG;AAC/D,QAAM,IAAI,CAAC,MAAc,OAAO,KAAK,IAAI,OAAO,UAAU,SAAS,MAAM;AAEzE,QAAM,MAAM,OAAO,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAU;AAC3D,QAAM,OAAO,OAAO,GAAG;AACvB,QAAM,OAAO,GAAG,IAAI,MAAM,CAAC,IAAI,MAAM,QAAQ,MAAM;AAEnD,QAAM,SAAS,eAAe,QAAQ,eAAe,KAAK,cAAc,OAAO;AAC/E,QAAM,WAAW,SAAU,eAAgB,OAAO,SAAS,KAAM,MAAM;AAEvE,SACE,qBAAC,SAAI,WAAW,GAAG,mBAAmB,SAAS,GAAG,OAAO,EAAE,OAAO,GAAG,MAAK,OAAM,cAAY,WAC1F;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,SAAS,OAAO,CAAC,IAAI,MAAM;AAAA,QAC3B,OAAM;AAAA,QACN;AAAA,QACA,qBAAoB;AAAA,QACpB,MAAK;AAAA,QACL,eAAY;AAAA,QAEZ;AAAA,8BAAC,UAAK,GAAG,MAAM,MAAM,QAAQ,aAAa,KAAK;AAAA,UAC/C;AAAA,YAAC;AAAA;AAAA,cACC,GAAG;AAAA,cACH;AAAA,cACA,aAAa,YAAY;AAAA,cACzB,eAAc;AAAA,cACd,gBAAe;AAAA,cACf,cAAa;AAAA;AAAA,UACf;AAAA,UACC,UACC;AAAA,YAAC;AAAA;AAAA,cACC,IAAI,cAAe;AAAA,cACnB,IAAI;AAAA,cACJ,IAAI,cAAe;AAAA,cACnB,IAAI;AAAA,cACJ,QAAQ,WAAW;AAAA,cACnB,aAAa,YAAY;AAAA,cACzB,cAAa;AAAA;AAAA,UACf;AAAA;AAAA;AAAA,IAEJ;AAAA,IAEC,UACC,iCAEE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,OAAO,EAAE,MAAM,GAAG,QAAQ,KAAK,KAAK,EAAE,OAAO,WAAY,CAAC,GAAG,aAAa,OAAO;AAAA,UACjF,eAAY;AAAA;AAAA,MACd;AAAA,MACC,eACC;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,OAAO,EAAE,MAAM,GAAG,QAAQ,IAAI;AAAA,UAE7B;AAAA;AAAA,MACH;AAAA,OAEJ;AAAA,KAEJ;AAEJ;AACA,UAAU,cAAc;","names":[]}
@@ -4,7 +4,7 @@ import {
4
4
  chartToken,
5
5
  sequential,
6
6
  sequentialOn
7
- } from "./chunk-NYHHTSX4.js";
7
+ } from "./chunk-AOULEGMT.js";
8
8
  import {
9
9
  cn
10
10
  } from "./chunk-DXRY7AS4.js";
@@ -12,7 +12,8 @@ import {
12
12
  // src/charts/segmented-bar.tsx
13
13
  import { jsx, jsxs } from "react/jsx-runtime";
14
14
  function SegmentedBar({ data, height = 40, scale = "mono", showLegend = true, className }) {
15
- const total = data.reduce((s, d) => s + d.value, 0) || 1;
15
+ const safe = (v) => Number.isFinite(v) && v > 0 ? v : 0;
16
+ const total = data.reduce((s, d) => s + safe(d.value), 0) || 1;
16
17
  const hasActive = data.some((d) => d.active);
17
18
  const fill = (d, i) => {
18
19
  if (scale === "categorical") return categorical(i);
@@ -26,18 +27,31 @@ function SegmentedBar({ data, height = 40, scale = "mono", showLegend = true, cl
26
27
  if (!hasActive) return "var(--sv-sys-color-on-primary)";
27
28
  return d.active ? "var(--sv-sys-color-on-primary)" : "var(--sv-sys-color-on-surface)";
28
29
  };
30
+ const needsEdge = scale === "mono" && hasActive;
29
31
  return /* @__PURE__ */ jsxs("div", { className: cn("w-full", className), children: [
30
- /* @__PURE__ */ jsx("div", { className: "flex w-full overflow-hidden rounded-control", style: { height }, role: "img", "aria-label": data.map((d) => `${d.label} ${d.value}`).join(", "), children: data.map((d, i) => /* @__PURE__ */ jsx(
32
+ /* @__PURE__ */ jsx(
31
33
  "div",
32
34
  {
33
- className: "flex items-center justify-end px-2 first:rounded-l-control last:rounded-r-control",
34
- style: { width: `${d.value / total * 100}%`, background: fill(d, i) },
35
- children: /* @__PURE__ */ jsx("span", { className: "truncate sv-body-xs font-medium tabular-nums", style: { color: onFill(d, i) }, children: d.value })
36
- },
37
- d.label
38
- )) }),
35
+ className: "flex w-full overflow-hidden rounded-control",
36
+ style: {
37
+ height,
38
+ ...needsEdge ? { outline: `1px solid ${chartToken.markEdge}`, outlineOffset: "-1px" } : {}
39
+ },
40
+ role: "img",
41
+ "aria-label": data.map((d) => `${d.label} ${d.value}`).join(", "),
42
+ children: data.map((d, i) => /* @__PURE__ */ jsx(
43
+ "div",
44
+ {
45
+ className: "flex items-center justify-end px-2 first:rounded-l-control last:rounded-r-control",
46
+ style: { width: `${safe(d.value) / total * 100}%`, background: fill(d, i) },
47
+ children: /* @__PURE__ */ jsx("span", { className: "truncate sv-body-xs font-medium tabular-nums", style: { color: onFill(d, i) }, children: d.value })
48
+ },
49
+ d.label
50
+ ))
51
+ }
52
+ ),
39
53
  showLegend && /* @__PURE__ */ jsx("ul", { className: "mt-3 flex flex-wrap gap-x-4 gap-y-1", children: data.map((d, i) => /* @__PURE__ */ jsxs("li", { className: cn("flex items-center gap-1.5 sv-body-sm", d.active ? "text-on-surface" : "text-on-surface-variant"), children: [
40
- /* @__PURE__ */ jsx("span", { className: "size-2 shrink-0 rounded-[2px]", style: { background: fill(d, i) }, "aria-hidden": "true" }),
54
+ /* @__PURE__ */ jsx("span", { className: "size-2 shrink-0 rounded-swatch", style: { background: fill(d, i) }, "aria-hidden": "true" }),
41
55
  d.label
42
56
  ] }, d.label)) })
43
57
  ] });
@@ -47,4 +61,4 @@ SegmentedBar.displayName = "SegmentedBar";
47
61
  export {
48
62
  SegmentedBar
49
63
  };
50
- //# sourceMappingURL=chunk-UM6DTEFE.js.map
64
+ //# sourceMappingURL=chunk-OY6MO6QQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/segmented-bar.tsx"],"sourcesContent":["import { cn } from '@/lib/utils';\nimport { categorical, categoricalOn, sequential, sequentialOn, chartToken } from './lib/series';\n\nexport interface Segment {\n label: string;\n value: number;\n /** Pull this segment forward (ink) and others recede. */\n active?: boolean;\n}\n\nexport interface SegmentedBarProps {\n data: Segment[];\n /** Bar thickness in px. */\n height?: number;\n /**\n * How segments get colour:\n * - `mono` (default): grayscale, active segment is ink, the rest are muted tints.\n * - `categorical`: the capped unordered palette (≤4 meaningful categories).\n * - `sequential`: single-hue magnitude ramp, in data order.\n */\n scale?: 'mono' | 'categorical' | 'sequential';\n /** Show the label + value row beneath the bar. */\n showLegend?: boolean;\n className?: string;\n}\n\n/**\n * Cairn SegmentedBar, a single horizontal bar split into labelled parts (a share-of-total\n * / stacked bar). Grayscale by default; hue is opt-in via `scale`. Every segment carries a\n * text label + value, so meaning never rests on colour alone (WCAG-safe). Zero-dependency.\n */\nexport function SegmentedBar({ data, height = 40, scale = 'mono', showLegend = true, className }: SegmentedBarProps) {\n // Negative / non-finite segment values would produce invalid or overflowing widths; clamp to 0.\n const safe = (v: number) => (Number.isFinite(v) && v > 0 ? v : 0);\n const total = data.reduce((s, d) => s + safe(d.value), 0) || 1;\n const hasActive = data.some((d) => d.active);\n\n const fill = (d: Segment, i: number): string => {\n if (scale === 'categorical') return categorical(i);\n if (scale === 'sequential') return sequential(i, data.length);\n // mono: ink for the active (or all, when none is active), muted tints otherwise.\n if (!hasActive) return chartToken.ink;\n return d.active ? chartToken.ink : chartToken.muted;\n };\n\n // Accessible foreground paired to each fill, WCAG AA, never a blend mode that guesses.\n const onFill = (d: Segment, i: number): string => {\n if (scale === 'categorical') return categoricalOn(i);\n if (scale === 'sequential') return sequentialOn(i, data.length);\n // mono: white on ink fills, ink on the light muted tint.\n if (!hasActive) return 'var(--sv-sys-color-on-primary)';\n return d.active ? 'var(--sv-sys-color-on-primary)' : 'var(--sv-sys-color-on-surface)';\n };\n\n // A pale muted segment is < 3:1 vs the surface; a keyline round the bar carries its shape\n // contrast (AGENTS.md rule 9). Only needed in mono when some segment recedes to the muted tint.\n const needsEdge = scale === 'mono' && hasActive;\n\n return (\n <div className={cn('w-full', className)}>\n <div\n className=\"flex w-full overflow-hidden rounded-control\"\n style={{\n height,\n ...(needsEdge ? { outline: `1px solid ${chartToken.markEdge}`, outlineOffset: '-1px' } : {}),\n }}\n role=\"img\"\n aria-label={data.map((d) => `${d.label} ${d.value}`).join(', ')}\n >\n {data.map((d, i) => (\n <div\n key={d.label}\n className=\"flex items-center justify-end px-2 first:rounded-l-control last:rounded-r-control\"\n style={{ width: `${(safe(d.value) / total) * 100}%`, background: fill(d, i) }}\n >\n <span className=\"truncate sv-body-xs font-medium tabular-nums\" style={{ color: onFill(d, i) }}>{d.value}</span>\n </div>\n ))}\n </div>\n {showLegend && (\n <ul className=\"mt-3 flex flex-wrap gap-x-4 gap-y-1\">\n {data.map((d, i) => (\n <li key={d.label} className={cn('flex items-center gap-1.5 sv-body-sm', d.active ? 'text-on-surface' : 'text-on-surface-variant')}>\n <span className=\"size-2 shrink-0 rounded-swatch\" style={{ background: fill(d, i) }} aria-hidden=\"true\" />\n {d.label}\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n}\nSegmentedBar.displayName = 'SegmentedBar';\n"],"mappings":";;;;;;;;;;;;AA2EY,cAOA,YAPA;AA5CL,SAAS,aAAa,EAAE,MAAM,SAAS,IAAI,QAAQ,QAAQ,aAAa,MAAM,UAAU,GAAsB;AAEnH,QAAM,OAAO,CAAC,MAAe,OAAO,SAAS,CAAC,KAAK,IAAI,IAAI,IAAI;AAC/D,QAAM,QAAQ,KAAK,OAAO,CAAC,GAAG,MAAM,IAAI,KAAK,EAAE,KAAK,GAAG,CAAC,KAAK;AAC7D,QAAM,YAAY,KAAK,KAAK,CAAC,MAAM,EAAE,MAAM;AAE3C,QAAM,OAAO,CAAC,GAAY,MAAsB;AAC9C,QAAI,UAAU,cAAe,QAAO,YAAY,CAAC;AACjD,QAAI,UAAU,aAAc,QAAO,WAAW,GAAG,KAAK,MAAM;AAE5D,QAAI,CAAC,UAAW,QAAO,WAAW;AAClC,WAAO,EAAE,SAAS,WAAW,MAAM,WAAW;AAAA,EAChD;AAGA,QAAM,SAAS,CAAC,GAAY,MAAsB;AAChD,QAAI,UAAU,cAAe,QAAO,cAAc,CAAC;AACnD,QAAI,UAAU,aAAc,QAAO,aAAa,GAAG,KAAK,MAAM;AAE9D,QAAI,CAAC,UAAW,QAAO;AACvB,WAAO,EAAE,SAAS,mCAAmC;AAAA,EACvD;AAIA,QAAM,YAAY,UAAU,UAAU;AAEtC,SACE,qBAAC,SAAI,WAAW,GAAG,UAAU,SAAS,GACpC;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,OAAO;AAAA,UACL;AAAA,UACA,GAAI,YAAY,EAAE,SAAS,aAAa,WAAW,QAAQ,IAAI,eAAe,OAAO,IAAI,CAAC;AAAA,QAC5F;AAAA,QACA,MAAK;AAAA,QACL,cAAY,KAAK,IAAI,CAAC,MAAM,GAAG,EAAE,KAAK,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,IAAI;AAAA,QAE7D,eAAK,IAAI,CAAC,GAAG,MACZ;AAAA,UAAC;AAAA;AAAA,YAEC,WAAU;AAAA,YACV,OAAO,EAAE,OAAO,GAAI,KAAK,EAAE,KAAK,IAAI,QAAS,GAAG,KAAK,YAAY,KAAK,GAAG,CAAC,EAAE;AAAA,YAE5E,8BAAC,UAAK,WAAU,gDAA+C,OAAO,EAAE,OAAO,OAAO,GAAG,CAAC,EAAE,GAAI,YAAE,OAAM;AAAA;AAAA,UAJnG,EAAE;AAAA,QAKT,CACD;AAAA;AAAA,IACH;AAAA,IACC,cACC,oBAAC,QAAG,WAAU,uCACX,eAAK,IAAI,CAAC,GAAG,MACZ,qBAAC,QAAiB,WAAW,GAAG,wCAAwC,EAAE,SAAS,oBAAoB,yBAAyB,GAC9H;AAAA,0BAAC,UAAK,WAAU,kCAAiC,OAAO,EAAE,YAAY,KAAK,GAAG,CAAC,EAAE,GAAG,eAAY,QAAO;AAAA,MACtG,EAAE;AAAA,SAFI,EAAE,KAGX,CACD,GACH;AAAA,KAEJ;AAEJ;AACA,aAAa,cAAc;","names":[]}