agentic-ds-kit 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (345) hide show
  1. package/AGENTS.md +10 -0
  2. package/CLAUDE.md +1 -0
  3. package/LICENSE +21 -0
  4. package/README.md +38 -0
  5. package/contracts/accordion.json +38 -0
  6. package/contracts/alert.json +57 -0
  7. package/contracts/alertdialog.json +89 -0
  8. package/contracts/appheader.json +140 -0
  9. package/contracts/appnav.json +72 -0
  10. package/contracts/avatar.json +63 -0
  11. package/contracts/avatargroup.json +83 -0
  12. package/contracts/badge.json +92 -0
  13. package/contracts/barchart.json +55 -0
  14. package/contracts/breadcrumb.json +76 -0
  15. package/contracts/button.json +120 -0
  16. package/contracts/buttongroup.json +48 -0
  17. package/contracts/calendar.json +93 -0
  18. package/contracts/card.json +123 -0
  19. package/contracts/carousel.json +98 -0
  20. package/contracts/cell.json +203 -0
  21. package/contracts/chat.json +131 -0
  22. package/contracts/checkbox.json +101 -0
  23. package/contracts/collapsible.json +66 -0
  24. package/contracts/command.json +84 -0
  25. package/contracts/datatable.json +126 -0
  26. package/contracts/datepicker.json +102 -0
  27. package/contracts/drawer.json +93 -0
  28. package/contracts/dropdownmenu.json +190 -0
  29. package/contracts/empty.json +79 -0
  30. package/contracts/field.json +49 -0
  31. package/contracts/fieldset.json +29 -0
  32. package/contracts/headercell.json +107 -0
  33. package/contracts/index.json +478 -0
  34. package/contracts/input.json +119 -0
  35. package/contracts/inputotp.json +119 -0
  36. package/contracts/insightcard.json +130 -0
  37. package/contracts/linechart.json +51 -0
  38. package/contracts/loadinganimation.json +33 -0
  39. package/contracts/modal.json +100 -0
  40. package/contracts/modalcard.json +88 -0
  41. package/contracts/navigationmenu.json +65 -0
  42. package/contracts/numbertransition.json +33 -0
  43. package/contracts/pageheader.json +101 -0
  44. package/contracts/pagination.json +85 -0
  45. package/contracts/patterns/activity.json +30 -0
  46. package/contracts/patterns/assistant-workspace.json +16 -0
  47. package/contracts/patterns/dashboard.json +12 -0
  48. package/contracts/patterns/empty-first-run.json +15 -0
  49. package/contracts/patterns/inbox.json +32 -0
  50. package/contracts/patterns/invite-members.json +14 -0
  51. package/contracts/patterns/list-detail.json +13 -0
  52. package/contracts/patterns/settings-form.json +13 -0
  53. package/contracts/piechart.json +68 -0
  54. package/contracts/progress.json +124 -0
  55. package/contracts/progresssteps.json +91 -0
  56. package/contracts/radiogroup.json +132 -0
  57. package/contracts/scoreboard.json +46 -0
  58. package/contracts/scorecard.json +124 -0
  59. package/contracts/section.json +97 -0
  60. package/contracts/select.json +130 -0
  61. package/contracts/shimmertext.json +33 -0
  62. package/contracts/sidenav.json +133 -0
  63. package/contracts/slider.json +81 -0
  64. package/contracts/spinner.json +52 -0
  65. package/contracts/switch.json +94 -0
  66. package/contracts/table.json +92 -0
  67. package/contracts/tabs.json +90 -0
  68. package/contracts/textarea.json +54 -0
  69. package/contracts/thinkinganimation.json +32 -0
  70. package/contracts/timeline.json +49 -0
  71. package/contracts/toast.json +104 -0
  72. package/contracts/tooltip.json +66 -0
  73. package/lib/tokens.css +637 -0
  74. package/package.json +60 -0
  75. package/skills/prototype-from-kit/SKILL.md +29 -0
  76. package/src/index.ts +71 -0
  77. package/tokens/tokens.json +725 -0
  78. package/ui/Accordion/Accordion.module.css +68 -0
  79. package/ui/Accordion/Accordion.tsx +51 -0
  80. package/ui/Accordion/Accordion.types.ts +10 -0
  81. package/ui/Accordion/index.ts +2 -0
  82. package/ui/Alert/Alert.module.css +62 -0
  83. package/ui/Alert/Alert.tsx +27 -0
  84. package/ui/Alert/Alert.types.ts +7 -0
  85. package/ui/Alert/index.ts +2 -0
  86. package/ui/AlertDialog/AlertDialog.module.css +71 -0
  87. package/ui/AlertDialog/AlertDialog.tsx +109 -0
  88. package/ui/AlertDialog/AlertDialog.types.ts +14 -0
  89. package/ui/AlertDialog/index.ts +6 -0
  90. package/ui/AppHeader/AppHeader.module.css +120 -0
  91. package/ui/AppHeader/AppHeader.tsx +70 -0
  92. package/ui/AppHeader/AppHeader.types.ts +28 -0
  93. package/ui/AppHeader/index.ts +2 -0
  94. package/ui/AppNav/AppNav.module.css +168 -0
  95. package/ui/AppNav/AppNav.tsx +137 -0
  96. package/ui/AppNav/AppNav.types.ts +24 -0
  97. package/ui/AppNav/index.ts +2 -0
  98. package/ui/Avatar/Avatar.module.css +52 -0
  99. package/ui/Avatar/Avatar.tsx +62 -0
  100. package/ui/Avatar/Avatar.types.ts +8 -0
  101. package/ui/Avatar/index.ts +2 -0
  102. package/ui/AvatarGroup/AvatarGroup.module.css +49 -0
  103. package/ui/AvatarGroup/AvatarGroup.tsx +29 -0
  104. package/ui/AvatarGroup/AvatarGroup.types.ts +16 -0
  105. package/ui/AvatarGroup/index.ts +2 -0
  106. package/ui/Badge/Badge.module.css +92 -0
  107. package/ui/Badge/Badge.tsx +43 -0
  108. package/ui/Badge/Badge.types.ts +11 -0
  109. package/ui/Badge/index.ts +2 -0
  110. package/ui/BarChart/BarChart.module.css +56 -0
  111. package/ui/BarChart/BarChart.tsx +380 -0
  112. package/ui/BarChart/BarChart.types.ts +18 -0
  113. package/ui/BarChart/index.ts +2 -0
  114. package/ui/Breadcrumb/Breadcrumb.module.css +64 -0
  115. package/ui/Breadcrumb/Breadcrumb.tsx +89 -0
  116. package/ui/Breadcrumb/Breadcrumb.types.ts +14 -0
  117. package/ui/Breadcrumb/index.ts +2 -0
  118. package/ui/Button/Button.module.css +101 -0
  119. package/ui/Button/Button.tsx +49 -0
  120. package/ui/Button/Button.types.ts +18 -0
  121. package/ui/Button/index.ts +2 -0
  122. package/ui/Button/lucideName.tsx +188 -0
  123. package/ui/ButtonGroup/ButtonGroup.module.css +31 -0
  124. package/ui/ButtonGroup/ButtonGroup.tsx +12 -0
  125. package/ui/ButtonGroup/ButtonGroup.types.ts +6 -0
  126. package/ui/ButtonGroup/index.ts +2 -0
  127. package/ui/Calendar/Calendar.module.css +146 -0
  128. package/ui/Calendar/Calendar.tsx +296 -0
  129. package/ui/Calendar/Calendar.types.ts +11 -0
  130. package/ui/Calendar/index.ts +2 -0
  131. package/ui/Card/Card.module.css +95 -0
  132. package/ui/Card/Card.tsx +69 -0
  133. package/ui/Card/Card.types.ts +23 -0
  134. package/ui/Card/index.ts +2 -0
  135. package/ui/Carousel/Carousel.module.css +114 -0
  136. package/ui/Carousel/Carousel.tsx +152 -0
  137. package/ui/Carousel/Carousel.types.ts +17 -0
  138. package/ui/Carousel/index.ts +7 -0
  139. package/ui/Cell/Cell.module.css +133 -0
  140. package/ui/Cell/Cell.tsx +300 -0
  141. package/ui/Cell/Cell.types.ts +69 -0
  142. package/ui/Cell/index.ts +11 -0
  143. package/ui/Chat/Chat.module.css +149 -0
  144. package/ui/Chat/Chat.tsx +175 -0
  145. package/ui/Chat/Chat.types.ts +39 -0
  146. package/ui/Chat/index.ts +2 -0
  147. package/ui/Checkbox/Checkbox.module.css +135 -0
  148. package/ui/Checkbox/Checkbox.tsx +70 -0
  149. package/ui/Checkbox/Checkbox.types.ts +15 -0
  150. package/ui/Checkbox/index.ts +2 -0
  151. package/ui/Collapsible/Collapsible.module.css +68 -0
  152. package/ui/Collapsible/Collapsible.tsx +59 -0
  153. package/ui/Collapsible/Collapsible.types.ts +9 -0
  154. package/ui/Collapsible/index.ts +2 -0
  155. package/ui/Command/Command.module.css +138 -0
  156. package/ui/Command/Command.tsx +152 -0
  157. package/ui/Command/Command.types.ts +20 -0
  158. package/ui/Command/index.ts +2 -0
  159. package/ui/DataTable/DataTable.module.css +211 -0
  160. package/ui/DataTable/DataTable.tsx +429 -0
  161. package/ui/DataTable/DataTable.types.ts +35 -0
  162. package/ui/DataTable/index.ts +8 -0
  163. package/ui/DatePicker/DatePicker.module.css +44 -0
  164. package/ui/DatePicker/DatePicker.tsx +123 -0
  165. package/ui/DatePicker/DatePicker.types.ts +15 -0
  166. package/ui/DatePicker/index.ts +2 -0
  167. package/ui/Drawer/Drawer.module.css +204 -0
  168. package/ui/Drawer/Drawer.tsx +112 -0
  169. package/ui/Drawer/Drawer.types.ts +14 -0
  170. package/ui/Drawer/index.ts +2 -0
  171. package/ui/DropdownMenu/DropdownMenu.module.css +319 -0
  172. package/ui/DropdownMenu/DropdownMenu.tsx +580 -0
  173. package/ui/DropdownMenu/DropdownMenu.types.ts +48 -0
  174. package/ui/DropdownMenu/index.ts +8 -0
  175. package/ui/Empty/Empty.module.css +68 -0
  176. package/ui/Empty/Empty.tsx +35 -0
  177. package/ui/Empty/Empty.types.ts +10 -0
  178. package/ui/Empty/index.ts +2 -0
  179. package/ui/Field/Field.module.css +66 -0
  180. package/ui/Field/Field.tsx +46 -0
  181. package/ui/Field/Field.types.ts +12 -0
  182. package/ui/Field/index.ts +2 -0
  183. package/ui/FieldSet/FieldSet.module.css +30 -0
  184. package/ui/FieldSet/FieldSet.tsx +14 -0
  185. package/ui/FieldSet/FieldSet.types.ts +7 -0
  186. package/ui/FieldSet/index.ts +2 -0
  187. package/ui/HeaderCell/HeaderCell.module.css +85 -0
  188. package/ui/HeaderCell/HeaderCell.tsx +71 -0
  189. package/ui/HeaderCell/HeaderCell.types.ts +18 -0
  190. package/ui/HeaderCell/index.ts +2 -0
  191. package/ui/Input/Input.module.css +59 -0
  192. package/ui/Input/Input.tsx +65 -0
  193. package/ui/Input/Input.types.ts +22 -0
  194. package/ui/Input/index.ts +2 -0
  195. package/ui/InputOTP/InputOTP.module.css +139 -0
  196. package/ui/InputOTP/InputOTP.tsx +136 -0
  197. package/ui/InputOTP/InputOTP.types.ts +19 -0
  198. package/ui/InputOTP/index.ts +2 -0
  199. package/ui/InsightCard/InsightCard.module.css +166 -0
  200. package/ui/InsightCard/InsightCard.tsx +90 -0
  201. package/ui/InsightCard/InsightCard.types.ts +20 -0
  202. package/ui/InsightCard/index.ts +7 -0
  203. package/ui/LineChart/LineChart.module.css +93 -0
  204. package/ui/LineChart/LineChart.tsx +424 -0
  205. package/ui/LineChart/LineChart.types.ts +19 -0
  206. package/ui/LineChart/index.ts +2 -0
  207. package/ui/LoadingAnimation/LoadingAnimation.module.css +66 -0
  208. package/ui/LoadingAnimation/LoadingAnimation.tsx +41 -0
  209. package/ui/LoadingAnimation/LoadingAnimation.types.ts +9 -0
  210. package/ui/LoadingAnimation/index.ts +6 -0
  211. package/ui/Modal/Modal.module.css +48 -0
  212. package/ui/Modal/Modal.tsx +114 -0
  213. package/ui/Modal/Modal.types.ts +15 -0
  214. package/ui/Modal/index.ts +2 -0
  215. package/ui/ModalCard/ModalCard.module.css +137 -0
  216. package/ui/ModalCard/ModalCard.tsx +58 -0
  217. package/ui/ModalCard/ModalCard.types.ts +15 -0
  218. package/ui/ModalCard/index.ts +2 -0
  219. package/ui/NavigationMenu/NavigationMenu.module.css +31 -0
  220. package/ui/NavigationMenu/NavigationMenu.tsx +57 -0
  221. package/ui/NavigationMenu/NavigationMenu.types.ts +22 -0
  222. package/ui/NavigationMenu/index.ts +7 -0
  223. package/ui/NumberTransition/NumberTransition.module.css +110 -0
  224. package/ui/NumberTransition/NumberTransition.tsx +78 -0
  225. package/ui/NumberTransition/NumberTransition.types.ts +9 -0
  226. package/ui/NumberTransition/index.ts +2 -0
  227. package/ui/PageHeader/PageHeader.module.css +57 -0
  228. package/ui/PageHeader/PageHeader.tsx +39 -0
  229. package/ui/PageHeader/PageHeader.types.ts +12 -0
  230. package/ui/PageHeader/index.ts +2 -0
  231. package/ui/Pagination/Pagination.module.css +19 -0
  232. package/ui/Pagination/Pagination.tsx +147 -0
  233. package/ui/Pagination/Pagination.types.ts +12 -0
  234. package/ui/Pagination/index.ts +2 -0
  235. package/ui/PieChart/PieChart.module.css +116 -0
  236. package/ui/PieChart/PieChart.tsx +293 -0
  237. package/ui/PieChart/PieChart.types.ts +22 -0
  238. package/ui/PieChart/index.ts +2 -0
  239. package/ui/Progress/Progress.module.css +226 -0
  240. package/ui/Progress/Progress.tsx +167 -0
  241. package/ui/Progress/Progress.types.ts +15 -0
  242. package/ui/Progress/index.ts +8 -0
  243. package/ui/ProgressSteps/ProgressSteps.module.css +210 -0
  244. package/ui/ProgressSteps/ProgressSteps.tsx +105 -0
  245. package/ui/ProgressSteps/ProgressSteps.types.ts +19 -0
  246. package/ui/ProgressSteps/index.ts +8 -0
  247. package/ui/RadioGroup/RadioGroup.module.css +284 -0
  248. package/ui/RadioGroup/RadioGroup.tsx +116 -0
  249. package/ui/RadioGroup/RadioGroup.types.ts +30 -0
  250. package/ui/RadioGroup/index.ts +8 -0
  251. package/ui/Scoreboard/Scoreboard.module.css +53 -0
  252. package/ui/Scoreboard/Scoreboard.tsx +41 -0
  253. package/ui/Scoreboard/Scoreboard.types.ts +7 -0
  254. package/ui/Scoreboard/index.ts +2 -0
  255. package/ui/Scorecard/Scorecard.module.css +150 -0
  256. package/ui/Scorecard/Scorecard.tsx +92 -0
  257. package/ui/Scorecard/Scorecard.types.ts +18 -0
  258. package/ui/Scorecard/index.ts +2 -0
  259. package/ui/Section/Section.module.css +104 -0
  260. package/ui/Section/Section.tsx +75 -0
  261. package/ui/Section/Section.types.ts +15 -0
  262. package/ui/Section/index.ts +2 -0
  263. package/ui/Select/Select.module.css +7 -0
  264. package/ui/Select/Select.tsx +113 -0
  265. package/ui/Select/Select.types.ts +26 -0
  266. package/ui/Select/index.ts +2 -0
  267. package/ui/ShimmerText/ShimmerText.module.css +46 -0
  268. package/ui/ShimmerText/ShimmerText.tsx +48 -0
  269. package/ui/ShimmerText/ShimmerText.types.ts +12 -0
  270. package/ui/ShimmerText/index.ts +2 -0
  271. package/ui/SideNav/SideNav.module.css +347 -0
  272. package/ui/SideNav/SideNav.tsx +222 -0
  273. package/ui/SideNav/SideNav.types.ts +42 -0
  274. package/ui/SideNav/index.ts +8 -0
  275. package/ui/Slider/Slider.module.css +105 -0
  276. package/ui/Slider/Slider.tsx +187 -0
  277. package/ui/Slider/Slider.types.ts +11 -0
  278. package/ui/Slider/index.ts +2 -0
  279. package/ui/Spinner/Spinner.module.css +58 -0
  280. package/ui/Spinner/Spinner.tsx +19 -0
  281. package/ui/Spinner/Spinner.types.ts +6 -0
  282. package/ui/Spinner/index.ts +2 -0
  283. package/ui/Switch/Switch.module.css +189 -0
  284. package/ui/Switch/Switch.tsx +65 -0
  285. package/ui/Switch/Switch.types.ts +12 -0
  286. package/ui/Switch/index.ts +2 -0
  287. package/ui/Table/Table.module.css +132 -0
  288. package/ui/Table/Table.tsx +108 -0
  289. package/ui/Table/Table.types.ts +26 -0
  290. package/ui/Table/index.ts +8 -0
  291. package/ui/Tabs/Tabs.module.css +162 -0
  292. package/ui/Tabs/Tabs.tsx +150 -0
  293. package/ui/Tabs/Tabs.types.ts +21 -0
  294. package/ui/Tabs/index.ts +2 -0
  295. package/ui/Textarea/Textarea.module.css +74 -0
  296. package/ui/Textarea/Textarea.tsx +38 -0
  297. package/ui/Textarea/Textarea.types.ts +14 -0
  298. package/ui/Textarea/index.ts +2 -0
  299. package/ui/ThinkingAnimation/ThinkingAnimation.module.css +75 -0
  300. package/ui/ThinkingAnimation/ThinkingAnimation.tsx +31 -0
  301. package/ui/ThinkingAnimation/ThinkingAnimation.types.ts +8 -0
  302. package/ui/ThinkingAnimation/index.ts +2 -0
  303. package/ui/Timeline/Timeline.module.css +99 -0
  304. package/ui/Timeline/Timeline.tsx +47 -0
  305. package/ui/Timeline/Timeline.types.ts +16 -0
  306. package/ui/Timeline/index.ts +2 -0
  307. package/ui/Toast/Toast.module.css +133 -0
  308. package/ui/Toast/Toast.tsx +89 -0
  309. package/ui/Toast/Toast.types.ts +17 -0
  310. package/ui/Toast/index.ts +2 -0
  311. package/ui/Tooltip/Tooltip.module.css +111 -0
  312. package/ui/Tooltip/Tooltip.tsx +101 -0
  313. package/ui/Tooltip/index.ts +2 -0
  314. package/ui/patterns/ActivityPattern/ActivityFeed.tsx +77 -0
  315. package/ui/patterns/ActivityPattern/ActivityPattern.tsx +120 -0
  316. package/ui/patterns/ActivityPattern/ActivityTasks.tsx +86 -0
  317. package/ui/patterns/ActivityPattern/TaskDrawer.module.css +39 -0
  318. package/ui/patterns/ActivityPattern/TaskDrawer.tsx +186 -0
  319. package/ui/patterns/ActivityPattern/index.ts +2 -0
  320. package/ui/patterns/AssistantWorkspacePattern/AssistantWorkspacePattern.module.css +16 -0
  321. package/ui/patterns/AssistantWorkspacePattern/AssistantWorkspacePattern.tsx +159 -0
  322. package/ui/patterns/AssistantWorkspacePattern/index.ts +2 -0
  323. package/ui/patterns/DashboardPattern/DashboardPattern.tsx +102 -0
  324. package/ui/patterns/DashboardPattern/index.ts +1 -0
  325. package/ui/patterns/DashboardPattern/patterns.module.css +6 -0
  326. package/ui/patterns/EmptyFirstRunPattern/EmptyFirstRunPattern.tsx +125 -0
  327. package/ui/patterns/EmptyFirstRunPattern/index.ts +2 -0
  328. package/ui/patterns/InboxPattern/InboxPattern.module.css +40 -0
  329. package/ui/patterns/InboxPattern/InboxPattern.tsx +192 -0
  330. package/ui/patterns/InboxPattern/InboxReplyDrawer.tsx +97 -0
  331. package/ui/patterns/InboxPattern/inbox-data.ts +101 -0
  332. package/ui/patterns/InboxPattern/index.ts +2 -0
  333. package/ui/patterns/InviteMembersPattern/InviteMembersPattern.tsx +148 -0
  334. package/ui/patterns/InviteMembersPattern/index.ts +2 -0
  335. package/ui/patterns/ListDetailPattern/ListDetailPattern.module.css +34 -0
  336. package/ui/patterns/ListDetailPattern/ListDetailPattern.tsx +145 -0
  337. package/ui/patterns/ListDetailPattern/index.ts +2 -0
  338. package/ui/patterns/SettingsFormPattern/SettingsFormPattern.module.css +12 -0
  339. package/ui/patterns/SettingsFormPattern/SettingsFormPattern.tsx +89 -0
  340. package/ui/patterns/SettingsFormPattern/index.ts +3 -0
  341. package/ui/shared/ChartFrame.module.css +295 -0
  342. package/ui/shared/ChartFrame.tsx +87 -0
  343. package/ui/shared/chartMath.ts +228 -0
  344. package/ui/shared/controls.module.css +48 -0
  345. package/ui/shared/useChartSize.ts +22 -0
@@ -0,0 +1,424 @@
1
+ "use client";
2
+
3
+ import { useId, useMemo, useState, type PointerEvent as ReactPointerEvent } from "react";
4
+ import { ChartFrame } from "../shared/ChartFrame";
5
+ import frameStyles from "../shared/ChartFrame.module.css";
6
+ import {
7
+ CHART_MARGINS,
8
+ formatAxisTick,
9
+ formatValue,
10
+ linearScale,
11
+ niceTicks,
12
+ normalizeLineInput,
13
+ seriesExtent,
14
+ type ChartSeries,
15
+ } from "../shared/chartMath";
16
+ import { useChartSize } from "../shared/useChartSize";
17
+ import type { LineChartProps } from "./LineChart.types";
18
+ import styles from "./LineChart.module.css";
19
+
20
+ export type { LineChartProps, LineChartVariant } from "./LineChart.types";
21
+
22
+ type Point = { x: number; y: number };
23
+
24
+ type LineGeom = ChartSeries & {
25
+ points: Point[];
26
+ linePath: string;
27
+ areaPath: string;
28
+ };
29
+
30
+ type TickMark = {
31
+ value: number;
32
+ label: string;
33
+ x: number;
34
+ y: number;
35
+ gridX1: number;
36
+ gridX2: number;
37
+ gridY1: number;
38
+ gridY2: number;
39
+ };
40
+
41
+ type CategoryLabel = { label: string; x: number; y: number };
42
+
43
+ type SampleHit = {
44
+ index: number;
45
+ label: string;
46
+ x: number;
47
+ hitX: number;
48
+ hitWidth: number;
49
+ };
50
+
51
+ const EMPTY_LAYOUT = {
52
+ lines: [] as LineGeom[],
53
+ ticks: [] as TickMark[],
54
+ categoryLabels: [] as CategoryLabel[],
55
+ samples: [] as SampleHit[],
56
+ plotLeft: 0,
57
+ plotRight: 0,
58
+ plotTop: 0,
59
+ plotBottom: 0,
60
+ };
61
+
62
+ function ChartTable({ labels, series }: { labels: string[]; series: ChartSeries[] }) {
63
+ return (
64
+ <div className={frameStyles.tableScroll}>
65
+ <table className={frameStyles.table}>
66
+ <thead>
67
+ <tr>
68
+ <th scope="col">Label</th>
69
+ {series.map((entry) => (
70
+ <th key={entry.label} scope="col">
71
+ {entry.label}
72
+ </th>
73
+ ))}
74
+ </tr>
75
+ </thead>
76
+ <tbody>
77
+ {labels.map((label, index) => (
78
+ <tr key={label}>
79
+ <th scope="row">{label}</th>
80
+ {series.map((entry) => (
81
+ <td key={entry.label}>{formatValue(entry.data[index] ?? 0)}</td>
82
+ ))}
83
+ </tr>
84
+ ))}
85
+ </tbody>
86
+ </table>
87
+ </div>
88
+ );
89
+ }
90
+
91
+ function Legend({
92
+ series,
93
+ active,
94
+ onActivate,
95
+ onClear,
96
+ }: {
97
+ series: ChartSeries[];
98
+ active: string | null;
99
+ onActivate: (label: string) => void;
100
+ onClear: () => void;
101
+ }) {
102
+ return (
103
+ <ul className={`${frameStyles.legend} ${frameStyles.legendInteractive}`}>
104
+ {series.map((entry) => {
105
+ const dimmed = Boolean(active) && active !== entry.label;
106
+ return (
107
+ <li key={entry.label}>
108
+ <button
109
+ type="button"
110
+ className={`${frameStyles.legendItem} ${frameStyles.legendButton}${dimmed ? ` ${frameStyles.legendItemDimmed}` : ""}`}
111
+ onMouseEnter={() => onActivate(entry.label)}
112
+ onMouseLeave={onClear}
113
+ onFocus={() => onActivate(entry.label)}
114
+ onBlur={onClear}
115
+ >
116
+ <span
117
+ className={`${frameStyles.legendSwatch} ${frameStyles.legendSwatchLine}`}
118
+ style={{ background: entry.color }}
119
+ aria-hidden
120
+ />
121
+ <span>{entry.label}</span>
122
+ </button>
123
+ </li>
124
+ );
125
+ })}
126
+ </ul>
127
+ );
128
+ }
129
+
130
+ function nearestIndex(x: number, samples: SampleHit[]) {
131
+ let best = 0;
132
+ let bestDist = Infinity;
133
+ samples.forEach((sample) => {
134
+ const dist = Math.abs(sample.x - x);
135
+ if (dist < bestDist) {
136
+ bestDist = dist;
137
+ best = sample.index;
138
+ }
139
+ });
140
+ return best;
141
+ }
142
+
143
+ export function LineChart({
144
+ data,
145
+ labels: labelsProp,
146
+ series: seriesProp,
147
+ title,
148
+ description,
149
+ variant = "area",
150
+ height = 240,
151
+ showGrid = true,
152
+ showTable = true,
153
+ includeZero = false,
154
+ emptyLabel = "No data for this range",
155
+ isLoading = false,
156
+ className = "",
157
+ }: LineChartProps) {
158
+ const [activeIndex, setActiveIndex] = useState<number | null>(null);
159
+ const [highlighted, setHighlighted] = useState<string | null>(null);
160
+ const { ref, width } = useChartSize(height);
161
+ const gridMaskId = `linechart-grid-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
162
+
163
+ const { labels, series } = useMemo(
164
+ () => normalizeLineInput({ data, labels: labelsProp, series: seriesProp }),
165
+ [data, labelsProp, seriesProp],
166
+ );
167
+
168
+ const hasValues = series.some((entry) => entry.data.some((value) => Number.isFinite(value)));
169
+ const isEmpty = !labels.length || !series.length || !hasValues;
170
+ const isArea = variant === "area";
171
+ const labelledSeries = series.filter((entry) => entry.label.trim().length > 0);
172
+ const showLegend = labelledSeries.length >= 2;
173
+
174
+ const layout = useMemo(() => {
175
+ if (isEmpty || width <= 0) return EMPTY_LAYOUT;
176
+
177
+ const plotLeft = CHART_MARGINS.left;
178
+ const plotRight = width - CHART_MARGINS.right;
179
+ const plotTop = CHART_MARGINS.top;
180
+ const plotBottom = height - CHART_MARGINS.bottom;
181
+
182
+ const [rawMin, rawMax] = seriesExtent(series, { includeZero });
183
+ const { ticks, min, max } = niceTicks(rawMin, rawMax, 5);
184
+ const yScale = linearScale([min, max], [plotBottom, plotTop]);
185
+ const xScale = linearScale([0, Math.max(labels.length - 1, 1)], [plotLeft, plotRight]);
186
+
187
+ const lines: LineGeom[] = series.map((entry) => {
188
+ const points = labels.map((_, index) => ({
189
+ x: xScale(index),
190
+ y: yScale(entry.data[index] ?? 0),
191
+ }));
192
+ const linePath = points.map((point, index) => `${index === 0 ? "M" : "L"} ${point.x} ${point.y}`).join(" ");
193
+ const areaPath = isArea
194
+ ? `${linePath} L ${points[points.length - 1]?.x ?? plotRight} ${plotBottom} L ${points[0]?.x ?? plotLeft} ${plotBottom} Z`
195
+ : "";
196
+ return { ...entry, points, linePath, areaPath };
197
+ });
198
+
199
+ const categoryLabels: CategoryLabel[] = labels.map((label, index) => ({
200
+ label,
201
+ x: xScale(index),
202
+ y: plotBottom + 18,
203
+ }));
204
+
205
+ const tickMarks: TickMark[] = ticks.map((tick) => ({
206
+ value: tick,
207
+ label: formatAxisTick(tick),
208
+ x: plotLeft - 8,
209
+ y: yScale(tick),
210
+ gridX1: plotLeft,
211
+ gridX2: plotRight,
212
+ gridY1: yScale(tick),
213
+ gridY2: yScale(tick),
214
+ }));
215
+
216
+ const samples: SampleHit[] = labels.map((label, index) => {
217
+ const x = xScale(index);
218
+ const prev = index === 0 ? plotLeft : (xScale(index - 1) + x) / 2;
219
+ const next = index === labels.length - 1 ? plotRight : (x + xScale(index + 1)) / 2;
220
+ return { index, label, x, hitX: prev, hitWidth: Math.max(next - prev, 1) };
221
+ });
222
+
223
+ return { lines, ticks: tickMarks, categoryLabels, samples, plotLeft, plotRight, plotTop, plotBottom };
224
+ }, [height, includeZero, isArea, isEmpty, labels, series, width]);
225
+
226
+ const visibleLines = highlighted
227
+ ? layout.lines.filter((line) => line.label === highlighted)
228
+ : layout.lines;
229
+ const activeSample = activeIndex !== null ? (layout.samples[activeIndex] ?? null) : null;
230
+ const flipTooltip = Boolean(activeSample && width > 0 && activeSample.x > width * 0.6);
231
+
232
+ const handlePlotPointer = (event: ReactPointerEvent<SVGRectElement>) => {
233
+ if (!layout.samples.length) return;
234
+ const rect = event.currentTarget.getBoundingClientRect();
235
+ const plotWidth = layout.plotRight - layout.plotLeft;
236
+ if (plotWidth <= 0 || rect.width <= 0) return;
237
+ const x = layout.plotLeft + ((event.clientX - rect.left) / rect.width) * plotWidth;
238
+ setActiveIndex(nearestIndex(x, layout.samples));
239
+ };
240
+
241
+ const clearSample = () => setActiveIndex(null);
242
+
243
+ return (
244
+ <ChartFrame
245
+ title={title}
246
+ description={description}
247
+ legend={showLegend ? (
248
+ <Legend
249
+ series={labelledSeries}
250
+ active={highlighted}
251
+ onActivate={setHighlighted}
252
+ onClear={() => setHighlighted(null)}
253
+ />
254
+ ) : undefined}
255
+ table={showTable ? <ChartTable labels={labels} series={series} /> : undefined}
256
+ isEmpty={isEmpty}
257
+ emptyLabel={emptyLabel}
258
+ isLoading={isLoading}
259
+ className={className}
260
+ >
261
+ <div ref={ref} className={styles.plot}>
262
+ <svg className={styles.chart} width={width || "100%"} height={height} role="img" aria-label={title}>
263
+ {showGrid && isArea && width > 0 ? (
264
+ <defs>
265
+ <mask id={gridMaskId} maskUnits="userSpaceOnUse">
266
+ <rect
267
+ x={layout.plotLeft}
268
+ y={layout.plotTop}
269
+ width={Math.max(layout.plotRight - layout.plotLeft, 1)}
270
+ height={Math.max(layout.plotBottom - layout.plotTop, 1)}
271
+ fill="white"
272
+ />
273
+ {layout.lines.map((line) =>
274
+ line.areaPath ? <path key={`grid-mask-${line.label}`} d={line.areaPath} fill="black" /> : null,
275
+ )}
276
+ </mask>
277
+ </defs>
278
+ ) : null}
279
+ {showGrid ? (
280
+ <g mask={isArea && width > 0 ? `url(#${gridMaskId})` : undefined}>
281
+ {layout.ticks.map((tick) => (
282
+ <line
283
+ key={tick.value}
284
+ x1={tick.gridX1}
285
+ x2={tick.gridX2}
286
+ y1={Math.round(tick.gridY1) + 0.5}
287
+ y2={Math.round(tick.gridY1) + 0.5}
288
+ className={styles.grid}
289
+ vectorEffect="non-scaling-stroke"
290
+ />
291
+ ))}
292
+ </g>
293
+ ) : null}
294
+ {width > 0 && !showGrid ? (
295
+ <>
296
+ <line
297
+ className={styles.axis}
298
+ x1={layout.plotLeft}
299
+ x2={layout.plotLeft}
300
+ y1={layout.plotTop}
301
+ y2={layout.plotBottom}
302
+ />
303
+ <line
304
+ className={styles.axis}
305
+ x1={layout.plotLeft}
306
+ x2={layout.plotRight}
307
+ y1={layout.plotBottom}
308
+ y2={layout.plotBottom}
309
+ />
310
+ </>
311
+ ) : null}
312
+ {layout.lines.map((line) => {
313
+ const dimmed = Boolean(highlighted) && highlighted !== line.label;
314
+ return (
315
+ <g
316
+ key={line.label}
317
+ className={`${styles.series}${dimmed ? ` ${styles.seriesDimmed}` : ""}`}
318
+ >
319
+ {isArea && line.areaPath ? (
320
+ <path className={styles.area} d={line.areaPath} fill={line.color} />
321
+ ) : null}
322
+ <path className={styles.line} d={line.linePath} stroke={line.color} />
323
+ </g>
324
+ );
325
+ })}
326
+ {activeSample ? (
327
+ <line
328
+ className={styles.crosshair}
329
+ x1={activeSample.x}
330
+ x2={activeSample.x}
331
+ y1={layout.plotTop}
332
+ y2={layout.plotBottom}
333
+ />
334
+ ) : null}
335
+ {activeSample
336
+ ? visibleLines.map((line) => {
337
+ const point = line.points[activeSample.index];
338
+ if (!point) return null;
339
+ return (
340
+ <circle
341
+ key={`dot-${line.label}`}
342
+ className={styles.dot}
343
+ cx={point.x}
344
+ cy={point.y}
345
+ r={5}
346
+ fill={line.color}
347
+ />
348
+ );
349
+ })
350
+ : null}
351
+ {layout.categoryLabels.map((entry) => (
352
+ <text
353
+ key={entry.label}
354
+ x={entry.x}
355
+ y={entry.y}
356
+ className={styles.categoryLabel}
357
+ textAnchor="middle"
358
+ dominantBaseline="hanging"
359
+ >
360
+ {entry.label}
361
+ </text>
362
+ ))}
363
+ {layout.ticks.map((tick) => (
364
+ <text
365
+ key={`tick-${tick.value}`}
366
+ x={tick.x}
367
+ y={tick.y}
368
+ className={styles.tickLabel}
369
+ textAnchor="end"
370
+ dominantBaseline="middle"
371
+ >
372
+ {tick.label}
373
+ </text>
374
+ ))}
375
+ {width > 0 ? (
376
+ <rect
377
+ className={styles.overlay}
378
+ x={layout.plotLeft}
379
+ y={layout.plotTop}
380
+ width={Math.max(layout.plotRight - layout.plotLeft, 1)}
381
+ height={Math.max(layout.plotBottom - layout.plotTop, 1)}
382
+ onPointerMove={handlePlotPointer}
383
+ onPointerLeave={clearSample}
384
+ />
385
+ ) : null}
386
+ {layout.samples.map((sample) => (
387
+ <rect
388
+ key={`hit-${sample.label}-${sample.index}`}
389
+ className={styles.hit}
390
+ x={sample.hitX}
391
+ y={layout.plotTop}
392
+ width={sample.hitWidth}
393
+ height={Math.max(layout.plotBottom - layout.plotTop, 1)}
394
+ tabIndex={0}
395
+ role="button"
396
+ aria-label={`${sample.label}: ${series
397
+ .map((entry) => `${entry.label} ${formatValue(entry.data[sample.index] ?? 0)}`)
398
+ .join(", ")}`}
399
+ onFocus={() => setActiveIndex(sample.index)}
400
+ onBlur={clearSample}
401
+ />
402
+ ))}
403
+ </svg>
404
+ {activeSample ? (
405
+ <div
406
+ className={`${frameStyles.tooltip}${flipTooltip ? ` ${frameStyles.tooltipFlip}` : ""}`}
407
+ style={{ left: activeSample.x, top: layout.plotTop }}
408
+ role="status"
409
+ aria-live="polite"
410
+ >
411
+ <p className={frameStyles.tooltipTitle}>{activeSample.label}</p>
412
+ {visibleLines.map((line) => (
413
+ <div key={line.label} className={frameStyles.tooltipRow}>
414
+ <span className={frameStyles.tooltipKey} style={{ background: line.color }} aria-hidden />
415
+ <span className={frameStyles.tooltipShare}>{line.label}</span>
416
+ <span className={frameStyles.tooltipValue}>{formatValue(line.data[activeSample.index] ?? 0)}</span>
417
+ </div>
418
+ ))}
419
+ </div>
420
+ ) : null}
421
+ </div>
422
+ </ChartFrame>
423
+ );
424
+ }
@@ -0,0 +1,19 @@
1
+ import type { ChartDatum, ChartSeries } from "../shared/chartMath";
2
+
3
+ export type LineChartVariant = "line" | "area";
4
+
5
+ export interface LineChartProps {
6
+ data?: ChartDatum[];
7
+ labels?: string[];
8
+ series?: ChartSeries[];
9
+ title?: string;
10
+ description?: string;
11
+ variant?: LineChartVariant;
12
+ height?: number;
13
+ showGrid?: boolean;
14
+ showTable?: boolean;
15
+ includeZero?: boolean;
16
+ emptyLabel?: string;
17
+ isLoading?: boolean;
18
+ className?: string;
19
+ }
@@ -0,0 +1,2 @@
1
+ export { LineChart } from "./LineChart";
2
+ export type { LineChartProps, LineChartVariant } from "./LineChart.types";
@@ -0,0 +1,66 @@
1
+ .root {
2
+ --loading-animation-duration: calc(var(--motion-modal-duration) * 5);
3
+ --loading-dot-size: var(--space-2);
4
+ display: inline-grid;
5
+ grid-template-columns: repeat(3, auto);
6
+ gap: var(--space-1);
7
+ padding: var(--space-2);
8
+ border: var(--border-width-thin) solid var(--border-faint);
9
+ border-radius: var(--radius-surface-sm);
10
+ background: var(--surface-muted);
11
+ }
12
+
13
+ .dot {
14
+ position: relative;
15
+ inline-size: var(--loading-dot-size);
16
+ block-size: var(--loading-dot-size);
17
+ }
18
+
19
+ .dot::before,
20
+ .dot::after {
21
+ position: absolute;
22
+ inset: 0;
23
+ border-radius: var(--radius-full);
24
+ content: "";
25
+ }
26
+
27
+ .dot::before {
28
+ background: var(--text-primary);
29
+ }
30
+
31
+ .dot::after {
32
+ background: var(--text-inverse);
33
+ opacity: 0.35;
34
+ animation: loading-dot-crossfade var(--loading-animation-duration) var(--motion-expand-easing) infinite;
35
+ animation-delay: calc(var(--loading-animation-duration) * var(--loading-phase) * -1);
36
+ }
37
+
38
+ .sm {
39
+ --loading-dot-size: 0.3rem;
40
+ gap: 0.2rem;
41
+ padding: var(--space-1);
42
+ }
43
+
44
+ .lg {
45
+ --loading-dot-size: var(--space-3);
46
+ gap: var(--space-2);
47
+ padding: var(--space-3);
48
+ }
49
+
50
+ @keyframes loading-dot-crossfade {
51
+ 0%,
52
+ 100% {
53
+ opacity: 0;
54
+ }
55
+
56
+ 50% {
57
+ opacity: 0.85;
58
+ }
59
+ }
60
+
61
+ @media (prefers-reduced-motion: reduce) {
62
+ .dot::after {
63
+ animation: none;
64
+ opacity: 0.5;
65
+ }
66
+ }
@@ -0,0 +1,41 @@
1
+ import type { CSSProperties } from "react";
2
+ import type { LoadingAnimationProps } from "./LoadingAnimation.types";
3
+ import styles from "./LoadingAnimation.module.css";
4
+
5
+ export type {
6
+ LoadingAnimationProps,
7
+ LoadingAnimationSize,
8
+ LoadingAnimationVariant,
9
+ } from "./LoadingAnimation.types";
10
+
11
+ const DOTS = Array.from({ length: 9 }, (_, index) => index);
12
+
13
+ export function LoadingAnimation({
14
+ label = "Loading",
15
+ size = "md",
16
+ variant = "grid",
17
+ className = "",
18
+ }: LoadingAnimationProps) {
19
+ return (
20
+ <span
21
+ className={`${styles.root} ${styles[size]} ${styles[variant]} ${className}`.trim()}
22
+ role="status"
23
+ aria-label={label}
24
+ aria-live="polite"
25
+ >
26
+ {DOTS.map((index) => (
27
+ <span
28
+ className={styles.dot}
29
+ style={
30
+ {
31
+ "--loading-index": index,
32
+ "--loading-phase": index / (DOTS.length - 1),
33
+ } as CSSProperties
34
+ }
35
+ aria-hidden="true"
36
+ key={index}
37
+ />
38
+ ))}
39
+ </span>
40
+ );
41
+ }
@@ -0,0 +1,9 @@
1
+ export type LoadingAnimationSize = "sm" | "md" | "lg";
2
+ export type LoadingAnimationVariant = "grid";
3
+
4
+ export interface LoadingAnimationProps {
5
+ label?: string;
6
+ size?: LoadingAnimationSize;
7
+ variant?: LoadingAnimationVariant;
8
+ className?: string;
9
+ }
@@ -0,0 +1,6 @@
1
+ export { LoadingAnimation } from "./LoadingAnimation";
2
+ export type {
3
+ LoadingAnimationProps,
4
+ LoadingAnimationSize,
5
+ LoadingAnimationVariant,
6
+ } from "./LoadingAnimation.types";
@@ -0,0 +1,48 @@
1
+ .root {
2
+ position: fixed;
3
+ inset: 0;
4
+ z-index: var(--z-overlay);
5
+ display: grid;
6
+ place-items: center;
7
+ padding: var(--space-inset-lg);
8
+ animation: overlayEnter var(--motion-overlay-duration) var(--motion-overlay-easing);
9
+ }
10
+
11
+ .contained {
12
+ position: absolute;
13
+ }
14
+
15
+ .scrim {
16
+ grid-area: 1 / 1;
17
+ justify-self: stretch;
18
+ align-self: stretch;
19
+ width: auto;
20
+ height: auto;
21
+ margin: 0;
22
+ padding: 0;
23
+ border: none;
24
+ border-radius: 0;
25
+ background-color: var(--surface-overlay);
26
+ cursor: pointer;
27
+ }
28
+
29
+ .scrim:focus-visible {
30
+ outline: var(--border-focus-width) solid var(--focus-ring);
31
+ outline-offset: calc(-1 * var(--border-focus-width));
32
+ }
33
+
34
+ .root > :not(.scrim) {
35
+ grid-area: 1 / 1;
36
+ z-index: var(--z-modal);
37
+ min-width: 0;
38
+ max-width: 100%;
39
+ }
40
+
41
+ @keyframes overlayEnter {
42
+ from {
43
+ opacity: var(--opacity-0);
44
+ }
45
+ to {
46
+ opacity: var(--opacity-full);
47
+ }
48
+ }