@jcsoftdev/ui 0.5.0 → 0.6.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 (373) hide show
  1. package/CHANGELOG.md +337 -0
  2. package/README.md +25 -3
  3. package/bin/ui-theme.mjs +40 -6
  4. package/dist/ai/code-block/code-block.js +1 -1
  5. package/dist/atoms/big-date/big-date.js +2 -2
  6. package/dist/atoms/button/button.d.ts +6 -1
  7. package/dist/atoms/button/button.js +2 -2
  8. package/dist/atoms/chip/chip.d.ts +5 -0
  9. package/dist/atoms/chip/chip.js +3 -3
  10. package/dist/atoms/icon-button/icon-button.js +1 -1
  11. package/dist/atoms/internal/hit-area.d.ts +5 -4
  12. package/dist/atoms/internal/hit-area.js +1 -1
  13. package/dist/atoms/progress/index.d.ts +1 -1
  14. package/dist/atoms/progress/index.js +4 -1
  15. package/dist/atoms/progress/progress.d.ts +6 -1
  16. package/dist/atoms/progress/progress.js +19 -1
  17. package/dist/atoms/radio-group/radio-group.js +1 -1
  18. package/dist/atoms/status-pill/status-pill.d.ts +16 -5
  19. package/dist/atoms/status-pill/status-pill.js +43 -18
  20. package/dist/brand/logo-forge.js +1 -1
  21. package/dist/charts/candlestick-chart/candlestick-chart.js +2 -2
  22. package/dist/charts/chart-grid/chart-grid.js +2 -2
  23. package/dist/charts/chord-chart/chord-chart.js +1 -1
  24. package/dist/charts/core/axes.js +2 -2
  25. package/dist/charts/core/cartesian/annotations.js +2 -2
  26. package/dist/charts/core/cartesian/marks.js +1 -1
  27. package/dist/charts/core/distribution/marks.js +1 -1
  28. package/dist/charts/core/distribution/xy-points.js +1 -1
  29. package/dist/charts/core/export-menu.js +1 -1
  30. package/dist/charts/funnel-chart/funnel-chart.js +1 -1
  31. package/dist/charts/gantt-chart/gantt-chart.js +4 -4
  32. package/dist/charts/gantt-chart/gantt-marks.js +3 -3
  33. package/dist/charts/index.d.ts +2 -0
  34. package/dist/charts/index.js +2 -0
  35. package/dist/charts/maps/geo/map-data-table.js +1 -1
  36. package/dist/charts/polar-area-chart/polar-area-chart.js +1 -1
  37. package/dist/charts/radar-chart/radar-chart.js +1 -1
  38. package/dist/charts/stock-chart/stock-chart.js +1 -1
  39. package/dist/charts/stock-chart/stock-drawing-layer.js +3 -3
  40. package/dist/charts/stock-chart/stock-plot.js +2 -2
  41. package/dist/containers/chat-thread/chat-thread.d.ts +98 -0
  42. package/dist/containers/chat-thread/chat-thread.js +219 -0
  43. package/dist/containers/chat-thread/format.d.ts +20 -0
  44. package/dist/containers/chat-thread/format.js +50 -0
  45. package/dist/containers/chat-thread/index.d.ts +1 -0
  46. package/dist/containers/chat-thread/index.js +8 -0
  47. package/dist/containers/cols/cols.d.ts +1 -1
  48. package/dist/containers/cols/cols.js +7 -0
  49. package/dist/containers/comment/comment.js +1 -1
  50. package/dist/containers/context-rail/context-rail.d.ts +62 -0
  51. package/dist/containers/context-rail/context-rail.js +175 -0
  52. package/dist/containers/context-rail/index.d.ts +1 -0
  53. package/dist/containers/context-rail/index.js +6 -0
  54. package/dist/containers/dashboard/dashboard.d.ts +40 -0
  55. package/dist/containers/dashboard/dashboard.js +84 -0
  56. package/dist/containers/dashboard/index.d.ts +1 -0
  57. package/dist/containers/dashboard/index.js +14 -0
  58. package/dist/containers/data-grid/data-grid.demos.js +4 -4
  59. package/dist/containers/data-grid/data-grid.js +6 -6
  60. package/dist/containers/data-grid/filter-builder-editor.js +2 -2
  61. package/dist/containers/data-grid/grid-toolbar.js +1 -1
  62. package/dist/containers/data-grid/spreadsheet.demos.d.ts +1 -1
  63. package/dist/containers/data-grid/spreadsheet.demos.js +1 -1
  64. package/dist/containers/detail-header/detail-header.d.ts +24 -0
  65. package/dist/containers/detail-header/detail-header.js +32 -0
  66. package/dist/containers/detail-header/index.d.ts +1 -0
  67. package/dist/containers/detail-header/index.js +6 -0
  68. package/dist/containers/facts/facts.js +1 -1
  69. package/dist/containers/filter-bar/filter-bar.d.ts +58 -0
  70. package/dist/containers/filter-bar/filter-bar.js +123 -0
  71. package/dist/containers/filter-bar/index.d.ts +1 -0
  72. package/dist/containers/filter-bar/index.js +6 -0
  73. package/dist/containers/hbars/hbars.js +2 -2
  74. package/dist/containers/index.d.ts +9 -0
  75. package/dist/containers/index.js +9 -0
  76. package/dist/containers/kanban/kanban.d.ts +23 -2
  77. package/dist/containers/kanban/kanban.js +101 -21
  78. package/dist/containers/kanban/model.d.ts +12 -0
  79. package/dist/containers/kanban/model.js +8 -0
  80. package/dist/containers/kpi/kpi.js +1 -1
  81. package/dist/containers/kpi-group/kpi-group.d.ts +6 -1
  82. package/dist/containers/kpi-group/kpi-group.js +6 -2
  83. package/dist/containers/list-detail/index.d.ts +1 -1
  84. package/dist/containers/list-detail/index.js +4 -0
  85. package/dist/containers/list-detail/list-detail.d.ts +51 -3
  86. package/dist/containers/list-detail/list-detail.js +109 -15
  87. package/dist/containers/page/page.d.ts +17 -4
  88. package/dist/containers/page/page.js +33 -4
  89. package/dist/containers/page-header/back.d.ts +10 -0
  90. package/dist/containers/page-header/back.js +28 -0
  91. package/dist/containers/page-header/index.d.ts +1 -0
  92. package/dist/containers/page-header/index.js +1 -0
  93. package/dist/containers/page-header/page-header.d.ts +19 -2
  94. package/dist/containers/page-header/page-header.js +26 -2
  95. package/dist/containers/pagination/cursor-pagination.d.ts +28 -0
  96. package/dist/containers/pagination/cursor-pagination.js +48 -0
  97. package/dist/containers/pagination/index.d.ts +3 -0
  98. package/dist/containers/pagination/index.js +10 -0
  99. package/dist/containers/pagination/pagination.d.ts +52 -0
  100. package/dist/containers/pagination/pagination.js +216 -0
  101. package/dist/containers/pagination/range.d.ts +29 -0
  102. package/dist/containers/pagination/range.js +42 -0
  103. package/dist/containers/pagination/use-pagination.d.ts +18 -0
  104. package/dist/containers/pagination/use-pagination.js +22 -0
  105. package/dist/containers/responsive-list/responsive-list.d.ts +28 -2
  106. package/dist/containers/responsive-list/responsive-list.js +134 -25
  107. package/dist/containers/row-actions/index.d.ts +1 -0
  108. package/dist/containers/row-actions/index.js +4 -0
  109. package/dist/containers/row-actions/row-actions.d.ts +26 -0
  110. package/dist/containers/row-actions/row-actions.js +78 -0
  111. package/dist/containers/selectable-card/index.d.ts +1 -0
  112. package/dist/containers/selectable-card/index.js +6 -0
  113. package/dist/containers/selectable-card/selectable-card.d.ts +26 -0
  114. package/dist/containers/selectable-card/selectable-card.js +57 -0
  115. package/dist/containers/settings-layout/settings-layout.d.ts +24 -7
  116. package/dist/containers/settings-layout/settings-layout.js +63 -8
  117. package/dist/containers/shortcuts/shortcuts.js +1 -1
  118. package/dist/containers/table/cell-padding.d.ts +2 -0
  119. package/dist/containers/table/cell-padding.js +4 -0
  120. package/dist/containers/table/index.d.ts +1 -0
  121. package/dist/containers/table/index.js +8 -0
  122. package/dist/containers/table/sort.d.ts +14 -0
  123. package/dist/containers/table/sort.js +11 -0
  124. package/dist/containers/table/table-parts.d.ts +24 -0
  125. package/dist/containers/table/table-parts.js +52 -0
  126. package/dist/containers/table/table.d.ts +37 -3
  127. package/dist/containers/table/table.js +120 -19
  128. package/dist/containers/table-columns-menu/index.d.ts +1 -0
  129. package/dist/containers/table-columns-menu/index.js +6 -0
  130. package/dist/containers/table-columns-menu/table-columns-menu.d.ts +14 -0
  131. package/dist/containers/table-columns-menu/table-columns-menu.js +46 -0
  132. package/dist/dashboards/layout.d.ts +1 -27
  133. package/dist/dashboards/layout.js +8 -40
  134. package/dist/forms/chip-group/chip-group.d.ts +5 -0
  135. package/dist/forms/chip-group/chip-group.js +3 -1
  136. package/dist/forms/combobox/combobox.js +1 -1
  137. package/dist/forms/copy-field/copy-field.js +1 -1
  138. package/dist/forms/date-picker/date-picker.d.ts +3 -1
  139. package/dist/forms/date-picker/date-picker.js +4 -2
  140. package/dist/forms/date-picker/date-time-picker.d.ts +8 -2
  141. package/dist/forms/date-picker/date-time-picker.js +13 -2
  142. package/dist/forms/field/field.d.ts +9 -2
  143. package/dist/forms/field/field.js +18 -4
  144. package/dist/forms/fieldset/fieldset.d.ts +11 -0
  145. package/dist/forms/fieldset/fieldset.js +12 -0
  146. package/dist/forms/fieldset/index.d.ts +1 -0
  147. package/dist/forms/fieldset/index.js +4 -0
  148. package/dist/forms/form-footer/form-footer.d.ts +26 -0
  149. package/dist/forms/form-footer/form-footer.js +44 -0
  150. package/dist/forms/form-footer/index.d.ts +1 -0
  151. package/dist/forms/form-footer/index.js +4 -0
  152. package/dist/forms/form-grid/form-grid.d.ts +21 -4
  153. package/dist/forms/form-grid/form-grid.js +20 -3
  154. package/dist/forms/form-grid/index.d.ts +1 -1
  155. package/dist/forms/form-grid/index.js +6 -2
  156. package/dist/forms/form-section/form-section.d.ts +12 -0
  157. package/dist/forms/form-section/form-section.js +30 -0
  158. package/dist/forms/form-section/index.d.ts +1 -0
  159. package/dist/forms/form-section/index.js +4 -0
  160. package/dist/forms/index.d.ts +3 -0
  161. package/dist/forms/index.js +3 -0
  162. package/dist/forms/input/input.d.ts +6 -2
  163. package/dist/forms/input/input.js +4 -1
  164. package/dist/forms/internal/listbox-items.d.ts +1 -1
  165. package/dist/forms/internal/listbox-items.js +3 -2
  166. package/dist/forms/native-select/native-select.js +1 -1
  167. package/dist/forms/select/index.d.ts +1 -1
  168. package/dist/forms/select/select.d.ts +5 -2
  169. package/dist/forms/select/select.js +7 -2
  170. package/dist/forms/select-menu/select-menu.js +1 -1
  171. package/dist/forms/time-input/time-input.d.ts +4 -2
  172. package/dist/forms/time-input/time-input.js +3 -1
  173. package/dist/i18n/strings.d.ts +86 -0
  174. package/dist/i18n/strings.js +46 -0
  175. package/dist/motion/count-up.d.ts +20 -0
  176. package/dist/motion/count-up.js +59 -0
  177. package/dist/motion/cross-fade.d.ts +21 -0
  178. package/dist/motion/cross-fade.js +86 -0
  179. package/dist/motion/index.d.ts +5 -0
  180. package/dist/motion/index.js +14 -0
  181. package/dist/motion/model.d.ts +15 -0
  182. package/dist/motion/model.js +68 -0
  183. package/dist/motion/motion-styles.d.ts +1 -0
  184. package/dist/motion/motion-styles.js +35 -0
  185. package/dist/motion/reveal.d.ts +37 -0
  186. package/dist/motion/reveal.js +69 -0
  187. package/dist/motion/use-enter-phase.d.ts +11 -0
  188. package/dist/motion/use-enter-phase.js +40 -0
  189. package/dist/motion/use-highlight-row.d.ts +22 -0
  190. package/dist/motion/use-highlight-row.js +38 -0
  191. package/dist/navigation/tabs/tabs.js +1 -1
  192. package/dist/navigation/wizard/wizard.d.ts +4 -1
  193. package/dist/navigation/wizard/wizard.js +3 -0
  194. package/dist/overlays/alert-dialog/alert-dialog.js +8 -1
  195. package/dist/overlays/context-menu/context-menu.js +3 -1
  196. package/dist/overlays/dialog/dialog.js +10 -2
  197. package/dist/overlays/drawer/drawer.d.ts +18 -4
  198. package/dist/overlays/drawer/drawer.js +53 -4
  199. package/dist/overlays/drawer/index.d.ts +1 -1
  200. package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +1 -1
  201. package/dist/overlays/dropdown-menu/dropdown-menu.js +5 -4
  202. package/dist/overlays/hover-card/hover-card.js +2 -0
  203. package/dist/overlays/popover/popover.js +2 -0
  204. package/dist/overlays/toaster/index.d.ts +1 -1
  205. package/dist/overlays/toaster/toaster.d.ts +28 -2
  206. package/dist/overlays/toaster/toaster.js +73 -29
  207. package/dist/overlays/tooltip/tooltip.js +2 -0
  208. package/dist/primitives/use-presence.js +9 -0
  209. package/dist/shell/app-shell/app-shell.d.ts +8 -1
  210. package/dist/shell/app-shell/app-shell.js +50 -3
  211. package/dist/shell/index.d.ts +1 -0
  212. package/dist/shell/index.js +1 -0
  213. package/dist/shell/sidebar/sidebar.d.ts +17 -1
  214. package/dist/shell/sidebar/sidebar.js +126 -76
  215. package/dist/shell/topbar/topbar.d.ts +4 -2
  216. package/dist/shell/topbar/topbar.js +2 -0
  217. package/dist/showcase/operations-bento.js +2 -2
  218. package/dist/states/empty-state/empty-state.d.ts +10 -3
  219. package/dist/states/empty-state/empty-state.js +46 -5
  220. package/dist/states/error-state/error-state.js +1 -1
  221. package/dist/states/skeleton/skeleton.js +1 -1
  222. package/dist/utils/class-tokens.generated.js +4 -6
  223. package/dist/utils/list-navigation.d.ts +14 -0
  224. package/dist/utils/list-navigation.js +44 -0
  225. package/dist/utils/overlay-motion.d.ts +12 -0
  226. package/dist/utils/overlay-motion.js +14 -0
  227. package/dist/utils/use-container-width.d.ts +6 -0
  228. package/dist/utils/use-container-width.js +19 -0
  229. package/package.json +2 -2
  230. package/scripts/build-theme.mjs +46 -5
  231. package/src/ai/code-block/code-block.tsx +1 -1
  232. package/src/atoms/big-date/big-date.tsx +2 -2
  233. package/src/atoms/button/button.tsx +8 -3
  234. package/src/atoms/chip/chip.tsx +8 -3
  235. package/src/atoms/icon-button/icon-button.tsx +1 -1
  236. package/src/atoms/internal/hit-area.ts +5 -4
  237. package/src/atoms/progress/index.ts +8 -1
  238. package/src/atoms/progress/progress.tsx +30 -1
  239. package/src/atoms/radio-group/radio-group.tsx +1 -1
  240. package/src/atoms/status-pill/status-pill.tsx +59 -18
  241. package/src/brand/logo-forge.tsx +1 -1
  242. package/src/charts/candlestick-chart/candlestick-chart.tsx +2 -2
  243. package/src/charts/chart-grid/chart-grid.tsx +2 -2
  244. package/src/charts/chord-chart/chord-chart.tsx +1 -1
  245. package/src/charts/core/axes.tsx +2 -2
  246. package/src/charts/core/cartesian/annotations.tsx +2 -2
  247. package/src/charts/core/cartesian/marks.tsx +1 -1
  248. package/src/charts/core/distribution/marks.tsx +1 -1
  249. package/src/charts/core/distribution/xy-points.tsx +1 -1
  250. package/src/charts/core/export-menu.tsx +1 -1
  251. package/src/charts/funnel-chart/funnel-chart.tsx +1 -1
  252. package/src/charts/gantt-chart/gantt-chart.tsx +4 -4
  253. package/src/charts/gantt-chart/gantt-marks.tsx +3 -3
  254. package/src/charts/index.ts +2 -0
  255. package/src/charts/maps/geo/map-data-table.tsx +1 -1
  256. package/src/charts/polar-area-chart/polar-area-chart.tsx +1 -1
  257. package/src/charts/radar-chart/radar-chart.tsx +1 -1
  258. package/src/charts/stock-chart/stock-chart.tsx +1 -1
  259. package/src/charts/stock-chart/stock-drawing-layer.tsx +3 -3
  260. package/src/charts/stock-chart/stock-plot.tsx +2 -2
  261. package/src/containers/chat-thread/chat-thread.tsx +331 -0
  262. package/src/containers/chat-thread/format.ts +67 -0
  263. package/src/containers/chat-thread/index.ts +12 -0
  264. package/src/containers/cols/cols.tsx +13 -1
  265. package/src/containers/comment/comment.tsx +1 -1
  266. package/src/containers/context-rail/context-rail.tsx +229 -0
  267. package/src/containers/context-rail/index.ts +7 -0
  268. package/src/containers/dashboard/dashboard.tsx +142 -0
  269. package/src/containers/dashboard/index.ts +12 -0
  270. package/src/containers/data-grid/data-grid.demos.tsx +4 -4
  271. package/src/containers/data-grid/data-grid.tsx +6 -6
  272. package/src/containers/data-grid/filter-builder-editor.tsx +2 -2
  273. package/src/containers/data-grid/grid-toolbar.tsx +1 -1
  274. package/src/containers/data-grid/spreadsheet.demos.tsx +1 -1
  275. package/src/containers/detail-header/detail-header.tsx +64 -0
  276. package/src/containers/detail-header/index.ts +5 -0
  277. package/src/containers/facts/facts.tsx +1 -1
  278. package/src/containers/filter-bar/filter-bar.tsx +201 -0
  279. package/src/containers/filter-bar/index.ts +7 -0
  280. package/src/containers/hbars/hbars.tsx +2 -2
  281. package/src/containers/index.ts +9 -0
  282. package/src/containers/kanban/kanban.tsx +146 -39
  283. package/src/containers/kanban/model.ts +20 -0
  284. package/src/containers/kpi/kpi.tsx +1 -1
  285. package/src/containers/kpi-group/kpi-group.tsx +17 -2
  286. package/src/containers/list-detail/index.ts +5 -0
  287. package/src/containers/list-detail/list-detail.tsx +157 -9
  288. package/src/containers/page/page.tsx +61 -7
  289. package/src/containers/page-header/back.tsx +42 -0
  290. package/src/containers/page-header/index.ts +1 -0
  291. package/src/containers/page-header/page-header.tsx +49 -3
  292. package/src/containers/pagination/cursor-pagination.tsx +79 -0
  293. package/src/containers/pagination/index.ts +7 -0
  294. package/src/containers/pagination/pagination.tsx +266 -0
  295. package/src/containers/pagination/range.ts +68 -0
  296. package/src/containers/pagination/use-pagination.ts +44 -0
  297. package/src/containers/responsive-list/responsive-list.tsx +183 -46
  298. package/src/containers/row-actions/index.ts +1 -0
  299. package/src/containers/row-actions/row-actions.tsx +114 -0
  300. package/src/containers/selectable-card/index.ts +5 -0
  301. package/src/containers/selectable-card/selectable-card.tsx +84 -0
  302. package/src/containers/settings-layout/settings-layout.tsx +104 -13
  303. package/src/containers/shortcuts/shortcuts.tsx +1 -1
  304. package/src/containers/table/cell-padding.ts +2 -0
  305. package/src/containers/table/index.ts +6 -0
  306. package/src/containers/table/sort.ts +23 -0
  307. package/src/containers/table/table-parts.tsx +81 -0
  308. package/src/containers/table/table.tsx +212 -45
  309. package/src/containers/table-columns-menu/index.ts +5 -0
  310. package/src/containers/table-columns-menu/table-columns-menu.tsx +68 -0
  311. package/src/dashboards/layout.tsx +8 -75
  312. package/src/forms/chip-group/chip-group.tsx +8 -1
  313. package/src/forms/combobox/combobox.tsx +1 -1
  314. package/src/forms/copy-field/copy-field.tsx +1 -1
  315. package/src/forms/date-picker/date-picker.tsx +7 -2
  316. package/src/forms/date-picker/date-time-picker.tsx +28 -2
  317. package/src/forms/field/field.tsx +30 -3
  318. package/src/forms/fieldset/fieldset.tsx +22 -0
  319. package/src/forms/fieldset/index.ts +1 -0
  320. package/src/forms/form-footer/form-footer.tsx +74 -0
  321. package/src/forms/form-footer/index.ts +1 -0
  322. package/src/forms/form-grid/form-grid.tsx +42 -5
  323. package/src/forms/form-grid/index.ts +8 -1
  324. package/src/forms/form-section/form-section.tsx +41 -0
  325. package/src/forms/form-section/index.ts +1 -0
  326. package/src/forms/index.ts +3 -0
  327. package/src/forms/input/input.tsx +10 -3
  328. package/src/forms/internal/listbox-items.tsx +3 -4
  329. package/src/forms/native-select/native-select.tsx +1 -1
  330. package/src/forms/select/index.ts +1 -1
  331. package/src/forms/select/select.tsx +14 -3
  332. package/src/forms/select-menu/select-menu.tsx +1 -1
  333. package/src/forms/time-input/time-input.tsx +6 -2
  334. package/src/i18n/strings.ts +86 -0
  335. package/src/motion/count-up.tsx +83 -0
  336. package/src/motion/cross-fade.tsx +139 -0
  337. package/src/motion/index.ts +5 -0
  338. package/src/motion/model.ts +86 -0
  339. package/src/motion/motion-styles.tsx +47 -0
  340. package/src/motion/reveal.tsx +115 -0
  341. package/src/motion/use-enter-phase.ts +50 -0
  342. package/src/motion/use-highlight-row.ts +63 -0
  343. package/src/navigation/tabs/tabs.tsx +1 -1
  344. package/src/navigation/wizard/wizard.tsx +6 -1
  345. package/src/overlays/alert-dialog/alert-dialog.tsx +5 -1
  346. package/src/overlays/context-menu/context-menu.tsx +3 -2
  347. package/src/overlays/dialog/dialog.tsx +7 -2
  348. package/src/overlays/drawer/drawer.tsx +68 -6
  349. package/src/overlays/drawer/index.ts +1 -0
  350. package/src/overlays/dropdown-menu/dropdown-menu.tsx +5 -4
  351. package/src/overlays/hover-card/hover-card.tsx +2 -0
  352. package/src/overlays/popover/popover.tsx +2 -0
  353. package/src/overlays/toaster/index.ts +2 -0
  354. package/src/overlays/toaster/toaster.tsx +113 -17
  355. package/src/overlays/tooltip/tooltip.tsx +2 -0
  356. package/src/primitives/use-presence.ts +13 -0
  357. package/src/shell/app-shell/app-shell.tsx +54 -2
  358. package/src/shell/index.ts +1 -0
  359. package/src/shell/sidebar/sidebar.tsx +154 -75
  360. package/src/shell/topbar/topbar.tsx +8 -0
  361. package/src/showcase/operations-bento.tsx +2 -2
  362. package/src/states/empty-state/empty-state.tsx +52 -9
  363. package/src/states/error-state/error-state.tsx +1 -1
  364. package/src/states/skeleton/skeleton.tsx +1 -1
  365. package/src/utils/class-tokens.generated.ts +4 -6
  366. package/src/utils/list-navigation.ts +63 -0
  367. package/src/utils/overlay-motion.ts +33 -0
  368. package/src/utils/use-container-width.ts +24 -0
  369. package/styles/Theme.kt +15 -18
  370. package/styles/tailwind.css +29 -28
  371. package/styles/theme.css +29 -28
  372. package/styles/tokens.css +46 -0
  373. package/tokens/default.json +51 -29
@@ -1 +1,9 @@
1
1
  export * from "./table.js";
2
+ import {
3
+ TableEmpty,
4
+ TableLoading
5
+ } from "./table-parts.js";
6
+ export {
7
+ TableEmpty,
8
+ TableLoading
9
+ };
@@ -0,0 +1,14 @@
1
+ export type TableSortDirection = "ascending" | "descending";
2
+ /** The sorted column and its direction. `null` stands for "not sorted". */
3
+ export interface TableSort {
4
+ columnId: string;
5
+ direction: TableSortDirection;
6
+ }
7
+ export type AriaSort = "ascending" | "descending" | "none";
8
+ /**
9
+ * Next sort when a header is activated: unsorted -> ascending -> descending -> unsorted. Activating
10
+ * another column starts it at ascending.
11
+ */
12
+ export declare function nextTableSort(current: TableSort | null, columnId: string): TableSort | null;
13
+ /** `aria-sort` value of a sortable header: only the sorted column reports a direction. */
14
+ export declare function ariaSortFor(current: TableSort | null, columnId: string): AriaSort;
@@ -0,0 +1,11 @@
1
+ function nextTableSort(current, columnId) {
2
+ if (!current || current.columnId !== columnId) return { columnId, direction: "ascending" };
3
+ return current.direction === "ascending" ? { columnId, direction: "descending" } : null;
4
+ }
5
+ function ariaSortFor(current, columnId) {
6
+ return current?.columnId === columnId ? current.direction : "none";
7
+ }
8
+ export {
9
+ ariaSortFor,
10
+ nextTableSort
11
+ };
@@ -0,0 +1,24 @@
1
+ import type { ReactNode } from "react";
2
+ export interface TableEmptyProps {
3
+ /** Number of columns to span: the count of header cells. */
4
+ colSpan: number;
5
+ /** Defaults to the localized "No rows to show". */
6
+ title?: ReactNode;
7
+ description?: ReactNode;
8
+ icon?: ReactNode;
9
+ /** Call to action, e.g. a button that clears the filters. */
10
+ action?: ReactNode;
11
+ className?: string;
12
+ }
13
+ /** Single row that holds an `EmptyState` across every column. Put it in `TableBody` when there are no rows. */
14
+ export declare function TableEmpty({ colSpan, title, description, icon, action, className, }: TableEmptyProps): import("react").JSX.Element;
15
+ export interface TableLoadingProps {
16
+ /** Number of columns of the table. */
17
+ columns: number;
18
+ /** Placeholder rows. Default 5. */
19
+ rows?: number;
20
+ /** Text announced to screen readers. Defaults to the localized "Loading". */
21
+ label?: string;
22
+ }
23
+ /** Placeholder rows for the first load. The rows are decorative; one status region announces the load. */
24
+ export declare function TableLoading({ columns, rows, label }: TableLoadingProps): import("react").JSX.Element[];
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useUiStrings } from "../../i18n/index.js";
4
+ import { EmptyState } from "../../states/empty-state/empty-state.js";
5
+ import { cn } from "../../utils/cn.js";
6
+ import { CELL_PY } from "./cell-padding.js";
7
+ function TableEmpty({
8
+ colSpan,
9
+ title,
10
+ description,
11
+ icon,
12
+ action,
13
+ className
14
+ }) {
15
+ const strings = useUiStrings();
16
+ return /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan, className: cn("p-0", className), children: /* @__PURE__ */ jsx(
17
+ EmptyState,
18
+ {
19
+ title: title ?? strings.tableEmpty,
20
+ description,
21
+ icon,
22
+ action
23
+ }
24
+ ) }) });
25
+ }
26
+ const WIDTHS = ["w-3/4", "w-1/2", "w-2/3", "w-5/6"];
27
+ function TableLoading({ columns, rows = 5, label }) {
28
+ const strings = useUiStrings();
29
+ return Array.from({ length: Math.max(0, rows) }, (_, row) => (
30
+ // biome-ignore lint/suspicious/noArrayIndexKey: placeholder rows have no identity
31
+ /* @__PURE__ */ jsx("tr", { "aria-hidden": row === 0 ? void 0 : "true", className: "border-b-divider", children: Array.from({ length: Math.max(1, columns) }, (_2, column) => (
32
+ // biome-ignore lint/suspicious/noArrayIndexKey: placeholder cells have no identity
33
+ /* @__PURE__ */ jsxs("td", { className: cn("px-4 align-middle @max-sm/table:px-2.5", CELL_PY), children: [
34
+ row === 0 && column === 0 ? /* @__PURE__ */ jsx("span", { role: "status", className: "sr-only", children: label ?? strings.loading }) : null,
35
+ /* @__PURE__ */ jsx(
36
+ "span",
37
+ {
38
+ "aria-hidden": "true",
39
+ className: cn(
40
+ "block h-3 animate-pulse rounded-xs bg-surface-2",
41
+ WIDTHS[(row + column) % WIDTHS.length]
42
+ )
43
+ }
44
+ )
45
+ ] }, column)
46
+ )) }, row)
47
+ ));
48
+ }
49
+ export {
50
+ TableEmpty,
51
+ TableLoading
52
+ };
@@ -1,6 +1,8 @@
1
1
  import { type ComponentPropsWithoutRef, type CSSProperties, type ReactNode } from "react";
2
2
  import { type PinnedColumns } from "./pin.js";
3
+ import { type TableSort } from "./sort.js";
3
4
  export type { PinnedColumns, PinSide } from "./pin.js";
5
+ export { type AriaSort, ariaSortFor, nextTableSort, type TableSort, type TableSortDirection, } from "./sort.js";
4
6
  export interface TableLabels {
5
7
  pinLeft: string;
6
8
  pinRight: string;
@@ -12,6 +14,12 @@ export interface TableLabels {
12
14
  /** Name of the overflow menu trigger of a `TableActionsCell`. Defaults to the UI string. */
13
15
  rowActions?: string;
14
16
  }
17
+ /**
18
+ * Row density. Each sets `--row-min-h` (the least a body row measures, whatever it holds) and
19
+ * `--table-cell-py` (the vertical cell padding), so a row of text and a row holding a 30px control
20
+ * come out the same height. Override either variable with `className` or `style` to tune it.
21
+ */
22
+ export type TableDensity = "comfortable" | "compact";
15
23
  export interface TableProps extends ComponentPropsWithoutRef<"table"> {
16
24
  /** Controlled pinned columns (ids of `columnId`). Pair it with `onPinnedColumnsChange`. */
17
25
  pinnedColumns?: PinnedColumns;
@@ -46,13 +54,34 @@ export interface TableProps extends ComponentPropsWithoutRef<"table"> {
46
54
  defaultSelectedKeys?: readonly string[];
47
55
  /** Called with the next keys. Setting it turns selection on. */
48
56
  onSelectedKeysChange?: (keys: string[]) => void;
57
+ /**
58
+ * Controlled sort state. Setting it, `defaultSort` or `onSortChange` turns sorting on for the
59
+ * headers marked `sortable`. The table only reports the state: sort your rows yourself.
60
+ */
61
+ sort?: TableSort | null;
62
+ /** Initial sort when uncontrolled. */
63
+ defaultSort?: TableSort | null;
64
+ /** Called with the next sort (`null` when the sort is cleared). */
65
+ onSortChange?: (sort: TableSort | null) => void;
66
+ /** Ids (`columnId`) of the columns to hide. Headers and cells with that id render nothing. */
67
+ hiddenColumns?: readonly string[];
68
+ /**
69
+ * Row density: `comfortable` (default) gives every body row at least 48px, `compact` 40px, with
70
+ * the cells centred vertically. Rows never depend on what a cell holds for their height.
71
+ */
72
+ density?: TableDensity;
73
+ /**
74
+ * Keeps the last column (the row actions) stuck to the right edge while the table scrolls
75
+ * sideways, from 24rem of the table's own width up. Leave the last column unpinned when using it.
76
+ */
77
+ stickyActions?: boolean;
49
78
  }
50
79
  /**
51
80
  * Table inside its own horizontal scroll wrapper. Give columns a `columnId` (header and cells)
52
81
  * and mark header cells `pinnable` to let the user pin them to the left or right edge: pinned
53
82
  * columns stay sticky while the rest scrolls.
54
83
  */
55
- export declare function Table({ className, wrapperClassName, pinnedColumns, defaultPinnedColumns, onPinnedColumnsChange, pinStorageKey, labels, flush, stickyHeader, maxHeight, selectedKeys, defaultSelectedKeys, onSelectedKeysChange, ...props }: TableProps): import("react").JSX.Element;
84
+ export declare function Table({ className, wrapperClassName, pinnedColumns, defaultPinnedColumns, onPinnedColumnsChange, pinStorageKey, labels, flush, stickyHeader, maxHeight, selectedKeys, defaultSelectedKeys, onSelectedKeysChange, sort, defaultSort, onSortChange, hiddenColumns, density, stickyActions, ...props }: TableProps): import("react").JSX.Element;
56
85
  export declare function TableHead(props: ComponentPropsWithoutRef<"thead">): import("react").JSX.Element;
57
86
  export declare function TableBody(props: ComponentPropsWithoutRef<"tbody">): import("react").JSX.Element;
58
87
  interface ColumnProps {
@@ -62,8 +91,13 @@ interface ColumnProps {
62
91
  interface AlignProps extends ColumnProps {
63
92
  alignRight?: boolean;
64
93
  }
65
- export declare function TableHeaderCell({ className, alignRight, columnId, pinnable, children, style, ...props }: ComponentPropsWithoutRef<"th"> & AlignProps & {
94
+ export declare function TableHeaderCell({ className, alignRight, columnId, pinnable, sortable, children, style, ...props }: ComponentPropsWithoutRef<"th"> & AlignProps & {
66
95
  pinnable?: boolean;
96
+ /**
97
+ * Makes the header a button that cycles the sort (ascending, descending, off) and reports it
98
+ * as `aria-sort`. Needs a `columnId` and a `Table` with `sort`, `defaultSort` or `onSortChange`.
99
+ */
100
+ sortable?: boolean;
67
101
  }): ReactNode;
68
102
  export interface TableRowProps extends ComponentPropsWithoutRef<"tr"> {
69
103
  /**
@@ -101,7 +135,7 @@ export interface TableActionsCellProps extends ComponentPropsWithoutRef<"td"> {
101
135
  * menu there. The container query is on the table wrapper, never the viewport.
102
136
  */
103
137
  export declare function TableActionsCell({ menu, className, children, ...props }: TableActionsCellProps): import("react").JSX.Element;
104
- export declare function TableCell({ className, alignRight, columnId, style, ...props }: ComponentPropsWithoutRef<"td"> & AlignProps): import("react").JSX.Element;
138
+ export declare function TableCell({ className, alignRight, columnId, style, ...props }: ComponentPropsWithoutRef<"td"> & AlignProps): import("react").JSX.Element | null;
105
139
  export interface TableLinkRowProps extends Omit<ComponentPropsWithoutRef<"tr">, "children"> {
106
140
  /** Row destination: rendered as a real `<a href>` in the first cell. */
107
141
  href: string;
@@ -6,14 +6,23 @@ import {
6
6
  useContext,
7
7
  useEffect,
8
8
  useLayoutEffect,
9
+ useMemo,
9
10
  useRef,
10
11
  useState
11
12
  } from "react";
12
13
  import { Checkbox } from "../../atoms/checkbox/checkbox.js";
13
14
  import { useUiStrings } from "../../i18n/index.js";
14
- import { ArrowLeftToLine, ArrowRightToLine, PinOff } from "../../icons/index.js";
15
+ import {
16
+ ArrowDown,
17
+ ArrowLeftToLine,
18
+ ArrowRightToLine,
19
+ ArrowUp,
20
+ ChevronsUpDown,
21
+ PinOff
22
+ } from "../../icons/index.js";
15
23
  import { cn } from "../../utils/cn.js";
16
24
  import { useControllableState } from "../../utils/use-controllable-state.js";
25
+ import { CELL_PY } from "./cell-padding.js";
17
26
  import {
18
27
  computePinOffsets,
19
28
  parseStoredPins,
@@ -21,6 +30,11 @@ import {
21
30
  setColumnPin
22
31
  } from "./pin.js";
23
32
  import { formatSelectRow, selectAllState, setKeys, toggleKey } from "./selection.js";
33
+ import { ariaSortFor, nextTableSort } from "./sort.js";
34
+ import {
35
+ ariaSortFor as ariaSortFor2,
36
+ nextTableSort as nextTableSort2
37
+ } from "./sort.js";
24
38
  const DEFAULT_LABELS = {
25
39
  pinLeft: "Fijar a la izquierda",
26
40
  pinRight: "Fijar a la derecha",
@@ -28,8 +42,23 @@ const DEFAULT_LABELS = {
28
42
  };
29
43
  const PinContext = createContext(null);
30
44
  const SelectionContext = createContext(null);
45
+ const SortContext = createContext(null);
46
+ const HiddenContext = createContext(/* @__PURE__ */ new Set());
31
47
  const FLUSH_START = "[&_:is(th,td):first-child]:pl-0 [&_td:first-child>a]:pl-0";
32
48
  const FLUSH_END = "[&_:is(th,td):last-child]:pr-0 [&_td:last-child>a]:pr-0";
49
+ const DENSITY = {
50
+ comfortable: "[--row-min-h:48px] [--table-cell-py:--spacing(2)]",
51
+ compact: "[--row-min-h:40px] [--table-cell-py:--spacing(1)]"
52
+ };
53
+ const ROW_MIN_HEIGHT = "[&>tbody>tr]:h-(--row-min-h)";
54
+ const STICKY_ACTIONS = cn(
55
+ "@sm/table:[&_:is(th,td):last-child]:sticky @sm/table:[&_:is(th,td):last-child]:right-0 @sm/table:[&_:is(th,td):last-child]:bg-surface",
56
+ "@sm/table:[&_td:last-child]:z-1 @sm/table:[&_th:last-child]:z-2 @sm/table:[&_td:last-child]:transition-colors @sm/table:[&_td:last-child]:duration-(--motion-duration)",
57
+ "@sm/table:[&_tr:hover>td:last-child]:bg-surface-2 @sm/table:[&_tr[data-selected]>td:last-child]:bg-accent-soft",
58
+ "@sm/table:[&_:is(th,td):last-child]:[box-shadow:var(--sticky-divider,0_0_transparent),var(--sticky-edge,0_0_transparent)]",
59
+ "[&_th:last-child]:[--sticky-divider:inset_0_-1px_0_var(--border-color-divider)] [&_tbody>tr:not(:last-child)>td:last-child]:[--sticky-divider:inset_0_-1px_0_var(--border-color-divider)]"
60
+ );
61
+ const STICKY_EDGE = "[&_:is(th,td):last-child]:[--sticky-edge:var(--shadow-pinned-end)]";
33
62
  const STICKY_HEADER = "[&_thead_th]:sticky [&_thead_th]:top-0 [&_thead_th]:z-2 [&_thead_th]:bg-surface [&_thead_th]:shadow-[inset_0_-1px_0_var(--border-color-divider)]";
34
63
  function readStorage(key) {
35
64
  try {
@@ -61,6 +90,12 @@ function Table({
61
90
  selectedKeys,
62
91
  defaultSelectedKeys,
63
92
  onSelectedKeysChange,
93
+ sort,
94
+ defaultSort,
95
+ onSortChange,
96
+ hiddenColumns,
97
+ density = "comfortable",
98
+ stickyActions,
64
99
  ...props
65
100
  }) {
66
101
  const strings = useUiStrings();
@@ -70,6 +105,15 @@ function Table({
70
105
  defaultProp: defaultSelectedKeys ?? [],
71
106
  onChange: onSelectedKeysChange ? (keys) => onSelectedKeysChange([...keys]) : void 0
72
107
  });
108
+ const sortOn = sort !== void 0 || defaultSort !== void 0 || onSortChange !== void 0;
109
+ const [currentSort, setSort] = useControllableState({
110
+ prop: sort,
111
+ defaultProp: defaultSort ?? null,
112
+ onChange: onSortChange
113
+ });
114
+ const sortContext = sortOn ? { sort: currentSort, toggle: (columnId) => setSort(nextTableSort(currentSort, columnId)) } : null;
115
+ const hiddenKey = (hiddenColumns ?? []).join("\0");
116
+ const hidden = useMemo(() => new Set(hiddenColumns ?? []), [hiddenKey]);
73
117
  const wrapperRef = useRef(null);
74
118
  const tableRef = useRef(null);
75
119
  const controlled = pinnedColumns !== void 0;
@@ -161,7 +205,7 @@ function Table({
161
205
  rowActions: labels?.rowActions ?? strings.rowActions
162
206
  }
163
207
  } : null;
164
- return /* @__PURE__ */ jsx(PinContext.Provider, { value: context, children: /* @__PURE__ */ jsx(SelectionContext.Provider, { value: selection, children: /* @__PURE__ */ jsx(
208
+ return /* @__PURE__ */ jsx(PinContext.Provider, { value: context, children: /* @__PURE__ */ jsx(SelectionContext.Provider, { value: selection, children: /* @__PURE__ */ jsx(SortContext.Provider, { value: sortContext, children: /* @__PURE__ */ jsx(HiddenContext.Provider, { value: hidden, children: /* @__PURE__ */ jsx(
165
209
  "div",
166
210
  {
167
211
  ref: wrapperRef,
@@ -177,8 +221,13 @@ function Table({
177
221
  "table",
178
222
  {
179
223
  ref: tableRef,
224
+ "data-table-density": density,
180
225
  className: cn(
181
226
  "w-full border-collapse text-fs-130",
227
+ DENSITY[density],
228
+ ROW_MIN_HEIGHT,
229
+ stickyActions && STICKY_ACTIONS,
230
+ stickyActions && scrolled.end && STICKY_EDGE,
182
231
  (flush === true || flush === "start") && FLUSH_START,
183
232
  (flush === true || flush === "end") && FLUSH_END,
184
233
  stickyHeader && STICKY_HEADER,
@@ -188,7 +237,7 @@ function Table({
188
237
  }
189
238
  )
190
239
  }
191
- ) }) });
240
+ ) }) }) }) });
192
241
  }
193
242
  function TableHead(props) {
194
243
  return /* @__PURE__ */ jsx("thead", { ...props });
@@ -204,7 +253,7 @@ function usePinnedCell(columnId, header) {
204
253
  if (!position) return { context, attrs, className: "", style: void 0 };
205
254
  const shadowed = position.edge && (position.side === "left" ? context.scrolledStart : context.scrolledEnd);
206
255
  const className = cn(
207
- "sticky bg-surface",
256
+ "sticky bg-surface transition-colors duration-(--motion-duration) motion-reduce:transition-none",
208
257
  header ? "z-2" : "z-1 group-hover/row:bg-surface-2 group-aria-selected/row:bg-accent-soft group-data-[selected=true]/row:bg-accent-soft",
209
258
  shadowed && (position.side === "left" ? "shadow-pinned-start" : "shadow-pinned-end")
210
259
  );
@@ -257,20 +306,56 @@ function PinButtons({ columnId }) {
257
306
  )
258
307
  ] });
259
308
  }
309
+ function SortButton({
310
+ columnId,
311
+ context,
312
+ children
313
+ }) {
314
+ const direction = ariaSortFor(context.sort, columnId);
315
+ const Icon = direction === "ascending" ? ArrowUp : direction === "descending" ? ArrowDown : ChevronsUpDown;
316
+ return /* @__PURE__ */ jsxs(
317
+ "button",
318
+ {
319
+ type: "button",
320
+ onClick: () => context.toggle(columnId),
321
+ className: cn(
322
+ "-mx-1 inline-flex items-center gap-1 rounded-xs px-1 font-[inherit] text-[length:inherit] uppercase tracking-[inherit] hover:text-ink focus-visible:focus-ring",
323
+ direction !== "none" ? "text-ink" : "text-inherit"
324
+ ),
325
+ children: [
326
+ children,
327
+ /* @__PURE__ */ jsx(
328
+ Icon,
329
+ {
330
+ "aria-hidden": "true",
331
+ className: cn("size-3.5 shrink-0", direction === "none" && "opacity-50")
332
+ }
333
+ )
334
+ ]
335
+ }
336
+ );
337
+ }
260
338
  function TableHeaderCell({
261
339
  className,
262
340
  alignRight,
263
341
  columnId,
264
342
  pinnable,
343
+ sortable,
265
344
  children,
266
345
  style,
267
346
  ...props
268
347
  }) {
269
348
  const pinned = usePinnedCell(columnId, true);
349
+ const hiddenIds = useContext(HiddenContext);
350
+ const sortContext = useContext(SortContext);
351
+ if (columnId && hiddenIds.has(columnId)) return null;
352
+ const sorting = sortable && columnId && sortContext ? { columnId, context: sortContext } : null;
353
+ const content = sorting ? /* @__PURE__ */ jsx(SortButton, { columnId: sorting.columnId, context: sorting.context, children }) : children;
270
354
  const showPin = pinnable && columnId && pinned.context;
271
355
  return /* @__PURE__ */ jsx(
272
356
  "th",
273
357
  {
358
+ "aria-sort": sorting ? ariaSortFor(sorting.context.sort, sorting.columnId) : void 0,
274
359
  className: cn(
275
360
  "whitespace-nowrap border-b-divider px-4 py-2.5 text-left font-[650] text-fs-110 text-ink-3 uppercase tracking-[.07em] @max-sm/table:px-2.5",
276
361
  alignRight && "text-right",
@@ -281,9 +366,9 @@ function TableHeaderCell({
281
366
  ...pinned.attrs,
282
367
  ...props,
283
368
  children: showPin ? /* @__PURE__ */ jsxs("span", { className: cn("inline-flex items-center gap-1", alignRight && "flex-row-reverse"), children: [
284
- children,
369
+ content,
285
370
  /* @__PURE__ */ jsx(PinButtons, { columnId })
286
- ] }) : children
371
+ ] }) : content
287
372
  }
288
373
  );
289
374
  }
@@ -296,7 +381,7 @@ function TableRow({ className, rowKey, ...props }) {
296
381
  "aria-selected": isSelected,
297
382
  "data-selected": isSelected || void 0,
298
383
  className: cn(
299
- "group/row border-b-divider last:border-b-0 hover:bg-surface-2",
384
+ "group/row border-b-divider transition-colors duration-(--motion-duration) ease-(--motion-ease) last:border-b-0 hover:bg-surface-2 motion-reduce:transition-none",
300
385
  isSelected && "bg-accent-soft hover:bg-accent-soft",
301
386
  className
302
387
  ),
@@ -308,14 +393,21 @@ function TableSelectCell({ rowKey, label, className, ...props }) {
308
393
  const selection = useContext(SelectionContext);
309
394
  if (!selection)
310
395
  throw new Error("TableSelectCell needs a Table with selectedKeys or onSelectedKeysChange");
311
- return /* @__PURE__ */ jsx("td", { className: cn("w-px px-4 py-2.75 align-middle @max-sm/table:px-2.5", className), ...props, children: /* @__PURE__ */ jsx(
312
- Checkbox,
396
+ return /* @__PURE__ */ jsx(
397
+ "td",
313
398
  {
314
- checked: selection.selected.includes(rowKey),
315
- onCheckedChange: () => selection.toggle(rowKey),
316
- "aria-label": formatSelectRow(selection.labels.selectRow ?? "", label ?? rowKey)
399
+ className: cn("w-px px-4 align-middle @max-sm/table:px-2.5", CELL_PY, className),
400
+ ...props,
401
+ children: /* @__PURE__ */ jsx(
402
+ Checkbox,
403
+ {
404
+ checked: selection.selected.includes(rowKey),
405
+ onCheckedChange: () => selection.toggle(rowKey),
406
+ "aria-label": formatSelectRow(selection.labels.selectRow ?? "", label ?? rowKey)
407
+ }
408
+ )
317
409
  }
318
- ) });
410
+ );
319
411
  }
320
412
  function TableSelectAllCell({ rowKeys, className, ...props }) {
321
413
  const selection = useContext(SelectionContext);
@@ -346,7 +438,7 @@ function TableActionsCell({ menu, className, children, ...props }) {
346
438
  return /* @__PURE__ */ jsxs(
347
439
  "td",
348
440
  {
349
- className: cn("w-px px-4 py-2.75 text-right align-middle @max-sm/table:px-2.5", className),
441
+ className: cn("w-px px-4 text-right align-middle @max-sm/table:px-2.5", CELL_PY, className),
350
442
  ...props,
351
443
  children: [
352
444
  /* @__PURE__ */ jsx(
@@ -372,11 +464,14 @@ function TableCell({
372
464
  ...props
373
465
  }) {
374
466
  const pinned = usePinnedCell(columnId, false);
467
+ const hiddenIds = useContext(HiddenContext);
468
+ if (columnId && hiddenIds.has(columnId)) return null;
375
469
  return /* @__PURE__ */ jsx(
376
470
  "td",
377
471
  {
378
472
  className: cn(
379
- "px-4 py-2.75 align-middle @max-sm/table:px-2.5",
473
+ "px-4 align-middle @max-sm/table:px-2.5",
474
+ CELL_PY,
380
475
  alignRight && "text-right",
381
476
  pinned.className,
382
477
  className
@@ -397,6 +492,7 @@ function TableLinkRow({
397
492
  ...props
398
493
  }) {
399
494
  const pinned = usePinnedCell(primaryColumnId, false);
495
+ const hiddenIds = useContext(HiddenContext);
400
496
  const selection = useContext(SelectionContext);
401
497
  const isSelected = selection && rowKey !== void 0 ? selection.selected.includes(rowKey) : void 0;
402
498
  return /* @__PURE__ */ jsxs(
@@ -405,13 +501,13 @@ function TableLinkRow({
405
501
  "aria-selected": isSelected,
406
502
  "data-selected": isSelected || void 0,
407
503
  className: cn(
408
- "group/row relative border-b-divider last:border-b-0 hover:bg-surface-2",
504
+ "group/row relative border-b-divider transition-colors duration-(--motion-duration) ease-(--motion-ease) last:border-b-0 hover:bg-surface-2 motion-reduce:transition-none",
409
505
  isSelected && "bg-accent-soft hover:bg-accent-soft",
410
506
  className
411
507
  ),
412
508
  ...props,
413
509
  children: [
414
- /* @__PURE__ */ jsx(
510
+ primaryColumnId && hiddenIds.has(primaryColumnId) ? null : /* @__PURE__ */ jsx(
415
511
  "td",
416
512
  {
417
513
  className: cn("p-0 align-middle", pinned.className),
@@ -421,7 +517,10 @@ function TableLinkRow({
421
517
  "a",
422
518
  {
423
519
  href,
424
- className: "block px-4 py-2.75 font-[650] text-ink no-underline before:absolute before:inset-0 before:content-[''] @max-sm/table:px-2.5",
520
+ className: cn(
521
+ "block px-4 font-[650] text-ink no-underline before:absolute before:inset-0 before:content-[''] @max-sm/table:px-2.5",
522
+ CELL_PY
523
+ ),
425
524
  children: primary
426
525
  }
427
526
  )
@@ -442,5 +541,7 @@ export {
442
541
  TableLinkRow,
443
542
  TableRow,
444
543
  TableSelectAllCell,
445
- TableSelectCell
544
+ TableSelectCell,
545
+ ariaSortFor2 as ariaSortFor,
546
+ nextTableSort2 as nextTableSort
446
547
  };
@@ -0,0 +1 @@
1
+ export { type TableColumnOption, TableColumnsMenu, type TableColumnsMenuProps, } from "./table-columns-menu.js";
@@ -0,0 +1,6 @@
1
+ import {
2
+ TableColumnsMenu
3
+ } from "./table-columns-menu.js";
4
+ export {
5
+ TableColumnsMenu
6
+ };
@@ -0,0 +1,14 @@
1
+ export interface TableColumnOption {
2
+ id: string;
3
+ label: string;
4
+ }
5
+ export interface TableColumnsMenuProps {
6
+ columns: readonly TableColumnOption[];
7
+ /** Ids of the hidden columns; pass the same list to `Table` as `hiddenColumns`. */
8
+ hiddenColumns: readonly string[];
9
+ onHiddenColumnsChange: (hidden: string[]) => void;
10
+ /** Trigger text. Defaults to the localized "Columns". */
11
+ label?: string;
12
+ }
13
+ /** Popover with a checkbox per column. The last visible column cannot be hidden. */
14
+ export declare function TableColumnsMenu({ columns, hiddenColumns, onHiddenColumnsChange, label, }: TableColumnsMenuProps): import("react").JSX.Element;
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { Checkbox } from "../../atoms/checkbox/checkbox.js";
4
+ import { useUiStrings } from "../../i18n/index.js";
5
+ import { Columns3 } from "../../icons/index.js";
6
+ import { Popover, PopoverContent, PopoverTrigger } from "../../overlays/popover/popover.js";
7
+ function TableColumnsMenu({
8
+ columns,
9
+ hiddenColumns,
10
+ onHiddenColumnsChange,
11
+ label
12
+ }) {
13
+ const strings = useUiStrings();
14
+ const name = label ?? strings.columns;
15
+ const visible = columns.filter((column) => !hiddenColumns.includes(column.id));
16
+ return /* @__PURE__ */ jsxs(Popover, { children: [
17
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
18
+ "button",
19
+ {
20
+ type: "button",
21
+ className: "inline-flex h-control-sm items-center gap-1.5 rounded-control bg-surface-control px-2.5 text-fs-120 text-ink shadow-control hover:bg-surface-2 focus-visible:focus-ring [&_svg]:size-4",
22
+ children: [
23
+ /* @__PURE__ */ jsx(Columns3, { "aria-hidden": "true" }),
24
+ name
25
+ ]
26
+ }
27
+ ) }),
28
+ /* @__PURE__ */ jsx(PopoverContent, { align: "end", "aria-label": name, children: /* @__PURE__ */ jsx("ul", { className: "m-0 grid list-none gap-1 p-0", children: columns.map((column) => {
29
+ const shown = !hiddenColumns.includes(column.id);
30
+ return /* @__PURE__ */ jsx("li", { className: "px-1.5 py-1", children: /* @__PURE__ */ jsx(
31
+ Checkbox,
32
+ {
33
+ label: column.label,
34
+ checked: shown,
35
+ disabled: shown && visible.length === 1,
36
+ onCheckedChange: () => onHiddenColumnsChange(
37
+ shown ? [...hiddenColumns, column.id] : hiddenColumns.filter((id) => id !== column.id)
38
+ )
39
+ }
40
+ ) }, column.id);
41
+ }) }) })
42
+ ] });
43
+ }
44
+ export {
45
+ TableColumnsMenu
46
+ };
@@ -1,31 +1,5 @@
1
1
  import type { Decorator } from "@storybook/react-vite";
2
- import type { ReactNode } from "react";
3
- /** Vertical rhythm of a dashboard page. */
4
- export declare function DashboardPage({ children }: {
5
- children: ReactNode;
6
- }): import("react").JSX.Element;
7
- /** Joined KPI tiles: two per row when narrow, four from 720 px of page width. */
8
- export declare function KpiRow({ children }: {
9
- children: ReactNode;
10
- }): import("react").JSX.Element;
11
- /** Equal cards that stack under 720 px of page width. */
12
- export declare function CardGrid({ columns, children }: {
13
- columns?: 2 | 3;
14
- children: ReactNode;
15
- }): import("react").JSX.Element;
16
- export interface ChartCardProps {
17
- title: string;
18
- subtitle?: string;
19
- /** Slot at the end of the header (a chip, a button). */
20
- aside?: ReactNode;
21
- /** Fixed height of the body in px; the chart inside uses `height="fill"`. */
22
- height?: number;
23
- children: ReactNode;
24
- }
25
- /** Card with a fixed-height body so `height="fill"` charts take exactly the space left. */
26
- export declare function ChartCard({ title, subtitle, aside, height, children }: ChartCardProps): import("react").JSX.Element;
27
- /** Card whose body is a table or grid that scrolls inside its own wrapper. */
28
- export declare function TableCard({ title, subtitle, aside, children }: Omit<ChartCardProps, "height">): import("react").JSX.Element;
2
+ export { CardGrid, ChartCard, type ChartCardProps, DashboardPage, KpiRow, TableCard, } from "../containers/dashboard/index.js";
29
3
  /** Container-width frames for the `Narrow` (320) and `Tablet` (768) variants. */
30
4
  export declare const narrowFrame: Decorator;
31
5
  export declare const tabletFrame: Decorator;
@@ -1,43 +1,11 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Card, CardBody, CardHeader } from "../containers/card/index.js";
3
- import { cn } from "../utils/cn.js";
4
- function DashboardPage({ children }) {
5
- return /* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-col gap-4", children });
6
- }
7
- function KpiRow({ children }) {
8
- return /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-px overflow-hidden rounded-card bg-line border-card shadow-card @min-[720px]/page:grid-cols-4", children });
9
- }
10
- const gridClasses = {
11
- 2: "grid-cols-1 @min-[720px]/page:grid-cols-2",
12
- 3: "grid-cols-1 @min-[720px]/page:grid-cols-2 @min-[1180px]/page:grid-cols-3"
13
- };
14
- function CardGrid({ columns = 2, children }) {
15
- return /* @__PURE__ */ jsx("div", { className: cn("grid items-start gap-4", gridClasses[columns]), children });
16
- }
17
- function CardTitle({ title, subtitle }) {
18
- return /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
19
- /* @__PURE__ */ jsx("h2", { className: "m-0 break-words font-semibold text-fs-140 text-ink", children: title }),
20
- subtitle ? /* @__PURE__ */ jsx("p", { className: "m-0 break-words text-fs-120 text-ink-3", children: subtitle }) : null
21
- ] });
22
- }
23
- function ChartCard({ title, subtitle, aside, height = 300, children }) {
24
- return /* @__PURE__ */ jsxs(Card, { children: [
25
- /* @__PURE__ */ jsxs(CardHeader, { children: [
26
- /* @__PURE__ */ jsx(CardTitle, { title, subtitle }),
27
- aside
28
- ] }),
29
- /* @__PURE__ */ jsx(CardBody, { children: /* @__PURE__ */ jsx("div", { className: "min-w-0", style: { height }, children }) })
30
- ] });
31
- }
32
- function TableCard({ title, subtitle, aside, children }) {
33
- return /* @__PURE__ */ jsxs(Card, { children: [
34
- /* @__PURE__ */ jsxs(CardHeader, { children: [
35
- /* @__PURE__ */ jsx(CardTitle, { title, subtitle }),
36
- aside
37
- ] }),
38
- /* @__PURE__ */ jsx("div", { className: "min-w-0", children })
39
- ] });
40
- }
1
+ import { jsx } from "react/jsx-runtime";
2
+ import {
3
+ CardGrid,
4
+ ChartCard,
5
+ DashboardPage,
6
+ KpiRow,
7
+ TableCard
8
+ } from "../containers/dashboard/index.js";
41
9
  const narrowFrame = (Story) => /* @__PURE__ */ jsx("div", { className: "@container/page w-[320px] max-w-full", children: /* @__PURE__ */ jsx(Story, {}) });
42
10
  const tabletFrame = (Story) => /* @__PURE__ */ jsx("div", { className: "@container/page w-[768px] max-w-full", children: /* @__PURE__ */ jsx(Story, {}) });
43
11
  const NARROW_NOTE = "Container of 320 px: Cols collapse to one column, KPIs go two per row and every chart adapts to its card.";