@misoto22/design 0.5.0 → 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 (214) 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/charts/AreaChart/AreaChart.d.ts +191 -0
  78. package/dist/charts/AreaChart/AreaChart.js +480 -0
  79. package/dist/charts/AreaChart/AreaChart.js.map +1 -0
  80. package/dist/charts/BarChart/BarChart.d.ts +179 -0
  81. package/dist/charts/BarChart/BarChart.js +591 -0
  82. package/dist/charts/BarChart/BarChart.js.map +1 -0
  83. package/dist/charts/BarList/BarList.d.ts +57 -0
  84. package/dist/charts/BarList/BarList.js +71 -0
  85. package/dist/charts/BarList/BarList.js.map +1 -0
  86. package/dist/charts/BigNumber/BigNumber.d.ts +56 -0
  87. package/dist/charts/BigNumber/BigNumber.js +31 -0
  88. package/dist/charts/BigNumber/BigNumber.js.map +1 -0
  89. package/dist/charts/BoxPlot/BoxPlot.d.ts +177 -0
  90. package/dist/charts/BoxPlot/BoxPlot.js +495 -0
  91. package/dist/charts/BoxPlot/BoxPlot.js.map +1 -0
  92. package/dist/charts/BulletChart/BulletChart.d.ts +100 -0
  93. package/dist/charts/BulletChart/BulletChart.js +162 -0
  94. package/dist/charts/BulletChart/BulletChart.js.map +1 -0
  95. package/dist/charts/ComposedChart/ComposedChart.d.ts +171 -0
  96. package/dist/charts/ComposedChart/ComposedChart.js +667 -0
  97. package/dist/charts/ComposedChart/ComposedChart.js.map +1 -0
  98. package/dist/charts/Facet/Facet.d.ts +240 -0
  99. package/dist/charts/Facet/Facet.js +133 -0
  100. package/dist/charts/Facet/Facet.js.map +1 -0
  101. package/dist/charts/Facet/panels.d.ts +187 -0
  102. package/dist/charts/Facet/panels.js +203 -0
  103. package/dist/charts/Facet/panels.js.map +1 -0
  104. package/dist/charts/FunnelChart/FunnelChart.d.ts +101 -0
  105. package/dist/charts/FunnelChart/FunnelChart.js +147 -0
  106. package/dist/charts/FunnelChart/FunnelChart.js.map +1 -0
  107. package/dist/charts/Heatmap/Heatmap.d.ts +78 -0
  108. package/dist/charts/Heatmap/Heatmap.js +108 -0
  109. package/dist/charts/Heatmap/Heatmap.js.map +1 -0
  110. package/dist/charts/Histogram/Histogram.d.ts +165 -0
  111. package/dist/charts/Histogram/Histogram.js +350 -0
  112. package/dist/charts/Histogram/Histogram.js.map +1 -0
  113. package/dist/charts/LineChart/LineChart.d.ts +167 -0
  114. package/dist/charts/LineChart/LineChart.js +486 -0
  115. package/dist/charts/LineChart/LineChart.js.map +1 -0
  116. package/dist/charts/PieChart/PieChart.d.ts +128 -0
  117. package/dist/charts/PieChart/PieChart.js +309 -0
  118. package/dist/charts/PieChart/PieChart.js.map +1 -0
  119. package/dist/charts/RadarChart/RadarChart.d.ts +123 -0
  120. package/dist/charts/RadarChart/RadarChart.js +299 -0
  121. package/dist/charts/RadarChart/RadarChart.js.map +1 -0
  122. package/dist/charts/RadialChart/RadialChart.d.ts +124 -0
  123. package/dist/charts/RadialChart/RadialChart.js +257 -0
  124. package/dist/charts/RadialChart/RadialChart.js.map +1 -0
  125. package/dist/charts/SankeyChart/SankeyChart.d.ts +137 -0
  126. package/dist/charts/SankeyChart/SankeyChart.js +501 -0
  127. package/dist/charts/SankeyChart/SankeyChart.js.map +1 -0
  128. package/dist/charts/ScatterChart/ScatterChart.d.ts +128 -0
  129. package/dist/charts/ScatterChart/ScatterChart.js +269 -0
  130. package/dist/charts/ScatterChart/ScatterChart.js.map +1 -0
  131. package/dist/charts/Sparkline/Sparkline.d.ts +53 -0
  132. package/dist/charts/Sparkline/Sparkline.js +93 -0
  133. package/dist/charts/Sparkline/Sparkline.js.map +1 -0
  134. package/dist/charts/TreemapChart/TreemapChart.d.ts +93 -0
  135. package/dist/charts/TreemapChart/TreemapChart.js +118 -0
  136. package/dist/charts/TreemapChart/TreemapChart.js.map +1 -0
  137. package/dist/charts/WaterfallChart/WaterfallChart.d.ts +164 -0
  138. package/dist/charts/WaterfallChart/WaterfallChart.js +319 -0
  139. package/dist/charts/WaterfallChart/WaterfallChart.js.map +1 -0
  140. package/dist/charts/index.d.ts +41 -0
  141. package/dist/charts/index.js +128 -0
  142. package/dist/charts/index.js.map +1 -0
  143. package/dist/charts/lib/annotations.d.ts +103 -0
  144. package/dist/charts/lib/annotations.js +99 -0
  145. package/dist/charts/lib/annotations.js.map +1 -0
  146. package/dist/charts/lib/axis.d.ts +18 -0
  147. package/dist/charts/lib/axis.js +21 -0
  148. package/dist/charts/lib/axis.js.map +1 -0
  149. package/dist/charts/lib/background.d.ts +33 -0
  150. package/dist/charts/lib/background.js +173 -0
  151. package/dist/charts/lib/background.js.map +1 -0
  152. package/dist/charts/lib/brush.d.ts +94 -0
  153. package/dist/charts/lib/brush.js +535 -0
  154. package/dist/charts/lib/brush.js.map +1 -0
  155. package/dist/charts/lib/chart.d.ts +94 -0
  156. package/dist/charts/lib/chart.js +134 -0
  157. package/dist/charts/lib/chart.js.map +1 -0
  158. package/dist/charts/lib/dot.d.ts +29 -0
  159. package/dist/charts/lib/dot.js +78 -0
  160. package/dist/charts/lib/dot.js.map +1 -0
  161. package/dist/charts/lib/empty.d.ts +31 -0
  162. package/dist/charts/lib/empty.js +13 -0
  163. package/dist/charts/lib/empty.js.map +1 -0
  164. package/dist/charts/lib/export.d.ts +103 -0
  165. package/dist/charts/lib/export.js +204 -0
  166. package/dist/charts/lib/export.js.map +1 -0
  167. package/dist/charts/lib/figure.d.ts +61 -0
  168. package/dist/charts/lib/figure.js +59 -0
  169. package/dist/charts/lib/figure.js.map +1 -0
  170. package/dist/charts/lib/format.d.ts +46 -0
  171. package/dist/charts/lib/format.js +56 -0
  172. package/dist/charts/lib/format.js.map +1 -0
  173. package/dist/charts/lib/legend.d.ts +45 -0
  174. package/dist/charts/lib/legend.js +117 -0
  175. package/dist/charts/lib/legend.js.map +1 -0
  176. package/dist/charts/lib/loading.d.ts +48 -0
  177. package/dist/charts/lib/loading.js +105 -0
  178. package/dist/charts/lib/loading.js.map +1 -0
  179. package/dist/charts/lib/paint.d.ts +154 -0
  180. package/dist/charts/lib/paint.js +551 -0
  181. package/dist/charts/lib/paint.js.map +1 -0
  182. package/dist/charts/lib/sonify-control.d.ts +163 -0
  183. package/dist/charts/lib/sonify-control.js +172 -0
  184. package/dist/charts/lib/sonify-control.js.map +1 -0
  185. package/dist/charts/lib/sonify.d.ts +248 -0
  186. package/dist/charts/lib/sonify.js +262 -0
  187. package/dist/charts/lib/sonify.js.map +1 -0
  188. package/dist/charts/lib/toolbar.d.ts +143 -0
  189. package/dist/charts/lib/toolbar.js +156 -0
  190. package/dist/charts/lib/toolbar.js.map +1 -0
  191. package/dist/charts/lib/tooltip.d.ts +59 -0
  192. package/dist/charts/lib/tooltip.js +135 -0
  193. package/dist/charts/lib/tooltip.js.map +1 -0
  194. package/dist/charts/lib/values.d.ts +56 -0
  195. package/dist/charts/lib/values.js +71 -0
  196. package/dist/charts/lib/values.js.map +1 -0
  197. package/dist/charts/lib/zoom.d.ts +139 -0
  198. package/dist/charts/lib/zoom.js +314 -0
  199. package/dist/charts/lib/zoom.js.map +1 -0
  200. package/dist/semantic.css +19 -0
  201. package/dist/styles.css +1 -1
  202. package/dist/themes.css +50 -0
  203. package/dist/tokens.css +118 -0
  204. package/dist/tokens.d.ts +17 -0
  205. package/dist/tokens.js +101 -0
  206. package/dist/tokens.json +101 -0
  207. package/package.json +26 -4
  208. package/skills/misoto22-design/SKILL.md +171 -0
  209. package/skills/misoto22-design/evals/claims.json +95 -0
  210. package/skills/misoto22-design/rules/a11y.md +115 -0
  211. package/skills/misoto22-design/rules/composition.md +108 -0
  212. package/skills/misoto22-design/rules/forms.md +128 -0
  213. package/skills/misoto22-design/rules/naming.md +155 -0
  214. package/skills/misoto22-design/rules/tokens.md +131 -0
@@ -0,0 +1,667 @@
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
+ Bar as RechartsBar,
15
+ CartesianGrid,
16
+ ComposedChart as RechartsComposedChart,
17
+ Line as RechartsLine,
18
+ XAxis as RechartsXAxis,
19
+ YAxis as RechartsYAxis
20
+ } from "recharts";
21
+ import { motion, useReducedMotion } from "motion/react";
22
+ import { ChartContainer } from "../lib/chart.js";
23
+ import { ChartFigure } from "../lib/figure.js";
24
+ import { ChartEmpty } from "../lib/empty.js";
25
+ import { axisLabel } from "../lib/axis.js";
26
+ import { defaultTick } from "../lib/format.js";
27
+ import { Annotation, ReferenceBand, ReferenceLine } from "../lib/annotations.js";
28
+ import { Values, findSlot, resolveValues } from "../lib/values.js";
29
+ import { ChartBackground } from "../lib/background.js";
30
+ import { ChartDot } from "../lib/dot.js";
31
+ import { ChartLegend, ChartLegendContent } from "../lib/legend.js";
32
+ import { ChartTooltip, ChartTooltipContent } from "../lib/tooltip.js";
33
+ import { Brush, ChartBrush } from "../lib/brush.js";
34
+ import { ChartControls, Toolbar } from "../lib/toolbar.js";
35
+ import { useChartZoom } from "../lib/zoom.js";
36
+ import { LoadingIndicator, LoadingShimmer, LOADING_KEY, useLoadingRows } from "../lib/loading.js";
37
+ import {
38
+ AnimatedDashedStroke,
39
+ BarDuotoneFill,
40
+ BarGradientFill,
41
+ BarHatchedFill,
42
+ BarStrippedFill,
43
+ GlowFilter,
44
+ REVEAL_EASE,
45
+ RevealMask,
46
+ SeriesGradient
47
+ } from "../lib/paint.js";
48
+ const STROKE_WIDTH = 2;
49
+ const BAR_RADIUS = 4;
50
+ const GROW_DURATION = 0.5;
51
+ const GROW_STAGGER = 0.05;
52
+ const CHART_MARGIN = { top: 8, right: 12, bottom: 0, left: 12 };
53
+ const ComposedChartContext = createContext(null);
54
+ function useComposedChart() {
55
+ const context = useContext(ComposedChartContext);
56
+ if (!context) throw new Error("A composed chart part must be rendered inside <ComposedChart>");
57
+ return context;
58
+ }
59
+ function ComposedChart({
60
+ config,
61
+ data,
62
+ title,
63
+ showTitle,
64
+ description,
65
+ children,
66
+ className,
67
+ chartProps,
68
+ curveType = "linear",
69
+ animationType = "forward",
70
+ barGap,
71
+ barCategoryGap,
72
+ defaultSelectedDataKey = null,
73
+ onSelectionChange,
74
+ isLoading = false,
75
+ loadingBars,
76
+ xDataKey,
77
+ hideDataTable = false,
78
+ empty
79
+ }) {
80
+ const chartId = useId().replace(/:/g, "");
81
+ const [introStartedAt] = useState(() => Date.now());
82
+ const [selectedDataKey, setSelectedDataKey] = useState(defaultSelectedDataKey);
83
+ const [hoveredIndex, setHoveredIndex] = useState(null);
84
+ const { rows: loadingData, onShimmerExit } = useLoadingRows(isLoading, loadingBars ?? 12);
85
+ const zoom = useChartZoom({ data, xDataKey });
86
+ const { brushSlot, toolbarSlot, chartChildren } = useMemo(() => {
87
+ const parts = Children.toArray(children);
88
+ const element = parts.find((child) => isValidElement(child) && child.type === Brush);
89
+ const props = isValidElement(element) ? element.props : {};
90
+ return {
91
+ brushSlot: { present: isValidElement(element), ...props },
92
+ toolbarSlot: findSlot(parts, Toolbar),
93
+ chartChildren: parts.filter(
94
+ (child) => !(isValidElement(child) && (child.type === Brush || child.type === Toolbar))
95
+ )
96
+ };
97
+ }, [children]);
98
+ const columns = useMemo(
99
+ () => Object.entries(config).map(([key, series]) => ({ key, label: series.label })),
100
+ [config]
101
+ );
102
+ const showBrush = brushSlot.present && !isLoading;
103
+ const showToolbar = toolbarSlot !== null && !isLoading;
104
+ const isEmpty = !isLoading && empty !== false && data.length === 0;
105
+ const displayData = showBrush || showToolbar ? zoom.visibleData : data;
106
+ const selectDataKey = useCallback(
107
+ (next) => {
108
+ setSelectedDataKey(next);
109
+ onSelectionChange?.(next);
110
+ },
111
+ [onSelectionChange]
112
+ );
113
+ const context = useMemo(
114
+ () => ({
115
+ config,
116
+ rows: displayData,
117
+ curveType,
118
+ animationType,
119
+ introStartedAt,
120
+ dataLength: displayData.length,
121
+ isLoading,
122
+ hoveredIndex,
123
+ selectedDataKey,
124
+ selectDataKey
125
+ }),
126
+ [
127
+ animationType,
128
+ config,
129
+ curveType,
130
+ displayData,
131
+ hoveredIndex,
132
+ introStartedAt,
133
+ isLoading,
134
+ selectDataKey,
135
+ selectedDataKey
136
+ ]
137
+ );
138
+ return /* @__PURE__ */ jsx(ComposedChartContext.Provider, { value: context, children: /* @__PURE__ */ jsxs(
139
+ ChartFigure,
140
+ {
141
+ title,
142
+ showTitle,
143
+ description,
144
+ className,
145
+ table: hideDataTable ? false : { rows: data, rowKey: xDataKey, columns },
146
+ children: [
147
+ isEmpty ? /* @__PURE__ */ jsx(ChartEmpty, { ...empty || {} }) : /* @__PURE__ */ jsx(
148
+ ChartControls,
149
+ {
150
+ toolbar: showToolbar ? toolbarSlot : null,
151
+ zoom,
152
+ title,
153
+ rows: data,
154
+ columns,
155
+ rowKey: xDataKey,
156
+ children: /* @__PURE__ */ jsx(
157
+ ChartContainer,
158
+ {
159
+ config,
160
+ footer: showBrush && /* @__PURE__ */ jsx(
161
+ ChartBrush,
162
+ {
163
+ data,
164
+ config,
165
+ xDataKey,
166
+ variant: "area",
167
+ curveType,
168
+ height: brushSlot.height,
169
+ formatLabel: brushSlot.formatLabel,
170
+ className: "mt-1",
171
+ ...zoom.brushProps,
172
+ onChange: (range) => {
173
+ zoom.brushProps.onChange(range);
174
+ brushSlot.onChange?.(range);
175
+ }
176
+ }
177
+ ),
178
+ children: /* @__PURE__ */ jsxs(
179
+ RechartsComposedChart,
180
+ {
181
+ id: chartId,
182
+ accessibilityLayer: true,
183
+ margin: CHART_MARGIN,
184
+ data: isLoading ? loadingData : displayData,
185
+ barGap,
186
+ barCategoryGap,
187
+ onMouseMove: (state) => {
188
+ const index = state?.activeTooltipIndex;
189
+ setHoveredIndex(typeof index === "number" ? index : null);
190
+ },
191
+ onMouseLeave: () => setHoveredIndex(null),
192
+ ...chartProps,
193
+ children: [
194
+ chartChildren,
195
+ isLoading && /* @__PURE__ */ jsx(LoadingBar, { chartId, onShimmerExit })
196
+ ]
197
+ }
198
+ )
199
+ }
200
+ )
201
+ }
202
+ ),
203
+ /* @__PURE__ */ jsx(LoadingIndicator, { isLoading })
204
+ ]
205
+ }
206
+ ) });
207
+ }
208
+ function Bar({
209
+ dataKey,
210
+ variant = "default",
211
+ radius = BAR_RADIUS,
212
+ glowing = false,
213
+ animationType,
214
+ isClickable = false,
215
+ enableHoverHighlight = false,
216
+ children,
217
+ barProps
218
+ }) {
219
+ const {
220
+ config,
221
+ animationType: defaultAnimation,
222
+ introStartedAt,
223
+ dataLength,
224
+ isLoading,
225
+ rows,
226
+ hoveredIndex,
227
+ selectedDataKey,
228
+ selectDataKey
229
+ } = useComposedChart();
230
+ const id = useId().replace(/:/g, "");
231
+ const reduceMotion = useReducedMotion();
232
+ if (isLoading) return null;
233
+ const isSelected = selectedDataKey === null || selectedDataKey === dataKey;
234
+ const reveal = reduceMotion ? "none" : animationType ?? defaultAnimation;
235
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
236
+ /* @__PURE__ */ jsx(
237
+ RechartsBar,
238
+ {
239
+ dataKey,
240
+ fill: `url(#${id}-colors-${dataKey})`,
241
+ radius,
242
+ isAnimationActive: false,
243
+ style: isClickable || enableHoverHighlight ? { cursor: "pointer" } : void 0,
244
+ shape: (props) => {
245
+ const geometry = props;
246
+ const index = typeof geometry.index === "number" ? geometry.index : -1;
247
+ return /* @__PURE__ */ jsx(
248
+ ComposedBarShape,
249
+ {
250
+ ...geometry,
251
+ id,
252
+ dataKey,
253
+ variant,
254
+ barRadius: radius,
255
+ filter: glowing ? `url(#${id}-glow-${dataKey})` : void 0,
256
+ fillOpacity: barOpacity({
257
+ isClickable,
258
+ isSelected,
259
+ selectedDataKey,
260
+ enableHoverHighlight,
261
+ hoveredIndex,
262
+ index
263
+ }),
264
+ isClickable,
265
+ enableHoverHighlight,
266
+ animationType: reveal,
267
+ dataLength,
268
+ introStartedAt,
269
+ onSelect: () => {
270
+ if (!isClickable) return;
271
+ selectDataKey(selectedDataKey === dataKey ? null : dataKey);
272
+ }
273
+ }
274
+ );
275
+ },
276
+ ...barProps,
277
+ children: resolveValues(
278
+ findSlot(children, Values),
279
+ rows.map((row) => Number(row[dataKey])).filter(Number.isFinite)
280
+ )
281
+ }
282
+ ),
283
+ /* @__PURE__ */ jsxs("defs", { children: [
284
+ /* @__PURE__ */ jsx(SeriesGradient, { id, dataKey, config, direction: "vertical" }),
285
+ variant === "hatched" && /* @__PURE__ */ jsx(BarHatchedFill, { id, dataKey }),
286
+ variant === "duotone" && /* @__PURE__ */ jsx(BarDuotoneFill, { id, dataKey, config }),
287
+ variant === "duotone-reverse" && /* @__PURE__ */ jsx(BarDuotoneFill, { id, dataKey, config, reverse: true }),
288
+ variant === "gradient" && /* @__PURE__ */ jsx(BarGradientFill, { id, dataKey }),
289
+ variant === "stripped" && /* @__PURE__ */ jsx(BarStrippedFill, { id, dataKey }),
290
+ glowing && /* @__PURE__ */ jsx(GlowFilter, { id, dataKey })
291
+ ] })
292
+ ] });
293
+ }
294
+ function ComposedBarShape({
295
+ x = 0,
296
+ y = 0,
297
+ width = 0,
298
+ height = 0,
299
+ background,
300
+ index = -1,
301
+ id,
302
+ dataKey,
303
+ variant,
304
+ barRadius,
305
+ filter,
306
+ fillOpacity,
307
+ isClickable,
308
+ enableHoverHighlight,
309
+ animationType,
310
+ dataLength,
311
+ introStartedAt,
312
+ onSelect
313
+ }) {
314
+ const cursor = isClickable || enableHoverHighlight ? { cursor: "pointer" } : void 0;
315
+ const grow = growAnimation(animationType, index, dataLength, introStartedAt) ?? {};
316
+ const fill = variant === "default" ? `url(#${id}-colors-${dataKey})` : `url(#${id}-${variant}-${dataKey})`;
317
+ const hitArea = /* @__PURE__ */ jsx(
318
+ "rect",
319
+ {
320
+ x: background?.x ?? x,
321
+ y: background?.y ?? y,
322
+ width: background?.width ?? width,
323
+ height: background?.height ?? height,
324
+ fill: "transparent"
325
+ }
326
+ );
327
+ if (variant === "stripped") {
328
+ return /* @__PURE__ */ jsxs("g", { style: cursor, onClick: onSelect, children: [
329
+ /* @__PURE__ */ jsxs(
330
+ motion.g,
331
+ {
332
+ ...grow,
333
+ filter,
334
+ opacity: fillOpacity,
335
+ className: "transition-opacity duration-(--duration-base)",
336
+ children: [
337
+ /* @__PURE__ */ jsx("rect", { x, y, width, height, fill }),
338
+ /* @__PURE__ */ jsx("rect", { x, y, width, height: 2, fill: `url(#${id}-colors-${dataKey})` })
339
+ ]
340
+ }
341
+ ),
342
+ hitArea
343
+ ] });
344
+ }
345
+ return /* @__PURE__ */ jsxs("g", { style: cursor, onClick: onSelect, children: [
346
+ /* @__PURE__ */ jsx(motion.g, { ...grow, children: /* @__PURE__ */ jsx(
347
+ "rect",
348
+ {
349
+ x,
350
+ y,
351
+ width,
352
+ height,
353
+ rx: barRadius,
354
+ ry: barRadius,
355
+ fill,
356
+ opacity: fillOpacity,
357
+ filter,
358
+ className: "transition-opacity duration-(--duration-base)"
359
+ }
360
+ ) }),
361
+ hitArea
362
+ ] });
363
+ }
364
+ function growAnimation(animationType, index, dataLength, introStartedAt) {
365
+ if (animationType === "none" || index < 0 || dataLength <= 0) return null;
366
+ const lastIndex = dataLength - 1;
367
+ const centre = lastIndex / 2;
368
+ let step;
369
+ switch (animationType) {
370
+ case "reverse":
371
+ step = lastIndex - index;
372
+ break;
373
+ case "center-out":
374
+ step = Math.abs(index - centre);
375
+ break;
376
+ case "edges-in":
377
+ step = centre - Math.abs(index - centre);
378
+ break;
379
+ default:
380
+ step = index;
381
+ }
382
+ const startMs = step * GROW_STAGGER * 1e3;
383
+ const endMs = startMs + GROW_DURATION * 1e3;
384
+ const elapsed = Date.now() - introStartedAt;
385
+ if (elapsed >= endMs) return null;
386
+ const from = elapsed <= startMs ? 0 : (elapsed - startMs) / (GROW_DURATION * 1e3);
387
+ return {
388
+ initial: { scaleY: from },
389
+ animate: { scaleY: 1 },
390
+ transition: {
391
+ duration: (endMs - Math.max(elapsed, startMs)) / 1e3,
392
+ ease: REVEAL_EASE,
393
+ delay: Math.max(0, startMs - elapsed) / 1e3
394
+ },
395
+ style: { originY: 1 }
396
+ };
397
+ }
398
+ function barOpacity({
399
+ isClickable,
400
+ isSelected,
401
+ selectedDataKey,
402
+ enableHoverHighlight,
403
+ hoveredIndex,
404
+ index
405
+ }) {
406
+ const selectionOpacity = isClickable && selectedDataKey !== null ? isSelected ? 1 : 0.15 : 1;
407
+ if (enableHoverHighlight && hoveredIndex !== null) {
408
+ return hoveredIndex === index ? selectionOpacity : selectionOpacity * 0.3;
409
+ }
410
+ return selectionOpacity;
411
+ }
412
+ function Line({
413
+ dataKey,
414
+ strokeVariant = "solid",
415
+ curveType,
416
+ animationType,
417
+ connectNulls = false,
418
+ glowing = false,
419
+ isClickable = false,
420
+ children,
421
+ lineProps
422
+ }) {
423
+ const {
424
+ config,
425
+ curveType: defaultCurve,
426
+ animationType: defaultAnimation,
427
+ isLoading,
428
+ rows,
429
+ selectedDataKey,
430
+ selectDataKey
431
+ } = useComposedChart();
432
+ const id = useId().replace(/:/g, "");
433
+ const reduceMotion = useReducedMotion();
434
+ if (isLoading) return null;
435
+ const resolvedCurve = curveType ?? defaultCurve;
436
+ const reveal = reduceMotion ? "none" : animationType ?? defaultAnimation;
437
+ const maskId = reveal === "none" ? void 0 : `${id}-reveal-mask`;
438
+ const hasSelection = selectedDataKey !== null;
439
+ const dimmed = hasSelection && selectedDataKey !== dataKey;
440
+ const opacity = dimmed ? { stroke: 0.3, dot: 0.3 } : { stroke: 1, dot: 1 };
441
+ const { dot, activeDot } = resolveDots(children, id, dataKey, opacity.dot, maskId);
442
+ const labels = resolveValues(
443
+ findSlot(children, Values),
444
+ rows.map((row) => Number(row[dataKey])).filter(Number.isFinite)
445
+ );
446
+ const animateDash = strokeVariant === "animated-dashed" && !hasSelection && !reduceMotion;
447
+ const isDashed = strokeVariant !== "solid";
448
+ const select = () => {
449
+ if (!isClickable) return;
450
+ selectDataKey(selectedDataKey === dataKey ? null : dataKey);
451
+ };
452
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
453
+ isClickable && // A 20px transparent line under the visible one, giving a 2px stroke a
454
+ // pointer target a finger can hit.
455
+ /* @__PURE__ */ jsx(
456
+ RechartsLine,
457
+ {
458
+ type: resolvedCurve,
459
+ dataKey,
460
+ connectNulls,
461
+ stroke: "transparent",
462
+ strokeWidth: 20,
463
+ dot: false,
464
+ activeDot: false,
465
+ isAnimationActive: false,
466
+ legendType: "none",
467
+ tooltipType: "none",
468
+ style: { cursor: "pointer" },
469
+ onClick: select
470
+ }
471
+ ),
472
+ /* @__PURE__ */ jsxs(
473
+ RechartsLine,
474
+ {
475
+ type: resolvedCurve,
476
+ dataKey,
477
+ connectNulls,
478
+ strokeOpacity: opacity.stroke,
479
+ stroke: `url(#${id}-colors-${dataKey})`,
480
+ filter: glowing ? `url(#${id}-glow-${dataKey})` : void 0,
481
+ dot,
482
+ activeDot,
483
+ strokeWidth: STROKE_WIDTH,
484
+ strokeDasharray: isDashed ? "5 5" : void 0,
485
+ isAnimationActive: false,
486
+ style: {
487
+ ...maskId ? { mask: `url(#${maskId})` } : {},
488
+ // The hit line underneath owns the pointer; without this the visible
489
+ // line swallows the click it is sitting on top of.
490
+ ...isClickable ? { cursor: "pointer", pointerEvents: "none" } : {}
491
+ },
492
+ ...lineProps,
493
+ children: [
494
+ animateDash && /* @__PURE__ */ jsx(AnimatedDashedStroke, { dash: 5 }),
495
+ labels
496
+ ]
497
+ }
498
+ ),
499
+ /* @__PURE__ */ jsxs("defs", { children: [
500
+ reveal !== "none" && /* @__PURE__ */ jsx(RevealMask, { id, type: reveal }),
501
+ /* @__PURE__ */ jsx(SeriesGradient, { id, dataKey, config }),
502
+ glowing && /* @__PURE__ */ jsx(GlowFilter, { id, dataKey, spread: 10, intensity: 2 })
503
+ ] })
504
+ ] });
505
+ }
506
+ const Dot = () => null;
507
+ const ActiveDot = () => null;
508
+ function resolveDots(children, id, dataKey, dotOpacity, maskId) {
509
+ let dot = false;
510
+ let activeDot = false;
511
+ Children.forEach(children, (child) => {
512
+ if (!isValidElement(child)) return;
513
+ const { variant } = child.props;
514
+ if (child.type === Dot) {
515
+ dot = /* @__PURE__ */ jsx(
516
+ ChartDot,
517
+ {
518
+ variant,
519
+ dataKey,
520
+ chartId: id,
521
+ fillOpacity: dotOpacity,
522
+ maskId
523
+ }
524
+ );
525
+ }
526
+ if (child.type === ActiveDot) {
527
+ activeDot = /* @__PURE__ */ jsx(ChartDot, { variant, dataKey, chartId: id, fillOpacity: dotOpacity });
528
+ }
529
+ });
530
+ return { dot, activeDot };
531
+ }
532
+ function XAxis({
533
+ tickLine = false,
534
+ axisLine = false,
535
+ tickMargin = 8,
536
+ minTickGap = 8,
537
+ label,
538
+ ...rest
539
+ }) {
540
+ const { isLoading } = useComposedChart();
541
+ if (isLoading) return null;
542
+ return /* @__PURE__ */ jsx(
543
+ RechartsXAxis,
544
+ {
545
+ tickLine,
546
+ axisLine,
547
+ tickMargin,
548
+ minTickGap,
549
+ ...rest,
550
+ children: axisLabel(label, "x")
551
+ }
552
+ );
553
+ }
554
+ function YAxis({
555
+ tickLine = false,
556
+ axisLine = false,
557
+ tickMargin = 8,
558
+ minTickGap = 8,
559
+ width = "auto",
560
+ tickFormatter = defaultTick,
561
+ label,
562
+ ...rest
563
+ }) {
564
+ const { isLoading } = useComposedChart();
565
+ if (isLoading) return null;
566
+ return /* @__PURE__ */ jsx(
567
+ RechartsYAxis,
568
+ {
569
+ tickLine,
570
+ axisLine,
571
+ tickMargin,
572
+ minTickGap,
573
+ width,
574
+ tickFormatter,
575
+ ...rest,
576
+ children: axisLabel(label, "y")
577
+ }
578
+ );
579
+ }
580
+ function Grid({
581
+ vertical = false,
582
+ strokeDasharray = "3 3",
583
+ ...rest
584
+ }) {
585
+ return /* @__PURE__ */ jsx(CartesianGrid, { vertical, strokeDasharray, ...rest });
586
+ }
587
+ function Tooltip({ variant, roundness, defaultIndex, cursor = true }) {
588
+ const { isLoading, selectedDataKey } = useComposedChart();
589
+ if (isLoading) return null;
590
+ return /* @__PURE__ */ jsx(
591
+ ChartTooltip,
592
+ {
593
+ defaultIndex,
594
+ cursor: cursor ? { strokeDasharray: "3 3", strokeWidth: STROKE_WIDTH } : false,
595
+ content: /* @__PURE__ */ jsx(ChartTooltipContent, { selected: selectedDataKey, roundness, variant })
596
+ }
597
+ );
598
+ }
599
+ function Legend({
600
+ variant,
601
+ align = "right",
602
+ verticalAlign = "top",
603
+ isClickable = false
604
+ }) {
605
+ const { selectedDataKey, selectDataKey } = useComposedChart();
606
+ return /* @__PURE__ */ jsx(
607
+ ChartLegend,
608
+ {
609
+ verticalAlign,
610
+ align,
611
+ content: /* @__PURE__ */ jsx(
612
+ ChartLegendContent,
613
+ {
614
+ selected: selectedDataKey,
615
+ onSelectChange: selectDataKey,
616
+ isClickable,
617
+ variant
618
+ }
619
+ )
620
+ }
621
+ );
622
+ }
623
+ function Background({ variant }) {
624
+ const { isLoading } = useComposedChart();
625
+ if (isLoading) return null;
626
+ return /* @__PURE__ */ jsx(ChartBackground, { variant });
627
+ }
628
+ function LoadingBar({ chartId, onShimmerExit }) {
629
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
630
+ /* @__PURE__ */ jsx(
631
+ RechartsBar,
632
+ {
633
+ dataKey: LOADING_KEY,
634
+ fill: "currentColor",
635
+ fillOpacity: 0.15,
636
+ radius: BAR_RADIUS,
637
+ isAnimationActive: false,
638
+ legendType: "none",
639
+ className: "text-(--ink)",
640
+ style: { mask: `url(#${chartId}-loading-mask)` }
641
+ }
642
+ ),
643
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx(LoadingShimmer, { id: chartId, onShimmerExit }) })
644
+ ] });
645
+ }
646
+ ComposedChart.Bar = Bar;
647
+ ComposedChart.Line = Line;
648
+ ComposedChart.Dot = Dot;
649
+ ComposedChart.ActiveDot = ActiveDot;
650
+ ComposedChart.XAxis = XAxis;
651
+ ComposedChart.YAxis = YAxis;
652
+ ComposedChart.Grid = Grid;
653
+ ComposedChart.Tooltip = Tooltip;
654
+ ComposedChart.Legend = Legend;
655
+ ComposedChart.Background = Background;
656
+ ComposedChart.ReferenceLine = ReferenceLine;
657
+ ComposedChart.ReferenceBand = ReferenceBand;
658
+ ComposedChart.Annotation = Annotation;
659
+ ComposedChart.Values = Values;
660
+ ComposedChart.Brush = Brush;
661
+ ComposedChart.Toolbar = Toolbar;
662
+ var ComposedChart_default = ComposedChart;
663
+ export {
664
+ ComposedChart,
665
+ ComposedChart_default as default
666
+ };
667
+ //# sourceMappingURL=ComposedChart.js.map