@cosmicdrift/kumiko-renderer 0.413.1 → 0.414.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 (334) hide show
  1. package/dist/app/action-form-support.js +4 -0
  2. package/dist/app/content-previews.d.ts +39 -0
  3. package/dist/app/content-previews.js +28 -0
  4. package/dist/app/entity-edit-screen.js +2 -5
  5. package/dist/app/entity-list-screen.js +30 -50
  6. package/dist/app/form-schema.d.ts +1 -0
  7. package/dist/app/form-schema.js +24 -0
  8. package/dist/app/list-sort-options.d.ts +4 -0
  9. package/dist/app/list-sort-options.js +11 -0
  10. package/dist/app/named-filter-facet.d.ts +17 -3
  11. package/dist/app/named-filter-facet.js +88 -5
  12. package/dist/app/projection-detail-body.d.ts +2 -4
  13. package/dist/app/projection-detail-body.js +7 -1
  14. package/dist/app/projection-detail-guidance-data.d.ts +7 -0
  15. package/dist/app/projection-detail-guidance-data.js +101 -0
  16. package/dist/app/projection-detail-guidance.d.ts +13 -0
  17. package/dist/app/projection-detail-guidance.js +197 -0
  18. package/dist/app/projection-detail-header-model.d.ts +1 -3
  19. package/dist/app/projection-detail-header-model.js +4 -8
  20. package/dist/app/projection-detail-header-region.d.ts +2 -1
  21. package/dist/app/projection-detail-header-region.js +63 -23
  22. package/dist/app/projection-detail-header.d.ts +6 -1
  23. package/dist/app/projection-detail-header.js +75 -18
  24. package/dist/app/projection-detail-states.d.ts +3 -3
  25. package/dist/app/projection-list-body.js +4 -2
  26. package/dist/app/projection-list-render.js +3 -1
  27. package/dist/app/projection-list-shim.d.ts +4 -1
  28. package/dist/app/projection-list-shim.js +35 -8
  29. package/dist/app/reference-link.d.ts +3 -2
  30. package/dist/app/reference-link.js +19 -4
  31. package/dist/app/row-actions.js +3 -3
  32. package/dist/app/screen-access.d.ts +4 -0
  33. package/dist/app/screen-access.js +19 -0
  34. package/dist/app/screen-shared.js +3 -1
  35. package/dist/app/unique-label-keys.d.ts +1 -0
  36. package/dist/app/unique-label-keys.js +9 -0
  37. package/dist/app/use-entity-list-payload.d.ts +25 -0
  38. package/dist/app/use-entity-list-payload.js +57 -0
  39. package/dist/app/use-entity-range-facets.js +2 -3
  40. package/dist/app/use-facet-counts.d.ts +5 -0
  41. package/dist/app/use-facet-counts.js +7 -0
  42. package/dist/app/use-list-summary-row.d.ts +10 -0
  43. package/dist/app/use-list-summary-row.js +33 -0
  44. package/dist/app/use-named-filter-queue.d.ts +20 -0
  45. package/dist/app/use-named-filter-queue.js +9 -0
  46. package/dist/app/use-projection-detail-actions.d.ts +4 -4
  47. package/dist/app/use-projection-detail-actions.js +30 -1
  48. package/dist/app/use-projection-list-data.d.ts +5 -0
  49. package/dist/app/use-projection-list-data.js +35 -6
  50. package/dist/app/use-projection-list-query.d.ts +2 -0
  51. package/dist/app/use-projection-list-query.js +29 -16
  52. package/dist/app/use-related-list-tab-counts.js +5 -1
  53. package/dist/app/use-row-decoration.d.ts +11 -0
  54. package/dist/app/use-row-decoration.js +55 -0
  55. package/dist/app/use-screen-list-rows.d.ts +4 -1
  56. package/dist/app/use-screen-list-rows.js +14 -5
  57. package/dist/app/use-screen-list-table.d.ts +3 -1
  58. package/dist/app/use-screen-list-table.js +10 -1
  59. package/dist/app/write-failed-error.d.ts +1 -0
  60. package/dist/app/write-failed-error.js +10 -0
  61. package/dist/compact-tap-classes.d.ts +1 -0
  62. package/dist/compact-tap-classes.js +3 -0
  63. package/dist/components/embedded-list-field.js +13 -12
  64. package/dist/components/list-empty-state.d.ts +8 -1
  65. package/dist/components/list-empty-state.js +4 -1
  66. package/dist/components/list-group-page-bridges.d.ts +1 -1
  67. package/dist/components/list-group-page-bridges.js +2 -2
  68. package/dist/components/related-list-section.js +4 -22
  69. package/dist/components/render-edit-action-button.d.ts +3 -1
  70. package/dist/components/render-edit-action-button.js +5 -3
  71. package/dist/components/render-edit-render-model.d.ts +2 -2
  72. package/dist/components/render-edit-types.d.ts +4 -2
  73. package/dist/components/render-edit.js +3 -1
  74. package/dist/components/render-list-hint-columns.d.ts +8 -0
  75. package/dist/components/render-list-hint-columns.js +77 -0
  76. package/dist/components/render-list-reference-columns.js +4 -2
  77. package/dist/components/render-list-row-tone.d.ts +3 -0
  78. package/dist/components/render-list-row-tone.js +10 -0
  79. package/dist/components/render-list-table-props.d.ts +9 -1
  80. package/dist/components/render-list-table-props.js +4 -1
  81. package/dist/components/render-list-toolbar-action.d.ts +1 -2
  82. package/dist/components/render-list-toolbar-model.d.ts +3 -0
  83. package/dist/components/render-list-toolbar-model.js +21 -6
  84. package/dist/components/render-list-toolbar.d.ts +3 -2
  85. package/dist/components/render-list-toolbar.js +8 -6
  86. package/dist/components/render-list-types.d.ts +6 -1
  87. package/dist/components/render-list.js +26 -7
  88. package/dist/components/use-render-edit-controlled-sync.js +3 -5
  89. package/dist/components/use-render-edit-draft-save.js +7 -9
  90. package/dist/components/use-render-edit-schema.d.ts +3 -0
  91. package/dist/components/use-render-edit-schema.js +15 -0
  92. package/dist/components/use-render-edit-state.d.ts +1 -0
  93. package/dist/components/use-render-edit-state.js +4 -1
  94. package/dist/components/use-render-edit-steps.js +2 -3
  95. package/dist/components/use-render-list-columns.d.ts +3 -1
  96. package/dist/components/use-render-list-columns.js +22 -10
  97. package/dist/context/screen-focus-context.d.ts +14 -0
  98. package/dist/context/screen-focus-context.js +28 -0
  99. package/dist/data-table-facet-types.d.ts +2 -0
  100. package/dist/data-table-view-types.d.ts +20 -1
  101. package/dist/headless/form/form-controller.js +3 -1
  102. package/dist/headless/form/zod-bridge.d.ts +7 -1
  103. package/dist/headless/form/zod-bridge.js +10 -0
  104. package/dist/headless/index.d.ts +2 -1
  105. package/dist/headless/index.js +1 -0
  106. package/dist/headless/pwa-service-worker-meta.d.ts +1 -0
  107. package/dist/headless/pwa-service-worker-meta.js +3 -0
  108. package/dist/headless/view-model/index.d.ts +1 -1
  109. package/dist/headless/view-model/list-file-display.js +3 -2
  110. package/dist/headless/view-model/list.js +16 -0
  111. package/dist/headless/view-model/types.d.ts +33 -0
  112. package/dist/hooks/list-column-layout.js +2 -1
  113. package/dist/hooks/list-server-groups.js +14 -1
  114. package/dist/hooks/list-state-schema.d.ts +1 -0
  115. package/dist/hooks/list-state-schema.js +9 -1
  116. package/dist/hooks/use-debounced-value.d.ts +1 -0
  117. package/dist/hooks/use-debounced-value.js +11 -0
  118. package/dist/hooks/use-list-aggregates.d.ts +5 -1
  119. package/dist/hooks/use-list-aggregates.js +9 -5
  120. package/dist/hooks/use-list-table.d.ts +2 -1
  121. package/dist/hooks/use-list-table.js +3 -9
  122. package/dist/hooks/use-list-url-state.d.ts +2 -0
  123. package/dist/hooks/use-list-url-state.js +12 -4
  124. package/dist/hooks/use-list-view-state.js +23 -3
  125. package/dist/hooks/use-reference-lookup.js +7 -2
  126. package/dist/hooks/use-remembered-list-params.d.ts +6 -2
  127. package/dist/hooks/use-remembered-list-params.js +18 -3
  128. package/dist/hooks/use-store.js +0 -1
  129. package/dist/i18n-defaults.js +37 -2
  130. package/dist/index.d.ts +7 -2
  131. package/dist/index.js +4 -1
  132. package/dist/live/dispatcher-live.js +2 -0
  133. package/dist/metric-types.d.ts +2 -0
  134. package/dist/primitives-record-guidance.d.ts +53 -0
  135. package/dist/primitives-record-guidance.js +1 -0
  136. package/dist/primitives.d.ts +41 -31
  137. package/dist/server-clock.d.ts +6 -0
  138. package/dist/server-clock.js +20 -0
  139. package/dist/session/session-ended.d.ts +1 -0
  140. package/dist/session/session-ended.js +2 -2
  141. package/dist/status-tone.d.ts +1 -0
  142. package/dist/status-tone.js +5 -0
  143. package/dist/web/app/browser-locale.js +1 -1
  144. package/dist/web/app/client-plugin.d.ts +6 -1
  145. package/dist/web/app/create-app.d.ts +2 -1
  146. package/dist/web/app/create-app.js +15 -5
  147. package/dist/web/app/dashboard-body.js +25 -11
  148. package/dist/web/app/dashboard-header.d.ts +2 -1
  149. package/dist/web/app/dashboard-header.js +19 -7
  150. package/dist/web/app/dashboard-list-panel.d.ts +12 -0
  151. package/dist/web/app/dashboard-list-panel.js +149 -0
  152. package/dist/web/app/dashboard-narrow-gate.d.ts +6 -0
  153. package/dist/web/app/dashboard-narrow-gate.js +6 -0
  154. package/dist/web/app/dashboard-narrow-order.d.ts +3 -0
  155. package/dist/web/app/dashboard-narrow-order.js +6 -0
  156. package/dist/web/app/dashboard-navigation-link.d.ts +12 -0
  157. package/dist/web/app/dashboard-navigation-link.js +21 -0
  158. package/dist/web/app/dashboard-panels.d.ts +6 -23
  159. package/dist/web/app/dashboard-panels.js +53 -123
  160. package/dist/web/app/dashboard-reference-list-table.d.ts +5 -1
  161. package/dist/web/app/dashboard-reference-list-table.js +12 -4
  162. package/dist/web/app/dashboard-shared.d.ts +23 -7
  163. package/dist/web/app/dashboard-shared.js +44 -17
  164. package/dist/web/app/dashboard-stat-group-panel.d.ts +13 -0
  165. package/dist/web/app/dashboard-stat-group-panel.js +67 -0
  166. package/dist/web/app/dashboard-text-panel.d.ts +12 -0
  167. package/dist/web/app/dashboard-text-panel.js +163 -0
  168. package/dist/web/app/dashboard-text.d.ts +2 -0
  169. package/dist/web/app/dashboard-text.js +1 -1
  170. package/dist/web/app/dashboard-visibility.js +1 -1
  171. package/dist/web/app/relative-time.js +2 -1
  172. package/dist/web/editor/editor-footer.d.ts +28 -0
  173. package/dist/web/editor/editor-footer.js +23 -0
  174. package/dist/web/editor/editor-frame.d.ts +23 -0
  175. package/dist/web/editor/editor-frame.js +24 -0
  176. package/dist/web/editor/editor-header.d.ts +36 -0
  177. package/dist/web/editor/editor-header.js +30 -0
  178. package/dist/web/editor/editor-rail.d.ts +32 -0
  179. package/dist/web/editor/editor-rail.js +37 -0
  180. package/dist/web/editor/editor-workbench.d.ts +34 -0
  181. package/dist/web/editor/editor-workbench.js +19 -0
  182. package/dist/web/editor/index.d.ts +6 -0
  183. package/dist/web/editor/index.js +6 -0
  184. package/dist/web/editor/relative-when.d.ts +1 -0
  185. package/dist/web/editor/relative-when.js +18 -0
  186. package/dist/web/index.d.ts +7 -1
  187. package/dist/web/index.js +5 -1
  188. package/dist/web/layout/default-app-shell.js +6 -4
  189. package/dist/web/layout/focus-aware-sidebar.d.ts +4 -7
  190. package/dist/web/layout/focus-aware-sidebar.js +5 -7
  191. package/dist/web/layout/header-action-pinned.d.ts +8 -0
  192. package/dist/web/layout/header-action-pinned.js +25 -0
  193. package/dist/web/layout/nav-collapse-state.d.ts +5 -0
  194. package/dist/web/layout/nav-collapse-state.js +66 -0
  195. package/dist/web/layout/nav-tree.js +25 -5
  196. package/dist/web/layout/page-header-slot.d.ts +2 -0
  197. package/dist/web/layout/page-header-slot.js +4 -0
  198. package/dist/web/layout/screen-focus.d.ts +8 -0
  199. package/dist/web/layout/screen-focus.js +42 -0
  200. package/dist/web/layout/shell-focus.d.ts +6 -5
  201. package/dist/web/layout/shell-focus.js +12 -9
  202. package/dist/web/layout/shell-header.js +38 -10
  203. package/dist/web/layout/sidebar-open-state.d.ts +6 -0
  204. package/dist/web/layout/sidebar-open-state.js +28 -0
  205. package/dist/web/layout/uniform-bar-controls.d.ts +2 -2
  206. package/dist/web/layout/uniform-bar-controls.js +4 -3
  207. package/dist/web/layout/use-in-app-inbox.js +8 -1
  208. package/dist/web/layout/workspace-shell.js +6 -4
  209. package/dist/web/lib/upload-file-ref.d.ts +2 -2
  210. package/dist/web/lib/upload-file-ref.js +4 -9
  211. package/dist/web/presence/use-presence.js +7 -2
  212. package/dist/web/primitives/banner.d.ts +1 -1
  213. package/dist/web/primitives/banner.js +14 -6
  214. package/dist/web/primitives/calendar-day-picker.js +24 -5
  215. package/dist/web/primitives/card.js +1 -1
  216. package/dist/web/primitives/code-input.js +6 -1
  217. package/dist/web/primitives/data-table/actions-column.d.ts +1 -0
  218. package/dist/web/primitives/data-table/actions-column.js +4 -2
  219. package/dist/web/primitives/data-table/card-body.d.ts +5 -0
  220. package/dist/web/primitives/data-table/card-body.js +47 -5
  221. package/dist/web/primitives/data-table/card-frame.d.ts +8 -0
  222. package/dist/web/primitives/data-table/card-frame.js +9 -0
  223. package/dist/web/primitives/data-table/card-row.js +40 -7
  224. package/dist/web/primitives/data-table/card-sort-select.d.ts +6 -2
  225. package/dist/web/primitives/data-table/card-sort-select.js +10 -7
  226. package/dist/web/primitives/data-table/card-view.js +12 -2
  227. package/dist/web/primitives/data-table/column-picker-section.js +9 -2
  228. package/dist/web/primitives/data-table/column-resize-handle.js +3 -4
  229. package/dist/web/primitives/data-table/column-role.d.ts +1 -0
  230. package/dist/web/primitives/data-table/column-role.js +1 -0
  231. package/dist/web/primitives/data-table/data-cell-props.d.ts +5 -0
  232. package/dist/web/primitives/data-table/data-cell-props.js +5 -0
  233. package/dist/web/primitives/data-table/density.js +1 -0
  234. package/dist/web/primitives/data-table/facet-cluster.d.ts +2 -1
  235. package/dist/web/primitives/data-table/facet-cluster.js +2 -2
  236. package/dist/web/primitives/data-table/group-band.js +4 -0
  237. package/dist/web/primitives/data-table/hint-cell.d.ts +16 -0
  238. package/dist/web/primitives/data-table/hint-cell.js +74 -0
  239. package/dist/web/primitives/data-table/hint-column-width.d.ts +3 -0
  240. package/dist/web/primitives/data-table/hint-column-width.js +11 -0
  241. package/dist/web/primitives/data-table/measure-value.js +2 -3
  242. package/dist/web/primitives/data-table/row-action-column.d.ts +3 -0
  243. package/dist/web/primitives/data-table/row-action-column.js +4 -0
  244. package/dist/web/primitives/data-table/sort-options-select.d.ts +22 -0
  245. package/dist/web/primitives/data-table/sort-options-select.js +46 -0
  246. package/dist/web/primitives/data-table/sortable-header.d.ts +3 -1
  247. package/dist/web/primitives/data-table/sortable-header.js +5 -3
  248. package/dist/web/primitives/data-table/table-body.d.ts +1 -1
  249. package/dist/web/primitives/data-table/table-body.js +5 -3
  250. package/dist/web/primitives/data-table/table-chrome.js +3 -1
  251. package/dist/web/primitives/data-table/table-content.js +10 -5
  252. package/dist/web/primitives/data-table/table-data-cell.js +9 -3
  253. package/dist/web/primitives/data-table/table-header-row.js +5 -2
  254. package/dist/web/primitives/data-table/table-view.js +17 -3
  255. package/dist/web/primitives/data-table/toolbar-end-cluster.js +1 -1
  256. package/dist/web/primitives/data-table/toolbar.js +31 -3
  257. package/dist/web/primitives/data-table/totals-footer.d.ts +20 -0
  258. package/dist/web/primitives/data-table/totals-footer.js +40 -9
  259. package/dist/web/primitives/data-table/use-bulk-selection.js +2 -1
  260. package/dist/web/primitives/data-table/use-column-pins.js +4 -0
  261. package/dist/web/primitives/data-table/use-data-table-state.d.ts +1 -0
  262. package/dist/web/primitives/data-table/use-data-table-state.js +9 -5
  263. package/dist/web/primitives/data-table/use-measured-column-widths.js +5 -4
  264. package/dist/web/primitives/data-table/use-row-selection.js +22 -11
  265. package/dist/web/primitives/data-table/view-menu.js +7 -1
  266. package/dist/web/primitives/data-table-cell.d.ts +21 -2
  267. package/dist/web/primitives/data-table-cell.js +96 -19
  268. package/dist/web/primitives/embedded-file-cell.js +3 -2
  269. package/dist/web/primitives/embedded-list-cards.js +3 -4
  270. package/dist/web/primitives/facet-filter.d.ts +4 -2
  271. package/dist/web/primitives/facet-filter.js +26 -3
  272. package/dist/web/primitives/facet-search-filter.js +1 -1
  273. package/dist/web/primitives/file-thumbnail.d.ts +6 -2
  274. package/dist/web/primitives/file-thumbnail.js +13 -6
  275. package/dist/web/primitives/file-upload.js +3 -2
  276. package/dist/web/primitives/file-view-action.d.ts +6 -0
  277. package/dist/web/primitives/file-view-action.js +19 -0
  278. package/dist/web/primitives/files-dropzone.js +20 -9
  279. package/dist/web/primitives/form-footer-parts.d.ts +0 -1
  280. package/dist/web/primitives/form.js +0 -1
  281. package/dist/web/primitives/hint-reason-row.d.ts +32 -0
  282. package/dist/web/primitives/hint-reason-row.js +45 -0
  283. package/dist/web/primitives/index.js +6 -0
  284. package/dist/web/primitives/layout-elements.d.ts +1 -1
  285. package/dist/web/primitives/layout-elements.js +2 -2
  286. package/dist/web/primitives/metric.js +8 -6
  287. package/dist/web/primitives/page-header.d.ts +1 -1
  288. package/dist/web/primitives/page-header.js +8 -1
  289. package/dist/web/primitives/pager.js +29 -18
  290. package/dist/web/primitives/reason-box.d.ts +20 -0
  291. package/dist/web/primitives/reason-box.js +13 -0
  292. package/dist/web/primitives/record-breadcrumb.d.ts +3 -0
  293. package/dist/web/primitives/record-breadcrumb.js +11 -0
  294. package/dist/web/primitives/record-steps.d.ts +3 -0
  295. package/dist/web/primitives/record-steps.js +45 -0
  296. package/dist/web/primitives/record-summary.d.ts +3 -0
  297. package/dist/web/primitives/record-summary.js +18 -0
  298. package/dist/web/primitives/row-actions.d.ts +3 -1
  299. package/dist/web/primitives/row-actions.js +14 -5
  300. package/dist/web/primitives/segmented-select.js +5 -7
  301. package/dist/web/pwa/pwa-support.d.ts +4 -0
  302. package/dist/web/pwa/pwa-support.js +113 -0
  303. package/dist/web/sse/live-events.js +2 -2
  304. package/dist/web/tokens.js +0 -3
  305. package/dist/web/widgets/chart-parts.d.ts +7 -1
  306. package/dist/web/widgets/chart-parts.js +10 -4
  307. package/dist/web/widgets/collapsible-section.js +1 -1
  308. package/dist/web/widgets/dashboard-list-cards.d.ts +17 -0
  309. package/dist/web/widgets/dashboard-list-cards.js +54 -0
  310. package/dist/web/widgets/dashboard-list.d.ts +37 -5
  311. package/dist/web/widgets/dashboard-list.js +95 -20
  312. package/dist/web/widgets/drawer-sizing.js +1 -1
  313. package/dist/web/widgets/floating-panel.js +4 -2
  314. package/dist/web/widgets/index.d.ts +2 -0
  315. package/dist/web/widgets/index.js +2 -0
  316. package/dist/web/widgets/infinity-list.js +18 -11
  317. package/dist/web/widgets/preview-width-frame.d.ts +7 -0
  318. package/dist/web/widgets/preview-width-frame.js +10 -0
  319. package/dist/web/widgets/section-card.d.ts +1 -1
  320. package/dist/web/widgets/stacked-area-chrome.js +3 -3
  321. package/dist/web/widgets/stacked-area-tooltip.js +2 -10
  322. package/dist/web/widgets/stat-box-cell.d.ts +19 -0
  323. package/dist/web/widgets/stat-box-cell.js +10 -0
  324. package/dist/web/widgets/stat.d.ts +10 -1
  325. package/dist/web/widgets/stat.js +14 -5
  326. package/dist/web/widgets/status-badge.d.ts +7 -5
  327. package/dist/web/widgets/status-badge.js +2 -2
  328. package/dist/web/widgets/step-bar.d.ts +1 -1
  329. package/dist/web/widgets/step-bar.js +37 -7
  330. package/dist/web/widgets/upload-zone.d.ts +8 -1
  331. package/dist/web/widgets/upload-zone.js +13 -3
  332. package/package.json +5 -5
  333. package/src/changes.json +217 -0
  334. package/src/web/styles.css +9 -0
@@ -4,6 +4,8 @@ import { cn } from "../../lib/cn.js";
4
4
  import { TableHead } from "../../ui/table.js";
5
5
  import { FIT_CONTENT_CELL_CLASS } from "../data-table-cell.js";
6
6
  export const COMPACT_HEADER_CLASS = "text-xs font-semibold";
7
+ /** Small-caps look of column headers from sm up: 11px keeps dense tables inside 1280px. */
8
+ const SMALL_CAPS_HEADER_CLASS = "sm:text-[11px] sm:uppercase sm:tracking-[0.05em]";
7
9
  // SortableHeader: renders the th header per column, with or without
8
10
  // click-sort. Three paths:
9
11
  // (a) sortable=false OR no onSortChange -> plain label, no cursor
@@ -13,7 +15,7 @@ export const COMPACT_HEADER_CLASS = "text-xs font-semibold";
13
15
  // (c) sortable=true in the schema but no onSortChange prop -> still
14
16
  // label-only, but data-sortable=true stays so tests that know the
15
17
  // schema view keep working.
16
- export function SortableHeader({ field, label, sortable, highlighted, numeric, fitContent, compact, className, sort, onSortChange, style, columnField, trailing, }) {
18
+ export function SortableHeader({ field, label, sortable, highlighted, numeric, actionColumn, fitContent, compact, className, sort, onSortChange, style, columnField, trailing, }) {
17
19
  const active = sort?.field === field ? sort : undefined;
18
20
  const ariaSort = active?.dir === "asc" ? "ascending" : active?.dir === "desc" ? "descending" : "none";
19
21
  const cellExtras = {
@@ -21,13 +23,13 @@ export function SortableHeader({ field, label, sortable, highlighted, numeric, f
21
23
  ...(columnField !== undefined && { "data-column-field": columnField }),
22
24
  };
23
25
  if (!sortable || onSortChange === undefined) {
24
- return (_jsxs(TableHead, { "data-testid": `column-${field}`, "data-sortable": sortable === true ? true : undefined, "data-highlighted": highlighted === true ? "true" : undefined, className: cn("font-medium whitespace-normal text-muted-foreground", numeric === true && "text-right", fitContent === true && FIT_CONTENT_CELL_CLASS, highlighted === true && "bg-accent/40", trailing !== undefined && "group/header relative", compact === true && COMPACT_HEADER_CLASS, className), ...cellExtras, children: [label, trailing] }));
26
+ return (_jsxs(TableHead, { "data-testid": `column-${field}`, "data-sortable": sortable === true ? true : undefined, "data-highlighted": highlighted === true ? "true" : undefined, className: cn("font-medium whitespace-normal text-muted-foreground", SMALL_CAPS_HEADER_CLASS, numeric === true && "text-right", actionColumn === true && "sm:text-right", fitContent === true && FIT_CONTENT_CELL_CLASS, highlighted === true && "bg-accent/40", trailing !== undefined && "group/header relative", compact === true && COMPACT_HEADER_CLASS, className), ...cellExtras, children: [actionColumn === true ? _jsx("span", { className: "sm:sr-only", children: label }) : label, trailing] }));
25
27
  }
26
28
  const Icon = active?.dir === "asc" ? ArrowUp : active?.dir === "desc" ? ArrowDown : ArrowUpDown;
27
29
  const next = nextSortState(active?.dir, field);
28
30
  return (_jsxs(TableHead, { "data-testid": `column-${field}`, "data-sortable": "true", "data-highlighted": highlighted === true ? "true" : undefined, "aria-sort": ariaSort, className: cn(active !== undefined
29
31
  ? "font-semibold text-foreground"
30
- : "font-medium text-muted-foreground", "whitespace-normal", numeric === true && "text-right", fitContent === true && FIT_CONTENT_CELL_CLASS, highlighted === true && "bg-accent/40", trailing !== undefined && "group/header relative", compact === true && COMPACT_HEADER_CLASS, className), ...cellExtras, children: [_jsxs("button", { type: "button", onClick: () => onSortChange(next), className: cn("group/sort inline-flex h-8 items-center gap-1.5 rounded-sm px-2 -mx-2 text-sm [font-weight:inherit]", "hover:bg-accent hover:text-accent-foreground", "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", active !== undefined && "text-foreground", compact === true && "text-xs"), children: [_jsx("span", { children: label }), _jsx(Icon, { "data-sort-icon": active === undefined ? "idle" : "active", className: cn("size-3.5", active === undefined &&
32
+ : "font-medium text-muted-foreground", "whitespace-normal", SMALL_CAPS_HEADER_CLASS, numeric === true && "text-right", fitContent === true && FIT_CONTENT_CELL_CLASS, highlighted === true && "bg-accent/40", trailing !== undefined && "group/header relative", compact === true && COMPACT_HEADER_CLASS, className), ...cellExtras, children: [_jsxs("button", { type: "button", onClick: () => onSortChange(next), className: cn("group/sort inline-flex h-8 items-center gap-1.5 rounded-sm px-2 -mx-2 text-sm [font-weight:inherit]", SMALL_CAPS_HEADER_CLASS, "hover:bg-accent hover:text-accent-foreground", "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", active !== undefined && "text-foreground", compact === true && "text-xs"), children: [_jsx("span", { children: label }), _jsx(Icon, { "data-sort-icon": active === undefined ? "idle" : "active", className: cn("size-3.5", active === undefined &&
31
33
  "opacity-0 group-hover/sort:opacity-40 group-focus-visible/sort:opacity-40"), "aria-hidden": "true" })] }), trailing] }));
32
34
  }
33
35
  // 3-state toggle: no sort -> asc -> desc -> no sort. Idiomatic for
@@ -1,3 +1,3 @@
1
- import { type ReactNode } from "react";
1
+ import type { ReactNode } from "react";
2
2
  import type { DataTableModel } from "./use-data-table-state.ts";
3
3
  export declare function renderTableBody(m: DataTableModel): ReactNode;
@@ -1,8 +1,8 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Fragment } from "react";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
2
  import { cn } from "../../lib/cn.js";
4
3
  import { TableBody, TableCell, TableRow } from "../../ui/table.js";
5
4
  import { rowToneClass } from "../data-table-cell.js";
5
+ import { HintReasonRowScope, hintReasonOf } from "../hint-reason-row.js";
6
6
  import { RowActionsCell } from "../row-actions.js";
7
7
  import { ActionsBodyCell } from "./actions-column.js";
8
8
  import { bandClassName, bandReactKey, bandTestId } from "./group-band.js";
@@ -25,7 +25,9 @@ function renderDataRow(m, row) {
25
25
  const openRow = m.rowOpener(row);
26
26
  const opensOnClick = openRow !== undefined;
27
27
  const keyboard = m.keyboardRow(row.id, openRow);
28
- return (_jsxs(Fragment, { children: [_jsxs(TableRow, { "data-testid": m.rowTestId(row), "data-tone": rowTone?.(row), onClick: openRow, className: cn(rowToneClass(rowTone?.(row)), opensOnClick && "cursor-pointer", m.fillsHeight && "h-10 border-border-row hover:bg-muted", density.row, keyboard.className), ...keyboard.props, children: [m.selection.bodyCell(row, m.pins.bodyCell(SELECT_COLUMN_KEY)), m.expansion !== undefined && renderExpandCell(m, row), m.columns.map((col, colIndex) => renderDataCell(m, row, col, colIndex, opensOnClick)), m.hasTableActions && tableActions !== undefined && renderActionsCell(m, row, tableActions)] }), renderExpansion(m, row, "row", m.fullColSpan)] }, row.id));
28
+ const reasonHint = m.columns.find((col) => col.hint !== undefined && hintReasonOf(col.hint, row.values) !== undefined)?.hint;
29
+ const rowElements = (_jsxs(_Fragment, { children: [_jsxs(TableRow, { "data-testid": m.rowTestId(row), "data-tone": rowTone?.(row), onClick: openRow, className: cn(rowToneClass(rowTone?.(row)), opensOnClick && "cursor-pointer", "[&:has(+[data-reason-row])]:border-b-0", m.fillsHeight && "h-10 border-border-row hover:bg-muted", density.row, keyboard.className), ...keyboard.props, children: [m.selection.bodyCell(row, m.pins.bodyCell(SELECT_COLUMN_KEY)), m.expansion !== undefined && renderExpandCell(m, row), m.columns.map((col, colIndex) => renderDataCell(m, row, col, colIndex, opensOnClick)), m.hasTableActions && tableActions !== undefined && renderActionsCell(m, row, tableActions)] }), renderExpansion(m, row, "row", m.fullColSpan)] }));
30
+ return (_jsx(HintReasonRowScope, { hint: reasonHint, row: row.values, renderBoxRow: (box) => (_jsx(TableRow, { "data-testid": `${m.rowTestId(row)}-reason`, "data-reason-row": "true", children: _jsx(TableCell, { colSpan: m.fullColSpan, children: box }) })), children: rowElements }, row.id));
29
31
  }
30
32
  export function renderTableBody(m) {
31
33
  return (_jsx(TableBody, { children: m.tableItems.map((item) => item.kind === "row" ? renderDataRow(m, item.row) : renderBandRow(m, item)) }));
@@ -14,7 +14,9 @@ export function FlushTable({ className, ...props }) {
14
14
  // in SortableHeader: a `[&_th]:font-*` rule here would outrank it.
15
15
  // Child selectors only: an expanded row nests a whole table inside a cell, and
16
16
  // descendant selectors would make its header sticky and re-pad its cells.
17
- export const FILL_TABLE_CLASS = cn("[&>thead>tr>th]:sticky [&>thead>tr>th]:top-0 [&>thead>tr>th]:z-10 [&>thead>tr>th]:h-9 [&>thead>tr>th]:bg-muted [&>thead>tr>th]:px-2 [&>thead>tr>th]:text-[13px]", "[&>thead>tr>th]:shadow-[inset_0_-1px_0_var(--color-border)] [&>thead>tr>th_button]:text-[13px] [&>tbody>tr>td]:px-2 [&>tbody>tr>td]:py-0", "[&>*>tr>:first-child]:pl-6 [&>*>tr>:last-child]:pr-6");
17
+ export const FILL_TABLE_CLASS = cn("[&>thead>tr>th]:sticky [&>thead>tr>th]:top-0 [&>thead>tr>th]:z-10 [&>thead>tr>th]:h-9 [&>thead>tr>th]:bg-muted [&>thead>tr>th]:px-2 [&>thead>tr>th]:text-[13px]", "[&>thead>tr>th]:shadow-[inset_0_-1px_0_var(--color-border)] [&>thead>tr>th_button]:text-[13px] [&>tbody>tr>td]:px-2 [&>tbody>tr>td]:py-0",
18
+ // The small-caps header size of SortableHeader; the child selectors above would outrank it.
19
+ "sm:[&>thead>tr>th]:text-[11px] sm:[&>thead>tr>th_button]:text-[11px]", "[&>*>tr>:first-child]:pl-6 [&>*>tr>:last-child]:pr-6");
18
20
  // `!`: beats the first/last-child padding of FILL_TABLE_CLASS, which would
19
21
  // otherwise widen the narrow toggle column / pad the full-width expansion cell.
20
22
  // The nested table's sticky actions cell (last td) gets the muted surface
@@ -1,5 +1,7 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "../../lib/cn.js";
2
3
  import { InfiniteSentinel, Pager } from "../pager.js";
4
+ import { CARD_SURFACE_CLASS, isInsideCardFrame } from "./card-frame.js";
3
5
  import { renderCardsView } from "./card-view.js";
4
6
  import { renderEmptyBlock } from "./row-render-parts.js";
5
7
  import { DataTableFooter } from "./table-footer.js";
@@ -12,7 +14,7 @@ function renderPager(m) {
12
14
  const { pager, serverGroups, itemNoun, testId } = m;
13
15
  if (pager === undefined || !(pager.total > 0) || serverGroups !== undefined)
14
16
  return undefined;
15
- return (_jsx(Pager, { page: pager.page, limit: pager.limit, total: pager.total, onPageChange: pager.onPageChange, ...(pager.pageSizeOptions !== undefined && { pageSizeOptions: pager.pageSizeOptions }), ...(pager.onPageSizeChange !== undefined && { onPageSizeChange: pager.onPageSizeChange }), ...(itemNoun !== undefined && { itemNoun }), testId: testId !== undefined ? `${testId}-pager` : "render-list-pager", pinned: m.fillsHeight }));
17
+ return (_jsx(Pager, { page: pager.page, limit: pager.limit, total: pager.total, onPageChange: pager.onPageChange, ...(pager.pageSizeOptions !== undefined && { pageSizeOptions: pager.pageSizeOptions }), ...(pager.onPageSizeChange !== undefined && { onPageSizeChange: pager.onPageSizeChange }), ...(itemNoun !== undefined && { itemNoun }), testId: testId !== undefined ? `${testId}-pager` : "render-list-pager", pinned: m.fillsHeight || isInsideCardFrame(m) }));
16
18
  }
17
19
  function renderSentinel(m, pagerElement) {
18
20
  const { onReachEnd, serverGroups, testId } = m;
@@ -31,11 +33,14 @@ export function renderTableContent(m) {
31
33
  const tableContent = renderTableBodyContent(m);
32
34
  const pagerElement = renderPager(m);
33
35
  const sentinelElement = renderSentinel(m, pagerElement);
36
+ const framed = isInsideCardFrame(m);
34
37
  // With scrollBody the footer (pager, else the entry count) sits OUTSIDE the
35
38
  // scroll surface so it stays put at any row count; the infinite sentinel
36
39
  // stays INSIDE, or it would never intersect the scrollport.
37
- if (!m.fillsHeight) {
38
- return (_jsxs(_Fragment, { children: [m.selection.bar, tableContent, pagerElement, sentinelElement] }));
39
- }
40
- return (_jsxs(_Fragment, { children: [m.selection.bar, _jsxs("div", { "data-testid": testId !== undefined ? `${testId}-scroll` : "render-list-scroll", className: "min-h-0 flex-1 overflow-auto border-t border-border bg-card", children: [tableContent, sentinelElement] }), pagerElement ?? (_jsx(DataTableFooter, { count: serverGroups?.totalCount ?? m.rows.length, ...(itemNoun !== undefined && { itemNoun }), testId: testId !== undefined ? `${testId}-footer` : "render-list-footer" }))] }));
40
+ const content = m.fillsHeight ? (_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-scroll` : "render-list-scroll", className: cn("min-h-0 flex-1 overflow-auto bg-card", !framed && "border-t border-border"), children: [tableContent, sentinelElement] })) : (_jsxs(_Fragment, { children: [tableContent, sentinelElement] }));
41
+ const footer = pagerElement ??
42
+ (m.fillsHeight ? (_jsx(DataTableFooter, { count: serverGroups?.totalCount ?? m.rows.length, ...(itemNoun !== undefined && { itemNoun }), testId: testId !== undefined ? `${testId}-footer` : "render-list-footer" })) : undefined);
43
+ // Frame card: content and footer share one bordered card. A fill-height card is as tall as
44
+ // its rows and shrinks into the scroll container; the 24px sides match the toolbar's inset.
45
+ return (_jsxs(_Fragment, { children: [m.selection.bar, framed ? (_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-frame` : "render-list-frame", className: cn(CARD_SURFACE_CLASS, "overflow-hidden", m.fillsHeight && "mx-6 mb-6 flex min-h-0 flex-col"), children: [content, footer] })) : (_jsxs(_Fragment, { children: [content, footer] }))] }));
41
46
  }
@@ -3,6 +3,8 @@ import { cn } from "../../lib/cn.js";
3
3
  import { TableCell } from "../../ui/table.js";
4
4
  import { cellLinkProp, cellTitle, DataTableCell, FIT_CONTENT_CELL_CLASS, FirstCellLink, isEmptyCellValue, NUMERIC_COLUMN_TYPES, TABULAR_COLUMN_TYPES, } from "../data-table-cell.js";
5
5
  import { columnCellPresentationProps } from "./data-cell-props.js";
6
+ import { hintColumnWidthStyle } from "./hint-column-width.js";
7
+ import { isRowActionColumn } from "./row-action-column.js";
6
8
  // Text wraps instead of truncating: nowrap cells keep their
7
9
  // full width, so a wide table scrolled sideways and its
8
10
  // last column slid under the sticky actions column with
@@ -28,6 +30,9 @@ function isDateColumn(col) {
28
30
  function autoLayoutCellClassName(m, col, colIndex) {
29
31
  if (m.sizing !== undefined && isDateColumn(col))
30
32
  return "whitespace-nowrap";
33
+ // max-w-xs would cap a hint column that states a wider width.
34
+ if (col.hint !== undefined && col.width !== undefined)
35
+ return "whitespace-normal break-words";
31
36
  return colIndex === 0 && m.sizing !== undefined
32
37
  ? "whitespace-normal [overflow-wrap:anywhere]"
33
38
  : "max-w-xs whitespace-normal break-words";
@@ -37,15 +42,16 @@ function dataCellClassName(m, col, colIndex, pinClassName) {
37
42
  ? m.sizing?.fixed === true
38
43
  ? "overflow-hidden whitespace-normal break-words"
39
44
  : autoLayoutCellClassName(m, col, colIndex)
40
- : FIT_CONTENT_CELL_CLASS, colIndex === 0 ? "font-medium text-foreground" : "text-foreground-secondary", NUMERIC_COLUMN_TYPES.has(col.type) && "text-right", TABULAR_COLUMN_TYPES.has(col.type) && "tabular-nums", col.highlighted === true && "bg-accent/40", m.density.cell, pinClassName);
45
+ : FIT_CONTENT_CELL_CLASS, colIndex === 0 ? "font-medium text-foreground" : "text-foreground-secondary", NUMERIC_COLUMN_TYPES.has(col.type) && "text-right", isRowActionColumn(col) && "sm:text-right", TABULAR_COLUMN_TYPES.has(col.type) && "tabular-nums", col.highlighted === true && "bg-accent/40", m.density.cell, pinClassName);
41
46
  }
42
47
  export function renderDataCell(m, row, col, colIndex, opensOnClick) {
43
48
  const { getCellTestId, onCellChange, onRowClick, tableTranslate, tableLocale } = m;
44
49
  const bodyPin = m.pins.bodyCell(col.field);
45
50
  const linksFirstCell = colIndex === 0 && opensOnClick && onCellChange === undefined;
46
- return (_jsx(TableCell, { "data-testid": getCellTestId?.(row, col.field) ?? `cell-${row.id}-${col.field}`, "data-highlighted": col.highlighted === true ? "true" : undefined, className: dataCellClassName(m, col, colIndex, bodyPin.className), style: bodyPin.style, title: cellTitle(row.values[col.field]), children: _jsx(FirstCellLink, { enabled: linksFirstCell, onOpen: () => onRowClick?.(row), empty: isEmptyCellValue(row.values[col.field]), emptyLabel: m.rowClickLabel, children: _jsx(DataTableCell, { value: row.values[col.field], row: row.values, field: col.field, type: col.type, renderer: col.renderer, translate: tableTranslate, locale: tableLocale, ...columnCellPresentationProps(col), ...(col.fileDisplay !== undefined && {
51
+ const wrapsCellInOpener = linksFirstCell && col.hint === undefined;
52
+ return (_jsx(TableCell, { "data-testid": getCellTestId?.(row, col.field) ?? `cell-${row.id}-${col.field}`, "data-highlighted": col.highlighted === true ? "true" : undefined, className: dataCellClassName(m, col, colIndex, bodyPin.className), style: { ...bodyPin.style, ...hintColumnWidthStyle(col, m.sizing !== undefined) }, title: cellTitle(row.values[col.field]), children: _jsx(FirstCellLink, { enabled: wrapsCellInOpener, onOpen: () => onRowClick?.(row), empty: col.hint === undefined && isEmptyCellValue(row.values[col.field]), emptyLabel: m.rowClickLabel, children: _jsx(DataTableCell, { value: row.values[col.field], row: row.values, field: col.field, type: col.type, renderer: col.renderer, translate: tableTranslate, locale: tableLocale, ...columnCellPresentationProps(col), ...(col.fileDisplay !== undefined && {
47
53
  fileDisplay: col.fileDisplay,
48
54
  }), ...(onCellChange !== undefined && {
49
55
  onChange: (value) => onCellChange(row.id, col.field, value),
50
- }), ...cellLinkProp(col, row, !linksFirstCell) }) }) }, col.field));
56
+ }), ...cellLinkProp(col, row, !linksFirstCell), ...(linksFirstCell && !wrapsCellInOpener && { onOpenRow: () => onRowClick?.(row) }) }) }) }, col.field));
51
57
  }
@@ -4,17 +4,20 @@ import { TableHead, TableHeader, TableRow } from "../../ui/table.js";
4
4
  import { NUMERIC_COLUMN_TYPES } from "../data-table-cell.js";
5
5
  import { ActionsHeaderCell } from "./actions-column.js";
6
6
  import { ColumnResizeHandle } from "./column-resize-handle.js";
7
+ import { COLUMN_ROLE_ATTRIBUTE } from "./column-role.js";
8
+ import { hintColumnWidthStyle } from "./hint-column-width.js";
9
+ import { isRowActionColumn } from "./row-action-column.js";
7
10
  import { SortableHeader } from "./sortable-header.js";
8
11
  import { EXPAND_TOGGLE_CELL_CLASS } from "./table-chrome.js";
9
12
  import { EXPAND_COLUMN_KEY, SELECT_COLUMN_KEY } from "./use-column-pins.js";
10
13
  function renderColumnHeader(m, col) {
11
14
  const { sizing, sort, onSortChange } = m;
12
15
  const headerPin = m.pins.headerCell(col.field);
13
- return (_jsx(SortableHeader, { field: col.field, label: col.label, sortable: col.sortable === true, highlighted: col.highlighted === true, numeric: NUMERIC_COLUMN_TYPES.has(col.type), fitContent: col.fileDisplay !== undefined, compact: m.compactHeader === true, className: cn(m.density.header, headerPin.className), style: headerPin.style, columnField: headerPin.columnField, trailing: sizing && _jsx(ColumnResizeHandle, { field: col.field, label: col.label, sizing: sizing }), ...(sort !== undefined && sort !== null && { sort }), ...(onSortChange !== undefined && { onSortChange }) }, col.field));
16
+ return (_jsx(SortableHeader, { field: col.field, label: col.label, sortable: col.sortable === true, highlighted: col.highlighted === true, numeric: NUMERIC_COLUMN_TYPES.has(col.type), actionColumn: isRowActionColumn(col), fitContent: col.fileDisplay !== undefined, compact: m.compactHeader === true, className: cn(m.density.header, headerPin.className), style: { ...headerPin.style, ...hintColumnWidthStyle(col, sizing !== undefined) }, columnField: headerPin.columnField, trailing: sizing && _jsx(ColumnResizeHandle, { field: col.field, label: col.label, sizing: sizing }), ...(sort !== undefined && sort !== null && { sort }), ...(onSortChange !== undefined && { onSortChange }) }, col.field));
14
17
  }
15
18
  function renderExpandHeaderCell(m) {
16
19
  const expandHeaderPin = m.pins.headerCell(EXPAND_COLUMN_KEY);
17
- return (_jsx(TableHead, { "data-testid": "column-expand", className: cn(EXPAND_TOGGLE_CELL_CLASS, expandHeaderPin.className), style: expandHeaderPin.style }));
20
+ return (_jsx(TableHead, { "data-testid": "column-expand", [COLUMN_ROLE_ATTRIBUTE]: "expand", className: cn(EXPAND_TOGGLE_CELL_CLASS, expandHeaderPin.className), style: expandHeaderPin.style }));
18
21
  }
19
22
  export function renderTableHeader(m) {
20
23
  return (_jsx(TableHeader, { className: "bg-muted", children: _jsxs(TableRow, { ref: m.headerRowRef, className: "hover:bg-transparent", children: [m.selection.headerCell(m.pins.headerCell(SELECT_COLUMN_KEY)), m.expansion !== undefined && renderExpandHeaderCell(m), m.columns.map((col) => renderColumnHeader(m, col)), m.hasTableActions && (_jsx(ActionsHeaderCell, { label: m.tableTranslate?.("kumiko.list.actions") ?? "Actions", style: m.pins.actionsHeaderStyle, absorbsLeftover: m.sizing?.fixed === true }))] }) }));
@@ -1,25 +1,39 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cn } from "../../lib/cn.js";
3
- import { Table } from "../../ui/table.js";
3
+ import { Table, TableFooter } from "../../ui/table.js";
4
+ import { isInsideCardFrame } from "./card-frame.js";
4
5
  import { ColumnWidthGroup } from "./column-resize-handle.js";
5
6
  import { renderTableBody } from "./table-body.js";
6
7
  import { FILL_TABLE_CLASS, FlushTable } from "./table-chrome.js";
7
8
  import { renderTableHeader } from "./table-header-row.js";
8
- import { TotalsFooterRow } from "./totals-footer.js";
9
+ import { SummaryFooterRow, TotalsFooterRow } from "./totals-footer.js";
9
10
  function renderColumnWidths(m) {
10
11
  const { sizing } = m;
11
12
  if (sizing === undefined || !sizing.fixed)
12
13
  return null;
13
14
  return (_jsx(ColumnWidthGroup, { fields: m.columns.map((col) => col.field), sizing: sizing, hasExpandColumn: m.expansion !== undefined, hasSelectColumn: m.selection.active, hasActionsColumn: m.hasTableActions }));
14
15
  }
16
+ function renderSummaryRow(m) {
17
+ if (m.summaryRow === undefined)
18
+ return null;
19
+ return (_jsx(SummaryFooterRow, { summary: m.summaryRow, colSpan: m.fullColSpan, cellClassName: m.density.cell, columns: m.columns, cellPin: m.pins.bodyCell, leadingCells: { select: m.selection.active, expand: m.expansion !== undefined }, actionsCell: m.hasTableActions ? { fillsHeight: m.fillsHeight } : undefined }));
20
+ }
15
21
  function renderTotalsRow(m) {
16
22
  const { totals } = m;
17
23
  if (totals === undefined)
18
24
  return null;
19
25
  return (_jsx(TotalsFooterRow, { totals: totals, columns: m.columns, cellPin: m.pins.bodyCell, leadingCells: { select: m.selection.active, expand: m.expansion !== undefined }, actionsCell: m.hasTableActions ? { fillsHeight: m.fillsHeight } : undefined, cellClassName: m.density.cell }));
20
26
  }
27
+ // Both rows share one tfoot; a second tfoot is invalid HTML.
28
+ function renderTableFooter(m) {
29
+ const summary = renderSummaryRow(m);
30
+ const totals = renderTotalsRow(m);
31
+ if (summary === null && totals === null)
32
+ return null;
33
+ return (_jsxs(TableFooter, { children: [summary, totals] }));
34
+ }
21
35
  export function renderTableView(m) {
22
36
  const { fillsHeight, chromeless, sizing, testId } = m;
23
37
  const TableRoot = fillsHeight ? FlushTable : Table;
24
- return (_jsx("div", { className: cn(!fillsHeight && "overflow-hidden", !fillsHeight && chromeless !== true && "rounded-lg border bg-card"), children: _jsxs(TableRoot, { "data-testid": testId, className: fillsHeight ? FILL_TABLE_CLASS : undefined, ...(sizing?.tableStyle !== undefined && { style: sizing.tableStyle }), children: [renderColumnWidths(m), renderTableHeader(m), renderTableBody(m), renderTotalsRow(m)] }) }));
38
+ return (_jsx("div", { className: cn(!fillsHeight && "overflow-hidden", !fillsHeight && chromeless !== true && !isInsideCardFrame(m) && "rounded-lg border bg-card"), children: _jsxs(TableRoot, { "data-testid": testId, className: fillsHeight ? FILL_TABLE_CLASS : undefined, ...(sizing?.tableStyle !== undefined && { style: sizing.tableStyle }), children: [renderColumnWidths(m), renderTableHeader(m), renderTableBody(m), renderTableFooter(m)] }) }));
25
39
  }
@@ -9,5 +9,5 @@ export function ToolbarEndCluster({ view, columnLabels, exportList, toolbarEnd,
9
9
  if (!toolbarEndHasContent(view, exportList, toolbarEnd))
10
10
  return null;
11
11
  const showsViewMenu = viewHasMenu(view);
12
- return (_jsxs("div", { className: "flex flex-wrap items-center gap-2 ml-auto", children: [showsViewMenu && _jsx(ViewMenu, { view: view, columnLabels: columnLabels }), exportList !== undefined && _jsx(ExportButton, { source: exportList }), toolbarEnd] }));
12
+ return (_jsxs("div", { className: "flex flex-wrap items-center gap-2 ml-auto", children: [showsViewMenu && (_jsx("div", { className: "max-sm:hidden", children: _jsx(ViewMenu, { view: view, columnLabels: columnLabels }) })), exportList !== undefined && (_jsx("div", { className: "max-sm:hidden", children: _jsx(ExportButton, { source: exportList }) })), toolbarEnd] }));
13
13
  }
@@ -4,6 +4,7 @@ import { UNIFORM_BAR_CONTROLS_CLASSES } from "../../layout/uniform-bar-controls.
4
4
  import { cn } from "../../lib/cn.js";
5
5
  import { Button as UiButton } from "../../ui/button.js";
6
6
  import { buildFacetCluster } from "./facet-cluster.js";
7
+ import { hasSortOptionsSelect, SortOptionsSelect } from "./sort-options-select.js";
7
8
  import { ToolbarEndCluster, toolbarEndHasContent } from "./toolbar-end-cluster.js";
8
9
  export function buildModelFacetCluster(m) {
9
10
  return buildFacetCluster({
@@ -18,13 +19,21 @@ export function buildModelFacetCluster(m) {
18
19
  resetAll: m.resetAll,
19
20
  notice: m.notice,
20
21
  dense: m.fillsHeight,
22
+ pills: m.narrowFacets === "pills" && m.belowSm,
21
23
  });
22
24
  }
23
25
  export function hasToolbarContent(m, facetCluster) {
24
26
  return (m.toolbarStart !== undefined ||
25
27
  facetCluster !== undefined ||
28
+ hasVisibleSortOptions(m) ||
26
29
  toolbarEndHasContent(m.view, m.exportList, m.toolbarEnd));
27
30
  }
31
+ // The toolbar select is max-md:hidden; below md the card sort bar owns sorting, so a toolbar
32
+ // holding only the hidden select would render an empty row.
33
+ function hasVisibleSortOptions(m) {
34
+ return (!(m.toolbarSort === true ? m.belowSm : m.isNarrow) &&
35
+ hasSortOptionsSelect(m.sortOptions, m.onSortChange));
36
+ }
28
37
  function toolbarClassName({ fillsHeight, isNarrow }) {
29
38
  if (!fillsHeight)
30
39
  return cn("flex flex-wrap items-center", UNIFORM_BAR_CONTROLS_CLASSES, "gap-3");
@@ -48,19 +57,38 @@ export function toolbarMergesDescription(m, facetCluster) {
48
57
  facetCluster === undefined &&
49
58
  toolbarEndHasContent(m.view, m.exportList, m.toolbarEnd));
50
59
  }
60
+ function renderSortOptions(m) {
61
+ const { sortOptions, onSortChange, testId } = m;
62
+ if (onSortChange === undefined || !hasSortOptionsSelect(sortOptions, onSortChange)) {
63
+ return null;
64
+ }
65
+ return (_jsx(SortOptionsSelect, { options: sortOptions, sort: m.sort, onSortChange: onSortChange, testId: testId !== undefined ? `${testId}-sort-options` : "render-list-sort-options", className: m.toolbarSort === true ? "max-sm:hidden" : "max-md:hidden", bordered: m.toolbarSort === true }));
66
+ }
67
+ function hasOnlySelectFacets(m) {
68
+ return ((m.filterFacets?.length ?? 0) > 0 &&
69
+ (m.dateRangeFacets?.length ?? 0) === 0 &&
70
+ (m.rangeFacets?.length ?? 0) === 0);
71
+ }
72
+ function renderFacetArea(m, facetCluster) {
73
+ if (!m.belowSm || facetCluster === undefined)
74
+ return facetCluster;
75
+ if (hasOnlySelectFacets(m)) {
76
+ return _jsx("div", { className: "flex w-full flex-wrap gap-2", children: facetCluster });
77
+ }
78
+ return m.fillsHeight ? renderFacetToggle(m, facetCluster) : facetCluster;
79
+ }
51
80
  export function renderToolbar(m, facetCluster) {
52
81
  const { testId, toolbarStart } = m;
53
- const collapsesFacetsBehindButton = m.isNarrow && m.fillsHeight && facetCluster !== undefined;
54
82
  const mergesDescription = toolbarMergesDescription(m, facetCluster);
55
83
  return (_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-toolbar` : "render-list-toolbar", className: cn(toolbarClassName(m), mergesDescription && "justify-between", mergesDescription && m.fillsHeight && !m.isNarrow && "md:py-2",
56
84
  // A dashboard panel head above has no inset; the toolbar shares its edges like the table below.
57
- m.fillsHeight && m.insideEmbeddedScreen && "px-0"), children: [mergesDescription && renderToolbarDescription(m, true, true), toolbarStart !== undefined && renderToolbarStart(m, toolbarStart), collapsesFacetsBehindButton ? renderFacetToggle(m, facetCluster) : facetCluster, _jsx(ToolbarEndCluster, { view: m.view, columnLabels: new Map(m.schemaColumns.map((col) => [col.field, col.label])), exportList: m.exportList, toolbarEnd: m.toolbarEnd })] }));
85
+ m.fillsHeight && m.insideEmbeddedScreen && "px-0"), children: [mergesDescription && renderToolbarDescription(m, true, true), toolbarStart !== undefined && renderToolbarStart(m, toolbarStart), renderFacetArea(m, facetCluster), renderSortOptions(m), _jsx(ToolbarEndCluster, { view: m.view, columnLabels: new Map(m.schemaColumns.map((col) => [col.field, col.label])), exportList: m.exportList, toolbarEnd: m.toolbarEnd })] }));
58
86
  }
59
87
  export function renderToolbarDescription(m, hasToolbar, inToolbarRow = false) {
60
88
  const { testId, toolbarDescription, fillsHeight, isNarrow } = m;
61
89
  if (toolbarDescription === undefined)
62
90
  return null;
63
- return (_jsx("p", { "data-testid": testId !== undefined ? `${testId}-description` : "render-list-description", className: cn("m-0 text-sm text-muted-foreground",
91
+ return (_jsx("p", { "data-testid": testId !== undefined ? `${testId}-description` : "render-list-description", className: cn("m-0 text-sm text-muted-foreground max-sm:hidden",
64
92
  // min-w-48 lets the actions wrap below the text instead of squeezing it.
65
93
  inToolbarRow ? "min-w-48 flex-1" : "pb-2", !inToolbarRow && fillsHeight && (isNarrow ? "px-3" : "px-6"), !inToolbarRow && fillsHeight && !hasToolbar && "pt-4"), children: toolbarDescription }));
66
94
  }
@@ -1,7 +1,27 @@
1
1
  import type { ReactNode } from "react";
2
2
  import type { DataTableTotals } from "../../../data-table-aggregate-types.ts";
3
+ import type { DataTableSummaryRow } from "../../../data-table-view-types.ts";
3
4
  import type { ListColumnViewModel } from "../../../headless/index.ts";
4
5
  import { type PinnedCellProps } from "./use-column-pins.ts";
6
+ /** Full-width row above the totals row, inside the same tfoot; the summary query's "label value · label value" pairs.
7
+ * When an item names a `column`, the row is drawn as table cells under their columns instead, without labels. */
8
+ export declare function SummaryFooterRow({ summary, colSpan, cellClassName, columns, cellPin, leadingCells, actionsCell, }: {
9
+ readonly summary: DataTableSummaryRow;
10
+ readonly colSpan: number;
11
+ readonly cellClassName?: string;
12
+ readonly columns: readonly ListColumnViewModel[];
13
+ readonly cellPin: (field: string) => PinnedCellProps;
14
+ readonly leadingCells: {
15
+ readonly select: boolean;
16
+ readonly expand: boolean;
17
+ };
18
+ readonly actionsCell: {
19
+ readonly fillsHeight: boolean;
20
+ } | undefined;
21
+ }): ReactNode;
22
+ export declare function SummaryCard({ summary }: {
23
+ readonly summary: DataTableSummaryRow;
24
+ }): ReactNode;
5
25
  /** Footer row under the table body, one cell per visible column. */
6
26
  export declare function TotalsFooterRow({ totals, columns, cellPin, leadingCells, actionsCell, cellClassName, }: {
7
27
  readonly totals: DataTableTotals;
@@ -1,9 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { uniqueLabelKeys } from "../../../app/unique-label-keys.js";
2
3
  import { useOptionalTranslation } from "../../../index.js";
3
4
  import { cn } from "../../lib/cn.js";
4
- import { TableCell, TableFooter, TableRow } from "../../ui/table.js";
5
+ import { TableCell, TableRow } from "../../ui/table.js";
5
6
  import { NUMERIC_COLUMN_TYPES } from "../data-table-cell.js";
6
7
  import { stickyActionsCellClass } from "./actions-column.js";
8
+ import { HINT_TONE_TEXT_CLASS } from "./hint-cell.js";
7
9
  import { MeasureValue, measureKindLabel, measureLabel } from "./measure-value.js";
8
10
  import { EXPAND_COLUMN_KEY, SELECT_COLUMN_KEY } from "./use-column-pins.js";
9
11
  function measuresOf(totals, field) {
@@ -26,17 +28,46 @@ function FooterMeasures({ measures, column, }) {
26
28
  }
27
29
  return (_jsx("span", { className: "inline-flex flex-col gap-0.5", children: measures.map((measure) => (_jsxs("span", { className: "inline-flex items-baseline justify-end gap-1.5", children: [_jsx("span", { className: "text-xs font-normal text-muted-foreground", children: measureKindLabel(measure.kind, translate) }), _jsx(MeasureValue, { measure: measure, column: column })] }, measure.kind))) }));
28
30
  }
31
+ function SummaryItems({ summary }) {
32
+ const keys = uniqueLabelKeys(summary.items.map((item) => item.label ?? String(item.value)));
33
+ return (_jsx("span", { className: "text-sm text-muted-foreground", children: summary.items.map((item, index) => (_jsxs("span", { "data-testid": "list-summary-item", children: [index > 0 && " · ", item.label !== undefined && `${item.label} `, _jsx("span", { className: cn("font-medium tabular-nums text-foreground", item.tone !== undefined && HINT_TONE_TEXT_CLASS[item.tone]), children: item.value })] }, keys[index]))) }));
34
+ }
35
+ function SummaryCellValues({ items }) {
36
+ return items.map((item) => (_jsx("span", { "data-testid": "list-summary-item", className: cn("me-2 font-medium tabular-nums text-foreground", item.tone !== undefined && HINT_TONE_TEXT_CLASS[item.tone]), children: item.value }, `${item.column ?? ""}-${item.label ?? ""}-${item.value}`)));
37
+ }
38
+ /** Full-width row above the totals row, inside the same tfoot; the summary query's "label value · label value" pairs.
39
+ * When an item names a `column`, the row is drawn as table cells under their columns instead, without labels. */
40
+ export function SummaryFooterRow({ summary, colSpan, cellClassName, columns, cellPin, leadingCells, actionsCell, }) {
41
+ if (summary.items.some((item) => item.column !== undefined) && columns.length > 0) {
42
+ const fields = new Set(columns.map((column) => column.field));
43
+ const firstField = columns[0]?.field;
44
+ // An item naming a column that is not shown lands in the first column instead of vanishing.
45
+ const columnOf = (item) => item.column !== undefined && fields.has(item.column) ? item.column : firstField;
46
+ return (_jsxs(TableRow, { "data-testid": "list-summary", className: "hover:bg-transparent", children: [leadingCellKeys(leadingCells).map((key) => {
47
+ const pin = cellPin(key);
48
+ return _jsx(TableCell, { className: pin.className, style: pin.style }, key);
49
+ }), columns.map((column) => {
50
+ const pin = cellPin(column.field);
51
+ const items = summary.items.filter((item) => columnOf(item) === column.field);
52
+ return (_jsx(TableCell, { "data-testid": `list-summary-${column.field}`, className: cn(NUMERIC_COLUMN_TYPES.has(column.type) && "text-right", cellClassName, pin.className), style: pin.style, children: _jsx(SummaryCellValues, { items: items }) }, column.field));
53
+ }), actionsCell !== undefined && (_jsx(TableCell, { className: stickyActionsCellClass(actionsCell.fillsHeight) }))] }));
54
+ }
55
+ return (_jsx(TableRow, { "data-testid": "list-summary", className: "hover:bg-transparent", children: _jsx(TableCell, { colSpan: colSpan, className: cn("text-left", cellClassName), children: _jsx(SummaryItems, { summary: summary }) }) }));
56
+ }
57
+ export function SummaryCard({ summary }) {
58
+ return (_jsx("div", { "data-testid": "list-summary", className: "border-b border-border-row bg-muted/50 px-4 py-3 text-left", children: _jsx(SummaryItems, { summary: summary }) }));
59
+ }
29
60
  /** Footer row under the table body, one cell per visible column. */
30
61
  export function TotalsFooterRow({ totals, columns, cellPin, leadingCells, actionsCell, cellClassName, }) {
31
62
  const translate = useOptionalTranslation();
32
- return (_jsx(TableFooter, { "data-testid": "list-totals", children: _jsxs(TableRow, { className: "hover:bg-transparent", children: [leadingCellKeys(leadingCells).map((key) => {
33
- const pin = cellPin(key);
34
- return (_jsx(TableCell, { "data-testid": `list-totals-${key}`, className: pin.className, style: pin.style }, key));
35
- }), columns.map((column, index) => {
36
- const measures = measuresOf(totals, column.field);
37
- const pin = cellPin(column.field);
38
- return (_jsx(TableCell, { "data-testid": `list-totals-${column.field}`, className: cn("tabular-nums", NUMERIC_COLUMN_TYPES.has(column.type) && "text-right", cellClassName, pin.className), style: pin.style, children: measures.length > 0 ? (_jsx(FooterMeasures, { measures: measures, column: column })) : index === 0 ? (totalsLabel(translate)) : null }, column.field));
39
- }), actionsCell !== undefined && (_jsx(TableCell, { className: stickyActionsCellClass(actionsCell.fillsHeight) }))] }) }));
63
+ return (_jsxs(TableRow, { "data-testid": "list-totals", className: "hover:bg-transparent", children: [leadingCellKeys(leadingCells).map((key) => {
64
+ const pin = cellPin(key);
65
+ return (_jsx(TableCell, { "data-testid": `list-totals-${key}`, className: pin.className, style: pin.style }, key));
66
+ }), columns.map((column, index) => {
67
+ const measures = measuresOf(totals, column.field);
68
+ const pin = cellPin(column.field);
69
+ return (_jsx(TableCell, { "data-testid": `list-totals-${column.field}`, className: cn("tabular-nums", NUMERIC_COLUMN_TYPES.has(column.type) && "text-right", cellClassName, pin.className), style: pin.style, children: measures.length > 0 ? (_jsx(FooterMeasures, { measures: measures, column: column })) : index === 0 ? (totalsLabel(translate)) : null }, column.field));
70
+ }), actionsCell !== undefined && (_jsx(TableCell, { className: stickyActionsCellClass(actionsCell.fillsHeight) }))] }));
40
71
  }
41
72
  /** Card layout: the totals as a labelled list under the cards. */
42
73
  export function TotalsCard({ totals, columnOf, }) {
@@ -7,6 +7,7 @@ import { Checkbox } from "../../ui/checkbox.js";
7
7
  import { TableCell, TableHead } from "../../ui/table.js";
8
8
  import { cellTitle } from "../data-table-cell.js";
9
9
  import { BulkSelectionBar } from "./bulk-selection-bar.js";
10
+ import { COLUMN_ROLE_ATTRIBUTE } from "./column-role.js";
10
11
  import { EXPAND_TOGGLE_CELL_CLASS } from "./table-chrome.js";
11
12
  import { useRowSelection } from "./use-row-selection.js";
12
13
  const INACTIVE = {
@@ -55,7 +56,7 @@ export function useBulkSelection({ bulk, rows, titleField, rowTestId, flush, })
55
56
  void execute(action);
56
57
  }, onConfirm: (action) => void execute(action), onConfirmClose: () => setPendingAction(undefined), onCancel: run.cancel, onClear: selection.clear, onDismissResult: run.dismissResult })),
57
58
  onKeyboardSelect: isRunning ? undefined : selection.toggle,
58
- headerCell: (pin) => (_jsx(TableHead, { "data-testid": "column-select", className: cn(EXPAND_TOGGLE_CELL_CLASS, "text-center", pin.className), style: pin.style, children: _jsx(Checkbox, { checked: selection.allState === "all"
59
+ headerCell: (pin) => (_jsx(TableHead, { "data-testid": "column-select", [COLUMN_ROLE_ATTRIBUTE]: "select", className: cn(EXPAND_TOGGLE_CELL_CLASS, "text-center", pin.className), style: pin.style, children: _jsx(Checkbox, { checked: selection.allState === "all"
59
60
  ? true
60
61
  : selection.allState === "some"
61
62
  ? "indeterminate"
@@ -48,6 +48,10 @@ function placePins(columns, pinOfField, measured, leading, hasActionsColumn) {
48
48
  function pinnedStyle(placement, part, fillsHeight) {
49
49
  const edgeLine = placement.side === "left" ? "inset -1px 0 0" : "inset 1px 0 0";
50
50
  const shadows = [];
51
+ // Keeps the row-tone stripe: this inline box-shadow would replace the class-based one.
52
+ if (part === "body" && placement.side === "left") {
53
+ shadows.push("inset 3px 0 0 var(--row-stripe, transparent)");
54
+ }
51
55
  if (placement.onInnerEdge)
52
56
  shadows.push(`${edgeLine} var(--color-border)`);
53
57
  if (part === "header" && fillsHeight)
@@ -18,6 +18,7 @@ export type DataTableModel = Omit<DataTableProps, "columns"> & {
18
18
  readonly tableTranslate: ReturnType<typeof useOptionalTranslation>;
19
19
  readonly tableLocale: ReturnType<typeof useOptionalLocale>;
20
20
  readonly isNarrow: boolean;
21
+ readonly belowSm: boolean;
21
22
  readonly density: ReturnType<typeof densityClasses>;
22
23
  readonly facetsOpenNarrow: boolean;
23
24
  readonly setFacetsOpenNarrow: Dispatch<SetStateAction<boolean>>;
@@ -1,7 +1,7 @@
1
- import { useId, useState } from "react";
1
+ import { useId, useMemo, useState } from "react";
2
2
  import { useIsEmbeddedScreen } from "../../../context/embedded-screen-context.js";
3
3
  import { useOptionalLocale, useOptionalTranslation } from "../../../index.js";
4
- import { useIsNarrowViewport } from "../use-narrow-viewport.js";
4
+ import { useIsBelowSmViewport, useIsNarrowViewport } from "../use-narrow-viewport.js";
5
5
  import { isPinningActive, isResizingActive } from "./column-layout-mode.js";
6
6
  import { densityClasses } from "./density.js";
7
7
  import { buildDataTableItems } from "./group-band.js";
@@ -14,8 +14,9 @@ import { useViewColumns } from "./use-view-columns.js";
14
14
  function resolveRowActions({ rowActions, onRowClick, rowActionMode, onCellChange, }) {
15
15
  // The row click already runs rowClick actions, so with a clickable row they
16
16
  // must not reappear in the kebab (a list whose only action is the rowClick
17
- // one gets no actions column at all).
18
- const menuActions = rowActions !== undefined && onRowClick !== undefined
17
+ // one gets no actions column at all). "menu" mode is the exception: every row
18
+ // shows the kebab, and the opener is one of its entries.
19
+ const menuActions = rowActions !== undefined && onRowClick !== undefined && rowActionMode !== "menu"
19
20
  ? rowActions.filter((action) => action.rowClick !== true)
20
21
  : rowActions;
21
22
  // The table keeps every action in "inline" mode, and with editable cells the
@@ -36,7 +37,7 @@ function isEmptyTable({ rows, serverGroups }) {
36
37
  return rows.length === 0 && (serverGroups?.groups.length ?? 0) === 0;
37
38
  }
38
39
  export function useDataTableState(props) {
39
- const { columns: schemaColumns, rows, view, scrollBody, serverGroups, bulk, getRowTestId, } = props;
40
+ const { columns: allColumns, rows, view, scrollBody, serverGroups, bulk, getRowTestId } = props;
40
41
  // One locale/translate subscription per table — not per cell.
41
42
  // Optional hooks: a bare DataTable outside LocaleProvider must not crash.
42
43
  const tableTranslate = useOptionalTranslation();
@@ -45,6 +46,8 @@ export function useDataTableState(props) {
45
46
  // affordance. Cards replace the table entirely below the breakpoint — same
46
47
  // single-mount pattern as EmbeddedListInput/embedded-list-input.tsx.
47
48
  const isNarrow = useIsNarrowViewport();
49
+ const belowSm = useIsBelowSmViewport();
50
+ const schemaColumns = useMemo(() => (isNarrow ? allColumns : allColumns.filter((col) => col.showOnNarrowOnly !== true)), [allColumns, isNarrow]);
48
51
  const viewColumns = useViewColumns(schemaColumns, view, isNarrow);
49
52
  const density = densityClasses(view, scrollBody === true);
50
53
  const [facetsOpenNarrow, setFacetsOpenNarrow] = useState(false);
@@ -100,6 +103,7 @@ export function useDataTableState(props) {
100
103
  tableTranslate,
101
104
  tableLocale,
102
105
  isNarrow,
106
+ belowSm,
103
107
  density,
104
108
  facetsOpenNarrow,
105
109
  setFacetsOpenNarrow,
@@ -1,5 +1,6 @@
1
1
  import { useLayoutEffect, useRef, useState } from "react";
2
2
  import { ACTIONS_CONTENT_ATTRIBUTE } from "./actions-column.js";
3
+ import { COLUMN_ROLE_ATTRIBUTE } from "./column-role.js";
3
4
  export const COLUMN_FIELD_ATTRIBUTE = "data-column-field";
4
5
  export const EXPAND_COLUMN_WIDTH_PX = 40;
5
6
  export const SELECT_COLUMN_WIDTH_PX = 40;
@@ -37,14 +38,14 @@ function measureHeaderRow(headerRow) {
37
38
  let actions = 0;
38
39
  for (const cell of headerRow.children) {
39
40
  const field = cell.getAttribute(COLUMN_FIELD_ATTRIBUTE);
40
- const testId = cell.getAttribute("data-testid");
41
+ const role = cell.getAttribute(COLUMN_ROLE_ATTRIBUTE);
41
42
  if (field !== null)
42
43
  fields[field] = widthOfElement(cell);
43
- else if (testId === "column-select")
44
+ else if (role === "select")
44
45
  select = widthOfElement(cell);
45
- else if (testId === "column-expand")
46
+ else if (role === "expand")
46
47
  expand = widthOfElement(cell);
47
- else if (testId === "column-actions")
48
+ else if (role === "actions")
48
49
  actions = naturalActionsWidth(headerRow, cell);
49
50
  }
50
51
  return { fields, select, expand, actions };
@@ -1,5 +1,5 @@
1
1
  import { MAX_BULK_SELECTION } from "@cosmicdrift/kumiko-framework/ui-types";
2
- import { useCallback, useEffect, useMemo, useState } from "react";
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
3
  const NOTHING_SELECTED = new Set();
4
4
  function retained(previous, keep) {
5
5
  const next = new Set([...previous].filter(keep));
@@ -8,37 +8,48 @@ function retained(previous, keep) {
8
8
  /** Checkbox selection over the loaded rows, capped at MAX_BULK_SELECTION. Rows that leave the list leave the selection. */
9
9
  export function useRowSelection(rows) {
10
10
  const [selectedIds, setSelectedIds] = useState(NOTHING_SELECTED);
11
+ // Set by retainOnly: the reload that follows may pass through an empty list that must not drop the retained rows.
12
+ const awaitingReload = useRef(false);
13
+ const loadedIds = useMemo(() => new Set(rows.map((row) => row.id)), [rows]);
11
14
  useEffect(() => {
12
- // skip: an empty list is the reload gap between two fetches; pruning then would drop the failed rows a run keeps selected
13
- if (rows.length === 0)
15
+ // skip: the pending reload may pass through an empty list; keep the retained rows
16
+ if (rows.length === 0 && awaitingReload.current)
14
17
  return;
15
- const loaded = new Set(rows.map((row) => row.id));
16
- setSelectedIds((previous) => retained(previous, (id) => loaded.has(id)));
17
- }, [rows]);
18
+ awaitingReload.current = false;
19
+ setSelectedIds((previous) => retained(previous, (id) => loadedIds.has(id)));
20
+ }, [rows, loadedIds]);
18
21
  const selectedRows = useMemo(() => rows.filter((row) => selectedIds.has(row.id)), [rows, selectedIds]);
19
22
  const selectableCount = Math.min(rows.length, MAX_BULK_SELECTION);
20
23
  const allState = selectedRows.length === 0 ? "none" : selectedRows.length >= selectableCount ? "all" : "some";
21
24
  const toggle = useCallback((rowId) => {
25
+ awaitingReload.current = false;
22
26
  setSelectedIds((previous) => {
23
27
  const next = new Set(previous);
24
28
  if (next.has(rowId))
25
29
  next.delete(rowId);
26
- else if (next.size < MAX_BULK_SELECTION)
30
+ else if (retained(previous, (id) => loadedIds.has(id)).size < MAX_BULK_SELECTION)
27
31
  next.add(rowId);
28
32
  return next;
29
33
  });
30
- }, []);
34
+ }, [loadedIds]);
31
35
  const toggleAll = useCallback(() => {
36
+ awaitingReload.current = false;
32
37
  setSelectedIds(allState === "all"
33
38
  ? NOTHING_SELECTED
34
39
  : new Set(rows.slice(0, MAX_BULK_SELECTION).map((row) => row.id)));
35
40
  }, [allState, rows]);
36
- const retainOnly = useCallback((rowIds) => setSelectedIds((previous) => retained(previous, (id) => rowIds.has(id))), []);
37
- const clear = useCallback(() => setSelectedIds(NOTHING_SELECTED), []);
41
+ const retainOnly = useCallback((rowIds) => {
42
+ awaitingReload.current = rowIds.size > 0;
43
+ setSelectedIds((previous) => retained(previous, (id) => rowIds.has(id)));
44
+ }, []);
45
+ const clear = useCallback(() => {
46
+ awaitingReload.current = false;
47
+ setSelectedIds(NOTHING_SELECTED);
48
+ }, []);
38
49
  return {
39
50
  selectedRows,
40
51
  isSelected: (rowId) => selectedIds.has(rowId),
41
- isFull: selectedIds.size >= MAX_BULK_SELECTION,
52
+ isFull: selectedRows.length >= MAX_BULK_SELECTION,
42
53
  allState,
43
54
  toggle,
44
55
  toggleAll,