@senvenli/react 0.2.0 → 0.3.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.
Files changed (43) hide show
  1. package/dist/charts/chart-parts.d.ts +21 -5
  2. package/dist/charts/chart-parts.js +31 -15
  3. package/dist/charts/chart-parts.js.map +1 -1
  4. package/dist/charts/core-charts.d.ts +2 -2
  5. package/dist/charts/core-charts.js +2 -2
  6. package/dist/charts/core-charts.js.map +1 -1
  7. package/dist/charts/list-charts.d.ts +4 -4
  8. package/dist/charts/list-charts.js +8 -8
  9. package/dist/charts/list-charts.js.map +1 -1
  10. package/dist/charts/more-charts.d.ts +9 -7
  11. package/dist/charts/more-charts.js +12 -12
  12. package/dist/charts/more-charts.js.map +1 -1
  13. package/dist/charts/report-charts.d.ts +2 -2
  14. package/dist/charts/report-charts.js +4 -4
  15. package/dist/charts/report-charts.js.map +1 -1
  16. package/dist/collection/table.js +4 -1
  17. package/dist/collection/table.js.map +1 -1
  18. package/dist/navigation/accordion.js +1 -1
  19. package/dist/navigation/accordion.js.map +1 -1
  20. package/dist/navigation/navbar.js +4 -2
  21. package/dist/navigation/navbar.js.map +1 -1
  22. package/dist/navigation/pagination.js +1 -1
  23. package/dist/navigation/pagination.js.map +1 -1
  24. package/dist/navigation/tabs.js +2 -2
  25. package/dist/navigation/tabs.js.map +1 -1
  26. package/manifests/area-chart.json +46 -1
  27. package/manifests/bar-chart.json +46 -0
  28. package/manifests/bar-list.json +6 -0
  29. package/manifests/calendar-heatmap.json +6 -0
  30. package/manifests/chart-parts.json +48 -1
  31. package/manifests/composed-chart.json +46 -1
  32. package/manifests/donut-chart.json +46 -1
  33. package/manifests/fab.json +10 -0
  34. package/manifests/funnel-chart.json +6 -0
  35. package/manifests/gauge-chart.json +46 -1
  36. package/manifests/heatmap.json +6 -0
  37. package/manifests/line-chart.json +46 -1
  38. package/manifests/radar-chart.json +46 -1
  39. package/manifests/radial-chart.json +46 -1
  40. package/manifests/scatter-chart.json +46 -1
  41. package/manifests/sparkline.json +6 -1
  42. package/manifests/tracker.json +6 -0
  43. package/package.json +2 -2
@@ -107,7 +107,22 @@ export type ChartDataTable<T> = {
107
107
  /** Opens a row's item from the shown table: the keyboard's way to what a press on a data point opens. */
108
108
  onRowAction?: (row: T) => void;
109
109
  };
110
- export type ChartFrameProps<T> = {
110
+ /** How a chart offers its data as a table. */
111
+ export type ChartTableView = "swap" | "hidden" | "none";
112
+ /** The data-table options every chart takes. */
113
+ export type ChartTableProps = {
114
+ /**
115
+ * How the data is offered as a table. `swap` (default): a toggle at the end of the chart's top row turns the plot
116
+ * into the table at the same height, scrolling inside, so the card never grows. `hidden`: no toggle; the table is
117
+ * there for screen readers only. `none`: no table at all, for a chart that is already text (BarList).
118
+ */
119
+ tableView?: ChartTableView;
120
+ /** The table is showing (`swap`), controlled; or `defaultTableOpen` + `onTableOpenChange`. */
121
+ isTableOpen?: boolean;
122
+ defaultTableOpen?: boolean;
123
+ onTableOpenChange?: (isOpen: boolean) => void;
124
+ };
125
+ export type ChartFrameProps<T> = ChartTableProps & {
111
126
  /** The chart's height in px: loading, empty and the plot all keep it. */
112
127
  height: number;
113
128
  isLoading?: boolean;
@@ -129,8 +144,9 @@ export type ChartFrameProps<T> = {
129
144
  children: React.ReactNode;
130
145
  };
131
146
  /**
132
- * The frame every chart sits in. While loading, a Skeleton at the chart's real size; with nothing to
133
- * draw, a compact EmptyState in the same space; otherwise the plot. Under every chart a "Show the data
134
- * as a table" button shows the same data as a compact Table, which screen readers get by default.
147
+ * The frame every chart sits in. While loading, a Skeleton at the chart's real size; with nothing to draw, a compact
148
+ * EmptyState in the same space; otherwise the plot. The data as a table (`tableView`): by default a toggle at the end
149
+ * of the top row swaps the plot for the same data as a compact Table at the same height, scrolling inside, so the
150
+ * card never changes size; with the plot showing, screen readers still get the table (visually hidden).
135
151
  */
136
- export declare function ChartFrame<T extends object>({ height, isLoading, emptyState, dataTable, legend, legendPlacement, children }: ChartFrameProps<T>): React.JSX.Element;
152
+ export declare function ChartFrame<T extends object>({ height, isLoading, emptyState, dataTable, legend, legendPlacement, tableView, isTableOpen, defaultTableOpen, onTableOpenChange, children, }: ChartFrameProps<T>): React.JSX.Element;
@@ -1,14 +1,17 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
- import { Button as AriaButton, useLocale } from "react-aria-components";
4
+ import { Button as AriaButton, ToggleButton as AriaToggleButton, useLocale } from "react-aria-components";
5
5
  import { cn } from "../utils.js";
6
+ import { TouchTarget } from "../action/touch-target.js";
6
7
  import { useMotionSetting } from "../defaults.js";
7
8
  /** The OS reduced-motion preference. */
8
9
  const REDUCED_MOTION_QUERY = "(prefers-reduced-motion: reduce)";
9
10
  import { Table } from "../collection/table.js";
10
11
  import { EmptyState } from "../feedback/empty-state.js";
11
12
  import { Skeleton } from "../feedback/skeleton.js";
13
+ import { TooltipFor } from "../overlay/floating.js";
14
+ import { IconGlyph } from "../display/icon.js";
12
15
  import { hideDataTableLabel, showDataTableLabel } from "../i18n.js";
13
16
  /* ── Colors ─────────────────────────────────────────────────────────────── */
14
17
  /** The categorical chart colors, in order; never hex in a chart. */
@@ -108,20 +111,28 @@ export function ChartLegend({ items, hidden, onToggle }) {
108
111
  return (_jsx("div", { "data-slot": "chart-legend", className: "flex flex-wrap items-center gap-x-ds-200 gap-y-ds-050 text-body-small text-ds-text-subtle", children: items.map((item) => {
109
112
  const isHidden = hidden?.has(item.key) ?? false;
110
113
  const key = item.kind === "line" ? (_jsx("svg", { "aria-hidden": true, "data-slot": "chart-legend-key", "data-kind": "line", width: "16", height: "2", className: "shrink-0 overflow-visible", children: _jsx("line", { x1: "0", y1: "1", x2: "16", y2: "1", stroke: item.color, strokeWidth: "2", strokeDasharray: item.strokeDasharray }) })) : (_jsx("span", { "aria-hidden": true, "data-slot": "chart-legend-key", "data-kind": item.kind ?? "area", className: "size-2.5 shrink-0 rounded-ds-xsmall", style: { background: item.color } }));
111
- return onToggle ? (_jsxs(AriaButton, { "aria-pressed": !isHidden, "data-slot": "chart-legend-item", onPress: () => onToggle(item.key), className: cn("inline-flex cursor-pointer items-center gap-ds-075 rounded-ds-small outline-hidden data-[hovered]:text-ds-text", "data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused", isHidden && "opacity-45"), children: [key, item.label] }, item.key)) : (_jsxs("span", { "data-slot": "chart-legend-item", className: "inline-flex items-center gap-ds-075", children: [key, item.label] }, item.key));
114
+ return onToggle ? (_jsxs(AriaButton, { "aria-pressed": !isHidden, "data-slot": "chart-legend-item", onPress: () => onToggle(item.key), className: cn("relative inline-flex cursor-pointer items-center gap-ds-075 rounded-ds-small outline-hidden data-[hovered]:text-ds-text", "data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused", isHidden && "opacity-45"), children: [_jsx(TouchTarget, {}), key, item.label] }, item.key)) : (_jsxs("span", { "data-slot": "chart-legend-item", className: "inline-flex items-center gap-ds-075", children: [key, item.label] }, item.key));
112
115
  }) }));
113
116
  }
114
117
  /**
115
- * The frame every chart sits in. While loading, a Skeleton at the chart's real size; with nothing to
116
- * draw, a compact EmptyState in the same space; otherwise the plot. Under every chart a "Show the data
117
- * as a table" button shows the same data as a compact Table, which screen readers get by default.
118
+ * The frame every chart sits in. While loading, a Skeleton at the chart's real size; with nothing to draw, a compact
119
+ * EmptyState in the same space; otherwise the plot. The data as a table (`tableView`): by default a toggle at the end
120
+ * of the top row swaps the plot for the same data as a compact Table at the same height, scrolling inside, so the
121
+ * card never changes size; with the plot showing, screen readers still get the table (visually hidden).
118
122
  */
119
- export function ChartFrame({ height, isLoading, emptyState, dataTable, legend, legendPlacement = "top", children }) {
123
+ export function ChartFrame({ height, isLoading, emptyState, dataTable, legend, legendPlacement = "top", tableView = "swap", isTableOpen, defaultTableOpen = false, onTableOpenChange, children, }) {
120
124
  const { locale } = useLocale();
121
- const [showTable, setShowTable] = React.useState(false);
122
- const tableId = React.useId();
125
+ const [ownOpen, setOwnOpen] = React.useState(defaultTableOpen);
126
+ const regionId = React.useId();
123
127
  const isEmpty = emptyState !== undefined && emptyState !== null && emptyState !== false;
124
128
  const hasData = !isLoading && !isEmpty;
129
+ const swaps = tableView === "swap";
130
+ const open = swaps && hasData && (isTableOpen ?? ownOpen);
131
+ const setOpen = (next) => {
132
+ if (isTableOpen === undefined)
133
+ setOwnOpen(next);
134
+ onTableOpenChange?.(next);
135
+ };
125
136
  const { rows, rowKey = (row) => row.id, onRowAction } = dataTable;
126
137
  const rowAction = onRowAction && ((key) => {
127
138
  const row = rows.find((candidate) => String(rowKey(candidate)) === String(key));
@@ -130,19 +141,24 @@ export function ChartFrame({ height, isLoading, emptyState, dataTable, legend, l
130
141
  });
131
142
  const plot = isLoading ? (_jsxs("div", { "data-slot": "chart-loading", "aria-busy": "true", style: { height }, className: "flex flex-col gap-ds-150", children: [_jsx(Skeleton, { width: "40%", height: 16 }), _jsx(Skeleton, { height: Math.max(0, height - 16 - 12), radius: "medium" })] })) : isEmpty ? (
132
143
  // At least the chart's height; a very short chart grows rather than clipping the message.
133
- _jsx("div", { "data-slot": "chart-empty", style: { minHeight: height }, className: "grid place-items-center", children: emptyState })) : (_jsx("div", { role: "group", "aria-label": dataTable.caption, "data-slot": "chart-plot", style: { height }, className: cn("min-w-0",
144
+ _jsx("div", { "data-slot": "chart-empty", style: { minHeight: height }, className: "grid place-items-center", children: emptyState })) : open ? (
145
+ // The table in the plot's place, at the plot's height: it scrolls inside, so nothing around it moves.
146
+ _jsx("div", { id: regionId, "data-slot": "chart-data-table", style: { height }, className: "flex min-w-0 flex-col", children: _jsx(Table, { "aria-label": dataTable.caption, density: "compact", maxHeight: `${height}px`, columns: dataTable.columns, rows: dataTable.rows, rowKey: dataTable.rowKey, onRowAction: rowAction }) })) : (_jsxs("div", { id: regionId, role: "group", "aria-label": dataTable.caption, "data-slot": "chart-plot", style: { height }, className: cn("min-w-0",
134
147
  // Recharts places SVG text for LTR; an inherited rtl flips its anchors (labels over bars, clipped
135
148
  // reference labels). The plot stays ltr inside; useChartDirection mirrors the axes themselves.
136
149
  "[&_.recharts-wrapper]:[direction:ltr]",
137
150
  // Recharts' keyboard layer: its focusable surface takes the DS focus border, drawn inside the plot (an inset
138
151
  // outline, as an inset ring would be on an element; an SVG has none). The style is named: Tailwind v4's
139
152
  // outline-hidden sets the outline style to none, and a width alone keeps it.
140
- "[&_.recharts-surface]:outline-hidden [&_.recharts-surface:focus-visible]:rounded-ds-small [&_.recharts-surface:focus-visible]:outline-2", "[&_.recharts-surface:focus-visible]:outline-solid", "[&_.recharts-surface:focus-visible]:-outline-offset-2 [&_.recharts-surface:focus-visible]:outline-ds-border-focused"), children: children }));
153
+ "[&_.recharts-surface]:outline-hidden [&_.recharts-surface:focus-visible]:rounded-ds-small [&_.recharts-surface:focus-visible]:outline-2", "[&_.recharts-surface:focus-visible]:outline-solid", "[&_.recharts-surface:focus-visible]:-outline-offset-2 [&_.recharts-surface:focus-visible]:outline-ds-border-focused"), children: [children, tableView !== "none" && (_jsx("div", { "data-slot": "chart-data-table", className: "relative overflow-hidden", children: _jsx(PlainTable, { caption: dataTable.caption, columns: dataTable.columns, rows: dataTable.rows, rowKey: dataTable.rowKey }) }))] }));
141
154
  const legendRow = legend && (hasData ? legend : _jsx("div", { "aria-hidden": true, inert: true, className: "invisible", children: legend }));
142
- return (_jsxs("div", { "data-slot": "chart-frame", className: "flex min-w-0 flex-col gap-ds-150", children: [legendPlacement === "top" && legendRow, plot, legendPlacement === "bottom" && legendRow, hasData ? (_jsxs(_Fragment, { children: [_jsx(AriaButton, { "aria-expanded": showTable, "aria-controls": tableId, "data-slot": "chart-table-toggle", onPress: () => setShowTable((value) => !value), className: "w-max cursor-pointer rounded-ds-small text-body-small font-[500] text-ds-link outline-hidden data-[hovered]:underline data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused", children: showTable ? hideDataTableLabel(locale) : showDataTableLabel(locale) }), _jsx("div", { id: tableId, "data-slot": "chart-data-table", className: showTable ? undefined : "relative overflow-hidden", children: showTable ? (_jsx(Table, { "aria-label": dataTable.caption, density: "compact", columns: dataTable.columns, rows: dataTable.rows, rowKey: dataTable.rowKey, onRowAction: rowAction })) : (
143
- // Collapsed: the same data as a plain table, for screen readers only. Nothing in it takes focus,
144
- // so Tab never lands in something unseen.
145
- _jsx(PlainTable, { caption: dataTable.caption, columns: dataTable.columns, rows: dataTable.rows, rowKey: dataTable.rowKey })) })] })) : (_jsx("div", { "aria-hidden": true, className: "h-4", "data-slot": "chart-table-toggle-space" }))] }));
155
+ // The toggle: an icon button that stays where it is (focus stays on it) while the region beside it swaps. Loading
156
+ // and empty keep its place, invisible, so the row does not jump when data arrives.
157
+ const toggle = swaps ? (hasData ? (
158
+ // TooltipFor: the toggle is itself a React Aria focusable, so it takes the trigger props directly.
159
+ _jsx(TooltipFor, { content: open ? hideDataTableLabel(locale) : showDataTableLabel(locale), children: _jsxs(AriaToggleButton, { isSelected: open, onChange: setOpen, "aria-label": showDataTableLabel(locale), "aria-controls": regionId, "data-slot": "chart-table-toggle", className: cn("relative ms-auto grid size-7 shrink-0 cursor-pointer place-items-center rounded-ds-control-small text-ds-icon-subtle outline-hidden", "data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[hovered]:text-ds-icon", "data-[selected]:bg-ds-background-selected data-[selected]:text-ds-icon-brand", "data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused"), children: [_jsx(TouchTarget, {}), _jsx(IconGlyph, { name: open ? "chart-column" : "table" })] }) })) : (_jsx("span", { "aria-hidden": true, "data-slot": "chart-table-toggle-space", className: "ms-auto size-7 shrink-0" }))) : null;
160
+ const topLegend = legendPlacement === "top" ? legendRow : null;
161
+ return (_jsxs("div", { "data-slot": "chart-frame", className: "flex min-w-0 flex-col gap-ds-150", children: [(topLegend || toggle) && (_jsxs("div", { "data-slot": "chart-top", className: "flex min-w-0 items-start gap-ds-200", children: [topLegend && _jsx("div", { className: "min-w-0 flex-1", children: topLegend }), toggle] })), plot, legendPlacement === "bottom" && legendRow] }));
146
162
  }
147
163
  /** The data table as plain, non-interactive markup, visually hidden: what screen readers get by default. */
148
164
  function PlainTable({ caption, columns, rows, rowKey = (row) => row.id }) {
@@ -1 +1 @@
1
- {"version":3,"file":"chart-parts.js","sourceRoot":"","sources":["../../src/charts/chart-parts.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,wCAAwC;AACxC,MAAM,oBAAoB,GAAG,kCAAkC,CAAC;AAChE,OAAO,EAAE,KAAK,EAAoB,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEjE,+EAA+E;AAE/E,oEAAoE;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,CAAU,CAAC;AAC/I,0DAA0D;AAC1D,MAAM,CAAC,MAAM,aAAa,GAAG,yBAAyB,CAAC;AACvD,wEAAwE;AACxE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,MAAM,CAA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EAAE,KAAK,EAAE,EAAE;wBAC7B,MAAM,GAAG,GAAI,GAAuC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;wBACjE,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;wBACtC,kFAAkF;wBAClF,MAAM,KAAK,GAAG,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC;wBAC5F,MAAM,QAAQ,GAAG,KAAK,KAAK,SAAS,CAAC;wBACrC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAChB,aAAqB,KAAK,EAAC,KAAK,YAC7B,KAAK,IADC,MAAM,CAAC,GAAG,CAEd,CACN,CAAC,CAAC,CAAC,CACF,uBAAsB,KAAK,IAAlB,MAAM,CAAC,GAAG,CAAc,CAClC,CAAC;oBACJ,CAAC,CAAC,IAdK,MAAM,CAAC,GAAG,CAAC,CAef,CACN,CAAC,GACI,IACF,CACT,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Button as AriaButton, useLocale } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { useMotionSetting } from \"../defaults\";\n/** The OS reduced-motion preference. */\nconst REDUCED_MOTION_QUERY = \"(prefers-reduced-motion: reduce)\";\nimport { Table, type TableColumn } from \"../collection/table\";\nimport { EmptyState } from \"../feedback/empty-state\";\nimport { Skeleton } from \"../feedback/skeleton\";\nimport { hideDataTableLabel, showDataTableLabel } from \"../i18n\";\n\n/* ── Colors ─────────────────────────────────────────────────────────────── */\n\n/** The categorical chart colors, in order; never hex in a chart. */\nexport const CHART_COLORS = [\"var(--ds-chart-1)\", \"var(--ds-chart-2)\", \"var(--ds-chart-3)\", \"var(--ds-chart-4)\", \"var(--ds-chart-5)\"] as const;\n/** Comparison series (last year, the target, \"other\"). */\nexport const CHART_NEUTRAL = \"var(--ds-chart-neutral)\";\n/** The color of the n-th series (0-based), cycling through the five. */\nexport const chartColor = (index: number) => CHART_COLORS[((index % CHART_COLORS.length) + CHART_COLORS.length) % CHART_COLORS.length]!;\n\n/** Dash patterns for line series beyond the second: told apart by pattern, not hue alone. */\nconst LINE_DASHES = [\"6 4\", \"2 3\", \"8 3 2 3\"] as const;\n\nexport type ChartSeriesStyle = { color: string; strokeDasharray?: string };\n\n/**\n * How the n-th series (0-based) is drawn. The chart\n * colors share one lightness, so series are told apart by lightness or pattern, never hue alone: the\n * first series is the brand color, a comparison series (last year, the target) is `ds-chart-neutral`,\n * lines after the second are dashed, and every series carries a legend key or a direct label. Bars and\n * areas take no pattern: their legend key or direct label tells them apart.\n */\nexport function chartSeries(index: number, options: { kind?: \"line\" | \"area\" | \"bar\"; isComparison?: boolean } = {}): ChartSeriesStyle {\n const color = options.isComparison ? CHART_NEUTRAL : chartColor(index);\n const strokeDasharray = options.kind === \"line\" && index >= 2 ? LINE_DASHES[(index - 2) % LINE_DASHES.length] : undefined;\n return strokeDasharray ? { color, strokeDasharray } : { color };\n}\n\n/* ── Animation ───────────────────────────────────────────────────────────── */\n\nconst ChartAnimationContext = React.createContext(true);\n\n/**\n * Turns chart animation off for everything inside, deterministically: snapshot tests and the DS lab\n * render the final frame at once. Reduced motion turns it off without this.\n */\nexport function ChartAnimation({ isEnabled, children }: { isEnabled: boolean; children: React.ReactNode }) {\n return <ChartAnimationContext.Provider value={isEnabled}>{children}</ChartAnimationContext.Provider>;\n}\n\nfunction subscribeReducedMotion(listener: () => void) {\n if (typeof window === \"undefined\" || !window.matchMedia) return () => {};\n const media = window.matchMedia(REDUCED_MOTION_QUERY);\n media.addEventListener(\"change\", listener);\n return () => media.removeEventListener(\"change\", listener);\n}\nconst reducedMotionNow = () => typeof window !== \"undefined\" && !!window.matchMedia?.(REDUCED_MOTION_QUERY).matches;\n\n/** Whether a chart may animate: pass it to Recharts' `isAnimationActive`. */\nexport function useChartAnimation(): boolean {\n const enabled = React.useContext(ChartAnimationContext);\n const reduced = React.useSyncExternalStore(subscribeReducedMotion, reducedMotionNow, () => false);\n const setting = useMotionSetting();\n return enabled && !reduced && setting === \"auto\";\n}\n\n/* ── Direction ───────────────────────────────────────────────────────────── */\n\n/**\n * How a cartesian chart follows the reading direction: in RTL time runs from the right, so the category\n * axis is reversed and the value axis sits on the right. Spread into Recharts' axes:\n * `<XAxis reversed={direction.reversed} />`, `<YAxis orientation={direction.valueAxis} />`.\n */\nexport function useChartDirection(): { isRtl: boolean; reversed: boolean; valueAxis: \"left\" | \"right\" } {\n const { direction } = useLocale();\n const isRtl = direction === \"rtl\";\n return { isRtl, reversed: isRtl, valueAxis: isRtl ? \"right\" : \"left\" };\n}\n\n/* ── Series visibility (the legend's toggle) ─────────────────────────────── */\n\n/** Which series the legend has hidden; charts skip (or fade) hidden series. */\nexport function useChartSeries() {\n const [hidden, setHidden] = React.useState<ReadonlySet<string>>(new Set());\n const toggle = React.useCallback((key: string) => {\n setHidden((current) => {\n const next = new Set(current);\n if (next.has(key)) next.delete(key);\n else next.add(key);\n return next;\n });\n }, []);\n const isHidden = React.useCallback((key: string) => hidden.has(key), [hidden]);\n return { hidden, toggle, isHidden };\n}\n\n/* ── Tooltip ─────────────────────────────────────────────────────────────── */\n\nexport type ChartValueFormatter = (value: number) => string;\n\n/** One series in the tooltip, as Recharts hands it over. */\nexport type ChartTooltipEntry = { dataKey?: string | number; name?: string | number; value?: unknown; color?: string; stroke?: string; fill?: string };\n\nexport type ChartTooltipProps = {\n /** Set by Recharts when used as `<Tooltip content={<ChartTooltip … />} />`. */\n active?: boolean;\n payload?: readonly ChartTooltipEntry[];\n label?: unknown;\n /** Shared with the chart: \"€ 55,0k\". */\n valueFormatter?: ChartValueFormatter;\n /** The period title (\"August 2026\"); the category label by default. */\n labelFormatter?: (label: unknown) => React.ReactNode;\n /** Series names by data key (\"2026\", \"Website\"). */\n labels?: Readonly<Record<string, string>>;\n /** An optional change row, colored by meaning (\"Change +11.8%\"). */\n change?: (payload: readonly ChartTooltipEntry[]) => { label: string; value: string; tone: \"success\" | \"danger\" | \"neutral\" } | null;\n};\n\nconst CHANGE_TONE = { success: \"text-ds-text-success\", danger: \"text-ds-text-danger\", neutral: \"text-ds-text-subtle\" } as const;\n\n/**\n * The tooltip every chart uses: the period as title, one row per series with its color key and value\n * in tabular figures, and an optional change row. On `ds-surface-overlay`. It follows keyboard focus on\n * data points as well as the pointer (Recharts' accessibility layer moves it with the arrow keys).\n */\nexport function ChartTooltip({ active, payload, label, valueFormatter = String, labelFormatter, labels, change }: ChartTooltipProps) {\n // Recharts draws the tooltip inside its wrapper, which the plot keeps left to right (ChartFrame): the tooltip takes the\n // page's direction back, so its rows read and align as the page does.\n const { direction } = useLocale();\n if (!active || !payload?.length) return null;\n const changeRow = change?.(payload);\n return (\n <div data-slot=\"chart-tooltip\" dir={direction} className=\"flex min-w-36 flex-col gap-ds-050 rounded-ds-medium bg-ds-surface-overlay px-ds-150 py-ds-100 text-body-small text-ds-text shadow-ds-overlay\">\n <span className=\"text-body-strong\">{labelFormatter ? labelFormatter(label) : String(label ?? \"\")}</span>\n {payload.map((entry, index) => {\n const key = String(entry.dataKey ?? entry.name ?? \"\");\n return (\n // By position too: a composed chart may draw one key twice (an area and a line on revenue).\n <span key={`${index}-${key}`} data-slot=\"chart-tooltip-row\" className=\"flex items-center gap-ds-100\">\n <span aria-hidden className=\"size-2.5 shrink-0 rounded-ds-xsmall\" style={{ background: entry.color ?? entry.stroke ?? entry.fill }} />\n <span className=\"text-ds-text-subtle\">{labels?.[key] ?? String(entry.name ?? key)}</span>\n <bdi className=\"ms-auto ps-ds-200 font-medium tabular-nums\">{typeof entry.value === \"number\" ? valueFormatter(entry.value) : String(entry.value ?? \"\")}</bdi>\n </span>\n );\n })}\n {changeRow && (\n <span data-slot=\"chart-tooltip-change\" className={cn(\"flex items-center gap-ds-100\", CHANGE_TONE[changeRow.tone])}>\n {changeRow.label}\n <bdi className=\"ms-auto ps-ds-200 font-medium tabular-nums\">{changeRow.value}</bdi>\n </span>\n )}\n </div>\n );\n}\n\n/* ── Legend ──────────────────────────────────────────────────────────────── */\n\nexport type ChartLegendItem = {\n key: string;\n label: string;\n color: string;\n /** Lines get a 2px line key (dashed like the line); areas and bars a 10px square. */\n kind?: \"line\" | \"area\" | \"bar\";\n /** The line's dash pattern, from `chartSeries()`. */\n strokeDasharray?: string;\n};\n\nexport type ChartLegendProps = {\n items: readonly ChartLegendItem[];\n /** From `useChartSeries()`: pressing a key hides or shows its series. Leave out for a static legend. */\n hidden?: ReadonlySet<string>;\n onToggle?: (key: string) => void;\n};\n\n/** Series keys with their labels in `ds-text-subtle`; pressing one hides or shows it (hidden at 45%). */\nexport function ChartLegend({ items, hidden, onToggle }: ChartLegendProps) {\n return (\n <div data-slot=\"chart-legend\" className=\"flex flex-wrap items-center gap-x-ds-200 gap-y-ds-050 text-body-small text-ds-text-subtle\">\n {items.map((item) => {\n const isHidden = hidden?.has(item.key) ?? false;\n const key =\n item.kind === \"line\" ? (\n <svg aria-hidden data-slot=\"chart-legend-key\" data-kind=\"line\" width=\"16\" height=\"2\" className=\"shrink-0 overflow-visible\">\n <line x1=\"0\" y1=\"1\" x2=\"16\" y2=\"1\" stroke={item.color} strokeWidth=\"2\" strokeDasharray={item.strokeDasharray} />\n </svg>\n ) : (\n <span aria-hidden data-slot=\"chart-legend-key\" data-kind={item.kind ?? \"area\"} className=\"size-2.5 shrink-0 rounded-ds-xsmall\" style={{ background: item.color }} />\n );\n return onToggle ? (\n <AriaButton\n key={item.key}\n aria-pressed={!isHidden}\n data-slot=\"chart-legend-item\"\n onPress={() => onToggle(item.key)}\n className={cn(\n \"inline-flex cursor-pointer items-center gap-ds-075 rounded-ds-small outline-hidden data-[hovered]:text-ds-text\",\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused\",\n isHidden && \"opacity-45\",\n )}\n >\n {key}\n {item.label}\n </AriaButton>\n ) : (\n <span key={item.key} data-slot=\"chart-legend-item\" className=\"inline-flex items-center gap-ds-075\">\n {key}\n {item.label}\n </span>\n );\n })}\n </div>\n );\n}\n\n/* ── Frame: loading, empty, the chart, and its data table ────────────────── */\n\nexport type ChartDataTable<T> = {\n /** Names the table (\"Monthly revenue\"). */\n caption: string;\n columns: readonly TableColumn<T>[];\n rows: readonly T[];\n rowKey?: (row: T) => string | number;\n /** Opens a row's item from the shown table: the keyboard's way to what a press on a data point opens. */\n onRowAction?: (row: T) => void;\n};\n\nexport type ChartFrameProps<T> = {\n /** The chart's height in px: loading, empty and the plot all keep it. */\n height: number;\n isLoading?: boolean;\n /** Shown instead of the plot when there is nothing to draw (a compact EmptyState); `null` while there is data. */\n emptyState?: React.ReactNode;\n /**\n * The same data as a compact Table: always there for screen readers, shown on request. Cells are\n * values: a `render` that returns text (a formatted figure) is used; anything else falls back to the\n * raw value in the hidden table.\n */\n dataTable: ChartDataTable<T>;\n /** The Legend: above the plot, or below it (LineChart). */\n legend?: React.ReactNode;\n legendPlacement?: \"top\" | \"bottom\";\n /**\n * The Recharts chart (inside a ResponsiveContainer), named by the table's caption. Its keyboard layer\n * (arrow keys move between data points, the tooltip follows) stays on; the table carries the data in full.\n */\n children: React.ReactNode;\n};\n\n/**\n * The frame every chart sits in. While loading, a Skeleton at the chart's real size; with nothing to\n * draw, a compact EmptyState in the same space; otherwise the plot. Under every chart a \"Show the data\n * as a table\" button shows the same data as a compact Table, which screen readers get by default.\n */\nexport function ChartFrame<T extends object>({ height, isLoading, emptyState, dataTable, legend, legendPlacement = \"top\", children }: ChartFrameProps<T>) {\n const { locale } = useLocale();\n const [showTable, setShowTable] = React.useState(false);\n const tableId = React.useId();\n const isEmpty = emptyState !== undefined && emptyState !== null && emptyState !== false;\n const hasData = !isLoading && !isEmpty;\n const { rows, rowKey = (row: T) => (row as { id: string | number }).id, onRowAction } = dataTable;\n const rowAction = onRowAction && ((key: React.Key) => {\n const row = rows.find((candidate) => String(rowKey(candidate)) === String(key));\n if (row) onRowAction(row);\n });\n const plot = isLoading ? (\n <div data-slot=\"chart-loading\" aria-busy=\"true\" style={{ height }} className=\"flex flex-col gap-ds-150\">\n <Skeleton width=\"40%\" height={16} />\n <Skeleton height={Math.max(0, height - 16 - 12)} radius=\"medium\" />\n </div>\n ) : isEmpty ? (\n // At least the chart's height; a very short chart grows rather than clipping the message.\n <div data-slot=\"chart-empty\" style={{ minHeight: height }} className=\"grid place-items-center\">\n {emptyState}\n </div>\n ) : (\n <div\n role=\"group\"\n aria-label={dataTable.caption}\n data-slot=\"chart-plot\"\n style={{ height }}\n className={cn(\n \"min-w-0\",\n // Recharts places SVG text for LTR; an inherited rtl flips its anchors (labels over bars, clipped\n // reference labels). The plot stays ltr inside; useChartDirection mirrors the axes themselves.\n \"[&_.recharts-wrapper]:[direction:ltr]\",\n // Recharts' keyboard layer: its focusable surface takes the DS focus border, drawn inside the plot (an inset\n // outline, as an inset ring would be on an element; an SVG has none). The style is named: Tailwind v4's\n // outline-hidden sets the outline style to none, and a width alone keeps it.\n \"[&_.recharts-surface]:outline-hidden [&_.recharts-surface:focus-visible]:rounded-ds-small [&_.recharts-surface:focus-visible]:outline-2\",\n \"[&_.recharts-surface:focus-visible]:outline-solid\",\n \"[&_.recharts-surface:focus-visible]:-outline-offset-2 [&_.recharts-surface:focus-visible]:outline-ds-border-focused\",\n )}\n >\n {children}\n </div>\n );\n const legendRow = legend && (hasData ? legend : <div aria-hidden inert className=\"invisible\">{legend}</div>);\n return (\n <div data-slot=\"chart-frame\" className=\"flex min-w-0 flex-col gap-ds-150\">\n {/* Loading and empty keep the legend's and the toggle's rows, so the frame does not jump when data arrives. */}\n {legendPlacement === \"top\" && legendRow}\n {plot}\n {legendPlacement === \"bottom\" && legendRow}\n {hasData ? (\n <>\n <AriaButton\n aria-expanded={showTable}\n aria-controls={tableId}\n data-slot=\"chart-table-toggle\"\n onPress={() => setShowTable((value) => !value)}\n className=\"w-max cursor-pointer rounded-ds-small text-body-small font-[500] text-ds-link outline-hidden data-[hovered]:underline data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused\"\n >\n {showTable ? hideDataTableLabel(locale) : showDataTableLabel(locale)}\n </AriaButton>\n {/* Collapsed, the box clips the visually hidden table: a table never shrinks below its content, so a\n long caption would otherwise stick out past the page edge. */}\n <div id={tableId} data-slot=\"chart-data-table\" className={showTable ? undefined : \"relative overflow-hidden\"}>\n {showTable ? (\n <Table\n aria-label={dataTable.caption}\n density=\"compact\"\n columns={dataTable.columns}\n rows={dataTable.rows}\n rowKey={dataTable.rowKey}\n onRowAction={rowAction}\n />\n ) : (\n // Collapsed: the same data as a plain table, for screen readers only. Nothing in it takes focus,\n // so Tab never lands in something unseen.\n <PlainTable caption={dataTable.caption} columns={dataTable.columns} rows={dataTable.rows} rowKey={dataTable.rowKey} />\n )}\n </div>\n </>\n ) : (\n <div aria-hidden className=\"h-4\" data-slot=\"chart-table-toggle-space\" />\n )}\n </div>\n );\n}\n\n/** The data table as plain, non-interactive markup, visually hidden: what screen readers get by default. */\nfunction PlainTable<T extends object>({ caption, columns, rows, rowKey = (row) => (row as { id: string | number }).id }: ChartDataTable<T>) {\n // The same row-header rule as Table: the marked column, or the first.\n const rowHeader = Math.max(0, columns.findIndex((column) => column.isRowHeader));\n return (\n <table data-slot=\"chart-data-table-plain\" className=\"sr-only\">\n <caption>{caption}</caption>\n <thead>\n <tr>\n {columns.map((column) => (\n <th key={column.key} scope=\"col\">\n {column.header}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {rows.map((row) => (\n <tr key={rowKey(row)}>\n {columns.map((column, index) => {\n const raw = (row as Record<string, React.ReactNode>)[column.key];\n const rendered = column.render?.(row);\n // Text only: a rendered link or button here would be a focus stop no one can see.\n const value = typeof rendered === \"string\" || typeof rendered === \"number\" ? rendered : raw;\n const isHeader = index === rowHeader;\n return isHeader ? (\n <th key={column.key} scope=\"row\">\n {value}\n </th>\n ) : (\n <td key={column.key}>{value}</td>\n );\n })}\n </tr>\n ))}\n </t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K,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC;wBAC5F,MAAM,QAAQ,GAAG,KAAK,KAAK,SAAS,CAAC;wBACrC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAChB,aAAqB,KAAK,EAAC,KAAK,YAC7B,KAAK,IADC,MAAM,CAAC,GAAG,CAEd,CACN,CAAC,CAAC,CAAC,CACF,uBAAsB,KAAK,IAAlB,MAAM,CAAC,GAAG,CAAc,CAClC,CAAC;oBACJ,CAAC,CAAC,IAdK,MAAM,CAAC,GAAG,CAAC,CAef,CACN,CAAC,GACI,IACF,CACT,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Button as AriaButton, ToggleButton as AriaToggleButton, useLocale } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { TouchTarget } from \"../action/touch-target\";\nimport { useMotionSetting } from \"../defaults\";\n/** The OS reduced-motion preference. */\nconst REDUCED_MOTION_QUERY = \"(prefers-reduced-motion: reduce)\";\nimport { Table, type TableColumn } from \"../collection/table\";\nimport { EmptyState } from \"../feedback/empty-state\";\nimport { Skeleton } from \"../feedback/skeleton\";\nimport { TooltipFor } from \"../overlay/floating\";\nimport { IconGlyph } from \"../display/icon\";\nimport { hideDataTableLabel, showDataTableLabel } from \"../i18n\";\n\n/* ── Colors ─────────────────────────────────────────────────────────────── */\n\n/** The categorical chart colors, in order; never hex in a chart. */\nexport const CHART_COLORS = [\"var(--ds-chart-1)\", \"var(--ds-chart-2)\", \"var(--ds-chart-3)\", \"var(--ds-chart-4)\", \"var(--ds-chart-5)\"] as const;\n/** Comparison series (last year, the target, \"other\"). */\nexport const CHART_NEUTRAL = \"var(--ds-chart-neutral)\";\n/** The color of the n-th series (0-based), cycling through the five. */\nexport const chartColor = (index: number) => CHART_COLORS[((index % CHART_COLORS.length) + CHART_COLORS.length) % CHART_COLORS.length]!;\n\n/** Dash patterns for line series beyond the second: told apart by pattern, not hue alone. */\nconst LINE_DASHES = [\"6 4\", \"2 3\", \"8 3 2 3\"] as const;\n\nexport type ChartSeriesStyle = { color: string; strokeDasharray?: string };\n\n/**\n * How the n-th series (0-based) is drawn. The chart\n * colors share one lightness, so series are told apart by lightness or pattern, never hue alone: the\n * first series is the brand color, a comparison series (last year, the target) is `ds-chart-neutral`,\n * lines after the second are dashed, and every series carries a legend key or a direct label. Bars and\n * areas take no pattern: their legend key or direct label tells them apart.\n */\nexport function chartSeries(index: number, options: { kind?: \"line\" | \"area\" | \"bar\"; isComparison?: boolean } = {}): ChartSeriesStyle {\n const color = options.isComparison ? CHART_NEUTRAL : chartColor(index);\n const strokeDasharray = options.kind === \"line\" && index >= 2 ? LINE_DASHES[(index - 2) % LINE_DASHES.length] : undefined;\n return strokeDasharray ? { color, strokeDasharray } : { color };\n}\n\n/* ── Animation ───────────────────────────────────────────────────────────── */\n\nconst ChartAnimationContext = React.createContext(true);\n\n/**\n * Turns chart animation off for everything inside, deterministically: snapshot tests and the DS lab\n * render the final frame at once. Reduced motion turns it off without this.\n */\nexport function ChartAnimation({ isEnabled, children }: { isEnabled: boolean; children: React.ReactNode }) {\n return <ChartAnimationContext.Provider value={isEnabled}>{children}</ChartAnimationContext.Provider>;\n}\n\nfunction subscribeReducedMotion(listener: () => void) {\n if (typeof window === \"undefined\" || !window.matchMedia) return () => {};\n const media = window.matchMedia(REDUCED_MOTION_QUERY);\n media.addEventListener(\"change\", listener);\n return () => media.removeEventListener(\"change\", listener);\n}\nconst reducedMotionNow = () => typeof window !== \"undefined\" && !!window.matchMedia?.(REDUCED_MOTION_QUERY).matches;\n\n/** Whether a chart may animate: pass it to Recharts' `isAnimationActive`. */\nexport function useChartAnimation(): boolean {\n const enabled = React.useContext(ChartAnimationContext);\n const reduced = React.useSyncExternalStore(subscribeReducedMotion, reducedMotionNow, () => false);\n const setting = useMotionSetting();\n return enabled && !reduced && setting === \"auto\";\n}\n\n/* ── Direction ───────────────────────────────────────────────────────────── */\n\n/**\n * How a cartesian chart follows the reading direction: in RTL time runs from the right, so the category\n * axis is reversed and the value axis sits on the right. Spread into Recharts' axes:\n * `<XAxis reversed={direction.reversed} />`, `<YAxis orientation={direction.valueAxis} />`.\n */\nexport function useChartDirection(): { isRtl: boolean; reversed: boolean; valueAxis: \"left\" | \"right\" } {\n const { direction } = useLocale();\n const isRtl = direction === \"rtl\";\n return { isRtl, reversed: isRtl, valueAxis: isRtl ? \"right\" : \"left\" };\n}\n\n/* ── Series visibility (the legend's toggle) ─────────────────────────────── */\n\n/** Which series the legend has hidden; charts skip (or fade) hidden series. */\nexport function useChartSeries() {\n const [hidden, setHidden] = React.useState<ReadonlySet<string>>(new Set());\n const toggle = React.useCallback((key: string) => {\n setHidden((current) => {\n const next = new Set(current);\n if (next.has(key)) next.delete(key);\n else next.add(key);\n return next;\n });\n }, []);\n const isHidden = React.useCallback((key: string) => hidden.has(key), [hidden]);\n return { hidden, toggle, isHidden };\n}\n\n/* ── Tooltip ─────────────────────────────────────────────────────────────── */\n\nexport type ChartValueFormatter = (value: number) => string;\n\n/** One series in the tooltip, as Recharts hands it over. */\nexport type ChartTooltipEntry = { dataKey?: string | number; name?: string | number; value?: unknown; color?: string; stroke?: string; fill?: string };\n\nexport type ChartTooltipProps = {\n /** Set by Recharts when used as `<Tooltip content={<ChartTooltip … />} />`. */\n active?: boolean;\n payload?: readonly ChartTooltipEntry[];\n label?: unknown;\n /** Shared with the chart: \"€ 55,0k\". */\n valueFormatter?: ChartValueFormatter;\n /** The period title (\"August 2026\"); the category label by default. */\n labelFormatter?: (label: unknown) => React.ReactNode;\n /** Series names by data key (\"2026\", \"Website\"). */\n labels?: Readonly<Record<string, string>>;\n /** An optional change row, colored by meaning (\"Change +11.8%\"). */\n change?: (payload: readonly ChartTooltipEntry[]) => { label: string; value: string; tone: \"success\" | \"danger\" | \"neutral\" } | null;\n};\n\nconst CHANGE_TONE = { success: \"text-ds-text-success\", danger: \"text-ds-text-danger\", neutral: \"text-ds-text-subtle\" } as const;\n\n/**\n * The tooltip every chart uses: the period as title, one row per series with its color key and value\n * in tabular figures, and an optional change row. On `ds-surface-overlay`. It follows keyboard focus on\n * data points as well as the pointer (Recharts' accessibility layer moves it with the arrow keys).\n */\nexport function ChartTooltip({ active, payload, label, valueFormatter = String, labelFormatter, labels, change }: ChartTooltipProps) {\n // Recharts draws the tooltip inside its wrapper, which the plot keeps left to right (ChartFrame): the tooltip takes the\n // page's direction back, so its rows read and align as the page does.\n const { direction } = useLocale();\n if (!active || !payload?.length) return null;\n const changeRow = change?.(payload);\n return (\n <div data-slot=\"chart-tooltip\" dir={direction} className=\"flex min-w-36 flex-col gap-ds-050 rounded-ds-medium bg-ds-surface-overlay px-ds-150 py-ds-100 text-body-small text-ds-text shadow-ds-overlay\">\n <span className=\"text-body-strong\">{labelFormatter ? labelFormatter(label) : String(label ?? \"\")}</span>\n {payload.map((entry, index) => {\n const key = String(entry.dataKey ?? entry.name ?? \"\");\n return (\n // By position too: a composed chart may draw one key twice (an area and a line on revenue).\n <span key={`${index}-${key}`} data-slot=\"chart-tooltip-row\" className=\"flex items-center gap-ds-100\">\n <span aria-hidden className=\"size-2.5 shrink-0 rounded-ds-xsmall\" style={{ background: entry.color ?? entry.stroke ?? entry.fill }} />\n <span className=\"text-ds-text-subtle\">{labels?.[key] ?? String(entry.name ?? key)}</span>\n <bdi className=\"ms-auto ps-ds-200 font-medium tabular-nums\">{typeof entry.value === \"number\" ? valueFormatter(entry.value) : String(entry.value ?? \"\")}</bdi>\n </span>\n );\n })}\n {changeRow && (\n <span data-slot=\"chart-tooltip-change\" className={cn(\"flex items-center gap-ds-100\", CHANGE_TONE[changeRow.tone])}>\n {changeRow.label}\n <bdi className=\"ms-auto ps-ds-200 font-medium tabular-nums\">{changeRow.value}</bdi>\n </span>\n )}\n </div>\n );\n}\n\n/* ── Legend ──────────────────────────────────────────────────────────────── */\n\nexport type ChartLegendItem = {\n key: string;\n label: string;\n color: string;\n /** Lines get a 2px line key (dashed like the line); areas and bars a 10px square. */\n kind?: \"line\" | \"area\" | \"bar\";\n /** The line's dash pattern, from `chartSeries()`. */\n strokeDasharray?: string;\n};\n\nexport type ChartLegendProps = {\n items: readonly ChartLegendItem[];\n /** From `useChartSeries()`: pressing a key hides or shows its series. Leave out for a static legend. */\n hidden?: ReadonlySet<string>;\n onToggle?: (key: string) => void;\n};\n\n/** Series keys with their labels in `ds-text-subtle`; pressing one hides or shows it (hidden at 45%). */\nexport function ChartLegend({ items, hidden, onToggle }: ChartLegendProps) {\n return (\n <div data-slot=\"chart-legend\" className=\"flex flex-wrap items-center gap-x-ds-200 gap-y-ds-050 text-body-small text-ds-text-subtle\">\n {items.map((item) => {\n const isHidden = hidden?.has(item.key) ?? false;\n const key =\n item.kind === \"line\" ? (\n <svg aria-hidden data-slot=\"chart-legend-key\" data-kind=\"line\" width=\"16\" height=\"2\" className=\"shrink-0 overflow-visible\">\n <line x1=\"0\" y1=\"1\" x2=\"16\" y2=\"1\" stroke={item.color} strokeWidth=\"2\" strokeDasharray={item.strokeDasharray} />\n </svg>\n ) : (\n <span aria-hidden data-slot=\"chart-legend-key\" data-kind={item.kind ?? \"area\"} className=\"size-2.5 shrink-0 rounded-ds-xsmall\" style={{ background: item.color }} />\n );\n return onToggle ? (\n <AriaButton\n key={item.key}\n aria-pressed={!isHidden}\n data-slot=\"chart-legend-item\"\n onPress={() => onToggle(item.key)}\n className={cn(\n \"relative inline-flex cursor-pointer items-center gap-ds-075 rounded-ds-small outline-hidden data-[hovered]:text-ds-text\",\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused\",\n isHidden && \"opacity-45\",\n )}\n >\n {/* A 16px row of text: a 44px hit area under a coarse pointer, as compact Buttons have. */}\n <TouchTarget />\n {key}\n {item.label}\n </AriaButton>\n ) : (\n <span key={item.key} data-slot=\"chart-legend-item\" className=\"inline-flex items-center gap-ds-075\">\n {key}\n {item.label}\n </span>\n );\n })}\n </div>\n );\n}\n\n/* ── Frame: loading, empty, the chart, and its data table ────────────────── */\n\nexport type ChartDataTable<T> = {\n /** Names the table (\"Monthly revenue\"). */\n caption: string;\n columns: readonly TableColumn<T>[];\n rows: readonly T[];\n rowKey?: (row: T) => string | number;\n /** Opens a row's item from the shown table: the keyboard's way to what a press on a data point opens. */\n onRowAction?: (row: T) => void;\n};\n\n/** How a chart offers its data as a table. */\nexport type ChartTableView = \"swap\" | \"hidden\" | \"none\";\n\n/** The data-table options every chart takes. */\nexport type ChartTableProps = {\n /**\n * How the data is offered as a table. `swap` (default): a toggle at the end of the chart's top row turns the plot\n * into the table at the same height, scrolling inside, so the card never grows. `hidden`: no toggle; the table is\n * there for screen readers only. `none`: no table at all, for a chart that is already text (BarList).\n */\n tableView?: ChartTableView;\n /** The table is showing (`swap`), controlled; or `defaultTableOpen` + `onTableOpenChange`. */\n isTableOpen?: boolean;\n defaultTableOpen?: boolean;\n onTableOpenChange?: (isOpen: boolean) => void;\n};\n\nexport type ChartFrameProps<T> = ChartTableProps & {\n /** The chart's height in px: loading, empty and the plot all keep it. */\n height: number;\n isLoading?: boolean;\n /** Shown instead of the plot when there is nothing to draw (a compact EmptyState); `null` while there is data. */\n emptyState?: React.ReactNode;\n /**\n * The same data as a compact Table: always there for screen readers, shown on request. Cells are\n * values: a `render` that returns text (a formatted figure) is used; anything else falls back to the\n * raw value in the hidden table.\n */\n dataTable: ChartDataTable<T>;\n /** The Legend: above the plot, or below it (LineChart). */\n legend?: React.ReactNode;\n legendPlacement?: \"top\" | \"bottom\";\n /**\n * The Recharts chart (inside a ResponsiveContainer), named by the table's caption. Its keyboard layer\n * (arrow keys move between data points, the tooltip follows) stays on; the table carries the data in full.\n */\n children: React.ReactNode;\n};\n\n/**\n * The frame every chart sits in. While loading, a Skeleton at the chart's real size; with nothing to draw, a compact\n * EmptyState in the same space; otherwise the plot. The data as a table (`tableView`): by default a toggle at the end\n * of the top row swaps the plot for the same data as a compact Table at the same height, scrolling inside, so the\n * card never changes size; with the plot showing, screen readers still get the table (visually hidden).\n */\nexport function ChartFrame<T extends object>({\n height,\n isLoading,\n emptyState,\n dataTable,\n legend,\n legendPlacement = \"top\",\n tableView = \"swap\",\n isTableOpen,\n defaultTableOpen = false,\n onTableOpenChange,\n children,\n}: ChartFrameProps<T>) {\n const { locale } = useLocale();\n const [ownOpen, setOwnOpen] = React.useState(defaultTableOpen);\n const regionId = React.useId();\n const isEmpty = emptyState !== undefined && emptyState !== null && emptyState !== false;\n const hasData = !isLoading && !isEmpty;\n const swaps = tableView === \"swap\";\n const open = swaps && hasData && (isTableOpen ?? ownOpen);\n const setOpen = (next: boolean) => {\n if (isTableOpen === undefined) setOwnOpen(next);\n onTableOpenChange?.(next);\n };\n const { rows, rowKey = (row: T) => (row as { id: string | number }).id, onRowAction } = dataTable;\n const rowAction = onRowAction && ((key: React.Key) => {\n const row = rows.find((candidate) => String(rowKey(candidate)) === String(key));\n if (row) onRowAction(row);\n });\n const plot = isLoading ? (\n <div data-slot=\"chart-loading\" aria-busy=\"true\" style={{ height }} className=\"flex flex-col gap-ds-150\">\n <Skeleton width=\"40%\" height={16} />\n <Skeleton height={Math.max(0, height - 16 - 12)} radius=\"medium\" />\n </div>\n ) : isEmpty ? (\n // At least the chart's height; a very short chart grows rather than clipping the message.\n <div data-slot=\"chart-empty\" style={{ minHeight: height }} className=\"grid place-items-center\">\n {emptyState}\n </div>\n ) : open ? (\n // The table in the plot's place, at the plot's height: it scrolls inside, so nothing around it moves.\n <div id={regionId} data-slot=\"chart-data-table\" style={{ height }} className=\"flex min-w-0 flex-col\">\n <Table\n aria-label={dataTable.caption}\n density=\"compact\"\n maxHeight={`${height}px`}\n columns={dataTable.columns}\n rows={dataTable.rows}\n rowKey={dataTable.rowKey}\n onRowAction={rowAction}\n />\n </div>\n ) : (\n <div\n id={regionId}\n role=\"group\"\n aria-label={dataTable.caption}\n data-slot=\"chart-plot\"\n style={{ height }}\n className={cn(\n \"min-w-0\",\n // Recharts places SVG text for LTR; an inherited rtl flips its anchors (labels over bars, clipped\n // reference labels). The plot stays ltr inside; useChartDirection mirrors the axes themselves.\n \"[&_.recharts-wrapper]:[direction:ltr]\",\n // Recharts' keyboard layer: its focusable surface takes the DS focus border, drawn inside the plot (an inset\n // outline, as an inset ring would be on an element; an SVG has none). The style is named: Tailwind v4's\n // outline-hidden sets the outline style to none, and a width alone keeps it.\n \"[&_.recharts-surface]:outline-hidden [&_.recharts-surface:focus-visible]:rounded-ds-small [&_.recharts-surface:focus-visible]:outline-2\",\n \"[&_.recharts-surface:focus-visible]:outline-solid\",\n \"[&_.recharts-surface:focus-visible]:-outline-offset-2 [&_.recharts-surface:focus-visible]:outline-ds-border-focused\",\n )}\n >\n {children}\n {/* With the plot showing, the same data as a plain table for screen readers only, inside the plot's box so it\n adds no row (the card is the same height with the plot and with the table). Nothing in it takes focus, so\n Tab never lands in something unseen; the box clips it, so a long caption never sticks out. */}\n {tableView !== \"none\" && (\n <div data-slot=\"chart-data-table\" className=\"relative overflow-hidden\">\n <PlainTable caption={dataTable.caption} columns={dataTable.columns} rows={dataTable.rows} rowKey={dataTable.rowKey} />\n </div>\n )}\n </div>\n );\n const legendRow = legend && (hasData ? legend : <div aria-hidden inert className=\"invisible\">{legend}</div>);\n // The toggle: an icon button that stays where it is (focus stays on it) while the region beside it swaps. Loading\n // and empty keep its place, invisible, so the row does not jump when data arrives.\n const toggle = swaps ? (\n hasData ? (\n // TooltipFor: the toggle is itself a React Aria focusable, so it takes the trigger props directly.\n <TooltipFor content={open ? hideDataTableLabel(locale) : showDataTableLabel(locale)}>\n <AriaToggleButton\n isSelected={open}\n onChange={setOpen}\n aria-label={showDataTableLabel(locale)}\n aria-controls={regionId}\n data-slot=\"chart-table-toggle\"\n className={cn(\n \"relative ms-auto grid size-7 shrink-0 cursor-pointer place-items-center rounded-ds-control-small text-ds-icon-subtle outline-hidden\",\n \"data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[hovered]:text-ds-icon\",\n \"data-[selected]:bg-ds-background-selected data-[selected]:text-ds-icon-brand\",\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused\",\n )}\n >\n {/* 28px: a 44px hit area under a coarse pointer, as compact Buttons have. */}\n <TouchTarget />\n <IconGlyph name={open ? \"chart-column\" : \"table\"} />\n </AriaToggleButton>\n </TooltipFor>\n ) : (\n <span aria-hidden data-slot=\"chart-table-toggle-space\" className=\"ms-auto size-7 shrink-0\" />\n )\n ) : null;\n const topLegend = legendPlacement === \"top\" ? legendRow : null;\n return (\n <div data-slot=\"chart-frame\" className=\"flex min-w-0 flex-col gap-ds-150\">\n {(topLegend || toggle) && (\n <div data-slot=\"chart-top\" className=\"flex min-w-0 items-start gap-ds-200\">\n {topLegend && <div className=\"min-w-0 flex-1\">{topLegend}</div>}\n {toggle}\n </div>\n )}\n {plot}\n {legendPlacement === \"bottom\" && legendRow}\n </div>\n );\n}\n\n/** The data table as plain, non-interactive markup, visually hidden: what screen readers get by default. */\nfunction PlainTable<T extends object>({ caption, columns, rows, rowKey = (row) => (row as { id: string | number }).id }: ChartDataTable<T>) {\n // The same row-header rule as Table: the marked column, or the first.\n const rowHeader = Math.max(0, columns.findIndex((column) => column.isRowHeader));\n return (\n <table data-slot=\"chart-data-table-plain\" className=\"sr-only\">\n <caption>{caption}</caption>\n <thead>\n <tr>\n {columns.map((column) => (\n <th key={column.key} scope=\"col\">\n {column.header}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {rows.map((row) => (\n <tr key={rowKey(row)}>\n {columns.map((column, index) => {\n const raw = (row as Record<string, React.ReactNode>)[column.key];\n const rendered = column.render?.(row);\n // Text only: a rendered link or button here would be a focus stop no one can see.\n const value = typeof rendered === \"string\" || typeof rendered === \"number\" ? rendered : raw;\n const isHeader = index === rowHeader;\n return isHeader ? (\n <th key={column.key} scope=\"row\">\n {value}\n </th>\n ) : (\n <td key={column.key}>{value}</td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import * as React from "react";
2
2
  import { type LabelProps } from "recharts";
3
- import { type ChartTooltipProps, type ChartValueFormatter } from "./chart-parts.js";
3
+ import { type ChartTooltipProps, type ChartValueFormatter, type ChartTableProps } from "./chart-parts.js";
4
4
  import { type FormattedValues } from "./axis-width.js";
5
5
  type Row = Record<string, unknown>;
6
- export type ChartBaseProps<T extends Row> = {
6
+ export type ChartBaseProps<T extends Row> = ChartTableProps & {
7
7
  /** What the chart shows ("Revenue"), over it; leave it out when a card or a heading already says so. */
8
8
  title?: string;
9
9
  /** Names the chart when it has no visible `title` (a card's heading already says what it shows). */
@@ -4,7 +4,7 @@ import * as React from "react";
4
4
  import { Area, Bar, CartesianGrid, ComposedChart as RechartsComposedChart, LabelList, Line, ReferenceLine, ResponsiveContainer, Tooltip, XAxis, YAxis, usePlotArea, } from "recharts";
5
5
  import { useLocale } from "react-aria-components";
6
6
  import { chartCategoryLabel, chartNoDataLabel, chartPeriodLabel } from "../i18n.js";
7
- import { CHART_NEUTRAL, ChartFrame, ChartLegend, ChartTooltip, chartColor, chartSeries, useChartAnimation, useChartDirection, useChartSeries, } from "./chart-parts.js";
7
+ import { CHART_NEUTRAL, ChartFrame, ChartLegend, ChartTooltip, chartColor, chartSeries, useChartAnimation, useChartDirection, useChartSeries } from "./chart-parts.js";
8
8
  import { chartNumber, formattedValues, labelText, textLines, textWidth, tickAxisWidth, tickOverhang, tickWrapWidth, valueAxisTicks, valueAxisWidth } from "./axis-width.js";
9
9
  import { CategoryTick, LineSpan, NameTick, ValueTick, clippedLine, firstLineDy, isolatedLabel, placedLine } from "./value-tick.js";
10
10
  import { EmptyState } from "../feedback/empty-state.js";
@@ -73,7 +73,7 @@ function Shell({ props, shell, legendPlacement, showLegend, onResize, children,
73
73
  const height = props.height ?? 240;
74
74
  // Rows keyed by position: two rows may share a category value.
75
75
  const positions = React.useMemo(() => new Map(props.data.map((row, position) => [row, position])), [props.data]);
76
- return (_jsxs("section", { "data-slot": "chart", "aria-label": props.title ?? props["aria-label"], className: "flex min-w-0 flex-col gap-ds-200", children: [(props.title || props.period || props.total != null) && _jsx(ChartHeader, { title: props.title, period: props.period, total: props.total }), _jsx(ChartFrame, { height: height, isLoading: props.isLoading, emptyState: props.data.length === 0 ? props.emptyState ?? _jsx(EmptyState, { size: "small", icon: "chart-column", title: chartNoDataLabel(shell.locale) }) : null, legendPlacement: legendPlacement, legend: showLegend ? _jsx(ChartLegend, { items: shell.legend, hidden: shell.series.hidden, onToggle: shell.series.toggle }) : undefined, dataTable: { caption: [props.title ?? props["aria-label"], props.period].filter(Boolean).join(" · "), columns: shell.columns, rows: props.data, rowKey: (row) => positions.get(row) ?? String(row[props.index]) }, children: _jsx(ResponsiveContainer, { width: "100%", height: "100%", onResize: onResize ? (width) => onResize(Math.round(width)) : undefined, children: children }) })] }));
76
+ return (_jsxs("section", { "data-slot": "chart", "aria-label": props.title ?? props["aria-label"], className: "flex min-w-0 flex-col gap-ds-200", children: [(props.title || props.period || props.total != null) && _jsx(ChartHeader, { title: props.title, period: props.period, total: props.total }), _jsx(ChartFrame, { height: height, isLoading: props.isLoading, emptyState: props.data.length === 0 ? props.emptyState ?? _jsx(EmptyState, { size: "small", icon: "chart-column", title: chartNoDataLabel(shell.locale) }) : null, legendPlacement: legendPlacement, legend: showLegend ? _jsx(ChartLegend, { items: shell.legend, hidden: shell.series.hidden, onToggle: shell.series.toggle }) : undefined, dataTable: { caption: [props.title ?? props["aria-label"], props.period].filter(Boolean).join(" · "), columns: shell.columns, rows: props.data, rowKey: (row) => positions.get(row) ?? String(row[props.index]) }, tableView: props.tableView, isTableOpen: props.isTableOpen, defaultTableOpen: props.defaultTableOpen, onTableOpenChange: props.onTableOpenChange, children: _jsx(ResponsiveContainer, { width: "100%", height: "100%", onResize: onResize ? (width) => onResize(Math.round(width)) : undefined, children: children }) })] }));
77
77
  }
78
78
  const VALUE_TICKS = 4;
79
79
  /** A value axis is never narrower than this, so short figures ("€ 54", "120") keep the axis they always had. */