@epilot/spark-ui 1.0.0-alpha.2 → 1.0.0-alpha.4

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 (561) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +2 -0
  3. package/README.md +7 -1
  4. package/dist/chunk-aJGBMT86.cjs +29 -0
  5. package/dist/components/accordion.cjs +57 -0
  6. package/dist/components/accordion.cjs.map +1 -0
  7. package/dist/components/accordion.d.cts +45 -0
  8. package/dist/components/accordion.d.ts +45 -0
  9. package/dist/components/accordion.js +51 -0
  10. package/dist/components/accordion.js.map +1 -0
  11. package/dist/components/alert-dialog.cjs +137 -0
  12. package/dist/components/alert-dialog.cjs.map +1 -0
  13. package/dist/components/alert-dialog.d.cts +63 -0
  14. package/dist/components/alert-dialog.d.ts +63 -0
  15. package/dist/components/alert-dialog.js +123 -0
  16. package/dist/components/alert-dialog.js.map +1 -0
  17. package/dist/components/attachment.cjs +119 -0
  18. package/dist/components/attachment.cjs.map +1 -0
  19. package/dist/components/attachment.d.cts +67 -0
  20. package/dist/components/attachment.d.ts +67 -0
  21. package/dist/components/attachment.js +108 -0
  22. package/dist/components/attachment.js.map +1 -0
  23. package/dist/components/badge.cjs +20 -0
  24. package/dist/components/badge.cjs.map +1 -0
  25. package/dist/components/badge.d.cts +12 -0
  26. package/dist/components/badge.d.ts +12 -0
  27. package/dist/components/badge.js +17 -0
  28. package/dist/components/badge.js.map +1 -0
  29. package/dist/components/bar-chart.cjs +520 -0
  30. package/dist/components/bar-chart.cjs.map +1 -0
  31. package/dist/components/bar-chart.d.cts +88 -0
  32. package/dist/components/bar-chart.d.ts +88 -0
  33. package/dist/components/bar-chart.js +518 -0
  34. package/dist/components/bar-chart.js.map +1 -0
  35. package/dist/components/battery-progress-row.cjs +140 -0
  36. package/dist/components/battery-progress-row.cjs.map +1 -0
  37. package/dist/components/battery-progress-row.d.cts +78 -0
  38. package/dist/components/battery-progress-row.d.ts +78 -0
  39. package/dist/components/battery-progress-row.js +129 -0
  40. package/dist/components/battery-progress-row.js.map +1 -0
  41. package/dist/components/breadcrumbs.cjs +65 -0
  42. package/dist/components/breadcrumbs.cjs.map +1 -0
  43. package/dist/components/breadcrumbs.d.cts +44 -0
  44. package/dist/components/breadcrumbs.d.ts +44 -0
  45. package/dist/components/breadcrumbs.js +58 -0
  46. package/dist/components/breadcrumbs.js.map +1 -0
  47. package/dist/components/bubble.cjs +84 -0
  48. package/dist/components/bubble.cjs.map +1 -0
  49. package/dist/components/bubble.d.cts +41 -0
  50. package/dist/components/bubble.d.ts +41 -0
  51. package/dist/components/bubble.js +78 -0
  52. package/dist/components/bubble.js.map +1 -0
  53. package/dist/components/button.cjs +54 -0
  54. package/dist/components/button.cjs.map +1 -0
  55. package/dist/components/button.d.cts +42 -0
  56. package/dist/components/button.d.ts +42 -0
  57. package/dist/components/button.js +50 -0
  58. package/dist/components/button.js.map +1 -0
  59. package/dist/components/calendar.cjs +58 -0
  60. package/dist/components/calendar.cjs.map +1 -0
  61. package/dist/components/calendar.d.cts +17 -0
  62. package/dist/components/calendar.d.ts +17 -0
  63. package/dist/components/calendar.js +55 -0
  64. package/dist/components/calendar.js.map +1 -0
  65. package/dist/components/callout.cjs +95 -0
  66. package/dist/components/callout.cjs.map +1 -0
  67. package/dist/components/callout.d.cts +39 -0
  68. package/dist/components/callout.d.ts +39 -0
  69. package/dist/components/callout.js +88 -0
  70. package/dist/components/callout.js.map +1 -0
  71. package/dist/components/card.cjs +86 -0
  72. package/dist/components/card.cjs.map +1 -0
  73. package/dist/components/card.d.cts +28 -0
  74. package/dist/components/card.d.ts +28 -0
  75. package/dist/components/card.js +76 -0
  76. package/dist/components/card.js.map +1 -0
  77. package/dist/components/chart.cjs +93 -0
  78. package/dist/components/chart.cjs.map +1 -0
  79. package/dist/components/chart.d.cts +83 -0
  80. package/dist/components/chart.d.ts +83 -0
  81. package/dist/components/chart.js +88 -0
  82. package/dist/components/chart.js.map +1 -0
  83. package/dist/components/checkbox.cjs +37 -0
  84. package/dist/components/checkbox.cjs.map +1 -0
  85. package/dist/components/checkbox.d.cts +22 -0
  86. package/dist/components/checkbox.d.ts +22 -0
  87. package/dist/components/checkbox.js +34 -0
  88. package/dist/components/checkbox.js.map +1 -0
  89. package/dist/components/circular-gauge.cjs +74 -0
  90. package/dist/components/circular-gauge.cjs.map +1 -0
  91. package/dist/components/circular-gauge.d.cts +38 -0
  92. package/dist/components/circular-gauge.d.ts +38 -0
  93. package/dist/components/circular-gauge.js +71 -0
  94. package/dist/components/circular-gauge.js.map +1 -0
  95. package/dist/components/day-of-week-picker.cjs +123 -0
  96. package/dist/components/day-of-week-picker.cjs.map +1 -0
  97. package/dist/components/day-of-week-picker.d.cts +39 -0
  98. package/dist/components/day-of-week-picker.d.ts +39 -0
  99. package/dist/components/day-of-week-picker.js +119 -0
  100. package/dist/components/day-of-week-picker.js.map +1 -0
  101. package/dist/components/device-card.cjs +118 -0
  102. package/dist/components/device-card.cjs.map +1 -0
  103. package/dist/components/device-card.d.cts +71 -0
  104. package/dist/components/device-card.d.ts +71 -0
  105. package/dist/components/device-card.js +104 -0
  106. package/dist/components/device-card.js.map +1 -0
  107. package/dist/components/dialog.cjs +115 -0
  108. package/dist/components/dialog.cjs.map +1 -0
  109. package/dist/components/dialog.d.cts +45 -0
  110. package/dist/components/dialog.d.ts +45 -0
  111. package/dist/components/dialog.js +103 -0
  112. package/dist/components/dialog.js.map +1 -0
  113. package/dist/components/donut-chart.cjs +71 -0
  114. package/dist/components/donut-chart.cjs.map +1 -0
  115. package/dist/components/donut-chart.d.cts +22 -0
  116. package/dist/components/donut-chart.d.ts +22 -0
  117. package/dist/components/donut-chart.js +69 -0
  118. package/dist/components/donut-chart.js.map +1 -0
  119. package/dist/components/drawer.cjs +95 -0
  120. package/dist/components/drawer.cjs.map +1 -0
  121. package/dist/components/drawer.d.cts +46 -0
  122. package/dist/components/drawer.d.ts +46 -0
  123. package/dist/components/drawer.js +83 -0
  124. package/dist/components/drawer.js.map +1 -0
  125. package/dist/components/dropdown-menu.cjs +165 -0
  126. package/dist/components/dropdown-menu.cjs.map +1 -0
  127. package/dist/components/dropdown-menu.d.cts +93 -0
  128. package/dist/components/dropdown-menu.d.ts +93 -0
  129. package/dist/components/dropdown-menu.js +148 -0
  130. package/dist/components/dropdown-menu.js.map +1 -0
  131. package/dist/components/empty-state.cjs +35 -0
  132. package/dist/components/empty-state.cjs.map +1 -0
  133. package/dist/components/empty-state.d.cts +22 -0
  134. package/dist/components/empty-state.d.ts +22 -0
  135. package/dist/components/empty-state.js +33 -0
  136. package/dist/components/empty-state.js.map +1 -0
  137. package/dist/components/energy-bar-chart.cjs +24 -0
  138. package/dist/components/energy-bar-chart.cjs.map +1 -0
  139. package/dist/components/energy-bar-chart.d.cts +43 -0
  140. package/dist/components/energy-bar-chart.d.ts +43 -0
  141. package/dist/components/energy-bar-chart.js +22 -0
  142. package/dist/components/energy-bar-chart.js.map +1 -0
  143. package/dist/components/energy-breakdown.cjs +81 -0
  144. package/dist/components/energy-breakdown.cjs.map +1 -0
  145. package/dist/components/energy-breakdown.d.cts +26 -0
  146. package/dist/components/energy-breakdown.d.ts +26 -0
  147. package/dist/components/energy-breakdown.js +79 -0
  148. package/dist/components/energy-breakdown.js.map +1 -0
  149. package/dist/components/energy-history-chart.cjs +64 -0
  150. package/dist/components/energy-history-chart.cjs.map +1 -0
  151. package/dist/components/energy-history-chart.d.cts +66 -0
  152. package/dist/components/energy-history-chart.d.ts +66 -0
  153. package/dist/components/energy-history-chart.js +62 -0
  154. package/dist/components/energy-history-chart.js.map +1 -0
  155. package/dist/components/feed-in-hero.cjs +56 -0
  156. package/dist/components/feed-in-hero.cjs.map +1 -0
  157. package/dist/components/feed-in-hero.d.cts +33 -0
  158. package/dist/components/feed-in-hero.d.ts +33 -0
  159. package/dist/components/feed-in-hero.js +51 -0
  160. package/dist/components/feed-in-hero.js.map +1 -0
  161. package/dist/components/field.cjs +257 -0
  162. package/dist/components/field.cjs.map +1 -0
  163. package/dist/components/field.d.cts +104 -0
  164. package/dist/components/field.d.ts +104 -0
  165. package/dist/components/field.js +243 -0
  166. package/dist/components/field.js.map +1 -0
  167. package/dist/components/icon.cjs +35 -0
  168. package/dist/components/icon.cjs.map +1 -0
  169. package/dist/components/icon.d.cts +27 -0
  170. package/dist/components/icon.d.ts +27 -0
  171. package/dist/components/icon.js +32 -0
  172. package/dist/components/icon.js.map +1 -0
  173. package/dist/components/info-block.cjs +75 -0
  174. package/dist/components/info-block.cjs.map +1 -0
  175. package/dist/components/info-block.d.cts +20 -0
  176. package/dist/components/info-block.d.ts +20 -0
  177. package/dist/components/info-block.js +65 -0
  178. package/dist/components/info-block.js.map +1 -0
  179. package/dist/components/input-group.cjs +164 -0
  180. package/dist/components/input-group.cjs.map +1 -0
  181. package/dist/components/input-group.d.cts +32 -0
  182. package/dist/components/input-group.d.ts +32 -0
  183. package/dist/components/input-group.js +158 -0
  184. package/dist/components/input-group.js.map +1 -0
  185. package/dist/components/input-otp.cjs +113 -0
  186. package/dist/components/input-otp.cjs.map +1 -0
  187. package/dist/components/input-otp.d.cts +22 -0
  188. package/dist/components/input-otp.d.ts +22 -0
  189. package/dist/components/input-otp.js +111 -0
  190. package/dist/components/input-otp.js.map +1 -0
  191. package/dist/components/input.cjs +112 -0
  192. package/dist/components/input.cjs.map +1 -0
  193. package/dist/components/input.d.cts +21 -0
  194. package/dist/components/input.d.ts +21 -0
  195. package/dist/components/input.js +109 -0
  196. package/dist/components/input.js.map +1 -0
  197. package/dist/components/label.cjs +18 -0
  198. package/dist/components/label.cjs.map +1 -0
  199. package/dist/components/label.d.cts +10 -0
  200. package/dist/components/label.d.ts +10 -0
  201. package/dist/components/label.js +15 -0
  202. package/dist/components/label.js.map +1 -0
  203. package/dist/components/layout.cjs +15 -0
  204. package/dist/components/layout.cjs.map +1 -0
  205. package/dist/components/layout.d.cts +12 -0
  206. package/dist/components/layout.d.ts +13 -0
  207. package/dist/components/layout.js +14 -0
  208. package/dist/components/layout.js.map +1 -0
  209. package/dist/components/line-chart.cjs +350 -0
  210. package/dist/components/line-chart.cjs.map +1 -0
  211. package/dist/components/line-chart.d.cts +78 -0
  212. package/dist/components/line-chart.d.ts +78 -0
  213. package/dist/components/line-chart.js +347 -0
  214. package/dist/components/line-chart.js.map +1 -0
  215. package/dist/components/list.cjs +132 -0
  216. package/dist/components/list.cjs.map +1 -0
  217. package/dist/components/list.d.cts +72 -0
  218. package/dist/components/list.d.ts +72 -0
  219. package/dist/components/list.js +122 -0
  220. package/dist/components/list.js.map +1 -0
  221. package/dist/components/marker.cjs +52 -0
  222. package/dist/components/marker.cjs.map +1 -0
  223. package/dist/components/marker.d.cts +29 -0
  224. package/dist/components/marker.d.ts +29 -0
  225. package/dist/components/marker.js +46 -0
  226. package/dist/components/marker.js.map +1 -0
  227. package/dist/components/message-scroller.cjs +73 -0
  228. package/dist/components/message-scroller.cjs.map +1 -0
  229. package/dist/components/message-scroller.d.cts +39 -0
  230. package/dist/components/message-scroller.d.ts +39 -0
  231. package/dist/components/message-scroller.js +62 -0
  232. package/dist/components/message-scroller.js.map +1 -0
  233. package/dist/components/message.cjs +60 -0
  234. package/dist/components/message.cjs.map +1 -0
  235. package/dist/components/message.d.cts +36 -0
  236. package/dist/components/message.d.ts +36 -0
  237. package/dist/components/message.js +52 -0
  238. package/dist/components/message.js.map +1 -0
  239. package/dist/components/metering-row.cjs +43 -0
  240. package/dist/components/metering-row.cjs.map +1 -0
  241. package/dist/components/metering-row.d.cts +32 -0
  242. package/dist/components/metering-row.d.ts +32 -0
  243. package/dist/components/metering-row.js +38 -0
  244. package/dist/components/metering-row.js.map +1 -0
  245. package/dist/components/money-saved-block.cjs +87 -0
  246. package/dist/components/money-saved-block.cjs.map +1 -0
  247. package/dist/components/money-saved-block.d.cts +57 -0
  248. package/dist/components/money-saved-block.d.ts +57 -0
  249. package/dist/components/money-saved-block.js +79 -0
  250. package/dist/components/money-saved-block.js.map +1 -0
  251. package/dist/components/number-flow.cjs +44 -0
  252. package/dist/components/number-flow.cjs.map +1 -0
  253. package/dist/components/number-flow.d.cts +4 -0
  254. package/dist/components/number-flow.d.ts +4 -0
  255. package/dist/components/number-flow.js +42 -0
  256. package/dist/components/number-flow.js.map +1 -0
  257. package/dist/components/on-off-button.cjs +36 -0
  258. package/dist/components/on-off-button.cjs.map +1 -0
  259. package/dist/components/on-off-button.d.cts +20 -0
  260. package/dist/components/on-off-button.d.ts +20 -0
  261. package/dist/components/on-off-button.js +34 -0
  262. package/dist/components/on-off-button.js.map +1 -0
  263. package/dist/components/onboarding-layout.cjs +68 -0
  264. package/dist/components/onboarding-layout.cjs.map +1 -0
  265. package/dist/components/onboarding-layout.d.cts +46 -0
  266. package/dist/components/onboarding-layout.d.ts +46 -0
  267. package/dist/components/onboarding-layout.js +60 -0
  268. package/dist/components/onboarding-layout.js.map +1 -0
  269. package/dist/components/page-header.cjs +50 -0
  270. package/dist/components/page-header.cjs.map +1 -0
  271. package/dist/components/page-header.d.cts +26 -0
  272. package/dist/components/page-header.d.ts +26 -0
  273. package/dist/components/page-header.js +44 -0
  274. package/dist/components/page-header.js.map +1 -0
  275. package/dist/components/page-spinner.cjs +19 -0
  276. package/dist/components/page-spinner.cjs.map +1 -0
  277. package/dist/components/page-spinner.d.cts +14 -0
  278. package/dist/components/page-spinner.d.ts +14 -0
  279. package/dist/components/page-spinner.js +17 -0
  280. package/dist/components/page-spinner.js.map +1 -0
  281. package/dist/components/period-tabs.cjs +79 -0
  282. package/dist/components/period-tabs.cjs.map +1 -0
  283. package/dist/components/period-tabs.d.cts +51 -0
  284. package/dist/components/period-tabs.d.ts +51 -0
  285. package/dist/components/period-tabs.js +73 -0
  286. package/dist/components/period-tabs.js.map +1 -0
  287. package/dist/components/popover.cjs +62 -0
  288. package/dist/components/popover.cjs.map +1 -0
  289. package/dist/components/popover.d.cts +29 -0
  290. package/dist/components/popover.d.ts +29 -0
  291. package/dist/components/popover.js +56 -0
  292. package/dist/components/popover.js.map +1 -0
  293. package/dist/components/power-history-chart.cjs +335 -0
  294. package/dist/components/power-history-chart.cjs.map +1 -0
  295. package/dist/components/power-history-chart.d.cts +63 -0
  296. package/dist/components/power-history-chart.d.ts +63 -0
  297. package/dist/components/power-history-chart.js +332 -0
  298. package/dist/components/power-history-chart.js.map +1 -0
  299. package/dist/components/power-history.cjs +115 -0
  300. package/dist/components/power-history.cjs.map +1 -0
  301. package/dist/components/power-history.d.cts +42 -0
  302. package/dist/components/power-history.d.ts +43 -0
  303. package/dist/components/power-history.js +114 -0
  304. package/dist/components/power-history.js.map +1 -0
  305. package/dist/components/power-network.cjs +530 -0
  306. package/dist/components/power-network.cjs.map +1 -0
  307. package/dist/components/power-network.d.cts +77 -0
  308. package/dist/components/power-network.d.ts +77 -0
  309. package/dist/components/power-network.js +523 -0
  310. package/dist/components/power-network.js.map +1 -0
  311. package/dist/components/progress.cjs +34 -0
  312. package/dist/components/progress.cjs.map +1 -0
  313. package/dist/components/progress.d.cts +17 -0
  314. package/dist/components/progress.d.ts +17 -0
  315. package/dist/components/progress.js +31 -0
  316. package/dist/components/progress.js.map +1 -0
  317. package/dist/components/radio-card-group.cjs +69 -0
  318. package/dist/components/radio-card-group.cjs.map +1 -0
  319. package/dist/components/radio-card-group.d.cts +21 -0
  320. package/dist/components/radio-card-group.d.ts +21 -0
  321. package/dist/components/radio-card-group.js +65 -0
  322. package/dist/components/radio-card-group.js.map +1 -0
  323. package/dist/components/radio.cjs +34 -0
  324. package/dist/components/radio.cjs.map +1 -0
  325. package/dist/components/radio.d.cts +21 -0
  326. package/dist/components/radio.d.ts +21 -0
  327. package/dist/components/radio.js +30 -0
  328. package/dist/components/radio.js.map +1 -0
  329. package/dist/components/reparent.cjs +55 -0
  330. package/dist/components/reparent.cjs.map +1 -0
  331. package/dist/components/reparent.d.cts +29 -0
  332. package/dist/components/reparent.d.ts +29 -0
  333. package/dist/components/reparent.js +49 -0
  334. package/dist/components/reparent.js.map +1 -0
  335. package/dist/components/sankey-chart.cjs +188 -0
  336. package/dist/components/sankey-chart.cjs.map +1 -0
  337. package/dist/components/sankey-chart.d.cts +66 -0
  338. package/dist/components/sankey-chart.d.ts +66 -0
  339. package/dist/components/sankey-chart.js +185 -0
  340. package/dist/components/sankey-chart.js.map +1 -0
  341. package/dist/components/schedule-editor.cjs +82 -0
  342. package/dist/components/schedule-editor.cjs.map +1 -0
  343. package/dist/components/schedule-editor.d.cts +25 -0
  344. package/dist/components/schedule-editor.d.ts +25 -0
  345. package/dist/components/schedule-editor.js +72 -0
  346. package/dist/components/schedule-editor.js.map +1 -0
  347. package/dist/components/schedule-list.cjs +110 -0
  348. package/dist/components/schedule-list.cjs.map +1 -0
  349. package/dist/components/schedule-list.d.cts +29 -0
  350. package/dist/components/schedule-list.d.ts +29 -0
  351. package/dist/components/schedule-list.js +99 -0
  352. package/dist/components/schedule-list.js.map +1 -0
  353. package/dist/components/scroll-area.cjs +53 -0
  354. package/dist/components/scroll-area.cjs.map +1 -0
  355. package/dist/components/scroll-area.d.cts +26 -0
  356. package/dist/components/scroll-area.d.ts +26 -0
  357. package/dist/components/scroll-area.js +44 -0
  358. package/dist/components/scroll-area.js.map +1 -0
  359. package/dist/components/segmented-control.cjs +44 -0
  360. package/dist/components/segmented-control.cjs.map +1 -0
  361. package/dist/components/segmented-control.d.cts +33 -0
  362. package/dist/components/segmented-control.d.ts +33 -0
  363. package/dist/components/segmented-control.js +40 -0
  364. package/dist/components/segmented-control.js.map +1 -0
  365. package/dist/components/select.cjs +136 -0
  366. package/dist/components/select.cjs.map +1 -0
  367. package/dist/components/select.d.cts +63 -0
  368. package/dist/components/select.d.ts +63 -0
  369. package/dist/components/select.js +124 -0
  370. package/dist/components/select.js.map +1 -0
  371. package/dist/components/separator.cjs +38 -0
  372. package/dist/components/separator.cjs.map +1 -0
  373. package/dist/components/separator.d.cts +13 -0
  374. package/dist/components/separator.d.ts +13 -0
  375. package/dist/components/separator.js +35 -0
  376. package/dist/components/separator.js.map +1 -0
  377. package/dist/components/series-legend.cjs +39 -0
  378. package/dist/components/series-legend.cjs.map +1 -0
  379. package/dist/components/series-legend.d.cts +31 -0
  380. package/dist/components/series-legend.d.ts +31 -0
  381. package/dist/components/series-legend.js +37 -0
  382. package/dist/components/series-legend.js.map +1 -0
  383. package/dist/components/sheet.cjs +102 -0
  384. package/dist/components/sheet.cjs.map +1 -0
  385. package/dist/components/sheet.d.cts +46 -0
  386. package/dist/components/sheet.d.ts +46 -0
  387. package/dist/components/sheet.js +90 -0
  388. package/dist/components/sheet.js.map +1 -0
  389. package/dist/components/skeleton.cjs +24 -0
  390. package/dist/components/skeleton.cjs.map +1 -0
  391. package/dist/components/skeleton.d.cts +24 -0
  392. package/dist/components/skeleton.d.ts +24 -0
  393. package/dist/components/skeleton.js +21 -0
  394. package/dist/components/skeleton.js.map +1 -0
  395. package/dist/components/slider.cjs +276 -0
  396. package/dist/components/slider.cjs.map +1 -0
  397. package/dist/components/slider.d.cts +150 -0
  398. package/dist/components/slider.d.ts +150 -0
  399. package/dist/components/slider.js +266 -0
  400. package/dist/components/slider.js.map +1 -0
  401. package/dist/components/smart-toggle-button.cjs +28 -0
  402. package/dist/components/smart-toggle-button.cjs.map +1 -0
  403. package/dist/components/smart-toggle-button.d.cts +18 -0
  404. package/dist/components/smart-toggle-button.d.ts +18 -0
  405. package/dist/components/smart-toggle-button.js +26 -0
  406. package/dist/components/smart-toggle-button.js.map +1 -0
  407. package/dist/components/solar-forecast-chart.cjs +106 -0
  408. package/dist/components/solar-forecast-chart.cjs.map +1 -0
  409. package/dist/components/solar-forecast-chart.d.cts +69 -0
  410. package/dist/components/solar-forecast-chart.d.ts +69 -0
  411. package/dist/components/solar-forecast-chart.js +100 -0
  412. package/dist/components/solar-forecast-chart.js.map +1 -0
  413. package/dist/components/sortable-list.cjs +69 -0
  414. package/dist/components/sortable-list.cjs.map +1 -0
  415. package/dist/components/sortable-list.d.cts +46 -0
  416. package/dist/components/sortable-list.d.ts +46 -0
  417. package/dist/components/sortable-list.js +67 -0
  418. package/dist/components/sortable-list.js.map +1 -0
  419. package/dist/components/spinner.cjs +42 -0
  420. package/dist/components/spinner.cjs.map +1 -0
  421. package/dist/components/spinner.d.cts +15 -0
  422. package/dist/components/spinner.d.ts +15 -0
  423. package/dist/components/spinner.js +39 -0
  424. package/dist/components/spinner.js.map +1 -0
  425. package/dist/components/stat-card.cjs +58 -0
  426. package/dist/components/stat-card.cjs.map +1 -0
  427. package/dist/components/stat-card.d.cts +36 -0
  428. package/dist/components/stat-card.d.ts +36 -0
  429. package/dist/components/stat-card.js +50 -0
  430. package/dist/components/stat-card.js.map +1 -0
  431. package/dist/components/stepper.cjs +79 -0
  432. package/dist/components/stepper.cjs.map +1 -0
  433. package/dist/components/stepper.d.cts +33 -0
  434. package/dist/components/stepper.d.ts +33 -0
  435. package/dist/components/stepper.js +76 -0
  436. package/dist/components/stepper.js.map +1 -0
  437. package/dist/components/switch.cjs +22 -0
  438. package/dist/components/switch.cjs.map +1 -0
  439. package/dist/components/switch.d.cts +28 -0
  440. package/dist/components/switch.d.ts +28 -0
  441. package/dist/components/switch.js +20 -0
  442. package/dist/components/switch.js.map +1 -0
  443. package/dist/components/tabs.cjs +175 -0
  444. package/dist/components/tabs.cjs.map +1 -0
  445. package/dist/components/tabs.d.cts +45 -0
  446. package/dist/components/tabs.d.ts +45 -0
  447. package/dist/components/tabs.js +167 -0
  448. package/dist/components/tabs.js.map +1 -0
  449. package/dist/components/theme.cjs +6 -0
  450. package/dist/components/theme.d.cts +38 -0
  451. package/dist/components/theme.d.ts +38 -0
  452. package/dist/components/theme.js +4 -0
  453. package/dist/components/thumbnail.cjs +54 -0
  454. package/dist/components/thumbnail.cjs.map +1 -0
  455. package/dist/components/thumbnail.d.cts +34 -0
  456. package/dist/components/thumbnail.d.ts +34 -0
  457. package/dist/components/thumbnail.js +51 -0
  458. package/dist/components/thumbnail.js.map +1 -0
  459. package/dist/components/time-picker.cjs +55 -0
  460. package/dist/components/time-picker.cjs.map +1 -0
  461. package/dist/components/time-picker.d.cts +41 -0
  462. package/dist/components/time-picker.d.ts +41 -0
  463. package/dist/components/time-picker.js +51 -0
  464. package/dist/components/time-picker.js.map +1 -0
  465. package/dist/components/toast.cjs +99 -0
  466. package/dist/components/toast.cjs.map +1 -0
  467. package/dist/components/toast.d.cts +18 -0
  468. package/dist/components/toast.d.ts +18 -0
  469. package/dist/components/toast.js +95 -0
  470. package/dist/components/toast.js.map +1 -0
  471. package/dist/components/tooltip.cjs +75 -0
  472. package/dist/components/tooltip.cjs.map +1 -0
  473. package/dist/components/tooltip.d.cts +47 -0
  474. package/dist/components/tooltip.d.ts +47 -0
  475. package/dist/components/tooltip.js +67 -0
  476. package/dist/components/tooltip.js.map +1 -0
  477. package/dist/components/typography.cjs +52 -0
  478. package/dist/components/typography.cjs.map +1 -0
  479. package/dist/components/typography.d.cts +32 -0
  480. package/dist/components/typography.d.ts +32 -0
  481. package/dist/components/typography.js +45 -0
  482. package/dist/components/typography.js.map +1 -0
  483. package/dist/hooks/use-container-width.cjs +22 -0
  484. package/dist/hooks/use-container-width.cjs.map +1 -0
  485. package/dist/hooks/use-container-width.d.cts +7 -0
  486. package/dist/hooks/use-container-width.d.ts +7 -0
  487. package/dist/hooks/use-container-width.js +20 -0
  488. package/dist/hooks/use-container-width.js.map +1 -0
  489. package/dist/icons/index.cjs +7 -0
  490. package/dist/icons/index.d.cts +4 -0
  491. package/dist/icons/index.d.ts +4 -0
  492. package/dist/icons/index.js +3 -0
  493. package/dist/icons/material-symbol.cjs +105 -0
  494. package/dist/icons/material-symbol.cjs.map +1 -0
  495. package/dist/icons/material-symbol.d.cts +23 -0
  496. package/dist/icons/material-symbol.d.ts +23 -0
  497. package/dist/icons/material-symbol.js +100 -0
  498. package/dist/icons/material-symbol.js.map +1 -0
  499. package/dist/input-box-variants-BMDdwvqg.cjs +40 -0
  500. package/dist/input-box-variants-BMDdwvqg.cjs.map +1 -0
  501. package/dist/input-box-variants-Dr1K7uYE.js +28 -0
  502. package/dist/input-box-variants-Dr1K7uYE.js.map +1 -0
  503. package/dist/number-flow-DMJouddg.d.cts +15 -0
  504. package/dist/number-flow-DSbucQ_K.d.ts +15 -0
  505. package/dist/styles/index.css +260 -0
  506. package/dist/styles/internal.css +5 -0
  507. package/dist/styles/material-symbol.css +22 -0
  508. package/dist/styles/spark-default.css +888 -0
  509. package/dist/styles/theme.css +620 -0
  510. package/dist/styles/utilities.css +557 -0
  511. package/dist/theme-C19BbKfO.js +574 -0
  512. package/dist/theme-C19BbKfO.js.map +1 -0
  513. package/dist/theme-CfFWrMEF.cjs +592 -0
  514. package/dist/theme-CfFWrMEF.cjs.map +1 -0
  515. package/dist/theme-types-DoROIXpi.d.ts +30 -0
  516. package/dist/theme-types-r20EJfEC.d.cts +30 -0
  517. package/dist/tones-DjgKOX3s.d.cts +8 -0
  518. package/dist/tones-DyCkL71h.d.ts +8 -0
  519. package/dist/utils/build-sankey-nodes.cjs +72 -0
  520. package/dist/utils/build-sankey-nodes.cjs.map +1 -0
  521. package/dist/utils/build-sankey-nodes.d.cts +27 -0
  522. package/dist/utils/build-sankey-nodes.d.ts +27 -0
  523. package/dist/utils/build-sankey-nodes.js +71 -0
  524. package/dist/utils/build-sankey-nodes.js.map +1 -0
  525. package/dist/utils/chars.cjs +18 -0
  526. package/dist/utils/chars.cjs.map +1 -0
  527. package/dist/utils/chars.d.cts +10 -0
  528. package/dist/utils/chars.d.ts +10 -0
  529. package/dist/utils/chars.js +14 -0
  530. package/dist/utils/chars.js.map +1 -0
  531. package/dist/utils/chart-scale.cjs +43 -0
  532. package/dist/utils/chart-scale.cjs.map +1 -0
  533. package/dist/utils/chart-scale.d.cts +22 -0
  534. package/dist/utils/chart-scale.d.ts +22 -0
  535. package/dist/utils/chart-scale.js +41 -0
  536. package/dist/utils/chart-scale.js.map +1 -0
  537. package/dist/utils/cn.cjs +10 -0
  538. package/dist/utils/cn.d.cts +4 -0
  539. package/dist/utils/cn.d.ts +4 -0
  540. package/dist/utils/cn.js +3 -0
  541. package/dist/utils/date-mask.cjs +45 -0
  542. package/dist/utils/date-mask.cjs.map +1 -0
  543. package/dist/utils/date-mask.d.cts +17 -0
  544. package/dist/utils/date-mask.d.ts +17 -0
  545. package/dist/utils/date-mask.js +41 -0
  546. package/dist/utils/date-mask.js.map +1 -0
  547. package/dist/utils/format.cjs +57 -0
  548. package/dist/utils/format.cjs.map +1 -0
  549. package/dist/utils/format.d.cts +23 -0
  550. package/dist/utils/format.d.ts +23 -0
  551. package/dist/utils/format.js +47 -0
  552. package/dist/utils/format.js.map +1 -0
  553. package/package.json +78 -63
  554. package/dist/index.cjs +0 -1631
  555. package/dist/index.cjs.map +0 -1
  556. package/dist/index.css +0 -1
  557. package/dist/index.d.cts +0 -299
  558. package/dist/index.d.ts +0 -299
  559. package/dist/index.js +0 -1518
  560. package/dist/index.js.map +0 -1
  561. package/dist/styles.js +0 -1
@@ -0,0 +1,88 @@
1
+ "use client";
2
+
3
+ //#region src/components/bar-chart.d.ts
4
+ type BarChartCategory = string | number;
5
+ interface BarChartSeries<TDatum> {
6
+ key: string;
7
+ label: string;
8
+ color: string;
9
+ hoverFill?: string;
10
+ getValue: (datum: TDatum) => number;
11
+ }
12
+ interface BarChartLineSeries<TDatum> {
13
+ key: string;
14
+ label: string;
15
+ color: string;
16
+ /** `null` gaps break the line (e.g. hours without a reading). */
17
+ getValue: (datum: TDatum) => number | null;
18
+ /** Own y-domain for this line (e.g. `[0, 100]` for a percentage). Defaults to the bar scale. */
19
+ domain?: [number, number];
20
+ /** Start hidden; the user can enable the line from the legend. */
21
+ hiddenByDefault?: boolean;
22
+ /** Formats this line's value in the hover tooltip. Defaults to `formatValue`. */
23
+ formatValue?: (value: number) => string;
24
+ strokeDasharray?: string;
25
+ }
26
+ interface BarChartProps<TDatum> {
27
+ data: TDatum[];
28
+ series: BarChartSeries<TDatum>[];
29
+ /** Line overlays drawn on top of the bars, toggleable from the legend. */
30
+ lines?: BarChartLineSeries<TDatum>[];
31
+ getCategory: (datum: TDatum) => BarChartCategory;
32
+ /** Full ordered set of categories on the x-axis. Defaults to `data.map(getCategory)`. */
33
+ categories?: BarChartCategory[];
34
+ /** Subset of categories that should render an x-axis label. Defaults to every category. */
35
+ categoryTicks?: BarChartCategory[];
36
+ formatCategory?: (category: BarChartCategory) => string;
37
+ /** Formats the hovered category in the tooltip header. Defaults to `formatCategory`. */
38
+ formatTooltipCategory?: (category: BarChartCategory) => string;
39
+ highlightedCategory?: BarChartCategory;
40
+ showHighlightLine?: boolean;
41
+ /**
42
+ * Horizontal reference line drawn across the plot at a given y-value.
43
+ * Useful for thresholds (e.g. price ceiling).
44
+ */
45
+ referenceLine?: {
46
+ value: number;
47
+ label?: string;
48
+ color?: string;
49
+ };
50
+ title?: string;
51
+ yAxisUnit?: string;
52
+ height?: number;
53
+ /**
54
+ * Override how the total value (sum of focused or all categories) is
55
+ * rendered. `animated` is false while a bar is focused (hover), so an
56
+ * animated total can snap between hovered buckets instead of re-firing a
57
+ * tween on every bar the pointer crosses.
58
+ */
59
+ renderTotal?: (value: number, animated: boolean) => React.ReactNode;
60
+ /** Format function used when `renderTotal` is not provided. */
61
+ formatTotal?: (value: number) => string;
62
+ /** Formats per-series values in the hover tooltip. Defaults to `formatTotal`. */
63
+ formatValue?: (value: number) => string;
64
+ className?: string;
65
+ }
66
+ declare function BarChart<TDatum>({
67
+ data,
68
+ series,
69
+ lines,
70
+ getCategory,
71
+ categories,
72
+ categoryTicks,
73
+ formatCategory,
74
+ formatTooltipCategory,
75
+ highlightedCategory,
76
+ showHighlightLine,
77
+ referenceLine,
78
+ title,
79
+ yAxisUnit,
80
+ height,
81
+ renderTotal,
82
+ formatTotal,
83
+ formatValue,
84
+ className
85
+ }: BarChartProps<TDatum>): React.ReactElement;
86
+ //#endregion
87
+ export { BarChart, BarChartCategory, BarChartLineSeries, BarChartProps, BarChartSeries };
88
+ //# sourceMappingURL=bar-chart.d.cts.map
@@ -0,0 +1,88 @@
1
+ "use client";
2
+
3
+ //#region src/components/bar-chart.d.ts
4
+ type BarChartCategory = string | number;
5
+ interface BarChartSeries<TDatum> {
6
+ key: string;
7
+ label: string;
8
+ color: string;
9
+ hoverFill?: string;
10
+ getValue: (datum: TDatum) => number;
11
+ }
12
+ interface BarChartLineSeries<TDatum> {
13
+ key: string;
14
+ label: string;
15
+ color: string;
16
+ /** `null` gaps break the line (e.g. hours without a reading). */
17
+ getValue: (datum: TDatum) => number | null;
18
+ /** Own y-domain for this line (e.g. `[0, 100]` for a percentage). Defaults to the bar scale. */
19
+ domain?: [number, number];
20
+ /** Start hidden; the user can enable the line from the legend. */
21
+ hiddenByDefault?: boolean;
22
+ /** Formats this line's value in the hover tooltip. Defaults to `formatValue`. */
23
+ formatValue?: (value: number) => string;
24
+ strokeDasharray?: string;
25
+ }
26
+ interface BarChartProps<TDatum> {
27
+ data: TDatum[];
28
+ series: BarChartSeries<TDatum>[];
29
+ /** Line overlays drawn on top of the bars, toggleable from the legend. */
30
+ lines?: BarChartLineSeries<TDatum>[];
31
+ getCategory: (datum: TDatum) => BarChartCategory;
32
+ /** Full ordered set of categories on the x-axis. Defaults to `data.map(getCategory)`. */
33
+ categories?: BarChartCategory[];
34
+ /** Subset of categories that should render an x-axis label. Defaults to every category. */
35
+ categoryTicks?: BarChartCategory[];
36
+ formatCategory?: (category: BarChartCategory) => string;
37
+ /** Formats the hovered category in the tooltip header. Defaults to `formatCategory`. */
38
+ formatTooltipCategory?: (category: BarChartCategory) => string;
39
+ highlightedCategory?: BarChartCategory;
40
+ showHighlightLine?: boolean;
41
+ /**
42
+ * Horizontal reference line drawn across the plot at a given y-value.
43
+ * Useful for thresholds (e.g. price ceiling).
44
+ */
45
+ referenceLine?: {
46
+ value: number;
47
+ label?: string;
48
+ color?: string;
49
+ };
50
+ title?: string;
51
+ yAxisUnit?: string;
52
+ height?: number;
53
+ /**
54
+ * Override how the total value (sum of focused or all categories) is
55
+ * rendered. `animated` is false while a bar is focused (hover), so an
56
+ * animated total can snap between hovered buckets instead of re-firing a
57
+ * tween on every bar the pointer crosses.
58
+ */
59
+ renderTotal?: (value: number, animated: boolean) => React.ReactNode;
60
+ /** Format function used when `renderTotal` is not provided. */
61
+ formatTotal?: (value: number) => string;
62
+ /** Formats per-series values in the hover tooltip. Defaults to `formatTotal`. */
63
+ formatValue?: (value: number) => string;
64
+ className?: string;
65
+ }
66
+ declare function BarChart<TDatum>({
67
+ data,
68
+ series,
69
+ lines,
70
+ getCategory,
71
+ categories,
72
+ categoryTicks,
73
+ formatCategory,
74
+ formatTooltipCategory,
75
+ highlightedCategory,
76
+ showHighlightLine,
77
+ referenceLine,
78
+ title,
79
+ yAxisUnit,
80
+ height,
81
+ renderTotal,
82
+ formatTotal,
83
+ formatValue,
84
+ className
85
+ }: BarChartProps<TDatum>): React.ReactElement;
86
+ //#endregion
87
+ export { BarChart, BarChartCategory, BarChartLineSeries, BarChartProps, BarChartSeries };
88
+ //# sourceMappingURL=bar-chart.d.ts.map
@@ -0,0 +1,518 @@
1
+ "use client";
2
+ import { cn } from "../utils/cn.js";
3
+ import { localeNumberFormat } from "../utils/format.js";
4
+ import { buildYAxisScale, formatYAxisTick } from "../utils/chart-scale.js";
5
+ import { ChartTooltipCard, clampTooltipPosition, useMeasuredSize } from "./chart.js";
6
+ import { SeriesLegend } from "./series-legend.js";
7
+ import { SectionTitle } from "./typography.js";
8
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
9
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
+ import { localPoint } from "@visx/event";
11
+ import { Group } from "@visx/group";
12
+ import { scaleBand, scaleLinear, scaleOrdinal } from "@visx/scale";
13
+ import { BarStack } from "@visx/shape";
14
+ //#region src/components/bar-chart.tsx
15
+ const defaultTotalFormat = localeNumberFormat();
16
+ const PADDING_TOP = 20;
17
+ const PADDING_BOTTOM = 28;
18
+ const HOVER_FADE_MS = 200;
19
+ const FOCUS_TRANSITION_MS = 180;
20
+ const DEFAULT_HEIGHT = 220;
21
+ const BAR_RADIUS = 2;
22
+ const Y_AXIS_GUTTER = 34;
23
+ function buildBarPath(x, y, width, height, radius, roundTop, roundBottom) {
24
+ const r = Math.max(0, Math.min(radius, width / 2, height / 2));
25
+ if (r === 0 || !roundTop && !roundBottom) return `M ${x} ${y} H ${x + width} V ${y + height} H ${x} Z`;
26
+ const tl = roundTop ? r : 0;
27
+ const tr = roundTop ? r : 0;
28
+ const br = roundBottom ? r : 0;
29
+ const bl = roundBottom ? r : 0;
30
+ return [
31
+ `M ${x + tl} ${y}`,
32
+ `H ${x + width - tr}`,
33
+ tr > 0 ? `Q ${x + width} ${y} ${x + width} ${y + tr}` : `L ${x + width} ${y}`,
34
+ `V ${y + height - br}`,
35
+ br > 0 ? `Q ${x + width} ${y + height} ${x + width - br} ${y + height}` : `L ${x + width} ${y + height}`,
36
+ `H ${x + bl}`,
37
+ bl > 0 ? `Q ${x} ${y + height} ${x} ${y + height - bl}` : `L ${x} ${y + height}`,
38
+ `V ${y + tl}`,
39
+ tl > 0 ? `Q ${x} ${y} ${x + tl} ${y}` : `L ${x} ${y}`,
40
+ "Z"
41
+ ].join(" ");
42
+ }
43
+ function BarStackLayer({ stackData, series, seriesByKey, xScale, yScale, colorScale }) {
44
+ return /* @__PURE__ */ jsx(BarStack, {
45
+ data: stackData,
46
+ keys: series.map((entry) => entry.key),
47
+ x: (record) => record.__category,
48
+ value: (record, key) => record.__values[key] ?? 0,
49
+ xScale,
50
+ yScale,
51
+ color: colorScale,
52
+ offset: "diverging",
53
+ children: (barStacks) => barStacks.map((barStack) => barStack.bars.map((bar) => {
54
+ const values = bar.bar.data.__values;
55
+ const segmentValue = values[barStack.key] ?? 0;
56
+ if (segmentValue === 0) return null;
57
+ const strokeColor = seriesByKey.get(barStack.key)?.color ?? bar.color;
58
+ const fillColor = strokeColor;
59
+ const positiveKeys = series.map((entry) => entry.key).filter((key) => (values[key] ?? 0) > 0);
60
+ const negativeKeys = series.map((entry) => entry.key).filter((key) => (values[key] ?? 0) < 0);
61
+ const roundTop = segmentValue > 0 && positiveKeys[positiveKeys.length - 1] === barStack.key;
62
+ const roundBottom = segmentValue > 0 ? positiveKeys[0] === barStack.key : negativeKeys[negativeKeys.length - 1] === barStack.key;
63
+ const top = bar.height < 0 ? bar.y + bar.height : bar.y;
64
+ const barHeight = Math.abs(bar.height);
65
+ return /* @__PURE__ */ jsx("path", {
66
+ d: buildBarPath(bar.x, top, bar.width, Math.max(0, barHeight), BAR_RADIUS, roundTop, roundBottom),
67
+ fill: fillColor,
68
+ stroke: strokeColor,
69
+ strokeWidth: 1,
70
+ style: { transition: "fill 180ms ease" }
71
+ }, `bar-${barStack.index}-${bar.index}`);
72
+ }))
73
+ });
74
+ }
75
+ function FocusBorder({ category, visible, stackData, series, xScale, yScale }) {
76
+ const x = xScale(category);
77
+ const datum = stackData.find((entry) => entry.__category === category);
78
+ if (x === void 0 || !datum) return null;
79
+ if (!series.some((entry) => (datum.__values[entry.key] ?? 0) !== 0)) return null;
80
+ const topY = PADDING_TOP;
81
+ const bottomY = yScale(series.reduce((sum, entry) => sum + Math.min(0, datum.__values[entry.key] ?? 0), 0));
82
+ const borderPaddingX = 4;
83
+ const borderPaddingY = 3;
84
+ const borderXRaw = x - borderPaddingX;
85
+ const borderY = topY - borderPaddingY;
86
+ const borderWidthRaw = xScale.bandwidth() + borderPaddingX * 2;
87
+ const [rangeStart, rangeEnd] = xScale.range();
88
+ const minX = Math.min(rangeStart, rangeEnd);
89
+ const maxX = Math.max(rangeStart, rangeEnd);
90
+ const borderX = Math.max(minX, borderXRaw);
91
+ const borderRight = Math.min(maxX, borderXRaw + borderWidthRaw);
92
+ const borderWidth = Math.max(0, borderRight - borderX);
93
+ const borderHeight = Math.max(1, bottomY - topY + borderPaddingY * 2);
94
+ if (borderWidth <= 0) return null;
95
+ return /* @__PURE__ */ jsx("rect", {
96
+ x: borderX,
97
+ y: borderY,
98
+ width: borderWidth,
99
+ height: borderHeight,
100
+ rx: 6,
101
+ fill: "var(--spark-a2)",
102
+ stroke: "var(--spark-a9)",
103
+ strokeWidth: 2,
104
+ pointerEvents: "none",
105
+ style: {
106
+ opacity: visible ? 1 : 0,
107
+ transition: `x ${FOCUS_TRANSITION_MS}ms ease, y ${FOCUS_TRANSITION_MS}ms ease, width ${FOCUS_TRANSITION_MS}ms ease, height ${FOCUS_TRANSITION_MS}ms ease, opacity ${FOCUS_TRANSITION_MS}ms ease`
108
+ }
109
+ });
110
+ }
111
+ function InteractionLayer({ xDomain, activeCategories, xScale, height, onHoverChange }) {
112
+ const bandwidth = xScale.bandwidth();
113
+ const [rangeStart, rangeEnd] = xScale.range();
114
+ const minX = Math.min(rangeStart, rangeEnd);
115
+ const maxX = Math.max(rangeStart, rangeEnd);
116
+ const handleMove = (event) => {
117
+ const point = localPoint(event);
118
+ if (!point) return;
119
+ let nearest = null;
120
+ let best = Infinity;
121
+ for (const category of xDomain) {
122
+ if (!activeCategories.has(category)) continue;
123
+ const x = xScale(category);
124
+ if (x === void 0) continue;
125
+ const distance = Math.abs(x + bandwidth / 2 - point.x);
126
+ if (distance < best) {
127
+ best = distance;
128
+ nearest = category;
129
+ }
130
+ }
131
+ if (nearest !== null) onHoverChange(nearest);
132
+ };
133
+ return /* @__PURE__ */ jsx("rect", {
134
+ x: minX,
135
+ y: PADDING_TOP,
136
+ width: Math.max(0, maxX - minX),
137
+ height: height - PADDING_TOP - PADDING_BOTTOM,
138
+ fill: "transparent",
139
+ onMouseMove: handleMove,
140
+ onMouseLeave: () => onHoverChange(null),
141
+ onTouchMove: handleMove,
142
+ onTouchEnd: () => onHoverChange(null)
143
+ });
144
+ }
145
+ function CategoryTicks({ ticks, xScale, height, formatCategory }) {
146
+ return /* @__PURE__ */ jsx(Fragment, { children: ticks.map((category) => {
147
+ const x = xScale(category);
148
+ if (x === void 0) return null;
149
+ return /* @__PURE__ */ jsx("text", {
150
+ x: x + xScale.bandwidth() / 2,
151
+ y: height - PADDING_BOTTOM + 16,
152
+ textAnchor: "middle",
153
+ fill: "var(--gray-a11)",
154
+ fontSize: 10,
155
+ children: formatCategory(category)
156
+ }, `tick-${String(category)}`);
157
+ }) });
158
+ }
159
+ function defaultFormatTotal(value) {
160
+ return defaultTotalFormat.format(value);
161
+ }
162
+ function BarChart({ data, series, lines, getCategory, categories, categoryTicks, formatCategory = (category) => String(category), formatTooltipCategory = formatCategory, highlightedCategory, showHighlightLine = false, referenceLine, title, yAxisUnit, height = DEFAULT_HEIGHT, renderTotal, formatTotal = defaultFormatTotal, formatValue, className }) {
163
+ const containerRef = useRef(null);
164
+ const [width, setWidth] = useState(0);
165
+ const [hoveredCategory, setHoveredCategory] = useState(null);
166
+ const [trailingHoverLabel, setTrailingHoverLabel] = useState(null);
167
+ const [hiddenSeries, setHiddenSeries] = useState(() => new Set((lines ?? []).filter((line) => line.hiddenByDefault).map((line) => line.key)));
168
+ const toggleSeries = useCallback((id) => {
169
+ setHiddenSeries((prev) => {
170
+ const next = new Set(prev);
171
+ if (next.has(id)) next.delete(id);
172
+ else next.add(id);
173
+ return next;
174
+ });
175
+ }, []);
176
+ useEffect(() => {
177
+ const element = containerRef.current;
178
+ if (!element) return;
179
+ const resizeObserver = new ResizeObserver((entries) => {
180
+ const entry = entries[0];
181
+ if (!entry) return;
182
+ setWidth(entry.contentRect.width);
183
+ });
184
+ resizeObserver.observe(element);
185
+ return () => {
186
+ resizeObserver.disconnect();
187
+ };
188
+ }, []);
189
+ const seriesByKey = useMemo(() => {
190
+ const map = /* @__PURE__ */ new Map();
191
+ for (const entry of series) map.set(entry.key, entry);
192
+ return map;
193
+ }, [series]);
194
+ const stackData = useMemo(() => data.map((datum) => {
195
+ const values = {};
196
+ for (const entry of series) values[entry.key] = hiddenSeries.has(entry.key) ? 0 : entry.getValue(datum);
197
+ return {
198
+ __category: getCategory(datum),
199
+ __values: values
200
+ };
201
+ }), [
202
+ data,
203
+ getCategory,
204
+ series,
205
+ hiddenSeries
206
+ ]);
207
+ const yMax = useMemo(() => Math.max(1, referenceLine?.value ?? 0, ...stackData.map((record) => series.reduce((sum, entry) => sum + Math.max(0, record.__values[entry.key] ?? 0), 0))), [
208
+ referenceLine,
209
+ series,
210
+ stackData
211
+ ]);
212
+ const yMin = useMemo(() => Math.min(0, ...stackData.map((record) => series.reduce((sum, entry) => sum + Math.min(0, record.__values[entry.key] ?? 0), 0))), [series, stackData]);
213
+ const xDomain = useMemo(() => categories ?? stackData.map((record) => record.__category), [categories, stackData]);
214
+ const xScale = useMemo(() => scaleBand({
215
+ domain: xDomain,
216
+ range: [Y_AXIS_GUTTER, Math.max(Y_AXIS_GUTTER, width)],
217
+ padding: .32
218
+ }), [xDomain, width]);
219
+ const yScale = useMemo(() => scaleLinear({
220
+ domain: [yMin, yMax],
221
+ range: [height - PADDING_BOTTOM, PADDING_TOP]
222
+ }), [
223
+ height,
224
+ yMax,
225
+ yMin
226
+ ]);
227
+ const colorScale = useMemo(() => scaleOrdinal({
228
+ domain: series.map((entry) => entry.key),
229
+ range: series.map((entry) => entry.color)
230
+ }), [series]);
231
+ const linePaths = useMemo(() => {
232
+ if (!lines || width === 0) return [];
233
+ return lines.filter((line) => !hiddenSeries.has(line.key)).map((line) => {
234
+ const lineScale = line.domain ? scaleLinear({
235
+ domain: line.domain,
236
+ range: [height - PADDING_BOTTOM, PADDING_TOP]
237
+ }) : yScale;
238
+ const segments = [];
239
+ let previous = null;
240
+ for (const datum of data) {
241
+ const x = xScale(getCategory(datum));
242
+ const value = line.getValue(datum);
243
+ if (x === void 0 || value === null || !Number.isFinite(value)) {
244
+ previous = null;
245
+ continue;
246
+ }
247
+ const point = {
248
+ x: x + xScale.bandwidth() / 2,
249
+ y: lineScale(value)
250
+ };
251
+ segments.push(previous === null ? `M ${point.x} ${point.y}` : `L ${point.x} ${point.y}`);
252
+ previous = point;
253
+ }
254
+ return {
255
+ key: line.key,
256
+ d: segments.join(" "),
257
+ color: line.color,
258
+ strokeDasharray: line.strokeDasharray ?? "5 4"
259
+ };
260
+ }).filter((path) => path.d !== "");
261
+ }, [
262
+ lines,
263
+ hiddenSeries,
264
+ data,
265
+ getCategory,
266
+ xScale,
267
+ yScale,
268
+ height,
269
+ width
270
+ ]);
271
+ const stackCategorySet = useMemo(() => new Set(stackData.map((record) => record.__category)), [stackData]);
272
+ const lastFocusCategoryRef = useRef(null);
273
+ if (hoveredCategory !== null) lastFocusCategoryRef.current = hoveredCategory;
274
+ const focusCategory = lastFocusCategoryRef.current;
275
+ const focused = useMemo(() => hoveredCategory === null ? null : stackData.find((record) => record.__category === hoveredCategory) ?? null, [hoveredCategory, stackData]);
276
+ const totalValue = useMemo(() => {
277
+ if (focused) return series.reduce((sum, entry) => sum + Math.max(0, focused.__values[entry.key] ?? 0), 0);
278
+ return stackData.reduce((sum, record) => sum + series.reduce((s, entry) => s + Math.max(0, record.__values[entry.key] ?? 0), 0), 0);
279
+ }, [
280
+ focused,
281
+ series,
282
+ stackData
283
+ ]);
284
+ const hoverLabel = focused ? formatTooltipCategory(focused.__category) : null;
285
+ useEffect(() => {
286
+ if (hoverLabel) {
287
+ setTrailingHoverLabel(hoverLabel);
288
+ return;
289
+ }
290
+ const timeoutId = window.setTimeout(() => {
291
+ setTrailingHoverLabel(null);
292
+ }, HOVER_FADE_MS);
293
+ return () => {
294
+ window.clearTimeout(timeoutId);
295
+ };
296
+ }, [hoverLabel]);
297
+ const ticks = categoryTicks ?? xDomain;
298
+ const yTicks = useMemo(() => buildYAxisScale(yMin, yMax).ticks, [yMin, yMax]);
299
+ const highlightX = useMemo(() => {
300
+ if (!showHighlightLine || highlightedCategory === void 0) return null;
301
+ const x = xScale(highlightedCategory);
302
+ if (x === void 0) return null;
303
+ return x + xScale.bandwidth() / 2;
304
+ }, [
305
+ highlightedCategory,
306
+ showHighlightLine,
307
+ xScale
308
+ ]);
309
+ const focusedDatum = useMemo(() => hoveredCategory === null ? null : data.find((datum) => getCategory(datum) === hoveredCategory) ?? null, [
310
+ hoveredCategory,
311
+ data,
312
+ getCategory
313
+ ]);
314
+ const barStackLayer = useMemo(() => /* @__PURE__ */ jsx(BarStackLayer, {
315
+ stackData,
316
+ series,
317
+ seriesByKey,
318
+ xScale,
319
+ yScale,
320
+ colorScale
321
+ }), [
322
+ stackData,
323
+ series,
324
+ seriesByKey,
325
+ xScale,
326
+ yScale,
327
+ colorScale
328
+ ]);
329
+ const fmtTooltipValue = formatValue ?? formatTotal;
330
+ const tooltipRows = focused ? [...series.filter((entry) => (focused.__values[entry.key] ?? 0) !== 0).map((entry) => ({
331
+ key: entry.key,
332
+ label: entry.label,
333
+ color: entry.color,
334
+ value: fmtTooltipValue(Math.abs(focused.__values[entry.key] ?? 0))
335
+ })), ...(lines ?? []).filter((line) => !hiddenSeries.has(line.key)).flatMap((line) => {
336
+ const value = focusedDatum === null ? null : line.getValue(focusedDatum);
337
+ if (value === null || !Number.isFinite(value)) return [];
338
+ return [{
339
+ key: line.key,
340
+ label: line.label,
341
+ color: line.color,
342
+ value: (line.formatValue ?? fmtTooltipValue)(value)
343
+ }];
344
+ })] : [];
345
+ const tooltipActive = tooltipRows.length > 0;
346
+ const anchorX = focusCategory !== null ? (xScale(focusCategory) ?? 0) + xScale.bandwidth() / 2 : 0;
347
+ const anchorY = yScale(totalValue);
348
+ const [tooltipRef, tooltipSize] = useMeasuredSize();
349
+ const tooltipPos = clampTooltipPosition({
350
+ anchorX,
351
+ anchorY,
352
+ width,
353
+ height,
354
+ tipWidth: tooltipSize.width,
355
+ tipHeight: tooltipSize.height
356
+ });
357
+ return /* @__PURE__ */ jsxs("div", {
358
+ className: cn("flex w-full flex-col", className),
359
+ children: [
360
+ /* @__PURE__ */ jsxs("div", {
361
+ className: "flex items-baseline justify-between",
362
+ children: [title && /* @__PURE__ */ jsx(SectionTitle, { children: title }), /* @__PURE__ */ jsx("span", {
363
+ className: "tabular-nums",
364
+ children: renderTotal ? renderTotal(totalValue, focused === null) : /* @__PURE__ */ jsx("span", {
365
+ className: "text-base font-bold text-gray tabular-nums",
366
+ children: formatTotal(totalValue)
367
+ })
368
+ })]
369
+ }),
370
+ /* @__PURE__ */ jsxs("div", {
371
+ className: "flex min-h-5 items-baseline justify-between gap-4",
372
+ children: [/* @__PURE__ */ jsx(SeriesLegend, {
373
+ items: [...series.map((entry) => ({
374
+ id: entry.key,
375
+ label: entry.label,
376
+ color: entry.color
377
+ })), ...(lines ?? []).map((line) => ({
378
+ id: line.key,
379
+ label: line.label,
380
+ color: line.color,
381
+ marker: "dashed-line"
382
+ }))],
383
+ hiddenIds: hiddenSeries,
384
+ onToggle: toggleSeries,
385
+ className: "gap-y-1"
386
+ }), /* @__PURE__ */ jsx("span", {
387
+ className: cn("text-xs text-gray-light transition-opacity duration-200", hoverLabel ? "opacity-100" : "opacity-0"),
388
+ children: trailingHoverLabel ?? " "
389
+ })]
390
+ }),
391
+ /* @__PURE__ */ jsxs("div", {
392
+ ref: containerRef,
393
+ className: "relative mt-2 w-full",
394
+ style: { height },
395
+ children: [/* @__PURE__ */ jsx("div", {
396
+ ref: tooltipRef,
397
+ className: "pointer-events-none absolute z-10",
398
+ style: {
399
+ left: tooltipPos.left,
400
+ top: tooltipPos.top,
401
+ opacity: tooltipActive ? 1 : 0,
402
+ transition: "left 140ms ease-out, top 140ms ease-out, opacity 140ms ease-out"
403
+ },
404
+ children: focusCategory !== null && /* @__PURE__ */ jsx(ChartTooltipCard, {
405
+ label: formatTooltipCategory(focusCategory),
406
+ rows: tooltipRows
407
+ })
408
+ }), width > 0 && /* @__PURE__ */ jsxs("svg", {
409
+ width,
410
+ height,
411
+ children: [
412
+ /* @__PURE__ */ jsx("line", {
413
+ x1: Y_AXIS_GUTTER,
414
+ x2: Y_AXIS_GUTTER,
415
+ y1: PADDING_TOP,
416
+ y2: height - PADDING_BOTTOM,
417
+ stroke: "var(--gray-a6)",
418
+ strokeWidth: 1
419
+ }),
420
+ yTicks.map((tick, index) => {
421
+ const y = yScale(tick);
422
+ const hideTickLabel = yAxisUnit !== void 0 && index === yTicks.length - 1;
423
+ return /* @__PURE__ */ jsxs("g", { children: [!hideTickLabel && /* @__PURE__ */ jsx("line", {
424
+ x1: Y_AXIS_GUTTER - 4,
425
+ x2: Y_AXIS_GUTTER,
426
+ y1: y,
427
+ y2: y,
428
+ stroke: "var(--gray-a8)",
429
+ strokeWidth: 1
430
+ }), !hideTickLabel && /* @__PURE__ */ jsx("text", {
431
+ x: Y_AXIS_GUTTER - 7,
432
+ y: y + 3,
433
+ textAnchor: "end",
434
+ fill: "var(--gray-a11)",
435
+ fontSize: 10,
436
+ children: formatYAxisTick(tick)
437
+ })] }, `y-tick-${tick}`);
438
+ }),
439
+ yAxisUnit && /* @__PURE__ */ jsx("text", {
440
+ x: 0,
441
+ y: PADDING_TOP - 6,
442
+ textAnchor: "start",
443
+ fill: "var(--gray-a11)",
444
+ fontSize: 10,
445
+ fontWeight: 600,
446
+ children: yAxisUnit
447
+ }),
448
+ highlightX !== null && /* @__PURE__ */ jsx("line", {
449
+ x1: highlightX,
450
+ x2: highlightX,
451
+ y1: PADDING_TOP,
452
+ y2: height - PADDING_BOTTOM,
453
+ stroke: "var(--spark-a9)",
454
+ strokeWidth: 1.5,
455
+ strokeDasharray: "5 4",
456
+ pointerEvents: "none"
457
+ }),
458
+ /* @__PURE__ */ jsx("line", {
459
+ x1: Y_AXIS_GUTTER,
460
+ x2: width,
461
+ y1: yScale(0),
462
+ y2: yScale(0),
463
+ stroke: "var(--gray-a5)",
464
+ strokeWidth: 1
465
+ }),
466
+ /* @__PURE__ */ jsxs(Group, { children: [
467
+ focusCategory !== null && /* @__PURE__ */ jsx(FocusBorder, {
468
+ category: focusCategory,
469
+ visible: hoveredCategory !== null,
470
+ stackData,
471
+ series,
472
+ xScale,
473
+ yScale
474
+ }),
475
+ barStackLayer,
476
+ referenceLine && /* @__PURE__ */ jsx("line", {
477
+ x1: Y_AXIS_GUTTER,
478
+ x2: width,
479
+ y1: yScale(referenceLine.value),
480
+ y2: yScale(referenceLine.value),
481
+ stroke: referenceLine.color ?? "var(--gray-a11)",
482
+ strokeWidth: 1.5,
483
+ pointerEvents: "none"
484
+ }),
485
+ linePaths.map((path) => /* @__PURE__ */ jsx("path", {
486
+ d: path.d,
487
+ fill: "none",
488
+ stroke: path.color,
489
+ strokeWidth: 1.5,
490
+ strokeDasharray: path.strokeDasharray,
491
+ strokeLinecap: "round",
492
+ strokeLinejoin: "round",
493
+ pointerEvents: "none"
494
+ }, `line-${path.key}`))
495
+ ] }),
496
+ /* @__PURE__ */ jsx(InteractionLayer, {
497
+ xDomain,
498
+ activeCategories: stackCategorySet,
499
+ xScale,
500
+ height,
501
+ onHoverChange: setHoveredCategory
502
+ }),
503
+ /* @__PURE__ */ jsx(CategoryTicks, {
504
+ ticks,
505
+ xScale,
506
+ height,
507
+ formatCategory
508
+ })
509
+ ]
510
+ })]
511
+ })
512
+ ]
513
+ });
514
+ }
515
+ //#endregion
516
+ export { BarChart };
517
+
518
+ //# sourceMappingURL=bar-chart.js.map