@misoto22/design 0.3.1 → 0.6.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 (266) hide show
  1. package/README.md +124 -0
  2. package/bin/misoto22-design.mjs +205 -0
  3. package/dist/agent/Accordion.md +41 -0
  4. package/dist/agent/Alert.md +42 -0
  5. package/dist/agent/AppShell.md +40 -0
  6. package/dist/agent/AreaChart.md +68 -0
  7. package/dist/agent/Article.md +41 -0
  8. package/dist/agent/Avatar.md +32 -0
  9. package/dist/agent/Badge.md +40 -0
  10. package/dist/agent/BarChart.md +65 -0
  11. package/dist/agent/BarList.md +40 -0
  12. package/dist/agent/BigNumber.md +45 -0
  13. package/dist/agent/BoxPlot.md +58 -0
  14. package/dist/agent/Breadcrumb.md +32 -0
  15. package/dist/agent/BulletChart.md +48 -0
  16. package/dist/agent/Button.md +56 -0
  17. package/dist/agent/Calendar.md +42 -0
  18. package/dist/agent/Card.md +49 -0
  19. package/dist/agent/Checkbox.md +35 -0
  20. package/dist/agent/Collapsible.md +46 -0
  21. package/dist/agent/Combobox.md +50 -0
  22. package/dist/agent/Command.md +93 -0
  23. package/dist/agent/ComposedChart.md +57 -0
  24. package/dist/agent/ContextMenu.md +59 -0
  25. package/dist/agent/DatePicker.md +75 -0
  26. package/dist/agent/Diagram.md +46 -0
  27. package/dist/agent/Dialog.md +52 -0
  28. package/dist/agent/DropdownMenu.md +70 -0
  29. package/dist/agent/EmptyState.md +37 -0
  30. package/dist/agent/ErrorState.md +41 -0
  31. package/dist/agent/Facet.md +82 -0
  32. package/dist/agent/Field.md +37 -0
  33. package/dist/agent/FigureBand.md +37 -0
  34. package/dist/agent/FloatingIconButton.md +38 -0
  35. package/dist/agent/FunnelChart.md +52 -0
  36. package/dist/agent/Heatmap.md +53 -0
  37. package/dist/agent/Histogram.md +63 -0
  38. package/dist/agent/Input.md +30 -0
  39. package/dist/agent/Kbd.md +29 -0
  40. package/dist/agent/LineChart.md +60 -0
  41. package/dist/agent/LinkArrow.md +29 -0
  42. package/dist/agent/NativeSelect.md +40 -0
  43. package/dist/agent/NavItem.md +35 -0
  44. package/dist/agent/Pagination.md +43 -0
  45. package/dist/agent/PieChart.md +55 -0
  46. package/dist/agent/Popover.md +57 -0
  47. package/dist/agent/Progress.md +33 -0
  48. package/dist/agent/RadarChart.md +54 -0
  49. package/dist/agent/RadialChart.md +57 -0
  50. package/dist/agent/RadioGroup.md +44 -0
  51. package/dist/agent/SankeyChart.md +61 -0
  52. package/dist/agent/ScatterChart.md +54 -0
  53. package/dist/agent/ScrollArea.md +40 -0
  54. package/dist/agent/SearchableMenu.md +46 -0
  55. package/dist/agent/Select.md +75 -0
  56. package/dist/agent/Separator.md +35 -0
  57. package/dist/agent/Sheet.md +57 -0
  58. package/dist/agent/Skeleton.md +73 -0
  59. package/dist/agent/Slider.md +39 -0
  60. package/dist/agent/Sparkline.md +45 -0
  61. package/dist/agent/Spinner.md +39 -0
  62. package/dist/agent/StatusDot.md +36 -0
  63. package/dist/agent/StatusPill.md +28 -0
  64. package/dist/agent/Steps.md +44 -0
  65. package/dist/agent/Switch.md +29 -0
  66. package/dist/agent/Table.md +85 -0
  67. package/dist/agent/Tabs.md +48 -0
  68. package/dist/agent/Tag.md +35 -0
  69. package/dist/agent/Textarea.md +26 -0
  70. package/dist/agent/Toast.md +26 -0
  71. package/dist/agent/ToggleGroup.md +44 -0
  72. package/dist/agent/Tooltip.md +51 -0
  73. package/dist/agent/TreemapChart.md +52 -0
  74. package/dist/agent/WaterfallChart.md +62 -0
  75. package/dist/agent/catalog.json +1791 -0
  76. package/dist/agent/index.md +131 -0
  77. package/dist/article.css +393 -0
  78. package/dist/charts/AreaChart/AreaChart.d.ts +191 -0
  79. package/dist/charts/AreaChart/AreaChart.js +480 -0
  80. package/dist/charts/AreaChart/AreaChart.js.map +1 -0
  81. package/dist/charts/BarChart/BarChart.d.ts +179 -0
  82. package/dist/charts/BarChart/BarChart.js +591 -0
  83. package/dist/charts/BarChart/BarChart.js.map +1 -0
  84. package/dist/charts/BarList/BarList.d.ts +57 -0
  85. package/dist/charts/BarList/BarList.js +71 -0
  86. package/dist/charts/BarList/BarList.js.map +1 -0
  87. package/dist/charts/BigNumber/BigNumber.d.ts +56 -0
  88. package/dist/charts/BigNumber/BigNumber.js +31 -0
  89. package/dist/charts/BigNumber/BigNumber.js.map +1 -0
  90. package/dist/charts/BoxPlot/BoxPlot.d.ts +177 -0
  91. package/dist/charts/BoxPlot/BoxPlot.js +495 -0
  92. package/dist/charts/BoxPlot/BoxPlot.js.map +1 -0
  93. package/dist/charts/BulletChart/BulletChart.d.ts +100 -0
  94. package/dist/charts/BulletChart/BulletChart.js +162 -0
  95. package/dist/charts/BulletChart/BulletChart.js.map +1 -0
  96. package/dist/charts/ComposedChart/ComposedChart.d.ts +171 -0
  97. package/dist/charts/ComposedChart/ComposedChart.js +667 -0
  98. package/dist/charts/ComposedChart/ComposedChart.js.map +1 -0
  99. package/dist/charts/Facet/Facet.d.ts +240 -0
  100. package/dist/charts/Facet/Facet.js +133 -0
  101. package/dist/charts/Facet/Facet.js.map +1 -0
  102. package/dist/charts/Facet/panels.d.ts +187 -0
  103. package/dist/charts/Facet/panels.js +203 -0
  104. package/dist/charts/Facet/panels.js.map +1 -0
  105. package/dist/charts/FunnelChart/FunnelChart.d.ts +101 -0
  106. package/dist/charts/FunnelChart/FunnelChart.js +147 -0
  107. package/dist/charts/FunnelChart/FunnelChart.js.map +1 -0
  108. package/dist/charts/Heatmap/Heatmap.d.ts +78 -0
  109. package/dist/charts/Heatmap/Heatmap.js +108 -0
  110. package/dist/charts/Heatmap/Heatmap.js.map +1 -0
  111. package/dist/charts/Histogram/Histogram.d.ts +165 -0
  112. package/dist/charts/Histogram/Histogram.js +350 -0
  113. package/dist/charts/Histogram/Histogram.js.map +1 -0
  114. package/dist/charts/LineChart/LineChart.d.ts +167 -0
  115. package/dist/charts/LineChart/LineChart.js +486 -0
  116. package/dist/charts/LineChart/LineChart.js.map +1 -0
  117. package/dist/charts/PieChart/PieChart.d.ts +128 -0
  118. package/dist/charts/PieChart/PieChart.js +309 -0
  119. package/dist/charts/PieChart/PieChart.js.map +1 -0
  120. package/dist/charts/RadarChart/RadarChart.d.ts +123 -0
  121. package/dist/charts/RadarChart/RadarChart.js +299 -0
  122. package/dist/charts/RadarChart/RadarChart.js.map +1 -0
  123. package/dist/charts/RadialChart/RadialChart.d.ts +124 -0
  124. package/dist/charts/RadialChart/RadialChart.js +257 -0
  125. package/dist/charts/RadialChart/RadialChart.js.map +1 -0
  126. package/dist/charts/SankeyChart/SankeyChart.d.ts +137 -0
  127. package/dist/charts/SankeyChart/SankeyChart.js +501 -0
  128. package/dist/charts/SankeyChart/SankeyChart.js.map +1 -0
  129. package/dist/charts/ScatterChart/ScatterChart.d.ts +128 -0
  130. package/dist/charts/ScatterChart/ScatterChart.js +269 -0
  131. package/dist/charts/ScatterChart/ScatterChart.js.map +1 -0
  132. package/dist/charts/Sparkline/Sparkline.d.ts +53 -0
  133. package/dist/charts/Sparkline/Sparkline.js +93 -0
  134. package/dist/charts/Sparkline/Sparkline.js.map +1 -0
  135. package/dist/charts/TreemapChart/TreemapChart.d.ts +93 -0
  136. package/dist/charts/TreemapChart/TreemapChart.js +118 -0
  137. package/dist/charts/TreemapChart/TreemapChart.js.map +1 -0
  138. package/dist/charts/WaterfallChart/WaterfallChart.d.ts +164 -0
  139. package/dist/charts/WaterfallChart/WaterfallChart.js +319 -0
  140. package/dist/charts/WaterfallChart/WaterfallChart.js.map +1 -0
  141. package/dist/charts/index.d.ts +41 -0
  142. package/dist/charts/index.js +128 -0
  143. package/dist/charts/index.js.map +1 -0
  144. package/dist/charts/lib/annotations.d.ts +103 -0
  145. package/dist/charts/lib/annotations.js +99 -0
  146. package/dist/charts/lib/annotations.js.map +1 -0
  147. package/dist/charts/lib/axis.d.ts +18 -0
  148. package/dist/charts/lib/axis.js +21 -0
  149. package/dist/charts/lib/axis.js.map +1 -0
  150. package/dist/charts/lib/background.d.ts +33 -0
  151. package/dist/charts/lib/background.js +173 -0
  152. package/dist/charts/lib/background.js.map +1 -0
  153. package/dist/charts/lib/brush.d.ts +94 -0
  154. package/dist/charts/lib/brush.js +535 -0
  155. package/dist/charts/lib/brush.js.map +1 -0
  156. package/dist/charts/lib/chart.d.ts +94 -0
  157. package/dist/charts/lib/chart.js +134 -0
  158. package/dist/charts/lib/chart.js.map +1 -0
  159. package/dist/charts/lib/dot.d.ts +29 -0
  160. package/dist/charts/lib/dot.js +78 -0
  161. package/dist/charts/lib/dot.js.map +1 -0
  162. package/dist/charts/lib/empty.d.ts +31 -0
  163. package/dist/charts/lib/empty.js +13 -0
  164. package/dist/charts/lib/empty.js.map +1 -0
  165. package/dist/charts/lib/export.d.ts +103 -0
  166. package/dist/charts/lib/export.js +204 -0
  167. package/dist/charts/lib/export.js.map +1 -0
  168. package/dist/charts/lib/figure.d.ts +61 -0
  169. package/dist/charts/lib/figure.js +59 -0
  170. package/dist/charts/lib/figure.js.map +1 -0
  171. package/dist/charts/lib/format.d.ts +46 -0
  172. package/dist/charts/lib/format.js +56 -0
  173. package/dist/charts/lib/format.js.map +1 -0
  174. package/dist/charts/lib/legend.d.ts +45 -0
  175. package/dist/charts/lib/legend.js +117 -0
  176. package/dist/charts/lib/legend.js.map +1 -0
  177. package/dist/charts/lib/loading.d.ts +48 -0
  178. package/dist/charts/lib/loading.js +105 -0
  179. package/dist/charts/lib/loading.js.map +1 -0
  180. package/dist/charts/lib/paint.d.ts +154 -0
  181. package/dist/charts/lib/paint.js +551 -0
  182. package/dist/charts/lib/paint.js.map +1 -0
  183. package/dist/charts/lib/sonify-control.d.ts +163 -0
  184. package/dist/charts/lib/sonify-control.js +172 -0
  185. package/dist/charts/lib/sonify-control.js.map +1 -0
  186. package/dist/charts/lib/sonify.d.ts +248 -0
  187. package/dist/charts/lib/sonify.js +262 -0
  188. package/dist/charts/lib/sonify.js.map +1 -0
  189. package/dist/charts/lib/toolbar.d.ts +143 -0
  190. package/dist/charts/lib/toolbar.js +156 -0
  191. package/dist/charts/lib/toolbar.js.map +1 -0
  192. package/dist/charts/lib/tooltip.d.ts +59 -0
  193. package/dist/charts/lib/tooltip.js +135 -0
  194. package/dist/charts/lib/tooltip.js.map +1 -0
  195. package/dist/charts/lib/values.d.ts +56 -0
  196. package/dist/charts/lib/values.js +71 -0
  197. package/dist/charts/lib/values.js.map +1 -0
  198. package/dist/charts/lib/zoom.d.ts +139 -0
  199. package/dist/charts/lib/zoom.js +314 -0
  200. package/dist/charts/lib/zoom.js.map +1 -0
  201. package/dist/components/AppShell/AppShell.d.ts +15 -1
  202. package/dist/components/AppShell/AppShell.js +8 -4
  203. package/dist/components/AppShell/AppShell.js.map +1 -1
  204. package/dist/components/Article/Article.d.ts +51 -0
  205. package/dist/components/Article/Article.js +21 -0
  206. package/dist/components/Article/Article.js.map +1 -0
  207. package/dist/components/Button/Button.js +2 -2
  208. package/dist/components/Button/Button.js.map +1 -1
  209. package/dist/components/Calendar/Calendar.d.ts +1 -1
  210. package/dist/components/Calendar/Calendar.js +259 -24
  211. package/dist/components/Calendar/Calendar.js.map +1 -1
  212. package/dist/components/Checkbox/Checkbox.js +1 -1
  213. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  214. package/dist/components/Collapsible/Collapsible.d.ts +15 -1
  215. package/dist/components/Collapsible/Collapsible.js +18 -0
  216. package/dist/components/Collapsible/Collapsible.js.map +1 -1
  217. package/dist/components/Combobox/Combobox.js +1 -1
  218. package/dist/components/Combobox/Combobox.js.map +1 -1
  219. package/dist/components/Command/Command.js +7 -7
  220. package/dist/components/Command/Command.js.map +1 -1
  221. package/dist/components/ContextMenu/ContextMenu.js +2 -2
  222. package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
  223. package/dist/components/Diagram/Diagram.d.ts +81 -0
  224. package/dist/components/Diagram/Diagram.js +139 -0
  225. package/dist/components/Diagram/Diagram.js.map +1 -0
  226. package/dist/components/Dialog/Dialog.js +1 -1
  227. package/dist/components/Dialog/Dialog.js.map +1 -1
  228. package/dist/components/DropdownMenu/DropdownMenu.js +2 -2
  229. package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
  230. package/dist/components/FigureBand/FigureBand.js +41 -30
  231. package/dist/components/FigureBand/FigureBand.js.map +1 -1
  232. package/dist/components/Popover/Popover.js +1 -1
  233. package/dist/components/Popover/Popover.js.map +1 -1
  234. package/dist/components/Select/Select.js +2 -2
  235. package/dist/components/Select/Select.js.map +1 -1
  236. package/dist/components/Sheet/Sheet.js +1 -1
  237. package/dist/components/Sheet/Sheet.js.map +1 -1
  238. package/dist/components/Slider/Slider.js +1 -1
  239. package/dist/components/Slider/Slider.js.map +1 -1
  240. package/dist/components/Steps/Steps.d.ts +65 -0
  241. package/dist/components/Steps/Steps.js +55 -0
  242. package/dist/components/Steps/Steps.js.map +1 -0
  243. package/dist/components/Switch/Switch.js +1 -1
  244. package/dist/components/Switch/Switch.js.map +1 -1
  245. package/dist/components/Tooltip/Tooltip.js +1 -1
  246. package/dist/components/Tooltip/Tooltip.js.map +1 -1
  247. package/dist/index.d.ts +4 -1
  248. package/dist/index.js +3 -0
  249. package/dist/index.js.map +1 -1
  250. package/dist/lib/useSelectionIndicator.js +14 -10
  251. package/dist/lib/useSelectionIndicator.js.map +1 -1
  252. package/dist/semantic.css +19 -0
  253. package/dist/styles.css +1 -1
  254. package/dist/themes.css +103 -7
  255. package/dist/tokens.css +193 -10
  256. package/dist/tokens.d.ts +25 -0
  257. package/dist/tokens.js +154 -8
  258. package/dist/tokens.json +154 -8
  259. package/package.json +45 -20
  260. package/skills/misoto22-design/SKILL.md +171 -0
  261. package/skills/misoto22-design/evals/claims.json +95 -0
  262. package/skills/misoto22-design/rules/a11y.md +115 -0
  263. package/skills/misoto22-design/rules/composition.md +108 -0
  264. package/skills/misoto22-design/rules/forms.md +128 -0
  265. package/skills/misoto22-design/rules/naming.md +155 -0
  266. package/skills/misoto22-design/rules/tokens.md +131 -0
@@ -0,0 +1,191 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ComponentProps, FC } from 'react';
3
+ import { AreaChart as AreaChart$1, Area, XAxis, YAxis, CartesianGrid } from 'recharts';
4
+ import { ChartConfig } from '../lib/chart.js';
5
+ import { ChartEmptyProps } from '../lib/empty.js';
6
+ import { ValuesProps } from '../lib/values.js';
7
+ import { SonifyProps } from '../lib/sonify-control.js';
8
+ import { ChartBackgroundVariant } from '../lib/background.js';
9
+ import { BrushProps } from '../lib/brush.js';
10
+ import { ToolbarProps } from '../lib/toolbar.js';
11
+ import { ChartRevealType } from '../lib/paint.js';
12
+ import { ChartDotVariant } from '../lib/dot.js';
13
+ import { ChartLegendVariant, ChartLegendAlign } from '../lib/legend.js';
14
+ import { ChartTooltipVariant, ChartTooltipRoundness } from '../lib/tooltip.js';
15
+ import { ReferenceLine, ReferenceBand, Annotation } from '../lib/annotations.js';
16
+ import '../lib/sonify.js';
17
+ import '../lib/zoom.js';
18
+ import '../lib/figure.js';
19
+ import 'recharts/types/component/DefaultTooltipContent';
20
+
21
+ /**
22
+ * The axis props, with `label` narrowed to a string.
23
+ *
24
+ * Recharts' own `label` accepts a render function and a config object, neither
25
+ * of which a call site should be reaching for to name an axis — and both of
26
+ * which would let a consumer opt out of the system's own axis type styling
27
+ * without noticing.
28
+ */
29
+ type ChartXAxisProps = Omit<ComponentProps<typeof XAxis>, 'label'> & {
30
+ /** What this axis measures. Say the unit here or in the series label, once. */
31
+ label?: string;
32
+ };
33
+ type ChartYAxisProps = Omit<ComponentProps<typeof YAxis>, 'label'> & {
34
+ /** What this axis measures. Say the unit here or in the series label, once. */
35
+ label?: string;
36
+ };
37
+
38
+ /** How an area's curve is interpolated between points. */
39
+ type ChartCurveType = ComponentProps<typeof Area>['type'];
40
+ /**
41
+ * How an area meets the plot.
42
+ *
43
+ * In the monochrome default this is the PRIMARY way two series are told apart
44
+ * — the ramp is the second encoding — so a chart with more than one area
45
+ * should vary this before it varies anything else.
46
+ */
47
+ type AreaVariant = 'gradient' | 'gradient-reverse' | 'solid' | 'dotted' | 'lines' | 'hatched';
48
+ /** How the line on top of an area is drawn. */
49
+ type AreaStrokeVariant = 'solid' | 'dashed' | 'animated-dashed';
50
+ /** How several areas combine: side by side, stacked, or normalised to 100%. */
51
+ type AreaStackType = 'default' | 'stacked' | 'expanded';
52
+ /** Fails the build when a config names a series the rows do not have. */
53
+ type ValidateKeys<TData, TConfig> = {
54
+ [K in keyof TConfig]: K extends keyof TData ? ChartConfig[string] : never;
55
+ };
56
+ interface AreaChartProps<TData extends Record<string, unknown>, TConfig extends Record<string, ChartConfig[string]>> {
57
+ /** Series keys → their label and paint. Declaration order is ramp order. */
58
+ config: TConfig & ValidateKeys<TData, TConfig>;
59
+ /** The rows the chart draws. One entry per point, bar or category. */
60
+ data: TData[];
61
+ /**
62
+ * What the chart shows, in a sentence a reader could act on. Required, and
63
+ * announced to a screen reader even when it is not printed.
64
+ */
65
+ title: string;
66
+ /** Prints the title above the plot instead of hiding it from sight. */
67
+ showTitle?: boolean;
68
+ /** A line under the title — the unit, the window, the caveat. */
69
+ description?: ReactNode;
70
+ /**
71
+ * The composed parts — axes, grid, tooltip, legend, and the marks
72
+ * themselves.
73
+ */
74
+ children: ReactNode;
75
+ /** Merged onto the figure, last, so a call site can size or space it. */
76
+ className?: string;
77
+ /** Escape hatch onto the raw Recharts chart element. */
78
+ chartProps?: ComponentProps<typeof AreaChart$1>;
79
+ /** The curve every `<AreaChart.Area>` inherits. */
80
+ curveType?: ChartCurveType;
81
+ /** The intro wipe every `<AreaChart.Area>` inherits. */
82
+ animationType?: ChartRevealType;
83
+ /** How several marks combine: side by side, stacked, or normalised to 100%. */
84
+ stackType?: AreaStackType;
85
+ /** The series lit on first render. Selection dims every other series. */
86
+ defaultSelectedDataKey?: string | null;
87
+ /** Fires when the selection changes, and with null when it is cleared. */
88
+ onSelectionChange?: (selectedDataKey: string | null) => void;
89
+ /**
90
+ * Swaps the marks for an animated skeleton, keeping the measured height so
91
+ * the page does not jump when the data lands.
92
+ */
93
+ isLoading?: boolean;
94
+ /** How many points the skeleton draws. */
95
+ loadingPoints?: number;
96
+ /**
97
+ * The row field on the category axis. Needed by the brush and by the table
98
+ * view.
99
+ */
100
+ xDataKey?: keyof TData & string;
101
+ /**
102
+ * Drops the hidden table view. Only correct when the page prints the data
103
+ * itself.
104
+ */
105
+ hideDataTable?: boolean;
106
+ /**
107
+ * What the chart shows when it has nothing to draw.
108
+ *
109
+ * Rendered instead of the plot whenever `data` is empty and the chart is not
110
+ * loading — the state a real dashboard reaches within a week, and the one an
111
+ * empty pair of axes is indistinguishable from a failed load. `false` keeps
112
+ * the axes, for a chart whose emptiness is itself the reading.
113
+ */
114
+ empty?: ChartEmptyProps | false;
115
+ }
116
+ /**
117
+ * A filled series over a category axis — the shape for a magnitude that is
118
+ * continuous, where the area under the line means something.
119
+ *
120
+ * Composed rather than configured: axes, grid, tooltip, legend and the areas
121
+ * themselves are children, so a chart renders exactly the parts it asked for
122
+ * and nothing is switched on by a prop nobody can see.
123
+ *
124
+ * Reach for `<LineChart>` instead when the reader is comparing several series
125
+ * against each other rather than reading one total, and for `<BarChart>` when
126
+ * the categories are discrete.
127
+ *
128
+ * @example
129
+ * <AreaChart title="Visitors per month" config={config} data={data} xDataKey="month">
130
+ * <AreaChart.Grid />
131
+ * <AreaChart.XAxis dataKey="month" />
132
+ * <AreaChart.Tooltip />
133
+ * <AreaChart.Area dataKey="desktop" variant="gradient" />
134
+ * </AreaChart>
135
+ */
136
+ declare function AreaChart<TData extends Record<string, unknown>, TConfig extends Record<string, ChartConfig[string]>>({ config, data, title, showTitle, description, children, className, chartProps, curveType, animationType, stackType, defaultSelectedDataKey, onSelectionChange, isLoading, loadingPoints, xDataKey, hideDataTable, empty, }: AreaChartProps<TData, TConfig>): react.JSX.Element;
137
+ declare namespace AreaChart {
138
+ var Area: ({ dataKey, variant, strokeVariant, strokeWidth, curveType, animationType, connectNulls, isClickable, children, areaProps, }: AreaProps) => react.JSX.Element | null;
139
+ var Dot: FC<DotProps>;
140
+ var ActiveDot: FC<DotProps>;
141
+ var XAxis: ({ tickLine, axisLine, tickMargin, minTickGap, label, ...rest }: ChartXAxisProps) => react.JSX.Element | null;
142
+ var YAxis: ({ tickLine, axisLine, tickMargin, minTickGap, width, tickFormatter, label, ...rest }: ChartYAxisProps) => react.JSX.Element | null;
143
+ var Grid: ({ vertical, strokeDasharray, ...rest }: ComponentProps<typeof CartesianGrid>) => react.JSX.Element;
144
+ var Tooltip: ({ variant, roundness, defaultIndex, cursor }: ChartTooltipSlotProps) => react.JSX.Element | null;
145
+ var Legend: ({ variant, align, verticalAlign, isClickable, }: ChartLegendSlotProps) => react.JSX.Element;
146
+ var Background: ({ variant }: {
147
+ variant: ChartBackgroundVariant;
148
+ }) => react.JSX.Element | null;
149
+ var ReferenceLine: typeof ReferenceLine;
150
+ var ReferenceBand: typeof ReferenceBand;
151
+ var Annotation: typeof Annotation;
152
+ var Values: FC<ValuesProps>;
153
+ var Brush: FC<BrushProps>;
154
+ var Toolbar: FC<ToolbarProps>;
155
+ var Sonify: FC<SonifyProps>;
156
+ }
157
+ interface AreaProps {
158
+ /** The series to draw. Must exist on both the rows and the config. */
159
+ dataKey: string;
160
+ variant?: AreaVariant;
161
+ strokeVariant?: AreaStrokeVariant;
162
+ strokeWidth?: number;
163
+ curveType?: ChartCurveType;
164
+ animationType?: ChartRevealType;
165
+ connectNulls?: boolean;
166
+ /** Lets a click on this area select it, dimming the rest. */
167
+ isClickable?: boolean;
168
+ /** `<AreaChart.Dot>`, `<AreaChart.ActiveDot>` and `<AreaChart.Values>`. */
169
+ children?: ReactNode;
170
+ areaProps?: ComponentProps<typeof Area>;
171
+ }
172
+ interface DotProps {
173
+ variant?: ChartDotVariant;
174
+ }
175
+ interface ChartTooltipSlotProps {
176
+ variant?: ChartTooltipVariant;
177
+ roundness?: ChartTooltipRoundness;
178
+ /** Shows the tooltip at this row before anything is hovered. */
179
+ defaultIndex?: number;
180
+ /** The crosshair that follows the pointer along the axis. */
181
+ cursor?: boolean;
182
+ }
183
+ interface ChartLegendSlotProps {
184
+ variant?: ChartLegendVariant;
185
+ align?: ChartLegendAlign;
186
+ verticalAlign?: 'top' | 'middle' | 'bottom';
187
+ /** Makes each entry a button that selects its series. */
188
+ isClickable?: boolean;
189
+ }
190
+
191
+ export { AreaChart, type AreaChartProps, type AreaProps, type AreaStackType, type AreaStrokeVariant, type AreaVariant, type ChartCurveType, type ChartLegendSlotProps, type ChartTooltipSlotProps, type ChartXAxisProps, type ChartYAxisProps, type DotProps, AreaChart as default };
@@ -0,0 +1,480 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import {
4
+ Children,
5
+ createContext,
6
+ isValidElement,
7
+ useCallback,
8
+ useContext,
9
+ useId,
10
+ useMemo,
11
+ useState
12
+ } from "react";
13
+ import {
14
+ Area as RechartsArea,
15
+ AreaChart as RechartsAreaChart,
16
+ CartesianGrid,
17
+ XAxis as RechartsXAxis,
18
+ YAxis as RechartsYAxis
19
+ } from "recharts";
20
+ import { useReducedMotion } from "motion/react";
21
+ import { ChartContainer, percentTick } from "../lib/chart.js";
22
+ import { ChartFigure } from "../lib/figure.js";
23
+ import { ChartEmpty } from "../lib/empty.js";
24
+ import { axisLabel } from "../lib/axis.js";
25
+ import { defaultTick } from "../lib/format.js";
26
+ import { Annotation, ReferenceBand, ReferenceLine } from "../lib/annotations.js";
27
+ import { Values, findSlot, resolveValues } from "../lib/values.js";
28
+ import {
29
+ ChartSonifyButton,
30
+ Sonify,
31
+ useChartSonifySeries
32
+ } from "../lib/sonify-control.js";
33
+ import { ChartBackground } from "../lib/background.js";
34
+ import { ChartDot } from "../lib/dot.js";
35
+ import {
36
+ ChartLegend,
37
+ ChartLegendContent
38
+ } from "../lib/legend.js";
39
+ import {
40
+ ChartTooltip,
41
+ ChartTooltipContent
42
+ } from "../lib/tooltip.js";
43
+ import { Brush, ChartBrush } from "../lib/brush.js";
44
+ import { ChartControls, Toolbar } from "../lib/toolbar.js";
45
+ import { useChartZoom } from "../lib/zoom.js";
46
+ import { LoadingIndicator, LoadingShimmer, LOADING_KEY, useLoadingRows } from "../lib/loading.js";
47
+ import {
48
+ AnimatedDashedStroke,
49
+ AreaDottedFill,
50
+ AreaGradientFill,
51
+ AreaGradientReverseFill,
52
+ AreaHatchedFill,
53
+ AreaLinesFill,
54
+ AreaSolidFill,
55
+ RevealMask,
56
+ SeriesGradient,
57
+ UnselectedFill
58
+ } from "../lib/paint.js";
59
+ const STROKE_WIDTH = 0.8;
60
+ const STACK_ID = "m22-area-stack";
61
+ const CHART_MARGIN = { top: 8, right: 12, bottom: 0, left: 12 };
62
+ const AreaChartContext = createContext(null);
63
+ function useAreaChart() {
64
+ const context = useContext(AreaChartContext);
65
+ if (!context) throw new Error("An area chart part must be rendered inside <AreaChart>");
66
+ return context;
67
+ }
68
+ function AreaChart({
69
+ config,
70
+ data,
71
+ title,
72
+ showTitle,
73
+ description,
74
+ children,
75
+ className,
76
+ chartProps,
77
+ curveType = "linear",
78
+ animationType = "forward",
79
+ stackType = "default",
80
+ defaultSelectedDataKey = null,
81
+ onSelectionChange,
82
+ isLoading = false,
83
+ loadingPoints,
84
+ xDataKey,
85
+ hideDataTable = false,
86
+ empty
87
+ }) {
88
+ const chartId = useId().replace(/:/g, "");
89
+ const [selectedDataKey, setSelectedDataKey] = useState(defaultSelectedDataKey);
90
+ const { rows: loadingData, onShimmerExit } = useLoadingRows(isLoading, loadingPoints);
91
+ const zoom = useChartZoom({ data, xDataKey });
92
+ const { brushSlot, toolbarSlot, sonifySlot, chartChildren } = useMemo(() => {
93
+ const parts = Children.toArray(children);
94
+ const element = parts.find((child) => isValidElement(child) && child.type === Brush);
95
+ const props = isValidElement(element) ? element.props : {};
96
+ return {
97
+ brushSlot: { present: isValidElement(element), ...props },
98
+ toolbarSlot: findSlot(parts, Toolbar),
99
+ sonifySlot: findSlot(parts, Sonify),
100
+ chartChildren: parts.filter(
101
+ (child) => !(isValidElement(child) && (child.type === Brush || child.type === Toolbar || child.type === Sonify))
102
+ )
103
+ };
104
+ }, [children]);
105
+ const columns = useMemo(
106
+ () => Object.entries(config).map(([key, series]) => ({ key, label: series.label })),
107
+ [config]
108
+ );
109
+ const isExpanded = stackType === "expanded";
110
+ const isStacked = stackType === "stacked" || isExpanded;
111
+ const showBrush = brushSlot.present && !isLoading;
112
+ const showToolbar = toolbarSlot !== null && !isLoading;
113
+ const isEmpty = !isLoading && empty !== false && data.length === 0;
114
+ const displayData = isLoading ? loadingData : showBrush || showToolbar ? zoom.visibleData : data;
115
+ const sonifySeries = useChartSonifySeries(
116
+ sonifySlot,
117
+ displayData,
118
+ config,
119
+ xDataKey
120
+ );
121
+ const selectDataKey = useCallback(
122
+ (next) => {
123
+ setSelectedDataKey(next);
124
+ onSelectionChange?.(next);
125
+ },
126
+ [onSelectionChange]
127
+ );
128
+ const context = useMemo(
129
+ () => ({
130
+ config,
131
+ rows: displayData,
132
+ curveType,
133
+ animationType,
134
+ isStacked,
135
+ isExpanded,
136
+ isLoading,
137
+ selectedDataKey,
138
+ selectDataKey
139
+ }),
140
+ [
141
+ animationType,
142
+ config,
143
+ curveType,
144
+ displayData,
145
+ isExpanded,
146
+ isLoading,
147
+ isStacked,
148
+ selectDataKey,
149
+ selectedDataKey
150
+ ]
151
+ );
152
+ return /* @__PURE__ */ jsx(AreaChartContext.Provider, { value: context, children: /* @__PURE__ */ jsxs(
153
+ ChartFigure,
154
+ {
155
+ title,
156
+ showTitle,
157
+ description,
158
+ className,
159
+ table: hideDataTable ? false : { rows: data, rowKey: xDataKey, columns },
160
+ children: [
161
+ sonifySlot && /* @__PURE__ */ jsx(ChartSonifyButton, { ...sonifySlot, title, series: sonifySeries }),
162
+ isEmpty ? /* @__PURE__ */ jsx(ChartEmpty, { ...empty || {} }) : /* @__PURE__ */ jsx(
163
+ ChartControls,
164
+ {
165
+ toolbar: showToolbar ? toolbarSlot : null,
166
+ zoom,
167
+ title,
168
+ rows: data,
169
+ columns,
170
+ rowKey: xDataKey,
171
+ children: /* @__PURE__ */ jsx(
172
+ ChartContainer,
173
+ {
174
+ config,
175
+ footer: showBrush && /* @__PURE__ */ jsx(
176
+ ChartBrush,
177
+ {
178
+ data,
179
+ config,
180
+ xDataKey,
181
+ variant: "area",
182
+ curveType,
183
+ height: brushSlot.height,
184
+ formatLabel: brushSlot.formatLabel,
185
+ stacked: isStacked,
186
+ className: "mt-1",
187
+ ...zoom.brushProps,
188
+ onChange: (range) => {
189
+ zoom.brushProps.onChange(range);
190
+ brushSlot.onChange?.(range);
191
+ }
192
+ }
193
+ ),
194
+ children: /* @__PURE__ */ jsxs(
195
+ RechartsAreaChart,
196
+ {
197
+ id: chartId,
198
+ accessibilityLayer: true,
199
+ margin: CHART_MARGIN,
200
+ stackOffset: isExpanded ? "expand" : void 0,
201
+ data: displayData,
202
+ ...chartProps,
203
+ children: [
204
+ chartChildren,
205
+ isLoading && /* @__PURE__ */ jsx(LoadingArea, { chartId, curveType, onShimmerExit })
206
+ ]
207
+ }
208
+ )
209
+ }
210
+ )
211
+ }
212
+ ),
213
+ /* @__PURE__ */ jsx(LoadingIndicator, { isLoading })
214
+ ]
215
+ }
216
+ ) });
217
+ }
218
+ function Area({
219
+ dataKey,
220
+ variant = "gradient",
221
+ strokeVariant = "dashed",
222
+ strokeWidth = STROKE_WIDTH,
223
+ curveType,
224
+ animationType,
225
+ connectNulls = false,
226
+ isClickable = false,
227
+ children,
228
+ areaProps
229
+ }) {
230
+ const {
231
+ config,
232
+ curveType: defaultCurve,
233
+ animationType: defaultAnimation,
234
+ isStacked,
235
+ isExpanded,
236
+ isLoading,
237
+ rows,
238
+ selectedDataKey,
239
+ selectDataKey
240
+ } = useAreaChart();
241
+ const id = useId().replace(/:/g, "");
242
+ const reduceMotion = useReducedMotion();
243
+ if (isLoading) return null;
244
+ const reveal = reduceMotion ? "none" : animationType ?? defaultAnimation;
245
+ const maskId = reveal === "none" ? void 0 : `${id}-reveal-mask`;
246
+ const isSelected = selectedDataKey === dataKey;
247
+ const hasSelection = selectedDataKey !== null;
248
+ const dimmed = hasSelection && !isSelected;
249
+ const opacity = dimmed ? { fill: 0.25, stroke: 0.3, dot: 0.3 } : { fill: 1, stroke: 1, dot: 1 };
250
+ const { dot, activeDot } = resolveDots(children, id, dataKey, opacity.dot, maskId);
251
+ const labels = resolveValues(
252
+ findSlot(children, Values),
253
+ rows.map((row) => Number(row[dataKey])).filter(Number.isFinite)
254
+ );
255
+ const animateDash = strokeVariant === "animated-dashed" && !hasSelection && !reduceMotion;
256
+ const isDashed = strokeVariant !== "solid";
257
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
258
+ /* @__PURE__ */ jsxs(
259
+ RechartsArea,
260
+ {
261
+ type: curveType ?? defaultCurve,
262
+ dataKey,
263
+ connectNulls,
264
+ fillOpacity: opacity.fill,
265
+ strokeOpacity: opacity.stroke,
266
+ fill: `url(#${id}-${dimmed ? "unselected" : variant}-${dataKey})`,
267
+ stroke: `url(#${id}-colors-${dataKey})`,
268
+ stackId: isStacked ? STACK_ID : void 0,
269
+ dot,
270
+ activeDot,
271
+ strokeWidth,
272
+ strokeDasharray: isDashed ? "3 3" : void 0,
273
+ isAnimationActive: false,
274
+ style: {
275
+ ...maskId ? { mask: `url(#${maskId})` } : {},
276
+ ...isClickable ? { cursor: "pointer" } : {}
277
+ },
278
+ onClick: () => {
279
+ if (!isClickable) return;
280
+ selectDataKey(isSelected ? null : dataKey);
281
+ },
282
+ ...areaProps,
283
+ children: [
284
+ animateDash && /* @__PURE__ */ jsx(AnimatedDashedStroke, {}),
285
+ labels
286
+ ]
287
+ }
288
+ ),
289
+ /* @__PURE__ */ jsxs("defs", { children: [
290
+ reveal !== "none" && /* @__PURE__ */ jsx(RevealMask, { id, type: reveal }),
291
+ /* @__PURE__ */ jsx(
292
+ SeriesGradient,
293
+ {
294
+ id,
295
+ dataKey,
296
+ config,
297
+ gradientUnits: isExpanded ? "userSpaceOnUse" : "objectBoundingBox"
298
+ }
299
+ ),
300
+ variant === "gradient" && /* @__PURE__ */ jsx(AreaGradientFill, { id, dataKey }),
301
+ variant === "gradient-reverse" && /* @__PURE__ */ jsx(AreaGradientReverseFill, { id, dataKey }),
302
+ variant === "solid" && /* @__PURE__ */ jsx(AreaSolidFill, { id, dataKey }),
303
+ variant === "dotted" && /* @__PURE__ */ jsx(AreaDottedFill, { id, dataKey }),
304
+ variant === "lines" && /* @__PURE__ */ jsx(AreaLinesFill, { id, dataKey }),
305
+ variant === "hatched" && /* @__PURE__ */ jsx(AreaHatchedFill, { id, dataKey }),
306
+ dimmed && /* @__PURE__ */ jsx(UnselectedFill, { id, dataKey })
307
+ ] })
308
+ ] });
309
+ }
310
+ const Dot = () => null;
311
+ const ActiveDot = () => null;
312
+ function resolveDots(children, id, dataKey, dotOpacity, maskId) {
313
+ let dot = false;
314
+ let activeDot = false;
315
+ Children.forEach(children, (child) => {
316
+ if (!isValidElement(child)) return;
317
+ const { variant } = child.props;
318
+ if (child.type === Dot) {
319
+ dot = /* @__PURE__ */ jsx(
320
+ ChartDot,
321
+ {
322
+ variant,
323
+ dataKey,
324
+ chartId: id,
325
+ fillOpacity: dotOpacity,
326
+ maskId
327
+ }
328
+ );
329
+ }
330
+ if (child.type === ActiveDot) {
331
+ activeDot = /* @__PURE__ */ jsx(ChartDot, { variant, dataKey, chartId: id, fillOpacity: dotOpacity });
332
+ }
333
+ });
334
+ return { dot, activeDot };
335
+ }
336
+ function XAxis({
337
+ tickLine = false,
338
+ axisLine = false,
339
+ tickMargin = 8,
340
+ minTickGap = 8,
341
+ label,
342
+ ...rest
343
+ }) {
344
+ const { isLoading } = useAreaChart();
345
+ if (isLoading) return null;
346
+ return /* @__PURE__ */ jsx(
347
+ RechartsXAxis,
348
+ {
349
+ tickLine,
350
+ axisLine,
351
+ tickMargin,
352
+ minTickGap,
353
+ ...rest,
354
+ children: axisLabel(label, "x")
355
+ }
356
+ );
357
+ }
358
+ function YAxis({
359
+ tickLine = false,
360
+ axisLine = false,
361
+ tickMargin = 8,
362
+ minTickGap = 8,
363
+ width = "auto",
364
+ tickFormatter,
365
+ label,
366
+ ...rest
367
+ }) {
368
+ const { isLoading, isExpanded } = useAreaChart();
369
+ if (isLoading) return null;
370
+ return /* @__PURE__ */ jsx(
371
+ RechartsYAxis,
372
+ {
373
+ tickLine,
374
+ axisLine,
375
+ tickMargin,
376
+ minTickGap,
377
+ width,
378
+ tickFormatter: isExpanded ? percentTick : tickFormatter ?? defaultTick,
379
+ ...rest,
380
+ children: axisLabel(label, "y")
381
+ }
382
+ );
383
+ }
384
+ function Grid({
385
+ vertical = false,
386
+ strokeDasharray = "3 3",
387
+ ...rest
388
+ }) {
389
+ return /* @__PURE__ */ jsx(CartesianGrid, { vertical, strokeDasharray, ...rest });
390
+ }
391
+ function Tooltip({ variant, roundness, defaultIndex, cursor = true }) {
392
+ const { isLoading, selectedDataKey } = useAreaChart();
393
+ if (isLoading) return null;
394
+ return /* @__PURE__ */ jsx(
395
+ ChartTooltip,
396
+ {
397
+ defaultIndex,
398
+ cursor: cursor ? { strokeDasharray: "3 3", strokeWidth: STROKE_WIDTH } : false,
399
+ content: /* @__PURE__ */ jsx(ChartTooltipContent, { selected: selectedDataKey, roundness, variant })
400
+ }
401
+ );
402
+ }
403
+ function Legend({
404
+ variant,
405
+ align = "right",
406
+ verticalAlign = "top",
407
+ isClickable = false
408
+ }) {
409
+ const { selectedDataKey, selectDataKey } = useAreaChart();
410
+ return /* @__PURE__ */ jsx(
411
+ ChartLegend,
412
+ {
413
+ verticalAlign,
414
+ align,
415
+ content: /* @__PURE__ */ jsx(
416
+ ChartLegendContent,
417
+ {
418
+ selected: selectedDataKey,
419
+ onSelectChange: selectDataKey,
420
+ isClickable,
421
+ variant
422
+ }
423
+ )
424
+ }
425
+ );
426
+ }
427
+ function Background({ variant }) {
428
+ const { isLoading } = useAreaChart();
429
+ if (isLoading) return null;
430
+ return /* @__PURE__ */ jsx(ChartBackground, { variant });
431
+ }
432
+ function LoadingArea({
433
+ chartId,
434
+ curveType,
435
+ onShimmerExit
436
+ }) {
437
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
438
+ /* @__PURE__ */ jsx(
439
+ RechartsArea,
440
+ {
441
+ type: curveType,
442
+ dataKey: LOADING_KEY,
443
+ fillOpacity: 0.05,
444
+ fill: "currentColor",
445
+ stroke: "currentColor",
446
+ strokeOpacity: 0.5,
447
+ isAnimationActive: false,
448
+ legendType: "none",
449
+ tooltipType: "none",
450
+ activeDot: false,
451
+ dot: false,
452
+ className: "text-(--ink)",
453
+ style: { mask: `url(#${chartId}-loading-mask)` }
454
+ }
455
+ ),
456
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx(LoadingShimmer, { id: chartId, onShimmerExit }) })
457
+ ] });
458
+ }
459
+ AreaChart.Area = Area;
460
+ AreaChart.Dot = Dot;
461
+ AreaChart.ActiveDot = ActiveDot;
462
+ AreaChart.XAxis = XAxis;
463
+ AreaChart.YAxis = YAxis;
464
+ AreaChart.Grid = Grid;
465
+ AreaChart.Tooltip = Tooltip;
466
+ AreaChart.Legend = Legend;
467
+ AreaChart.Background = Background;
468
+ AreaChart.ReferenceLine = ReferenceLine;
469
+ AreaChart.ReferenceBand = ReferenceBand;
470
+ AreaChart.Annotation = Annotation;
471
+ AreaChart.Values = Values;
472
+ AreaChart.Brush = Brush;
473
+ AreaChart.Toolbar = Toolbar;
474
+ AreaChart.Sonify = Sonify;
475
+ var AreaChart_default = AreaChart;
476
+ export {
477
+ AreaChart,
478
+ AreaChart_default as default
479
+ };
480
+ //# sourceMappingURL=AreaChart.js.map