@jcsoftdev/ui 0.5.0 → 0.7.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 (392) hide show
  1. package/CHANGELOG.md +361 -0
  2. package/README.md +31 -5
  3. package/bin/ui-theme.mjs +40 -6
  4. package/dist/ai/code-block/code-block.js +1 -1
  5. package/dist/atoms/avatar/avatar.d.ts +6 -1
  6. package/dist/atoms/avatar/avatar.js +3 -2
  7. package/dist/atoms/big-date/big-date.js +2 -2
  8. package/dist/atoms/button/button.d.ts +6 -1
  9. package/dist/atoms/button/button.js +2 -2
  10. package/dist/atoms/chip/chip.d.ts +5 -0
  11. package/dist/atoms/chip/chip.js +3 -3
  12. package/dist/atoms/icon-button/icon-button.js +1 -1
  13. package/dist/atoms/internal/hit-area.d.ts +5 -4
  14. package/dist/atoms/internal/hit-area.js +1 -1
  15. package/dist/atoms/progress/index.d.ts +1 -1
  16. package/dist/atoms/progress/index.js +4 -1
  17. package/dist/atoms/progress/progress.d.ts +6 -1
  18. package/dist/atoms/progress/progress.js +19 -1
  19. package/dist/atoms/radio-group/radio-group.js +1 -1
  20. package/dist/atoms/status-pill/status-pill.d.ts +16 -5
  21. package/dist/atoms/status-pill/status-pill.js +43 -18
  22. package/dist/brand/logo-forge.js +1 -1
  23. package/dist/charts/candlestick-chart/candlestick-chart.js +2 -2
  24. package/dist/charts/chart-grid/chart-grid.js +2 -2
  25. package/dist/charts/chord-chart/chord-chart.js +1 -1
  26. package/dist/charts/core/axes.js +2 -2
  27. package/dist/charts/core/cartesian/annotations.js +2 -2
  28. package/dist/charts/core/cartesian/marks.js +1 -1
  29. package/dist/charts/core/distribution/marks.js +1 -1
  30. package/dist/charts/core/distribution/xy-points.js +1 -1
  31. package/dist/charts/core/export-menu.js +1 -1
  32. package/dist/charts/funnel-chart/funnel-chart.js +1 -1
  33. package/dist/charts/gantt-chart/gantt-chart.js +4 -4
  34. package/dist/charts/gantt-chart/gantt-marks.js +3 -3
  35. package/dist/charts/index.d.ts +2 -0
  36. package/dist/charts/index.js +2 -0
  37. package/dist/charts/maps/geo/map-data-table.js +1 -1
  38. package/dist/charts/polar-area-chart/polar-area-chart.js +1 -1
  39. package/dist/charts/radar-chart/radar-chart.js +1 -1
  40. package/dist/charts/stock-chart/stock-chart.js +1 -1
  41. package/dist/charts/stock-chart/stock-drawing-layer.js +3 -3
  42. package/dist/charts/stock-chart/stock-plot.js +2 -2
  43. package/dist/containers/chat-thread/chat-thread.d.ts +98 -0
  44. package/dist/containers/chat-thread/chat-thread.js +219 -0
  45. package/dist/containers/chat-thread/format.d.ts +20 -0
  46. package/dist/containers/chat-thread/format.js +50 -0
  47. package/dist/containers/chat-thread/index.d.ts +1 -0
  48. package/dist/containers/chat-thread/index.js +8 -0
  49. package/dist/containers/cols/cols.d.ts +1 -1
  50. package/dist/containers/cols/cols.js +7 -0
  51. package/dist/containers/comment/comment.js +1 -1
  52. package/dist/containers/context-rail/context-rail.d.ts +62 -0
  53. package/dist/containers/context-rail/context-rail.js +175 -0
  54. package/dist/containers/context-rail/index.d.ts +1 -0
  55. package/dist/containers/context-rail/index.js +6 -0
  56. package/dist/containers/dashboard/dashboard.d.ts +40 -0
  57. package/dist/containers/dashboard/dashboard.js +84 -0
  58. package/dist/containers/dashboard/index.d.ts +1 -0
  59. package/dist/containers/dashboard/index.js +14 -0
  60. package/dist/containers/data-grid/data-grid.demos.js +4 -4
  61. package/dist/containers/data-grid/data-grid.js +6 -6
  62. package/dist/containers/data-grid/filter-builder-editor.js +2 -2
  63. package/dist/containers/data-grid/grid-toolbar.js +1 -1
  64. package/dist/containers/data-grid/spreadsheet.demos.d.ts +1 -1
  65. package/dist/containers/data-grid/spreadsheet.demos.js +1 -1
  66. package/dist/containers/detail-header/detail-header.d.ts +24 -0
  67. package/dist/containers/detail-header/detail-header.js +32 -0
  68. package/dist/containers/detail-header/index.d.ts +1 -0
  69. package/dist/containers/detail-header/index.js +6 -0
  70. package/dist/containers/facts/facts.js +1 -1
  71. package/dist/containers/filter-bar/filter-bar.d.ts +58 -0
  72. package/dist/containers/filter-bar/filter-bar.js +123 -0
  73. package/dist/containers/filter-bar/index.d.ts +1 -0
  74. package/dist/containers/filter-bar/index.js +6 -0
  75. package/dist/containers/hbars/hbars.js +2 -2
  76. package/dist/containers/index.d.ts +9 -0
  77. package/dist/containers/index.js +9 -0
  78. package/dist/containers/kanban/kanban.d.ts +23 -2
  79. package/dist/containers/kanban/kanban.js +103 -21
  80. package/dist/containers/kanban/model.d.ts +12 -0
  81. package/dist/containers/kanban/model.js +8 -0
  82. package/dist/containers/kpi/kpi.js +1 -1
  83. package/dist/containers/kpi-group/kpi-group.d.ts +6 -1
  84. package/dist/containers/kpi-group/kpi-group.js +6 -2
  85. package/dist/containers/list-detail/index.d.ts +1 -1
  86. package/dist/containers/list-detail/index.js +4 -0
  87. package/dist/containers/list-detail/list-detail.d.ts +51 -3
  88. package/dist/containers/list-detail/list-detail.js +111 -15
  89. package/dist/containers/page/page.d.ts +17 -4
  90. package/dist/containers/page/page.js +33 -4
  91. package/dist/containers/page-header/back.d.ts +10 -0
  92. package/dist/containers/page-header/back.js +28 -0
  93. package/dist/containers/page-header/index.d.ts +1 -0
  94. package/dist/containers/page-header/index.js +1 -0
  95. package/dist/containers/page-header/page-header.d.ts +19 -2
  96. package/dist/containers/page-header/page-header.js +26 -2
  97. package/dist/containers/pagination/cursor-pagination.d.ts +28 -0
  98. package/dist/containers/pagination/cursor-pagination.js +48 -0
  99. package/dist/containers/pagination/index.d.ts +3 -0
  100. package/dist/containers/pagination/index.js +10 -0
  101. package/dist/containers/pagination/pagination.d.ts +52 -0
  102. package/dist/containers/pagination/pagination.js +216 -0
  103. package/dist/containers/pagination/range.d.ts +29 -0
  104. package/dist/containers/pagination/range.js +42 -0
  105. package/dist/containers/pagination/use-pagination.d.ts +18 -0
  106. package/dist/containers/pagination/use-pagination.js +22 -0
  107. package/dist/containers/responsive-list/responsive-list.d.ts +29 -3
  108. package/dist/containers/responsive-list/responsive-list.js +202 -82
  109. package/dist/containers/row-actions/index.d.ts +1 -0
  110. package/dist/containers/row-actions/index.js +4 -0
  111. package/dist/containers/row-actions/row-actions.d.ts +26 -0
  112. package/dist/containers/row-actions/row-actions.js +78 -0
  113. package/dist/containers/selectable-card/index.d.ts +1 -0
  114. package/dist/containers/selectable-card/index.js +6 -0
  115. package/dist/containers/selectable-card/selectable-card.d.ts +26 -0
  116. package/dist/containers/selectable-card/selectable-card.js +57 -0
  117. package/dist/containers/settings-layout/settings-layout.d.ts +24 -7
  118. package/dist/containers/settings-layout/settings-layout.js +63 -8
  119. package/dist/containers/shortcuts/shortcuts.js +1 -1
  120. package/dist/containers/table/cell-padding.d.ts +2 -0
  121. package/dist/containers/table/cell-padding.js +4 -0
  122. package/dist/containers/table/index.d.ts +1 -0
  123. package/dist/containers/table/index.js +8 -0
  124. package/dist/containers/table/sort.d.ts +14 -0
  125. package/dist/containers/table/sort.js +11 -0
  126. package/dist/containers/table/table-parts.d.ts +24 -0
  127. package/dist/containers/table/table-parts.js +52 -0
  128. package/dist/containers/table/table.d.ts +37 -3
  129. package/dist/containers/table/table.js +120 -19
  130. package/dist/containers/table-columns-menu/index.d.ts +1 -0
  131. package/dist/containers/table-columns-menu/index.js +6 -0
  132. package/dist/containers/table-columns-menu/table-columns-menu.d.ts +14 -0
  133. package/dist/containers/table-columns-menu/table-columns-menu.js +46 -0
  134. package/dist/dashboards/layout.d.ts +1 -27
  135. package/dist/dashboards/layout.js +8 -40
  136. package/dist/forms/chip-group/chip-group.d.ts +5 -0
  137. package/dist/forms/chip-group/chip-group.js +3 -1
  138. package/dist/forms/combobox/combobox.js +1 -1
  139. package/dist/forms/copy-field/copy-field.js +1 -1
  140. package/dist/forms/date-picker/date-picker.d.ts +3 -1
  141. package/dist/forms/date-picker/date-picker.js +4 -2
  142. package/dist/forms/date-picker/date-time-picker.d.ts +8 -2
  143. package/dist/forms/date-picker/date-time-picker.js +13 -2
  144. package/dist/forms/field/field.d.ts +9 -2
  145. package/dist/forms/field/field.js +18 -4
  146. package/dist/forms/fieldset/fieldset.d.ts +11 -0
  147. package/dist/forms/fieldset/fieldset.js +12 -0
  148. package/dist/forms/fieldset/index.d.ts +1 -0
  149. package/dist/forms/fieldset/index.js +4 -0
  150. package/dist/forms/form-footer/form-footer.d.ts +26 -0
  151. package/dist/forms/form-footer/form-footer.js +44 -0
  152. package/dist/forms/form-footer/index.d.ts +1 -0
  153. package/dist/forms/form-footer/index.js +4 -0
  154. package/dist/forms/form-grid/form-grid.d.ts +21 -4
  155. package/dist/forms/form-grid/form-grid.js +20 -3
  156. package/dist/forms/form-grid/index.d.ts +1 -1
  157. package/dist/forms/form-grid/index.js +6 -2
  158. package/dist/forms/form-section/form-section.d.ts +12 -0
  159. package/dist/forms/form-section/form-section.js +30 -0
  160. package/dist/forms/form-section/index.d.ts +1 -0
  161. package/dist/forms/form-section/index.js +4 -0
  162. package/dist/forms/index.d.ts +3 -0
  163. package/dist/forms/index.js +3 -0
  164. package/dist/forms/input/input.d.ts +6 -2
  165. package/dist/forms/input/input.js +4 -1
  166. package/dist/forms/internal/listbox-items.d.ts +1 -1
  167. package/dist/forms/internal/listbox-items.js +3 -2
  168. package/dist/forms/native-select/native-select.js +1 -1
  169. package/dist/forms/number-stepper/index.d.ts +1 -1
  170. package/dist/forms/number-stepper/number-stepper.d.ts +7 -0
  171. package/dist/forms/number-stepper/number-stepper.js +37 -6
  172. package/dist/forms/select/index.d.ts +1 -1
  173. package/dist/forms/select/select.d.ts +5 -2
  174. package/dist/forms/select/select.js +7 -2
  175. package/dist/forms/select-menu/select-menu.js +1 -1
  176. package/dist/forms/time-input/time-input.d.ts +4 -2
  177. package/dist/forms/time-input/time-input.js +3 -1
  178. package/dist/i18n/strings.d.ts +94 -0
  179. package/dist/i18n/strings.js +50 -0
  180. package/dist/motion/count-up.d.ts +20 -0
  181. package/dist/motion/count-up.js +59 -0
  182. package/dist/motion/cross-fade.d.ts +21 -0
  183. package/dist/motion/cross-fade.js +86 -0
  184. package/dist/motion/index.d.ts +5 -0
  185. package/dist/motion/index.js +14 -0
  186. package/dist/motion/model.d.ts +15 -0
  187. package/dist/motion/model.js +68 -0
  188. package/dist/motion/motion-styles.d.ts +1 -0
  189. package/dist/motion/motion-styles.js +35 -0
  190. package/dist/motion/reveal.d.ts +37 -0
  191. package/dist/motion/reveal.js +69 -0
  192. package/dist/motion/use-enter-phase.d.ts +11 -0
  193. package/dist/motion/use-enter-phase.js +40 -0
  194. package/dist/motion/use-highlight-row.d.ts +22 -0
  195. package/dist/motion/use-highlight-row.js +38 -0
  196. package/dist/navigation/tabs/tabs.js +1 -1
  197. package/dist/navigation/wizard/wizard.d.ts +4 -1
  198. package/dist/navigation/wizard/wizard.js +3 -0
  199. package/dist/overlays/alert-dialog/alert-dialog.js +8 -1
  200. package/dist/overlays/context-menu/context-menu.js +3 -1
  201. package/dist/overlays/dialog/dialog.d.ts +1 -0
  202. package/dist/overlays/dialog/dialog.js +11 -3
  203. package/dist/overlays/drawer/drawer.d.ts +18 -4
  204. package/dist/overlays/drawer/drawer.js +53 -4
  205. package/dist/overlays/drawer/index.d.ts +1 -1
  206. package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +1 -1
  207. package/dist/overlays/dropdown-menu/dropdown-menu.js +5 -4
  208. package/dist/overlays/hover-card/hover-card.js +2 -0
  209. package/dist/overlays/popover/popover.js +2 -0
  210. package/dist/overlays/toaster/index.d.ts +1 -1
  211. package/dist/overlays/toaster/toast-store.d.ts +2 -0
  212. package/dist/overlays/toaster/toast-store.js +6 -1
  213. package/dist/overlays/toaster/toaster.d.ts +28 -2
  214. package/dist/overlays/toaster/toaster.js +86 -29
  215. package/dist/overlays/tooltip/tooltip.js +2 -0
  216. package/dist/primitives/use-presence.js +9 -0
  217. package/dist/shell/app-shell/app-shell.d.ts +8 -1
  218. package/dist/shell/app-shell/app-shell.js +50 -3
  219. package/dist/shell/index.d.ts +1 -0
  220. package/dist/shell/index.js +1 -0
  221. package/dist/shell/sidebar/sidebar.d.ts +17 -1
  222. package/dist/shell/sidebar/sidebar.js +126 -76
  223. package/dist/shell/topbar/topbar.d.ts +4 -2
  224. package/dist/shell/topbar/topbar.js +2 -0
  225. package/dist/showcase/operations-bento.js +2 -2
  226. package/dist/states/empty-state/empty-state.d.ts +10 -3
  227. package/dist/states/empty-state/empty-state.js +46 -5
  228. package/dist/states/error-state/error-state.js +1 -1
  229. package/dist/states/skeleton/skeleton.d.ts +16 -1
  230. package/dist/states/skeleton/skeleton.js +13 -5
  231. package/dist/utils/class-tokens.generated.js +4 -6
  232. package/dist/utils/focus-chain.d.ts +11 -0
  233. package/dist/utils/focus-chain.js +39 -0
  234. package/dist/utils/focus-rescue.d.ts +13 -0
  235. package/dist/utils/focus-rescue.js +48 -0
  236. package/dist/utils/list-navigation.d.ts +14 -0
  237. package/dist/utils/list-navigation.js +44 -0
  238. package/dist/utils/overlay-motion.d.ts +12 -0
  239. package/dist/utils/overlay-motion.js +14 -0
  240. package/dist/utils/use-container-width.d.ts +6 -0
  241. package/dist/utils/use-container-width.js +19 -0
  242. package/package.json +2 -2
  243. package/scripts/build-theme.mjs +46 -5
  244. package/src/ai/code-block/code-block.tsx +1 -1
  245. package/src/atoms/avatar/avatar.tsx +8 -2
  246. package/src/atoms/big-date/big-date.tsx +2 -2
  247. package/src/atoms/button/button.tsx +8 -3
  248. package/src/atoms/chip/chip.tsx +8 -3
  249. package/src/atoms/icon-button/icon-button.tsx +1 -1
  250. package/src/atoms/internal/hit-area.ts +5 -4
  251. package/src/atoms/progress/index.ts +8 -1
  252. package/src/atoms/progress/progress.tsx +30 -1
  253. package/src/atoms/radio-group/radio-group.tsx +1 -1
  254. package/src/atoms/status-pill/status-pill.tsx +59 -18
  255. package/src/brand/logo-forge.tsx +1 -1
  256. package/src/charts/candlestick-chart/candlestick-chart.tsx +2 -2
  257. package/src/charts/chart-grid/chart-grid.tsx +2 -2
  258. package/src/charts/chord-chart/chord-chart.tsx +1 -1
  259. package/src/charts/core/axes.tsx +2 -2
  260. package/src/charts/core/cartesian/annotations.tsx +2 -2
  261. package/src/charts/core/cartesian/marks.tsx +1 -1
  262. package/src/charts/core/distribution/marks.tsx +1 -1
  263. package/src/charts/core/distribution/xy-points.tsx +1 -1
  264. package/src/charts/core/export-menu.tsx +1 -1
  265. package/src/charts/funnel-chart/funnel-chart.tsx +1 -1
  266. package/src/charts/gantt-chart/gantt-chart.tsx +4 -4
  267. package/src/charts/gantt-chart/gantt-marks.tsx +3 -3
  268. package/src/charts/index.ts +2 -0
  269. package/src/charts/maps/geo/map-data-table.tsx +1 -1
  270. package/src/charts/polar-area-chart/polar-area-chart.tsx +1 -1
  271. package/src/charts/radar-chart/radar-chart.tsx +1 -1
  272. package/src/charts/stock-chart/stock-chart.tsx +1 -1
  273. package/src/charts/stock-chart/stock-drawing-layer.tsx +3 -3
  274. package/src/charts/stock-chart/stock-plot.tsx +2 -2
  275. package/src/containers/chat-thread/chat-thread.tsx +331 -0
  276. package/src/containers/chat-thread/format.ts +67 -0
  277. package/src/containers/chat-thread/index.ts +12 -0
  278. package/src/containers/cols/cols.tsx +13 -1
  279. package/src/containers/comment/comment.tsx +1 -1
  280. package/src/containers/context-rail/context-rail.tsx +229 -0
  281. package/src/containers/context-rail/index.ts +7 -0
  282. package/src/containers/dashboard/dashboard.tsx +142 -0
  283. package/src/containers/dashboard/index.ts +12 -0
  284. package/src/containers/data-grid/data-grid.demos.tsx +4 -4
  285. package/src/containers/data-grid/data-grid.tsx +6 -6
  286. package/src/containers/data-grid/filter-builder-editor.tsx +2 -2
  287. package/src/containers/data-grid/grid-toolbar.tsx +1 -1
  288. package/src/containers/data-grid/spreadsheet.demos.tsx +1 -1
  289. package/src/containers/detail-header/detail-header.tsx +64 -0
  290. package/src/containers/detail-header/index.ts +5 -0
  291. package/src/containers/facts/facts.tsx +1 -1
  292. package/src/containers/filter-bar/filter-bar.tsx +201 -0
  293. package/src/containers/filter-bar/index.ts +7 -0
  294. package/src/containers/hbars/hbars.tsx +2 -2
  295. package/src/containers/index.ts +9 -0
  296. package/src/containers/kanban/kanban.tsx +148 -39
  297. package/src/containers/kanban/model.ts +20 -0
  298. package/src/containers/kpi/kpi.tsx +1 -1
  299. package/src/containers/kpi-group/kpi-group.tsx +17 -2
  300. package/src/containers/list-detail/index.ts +5 -0
  301. package/src/containers/list-detail/list-detail.tsx +159 -9
  302. package/src/containers/page/page.tsx +61 -7
  303. package/src/containers/page-header/back.tsx +42 -0
  304. package/src/containers/page-header/index.ts +1 -0
  305. package/src/containers/page-header/page-header.tsx +49 -3
  306. package/src/containers/pagination/cursor-pagination.tsx +79 -0
  307. package/src/containers/pagination/index.ts +7 -0
  308. package/src/containers/pagination/pagination.tsx +266 -0
  309. package/src/containers/pagination/range.ts +68 -0
  310. package/src/containers/pagination/use-pagination.ts +44 -0
  311. package/src/containers/responsive-list/responsive-list.tsx +190 -47
  312. package/src/containers/row-actions/index.ts +1 -0
  313. package/src/containers/row-actions/row-actions.tsx +114 -0
  314. package/src/containers/selectable-card/index.ts +5 -0
  315. package/src/containers/selectable-card/selectable-card.tsx +84 -0
  316. package/src/containers/settings-layout/settings-layout.tsx +104 -13
  317. package/src/containers/shortcuts/shortcuts.tsx +1 -1
  318. package/src/containers/table/cell-padding.ts +2 -0
  319. package/src/containers/table/index.ts +6 -0
  320. package/src/containers/table/sort.ts +23 -0
  321. package/src/containers/table/table-parts.tsx +81 -0
  322. package/src/containers/table/table.tsx +212 -45
  323. package/src/containers/table-columns-menu/index.ts +5 -0
  324. package/src/containers/table-columns-menu/table-columns-menu.tsx +68 -0
  325. package/src/dashboards/layout.tsx +8 -75
  326. package/src/forms/chip-group/chip-group.tsx +8 -1
  327. package/src/forms/combobox/combobox.tsx +1 -1
  328. package/src/forms/copy-field/copy-field.tsx +1 -1
  329. package/src/forms/date-picker/date-picker.tsx +7 -2
  330. package/src/forms/date-picker/date-time-picker.tsx +28 -2
  331. package/src/forms/field/field.tsx +30 -3
  332. package/src/forms/fieldset/fieldset.tsx +22 -0
  333. package/src/forms/fieldset/index.ts +1 -0
  334. package/src/forms/form-footer/form-footer.tsx +74 -0
  335. package/src/forms/form-footer/index.ts +1 -0
  336. package/src/forms/form-grid/form-grid.tsx +42 -5
  337. package/src/forms/form-grid/index.ts +8 -1
  338. package/src/forms/form-section/form-section.tsx +41 -0
  339. package/src/forms/form-section/index.ts +1 -0
  340. package/src/forms/index.ts +3 -0
  341. package/src/forms/input/input.tsx +10 -3
  342. package/src/forms/internal/listbox-items.tsx +3 -4
  343. package/src/forms/native-select/native-select.tsx +1 -1
  344. package/src/forms/number-stepper/index.ts +1 -0
  345. package/src/forms/number-stepper/number-stepper.tsx +51 -6
  346. package/src/forms/select/index.ts +1 -1
  347. package/src/forms/select/select.tsx +14 -3
  348. package/src/forms/select-menu/select-menu.tsx +1 -1
  349. package/src/forms/time-input/time-input.tsx +6 -2
  350. package/src/i18n/strings.ts +94 -0
  351. package/src/motion/count-up.tsx +83 -0
  352. package/src/motion/cross-fade.tsx +139 -0
  353. package/src/motion/index.ts +5 -0
  354. package/src/motion/model.ts +86 -0
  355. package/src/motion/motion-styles.tsx +47 -0
  356. package/src/motion/reveal.tsx +115 -0
  357. package/src/motion/use-enter-phase.ts +50 -0
  358. package/src/motion/use-highlight-row.ts +63 -0
  359. package/src/navigation/tabs/tabs.tsx +1 -1
  360. package/src/navigation/wizard/wizard.tsx +6 -1
  361. package/src/overlays/alert-dialog/alert-dialog.tsx +5 -1
  362. package/src/overlays/context-menu/context-menu.tsx +3 -2
  363. package/src/overlays/dialog/dialog.tsx +9 -3
  364. package/src/overlays/drawer/drawer.tsx +68 -6
  365. package/src/overlays/drawer/index.ts +1 -0
  366. package/src/overlays/dropdown-menu/dropdown-menu.tsx +5 -4
  367. package/src/overlays/hover-card/hover-card.tsx +2 -0
  368. package/src/overlays/popover/popover.tsx +2 -0
  369. package/src/overlays/toaster/index.ts +2 -0
  370. package/src/overlays/toaster/toast-store.ts +8 -0
  371. package/src/overlays/toaster/toaster.tsx +127 -17
  372. package/src/overlays/tooltip/tooltip.tsx +2 -0
  373. package/src/primitives/use-presence.ts +13 -0
  374. package/src/shell/app-shell/app-shell.tsx +54 -2
  375. package/src/shell/index.ts +1 -0
  376. package/src/shell/sidebar/sidebar.tsx +154 -75
  377. package/src/shell/topbar/topbar.tsx +8 -0
  378. package/src/showcase/operations-bento.tsx +2 -2
  379. package/src/states/empty-state/empty-state.tsx +52 -9
  380. package/src/states/error-state/error-state.tsx +1 -1
  381. package/src/states/skeleton/skeleton.tsx +33 -5
  382. package/src/utils/class-tokens.generated.ts +4 -6
  383. package/src/utils/focus-chain.ts +53 -0
  384. package/src/utils/focus-rescue.ts +68 -0
  385. package/src/utils/list-navigation.ts +63 -0
  386. package/src/utils/overlay-motion.ts +33 -0
  387. package/src/utils/use-container-width.ts +24 -0
  388. package/styles/Theme.kt +15 -18
  389. package/styles/tailwind.css +29 -28
  390. package/styles/theme.css +29 -28
  391. package/styles/tokens.css +46 -0
  392. package/tokens/default.json +51 -29
@@ -4,10 +4,12 @@ import {
4
4
  type ChangeEvent,
5
5
  type ChangeEventHandler,
6
6
  type KeyboardEvent,
7
+ useEffect,
7
8
  useId,
8
9
  useRef,
9
10
  useState,
10
11
  } from "react";
12
+ import { useUiStrings } from "../../i18n/index.js";
11
13
  import { Minus, Plus } from "../../icons/index.js";
12
14
  import type { ClassNames } from "../../utils/class-names.js";
13
15
  import { cn } from "../../utils/cn.js";
@@ -16,7 +18,20 @@ import { canStep, parseNumber, stepText } from "./model.js";
16
18
 
17
19
  export type NumberStepperPart = "root" | "decrement" | "increment" | "input" | "unit";
18
20
 
21
+ export type NumberStepperSize = "sm" | "md";
22
+
23
+ const sizeClasses: Readonly<Record<NumberStepperSize, { root: string; button: string }>> = {
24
+ sm: { root: "h-control-sm", button: "w-7" },
25
+ md: { root: "h-input", button: "w-9" },
26
+ };
27
+
19
28
  interface NumberStepperBaseProps {
29
+ /** `sm` (30px) matches a small `Button` or `Input` for dense rows; `md` (default) is the regular field height. */
30
+ size?: NumberStepperSize;
31
+ /** Accessible name of the plus button. Defaults to the localized verb followed by the field label. */
32
+ incrementLabel?: string;
33
+ /** Accessible name of the minus button. Defaults to the localized verb followed by the field label. */
34
+ decrementLabel?: string;
20
35
  min?: number;
21
36
  max?: number;
22
37
  step?: number;
@@ -68,6 +83,9 @@ export type NumberStepperProps = NumberStepperNumberProps | NumberStepperStringP
68
83
  */
69
84
  export function NumberStepper(props: NumberStepperProps) {
70
85
  const {
86
+ size = "md",
87
+ incrementLabel,
88
+ decrementLabel,
71
89
  min = Number.NEGATIVE_INFINITY,
72
90
  max = Number.POSITIVE_INFINITY,
73
91
  step = 1,
@@ -85,9 +103,33 @@ export function NumberStepper(props: NumberStepperProps) {
85
103
  "aria-describedby": ariaDescribedBy,
86
104
  "aria-invalid": ariaInvalid,
87
105
  } = props;
106
+ const strings = useUiStrings();
88
107
  const autoId = useId();
89
108
  const id = idProp ?? autoId;
109
+ const decrementId = `${autoId}-decrement`;
110
+ const incrementId = `${autoId}-increment`;
111
+ const [fieldLabel, setFieldLabel] = useState("");
90
112
  const inputRef = useRef<HTMLInputElement | null>(null);
113
+
114
+ useEffect(() => {
115
+ if (ariaLabel || ariaLabelledBy) return;
116
+ const labels = Array.from(inputRef.current?.labels ?? []);
117
+ setFieldLabel(
118
+ labels
119
+ .map((label) => label.textContent?.trim() ?? "")
120
+ .filter(Boolean)
121
+ .join(" "),
122
+ );
123
+ });
124
+
125
+ const stepButtonName = (verb: string, custom: string | undefined, buttonId: string) => {
126
+ if (custom) return { "aria-label": custom };
127
+ if (ariaLabelledBy) {
128
+ return { "aria-label": verb, "aria-labelledby": `${buttonId} ${ariaLabelledBy}` };
129
+ }
130
+ const subject = ariaLabel ?? fieldLabel;
131
+ return { "aria-label": subject ? `${verb} ${subject}` : verb };
132
+ };
91
133
  const isString = props.mode === "string";
92
134
  const [innerNumber, setInnerNumber] = useState(isString ? 0 : (props.defaultValue ?? 0));
93
135
  const [innerText, setInnerText] = useState(isString ? (props.defaultValue ?? "") : "");
@@ -148,13 +190,14 @@ export function NumberStepper(props: NumberStepperProps) {
148
190
  };
149
191
 
150
192
  const button =
151
- "grid h-full w-9 shrink-0 place-items-center text-ink-2 outline-none hover:bg-surface-sunken hover:text-ink focus-visible:focus-ring disabled:cursor-not-allowed disabled:opacity-40";
193
+ "grid h-full shrink-0 place-items-center text-ink-2 outline-none hover:bg-surface-sunken hover:text-ink focus-visible:focus-ring disabled:cursor-not-allowed disabled:opacity-40";
152
194
  const valid = !Number.isNaN(number);
153
195
 
154
196
  return (
155
197
  <div
156
198
  className={cn(
157
- "inline-flex h-input min-w-32 max-w-full items-stretch overflow-hidden rounded-input border-control bg-surface-control",
199
+ "inline-flex min-w-32 max-w-full items-stretch overflow-hidden rounded-input border-control bg-surface-control",
200
+ sizeClasses[size].root,
158
201
  disabled && "opacity-60",
159
202
  (invalid || ariaInvalid) && "border-danger",
160
203
  classNames?.root,
@@ -164,11 +207,12 @@ export function NumberStepper(props: NumberStepperProps) {
164
207
  <button
165
208
  type="button"
166
209
  tabIndex={-1}
167
- aria-label="Disminuir"
210
+ id={decrementId}
211
+ {...stepButtonName(strings.decrease, decrementLabel, decrementId)}
168
212
  aria-controls={id}
169
213
  disabled={disabled || !canStep(text, -1, { min, max })}
170
214
  onClick={() => move(-1)}
171
- className={cn(button, "pressable", classNames?.decrement)}
215
+ className={cn(button, sizeClasses[size].button, "pressable", classNames?.decrement)}
172
216
  >
173
217
  <Minus aria-hidden="true" className="size-3.5" />
174
218
  </button>
@@ -210,11 +254,12 @@ export function NumberStepper(props: NumberStepperProps) {
210
254
  <button
211
255
  type="button"
212
256
  tabIndex={-1}
213
- aria-label="Aumentar"
257
+ id={incrementId}
258
+ {...stepButtonName(strings.increase, incrementLabel, incrementId)}
214
259
  aria-controls={id}
215
260
  disabled={disabled || !canStep(text, 1, { min, max })}
216
261
  onClick={() => move(1)}
217
- className={cn(button, "pressable", classNames?.increment)}
262
+ className={cn(button, sizeClasses[size].button, "pressable", classNames?.increment)}
218
263
  >
219
264
  <Plus aria-hidden="true" className="size-3.5" />
220
265
  </button>
@@ -1 +1 @@
1
- export { Select, type SelectProps } from "./select.js";
1
+ export { Select, type SelectProps, type SelectSize } from "./select.js";
@@ -2,18 +2,29 @@ import type { ComponentPropsWithoutRef } from "react";
2
2
  import { ChevronDown } from "../../icons/index.js";
3
3
  import { cn } from "../../utils/cn.js";
4
4
 
5
- export interface SelectProps extends ComponentPropsWithoutRef<"select"> {}
5
+ export type SelectSize = "sm" | "md";
6
+
7
+ export interface SelectProps extends Omit<ComponentPropsWithoutRef<"select">, "size"> {
8
+ /** `sm` is 30px and `md` (default) 38px, the heights of `Button` and `Input` of the same size. */
9
+ size?: SelectSize;
10
+ }
11
+
12
+ const selectSizeClasses: Readonly<Record<SelectSize, string>> = {
13
+ sm: "h-control-sm pl-2.5",
14
+ md: "h-control-md pl-3",
15
+ };
6
16
 
7
17
  /**
8
18
  * Wraps the native `<select>` (keeps the system picker on mobile) and draws
9
19
  * the chevron with an icon.
10
20
  */
11
- export function Select({ className, children, ...props }: SelectProps) {
21
+ export function Select({ size = "md", className, children, ...props }: SelectProps) {
12
22
  return (
13
23
  <span className="relative flex w-full items-center">
14
24
  <select
15
25
  className={cn(
16
- "h-input w-full min-w-0 appearance-none rounded-input border-control bg-surface-control py-0 pr-7 pl-3 text-control text-ink focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1 aria-[invalid=true]:border-danger",
26
+ "w-full min-w-0 appearance-none rounded-input border-control bg-surface-control py-0 pr-7 text-control text-ink focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1 aria-[invalid=true]:border-danger",
27
+ selectSizeClasses[size],
17
28
  className,
18
29
  )}
19
30
  {...props}
@@ -223,7 +223,7 @@ export function SelectMenu({
223
223
  }}
224
224
  className={cn(
225
225
  "flex w-full min-w-0 items-center justify-between gap-2 rounded-input border-control bg-surface-control py-0 pr-2.5 pl-3 text-left text-control text-ink focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-danger",
226
- size === "sm" ? "h-control-sm" : "h-input min-h-(--touch-target)",
226
+ size === "sm" ? "h-control-sm" : "h-control-md min-h-(--touch-target)",
227
227
  classNames?.trigger,
228
228
  className,
229
229
  )}
@@ -12,8 +12,10 @@ import { cn } from "../../utils/cn.js";
12
12
  export interface TimeInputProps
13
13
  extends Omit<
14
14
  ComponentPropsWithoutRef<"input">,
15
- "type" | "value" | "defaultValue" | "onChange" | "step" | "inputMode" | "maxLength"
15
+ "type" | "value" | "defaultValue" | "onChange" | "step" | "inputMode" | "maxLength" | "size"
16
16
  > {
17
+ /** `sm` is 30px and `md` (default) 38px, the heights of `Button` and `Input` of the same size. */
18
+ size?: "sm" | "md";
17
19
  /** 24h "HH:MM" (controlled). */
18
20
  value?: string;
19
21
  defaultValue?: string;
@@ -50,6 +52,7 @@ export function TimeInput({
50
52
  defaultValue = "",
51
53
  onValueChange,
52
54
  step = 5,
55
+ size = "md",
53
56
  className,
54
57
  onBlur,
55
58
  onKeyDown,
@@ -103,7 +106,8 @@ export function TimeInput({
103
106
  maxLength={5}
104
107
  placeholder={placeholder}
105
108
  className={cn(
106
- "h-input w-full min-w-0 rounded-input border-control bg-surface-control px-3 font-mono text-control text-ink tabular-nums placeholder:text-ink-3 focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1 aria-[invalid=true]:border-danger",
109
+ size === "sm" ? "h-control-sm" : "h-control-md",
110
+ "w-full min-w-0 rounded-input border-control bg-surface-control px-3 font-mono text-control text-ink tabular-nums placeholder:text-ink-3 focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1 aria-[invalid=true]:border-danger",
107
111
  className,
108
112
  )}
109
113
  {...props}
@@ -3,6 +3,8 @@ export interface UiStrings {
3
3
  close: string;
4
4
  loading: string;
5
5
  optional: string;
6
+ save: string;
7
+ unsavedChanges: string;
6
8
  cancel: string;
7
9
  confirm: string;
8
10
  processing: string;
@@ -40,6 +42,10 @@ export interface UiStrings {
40
42
  steps: string;
41
43
  /** Default accessible name of an `Aside`. */
42
44
  aside: string;
45
+ /** Verb of the `NumberStepper` plus button; the field label follows it. */
46
+ increase: string;
47
+ /** Verb of the `NumberStepper` minus button; the field label follows it. */
48
+ decrease: string;
43
49
  /** Back action of a single-pane `ListDetail`. */
44
50
  backToList: string;
45
51
  /** Screen-reader state of a `DueChip` past its date. */
@@ -56,6 +62,44 @@ export interface UiStrings {
56
62
  selectAll: string;
57
63
  /** Name of the overflow menu trigger of a `TableActionsCell`. */
58
64
  rowActions: string;
65
+ /** Default body of a `TableEmpty` row. */
66
+ tableEmpty: string;
67
+ /** Label of the `TableColumnsMenu` trigger and its group. */
68
+ columns: string;
69
+ /** Name of the `Pagination` landmark. */
70
+ pagination: string;
71
+ /** Label of the page size picker of a `Pagination`. */
72
+ rowsPerPage: string;
73
+ /** Range text of a `Pagination`; `{first}`, `{last}` and `{total}` are replaced. */
74
+ pageRange: string;
75
+ firstPage: string;
76
+ previousPage: string;
77
+ nextPage: string;
78
+ lastPage: string;
79
+ /** Range text of a `Pagination variant="pages"`; `{first}`, `{last}` and `{total}` are replaced. */
80
+ showingRange: string;
81
+ /** Range text of a `CursorPagination` (no known total); `{first}` and `{last}` are replaced. */
82
+ showingRangeOpen: string;
83
+ /** Visible label of the previous-page button of `Pagination variant="pages"` and `CursorPagination`. */
84
+ previous: string;
85
+ /** Name of a page number button; `{page}` is replaced. */
86
+ pageNumber: string;
87
+ /** Name of the search field of a `FilterBar`. */
88
+ search: string;
89
+ /** Label of the `FilterBar` button that opens every filter under a narrow container. */
90
+ filters: string;
91
+ /** Label of the `FilterBar` button that opens the extra filters. */
92
+ moreFilters: string;
93
+ /** Clears every active filter of a `FilterBar`. */
94
+ clearAllFilters: string;
95
+ /** Name of the remove button of an active filter chip; `{filter}` is replaced by its label. */
96
+ removeFilter: string;
97
+ /** Name of the list of active filter chips of a `FilterBar`. */
98
+ activeFilters: string;
99
+ /** Result count of a `FilterBar` for exactly one result. */
100
+ resultOne: string;
101
+ /** Result count of a `FilterBar`; `{count}` is replaced. */
102
+ resultMany: string;
59
103
  /** Name of the `PasswordInput` toggle; its pressed state says whether the password is visible. */
60
104
  showPassword: string;
61
105
  /** Default title of a `LoginForm`. */
@@ -98,6 +142,8 @@ export const uiStrings = {
98
142
  close: "Close",
99
143
  loading: "Loading",
100
144
  optional: "optional",
145
+ save: "Save",
146
+ unsavedChanges: "Unsaved changes",
101
147
  cancel: "Cancel",
102
148
  confirm: "Confirm",
103
149
  processing: "Processing…",
@@ -132,6 +178,8 @@ export const uiStrings = {
132
178
  stepOf: "Step {current} of {total}: {label}",
133
179
  steps: "Steps",
134
180
  aside: "Related information",
181
+ increase: "Increase",
182
+ decrease: "Decrease",
135
183
  backToList: "Back to list",
136
184
  overdue: "Overdue",
137
185
  dueSoon: "Due soon",
@@ -140,6 +188,27 @@ export const uiStrings = {
140
188
  selectRow: "Select {row}",
141
189
  selectAll: "Select all rows",
142
190
  rowActions: "Row actions",
191
+ tableEmpty: "No rows to show",
192
+ columns: "Columns",
193
+ pagination: "Pagination",
194
+ rowsPerPage: "Rows per page",
195
+ pageRange: "{first}–{last} of {total}",
196
+ firstPage: "First page",
197
+ previousPage: "Previous page",
198
+ nextPage: "Next page",
199
+ lastPage: "Last page",
200
+ showingRange: "Showing {first}–{last} of {total}",
201
+ showingRangeOpen: "Showing {first}–{last}",
202
+ previous: "Previous",
203
+ pageNumber: "Page {page}",
204
+ search: "Search",
205
+ filters: "Filters",
206
+ moreFilters: "More filters",
207
+ clearAllFilters: "Clear all filters",
208
+ removeFilter: "Remove filter {filter}",
209
+ activeFilters: "Active filters",
210
+ resultOne: "1 result",
211
+ resultMany: "{count} results",
143
212
  showPassword: "Show password",
144
213
  signIn: "Sign in",
145
214
  signInAs: "Sign in as",
@@ -162,6 +231,8 @@ export const uiStrings = {
162
231
  close: "Cerrar",
163
232
  loading: "Cargando",
164
233
  optional: "opcional",
234
+ save: "Guardar",
235
+ unsavedChanges: "Cambios sin guardar",
165
236
  cancel: "Cancelar",
166
237
  confirm: "Confirmar",
167
238
  processing: "Procesando…",
@@ -196,6 +267,8 @@ export const uiStrings = {
196
267
  stepOf: "Paso {current} de {total}: {label}",
197
268
  steps: "Pasos",
198
269
  aside: "Información relacionada",
270
+ increase: "Aumentar",
271
+ decrease: "Disminuir",
199
272
  backToList: "Volver a la lista",
200
273
  overdue: "Vencido",
201
274
  dueSoon: "Vence pronto",
@@ -204,6 +277,27 @@ export const uiStrings = {
204
277
  selectRow: "Seleccionar {row}",
205
278
  selectAll: "Seleccionar todas las filas",
206
279
  rowActions: "Acciones de la fila",
280
+ tableEmpty: "No hay filas para mostrar",
281
+ columns: "Columnas",
282
+ pagination: "Paginación",
283
+ rowsPerPage: "Filas por página",
284
+ pageRange: "{first}–{last} de {total}",
285
+ firstPage: "Primera página",
286
+ previousPage: "Página anterior",
287
+ nextPage: "Página siguiente",
288
+ lastPage: "Última página",
289
+ showingRange: "Mostrando {first}–{last} de {total}",
290
+ showingRangeOpen: "Mostrando {first}–{last}",
291
+ previous: "Anterior",
292
+ pageNumber: "Página {page}",
293
+ search: "Buscar",
294
+ filters: "Filtros",
295
+ moreFilters: "Más filtros",
296
+ clearAllFilters: "Limpiar todos los filtros",
297
+ removeFilter: "Quitar filtro {filter}",
298
+ activeFilters: "Filtros activos",
299
+ resultOne: "1 resultado",
300
+ resultMany: "{count} resultados",
207
301
  showPassword: "Mostrar contraseña",
208
302
  signIn: "Inicia sesión",
209
303
  signInAs: "Ingresar como",
@@ -0,0 +1,83 @@
1
+ "use client";
2
+
3
+ import { type HTMLAttributes, type Ref, useEffect, useMemo, useRef, useState } from "react";
4
+ import { useUiStrings } from "../i18n/index.js";
5
+ import { usePrefersReducedMotion } from "../utils/reduced-motion.js";
6
+ import { composeRefs } from "../utils/slot.js";
7
+ import { COUNT_UP_SCALE, countAt, parseDuration, parseEasing } from "./model.js";
8
+ import { MotionStyles } from "./motion-styles.js";
9
+ import { useStartedOnServer } from "./use-enter-phase.js";
10
+
11
+ /** Anything with an `Intl.NumberFormat`-style `format`, such as `new Intl.NumberFormat(...)`. */
12
+ export interface NumberFormatter {
13
+ format(value: number): string;
14
+ }
15
+
16
+ export interface CountUpProps extends Omit<HTMLAttributes<HTMLSpanElement>, "children"> {
17
+ value: number;
18
+ /** Formats every shown value. Defaults to `Intl.NumberFormat` in the UI strings locale. */
19
+ formatter?: NumberFormatter;
20
+ /** Where a client-side mount starts counting from. Default 0. */
21
+ from?: number;
22
+ ref?: Ref<HTMLSpanElement>;
23
+ }
24
+
25
+ /**
26
+ * A number that counts to `value` over 1.5 `--motion-duration`s with `--motion-ease`, on a client
27
+ * mount and on every change. Server HTML, hydration and reduced motion show the final value at
28
+ * once. While it counts, assistive tech reads only the final value and the final text reserves
29
+ * its width, so the line does not grow digit by digit. Works as the `value` of a `Kpi`.
30
+ */
31
+ export function CountUp({ value, formatter, from = 0, className, ref, ...props }: CountUpProps) {
32
+ const { locale } = useUiStrings();
33
+ const format = useMemo(() => formatter ?? new Intl.NumberFormat(locale), [formatter, locale]);
34
+ const startedOnServer = useStartedOnServer();
35
+ const reduced = usePrefersReducedMotion();
36
+ const [shown, setShown] = useState(() => (startedOnServer || reduced ? value : from));
37
+ const node = useRef<HTMLSpanElement>(null);
38
+ const latest = useRef(shown);
39
+ latest.current = shown;
40
+
41
+ useEffect(() => {
42
+ const start = latest.current;
43
+ const el = node.current;
44
+ if (reduced || start === value || !el || typeof requestAnimationFrame === "undefined") {
45
+ setShown(value);
46
+ return;
47
+ }
48
+ const styles = getComputedStyle(el);
49
+ const duration = parseDuration(styles.getPropertyValue("--motion-duration")) * COUNT_UP_SCALE;
50
+ const ease = parseEasing(styles.getPropertyValue("--motion-ease"));
51
+ const t0 = performance.now();
52
+ let frame = requestAnimationFrame(function tick(now) {
53
+ const next = countAt(start, value, now - t0, duration, ease);
54
+ setShown(next);
55
+ if (next !== value) frame = requestAnimationFrame(tick);
56
+ });
57
+ return () => cancelAnimationFrame(frame);
58
+ }, [value, reduced]);
59
+
60
+ const final = format.format(value);
61
+ return (
62
+ <>
63
+ <MotionStyles />
64
+ <span
65
+ ref={composeRefs(ref, node)}
66
+ className={className ? `ui-count ${className}` : "ui-count"}
67
+ {...props}
68
+ >
69
+ {shown === value ? (
70
+ final
71
+ ) : (
72
+ <>
73
+ <span className="ui-count-run" aria-hidden="true">
74
+ <span>{final}</span>
75
+ <span>{format.format(shown)}</span>
76
+ </span>
77
+ <span className="ui-motion-sr">{final}</span>
78
+ </>
79
+ )}
80
+ </span>
81
+ </>
82
+ );
83
+ }
@@ -0,0 +1,139 @@
1
+ "use client";
2
+
3
+ import {
4
+ type AnimationEvent,
5
+ type HTMLAttributes,
6
+ type Key,
7
+ type ReactNode,
8
+ type Ref,
9
+ useEffect,
10
+ useLayoutEffect,
11
+ useRef,
12
+ useState,
13
+ } from "react";
14
+ import { usePrefersReducedMotion } from "../utils/reduced-motion.js";
15
+ import { MotionStyles } from "./motion-styles.js";
16
+
17
+ interface Leaving {
18
+ key: Key;
19
+ node: ReactNode;
20
+ }
21
+
22
+ interface SwapState {
23
+ key: Key;
24
+ entering: Key | null;
25
+ leaving: Leaving[];
26
+ /** Bumped each time focus was inside the content that left, so it moves to the new content. */
27
+ refocus: number;
28
+ }
29
+
30
+ /** Leaving layers are dropped on `animationend`; this bounds them when no animation runs. */
31
+ const LEAVE_TIMEOUT_MS = 1000;
32
+
33
+ export interface CrossFadeProps extends HTMLAttributes<HTMLDivElement> {
34
+ /** Identity of the content. A new key fades the old content out and the new one in. */
35
+ contentKey: Key;
36
+ children?: ReactNode;
37
+ ref?: Ref<HTMLDivElement>;
38
+ }
39
+
40
+ /**
41
+ * Swaps keyed content (a list-detail pane, a tab panel) with a cross-fade and a 4px rise. The old
42
+ * content stays mounted on top of the new one until it has faded, out of the layout (so nothing
43
+ * jumps), hidden from assistive tech and inert. If focus was inside the old content it moves to
44
+ * the new content. The first render (also server HTML) never animates; reduced motion swaps
45
+ * without any fade.
46
+ */
47
+ export function CrossFade({ contentKey, children, ref, ...props }: CrossFadeProps) {
48
+ const reduced = usePrefersReducedMotion();
49
+ const current = useRef<HTMLDivElement>(null);
50
+ const committed = useRef<ReactNode>(children);
51
+ const [state, setState] = useState<SwapState>({
52
+ key: contentKey,
53
+ entering: null,
54
+ leaving: [],
55
+ refocus: 0,
56
+ });
57
+
58
+ if (state.key !== contentKey) {
59
+ const animate = !reduced;
60
+ const focused = typeof document !== "undefined" && document.activeElement;
61
+ setState({
62
+ key: contentKey,
63
+ entering: animate ? contentKey : null,
64
+ leaving: animate
65
+ ? [
66
+ ...state.leaving.filter((layer) => layer.key !== contentKey),
67
+ { key: state.key, node: committed.current },
68
+ ]
69
+ : [],
70
+ refocus: focused && current.current?.contains(focused) ? state.refocus + 1 : state.refocus,
71
+ });
72
+ }
73
+
74
+ useLayoutEffect(() => {
75
+ committed.current = children;
76
+ });
77
+
78
+ useLayoutEffect(() => {
79
+ if (state.refocus === 0 || !current.current) return;
80
+ current.current.tabIndex = -1;
81
+ current.current.focus({ preventScroll: true });
82
+ }, [state.refocus]);
83
+
84
+ const leavingCount = state.leaving.length;
85
+ useEffect(() => {
86
+ if (leavingCount === 0) return;
87
+ const timer = setTimeout(() => setState((s) => ({ ...s, leaving: [] })), LEAVE_TIMEOUT_MS);
88
+ return () => clearTimeout(timer);
89
+ }, [leavingCount]);
90
+
91
+ const drop = (key: Key) => (event: AnimationEvent<HTMLDivElement>) => {
92
+ if (event.target !== event.currentTarget) return;
93
+ setState((s) => ({ ...s, leaving: s.leaving.filter((layer) => layer.key !== key) }));
94
+ };
95
+
96
+ const layers = [
97
+ ...state.leaving.map((layer) => (
98
+ <div
99
+ key={`k:${String(layer.key)}`}
100
+ data-motion-leave=""
101
+ aria-hidden="true"
102
+ inert
103
+ onAnimationEnd={drop(layer.key)}
104
+ >
105
+ {layer.node}
106
+ </div>
107
+ )),
108
+ <div
109
+ key={`k:${String(contentKey)}`}
110
+ ref={current}
111
+ data-motion={state.entering === contentKey ? "enter" : undefined}
112
+ >
113
+ {children}
114
+ </div>,
115
+ ];
116
+
117
+ return (
118
+ <>
119
+ <MotionStyles />
120
+ <div ref={ref} data-motion-swap="" {...props}>
121
+ {layers}
122
+ </div>
123
+ </>
124
+ );
125
+ }
126
+
127
+ export interface PresenceProps extends Omit<CrossFadeProps, "contentKey"> {
128
+ /** Shows the children when true; changes fade them in and out. */
129
+ present: boolean;
130
+ }
131
+
132
+ /** `CrossFade` between the children and nothing: shows or hides content with a fade. */
133
+ export function Presence({ present, children, ...props }: PresenceProps) {
134
+ return (
135
+ <CrossFade contentKey={present ? "present" : "absent"} {...props}>
136
+ {present ? children : null}
137
+ </CrossFade>
138
+ );
139
+ }
@@ -0,0 +1,5 @@
1
+ export { CountUp, type CountUpProps, type NumberFormatter } from "./count-up.js";
2
+ export { CrossFade, type CrossFadeProps, Presence, type PresenceProps } from "./cross-fade.js";
3
+ export { MotionStyles } from "./motion-styles.js";
4
+ export { Reveal, type RevealProps, Stagger, type StaggerProps } from "./reveal.js";
5
+ export { type HighlightRow, type HighlightRowProps, useHighlightRow } from "./use-highlight-row.js";
@@ -0,0 +1,86 @@
1
+ // Pure motion math shared by the motion components: token parsing, easing and the count-up tween.
2
+
3
+ /** Fallbacks when the theme does not define `--motion-duration` / `--motion-ease`. */
4
+ export const DEFAULT_DURATION_MS = 180;
5
+ export const DEFAULT_EASE = "cubic-bezier(.2,.8,.2,1)";
6
+
7
+ /** A count-up runs this many token durations: long enough to read, still under 300ms by default. */
8
+ export const COUNT_UP_SCALE = 1.5;
9
+
10
+ export type Easing = (t: number) => number;
11
+
12
+ /** Milliseconds from a CSS time (`180ms`, `.18s`); `fallback` when it does not parse. */
13
+ export function parseDuration(value: string | null | undefined, fallback = DEFAULT_DURATION_MS) {
14
+ const match = /^\s*(-?\d*\.?\d+)\s*(ms|s)\s*$/i.exec(value ?? "");
15
+ if (!match) return fallback;
16
+ const amount = Number(match[1]) * (match[2]?.toLowerCase() === "s" ? 1000 : 1);
17
+ return Number.isFinite(amount) && amount >= 0 ? amount : fallback;
18
+ }
19
+
20
+ function cubicBezier(x1: number, y1: number, x2: number, y2: number): Easing {
21
+ const sample = (a: number, b: number, t: number) =>
22
+ 3 * a * t * (1 - t) ** 2 + 3 * b * t ** 2 * (1 - t) + t ** 3;
23
+ const slope = (a: number, b: number, t: number) =>
24
+ 3 * a * (1 - t) ** 2 + 6 * (b - a) * t * (1 - t) + 3 * (1 - b) * t ** 2;
25
+ return (x) => {
26
+ if (x <= 0) return 0;
27
+ if (x >= 1) return 1;
28
+ let t = x;
29
+ for (let i = 0; i < 8; i += 1) {
30
+ const error = sample(x1, x2, t) - x;
31
+ if (Math.abs(error) < 1e-6) return sample(y1, y2, t);
32
+ const d = slope(x1, x2, t);
33
+ if (Math.abs(d) < 1e-6) break;
34
+ t -= error / d;
35
+ }
36
+ let lo = 0;
37
+ let hi = 1;
38
+ t = x;
39
+ for (let i = 0; i < 30; i += 1) {
40
+ const value = sample(x1, x2, t);
41
+ if (Math.abs(value - x) < 1e-6) break;
42
+ if (value < x) lo = t;
43
+ else hi = t;
44
+ t = (lo + hi) / 2;
45
+ }
46
+ return sample(y1, y2, t);
47
+ };
48
+ }
49
+
50
+ const KEYWORDS: Record<string, [number, number, number, number]> = {
51
+ ease: [0.25, 0.1, 0.25, 1],
52
+ "ease-in": [0.42, 0, 1, 1],
53
+ "ease-out": [0, 0, 0.58, 1],
54
+ "ease-in-out": [0.42, 0, 0.58, 1],
55
+ };
56
+
57
+ /** Easing function for a CSS `<easing-function>`: `linear`, the `ease*` keywords or `cubic-bezier()`. */
58
+ export function parseEasing(value: string | null | undefined): Easing {
59
+ const text = (value ?? "").trim().toLowerCase();
60
+ if (text === "linear") return (t) => Math.min(1, Math.max(0, t));
61
+ const keyword = KEYWORDS[text];
62
+ if (keyword) return cubicBezier(...keyword);
63
+ const match = /^cubic-bezier\(([^)]*)\)$/.exec(text);
64
+ const points = match?.[1]?.split(",").map(Number);
65
+ if (points?.length === 4 && points.every(Number.isFinite)) {
66
+ const [x1, y1, x2, y2] = points as [number, number, number, number];
67
+ if (x1 >= 0 && x1 <= 1 && x2 >= 0 && x2 <= 1) return cubicBezier(x1, y1, x2, y2);
68
+ }
69
+ return cubicBezier(0.2, 0.8, 0.2, 1);
70
+ }
71
+
72
+ /**
73
+ * Value a count-up shows `elapsed` ms into a run of `duration` ms. It lands exactly on `to` at the
74
+ * end, and integer runs stay integers so a formatter never flashes decimals.
75
+ */
76
+ export function countAt(
77
+ from: number,
78
+ to: number,
79
+ elapsed: number,
80
+ duration: number,
81
+ ease: Easing,
82
+ ): number {
83
+ if (!(duration > 0) || elapsed >= duration) return to;
84
+ const value = from + (to - from) * ease(Math.max(0, elapsed) / duration);
85
+ return Number.isInteger(from) && Number.isInteger(to) ? Math.round(value) : value;
86
+ }