@eifi1/ui-kit 0.11.0 → 0.13.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 (397) hide show
  1. package/README.md +59 -34
  2. package/dist/chart.d.ts +3 -1
  3. package/dist/chart.js +2 -0
  4. package/dist/chart.js.map +1 -1
  5. package/dist/components/account-settings-labels.d.ts +105 -0
  6. package/dist/components/account-settings-labels.js +81 -0
  7. package/dist/components/account-settings-labels.js.map +1 -0
  8. package/dist/components/account-settings.d.ts +36 -52
  9. package/dist/components/account-settings.js +44 -8
  10. package/dist/components/account-settings.js.map +1 -1
  11. package/dist/components/amount-input.d.ts +40 -4
  12. package/dist/components/amount-input.js +50 -12
  13. package/dist/components/amount-input.js.map +1 -1
  14. package/dist/components/authed-image.d.ts +68 -0
  15. package/dist/components/authed-image.js +117 -0
  16. package/dist/components/authed-image.js.map +1 -0
  17. package/dist/components/breadcrumbs.d.ts +2 -1
  18. package/dist/components/breadcrumbs.js +5 -2
  19. package/dist/components/breadcrumbs.js.map +1 -1
  20. package/dist/components/bulk-action-bar.d.ts +10 -2
  21. package/dist/components/bulk-action-bar.js.map +1 -1
  22. package/dist/components/button-group.d.ts +51 -2
  23. package/dist/components/button-group.js +5 -1
  24. package/dist/components/button-group.js.map +1 -1
  25. package/dist/components/calculator.d.ts +15 -4
  26. package/dist/components/calendar-heatmap.d.ts +41 -3
  27. package/dist/components/calendar-heatmap.js +48 -7
  28. package/dist/components/calendar-heatmap.js.map +1 -1
  29. package/dist/components/chart.js +14 -8
  30. package/dist/components/chart.js.map +1 -1
  31. package/dist/components/chip.d.ts +2 -1
  32. package/dist/components/chip.js +26 -18
  33. package/dist/components/chip.js.map +1 -1
  34. package/dist/components/choice-card.d.ts +35 -3
  35. package/dist/components/choice-card.js +83 -25
  36. package/dist/components/choice-card.js.map +1 -1
  37. package/dist/components/combobox-core.d.ts +3 -1
  38. package/dist/components/combobox-core.js +18 -5
  39. package/dist/components/combobox-core.js.map +1 -1
  40. package/dist/components/combobox.d.ts +2 -2
  41. package/dist/components/combobox.js +31 -9
  42. package/dist/components/combobox.js.map +1 -1
  43. package/dist/components/copy-button.d.ts +51 -70
  44. package/dist/components/copy-button.js +1 -1
  45. package/dist/components/copy-button.js.map +1 -1
  46. package/dist/components/data-table-cells.d.ts +63 -0
  47. package/dist/components/data-table-cells.js +64 -0
  48. package/dist/components/data-table-cells.js.map +1 -0
  49. package/dist/components/data-table-filter-popover.d.ts +1 -1
  50. package/dist/components/data-table-filter-popover.js +8 -1
  51. package/dist/components/data-table-filter-popover.js.map +1 -1
  52. package/dist/components/data-table-filters.d.ts +1 -1
  53. package/dist/components/data-table-filters.js +31 -1
  54. package/dist/components/data-table-filters.js.map +1 -1
  55. package/dist/components/data-table-labels.d.ts +13 -0
  56. package/dist/components/data-table-labels.js +8 -1
  57. package/dist/components/data-table-labels.js.map +1 -1
  58. package/dist/components/data-table.d.ts +1 -1
  59. package/dist/components/data-table.js +125 -27
  60. package/dist/components/data-table.js.map +1 -1
  61. package/dist/components/date-picker.d.ts +3 -1
  62. package/dist/components/date-picker.js +15 -2
  63. package/dist/components/date-picker.js.map +1 -1
  64. package/dist/components/description-list.d.ts +23 -3
  65. package/dist/components/description-list.js +23 -3
  66. package/dist/components/description-list.js.map +1 -1
  67. package/dist/components/dialog-frame.d.ts +1 -0
  68. package/dist/components/entity-combobox.d.ts +1 -1
  69. package/dist/components/entity-combobox.js +40 -20
  70. package/dist/components/entity-combobox.js.map +1 -1
  71. package/dist/components/error-boundary.d.ts +281 -0
  72. package/dist/components/error-boundary.js +302 -0
  73. package/dist/components/error-boundary.js.map +1 -0
  74. package/dist/components/field-sync.js +90 -83
  75. package/dist/components/field-sync.js.map +1 -1
  76. package/dist/components/field.d.ts +30 -4
  77. package/dist/components/field.js +40 -17
  78. package/dist/components/field.js.map +1 -1
  79. package/dist/components/file-button.d.ts +50 -208
  80. package/dist/components/file-dropzone.d.ts +49 -2
  81. package/dist/components/floating-panel.d.ts +13 -4
  82. package/dist/components/floating-panel.js +7 -3
  83. package/dist/components/floating-panel.js.map +1 -1
  84. package/dist/components/form-actions.d.ts +53 -0
  85. package/dist/components/form-actions.js +98 -0
  86. package/dist/components/form-actions.js.map +1 -0
  87. package/dist/components/full-bleed-dialog.js +4 -0
  88. package/dist/components/full-bleed-dialog.js.map +1 -1
  89. package/dist/components/hover-menu.js +64 -56
  90. package/dist/components/hover-menu.js.map +1 -1
  91. package/dist/components/image-grid.d.ts +67 -0
  92. package/dist/components/image-grid.js +112 -0
  93. package/dist/components/image-grid.js.map +1 -0
  94. package/dist/components/lightbox.d.ts +104 -0
  95. package/dist/components/lightbox.js +229 -0
  96. package/dist/components/lightbox.js.map +1 -0
  97. package/dist/components/line-items.d.ts +114 -0
  98. package/dist/components/line-items.js +238 -0
  99. package/dist/components/line-items.js.map +1 -0
  100. package/dist/components/list.d.ts +37 -4
  101. package/dist/components/list.js +35 -14
  102. package/dist/components/list.js.map +1 -1
  103. package/dist/components/loading-state.d.ts +24 -0
  104. package/dist/components/loading-state.js +32 -0
  105. package/dist/components/loading-state.js.map +1 -0
  106. package/dist/components/menu-item.d.ts +2 -1
  107. package/dist/components/menu-item.js +5 -1
  108. package/dist/components/menu-item.js.map +1 -1
  109. package/dist/components/mini-calendar.d.ts +13 -1
  110. package/dist/components/mini-calendar.js +46 -2
  111. package/dist/components/mini-calendar.js.map +1 -1
  112. package/dist/components/modal.d.ts +20 -1
  113. package/dist/components/modal.js +26 -2
  114. package/dist/components/modal.js.map +1 -1
  115. package/dist/components/month-picker.d.ts +21 -1
  116. package/dist/components/month-picker.js +139 -26
  117. package/dist/components/month-picker.js.map +1 -1
  118. package/dist/components/multi-entity-combobox.d.ts +1 -1
  119. package/dist/components/multi-entity-combobox.js +42 -20
  120. package/dist/components/multi-entity-combobox.js.map +1 -1
  121. package/dist/components/nav-pills.d.ts +2 -1
  122. package/dist/components/nav-pills.js +5 -1
  123. package/dist/components/nav-pills.js.map +1 -1
  124. package/dist/components/number-field.d.ts +24 -5
  125. package/dist/components/number-field.js +5 -7
  126. package/dist/components/number-field.js.map +1 -1
  127. package/dist/components/number-input.d.ts +25 -5
  128. package/dist/components/number-input.js +7 -1
  129. package/dist/components/number-input.js.map +1 -1
  130. package/dist/components/numpad-sheet.d.ts +20 -5
  131. package/dist/components/numpad-sheet.js +3 -2
  132. package/dist/components/numpad-sheet.js.map +1 -1
  133. package/dist/components/page-header.d.ts +35 -6
  134. package/dist/components/page-header.js +7 -1
  135. package/dist/components/page-header.js.map +1 -1
  136. package/dist/components/passkeys-setting.d.ts +67 -0
  137. package/dist/components/passkeys-setting.js +214 -0
  138. package/dist/components/passkeys-setting.js.map +1 -0
  139. package/dist/components/picker-sheet.js +5 -1
  140. package/dist/components/picker-sheet.js.map +1 -1
  141. package/dist/components/pie-chart-labels.d.ts +20 -0
  142. package/dist/components/pie-chart-labels.js +12 -0
  143. package/dist/components/pie-chart-labels.js.map +1 -0
  144. package/dist/components/pie-chart.d.ts +101 -0
  145. package/dist/components/pie-chart.js +283 -0
  146. package/dist/components/pie-chart.js.map +1 -0
  147. package/dist/components/popover.js +3 -0
  148. package/dist/components/popover.js.map +1 -1
  149. package/dist/components/progress-bar.d.ts +44 -3
  150. package/dist/components/progress-bar.js +58 -22
  151. package/dist/components/progress-bar.js.map +1 -1
  152. package/dist/components/qr-code.d.ts +34 -0
  153. package/dist/components/qr-code.js +57 -0
  154. package/dist/components/qr-code.js.map +1 -0
  155. package/dist/components/search-field.d.ts +15 -3
  156. package/dist/components/search-field.js +5 -1
  157. package/dist/components/search-field.js.map +1 -1
  158. package/dist/components/settings-fields.d.ts +49 -1
  159. package/dist/components/signed-amount.d.ts +122 -0
  160. package/dist/components/signed-amount.js +152 -0
  161. package/dist/components/signed-amount.js.map +1 -0
  162. package/dist/components/skeleton.d.ts +10 -3
  163. package/dist/components/skeleton.js +12 -2
  164. package/dist/components/skeleton.js.map +1 -1
  165. package/dist/components/stat-tile.d.ts +2 -1
  166. package/dist/components/stat-tile.js +6 -3
  167. package/dist/components/stat-tile.js.map +1 -1
  168. package/dist/components/swipeable-row.js +4 -3
  169. package/dist/components/swipeable-row.js.map +1 -1
  170. package/dist/components/table.d.ts +39 -5
  171. package/dist/components/table.js +45 -11
  172. package/dist/components/table.js.map +1 -1
  173. package/dist/components/text-link.d.ts +238 -0
  174. package/dist/components/text-link.js +144 -0
  175. package/dist/components/text-link.js.map +1 -0
  176. package/dist/components/text.d.ts +26 -2
  177. package/dist/components/text.js +16 -2
  178. package/dist/components/text.js.map +1 -1
  179. package/dist/components/time-input.d.ts +49 -1
  180. package/dist/components/toggle-group.d.ts +35 -0
  181. package/dist/components/toggle-group.js +43 -14
  182. package/dist/components/toggle-group.js.map +1 -1
  183. package/dist/components/toggle-legend.d.ts +53 -3
  184. package/dist/components/toggle-legend.js +54 -1
  185. package/dist/components/toggle-legend.js.map +1 -1
  186. package/dist/components/tooltip.d.ts +51 -1
  187. package/dist/components/tooltip.js +59 -35
  188. package/dist/components/tooltip.js.map +1 -1
  189. package/dist/components/ui.d.ts +51 -779
  190. package/dist/components/ui.js +364 -34
  191. package/dist/components/ui.js.map +1 -1
  192. package/dist/components/use-table-state.d.ts +3 -52
  193. package/dist/components/use-table-state.js +128 -30
  194. package/dist/components/use-table-state.js.map +1 -1
  195. package/dist/{data-table-filters-Dh9uF_S-.d.ts → data-table-Drun8Fk9.d.ts} +305 -61
  196. package/dist/data-table.d.ts +2 -1
  197. package/dist/data-table.js +5 -1
  198. package/dist/data-table.js.map +1 -1
  199. package/dist/feedback/feedback-attachment.js +4 -6
  200. package/dist/feedback/feedback-attachment.js.map +1 -1
  201. package/dist/feedback/feedback-dialog.d.ts +26 -3
  202. package/dist/feedback/feedback-dialog.js +21 -5
  203. package/dist/feedback/feedback-dialog.js.map +1 -1
  204. package/dist/feedback/feedback-inbox.js +86 -75
  205. package/dist/feedback/feedback-inbox.js.map +1 -1
  206. package/dist/feedback/feedback-thread.d.ts +173 -0
  207. package/dist/feedback/feedback-thread.js +264 -0
  208. package/dist/feedback/feedback-thread.js.map +1 -0
  209. package/dist/feedback.d.ts +2 -1
  210. package/dist/feedback.js +1 -0
  211. package/dist/feedback.js.map +1 -1
  212. package/dist/hooks/use-authed-src.d.ts +71 -0
  213. package/dist/hooks/use-authed-src.js +63 -0
  214. package/dist/hooks/use-authed-src.js.map +1 -0
  215. package/dist/hooks/use-file-drop.d.ts +49 -2
  216. package/dist/hooks/use-hotkey.d.ts +59 -0
  217. package/dist/hooks/use-hotkey.js +105 -0
  218. package/dist/hooks/use-hotkey.js.map +1 -0
  219. package/dist/hooks/use-search-param-state.d.ts +83 -0
  220. package/dist/hooks/use-search-param-state.js +94 -0
  221. package/dist/hooks/use-search-param-state.js.map +1 -0
  222. package/dist/i18n/defaults.d.ts +15 -4
  223. package/dist/i18n/defaults.js +31 -1
  224. package/dist/i18n/defaults.js.map +1 -1
  225. package/dist/i18n/kit-labels.d.ts +46 -312
  226. package/dist/i18n/kit-labels.js +20 -5
  227. package/dist/i18n/kit-labels.js.map +1 -1
  228. package/dist/i18n/locales/de-CH-informal.d.ts +15 -4
  229. package/dist/i18n/locales/de-CH.d.ts +15 -4
  230. package/dist/i18n/locales/de-informal.d.ts +15 -4
  231. package/dist/i18n/locales/de.d.ts +15 -4
  232. package/dist/i18n/locales/de.js +164 -3
  233. package/dist/i18n/locales/de.js.map +1 -1
  234. package/dist/i18n/locales/es.d.ts +15 -4
  235. package/dist/i18n/locales/es.js +161 -3
  236. package/dist/i18n/locales/es.js.map +1 -1
  237. package/dist/i18n/locales/fr.d.ts +15 -4
  238. package/dist/i18n/locales/fr.js +161 -3
  239. package/dist/i18n/locales/fr.js.map +1 -1
  240. package/dist/i18n/locales/hu.d.ts +15 -4
  241. package/dist/i18n/locales/hu.js +161 -3
  242. package/dist/i18n/locales/hu.js.map +1 -1
  243. package/dist/i18n/locales/it.d.ts +15 -4
  244. package/dist/i18n/locales/it.js +161 -3
  245. package/dist/i18n/locales/it.js.map +1 -1
  246. package/dist/i18n/locales/zh.d.ts +15 -4
  247. package/dist/i18n/locales/zh.js +161 -3
  248. package/dist/i18n/locales/zh.js.map +1 -1
  249. package/dist/index.d.ts +39 -19
  250. package/dist/index.js +40 -1
  251. package/dist/index.js.map +1 -1
  252. package/dist/kit-labels-Mz8zZHIF.d.ts +1744 -0
  253. package/dist/lib/format.d.ts +162 -0
  254. package/dist/lib/format.js +151 -0
  255. package/dist/lib/format.js.map +1 -0
  256. package/dist/lib/qr-encode.d.ts +44 -0
  257. package/dist/lib/qr-encode.js +338 -0
  258. package/dist/lib/qr-encode.js.map +1 -0
  259. package/dist/rhf/fields.d.ts +283 -0
  260. package/dist/rhf/fields.js +631 -0
  261. package/dist/rhf/fields.js.map +1 -0
  262. package/dist/rhf/form.d.ts +49 -1
  263. package/dist/rhf/line-items.d.ts +31 -0
  264. package/dist/rhf/line-items.js +59 -0
  265. package/dist/rhf/line-items.js.map +1 -0
  266. package/dist/rhf.d.ts +61 -1
  267. package/dist/rhf.js +2 -0
  268. package/dist/rhf.js.map +1 -1
  269. package/dist/search/command-palette.js +20 -14
  270. package/dist/search/command-palette.js.map +1 -1
  271. package/dist/shell/app-shell.d.ts +99 -2
  272. package/dist/shell/app-shell.js +120 -57
  273. package/dist/shell/app-shell.js.map +1 -1
  274. package/dist/shell/auth-layout.d.ts +74 -0
  275. package/dist/shell/auth-layout.js +97 -0
  276. package/dist/shell/auth-layout.js.map +1 -0
  277. package/dist/shell/top-bar-brand.d.ts +81 -0
  278. package/dist/shell/top-bar-brand.js +47 -0
  279. package/dist/shell/top-bar-brand.js.map +1 -0
  280. package/dist/shell/topbar-action-menu.d.ts +21 -4
  281. package/dist/shell/topbar-action-menu.js +18 -2
  282. package/dist/shell/topbar-action-menu.js.map +1 -1
  283. package/dist/shell.d.ts +56 -1
  284. package/dist/shell.js +2 -0
  285. package/dist/shell.js.map +1 -1
  286. package/dist/tour/tour.js +10 -4
  287. package/dist/tour/tour.js.map +1 -1
  288. package/dist/wizard/stepper-nav.d.ts +48 -1
  289. package/dist/wizard/use-wizard.js +4 -2
  290. package/dist/wizard/use-wizard.js.map +1 -1
  291. package/dist/wizard/wizard-context.d.ts +24 -1
  292. package/dist/wizard/wizard-context.js +19 -2
  293. package/dist/wizard/wizard-context.js.map +1 -1
  294. package/dist/wizard/wizard-step.d.ts +30 -5
  295. package/dist/wizard/wizard-step.js +34 -3
  296. package/dist/wizard/wizard-step.js.map +1 -1
  297. package/dist/wizard.d.ts +50 -3
  298. package/package.json +6 -6
  299. package/src/chart.ts +4 -0
  300. package/src/components/account-settings-labels.ts +190 -0
  301. package/src/components/account-settings.tsx +110 -63
  302. package/src/components/amount-input.tsx +109 -10
  303. package/src/components/authed-image.tsx +190 -0
  304. package/src/components/breadcrumbs.tsx +8 -2
  305. package/src/components/bulk-action-bar.tsx +16 -3
  306. package/src/components/button-group.tsx +7 -2
  307. package/src/components/calendar-heatmap.tsx +105 -10
  308. package/src/components/chart.tsx +19 -8
  309. package/src/components/chip.tsx +14 -4
  310. package/src/components/choice-card.tsx +136 -25
  311. package/src/components/combobox-core.tsx +33 -9
  312. package/src/components/combobox.tsx +33 -9
  313. package/src/components/copy-button.tsx +3 -2
  314. package/src/components/data-table-cells.tsx +119 -0
  315. package/src/components/data-table-filter-popover.tsx +13 -5
  316. package/src/components/data-table-filters.ts +77 -0
  317. package/src/components/data-table-labels.ts +23 -0
  318. package/src/components/data-table.tsx +230 -13
  319. package/src/components/date-picker.tsx +19 -3
  320. package/src/components/description-list.tsx +52 -3
  321. package/src/components/entity-combobox.tsx +25 -7
  322. package/src/components/error-boundary.tsx +640 -0
  323. package/src/components/field-sync.tsx +48 -40
  324. package/src/components/field.tsx +56 -5
  325. package/src/components/floating-panel.tsx +20 -7
  326. package/src/components/form-actions.tsx +191 -0
  327. package/src/components/full-bleed-dialog.tsx +4 -0
  328. package/src/components/hover-menu.tsx +26 -17
  329. package/src/components/image-grid.tsx +181 -0
  330. package/src/components/lightbox.tsx +374 -0
  331. package/src/components/line-items.tsx +385 -0
  332. package/src/components/list.tsx +82 -19
  333. package/src/components/loading-state.tsx +47 -0
  334. package/src/components/menu-item.tsx +7 -2
  335. package/src/components/mini-calendar.tsx +72 -3
  336. package/src/components/modal.tsx +65 -3
  337. package/src/components/month-picker.tsx +181 -26
  338. package/src/components/multi-entity-combobox.tsx +27 -7
  339. package/src/components/nav-pills.tsx +8 -1
  340. package/src/components/number-field.tsx +15 -10
  341. package/src/components/number-input.tsx +17 -1
  342. package/src/components/numpad-sheet.tsx +6 -1
  343. package/src/components/page-header.tsx +42 -5
  344. package/src/components/passkeys-setting.tsx +331 -0
  345. package/src/components/picker-sheet.tsx +10 -1
  346. package/src/components/pie-chart-labels.ts +32 -0
  347. package/src/components/pie-chart.tsx +479 -0
  348. package/src/components/popover.tsx +3 -0
  349. package/src/components/progress-bar.tsx +129 -19
  350. package/src/components/qr-code.tsx +83 -0
  351. package/src/components/search-field.tsx +20 -4
  352. package/src/components/signed-amount.tsx +295 -0
  353. package/src/components/skeleton.tsx +21 -3
  354. package/src/components/stat-tile.tsx +11 -3
  355. package/src/components/swipeable-row.tsx +7 -7
  356. package/src/components/table.tsx +102 -13
  357. package/src/components/text-link.tsx +356 -0
  358. package/src/components/text.tsx +46 -2
  359. package/src/components/toggle-group.tsx +93 -20
  360. package/src/components/toggle-legend.tsx +108 -2
  361. package/src/components/tooltip.tsx +79 -8
  362. package/src/components/ui.tsx +707 -49
  363. package/src/components/use-table-state.ts +265 -33
  364. package/src/data-table.ts +10 -0
  365. package/src/feedback/feedback-attachment.tsx +10 -7
  366. package/src/feedback/feedback-dialog.tsx +49 -7
  367. package/src/feedback/feedback-inbox.tsx +7 -0
  368. package/src/feedback/feedback-thread.tsx +510 -0
  369. package/src/feedback.ts +1 -0
  370. package/src/hooks/use-authed-src.ts +161 -0
  371. package/src/hooks/use-hotkey.ts +172 -0
  372. package/src/hooks/use-search-param-state.ts +187 -0
  373. package/src/i18n/defaults.ts +30 -0
  374. package/src/i18n/kit-labels.tsx +118 -8
  375. package/src/i18n/locales/de.ts +161 -0
  376. package/src/i18n/locales/es.ts +158 -0
  377. package/src/i18n/locales/fr.ts +161 -0
  378. package/src/i18n/locales/hu.ts +159 -0
  379. package/src/i18n/locales/it.ts +159 -0
  380. package/src/i18n/locales/zh.ts +158 -0
  381. package/src/index.ts +59 -0
  382. package/src/lib/format.ts +348 -0
  383. package/src/lib/qr-encode.ts +420 -0
  384. package/src/rhf/fields.tsx +1135 -0
  385. package/src/rhf/line-items.tsx +130 -0
  386. package/src/rhf.ts +6 -0
  387. package/src/search/command-palette.tsx +29 -19
  388. package/src/shell/app-shell.tsx +153 -3
  389. package/src/shell/auth-layout.tsx +190 -0
  390. package/src/shell/top-bar-brand.tsx +76 -0
  391. package/src/shell/topbar-action-menu.tsx +32 -4
  392. package/src/shell.ts +2 -0
  393. package/src/tour/tour.tsx +16 -5
  394. package/src/wizard/use-wizard.ts +8 -4
  395. package/src/wizard/wizard-context.tsx +41 -1
  396. package/src/wizard/wizard-step.tsx +75 -6
  397. package/tokens.css +12 -0
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { CalculatorLabels } from '../i18n/kit-labels.js';
2
+ import { C as CalculatorLabels } from '../kit-labels-Mz8zZHIF.js';
3
3
  import './data-table-labels.js';
4
4
  import './mini-calendar.js';
5
5
  import './calendar-heatmap.js';
@@ -7,7 +7,6 @@ import './popover.js';
7
7
  import './chip.js';
8
8
  import 'lucide-react';
9
9
  import './field-sync.js';
10
- import './ui.js';
11
10
  import './tooltip.js';
12
11
  import '../hooks/use-anchored-rect.js';
13
12
  import '../lib/clipping.js';
@@ -19,6 +18,7 @@ import '../search/search-index.js';
19
18
  import './month-picker.js';
20
19
  import './page-contents.js';
21
20
  import './series-chart-labels.js';
21
+ import './pie-chart-labels.js';
22
22
  import './sparkline.js';
23
23
  import './stat-tile.js';
24
24
  import './signature-pad.js';
@@ -29,17 +29,28 @@ import './tile-radio.js';
29
29
  import './icon-picker.js';
30
30
  import './dialog-frame.js';
31
31
  import './modal.js';
32
- import './file-button.js';
32
+ import '../hooks/use-search-param-state.js';
33
33
  import './measured-grid.js';
34
34
  import '../feedback/feedback-attachment.js';
35
35
  import '../feedback/feedback-dialog.js';
36
+ import '../feedback/feedback-thread.js';
37
+ import '../feedback/feedback-inbox.js';
38
+ import './account-settings-labels.js';
36
39
  import './confirm-dialog.js';
37
40
  import './floating-panel.js';
38
- import './copy-button.js';
39
41
  import './bulk-action-bar.js';
40
42
  import './list.js';
41
43
  import './breadcrumbs.js';
42
44
  import './toast.js';
45
+ import './description-list.js';
46
+ import './line-items.js';
47
+ import './progress-bar.js';
48
+ import './signed-amount.js';
49
+ import './error-boundary.js';
50
+ import './authed-image.js';
51
+ import '../hooks/use-authed-src.js';
52
+ import './image-grid.js';
53
+ import './lightbox.js';
43
54
 
44
55
  /** Screen-reader names for the calculator panel's own controls — any part of the
45
56
  * kit's `calculator` namespace. Once three optional keys of its own; widened, not
@@ -87,6 +87,39 @@ interface CalendarHeatmapProps extends Omit<ComponentPropsWithoutRef<"div">, "on
87
87
  /** The scale's colour, as any CSS colour. Default `var(--brand)`; each step is this
88
88
  * mixed into `--bg-surface`, so the ramp follows the theme. */
89
89
  color?: string;
90
+ /**
91
+ * A CONTINUOUS scale from `colorFrom` (the smallest value) to `colorTo` (the busiest
92
+ * day), instead of `levels` steps of `color` — keksdose's palette-store ramp,
93
+ * `seqLow` → `seqHigh`. Both are needed; `color` is then unused. Two `#rrggbb`
94
+ * colours are interpolated in JS, so the fill is a concrete hex and the day number's
95
+ * ink (in `"month"`) is MEASURED against it; anything else (a `var()`) is mixed with
96
+ * `color-mix()`. `levels` still sets `data-level` and the legend's swatch count.
97
+ */
98
+ colorFrom?: string;
99
+ colorTo?: string;
100
+ /**
101
+ * A fill of the caller's own for a day with a value: handed the value and the
102
+ * scale's `max`, returns any CSS colour. Wins over `color` and `colorFrom`/`colorTo`.
103
+ * Also paints the legend, at `max × level / levels`.
104
+ */
105
+ fill?: (value: number, max: number) => string;
106
+ /** The fill of a day with no value (or a value of 0). Default: a wash of the text
107
+ * colour over the surface, which reads as a cell on both themes. */
108
+ emptyColor?: string;
109
+ /**
110
+ * Where the window ENDS — the day `maxDays` counts back from, and the last one drawn:
111
+ *
112
+ * - `"to"` (default): on `to`.
113
+ * - `"today"`: on today.
114
+ * - `"latest"`: on the last day that can carry a figure — today, or a later day that
115
+ * actually has a value. A window running into the future (a report's "all" preset
116
+ * ends a year ahead) then spends its cells on the days a person is looking for,
117
+ * not on a year of empty ones.
118
+ * - a `"YYYY-MM-DD"`: on that day.
119
+ *
120
+ * Always kept inside `from`…`to`.
121
+ */
122
+ anchor?: "to" | "today" | "latest" | (string & {});
90
123
  /**
91
124
  * The most days to draw. A longer window keeps its LATEST `maxDays` and says how many
92
125
  * it left out (`labels.truncated`) rather than silently ending. Default: no cap.
@@ -101,6 +134,9 @@ interface CalendarHeatmapProps extends Omit<ComponentPropsWithoutRef<"div">, "on
101
134
  labels?: Partial<CalendarHeatmapLabels>;
102
135
  className?: string;
103
136
  }
137
+ /** Where the window ends for an {@link CalendarHeatmapProps.anchor}, kept in `[from, to]`.
138
+ * `latestData` is the latest ISO date carrying a value, or `""`. */
139
+ declare function heatmapWindowEnd(from: string, to: string, anchor: string, latestData: string, today?: string): string;
104
140
  /** The step a value falls on: 0 for nothing, else 1…levels by its share of `max`. */
105
141
  declare function heatmapLevel(value: number, max: number, levels: number): number;
106
142
  /**
@@ -113,12 +149,14 @@ declare function heatmapLevel(value: number, max: number, levels: number): numbe
113
149
  * the other way round, mirrored in RTL — PageUp/PageDown move a month and Home/End go
114
150
  * to the window's first/last day. Each cell is named with its whole date AND its value,
115
151
  * because the colour is not something a screen reader can say, and carries
116
- * `data-day="YYYY-MM-DD"` as its identity for tests and for the host.
152
+ * `data-day="YYYY-MM-DD"` as its identity for tests and for the host. Note that in
153
+ * `"weeks"` the cells are in DOM order by WEEKDAY ROW (all Mondays, then all
154
+ * Tuesdays…), not by date — query by `data-day`, not by position.
117
155
  *
118
156
  * The tooltip is portalled (a year of squares always sits in a sideways scroller) and
119
157
  * `data-private` unless `sensitive={false}`. Cell size in `"weeks"` is the CSS variable
120
158
  * `--heatmap-cell` (default `0.75rem`): `style={{ "--heatmap-cell": "1rem" }}`.
121
159
  */
122
- declare function CalendarHeatmap({ data, from, to, layout, selected, onSelect, formatValue: formatValueProp, tooltip, sensitive, max: maxProp, levels, color, maxDays, legend, locale: localeProp, weekStartsOn, labels: labelsProp, className, "aria-label": ariaLabel, ...rest }: CalendarHeatmapProps): react.JSX.Element;
160
+ declare function CalendarHeatmap({ data, from, to, layout, selected, onSelect, formatValue: formatValueProp, tooltip, sensitive, max: maxProp, levels, color, colorFrom, colorTo, fill: fillProp, emptyColor, anchor, maxDays, legend, locale: localeProp, weekStartsOn, labels: labelsProp, className, "aria-label": ariaLabel, ...rest }: CalendarHeatmapProps): react.JSX.Element;
123
161
 
124
- export { CalendarHeatmap, type CalendarHeatmapDatum, type CalendarHeatmapDay, type CalendarHeatmapLabels, type CalendarHeatmapProps, DEFAULT_CALENDAR_HEATMAP_LABELS, heatmapLevel };
162
+ export { CalendarHeatmap, type CalendarHeatmapDatum, type CalendarHeatmapDay, type CalendarHeatmapLabels, type CalendarHeatmapProps, DEFAULT_CALENDAR_HEATMAP_LABELS, heatmapLevel, heatmapWindowEnd };
@@ -5,6 +5,8 @@ import { cn } from "../lib/cn.js";
5
5
  import { dirOf, horizontalStep } from "../lib/direction.js";
6
6
  import { addMonthsClamped, localeWeekStart, parseIsoDate, toLocalIso } from "../lib/dates.js";
7
7
  import { useKitLabels, useKitLocale, useKitWeekStart } from "../i18n/kit-labels.js";
8
+ import { lerpHex, textOn } from "../theme/chart-palette.js";
9
+ import { parseHex } from "../theme/color.js";
8
10
  import { Tooltip } from "./tooltip.js";
9
11
  const DEFAULT_CALENDAR_HEATMAP_LABELS = {
10
12
  grid: "Daily values",
@@ -21,6 +23,16 @@ const DAY_NAME_FORMAT = {
21
23
  };
22
24
  const EMPTY_FILL = "color-mix(in oklab, var(--text-primary) 8%, var(--bg-surface))";
23
25
  const weekdayIndex = (d, weekStart) => (d.getDay() - weekStart + 7) % 7;
26
+ function heatmapWindowEnd(from, to, anchor, latestData, today = toLocalIso(/* @__PURE__ */ new Date())) {
27
+ let end;
28
+ if (anchor === "today") end = today;
29
+ else if (anchor === "latest") end = latestData > today ? latestData : today;
30
+ else if (anchor === "to" || !parseIsoDate(anchor)) end = to;
31
+ else end = anchor;
32
+ if (end > to) end = to;
33
+ if (end < from) end = from;
34
+ return end;
35
+ }
24
36
  function heatmapLevel(value, max, levels) {
25
37
  if (!(value > 0) || !(max > 0) || levels < 1) return 0;
26
38
  return Math.min(levels, Math.max(1, Math.ceil(value / max * levels)));
@@ -46,6 +58,11 @@ function CalendarHeatmap({
46
58
  max: maxProp,
47
59
  levels = 4,
48
60
  color = "var(--brand)",
61
+ colorFrom,
62
+ colorTo,
63
+ fill: fillProp,
64
+ emptyColor,
65
+ anchor = "to",
49
66
  maxDays,
50
67
  legend = true,
51
68
  locale: localeProp,
@@ -66,9 +83,15 @@ function CalendarHeatmap({
66
83
  for (const p of data) m.set(p.date, (m.get(p.date) ?? 0) + p.value);
67
84
  return m;
68
85
  }, [data]);
86
+ const latestData = useMemo(() => {
87
+ let latest = "";
88
+ for (const [iso, v] of values) if (v !== 0 && iso > latest) latest = iso;
89
+ return latest;
90
+ }, [values]);
91
+ const windowEnd = heatmapWindowEnd(from, to, anchor, latestData);
69
92
  const { days, dropped } = useMemo(() => {
70
93
  const start = parseIsoDate(from);
71
- const end = parseIsoDate(to);
94
+ const end = parseIsoDate(windowEnd);
72
95
  const list = [];
73
96
  if (!start || !end || end < start) return { days: list, dropped: 0 };
74
97
  const cursor = new Date(end);
@@ -80,7 +103,7 @@ function CalendarHeatmap({
80
103
  const first = list[0];
81
104
  const trimmed = first ? Math.round((first.getTime() - start.getTime()) / 864e5) : 0;
82
105
  return { days: list, dropped: Math.max(0, trimmed) };
83
- }, [from, to, maxDays]);
106
+ }, [from, windowEnd, maxDays]);
84
107
  const firstIso = days.length ? toLocalIso(days[0]) : "";
85
108
  const lastIso = days.length ? toLocalIso(days[days.length - 1]) : "";
86
109
  const max = useMemo(() => {
@@ -182,18 +205,35 @@ function CalendarHeatmap({
182
205
  setActiveIso(iso);
183
206
  };
184
207
  const legendLevels = Array.from({ length: levels + 1 }, (_, l) => l);
208
+ const empty = emptyColor ?? EMPTY_FILL;
209
+ const continuous = colorFrom !== void 0 && colorTo !== void 0;
210
+ const hexRamp = continuous && parseHex(colorFrom) != null && parseHex(colorTo) != null;
211
+ const paint = (value, level) => {
212
+ if (level === 0) return { fill: empty, ink: "var(--text-primary)" };
213
+ if (fillProp || continuous) {
214
+ const t = max > 0 ? Math.min(1, Math.max(0, value / max)) : 1;
215
+ const fill = fillProp ? fillProp(value, max) : hexRamp ? lerpHex(colorFrom, colorTo, t) : `color-mix(in oklab, ${colorTo} ${Math.round(t * 100)}%, ${colorFrom})`;
216
+ const measured = textOn(fill);
217
+ return { fill, ink: measured === "currentColor" ? "var(--text-primary)" : measured };
218
+ }
219
+ const strong = levelPercent(level, levels) >= 45;
220
+ return {
221
+ fill: levelFill(level, levels, color),
222
+ ink: strong ? "var(--bg-surface)" : "var(--text-primary)"
223
+ };
224
+ };
225
+ const legendFill = (l) => paint((max > 0 ? max : 1) * l / levels, l).fill;
185
226
  const cell = (d, wrapClass, cellClass, withNumber) => {
186
227
  const iso = toLocalIso(d);
187
228
  const raw = values.get(iso);
188
229
  const value = raw ?? 0;
189
230
  const level = heatmapLevel(value, max, levels);
190
- const fill = levelFill(level, levels, color);
231
+ const { fill, ink } = paint(value, level);
191
232
  const formattedDate = formatDay(d);
192
233
  const formattedValue = formatValue(value);
193
234
  const name = labels.day(formattedDate, formattedValue);
194
235
  const label = tooltip ? tooltip({ iso, date: d, value, hasData: raw !== void 0, level, formattedDate, formattedValue }) : name;
195
236
  const isSelected = selected === iso;
196
- const strong = level > 0 && levelPercent(level, levels) >= 45;
197
237
  const shared = {
198
238
  role: "gridcell",
199
239
  "data-day": iso,
@@ -205,7 +245,7 @@ function CalendarHeatmap({
205
245
  onFocus: () => {
206
246
  if (iso !== activeIso) setActiveIso(iso);
207
247
  },
208
- style: { background: fill, color: strong ? "var(--bg-surface)" : "var(--text-primary)" },
248
+ style: { background: fill, color: ink },
209
249
  className: cn(
210
250
  cellClass,
211
251
  isSelected && "ring-2 ring-[var(--text-primary)]",
@@ -279,7 +319,7 @@ function CalendarHeatmap({
279
319
  {
280
320
  "data-legend-level": l,
281
321
  className: "size-2.5 rounded-sm",
282
- style: { background: levelFill(l, levels, color) }
322
+ style: { background: legendFill(l) }
283
323
  },
284
324
  l
285
325
  )),
@@ -290,6 +330,7 @@ function CalendarHeatmap({
290
330
  export {
291
331
  CalendarHeatmap,
292
332
  DEFAULT_CALENDAR_HEATMAP_LABELS,
293
- heatmapLevel
333
+ heatmapLevel,
334
+ heatmapWindowEnd
294
335
  };
295
336
  //# sourceMappingURL=calendar-heatmap.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/calendar-heatmap.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, CSSProperties, KeyboardEvent, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { dirOf, horizontalStep } from \"../lib/direction\";\nimport { addMonthsClamped, localeWeekStart, parseIsoDate, toLocalIso } from \"../lib/dates\";\nimport { useKitLabels, useKitLocale, useKitWeekStart } from \"../i18n/kit-labels\";\nimport { Tooltip } from \"./tooltip\";\nimport type { WeekDay } from \"./mini-calendar\";\n\n/**\n * Every string the heatmap speaks — the `calendarHeatmap` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`. Dates and\n * values arrive already formatted (in `locale`, and through `formatValue`), so the\n * functions only arrange them.\n */\nexport interface CalendarHeatmapLabels {\n /** Accessible name of the grid. */\n grid: string;\n /**\n * One day: its accessible name, and the tooltip unless `tooltip` is given. `date`\n * is the whole date in `locale` (\"Monday, 14 September 2026\"), `value` the day's\n * figure through `formatValue`.\n */\n day: (date: string, value: string) => string;\n /** The two ends of the legend's scale. */\n less: string;\n more: string;\n /** `maxDays` cut the window: how many of its earliest days are not drawn. */\n truncated: (count: number) => string;\n}\n\n/** English defaults, exported as the `calendarHeatmap` namespace of `UiKitLabels`. */\nexport const DEFAULT_CALENDAR_HEATMAP_LABELS: CalendarHeatmapLabels = {\n grid: \"Daily values\",\n day: (date, value) => `${date}: ${value}`,\n less: \"Less\",\n more: \"More\",\n truncated: (count) =>\n `Showing the most recent days; ${count} earlier ${count === 1 ? \"day is\" : \"days are\"} not shown.`,\n};\n\n/** One day's figure. Several entries for one date are added up. */\nexport interface CalendarHeatmapDatum {\n /** \"YYYY-MM-DD\". */\n date: string;\n value: number;\n}\n\n/** What `tooltip` is told about the day under the pointer. */\nexport interface CalendarHeatmapDay {\n iso: string;\n date: Date;\n /** The day's figure; `0` when `data` has no entry for it (see `hasData`). */\n value: number;\n hasData: boolean;\n /** `0` = empty … `levels` = the busiest. */\n level: number;\n /** The whole date in `locale`. */\n formattedDate: string;\n /** `value` through `formatValue`. */\n formattedValue: string;\n}\n\n/**\n * `onSelect` is omitted from the `<div>` attributes for the reason `MiniCalendar` gives:\n * the DOM event of that name is a text-selection event, and this one answers with a date.\n */\nexport interface CalendarHeatmapProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onSelect\"> {\n data: readonly CalendarHeatmapDatum[];\n /** The window, inclusive, as \"YYYY-MM-DD\". */\n from: string;\n to: string;\n /**\n * `\"weeks\"` (default): the contribution-graph shape — one COLUMN per week, the\n * weekdays down the side, month names along the top; a year fits in ~53 small\n * squares and scrolls sideways where it does not. `\"month\"`: a 7-column calendar\n * with day numbers in large square cells, for a single month on a phone (switch on\n * `useMediaQuery` and narrow `from`/`to` to the month).\n */\n layout?: \"weeks\" | \"month\";\n /** The day shown as selected (\"YYYY-MM-DD\"). */\n selected?: string;\n /** Makes each day a button: a click (or Enter/Space) selects it — a drill-down into\n * that day's rows, a day panel. Without it the days are focusable but inert. */\n onSelect?: (iso: string) => void;\n /** How a value is written in the tooltip and the day's name. Default: `Intl.NumberFormat`\n * in `locale`. Pass a currency formatter for money. */\n formatValue?: (value: number) => string;\n /** Tooltip content for a day. Default: `labels.day(date, value)`. */\n tooltip?: (day: CalendarHeatmapDay) => ReactNode;\n /**\n * Tag each tooltip `data-private`, so the host's demo-mode rule blurs it (the\n * attribute `Tooltip redact` and `StatTile sensitive` carry). ON by default: a heatmap\n * is almost always the user's own figures, and a missing tag is silent — the grid\n * looks anonymous and the bubble spells the amount out on hover.\n */\n sensitive?: boolean;\n /** The value that reaches the top of the scale. Default: the largest value ON SCREEN,\n * so a peak outside the window does not wash the drawn days out to empty. */\n max?: number;\n /** How many non-empty intensity steps. Default 4. */\n levels?: number;\n /** The scale's colour, as any CSS colour. Default `var(--brand)`; each step is this\n * mixed into `--bg-surface`, so the ramp follows the theme. */\n color?: string;\n /**\n * The most days to draw. A longer window keeps its LATEST `maxDays` and says how many\n * it left out (`labels.truncated`) rather than silently ending. Default: no cap.\n */\n maxDays?: number;\n /** Draw the Less … More legend. Default `true`. */\n legend?: boolean;\n /** BCP 47 tag for the dates, month and weekday names and numbers. */\n locale?: string;\n /** `0` = Sunday … `6` = Saturday. Default: the provider's, else the locale's. */\n weekStartsOn?: WeekDay;\n labels?: Partial<CalendarHeatmapLabels>;\n className?: string;\n}\n\nconst DAY_NAME_FORMAT: Intl.DateTimeFormatOptions = {\n weekday: \"long\",\n day: \"numeric\",\n month: \"long\",\n year: \"numeric\",\n};\n\n/** The empty day: a wash of the text colour, like `--bg-hover`, so it reads as a cell\n * on both themes without claiming any value. */\nconst EMPTY_FILL = \"color-mix(in oklab, var(--text-primary) 8%, var(--bg-surface))\";\n\nconst weekdayIndex = (d: Date, weekStart: WeekDay) => (d.getDay() - weekStart + 7) % 7;\n\n/** The step a value falls on: 0 for nothing, else 1…levels by its share of `max`. */\nexport function heatmapLevel(value: number, max: number, levels: number): number {\n if (!(value > 0) || !(max > 0) || levels < 1) return 0;\n return Math.min(levels, Math.max(1, Math.ceil((value / max) * levels)));\n}\n\n/** How much of `color` a step mixes into the surface: 20% for the first step, 100% for\n * the last — the floor keeps the smallest value visibly apart from an empty day. */\nfunction levelPercent(level: number, levels: number): number {\n if (levels <= 1) return 100;\n return Math.round(20 + (80 * (level - 1)) / (levels - 1));\n}\n\nfunction levelFill(level: number, levels: number, color: string): string {\n if (level === 0) return EMPTY_FILL;\n return `color-mix(in oklab, ${color} ${levelPercent(level, levels)}%, var(--bg-surface))`;\n}\n\n/**\n * Days as a grid of shaded squares — how much happened on each, at a glance\n * (a contribution graph, a spending calendar).\n *\n * **Every day is a cell you can reach.** The grid is a `role=\"grid\"` with ONE tab\n * stop (the roving tabindex, as in `MiniCalendar`); the arrows move by the grid's own\n * geometry — in `\"weeks\"` ↑/↓ are the previous/next day and ←/→ a week, in `\"month\"`\n * the other way round, mirrored in RTL — PageUp/PageDown move a month and Home/End go\n * to the window's first/last day. Each cell is named with its whole date AND its value,\n * because the colour is not something a screen reader can say, and carries\n * `data-day=\"YYYY-MM-DD\"` as its identity for tests and for the host.\n *\n * The tooltip is portalled (a year of squares always sits in a sideways scroller) and\n * `data-private` unless `sensitive={false}`. Cell size in `\"weeks\"` is the CSS variable\n * `--heatmap-cell` (default `0.75rem`): `style={{ \"--heatmap-cell\": \"1rem\" }}`.\n */\nexport function CalendarHeatmap({\n data,\n from,\n to,\n layout = \"weeks\",\n selected,\n onSelect,\n formatValue: formatValueProp,\n tooltip,\n sensitive = true,\n max: maxProp,\n levels = 4,\n color = \"var(--brand)\",\n maxDays,\n legend = true,\n locale: localeProp,\n weekStartsOn,\n labels: labelsProp,\n className,\n \"aria-label\": ariaLabel,\n ...rest\n}: CalendarHeatmapProps) {\n const labels = useKitLabels(\"calendarHeatmap\", DEFAULT_CALENDAR_HEATMAP_LABELS, labelsProp);\n const locale = useKitLocale(localeProp);\n const providerWeekStart = useKitWeekStart();\n const weekStart: WeekDay = weekStartsOn ?? providerWeekStart ?? localeWeekStart(locale);\n const numberFormat = useMemo(() => new Intl.NumberFormat(locale), [locale]);\n const formatValue = formatValueProp ?? ((v: number) => numberFormat.format(v));\n\n const values = useMemo(() => {\n const m = new Map<string, number>();\n for (const p of data) m.set(p.date, (m.get(p.date) ?? 0) + p.value);\n return m;\n }, [data]);\n\n // The window, trimmed from the FRONT: the days a person looks for are the recent\n // ones, and a cap that kept the oldest would end the calendar before today.\n const { days, dropped } = useMemo(() => {\n const start = parseIsoDate(from);\n const end = parseIsoDate(to);\n const list: Date[] = [];\n if (!start || !end || end < start) return { days: list, dropped: 0 };\n const cursor = new Date(end);\n const cap = maxDays && maxDays > 0 ? maxDays : Infinity;\n while (cursor >= start && list.length < cap) {\n list.unshift(new Date(cursor));\n cursor.setDate(cursor.getDate() - 1);\n }\n const first = list[0];\n const trimmed = first ? Math.round((first.getTime() - start.getTime()) / 86_400_000) : 0;\n return { days: list, dropped: Math.max(0, trimmed) };\n }, [from, to, maxDays]);\n\n const firstIso = days.length ? toLocalIso(days[0]) : \"\";\n const lastIso = days.length ? toLocalIso(days[days.length - 1]) : \"\";\n\n const max = useMemo(() => {\n if (maxProp !== undefined) return maxProp;\n let m = 0;\n for (const d of days) m = Math.max(m, values.get(toLocalIso(d)) ?? 0);\n return m;\n }, [maxProp, days, values]);\n\n const clampIso = (iso: string) => (iso < firstIso ? firstIso : iso > lastIso ? lastIso : iso);\n\n // The roving tab stop: the selected day, else the latest one.\n const [activeState, setActiveIso] = useState(() => selected || lastIso);\n const [lastSelected, setLastSelected] = useState(selected);\n if (lastSelected !== selected) {\n setLastSelected(selected);\n if (selected) setActiveIso(selected);\n }\n const activeIso = days.length ? clampIso(activeState || lastIso) : \"\";\n\n const gridRef = useRef<HTMLDivElement>(null);\n const scrollerRef = useRef<HTMLDivElement>(null);\n const pendingFocus = useRef<string | null>(null);\n useEffect(() => {\n const iso = pendingFocus.current;\n if (!iso) return;\n pendingFocus.current = null;\n gridRef.current?.querySelector<HTMLElement>(`[data-day=\"${iso}\"]`)?.focus();\n });\n\n // Open the sideways scroller on the latest weeks, not the oldest. In RTL the end is\n // on the left, where browsers count scrollLeft down from 0.\n //\n // And KEEP it there while the box changes size — a sidebar or a contents rail that\n // appears after mount narrows the scroller, which leaves scrollLeft where it was and\n // so shows older weeks than it opened on. The pin holds only while the view sits at\n // the end: a user who scrolls back through the year unpins it, and a resize then\n // leaves their position alone. (Scrolling back to the end pins it again.)\n useLayoutEffect(() => {\n const el = scrollerRef.current;\n if (!el || layout !== \"weeks\") return;\n const toEnd = () => {\n el.scrollLeft = dirOf(el) === \"rtl\" ? -el.scrollWidth : el.scrollWidth;\n };\n toEnd();\n if (typeof ResizeObserver === \"undefined\") return;\n // |scrollLeft| covers both directions: 0 → max in LTR, 0 → -max in RTL.\n let pinned = true;\n const onScroll = () => {\n pinned = Math.abs(el.scrollLeft) >= el.scrollWidth - el.clientWidth - 1;\n };\n const ro = new ResizeObserver(() => {\n if (pinned) toEnd();\n });\n el.addEventListener(\"scroll\", onScroll, { passive: true });\n ro.observe(el);\n return () => {\n ro.disconnect();\n el.removeEventListener(\"scroll\", onScroll);\n };\n }, [layout, firstIso, lastIso]);\n\n const formatDay = (d: Date) => d.toLocaleDateString(locale, DAY_NAME_FORMAT);\n\n const weekdayLabels = useMemo(() => {\n const ref = new Date(2024, 0, 7 + weekStart); // 7 January 2024 was a Sunday\n return Array.from({ length: 7 }, (_, i) => {\n const d = new Date(ref);\n d.setDate(ref.getDate() + i);\n return {\n short: d.toLocaleDateString(locale, { weekday: \"short\" }),\n long: d.toLocaleDateString(locale, { weekday: \"long\" }),\n };\n });\n }, [locale, weekStart]);\n\n const lead = days.length ? weekdayIndex(days[0], weekStart) : 0;\n const weekCount = Math.ceil((lead + days.length) / 7);\n /** The day at position `i` of the week-aligned sequence (blanks before the first). */\n const dayAt = (i: number): Date | null => (i >= lead && i - lead < days.length ? days[i - lead] : null);\n\n const move = (e: KeyboardEvent<HTMLElement>) => {\n const current = parseIsoDate(activeIso);\n if (!current) return;\n const next = new Date(current);\n const step = horizontalStep(e.key, e.currentTarget);\n // In \"weeks\" a row is a weekday, so sideways is a week and up/down is a day.\n const across = layout === \"weeks\" ? 7 : 1;\n const down = layout === \"weeks\" ? 1 : 7;\n switch (step ? \"horizontal\" : e.key) {\n case \"horizontal\":\n next.setDate(next.getDate() + step * across);\n break;\n case \"ArrowUp\":\n next.setDate(next.getDate() - down);\n break;\n case \"ArrowDown\":\n next.setDate(next.getDate() + down);\n break;\n case \"PageUp\":\n next.setTime(addMonthsClamped(next, -1).getTime());\n break;\n case \"PageDown\":\n next.setTime(addMonthsClamped(next, 1).getTime());\n break;\n case \"Home\":\n next.setTime(days[0].getTime());\n break;\n case \"End\":\n next.setTime(days[days.length - 1].getTime());\n break;\n default:\n return;\n }\n e.preventDefault();\n const iso = clampIso(toLocalIso(next));\n if (iso === activeIso) return;\n pendingFocus.current = iso;\n setActiveIso(iso);\n };\n\n const legendLevels = Array.from({ length: levels + 1 }, (_, l) => l);\n\n const cell = (d: Date, wrapClass: string, cellClass: string, withNumber: boolean) => {\n const iso = toLocalIso(d);\n const raw = values.get(iso);\n const value = raw ?? 0;\n const level = heatmapLevel(value, max, levels);\n const fill = levelFill(level, levels, color);\n const formattedDate = formatDay(d);\n const formattedValue = formatValue(value);\n const name = labels.day(formattedDate, formattedValue);\n const label = tooltip\n ? tooltip({ iso, date: d, value, hasData: raw !== undefined, level, formattedDate, formattedValue })\n : name;\n const isSelected = selected === iso;\n // Light text once the fill is the stronger half of the mix — `--bg-surface` is the\n // colour the scale is mixed INTO, so it is the one that contrasts with its far end\n // on either theme.\n const strong = level > 0 && levelPercent(level, levels) >= 45;\n const shared = {\n role: \"gridcell\",\n \"data-day\": iso,\n \"data-level\": level,\n tabIndex: iso === activeIso ? 0 : -1,\n \"aria-label\": name,\n \"aria-selected\": onSelect ? isSelected : undefined,\n onKeyDown: move,\n onFocus: () => {\n if (iso !== activeIso) setActiveIso(iso);\n },\n style: { background: fill, color: strong ? \"var(--bg-surface)\" : \"var(--text-primary)\" },\n className: cn(\n cellClass,\n isSelected && \"ring-2 ring-[var(--text-primary)]\",\n onSelect && \"cursor-pointer hover:ring-1 hover:ring-[var(--brand)]\",\n ),\n } as const;\n const inner = withNumber ? (\n <span aria-hidden className=\"text-[11px] leading-none tabular-nums\">\n {numberFormat.format(d.getDate())}\n </span>\n ) : null;\n return (\n <Tooltip key={iso} label={label} portal redact={sensitive} role=\"none\" className={wrapClass}>\n {onSelect ? (\n <button type=\"button\" {...shared} onClick={() => onSelect(iso)}>\n {inner}\n </button>\n ) : (\n <div {...shared}>{inner}</div>\n )}\n </Tooltip>\n );\n };\n\n const gridName = ariaLabel ?? labels.grid;\n let body: ReactNode;\n if (layout === \"weeks\") {\n const columns = { gridTemplateColumns: `var(--heatmap-label, 2rem) repeat(${weekCount}, var(--heatmap-cell, 0.75rem))` } as CSSProperties;\n const cellSize = \"size-[var(--heatmap-cell,0.75rem)]\";\n // A month's name over the first column that holds its 1st — or over the first\n // column, when the window opens far enough before the next month for it to fit.\n const monthLabels = Array.from({ length: weekCount }, (_, w) => {\n for (let r = 0; r < 7; r++) {\n const d = dayAt(w * 7 + r);\n if (d && (d.getDate() === 1 || (w === 0 && r === lead && d.getDate() <= 14))) {\n return d.toLocaleDateString(locale, { month: \"short\" });\n }\n }\n return \"\";\n });\n body = (\n <div ref={scrollerRef} className=\"overflow-x-auto pb-1\">\n <div ref={gridRef} role=\"grid\" aria-label={gridName} className=\"inline-grid gap-0.5\">\n {/* Decoration: every cell's name already carries its month. */}\n <div aria-hidden className=\"grid gap-0.5 text-[10px] leading-3 text-[var(--text-muted)]\" style={columns}>\n <span />\n {monthLabels.map((m, w) => (\n <span key={w} className=\"overflow-visible whitespace-nowrap\">\n {m}\n </span>\n ))}\n </div>\n {Array.from({ length: 7 }, (_, r) => (\n <div key={r} role=\"row\" className=\"grid gap-0.5\" style={columns}>\n <div\n role=\"rowheader\"\n aria-label={weekdayLabels[r].long}\n className=\"overflow-hidden pe-1 text-[10px] leading-3 text-[var(--text-muted)]\"\n >\n {/* Every other weekday, as a contribution graph does: seven labels\n at this size are a smear. The name is there for all seven. */}\n {r % 2 === 1 ? weekdayLabels[r].short : \"\"}\n </div>\n {Array.from({ length: weekCount }, (_, w) => {\n const d = dayAt(w * 7 + r);\n return d ? (\n cell(d, cellSize, cn(cellSize, \"block rounded-sm\"), false)\n ) : (\n <div key={`pad-${w}`} role=\"gridcell\" className={cellSize} />\n );\n })}\n </div>\n ))}\n </div>\n </div>\n );\n } else {\n const rows = Array.from({ length: weekCount }, (_, w) => w);\n body = (\n <div ref={gridRef} role=\"grid\" aria-label={gridName} className=\"grid gap-1\">\n <div role=\"row\" className=\"grid grid-cols-7 gap-1\">\n {weekdayLabels.map((w, i) => (\n <div\n key={i}\n role=\"columnheader\"\n aria-label={w.long}\n className=\"pb-0.5 text-center text-[10px] uppercase tracking-wide text-[var(--text-muted)]\"\n >\n {w.short}\n </div>\n ))}\n </div>\n {rows.map((w) => (\n <div key={w} role=\"row\" className=\"grid grid-cols-7 gap-1\">\n {Array.from({ length: 7 }, (_, c) => {\n const d = dayAt(w * 7 + c);\n return d ? (\n cell(d, \"aspect-square w-full\", \"flex h-full w-full items-center justify-center rounded\", true)\n ) : (\n <div key={`pad-${c}`} role=\"gridcell\" className=\"aspect-square\" />\n );\n })}\n </div>\n ))}\n </div>\n );\n }\n\n return (\n <div {...rest} className={cn(\"min-w-0\", className)}>\n {dropped > 0 && (\n <div className=\"mb-2 text-xs text-[var(--text-muted)]\">{labels.truncated(dropped)}</div>\n )}\n {body}\n {legend && (\n <div aria-hidden className=\"mt-2 flex items-center justify-end gap-1 text-[10px] text-[var(--text-muted)]\">\n <span className=\"me-0.5\">{labels.less}</span>\n {legendLevels.map((l) => (\n <span\n key={l}\n data-legend-level={l}\n className=\"size-2.5 rounded-sm\"\n style={{ background: levelFill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BAAC,UAAK,WAAU,UAAU,iBAAO,MAAK;AAAA,OACxC;AAAA,KAEJ;AAEJ;","names":["_"]}
1
+ {"version":3,"sources":["../../src/components/calendar-heatmap.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, CSSProperties, KeyboardEvent, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { dirOf, horizontalStep } from \"../lib/direction\";\nimport { addMonthsClamped, localeWeekStart, parseIsoDate, toLocalIso } from \"../lib/dates\";\nimport { useKitLabels, useKitLocale, useKitWeekStart } from \"../i18n/kit-labels\";\nimport { lerpHex, textOn } from \"../theme/chart-palette\";\nimport { parseHex } from \"../theme/color\";\nimport { Tooltip } from \"./tooltip\";\nimport type { WeekDay } from \"./mini-calendar\";\n\n/**\n * Every string the heatmap speaks — the `calendarHeatmap` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`. Dates and\n * values arrive already formatted (in `locale`, and through `formatValue`), so the\n * functions only arrange them.\n */\nexport interface CalendarHeatmapLabels {\n /** Accessible name of the grid. */\n grid: string;\n /**\n * One day: its accessible name, and the tooltip unless `tooltip` is given. `date`\n * is the whole date in `locale` (\"Monday, 14 September 2026\"), `value` the day's\n * figure through `formatValue`.\n */\n day: (date: string, value: string) => string;\n /** The two ends of the legend's scale. */\n less: string;\n more: string;\n /** `maxDays` cut the window: how many of its earliest days are not drawn. */\n truncated: (count: number) => string;\n}\n\n/** English defaults, exported as the `calendarHeatmap` namespace of `UiKitLabels`. */\nexport const DEFAULT_CALENDAR_HEATMAP_LABELS: CalendarHeatmapLabels = {\n grid: \"Daily values\",\n day: (date, value) => `${date}: ${value}`,\n less: \"Less\",\n more: \"More\",\n truncated: (count) =>\n `Showing the most recent days; ${count} earlier ${count === 1 ? \"day is\" : \"days are\"} not shown.`,\n};\n\n/** One day's figure. Several entries for one date are added up. */\nexport interface CalendarHeatmapDatum {\n /** \"YYYY-MM-DD\". */\n date: string;\n value: number;\n}\n\n/** What `tooltip` is told about the day under the pointer. */\nexport interface CalendarHeatmapDay {\n iso: string;\n date: Date;\n /** The day's figure; `0` when `data` has no entry for it (see `hasData`). */\n value: number;\n hasData: boolean;\n /** `0` = empty … `levels` = the busiest. */\n level: number;\n /** The whole date in `locale`. */\n formattedDate: string;\n /** `value` through `formatValue`. */\n formattedValue: string;\n}\n\n/**\n * `onSelect` is omitted from the `<div>` attributes for the reason `MiniCalendar` gives:\n * the DOM event of that name is a text-selection event, and this one answers with a date.\n */\nexport interface CalendarHeatmapProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onSelect\"> {\n data: readonly CalendarHeatmapDatum[];\n /** The window, inclusive, as \"YYYY-MM-DD\". */\n from: string;\n to: string;\n /**\n * `\"weeks\"` (default): the contribution-graph shape — one COLUMN per week, the\n * weekdays down the side, month names along the top; a year fits in ~53 small\n * squares and scrolls sideways where it does not. `\"month\"`: a 7-column calendar\n * with day numbers in large square cells, for a single month on a phone (switch on\n * `useMediaQuery` and narrow `from`/`to` to the month).\n */\n layout?: \"weeks\" | \"month\";\n /** The day shown as selected (\"YYYY-MM-DD\"). */\n selected?: string;\n /** Makes each day a button: a click (or Enter/Space) selects it — a drill-down into\n * that day's rows, a day panel. Without it the days are focusable but inert. */\n onSelect?: (iso: string) => void;\n /** How a value is written in the tooltip and the day's name. Default: `Intl.NumberFormat`\n * in `locale`. Pass a currency formatter for money. */\n formatValue?: (value: number) => string;\n /** Tooltip content for a day. Default: `labels.day(date, value)`. */\n tooltip?: (day: CalendarHeatmapDay) => ReactNode;\n /**\n * Tag each tooltip `data-private`, so the host's demo-mode rule blurs it (the\n * attribute `Tooltip redact` and `StatTile sensitive` carry). ON by default: a heatmap\n * is almost always the user's own figures, and a missing tag is silent — the grid\n * looks anonymous and the bubble spells the amount out on hover.\n */\n sensitive?: boolean;\n /** The value that reaches the top of the scale. Default: the largest value ON SCREEN,\n * so a peak outside the window does not wash the drawn days out to empty. */\n max?: number;\n /** How many non-empty intensity steps. Default 4. */\n levels?: number;\n /** The scale's colour, as any CSS colour. Default `var(--brand)`; each step is this\n * mixed into `--bg-surface`, so the ramp follows the theme. */\n color?: string;\n /**\n * A CONTINUOUS scale from `colorFrom` (the smallest value) to `colorTo` (the busiest\n * day), instead of `levels` steps of `color` — keksdose's palette-store ramp,\n * `seqLow` → `seqHigh`. Both are needed; `color` is then unused. Two `#rrggbb`\n * colours are interpolated in JS, so the fill is a concrete hex and the day number's\n * ink (in `\"month\"`) is MEASURED against it; anything else (a `var()`) is mixed with\n * `color-mix()`. `levels` still sets `data-level` and the legend's swatch count.\n */\n colorFrom?: string;\n colorTo?: string;\n /**\n * A fill of the caller's own for a day with a value: handed the value and the\n * scale's `max`, returns any CSS colour. Wins over `color` and `colorFrom`/`colorTo`.\n * Also paints the legend, at `max × level / levels`.\n */\n fill?: (value: number, max: number) => string;\n /** The fill of a day with no value (or a value of 0). Default: a wash of the text\n * colour over the surface, which reads as a cell on both themes. */\n emptyColor?: string;\n /**\n * Where the window ENDS — the day `maxDays` counts back from, and the last one drawn:\n *\n * - `\"to\"` (default): on `to`.\n * - `\"today\"`: on today.\n * - `\"latest\"`: on the last day that can carry a figure — today, or a later day that\n * actually has a value. A window running into the future (a report's \"all\" preset\n * ends a year ahead) then spends its cells on the days a person is looking for,\n * not on a year of empty ones.\n * - a `\"YYYY-MM-DD\"`: on that day.\n *\n * Always kept inside `from`…`to`.\n */\n anchor?: \"to\" | \"today\" | \"latest\" | (string & {});\n /**\n * The most days to draw. A longer window keeps its LATEST `maxDays` and says how many\n * it left out (`labels.truncated`) rather than silently ending. Default: no cap.\n */\n maxDays?: number;\n /** Draw the Less … More legend. Default `true`. */\n legend?: boolean;\n /** BCP 47 tag for the dates, month and weekday names and numbers. */\n locale?: string;\n /** `0` = Sunday … `6` = Saturday. Default: the provider's, else the locale's. */\n weekStartsOn?: WeekDay;\n labels?: Partial<CalendarHeatmapLabels>;\n className?: string;\n}\n\nconst DAY_NAME_FORMAT: Intl.DateTimeFormatOptions = {\n weekday: \"long\",\n day: \"numeric\",\n month: \"long\",\n year: \"numeric\",\n};\n\n/** The empty day: a wash of the text colour, like `--bg-hover`, so it reads as a cell\n * on both themes without claiming any value. */\nconst EMPTY_FILL = \"color-mix(in oklab, var(--text-primary) 8%, var(--bg-surface))\";\n\nconst weekdayIndex = (d: Date, weekStart: WeekDay) => (d.getDay() - weekStart + 7) % 7;\n\n/** Where the window ends for an {@link CalendarHeatmapProps.anchor}, kept in `[from, to]`.\n * `latestData` is the latest ISO date carrying a value, or `\"\"`. */\nexport function heatmapWindowEnd(\n from: string,\n to: string,\n anchor: string,\n latestData: string,\n today: string = toLocalIso(new Date()),\n): string {\n let end: string;\n if (anchor === \"today\") end = today;\n else if (anchor === \"latest\") end = latestData > today ? latestData : today;\n else if (anchor === \"to\" || !parseIsoDate(anchor)) end = to;\n else end = anchor;\n // ISO dates sort as strings, so the clamp is plain comparison.\n if (end > to) end = to;\n if (end < from) end = from;\n return end;\n}\n\n/** The step a value falls on: 0 for nothing, else 1…levels by its share of `max`. */\nexport function heatmapLevel(value: number, max: number, levels: number): number {\n if (!(value > 0) || !(max > 0) || levels < 1) return 0;\n return Math.min(levels, Math.max(1, Math.ceil((value / max) * levels)));\n}\n\n/** How much of `color` a step mixes into the surface: 20% for the first step, 100% for\n * the last — the floor keeps the smallest value visibly apart from an empty day. */\nfunction levelPercent(level: number, levels: number): number {\n if (levels <= 1) return 100;\n return Math.round(20 + (80 * (level - 1)) / (levels - 1));\n}\n\nfunction levelFill(level: number, levels: number, color: string): string {\n if (level === 0) return EMPTY_FILL;\n return `color-mix(in oklab, ${color} ${levelPercent(level, levels)}%, var(--bg-surface))`;\n}\n\n/**\n * Days as a grid of shaded squares — how much happened on each, at a glance\n * (a contribution graph, a spending calendar).\n *\n * **Every day is a cell you can reach.** The grid is a `role=\"grid\"` with ONE tab\n * stop (the roving tabindex, as in `MiniCalendar`); the arrows move by the grid's own\n * geometry — in `\"weeks\"` ↑/↓ are the previous/next day and ←/→ a week, in `\"month\"`\n * the other way round, mirrored in RTL — PageUp/PageDown move a month and Home/End go\n * to the window's first/last day. Each cell is named with its whole date AND its value,\n * because the colour is not something a screen reader can say, and carries\n * `data-day=\"YYYY-MM-DD\"` as its identity for tests and for the host. Note that in\n * `\"weeks\"` the cells are in DOM order by WEEKDAY ROW (all Mondays, then all\n * Tuesdays…), not by date — query by `data-day`, not by position.\n *\n * The tooltip is portalled (a year of squares always sits in a sideways scroller) and\n * `data-private` unless `sensitive={false}`. Cell size in `\"weeks\"` is the CSS variable\n * `--heatmap-cell` (default `0.75rem`): `style={{ \"--heatmap-cell\": \"1rem\" }}`.\n */\nexport function CalendarHeatmap({\n data,\n from,\n to,\n layout = \"weeks\",\n selected,\n onSelect,\n formatValue: formatValueProp,\n tooltip,\n sensitive = true,\n max: maxProp,\n levels = 4,\n color = \"var(--brand)\",\n colorFrom,\n colorTo,\n fill: fillProp,\n emptyColor,\n anchor = \"to\",\n maxDays,\n legend = true,\n locale: localeProp,\n weekStartsOn,\n labels: labelsProp,\n className,\n \"aria-label\": ariaLabel,\n ...rest\n}: CalendarHeatmapProps) {\n const labels = useKitLabels(\"calendarHeatmap\", DEFAULT_CALENDAR_HEATMAP_LABELS, labelsProp);\n const locale = useKitLocale(localeProp);\n const providerWeekStart = useKitWeekStart();\n const weekStart: WeekDay = weekStartsOn ?? providerWeekStart ?? localeWeekStart(locale);\n const numberFormat = useMemo(() => new Intl.NumberFormat(locale), [locale]);\n const formatValue = formatValueProp ?? ((v: number) => numberFormat.format(v));\n\n const values = useMemo(() => {\n const m = new Map<string, number>();\n for (const p of data) m.set(p.date, (m.get(p.date) ?? 0) + p.value);\n return m;\n }, [data]);\n\n // The window, trimmed from the FRONT: the days a person looks for are the recent\n // ones, and a cap that kept the oldest would end the calendar before today.\n const latestData = useMemo(() => {\n let latest = \"\";\n for (const [iso, v] of values) if (v !== 0 && iso > latest) latest = iso;\n return latest;\n }, [values]);\n const windowEnd = heatmapWindowEnd(from, to, anchor, latestData);\n\n const { days, dropped } = useMemo(() => {\n const start = parseIsoDate(from);\n const end = parseIsoDate(windowEnd);\n const list: Date[] = [];\n if (!start || !end || end < start) return { days: list, dropped: 0 };\n const cursor = new Date(end);\n const cap = maxDays && maxDays > 0 ? maxDays : Infinity;\n while (cursor >= start && list.length < cap) {\n list.unshift(new Date(cursor));\n cursor.setDate(cursor.getDate() - 1);\n }\n const first = list[0];\n const trimmed = first ? Math.round((first.getTime() - start.getTime()) / 86_400_000) : 0;\n return { days: list, dropped: Math.max(0, trimmed) };\n }, [from, windowEnd, maxDays]);\n\n const firstIso = days.length ? toLocalIso(days[0]) : \"\";\n const lastIso = days.length ? toLocalIso(days[days.length - 1]) : \"\";\n\n const max = useMemo(() => {\n if (maxProp !== undefined) return maxProp;\n let m = 0;\n for (const d of days) m = Math.max(m, values.get(toLocalIso(d)) ?? 0);\n return m;\n }, [maxProp, days, values]);\n\n const clampIso = (iso: string) => (iso < firstIso ? firstIso : iso > lastIso ? lastIso : iso);\n\n // The roving tab stop: the selected day, else the latest one.\n const [activeState, setActiveIso] = useState(() => selected || lastIso);\n const [lastSelected, setLastSelected] = useState(selected);\n if (lastSelected !== selected) {\n setLastSelected(selected);\n if (selected) setActiveIso(selected);\n }\n const activeIso = days.length ? clampIso(activeState || lastIso) : \"\";\n\n const gridRef = useRef<HTMLDivElement>(null);\n const scrollerRef = useRef<HTMLDivElement>(null);\n const pendingFocus = useRef<string | null>(null);\n useEffect(() => {\n const iso = pendingFocus.current;\n if (!iso) return;\n pendingFocus.current = null;\n gridRef.current?.querySelector<HTMLElement>(`[data-day=\"${iso}\"]`)?.focus();\n });\n\n // Open the sideways scroller on the latest weeks, not the oldest. In RTL the end is\n // on the left, where browsers count scrollLeft down from 0.\n //\n // And KEEP it there while the box changes size — a sidebar or a contents rail that\n // appears after mount narrows the scroller, which leaves scrollLeft where it was and\n // so shows older weeks than it opened on. The pin holds only while the view sits at\n // the end: a user who scrolls back through the year unpins it, and a resize then\n // leaves their position alone. (Scrolling back to the end pins it again.)\n useLayoutEffect(() => {\n const el = scrollerRef.current;\n if (!el || layout !== \"weeks\") return;\n const toEnd = () => {\n el.scrollLeft = dirOf(el) === \"rtl\" ? -el.scrollWidth : el.scrollWidth;\n };\n toEnd();\n if (typeof ResizeObserver === \"undefined\") return;\n // |scrollLeft| covers both directions: 0 → max in LTR, 0 → -max in RTL.\n let pinned = true;\n const onScroll = () => {\n pinned = Math.abs(el.scrollLeft) >= el.scrollWidth - el.clientWidth - 1;\n };\n const ro = new ResizeObserver(() => {\n if (pinned) toEnd();\n });\n el.addEventListener(\"scroll\", onScroll, { passive: true });\n ro.observe(el);\n return () => {\n ro.disconnect();\n el.removeEventListener(\"scroll\", onScroll);\n };\n }, [layout, firstIso, lastIso]);\n\n const formatDay = (d: Date) => d.toLocaleDateString(locale, DAY_NAME_FORMAT);\n\n const weekdayLabels = useMemo(() => {\n const ref = new Date(2024, 0, 7 + weekStart); // 7 January 2024 was a Sunday\n return Array.from({ length: 7 }, (_, i) => {\n const d = new Date(ref);\n d.setDate(ref.getDate() + i);\n return {\n short: d.toLocaleDateString(locale, { weekday: \"short\" }),\n long: d.toLocaleDateString(locale, { weekday: \"long\" }),\n };\n });\n }, [locale, weekStart]);\n\n const lead = days.length ? weekdayIndex(days[0], weekStart) : 0;\n const weekCount = Math.ceil((lead + days.length) / 7);\n /** The day at position `i` of the week-aligned sequence (blanks before the first). */\n const dayAt = (i: number): Date | null => (i >= lead && i - lead < days.length ? days[i - lead] : null);\n\n const move = (e: KeyboardEvent<HTMLElement>) => {\n const current = parseIsoDate(activeIso);\n if (!current) return;\n const next = new Date(current);\n const step = horizontalStep(e.key, e.currentTarget);\n // In \"weeks\" a row is a weekday, so sideways is a week and up/down is a day.\n const across = layout === \"weeks\" ? 7 : 1;\n const down = layout === \"weeks\" ? 1 : 7;\n switch (step ? \"horizontal\" : e.key) {\n case \"horizontal\":\n next.setDate(next.getDate() + step * across);\n break;\n case \"ArrowUp\":\n next.setDate(next.getDate() - down);\n break;\n case \"ArrowDown\":\n next.setDate(next.getDate() + down);\n break;\n case \"PageUp\":\n next.setTime(addMonthsClamped(next, -1).getTime());\n break;\n case \"PageDown\":\n next.setTime(addMonthsClamped(next, 1).getTime());\n break;\n case \"Home\":\n next.setTime(days[0].getTime());\n break;\n case \"End\":\n next.setTime(days[days.length - 1].getTime());\n break;\n default:\n return;\n }\n e.preventDefault();\n const iso = clampIso(toLocalIso(next));\n if (iso === activeIso) return;\n pendingFocus.current = iso;\n setActiveIso(iso);\n };\n\n const legendLevels = Array.from({ length: levels + 1 }, (_, l) => l);\n const empty = emptyColor ?? EMPTY_FILL;\n const continuous = colorFrom !== undefined && colorTo !== undefined;\n const hexRamp = continuous && parseHex(colorFrom) != null && parseHex(colorTo) != null;\n\n /** A day's fill, and the ink its number is set in (`\"month\"`). */\n const paint = (value: number, level: number): { fill: string; ink: string } => {\n if (level === 0) return { fill: empty, ink: \"var(--text-primary)\" };\n if (fillProp || continuous) {\n const t = max > 0 ? Math.min(1, Math.max(0, value / max)) : 1;\n const fill = fillProp\n ? fillProp(value, max)\n : hexRamp\n ? lerpHex(colorFrom!, colorTo!, t)\n : `color-mix(in oklab, ${colorTo} ${Math.round(t * 100)}%, ${colorFrom})`;\n // Measured where the fill is a colour; a mix of references cannot be measured,\n // and the page's own text colour is the safe answer there.\n const measured = textOn(fill);\n return { fill, ink: measured === \"currentColor\" ? \"var(--text-primary)\" : measured };\n }\n // Light text once the fill is the stronger half of the mix — `--bg-surface` is the\n // colour the scale is mixed INTO, so it is the one that contrasts with its far end\n // on either theme.\n const strong = levelPercent(level, levels) >= 45;\n return {\n fill: levelFill(level, levels, color),\n ink: strong ? \"var(--bg-surface)\" : \"var(--text-primary)\",\n };\n };\n // The legend's swatches: a value that lands on each step (the top one on `max`).\n const legendFill = (l: number) => paint(((max > 0 ? max : 1) * l) / levels, l).fill;\n\n const cell = (d: Date, wrapClass: string, cellClass: string, withNumber: boolean) => {\n const iso = toLocalIso(d);\n const raw = values.get(iso);\n const value = raw ?? 0;\n const level = heatmapLevel(value, max, levels);\n const { fill, ink } = paint(value, level);\n const formattedDate = formatDay(d);\n const formattedValue = formatValue(value);\n const name = labels.day(formattedDate, formattedValue);\n const label = tooltip\n ? tooltip({ iso, date: d, value, hasData: raw !== undefined, level, formattedDate, formattedValue })\n : name;\n const isSelected = selected === iso;\n const shared = {\n role: \"gridcell\",\n \"data-day\": iso,\n \"data-level\": level,\n tabIndex: iso === activeIso ? 0 : -1,\n \"aria-label\": name,\n \"aria-selected\": onSelect ? isSelected : undefined,\n onKeyDown: move,\n onFocus: () => {\n if (iso !== activeIso) setActiveIso(iso);\n },\n style: { background: fill, color: ink },\n className: cn(\n cellClass,\n isSelected && \"ring-2 ring-[var(--text-primary)]\",\n onSelect && \"cursor-pointer hover:ring-1 hover:ring-[var(--brand)]\",\n ),\n } as const;\n const inner = withNumber ? (\n <span aria-hidden className=\"text-[11px] leading-none tabular-nums\">\n {numberFormat.format(d.getDate())}\n </span>\n ) : null;\n return (\n <Tooltip key={iso} label={label} portal redact={sensitive} role=\"none\" className={wrapClass}>\n {onSelect ? (\n <button type=\"button\" {...shared} onClick={() => onSelect(iso)}>\n {inner}\n </button>\n ) : (\n <div {...shared}>{inner}</div>\n )}\n </Tooltip>\n );\n };\n\n const gridName = ariaLabel ?? labels.grid;\n let body: ReactNode;\n if (layout === \"weeks\") {\n const columns = { gridTemplateColumns: `var(--heatmap-label, 2rem) repeat(${weekCount}, var(--heatmap-cell, 0.75rem))` } as CSSProperties;\n const cellSize = \"size-[var(--heatmap-cell,0.75rem)]\";\n // A month's name over the first column that holds its 1st — or over the first\n // column, when the window opens far enough before the next month for it to fit.\n const monthLabels = Array.from({ length: weekCount }, (_, w) => {\n for (let r = 0; r < 7; r++) {\n const d = dayAt(w * 7 + r);\n if (d && (d.getDate() === 1 || (w === 0 && r === lead && d.getDate() <= 14))) {\n return d.toLocaleDateString(locale, { month: \"short\" });\n }\n }\n return \"\";\n });\n body = (\n <div ref={scrollerRef} className=\"overflow-x-auto pb-1\">\n <div ref={gridRef} role=\"grid\" aria-label={gridName} className=\"inline-grid gap-0.5\">\n {/* Decoration: every cell's name already carries its month. */}\n <div aria-hidden className=\"grid gap-0.5 text-[10px] leading-3 text-[var(--text-muted)]\" style={columns}>\n <span />\n {monthLabels.map((m, w) => (\n <span key={w} className=\"overflow-visible whitespace-nowrap\">\n {m}\n </span>\n ))}\n </div>\n {Array.from({ length: 7 }, (_, r) => (\n <div key={r} role=\"row\" className=\"grid gap-0.5\" style={columns}>\n <div\n role=\"rowheader\"\n aria-label={weekdayLabels[r].long}\n className=\"overflow-hidden pe-1 text-[10px] leading-3 text-[var(--text-muted)]\"\n >\n {/* Every other weekday, as a contribution graph does: seven labels\n at this size are a smear. The name is there for all seven. */}\n {r % 2 === 1 ? weekdayLabels[r].short : \"\"}\n </div>\n {Array.from({ length: weekCount }, (_, w) => {\n const d = dayAt(w * 7 + r);\n return d ? (\n cell(d, cellSize, cn(cellSize, \"block rounded-sm\"), false)\n ) : (\n <div key={`pad-${w}`} role=\"gridcell\" className={cellSize} />\n );\n })}\n </div>\n ))}\n </div>\n </div>\n );\n } else {\n const rows = Array.from({ length: weekCount }, (_, w) => w);\n body = (\n <div ref={gridRef} role=\"grid\" aria-label={gridName} className=\"grid gap-1\">\n <div role=\"row\" className=\"grid grid-cols-7 gap-1\">\n {weekdayLabels.map((w, i) => (\n <div\n key={i}\n role=\"columnheader\"\n aria-label={w.long}\n className=\"pb-0.5 text-center text-[10px] uppercase tracking-wide text-[var(--text-muted)]\"\n >\n {w.short}\n </div>\n ))}\n </div>\n {rows.map((w) => (\n <div key={w} role=\"row\" className=\"grid grid-cols-7 gap-1\">\n {Array.from({ length: 7 }, (_, c) => {\n const d = dayAt(w * 7 + c);\n return d ? (\n cell(d, \"aspect-square w-full\", \"flex h-full w-full items-center justify-center rounded\", true)\n ) : (\n <div key={`pad-${c}`} role=\"gridcell\" className=\"aspect-square\" />\n );\n })}\n </div>\n ))}\n </div>\n );\n }\n\n return (\n <div {...rest} className={cn(\"min-w-0\", className)}>\n {dropped > 0 && (\n <div className=\"mb-2 text-xs text-[var(--text-muted)]\">{labels.truncated(dropped)}</div>\n )}\n {body}\n {legend && (\n <div aria-hidden className=\"mt-2 flex items-center justify-end gap-1 text-[10px] text-[var(--text-muted)]\">\n <span className=\"me-0.5\">{labels.less}</span>\n {legendLevels.map((l) => (\n <span\n key={l}\n data-legend-level={l}\n className=\"size-2.5 rounded-sm\"\n style={{ background: legendFill(l) }}\n />\n ))}\n <span className=\"ms-0.5\">{labels.more}</span>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";AA2dM,cAqCI,YArCJ;AA3dN,SAAS,WAAW,iBAAiB,SAAS,QAAQ,gBAAgB;AAEtE,SAAS,UAAU;AACnB,SAAS,OAAO,sBAAsB;AACtC,SAAS,kBAAkB,iBAAiB,cAAc,kBAAkB;AAC5E,SAAS,cAAc,cAAc,uBAAuB;AAC5D,SAAS,SAAS,cAAc;AAChC,SAAS,gBAAgB;AACzB,SAAS,eAAe;AA0BjB,MAAM,kCAAyD;AAAA,EACpE,MAAM;AAAA,EACN,KAAK,CAAC,MAAM,UAAU,GAAG,IAAI,KAAK,KAAK;AAAA,EACvC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WAAW,CAAC,UACV,iCAAiC,KAAK,YAAY,UAAU,IAAI,WAAW,UAAU;AACzF;AAkHA,MAAM,kBAA8C;AAAA,EAClD,SAAS;AAAA,EACT,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AACR;AAIA,MAAM,aAAa;AAEnB,MAAM,eAAe,CAAC,GAAS,eAAwB,EAAE,OAAO,IAAI,YAAY,KAAK;AAI9E,SAAS,iBACd,MACA,IACA,QACA,YACA,QAAgB,WAAW,oBAAI,KAAK,CAAC,GAC7B;AACR,MAAI;AACJ,MAAI,WAAW,QAAS,OAAM;AAAA,WACrB,WAAW,SAAU,OAAM,aAAa,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AU,mBAAtC,OAAO,CAAC,EAA8C;AAAA,MAEpE,CAAC,KARO,CASV,CACD;AAAA,OACH;AAAA,EAEJ;AAEA,SACE,qBAAC,SAAK,GAAG,MAAM,WAAW,GAAG,WAAW,SAAS,GAC9C;AAAA,cAAU,KACT,oBAAC,SAAI,WAAU,yCAAyC,iBAAO,UAAU,OAAO,GAAE;AAAA,IAEnF;AAAA,IACA,UACC,qBAAC,SAAI,eAAW,MAAC,WAAU,iFACzB;AAAA,0BAAC,UAAK,WAAU,UAAU,iBAAO,MAAK;AAAA,MACrC,aAAa,IAAI,CAAC,MACjB;AAAA,QAAC;AAAA;AAAA,UAEC,qBAAmB;AAAA,UACnB,WAAU;AAAA,UACV,OAAO,EAAE,YAAY,WAAW,CAAC,EAAE;AAAA;AAAA,QAH9B;AAAA,MAIP,CACD;AAAA,MACD,oBAAC,UAAK,WAAU,UAAU,iBAAO,MAAK;AAAA,OACxC;AAAA,KAEJ;AAEJ;","names":["_"]}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { createContext, useContext, useId, useRef } from "react";
3
+ import { createContext, useContext, useId, useLayoutEffect, useRef, useState } from "react";
4
4
  import {
5
5
  Legend as RechartsLegend,
6
6
  ResponsiveContainer,
@@ -99,15 +99,21 @@ function ChartTooltipContent({
99
99
  const config = useChart();
100
100
  const tipRef = useRef(null);
101
101
  const items = includeHidden ? payload : payload?.filter((item) => item.hide !== true);
102
- if (!active || !items?.length) return null;
103
- let flip = false;
104
- const boundary = boundaryRef?.current;
105
- if (boundary && coordinate?.x != null) {
102
+ const visible = Boolean(active && items?.length);
103
+ const [flip, setFlip] = useState(false);
104
+ const x = coordinate?.x;
105
+ useLayoutEffect(() => {
106
+ const boundary = boundaryRef?.current;
107
+ if (!visible || !boundary || x == null) {
108
+ setFlip(false);
109
+ return;
110
+ }
106
111
  const offset = isRtl(boundary) ? boundary.scrollWidth - boundary.clientWidth + boundary.scrollLeft : boundary.scrollLeft;
107
- const visibleX = coordinate.x - offset;
112
+ const visibleX = x - offset;
108
113
  const tipWidth = tipRef.current?.offsetWidth ?? 160;
109
- flip = visibleX + tipWidth + 12 > boundary.clientWidth;
110
- }
114
+ setFlip(visibleX + tipWidth + 12 > boundary.clientWidth);
115
+ }, [visible, x, boundaryRef, payload, label]);
116
+ if (!visible || !items) return null;
111
117
  return /* @__PURE__ */ jsxs(
112
118
  "div",
113
119
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/chart.tsx"],"sourcesContent":["// shadcn/ui chart kit — vendored (MIT) and adapted for this app:\n// - Recharts 3 instead of 2\n// - the original keys its styling off shadcn theme tokens (--muted-foreground,\n// --border, bg-background …). This app has no shadcn token layer, so those\n// are mapped onto this kit's own tokens (--text-muted, --border, --bg-surface\n// …), which follow the active palette preset and flip with the theme by\n// themselves — hence no `dark:` variants anywhere below.\n// The value on show is the *structure*: config-driven colors injected as CSS\n// vars, muted axis/grid styling, and a polished tooltip/legend — the things\n// that make shadcn charts read as \"designed\" rather than \"default Recharts\".\nimport { createContext, useContext, useId, useRef } from \"react\";\nimport type { ComponentProps, CSSProperties, ReactNode, RefObject } from \"react\";\nimport {\n Legend as RechartsLegend,\n ResponsiveContainer,\n Tooltip as RechartsTooltip,\n} from \"recharts\";\nimport { cn } from \"../lib/cn\";\nimport { isRtl } from \"../lib/direction\";\n\nexport interface ChartSeriesConfig {\n label: ReactNode;\n color: string;\n}\n\nexport type ChartConfig = Record<string, ChartSeriesConfig>;\n\nconst ChartContext = createContext<ChartConfig | null>(null);\n\nexport function useChart(): ChartConfig {\n const ctx = useContext(ChartContext);\n if (!ctx) throw new Error(\"useChart must be used within a <ChartContainer />\");\n return ctx;\n}\n\ninterface ChartContainerProps extends ComponentProps<\"div\"> {\n config: ChartConfig;\n children: ComponentProps<typeof ResponsiveContainer>[\"children\"];\n}\n\n/**\n * The shell every chart in the kit is drawn inside.\n *\n * **The plot is not mirrored in RTL.** An x axis is a number line or a timeline, and\n * both run left-to-right in Hebrew and Arabic charts as much as in English ones; a\n * time axis flipped to run right-to-left is the surprise, not the courtesy. So no\n * `reversed` on any axis, and the SVG is pinned to `direction: ltr` — without that it\n * inherits the page's `rtl`, which flips what `text-anchor: end` means, and the tick\n * labels of a left-hand y axis are drawn INTO the plot instead of beside it. Text\n * inside the SVG still shapes by its own script; only the anchoring is physical.\n * The HTML around the plot — legend, tooltip, the zoom reset button — follows the\n * page's direction like any other markup. A consumer who does want a mirrored\n * category axis passes `reversed` on its own `XAxis`.\n */\nexport function ChartContainer({ id, className, children, config, ...props }: ChartContainerProps) {\n const uid = useId();\n // The id is pasted into an UNQUOTED `[data-chart=…]` selector below, so it has to be\n // a CSS identifier: one stray space or `#` and the browser discards the whole rule,\n // taking every series colour with it — silently, because an invalid rule is not an\n // error anywhere. `useId()` gives `:r0:`, and a consumer-supplied id gives whatever\n // they typed, so both are filtered rather than just the colons.\n const chartId = `chart-${(id ?? uid).replace(/[^A-Za-z0-9_-]/g, \"\")}`;\n return (\n <ChartContext.Provider value={config}>\n <div\n data-chart={chartId}\n className={cn(\n // touch-pan-y lets a vertical finger drag still scroll the page while\n // a horizontal drag is handed to recharts for tooltip scrubbing,\n // instead of the page scrolling underneath the gesture (feedback #292).\n \"flex w-full touch-pan-y justify-center text-xs\",\n // physical anchoring for the unmirrored plot (see the doc comment above)\n \"[&_.recharts-surface]:[direction:ltr]\",\n // muted axis labels + gridlines; one class each, since the tokens\n // already carry the light/dark values\n \"[&_.recharts-cartesian-axis-tick_text]:fill-[var(--text-muted)]\",\n \"[&_.recharts-cartesian-grid_line]:stroke-[var(--border)]/70\",\n // hairline hover cursor instead of the heavy default\n \"[&_.recharts-curve.recharts-tooltip-cursor]:stroke-[var(--border-strong)]\",\n \"[&_.recharts-rectangle.recharts-tooltip-cursor]:fill-[var(--bg-hover)]\",\n // kill the focus outlines & white sector strokes Recharts adds\n \"[&_.recharts-sector]:outline-none [&_.recharts-sector[stroke='#fff']]:stroke-transparent\",\n \"[&_.recharts-layer]:outline-none [&_.recharts-surface]:outline-none [&_.recharts-dot[stroke='#fff']]:stroke-transparent\",\n className,\n )}\n {...props}\n >\n <ChartStyle id={chartId} config={config} />\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n {children}\n </ResponsiveContainer>\n </div>\n </ChartContext.Provider>\n );\n}\n\n/**\n * A config key, which becomes the tail of a custom-property NAME.\n *\n * `dangerouslySetInnerHTML` means what it says: nothing below is escaped by React, and\n * a `ChartConfig` is not necessarily written by hand — kastlan builds one from category\n * rows in its database, so these keys are user data. A key containing `}` closes this\n * rule, and whatever follows it in that key becomes a NEW rule — one that applies to\n * the whole document rather than to this one chart.\n */\nconst CSS_IDENT = /^[A-Za-z_][A-Za-z0-9_-]*$/;\n\n/**\n * A config colour, which becomes a declaration VALUE.\n *\n * Every form a palette actually produces: both hex spellings, the functional notations\n * — with the argument list restricted to the characters those functions can legally\n * contain, so no `;`, no `}` and no nested `url(` — and `var(--token)`, which is what\n * this kit's own `paletteFor`/`CHART_COLORS` return. `var()`'s optional FALLBACK is\n * deliberately not accepted: its second argument is an arbitrary value, i.e. the same\n * hole in a shape that looks safe.\n */\nconst CSS_COLOR =\n /^(?:#[0-9a-fA-F]{3}|#[0-9a-fA-F]{6}|(?:rgba?|hsla?)\\([0-9A-Za-z.,%/ -]*\\)|var\\(--[A-Za-z0-9_-]+\\))$/;\n\n/**\n * The colour an entry is painted with, or `undefined` when the style block refuses it.\n *\n * The one gate both sides go through: {@link ChartStyle} emits exactly these, and the\n * legend and tooltip swatches show exactly these. They used to read `config[key].color`\n * directly, so an entry the style block had skipped still showed its configured colour\n * in the key — a swatch promising a colour the series was never painted in.\n */\nfunction paintedColor(key: string, entry: ChartSeriesConfig | undefined): string | undefined {\n if (!entry?.color) return undefined;\n return CSS_IDENT.test(key) && CSS_COLOR.test(entry.color) ? entry.color : undefined;\n}\n\n// Inject each series colour as a `--color-<key>` custom property scoped to this\n// chart, so chart JSX can refer to `var(--color-total)` and the legend/tooltip\n// stay in sync from one source of truth.\nfunction ChartStyle({ id, config }: { id: string; config: ChartConfig }) {\n const entries = Object.entries(config).filter(([key, c]) => {\n if (!c.color) return false;\n // Skipping the entry costs that one series its `var(--color-…)` and leaves the rest\n // of the chart painted; emitting it unchecked costs the page. The warning is so the\n // consumer finds out from their console rather than from a colourless bar.\n if (!CSS_IDENT.test(key)) {\n console.warn(`[ui-kit] chart config key is not a CSS identifier, skipped: ${key}`);\n return false;\n }\n if (!CSS_COLOR.test(c.color)) {\n console.warn(`[ui-kit] chart config colour for \"${key}\" is not a colour, skipped: ${c.color}`);\n return false;\n }\n return true;\n });\n if (!entries.length) return null;\n const css = `[data-chart=${id}] {\\n${entries\n .map(([key, c]) => ` --color-${key}: ${c.color};`)\n .join(\"\\n\")}\\n}`;\n return <style dangerouslySetInnerHTML={{ __html: css }} />;\n}\n\n/**\n * recharts' `Tooltip`, with `filterNull` defaulting to **false**.\n *\n * recharts drops every payload entry whose value is `null`/`undefined` before the\n * content sees it, so the missing-value path {@link ChartTooltipContent} documents —\n * the em dash, `formatValue(undefined)` — never ran under the default: a series with a\n * gap at the cursor simply vanished from the tooltip, which reads as \"this series does\n * not exist here\" rather than \"it has no value here\". Kept, the entry prints \"—\".\n *\n * The other half of that filter — dropping series drawn with `hide` — is redone by\n * `ChartTooltipContent` itself (honouring `includeHidden`), so a legend toggle still\n * takes a series out of the tooltip. Pass `filterNull` to get recharts' behaviour back.\n */\nexport function ChartTooltip(props: ComponentProps<typeof RechartsTooltip>) {\n return <RechartsTooltip filterNull={false} {...props} />;\n}\nexport const ChartLegend = RechartsLegend;\n\ninterface TooltipPayloadItem {\n dataKey?: string | number;\n name?: string | number;\n value?: number | string;\n color?: string;\n /** A series drawn with `hide` — dropped here, see {@link ChartTooltip}. */\n hide?: boolean;\n payload?: Record<string, unknown>;\n}\n\n/**\n * What a series has no value for at this point: a gap in a history, a projection that\n * has not happened yet, a field that did not exist at an earlier capture.\n *\n * An em dash rather than an empty cell, so the row still lines up with its siblings and\n * the reader can see that the series WAS asked and had nothing, rather than wondering\n * whether it was dropped. It is a mark, not a word, so there is nothing here to\n * translate and no label prop to resolve; a caller who wants words passes\n * `formatValue`, which is handed the `undefined` and decides.\n */\nconst NO_VALUE = \"—\";\n\n/**\n * The number this payload item carries, or `undefined` when it carries none.\n *\n * This was `item.value ?? 0`, so every one of the absences above printed a confident\n * \"0\" that appears nowhere in the data — a fabricated figure in a tooltip, which is the\n * one place a reader goes to check an exact number. keksdose found it and wrapped the\n * component rather than trust it. `\"\"` and a non-numeric string are the same absence\n * spelled differently (recharts hands a string value straight through from the data),\n * and are answered the same way.\n */\nfunction tooltipValue(value: number | string | undefined): number | undefined {\n if (value == null || value === \"\") return undefined;\n const n = typeof value === \"string\" ? Number(value) : value;\n return Number.isFinite(n) ? n : undefined;\n}\n\ninterface ChartTooltipContentProps {\n active?: boolean;\n payload?: TooltipPayloadItem[];\n label?: string | number;\n indicator?: \"dot\" | \"line\";\n hideLabel?: boolean;\n labelFormatter?: (label: string | number) => ReactNode;\n /** Formats one series' value for display. NOT called when the series has no value at\n * this point — {@link ChartTooltipContentProps.formatValue} is the one that is. */\n valueFormatter?: (value: number) => ReactNode;\n /** Formats one series' value INCLUDING its absence: handed `undefined` for a gap, a\n * projection that has not happened yet, or a field that did not exist at an earlier\n * capture, and whatever it returns is rendered as-is. Only the caller knows whether\n * that absence reads as a dash, a \"not yet\" or a genuine zero, so this is how it\n * says. Supplying it wins over `valueFormatter` for every value.\n *\n * It sits NEXT to `valueFormatter` rather than widening it because that prop's\n * parameter is contextually typed at every call site there is — `(v) => money(v)` —\n * so widening it to `number | undefined` is a compile error in all three consuming\n * apps, which is a breaking change this module does not get to make by itself. */\n formatValue?: (value: number | undefined) => ReactNode;\n /** Cursor position within the chart, injected by recharts. Used with\n * {@link boundaryRef} to decide whether to flip the tooltip. */\n coordinate?: { x?: number; y?: number };\n /** When set, the tooltip flips to the LEFT of the cursor if it would otherwise\n * spill past the right edge of this (usually horizontally-scrolling) container\n * — e.g. a wide chart whose rightmost bars sat off-screen (feedback #77). */\n boundaryRef?: RefObject<HTMLElement | null>;\n /** Injected by recharts: keep series drawn with `hide` in the tooltip. */\n includeHidden?: boolean;\n}\n\nexport function ChartTooltipContent({\n active,\n payload,\n label,\n indicator = \"dot\",\n hideLabel = false,\n labelFormatter,\n valueFormatter,\n formatValue,\n coordinate,\n boundaryRef,\n includeHidden = false,\n}: ChartTooltipContentProps) {\n const config = useChart();\n const tipRef = useRef<HTMLDivElement>(null);\n // `ChartTooltip` keeps null values (so they can print \"—\"), which also keeps the\n // series a legend toggle switched off with `hide`; those go here instead.\n const items = includeHidden ? payload : payload?.filter((item) => item.hide !== true);\n if (!active || !items?.length) return null;\n // Recharts anchors the tooltip at coordinate.x inside the full (scrolled) chart\n // width; subtract the container's scrollLeft to get its on-screen x, then flip\n // left if the tooltip's own width would run past the visible right edge.\n //\n // Both the cursor and the flip are PHYSICAL (the plot is never mirrored, see\n // `ChartContainer`), but an RTL scroller counts `scrollLeft` from its right edge —\n // 0 at the start, negative going left — so there the content's left edge sits\n // `scrollWidth - clientWidth + scrollLeft` px to the left of the visible one.\n let flip = false;\n const boundary = boundaryRef?.current;\n if (boundary && coordinate?.x != null) {\n const offset = isRtl(boundary)\n ? boundary.scrollWidth - boundary.clientWidth + boundary.scrollLeft\n : boundary.scrollLeft;\n const visibleX = coordinate.x - offset;\n const tipWidth = tipRef.current?.offsetWidth ?? 160;\n flip = visibleX + tipWidth + 12 > boundary.clientWidth;\n }\n return (\n <div\n ref={tipRef}\n style={boundaryRef ? { transform: flip ? \"translateX(calc(-100% - 12px))\" : \"translateX(12px)\" } : undefined}\n className=\"min-w-[9rem] rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] px-2.5 py-2 text-xs shadow-xl\"\n >\n {!hideLabel && label != null && (\n <div className=\"mb-1.5 font-medium text-[var(--text-primary)]\">\n {labelFormatter ? labelFormatter(label) : label}\n </div>\n )}\n <div className=\"grid gap-1.5\">\n {items.map((item, i) => {\n // Bars/lines/areas identify a series by dataKey; pies/treemaps key off\n // `name` (the nameKey value). Prefer whichever the config knows.\n const dk = item.dataKey != null ? String(item.dataKey) : undefined;\n const nm = item.name != null ? String(item.name) : undefined;\n const cfgKey = dk && config[dk] ? dk : nm && config[nm] ? nm : (dk ?? nm ?? String(i));\n const series = config[cfgKey];\n const fill = typeof item.payload?.fill === \"string\" ? item.payload.fill : undefined;\n // The data point's own `fill` before recharts' `item.color`: a treemap tile,\n // or a bar with a per-cell colour, IS the colour the reader is pointing at,\n // while `item.color` is the series-wide one — every tile's swatch came out\n // `--chart-1` whatever colour the tile was.\n const color = paintedColor(cfgKey, series) ?? fill ?? item.color ?? \"#64748b\";\n const name = series?.label ?? nm ?? cfgKey;\n const raw = tooltipValue(item.value);\n let shown: ReactNode;\n if (formatValue) shown = formatValue(raw);\n else if (raw == null) shown = NO_VALUE;\n else shown = valueFormatter ? valueFormatter(raw) : raw;\n return (\n <div key={`${cfgKey}-${i}`} className=\"flex items-center gap-2\">\n <span\n className={cn(\n \"shrink-0 rounded-[2px]\",\n indicator === \"dot\" ? \"h-2.5 w-2.5 rounded-full\" : \"h-2.5 w-1\",\n )}\n style={{ backgroundColor: color }}\n />\n <span className=\"text-[var(--text-muted)]\">{name}</span>\n <span data-private className=\"ms-auto font-mono font-medium tabular-nums text-[var(--text-primary)]\">\n {shown}\n </span>\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\ninterface LegendPayloadItem {\n value?: string;\n dataKey?: string | number;\n color?: string;\n}\n\ninterface ChartLegendContentProps {\n payload?: LegendPayloadItem[];\n onItemClick?: (key: string) => void;\n /**\n * TOGGLE mode (recommended): the series currently switched off. Each entry is a\n * toggle button — pressed while its series is shown — and a hidden one is drawn\n * faded with its label struck through. Several can be off at once; pair with\n * `toggleHidden(hidden, key)` in `onItemClick` and `hide` on the chart's series.\n */\n hiddenKeys?: ReadonlySet<string> | readonly string[];\n /**\n * ISOLATE mode: the one series shown in full, every other entry dimmed. Kept for\n * the charts built on it; a legend where each entry switches its own series is\n * what readers expect from a legend, so prefer `hiddenKeys`.\n */\n activeKey?: string | null;\n}\n\nexport function ChartLegendContent({\n payload,\n onItemClick,\n hiddenKeys,\n activeKey,\n}: ChartLegendContentProps) {\n const hidden = hiddenKeys ? new Set(hiddenKeys) : null;\n const config = useChart();\n if (!payload?.length) return null;\n return (\n <div className=\"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 pt-3\">\n {payload.map((item, i) => {\n const dk = item.dataKey != null ? String(item.dataKey) : undefined;\n const vv = item.value != null ? String(item.value) : undefined;\n const cfgKey = dk && config[dk] ? dk : vv && config[vv] ? vv : (dk ?? vv ?? String(i));\n const series = config[cfgKey];\n const color = paintedColor(cfgKey, series) ?? item.color ?? \"#64748b\";\n const label = series?.label ?? vv ?? cfgKey;\n const off = hidden?.has(cfgKey) ?? false;\n const dimmed = off || (activeKey != null && activeKey !== cfgKey);\n const className = cn(\n \"flex items-center gap-1.5 text-[var(--text-secondary)] transition-opacity\",\n onItemClick ? \"cursor-pointer hover:opacity-80\" : \"cursor-default\",\n dimmed && \"opacity-40\",\n );\n const swatch = (\n <span\n aria-hidden\n className=\"h-2.5 w-2.5 shrink-0 rounded-[3px]\"\n style={{ backgroundColor: color } as CSSProperties}\n />\n );\n // A legend with no `onItemClick` is a KEY, not a control — and that is every\n // legend in kastlan, where this rendered N focusable buttons per chart that did\n // nothing when activated. A keyboard user paid the tab stops for all of them,\n // and a screen reader announced each one as a button, promising an action there\n // was none of. The interactive branch is unchanged.\n return onItemClick ? (\n <button\n key={`${cfgKey}-${i}`}\n type=\"button\"\n onClick={() => onItemClick(cfgKey)}\n // Toggles report their state: in toggle mode pressed = the series is shown;\n // in isolate mode pressed = the isolated one. With neither supplied the\n // legend knows nothing about state, and a pressed=\"false\" it cannot vouch\n // for would lie — so it says nothing.\n aria-pressed={\n hidden ? !off : activeKey === undefined ? undefined : activeKey === cfgKey\n }\n className={className}\n >\n {swatch}\n <span className={cn(off && \"line-through\")}>{label}</span>\n </button>\n ) : (\n <span key={`${cfgKey}-${i}`} className={className}>\n {swatch}\n {label}\n </span>\n );\n })}\n </div>\n );\n}\n"],"mappings":";AAgEM,SAuBE,KAvBF;AAtDN,SAAS,eAAe,YAAY,OAAO,cAAc;AAEzD;AAAA,EACE,UAAU;AAAA,EACV;AAAA,EACA,WAAW;AAAA,OACN;AACP,SAAS,UAAU;AACnB,SAAS,aAAa;AAStB,MAAM,eAAe,cAAkC,IAAI;AAEpD,SAAS,WAAwB;AACtC,QAAM,MAAM,WAAW,YAAY;AACnC,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,mDAAmD;AAC7E,SAAO;AACT;AAqBO,SAAS,eAAe,EAAE,IAAI,WAAW,UAAU,QAAQ,GAAG,MAAM,GAAwB;AACjG,QAAM,MAAM,MAAM;AAMlB,QAAM,UAAU,UAAU,MAAM,KAAK,QAAQ,mBAAmB,EAAE,CAAC;AACnE,SACE,oBAAC,aAAa,UAAb,EAAsB,OAAO,QAC5B;AAAA,IAAC;AAAA;AAAA,MACC,cAAY;AAAA,MACZ,WAAW;AAAA;AAAA;AAAA;AAAA,QAIT;AAAA;AAAA,QAEA;AAAA;AAAA;AAAA,QAGA;AAAA,QACA;AAAA;AAAA,QAEA;AAAA,QACA;AAAA;AAAA,QAEA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAEJ;AAAA,4BAAC,cAAW,IAAI,SAAS,QAAgB;AAAA,QACzC,oBAAC,uBAAoB,OAAM,QAAO,QAAO,QACtC,UACH;AAAA;AAAA;AAAA,EACF,GACF;AAEJ;AAWA,MAAM,YAAY;AAYlB,MAAM,YACJ;AAUF,SAAS,aAAa,KAAa,OAA0D;AAC3F,MAAI,CAAC,OAAO,MAAO,QAAO;AAC1B,SAAO,UAAU,KAAK,GAAG,KAAK,UAAU,KAAK,MAAM,KAAK,IAAI,MAAM,QAAQ;AAC5E;AAKA,SAAS,WAAW,EAA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AAC;AAAA;AAAA,QACC,eAAW;AAAA,QACX,WAAU;AAAA,QACV,OAAO,EAAE,iBAAiB,MAAM;AAAA;AAAA,IAClC;AAOF,WAAO,cACL;AAAA,MAAC;AAAA;AAAA,QAEC,MAAK;AAAA,QACL,SAAS,MAAM,YAAY,MAAM;AAAA,QAKjC,gBACE,SAAS,CAAC,MAAM,cAAc,SAAY,SAAY,cAAc;AAAA,QAEtE;AAAA,QAEC;AAAA;AAAA,UACD,oBAAC,UAAK,WAAW,GAAG,OAAO,cAAc,GAAI,iBAAM;AAAA;AAAA;AAAA,MAb9C,GAAG,MAAM,IAAI,CAAC;AAAA,IAcrB,IAEA,qBAAC,UAA4B,WAC1B;AAAA;AAAA,MACA;AAAA,SAFQ,GAAG,MAAM,IAAI,CAAC,EAGzB;AAAA,EAEJ,CAAC,GACH;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/chart.tsx"],"sourcesContent":["// shadcn/ui chart kit — vendored (MIT) and adapted for this app:\n// - Recharts 3 instead of 2\n// - the original keys its styling off shadcn theme tokens (--muted-foreground,\n// --border, bg-background …). This app has no shadcn token layer, so those\n// are mapped onto this kit's own tokens (--text-muted, --border, --bg-surface\n// …), which follow the active palette preset and flip with the theme by\n// themselves — hence no `dark:` variants anywhere below.\n// The value on show is the *structure*: config-driven colors injected as CSS\n// vars, muted axis/grid styling, and a polished tooltip/legend — the things\n// that make shadcn charts read as \"designed\" rather than \"default Recharts\".\nimport { createContext, useContext, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ComponentProps, CSSProperties, ReactNode, RefObject } from \"react\";\nimport {\n Legend as RechartsLegend,\n ResponsiveContainer,\n Tooltip as RechartsTooltip,\n} from \"recharts\";\nimport { cn } from \"../lib/cn\";\nimport { isRtl } from \"../lib/direction\";\n\nexport interface ChartSeriesConfig {\n label: ReactNode;\n color: string;\n}\n\nexport type ChartConfig = Record<string, ChartSeriesConfig>;\n\nconst ChartContext = createContext<ChartConfig | null>(null);\n\nexport function useChart(): ChartConfig {\n const ctx = useContext(ChartContext);\n if (!ctx) throw new Error(\"useChart must be used within a <ChartContainer />\");\n return ctx;\n}\n\ninterface ChartContainerProps extends ComponentProps<\"div\"> {\n config: ChartConfig;\n children: ComponentProps<typeof ResponsiveContainer>[\"children\"];\n}\n\n/**\n * The shell every chart in the kit is drawn inside.\n *\n * **The plot is not mirrored in RTL.** An x axis is a number line or a timeline, and\n * both run left-to-right in Hebrew and Arabic charts as much as in English ones; a\n * time axis flipped to run right-to-left is the surprise, not the courtesy. So no\n * `reversed` on any axis, and the SVG is pinned to `direction: ltr` — without that it\n * inherits the page's `rtl`, which flips what `text-anchor: end` means, and the tick\n * labels of a left-hand y axis are drawn INTO the plot instead of beside it. Text\n * inside the SVG still shapes by its own script; only the anchoring is physical.\n * The HTML around the plot — legend, tooltip, the zoom reset button — follows the\n * page's direction like any other markup. A consumer who does want a mirrored\n * category axis passes `reversed` on its own `XAxis`.\n */\nexport function ChartContainer({ id, className, children, config, ...props }: ChartContainerProps) {\n const uid = useId();\n // The id is pasted into an UNQUOTED `[data-chart=…]` selector below, so it has to be\n // a CSS identifier: one stray space or `#` and the browser discards the whole rule,\n // taking every series colour with it — silently, because an invalid rule is not an\n // error anywhere. `useId()` gives `:r0:`, and a consumer-supplied id gives whatever\n // they typed, so both are filtered rather than just the colons.\n const chartId = `chart-${(id ?? uid).replace(/[^A-Za-z0-9_-]/g, \"\")}`;\n return (\n <ChartContext.Provider value={config}>\n <div\n data-chart={chartId}\n className={cn(\n // touch-pan-y lets a vertical finger drag still scroll the page while\n // a horizontal drag is handed to recharts for tooltip scrubbing,\n // instead of the page scrolling underneath the gesture (feedback #292).\n \"flex w-full touch-pan-y justify-center text-xs\",\n // physical anchoring for the unmirrored plot (see the doc comment above)\n \"[&_.recharts-surface]:[direction:ltr]\",\n // muted axis labels + gridlines; one class each, since the tokens\n // already carry the light/dark values\n \"[&_.recharts-cartesian-axis-tick_text]:fill-[var(--text-muted)]\",\n \"[&_.recharts-cartesian-grid_line]:stroke-[var(--border)]/70\",\n // hairline hover cursor instead of the heavy default\n \"[&_.recharts-curve.recharts-tooltip-cursor]:stroke-[var(--border-strong)]\",\n \"[&_.recharts-rectangle.recharts-tooltip-cursor]:fill-[var(--bg-hover)]\",\n // kill the focus outlines & white sector strokes Recharts adds\n \"[&_.recharts-sector]:outline-none [&_.recharts-sector[stroke='#fff']]:stroke-transparent\",\n \"[&_.recharts-layer]:outline-none [&_.recharts-surface]:outline-none [&_.recharts-dot[stroke='#fff']]:stroke-transparent\",\n className,\n )}\n {...props}\n >\n <ChartStyle id={chartId} config={config} />\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n {children}\n </ResponsiveContainer>\n </div>\n </ChartContext.Provider>\n );\n}\n\n/**\n * A config key, which becomes the tail of a custom-property NAME.\n *\n * `dangerouslySetInnerHTML` means what it says: nothing below is escaped by React, and\n * a `ChartConfig` is not necessarily written by hand — kastlan builds one from category\n * rows in its database, so these keys are user data. A key containing `}` closes this\n * rule, and whatever follows it in that key becomes a NEW rule — one that applies to\n * the whole document rather than to this one chart.\n */\nconst CSS_IDENT = /^[A-Za-z_][A-Za-z0-9_-]*$/;\n\n/**\n * A config colour, which becomes a declaration VALUE.\n *\n * Every form a palette actually produces: both hex spellings, the functional notations\n * — with the argument list restricted to the characters those functions can legally\n * contain, so no `;`, no `}` and no nested `url(` — and `var(--token)`, which is what\n * this kit's own `paletteFor`/`CHART_COLORS` return. `var()`'s optional FALLBACK is\n * deliberately not accepted: its second argument is an arbitrary value, i.e. the same\n * hole in a shape that looks safe.\n */\nconst CSS_COLOR =\n /^(?:#[0-9a-fA-F]{3}|#[0-9a-fA-F]{6}|(?:rgba?|hsla?)\\([0-9A-Za-z.,%/ -]*\\)|var\\(--[A-Za-z0-9_-]+\\))$/;\n\n/**\n * The colour an entry is painted with, or `undefined` when the style block refuses it.\n *\n * The one gate both sides go through: {@link ChartStyle} emits exactly these, and the\n * legend and tooltip swatches show exactly these. They used to read `config[key].color`\n * directly, so an entry the style block had skipped still showed its configured colour\n * in the key — a swatch promising a colour the series was never painted in.\n */\nfunction paintedColor(key: string, entry: ChartSeriesConfig | undefined): string | undefined {\n if (!entry?.color) return undefined;\n return CSS_IDENT.test(key) && CSS_COLOR.test(entry.color) ? entry.color : undefined;\n}\n\n// Inject each series colour as a `--color-<key>` custom property scoped to this\n// chart, so chart JSX can refer to `var(--color-total)` and the legend/tooltip\n// stay in sync from one source of truth.\nfunction ChartStyle({ id, config }: { id: string; config: ChartConfig }) {\n const entries = Object.entries(config).filter(([key, c]) => {\n if (!c.color) return false;\n // Skipping the entry costs that one series its `var(--color-…)` and leaves the rest\n // of the chart painted; emitting it unchecked costs the page. The warning is so the\n // consumer finds out from their console rather than from a colourless bar.\n if (!CSS_IDENT.test(key)) {\n console.warn(`[ui-kit] chart config key is not a CSS identifier, skipped: ${key}`);\n return false;\n }\n if (!CSS_COLOR.test(c.color)) {\n console.warn(`[ui-kit] chart config colour for \"${key}\" is not a colour, skipped: ${c.color}`);\n return false;\n }\n return true;\n });\n if (!entries.length) return null;\n const css = `[data-chart=${id}] {\\n${entries\n .map(([key, c]) => ` --color-${key}: ${c.color};`)\n .join(\"\\n\")}\\n}`;\n return <style dangerouslySetInnerHTML={{ __html: css }} />;\n}\n\n/**\n * recharts' `Tooltip`, with `filterNull` defaulting to **false**.\n *\n * recharts drops every payload entry whose value is `null`/`undefined` before the\n * content sees it, so the missing-value path {@link ChartTooltipContent} documents —\n * the em dash, `formatValue(undefined)` — never ran under the default: a series with a\n * gap at the cursor simply vanished from the tooltip, which reads as \"this series does\n * not exist here\" rather than \"it has no value here\". Kept, the entry prints \"—\".\n *\n * The other half of that filter — dropping series drawn with `hide` — is redone by\n * `ChartTooltipContent` itself (honouring `includeHidden`), so a legend toggle still\n * takes a series out of the tooltip. Pass `filterNull` to get recharts' behaviour back.\n */\nexport function ChartTooltip(props: ComponentProps<typeof RechartsTooltip>) {\n return <RechartsTooltip filterNull={false} {...props} />;\n}\nexport const ChartLegend = RechartsLegend;\n\ninterface TooltipPayloadItem {\n dataKey?: string | number;\n name?: string | number;\n value?: number | string;\n color?: string;\n /** A series drawn with `hide` — dropped here, see {@link ChartTooltip}. */\n hide?: boolean;\n payload?: Record<string, unknown>;\n}\n\n/**\n * What a series has no value for at this point: a gap in a history, a projection that\n * has not happened yet, a field that did not exist at an earlier capture.\n *\n * An em dash rather than an empty cell, so the row still lines up with its siblings and\n * the reader can see that the series WAS asked and had nothing, rather than wondering\n * whether it was dropped. It is a mark, not a word, so there is nothing here to\n * translate and no label prop to resolve; a caller who wants words passes\n * `formatValue`, which is handed the `undefined` and decides.\n */\nconst NO_VALUE = \"—\";\n\n/**\n * The number this payload item carries, or `undefined` when it carries none.\n *\n * This was `item.value ?? 0`, so every one of the absences above printed a confident\n * \"0\" that appears nowhere in the data — a fabricated figure in a tooltip, which is the\n * one place a reader goes to check an exact number. keksdose found it and wrapped the\n * component rather than trust it. `\"\"` and a non-numeric string are the same absence\n * spelled differently (recharts hands a string value straight through from the data),\n * and are answered the same way.\n */\nfunction tooltipValue(value: number | string | undefined): number | undefined {\n if (value == null || value === \"\") return undefined;\n const n = typeof value === \"string\" ? Number(value) : value;\n return Number.isFinite(n) ? n : undefined;\n}\n\ninterface ChartTooltipContentProps {\n active?: boolean;\n payload?: TooltipPayloadItem[];\n label?: string | number;\n indicator?: \"dot\" | \"line\";\n hideLabel?: boolean;\n labelFormatter?: (label: string | number) => ReactNode;\n /** Formats one series' value for display. NOT called when the series has no value at\n * this point — {@link ChartTooltipContentProps.formatValue} is the one that is. */\n valueFormatter?: (value: number) => ReactNode;\n /** Formats one series' value INCLUDING its absence: handed `undefined` for a gap, a\n * projection that has not happened yet, or a field that did not exist at an earlier\n * capture, and whatever it returns is rendered as-is. Only the caller knows whether\n * that absence reads as a dash, a \"not yet\" or a genuine zero, so this is how it\n * says. Supplying it wins over `valueFormatter` for every value.\n *\n * It sits NEXT to `valueFormatter` rather than widening it because that prop's\n * parameter is contextually typed at every call site there is — `(v) => money(v)` —\n * so widening it to `number | undefined` is a compile error in all three consuming\n * apps, which is a breaking change this module does not get to make by itself. */\n formatValue?: (value: number | undefined) => ReactNode;\n /** Cursor position within the chart, injected by recharts. Used with\n * {@link boundaryRef} to decide whether to flip the tooltip. */\n coordinate?: { x?: number; y?: number };\n /** When set, the tooltip flips to the LEFT of the cursor if it would otherwise\n * spill past the right edge of this (usually horizontally-scrolling) container\n * — e.g. a wide chart whose rightmost bars sat off-screen (feedback #77). */\n boundaryRef?: RefObject<HTMLElement | null>;\n /** Injected by recharts: keep series drawn with `hide` in the tooltip. */\n includeHidden?: boolean;\n}\n\nexport function ChartTooltipContent({\n active,\n payload,\n label,\n indicator = \"dot\",\n hideLabel = false,\n labelFormatter,\n valueFormatter,\n formatValue,\n coordinate,\n boundaryRef,\n includeHidden = false,\n}: ChartTooltipContentProps) {\n const config = useChart();\n const tipRef = useRef<HTMLDivElement>(null);\n // `ChartTooltip` keeps null values (so they can print \"—\"), which also keeps the\n // series a legend toggle switched off with `hide`; those go here instead.\n const items = includeHidden ? payload : payload?.filter((item) => item.hide !== true);\n const visible = Boolean(active && items?.length);\n // Recharts anchors the tooltip at coordinate.x inside the full (scrolled) chart\n // width; subtract the container's scrollLeft to get its on-screen x, then flip\n // left if the tooltip's own width would run past the visible right edge.\n //\n // Both the cursor and the flip are PHYSICAL (the plot is never mirrored, see\n // `ChartContainer`), but an RTL scroller counts `scrollLeft` from its right edge —\n // 0 at the start, negative going left — so there the content's left edge sits\n // `scrollWidth - clientWidth + scrollLeft` px to the left of the visible one.\n //\n // Measured in a layout effect (the DOM is not readable during render), so it commits\n // before paint. `payload` and `label` are deps because they change the tooltip's own\n // width, and recharts hands a fresh `payload` on every tooltip render, so a scroll\n // followed by any re-render is re-measured just as it was when this ran in render.\n const [flip, setFlip] = useState(false);\n const x = coordinate?.x;\n useLayoutEffect(() => {\n const boundary = boundaryRef?.current;\n if (!visible || !boundary || x == null) {\n setFlip(false);\n return;\n }\n const offset = isRtl(boundary)\n ? boundary.scrollWidth - boundary.clientWidth + boundary.scrollLeft\n : boundary.scrollLeft;\n const visibleX = x - offset;\n const tipWidth = tipRef.current?.offsetWidth ?? 160;\n setFlip(visibleX + tipWidth + 12 > boundary.clientWidth);\n }, [visible, x, boundaryRef, payload, label]);\n if (!visible || !items) return null;\n return (\n <div\n ref={tipRef}\n style={boundaryRef ? { transform: flip ? \"translateX(calc(-100% - 12px))\" : \"translateX(12px)\" } : undefined}\n className=\"min-w-[9rem] rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] px-2.5 py-2 text-xs shadow-xl\"\n >\n {!hideLabel && label != null && (\n <div className=\"mb-1.5 font-medium text-[var(--text-primary)]\">\n {labelFormatter ? labelFormatter(label) : label}\n </div>\n )}\n <div className=\"grid gap-1.5\">\n {items.map((item, i) => {\n // Bars/lines/areas identify a series by dataKey; pies/treemaps key off\n // `name` (the nameKey value). Prefer whichever the config knows.\n const dk = item.dataKey != null ? String(item.dataKey) : undefined;\n const nm = item.name != null ? String(item.name) : undefined;\n const cfgKey = dk && config[dk] ? dk : nm && config[nm] ? nm : (dk ?? nm ?? String(i));\n const series = config[cfgKey];\n const fill = typeof item.payload?.fill === \"string\" ? item.payload.fill : undefined;\n // The data point's own `fill` before recharts' `item.color`: a treemap tile,\n // or a bar with a per-cell colour, IS the colour the reader is pointing at,\n // while `item.color` is the series-wide one — every tile's swatch came out\n // `--chart-1` whatever colour the tile was.\n const color = paintedColor(cfgKey, series) ?? fill ?? item.color ?? \"#64748b\";\n const name = series?.label ?? nm ?? cfgKey;\n const raw = tooltipValue(item.value);\n let shown: ReactNode;\n if (formatValue) shown = formatValue(raw);\n else if (raw == null) shown = NO_VALUE;\n else shown = valueFormatter ? valueFormatter(raw) : raw;\n return (\n <div key={`${cfgKey}-${i}`} className=\"flex items-center gap-2\">\n <span\n className={cn(\n \"shrink-0 rounded-[2px]\",\n indicator === \"dot\" ? \"h-2.5 w-2.5 rounded-full\" : \"h-2.5 w-1\",\n )}\n style={{ backgroundColor: color }}\n />\n <span className=\"text-[var(--text-muted)]\">{name}</span>\n <span data-private className=\"ms-auto font-mono font-medium tabular-nums text-[var(--text-primary)]\">\n {shown}\n </span>\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\ninterface LegendPayloadItem {\n value?: string;\n dataKey?: string | number;\n color?: string;\n}\n\ninterface ChartLegendContentProps {\n payload?: LegendPayloadItem[];\n onItemClick?: (key: string) => void;\n /**\n * TOGGLE mode (recommended): the series currently switched off. Each entry is a\n * toggle button — pressed while its series is shown — and a hidden one is drawn\n * faded with its label struck through. Several can be off at once; pair with\n * `toggleHidden(hidden, key)` in `onItemClick` and `hide` on the chart's series.\n */\n hiddenKeys?: ReadonlySet<string> | readonly string[];\n /**\n * ISOLATE mode: the one series shown in full, every other entry dimmed. Kept for\n * the charts built on it; a legend where each entry switches its own series is\n * what readers expect from a legend, so prefer `hiddenKeys`.\n */\n activeKey?: string | null;\n}\n\nexport function ChartLegendContent({\n payload,\n onItemClick,\n hiddenKeys,\n activeKey,\n}: ChartLegendContentProps) {\n const hidden = hiddenKeys ? new Set(hiddenKeys) : null;\n const config = useChart();\n if (!payload?.length) return null;\n return (\n <div className=\"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 pt-3\">\n {payload.map((item, i) => {\n const dk = item.dataKey != null ? String(item.dataKey) : undefined;\n const vv = item.value != null ? String(item.value) : undefined;\n const cfgKey = dk && config[dk] ? dk : vv && config[vv] ? vv : (dk ?? vv ?? String(i));\n const series = config[cfgKey];\n const color = paintedColor(cfgKey, series) ?? item.color ?? \"#64748b\";\n const label = series?.label ?? vv ?? cfgKey;\n const off = hidden?.has(cfgKey) ?? false;\n const dimmed = off || (activeKey != null && activeKey !== cfgKey);\n const className = cn(\n \"flex items-center gap-1.5 text-[var(--text-secondary)] transition-opacity\",\n onItemClick ? \"cursor-pointer hover:opacity-80\" : \"cursor-default\",\n dimmed && \"opacity-40\",\n );\n const swatch = (\n <span\n aria-hidden\n className=\"h-2.5 w-2.5 shrink-0 rounded-[3px]\"\n style={{ backgroundColor: color } as CSSProperties}\n />\n );\n // A legend with no `onItemClick` is a KEY, not a control — and that is every\n // legend in kastlan, where this rendered N focusable buttons per chart that did\n // nothing when activated. A keyboard user paid the tab stops for all of them,\n // and a screen reader announced each one as a button, promising an action there\n // was none of. The interactive branch is unchanged.\n return onItemClick ? (\n <button\n key={`${cfgKey}-${i}`}\n type=\"button\"\n onClick={() => onItemClick(cfgKey)}\n // Toggles report their state: in toggle mode pressed = the series is shown;\n // in isolate mode pressed = the isolated one. With neither supplied the\n // legend knows nothing about state, and a pressed=\"false\" it cannot vouch\n // for would lie — so it says nothing.\n aria-pressed={\n hidden ? !off : activeKey === undefined ? undefined : activeKey === cfgKey\n }\n className={className}\n >\n {swatch}\n <span className={cn(off && \"line-through\")}>{label}</span>\n </button>\n ) : (\n <span key={`${cfgKey}-${i}`} className={className}>\n {swatch}\n {label}\n </span>\n );\n })}\n </div>\n );\n}\n"],"mappings":";AAgEM,SAuBE,KAvBF;AAtDN,SAAS,eAAe,YAAY,OAAO,iBAAiB,QAAQ,gBAAgB;AAEpF;AAAA,EACE,UAAU;AAAA,EACV;AAAA,EACA,WAAW;AAAA,OACN;AACP,SAAS,UAAU;AACnB,SAAS,aAAa;AAStB,MAAM,eAAe,cAAkC,IAAI;AAEpD,SAAS,WAAwB;AACtC,QAAM,MAAM,WAAW,YAAY;AACnC,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,mDAAmD;AAC7E,SAAO;AACT;AAqBO,SAAS,eAAe,EAAE,IAAI,WAAW,UAAU,QAAQ,GAAG,MAAM,GAAwB;AACjG,QAAM,MAAM,MAAM;AAMlB,QAAM,UAAU,UAAU,MAAM,KAAK,QAAQ,mBAAmB,EAAE,CAAC;AACnE,SACE,oBAAC,aAAa,UAAb,EAAsB,OAAO,QAC5B;AAAA,IAAC;AAAA;AAAA,MACC,cAAY;AAAA,MACZ,WAAW;AAAA;AAAA;AAAA;AAA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,CAAC,GACH;AAEJ;","names":[]}
@@ -166,7 +166,8 @@ type ChipProps = ChipBaseProps & ({
166
166
  /**
167
167
  * Renders the link for `href` — pass your router's `<Link>` here, since a
168
168
  * plain `<a>` reloads a single-page app (keksdose's account-menu admin pill).
169
- * Default: `<a>`. Ignored without `href`.
169
+ * Default: the `<UiKitProvider linkComponent>`, then `<a>`. Ignored without
170
+ * `href`.
170
171
  *
171
172
  * A render function rather than an `as={Link}`, for three reasons. It is the
172
173
  * API `StatTile` already has (`renderLink`), so a consumer learns it once.