@nocoo/basalt 2.0.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/README.md +134 -15
  2. package/ai/COMPATIBILITY.md +180 -0
  3. package/ai/INTEGRATION.md +1760 -0
  4. package/ai/RECIPES.md +161 -0
  5. package/ai/USAGE.md +99 -0
  6. package/ai/registry.json +38099 -0
  7. package/ai/sources.json +10 -0
  8. package/dist/assets/brand-mark.d.ts +1 -0
  9. package/dist/assets/brand-mark.js +7 -0
  10. package/dist/assets/brand-mark.js.map +1 -0
  11. package/dist/charts/area.d.ts +58 -5
  12. package/dist/charts/area.js +20 -12
  13. package/dist/charts/area.js.map +1 -1
  14. package/dist/charts/bar.d.ts +54 -5
  15. package/dist/charts/bar.js +16 -10
  16. package/dist/charts/bar.js.map +1 -1
  17. package/dist/charts/bullet.d.ts +18 -1
  18. package/dist/charts/bullet.js +6 -3
  19. package/dist/charts/bullet.js.map +1 -1
  20. package/dist/charts/charts.d.ts +58 -5
  21. package/dist/charts/charts.js +13 -2
  22. package/dist/charts/charts.js.map +1 -1
  23. package/dist/charts/config.d.ts +7 -0
  24. package/dist/charts/config.js +5 -1
  25. package/dist/charts/config.js.map +1 -1
  26. package/dist/charts/custom-chart.d.ts +58 -5
  27. package/dist/charts/custom-chart.js +13 -2
  28. package/dist/charts/custom-chart.js.map +1 -1
  29. package/dist/charts/donut.d.ts +18 -1
  30. package/dist/charts/donut.js +6 -3
  31. package/dist/charts/donut.js.map +1 -1
  32. package/dist/charts/frame.d.ts +40 -3
  33. package/dist/charts/frame.js +55 -28
  34. package/dist/charts/frame.js.map +1 -1
  35. package/dist/charts/funnel.d.ts +18 -1
  36. package/dist/charts/funnel.js +5 -1
  37. package/dist/charts/funnel.js.map +1 -1
  38. package/dist/charts/gauge.d.ts +18 -1
  39. package/dist/charts/gauge.js +38 -20
  40. package/dist/charts/gauge.js.map +1 -1
  41. package/dist/charts/grouped-bar.d.ts +54 -5
  42. package/dist/charts/grouped-bar.js +16 -10
  43. package/dist/charts/grouped-bar.js.map +1 -1
  44. package/dist/charts/heatmap-calendar.d.ts +61 -0
  45. package/dist/charts/heatmap-calendar.js +287 -96
  46. package/dist/charts/heatmap-calendar.js.map +1 -1
  47. package/dist/charts/heatmap-matrix.d.ts +99 -0
  48. package/dist/charts/heatmap-matrix.js +249 -0
  49. package/dist/charts/heatmap-matrix.js.map +1 -0
  50. package/dist/charts/line.d.ts +66 -5
  51. package/dist/charts/line.js +37 -30
  52. package/dist/charts/line.js.map +1 -1
  53. package/dist/charts/palette.d.ts +1 -0
  54. package/dist/charts/palette.js +7 -1
  55. package/dist/charts/palette.js.map +1 -1
  56. package/dist/charts/radar.d.ts +18 -1
  57. package/dist/charts/radar.js +26 -19
  58. package/dist/charts/radar.js.map +1 -1
  59. package/dist/charts/sankey.d.ts +18 -1
  60. package/dist/charts/sankey.js +4 -1
  61. package/dist/charts/sankey.js.map +1 -1
  62. package/dist/charts/series.d.ts +5 -7
  63. package/dist/charts/series.js.map +1 -1
  64. package/dist/charts/slot-bar.d.ts +38 -6
  65. package/dist/charts/slot-bar.js +5 -2
  66. package/dist/charts/slot-bar.js.map +1 -1
  67. package/dist/charts/sparkline.d.ts +35 -5
  68. package/dist/charts/sparkline.js +22 -18
  69. package/dist/charts/sparkline.js.map +1 -1
  70. package/dist/charts/stacked-bar.d.ts +58 -5
  71. package/dist/charts/stacked-bar.js +19 -12
  72. package/dist/charts/stacked-bar.js.map +1 -1
  73. package/dist/charts/stat-card.d.ts +51 -1
  74. package/dist/charts/stat-card.js +66 -39
  75. package/dist/charts/stat-card.js.map +1 -1
  76. package/dist/charts/timeline.d.ts +3 -0
  77. package/dist/charts/timeline.js +4 -3
  78. package/dist/charts/timeline.js.map +1 -1
  79. package/dist/charts/timeseries.d.ts +58 -5
  80. package/dist/charts/timeseries.js +13 -2
  81. package/dist/charts/timeseries.js.map +1 -1
  82. package/dist/charts/tooltip.d.ts +57 -0
  83. package/dist/charts/tooltip.js +119 -2
  84. package/dist/charts/tooltip.js.map +1 -1
  85. package/dist/components/accordion.d.ts +117 -2
  86. package/dist/components/accordion.js +20 -13
  87. package/dist/components/accordion.js.map +1 -1
  88. package/dist/components/alert-dialog.d.ts +131 -13
  89. package/dist/components/alert-dialog.js +12 -9
  90. package/dist/components/alert-dialog.js.map +1 -1
  91. package/dist/components/app-header.js +18 -17
  92. package/dist/components/app-header.js.map +1 -1
  93. package/dist/components/app-shell.js +15 -14
  94. package/dist/components/app-shell.js.map +1 -1
  95. package/dist/components/autocomplete.d.ts +4 -0
  96. package/dist/components/autocomplete.js.map +1 -1
  97. package/dist/components/avatar.d.ts +76 -3
  98. package/dist/components/avatar.js.map +1 -1
  99. package/dist/components/badge.d.ts +15 -1
  100. package/dist/components/badge.js +17 -16
  101. package/dist/components/badge.js.map +1 -1
  102. package/dist/components/banner.d.ts +88 -2
  103. package/dist/components/banner.js +41 -40
  104. package/dist/components/banner.js.map +1 -1
  105. package/dist/components/basalt-mark.js +14 -8
  106. package/dist/components/basalt-mark.js.map +1 -1
  107. package/dist/components/battery-meter.d.ts +10 -0
  108. package/dist/components/battery-meter.js +56 -0
  109. package/dist/components/battery-meter.js.map +1 -0
  110. package/dist/components/breadcrumbs.d.ts +27 -7
  111. package/dist/components/breadcrumbs.js +21 -20
  112. package/dist/components/breadcrumbs.js.map +1 -1
  113. package/dist/components/button.d.ts +48 -2
  114. package/dist/components/button.js +87 -36
  115. package/dist/components/button.js.map +1 -1
  116. package/dist/components/chat-bubble.d.ts +7 -0
  117. package/dist/components/chat-bubble.js +14 -13
  118. package/dist/components/chat-bubble.js.map +1 -1
  119. package/dist/components/chat-composer.d.ts +7 -3
  120. package/dist/components/chat-composer.js.map +1 -1
  121. package/dist/components/chat-header.d.ts +6 -1
  122. package/dist/components/chat-header.js +17 -16
  123. package/dist/components/chat-header.js.map +1 -1
  124. package/dist/components/chat-inbox.d.ts +7 -2
  125. package/dist/components/chat-inbox.js.map +1 -1
  126. package/dist/components/checkbox.js +84 -53
  127. package/dist/components/checkbox.js.map +1 -1
  128. package/dist/components/clipboard-text.d.ts +13 -2
  129. package/dist/components/clipboard-text.js +4 -4
  130. package/dist/components/clipboard-text.js.map +1 -1
  131. package/dist/components/collapsible.d.ts +58 -15
  132. package/dist/components/collapsible.js.map +1 -1
  133. package/dist/components/command-palette.d.ts +151 -61
  134. package/dist/components/command-palette.js.map +1 -1
  135. package/dist/components/confirm-dialog.d.ts +1 -1
  136. package/dist/components/confirm-dialog.js +6 -4
  137. package/dist/components/confirm-dialog.js.map +1 -1
  138. package/dist/components/context-menu.d.ts +210 -2
  139. package/dist/components/context-menu.js +7 -4
  140. package/dist/components/context-menu.js.map +1 -1
  141. package/dist/components/data-table.d.ts +40 -2
  142. package/dist/components/data-table.js +168 -120
  143. package/dist/components/data-table.js.map +1 -1
  144. package/dist/components/date-picker.d.ts +53 -2
  145. package/dist/components/date-picker.js +387 -219
  146. package/dist/components/date-picker.js.map +1 -1
  147. package/dist/components/delete-resource.d.ts +7 -1
  148. package/dist/components/delete-resource.js +22 -18
  149. package/dist/components/delete-resource.js.map +1 -1
  150. package/dist/components/description-list.js +16 -15
  151. package/dist/components/description-list.js.map +1 -1
  152. package/dist/components/dialog.d.ts +141 -12
  153. package/dist/components/dialog.js +42 -38
  154. package/dist/components/dialog.js.map +1 -1
  155. package/dist/components/dock.d.ts +1 -1
  156. package/dist/components/dock.js +39 -58
  157. package/dist/components/dock.js.map +1 -1
  158. package/dist/components/dropdown-menu.d.ts +229 -15
  159. package/dist/components/dropdown-menu.js +9 -6
  160. package/dist/components/dropdown-menu.js.map +1 -1
  161. package/dist/components/editable-nav-item.d.ts +33 -0
  162. package/dist/components/editable-nav-item.js +90 -0
  163. package/dist/components/editable-nav-item.js.map +1 -0
  164. package/dist/components/empty.d.ts +22 -2
  165. package/dist/components/empty.js +22 -13
  166. package/dist/components/empty.js.map +1 -1
  167. package/dist/components/field.js +31 -30
  168. package/dist/components/field.js.map +1 -1
  169. package/dist/components/file-dropzone.d.ts +37 -0
  170. package/dist/components/file-dropzone.js +103 -0
  171. package/dist/components/file-dropzone.js.map +1 -0
  172. package/dist/components/filter-bar.d.ts +34 -0
  173. package/dist/components/filter-bar.js +52 -0
  174. package/dist/components/filter-bar.js.map +1 -0
  175. package/dist/components/flow.js +19 -18
  176. package/dist/components/flow.js.map +1 -1
  177. package/dist/components/grid.d.ts +3 -1
  178. package/dist/components/grid.js.map +1 -1
  179. package/dist/components/hover-card.d.ts +111 -1
  180. package/dist/components/hover-card.js +9 -6
  181. package/dist/components/hover-card.js.map +1 -1
  182. package/dist/components/icon-picker.d.ts +34 -0
  183. package/dist/components/icon-picker.js +77 -0
  184. package/dist/components/icon-picker.js.map +1 -0
  185. package/dist/components/inline-editable.d.ts +46 -0
  186. package/dist/components/inline-editable.js +124 -0
  187. package/dist/components/inline-editable.js.map +1 -0
  188. package/dist/components/input-area.js +3 -3
  189. package/dist/components/input-group.js +7 -7
  190. package/dist/components/input.js +3 -3
  191. package/dist/components/label.js +18 -17
  192. package/dist/components/label.js.map +1 -1
  193. package/dist/components/layer-card.d.ts +10 -2
  194. package/dist/components/layer-card.js +71 -68
  195. package/dist/components/layer-card.js.map +1 -1
  196. package/dist/components/loader.d.ts +10 -2
  197. package/dist/components/loader.js.map +1 -1
  198. package/dist/components/menu-bar.d.ts +174 -6
  199. package/dist/components/menu-bar.js +33 -29
  200. package/dist/components/menu-bar.js.map +1 -1
  201. package/dist/components/meter.d.ts +27 -2
  202. package/dist/components/meter.js.map +1 -1
  203. package/dist/components/multi-select.d.ts +64 -0
  204. package/dist/components/multi-select.js +218 -0
  205. package/dist/components/multi-select.js.map +1 -0
  206. package/dist/components/navigation-menu.d.ts +88 -5
  207. package/dist/components/navigation-menu.js.map +1 -1
  208. package/dist/components/overlay.js +6 -5
  209. package/dist/components/overlay.js.map +1 -1
  210. package/dist/components/page-header.js +23 -21
  211. package/dist/components/page-header.js.map +1 -1
  212. package/dist/components/pagination.js +7 -7
  213. package/dist/components/popover.d.ts +136 -16
  214. package/dist/components/popover.js +32 -28
  215. package/dist/components/popover.js.map +1 -1
  216. package/dist/components/radio.js +38 -37
  217. package/dist/components/radio.js.map +1 -1
  218. package/dist/components/resource-list.d.ts +26 -1
  219. package/dist/components/resource-list.js +28 -15
  220. package/dist/components/resource-list.js.map +1 -1
  221. package/dist/components/responsive-master-detail.d.ts +27 -0
  222. package/dist/components/responsive-master-detail.js +85 -0
  223. package/dist/components/responsive-master-detail.js.map +1 -0
  224. package/dist/components/section-rule.js +23 -22
  225. package/dist/components/section-rule.js.map +1 -1
  226. package/dist/components/select.d.ts +27 -3
  227. package/dist/components/select.js +11 -11
  228. package/dist/components/select.js.map +1 -1
  229. package/dist/components/sheet.d.ts +115 -11
  230. package/dist/components/sheet.js +37 -30
  231. package/dist/components/sheet.js.map +1 -1
  232. package/dist/components/sidebar.d.ts +109 -17
  233. package/dist/components/sidebar.js +109 -108
  234. package/dist/components/sidebar.js.map +1 -1
  235. package/dist/components/skeleton-line.d.ts +22 -2
  236. package/dist/components/skeleton-line.js.map +1 -1
  237. package/dist/components/slider.d.ts +61 -1
  238. package/dist/components/slider.js +31 -15
  239. package/dist/components/slider.js.map +1 -1
  240. package/dist/components/stat-strip.js +16 -15
  241. package/dist/components/stat-strip.js.map +1 -1
  242. package/dist/components/switch.js +78 -47
  243. package/dist/components/switch.js.map +1 -1
  244. package/dist/components/table-of-contents.js +18 -17
  245. package/dist/components/table-of-contents.js.map +1 -1
  246. package/dist/components/table-pager.js +20 -19
  247. package/dist/components/table-pager.js.map +1 -1
  248. package/dist/components/table.d.ts +9 -3
  249. package/dist/components/table.js +19 -18
  250. package/dist/components/table.js.map +1 -1
  251. package/dist/components/tabs.js +29 -22
  252. package/dist/components/tabs.js.map +1 -1
  253. package/dist/components/tag-badge.d.ts +58 -0
  254. package/dist/components/tag-badge.js +72 -0
  255. package/dist/components/tag-badge.js.map +1 -0
  256. package/dist/components/tag-color-picker.d.ts +20 -0
  257. package/dist/components/tag-color-picker.js +42 -0
  258. package/dist/components/tag-color-picker.js.map +1 -0
  259. package/dist/components/text.js +17 -16
  260. package/dist/components/text.js.map +1 -1
  261. package/dist/components/toast.d.ts +173 -3
  262. package/dist/components/toast.js +1 -1
  263. package/dist/components/toast.js.map +1 -1
  264. package/dist/components/toggle-group.d.ts +88 -2
  265. package/dist/components/toggle-group.js +32 -31
  266. package/dist/components/toggle-group.js.map +1 -1
  267. package/dist/components/toggle.d.ts +35 -2
  268. package/dist/components/toggle.js +12 -11
  269. package/dist/components/toggle.js.map +1 -1
  270. package/dist/components/tooltip.d.ts +144 -6
  271. package/dist/components/tooltip.js +9 -6
  272. package/dist/components/tooltip.js.map +1 -1
  273. package/dist/components/typeahead-field.js +193 -132
  274. package/dist/components/typeahead-field.js.map +1 -1
  275. package/dist/components/upload-queue.d.ts +51 -0
  276. package/dist/components/upload-queue.js +116 -0
  277. package/dist/components/upload-queue.js.map +1 -0
  278. package/dist/providers/accent.d.ts +46 -2
  279. package/dist/providers/accent.js +358 -172
  280. package/dist/providers/accent.js.map +1 -1
  281. package/dist/providers/link.d.ts +14 -4
  282. package/dist/providers/link.js.map +1 -1
  283. package/dist/providers/theme.d.ts +38 -2
  284. package/dist/providers/theme.js +160 -27
  285. package/dist/providers/theme.js.map +1 -1
  286. package/dist/styles/base.css +83 -0
  287. package/dist/styles/standalone.css +711 -120
  288. package/dist/styles/tailwind.css +21 -7
  289. package/dist/styles/tokens.css +145 -91
  290. package/dist/utils/control-surface.d.ts +2 -1
  291. package/dist/utils/control-surface.js +4 -4
  292. package/dist/utils/control-surface.js.map +1 -1
  293. package/dist/utils/selection-indicator.js +2 -2
  294. package/dist/utils/selection-indicator.js.map +1 -1
  295. package/package.json +8 -4
@@ -1,8 +1,61 @@
1
- import type { XYPoint, XYSeriesDescriptor } from "./series.js";
2
- export type ChartsProps = {
3
- data: XYPoint[];
4
- series?: XYSeriesDescriptor[];
1
+ import type { ReactNode } from "react";
2
+ import { type LineChartAxisDomain, type LineChartLegendRenderer, type LineChartNumericKeys, type LineChartTooltipRenderer } from "./line.js";
3
+ import type { ChartSeriesDescriptor, XYPoint } from "./series.js";
4
+ export type ChartsProps<TData extends {
5
+ x: string | number;
6
+ } = XYPoint, K extends LineChartNumericKeys<TData> & string = LineChartNumericKeys<TData> & string> = {
7
+ /**
8
+ * Dataset array where each record requires an `x` category or time coordinate.
9
+ * Any remaining fields with numeric, nullable, or optional number values are inferred as valid series keys.
10
+ */
11
+ data: TData[];
12
+ /**
13
+ * Series descriptors identifying which numeric keys to plot.
14
+ * Inferred strictly from numeric keys of `TData` (rejects non-numeric fields, `x`, and typos).
15
+ */
16
+ series?: Array<ChartSeriesDescriptor<NoInfer<K>>>;
5
17
  ariaLabel?: string;
6
18
  className?: string;
19
+ showAxes?: boolean;
20
+ showLegend?: boolean;
21
+ color?: string;
22
+ /**
23
+ * Value formatter for Y-axis tick values and fallback tooltip values.
24
+ */
25
+ valueFormatter?: (value: number) => string;
26
+ /**
27
+ * Formatter for X-axis category or time tick labels.
28
+ */
29
+ xValueFormatter?: (value: string | number) => string;
30
+ /**
31
+ * Custom numerical or keyword bounds for the Y-axis.
32
+ */
33
+ yDomain?: LineChartAxisDomain;
34
+ /**
35
+ * Custom legend slot or render function receiving resolved series descriptors.
36
+ */
37
+ legend?: ReactNode | LineChartLegendRenderer<K>;
38
+ /**
39
+ * Custom tooltip content renderer receiving Recharts payload, active status, and coordinate label.
40
+ */
41
+ customTooltip?: LineChartTooltipRenderer;
42
+ /**
43
+ * Textual summary describing key insights, highs, lows, and keyboard exploration instructions.
44
+ * Associated with the chart via useId and aria-describedby.
45
+ */
46
+ summary?: ReactNode;
47
+ /**
48
+ * Accessible tabular or structured data alternative rendered outside the plot area.
49
+ */
50
+ dataAlternative?: ReactNode;
51
+ /**
52
+ * Whether the interactive accessibility layer is enabled on the underlying Recharts graphic.
53
+ * Enables keyboard exploration with Tab and arrow keys where supported by the underlying chart type.
54
+ * Non-interactive compact or decorative charts without tooltip navigation should provide summary or dataAlternative.
55
+ * @default true
56
+ */
57
+ accessibilityLayer?: boolean;
7
58
  };
8
- export declare function Charts({ data, series, ariaLabel, className }: ChartsProps): import("react").JSX.Element;
59
+ export declare function Charts<TData extends {
60
+ x: string | number;
61
+ } = XYPoint, K extends LineChartNumericKeys<TData> & string = LineChartNumericKeys<TData> & string>({ data, series, ariaLabel, className, showAxes, showLegend, color, valueFormatter, xValueFormatter, yDomain, legend, customTooltip, summary, dataAlternative, accessibilityLayer, }: ChartsProps<TData, K>): import("react").JSX.Element;
@@ -2,12 +2,23 @@
2
2
  import { LineChart as e } from "./line.js";
3
3
  import { jsx as t } from "react/jsx-runtime";
4
4
  //#region src/charts/charts.tsx
5
- function n({ data: n, series: r, ariaLabel: i = "Charts", className: a }) {
5
+ function n({ data: n, series: r, ariaLabel: i = "Charts", className: a, showAxes: o = !1, showLegend: s = !1, color: c, valueFormatter: l, xValueFormatter: u, yDomain: d, legend: f, customTooltip: p, summary: m, dataAlternative: h, accessibilityLayer: g }) {
6
6
  return /* @__PURE__ */ t(e, {
7
7
  data: n,
8
8
  series: r,
9
9
  ariaLabel: i,
10
- className: a
10
+ className: a,
11
+ showAxes: o,
12
+ showLegend: s,
13
+ color: c,
14
+ valueFormatter: l,
15
+ xValueFormatter: u,
16
+ yDomain: d,
17
+ legend: f,
18
+ customTooltip: p,
19
+ summary: m,
20
+ dataAlternative: h,
21
+ accessibilityLayer: g
11
22
  });
12
23
  }
13
24
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"charts.js","names":[],"sources":["../../src/charts/charts.tsx"],"sourcesContent":["import { LineChart } from \"./line\";\nimport type { XYPoint, XYSeriesDescriptor } from \"./series\";\n\nexport type ChartsProps = {\n\tdata: XYPoint[];\n\tseries?: XYSeriesDescriptor[];\n\tariaLabel?: string;\n\tclassName?: string;\n};\n\nexport function Charts({ data, series, ariaLabel = \"Charts\", className }: ChartsProps) {\n\treturn <LineChart data={data} series={series} ariaLabel={ariaLabel} className={className} />;\n}\n"],"mappings":";;;;AAUA,SAAgB,EAAO,EAAE,SAAM,WAAQ,eAAY,UAAU,gBAA0B;CACtF,OAAO,kBAAC,GAAD;EAAiB;EAAc;EAAmB;EAAsB;CAAY,CAAA;AAC5F"}
1
+ {"version":3,"file":"charts.js","names":[],"sources":["../../src/charts/charts.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport {\n\tLineChart,\n\ttype LineChartAxisDomain,\n\ttype LineChartLegendRenderer,\n\ttype LineChartNumericKeys,\n\ttype LineChartTooltipRenderer,\n} from \"./line\";\nimport type { ChartSeriesDescriptor, XYPoint } from \"./series\";\n\nexport type ChartsProps<\n\tTData extends { x: string | number } = XYPoint,\n\tK extends LineChartNumericKeys<TData> & string = LineChartNumericKeys<TData> & string,\n> = {\n\t/**\n\t * Dataset array where each record requires an `x` category or time coordinate.\n\t * Any remaining fields with numeric, nullable, or optional number values are inferred as valid series keys.\n\t */\n\tdata: TData[];\n\t/**\n\t * Series descriptors identifying which numeric keys to plot.\n\t * Inferred strictly from numeric keys of `TData` (rejects non-numeric fields, `x`, and typos).\n\t */\n\tseries?: Array<ChartSeriesDescriptor<NoInfer<K>>>;\n\tariaLabel?: string;\n\tclassName?: string;\n\tshowAxes?: boolean;\n\tshowLegend?: boolean;\n\tcolor?: string;\n\t/**\n\t * Value formatter for Y-axis tick values and fallback tooltip values.\n\t */\n\tvalueFormatter?: (value: number) => string;\n\t/**\n\t * Formatter for X-axis category or time tick labels.\n\t */\n\txValueFormatter?: (value: string | number) => string;\n\t/**\n\t * Custom numerical or keyword bounds for the Y-axis.\n\t */\n\tyDomain?: LineChartAxisDomain;\n\t/**\n\t * Custom legend slot or render function receiving resolved series descriptors.\n\t */\n\tlegend?: ReactNode | LineChartLegendRenderer<K>;\n\t/**\n\t * Custom tooltip content renderer receiving Recharts payload, active status, and coordinate label.\n\t */\n\tcustomTooltip?: LineChartTooltipRenderer;\n\t/**\n\t * Textual summary describing key insights, highs, lows, and keyboard exploration instructions.\n\t * Associated with the chart via useId and aria-describedby.\n\t */\n\tsummary?: ReactNode;\n\t/**\n\t * Accessible tabular or structured data alternative rendered outside the plot area.\n\t */\n\tdataAlternative?: ReactNode;\n\t/**\n\t * Whether the interactive accessibility layer is enabled on the underlying Recharts graphic.\n\t * Enables keyboard exploration with Tab and arrow keys where supported by the underlying chart type.\n\t * Non-interactive compact or decorative charts without tooltip navigation should provide summary or dataAlternative.\n\t * @default true\n\t */\n\taccessibilityLayer?: boolean;\n};\n\nexport function Charts<\n\tTData extends { x: string | number } = XYPoint,\n\tK extends LineChartNumericKeys<TData> & string = LineChartNumericKeys<TData> & string,\n>({\n\tdata,\n\tseries,\n\tariaLabel = \"Charts\",\n\tclassName,\n\tshowAxes = false,\n\tshowLegend = false,\n\tcolor,\n\tvalueFormatter,\n\txValueFormatter,\n\tyDomain,\n\tlegend,\n\tcustomTooltip,\n\tsummary,\n\tdataAlternative,\n\taccessibilityLayer,\n}: ChartsProps<TData, K>) {\n\treturn (\n\t\t<LineChart\n\t\t\tdata={data}\n\t\t\tseries={series}\n\t\t\tariaLabel={ariaLabel}\n\t\t\tclassName={className}\n\t\t\tshowAxes={showAxes}\n\t\t\tshowLegend={showLegend}\n\t\t\tcolor={color}\n\t\t\tvalueFormatter={valueFormatter}\n\t\t\txValueFormatter={xValueFormatter}\n\t\t\tyDomain={yDomain}\n\t\t\tlegend={legend}\n\t\t\tcustomTooltip={customTooltip}\n\t\t\tsummary={summary}\n\t\t\tdataAlternative={dataAlternative}\n\t\t\taccessibilityLayer={accessibilityLayer}\n\t\t/>\n\t);\n}\n"],"mappings":";;;;AAmEA,SAAgB,EAGd,EACD,SACA,WACA,eAAY,UACZ,cACA,cAAW,IACX,gBAAa,IACb,UACA,mBACA,oBACA,YACA,WACA,kBACA,YACA,oBACA,yBACyB;CACzB,OACC,kBAAC,GAAD;EACO;EACE;EACG;EACA;EACD;EACE;EACL;EACS;EACC;EACR;EACD;EACO;EACN;EACQ;EACG;CACpB,CAAA;AAEH"}
@@ -1,4 +1,6 @@
1
+ import { type ReactNode } from "react";
1
2
  import type { ChartSeriesDescriptor } from "./series.js";
3
+ import { type ChartTooltipItem } from "./tooltip.js";
2
4
  export type { ChartSeriesDescriptor } from "./series.js";
3
5
  export type ChartTypeFace = "axis" | "legend" | "tooltipTitle" | "tooltipBody";
4
6
  export declare const CHART_TYPE: {
@@ -72,6 +74,11 @@ export declare function chartTooltipContentStyle(): {
72
74
  export declare function chartTooltipProps(options?: {
73
75
  formatter?: (value: number) => string;
74
76
  cursor?: "bar" | "line" | false;
77
+ customTooltip?: (props: {
78
+ active?: boolean;
79
+ payload?: readonly ChartTooltipItem[];
80
+ label?: string | number;
81
+ }) => ReactNode;
75
82
  }): {
76
83
  isAnimationActive: boolean;
77
84
  animationDuration: number;
@@ -97,7 +97,11 @@ function v(e) {
97
97
  animation: "none"
98
98
  },
99
99
  contentStyle: _(),
100
- content: ((t) => i(r, {
100
+ content: ((t) => e?.customTooltip ? e.customTooltip({
101
+ active: t.active,
102
+ payload: t.payload,
103
+ label: t.label
104
+ }) : i(r, {
101
105
  active: t.active,
102
106
  payload: t.payload,
103
107
  label: t.label,
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":[],"sources":["../../src/charts/config.ts"],"sourcesContent":["import { createElement } from \"react\";\nimport { CHART_COLORS, chartAxis, withAlpha } from \"./palette\";\nimport type { ChartSeriesDescriptor } from \"./series\";\nimport { ChartTooltipContent, type ChartTooltipItem } from \"./tooltip\";\n\nexport type { ChartSeriesDescriptor } from \"./series\";\n\nexport type ChartTypeFace = \"axis\" | \"legend\" | \"tooltipTitle\" | \"tooltipBody\";\n\nexport const CHART_TYPE = {\n\taxisFontSize: 11,\n\tlegendFontSize: 12,\n\ttooltipTitleSize: 12,\n\ttooltipBodySize: 12,\n\ttooltipDot: 8,\n\tstrokeWidth: 2,\n\tgridDash: \"3 3\",\n\tgridOpacity: 0.15,\n\tareaFillAlpha: 0.2,\n} as const;\n\nexport function chartFontSize(face: ChartTypeFace): number {\n\tif (face === \"legend\") {\n\t\treturn CHART_TYPE.legendFontSize;\n\t}\n\tif (face === \"tooltipTitle\") {\n\t\treturn CHART_TYPE.tooltipTitleSize;\n\t}\n\tif (face === \"tooltipBody\") {\n\t\treturn CHART_TYPE.tooltipBodySize;\n\t}\n\treturn CHART_TYPE.axisFontSize;\n}\n\nexport function chartTextStyle(face: ChartTypeFace): { fontSize: number } {\n\treturn { fontSize: chartFontSize(face) };\n}\n\nexport function chartTickStyle(face: ChartTypeFace = \"axis\"): {\n\tfontSize: number;\n\tfill: string;\n} {\n\treturn { fontSize: chartFontSize(face), fill: chartAxis };\n}\n\nexport function getChartColor(index: number): string {\n\treturn CHART_COLORS[index % CHART_COLORS.length] ?? CHART_COLORS[0];\n}\n\nexport const AXIS_CONFIG = {\n\tget tick() {\n\t\treturn chartTickStyle(\"axis\");\n\t},\n\taxisLine: false as const,\n\ttickLine: false as const,\n};\n\nexport function cartesianAxisProps(hidden = false) {\n\treturn { hide: hidden, ...AXIS_CONFIG };\n}\n\nexport const GRID_PROPS = {\n\tvertical: false as const,\n\tstroke: chartAxis,\n\tstrokeOpacity: CHART_TYPE.gridOpacity,\n\tstrokeDasharray: CHART_TYPE.gridDash,\n};\n\nexport const BAR_RADIUS = {\n\thorizontal: [0, 4, 4, 0] as [number, number, number, number],\n\tvertical: [4, 4, 0, 0] as [number, number, number, number],\n};\n\nexport const ANIMATION_PROPS = {\n\tisAnimationActive: false,\n};\n\nexport const CHART_TOOLTIP_CURSOR_LINE = {\n\tstroke: chartAxis,\n\tstrokeOpacity: 0.35,\n\tstrokeWidth: 1,\n} as const;\n\nexport const CHART_TOOLTIP_CURSOR_BAR = {\n\tfill: withAlpha(\"foreground\", 0.06),\n\tstroke: \"none\",\n} as const;\n\nexport function chartTooltipContentStyle(): {\n\tbackground: string;\n\tborder: string;\n\tborderRadius: string;\n\tboxShadow: string;\n\tfontSize: number;\n\tcolor: string;\n\tpadding: string;\n} {\n\treturn {\n\t\tbackground: \"transparent\",\n\t\tborder: \"none\",\n\t\tborderRadius: \"0\",\n\t\tboxShadow: \"none\",\n\t\tfontSize: chartFontSize(\"tooltipBody\"),\n\t\tcolor: \"hsl(var(--basalt-foreground))\",\n\t\tpadding: \"0\",\n\t};\n}\n\nexport function chartTooltipProps(options?: {\n\tformatter?: (value: number) => string;\n\tcursor?: \"bar\" | \"line\" | false;\n}) {\n\tconst cursor =\n\t\toptions?.cursor === false\n\t\t\t? false\n\t\t\t: options?.cursor === \"line\"\n\t\t\t\t? CHART_TOOLTIP_CURSOR_LINE\n\t\t\t\t: CHART_TOOLTIP_CURSOR_BAR;\n\treturn {\n\t\tisAnimationActive: false,\n\t\tanimationDuration: 0,\n\t\toffset: 12,\n\t\tallowEscapeViewBox: { x: false, y: false },\n\t\tcursor,\n\t\twrapperStyle: {\n\t\t\toutline: \"none\",\n\t\t\tzIndex: 40,\n\t\t\tpointerEvents: \"none\" as const,\n\t\t\ttransition: \"none\",\n\t\t\tanimation: \"none\",\n\t\t},\n\t\tcontentStyle: chartTooltipContentStyle(),\n\t\tcontent: ((props: {\n\t\t\tactive?: boolean;\n\t\t\tpayload?: readonly ChartTooltipItem[];\n\t\t\tlabel?: unknown;\n\t\t}) =>\n\t\t\tcreateElement(ChartTooltipContent, {\n\t\t\t\tactive: props.active,\n\t\t\t\tpayload: props.payload,\n\t\t\t\tlabel: props.label as string | number | undefined,\n\t\t\t\tformatter: options?.formatter,\n\t\t\t})) as never,\n\t};\n}\n\nexport function seriesColor(\n\tseries: ChartSeriesDescriptor | undefined,\n\tindex: number,\n): string | undefined {\n\treturn series?.color ?? CHART_COLORS[index % CHART_COLORS.length];\n}\n\nexport const RESPONSIVE_CONTAINER_PROPS = {\n\twidth: \"100%\" as const,\n\theight: \"100%\" as const,\n\tminWidth: 0,\n\tminHeight: 0,\n\tdebounce: 150,\n};\n\nexport const CHART_PLOT_MARGIN = {\n\ttop: 4,\n\tright: 4,\n\tbottom: 0,\n\tleft: 0,\n} as const;\n\nexport const CHART_PLOT_MARGIN_BARE = {\n\ttop: 2,\n\tright: 2,\n\tbottom: 2,\n\tleft: 2,\n} as const;\n"],"mappings":";;;;;AASA,IAAa,IAAa;CACzB,cAAc;CACd,gBAAgB;CAChB,kBAAkB;CAClB,iBAAiB;CACjB,YAAY;CACZ,aAAa;CACb,UAAU;CACV,aAAa;CACb,eAAe;AAChB;AAEA,SAAgB,EAAc,GAA6B;CAU1D,OATI,MAAS,WACL,EAAW,iBAEf,MAAS,iBACL,EAAW,mBAEf,MAAS,gBACL,EAAW,kBAEZ,EAAW;AACnB;AAEA,SAAgB,EAAe,GAA2C;CACzE,OAAO,EAAE,UAAU,EAAc,CAAI,EAAE;AACxC;AAEA,SAAgB,EAAe,IAAsB,QAGnD;CACD,OAAO;EAAE,UAAU,EAAc,CAAI;EAAG,MAAM;CAAU;AACzD;AAEA,SAAgB,EAAc,GAAuB;CACpD,OAAO,EAAa,IAAQ,EAAa,WAAW,EAAa;AAClE;AAEA,IAAa,IAAc;CAC1B,IAAI,OAAO;EACV,OAAO,EAAe,MAAM;CAC7B;CACA,UAAU;CACV,UAAU;AACX;AAEA,SAAgB,EAAmB,IAAS,IAAO;CAClD,OAAO;EAAE,MAAM;EAAQ,GAAG;CAAY;AACvC;AAEA,IAAa,IAAa;CACzB,UAAU;CACV,QAAQ;CACR,eAAe,EAAW;CAC1B,iBAAiB,EAAW;AAC7B,GAEa,IAAa;CACzB,YAAY;EAAC;EAAG;EAAG;EAAG;CAAC;CACvB,UAAU;EAAC;EAAG;EAAG;EAAG;CAAC;AACtB,GAEa,IAAkB,EAC9B,mBAAmB,GACpB,GAEa,IAA4B;CACxC,QAAQ;CACR,eAAe;CACf,aAAa;AACd,GAEa,IAA2B;CACvC,MAAM,EAAU,cAAc,GAAI;CAClC,QAAQ;AACT;AAEA,SAAgB,IAQd;CACD,OAAO;EACN,YAAY;EACZ,QAAQ;EACR,cAAc;EACd,WAAW;EACX,UAAU,EAAc,aAAa;EACrC,OAAO;EACP,SAAS;CACV;AACD;AAEA,SAAgB,EAAkB,GAG/B;CAOF,OAAO;EACN,mBAAmB;EACnB,mBAAmB;EACnB,QAAQ;EACR,oBAAoB;GAAE,GAAG;GAAO,GAAG;EAAM;EACzC,QAVA,GAAS,WAAW,KACjB,KACA,GAAS,WAAW,SACnB,IACA;EAOJ,cAAc;GACb,SAAS;GACT,QAAQ;GACR,eAAe;GACf,YAAY;GACZ,WAAW;EACZ;EACA,cAAc,EAAyB;EACvC,WAAW,MAKV,EAAc,GAAqB;GAClC,QAAQ,EAAM;GACd,SAAS,EAAM;GACf,OAAO,EAAM;GACb,WAAW,GAAS;EACrB,CAAC;CACH;AACD;AAEA,SAAgB,EACf,GACA,GACqB;CACrB,OAAO,GAAQ,SAAS,EAAa,IAAQ,EAAa;AAC3D;AAEA,IAAa,IAA6B;CACzC,OAAO;CACP,QAAQ;CACR,UAAU;CACV,WAAW;CACX,UAAU;AACX,GAEa,IAAoB;CAChC,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;AACP,GAEa,IAAyB;CACrC,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;AACP"}
1
+ {"version":3,"file":"config.js","names":[],"sources":["../../src/charts/config.ts"],"sourcesContent":["import { createElement, type ReactNode } from \"react\";\nimport { CHART_COLORS, chartAxis, withAlpha } from \"./palette\";\nimport type { ChartSeriesDescriptor } from \"./series\";\nimport { ChartTooltipContent, type ChartTooltipItem } from \"./tooltip\";\n\nexport type { ChartSeriesDescriptor } from \"./series\";\n\nexport type ChartTypeFace = \"axis\" | \"legend\" | \"tooltipTitle\" | \"tooltipBody\";\n\nexport const CHART_TYPE = {\n\taxisFontSize: 11,\n\tlegendFontSize: 12,\n\ttooltipTitleSize: 12,\n\ttooltipBodySize: 12,\n\ttooltipDot: 8,\n\tstrokeWidth: 2,\n\tgridDash: \"3 3\",\n\tgridOpacity: 0.15,\n\tareaFillAlpha: 0.2,\n} as const;\n\nexport function chartFontSize(face: ChartTypeFace): number {\n\tif (face === \"legend\") {\n\t\treturn CHART_TYPE.legendFontSize;\n\t}\n\tif (face === \"tooltipTitle\") {\n\t\treturn CHART_TYPE.tooltipTitleSize;\n\t}\n\tif (face === \"tooltipBody\") {\n\t\treturn CHART_TYPE.tooltipBodySize;\n\t}\n\treturn CHART_TYPE.axisFontSize;\n}\n\nexport function chartTextStyle(face: ChartTypeFace): { fontSize: number } {\n\treturn { fontSize: chartFontSize(face) };\n}\n\nexport function chartTickStyle(face: ChartTypeFace = \"axis\"): {\n\tfontSize: number;\n\tfill: string;\n} {\n\treturn { fontSize: chartFontSize(face), fill: chartAxis };\n}\n\nexport function getChartColor(index: number): string {\n\treturn CHART_COLORS[index % CHART_COLORS.length] ?? CHART_COLORS[0];\n}\n\nexport const AXIS_CONFIG = {\n\tget tick() {\n\t\treturn chartTickStyle(\"axis\");\n\t},\n\taxisLine: false as const,\n\ttickLine: false as const,\n};\n\nexport function cartesianAxisProps(hidden = false) {\n\treturn { hide: hidden, ...AXIS_CONFIG };\n}\n\nexport const GRID_PROPS = {\n\tvertical: false as const,\n\tstroke: chartAxis,\n\tstrokeOpacity: CHART_TYPE.gridOpacity,\n\tstrokeDasharray: CHART_TYPE.gridDash,\n};\n\nexport const BAR_RADIUS = {\n\thorizontal: [0, 4, 4, 0] as [number, number, number, number],\n\tvertical: [4, 4, 0, 0] as [number, number, number, number],\n};\n\nexport const ANIMATION_PROPS = {\n\tisAnimationActive: false,\n};\n\nexport const CHART_TOOLTIP_CURSOR_LINE = {\n\tstroke: chartAxis,\n\tstrokeOpacity: 0.35,\n\tstrokeWidth: 1,\n} as const;\n\nexport const CHART_TOOLTIP_CURSOR_BAR = {\n\tfill: withAlpha(\"foreground\", 0.06),\n\tstroke: \"none\",\n} as const;\n\nexport function chartTooltipContentStyle(): {\n\tbackground: string;\n\tborder: string;\n\tborderRadius: string;\n\tboxShadow: string;\n\tfontSize: number;\n\tcolor: string;\n\tpadding: string;\n} {\n\treturn {\n\t\tbackground: \"transparent\",\n\t\tborder: \"none\",\n\t\tborderRadius: \"0\",\n\t\tboxShadow: \"none\",\n\t\tfontSize: chartFontSize(\"tooltipBody\"),\n\t\tcolor: \"hsl(var(--basalt-foreground))\",\n\t\tpadding: \"0\",\n\t};\n}\n\nexport function chartTooltipProps(options?: {\n\tformatter?: (value: number) => string;\n\tcursor?: \"bar\" | \"line\" | false;\n\tcustomTooltip?: (props: {\n\t\tactive?: boolean;\n\t\tpayload?: readonly ChartTooltipItem[];\n\t\tlabel?: string | number;\n\t}) => ReactNode;\n}) {\n\tconst cursor =\n\t\toptions?.cursor === false\n\t\t\t? false\n\t\t\t: options?.cursor === \"line\"\n\t\t\t\t? CHART_TOOLTIP_CURSOR_LINE\n\t\t\t\t: CHART_TOOLTIP_CURSOR_BAR;\n\treturn {\n\t\tisAnimationActive: false,\n\t\tanimationDuration: 0,\n\t\toffset: 12,\n\t\tallowEscapeViewBox: { x: false, y: false },\n\t\tcursor,\n\t\twrapperStyle: {\n\t\t\toutline: \"none\",\n\t\t\tzIndex: 40,\n\t\t\tpointerEvents: \"none\" as const,\n\t\t\ttransition: \"none\",\n\t\t\tanimation: \"none\",\n\t\t},\n\t\tcontentStyle: chartTooltipContentStyle(),\n\t\tcontent: ((props: {\n\t\t\tactive?: boolean;\n\t\t\tpayload?: readonly ChartTooltipItem[];\n\t\t\tlabel?: unknown;\n\t\t}) => {\n\t\t\tif (options?.customTooltip) {\n\t\t\t\treturn options.customTooltip({\n\t\t\t\t\tactive: props.active,\n\t\t\t\t\tpayload: props.payload,\n\t\t\t\t\tlabel: props.label as string | number | undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn createElement(ChartTooltipContent, {\n\t\t\t\tactive: props.active,\n\t\t\t\tpayload: props.payload,\n\t\t\t\tlabel: props.label as string | number | undefined,\n\t\t\t\tformatter: options?.formatter,\n\t\t\t});\n\t\t}) as never,\n\t};\n}\n\nexport function seriesColor(\n\tseries: ChartSeriesDescriptor | undefined,\n\tindex: number,\n): string | undefined {\n\treturn series?.color ?? CHART_COLORS[index % CHART_COLORS.length];\n}\n\nexport const RESPONSIVE_CONTAINER_PROPS = {\n\twidth: \"100%\" as const,\n\theight: \"100%\" as const,\n\tminWidth: 0,\n\tminHeight: 0,\n\tdebounce: 150,\n};\n\nexport const CHART_PLOT_MARGIN = {\n\ttop: 4,\n\tright: 4,\n\tbottom: 0,\n\tleft: 0,\n} as const;\n\nexport const CHART_PLOT_MARGIN_BARE = {\n\ttop: 2,\n\tright: 2,\n\tbottom: 2,\n\tleft: 2,\n} as const;\n"],"mappings":";;;;;AASA,IAAa,IAAa;CACzB,cAAc;CACd,gBAAgB;CAChB,kBAAkB;CAClB,iBAAiB;CACjB,YAAY;CACZ,aAAa;CACb,UAAU;CACV,aAAa;CACb,eAAe;AAChB;AAEA,SAAgB,EAAc,GAA6B;CAU1D,OATI,MAAS,WACL,EAAW,iBAEf,MAAS,iBACL,EAAW,mBAEf,MAAS,gBACL,EAAW,kBAEZ,EAAW;AACnB;AAEA,SAAgB,EAAe,GAA2C;CACzE,OAAO,EAAE,UAAU,EAAc,CAAI,EAAE;AACxC;AAEA,SAAgB,EAAe,IAAsB,QAGnD;CACD,OAAO;EAAE,UAAU,EAAc,CAAI;EAAG,MAAM;CAAU;AACzD;AAEA,SAAgB,EAAc,GAAuB;CACpD,OAAO,EAAa,IAAQ,EAAa,WAAW,EAAa;AAClE;AAEA,IAAa,IAAc;CAC1B,IAAI,OAAO;EACV,OAAO,EAAe,MAAM;CAC7B;CACA,UAAU;CACV,UAAU;AACX;AAEA,SAAgB,EAAmB,IAAS,IAAO;CAClD,OAAO;EAAE,MAAM;EAAQ,GAAG;CAAY;AACvC;AAEA,IAAa,IAAa;CACzB,UAAU;CACV,QAAQ;CACR,eAAe,EAAW;CAC1B,iBAAiB,EAAW;AAC7B,GAEa,IAAa;CACzB,YAAY;EAAC;EAAG;EAAG;EAAG;CAAC;CACvB,UAAU;EAAC;EAAG;EAAG;EAAG;CAAC;AACtB,GAEa,IAAkB,EAC9B,mBAAmB,GACpB,GAEa,IAA4B;CACxC,QAAQ;CACR,eAAe;CACf,aAAa;AACd,GAEa,IAA2B;CACvC,MAAM,EAAU,cAAc,GAAI;CAClC,QAAQ;AACT;AAEA,SAAgB,IAQd;CACD,OAAO;EACN,YAAY;EACZ,QAAQ;EACR,cAAc;EACd,WAAW;EACX,UAAU,EAAc,aAAa;EACrC,OAAO;EACP,SAAS;CACV;AACD;AAEA,SAAgB,EAAkB,GAQ/B;CAOF,OAAO;EACN,mBAAmB;EACnB,mBAAmB;EACnB,QAAQ;EACR,oBAAoB;GAAE,GAAG;GAAO,GAAG;EAAM;EACzC,QAVA,GAAS,WAAW,KACjB,KACA,GAAS,WAAW,SACnB,IACA;EAOJ,cAAc;GACb,SAAS;GACT,QAAQ;GACR,eAAe;GACf,YAAY;GACZ,WAAW;EACZ;EACA,cAAc,EAAyB;EACvC,WAAW,MAKN,GAAS,gBACL,EAAQ,cAAc;GAC5B,QAAQ,EAAM;GACd,SAAS,EAAM;GACf,OAAO,EAAM;EACd,CAAC,IAEK,EAAc,GAAqB;GACzC,QAAQ,EAAM;GACd,SAAS,EAAM;GACf,OAAO,EAAM;GACb,WAAW,GAAS;EACrB,CAAC;CAEH;AACD;AAEA,SAAgB,EACf,GACA,GACqB;CACrB,OAAO,GAAQ,SAAS,EAAa,IAAQ,EAAa;AAC3D;AAEA,IAAa,IAA6B;CACzC,OAAO;CACP,QAAQ;CACR,UAAU;CACV,WAAW;CACX,UAAU;AACX,GAEa,IAAoB;CAChC,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;AACP,GAEa,IAAyB;CACrC,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;AACP"}
@@ -1,8 +1,61 @@
1
- import type { XYPoint, XYSeriesDescriptor } from "./series.js";
2
- export type CustomChartProps = {
3
- data: XYPoint[];
4
- series?: XYSeriesDescriptor[];
1
+ import type { ReactNode } from "react";
2
+ import { type LineChartAxisDomain, type LineChartLegendRenderer, type LineChartNumericKeys, type LineChartTooltipRenderer } from "./line.js";
3
+ import type { ChartSeriesDescriptor, XYPoint } from "./series.js";
4
+ export type CustomChartProps<TData extends {
5
+ x: string | number;
6
+ } = XYPoint, K extends LineChartNumericKeys<TData> & string = LineChartNumericKeys<TData> & string> = {
7
+ /**
8
+ * Dataset array where each record requires an `x` category or time coordinate.
9
+ * Any remaining fields with numeric, nullable, or optional number values are inferred as valid series keys.
10
+ */
11
+ data: TData[];
12
+ /**
13
+ * Series descriptors identifying which numeric keys to plot.
14
+ * Inferred strictly from numeric keys of `TData` (rejects non-numeric fields, `x`, and typos).
15
+ */
16
+ series?: Array<ChartSeriesDescriptor<NoInfer<K>>>;
5
17
  ariaLabel?: string;
6
18
  className?: string;
19
+ showAxes?: boolean;
20
+ showLegend?: boolean;
21
+ color?: string;
22
+ /**
23
+ * Value formatter for Y-axis tick values and fallback tooltip values.
24
+ */
25
+ valueFormatter?: (value: number) => string;
26
+ /**
27
+ * Formatter for X-axis category or time tick labels.
28
+ */
29
+ xValueFormatter?: (value: string | number) => string;
30
+ /**
31
+ * Custom numerical or keyword bounds for the Y-axis.
32
+ */
33
+ yDomain?: LineChartAxisDomain;
34
+ /**
35
+ * Custom legend slot or render function receiving resolved series descriptors.
36
+ */
37
+ legend?: ReactNode | LineChartLegendRenderer<K>;
38
+ /**
39
+ * Custom tooltip content renderer receiving Recharts payload, active status, and coordinate label.
40
+ */
41
+ customTooltip?: LineChartTooltipRenderer;
42
+ /**
43
+ * Textual summary describing key insights, highs, lows, and keyboard exploration instructions.
44
+ * Associated with the chart via useId and aria-describedby.
45
+ */
46
+ summary?: ReactNode;
47
+ /**
48
+ * Accessible tabular or structured data alternative rendered outside the plot area.
49
+ */
50
+ dataAlternative?: ReactNode;
51
+ /**
52
+ * Whether the interactive accessibility layer is enabled on the underlying Recharts graphic.
53
+ * Enables keyboard exploration with Tab and arrow keys where supported by the underlying chart type.
54
+ * Non-interactive compact or decorative charts without tooltip navigation should provide summary or dataAlternative.
55
+ * @default true
56
+ */
57
+ accessibilityLayer?: boolean;
7
58
  };
8
- export declare function CustomChart({ data, series, ariaLabel, className, }: CustomChartProps): import("react").JSX.Element;
59
+ export declare function CustomChart<TData extends {
60
+ x: string | number;
61
+ } = XYPoint, K extends LineChartNumericKeys<TData> & string = LineChartNumericKeys<TData> & string>({ data, series, ariaLabel, className, showAxes, showLegend, color, valueFormatter, xValueFormatter, yDomain, legend, customTooltip, summary, dataAlternative, accessibilityLayer, }: CustomChartProps<TData, K>): import("react").JSX.Element;
@@ -2,12 +2,23 @@
2
2
  import { LineChart as e } from "./line.js";
3
3
  import { jsx as t } from "react/jsx-runtime";
4
4
  //#region src/charts/custom-chart.tsx
5
- function n({ data: n, series: r, ariaLabel: i = "Custom chart", className: a }) {
5
+ function n({ data: n, series: r, ariaLabel: i = "Custom chart", className: a, showAxes: o = !1, showLegend: s = !1, color: c, valueFormatter: l, xValueFormatter: u, yDomain: d, legend: f, customTooltip: p, summary: m, dataAlternative: h, accessibilityLayer: g }) {
6
6
  return /* @__PURE__ */ t(e, {
7
7
  data: n,
8
8
  series: r,
9
9
  ariaLabel: i,
10
- className: a
10
+ className: a,
11
+ showAxes: o,
12
+ showLegend: s,
13
+ color: c,
14
+ valueFormatter: l,
15
+ xValueFormatter: u,
16
+ yDomain: d,
17
+ legend: f,
18
+ customTooltip: p,
19
+ summary: m,
20
+ dataAlternative: h,
21
+ accessibilityLayer: g
11
22
  });
12
23
  }
13
24
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"custom-chart.js","names":[],"sources":["../../src/charts/custom-chart.tsx"],"sourcesContent":["import { LineChart } from \"./line\";\nimport type { XYPoint, XYSeriesDescriptor } from \"./series\";\n\nexport type CustomChartProps = {\n\tdata: XYPoint[];\n\tseries?: XYSeriesDescriptor[];\n\tariaLabel?: string;\n\tclassName?: string;\n};\n\nexport function CustomChart({\n\tdata,\n\tseries,\n\tariaLabel = \"Custom chart\",\n\tclassName,\n}: CustomChartProps) {\n\treturn <LineChart data={data} series={series} ariaLabel={ariaLabel} className={className} />;\n}\n"],"mappings":";;;;AAUA,SAAgB,EAAY,EAC3B,SACA,WACA,eAAY,gBACZ,gBACoB;CACpB,OAAO,kBAAC,GAAD;EAAiB;EAAc;EAAmB;EAAsB;CAAY,CAAA;AAC5F"}
1
+ {"version":3,"file":"custom-chart.js","names":[],"sources":["../../src/charts/custom-chart.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport {\n\tLineChart,\n\ttype LineChartAxisDomain,\n\ttype LineChartLegendRenderer,\n\ttype LineChartNumericKeys,\n\ttype LineChartTooltipRenderer,\n} from \"./line\";\nimport type { ChartSeriesDescriptor, XYPoint } from \"./series\";\n\nexport type CustomChartProps<\n\tTData extends { x: string | number } = XYPoint,\n\tK extends LineChartNumericKeys<TData> & string = LineChartNumericKeys<TData> & string,\n> = {\n\t/**\n\t * Dataset array where each record requires an `x` category or time coordinate.\n\t * Any remaining fields with numeric, nullable, or optional number values are inferred as valid series keys.\n\t */\n\tdata: TData[];\n\t/**\n\t * Series descriptors identifying which numeric keys to plot.\n\t * Inferred strictly from numeric keys of `TData` (rejects non-numeric fields, `x`, and typos).\n\t */\n\tseries?: Array<ChartSeriesDescriptor<NoInfer<K>>>;\n\tariaLabel?: string;\n\tclassName?: string;\n\tshowAxes?: boolean;\n\tshowLegend?: boolean;\n\tcolor?: string;\n\t/**\n\t * Value formatter for Y-axis tick values and fallback tooltip values.\n\t */\n\tvalueFormatter?: (value: number) => string;\n\t/**\n\t * Formatter for X-axis category or time tick labels.\n\t */\n\txValueFormatter?: (value: string | number) => string;\n\t/**\n\t * Custom numerical or keyword bounds for the Y-axis.\n\t */\n\tyDomain?: LineChartAxisDomain;\n\t/**\n\t * Custom legend slot or render function receiving resolved series descriptors.\n\t */\n\tlegend?: ReactNode | LineChartLegendRenderer<K>;\n\t/**\n\t * Custom tooltip content renderer receiving Recharts payload, active status, and coordinate label.\n\t */\n\tcustomTooltip?: LineChartTooltipRenderer;\n\t/**\n\t * Textual summary describing key insights, highs, lows, and keyboard exploration instructions.\n\t * Associated with the chart via useId and aria-describedby.\n\t */\n\tsummary?: ReactNode;\n\t/**\n\t * Accessible tabular or structured data alternative rendered outside the plot area.\n\t */\n\tdataAlternative?: ReactNode;\n\t/**\n\t * Whether the interactive accessibility layer is enabled on the underlying Recharts graphic.\n\t * Enables keyboard exploration with Tab and arrow keys where supported by the underlying chart type.\n\t * Non-interactive compact or decorative charts without tooltip navigation should provide summary or dataAlternative.\n\t * @default true\n\t */\n\taccessibilityLayer?: boolean;\n};\n\nexport function CustomChart<\n\tTData extends { x: string | number } = XYPoint,\n\tK extends LineChartNumericKeys<TData> & string = LineChartNumericKeys<TData> & string,\n>({\n\tdata,\n\tseries,\n\tariaLabel = \"Custom chart\",\n\tclassName,\n\tshowAxes = false,\n\tshowLegend = false,\n\tcolor,\n\tvalueFormatter,\n\txValueFormatter,\n\tyDomain,\n\tlegend,\n\tcustomTooltip,\n\tsummary,\n\tdataAlternative,\n\taccessibilityLayer,\n}: CustomChartProps<TData, K>) {\n\treturn (\n\t\t<LineChart\n\t\t\tdata={data}\n\t\t\tseries={series}\n\t\t\tariaLabel={ariaLabel}\n\t\t\tclassName={className}\n\t\t\tshowAxes={showAxes}\n\t\t\tshowLegend={showLegend}\n\t\t\tcolor={color}\n\t\t\tvalueFormatter={valueFormatter}\n\t\t\txValueFormatter={xValueFormatter}\n\t\t\tyDomain={yDomain}\n\t\t\tlegend={legend}\n\t\t\tcustomTooltip={customTooltip}\n\t\t\tsummary={summary}\n\t\t\tdataAlternative={dataAlternative}\n\t\t\taccessibilityLayer={accessibilityLayer}\n\t\t/>\n\t);\n}\n"],"mappings":";;;;AAmEA,SAAgB,EAGd,EACD,SACA,WACA,eAAY,gBACZ,cACA,cAAW,IACX,gBAAa,IACb,UACA,mBACA,oBACA,YACA,WACA,kBACA,YACA,oBACA,yBAC8B;CAC9B,OACC,kBAAC,GAAD;EACO;EACE;EACG;EACA;EACD;EACE;EACL;EACS;EACC;EACR;EACD;EACO;EACN;EACQ;EACG;CACpB,CAAA;AAEH"}
@@ -1,3 +1,4 @@
1
+ import type { ReactNode } from "react";
1
2
  import type { ChartSeriesDescriptor, NamedValue } from "./series.js";
2
3
  export type DonutChartProps = {
3
4
  data: NamedValue[];
@@ -6,5 +7,21 @@ export type DonutChartProps = {
6
7
  className?: string;
7
8
  showLegend?: boolean;
8
9
  valueFormatter?: (value: number) => string;
10
+ /**
11
+ * Textual summary describing key insights, highs, lows, and keyboard exploration instructions.
12
+ * Associated with the chart via useId and aria-describedby.
13
+ */
14
+ summary?: ReactNode;
15
+ /**
16
+ * Accessible tabular or structured data alternative rendered outside the plot area.
17
+ */
18
+ dataAlternative?: ReactNode;
19
+ /**
20
+ * Whether the interactive accessibility layer is enabled on the underlying Recharts graphic.
21
+ * Enables keyboard exploration with Tab and arrow keys where supported by the underlying chart type.
22
+ * Non-interactive compact or decorative charts without tooltip navigation should provide summary or dataAlternative.
23
+ * @default true
24
+ */
25
+ accessibilityLayer?: boolean;
9
26
  };
10
- export declare function DonutChart({ data, series, ariaLabel, className, showLegend, valueFormatter, }: DonutChartProps): import("react").JSX.Element;
27
+ export declare function DonutChart({ data, series, ariaLabel, className, showLegend, valueFormatter, summary, dataAlternative, accessibilityLayer, }: DonutChartProps): import("react").JSX.Element;
@@ -5,8 +5,8 @@ import { ChartLegend as i } from "./legend.js";
5
5
  import { jsx as a, jsxs as o } from "react/jsx-runtime";
6
6
  import { Cell as s, Pie as c, PieChart as l, Tooltip as u } from "recharts";
7
7
  //#region src/charts/donut.tsx
8
- function d({ data: d, series: f, ariaLabel: p = "Donut chart", className: m, showLegend: h = !1, valueFormatter: g }) {
9
- let _ = d.map((e, t) => {
8
+ function d({ data: d, series: f, ariaLabel: p = "Donut chart", className: m, showLegend: h = !1, valueFormatter: g, summary: _, dataAlternative: v, accessibilityLayer: y }) {
9
+ let b = d.map((e, t) => {
10
10
  let r = f?.find((t) => t.key === e.name);
11
11
  return {
12
12
  key: `${e.name}-${t}`,
@@ -19,9 +19,12 @@ function d({ data: d, series: f, ariaLabel: p = "Donut chart", className: m, sho
19
19
  className: m,
20
20
  size: "h-36 w-36",
21
21
  legend: h ? /* @__PURE__ */ a(i, {
22
- items: _,
22
+ items: b,
23
23
  shape: "bar"
24
24
  }) : void 0,
25
+ summary: _,
26
+ dataAlternative: v,
27
+ accessibilityLayer: y,
25
28
  children: /* @__PURE__ */ o(l, { children: [/* @__PURE__ */ a(c, {
26
29
  data: d,
27
30
  dataKey: "value",
@@ -1 +1 @@
1
- {"version":3,"file":"donut.js","names":[],"sources":["../../src/charts/donut.tsx"],"sourcesContent":["import { Cell, Pie, PieChart, Tooltip } from \"recharts\";\nimport { ANIMATION_PROPS, chartTooltipProps, seriesColor } from \"./config\";\nimport { ChartShell } from \"./frame\";\nimport { ChartLegend } from \"./legend\";\nimport type { ChartSeriesDescriptor, NamedValue } from \"./series\";\n\nexport type DonutChartProps = {\n\tdata: NamedValue[];\n\tseries?: ChartSeriesDescriptor[];\n\tariaLabel?: string;\n\tclassName?: string;\n\tshowLegend?: boolean;\n\tvalueFormatter?: (value: number) => string;\n};\n\nexport function DonutChart({\n\tdata,\n\tseries,\n\tariaLabel = \"Donut chart\",\n\tclassName,\n\tshowLegend = false,\n\tvalueFormatter,\n}: DonutChartProps) {\n\tconst legendItems = data.map((entry, index) => {\n\t\tconst item = series?.find((candidate) => candidate.key === entry.name);\n\t\treturn {\n\t\t\tkey: `${entry.name}-${index}`,\n\t\t\tlabel: item?.label ?? entry.name,\n\t\t\tcolor: seriesColor(item, index),\n\t\t};\n\t});\n\treturn (\n\t\t<ChartShell\n\t\t\tariaLabel={ariaLabel}\n\t\t\tclassName={className}\n\t\t\tsize=\"h-36 w-36\"\n\t\t\tlegend={showLegend ? <ChartLegend items={legendItems} shape=\"bar\" /> : undefined}\n\t\t>\n\t\t\t<PieChart>\n\t\t\t\t<Pie\n\t\t\t\t\tdata={data}\n\t\t\t\t\tdataKey=\"value\"\n\t\t\t\t\tnameKey=\"name\"\n\t\t\t\t\tinnerRadius={24}\n\t\t\t\t\touterRadius={48}\n\t\t\t\t\tstroke=\"none\"\n\t\t\t\t\t{...ANIMATION_PROPS}\n\t\t\t\t>\n\t\t\t\t\t{data.map((entry, index) => {\n\t\t\t\t\t\tconst item = series?.find((candidate) => candidate.key === entry.name);\n\t\t\t\t\t\treturn <Cell key={`${entry.name}-${index}`} fill={seriesColor(item, index)} />;\n\t\t\t\t\t})}\n\t\t\t\t</Pie>\n\t\t\t\t<Tooltip {...chartTooltipProps({ formatter: valueFormatter, cursor: false })} />\n\t\t\t</PieChart>\n\t\t</ChartShell>\n\t);\n}\n"],"mappings":";;;;;;;AAeA,SAAgB,EAAW,EAC1B,SACA,WACA,eAAY,eACZ,cACA,gBAAa,IACb,qBACmB;CACnB,IAAM,IAAc,EAAK,KAAK,GAAO,MAAU;EAC9C,IAAM,IAAO,GAAQ,MAAM,MAAc,EAAU,QAAQ,EAAM,IAAI;EACrE,OAAO;GACN,KAAK,GAAG,EAAM,KAAK,GAAG;GACtB,OAAO,GAAM,SAAS,EAAM;GAC5B,OAAO,EAAY,GAAM,CAAK;EAC/B;CACD,CAAC;CACD,OACC,kBAAC,GAAD;EACY;EACA;EACX,MAAK;EACL,QAAQ,IAAa,kBAAC,GAAD;GAAa,OAAO;GAAa,OAAM;EAAO,CAAA,IAAI,KAAA;EAEvE,UAAA,kBAAC,GAAD,EAAA,UAAA,CACC,kBAAC,GAAD;GACO;GACN,SAAQ;GACR,SAAQ;GACR,aAAa;GACb,aAAa;GACb,QAAO;GACP,GAAI;GAEH,UAAA,EAAK,KAAK,GAAO,MAAU;IAC3B,IAAM,IAAO,GAAQ,MAAM,MAAc,EAAU,QAAQ,EAAM,IAAI;IACrE,OAAO,kBAAC,GAAD,EAAqC,MAAM,EAAY,GAAM,CAAK,EAAI,GAA3D,GAAG,EAAM,KAAK,GAAG,GAA0C;GAC9E,CAAC;EACG,CAAA,GACL,kBAAC,GAAD,EAAS,GAAI,EAAkB;GAAE,WAAW;GAAgB,QAAQ;EAAM,CAAC,EAAI,CAAA,CACtE,EAAA,CAAA;CACC,CAAA;AAEd"}
1
+ {"version":3,"file":"donut.js","names":[],"sources":["../../src/charts/donut.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Cell, Pie, PieChart, Tooltip } from \"recharts\";\nimport { ANIMATION_PROPS, chartTooltipProps, seriesColor } from \"./config\";\nimport { ChartShell } from \"./frame\";\nimport { ChartLegend } from \"./legend\";\nimport type { ChartSeriesDescriptor, NamedValue } from \"./series\";\n\nexport type DonutChartProps = {\n\tdata: NamedValue[];\n\tseries?: ChartSeriesDescriptor[];\n\tariaLabel?: string;\n\tclassName?: string;\n\tshowLegend?: boolean;\n\tvalueFormatter?: (value: number) => string;\n\t/**\n\t * Textual summary describing key insights, highs, lows, and keyboard exploration instructions.\n\t * Associated with the chart via useId and aria-describedby.\n\t */\n\tsummary?: ReactNode;\n\t/**\n\t * Accessible tabular or structured data alternative rendered outside the plot area.\n\t */\n\tdataAlternative?: ReactNode;\n\t/**\n\t * Whether the interactive accessibility layer is enabled on the underlying Recharts graphic.\n\t * Enables keyboard exploration with Tab and arrow keys where supported by the underlying chart type.\n\t * Non-interactive compact or decorative charts without tooltip navigation should provide summary or dataAlternative.\n\t * @default true\n\t */\n\taccessibilityLayer?: boolean;\n};\n\nexport function DonutChart({\n\tdata,\n\tseries,\n\tariaLabel = \"Donut chart\",\n\tclassName,\n\tshowLegend = false,\n\tvalueFormatter,\n\tsummary,\n\tdataAlternative,\n\taccessibilityLayer,\n}: DonutChartProps) {\n\tconst legendItems = data.map((entry, index) => {\n\t\tconst item = series?.find((candidate) => candidate.key === entry.name);\n\t\treturn {\n\t\t\tkey: `${entry.name}-${index}`,\n\t\t\tlabel: item?.label ?? entry.name,\n\t\t\tcolor: seriesColor(item, index),\n\t\t};\n\t});\n\treturn (\n\t\t<ChartShell\n\t\t\tariaLabel={ariaLabel}\n\t\t\tclassName={className}\n\t\t\tsize=\"h-36 w-36\"\n\t\t\tlegend={showLegend ? <ChartLegend items={legendItems} shape=\"bar\" /> : undefined}\n\t\t\tsummary={summary}\n\t\t\tdataAlternative={dataAlternative}\n\t\t\taccessibilityLayer={accessibilityLayer}\n\t\t>\n\t\t\t<PieChart>\n\t\t\t\t<Pie\n\t\t\t\t\tdata={data}\n\t\t\t\t\tdataKey=\"value\"\n\t\t\t\t\tnameKey=\"name\"\n\t\t\t\t\tinnerRadius={24}\n\t\t\t\t\touterRadius={48}\n\t\t\t\t\tstroke=\"none\"\n\t\t\t\t\t{...ANIMATION_PROPS}\n\t\t\t\t>\n\t\t\t\t\t{data.map((entry, index) => {\n\t\t\t\t\t\tconst item = series?.find((candidate) => candidate.key === entry.name);\n\t\t\t\t\t\treturn <Cell key={`${entry.name}-${index}`} fill={seriesColor(item, index)} />;\n\t\t\t\t\t})}\n\t\t\t\t</Pie>\n\t\t\t\t<Tooltip {...chartTooltipProps({ formatter: valueFormatter, cursor: false })} />\n\t\t\t</PieChart>\n\t\t</ChartShell>\n\t);\n}\n"],"mappings":";;;;;;;AAgCA,SAAgB,EAAW,EAC1B,SACA,WACA,eAAY,eACZ,cACA,gBAAa,IACb,mBACA,YACA,oBACA,yBACmB;CACnB,IAAM,IAAc,EAAK,KAAK,GAAO,MAAU;EAC9C,IAAM,IAAO,GAAQ,MAAM,MAAc,EAAU,QAAQ,EAAM,IAAI;EACrE,OAAO;GACN,KAAK,GAAG,EAAM,KAAK,GAAG;GACtB,OAAO,GAAM,SAAS,EAAM;GAC5B,OAAO,EAAY,GAAM,CAAK;EAC/B;CACD,CAAC;CACD,OACC,kBAAC,GAAD;EACY;EACA;EACX,MAAK;EACL,QAAQ,IAAa,kBAAC,GAAD;GAAa,OAAO;GAAa,OAAM;EAAO,CAAA,IAAI,KAAA;EAC9D;EACQ;EACG;EAEpB,UAAA,kBAAC,GAAD,EAAA,UAAA,CACC,kBAAC,GAAD;GACO;GACN,SAAQ;GACR,SAAQ;GACR,aAAa;GACb,aAAa;GACb,QAAO;GACP,GAAI;GAEH,UAAA,EAAK,KAAK,GAAO,MAAU;IAC3B,IAAM,IAAO,GAAQ,MAAM,MAAc,EAAU,QAAQ,EAAM,IAAI;IACrE,OAAO,kBAAC,GAAD,EAAqC,MAAM,EAAY,GAAM,CAAK,EAAI,GAA3D,GAAG,EAAM,KAAK,GAAG,GAA0C;GAC9E,CAAC;EACG,CAAA,GACL,kBAAC,GAAD,EAAS,GAAI,EAAkB;GAAE,WAAW;GAAgB,QAAQ;EAAM,CAAC,EAAI,CAAA,CACtE,EAAA,CAAA;CACC,CAAA;AAEd"}
@@ -1,13 +1,50 @@
1
1
  import { type ReactElement, type ReactNode } from "react";
2
2
  export type ChartFrameProps = {
3
+ /**
4
+ * Accessible label describing the purpose or dataset of the chart.
5
+ */
3
6
  ariaLabel: string;
7
+ /**
8
+ * Additional CSS class names for styling the chart container.
9
+ */
4
10
  className?: string;
11
+ /**
12
+ * Single child Recharts element to render inside the responsive container.
13
+ * Explicit child accessibilityLayer prop takes precedence over wrapper prop, which defaults to true.
14
+ */
5
15
  children: ReactElement<{
6
16
  accessibilityLayer?: boolean;
17
+ "aria-label"?: string;
18
+ "aria-describedby"?: string;
7
19
  }>;
20
+ /**
21
+ * Tailwind size classes for the chart container.
22
+ * @default "h-36 w-56"
23
+ */
8
24
  size?: string;
25
+ /**
26
+ * Textual summary describing key insights, highs, lows, and keyboard exploration instructions.
27
+ * Associated with the chart via useId and aria-describedby.
28
+ */
29
+ summary?: ReactNode;
30
+ /**
31
+ * Accessible tabular or structured data alternative rendered outside the plot area.
32
+ */
33
+ dataAlternative?: ReactNode;
34
+ /**
35
+ * Whether the interactive accessibility layer is enabled on the underlying Recharts graphic.
36
+ * Enables keyboard exploration with Tab and arrow keys where supported by the underlying chart type.
37
+ * Non-interactive compact or decorative charts without tooltip navigation should provide summary or dataAlternative.
38
+ * @default true
39
+ */
40
+ accessibilityLayer?: boolean;
9
41
  };
10
- export declare function ChartFrame({ ariaLabel, className, children, size, }: ChartFrameProps): import("react").JSX.Element;
11
- export declare function ChartShell({ ariaLabel, className, children, size, legend, }: ChartFrameProps & {
42
+ export type ChartShellProps = ChartFrameProps & {
43
+ /**
44
+ * Optional legend node rendered alongside the chart plot.
45
+ */
12
46
  legend?: ReactNode;
13
- }): import("react").JSX.Element;
47
+ };
48
+ export type ChartAccessibilityProps = Pick<ChartFrameProps, "summary" | "dataAlternative" | "accessibilityLayer">;
49
+ export declare function ChartFrame(props: ChartFrameProps): import("react").JSX.Element;
50
+ export declare function ChartShell(props: ChartShellProps): import("react").JSX.Element;
@@ -1,45 +1,72 @@
1
1
  "use client";
2
2
  import { cn as e } from "../utils/cn.js";
3
3
  import { RESPONSIVE_CONTAINER_PROPS as t } from "./config.js";
4
- import { cloneElement as n } from "react";
5
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
6
- import { ResponsiveContainer as a } from "recharts";
4
+ import { cloneElement as n, useId as r } from "react";
5
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
+ import { ResponsiveContainer as o } from "recharts";
7
7
  //#region src/charts/frame.tsx
8
- function o({ ariaLabel: i, className: o, children: s, size: c = "h-36 w-56" }) {
9
- return /* @__PURE__ */ r("div", {
10
- role: "img",
11
- "aria-label": i,
12
- className: e(c, "min-h-0 min-w-0 basalt-chart outline-none [&_.recharts-layer]:outline-none [&_.recharts-rectangle]:outline-none [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none", o),
13
- children: /* @__PURE__ */ r(a, {
14
- ...t,
15
- children: n(s, { accessibilityLayer: !1 })
16
- })
17
- });
8
+ function s(e) {
9
+ return e != null && e !== !1;
18
10
  }
19
- function s({ ariaLabel: t, className: n, children: a, size: s, legend: c }) {
20
- return c ? /* @__PURE__ */ i("div", {
11
+ function c({ ariaLabel: c, className: l, children: u, size: d = "h-36 w-56", legend: f, summary: p, dataAlternative: m, accessibilityLayer: h = !0 }) {
12
+ let g = r(), _ = s(p), v = s(m), y = u?.props ?? {}, b = y.accessibilityLayer, x = n(u, {
13
+ accessibilityLayer: b === void 0 ? h : b,
14
+ "aria-label": y["aria-label"] ?? c,
15
+ "aria-describedby": y["aria-describedby"] ?? (_ ? g : void 0)
16
+ }), S;
17
+ return S = s(f) ? /* @__PURE__ */ a("div", {
21
18
  "data-testid": "chart-shell",
22
- className: e(s ?? "h-36 w-56", n),
19
+ className: e(d, l),
23
20
  style: {
24
21
  display: "flex",
25
22
  flexDirection: "column",
26
23
  minHeight: 0,
27
24
  minWidth: 0
28
25
  },
29
- children: [/* @__PURE__ */ r(o, {
30
- ariaLabel: t,
31
- className: "min-h-0 w-full flex-1",
32
- size: "",
33
- children: a
34
- }), c]
35
- }) : /* @__PURE__ */ r(o, {
36
- ariaLabel: t,
37
- className: n,
38
- size: s,
39
- children: a
26
+ children: [/* @__PURE__ */ i("div", {
27
+ className: "min-h-0 w-full flex-1 basalt-chart [&_.recharts-surface:focus-visible]:outline-2 [&_.recharts-surface:focus-visible]:outline-offset-2 [&_.recharts-surface:focus-visible]:outline-basalt-ring",
28
+ children: /* @__PURE__ */ i(o, {
29
+ ...t,
30
+ children: x
31
+ })
32
+ }), f]
33
+ }) : /* @__PURE__ */ i("div", {
34
+ className: e(d, "min-h-0 min-w-0 basalt-chart [&_.recharts-surface:focus-visible]:outline-2 [&_.recharts-surface:focus-visible]:outline-offset-2 [&_.recharts-surface:focus-visible]:outline-basalt-ring", l),
35
+ children: /* @__PURE__ */ i(o, {
36
+ ...t,
37
+ children: x
38
+ })
39
+ }), !_ && !v ? /* @__PURE__ */ i("figure", {
40
+ role: "group",
41
+ "aria-label": c,
42
+ className: "contents m-0 p-0",
43
+ children: S
44
+ }) : /* @__PURE__ */ a("figure", {
45
+ role: "group",
46
+ "aria-label": c,
47
+ "aria-describedby": _ ? g : void 0,
48
+ className: "m-0 flex flex-col gap-2 p-0 min-h-0 min-w-0",
49
+ children: [
50
+ _ ? /* @__PURE__ */ i("div", {
51
+ id: g,
52
+ className: "text-xs text-basalt-muted-foreground",
53
+ children: p
54
+ }) : null,
55
+ S,
56
+ v ? /* @__PURE__ */ i("div", {
57
+ className: "text-xs text-basalt-muted-foreground",
58
+ children: m
59
+ }) : null
60
+ ]
40
61
  });
41
62
  }
63
+ function l(e) {
64
+ return /* @__PURE__ */ i(c, { ...e });
65
+ }
66
+ function u(e) {
67
+ return /* @__PURE__ */ i(c, { ...e });
68
+ }
42
69
  //#endregion
43
- export { o as ChartFrame, s as ChartShell };
70
+ export { l as ChartFrame, u as ChartShell };
44
71
 
45
72
  //# sourceMappingURL=frame.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"frame.js","names":[],"sources":["../../src/charts/frame.tsx"],"sourcesContent":["import { cloneElement, type ReactElement, type ReactNode } from \"react\";\nimport { ResponsiveContainer } from \"recharts\";\nimport { cn } from \"../utils/cn\";\nimport { RESPONSIVE_CONTAINER_PROPS } from \"./config\";\n\nexport type ChartFrameProps = {\n\tariaLabel: string;\n\tclassName?: string;\n\tchildren: ReactElement<{ accessibilityLayer?: boolean }>;\n\tsize?: string;\n};\n\nexport function ChartFrame({\n\tariaLabel,\n\tclassName,\n\tchildren,\n\tsize = \"h-36 w-56\",\n}: ChartFrameProps) {\n\treturn (\n\t\t<div\n\t\t\trole=\"img\"\n\t\t\taria-label={ariaLabel}\n\t\t\tclassName={cn(\n\t\t\t\tsize,\n\t\t\t\t\"min-h-0 min-w-0 basalt-chart outline-none [&_.recharts-layer]:outline-none [&_.recharts-rectangle]:outline-none [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t>\n\t\t\t<ResponsiveContainer {...RESPONSIVE_CONTAINER_PROPS}>\n\t\t\t\t{cloneElement(children, { accessibilityLayer: false })}\n\t\t\t</ResponsiveContainer>\n\t\t</div>\n\t);\n}\n\nexport function ChartShell({\n\tariaLabel,\n\tclassName,\n\tchildren,\n\tsize,\n\tlegend,\n}: ChartFrameProps & { legend?: ReactNode }) {\n\tif (!legend) {\n\t\treturn (\n\t\t\t<ChartFrame ariaLabel={ariaLabel} className={className} size={size}>\n\t\t\t\t{children}\n\t\t\t</ChartFrame>\n\t\t);\n\t}\n\treturn (\n\t\t<div\n\t\t\tdata-testid=\"chart-shell\"\n\t\t\tclassName={cn(size ?? \"h-36 w-56\", className)}\n\t\t\tstyle={{ display: \"flex\", flexDirection: \"column\", minHeight: 0, minWidth: 0 }}\n\t\t>\n\t\t\t<ChartFrame ariaLabel={ariaLabel} className=\"min-h-0 w-full flex-1\" size=\"\">\n\t\t\t\t{children}\n\t\t\t</ChartFrame>\n\t\t\t{legend}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAYA,SAAgB,EAAW,EAC1B,cACA,cACA,aACA,UAAO,eACY;CACnB,OACC,kBAAC,OAAD;EACC,MAAK;EACL,cAAY;EACZ,WAAW,EACV,GACA,2NACA,CACD;EAEA,UAAA,kBAAC,GAAD;GAAqB,GAAI;GACvB,UAAA,EAAa,GAAU,EAAE,oBAAoB,GAAM,CAAC;EACjC,CAAA;CACjB,CAAA;AAEP;AAEA,SAAgB,EAAW,EAC1B,cACA,cACA,aACA,SACA,aAC4C;CAQ5C,OAPK,IAQJ,kBAAC,OAAD;EACC,eAAY;EACZ,WAAW,EAAG,KAAQ,aAAa,CAAS;EAC5C,OAAO;GAAE,SAAS;GAAQ,eAAe;GAAU,WAAW;GAAG,UAAU;EAAE;EAH9E,UAAA,CAKC,kBAAC,GAAD;GAAuB;GAAW,WAAU;GAAwB,MAAK;GACvE;EACU,CAAA,GACX,CACG;MAfJ,kBAAC,GAAD;EAAuB;EAAsB;EAAiB;EAC5D;CACU,CAAA;AAef"}
1
+ {"version":3,"file":"frame.js","names":[],"sources":["../../src/charts/frame.tsx"],"sourcesContent":["import { cloneElement, type ReactElement, type ReactNode, useId } from \"react\";\nimport { ResponsiveContainer } from \"recharts\";\nimport { cn } from \"../utils/cn\";\nimport { RESPONSIVE_CONTAINER_PROPS } from \"./config\";\n\nexport type ChartFrameProps = {\n\t/**\n\t * Accessible label describing the purpose or dataset of the chart.\n\t */\n\tariaLabel: string;\n\t/**\n\t * Additional CSS class names for styling the chart container.\n\t */\n\tclassName?: string;\n\t/**\n\t * Single child Recharts element to render inside the responsive container.\n\t * Explicit child accessibilityLayer prop takes precedence over wrapper prop, which defaults to true.\n\t */\n\tchildren: ReactElement<{\n\t\taccessibilityLayer?: boolean;\n\t\t\"aria-label\"?: string;\n\t\t\"aria-describedby\"?: string;\n\t}>;\n\t/**\n\t * Tailwind size classes for the chart container.\n\t * @default \"h-36 w-56\"\n\t */\n\tsize?: string;\n\t/**\n\t * Textual summary describing key insights, highs, lows, and keyboard exploration instructions.\n\t * Associated with the chart via useId and aria-describedby.\n\t */\n\tsummary?: ReactNode;\n\t/**\n\t * Accessible tabular or structured data alternative rendered outside the plot area.\n\t */\n\tdataAlternative?: ReactNode;\n\t/**\n\t * Whether the interactive accessibility layer is enabled on the underlying Recharts graphic.\n\t * Enables keyboard exploration with Tab and arrow keys where supported by the underlying chart type.\n\t * Non-interactive compact or decorative charts without tooltip navigation should provide summary or dataAlternative.\n\t * @default true\n\t */\n\taccessibilityLayer?: boolean;\n};\n\nexport type ChartShellProps = ChartFrameProps & {\n\t/**\n\t * Optional legend node rendered alongside the chart plot.\n\t */\n\tlegend?: ReactNode;\n};\n\nexport type ChartAccessibilityProps = Pick<\n\tChartFrameProps,\n\t\"summary\" | \"dataAlternative\" | \"accessibilityLayer\"\n>;\n\nfunction hasSlotContent(slot: ReactNode | undefined): boolean {\n\treturn slot !== undefined && slot !== null && slot !== false;\n}\n\nfunction ChartContainer({\n\tariaLabel,\n\tclassName,\n\tchildren,\n\tsize = \"h-36 w-56\",\n\tlegend,\n\tsummary,\n\tdataAlternative,\n\taccessibilityLayer = true,\n}: ChartShellProps) {\n\tconst summaryId = useId();\n\tconst hasSummary = hasSlotContent(summary);\n\tconst hasAlternative = hasSlotContent(dataAlternative);\n\n\tconst childProps = (children?.props ?? {}) as {\n\t\taccessibilityLayer?: boolean;\n\t\t\"aria-label\"?: string;\n\t\t\"aria-describedby\"?: string;\n\t};\n\tconst childLayer = childProps.accessibilityLayer;\n\tconst resolvedLayer = childLayer !== undefined ? childLayer : accessibilityLayer;\n\n\tconst clonedChild = cloneElement(children, {\n\t\taccessibilityLayer: resolvedLayer,\n\t\t\"aria-label\": childProps[\"aria-label\"] ?? ariaLabel,\n\t\t\"aria-describedby\": childProps[\"aria-describedby\"] ?? (hasSummary ? summaryId : undefined),\n\t});\n\n\tlet plotContainer: ReactNode;\n\tif (hasSlotContent(legend)) {\n\t\tplotContainer = (\n\t\t\t<div\n\t\t\t\tdata-testid=\"chart-shell\"\n\t\t\t\tclassName={cn(size, className)}\n\t\t\t\tstyle={{ display: \"flex\", flexDirection: \"column\", minHeight: 0, minWidth: 0 }}\n\t\t\t>\n\t\t\t\t<div className=\"min-h-0 w-full flex-1 basalt-chart [&_.recharts-surface:focus-visible]:outline-2 [&_.recharts-surface:focus-visible]:outline-offset-2 [&_.recharts-surface:focus-visible]:outline-basalt-ring\">\n\t\t\t\t\t<ResponsiveContainer {...RESPONSIVE_CONTAINER_PROPS}>{clonedChild}</ResponsiveContainer>\n\t\t\t\t</div>\n\t\t\t\t{legend}\n\t\t\t</div>\n\t\t);\n\t} else {\n\t\tplotContainer = (\n\t\t\t<div\n\t\t\t\tclassName={cn(\n\t\t\t\t\tsize,\n\t\t\t\t\t\"min-h-0 min-w-0 basalt-chart [&_.recharts-surface:focus-visible]:outline-2 [&_.recharts-surface:focus-visible]:outline-offset-2 [&_.recharts-surface:focus-visible]:outline-basalt-ring\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t<ResponsiveContainer {...RESPONSIVE_CONTAINER_PROPS}>{clonedChild}</ResponsiveContainer>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif (!hasSummary && !hasAlternative) {\n\t\treturn (\n\t\t\t<figure role=\"group\" aria-label={ariaLabel} className=\"contents m-0 p-0\">\n\t\t\t\t{plotContainer}\n\t\t\t</figure>\n\t\t);\n\t}\n\n\treturn (\n\t\t<figure\n\t\t\trole=\"group\"\n\t\t\taria-label={ariaLabel}\n\t\t\taria-describedby={hasSummary ? summaryId : undefined}\n\t\t\tclassName=\"m-0 flex flex-col gap-2 p-0 min-h-0 min-w-0\"\n\t\t>\n\t\t\t{hasSummary ? (\n\t\t\t\t<div id={summaryId} className=\"text-xs text-basalt-muted-foreground\">\n\t\t\t\t\t{summary}\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t\t{plotContainer}\n\t\t\t{hasAlternative ? (\n\t\t\t\t<div className=\"text-xs text-basalt-muted-foreground\">{dataAlternative}</div>\n\t\t\t) : null}\n\t\t</figure>\n\t);\n}\n\nexport function ChartFrame(props: ChartFrameProps) {\n\treturn <ChartContainer {...props} />;\n}\n\nexport function ChartShell(props: ChartShellProps) {\n\treturn <ChartContainer {...props} />;\n}\n"],"mappings":";;;;;;;AA0DA,SAAS,EAAe,GAAsC;CAC7D,OAAO,KAA+B,QAAQ,MAAS;AACxD;AAEA,SAAS,EAAe,EACvB,cACA,cACA,aACA,UAAO,aACP,WACA,YACA,oBACA,wBAAqB,MACF;CACnB,IAAM,IAAY,EAAM,GAClB,IAAa,EAAe,CAAO,GACnC,IAAiB,EAAe,CAAe,GAE/C,IAAc,GAAU,SAAS,CAAC,GAKlC,IAAa,EAAW,oBAGxB,IAAc,EAAa,GAAU;EAC1C,oBAHqB,MAAe,KAAA,IAAyB,IAAb;EAIhD,cAAc,EAAW,iBAAiB;EAC1C,oBAAoB,EAAW,wBAAwB,IAAa,IAAY,KAAA;CACjF,CAAC,GAEG;CAoCJ,OAnCA,AAcC,IAdG,EAAe,CAAM,IAEvB,kBAAC,OAAD;EACC,eAAY;EACZ,WAAW,EAAG,GAAM,CAAS;EAC7B,OAAO;GAAE,SAAS;GAAQ,eAAe;GAAU,WAAW;GAAG,UAAU;EAAE;EAH9E,UAAA,CAKC,kBAAC,OAAD;GAAK,WAAU;GACd,UAAA,kBAAC,GAAD;IAAqB,GAAI;IAA6B,UAAA;GAAiC,CAAA;EACnF,CAAA,GACJ,CACG;MAIL,kBAAC,OAAD;EACC,WAAW,EACV,GACA,2LACA,CACD;EAEA,UAAA,kBAAC,GAAD;GAAqB,GAAI;GAA6B,UAAA;EAAiC,CAAA;CACnF,CAAA,GAIH,CAAC,KAAc,CAAC,IAElB,kBAAC,UAAD;EAAQ,MAAK;EAAQ,cAAY;EAAW,WAAU;EACpD,UAAA;CACM,CAAA,IAKT,kBAAC,UAAD;EACC,MAAK;EACL,cAAY;EACZ,oBAAkB,IAAa,IAAY,KAAA;EAC3C,WAAU;EAJX,UAAA;GAME,IACA,kBAAC,OAAD;IAAK,IAAI;IAAW,WAAU;IAC5B,UAAA;GACG,CAAA,IACF;GACH;GACA,IACA,kBAAC,OAAD;IAAK,WAAU;IAAwC,UAAA;GAAqB,CAAA,IACzE;EACG;;AAEV;AAEA,SAAgB,EAAW,GAAwB;CAClD,OAAO,kBAAC,GAAD,EAAgB,GAAI,EAAQ,CAAA;AACpC;AAEA,SAAgB,EAAW,GAAwB;CAClD,OAAO,kBAAC,GAAD,EAAgB,GAAI,EAAQ,CAAA;AACpC"}
@@ -1,3 +1,4 @@
1
+ import type { ReactNode } from "react";
1
2
  import type { ChartSeriesDescriptor, NamedValue } from "./series.js";
2
3
  export type FunnelChartProps = {
3
4
  data: NamedValue[];
@@ -5,5 +6,21 @@ export type FunnelChartProps = {
5
6
  ariaLabel?: string;
6
7
  className?: string;
7
8
  valueFormatter?: (value: number) => string;
9
+ /**
10
+ * Textual summary describing key insights, highs, lows, and keyboard exploration instructions.
11
+ * Associated with the chart via useId and aria-describedby.
12
+ */
13
+ summary?: ReactNode;
14
+ /**
15
+ * Accessible tabular or structured data alternative rendered outside the plot area.
16
+ */
17
+ dataAlternative?: ReactNode;
18
+ /**
19
+ * Whether the interactive accessibility layer is enabled on the underlying Recharts graphic.
20
+ * Enables keyboard exploration with Tab and arrow keys where supported by the underlying chart type.
21
+ * Non-interactive compact or decorative charts without tooltip navigation should provide summary or dataAlternative.
22
+ * @default true
23
+ */
24
+ accessibilityLayer?: boolean;
8
25
  };
9
- export declare function FunnelChart({ data, series, ariaLabel, className, valueFormatter, }: FunnelChartProps): import("react").JSX.Element;
26
+ export declare function FunnelChart({ data, series, ariaLabel, className, valueFormatter, summary, dataAlternative, accessibilityLayer, }: FunnelChartProps): import("react").JSX.Element;
@@ -5,10 +5,13 @@ import { ChartFrame as a } from "./frame.js";
5
5
  import { jsx as o, jsxs as s } from "react/jsx-runtime";
6
6
  import { Funnel as c, FunnelChart as l, LabelList as u, Tooltip as d } from "recharts";
7
7
  //#region src/charts/funnel.tsx
8
- function f({ data: f, series: p, ariaLabel: m = "Funnel chart", className: h, valueFormatter: g }) {
8
+ function f({ data: f, series: p, ariaLabel: m = "Funnel chart", className: h, valueFormatter: g, summary: _, dataAlternative: v, accessibilityLayer: y }) {
9
9
  return /* @__PURE__ */ o(a, {
10
10
  ariaLabel: m,
11
11
  className: h,
12
+ summary: _,
13
+ dataAlternative: v,
14
+ accessibilityLayer: y,
12
15
  children: /* @__PURE__ */ s(l, { children: [/* @__PURE__ */ o(d, { ...r({
13
16
  formatter: g,
14
17
  cursor: !1
@@ -17,6 +20,7 @@ function f({ data: f, series: p, ariaLabel: m = "Funnel chart", className: h, va
17
20
  dataKey: "value",
18
21
  nameKey: "name",
19
22
  fill: i(p?.[0], 1),
23
+ stroke: "none",
20
24
  ...t,
21
25
  children: /* @__PURE__ */ o(u, {
22
26
  dataKey: "name",
@@ -1 +1 @@
1
- {"version":3,"file":"funnel.js","names":[],"sources":["../../src/charts/funnel.tsx"],"sourcesContent":["import { Funnel, LabelList, FunnelChart as RechartsFunnel, Tooltip } from \"recharts\";\nimport { ANIMATION_PROPS, chartFontSize, chartTooltipProps, seriesColor } from \"./config\";\nimport { ChartFrame } from \"./frame\";\nimport { chartAxis } from \"./palette\";\nimport type { ChartSeriesDescriptor, NamedValue } from \"./series\";\n\nexport type FunnelChartProps = {\n\tdata: NamedValue[];\n\tseries?: ChartSeriesDescriptor[];\n\tariaLabel?: string;\n\tclassName?: string;\n\tvalueFormatter?: (value: number) => string;\n};\n\nexport function FunnelChart({\n\tdata,\n\tseries,\n\tariaLabel = \"Funnel chart\",\n\tclassName,\n\tvalueFormatter,\n}: FunnelChartProps) {\n\treturn (\n\t\t<ChartFrame ariaLabel={ariaLabel} className={className}>\n\t\t\t<RechartsFunnel>\n\t\t\t\t<Tooltip {...chartTooltipProps({ formatter: valueFormatter, cursor: false })} />\n\t\t\t\t<Funnel\n\t\t\t\t\tdata={data}\n\t\t\t\t\tdataKey=\"value\"\n\t\t\t\t\tnameKey=\"name\"\n\t\t\t\t\tfill={seriesColor(series?.[0], 1)}\n\t\t\t\t\t{...ANIMATION_PROPS}\n\t\t\t\t>\n\t\t\t\t\t<LabelList\n\t\t\t\t\t\tdataKey=\"name\"\n\t\t\t\t\t\tposition=\"right\"\n\t\t\t\t\t\tfill={chartAxis}\n\t\t\t\t\t\tstroke=\"none\"\n\t\t\t\t\t\tfontSize={chartFontSize(\"axis\")}\n\t\t\t\t\t/>\n\t\t\t\t</Funnel>\n\t\t\t</RechartsFunnel>\n\t\t</ChartFrame>\n\t);\n}\n"],"mappings":";;;;;;;AAcA,SAAgB,EAAY,EAC3B,SACA,WACA,eAAY,gBACZ,cACA,qBACoB;CACpB,OACC,kBAAC,GAAD;EAAuB;EAAsB;EAC5C,UAAA,kBAAC,GAAD,EAAA,UAAA,CACC,kBAAC,GAAD,EAAS,GAAI,EAAkB;GAAE,WAAW;GAAgB,QAAQ;EAAM,CAAC,EAAI,CAAA,GAC/E,kBAAC,GAAD;GACO;GACN,SAAQ;GACR,SAAQ;GACR,MAAM,EAAY,IAAS,IAAI,CAAC;GAChC,GAAI;GAEJ,UAAA,kBAAC,GAAD;IACC,SAAQ;IACR,UAAS;IACT,MAAM;IACN,QAAO;IACP,UAAU,EAAc,MAAM;GAC9B,CAAA;EACM,CAAA,CACO,EAAA,CAAA;CACL,CAAA;AAEd"}
1
+ {"version":3,"file":"funnel.js","names":[],"sources":["../../src/charts/funnel.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Funnel, LabelList, FunnelChart as RechartsFunnel, Tooltip } from \"recharts\";\nimport { ANIMATION_PROPS, chartFontSize, chartTooltipProps, seriesColor } from \"./config\";\nimport { ChartFrame } from \"./frame\";\nimport { chartAxis } from \"./palette\";\nimport type { ChartSeriesDescriptor, NamedValue } from \"./series\";\n\nexport type FunnelChartProps = {\n\tdata: NamedValue[];\n\tseries?: ChartSeriesDescriptor[];\n\tariaLabel?: string;\n\tclassName?: string;\n\tvalueFormatter?: (value: number) => string;\n\t/**\n\t * Textual summary describing key insights, highs, lows, and keyboard exploration instructions.\n\t * Associated with the chart via useId and aria-describedby.\n\t */\n\tsummary?: ReactNode;\n\t/**\n\t * Accessible tabular or structured data alternative rendered outside the plot area.\n\t */\n\tdataAlternative?: ReactNode;\n\t/**\n\t * Whether the interactive accessibility layer is enabled on the underlying Recharts graphic.\n\t * Enables keyboard exploration with Tab and arrow keys where supported by the underlying chart type.\n\t * Non-interactive compact or decorative charts without tooltip navigation should provide summary or dataAlternative.\n\t * @default true\n\t */\n\taccessibilityLayer?: boolean;\n};\n\nexport function FunnelChart({\n\tdata,\n\tseries,\n\tariaLabel = \"Funnel chart\",\n\tclassName,\n\tvalueFormatter,\n\tsummary,\n\tdataAlternative,\n\taccessibilityLayer,\n}: FunnelChartProps) {\n\treturn (\n\t\t<ChartFrame\n\t\t\tariaLabel={ariaLabel}\n\t\t\tclassName={className}\n\t\t\tsummary={summary}\n\t\t\tdataAlternative={dataAlternative}\n\t\t\taccessibilityLayer={accessibilityLayer}\n\t\t>\n\t\t\t<RechartsFunnel>\n\t\t\t\t<Tooltip {...chartTooltipProps({ formatter: valueFormatter, cursor: false })} />\n\t\t\t\t<Funnel\n\t\t\t\t\tdata={data}\n\t\t\t\t\tdataKey=\"value\"\n\t\t\t\t\tnameKey=\"name\"\n\t\t\t\t\tfill={seriesColor(series?.[0], 1)}\n\t\t\t\t\tstroke=\"none\"\n\t\t\t\t\t{...ANIMATION_PROPS}\n\t\t\t\t>\n\t\t\t\t\t<LabelList\n\t\t\t\t\t\tdataKey=\"name\"\n\t\t\t\t\t\tposition=\"right\"\n\t\t\t\t\t\tfill={chartAxis}\n\t\t\t\t\t\tstroke=\"none\"\n\t\t\t\t\t\tfontSize={chartFontSize(\"axis\")}\n\t\t\t\t\t/>\n\t\t\t\t</Funnel>\n\t\t\t</RechartsFunnel>\n\t\t</ChartFrame>\n\t);\n}\n"],"mappings":";;;;;;;AA+BA,SAAgB,EAAY,EAC3B,SACA,WACA,eAAY,gBACZ,cACA,mBACA,YACA,oBACA,yBACoB;CACpB,OACC,kBAAC,GAAD;EACY;EACA;EACF;EACQ;EACG;EAEpB,UAAA,kBAAC,GAAD,EAAA,UAAA,CACC,kBAAC,GAAD,EAAS,GAAI,EAAkB;GAAE,WAAW;GAAgB,QAAQ;EAAM,CAAC,EAAI,CAAA,GAC/E,kBAAC,GAAD;GACO;GACN,SAAQ;GACR,SAAQ;GACR,MAAM,EAAY,IAAS,IAAI,CAAC;GAChC,QAAO;GACP,GAAI;GAEJ,UAAA,kBAAC,GAAD;IACC,SAAQ;IACR,UAAS;IACT,MAAM;IACN,QAAO;IACP,UAAU,EAAc,MAAM;GAC9B,CAAA;EACM,CAAA,CACO,EAAA,CAAA;CACL,CAAA;AAEd"}