@six-vallees/ui-react 0.1.2 → 0.2.1

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Button,
3
3
  buttonVariants
4
- } from "../chunk-I2PXLL75.js";
4
+ } from "../chunk-KUKSVVDZ.js";
5
5
  import "../chunk-DXRY7AS4.js";
6
6
  export {
7
7
  Button,
@@ -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-UNKWUPX2.js";
3
+ } from "../chunk-L62UZTWJ.js";
4
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-SN3OYOEU.js";
5
- import "../chunk-WBTUZO4N.js";
4
+ } from "../chunk-PJRCDPG5.js";
5
+ import "../chunk-AOULEGMT.js";
6
6
  import "../chunk-DXRY7AS4.js";
7
7
  export {
8
8
  BarChart
@@ -20,9 +20,18 @@ declare const chartToken: {
20
20
  readonly track: "var(--sv-sys-chart-track)";
21
21
  };
22
22
  declare const CATEGORICAL_MAX: 4;
23
- /** Promoted-mark colour for a fixed-shape chart: `ink` by default, categorical blue for `accent`.
24
- * The single definition of the mono `tone` option, shared by BarChart and Ring. */
25
- declare function toneFill(tone: 'ink' | 'accent'): string;
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;
26
35
  /** Colour for category `i` (0-based). Wraps past the cap, pair with a label/pattern. */
27
36
  declare function categorical(i: number): string;
28
37
  /** WCAG-AA foreground for text drawn on `categorical(i)`. */
@@ -32,4 +41,4 @@ declare function sequential(i: number, n: number): string;
32
41
  /** WCAG-AA foreground for text drawn on `sequential(i, n)`. */
33
42
  declare function sequentialOn(i: number, n: number): string;
34
43
 
35
- export { CATEGORICAL_MAX, categorical, categoricalOn, chartToken, sequential, sequentialOn, toneFill };
44
+ export { CATEGORICAL_MAX, categorical, categoricalOn, chartStroke, chartToken, sequential, sequentialOn, toneFill };
@@ -2,15 +2,17 @@ import {
2
2
  CATEGORICAL_MAX,
3
3
  categorical,
4
4
  categoricalOn,
5
+ chartStroke,
5
6
  chartToken,
6
7
  sequential,
7
8
  sequentialOn,
8
9
  toneFill
9
- } from "../../chunk-WBTUZO4N.js";
10
+ } from "../../chunk-AOULEGMT.js";
10
11
  export {
11
12
  CATEGORICAL_MAX,
12
13
  categorical,
13
14
  categoricalOn,
15
+ chartStroke,
14
16
  chartToken,
15
17
  sequential,
16
18
  sequentialOn,
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import {
3
3
  Ring
4
- } from "../chunk-OIL3X3BZ.js";
5
- import "../chunk-WBTUZO4N.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-HXRF55LD.js";
4
- import "../chunk-WBTUZO4N.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-IAKPFV2O.js";
3
+ } from "../chunk-64YDZRCU.js";
4
4
  import "../chunk-27MWE4F5.js";
5
+ import "../chunk-AOULEGMT.js";
5
6
  import "../chunk-DXRY7AS4.js";
6
7
  export {
7
8
  Sparkline
@@ -3,13 +3,26 @@ import {
3
3
  finite,
4
4
  smooth
5
5
  } from "./chunk-27MWE4F5.js";
6
+ import {
7
+ chartStroke,
8
+ toneFill
9
+ } from "./chunk-AOULEGMT.js";
6
10
  import {
7
11
  cn
8
12
  } from "./chunk-DXRY7AS4.js";
9
13
 
10
14
  // src/charts/sparkline.tsx
11
15
  import { jsx, jsxs } from "react/jsx-runtime";
12
- function Sparkline({ data, width = 120, height = 34, type = "line", strokeWidth = 1.75, className }) {
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
+ }) {
13
26
  if (data.length < 2) return null;
14
27
  const values = finite(data);
15
28
  const { min, range } = extent(values);
@@ -18,9 +31,10 @@ function Sparkline({ data, width = 120, height = 34, type = "line", strokeWidth
18
31
  const pts = values.map((v, i) => [i * step, pad + (1 - (v - min) / range) * (height - pad * 2)]);
19
32
  const line = smooth(pts);
20
33
  const area = `${line} L ${width},${height} L 0,${height} Z`;
34
+ const stroke = color ?? toneFill(tone);
21
35
  return /* @__PURE__ */ jsxs("svg", { viewBox: `0 0 ${width} ${height}`, width, height, fill: "none", className: cn("overflow-visible", className), "aria-hidden": "true", children: [
22
- type === "area" && /* @__PURE__ */ jsx("path", { d: area, fill: "currentColor", opacity: "0.12" }),
23
- /* @__PURE__ */ jsx("path", { d: line, stroke: "currentColor", strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" })
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" })
24
38
  ] });
25
39
  }
26
40
  Sparkline.displayName = "Sparkline";
@@ -28,4 +42,4 @@ Sparkline.displayName = "Sparkline";
28
42
  export {
29
43
  Sparkline
30
44
  };
31
- //# sourceMappingURL=chunk-IAKPFV2O.js.map
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":[]}
@@ -44,8 +44,11 @@ var SEQUENTIAL_ON = [
44
44
  "var(--sv-sys-color-on-primary)"
45
45
  // white, on blue.900
46
46
  ];
47
+ var chartStroke = { line: 2, guide: 1 };
47
48
  function toneFill(tone) {
48
- return tone === "accent" ? chartToken.accent : chartToken.ink;
49
+ if (tone === "accent") return chartToken.accent;
50
+ if (tone === "muted") return chartToken.muted;
51
+ return chartToken.ink;
49
52
  }
50
53
  var wrap = (i, n) => (i % n + n) % n;
51
54
  var rampIndex = (i, n) => n <= 1 ? SEQUENTIAL.length - 1 : Math.round(Math.min(Math.max(i / (n - 1), 0), 1) * (SEQUENTIAL.length - 1));
@@ -65,10 +68,11 @@ function sequentialOn(i, n) {
65
68
  export {
66
69
  chartToken,
67
70
  CATEGORICAL_MAX,
71
+ chartStroke,
68
72
  toneFill,
69
73
  categorical,
70
74
  categoricalOn,
71
75
  sequential,
72
76
  sequentialOn
73
77
  };
74
- //# sourceMappingURL=chunk-WBTUZO4N.js.map
78
+ //# sourceMappingURL=chunk-AOULEGMT.js.map
@@ -1 +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/** Promoted-mark colour for a fixed-shape chart: `ink` by default, categorical blue for `accent`.\n * The single definition of the mono `tone` option, shared by BarChart and Ring. */\nexport function toneFill(tone: 'ink' | 'accent'): string {\n return tone === 'accent' ? chartToken.accent : 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;AAIO,SAAS,SAAS,MAAgC;AACvD,SAAO,SAAS,WAAW,WAAW,SAAS,WAAW;AAC5D;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
+ {"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":[]}
@@ -8,7 +8,9 @@ import { Slot } from "@radix-ui/react-slot";
8
8
  import { cva } from "class-variance-authority";
9
9
  import { jsx } from "react/jsx-runtime";
10
10
  var buttonVariants = cva(
11
- "inline-flex items-center justify-center gap-2 leading-none rounded-control font-medium whitespace-nowrap transition-[background-color,border-color,filter] duration-150 outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus disabled:pointer-events-none disabled:opacity-40",
11
+ // A soft accent halo on hover (a fill-grade ring in `accent-halo`, box-shadow so it never shifts
12
+ // layout and coexists with the focus-visible outline). Disabled buttons can't hover, so no halo.
13
+ "inline-flex items-center justify-center gap-2 leading-none rounded-control font-medium whitespace-nowrap transition-[background-color,border-color,box-shadow,filter] duration-150 outline-none hover:[box-shadow:0_0_0_4px_var(--sv-sys-color-accent-halo)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus disabled:pointer-events-none disabled:opacity-40",
12
14
  {
13
15
  variants: {
14
16
  variant: {
@@ -38,4 +40,4 @@ export {
38
40
  buttonVariants,
39
41
  Button
40
42
  };
41
- //# sourceMappingURL=chunk-I2PXLL75.js.map
43
+ //# sourceMappingURL=chunk-KUKSVVDZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/button/button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Slot } from '@radix-ui/react-slot';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from '@/lib/utils';\n\n/**\n * Cairn Button. Consumes the design tokens through the Tailwind bridge\n * (bg-primary, rounded-control, …), install the Cairn theme in the target project.\n */\nconst buttonVariants = cva(\n // A soft accent halo on hover (a fill-grade ring in `accent-halo`, box-shadow so it never shifts\n // layout and coexists with the focus-visible outline). Disabled buttons can't hover, so no halo.\n 'inline-flex items-center justify-center gap-2 leading-none rounded-control font-medium whitespace-nowrap transition-[background-color,border-color,box-shadow,filter] duration-150 outline-none hover:[box-shadow:0_0_0_4px_var(--sv-sys-color-accent-halo)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus disabled:pointer-events-none disabled:opacity-40',\n {\n variants: {\n variant: {\n primary: 'bg-primary text-on-primary hover:bg-primary-hover active:brightness-90',\n secondary:\n 'border border-outline-strong bg-surface text-on-surface hover:bg-surface-subtle active:bg-surface-muted',\n ghost: 'text-on-surface hover:bg-surface-subtle active:bg-surface-muted',\n danger: 'bg-danger text-on-danger hover:brightness-95 active:brightness-90',\n },\n size: {\n sm: 'h-9 px-3 text-sm',\n md: 'h-11 px-5 text-sm',\n lg: 'h-12 px-6 text-base',\n },\n },\n defaultVariants: { variant: 'primary', size: 'md' },\n }\n);\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n /** Visual style of the button. */\n variant?: 'primary' | 'secondary' | 'ghost' | 'danger';\n /** Control height and padding. */\n size?: 'sm' | 'md' | 'lg';\n /** Render as the child element (e.g. an `<a>`) instead of a `<button>`. */\n asChild?: boolean;\n}\n\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : 'button';\n return (\n <Comp ref={ref} className={cn(buttonVariants({ variant, size }), className)} {...props} />\n );\n }\n);\nButton.displayName = 'Button';\n\nexport { buttonVariants };\n"],"mappings":";;;;;AAAA,YAAY,WAAW;AACvB,SAAS,YAAY;AACrB,SAAS,WAA8B;AA6CjC;AAtCN,IAAM,iBAAiB;AAAA;AAAA;AAAA,EAGrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SAAS;AAAA,QACT,WACE;AAAA,QACF,OAAO;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,MACA,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MACN;AAAA,IACF;AAAA,IACA,iBAAiB,EAAE,SAAS,WAAW,MAAM,KAAK;AAAA,EACpD;AACF;AAaO,IAAM,SAAe;AAAA,EAC1B,CAAC,EAAE,WAAW,SAAS,MAAM,UAAU,OAAO,GAAG,MAAM,GAAG,QAAQ;AAChE,UAAM,OAAO,UAAU,OAAO;AAC9B,WACE,oBAAC,QAAK,KAAU,WAAW,GAAG,eAAe,EAAE,SAAS,KAAK,CAAC,GAAG,SAAS,GAAI,GAAG,OAAO;AAAA,EAE5F;AACF;AACA,OAAO,cAAc;","names":[]}
@@ -3,6 +3,11 @@ import {
3
3
  finite,
4
4
  smooth
5
5
  } from "./chunk-27MWE4F5.js";
6
+ import {
7
+ chartStroke,
8
+ chartToken,
9
+ toneFill
10
+ } from "./chunk-AOULEGMT.js";
6
11
  import {
7
12
  cn
8
13
  } from "./chunk-DXRY7AS4.js";
@@ -12,9 +17,10 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
17
  var W = 1e3;
13
18
  var TOP = 26;
14
19
  var BOTTOM = 8;
15
- function AreaChart({ data, height = 240, markerIndex, markerLabel, className }) {
20
+ function AreaChart({ data, height = 240, markerIndex, markerLabel, tone = "ink", color, className }) {
16
21
  const values = finite(data.map((d) => typeof d === "number" ? d : d.value));
17
22
  if (values.length < 2) return null;
23
+ const stroke = color ?? toneFill(tone);
18
24
  const { min, max, range } = extent(values);
19
25
  const stepX = W / (values.length - 1);
20
26
  const labelled = data.filter((d) => typeof d !== "number" && d.label);
@@ -36,13 +42,13 @@ function AreaChart({ data, height = 240, markerIndex, markerLabel, className })
36
42
  fill: "none",
37
43
  "aria-hidden": "true",
38
44
  children: [
39
- /* @__PURE__ */ jsx("path", { d: area, fill: "currentColor", fillOpacity: 0.1 }),
45
+ /* @__PURE__ */ jsx("path", { d: area, fill: stroke, fillOpacity: 0.1 }),
40
46
  /* @__PURE__ */ jsx(
41
47
  "path",
42
48
  {
43
49
  d: line,
44
- stroke: "currentColor",
45
- strokeWidth: 2.5,
50
+ stroke,
51
+ strokeWidth: chartStroke.line,
46
52
  strokeLinecap: "round",
47
53
  strokeLinejoin: "round",
48
54
  vectorEffect: "non-scaling-stroke"
@@ -55,8 +61,8 @@ function AreaChart({ data, height = 240, markerIndex, markerLabel, className })
55
61
  y1: TOP,
56
62
  x2: markerIndex * stepX,
57
63
  y2: height,
58
- stroke: "var(--sv-sys-color-outline-strong)",
59
- strokeWidth: 1,
64
+ stroke: chartToken.axis,
65
+ strokeWidth: chartStroke.guide,
60
66
  vectorEffect: "non-scaling-stroke"
61
67
  }
62
68
  )
@@ -67,8 +73,8 @@ function AreaChart({ data, height = 240, markerIndex, markerLabel, className })
67
73
  /* @__PURE__ */ jsx(
68
74
  "span",
69
75
  {
70
- className: "pointer-events-none absolute size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-[2.5px] border-current bg-surface",
71
- 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 },
72
78
  "aria-hidden": "true"
73
79
  }
74
80
  ),
@@ -88,4 +94,4 @@ AreaChart.displayName = "AreaChart";
88
94
  export {
89
95
  AreaChart
90
96
  };
91
- //# sourceMappingURL=chunk-UNKWUPX2.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,S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EGMT.js";
8
8
  import {
9
9
  cn
10
10
  } from "./chunk-DXRY7AS4.js";
@@ -51,7 +51,7 @@ function SegmentedBar({ data, height = 40, scale = "mono", showLegend = true, cl
51
51
  }
52
52
  ),
53
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: [
54
- /* @__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" }),
55
55
  d.label
56
56
  ] }, d.label)) })
57
57
  ] });
@@ -61,4 +61,4 @@ SegmentedBar.displayName = "SegmentedBar";
61
61
  export {
62
62
  SegmentedBar
63
63
  };
64
- //# sourceMappingURL=chunk-HXRF55LD.js.map
64
+ //# sourceMappingURL=chunk-OY6MO6QQ.js.map
@@ -1 +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-[2px]\" 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,iCAAgC,OAAO,EAAE,YAAY,KAAK,GAAG,CAAC,EAAE,GAAG,eAAY,QAAO;AAAA,MACrG,EAAE;AAAA,SAFI,EAAE,KAGX,CACD,GACH;AAAA,KAEJ;AAEJ;AACA,aAAa,cAAc;","names":[]}
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,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 BarChart.displayName = "BarChart";
86
86
  export {
87
87
  BarChart
88
88
  };
89
- //# sourceMappingURL=chunk-SN3OYOEU.js.map
89
+ //# sourceMappingURL=chunk-PJRCDPG5.js.map
@@ -3,7 +3,7 @@
3
3
  import {
4
4
  chartToken,
5
5
  toneFill
6
- } from "./chunk-WBTUZO4N.js";
6
+ } from "./chunk-AOULEGMT.js";
7
7
  import {
8
8
  cn
9
9
  } from "./chunk-DXRY7AS4.js";
@@ -95,4 +95,4 @@ Ring.displayName = "Ring";
95
95
  export {
96
96
  Ring
97
97
  };
98
- //# sourceMappingURL=chunk-OIL3X3BZ.js.map
98
+ //# sourceMappingURL=chunk-X3LG535W.js.map
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export { BarChart, BarChartProps, BarDatum } from './charts/bar-chart.js';
8
8
  export { Stat, StatProps } from './charts/stat.js';
9
9
  export { Ring, RingProps } from './charts/ring.js';
10
10
  export { Segment, SegmentedBar, SegmentedBarProps } from './charts/segmented-bar.js';
11
- export { CATEGORICAL_MAX, categorical, categoricalOn, chartToken, sequential, sequentialOn, toneFill } from './charts/lib/series.js';
11
+ export { CATEGORICAL_MAX, categorical, categoricalOn, chartStroke, chartToken, sequential, sequentialOn, toneFill } from './charts/lib/series.js';
12
12
  import 'class-variance-authority/types';
13
13
  import 'react';
14
14
  import 'class-variance-authority';
package/dist/index.js CHANGED
@@ -10,32 +10,33 @@ import {
10
10
  import {
11
11
  Button,
12
12
  buttonVariants
13
- } from "./chunk-I2PXLL75.js";
13
+ } from "./chunk-KUKSVVDZ.js";
14
14
  import {
15
15
  AreaChart
16
- } from "./chunk-UNKWUPX2.js";
16
+ } from "./chunk-L62UZTWJ.js";
17
17
  import {
18
18
  BarChart
19
- } from "./chunk-SN3OYOEU.js";
19
+ } from "./chunk-PJRCDPG5.js";
20
20
  import {
21
21
  Ring
22
- } from "./chunk-OIL3X3BZ.js";
22
+ } from "./chunk-X3LG535W.js";
23
23
  import {
24
24
  SegmentedBar
25
- } from "./chunk-HXRF55LD.js";
25
+ } from "./chunk-OY6MO6QQ.js";
26
+ import {
27
+ Sparkline
28
+ } from "./chunk-64YDZRCU.js";
29
+ import "./chunk-27MWE4F5.js";
26
30
  import {
27
31
  CATEGORICAL_MAX,
28
32
  categorical,
29
33
  categoricalOn,
34
+ chartStroke,
30
35
  chartToken,
31
36
  sequential,
32
37
  sequentialOn,
33
38
  toneFill
34
- } from "./chunk-WBTUZO4N.js";
35
- import {
36
- Sparkline
37
- } from "./chunk-IAKPFV2O.js";
38
- import "./chunk-27MWE4F5.js";
39
+ } from "./chunk-AOULEGMT.js";
39
40
  import {
40
41
  Stat
41
42
  } from "./chunk-5DZPPT7X.js";
@@ -55,6 +56,7 @@ export {
55
56
  buttonVariants,
56
57
  categorical,
57
58
  categoricalOn,
59
+ chartStroke,
58
60
  chartToken,
59
61
  sequential,
60
62
  sequentialOn,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@six-vallees/ui-react",
3
- "version": "0.1.2",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "description": "Cairn React components — the Six Vallées design system UI, driven by the Cairn tokens.",
6
6
  "license": "UNLICENSED",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/button/button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Slot } from '@radix-ui/react-slot';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from '@/lib/utils';\n\n/**\n * Cairn Button. Consumes the design tokens through the Tailwind bridge\n * (bg-primary, rounded-control, …), install the Cairn theme in the target project.\n */\nconst buttonVariants = cva(\n 'inline-flex items-center justify-center gap-2 leading-none rounded-control font-medium whitespace-nowrap transition-[background-color,border-color,filter] duration-150 outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus disabled:pointer-events-none disabled:opacity-40',\n {\n variants: {\n variant: {\n primary: 'bg-primary text-on-primary hover:bg-primary-hover active:brightness-90',\n secondary:\n 'border border-outline-strong bg-surface text-on-surface hover:bg-surface-subtle active:bg-surface-muted',\n ghost: 'text-on-surface hover:bg-surface-subtle active:bg-surface-muted',\n danger: 'bg-danger text-on-danger hover:brightness-95 active:brightness-90',\n },\n size: {\n sm: 'h-9 px-3 text-sm',\n md: 'h-11 px-5 text-sm',\n lg: 'h-12 px-6 text-base',\n },\n },\n defaultVariants: { variant: 'primary', size: 'md' },\n }\n);\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n /** Visual style of the button. */\n variant?: 'primary' | 'secondary' | 'ghost' | 'danger';\n /** Control height and padding. */\n size?: 'sm' | 'md' | 'lg';\n /** Render as the child element (e.g. an `<a>`) instead of a `<button>`. */\n asChild?: boolean;\n}\n\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : 'button';\n return (\n <Comp ref={ref} className={cn(buttonVariants({ variant, size }), className)} {...props} />\n );\n }\n);\nButton.displayName = 'Button';\n\nexport { buttonVariants };\n"],"mappings":";;;;;AAAA,YAAY,WAAW;AACvB,SAAS,YAAY;AACrB,SAAS,WAA8B;AA2CjC;AApCN,IAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SAAS;AAAA,QACT,WACE;AAAA,QACF,OAAO;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,MACA,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MACN;AAAA,IACF;AAAA,IACA,iBAAiB,EAAE,SAAS,WAAW,MAAM,KAAK;AAAA,EACpD;AACF;AAaO,IAAM,SAAe;AAAA,EAC1B,CAAC,EAAE,WAAW,SAAS,MAAM,UAAU,OAAO,GAAG,MAAM,GAAG,QAAQ;AAChE,UAAM,OAAO,UAAU,OAAO;AAC9B,WACE,oBAAC,QAAK,KAAU,WAAW,GAAG,eAAe,EAAE,SAAS,KAAK,CAAC,GAAG,SAAS,GAAI,GAAG,OAAO;AAAA,EAE5F;AACF;AACA,OAAO,cAAc;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/charts/sparkline.tsx"],"sourcesContent":["import { cn } from '@/lib/utils';\nimport { smooth, finite, extent } from './lib/path';\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 strokeWidth?: number;\n className?: string;\n}\n\n/** Cairn Sparkline, a compact, axis-less trend line. Colour follows currentColor. */\nexport function Sparkline({ data, width = 120, height = 34, type = 'line', strokeWidth = 1.75, className }: 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 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=\"currentColor\" opacity=\"0.12\" />}\n <path d={line} stroke=\"currentColor\" strokeWidth={strokeWidth} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n );\n}\nSparkline.displayName = 'Sparkline';\n"],"mappings":";;;;;;;;;;AAyBI,SACsB,KADtB;AAVG,SAAS,UAAU,EAAE,MAAM,QAAQ,KAAK,SAAS,IAAI,OAAO,QAAQ,cAAc,MAAM,UAAU,GAAmB;AAC1H,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,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,MAAK,gBAAe,SAAQ,QAAO;AAAA,IACtE,oBAAC,UAAK,GAAG,MAAM,QAAO,gBAAe,aAA0B,eAAc,SAAQ,gBAAe,SAAQ;AAAA,KAC9G;AAEJ;AACA,UAAU,cAAc;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/charts/area-chart.tsx"],"sourcesContent":["import { cn } from '@/lib/utils';\nimport { smooth, finite, extent } from './lib/path';\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 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. Colour follows `currentColor`.\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, className }: AreaChartProps) {\n const values = finite(data.map((d) => (typeof d === 'number' ? d : d.value)));\n if (values.length < 2) return null;\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=\"currentColor\" fillOpacity={0.1} />\n <path\n d={line}\n stroke=\"currentColor\"\n strokeWidth={2.5}\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=\"var(--sv-sys-color-outline-strong)\"\n strokeWidth={1}\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.5px] border-current bg-surface\"\n style={{ left: `${markLeft}%`, top: y(values[markerIndex!]) }}\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 );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