@cosmicdrift/kumiko-renderer 0.413.0 → 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 (339) 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/form-pending-uploads.d.ts +8 -0
  65. package/dist/components/form-pending-uploads.js +27 -0
  66. package/dist/components/list-empty-state.d.ts +8 -1
  67. package/dist/components/list-empty-state.js +4 -1
  68. package/dist/components/list-group-page-bridges.d.ts +1 -1
  69. package/dist/components/list-group-page-bridges.js +2 -2
  70. package/dist/components/related-list-section.js +4 -22
  71. package/dist/components/render-edit-action-button.d.ts +3 -1
  72. package/dist/components/render-edit-action-button.js +5 -3
  73. package/dist/components/render-edit-form-actions.js +6 -3
  74. package/dist/components/render-edit-layout.js +2 -1
  75. package/dist/components/render-edit-render-model.d.ts +2 -2
  76. package/dist/components/render-edit-submit.js +2 -1
  77. package/dist/components/render-edit-types.d.ts +4 -2
  78. package/dist/components/render-edit.js +3 -1
  79. package/dist/components/render-list-hint-columns.d.ts +8 -0
  80. package/dist/components/render-list-hint-columns.js +77 -0
  81. package/dist/components/render-list-reference-columns.js +4 -2
  82. package/dist/components/render-list-row-tone.d.ts +3 -0
  83. package/dist/components/render-list-row-tone.js +10 -0
  84. package/dist/components/render-list-table-props.d.ts +9 -1
  85. package/dist/components/render-list-table-props.js +4 -1
  86. package/dist/components/render-list-toolbar-action.d.ts +1 -2
  87. package/dist/components/render-list-toolbar-model.d.ts +3 -0
  88. package/dist/components/render-list-toolbar-model.js +21 -6
  89. package/dist/components/render-list-toolbar.d.ts +3 -2
  90. package/dist/components/render-list-toolbar.js +8 -6
  91. package/dist/components/render-list-types.d.ts +6 -1
  92. package/dist/components/render-list.js +26 -7
  93. package/dist/components/use-render-edit-controlled-sync.js +5 -4
  94. package/dist/components/use-render-edit-draft-save.js +7 -9
  95. package/dist/components/use-render-edit-schema.d.ts +3 -0
  96. package/dist/components/use-render-edit-schema.js +15 -0
  97. package/dist/components/use-render-edit-state.d.ts +4 -0
  98. package/dist/components/use-render-edit-state.js +9 -1
  99. package/dist/components/use-render-edit-steps.js +2 -3
  100. package/dist/components/use-render-list-columns.d.ts +3 -1
  101. package/dist/components/use-render-list-columns.js +22 -10
  102. package/dist/context/screen-focus-context.d.ts +14 -0
  103. package/dist/context/screen-focus-context.js +28 -0
  104. package/dist/data-table-facet-types.d.ts +2 -0
  105. package/dist/data-table-view-types.d.ts +20 -1
  106. package/dist/headless/form/form-controller.js +3 -1
  107. package/dist/headless/form/zod-bridge.d.ts +7 -1
  108. package/dist/headless/form/zod-bridge.js +10 -0
  109. package/dist/headless/index.d.ts +2 -1
  110. package/dist/headless/index.js +1 -0
  111. package/dist/headless/pwa-service-worker-meta.d.ts +1 -0
  112. package/dist/headless/pwa-service-worker-meta.js +3 -0
  113. package/dist/headless/view-model/index.d.ts +1 -1
  114. package/dist/headless/view-model/list-file-display.js +3 -2
  115. package/dist/headless/view-model/list.js +16 -0
  116. package/dist/headless/view-model/types.d.ts +33 -0
  117. package/dist/hooks/list-column-layout.js +2 -1
  118. package/dist/hooks/list-server-groups.js +14 -1
  119. package/dist/hooks/list-state-schema.d.ts +1 -0
  120. package/dist/hooks/list-state-schema.js +9 -1
  121. package/dist/hooks/use-debounced-value.d.ts +1 -0
  122. package/dist/hooks/use-debounced-value.js +11 -0
  123. package/dist/hooks/use-list-aggregates.d.ts +5 -1
  124. package/dist/hooks/use-list-aggregates.js +9 -5
  125. package/dist/hooks/use-list-table.d.ts +2 -1
  126. package/dist/hooks/use-list-table.js +3 -9
  127. package/dist/hooks/use-list-url-state.d.ts +2 -0
  128. package/dist/hooks/use-list-url-state.js +12 -4
  129. package/dist/hooks/use-list-view-state.js +23 -3
  130. package/dist/hooks/use-reference-lookup.js +7 -2
  131. package/dist/hooks/use-remembered-list-params.d.ts +6 -2
  132. package/dist/hooks/use-remembered-list-params.js +18 -3
  133. package/dist/hooks/use-store.js +0 -1
  134. package/dist/i18n-defaults.js +37 -2
  135. package/dist/index.d.ts +8 -2
  136. package/dist/index.js +5 -1
  137. package/dist/live/dispatcher-live.js +2 -0
  138. package/dist/metric-types.d.ts +2 -0
  139. package/dist/primitives-record-guidance.d.ts +53 -0
  140. package/dist/primitives-record-guidance.js +1 -0
  141. package/dist/primitives.d.ts +41 -31
  142. package/dist/server-clock.d.ts +6 -0
  143. package/dist/server-clock.js +20 -0
  144. package/dist/session/session-ended.d.ts +1 -0
  145. package/dist/session/session-ended.js +2 -2
  146. package/dist/status-tone.d.ts +1 -0
  147. package/dist/status-tone.js +5 -0
  148. package/dist/web/app/browser-locale.js +1 -1
  149. package/dist/web/app/client-plugin.d.ts +6 -1
  150. package/dist/web/app/create-app.d.ts +2 -1
  151. package/dist/web/app/create-app.js +15 -5
  152. package/dist/web/app/dashboard-body.js +25 -11
  153. package/dist/web/app/dashboard-header.d.ts +2 -1
  154. package/dist/web/app/dashboard-header.js +19 -7
  155. package/dist/web/app/dashboard-list-panel.d.ts +12 -0
  156. package/dist/web/app/dashboard-list-panel.js +149 -0
  157. package/dist/web/app/dashboard-narrow-gate.d.ts +6 -0
  158. package/dist/web/app/dashboard-narrow-gate.js +6 -0
  159. package/dist/web/app/dashboard-narrow-order.d.ts +3 -0
  160. package/dist/web/app/dashboard-narrow-order.js +6 -0
  161. package/dist/web/app/dashboard-navigation-link.d.ts +12 -0
  162. package/dist/web/app/dashboard-navigation-link.js +21 -0
  163. package/dist/web/app/dashboard-panels.d.ts +6 -23
  164. package/dist/web/app/dashboard-panels.js +53 -123
  165. package/dist/web/app/dashboard-reference-list-table.d.ts +5 -1
  166. package/dist/web/app/dashboard-reference-list-table.js +12 -4
  167. package/dist/web/app/dashboard-shared.d.ts +23 -7
  168. package/dist/web/app/dashboard-shared.js +44 -17
  169. package/dist/web/app/dashboard-stat-group-panel.d.ts +13 -0
  170. package/dist/web/app/dashboard-stat-group-panel.js +67 -0
  171. package/dist/web/app/dashboard-text-panel.d.ts +12 -0
  172. package/dist/web/app/dashboard-text-panel.js +163 -0
  173. package/dist/web/app/dashboard-text.d.ts +2 -0
  174. package/dist/web/app/dashboard-text.js +1 -1
  175. package/dist/web/app/dashboard-visibility.js +1 -1
  176. package/dist/web/app/relative-time.js +2 -1
  177. package/dist/web/editor/editor-footer.d.ts +28 -0
  178. package/dist/web/editor/editor-footer.js +23 -0
  179. package/dist/web/editor/editor-frame.d.ts +23 -0
  180. package/dist/web/editor/editor-frame.js +24 -0
  181. package/dist/web/editor/editor-header.d.ts +36 -0
  182. package/dist/web/editor/editor-header.js +30 -0
  183. package/dist/web/editor/editor-rail.d.ts +32 -0
  184. package/dist/web/editor/editor-rail.js +37 -0
  185. package/dist/web/editor/editor-workbench.d.ts +34 -0
  186. package/dist/web/editor/editor-workbench.js +19 -0
  187. package/dist/web/editor/index.d.ts +6 -0
  188. package/dist/web/editor/index.js +6 -0
  189. package/dist/web/editor/relative-when.d.ts +1 -0
  190. package/dist/web/editor/relative-when.js +18 -0
  191. package/dist/web/index.d.ts +7 -1
  192. package/dist/web/index.js +5 -1
  193. package/dist/web/layout/default-app-shell.js +6 -4
  194. package/dist/web/layout/focus-aware-sidebar.d.ts +4 -7
  195. package/dist/web/layout/focus-aware-sidebar.js +5 -7
  196. package/dist/web/layout/header-action-pinned.d.ts +8 -0
  197. package/dist/web/layout/header-action-pinned.js +25 -0
  198. package/dist/web/layout/nav-collapse-state.d.ts +5 -0
  199. package/dist/web/layout/nav-collapse-state.js +66 -0
  200. package/dist/web/layout/nav-tree.js +25 -5
  201. package/dist/web/layout/page-header-slot.d.ts +2 -0
  202. package/dist/web/layout/page-header-slot.js +4 -0
  203. package/dist/web/layout/screen-focus.d.ts +8 -0
  204. package/dist/web/layout/screen-focus.js +42 -0
  205. package/dist/web/layout/shell-focus.d.ts +6 -5
  206. package/dist/web/layout/shell-focus.js +12 -9
  207. package/dist/web/layout/shell-header.js +38 -10
  208. package/dist/web/layout/sidebar-open-state.d.ts +6 -0
  209. package/dist/web/layout/sidebar-open-state.js +28 -0
  210. package/dist/web/layout/uniform-bar-controls.d.ts +2 -2
  211. package/dist/web/layout/uniform-bar-controls.js +4 -3
  212. package/dist/web/layout/use-in-app-inbox.js +8 -1
  213. package/dist/web/layout/workspace-shell.js +6 -4
  214. package/dist/web/lib/upload-file-ref.d.ts +2 -2
  215. package/dist/web/lib/upload-file-ref.js +4 -9
  216. package/dist/web/presence/use-presence.js +7 -2
  217. package/dist/web/primitives/banner.d.ts +1 -1
  218. package/dist/web/primitives/banner.js +14 -6
  219. package/dist/web/primitives/calendar-day-picker.js +24 -5
  220. package/dist/web/primitives/card.js +1 -1
  221. package/dist/web/primitives/code-input.js +6 -1
  222. package/dist/web/primitives/data-table/actions-column.d.ts +1 -0
  223. package/dist/web/primitives/data-table/actions-column.js +4 -2
  224. package/dist/web/primitives/data-table/card-body.d.ts +5 -0
  225. package/dist/web/primitives/data-table/card-body.js +47 -5
  226. package/dist/web/primitives/data-table/card-frame.d.ts +8 -0
  227. package/dist/web/primitives/data-table/card-frame.js +9 -0
  228. package/dist/web/primitives/data-table/card-row.js +40 -7
  229. package/dist/web/primitives/data-table/card-sort-select.d.ts +6 -2
  230. package/dist/web/primitives/data-table/card-sort-select.js +10 -7
  231. package/dist/web/primitives/data-table/card-view.js +12 -2
  232. package/dist/web/primitives/data-table/column-picker-section.js +9 -2
  233. package/dist/web/primitives/data-table/column-resize-handle.js +3 -4
  234. package/dist/web/primitives/data-table/column-role.d.ts +1 -0
  235. package/dist/web/primitives/data-table/column-role.js +1 -0
  236. package/dist/web/primitives/data-table/data-cell-props.d.ts +5 -0
  237. package/dist/web/primitives/data-table/data-cell-props.js +5 -0
  238. package/dist/web/primitives/data-table/density.js +1 -0
  239. package/dist/web/primitives/data-table/facet-cluster.d.ts +2 -1
  240. package/dist/web/primitives/data-table/facet-cluster.js +2 -2
  241. package/dist/web/primitives/data-table/group-band.js +4 -0
  242. package/dist/web/primitives/data-table/hint-cell.d.ts +16 -0
  243. package/dist/web/primitives/data-table/hint-cell.js +74 -0
  244. package/dist/web/primitives/data-table/hint-column-width.d.ts +3 -0
  245. package/dist/web/primitives/data-table/hint-column-width.js +11 -0
  246. package/dist/web/primitives/data-table/measure-value.js +2 -3
  247. package/dist/web/primitives/data-table/row-action-column.d.ts +3 -0
  248. package/dist/web/primitives/data-table/row-action-column.js +4 -0
  249. package/dist/web/primitives/data-table/sort-options-select.d.ts +22 -0
  250. package/dist/web/primitives/data-table/sort-options-select.js +46 -0
  251. package/dist/web/primitives/data-table/sortable-header.d.ts +3 -1
  252. package/dist/web/primitives/data-table/sortable-header.js +5 -3
  253. package/dist/web/primitives/data-table/table-body.d.ts +1 -1
  254. package/dist/web/primitives/data-table/table-body.js +5 -3
  255. package/dist/web/primitives/data-table/table-chrome.js +3 -1
  256. package/dist/web/primitives/data-table/table-content.js +10 -5
  257. package/dist/web/primitives/data-table/table-data-cell.js +9 -3
  258. package/dist/web/primitives/data-table/table-header-row.js +5 -2
  259. package/dist/web/primitives/data-table/table-view.js +17 -3
  260. package/dist/web/primitives/data-table/toolbar-end-cluster.js +1 -1
  261. package/dist/web/primitives/data-table/toolbar.js +31 -3
  262. package/dist/web/primitives/data-table/totals-footer.d.ts +20 -0
  263. package/dist/web/primitives/data-table/totals-footer.js +40 -9
  264. package/dist/web/primitives/data-table/use-bulk-selection.js +2 -1
  265. package/dist/web/primitives/data-table/use-column-pins.js +4 -0
  266. package/dist/web/primitives/data-table/use-data-table-state.d.ts +1 -0
  267. package/dist/web/primitives/data-table/use-data-table-state.js +9 -5
  268. package/dist/web/primitives/data-table/use-measured-column-widths.js +5 -4
  269. package/dist/web/primitives/data-table/use-row-selection.js +22 -11
  270. package/dist/web/primitives/data-table/view-menu.js +7 -1
  271. package/dist/web/primitives/data-table-cell.d.ts +21 -2
  272. package/dist/web/primitives/data-table-cell.js +96 -19
  273. package/dist/web/primitives/embedded-file-cell.js +10 -6
  274. package/dist/web/primitives/embedded-list-cards.js +3 -4
  275. package/dist/web/primitives/facet-filter.d.ts +4 -2
  276. package/dist/web/primitives/facet-filter.js +26 -3
  277. package/dist/web/primitives/facet-search-filter.js +1 -1
  278. package/dist/web/primitives/file-thumbnail.d.ts +6 -2
  279. package/dist/web/primitives/file-thumbnail.js +13 -6
  280. package/dist/web/primitives/file-upload.js +15 -11
  281. package/dist/web/primitives/file-view-action.d.ts +6 -0
  282. package/dist/web/primitives/file-view-action.js +19 -0
  283. package/dist/web/primitives/files-dropzone.js +18 -4
  284. package/dist/web/primitives/form-footer-parts.d.ts +0 -1
  285. package/dist/web/primitives/form.js +0 -1
  286. package/dist/web/primitives/hint-reason-row.d.ts +32 -0
  287. package/dist/web/primitives/hint-reason-row.js +45 -0
  288. package/dist/web/primitives/index.js +6 -0
  289. package/dist/web/primitives/layout-elements.d.ts +1 -1
  290. package/dist/web/primitives/layout-elements.js +2 -2
  291. package/dist/web/primitives/metric.js +8 -6
  292. package/dist/web/primitives/page-header.d.ts +1 -1
  293. package/dist/web/primitives/page-header.js +8 -1
  294. package/dist/web/primitives/pager.js +29 -18
  295. package/dist/web/primitives/reason-box.d.ts +20 -0
  296. package/dist/web/primitives/reason-box.js +13 -0
  297. package/dist/web/primitives/record-breadcrumb.d.ts +3 -0
  298. package/dist/web/primitives/record-breadcrumb.js +11 -0
  299. package/dist/web/primitives/record-steps.d.ts +3 -0
  300. package/dist/web/primitives/record-steps.js +45 -0
  301. package/dist/web/primitives/record-summary.d.ts +3 -0
  302. package/dist/web/primitives/record-summary.js +18 -0
  303. package/dist/web/primitives/row-actions.d.ts +3 -1
  304. package/dist/web/primitives/row-actions.js +14 -5
  305. package/dist/web/primitives/segmented-select.js +5 -7
  306. package/dist/web/pwa/pwa-support.d.ts +4 -0
  307. package/dist/web/pwa/pwa-support.js +113 -0
  308. package/dist/web/sse/live-events.js +2 -2
  309. package/dist/web/tokens.js +0 -3
  310. package/dist/web/widgets/chart-parts.d.ts +7 -1
  311. package/dist/web/widgets/chart-parts.js +10 -4
  312. package/dist/web/widgets/collapsible-section.js +1 -1
  313. package/dist/web/widgets/dashboard-list-cards.d.ts +17 -0
  314. package/dist/web/widgets/dashboard-list-cards.js +54 -0
  315. package/dist/web/widgets/dashboard-list.d.ts +37 -5
  316. package/dist/web/widgets/dashboard-list.js +95 -20
  317. package/dist/web/widgets/drawer-sizing.js +1 -1
  318. package/dist/web/widgets/floating-panel.js +4 -2
  319. package/dist/web/widgets/index.d.ts +2 -0
  320. package/dist/web/widgets/index.js +2 -0
  321. package/dist/web/widgets/infinity-list.js +18 -11
  322. package/dist/web/widgets/preview-width-frame.d.ts +7 -0
  323. package/dist/web/widgets/preview-width-frame.js +10 -0
  324. package/dist/web/widgets/section-card.d.ts +1 -1
  325. package/dist/web/widgets/stacked-area-chrome.js +3 -3
  326. package/dist/web/widgets/stacked-area-tooltip.js +2 -10
  327. package/dist/web/widgets/stat-box-cell.d.ts +19 -0
  328. package/dist/web/widgets/stat-box-cell.js +10 -0
  329. package/dist/web/widgets/stat.d.ts +10 -1
  330. package/dist/web/widgets/stat.js +14 -5
  331. package/dist/web/widgets/status-badge.d.ts +7 -5
  332. package/dist/web/widgets/status-badge.js +2 -2
  333. package/dist/web/widgets/step-bar.d.ts +1 -1
  334. package/dist/web/widgets/step-bar.js +37 -7
  335. package/dist/web/widgets/upload-zone.d.ts +8 -1
  336. package/dist/web/widgets/upload-zone.js +13 -3
  337. package/package.json +5 -5
  338. package/src/changes.json +223 -0
  339. package/src/web/styles.css +9 -0
@@ -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,
@@ -1,4 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { LIST_TABLE_DENSITIES } from "@cosmicdrift/kumiko-types/screen";
3
+ import { isOneOf } from "@cosmicdrift/kumiko-types/type-guards";
2
4
  import { Columns3 } from "lucide-react";
3
5
  import { Popover as PopoverPrimitive } from "radix-ui";
4
6
  import { useOptionalTranslation } from "../../../index.js";
@@ -9,6 +11,9 @@ import { PinSection } from "./pin-section.js";
9
11
  const POPOVER_CLASS = "z-50 flex w-72 max-w-[calc(100vw-2rem)] flex-col gap-3 rounded-md border bg-popover p-3 " +
10
12
  "text-popover-foreground shadow-md max-h-[var(--radix-popover-content-available-height)] overflow-y-auto";
11
13
  const SECTION_TITLE_CLASS = "m-0 text-xs font-medium text-muted-foreground";
14
+ function densityOf(value) {
15
+ return isOneOf(LIST_TABLE_DENSITIES, value) ? value : "comfortable";
16
+ }
12
17
  /** The menu also opens for pinning or resizing alone: pins get a section, widths only the reset. */
13
18
  export function viewHasMenu(view) {
14
19
  if (view === undefined)
@@ -29,12 +34,13 @@ export function ViewMenu({ view, columnLabels, }) {
29
34
  const pinnableFields = columns !== undefined
30
35
  ? columns.filter((column) => column.visible).map((column) => column.field)
31
36
  : [...columnLabels.keys()];
32
- return (_jsxs(PopoverPrimitive.Root, { children: [_jsx(PopoverPrimitive.Trigger, { asChild: true, children: _jsx(UiButton, { type: "button", variant: "outline", size: "icon", className: "size-9 max-md:size-11", "aria-label": label("kumiko.list.view.menu", "View"), "data-testid": "list-view-menu", children: _jsx(Columns3, { className: "size-4", "aria-hidden": "true" }) }) }), _jsx(PopoverPrimitive.Portal, { children: _jsxs(PopoverPrimitive.Content, { align: "end", sideOffset: 4, className: POPOVER_CLASS, "data-testid": "list-view-menu-content", children: [hasColumns && (_jsxs("section", { className: "flex flex-col gap-1", children: [_jsx("h3", { className: SECTION_TITLE_CLASS, children: label("kumiko.list.view.columns", "Columns") }), _jsx(ColumnPickerSection, { columns: columns, labels: columnLabels, onChange: onColumnsChange })] })), onDensityChange !== undefined && (_jsxs("section", { className: "flex flex-col gap-1", children: [_jsx("h3", { className: SECTION_TITLE_CLASS, children: label("kumiko.list.view.density", "Density") }), _jsx(SegmentedControl, { id: "list-view-density", name: "list-view-density", value: view.density, onChange: (next) => onDensityChange(next === "compact" ? "compact" : "comfortable"), options: [
37
+ return (_jsxs(PopoverPrimitive.Root, { children: [_jsx(PopoverPrimitive.Trigger, { asChild: true, children: _jsx(UiButton, { type: "button", variant: "outline", size: "icon", className: "size-9 max-md:size-11", "aria-label": label("kumiko.list.view.menu", "View"), "data-testid": "list-view-menu", children: _jsx(Columns3, { className: "size-4", "aria-hidden": "true" }) }) }), _jsx(PopoverPrimitive.Portal, { children: _jsxs(PopoverPrimitive.Content, { align: "end", sideOffset: 4, className: POPOVER_CLASS, "data-testid": "list-view-menu-content", children: [hasColumns && (_jsxs("section", { className: "flex flex-col gap-1", children: [_jsx("h3", { className: SECTION_TITLE_CLASS, children: label("kumiko.list.view.columns", "Columns") }), _jsx(ColumnPickerSection, { columns: columns, labels: columnLabels, onChange: onColumnsChange })] })), onDensityChange !== undefined && (_jsxs("section", { className: "flex flex-col gap-1", children: [_jsx("h3", { className: SECTION_TITLE_CLASS, children: label("kumiko.list.view.density", "Density") }), _jsx(SegmentedControl, { id: "list-view-density", name: "list-view-density", value: view.density, onChange: (next) => onDensityChange(densityOf(next)), options: [
33
38
  {
34
39
  value: "comfortable",
35
40
  label: label("kumiko.list.view.density.comfortable", "Comfortable"),
36
41
  },
37
42
  { value: "compact", label: label("kumiko.list.view.density.compact", "Compact") },
43
+ { value: "relaxed", label: label("kumiko.list.view.density.relaxed", "Relaxed") },
38
44
  ], labelProps: { "aria-label": label("kumiko.list.view.density", "Density") } })] })), view.groupBy !== undefined && (_jsxs("section", { className: "flex flex-col gap-1", children: [_jsx("h3", { className: SECTION_TITLE_CLASS, children: label("kumiko.list.group.by", "Group by") }), _jsx(SegmentedControl, { id: "list-view-group-by", name: "list-view-group-by", value: view.groupBy.value, onChange: view.groupBy.onChange, options: [
39
45
  { value: "", label: label("kumiko.list.group.none", "None") },
40
46
  ...view.groupBy.fields.map((field) => ({
@@ -1,7 +1,8 @@
1
1
  import type { SelectOptionTone } from "@cosmicdrift/kumiko-framework/ui-types";
2
2
  import { type ReactNode } from "react";
3
- import type { CellLink, CellLinkItem, ListColumnFileDisplay, ListRowViewModel, RuntimeCellLink, RuntimeCellLinkItems } from "../../headless/index.ts";
3
+ import type { CellLink, CellLinkItem, ListColumnCellDisplay, ListColumnFileDisplay, ListColumnHintViewModel, ListRowViewModel, RuntimeCellLink, RuntimeCellLinkItems } from "../../headless/index.ts";
4
4
  import { type PrimitivesRegistry } from "../../index.ts";
5
+ import { type StatusBadgeTone } from "../widgets/status-badge.tsx";
5
6
  import "../react-css-custom-properties.ts";
6
7
  export declare function isEmptyCellValue(value: unknown): boolean;
7
8
  export declare function isUnlabeledFalse(type: string, value: unknown, renderer: unknown): boolean;
@@ -40,7 +41,17 @@ type DataTableCellProps = {
40
41
  readonly compactFile?: boolean;
41
42
  readonly link?: CellLink;
42
43
  readonly linkItems?: readonly CellLinkItem[];
44
+ readonly hint?: ListColumnHintViewModel;
45
+ readonly display?: ListColumnCellDisplay;
46
+ readonly badgeToneField?: string;
47
+ readonly badgeDot?: false;
48
+ readonly emptyPlaceholder?: false;
49
+ readonly onOpenRow?: () => void;
43
50
  };
51
+ /** `display: "button"` draws a cell link as a small outline button. */
52
+ export declare const LINK_BUTTON_CLASS: string;
53
+ /** Badge tones by the list-wide ListBadgeTone words. */
54
+ export declare const LIST_BADGE_TONE: Readonly<Record<string, StatusBadgeTone>>;
44
55
  export declare function cellLinkProp(col: {
45
56
  readonly field: string;
46
57
  readonly linkFor?: RuntimeCellLink | undefined;
@@ -50,7 +61,15 @@ export declare function cellLinkProp(col: {
50
61
  readonly linkItems?: readonly CellLinkItem[];
51
62
  };
52
63
  export declare function rowToneClass(tone: SelectOptionTone | undefined): string;
64
+ /** Background class of the small tone dot that `rowToneMarker: "dot"` draws in front of a row. */
65
+ export declare function toneDotClass(tone: SelectOptionTone): string;
66
+ export declare function cardToneClass(tone: SelectOptionTone | undefined): string;
53
67
  export declare const NUMERIC_COLUMN_TYPES: ReadonlySet<string>;
54
68
  export declare const TABULAR_COLUMN_TYPES: ReadonlySet<string>;
55
- export declare function DataTableCell({ value, row, field, type, renderer, optionLabels, optionTones, onChange, translate, locale, grouping, fileDisplay, compactFile, link, linkItems, }: DataTableCellProps): ReactNode;
69
+ export declare function CellTextLink({ link, children, className, }: {
70
+ readonly link: CellLink;
71
+ readonly children: ReactNode;
72
+ readonly className?: string;
73
+ }): ReactNode;
74
+ export declare function DataTableCell({ value, row, field, type, renderer, optionLabels, optionTones, onChange, translate, locale, grouping, fileDisplay, compactFile, link, linkItems, hint, display, badgeToneField, badgeDot, emptyPlaceholder, onOpenRow, }: DataTableCellProps): ReactNode;
56
75
  export {};
@@ -1,15 +1,19 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { SELECT_OPTION_TONES } from "@cosmicdrift/kumiko-types/fields";
3
2
  import { PII_ERASED_SENTINEL } from "@cosmicdrift/kumiko-types/kms-adapter-types";
4
3
  import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
5
4
  import { Check } from "lucide-react";
6
5
  import { Fragment } from "react";
7
6
  import { rendererWarn } from "../../dev-console.js";
7
+ import { fileIdsOf } from "../../file-ids-of.js";
8
8
  import { applyFormatSpec, EMPTY_VALUE_PLACEHOLDER, isSafeHref } from "../../headless/index.js";
9
9
  import { statusToneForOptionTone, statusToneForValue, useColumnRenderer, useOptionalPrimitives, } from "../../index.js";
10
+ import { isSelectOptionTone } from "../../status-tone.js";
10
11
  import { Badge } from "../ui/badge.js";
12
+ import { buttonVariants } from "../ui/button.js";
11
13
  import { StatusBadge } from "../widgets/status-badge.js";
14
+ import { HintCell } from "./data-table/hint-cell.js";
12
15
  import { FileDisplayCell } from "./file-thumbnail.js";
16
+ import { FileViewAction } from "./file-view-action.js";
13
17
  import { currencyDecimals, formatMoney } from "./money-input.js";
14
18
  import "../react-css-custom-properties.js";
15
19
  import { isPlainPrimaryClick } from "./layout-elements.js";
@@ -218,9 +222,6 @@ export function selectPill(value, optionLabels, optionTones, locale, RegisteredS
218
222
  // dashboard-01 pattern: outline badge + muted instead of a filled secondary.
219
223
  return (_jsx(Badge, { variant: "outline", className: "px-1.5 text-muted-foreground", children: label }));
220
224
  }
221
- function isSelectOptionTone(value) {
222
- return SELECT_OPTION_TONES.some((tone) => tone === value);
223
- }
224
225
  // enumOption's `tones` arrive with the untyped spec, so each entry is checked here.
225
226
  function enumOptionTones(spec) {
226
227
  const tones = spec["tones"];
@@ -234,6 +235,18 @@ function enumOptionTones(spec) {
234
235
  }
235
236
  return out;
236
237
  }
238
+ function EmptyCell({ placeholder }) {
239
+ return (_jsx("span", { "data-empty-cell": "true", className: "text-muted-foreground", children: placeholder === false ? null : EMPTY_VALUE_PLACEHOLDER }));
240
+ }
241
+ /** `display: "button"` draws a cell link as a small outline button. */
242
+ export const LINK_BUTTON_CLASS = buttonVariants({ variant: "outline", size: "sm" });
243
+ /** Badge tones by the list-wide ListBadgeTone words. */
244
+ export const LIST_BADGE_TONE = {
245
+ positive: "ok",
246
+ warn: "warn",
247
+ negative: "bad",
248
+ neutral: "muted",
249
+ };
237
250
  // A multi reference may list the same id twice; the occurrence count keeps React keys unique.
238
251
  function uniqueLinkItemKeys(items) {
239
252
  const seen = new Map();
@@ -255,16 +268,44 @@ export function cellLinkProp(col, row, allowed) {
255
268
  ...(linkItems !== undefined && { linkItems }),
256
269
  };
257
270
  }
258
- const ROW_TONE_CLASS = {
259
- bad: "bg-status-bad/10 hover:bg-status-bad/15",
260
- warn: "bg-status-warn/10 hover:bg-status-warn/15",
261
- ok: "bg-status-ok/10 hover:bg-status-ok/15",
262
- critical: "bg-status-critical/10 hover:bg-status-critical/15",
263
- accent: "bg-primary/10 hover:bg-primary/15",
271
+ // Tone is a left stripe, not a fill: a tinted row reads as selected or disabled and fights the
272
+ // opaque sticky actions cell. Rows draw it as an inset shadow on the first cell (a border on a
273
+ // <tr> collapses away), cards as a real border. The colour also lands in --row-stripe because a
274
+ // pinned cell sets its own inline box-shadow, which would otherwise replace the stripe.
275
+ const ROW_STRIPE_SHADOW_CLASS = "[&>td:first-child]:shadow-[inset_3px_0_0_var(--row-stripe)]";
276
+ const ROW_TONE_STRIPE_CLASS = {
277
+ bad: `${ROW_STRIPE_SHADOW_CLASS} [&>td:first-child]:[--row-stripe:var(--color-status-bad)]`,
278
+ warn: `${ROW_STRIPE_SHADOW_CLASS} [&>td:first-child]:[--row-stripe:var(--color-status-warn)]`,
279
+ ok: `${ROW_STRIPE_SHADOW_CLASS} [&>td:first-child]:[--row-stripe:var(--color-status-ok)]`,
280
+ critical: `${ROW_STRIPE_SHADOW_CLASS} [&>td:first-child]:[--row-stripe:var(--color-status-critical)]`,
281
+ accent: `${ROW_STRIPE_SHADOW_CLASS} [&>td:first-child]:[--row-stripe:var(--color-primary)]`,
282
+ neutral: "",
283
+ };
284
+ const CARD_TONE_STRIPE_CLASS = {
285
+ bad: "border-l-[3px] border-l-status-bad",
286
+ warn: "border-l-[3px] border-l-status-warn",
287
+ ok: "border-l-[3px] border-l-status-ok",
288
+ critical: "border-l-[3px] border-l-status-critical",
289
+ accent: "border-l-[3px] border-l-primary",
264
290
  neutral: "",
265
291
  };
266
292
  export function rowToneClass(tone) {
267
- return tone === undefined ? "" : ROW_TONE_CLASS[tone];
293
+ return tone === undefined ? "" : ROW_TONE_STRIPE_CLASS[tone];
294
+ }
295
+ const TONE_DOT_CLASS = {
296
+ bad: "bg-status-bad",
297
+ warn: "bg-status-warn",
298
+ ok: "bg-status-ok",
299
+ critical: "bg-status-critical",
300
+ accent: "bg-primary",
301
+ neutral: "bg-status-neutral",
302
+ };
303
+ /** Background class of the small tone dot that `rowToneMarker: "dot"` draws in front of a row. */
304
+ export function toneDotClass(tone) {
305
+ return TONE_DOT_CLASS[tone];
306
+ }
307
+ export function cardToneClass(tone) {
308
+ return tone === undefined ? "" : CARD_TONE_STRIPE_CLASS[tone];
268
309
  }
269
310
  export const NUMERIC_COLUMN_TYPES = new Set([
270
311
  "number",
@@ -281,8 +322,8 @@ export const TABULAR_COLUMN_TYPES = new Set([
281
322
  ]);
282
323
  // A plain <a>, not DefaultLink: the click must not reach the row's own click
283
324
  // handler, which opens the same record's row action.
284
- function CellTextLink({ link, children, }) {
285
- return (_jsx("a", { href: isSafeHref(link.href) ? link.href : "#", className: "text-primary underline-offset-4 hover:underline", onClick: (event) => {
325
+ export function CellTextLink({ link, children, className = "text-primary underline-offset-4 hover:underline", }) {
326
+ return (_jsx("a", { href: isSafeHref(link.href) ? link.href : "#", className: className, onClick: (event) => {
286
327
  event.stopPropagation();
287
328
  if (!isPlainPrimaryClick(event))
288
329
  return;
@@ -290,6 +331,28 @@ function CellTextLink({ link, children, }) {
290
331
  link.onPress();
291
332
  }, children: children }));
292
333
  }
334
+ // A list column's `display` (badge pill, outline link button); undefined = fall through to the normal paths.
335
+ function renderDisplayCell({ display, value, text, row, badgeToneField, badgeDot, emptyPlaceholder, link, }) {
336
+ // A column renderer skips the generic empty-cell path, so a pill or button would otherwise wrap nothing.
337
+ if ((display === "badge" || display === "button") && isEmptyCellValue(value)) {
338
+ return _jsx(EmptyCell, { placeholder: emptyPlaceholder });
339
+ }
340
+ if (display === "badge") {
341
+ const toneKey = badgeToneField === undefined ? undefined : row[badgeToneField];
342
+ const tone = (typeof toneKey === "string" ? LIST_BADGE_TONE[toneKey] : undefined) ?? "muted";
343
+ return (_jsx(StatusBadge, { tone: tone, dot: badgeDot !== false, children: text }));
344
+ }
345
+ if (display === "button" && link !== undefined) {
346
+ return (_jsx(CellTextLink, { link: link, className: LINK_BUTTON_CLASS, children: text }));
347
+ }
348
+ return undefined;
349
+ }
350
+ function renderFileCell({ value, fileDisplay, compactFile, translate, }) {
351
+ const [firstFileId] = fileIdsOf(value);
352
+ return (_jsxs("span", { className: "inline-flex items-center gap-3", children: [_jsx(FileDisplayCell, { value: value, display: fileDisplay, compact: compactFile, fallbackLabel: translate?.("kumiko.field.file-upload.attached") ?? "File attached" }), fileDisplay.kind === "file" &&
353
+ fileDisplay.viewInDrawer === true &&
354
+ firstFileId !== undefined && _jsx(FileViewAction, { fileId: firstFileId })] }));
355
+ }
293
356
  // Cell renderer as a component (instead of a plain function) so the
294
357
  // useColumnRenderer hook can read from the provider. The four paths:
295
358
  // 1. FormatSpec (`{ format: "timestamp" }` etc.) -> applyFormatSpec.
@@ -299,26 +362,40 @@ function CellTextLink({ link, children, }) {
299
362
  // "X" via useColumnRenderer and renders `<X value row column/>`.
300
363
  // Not registered -> one-time warning + default fallback.
301
364
  // 4. Otherwise -> defaultCellRender (type-based string renderer).
302
- export function DataTableCell({ value, row, field, type, renderer, optionLabels, optionTones, onChange, translate, locale, grouping = true, fileDisplay, compactFile = false, link, linkItems, }) {
365
+ export function DataTableCell({ value, row, field, type, renderer, optionLabels, optionTones, onChange, translate, locale, grouping = true, fileDisplay, compactFile = false, link, linkItems, hint, display, badgeToneField, badgeDot, emptyPlaceholder, onOpenRow, }) {
303
366
  const componentRef = isComponentRendererRef(renderer);
304
367
  const ResolvedComponent = useColumnRenderer(componentRef?.name);
305
368
  const RegisteredStatusBadge = useOptionalPrimitives()?.StatusBadge;
369
+ if (hint !== undefined) {
370
+ return (_jsx(HintCell, { value: value, row: row, hint: hint, ...(onOpenRow !== undefined && { onOpen: onOpenRow }) }));
371
+ }
306
372
  if (isEmptyCellValue(value) && typeof renderer !== "function" && componentRef === undefined) {
307
- return (_jsx("span", { "data-empty-cell": "true", className: "text-muted-foreground", children: EMPTY_VALUE_PLACEHOLDER }));
373
+ return _jsx(EmptyCell, { placeholder: emptyPlaceholder });
308
374
  }
309
375
  if (value === PII_ERASED_SENTINEL && translate !== undefined) {
310
376
  return translate("kumiko.pii.erased");
311
377
  }
378
+ const displayCell = renderDisplayCell({
379
+ display,
380
+ value,
381
+ text: defaultCellRender(value, type, optionLabels, locale, field, grouping),
382
+ row,
383
+ badgeToneField,
384
+ badgeDot,
385
+ emptyPlaceholder,
386
+ link,
387
+ });
388
+ if (displayCell !== undefined)
389
+ return displayCell;
312
390
  if (typeof value === "boolean" &&
313
391
  isBooleanColumn(type, renderer) &&
314
392
  (renderer === undefined || isUnlabeledBooleanFormat(renderer))) {
315
393
  return _jsx(BooleanCell, { value: value, translate: translate });
316
394
  }
317
- if (isUnlabeledFalse(type, value, renderer)) {
318
- return (_jsx("span", { "data-empty-cell": "true", className: "text-muted-foreground", children: EMPTY_VALUE_PLACEHOLDER }));
319
- }
395
+ if (isUnlabeledFalse(type, value, renderer))
396
+ return _jsx(EmptyCell, { placeholder: emptyPlaceholder });
320
397
  if (fileDisplay !== undefined) {
321
- return (_jsx(FileDisplayCell, { value: value, display: fileDisplay, compact: compactFile, fallbackLabel: translate?.("kumiko.field.file-upload.attached") ?? "File attached" }));
398
+ return renderFileCell({ value, fileDisplay, compactFile, translate });
322
399
  }
323
400
  if (typeof renderer === "object" && renderer !== null && "format" in renderer) {
324
401
  const spec = renderer;