@eifi1/ui-kit 0.4.1 → 0.5.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 (410) hide show
  1. package/LICENSE +32 -0
  2. package/README.md +498 -57
  3. package/dist/chart.d.ts +10 -0
  4. package/dist/chart.js +10 -0
  5. package/dist/chart.js.map +1 -0
  6. package/dist/components/account-settings.d.ts +11 -0
  7. package/dist/components/account-settings.js +19 -12
  8. package/dist/components/account-settings.js.map +1 -1
  9. package/dist/components/alert-banner.d.ts +10 -6
  10. package/dist/components/alert-banner.js +20 -16
  11. package/dist/components/alert-banner.js.map +1 -1
  12. package/dist/components/amount-input.d.ts +30 -4
  13. package/dist/components/amount-input.js +36 -14
  14. package/dist/components/amount-input.js.map +1 -1
  15. package/dist/components/calculator.d.ts +24 -7
  16. package/dist/components/calculator.js +37 -20
  17. package/dist/components/calculator.js.map +1 -1
  18. package/dist/components/chart-zoom.d.ts +156 -0
  19. package/dist/components/chart-zoom.js +262 -0
  20. package/dist/components/chart-zoom.js.map +1 -0
  21. package/dist/components/chart.d.ts +28 -3
  22. package/dist/components/chart.js +71 -32
  23. package/dist/components/chart.js.map +1 -1
  24. package/dist/components/checkbox.d.ts +51 -0
  25. package/dist/components/checkbox.js +123 -0
  26. package/dist/components/checkbox.js.map +1 -0
  27. package/dist/components/chip.d.ts +128 -0
  28. package/dist/components/chip.js +357 -0
  29. package/dist/components/chip.js.map +1 -0
  30. package/dist/components/choice-parts.d.ts +24 -0
  31. package/dist/components/choice-parts.js +18 -0
  32. package/dist/components/choice-parts.js.map +1 -0
  33. package/dist/components/combobox-core.d.ts +52 -9
  34. package/dist/components/combobox-core.js +89 -19
  35. package/dist/components/combobox-core.js.map +1 -1
  36. package/dist/components/combobox.d.ts +43 -33
  37. package/dist/components/combobox.js +409 -340
  38. package/dist/components/combobox.js.map +1 -1
  39. package/dist/components/currency-select.d.ts +48 -8
  40. package/dist/components/currency-select.js +107 -65
  41. package/dist/components/currency-select.js.map +1 -1
  42. package/dist/components/data-table-filter-popover.d.ts +15 -3
  43. package/dist/components/data-table-filter-popover.js +23 -17
  44. package/dist/components/data-table-filter-popover.js.map +1 -1
  45. package/dist/components/data-table-filters.d.ts +1 -1
  46. package/dist/components/data-table-filters.js +3 -2
  47. package/dist/components/data-table-filters.js.map +1 -1
  48. package/dist/components/data-table-labels.d.ts +53 -2
  49. package/dist/components/data-table-labels.js +31 -2
  50. package/dist/components/data-table-labels.js.map +1 -1
  51. package/dist/components/data-table-pagination.d.ts +3 -1
  52. package/dist/components/data-table-pagination.js +16 -10
  53. package/dist/components/data-table-pagination.js.map +1 -1
  54. package/dist/components/data-table-sort.js +1 -0
  55. package/dist/components/data-table-sort.js.map +1 -1
  56. package/dist/components/data-table.d.ts +1 -1
  57. package/dist/components/data-table.js +201 -85
  58. package/dist/components/data-table.js.map +1 -1
  59. package/dist/components/date-picker.d.ts +25 -9
  60. package/dist/components/date-picker.js +232 -94
  61. package/dist/components/date-picker.js.map +1 -1
  62. package/dist/components/dropdown.d.ts +74 -19
  63. package/dist/components/dropdown.js +72 -22
  64. package/dist/components/dropdown.js.map +1 -1
  65. package/dist/components/entity-combobox.d.ts +5 -4
  66. package/dist/components/entity-combobox.js +107 -76
  67. package/dist/components/entity-combobox.js.map +1 -1
  68. package/dist/components/facing-pair.d.ts +36 -0
  69. package/dist/components/facing-pair.js +40 -0
  70. package/dist/components/facing-pair.js.map +1 -0
  71. package/dist/components/field-sync.d.ts +164 -0
  72. package/dist/components/field-sync.js +264 -0
  73. package/dist/components/field-sync.js.map +1 -0
  74. package/dist/components/file-dropzone.d.ts +21 -7
  75. package/dist/components/file-dropzone.js +28 -7
  76. package/dist/components/file-dropzone.js.map +1 -1
  77. package/dist/components/full-bleed-dialog.d.ts +37 -26
  78. package/dist/components/full-bleed-dialog.js +20 -5
  79. package/dist/components/full-bleed-dialog.js.map +1 -1
  80. package/dist/components/grouped-picker.d.ts +21 -10
  81. package/dist/components/grouped-picker.js +66 -52
  82. package/dist/components/grouped-picker.js.map +1 -1
  83. package/dist/components/hover-menu.d.ts +20 -4
  84. package/dist/components/hover-menu.js +15 -4
  85. package/dist/components/hover-menu.js.map +1 -1
  86. package/dist/components/mini-calendar.d.ts +102 -14
  87. package/dist/components/mini-calendar.js +256 -70
  88. package/dist/components/mini-calendar.js.map +1 -1
  89. package/dist/components/modal.d.ts +9 -3
  90. package/dist/components/modal.js +34 -45
  91. package/dist/components/modal.js.map +1 -1
  92. package/dist/components/month-picker.d.ts +79 -0
  93. package/dist/components/month-picker.js +342 -0
  94. package/dist/components/month-picker.js.map +1 -0
  95. package/dist/components/multi-entity-combobox.d.ts +7 -6
  96. package/dist/components/multi-entity-combobox.js +112 -72
  97. package/dist/components/multi-entity-combobox.js.map +1 -1
  98. package/dist/components/multi-select.d.ts +13 -11
  99. package/dist/components/multi-select.js +161 -84
  100. package/dist/components/multi-select.js.map +1 -1
  101. package/dist/components/number-field.d.ts +92 -0
  102. package/dist/components/number-field.js +111 -0
  103. package/dist/components/number-field.js.map +1 -0
  104. package/dist/components/number-input.d.ts +21 -2
  105. package/dist/components/number-input.js +2 -1
  106. package/dist/components/number-input.js.map +1 -1
  107. package/dist/components/numpad-sheet.d.ts +25 -4
  108. package/dist/components/numpad-sheet.js +30 -13
  109. package/dist/components/numpad-sheet.js.map +1 -1
  110. package/dist/components/page-contents.d.ts +90 -0
  111. package/dist/components/page-contents.js +170 -0
  112. package/dist/components/page-contents.js.map +1 -0
  113. package/dist/components/password-strength.d.ts +106 -0
  114. package/dist/components/password-strength.js +132 -0
  115. package/dist/components/password-strength.js.map +1 -0
  116. package/dist/components/picker-sheet.d.ts +23 -15
  117. package/dist/components/picker-sheet.js +34 -14
  118. package/dist/components/picker-sheet.js.map +1 -1
  119. package/dist/components/popover.d.ts +62 -4
  120. package/dist/components/popover.js +52 -2
  121. package/dist/components/popover.js.map +1 -1
  122. package/dist/components/search-field.d.ts +25 -7
  123. package/dist/components/search-field.js +7 -5
  124. package/dist/components/search-field.js.map +1 -1
  125. package/dist/components/series-chart-labels.d.ts +14 -0
  126. package/dist/components/series-chart-labels.js +11 -0
  127. package/dist/components/series-chart-labels.js.map +1 -0
  128. package/dist/components/series-chart.d.ts +207 -0
  129. package/dist/components/series-chart.js +223 -0
  130. package/dist/components/series-chart.js.map +1 -0
  131. package/dist/components/settings-fields.d.ts +14 -4
  132. package/dist/components/settings-fields.js +19 -8
  133. package/dist/components/settings-fields.js.map +1 -1
  134. package/dist/components/signature-pad.d.ts +119 -0
  135. package/dist/components/signature-pad.js +405 -0
  136. package/dist/components/signature-pad.js.map +1 -0
  137. package/dist/components/slider.d.ts +80 -0
  138. package/dist/components/slider.js +155 -0
  139. package/dist/components/slider.js.map +1 -0
  140. package/dist/components/sparkline.d.ts +93 -0
  141. package/dist/components/sparkline.js +205 -0
  142. package/dist/components/sparkline.js.map +1 -0
  143. package/dist/components/stat-tile.d.ts +151 -0
  144. package/dist/components/stat-tile.js +236 -0
  145. package/dist/components/stat-tile.js.map +1 -0
  146. package/dist/components/swipeable-row.d.ts +25 -2
  147. package/dist/components/swipeable-row.js +31 -0
  148. package/dist/components/swipeable-row.js.map +1 -1
  149. package/dist/components/switch.d.ts +60 -0
  150. package/dist/components/switch.js +81 -0
  151. package/dist/components/switch.js.map +1 -0
  152. package/dist/components/time-input.d.ts +58 -0
  153. package/dist/components/time-input.js +50 -0
  154. package/dist/components/time-input.js.map +1 -0
  155. package/dist/components/toggle-group.d.ts +18 -3
  156. package/dist/components/toggle-group.js +10 -6
  157. package/dist/components/toggle-group.js.map +1 -1
  158. package/dist/components/toggle-legend.d.ts +115 -0
  159. package/dist/components/toggle-legend.js +114 -0
  160. package/dist/components/toggle-legend.js.map +1 -0
  161. package/dist/components/tooltip.d.ts +40 -11
  162. package/dist/components/tooltip.js +77 -20
  163. package/dist/components/tooltip.js.map +1 -1
  164. package/dist/components/treemap.d.ts +132 -0
  165. package/dist/components/treemap.js +179 -0
  166. package/dist/components/treemap.js.map +1 -0
  167. package/dist/components/ui.d.ts +159 -46
  168. package/dist/components/ui.js +220 -115
  169. package/dist/components/ui.js.map +1 -1
  170. package/dist/components/use-mobile-reveal.js +1 -0
  171. package/dist/components/use-mobile-reveal.js.map +1 -1
  172. package/dist/components/use-table-state.d.ts +1 -1
  173. package/dist/components/use-table-state.js +38 -17
  174. package/dist/components/use-table-state.js.map +1 -1
  175. package/dist/components/user-avatar.d.ts +5 -3
  176. package/dist/components/user-avatar.js +4 -2
  177. package/dist/components/user-avatar.js.map +1 -1
  178. package/dist/components/wizard-stepper.js +3 -2
  179. package/dist/components/wizard-stepper.js.map +1 -1
  180. package/dist/{data-table-filters-aXyf0Xub.d.ts → data-table-filters-DM1auUfH.d.ts} +27 -5
  181. package/dist/data-table.d.ts +7 -0
  182. package/dist/data-table.js +12 -0
  183. package/dist/data-table.js.map +1 -0
  184. package/dist/feedback/feedback-attachment.js +12 -11
  185. package/dist/feedback/feedback-attachment.js.map +1 -1
  186. package/dist/feedback/feedback-dialog.js +2 -1
  187. package/dist/feedback/feedback-dialog.js.map +1 -1
  188. package/dist/feedback/feedback-inbox.d.ts +33 -7
  189. package/dist/feedback/feedback-inbox.js +49 -37
  190. package/dist/feedback/feedback-inbox.js.map +1 -1
  191. package/dist/feedback.d.ts +5 -0
  192. package/dist/feedback.js +5 -0
  193. package/dist/feedback.js.map +1 -0
  194. package/dist/hooks/use-anchored-panel.js +1 -0
  195. package/dist/hooks/use-anchored-panel.js.map +1 -1
  196. package/dist/hooks/use-anchored-rect.js +1 -0
  197. package/dist/hooks/use-anchored-rect.js.map +1 -1
  198. package/dist/hooks/use-announce.d.ts +46 -0
  199. package/dist/hooks/use-announce.js +37 -0
  200. package/dist/hooks/use-announce.js.map +1 -0
  201. package/dist/hooks/use-body-scroll-lock.js +1 -0
  202. package/dist/hooks/use-body-scroll-lock.js.map +1 -1
  203. package/dist/hooks/use-close-transition.js +1 -0
  204. package/dist/hooks/use-close-transition.js.map +1 -1
  205. package/dist/hooks/use-dismiss.js +1 -0
  206. package/dist/hooks/use-dismiss.js.map +1 -1
  207. package/dist/hooks/use-focus-trap.d.ts +16 -0
  208. package/dist/hooks/use-focus-trap.js +67 -0
  209. package/dist/hooks/use-focus-trap.js.map +1 -0
  210. package/dist/hooks/use-media-query.js +1 -0
  211. package/dist/hooks/use-media-query.js.map +1 -1
  212. package/dist/hooks/use-overlay-history.js +27 -1
  213. package/dist/hooks/use-overlay-history.js.map +1 -1
  214. package/dist/hooks/use-row-swipe.js +1 -0
  215. package/dist/hooks/use-row-swipe.js.map +1 -1
  216. package/dist/i18n/defaults.d.ts +31 -0
  217. package/dist/i18n/defaults.js +63 -0
  218. package/dist/i18n/defaults.js.map +1 -0
  219. package/dist/i18n/kit-labels.d.ts +250 -0
  220. package/dist/i18n/kit-labels.js +184 -0
  221. package/dist/i18n/kit-labels.js.map +1 -0
  222. package/dist/index.d.ts +47 -22
  223. package/dist/index.js +28 -0
  224. package/dist/index.js.map +1 -1
  225. package/dist/lib/calc.js +1 -0
  226. package/dist/lib/calc.js.map +1 -1
  227. package/dist/lib/cn.js +1 -0
  228. package/dist/lib/cn.js.map +1 -1
  229. package/dist/lib/dates.js +1 -0
  230. package/dist/lib/dates.js.map +1 -1
  231. package/dist/lib/logger.js +1 -0
  232. package/dist/lib/logger.js.map +1 -1
  233. package/dist/lib/safe-storage.js +1 -0
  234. package/dist/lib/safe-storage.js.map +1 -1
  235. package/dist/search/command-palette.d.ts +11 -1
  236. package/dist/search/command-palette.js +21 -15
  237. package/dist/search/command-palette.js.map +1 -1
  238. package/dist/search.d.ts +2 -0
  239. package/dist/search.js +3 -0
  240. package/dist/search.js.map +1 -0
  241. package/dist/shell/app-shell.d.ts +33 -4
  242. package/dist/shell/app-shell.js +275 -78
  243. package/dist/shell/app-shell.js.map +1 -1
  244. package/dist/shell/option-switcher-menu.js +3 -2
  245. package/dist/shell/option-switcher-menu.js.map +1 -1
  246. package/dist/shell/role-switcher.d.ts +6 -0
  247. package/dist/shell/role-switcher.js +7 -4
  248. package/dist/shell/role-switcher.js.map +1 -1
  249. package/dist/shell/top-bar.d.ts +15 -7
  250. package/dist/shell/top-bar.js +3 -5
  251. package/dist/shell/top-bar.js.map +1 -1
  252. package/dist/shell/topbar-action-menu.js +3 -2
  253. package/dist/shell/topbar-action-menu.js.map +1 -1
  254. package/dist/shell/topbar-controls.d.ts +5 -2
  255. package/dist/shell/topbar-controls.js +20 -15
  256. package/dist/shell/topbar-controls.js.map +1 -1
  257. package/dist/shell.d.ts +13 -0
  258. package/dist/shell.js +8 -0
  259. package/dist/shell.js.map +1 -0
  260. package/dist/theme/chart-palette.d.ts +19 -12
  261. package/dist/theme/chart-palette.js +24 -30
  262. package/dist/theme/chart-palette.js.map +1 -1
  263. package/dist/theme/color.d.ts +78 -0
  264. package/dist/theme/color.js +148 -0
  265. package/dist/theme/color.js.map +1 -0
  266. package/dist/theme/palette-derive.d.ts +140 -0
  267. package/dist/theme/palette-derive.js +376 -0
  268. package/dist/theme/palette-derive.js.map +1 -0
  269. package/dist/theme/palette-presets.d.ts +14 -1
  270. package/dist/theme/palette-presets.js +231 -3
  271. package/dist/theme/palette-presets.js.map +1 -1
  272. package/dist/theme/palette-store.js +1 -0
  273. package/dist/theme/palette-store.js.map +1 -1
  274. package/dist/theme/theme-store.js +1 -0
  275. package/dist/theme/theme-store.js.map +1 -1
  276. package/dist/tour/tour.d.ts +2 -1
  277. package/dist/tour/tour.js +15 -9
  278. package/dist/tour/tour.js.map +1 -1
  279. package/dist/tour.d.ts +2 -0
  280. package/dist/tour.js +3 -0
  281. package/dist/tour.js.map +1 -0
  282. package/dist/wizard/stepper-nav.js +10 -8
  283. package/dist/wizard/stepper-nav.js.map +1 -1
  284. package/dist/wizard/types.d.ts +18 -2
  285. package/dist/wizard/types.js +4 -1
  286. package/dist/wizard/types.js.map +1 -1
  287. package/dist/wizard/use-wizard.js +12 -4
  288. package/dist/wizard/use-wizard.js.map +1 -1
  289. package/dist/wizard/validation.js +1 -0
  290. package/dist/wizard/validation.js.map +1 -1
  291. package/dist/wizard/wizard-context.js +1 -0
  292. package/dist/wizard/wizard-context.js.map +1 -1
  293. package/dist/wizard/wizard-step.js +1 -0
  294. package/dist/wizard/wizard-step.js.map +1 -1
  295. package/dist/wizard/wizard-summary.js +5 -3
  296. package/dist/wizard/wizard-summary.js.map +1 -1
  297. package/dist/wizard.d.ts +8 -0
  298. package/dist/wizard.js +9 -0
  299. package/dist/wizard.js.map +1 -0
  300. package/package.json +66 -13
  301. package/src/chart.ts +22 -0
  302. package/src/components/account-settings.tsx +275 -0
  303. package/src/components/alert-banner.tsx +75 -0
  304. package/src/components/amount-input.tsx +471 -0
  305. package/src/components/calculator.tsx +252 -0
  306. package/src/components/chart-zoom.tsx +499 -0
  307. package/src/components/chart.tsx +363 -0
  308. package/src/components/checkbox.tsx +222 -0
  309. package/src/components/chip.tsx +570 -0
  310. package/src/components/choice-parts.ts +33 -0
  311. package/src/components/combobox-core.tsx +540 -0
  312. package/src/components/combobox.tsx +1026 -0
  313. package/src/components/currency-select.tsx +269 -0
  314. package/src/components/data-table-filter-popover.tsx +252 -0
  315. package/src/components/data-table-filters.ts +176 -0
  316. package/src/components/data-table-labels.ts +190 -0
  317. package/src/components/data-table-pagination.tsx +126 -0
  318. package/src/components/data-table-sort.ts +70 -0
  319. package/src/components/data-table.tsx +1740 -0
  320. package/src/components/date-picker.tsx +631 -0
  321. package/src/components/dropdown.tsx +341 -0
  322. package/src/components/entity-combobox.tsx +215 -0
  323. package/src/components/facing-pair.ts +86 -0
  324. package/src/components/field-sync.tsx +472 -0
  325. package/src/components/file-dropzone.tsx +181 -0
  326. package/src/components/full-bleed-dialog.tsx +179 -0
  327. package/src/components/grouped-picker.tsx +157 -0
  328. package/src/components/hover-menu.tsx +183 -0
  329. package/src/components/mini-calendar.tsx +554 -0
  330. package/src/components/modal.tsx +287 -0
  331. package/src/components/month-picker.tsx +549 -0
  332. package/src/components/multi-entity-combobox.tsx +226 -0
  333. package/src/components/multi-select.tsx +303 -0
  334. package/src/components/number-field.tsx +225 -0
  335. package/src/components/number-input.tsx +211 -0
  336. package/src/components/numpad-sheet.tsx +264 -0
  337. package/src/components/page-contents.tsx +289 -0
  338. package/src/components/password-strength.tsx +258 -0
  339. package/src/components/picker-sheet.tsx +251 -0
  340. package/src/components/popover.tsx +195 -0
  341. package/src/components/search-field.tsx +146 -0
  342. package/src/components/series-chart-labels.ts +26 -0
  343. package/src/components/series-chart.tsx +481 -0
  344. package/src/components/settings-fields.tsx +68 -0
  345. package/src/components/signature-pad.tsx +630 -0
  346. package/src/components/slider.tsx +313 -0
  347. package/src/components/sparkline.tsx +329 -0
  348. package/src/components/stat-tile.tsx +448 -0
  349. package/src/components/swipeable-row.tsx +271 -0
  350. package/src/components/switch.tsx +170 -0
  351. package/src/components/time-input.tsx +107 -0
  352. package/src/components/toggle-group.tsx +153 -0
  353. package/src/components/toggle-legend.tsx +229 -0
  354. package/src/components/tooltip.tsx +477 -0
  355. package/src/components/treemap.tsx +390 -0
  356. package/src/components/ui.tsx +1284 -0
  357. package/src/components/use-mobile-reveal.ts +54 -0
  358. package/src/components/use-table-state.ts +295 -0
  359. package/src/components/user-avatar.tsx +61 -0
  360. package/src/components/wizard-stepper.tsx +37 -0
  361. package/src/data-table.ts +19 -0
  362. package/src/feedback/feedback-attachment.tsx +246 -0
  363. package/src/feedback/feedback-dialog.tsx +209 -0
  364. package/src/feedback/feedback-inbox.tsx +615 -0
  365. package/src/feedback.ts +8 -0
  366. package/src/hooks/use-anchored-panel.ts +169 -0
  367. package/src/hooks/use-anchored-rect.ts +78 -0
  368. package/src/hooks/use-announce.ts +85 -0
  369. package/src/hooks/use-body-scroll-lock.ts +94 -0
  370. package/src/hooks/use-close-transition.ts +99 -0
  371. package/src/hooks/use-dismiss.ts +77 -0
  372. package/src/hooks/use-focus-trap.ts +160 -0
  373. package/src/hooks/use-media-query.ts +23 -0
  374. package/src/hooks/use-overlay-history.ts +345 -0
  375. package/src/hooks/use-row-swipe.ts +212 -0
  376. package/src/i18n/defaults.ts +68 -0
  377. package/src/i18n/kit-labels.tsx +447 -0
  378. package/src/index.ts +169 -0
  379. package/src/lib/calc.ts +309 -0
  380. package/src/lib/cn.ts +5 -0
  381. package/src/lib/dates.ts +187 -0
  382. package/src/lib/logger.ts +73 -0
  383. package/src/lib/safe-storage.ts +37 -0
  384. package/src/search/command-palette.tsx +342 -0
  385. package/src/search.ts +3 -0
  386. package/src/shell/app-shell.tsx +772 -0
  387. package/src/shell/option-switcher-menu.tsx +72 -0
  388. package/src/shell/role-switcher.tsx +46 -0
  389. package/src/shell/top-bar.tsx +39 -0
  390. package/src/shell/topbar-action-menu.tsx +91 -0
  391. package/src/shell/topbar-controls.tsx +229 -0
  392. package/src/shell.ts +10 -0
  393. package/src/theme/chart-palette.ts +145 -0
  394. package/src/theme/color.ts +266 -0
  395. package/src/theme/palette-derive.ts +681 -0
  396. package/src/theme/palette-presets.ts +760 -0
  397. package/src/theme/palette-store.ts +94 -0
  398. package/src/theme/theme-store.ts +145 -0
  399. package/src/tour/tour.tsx +586 -0
  400. package/src/tour.ts +3 -0
  401. package/src/vite-env.d.ts +26 -0
  402. package/src/wizard/stepper-nav.tsx +221 -0
  403. package/src/wizard/types.ts +178 -0
  404. package/src/wizard/use-wizard.ts +345 -0
  405. package/src/wizard/validation.ts +37 -0
  406. package/src/wizard/wizard-context.tsx +29 -0
  407. package/src/wizard/wizard-step.tsx +14 -0
  408. package/src/wizard/wizard-summary.tsx +69 -0
  409. package/src/wizard.ts +14 -0
  410. package/tokens.css +222 -20
@@ -1,7 +1,15 @@
1
1
  import * as react from 'react';
2
- import { ReactNode } from 'react';
2
+ import { ComponentPropsWithoutRef, ReactNode } from 'react';
3
3
 
4
- interface HoverMenuProps {
4
+ /**
5
+ * Exported and `<div>`-shaped: the top bar composes several of these side by side, and
6
+ * telling them apart — in a test, in a guided tour, in an accessibility tree — needs an
7
+ * attribute the kit does not know about. A closed prop list dropped every one of them.
8
+ *
9
+ * `children` is omitted from the div attributes because here it is a render prop taking
10
+ * the panel's `close`, not a `ReactNode`.
11
+ */
12
+ interface HoverMenuProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
5
13
  trigger: (state: {
6
14
  open: boolean;
7
15
  toggle: () => void;
@@ -9,8 +17,16 @@ interface HoverMenuProps {
9
17
  children: (close: () => void) => ReactNode;
10
18
  align?: "left" | "right";
11
19
  panelClassName?: string;
20
+ /** Extra classes for the WRAPPER (the panel has {@link panelClassName}). */
21
+ className?: string;
22
+ /**
23
+ * @deprecated Use the DOM spelling `aria-label`, which now reaches the wrapper like
24
+ * any other attribute. Kept working because keksdose, kastlan and lenkbank all pass
25
+ * this today and a rename to save one line of resolution is not a patch release; it
26
+ * loses to `aria-label` wherever both are given. Removal is a later minor.
27
+ */
12
28
  ariaLabel?: string;
13
29
  }
14
- declare function HoverMenu({ trigger, children, align, panelClassName, ariaLabel }: HoverMenuProps): react.JSX.Element;
30
+ declare function HoverMenu({ trigger, children, align, panelClassName, className, ariaLabel, "aria-label": ariaLabelAttr, ...rest }: HoverMenuProps): react.JSX.Element;
15
31
 
16
- export { HoverMenu };
32
+ export { HoverMenu, type HoverMenuProps };
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
3
4
  import { cn } from "../lib/cn.js";
@@ -5,7 +6,16 @@ import { useOutsideClick } from "../hooks/use-dismiss.js";
5
6
  const OPEN_DELAY_MS = 120;
6
7
  const CLOSE_DELAY_MS = 120;
7
8
  let activeClose = null;
8
- function HoverMenu({ trigger, children, align = "right", panelClassName, ariaLabel }) {
9
+ function HoverMenu({
10
+ trigger,
11
+ children,
12
+ align = "right",
13
+ panelClassName,
14
+ className,
15
+ ariaLabel,
16
+ "aria-label": ariaLabelAttr,
17
+ ...rest
18
+ }) {
9
19
  const wrapperRef = useRef(null);
10
20
  const [phase, setPhase] = useState("closed");
11
21
  const open = phase === "open" || phase === "closing";
@@ -74,11 +84,12 @@ function HoverMenu({ trigger, children, align = "right", panelClassName, ariaLab
74
84
  return /* @__PURE__ */ jsxs(
75
85
  "div",
76
86
  {
87
+ ...rest,
77
88
  ref: wrapperRef,
78
- className: "relative",
89
+ className: cn("relative", className),
79
90
  onMouseEnter: handleMouseEnter,
80
91
  onMouseLeave: handleMouseLeave,
81
- "aria-label": ariaLabel,
92
+ "aria-label": ariaLabelAttr ?? ariaLabel,
82
93
  children: [
83
94
  trigger({ open, toggle }),
84
95
  open && /* @__PURE__ */ jsx(
@@ -95,7 +106,7 @@ function HoverMenu({ trigger, children, align = "right", panelClassName, ariaLab
95
106
  {
96
107
  role: "menu",
97
108
  className: cn(
98
- "min-w-44 max-w-[calc(100vw-1rem)] rounded-md border border-slate-200 bg-white shadow-lg dark:border-slate-700 dark:bg-slate-900",
109
+ "min-w-44 max-w-[calc(100vw-1rem)] rounded-md border border-[var(--border)] bg-[var(--bg-surface)] shadow-lg",
99
110
  panelClassName
100
111
  ),
101
112
  children: children(close)
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/hover-menu.tsx"],"sourcesContent":["import { useCallback, useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useOutsideClick } from \"../hooks/use-dismiss\";\n\ninterface HoverMenuProps {\n trigger: (state: { open: boolean; toggle: () => void }) => ReactNode;\n children: (close: () => void) => ReactNode;\n align?: \"left\" | \"right\";\n panelClassName?: string;\n ariaLabel?: string;\n}\n\n// Hovering waits briefly before opening so sweeping the cursor across a row of\n// triggers doesn't flash menus; closing waits so the cursor can travel from\n// trigger to panel. Click/keyboard toggling is instant (no \"opening\" phase).\nconst OPEN_DELAY_MS = 120;\nconst CLOSE_DELAY_MS = 120;\n\ntype Phase = \"closed\" | \"opening\" | \"open\" | \"closing\";\n\n// Only one hover menu may show its panel at a time across the app — opening\n// one closes whichever was open, so adjacent top-bar menus can't overlap\n// (feedback #251). Module-level is fine: there is one cursor per document.\nlet activeClose: (() => void) | null = null;\n\nexport function HoverMenu({ trigger, children, align = \"right\", panelClassName, ariaLabel }: HoverMenuProps) {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [phase, setPhase] = useState<Phase>(\"closed\");\n const open = phase === \"open\" || phase === \"closing\";\n\n // Whether the panel is open *because hover opened it*, vs. an explicit\n // click/keyboard toggle. A real mouse click on the trigger is always\n // preceded by a real mouseenter — the cursor has to land on the button\n // before it can be clicked — so once hover has opened the panel, the click\n // that inevitably follows is the same physical gesture, not a request to\n // close what was just opened (feedback #19). Toggling closed on click stays\n // for keyboard/touch activation, which reaches \"open\" without going through\n // the hover path.\n const openedByHoverRef = useRef(false);\n\n const close = useCallback(() => {\n openedByHoverRef.current = false;\n setPhase(\"closed\");\n }, []);\n\n const toggle = useCallback(\n () =>\n setPhase((p) => {\n if (p === \"open\" || p === \"closing\") return openedByHoverRef.current ? p : \"closed\";\n openedByHoverRef.current = false;\n return \"open\";\n }),\n [],\n );\n\n const handleMouseEnter = useCallback(\n () => setPhase((p) => (p === \"closing\" ? \"open\" : p === \"closed\" ? \"opening\" : p)),\n [],\n );\n\n const handleMouseLeave = useCallback(\n () => setPhase((p) => (p === \"opening\" ? \"closed\" : p === \"open\" ? \"closing\" : p)),\n [],\n );\n\n // Drive the delayed transitions; unmount/phase changes cancel the timer.\n useEffect(() => {\n if (phase === \"opening\") {\n const id = setTimeout(() => {\n openedByHoverRef.current = true;\n setPhase(\"open\");\n }, OPEN_DELAY_MS);\n return () => clearTimeout(id);\n }\n if (phase === \"closing\") {\n const id = setTimeout(() => setPhase(\"closed\"), CLOSE_DELAY_MS);\n return () => clearTimeout(id);\n }\n }, [phase]);\n\n // Claim the \"active menu\" slot while our panel is visible, closing the\n // previous holder. Cleanup releases the slot only if we still hold it\n // (a successor that displaced us has already overwritten it).\n useEffect(() => {\n if (!open) return;\n if (activeClose !== close) activeClose?.();\n activeClose = close;\n return () => {\n if (activeClose === close) activeClose = null;\n };\n }, [open, close]);\n\n useOutsideClick(wrapperRef, close, open);\n\n // Keep the panel inside the viewport (feedback #85): a wide panel anchored to a\n // trigger near a screen edge would otherwise spill off it (on mobile the guided-\n // tours menu ran off the left). Once open, measure and translate it horizontally\n // just enough to sit within an 8px margin. Recomputed on each open; `shiftX` is\n // subtracted first so the measurement is against the natural position.\n const panelRef = useRef<HTMLDivElement>(null);\n const [shiftX, setShiftX] = useState(0);\n useLayoutEffect(() => {\n if (!open) {\n setShiftX(0);\n return;\n }\n const el = panelRef.current;\n if (!el) return;\n const rect = el.getBoundingClientRect();\n if (rect.width === 0) return; // unmeasured (e.g. jsdom) — leave as-is\n const margin = 8;\n const naturalLeft = rect.left - shiftX;\n const naturalRight = rect.right - shiftX;\n let next = 0;\n if (naturalRight > window.innerWidth - margin) next = window.innerWidth - margin - naturalRight;\n if (naturalLeft + next < margin) next = margin - naturalLeft;\n setShiftX(next);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- recompute only on open/close\n }, [open]);\n\n return (\n <div\n ref={wrapperRef}\n className=\"relative\"\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n aria-label={ariaLabel}\n >\n {trigger({ open, toggle })}\n {open && (\n <div\n ref={panelRef}\n className={cn(\n \"absolute top-full z-40 pt-2\",\n align === \"right\" ? \"right-0\" : \"left-0\",\n )}\n style={shiftX ? { transform: `translateX(${shiftX}px)` } : undefined}\n >\n <div\n role=\"menu\"\n className={cn(\n \"min-w-44 max-w-[calc(100vw-1rem)] rounded-md border border-slate-200 bg-white shadow-lg dark:border-slate-700 dark:bg-slate-900\",\n panelClassName,\n )}\n >\n {children(close)}\n </div>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":"AA0HI,SAiBM,KAjBN;AA1HJ,SAAS,aAAa,WAAW,iBAAiB,QAAQ,gBAAgB;AAE1E,SAAS,UAAU;AACnB,SAAS,uBAAuB;AAahC,MAAM,gBAAgB;AACtB,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../src/components/hover-menu.tsx"],"sourcesContent":["import { useCallback, useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useOutsideClick } from \"../hooks/use-dismiss\";\n\n/**\n * Exported and `<div>`-shaped: the top bar composes several of these side by side, and\n * telling them apart — in a test, in a guided tour, in an accessibility tree — needs an\n * attribute the kit does not know about. A closed prop list dropped every one of them.\n *\n * `children` is omitted from the div attributes because here it is a render prop taking\n * the panel's `close`, not a `ReactNode`.\n */\nexport interface HoverMenuProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n trigger: (state: { open: boolean; toggle: () => void }) => ReactNode;\n children: (close: () => void) => ReactNode;\n align?: \"left\" | \"right\";\n panelClassName?: string;\n /** Extra classes for the WRAPPER (the panel has {@link panelClassName}). */\n className?: string;\n /**\n * @deprecated Use the DOM spelling `aria-label`, which now reaches the wrapper like\n * any other attribute. Kept working because keksdose, kastlan and lenkbank all pass\n * this today and a rename to save one line of resolution is not a patch release; it\n * loses to `aria-label` wherever both are given. Removal is a later minor.\n */\n ariaLabel?: string;\n}\n\n// Hovering waits briefly before opening so sweeping the cursor across a row of\n// triggers doesn't flash menus; closing waits so the cursor can travel from\n// trigger to panel. Click/keyboard toggling is instant (no \"opening\" phase).\nconst OPEN_DELAY_MS = 120;\nconst CLOSE_DELAY_MS = 120;\n\ntype Phase = \"closed\" | \"opening\" | \"open\" | \"closing\";\n\n// Only one hover menu may show its panel at a time across the app — opening\n// one closes whichever was open, so adjacent top-bar menus can't overlap\n// (feedback #251). Module-level is fine: there is one cursor per document.\nlet activeClose: (() => void) | null = null;\n\nexport function HoverMenu({\n trigger,\n children,\n align = \"right\",\n panelClassName,\n className,\n ariaLabel,\n \"aria-label\": ariaLabelAttr,\n ...rest\n}: HoverMenuProps) {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [phase, setPhase] = useState<Phase>(\"closed\");\n const open = phase === \"open\" || phase === \"closing\";\n\n // Whether the panel is open *because hover opened it*, vs. an explicit\n // click/keyboard toggle. A real mouse click on the trigger is always\n // preceded by a real mouseenter — the cursor has to land on the button\n // before it can be clicked — so once hover has opened the panel, the click\n // that inevitably follows is the same physical gesture, not a request to\n // close what was just opened (feedback #19). Toggling closed on click stays\n // for keyboard/touch activation, which reaches \"open\" without going through\n // the hover path.\n const openedByHoverRef = useRef(false);\n\n const close = useCallback(() => {\n openedByHoverRef.current = false;\n setPhase(\"closed\");\n }, []);\n\n const toggle = useCallback(\n () =>\n setPhase((p) => {\n if (p === \"open\" || p === \"closing\") return openedByHoverRef.current ? p : \"closed\";\n openedByHoverRef.current = false;\n return \"open\";\n }),\n [],\n );\n\n const handleMouseEnter = useCallback(\n () => setPhase((p) => (p === \"closing\" ? \"open\" : p === \"closed\" ? \"opening\" : p)),\n [],\n );\n\n const handleMouseLeave = useCallback(\n () => setPhase((p) => (p === \"opening\" ? \"closed\" : p === \"open\" ? \"closing\" : p)),\n [],\n );\n\n // Drive the delayed transitions; unmount/phase changes cancel the timer.\n useEffect(() => {\n if (phase === \"opening\") {\n const id = setTimeout(() => {\n openedByHoverRef.current = true;\n setPhase(\"open\");\n }, OPEN_DELAY_MS);\n return () => clearTimeout(id);\n }\n if (phase === \"closing\") {\n const id = setTimeout(() => setPhase(\"closed\"), CLOSE_DELAY_MS);\n return () => clearTimeout(id);\n }\n }, [phase]);\n\n // Claim the \"active menu\" slot while our panel is visible, closing the\n // previous holder. Cleanup releases the slot only if we still hold it\n // (a successor that displaced us has already overwritten it).\n useEffect(() => {\n if (!open) return;\n if (activeClose !== close) activeClose?.();\n activeClose = close;\n return () => {\n if (activeClose === close) activeClose = null;\n };\n }, [open, close]);\n\n useOutsideClick(wrapperRef, close, open);\n\n // Keep the panel inside the viewport (feedback #85): a wide panel anchored to a\n // trigger near a screen edge would otherwise spill off it (on mobile the guided-\n // tours menu ran off the left). Once open, measure and translate it horizontally\n // just enough to sit within an 8px margin. Recomputed on each open; `shiftX` is\n // subtracted first so the measurement is against the natural position.\n const panelRef = useRef<HTMLDivElement>(null);\n const [shiftX, setShiftX] = useState(0);\n useLayoutEffect(() => {\n if (!open) {\n setShiftX(0);\n return;\n }\n const el = panelRef.current;\n if (!el) return;\n const rect = el.getBoundingClientRect();\n if (rect.width === 0) return; // unmeasured (e.g. jsdom) — leave as-is\n const margin = 8;\n const naturalLeft = rect.left - shiftX;\n const naturalRight = rect.right - shiftX;\n let next = 0;\n if (naturalRight > window.innerWidth - margin) next = window.innerWidth - margin - naturalRight;\n if (naturalLeft + next < margin) next = margin - naturalLeft;\n setShiftX(next);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- recompute only on open/close\n }, [open]);\n\n return (\n <div\n // `...rest` first: the hover handlers below are the whole component, and a caller\n // passing one of its own must not silently replace them.\n {...rest}\n ref={wrapperRef}\n className={cn(\"relative\", className)}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n // The DOM spelling wins; {@link HoverMenuProps.ariaLabel} is the deprecated alias\n // three apps still pass, so it stays as the fallback rather than as the answer.\n aria-label={ariaLabelAttr ?? ariaLabel}\n >\n {trigger({ open, toggle })}\n {open && (\n <div\n ref={panelRef}\n className={cn(\n \"absolute top-full z-40 pt-2\",\n align === \"right\" ? \"right-0\" : \"left-0\",\n )}\n style={shiftX ? { transform: `translateX(${shiftX}px)` } : undefined}\n >\n <div\n role=\"menu\"\n className={cn(\n \"min-w-44 max-w-[calc(100vw-1rem)] rounded-md border border-[var(--border)] bg-[var(--bg-surface)] shadow-lg\",\n panelClassName,\n )}\n >\n {children(close)}\n </div>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";AAmJI,SAsBM,KAtBN;AAnJJ,SAAS,aAAa,WAAW,iBAAiB,QAAQ,gBAAgB;AAE1E,SAAS,UAAU;AACnB,SAAS,uBAAuB;AA6BhC,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AAOvB,IAAI,cAAmC;AAEhC,SAAS,UAAU;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AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
@@ -1,9 +1,75 @@
1
1
  import * as react from 'react';
2
+ import { ComponentPropsWithoutRef } from 'react';
2
3
 
3
- interface MiniCalendarProps {
4
+ /**
5
+ * Every string this calendar can speak — the `miniCalendar` namespace of
6
+ * `<UiKitProvider labels>`, overridable per instance through the `labels` prop. The
7
+ * package carries no translation catalog (see the README), so the English defaults
8
+ * below are a starting point and not a commitment. `previousMonth`/`nextMonth` were already props for the
9
+ * reason the audit records: a German app reached this component through a bare
10
+ * re-export and announced its two icon-only arrows in English on a page whose
11
+ * `<html lang>` says `de`.
12
+ *
13
+ * The month caption is deliberately NOT here. It is produced by `Intl` from the
14
+ * `locale` prop, so it is already in the user's language, and the grid takes its
15
+ * accessible name from that element rather than from a string someone has to
16
+ * translate a second time.
17
+ *
18
+ * The ones that interpolate a date are FUNCTIONS taking the formatted date, for the
19
+ * reason `DataTableLabels` gives for its counted strings: a value glued into an
20
+ * English template literal is untranslatable, and the grammar around a date moves
21
+ * with it in most languages.
22
+ */
23
+ interface MiniCalendarLabels {
24
+ previousMonth: string;
25
+ nextMonth: string;
26
+ /**
27
+ * Accessible name of one day cell, given that day formatted in `locale`
28
+ * ("Monday, 14 September 2026").
29
+ *
30
+ * The name has to carry the WHOLE date. The visible text of a cell is the day
31
+ * number alone, and "14" on its own tells a screen-reader user nothing — not the
32
+ * month they have arrowed into, not the year, not the weekday they are picking.
33
+ */
34
+ day: (date: string) => string;
35
+ /** Range mode: what the NEXT click will set. Spoken after every click, and the
36
+ * grid's description while the panel is open. */
37
+ chooseStart: string;
38
+ chooseEnd: string;
39
+ /** Range mode: spoken after the click that set the start. */
40
+ startSelected: (date: string) => string;
41
+ /** Range mode: spoken after the click that completed the range. */
42
+ rangeSelected: (from: string, to: string) => string;
43
+ }
44
+ /** English defaults. Exported as the `miniCalendar` namespace of `UiKitLabels`
45
+ * (src/i18n), the complete reference a translation is written against. */
46
+ declare const DEFAULT_MINI_CALENDAR_LABELS: MiniCalendarLabels;
47
+ /**
48
+ * `onSelect` is omitted from the `<div>` attributes and kept as this component's own:
49
+ * the DOM event of that name is a text-selection event taking one argument, and this one
50
+ * answers with the two ISO dates a range is made of. Everything else a `<div>` takes
51
+ * passes through to the root, so a tour anchor or a test id can find the calendar —
52
+ * before this, a closed prop list dropped both (audit §api-design).
53
+ */
54
+ interface MiniCalendarProps extends Omit<ComponentPropsWithoutRef<"div">, "onSelect"> {
4
55
  from: string;
5
56
  to: string;
6
- locale: string;
57
+ /**
58
+ * BCP 47 tag for the month caption, the weekday heads, the day numbers and the
59
+ * spoken dates. Optional since the kit grew `<UiKitProvider locale>`: a calendar
60
+ * NESTED in another kit component (the data table's date filter) has no call site
61
+ * of its own to pass one at, so it reads the provider's. Without either, `Intl`
62
+ * uses the runtime's default.
63
+ */
64
+ locale?: string;
65
+ /**
66
+ * The weekday the grid starts on, `0` = Sunday … `6` = Saturday (as `Date#getDay`).
67
+ * Defaults to the LOCALE's first day — Monday in most of Europe, Sunday in the US,
68
+ * Saturday in much of the Arab world — which is what the user's own wall calendar
69
+ * does. It was hard-wired to Monday before, which is wrong for most of the people
70
+ * who use a Sunday-first calendar and invisible to the people who wrote this one.
71
+ */
72
+ weekStartsOn?: WeekDay;
7
73
  onSelect: (from: string, to: string) => void;
8
74
  /** `"range"` (default) = two-click from→to; `"single"` = one click selects a
9
75
  * single day (emitted as `onSelect(iso, iso)`). */
@@ -11,23 +77,45 @@ interface MiniCalendarProps {
11
77
  /** Optional inclusive ISO bounds; days outside `[min, max]` are disabled. */
12
78
  min?: string;
13
79
  max?: string;
14
- /** Screen-reader names for the two month arrows. The package carries no
15
- * translation catalog (see the README), so every user-facing string is a prop
16
- * with an English default — these two were the exception, and a German app
17
- * reached this component through a bare re-export and announced them in
18
- * English on a page whose `<html lang>` says `de`. */
19
- labels?: {
20
- previousMonth?: string;
21
- nextMonth?: string;
22
- };
80
+ /** User-facing strings; see {@link MiniCalendarLabels}. */
81
+ labels?: Partial<MiniCalendarLabels>;
82
+ /**
83
+ * Take focus to the day the grid opens on — the selected one, or today — when this
84
+ * calendar mounts. For a panel that opened BECAUSE the user asked to pick a date:
85
+ * landing them on the day they are editing is the difference between one arrow key
86
+ * and a hunt through 42 cells.
87
+ *
88
+ * Off by default, and not called `autoFocus`, because it is not the same promise as
89
+ * the DOM attribute of that name: a calendar rendered INLINE (the data-table's
90
+ * column filter draws one above its from/to inputs) must not take the page's focus
91
+ * merely by existing.
92
+ */
93
+ focusOnOpen?: boolean;
94
+ /** Extra classes for the calendar's root. */
95
+ className?: string;
23
96
  }
97
+ type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6;
24
98
  /**
25
99
  * Month-grid range picker used by the data-table date filter. Click once to set
26
100
  * the start (and clear the end), click again to set the end; clicking with a
27
- * full range already selected starts over. Monday-first, locale-aware labels.
101
+ * full range already selected starts over. The week starts where the locale's does
102
+ * (or at `weekStartsOn`), and every label comes from `Intl` in that locale.
28
103
  * In `single` mode each click selects one day. Days outside `min`/`max` (when
29
104
  * given) are disabled.
105
+ *
106
+ * **It is a grid, in the APG sense** (audit §a11y, "MiniCalendar is unusable with a
107
+ * keyboard or screen reader"). Before this it was 42 buttons in a `grid-cols-7` div:
108
+ * every one of them in the tab order, none of them saying which date it was, and no
109
+ * way to reach next month without a mouse. Now the month is a `role="grid"` of rows
110
+ * and `gridcell`s, exactly one day is tabbable (the roving tabindex), and the arrows
111
+ * walk the calendar the way the pattern says — day, week, month — crossing into the
112
+ * neighbouring month by MOVING the grid rather than stopping at its edge.
113
+ *
114
+ * Out-of-range days are `aria-disabled` rather than `disabled`, which is the APG
115
+ * guidance and not a shortcut: a `disabled` button cannot be focused, so a bounded
116
+ * month would have holes that the roving tabindex falls into. They stay reachable and
117
+ * readable, and the click handler is what refuses them.
30
118
  */
31
- declare function MiniCalendar({ from, to, locale, onSelect, mode, min, max, labels, }: MiniCalendarProps): react.JSX.Element;
119
+ declare function MiniCalendar({ from, to, locale: localeProp, weekStartsOn, onSelect, mode, min, max, labels: labelsProp, focusOnOpen, className, ...rest }: MiniCalendarProps): react.JSX.Element;
32
120
 
33
- export { MiniCalendar, type MiniCalendarProps };
121
+ export { DEFAULT_MINI_CALENDAR_LABELS, MiniCalendar, type MiniCalendarLabels, type MiniCalendarProps, type WeekDay };
@@ -1,61 +1,171 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useMemo, useState } from "react";
3
+ import { useEffect, useId, useMemo, useRef, useState } from "react";
3
4
  import { ChevronLeft, ChevronRight } from "lucide-react";
4
5
  import { cn } from "../lib/cn.js";
6
+ import { useAnnounce } from "../hooks/use-announce.js";
5
7
  import { parseIsoDate, sameYmd, toLocalIso } from "../lib/dates.js";
8
+ import { useKitLabels, useKitLocale } from "../i18n/kit-labels.js";
9
+ const DEFAULT_MINI_CALENDAR_LABELS = {
10
+ previousMonth: "Previous month",
11
+ nextMonth: "Next month",
12
+ day: (date) => date,
13
+ chooseStart: "Choose a start date",
14
+ chooseEnd: "Choose an end date",
15
+ startSelected: (date) => `${date} selected as the start. Choose an end date.`,
16
+ rangeSelected: (from, to) => `${from} to ${to} selected. Choose a start date to begin again.`
17
+ };
18
+ const DAY_NAME_FORMAT = {
19
+ weekday: "long",
20
+ day: "numeric",
21
+ month: "long",
22
+ year: "numeric"
23
+ };
24
+ function localeWeekStart(locale) {
25
+ try {
26
+ const tag = locale ?? new Intl.DateTimeFormat().resolvedOptions().locale;
27
+ const loc = new Intl.Locale(tag);
28
+ const firstDay = (loc.getWeekInfo?.() ?? loc.weekInfo)?.firstDay;
29
+ if (typeof firstDay === "number") return firstDay % 7;
30
+ } catch {
31
+ }
32
+ return 1;
33
+ }
34
+ const weekdayIndex = (d, weekStart) => (d.getDay() - weekStart + 7) % 7;
35
+ function stepMonths(d, months) {
36
+ const day = d.getDate();
37
+ const out = new Date(d.getFullYear(), d.getMonth() + months, 1);
38
+ const lastOfTarget = new Date(out.getFullYear(), out.getMonth() + 1, 0).getDate();
39
+ out.setDate(Math.min(day, lastOfTarget));
40
+ return out;
41
+ }
6
42
  function MiniCalendar({
7
43
  from,
8
44
  to,
9
- locale,
45
+ locale: localeProp,
46
+ weekStartsOn,
10
47
  onSelect,
11
48
  mode = "range",
12
49
  min,
13
50
  max,
14
- labels
51
+ labels: labelsProp,
52
+ focusOnOpen,
53
+ className,
54
+ ...rest
15
55
  }) {
56
+ const labels = useKitLabels("miniCalendar", DEFAULT_MINI_CALENDAR_LABELS, labelsProp);
57
+ const locale = useKitLocale(localeProp);
58
+ const weekStart = useMemo(
59
+ () => weekStartsOn ?? localeWeekStart(locale),
60
+ [weekStartsOn, locale]
61
+ );
62
+ const dayNumber = useMemo(() => new Intl.NumberFormat(locale), [locale]);
16
63
  const fromDate = parseIsoDate(from);
17
64
  const toDate = parseIsoDate(to);
18
65
  const minDate = min ? parseIsoDate(min) : null;
19
66
  const maxDate = max ? parseIsoDate(max) : null;
20
67
  const isDisabled = (d) => Boolean(minDate && d < minDate || maxDate && d > maxDate);
21
- const initial = fromDate ?? toDate ?? /* @__PURE__ */ new Date();
22
- const [view, setView] = useState({
23
- year: initial.getFullYear(),
24
- month: initial.getMonth()
68
+ const gridRef = useRef(null);
69
+ const id = useId();
70
+ const monthId = `${id}-month`;
71
+ const hintId = `${id}-hint`;
72
+ const { announce, regionProps } = useAnnounce();
73
+ const [activeIso, setActiveIso] = useState(() => {
74
+ const start = fromDate ?? toDate ?? /* @__PURE__ */ new Date();
75
+ if (minDate && start < minDate) return toLocalIso(minDate);
76
+ if (maxDate && start > maxDate) return toLocalIso(maxDate);
77
+ return toLocalIso(start);
25
78
  });
26
- const [lastKey, setLastKey] = useState(`${from}|${to}`);
27
- const currentKey = `${from}|${to}`;
28
- if (currentKey !== lastKey) {
29
- setLastKey(currentKey);
30
- const next = parseIsoDate(from) ?? parseIsoDate(to);
31
- if (next && (next.getFullYear() !== view.year || next.getMonth() !== view.month)) {
32
- setView({ year: next.getFullYear(), month: next.getMonth() });
33
- }
79
+ const [lastValue, setLastValue] = useState({ from, to });
80
+ if (lastValue.from !== from || lastValue.to !== to) {
81
+ const changed = lastValue.from !== from ? from : to;
82
+ setLastValue({ from, to });
83
+ const next = parseIsoDate(changed) ?? fromDate ?? toDate;
84
+ if (next && toLocalIso(next) !== activeIso) setActiveIso(toLocalIso(next));
34
85
  }
86
+ const activeDate = parseIsoDate(activeIso) ?? /* @__PURE__ */ new Date();
87
+ const view = { year: activeDate.getFullYear(), month: activeDate.getMonth() };
35
88
  const firstOfMonth = new Date(view.year, view.month, 1);
36
89
  const lastOfMonth = new Date(view.year, view.month + 1, 0);
37
- const startWeekday = (firstOfMonth.getDay() + 6) % 7;
90
+ const startWeekday = weekdayIndex(firstOfMonth, weekStart);
38
91
  const cells = [];
39
92
  for (let i = 0; i < startWeekday; i++) cells.push(null);
40
93
  for (let d = 1; d <= lastOfMonth.getDate(); d++) cells.push(new Date(view.year, view.month, d));
41
94
  while (cells.length % 7 !== 0) cells.push(null);
95
+ const weeks = [];
96
+ for (let i = 0; i < cells.length; i += 7) weeks.push(cells.slice(i, i + 7));
42
97
  const monthLabel = firstOfMonth.toLocaleDateString(locale, { month: "long", year: "numeric" });
98
+ const formatDay = (d) => d.toLocaleDateString(locale, DAY_NAME_FORMAT);
43
99
  const weekdayLabels = useMemo(() => {
44
- const ref = new Date(2024, 0, 1);
100
+ const ref = new Date(2024, 0, 7 + weekStart);
45
101
  return Array.from({ length: 7 }, (_, i) => {
46
102
  const d = new Date(ref);
47
103
  d.setDate(ref.getDate() + i);
48
- return d.toLocaleDateString(locale, { weekday: "narrow" });
49
- });
50
- }, [locale]);
51
- const move = (delta) => {
52
- setView((v) => {
53
- const d = new Date(v.year, v.month + delta, 1);
54
- return { year: d.getFullYear(), month: d.getMonth() };
104
+ return {
105
+ narrow: d.toLocaleDateString(locale, { weekday: "narrow" }),
106
+ long: d.toLocaleDateString(locale, { weekday: "long" })
107
+ };
55
108
  });
109
+ }, [locale, weekStart]);
110
+ const pendingFocus = useRef(null);
111
+ useEffect(() => {
112
+ const iso = pendingFocus.current;
113
+ if (!iso) return;
114
+ pendingFocus.current = null;
115
+ gridRef.current?.querySelector(`[data-iso="${iso}"]`)?.focus();
116
+ });
117
+ useEffect(() => {
118
+ if (!focusOnOpen) return;
119
+ gridRef.current?.querySelector('[tabindex="0"]')?.focus();
120
+ }, [focusOnOpen]);
121
+ const moveTo = (d, focus) => {
122
+ const iso = toLocalIso(d);
123
+ if (iso === activeIso) return;
124
+ if (focus) pendingFocus.current = iso;
125
+ setActiveIso(iso);
126
+ };
127
+ const onDayKeyDown = (e) => {
128
+ const next = new Date(activeDate);
129
+ switch (e.key) {
130
+ case "ArrowLeft":
131
+ next.setDate(next.getDate() - 1);
132
+ break;
133
+ case "ArrowRight":
134
+ next.setDate(next.getDate() + 1);
135
+ break;
136
+ case "ArrowUp":
137
+ next.setDate(next.getDate() - 7);
138
+ break;
139
+ case "ArrowDown":
140
+ next.setDate(next.getDate() + 7);
141
+ break;
142
+ case "Home":
143
+ next.setDate(next.getDate() - weekdayIndex(next, weekStart));
144
+ break;
145
+ case "End":
146
+ next.setDate(next.getDate() + (6 - weekdayIndex(next, weekStart)));
147
+ break;
148
+ // Shift+Page is the year step, as in the APG example. It is the only way to
149
+ // reach a birth year without holding PageUp for four hundred keystrokes.
150
+ case "PageUp":
151
+ next.setTime(stepMonths(next, e.shiftKey ? -12 : -1).getTime());
152
+ break;
153
+ case "PageDown":
154
+ next.setTime(stepMonths(next, e.shiftKey ? 12 : 1).getTime());
155
+ break;
156
+ default:
157
+ return;
158
+ }
159
+ e.preventDefault();
160
+ moveTo(next, true);
161
+ };
162
+ const moveMonth = (delta) => {
163
+ moveTo(stepMonths(activeDate, delta), false);
56
164
  };
57
165
  const handleClick = (d) => {
166
+ if (isDisabled(d)) return;
58
167
  const iso = toLocalIso(d);
168
+ moveTo(d, false);
59
169
  if (mode === "single") {
60
170
  onSelect(iso, iso);
61
171
  return;
@@ -64,70 +174,146 @@ function MiniCalendar({
64
174
  const tt = parseIsoDate(to);
65
175
  if (!f || f && tt) {
66
176
  onSelect(iso, "");
177
+ announce(labels.startSelected(formatDay(d)));
67
178
  return;
68
179
  }
69
180
  if (d < f) {
70
181
  onSelect(iso, toLocalIso(f));
182
+ announce(labels.rangeSelected(formatDay(d), formatDay(f)));
71
183
  } else {
72
184
  onSelect(toLocalIso(f), iso);
185
+ announce(labels.rangeSelected(formatDay(f), formatDay(d)));
73
186
  }
74
187
  };
75
188
  const today = /* @__PURE__ */ new Date();
189
+ const hasBand = Boolean(fromDate && toDate && !sameYmd(fromDate, toDate));
190
+ const daysInMonth = (d) => new Date(d.getFullYear(), d.getMonth() + 1, 0).getDate();
76
191
  const inRange = (d) => {
77
192
  if (!fromDate || !toDate) return false;
78
193
  return d >= fromDate && d <= toDate;
79
194
  };
80
- return /* @__PURE__ */ jsxs("div", { className: "select-none", children: [
81
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pb-1", children: [
82
- /* @__PURE__ */ jsx(
83
- "button",
195
+ const awaitingEnd = Boolean(fromDate) && !toDate;
196
+ const rangeHint = awaitingEnd ? labels.chooseEnd : labels.chooseStart;
197
+ return (
198
+ // The caller's classes come last, so tailwind-merge lets them win the way
199
+ // `className` does everywhere else in the kit; `...rest` first, as in the rest of
200
+ // this wave, so nothing from outside can take the grid's own wiring away.
201
+ /* @__PURE__ */ jsxs("div", { ...rest, className: cn("select-none", className), children: [
202
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pb-1", children: [
203
+ /* @__PURE__ */ jsx(
204
+ "button",
205
+ {
206
+ type: "button",
207
+ onClick: () => moveMonth(-1),
208
+ "aria-label": labels.previousMonth,
209
+ className: "rounded p-1 text-[var(--text-muted)] hover:bg-[var(--bg-hover)]",
210
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "size-4" })
211
+ }
212
+ ),
213
+ /* @__PURE__ */ jsx(
214
+ "div",
215
+ {
216
+ id: monthId,
217
+ "aria-live": "polite",
218
+ className: "text-xs font-medium capitalize text-[var(--text-secondary)]",
219
+ children: monthLabel
220
+ }
221
+ ),
222
+ /* @__PURE__ */ jsx(
223
+ "button",
224
+ {
225
+ type: "button",
226
+ onClick: () => moveMonth(1),
227
+ "aria-label": labels.nextMonth,
228
+ className: "rounded p-1 text-[var(--text-muted)] hover:bg-[var(--bg-hover)]",
229
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "size-4" })
230
+ }
231
+ )
232
+ ] }),
233
+ /* @__PURE__ */ jsxs(
234
+ "div",
84
235
  {
85
- type: "button",
86
- onClick: () => move(-1),
87
- "aria-label": labels?.previousMonth ?? "Previous month",
88
- className: "rounded p-1 text-slate-500 hover:bg-slate-100 dark:text-slate-400 dark:hover:bg-slate-800",
89
- children: /* @__PURE__ */ jsx(ChevronLeft, { className: "size-4" })
236
+ ref: gridRef,
237
+ role: "grid",
238
+ "aria-labelledby": monthId,
239
+ "aria-describedby": mode === "range" ? hintId : void 0,
240
+ className: "grid gap-y-0.5",
241
+ children: [
242
+ /* @__PURE__ */ jsx(
243
+ "div",
244
+ {
245
+ role: "row",
246
+ className: "grid grid-cols-7 text-center text-[10px] font-medium uppercase text-[var(--text-placeholder)]",
247
+ children: weekdayLabels.map((w, i) => /* @__PURE__ */ jsx("div", { role: "columnheader", "aria-label": w.long, className: "py-0.5", children: w.narrow }, i))
248
+ }
249
+ ),
250
+ weeks.map((week, wi) => (
251
+ // No column gap: the days of a range join into ONE band. With a gap each day
252
+ // was its own tinted box, and a selected fortnight read as fourteen chips.
253
+ /* @__PURE__ */ jsx("div", { role: "row", className: "grid grid-cols-7", children: week.map((d, di) => {
254
+ if (!d) return /* @__PURE__ */ jsx("div", { role: "gridcell", className: "h-8" }, di);
255
+ const iso = toLocalIso(d);
256
+ const disabled = isDisabled(d);
257
+ const isStart = !disabled && fromDate && sameYmd(d, fromDate);
258
+ const isEnd = !disabled && toDate && sameYmd(d, toDate);
259
+ const isToday = sameYmd(d, today);
260
+ const isInRange = !disabled && inRange(d) && !isStart && !isEnd;
261
+ const isActive = iso === activeIso;
262
+ const banded = hasBand && !disabled && (isStart || isEnd || isInRange);
263
+ const lastOfMonth2 = d.getDate() === daysInMonth(d);
264
+ const band = banded ? cn(
265
+ "pointer-events-none absolute inset-y-0 bg-[var(--brand-bg)]",
266
+ isStart ? "start-1/2 end-0" : isEnd ? "start-0 end-1/2" : "inset-x-0",
267
+ isInRange && (di === 0 || d.getDate() === 1) && "rounded-s-full",
268
+ isInRange && (di === 6 || lastOfMonth2) && "rounded-e-full",
269
+ isStart && (di === 6 || lastOfMonth2) && "hidden",
270
+ isEnd && (di === 0 || d.getDate() === 1) && "hidden"
271
+ ) : null;
272
+ return /* @__PURE__ */ jsxs("div", { role: "none", className: "relative flex h-8 items-center justify-center", children: [
273
+ band && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: band }),
274
+ /* @__PURE__ */ jsx(
275
+ "button",
276
+ {
277
+ type: "button",
278
+ role: "gridcell",
279
+ "data-iso": iso,
280
+ tabIndex: isActive ? 0 : -1,
281
+ "aria-label": labels.day(formatDay(d)),
282
+ "aria-selected": Boolean(isStart || isEnd || isInRange),
283
+ "aria-disabled": disabled || void 0,
284
+ "aria-current": isToday ? "date" : void 0,
285
+ onClick: () => handleClick(d),
286
+ onKeyDown: onDayKeyDown,
287
+ className: cn(
288
+ "relative size-8 rounded-full text-xs tabular-nums transition-colors",
289
+ // A grid you can walk with the keyboard needs to show where the
290
+ // keyboard IS. Inset because the cells sit half a pixel apart and
291
+ // an outset ring would be drawn over by its neighbours; the
292
+ // colour flips on the selected days for the reason the numpad's
293
+ // "Done" key does — a --brand ring on a --brand fill is a ring
294
+ // that exists only in the DOM.
295
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset",
296
+ isStart || isEnd ? "focus-visible:ring-[var(--brand-contrast)]" : "focus-visible:ring-[var(--brand)]",
297
+ disabled ? "cursor-not-allowed text-[var(--text-placeholder)]" : isStart || isEnd ? "bg-[var(--brand)] text-[var(--brand-contrast)] hover:bg-[var(--brand-hover)]" : isInRange ? "font-medium text-[var(--brand-muted)] hover:bg-[var(--brand-bg-hover)]" : "text-[var(--text-primary)] hover:bg-[var(--bg-hover)]",
298
+ isToday && !isStart && !isEnd && !isInRange && !disabled && "ring-1 ring-inset ring-[var(--border-strong)]"
299
+ ),
300
+ children: dayNumber.format(d.getDate())
301
+ },
302
+ di
303
+ )
304
+ ] }, di);
305
+ }) }, wi)
306
+ ))
307
+ ]
90
308
  }
91
309
  ),
92
- /* @__PURE__ */ jsx("div", { className: "text-xs font-medium capitalize text-slate-700 dark:text-slate-200", children: monthLabel }),
93
- /* @__PURE__ */ jsx(
94
- "button",
95
- {
96
- type: "button",
97
- onClick: () => move(1),
98
- "aria-label": labels?.nextMonth ?? "Next month",
99
- className: "rounded p-1 text-slate-500 hover:bg-slate-100 dark:text-slate-400 dark:hover:bg-slate-800",
100
- children: /* @__PURE__ */ jsx(ChevronRight, { className: "size-4" })
101
- }
102
- )
103
- ] }),
104
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-7 gap-0.5 text-center text-[10px] font-medium uppercase text-slate-400 dark:text-slate-500", children: weekdayLabels.map((w, i) => /* @__PURE__ */ jsx("div", { className: "py-0.5", children: w }, i)) }),
105
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-7 gap-0.5", children: cells.map((d, i) => {
106
- if (!d) return /* @__PURE__ */ jsx("div", { className: "h-7" }, i);
107
- const disabled = isDisabled(d);
108
- const isStart = !disabled && fromDate && sameYmd(d, fromDate);
109
- const isEnd = !disabled && toDate && sameYmd(d, toDate);
110
- const isToday = sameYmd(d, today);
111
- const isInRange = !disabled && inRange(d) && !isStart && !isEnd;
112
- return /* @__PURE__ */ jsx(
113
- "button",
114
- {
115
- type: "button",
116
- disabled,
117
- onClick: () => handleClick(d),
118
- className: cn(
119
- "h-7 text-xs rounded transition-colors",
120
- disabled ? "cursor-not-allowed text-slate-300 dark:text-slate-600" : isStart || isEnd ? "bg-sky-600 text-white hover:bg-sky-700 dark:bg-sky-500 dark:hover:bg-sky-400" : isInRange ? "bg-sky-100 text-sky-800 hover:bg-sky-200 dark:bg-sky-500/20 dark:text-sky-200" : "text-slate-700 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-800",
121
- isToday && !isStart && !isEnd && !isInRange && !disabled && "ring-1 ring-inset ring-slate-300 dark:ring-slate-600"
122
- ),
123
- children: d.getDate()
124
- },
125
- i
126
- );
127
- }) })
128
- ] });
310
+ mode === "range" && /* @__PURE__ */ jsx("span", { id: hintId, className: "sr-only-fixed", children: rangeHint }),
311
+ /* @__PURE__ */ jsx("span", { ...regionProps })
312
+ ] })
313
+ );
129
314
  }
130
315
  export {
316
+ DEFAULT_MINI_CALENDAR_LABELS,
131
317
  MiniCalendar
132
318
  };
133
319
  //# sourceMappingURL=mini-calendar.js.map