@spatika/react 1.1.0 → 1.2.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 (311) hide show
  1. package/AGENTS.md +71 -0
  2. package/README.md +4 -3
  3. package/dist/composites/Card.d.ts +7 -1
  4. package/dist/composites/Card.d.ts.map +1 -1
  5. package/dist/composites/Card.js +10 -0
  6. package/dist/composites/ChartDataGrid.d.ts +33 -0
  7. package/dist/composites/ChartDataGrid.d.ts.map +1 -0
  8. package/dist/composites/ChartDataGrid.js +77 -0
  9. package/dist/composites/CoverHero.d.ts +1 -1
  10. package/dist/composites/CoverHero.d.ts.map +1 -1
  11. package/dist/composites/CoverHero.js +2 -2
  12. package/dist/composites/EntityMediaCard.d.ts +1 -1
  13. package/dist/composites/EntityMediaCard.d.ts.map +1 -1
  14. package/dist/composites/EntityMediaCard.js +12 -4
  15. package/dist/composites/EventCalendar.d.ts +35 -0
  16. package/dist/composites/EventCalendar.d.ts.map +1 -0
  17. package/dist/composites/EventCalendar.js +339 -0
  18. package/dist/composites/EventEditor.d.ts +22 -0
  19. package/dist/composites/EventEditor.d.ts.map +1 -0
  20. package/dist/composites/EventEditor.js +86 -0
  21. package/dist/composites/EventTimeline.d.ts +24 -0
  22. package/dist/composites/EventTimeline.d.ts.map +1 -0
  23. package/dist/composites/EventTimeline.js +184 -0
  24. package/dist/composites/MapChart.d.ts +24 -0
  25. package/dist/composites/MapChart.d.ts.map +1 -0
  26. package/dist/composites/MapChart.js +58 -0
  27. package/dist/composites/ProfileHero.d.ts +6 -4
  28. package/dist/composites/ProfileHero.d.ts.map +1 -1
  29. package/dist/composites/ProfileHero.js +8 -8
  30. package/dist/composites/ScatterWebGL.d.ts +22 -0
  31. package/dist/composites/ScatterWebGL.d.ts.map +1 -0
  32. package/dist/composites/ScatterWebGL.js +45 -0
  33. package/dist/composites/SiteFooter.d.ts +1 -1
  34. package/dist/composites/SiteFooter.js +1 -1
  35. package/dist/composites/SiteNav.d.ts +7 -2
  36. package/dist/composites/SiteNav.d.ts.map +1 -1
  37. package/dist/composites/SiteNav.js +9 -5
  38. package/dist/composites/StatCard.d.ts +2 -1
  39. package/dist/composites/StatCard.d.ts.map +1 -1
  40. package/dist/composites/StatCard.js +3 -3
  41. package/dist/composites/StatusDot.d.ts +1 -1
  42. package/dist/composites/Wordmark.d.ts +2 -2
  43. package/dist/composites/Wordmark.d.ts.map +1 -1
  44. package/dist/composites/cartesian-charts.d.ts +138 -0
  45. package/dist/composites/cartesian-charts.d.ts.map +1 -0
  46. package/dist/composites/cartesian-charts.js +401 -0
  47. package/dist/composites/chart-composition.d.ts +139 -0
  48. package/dist/composites/chart-composition.d.ts.map +1 -0
  49. package/dist/composites/chart-composition.js +486 -0
  50. package/dist/composites/chart-ui.d.ts +83 -0
  51. package/dist/composites/chart-ui.d.ts.map +1 -0
  52. package/dist/composites/chart-ui.js +108 -0
  53. package/dist/composites/charts-3d.d.ts +37 -0
  54. package/dist/composites/charts-3d.d.ts.map +1 -0
  55. package/dist/composites/charts-3d.js +121 -0
  56. package/dist/composites/flow-charts.d.ts +89 -0
  57. package/dist/composites/flow-charts.d.ts.map +1 -0
  58. package/dist/composites/flow-charts.js +186 -0
  59. package/dist/composites/radial-charts.d.ts +109 -0
  60. package/dist/composites/radial-charts.d.ts.map +1 -0
  61. package/dist/composites/radial-charts.js +176 -0
  62. package/dist/composites/scheduler-ui.d.ts +43 -0
  63. package/dist/composites/scheduler-ui.d.ts.map +1 -0
  64. package/dist/composites/scheduler-ui.js +71 -0
  65. package/dist/index.d.ts +67 -7
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +57 -7
  68. package/dist/lib/chart-export.d.ts +10 -0
  69. package/dist/lib/chart-export.d.ts.map +1 -0
  70. package/dist/lib/chart-export.js +102 -0
  71. package/dist/lib/charts.d.ts +235 -0
  72. package/dist/lib/charts.d.ts.map +1 -0
  73. package/dist/lib/charts.js +744 -0
  74. package/dist/lib/geo.d.ts +39 -0
  75. package/dist/lib/geo.d.ts.map +1 -0
  76. package/dist/lib/geo.js +101 -0
  77. package/dist/lib/iso.d.ts +21 -0
  78. package/dist/lib/iso.d.ts.map +1 -0
  79. package/dist/lib/iso.js +56 -0
  80. package/dist/lib/rrule.d.ts +20 -0
  81. package/dist/lib/rrule.d.ts.map +1 -0
  82. package/dist/lib/rrule.js +236 -0
  83. package/dist/lib/scheduler.d.ts +152 -0
  84. package/dist/lib/scheduler.d.ts.map +1 -0
  85. package/dist/lib/scheduler.js +501 -0
  86. package/dist/lib/webgl-scatter.d.ts +44 -0
  87. package/dist/lib/webgl-scatter.d.ts.map +1 -0
  88. package/dist/lib/webgl-scatter.js +185 -0
  89. package/dist/primitives/Accordion.d.ts +44 -20
  90. package/dist/primitives/Accordion.d.ts.map +1 -1
  91. package/dist/primitives/Accordion.js +82 -22
  92. package/dist/primitives/AppBar.d.ts +13 -0
  93. package/dist/primitives/AppBar.d.ts.map +1 -0
  94. package/dist/primitives/AppBar.js +27 -0
  95. package/dist/primitives/Autocomplete.d.ts +28 -0
  96. package/dist/primitives/Autocomplete.d.ts.map +1 -0
  97. package/dist/primitives/Autocomplete.js +118 -0
  98. package/dist/primitives/Avatar.d.ts +13 -1
  99. package/dist/primitives/Avatar.d.ts.map +1 -1
  100. package/dist/primitives/Avatar.js +17 -2
  101. package/dist/primitives/Backdrop.d.ts +17 -0
  102. package/dist/primitives/Backdrop.d.ts.map +1 -0
  103. package/dist/primitives/Backdrop.js +17 -0
  104. package/dist/primitives/BottomNavigation.d.ts +23 -0
  105. package/dist/primitives/BottomNavigation.d.ts.map +1 -0
  106. package/dist/primitives/BottomNavigation.js +30 -0
  107. package/dist/primitives/ButtonBase.d.ts +14 -0
  108. package/dist/primitives/ButtonBase.d.ts.map +1 -0
  109. package/dist/primitives/ButtonBase.js +13 -0
  110. package/dist/primitives/ButtonGroup.d.ts +25 -0
  111. package/dist/primitives/ButtonGroup.d.ts.map +1 -0
  112. package/dist/primitives/ButtonGroup.js +44 -0
  113. package/dist/primitives/CircularProgress.d.ts +16 -0
  114. package/dist/primitives/CircularProgress.d.ts.map +1 -0
  115. package/dist/primitives/CircularProgress.js +17 -0
  116. package/dist/primitives/ClickAwayListener.d.ts +16 -0
  117. package/dist/primitives/ClickAwayListener.d.ts.map +1 -0
  118. package/dist/primitives/ClickAwayListener.js +33 -0
  119. package/dist/primitives/Collapse.d.ts +19 -0
  120. package/dist/primitives/Collapse.d.ts.map +1 -0
  121. package/dist/primitives/Collapse.js +14 -0
  122. package/dist/primitives/Container.d.ts +13 -0
  123. package/dist/primitives/Container.d.ts.map +1 -0
  124. package/dist/primitives/Container.js +26 -0
  125. package/dist/primitives/Fab.d.ts +22 -0
  126. package/dist/primitives/Fab.d.ts.map +1 -0
  127. package/dist/primitives/Fab.js +42 -0
  128. package/dist/primitives/FormControl.d.ts +27 -0
  129. package/dist/primitives/FormControl.d.ts.map +1 -0
  130. package/dist/primitives/FormControl.js +24 -0
  131. package/dist/primitives/FormControlLabel.d.ts +18 -0
  132. package/dist/primitives/FormControlLabel.d.ts.map +1 -0
  133. package/dist/primitives/FormControlLabel.js +19 -0
  134. package/dist/primitives/Grid.d.ts +32 -0
  135. package/dist/primitives/Grid.d.ts.map +1 -0
  136. package/dist/primitives/Grid.js +50 -0
  137. package/dist/primitives/IconButton.d.ts +22 -0
  138. package/dist/primitives/IconButton.d.ts.map +1 -0
  139. package/dist/primitives/IconButton.js +39 -0
  140. package/dist/primitives/ImageList.d.ts +31 -0
  141. package/dist/primitives/ImageList.d.ts.map +1 -0
  142. package/dist/primitives/ImageList.js +33 -0
  143. package/dist/primitives/InputAdornment.d.ts +28 -0
  144. package/dist/primitives/InputAdornment.d.ts.map +1 -0
  145. package/dist/primitives/InputAdornment.js +13 -0
  146. package/dist/primitives/Link.d.ts +17 -0
  147. package/dist/primitives/Link.d.ts.map +1 -0
  148. package/dist/primitives/Link.js +29 -0
  149. package/dist/primitives/List.d.ts +41 -0
  150. package/dist/primitives/List.d.ts.map +1 -0
  151. package/dist/primitives/List.js +22 -0
  152. package/dist/primitives/Masonry.d.ts +14 -0
  153. package/dist/primitives/Masonry.d.ts.map +1 -0
  154. package/dist/primitives/Masonry.js +15 -0
  155. package/dist/primitives/Menu.d.ts +28 -0
  156. package/dist/primitives/Menu.d.ts.map +1 -0
  157. package/dist/primitives/Menu.js +54 -0
  158. package/dist/primitives/MobileStepper.d.ts +15 -0
  159. package/dist/primitives/MobileStepper.d.ts.map +1 -0
  160. package/dist/primitives/MobileStepper.js +8 -0
  161. package/dist/primitives/Modal.d.ts +18 -0
  162. package/dist/primitives/Modal.d.ts.map +1 -0
  163. package/dist/primitives/Modal.js +29 -0
  164. package/dist/primitives/NoSsr.d.ts +15 -0
  165. package/dist/primitives/NoSsr.d.ts.map +1 -0
  166. package/dist/primitives/NoSsr.js +19 -0
  167. package/dist/primitives/Paper.d.ts +22 -0
  168. package/dist/primitives/Paper.d.ts.map +1 -0
  169. package/dist/primitives/Paper.js +33 -0
  170. package/dist/primitives/Progress.d.ts +6 -2
  171. package/dist/primitives/Progress.d.ts.map +1 -1
  172. package/dist/primitives/Progress.js +8 -3
  173. package/dist/primitives/Snackbar.d.ts +23 -0
  174. package/dist/primitives/Snackbar.d.ts.map +1 -0
  175. package/dist/primitives/Snackbar.js +33 -0
  176. package/dist/primitives/SpeedDial.d.ts +26 -0
  177. package/dist/primitives/SpeedDial.d.ts.map +1 -0
  178. package/dist/primitives/SpeedDial.js +26 -0
  179. package/dist/primitives/Stack.d.ts +15 -0
  180. package/dist/primitives/Stack.d.ts.map +1 -0
  181. package/dist/primitives/Stack.js +45 -0
  182. package/dist/primitives/StarRating.d.ts +19 -1
  183. package/dist/primitives/StarRating.d.ts.map +1 -1
  184. package/dist/primitives/StarRating.js +36 -6
  185. package/dist/primitives/Stepper.d.ts +36 -0
  186. package/dist/primitives/Stepper.d.ts.map +1 -0
  187. package/dist/primitives/Stepper.js +53 -0
  188. package/dist/primitives/TablePagination.d.ts +16 -0
  189. package/dist/primitives/TablePagination.d.ts.map +1 -0
  190. package/dist/primitives/TablePagination.js +12 -0
  191. package/dist/primitives/TextField.d.ts +24 -0
  192. package/dist/primitives/TextField.d.ts.map +1 -0
  193. package/dist/primitives/TextField.js +19 -0
  194. package/dist/primitives/TextareaAutosize.d.ts +11 -0
  195. package/dist/primitives/TextareaAutosize.d.ts.map +1 -0
  196. package/dist/primitives/TextareaAutosize.js +26 -0
  197. package/dist/primitives/ToggleButton.d.ts +28 -0
  198. package/dist/primitives/ToggleButton.d.ts.map +1 -0
  199. package/dist/primitives/ToggleButton.js +56 -0
  200. package/dist/primitives/TransferList.d.ts +21 -0
  201. package/dist/primitives/TransferList.d.ts.map +1 -0
  202. package/dist/primitives/TransferList.js +40 -0
  203. package/dist/primitives/Typography.d.ts +23 -0
  204. package/dist/primitives/Typography.d.ts.map +1 -0
  205. package/dist/primitives/Typography.js +69 -0
  206. package/dist/primitives/transitions.d.ts +29 -0
  207. package/dist/primitives/transitions.d.ts.map +1 -0
  208. package/dist/primitives/transitions.js +52 -0
  209. package/package.json +28 -4
  210. package/skills/spatika-ui/SKILL.md +96 -0
  211. package/src/composites/Card.tsx +51 -1
  212. package/src/composites/ChartDataGrid.test.tsx +57 -0
  213. package/src/composites/ChartDataGrid.tsx +196 -0
  214. package/src/composites/CoverHero.test.tsx +38 -0
  215. package/src/composites/CoverHero.tsx +29 -22
  216. package/src/composites/EntityMediaCard.test.tsx +58 -0
  217. package/src/composites/EntityMediaCard.tsx +31 -13
  218. package/src/composites/EventCalendar.tsx +928 -0
  219. package/src/composites/EventEditor.tsx +268 -0
  220. package/src/composites/EventTimeline.tsx +357 -0
  221. package/src/composites/MapChart.test.tsx +39 -0
  222. package/src/composites/MapChart.tsx +130 -0
  223. package/src/composites/ProfileHero.test.tsx +33 -0
  224. package/src/composites/ProfileHero.tsx +96 -79
  225. package/src/composites/ScatterWebGL.test.tsx +25 -0
  226. package/src/composites/ScatterWebGL.tsx +79 -0
  227. package/src/composites/SiteFooter.test.tsx +37 -0
  228. package/src/composites/SiteFooter.tsx +1 -1
  229. package/src/composites/SiteNav.test.tsx +46 -0
  230. package/src/composites/SiteNav.tsx +14 -4
  231. package/src/composites/StatCard.test.tsx +30 -0
  232. package/src/composites/StatCard.tsx +4 -0
  233. package/src/composites/Wordmark.test.tsx +23 -0
  234. package/src/composites/Wordmark.tsx +2 -2
  235. package/src/composites/cartesian-charts.test.tsx +52 -0
  236. package/src/composites/cartesian-charts.tsx +1287 -0
  237. package/src/composites/chart-composition.test.tsx +53 -0
  238. package/src/composites/chart-composition.tsx +898 -0
  239. package/src/composites/chart-ui.tsx +328 -0
  240. package/src/composites/charts-3d.test.tsx +25 -0
  241. package/src/composites/charts-3d.tsx +318 -0
  242. package/src/composites/charts.test.tsx +254 -0
  243. package/src/composites/chrome.test.tsx +29 -0
  244. package/src/composites/flow-charts.test.tsx +79 -0
  245. package/src/composites/flow-charts.tsx +607 -0
  246. package/src/composites/marketing.test.tsx +38 -34
  247. package/src/composites/radial-charts.test.tsx +74 -0
  248. package/src/composites/radial-charts.tsx +617 -0
  249. package/src/composites/scheduler-ui.tsx +304 -0
  250. package/src/composites/scheduler.test.tsx +194 -0
  251. package/src/index.test.ts +22 -0
  252. package/src/index.ts +277 -5
  253. package/src/lib/chart-export.test.ts +20 -0
  254. package/src/lib/chart-export.ts +99 -0
  255. package/src/lib/charts-platform.test.ts +93 -0
  256. package/src/lib/charts.test.ts +132 -0
  257. package/src/lib/charts.ts +1021 -0
  258. package/src/lib/geo.test.ts +42 -0
  259. package/src/lib/geo.ts +138 -0
  260. package/src/lib/iso.test.ts +22 -0
  261. package/src/lib/iso.ts +102 -0
  262. package/src/lib/rrule.test.ts +53 -0
  263. package/src/lib/rrule.ts +281 -0
  264. package/src/lib/scheduler.test.ts +186 -0
  265. package/src/lib/scheduler.ts +688 -0
  266. package/src/lib/tokens.test.ts +2 -2
  267. package/src/lib/webgl-scatter.test.ts +36 -0
  268. package/src/lib/webgl-scatter.ts +230 -0
  269. package/src/primitives/Accordion.tsx +218 -63
  270. package/src/primitives/AppBar.tsx +39 -0
  271. package/src/primitives/Autocomplete.tsx +236 -0
  272. package/src/primitives/Avatar.tsx +52 -1
  273. package/src/primitives/Backdrop.tsx +48 -0
  274. package/src/primitives/BottomNavigation.tsx +102 -0
  275. package/src/primitives/ButtonBase.tsx +34 -0
  276. package/src/primitives/ButtonGroup.tsx +90 -0
  277. package/src/primitives/CircularProgress.tsx +104 -0
  278. package/src/primitives/ClickAwayListener.tsx +46 -0
  279. package/src/primitives/Collapse.tsx +39 -0
  280. package/src/primitives/Container.tsx +40 -0
  281. package/src/primitives/Fab.tsx +62 -0
  282. package/src/primitives/FormControl.tsx +90 -0
  283. package/src/primitives/FormControlLabel.tsx +51 -0
  284. package/src/primitives/Grid.tsx +101 -0
  285. package/src/primitives/IconButton.tsx +59 -0
  286. package/src/primitives/ImageList.test.tsx +48 -0
  287. package/src/primitives/ImageList.tsx +112 -0
  288. package/src/primitives/InputAdornment.tsx +86 -0
  289. package/src/primitives/Link.tsx +48 -0
  290. package/src/primitives/List.tsx +121 -0
  291. package/src/primitives/Masonry.tsx +32 -0
  292. package/src/primitives/Menu.tsx +112 -0
  293. package/src/primitives/MobileStepper.tsx +64 -0
  294. package/src/primitives/Modal.tsx +70 -0
  295. package/src/primitives/NoSsr.tsx +28 -0
  296. package/src/primitives/Paper.tsx +55 -0
  297. package/src/primitives/Progress.tsx +25 -7
  298. package/src/primitives/Snackbar.tsx +83 -0
  299. package/src/primitives/SpeedDial.tsx +110 -0
  300. package/src/primitives/Stack.tsx +88 -0
  301. package/src/primitives/StarRating.tsx +87 -28
  302. package/src/primitives/Stepper.tsx +184 -0
  303. package/src/primitives/TablePagination.tsx +58 -0
  304. package/src/primitives/TextField.tsx +105 -0
  305. package/src/primitives/TextareaAutosize.tsx +49 -0
  306. package/src/primitives/ToggleButton.tsx +148 -0
  307. package/src/primitives/TransferList.tsx +110 -0
  308. package/src/primitives/Typography.tsx +90 -0
  309. package/src/primitives/mui-more.test.tsx +76 -0
  310. package/src/primitives/mui.test.tsx +134 -0
  311. package/src/primitives/transitions.tsx +120 -0
@@ -0,0 +1,254 @@
1
+ import { render, screen } from "@testing-library/react";
2
+ import userEvent from "@testing-library/user-event";
3
+ import { describe, expect, it } from "vitest";
4
+ import { ChartContainer } from "./chart-composition";
5
+ import { BarChart, LineChart, ScatterChart, SparkLineChart, WaterfallChart } from "./cartesian-charts";
6
+ import { Gauge, LinearGauge, PieChart, RadarChart } from "./radial-charts";
7
+ import { FunnelChart, Heatmap, SankeyChart, Treemap } from "./flow-charts";
8
+ import { MapChart } from "./MapChart";
9
+ import { BarChart3D, PieChart3D } from "./charts-3d";
10
+ import { ChartDataGrid } from "./ChartDataGrid";
11
+
12
+ const months = ["Jan", "Feb", "Mar"];
13
+
14
+ describe("charts", () => {
15
+ it("renders a grouped bar chart and shows a tooltip on hover", async () => {
16
+ const user = userEvent.setup();
17
+ render(
18
+ <BarChart
19
+ width={360}
20
+ height={220}
21
+ xAxis={[{ data: months }]}
22
+ series={[
23
+ { label: "Views", data: [4, 3, 5] },
24
+ { label: "Signups", data: [1, 2, 2] },
25
+ ]}
26
+ />,
27
+ );
28
+ expect(screen.getByRole("img", { name: /bar chart/i })).toBeInTheDocument();
29
+ const marks = document.querySelectorAll('[data-slot="bar-plot"] .spk-chart-mark');
30
+ expect(marks.length).toBeGreaterThan(0);
31
+ await user.hover(marks[0]!);
32
+ expect(screen.getByRole("tooltip")).toBeInTheDocument();
33
+ });
34
+
35
+ it("hides a line series from the legend", async () => {
36
+ const user = userEvent.setup();
37
+ render(
38
+ <LineChart
39
+ width={360}
40
+ height={220}
41
+ xAxis={[{ data: months }]}
42
+ series={[
43
+ { label: "Revenue", data: [2, 4, 3] },
44
+ { label: "Cost", data: [1, 1, 2] },
45
+ ]}
46
+ />,
47
+ );
48
+ const paths = () => document.querySelectorAll('[data-slot="line-plot"] path');
49
+ const before = paths().length;
50
+ await user.click(screen.getByRole("button", { name: "Cost" }));
51
+ expect(paths().length).toBeLessThan(before);
52
+ });
53
+
54
+ it("renders pie, gauge, radar, scatter, sparkline, and linear gauge", () => {
55
+ const { container } = render(
56
+ <div>
57
+ <PieChart
58
+ width={200}
59
+ height={200}
60
+ series={[{ data: [{ value: 10, label: "A" }, { value: 20, label: "B" }] }]}
61
+ />
62
+ <Gauge value={40} width={160} height={120} />
63
+ <Gauge
64
+ width={160}
65
+ height={120}
66
+ startAngle={-90}
67
+ endAngle={90}
68
+ sections={[
69
+ { value: 40, label: "v5" },
70
+ { value: 35, label: "v6" },
71
+ { value: 25, label: "v7" },
72
+ ]}
73
+ />
74
+ <LinearGauge value={25} width={200} />
75
+ <RadarChart
76
+ width={220}
77
+ height={220}
78
+ radar={{ metrics: ["A", "B", "C"] }}
79
+ series={[{ label: "One", data: [3, 5, 4] }]}
80
+ />
81
+ <ScatterChart
82
+ width={220}
83
+ height={180}
84
+ series={[{ label: "Pts", data: [{ x: 1, y: 2, id: 1 }] }]}
85
+ />
86
+ <SparkLineChart data={[1, 4, 2, 6]} width={160} height={48} />
87
+ </div>,
88
+ );
89
+ expect(container.querySelector('[data-slot="pie-chart"]')).toBeTruthy();
90
+ expect(container.querySelector('[data-slot="gauge"]')).toBeTruthy();
91
+ expect(screen.getByRole("button", { name: "v5" })).toBeInTheDocument();
92
+ expect(container.querySelector('[data-slot="linear-gauge"]')).toBeTruthy();
93
+ expect(container.querySelector('[data-slot="radar-chart"]')).toBeTruthy();
94
+ expect(container.querySelector('[data-slot="scatter-chart"]')).toBeTruthy();
95
+ expect(container.querySelector('[data-slot="sparkline"]')).toBeTruthy();
96
+ });
97
+
98
+ it("renders heatmap, funnel, sankey, treemap, and waterfall", () => {
99
+ const { container } = render(
100
+ <div>
101
+ <Heatmap
102
+ width={240}
103
+ height={160}
104
+ xAxis={[{ data: ["A", "B"] }]}
105
+ yAxis={[{ data: ["1"] }]}
106
+ series={[{ data: [{ x: 0, y: 0, value: 2 }, { x: 1, y: 0, value: 5 }] }]}
107
+ />
108
+ <FunnelChart
109
+ width={240}
110
+ height={180}
111
+ series={[{ data: [{ label: "Visit", value: 10 }, { label: "Paid", value: 3 }] }]}
112
+ />
113
+ <SankeyChart
114
+ width={280}
115
+ height={180}
116
+ series={{
117
+ data: [{ id: "a" }, { id: "b" }],
118
+ links: [{ source: "a", target: "b", value: 4 }],
119
+ }}
120
+ />
121
+ <Treemap
122
+ width={240}
123
+ height={160}
124
+ series={[{ data: [{ label: "A", value: 8 }, { label: "B", value: 4 }] }]}
125
+ />
126
+ <WaterfallChart
127
+ width={280}
128
+ height={180}
129
+ xAxis={[{ data: ["Start", "Up", "End"] }]}
130
+ series={[{ data: [10, 4, null] }]}
131
+ />
132
+ </div>,
133
+ );
134
+ expect(container.querySelector('[data-slot="heatmap"]')).toBeTruthy();
135
+ expect(container.querySelector('[data-slot="funnel-chart"]')).toBeTruthy();
136
+ expect(container.querySelector('[data-slot="sankey-chart"]')).toBeTruthy();
137
+ expect(container.querySelector('[data-slot="treemap"]')).toBeTruthy();
138
+ expect(container.querySelector('[data-slot="waterfall-chart"]')).toBeTruthy();
139
+ });
140
+
141
+ it("composes bar and line plots from a dataset with a toolbar", async () => {
142
+ const user = userEvent.setup();
143
+ const { container } = render(
144
+ <ChartContainer
145
+ width={360}
146
+ height={220}
147
+ zoom
148
+ showToolbar
149
+ dataset={[
150
+ { month: "Jan", views: 4, conv: 1 },
151
+ { month: "Feb", views: 6, conv: 2 },
152
+ { month: "Mar", views: 5, conv: 2 },
153
+ ]}
154
+ xAxis={[{ dataKey: "month" }]}
155
+ yAxis={[{ id: "left" }, { id: "right", position: "right" }]}
156
+ series={[
157
+ { type: "bar", dataKey: "views", label: "Views" },
158
+ { type: "line", dataKey: "conv", label: "Conv", yAxisId: "right" },
159
+ ]}
160
+ />,
161
+ );
162
+ expect(container.querySelector('[data-slot="bar-plot"]')).toBeTruthy();
163
+ expect(container.querySelector('[data-slot="line-plot"]')).toBeTruthy();
164
+ expect(container.querySelector('[data-slot="chart-y-axis-right"]')).toBeTruthy();
165
+ expect(screen.getByRole("toolbar", { name: "Chart tools" })).toBeInTheDocument();
166
+ await user.click(screen.getByRole("button", { name: "Zoom in" }));
167
+ expect(container.querySelector("svg")).toBeTruthy();
168
+ });
169
+
170
+ it("renders a map, isometric 3d charts, and a sparkline bar", () => {
171
+ const { container } = render(
172
+ <div>
173
+ <MapChart
174
+ width={240}
175
+ height={160}
176
+ geoData={{
177
+ type: "FeatureCollection",
178
+ features: [
179
+ {
180
+ type: "Feature",
181
+ id: "a",
182
+ properties: { name: "A" },
183
+ geometry: {
184
+ type: "Polygon",
185
+ coordinates: [
186
+ [
187
+ [0, 0],
188
+ [4, 0],
189
+ [4, 3],
190
+ [0, 3],
191
+ [0, 0],
192
+ ],
193
+ ],
194
+ },
195
+ },
196
+ ],
197
+ }}
198
+ series={[{ data: [{ id: "a", value: 12, label: "A" }] }]}
199
+ />
200
+ <BarChart3D
201
+ width={240}
202
+ height={160}
203
+ xAxis={[{ data: ["A", "B"] }]}
204
+ series={[{ label: "Views", data: [3, 5] }]}
205
+ />
206
+ <PieChart3D
207
+ width={200}
208
+ height={160}
209
+ series={[{ data: [{ value: 2, label: "A" }, { value: 3, label: "B" }] }]}
210
+ />
211
+ <SparkLineChart data={[1, 3, 2, 5]} plotType="bar" width={120} height={36} />
212
+ <ScatterChart
213
+ width={200}
214
+ height={140}
215
+ renderer="webgl"
216
+ series={[{ label: "Pts", data: [{ x: 1, y: 2, id: 1 }] }]}
217
+ />
218
+ </div>,
219
+ );
220
+ expect(container.querySelector('[data-slot="map-chart"]')).toBeTruthy();
221
+ expect(container.querySelector('[data-slot="map-chart"] path')).toBeTruthy();
222
+ expect(container.querySelector('[data-slot="bar-chart-3d"]')).toBeTruthy();
223
+ expect(container.querySelector('[data-slot="pie-chart-3d"]')).toBeTruthy();
224
+ expect(container.querySelector('[data-slot="sparkline"] rect')).toBeTruthy();
225
+ expect(container.querySelector('[data-slot="scatter-chart"]')).toBeTruthy();
226
+ });
227
+
228
+ it("highlights a chart bar from a selected grid row", async () => {
229
+ const user = userEvent.setup();
230
+ const { container } = render(
231
+ <ChartDataGrid
232
+ height={140}
233
+ categoryField="name"
234
+ valueField="views"
235
+ rows={[
236
+ { id: "web", name: "Web", views: 10, trend: [1, 2, 3] },
237
+ { id: "ios", name: "iOS", views: 6, trend: [2, 2, 1] },
238
+ ]}
239
+ columns={[
240
+ { field: "name", headerName: "Channel" },
241
+ { field: "views", headerName: "Views", type: "number" },
242
+ { field: "trend", headerName: "Trend", type: "sparkline" },
243
+ ]}
244
+ />,
245
+ );
246
+ expect(container.querySelector('[data-slot="chart-data-grid"]')).toBeTruthy();
247
+ const row = container.querySelector(
248
+ '[data-slot="chart-data-grid"] tbody [data-slot="table-row"]:nth-child(2)',
249
+ );
250
+ expect(row).toBeTruthy();
251
+ await user.click(row!);
252
+ expect(row).toHaveAttribute("data-state", "selected");
253
+ });
254
+ });
@@ -120,6 +120,20 @@ describe("CoverHero", () => {
120
120
  expect(screen.getByText("Friday night · Studio district")).toBeInTheDocument();
121
121
  expect(screen.getByText("Meetup Story")).toBeInTheDocument();
122
122
  expect(screen.getByText("When")).toBeInTheDocument();
123
+ expect(document.querySelector("[data-slot='cover-hero']")).toHaveAttribute(
124
+ "data-cover-bleed",
125
+ "true",
126
+ );
127
+ });
128
+
129
+ it("keeps the cover inside the frame when bleed is off", () => {
130
+ render(
131
+ <CoverHero title="Coastal Drive" coverSeed="coast" bleed={false} />,
132
+ );
133
+ const hero = document.querySelector("[data-slot='cover-hero']");
134
+ expect(hero).not.toHaveAttribute("data-cover-bleed");
135
+ expect(hero).toHaveClass("overflow-hidden");
136
+ expect(document.querySelector(".cover-chrome-bar")).toBeNull();
123
137
  });
124
138
  });
125
139
 
@@ -132,6 +146,21 @@ describe("ProfileHero", () => {
132
146
  expect(screen.getByText("Product designer")).toBeInTheDocument();
133
147
  expect(container.querySelector(".profile-identity")).toBeTruthy();
134
148
  expect(container.querySelector(".profile-identity__plate")).toBeTruthy();
149
+ expect(container.querySelector("[data-slot='profile-hero']")).toHaveAttribute(
150
+ "data-cover-bleed",
151
+ "true",
152
+ );
153
+ });
154
+
155
+ it("contains the cover when bleed is off", () => {
156
+ const { container } = render(
157
+ <ProfileHero name="Alex Chen" alias="Product designer" coverSeed="alex" bleed={false} />,
158
+ );
159
+ const hero = container.querySelector("[data-slot='profile-hero']");
160
+ expect(hero).not.toHaveAttribute("data-cover-bleed");
161
+ expect(hero).toHaveClass("overflow-hidden");
162
+ expect(hero?.querySelector(".cover-media")).toBeTruthy();
163
+ expect(screen.getByRole("button", { name: "Alex Chen" })).toBeDisabled();
135
164
  });
136
165
  });
137
166
 
@@ -0,0 +1,79 @@
1
+ import { render, screen } from "@testing-library/react";
2
+ import { describe, expect, it } from "vitest";
3
+ import { FunnelChart, Heatmap } from "./flow-charts";
4
+
5
+ describe("FunnelChart", () => {
6
+ it("renders a comparison overlay with inside and outside value labels", () => {
7
+ render(
8
+ <FunnelChart
9
+ width={280}
10
+ height={200}
11
+ valueFormatter={(value) => `${value}%`}
12
+ series={[
13
+ {
14
+ label: "2000",
15
+ data: [
16
+ { label: "Primary", value: 85 },
17
+ { label: "Secondary", value: 50 },
18
+ ],
19
+ },
20
+ {
21
+ label: "2020",
22
+ data: [
23
+ { label: "Primary", value: 90 },
24
+ { label: "Secondary", value: 67 },
25
+ ],
26
+ },
27
+ ]}
28
+ />,
29
+ );
30
+ expect(screen.getByRole("img", { name: /funnel chart/i })).toBeInTheDocument();
31
+ expect(screen.getByText("85%")).toBeInTheDocument();
32
+ expect(screen.getByText("90%")).toBeInTheDocument();
33
+ expect(screen.getByText("67%")).toBeInTheDocument();
34
+ expect(document.querySelectorAll('[data-slot="funnel-chart"] path').length).toBe(4);
35
+ });
36
+
37
+ it("keeps stage names on a single funnel when the legend is hidden", () => {
38
+ render(
39
+ <FunnelChart
40
+ width={240}
41
+ height={160}
42
+ hideLegend
43
+ series={[{ data: [{ label: "Visit", value: 10 }, { label: "Paid", value: 3 }] }]}
44
+ />,
45
+ );
46
+ expect(screen.getByText("Visit")).toBeInTheDocument();
47
+ expect(screen.getByText("Paid")).toBeInTheDocument();
48
+ });
49
+ });
50
+
51
+ describe("Heatmap", () => {
52
+ it("draws a color scale for the value domain", () => {
53
+ const { container } = render(
54
+ <Heatmap
55
+ width={240}
56
+ height={160}
57
+ xAxis={[{ data: ["A", "B"] }]}
58
+ yAxis={[{ data: ["1"] }]}
59
+ series={[{ data: [{ x: 0, y: 0, value: 2 }, { x: 1, y: 0, value: 8 }] }]}
60
+ />,
61
+ );
62
+ expect(container.querySelector('[data-slot="heatmap-color-scale"]')).toBeTruthy();
63
+ expect(screen.getByText("8")).toBeInTheDocument();
64
+ });
65
+
66
+ it("hides the color scale when hideLegend is set", () => {
67
+ const { container } = render(
68
+ <Heatmap
69
+ width={240}
70
+ height={160}
71
+ hideLegend
72
+ xAxis={[{ data: ["A"] }]}
73
+ yAxis={[{ data: ["1"] }]}
74
+ series={[{ data: [{ x: 0, y: 0, value: 4 }] }]}
75
+ />,
76
+ );
77
+ expect(container.querySelector('[data-slot="heatmap-color-scale"]')).toBeNull();
78
+ });
79
+ });