@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
@@ -1,22 +1,21 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { normalizeListColumn } from "@cosmicdrift/kumiko-framework/ui-types";
3
2
  import { DASHBOARD_STAT_TONES } from "@cosmicdrift/kumiko-types/screen";
4
3
  import { isOneOf } from "@cosmicdrift/kumiko-types/type-guards";
5
4
  import { useEffect, useState } from "react";
5
+ import { namedFilterNavigateAllows, navigateTargetAllows } from "../../app/screen-access.js";
6
6
  import { rendererWarn } from "../../dev-console.js";
7
7
  import { EMPTY_VALUE_PLACEHOLDER } from "../../headless/index.js";
8
- import { listNamedFilterUrlKey } from "../../hooks/use-list-url-state.js";
9
- import { extensionSectionName, lastSegment, useExtensionSectionComponent, useNav, usePrimitives, useTranslation, useUserRoles, } from "../../index.js";
8
+ import { extensionSectionName, useAppFeatures, useExtensionSectionComponent, useNav, useTranslation, useUserRoles, } from "../../index.js";
10
9
  import { initialWindowSelection, } from "../widgets/chart-window.js";
11
10
  import { chartToneColor, SegmentBarChart, StackedAreaChart, StackedBarChart, TimeseriesChart, } from "../widgets/charts.js";
12
11
  import { FeedList } from "../widgets/feed-list.js";
13
12
  import { ModeSwitch } from "../widgets/mode-switch.js";
14
13
  import { ProgressList } from "../widgets/progress-list.js";
15
- import { SectionCard } from "../widgets/section-card.js";
16
- import { STAT_CARD_GRID_CLASSES, StatCard, StatStripCell, } from "../widgets/stat.js";
14
+ import { StatCard, StatStripCell, } from "../widgets/stat.js";
15
+ import { StatBoxCell } from "../widgets/stat-box-cell.js";
17
16
  import { EmptyState, LoadingState } from "../widgets/states.js";
18
- import { DashboardReferenceListTable } from "./dashboard-reference-list-table.js";
19
- import { DAY_MS, HOUR_MS, PanelError, PanelShell, panelPayload, QueryPanel, useDashboardFormats, useDashboardQuery, useReportPanelLoaded, } from "./dashboard-shared.js";
17
+ import { optionalDashboardNavigationLink } from "./dashboard-navigation-link.js";
18
+ import { DAY_MS, HOUR_MS, PanelError, panelPayload, QueryPanel, useDashboardFormats, useDashboardQuery, useReportPanelLoaded, } from "./dashboard-shared.js";
20
19
  import { isRecord, resolveDashboardText } from "./dashboard-text.js";
21
20
  function isSparkPoint(value) {
22
21
  return (typeof value === "object" &&
@@ -40,10 +39,22 @@ function fallbackText(raw, placeholder) {
40
39
  return placeholder;
41
40
  return String(raw);
42
41
  }
43
- export function StatPanelBody({ panel, label, screenId, screenParams, translate, variant, }) {
42
+ // Hidden before any query hook runs: the tile's own count query would be refused for this user.
43
+ export function StatPanelBody(props) {
44
+ const appFeatures = useAppFeatures();
45
+ const userRoles = useUserRoles();
46
+ const { navigate } = props.panel;
47
+ if (navigate !== undefined &&
48
+ !(navigateTargetAllows({ screen: navigate.screen }, appFeatures, userRoles) &&
49
+ namedFilterNavigateAllows(navigate, appFeatures, userRoles))) {
50
+ return null;
51
+ }
52
+ return _jsx(StatPanelContent, { ...props });
53
+ }
54
+ function StatPanelContent({ panel, label, screenId, screenParams, translate, variant, }) {
44
55
  const formats = useDashboardFormats();
45
56
  const nav = useNav();
46
- const link = statNavigationLink(nav, panel.navigate);
57
+ const link = optionalDashboardNavigationLink(nav, panel.navigate);
47
58
  // Resolved HERE (not in a separate always-rendered child) so `icon` on
48
59
  // <StatCard> is `undefined` — not a React element that renders empty —
49
60
  // when the icon name isn't registered. StatCard gates its accent chip on
@@ -60,7 +71,7 @@ export function StatPanelBody({ panel, label, screenId, screenParams, translate,
60
71
  const { data, error, loading, refetch } = useDashboardQuery(panel.query,
61
72
  // A navigate tile counts exactly what its target list can reproduce from the URL.
62
73
  panel.navigate === undefined ? panelPayload(panel, screenParams) : (panel.params ?? {}));
63
- useReportPanelLoaded(data);
74
+ useReportPanelLoaded(data, loading);
64
75
  if (loading && data === null)
65
76
  return _jsx(LoadingState, { rows: 2 });
66
77
  if (error !== null) {
@@ -72,40 +83,45 @@ export function StatPanelBody({ panel, label, screenId, screenParams, translate,
72
83
  // A fixed tone must not paint an all-clear "0" as an alarm.
73
84
  (rawValue === 0 ? undefined : panel.tone);
74
85
  const sub = panel.subField !== undefined ? record[panel.subField] : undefined;
86
+ const dynamicLabel = panel.labelField !== undefined ? record[panel.labelField] : undefined;
87
+ const shownLabel = typeof dynamicLabel === "string" && dynamicLabel !== "" ? dynamicLabel : label;
75
88
  const delta = readDelta(panel, record);
76
- const valueFormat = panel.valueFormat;
77
- let value;
78
- if (typeof rawValue !== "number") {
79
- value =
80
- resolveDashboardText(rawValue, translate, formats) ??
81
- fallbackText(rawValue, EMPTY_VALUE_PLACEHOLDER);
82
- }
83
- else if (valueFormat?.kind === "relativeTime") {
84
- value = formats.formatRelative(rawValue);
85
- }
86
- else {
87
- value = formats.formatPanelValue(valueFormat)(rawValue);
88
- }
89
+ const value = statValueText(rawValue, panel.valueFormat, translate, formats);
89
90
  const spark = readSparkline(panel, record);
90
91
  const testId = `dashboard-panel-${panel.id}`;
91
92
  const subText = resolveDashboardText(sub, translate, formats) ?? fallbackText(sub, undefined);
92
93
  const icon = Icon !== undefined ? (_jsx(Icon, { entityName: screenId, entityId: null, screenId: screenId, filterParams: screenParams.filterParams })) : undefined;
93
- if (variant === "strip") {
94
- return (_jsx(StatStripCell, { icon: icon, label: label, value: value, tone: tone ?? "default", ...(Icon !== undefined && { accentColor: panel.accentColor }), ...(subText !== undefined && { sub: subText }), ...(delta !== undefined && { delta }), ...(spark !== undefined && { spark }), testId: testId, ...(link !== undefined && { link }) }));
94
+ const narrowLabel = panel.narrowLabel !== undefined ? translate(panel.narrowLabel) : undefined;
95
+ return (_jsx(StatVariantCell, { variant: variant, cell: {
96
+ icon,
97
+ label: shownLabel,
98
+ value,
99
+ tone: tone ?? "default",
100
+ testId,
101
+ ...(narrowLabel !== undefined && { narrowLabel }),
102
+ ...(Icon !== undefined && { accentColor: panel.accentColor }),
103
+ ...(subText !== undefined && { sub: subText }),
104
+ ...(delta !== undefined && { delta }),
105
+ ...(spark !== undefined && { spark }),
106
+ ...(link !== undefined && { link }),
107
+ } }));
108
+ }
109
+ function StatVariantCell({ variant, cell, }) {
110
+ if (variant === "strip-compact") {
111
+ const { accentColor: _unused, ...boxCell } = cell;
112
+ return _jsx(StatBoxCell, { ...boxCell });
95
113
  }
96
- return (_jsx(StatCard, { icon: icon, label: label, value: value, tone: tone ?? "default", ...(Icon !== undefined && { accentColor: panel.accentColor }), ...(subText !== undefined && { sub: subText }), ...(delta !== undefined && { delta }), ...(spark !== undefined && { spark }), testId: testId, ...(link !== undefined && { link }) }));
114
+ const { narrowLabel: _narrow, ...tileCell } = cell;
115
+ return variant === "strip" ? _jsx(StatStripCell, { ...tileCell }) : _jsx(StatCard, { ...tileCell });
97
116
  }
98
- function statNavigationLink(nav, navigate) {
99
- if (navigate === undefined)
100
- return undefined;
101
- const target = { screenId: lastSegment(navigate.screen) };
102
- const options = navigate.namedFilter === undefined
103
- ? undefined
104
- : { searchParams: { [listNamedFilterUrlKey(target.screenId)]: navigate.namedFilter } };
105
- return {
106
- href: nav.hrefFor(target, options),
107
- onPress: () => nav.navigate(target, options),
108
- };
117
+ function statValueText(rawValue, valueFormat, translate, formats) {
118
+ if (typeof rawValue !== "number") {
119
+ return (resolveDashboardText(rawValue, translate, formats) ??
120
+ fallbackText(rawValue, EMPTY_VALUE_PLACEHOLDER));
121
+ }
122
+ if (valueFormat?.kind === "relativeTime")
123
+ return formats.formatRelative(rawValue);
124
+ return formats.formatPanelValue(valueFormat)(rawValue);
109
125
  }
110
126
  function readDelta(panel, record) {
111
127
  if (panel.deltaField === undefined || panel.deltaDirectionField === undefined)
@@ -119,13 +135,6 @@ function readDelta(panel, record) {
119
135
  const tone = readTone(panel.deltaToneField !== undefined ? record[panel.deltaToneField] : undefined);
120
136
  return { value: String(value), direction, ...(tone !== undefined && { tone }) };
121
137
  }
122
- export function StatGroupPanelBody({ panel, label, screenId, screenParams, translate, }) {
123
- const testId = `dashboard-panel-${panel.id}`;
124
- if (label === undefined) {
125
- return (_jsx("div", { "data-testid": testId, className: "grid grid-cols-2 gap-y-2 rounded-lg border border-border bg-card py-1 lg:auto-cols-fr lg:grid-flow-col lg:divide-x lg:divide-border-row", children: panel.stats.map((stat) => (_jsx(StatPanelBody, { panel: stat, label: translate(stat.label), screenId: screenId, screenParams: screenParams, translate: translate, variant: "strip" }, stat.id))) }));
126
- }
127
- return (_jsx(SectionCard, { title: label, ...(panel.subtitle !== undefined && { subtitle: translate(panel.subtitle) }), testId: testId, children: _jsx("section", { className: STAT_CARD_GRID_CLASSES, children: panel.stats.map((stat) => (_jsx(StatPanelBody, { panel: stat, label: translate(stat.label), screenId: screenId, screenParams: screenParams, translate: translate, variant: "card" }, stat.id))) }) }));
128
- }
129
138
  function markerKindColor(kind) {
130
139
  if (kind === undefined)
131
140
  return undefined;
@@ -239,29 +248,6 @@ export function ChartPanelBody({ panel, label, screenParams, translate, }) {
239
248
  }), ariaLabel: label, testId: testId }));
240
249
  } }));
241
250
  }
242
- export function ListPanelBody({ panel, label, featureName, screenParams, translate, }) {
243
- const { formatPercent, formatNumber, formatDateTime } = useDashboardFormats();
244
- const columns = panel.columns.map((c) => {
245
- const normalized = normalizeListColumn(c);
246
- return {
247
- field: normalized.field,
248
- label: translate(normalized.label ?? normalized.field),
249
- ...(normalized.display !== undefined && { display: normalized.display }),
250
- ...(normalized.badgeToneField !== undefined && {
251
- badgeToneField: normalized.badgeToneField,
252
- }),
253
- ...(normalized.refEntity !== undefined && {
254
- reference: {
255
- refEntity: normalized.refEntity,
256
- ...(normalized.refLabelField !== undefined && {
257
- refLabelField: normalized.refLabelField,
258
- }),
259
- },
260
- }),
261
- };
262
- });
263
- return (_jsx(QueryPanel, { panel: panel, label: label, screenParams: screenParams, translate: translate, skeleton: "rows", isEmpty: (data) => (data.rows ?? []).length === 0, children: (data) => (_jsx(DashboardReferenceListTable, { columns: columns, rows: data.rows ?? [], featureName: featureName, formatPercent: formatPercent, formatNumber: formatNumber, formatDateTime: formatDateTime, translate: translate })) }));
264
- }
265
251
  export function FeedPanelBody({ panel, label, screenParams, translate, }) {
266
252
  return (_jsx(QueryPanel, { panel: panel, label: label, screenParams: screenParams, translate: translate, skeleton: "rows", isEmpty: (data) => (data.rows ?? []).length === 0, children: (data, formats) => {
267
253
  const rows = (data.rows ?? []).map((row, i) => {
@@ -327,62 +313,6 @@ export function ProgressListPanelBody({ panel, label, screenParams, translate, }
327
313
  return _jsx(ProgressList, { rows: rows });
328
314
  } }));
329
315
  }
330
- function TextBlockView({ block, translate, }) {
331
- switch (block.kind) {
332
- case "heading":
333
- return (_jsx("h3", { "data-block": "heading", className: "text-sm font-semibold text-foreground", children: translate(block.text) }));
334
- case "paragraph":
335
- return (_jsx("p", { "data-block": "paragraph", className: block.emphasis === "strong"
336
- ? "text-sm font-medium text-foreground"
337
- : "text-sm text-muted-foreground", children: translate(block.text) }));
338
- case "list":
339
- return (_jsx("ul", { "data-block": "list", className: "list-disc space-y-1 pl-5 text-sm text-muted-foreground", children: withOccurrenceKeys(block.items, (item) => item).map(({ entry, key }) => (_jsx("li", { children: translate(entry) }, key))) }));
340
- case "code":
341
- return (_jsx("pre", { "data-block": "code", className: "overflow-x-auto rounded-md bg-muted p-3 text-xs", children: _jsx("code", { children: block.code }) }));
342
- case "hint":
343
- return (_jsx("p", { "data-block": "hint", className: "text-xs text-muted-foreground", children: translate(block.text) }));
344
- case "link":
345
- return _jsx(TextBlockLink, { block: block, translate: translate });
346
- }
347
- }
348
- function TextBlockLink({ block, translate, }) {
349
- const { Link } = usePrimitives();
350
- const nav = useNav();
351
- const userRoles = useUserRoles();
352
- if (block.roles !== undefined && !block.roles.some((role) => userRoles?.includes(role))) {
353
- return null;
354
- }
355
- const target = { screenId: lastSegment(block.screen) };
356
- return (_jsx(Link, { href: nav.hrefFor(target), onPress: () => nav.navigate(target), testId: `dashboard-text-link-${target.screenId}`, children: translate(block.text) }));
357
- }
358
- // Content-derived keys collide for identical entries; the occurrence count keeps them unique.
359
- function withOccurrenceKeys(entries, contentKey) {
360
- const seen = new Map();
361
- return entries.map((entry) => {
362
- const content = contentKey(entry);
363
- const occurrence = seen.get(content) ?? 0;
364
- seen.set(content, occurrence + 1);
365
- return { entry, key: `${content}#${occurrence}` };
366
- });
367
- }
368
- function textBlockKey(block) {
369
- switch (block.kind) {
370
- case "list":
371
- return `list:${block.items.join("|")}`;
372
- case "code":
373
- return `code:${block.code}`;
374
- default:
375
- return `${block.kind}:${block.text}`;
376
- }
377
- }
378
- export function TextPanelBody({ panel, label, translate, }) {
379
- const blocks = (_jsx("div", { className: "flex flex-col gap-3", children: withOccurrenceKeys(panel.blocks, textBlockKey).map(({ entry, key }) => (_jsx(TextBlockView, { block: entry, translate: translate }, key))) }));
380
- const testId = `dashboard-panel-${panel.id}`;
381
- if (label !== undefined) {
382
- return (_jsx(PanelShell, { testId: testId, title: label, children: blocks }));
383
- }
384
- return (_jsx("section", { "data-testid": testId, className: "h-full rounded-lg border border-border bg-card p-4 text-card-foreground", children: blocks }));
385
- }
386
316
  // Resolves panel.component through the same extensionSectionComponents
387
317
  // registry as entityEdit extension sections and list header slots; it
388
318
  // stays at its array position instead of moving into a separate slot (see
@@ -12,6 +12,10 @@ type Props = Omit<ComponentProps<typeof DashboardListTable>, "columns"> & {
12
12
  readonly columns: readonly DashboardListTableColumn[];
13
13
  readonly featureName: string;
14
14
  readonly translate: Translate;
15
+ /** Phone layout: one card per row instead of the table. */
16
+ readonly narrowCards?: boolean;
17
+ /** Row field whose text replaces the card title in the phone layout. */
18
+ readonly titleField?: string;
15
19
  };
16
- export declare function DashboardReferenceListTable({ columns, rows, featureName, translate, ...tableProps }: Props): ReactNode;
20
+ export declare function DashboardReferenceListTable({ columns, rows, featureName, translate, narrowCards, titleField, ...tableProps }: Props): ReactNode;
17
21
  export {};
@@ -6,6 +6,7 @@ import { renderReferenceLookupBridges } from "../../components/render-list-refer
6
6
  import { enrichReferenceColumns, selectReferenceColumns, } from "../../components/render-list-reference-columns.js";
7
7
  import { useReferenceColumnLookups } from "../../components/use-reference-column-lookups.js";
8
8
  import { DashboardListTable } from "../widgets/dashboard-list.js";
9
+ import { DashboardListCards } from "../widgets/dashboard-list-cards.js";
9
10
  function toReferenceViewColumn(column, featureName) {
10
11
  if (column.reference === undefined)
11
12
  return undefined;
@@ -22,7 +23,7 @@ function toReferenceViewColumn(column, featureName) {
22
23
  }
23
24
  // Dashboard list rows carry raw ids; reference columns resolve them to the target's label
24
25
  // the way entity lists do.
25
- export function DashboardReferenceListTable({ columns, rows, featureName, translate, ...tableProps }) {
26
+ export function DashboardReferenceListTable({ columns, rows, featureName, translate, narrowCards = false, titleField, ...tableProps }) {
26
27
  const viewColumns = useMemo(() => columns.flatMap((column) => {
27
28
  const viewColumn = toReferenceViewColumn(column, featureName);
28
29
  return viewColumn === undefined ? [] : [viewColumn];
@@ -39,9 +40,16 @@ export function DashboardReferenceListTable({ columns, rows, featureName, transl
39
40
  translate,
40
41
  }), [viewColumns, referenceColumns, referenceLookups, resolveReferenceLink, featureName, translate]);
41
42
  const tableColumns = columns.map((column) => {
42
- const renderer = enriched.find((c) => c.field === column.field)?.renderer;
43
+ const enrichedColumn = enriched.find((c) => c.field === column.field);
44
+ const renderer = enrichedColumn?.renderer;
43
45
  const { reference: _reference, ...base } = column;
44
- return typeof renderer === "function" ? { ...base, renderValue: renderer } : base;
46
+ if (typeof renderer !== "function")
47
+ return base;
48
+ return {
49
+ ...base,
50
+ renderValue: renderer,
51
+ ...(enrichedColumn?.linkFor !== undefined && { linkFor: enrichedColumn.linkFor }),
52
+ };
45
53
  });
46
- return (_jsxs(_Fragment, { children: [renderReferenceLookupBridges(referenceRequests, handleLookupMap), _jsx(DashboardListTable, { columns: tableColumns, rows: rows, translate: translate, ...tableProps })] }));
54
+ return (_jsxs(_Fragment, { children: [renderReferenceLookupBridges(referenceRequests, handleLookupMap), narrowCards ? (_jsx(DashboardListCards, { columns: tableColumns, rows: rows, translate: translate, formatPercent: tableProps.formatPercent, formatNumber: tableProps.formatNumber, formatDateTime: tableProps.formatDateTime, ...(tableProps.testId !== undefined && { testId: tableProps.testId }), ...(tableProps.rowToneField !== undefined && { rowToneField: tableProps.rowToneField }), ...(titleField !== undefined && { titleField }) })) : (_jsx(DashboardListTable, { columns: tableColumns, rows: rows, translate: translate, ...tableProps }))] }));
47
55
  }
@@ -2,8 +2,11 @@ import type { DashboardCurrencyFormat, DashboardPanelEmptyState, DashboardPanelQ
2
2
  import { type ReactNode } from "react";
3
3
  import { type Translate } from "../../headless/index.ts";
4
4
  import { dispatcherErrorText, type UseQueryResult } from "../../index.ts";
5
- export declare const WIDE_PANEL = "sm:col-span-2 lg:col-span-4";
6
- export declare const HALF_PANEL = "sm:col-span-2 lg:col-span-2";
5
+ export declare const STAT_PANEL = "lg:col-span-3";
6
+ export declare const WIDE_PANEL = "sm:col-span-2 lg:col-span-12";
7
+ export declare const HALF_PANEL = "sm:col-span-2 lg:col-span-6";
8
+ export declare const THIRD_PANEL = "lg:col-span-4";
9
+ export declare const TWO_THIRDS_PANEL = "sm:col-span-2 lg:col-span-8";
7
10
  export declare const HOUR_MS = 3600000;
8
11
  export declare const DAY_MS: number;
9
12
  export type ScreenParams = {
@@ -41,6 +44,8 @@ export type DashboardFormats = {
41
44
  readonly formatMonth: (atMs: number) => string;
42
45
  readonly formatHour: (atMs: number) => string;
43
46
  readonly formatDateTime: (atMs: number) => string;
47
+ /** Weekday and full date, no time: "Tuesday, 3 November 2026". */
48
+ readonly formatLongDate: (atMs: number) => string;
44
49
  readonly formatMedium: (atMs: number) => string;
45
50
  readonly formatMinor: (amountMinor: number, currency: string, fractionDigits?: number) => string;
46
51
  /** "5 minutes ago"; the component that called `useDashboardFormats` redraws on a
@@ -52,11 +57,13 @@ export type DashboardFormats = {
52
57
  readonly formatPanelAxisValue: (valueFormat: DashboardCurrencyFormat | undefined) => (value: number) => string;
53
58
  };
54
59
  export declare function useDashboardFormats(): DashboardFormats;
55
- export declare function PanelShell({ testId, title, subtitle, action, children, }: {
60
+ export declare function PanelShell({ testId, title, subtitle, action, footer, children, }: {
56
61
  readonly testId: string;
57
- readonly title: string;
62
+ /** Without a title the panel has no header (a titleless stat-group). */
63
+ readonly title?: string;
58
64
  readonly subtitle?: string;
59
65
  readonly action?: ReactNode;
66
+ readonly footer?: ReactNode;
60
67
  readonly children: ReactNode;
61
68
  }): ReactNode;
62
69
  export declare function PanelError({ label, error, onRetry, testId, }: {
@@ -66,14 +73,23 @@ export declare function PanelError({ label, error, onRetry, testId, }: {
66
73
  readonly testId?: string;
67
74
  }): ReactNode;
68
75
  type SkeletonShape = "bars" | "segments" | "rows";
76
+ export declare function PanelSkeleton({ shape }: {
77
+ readonly shape: SkeletonShape;
78
+ }): ReactNode;
69
79
  type QueryPanelProps<TData> = {
70
80
  readonly panel: DashboardPanelQueryOptions & DashboardPanelEmptyState & {
71
81
  readonly id: string;
72
82
  readonly query: string;
73
83
  };
74
84
  readonly label: string;
75
- readonly subtitle?: string;
85
+ /** A function derives the line from the loaded data (e.g. "n of m"); `staticSubtitle` stands in until then. */
86
+ readonly subtitle?: string | ((data: TData) => string | undefined);
87
+ readonly staticSubtitle?: string;
76
88
  readonly action?: ReactNode;
89
+ /** Rendered under the body, only once data is shown. */
90
+ readonly footer?: (data: TData) => ReactNode;
91
+ /** Replaces the whole panel shell once data is shown, e.g. a one-line summary on phones. */
92
+ readonly replaceShell?: (data: TData) => ReactNode;
77
93
  readonly screenParams: ScreenParams;
78
94
  readonly translate: Translate;
79
95
  readonly skeleton: SkeletonShape;
@@ -82,11 +98,11 @@ type QueryPanelProps<TData> = {
82
98
  * redraws this panel and nothing else. */
83
99
  readonly children: (data: TData, formats: DashboardFormats) => ReactNode;
84
100
  };
85
- export declare function QueryPanel<TData>({ panel, label, subtitle, action, screenParams, translate, skeleton, isEmpty, children, }: QueryPanelProps<TData>): ReactNode;
101
+ export declare function QueryPanel<TData>({ panel, label, subtitle, staticSubtitle, action, footer, replaceShell, screenParams, translate, skeleton, isEmpty, children, }: QueryPanelProps<TData>): ReactNode;
86
102
  export declare function useLoadedAt(screenParams: ScreenParams): {
87
103
  readonly loadedAtMs: number;
88
104
  readonly reportLoaded: (atMs: number) => void;
89
105
  };
90
106
  export declare const PanelLoadedContext: import("react").Context<(atMs: number) => void>;
91
- export declare function useReportPanelLoaded(data: unknown): void;
107
+ export declare function useReportPanelLoaded(data: unknown, loading: boolean): void;
92
108
  export {};
@@ -2,14 +2,19 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { createContext, useCallback, useContext, useEffect, useRef, useState, } from "react";
3
3
  import { currencyDecimals } from "../../headless/index.js";
4
4
  import { dispatcherErrorText, useLocale, usePrimitives, useQuery, useTranslation, } from "../../index.js";
5
+ import { serverNowMs } from "../../server-clock.js";
5
6
  import { resolveSafeLocale } from "../primitives/locale-number.js";
6
7
  import { formatMoney } from "../primitives/money-input.js";
7
8
  import { Skeleton } from "../ui/skeleton.js";
8
9
  import { EmptyState, LoadingState } from "../widgets/states.js";
9
10
  import { useRelativeTimeFormatter } from "./relative-time.js";
10
11
  const SKELETON_SEGMENT_WIDTHS = ["100%", "72%", "48%"];
11
- export const WIDE_PANEL = "sm:col-span-2 lg:col-span-4";
12
- export const HALF_PANEL = "sm:col-span-2 lg:col-span-2";
12
+ // The dashboard grid has twelve columns on wide screens, so a stat tile is a quarter of the row.
13
+ export const STAT_PANEL = "lg:col-span-3";
14
+ export const WIDE_PANEL = "sm:col-span-2 lg:col-span-12";
15
+ export const HALF_PANEL = "sm:col-span-2 lg:col-span-6";
16
+ export const THIRD_PANEL = "lg:col-span-4";
17
+ export const TWO_THIRDS_PANEL = "sm:col-span-2 lg:col-span-8";
13
18
  const CURRENCY_CODE_PATTERN = /^[A-Za-z]{3}$/;
14
19
  export const HOUR_MS = 3_600_000;
15
20
  export const DAY_MS = 24 * HOUR_MS;
@@ -80,6 +85,7 @@ export function useDashboardFormats() {
80
85
  timeStyle: "short",
81
86
  timeZone,
82
87
  });
88
+ const longDate = new Intl.DateTimeFormat(locale, { dateStyle: "full", timeZone });
83
89
  const medium = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeZone });
84
90
  const formatMinor = (amountMinor, currency, fractionDigits) => formatMoney(amountMinor, currency, locale, fractionDigits);
85
91
  return {
@@ -108,17 +114,18 @@ export function useDashboardFormats() {
108
114
  formatMonth: (atMs) => month.format(atMs),
109
115
  formatHour: (atMs) => hour.format(atMs),
110
116
  formatDateTime: (atMs) => dateTime.format(atMs),
117
+ formatLongDate: (atMs) => longDate.format(atMs),
111
118
  };
112
119
  }
113
- export function PanelShell({ testId, title, subtitle, action, children, }) {
114
- return (_jsxs("section", { "data-testid": testId, className: "flex h-full flex-col rounded-lg border border-border bg-card text-card-foreground", children: [_jsxs("header", { className: "flex min-h-11 shrink-0 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b border-border-row px-4 py-2", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-0.5", children: [_jsx("h2", { className: "text-sm font-semibold break-words", children: title }), subtitle !== undefined && _jsx("p", { className: "text-xs text-muted-foreground", children: subtitle })] }), action !== undefined && _jsx("div", { className: "shrink-0", children: action })] }), _jsx("div", { className: "grow p-4", children: children })] }));
120
+ export function PanelShell({ testId, title, subtitle, action, footer, children, }) {
121
+ return (_jsxs("section", { "data-testid": testId, className: "flex h-full flex-col rounded-lg border border-border bg-card text-card-foreground", children: [(title !== undefined || action !== undefined) && (_jsxs("header", { className: "flex min-h-11 shrink-0 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b border-border-row px-4 py-2", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-0.5 sm:flex-row sm:flex-wrap sm:items-baseline sm:gap-x-3", children: [title !== undefined && _jsx("h2", { className: "text-sm font-semibold break-words", children: title }), subtitle !== undefined && _jsx("p", { className: "text-xs text-muted-foreground", children: subtitle })] }), action !== undefined && _jsx("div", { className: "shrink-0", children: action })] })), _jsx("div", { className: "grow p-4", children: children }), footer !== undefined && (_jsx("footer", { className: "flex shrink-0 flex-wrap items-center gap-x-1 border-t border-border-row px-4 py-2 text-xs text-muted-foreground", children: footer }))] }));
115
122
  }
116
123
  export function PanelError({ label, error, onRetry, testId, }) {
117
124
  const { Button } = usePrimitives();
118
125
  const t = useTranslation();
119
126
  return (_jsxs("div", { role: "alert", "data-testid": testId, className: "flex flex-col items-start gap-2 rounded-lg border border-dashed border-status-bad/40 px-4 py-6 text-sm", children: [_jsx("div", { className: "font-medium text-status-bad", children: t("kumiko.dashboard.panel.error.title", { label }) }), _jsx("div", { className: "text-muted-foreground", children: dispatcherErrorText(error, t) }), _jsx(Button, { variant: "secondary", onClick: onRetry, children: t("kumiko.dashboard.panel.error.retry") }), _jsx("div", { className: "text-xs text-muted-foreground", children: t("kumiko.dashboard.panel.error.isolated") })] }));
120
127
  }
121
- function PanelSkeleton({ shape }) {
128
+ export function PanelSkeleton({ shape }) {
122
129
  const t = useTranslation();
123
130
  if (shape === "rows")
124
131
  return _jsx(LoadingState, { rows: 3 });
@@ -127,11 +134,19 @@ function PanelSkeleton({ shape }) {
127
134
  }
128
135
  return (_jsx("output", { "aria-label": t("kumiko.widget.loading"), className: "flex h-40 items-end gap-1", children: SKELETON_BAR_HEIGHTS.map((height) => (_jsx(Skeleton, { className: "flex-1", style: { height } }, height))) }));
129
136
  }
130
- export function QueryPanel({ panel, label, subtitle, action, screenParams, translate, skeleton, isEmpty, children, }) {
137
+ // Without loaded data the derived line cannot be computed; the static line keeps the header height
138
+ // from jumping when the data arrives.
139
+ function resolveSubtitle(subtitle, fallback, data) {
140
+ if (typeof subtitle !== "function")
141
+ return subtitle;
142
+ return data === undefined ? fallback : subtitle(data);
143
+ }
144
+ export function QueryPanel({ panel, label, subtitle, staticSubtitle, action, footer, replaceShell, screenParams, translate, skeleton, isEmpty, children, }) {
131
145
  const formats = useDashboardFormats();
132
146
  const { data, error, loading, refetch } = useDashboardQuery(panel.query, panelPayload(panel, screenParams));
133
- useReportPanelLoaded(data);
147
+ useReportPanelLoaded(data, loading);
134
148
  let body;
149
+ let shown;
135
150
  if (loading && data === null) {
136
151
  body = _jsx(PanelSkeleton, { shape: skeleton });
137
152
  }
@@ -142,30 +157,42 @@ export function QueryPanel({ panel, label, subtitle, action, screenParams, trans
142
157
  body = (_jsx(EmptyState, { title: translate(panel.emptyLabel ?? "kumiko.list.no-entries"), description: panel.emptyHint !== undefined ? translate(panel.emptyHint) : undefined }));
143
158
  }
144
159
  else {
160
+ shown = data;
145
161
  body = children(data, formats);
146
162
  }
147
- return (_jsx(PanelShell, { testId: `dashboard-panel-${panel.id}`, title: label, subtitle: subtitle, action: action, children: body }));
163
+ if (shown !== undefined && replaceShell !== undefined)
164
+ return replaceShell(shown);
165
+ return (_jsx(PanelShell, { testId: `dashboard-panel-${panel.id}`, title: label, subtitle: resolveSubtitle(subtitle, staticSubtitle, shown), action: action, footer: shown !== undefined ? footer?.(shown) : undefined, children: body }));
148
166
  }
149
167
  // Starts at render time and restarts whenever the merged query params change;
150
168
  // panels additionally report each successful (re)load, so live refetches and
151
- // retries keep the stamp current.
169
+ // retries keep the stamp current. An older report never replaces a newer answer-based stamp;
170
+ // the render-time stamp is only a guess from the device clock until the first answer, so
171
+ // that answer wins even when the app clock is pinned behind the device.
152
172
  export function useLoadedAt(screenParams) {
153
173
  const paramsKey = JSON.stringify([
154
174
  screenParams.filterParams,
155
175
  screenParams.rangeParams,
156
176
  screenParams.recordParams,
157
177
  ]);
158
- const [loaded, setLoaded] = useState(() => ({ paramsKey, atMs: Date.now() }));
159
- if (loaded.paramsKey !== paramsKey)
160
- setLoaded({ paramsKey, atMs: Date.now() });
161
- const reportLoaded = useCallback((atMs) => setLoaded((prev) => (prev.atMs >= atMs ? prev : { ...prev, atMs })), []);
178
+ const [loaded, setLoaded] = useState(() => ({
179
+ paramsKey,
180
+ atMs: serverNowMs(),
181
+ answered: false,
182
+ }));
183
+ if (loaded.paramsKey !== paramsKey) {
184
+ setLoaded({ paramsKey, atMs: serverNowMs(), answered: false });
185
+ }
186
+ const reportLoaded = useCallback((atMs) => setLoaded((prev) => prev.answered && prev.atMs >= atMs ? prev : { ...prev, atMs, answered: true }), []);
162
187
  return { loadedAtMs: loaded.atMs, reportLoaded };
163
188
  }
164
189
  export const PanelLoadedContext = createContext(() => { });
165
- export function useReportPanelLoaded(data) {
190
+ // While `loading`, `data` still holds the answer to the previous params (useQuery keeps it
191
+ // until the new one lands), so only a settled answer may stamp the header.
192
+ export function useReportPanelLoaded(data, loading) {
166
193
  const reportLoaded = useContext(PanelLoadedContext);
167
194
  useEffect(() => {
168
- if (data !== null)
169
- reportLoaded(Date.now());
170
- }, [data, reportLoaded]);
195
+ if (data !== null && !loading)
196
+ reportLoaded(serverNowMs());
197
+ }, [data, loading, reportLoaded]);
171
198
  }
@@ -0,0 +1,13 @@
1
+ import type { DashboardStatGroupPanel } from "@cosmicdrift/kumiko-framework/ui-types";
2
+ import type { ReactNode } from "react";
3
+ import type { Translate } from "../../headless/index.ts";
4
+ import { type ScreenParams } from "./dashboard-shared.tsx";
5
+ type StatGroupProps = {
6
+ readonly panel: DashboardStatGroupPanel;
7
+ readonly label: string | undefined;
8
+ readonly screenId: string;
9
+ readonly screenParams: ScreenParams;
10
+ readonly translate: Translate;
11
+ };
12
+ export declare function StatGroupPanelBody(props: StatGroupProps): ReactNode;
13
+ export {};
@@ -0,0 +1,67 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ChevronRight } from "lucide-react";
3
+ import { useNav } from "../../app/nav.js";
4
+ import { navigateTargetAllows } from "../../app/screen-access.js";
5
+ import { extensionSectionName, useAppFeatures, useExtensionSectionComponent, usePrimitives, useUserRoles, } from "../../index.js";
6
+ import { cn } from "../lib/cn.js";
7
+ import { STAT_CARD_GRID_CLASSES } from "../widgets/stat.js";
8
+ import { dashboardNavigationLink } from "./dashboard-navigation-link.js";
9
+ import { StatPanelBody } from "./dashboard-panels.js";
10
+ import { PanelShell } from "./dashboard-shared.js";
11
+ // Literal class strings: Tailwind only emits classes it can read in the source.
12
+ const STAT_CARD_COLUMN_CLASSES = {
13
+ 2: "grid grid-cols-1 gap-3 sm:grid-cols-2",
14
+ 3: "grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-3",
15
+ 4: "grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-4",
16
+ };
17
+ // Literal class strings: Tailwind only emits classes it can read in the source.
18
+ const PHONE_STRIP_TONE_CLASS = {
19
+ accent: "max-sm:border-primary/30 max-sm:bg-primary/10",
20
+ ok: "max-sm:border-status-ok/30 max-sm:bg-status-ok-surface",
21
+ warn: "max-sm:border-status-warn/30 max-sm:bg-status-warn-surface",
22
+ bad: "max-sm:border-status-bad/30 max-sm:bg-status-bad-surface",
23
+ critical: "max-sm:border-status-critical/30 max-sm:bg-status-critical-surface",
24
+ neutral: "",
25
+ };
26
+ function StatGroupLink({ link, translate, stretchOnNarrow, }) {
27
+ const { Link } = usePrimitives();
28
+ const nav = useNav();
29
+ const appFeatures = useAppFeatures();
30
+ const userRoles = useUserRoles();
31
+ if (!navigateTargetAllows({ screen: link.screen }, appFeatures, userRoles))
32
+ return null;
33
+ const target = dashboardNavigationLink(nav, link);
34
+ return (_jsxs(Link, { href: target.href, onPress: target.onPress, testId: "dashboard-stat-group-link", className: stretchOnNarrow
35
+ ? "ml-auto flex shrink-0 items-center gap-1 text-sm font-medium max-sm:after:absolute max-sm:after:inset-0"
36
+ : "ml-auto flex shrink-0 items-center gap-1 text-sm font-medium", children: [_jsx("span", { className: stretchOnNarrow ? "max-sm:sr-only" : undefined, children: translate(link.label) }), _jsx(ChevronRight, { className: "size-4", "aria-hidden": "true" })] }));
37
+ }
38
+ function StatCells({ panel, screenId, screenParams, translate, variant, }) {
39
+ return panel.stats.map((stat) => (_jsx(StatPanelBody, { panel: stat, label: translate(stat.label), screenId: screenId, screenParams: screenParams, translate: translate, variant: variant }, stat.id)));
40
+ }
41
+ function FlatStatStrip(props) {
42
+ const { panel, translate } = props;
43
+ return (_jsxs("div", { "data-testid": `dashboard-panel-${panel.id}`, className: "rounded-lg border border-border bg-card py-1 lg:flex lg:items-center", children: [_jsx("div", { className: "grid grow grid-cols-2 gap-y-2 lg:auto-cols-fr lg:grid-flow-col lg:divide-x lg:divide-border-row", children: _jsx(StatCells, { ...props, variant: "strip" }) }), panel.link !== undefined && (_jsx("div", { className: "flex px-4 max-lg:pt-1 lg:shrink-0", children: _jsx(StatGroupLink, { link: panel.link, translate: translate, stretchOnNarrow: false }) }))] }));
44
+ }
45
+ function PhoneStripIcon({ panel, screenId, screenParams, }) {
46
+ const Icon = useExtensionSectionComponent(panel.icon !== undefined ? extensionSectionName(panel.icon) : undefined);
47
+ if (Icon === undefined)
48
+ return null;
49
+ return (_jsx("span", { className: "flex shrink-0 items-center self-center sm:hidden", children: _jsx(Icon, { entityName: screenId, entityId: null, screenId: screenId, filterParams: screenParams.filterParams }) }));
50
+ }
51
+ function TitledStatStrip(props) {
52
+ const { panel, label, translate } = props;
53
+ return (_jsxs("div", { "data-testid": `dashboard-panel-${panel.id}`, "data-narrow-tone": panel.narrow?.tone, className: cn("relative flex items-center gap-x-4 rounded-lg border border-border bg-card px-4 py-3 max-sm:items-baseline max-sm:gap-x-2 max-sm:overflow-hidden max-sm:py-2", panel.narrow?.tone !== undefined && PHONE_STRIP_TONE_CLASS[panel.narrow.tone]), children: [_jsx(PhoneStripIcon, { panel: panel, screenId: props.screenId, screenParams: props.screenParams }), _jsxs("div", { className: "flex min-w-0 shrink-0 flex-col max-sm:flex-row max-sm:items-baseline", children: [_jsx("h2", { className: "text-sm font-semibold max-sm:after:ml-2 max-sm:after:font-normal max-sm:after:text-muted-foreground max-sm:after:content-['\u00B7']", children: label }), panel.subtitle !== undefined && (_jsx("p", { className: "text-xs text-muted-foreground max-sm:hidden", children: translate(panel.subtitle) }))] }), _jsx("div", { className: "flex min-w-0 items-stretch gap-3 max-sm:block max-sm:grow max-sm:truncate max-sm:text-sm", children: panel.stats.map((stat) => (_jsx("div", { className: `flex min-w-0 max-sm:inline max-sm:[&_a]:inline max-sm:[&:not(:last-child)]:after:mx-1.5 max-sm:[&:not(:last-child)]:after:text-muted-foreground max-sm:[&:not(:last-child)]:after:content-['·'] [&>*]:min-w-0${stat.navigate !== undefined ? " max-sm:relative max-sm:z-10" : ""}`, children: _jsx(StatPanelBody, { panel: stat, label: translate(stat.label), screenId: props.screenId, screenParams: props.screenParams, translate: translate, variant: "strip-compact" }) }, stat.id))) }), panel.link !== undefined && (_jsx(StatGroupLink, { link: panel.link, translate: translate, stretchOnNarrow: true }))] }));
54
+ }
55
+ export function StatGroupPanelBody(props) {
56
+ const { panel, label, translate } = props;
57
+ const layout = panel.layout ?? (label === undefined ? "strip" : "cards");
58
+ if (layout === "strip") {
59
+ return label === undefined ? (_jsx(FlatStatStrip, { ...props })) : (_jsx(TitledStatStrip, { ...props, label: label }));
60
+ }
61
+ const cells = (_jsx("section", { className: panel.columns === undefined
62
+ ? STAT_CARD_GRID_CLASSES
63
+ : STAT_CARD_COLUMN_CLASSES[panel.columns], children: _jsx(StatCells, { ...props, variant: "card" }) }));
64
+ return (_jsx(PanelShell, { testId: `dashboard-panel-${panel.id}`, ...(label !== undefined && { title: label }), ...(panel.subtitle !== undefined && { subtitle: translate(panel.subtitle) }), ...(panel.link !== undefined && {
65
+ action: _jsx(StatGroupLink, { link: panel.link, translate: translate, stretchOnNarrow: false }),
66
+ }), children: cells }));
67
+ }
@@ -0,0 +1,12 @@
1
+ import type { DashboardTextPanel } from "@cosmicdrift/kumiko-framework/ui-types";
2
+ import type { ReactNode } from "react";
3
+ import type { Translate } from "../../headless/index.ts";
4
+ import { type ScreenParams } from "./dashboard-shared.tsx";
5
+ type TextPanelBodyProps = {
6
+ readonly panel: DashboardTextPanel;
7
+ readonly label: string | undefined;
8
+ readonly screenParams: ScreenParams;
9
+ readonly translate: Translate;
10
+ };
11
+ export declare function TextPanelBody(props: TextPanelBodyProps): ReactNode;
12
+ export {};