@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
@@ -0,0 +1,163 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { navigateTargetAllows } from "../../app/screen-access.js";
3
+ import { lastSegment, useAppFeatures, useNav, usePrimitives, useUserRoles } from "../../index.js";
4
+ import { useIsBelowSmViewport } from "../primitives/use-narrow-viewport.js";
5
+ import { PanelError, PanelShell, PanelSkeleton, panelPayload, useDashboardFormats, useDashboardQuery, useReportPanelLoaded, } from "./dashboard-shared.js";
6
+ import { isDashboardI18nText, isRecord, resolveDashboardText } from "./dashboard-text.js";
7
+ function isDashboardText(value) {
8
+ return typeof value === "string" || isDashboardI18nText(value);
9
+ }
10
+ function isRoleList(value) {
11
+ return Array.isArray(value) && value.every((role) => typeof role === "string");
12
+ }
13
+ function readParagraphBlock(raw) {
14
+ const { text, emphasis } = raw;
15
+ if (!isDashboardText(text))
16
+ return undefined;
17
+ return {
18
+ kind: "paragraph",
19
+ text,
20
+ ...((emphasis === "muted" || emphasis === "strong" || emphasis === "lead") && { emphasis }),
21
+ };
22
+ }
23
+ function readLinkBlock(raw) {
24
+ const { text, screen, roles } = raw;
25
+ if (!isDashboardText(text) || typeof screen !== "string" || screen === "")
26
+ return undefined;
27
+ return { kind: "link", text, screen, ...(isRoleList(roles) && { roles }) };
28
+ }
29
+ // A query answers untyped JSON: one guard per block kind, so a malformed block is dropped
30
+ // instead of crashing the panel.
31
+ const QUERY_BLOCK_READERS = {
32
+ heading: ({ text }) => (isDashboardText(text) ? { kind: "heading", text } : undefined),
33
+ hint: ({ text }) => (isDashboardText(text) ? { kind: "hint", text } : undefined),
34
+ paragraph: readParagraphBlock,
35
+ list: ({ items }) => Array.isArray(items) && items.every(isDashboardText) ? { kind: "list", items } : undefined,
36
+ code: ({ code }) => (typeof code === "string" ? { kind: "code", code } : undefined),
37
+ link: readLinkBlock,
38
+ };
39
+ function isBlockKind(value) {
40
+ return typeof value === "string" && Object.hasOwn(QUERY_BLOCK_READERS, value);
41
+ }
42
+ function readQueryBlock(raw) {
43
+ if (!isRecord(raw) || !isBlockKind(raw["kind"]))
44
+ return undefined;
45
+ return QUERY_BLOCK_READERS[raw["kind"]](raw);
46
+ }
47
+ function readQueryBlocks(data, key) {
48
+ const blocks = isRecord(data) ? data[key] : undefined;
49
+ if (!Array.isArray(blocks))
50
+ return [];
51
+ return blocks.flatMap((raw) => {
52
+ const block = readQueryBlock(raw);
53
+ return block === undefined ? [] : [block];
54
+ });
55
+ }
56
+ function resolveBlockText(text, translate, formats) {
57
+ return typeof text === "string"
58
+ ? translate(text)
59
+ : (resolveDashboardText(text, translate, formats) ?? "");
60
+ }
61
+ const PARAGRAPH_CLASS_NAMES = {
62
+ muted: "text-sm text-muted-foreground",
63
+ strong: "text-sm font-medium text-foreground",
64
+ lead: "font-heading text-[15.5px] leading-[1.5] sm:text-[17px] sm:leading-relaxed text-foreground",
65
+ };
66
+ function TextBlockView({ block, translate, }) {
67
+ const formats = useDashboardFormats();
68
+ const resolve = (text) => resolveBlockText(text, translate, formats);
69
+ switch (block.kind) {
70
+ case "heading":
71
+ return (_jsx("h3", { "data-block": "heading", className: "text-sm font-semibold text-foreground", children: resolve(block.text) }));
72
+ case "paragraph":
73
+ return (_jsx("p", { "data-block": "paragraph", className: PARAGRAPH_CLASS_NAMES[block.emphasis ?? "muted"], children: resolve(block.text) }));
74
+ case "list":
75
+ return (_jsx("ul", { "data-block": "list", className: "list-disc space-y-1 pl-5 text-sm text-muted-foreground", children: withOccurrenceKeys(block.items, textKey).map(({ entry, key }) => (_jsx("li", { children: resolve(entry) }, key))) }));
76
+ case "code":
77
+ return (_jsx("pre", { "data-block": "code", className: "overflow-x-auto rounded-md bg-muted p-3 text-xs", children: _jsx("code", { children: block.code }) }));
78
+ case "hint":
79
+ return (_jsx("p", { "data-block": "hint", className: "text-xs text-muted-foreground", children: resolve(block.text) }));
80
+ case "link":
81
+ return _jsx(TextBlockLink, { block: block, resolve: resolve });
82
+ }
83
+ }
84
+ function TextBlockLink({ block, resolve, }) {
85
+ const { Link } = usePrimitives();
86
+ const nav = useNav();
87
+ const userRoles = useUserRoles();
88
+ const appFeatures = useAppFeatures();
89
+ if (block.roles !== undefined && !block.roles.some((role) => userRoles?.includes(role))) {
90
+ return null;
91
+ }
92
+ const target = { screenId: lastSegment(block.screen) };
93
+ if (!navigateTargetAllows({ screen: target.screenId }, appFeatures, userRoles))
94
+ return null;
95
+ return (_jsx(Link, { href: nav.hrefFor(target), onPress: () => nav.navigate(target), testId: `dashboard-text-link-${target.screenId}`, children: resolve(block.text) }));
96
+ }
97
+ // Content-derived keys collide for identical entries; the occurrence count keeps them unique.
98
+ function withOccurrenceKeys(entries, contentKey) {
99
+ const seen = new Map();
100
+ return entries.map((entry) => {
101
+ const content = contentKey(entry);
102
+ const occurrence = seen.get(content) ?? 0;
103
+ seen.set(content, occurrence + 1);
104
+ return { entry, key: `${content}#${occurrence}` };
105
+ });
106
+ }
107
+ function textKey(text) {
108
+ return typeof text === "string" ? text : JSON.stringify(text);
109
+ }
110
+ function textBlockKey(block) {
111
+ switch (block.kind) {
112
+ case "list":
113
+ return `list:${block.items.map(textKey).join("|")}`;
114
+ case "code":
115
+ return `code:${block.code}`;
116
+ default:
117
+ return `${block.kind}:${textKey(block.text)}`;
118
+ }
119
+ }
120
+ function TextPanelFrame({ panel, label, children, }) {
121
+ const testId = `dashboard-panel-${panel.id}`;
122
+ if (label !== undefined) {
123
+ return (_jsx(PanelShell, { testId: testId, title: label, children: children }));
124
+ }
125
+ return (_jsx("section", { "data-testid": testId, className: "h-full rounded-lg border border-border bg-card p-4 text-card-foreground", children: children }));
126
+ }
127
+ function TextBlockList({ blocks, translate, }) {
128
+ return (_jsx("div", { className: "flex flex-col gap-3", children: withOccurrenceKeys(blocks, textBlockKey).map(({ entry, key }) => (_jsx(TextBlockView, { block: entry, translate: translate }, key))) }));
129
+ }
130
+ export function TextPanelBody(props) {
131
+ const { panel, label, translate } = props;
132
+ const narrow = useIsBelowSmViewport();
133
+ if (panel.query === undefined) {
134
+ return (_jsx(TextPanelFrame, { panel: panel, label: label, children: _jsx(TextBlockList, { blocks: (narrow ? panel.narrowBlocks : undefined) ?? panel.blocks ?? [], translate: translate }) }));
135
+ }
136
+ return _jsx(QueryTextPanelBody, { ...props, query: panel.query });
137
+ }
138
+ // Not QueryPanel: that shell shows a skeleton/error/empty state instead of content, but the
139
+ // static blocks are the fallback here and must stay visible while the query loads, fails or is empty.
140
+ function QueryTextPanelBody({ panel, query, label, screenParams, translate, }) {
141
+ const { data, error, loading, refetch } = useDashboardQuery(query, panelPayload(panel, screenParams));
142
+ useReportPanelLoaded(data, loading);
143
+ const narrow = useIsBelowSmViewport();
144
+ const queriedNarrow = narrow ? readQueryBlocks(data, "narrowBlocks") : [];
145
+ const queriedWide = readQueryBlocks(data, "blocks");
146
+ const queried = queriedNarrow.length > 0 ? queriedNarrow : queriedWide;
147
+ const staticBlocks = (narrow ? panel.narrowBlocks : undefined) ?? panel.blocks ?? [];
148
+ const blocks = queried.length > 0 ? queried : staticBlocks;
149
+ let body;
150
+ if (blocks.length > 0) {
151
+ body = _jsx(TextBlockList, { blocks: blocks, translate: translate });
152
+ }
153
+ else if (error !== null) {
154
+ body = _jsx(PanelError, { label: label ?? "", error: error, onRetry: () => void refetch() });
155
+ }
156
+ else if (loading && data === null) {
157
+ body = _jsx(PanelSkeleton, { shape: "rows" });
158
+ }
159
+ else {
160
+ body = null;
161
+ }
162
+ return (_jsx(TextPanelFrame, { panel: panel, label: label, children: body }));
163
+ }
@@ -1,6 +1,8 @@
1
+ import type { DashboardI18nText } from "@cosmicdrift/kumiko-framework/ui-types";
1
2
  import type { Translate } from "../../headless/index.ts";
2
3
  import type { DashboardFormats } from "./dashboard-shared.tsx";
3
4
  export declare function isRecord(value: unknown): value is Readonly<Record<string, unknown>>;
5
+ export declare function isDashboardI18nText(value: unknown): value is DashboardI18nText;
4
6
  /** Plain strings pass through; DashboardI18nText is translated (nested params first).
5
7
  * Anything else yields undefined so callers fall back to their own placeholder. */
6
8
  export declare function resolveDashboardText(value: unknown, translate: Translate, formats: DashboardFormats): string | undefined;
@@ -2,7 +2,7 @@ const MAX_TEXT_PARAM_DEPTH = 4;
2
2
  export function isRecord(value) {
3
3
  return typeof value === "object" && value !== null && !Array.isArray(value);
4
4
  }
5
- function isDashboardI18nText(value) {
5
+ export function isDashboardI18nText(value) {
6
6
  return isRecord(value) && typeof value["i18nKey"] === "string";
7
7
  }
8
8
  function isMoneyParam(value) {
@@ -15,7 +15,7 @@ function panelVisibilityGate(panel, screenParams) {
15
15
  return undefined;
16
16
  if (panel.kind === "screen")
17
17
  return visibilityGate(panel.visibleWhen.query, NO_GATE_PAYLOAD);
18
- const dropsFilter = panel.kind !== "stat-group" && panel.kind !== "text" && panel.ignoreScreenFilter === true;
18
+ const dropsFilter = panel.kind !== "stat-group" && panel.ignoreScreenFilter === true;
19
19
  return visibilityGate(panel.visibleWhen.query, {
20
20
  ...(dropsFilter ? {} : screenParams.filterParams),
21
21
  ...screenParams.rangeParams,
@@ -1,4 +1,5 @@
1
1
  import { useEffect, useRef, useState } from "react";
2
+ import { serverNowMs } from "../../server-clock.js";
2
3
  import { resolveSafeLocale } from "../primitives/locale-number.js";
3
4
  const SECONDS_PER_MINUTE = 60;
4
5
  const MINUTES_PER_HOUR = 60;
@@ -49,7 +50,7 @@ export function useRelativeTimeFormatter(locale) {
49
50
  return () => clearInterval(timer);
50
51
  }, [intervalMs]);
51
52
  return (atMs) => {
52
- const nowMs = Date.now();
53
+ const nowMs = serverNowMs();
53
54
  nearestDistanceMs.current = Math.min(nearestDistanceMs.current, Math.abs(atMs - nowMs));
54
55
  return formatRelativeTime(atMs, nowMs, locale);
55
56
  };
@@ -0,0 +1,28 @@
1
+ import type { ReactNode } from "react";
2
+ export type FooterTone = "bad" | "warn" | "ok";
3
+ export type EditorActionTestIds = {
4
+ readonly discard: string;
5
+ readonly save: string;
6
+ readonly publish: string;
7
+ };
8
+ export declare function EditorFooter({ testIdPrefix, actionTestIds, message, pendingMessage, saveError, modifiedAt, dirty, busy, canSave, canPublish, onDiscard, onSave, saveLabel, onPublish, }: {
9
+ readonly testIdPrefix: string;
10
+ readonly actionTestIds?: EditorActionTestIds;
11
+ readonly message: {
12
+ readonly tone: FooterTone;
13
+ readonly text: string;
14
+ } | null;
15
+ /** Shown while `message` is null (a check still running, or nothing to report). */
16
+ readonly pendingMessage?: string;
17
+ readonly saveError: string | null;
18
+ readonly modifiedAt: string | null;
19
+ readonly dirty: boolean;
20
+ readonly busy: boolean;
21
+ readonly canSave: boolean;
22
+ readonly canPublish?: boolean;
23
+ readonly onDiscard: () => void;
24
+ readonly onSave: () => void;
25
+ readonly saveLabel?: string;
26
+ /** Without it the footer has no publish button (content that is live as soon as it is saved). */
27
+ readonly onPublish?: () => void;
28
+ }): ReactNode;
@@ -0,0 +1,23 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useTranslation } from "../../i18n.js";
3
+ import { usePrimitives } from "../../primitives.js";
4
+ import { cn } from "../lib/cn.js";
5
+ import { formatRelativeWhen } from "./relative-when.js";
6
+ const FOOTER_TONE = {
7
+ ok: { text: "text-status-ok", glyph: "✓" },
8
+ warn: { text: "text-status-warn", glyph: "!" },
9
+ bad: { text: "text-status-bad", glyph: "!" },
10
+ };
11
+ const DEFAULT_ACTION_TEST_IDS = {
12
+ discard: "editor-discard",
13
+ save: "editor-save",
14
+ publish: "editor-publish",
15
+ };
16
+ export function EditorFooter({ testIdPrefix, actionTestIds = DEFAULT_ACTION_TEST_IDS, message, pendingMessage, saveError, modifiedAt, dirty, busy, canSave, canPublish, onDiscard, onSave, saveLabel, onPublish, }) {
17
+ const t = useTranslation();
18
+ const { Banner, Button, Text } = usePrimitives();
19
+ const tone = message === null ? null : FOOTER_TONE[message.tone];
20
+ return (_jsxs("div", { className: "flex items-center gap-4 border-t bg-background px-6 py-3", "data-testid": `${testIdPrefix}-footer`, children: [_jsxs("div", { className: "min-w-0 flex-1 text-sm", children: [saveError !== null ? (_jsx(Banner, { variant: "error", testId: `${testIdPrefix}-save-error`, children: saveError })) : (_jsx("span", { className: cn(tone === null ? "text-muted-foreground" : tone.text), "data-testid": `${testIdPrefix}-footer-message`, "data-tone": message?.tone, children: message === null
21
+ ? (pendingMessage ?? t("kumiko.editor.noChanges"))
22
+ : `${tone?.glyph ?? ""} ${message.text}` })), modifiedAt !== null && (_jsxs(_Fragment, { children: [" ", _jsx(Text, { variant: "muted", testId: `${testIdPrefix}-saved-at`, children: t("kumiko.editor.savedAt", { when: formatRelativeWhen(modifiedAt) }) })] }))] }), _jsxs("div", { className: "flex shrink-0 items-center gap-3", children: [_jsx(Button, { variant: "ghost", disabled: !dirty, onClick: onDiscard, testId: actionTestIds.discard, children: t("kumiko.editor.discard") }), _jsx(Button, { variant: onPublish === undefined ? "primary" : "secondary", disabled: !canSave, loading: busy, onClick: onSave, testId: actionTestIds.save, children: saveLabel ?? t("kumiko.actions.save") }), onPublish !== undefined && (_jsx(Button, { disabled: canPublish !== true, onClick: onPublish, testId: actionTestIds.publish, children: t("kumiko.editor.publish") }))] })] }));
23
+ }
@@ -0,0 +1,23 @@
1
+ import type { ReactNode } from "react";
2
+ export type InfoBarTone = "active" | "muted" | "warn";
3
+ export declare function EditorFrame({ testId, children, }: {
4
+ readonly testId: string;
5
+ readonly children: ReactNode;
6
+ }): ReactNode;
7
+ export declare function EditorInfoBar({ tone, testId, origin, controls, links, overlays, children, }: {
8
+ readonly tone: InfoBarTone;
9
+ readonly testId: string;
10
+ /** Badge in front of the text: where the content comes from. */
11
+ readonly origin?: ReactNode;
12
+ /** Right side, before the links: locale switch and the editor's secondary action. */
13
+ readonly controls?: ReactNode;
14
+ readonly links?: ReactNode;
15
+ readonly overlays?: ReactNode;
16
+ readonly children: ReactNode;
17
+ }): ReactNode;
18
+ export declare function EditorBody({ left, center, right, testId, }: {
19
+ readonly left?: ReactNode;
20
+ readonly center: ReactNode;
21
+ readonly right: ReactNode;
22
+ readonly testId?: string;
23
+ }): ReactNode;
@@ -0,0 +1,24 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "../lib/cn.js";
3
+ const INFO_BAR_TONE = {
4
+ active: "bg-primary/10",
5
+ muted: "bg-muted",
6
+ warn: "bg-status-warn-surface",
7
+ };
8
+ // Height below the shell header: the rails and the center scroll on their own.
9
+ export function EditorFrame({ testId, children, }) {
10
+ return (_jsx("div", { className: "flex h-[calc(100svh-var(--shell-header-height))] min-h-[600px] flex-col", "data-testid": testId, children: children }));
11
+ }
12
+ export function EditorInfoBar({ tone, testId, origin, controls, links, overlays, children, }) {
13
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: cn("flex items-start gap-4 border-b px-6 py-2 text-sm", INFO_BAR_TONE[tone]), "data-testid": testId, "data-variant": tone === "warn" ? "warn" : undefined, children: [_jsxs("span", { className: "min-w-0 flex-1", children: [origin, " ", children] }), controls !== undefined && (_jsx("div", { className: "flex shrink-0 items-center gap-2", children: controls })), links !== undefined && _jsx("div", { className: "flex shrink-0 items-center gap-4", children: links })] }), overlays] }));
14
+ }
15
+ export function EditorBody({ left, center, right, testId, }) {
16
+ const centerColumn = (_jsx("div", { className: "flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted", children: center }));
17
+ if (left === undefined) {
18
+ return (_jsxs("div", { className: "grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)_280px]", "data-testid": testId, children: [centerColumn, _jsx("aside", { className: "min-h-0 overflow-y-auto border-l bg-background", children: right })] }));
19
+ }
20
+ // Three columns leave a narrow window (1024px beside the app sidebar) too little room for the
21
+ // page: there both rails share the left column, one below the other, and the center keeps its width.
22
+ // DOM order stays left, center, right (focus order); only grid placement moves the rails.
23
+ return (_jsx("div", { className: "@container flex min-h-0 min-w-0 flex-1", "data-testid": testId, children: _jsxs("div", { className: "grid min-h-0 min-w-0 flex-1 grid-cols-[240px_minmax(0,1fr)_280px] @max-4xl:grid-cols-[240px_minmax(0,1fr)] @max-4xl:grid-rows-[minmax(0,1fr)_minmax(0,1fr)]", children: [_jsx("aside", { className: "min-h-0 overflow-y-auto border-r bg-background @max-4xl:col-start-1 @max-4xl:row-start-1 @max-4xl:border-b", children: left }), _jsx("div", { className: "flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted @max-4xl:col-start-2 @max-4xl:row-span-2 @max-4xl:row-start-1", children: center }), _jsx("aside", { className: "min-h-0 overflow-y-auto border-l bg-background @max-4xl:col-start-1 @max-4xl:row-start-2 @max-4xl:border-l-0 @max-4xl:border-r", children: right })] }) }));
24
+ }
@@ -0,0 +1,36 @@
1
+ import type { ReactNode } from "react";
2
+ export type EditorMode = "edit" | "preview";
3
+ export declare function EditorModeSwitch({ testIdPrefix, mode, onMode, }: {
4
+ readonly testIdPrefix: string;
5
+ readonly mode: EditorMode;
6
+ readonly onMode: (mode: EditorMode) => void;
7
+ }): ReactNode;
8
+ export declare function EditorLocaleSwitch({ testIdPrefix, locales, locale, onLocale, }: {
9
+ readonly testIdPrefix: string;
10
+ readonly locales: readonly string[];
11
+ readonly locale: string;
12
+ readonly onLocale: (locale: string) => void;
13
+ }): ReactNode;
14
+ export type EditorSaveActions = {
15
+ readonly busy: boolean;
16
+ readonly canSave: boolean;
17
+ readonly onSave: () => void;
18
+ /** Replaces "Save", e.g. "Create" for a record that does not exist yet. */
19
+ readonly saveLabel?: string;
20
+ /** Without them the header has no publish button. */
21
+ readonly canPublish?: boolean;
22
+ readonly onPublish?: () => void;
23
+ };
24
+ export type EditorHeaderTestIds = {
25
+ readonly save: string;
26
+ readonly publish: string;
27
+ };
28
+ export declare function EditorHeader({ title, status, actions, testIds, children, }: {
29
+ readonly title: string;
30
+ /** Badge next to the title, e.g. the stored version's state. */
31
+ readonly status?: ReactNode;
32
+ readonly actions: EditorSaveActions;
33
+ readonly testIds?: EditorHeaderTestIds;
34
+ /** View controls left of the save actions (mode or kind switch). */
35
+ readonly children: ReactNode;
36
+ }): ReactNode;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useTranslation } from "../../i18n.js";
3
+ import { usePrimitives } from "../../primitives.js";
4
+ import { ModeSwitch } from "../widgets/index.js";
5
+ export function EditorModeSwitch({ testIdPrefix, mode, onMode, }) {
6
+ const t = useTranslation();
7
+ return (_jsx(ModeSwitch, { value: mode, onChange: onMode, ariaLabel: t("kumiko.editor.modeSwitch"), testId: `${testIdPrefix}-mode-switch`, options: [
8
+ { value: "edit", label: t("kumiko.contentEditor.editMode") },
9
+ { value: "preview", label: t("kumiko.contentEditor.preview") },
10
+ ] }));
11
+ }
12
+ export function EditorLocaleSwitch({ testIdPrefix, locales, locale, onLocale, }) {
13
+ const t = useTranslation();
14
+ return (_jsx(ModeSwitch, { value: locale, onChange: onLocale, ariaLabel: t("kumiko.editor.localeSwitch"), testId: `${testIdPrefix}-locale-switch`, options: locales.map((code) => ({ value: code, label: code })) }));
15
+ }
16
+ const DEFAULT_HEADER_TEST_IDS = {
17
+ save: "editor-header-save",
18
+ publish: "editor-header-publish",
19
+ };
20
+ // Title, status and the save/publish actions live in the shell header. The origin badge, the
21
+ // locale switch and the secondary action sit in the info bar below: at 1280px next to the
22
+ // sidebar, assistant and theme toggle the header has no room for them and the title would clip.
23
+ export function EditorHeader({ title, status, actions, testIds = DEFAULT_HEADER_TEST_IDS, children, }) {
24
+ const t = useTranslation();
25
+ const { Button, PageHeader } = usePrimitives();
26
+ if (PageHeader === undefined)
27
+ return null;
28
+ const { onPublish } = actions;
29
+ return (_jsx(PageHeader, { title: title, status: status, actions: _jsxs("span", { className: "flex items-center gap-2 [&_button]:px-2.5 [&_button]:text-sm", children: [children, _jsxs("span", { className: "hidden items-center gap-2 xl:flex", children: [_jsx(Button, { variant: onPublish === undefined ? "primary" : "secondary", size: "sm", disabled: !actions.canSave, loading: actions.busy, onClick: actions.onSave, testId: testIds.save, children: actions.saveLabel ?? t("kumiko.actions.save") }), onPublish !== undefined && (_jsx(Button, { size: "sm", disabled: actions.canPublish !== true, onClick: onPublish, testId: testIds.publish, children: t("kumiko.editor.publish") }))] })] }) }));
30
+ }
@@ -0,0 +1,32 @@
1
+ import type { ReactNode } from "react";
2
+ export declare function RailSection({ title, action, testId, children, }: {
3
+ readonly title: string;
4
+ readonly action?: ReactNode;
5
+ readonly testId?: string;
6
+ readonly children: ReactNode;
7
+ }): ReactNode;
8
+ export declare function RailField({ children }: {
9
+ readonly children: ReactNode;
10
+ }): ReactNode;
11
+ declare const TRAILING_TONE: {
12
+ readonly ok: "text-status-ok";
13
+ readonly bad: "text-status-bad";
14
+ readonly muted: "text-muted-foreground";
15
+ };
16
+ export declare function RailRow({ symbol, label, nameHint, required, trailing, trailingTone, action, bad, testId, onPress, }: {
17
+ readonly symbol?: string;
18
+ readonly label: string;
19
+ /** Technical name behind a translated label, shown as tooltip. */
20
+ readonly nameHint?: string;
21
+ readonly required?: boolean;
22
+ readonly trailing?: ReactNode;
23
+ readonly trailingTone?: keyof typeof TRAILING_TONE;
24
+ readonly action?: ReactNode;
25
+ readonly bad?: boolean;
26
+ readonly testId?: string;
27
+ readonly onPress?: () => void;
28
+ }): ReactNode;
29
+ export declare function RailHint({ children }: {
30
+ readonly children: ReactNode;
31
+ }): ReactNode;
32
+ export {};
@@ -0,0 +1,37 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "../lib/cn.js";
3
+ export function RailSection({ title, action, testId, children, }) {
4
+ return (_jsxs("section", { className: "flex flex-col border-b pb-1", "data-testid": testId, children: [_jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1 px-3.5 pt-2.5 pb-1", children: [_jsx("span", { className: "min-w-0 text-xs font-medium uppercase tracking-wider text-muted-foreground", children: title }), action !== undefined && _jsx("div", { className: "ml-auto", children: action })] }), children] }));
5
+ }
6
+ export function RailField({ children }) {
7
+ return _jsx("div", { className: "flex flex-col gap-3 px-3.5 py-2", children: children });
8
+ }
9
+ const TRAILING_TONE = {
10
+ ok: "text-status-ok",
11
+ bad: "text-status-bad",
12
+ muted: "text-muted-foreground",
13
+ };
14
+ // The star rides on the last word so a wrapping label never leaves it alone on a line.
15
+ function RequiredLabel({ label }) {
16
+ const lastSpace = label.lastIndexOf(" ");
17
+ return (_jsxs(_Fragment, { children: [label.slice(0, lastSpace + 1), _jsxs("span", { className: "whitespace-nowrap", children: [label.slice(lastSpace + 1), _jsx("span", { className: "font-semibold text-status-bad", children: " *" })] })] }));
18
+ }
19
+ function RailSymbol({ symbol }) {
20
+ return (_jsx("span", { className: "inline-flex h-[18px] w-[22px] shrink-0 items-center justify-center rounded-sm bg-muted font-mono text-xs text-muted-foreground", children: symbol }));
21
+ }
22
+ function RailTrailing({ tone, bad, withAction, children, }) {
23
+ return (_jsx("span", { className: cn("min-w-0 text-xs", withAction ? "basis-full wrap-anywhere" : "truncate text-right", bad ? "text-status-bad" : TRAILING_TONE[tone]), title: typeof children === "string" ? children : undefined, children: children }));
24
+ }
25
+ export function RailRow({ symbol, label, nameHint, required, trailing, trailingTone = "muted", action, bad, testId, onPress, }) {
26
+ const content = (_jsxs(_Fragment, { children: [symbol !== undefined && _jsx(RailSymbol, { symbol: symbol }), _jsx("span", { className: cn(
27
+ // anywhere, not break-word: only it lets a file name without spaces narrow the min-content
28
+ // width, so the label wraps instead of running under the action.
29
+ "min-w-0 grow wrap-anywhere text-sm", trailing !== undefined && "min-w-min max-w-[65%] shrink-0", bad === true && "text-status-bad"), title: nameHint !== undefined && nameHint !== label ? nameHint : undefined, children: required === true ? _jsx(RequiredLabel, { label: label }) : label }), trailing !== undefined && (_jsx(RailTrailing, { tone: trailingTone, bad: bad === true, withAction: action !== undefined, children: trailing }))] }));
30
+ // Beside an action the row is too narrow for label and trailing text: the trailing text takes its
31
+ // own line and wraps there instead of being clipped to an ellipsis.
32
+ const rowClass = cn("flex min-h-10 min-w-0 grow items-center gap-2 px-3.5 text-left", action !== undefined && "flex-wrap gap-y-0.5 py-1");
33
+ return (_jsxs("div", { className: cn("flex items-center border-b", bad === true && "bg-status-bad-surface"), "data-testid": testId, "data-bad": bad === true ? "true" : undefined, children: [onPress === undefined ? (_jsx("div", { className: rowClass, children: content })) : (_jsx("button", { type: "button", onClick: onPress, className: cn(rowClass, "hover:bg-muted"), ...(testId !== undefined && { "data-testid": `${testId}-insert` }), children: content })), action !== undefined && _jsx("div", { className: "shrink-0 pr-2", children: action })] }));
34
+ }
35
+ export function RailHint({ children }) {
36
+ return _jsx("p", { className: "px-3.5 pt-1 pb-2 text-xs text-muted-foreground", children: children });
37
+ }
@@ -0,0 +1,34 @@
1
+ import { type ReactNode } from "react";
2
+ export type WorkbenchSave = {
3
+ readonly busy: boolean;
4
+ readonly canSave: boolean;
5
+ readonly dirty: boolean;
6
+ readonly onSave: () => void;
7
+ readonly saveLabel?: string;
8
+ readonly onDiscard: () => void;
9
+ readonly saveError: string | null;
10
+ readonly modifiedAt?: string | null;
11
+ };
12
+ export type EditorWorkbenchProps = {
13
+ readonly testId: string;
14
+ readonly title: string;
15
+ readonly status?: ReactNode;
16
+ /** Info bar text per mode. */
17
+ readonly info: {
18
+ readonly edit: ReactNode;
19
+ readonly preview: ReactNode;
20
+ };
21
+ /** Info bar controls shared by both modes, e.g. the locale switch. */
22
+ readonly controls?: ReactNode;
23
+ readonly banners?: ReactNode;
24
+ readonly edit: ReactNode;
25
+ readonly preview: ReactNode;
26
+ /** Right rail per mode; `left` adds a rail on the left (a placeholder list) shown in both modes. */
27
+ readonly rail: {
28
+ readonly edit: ReactNode;
29
+ readonly preview: ReactNode;
30
+ readonly left?: ReactNode;
31
+ };
32
+ readonly save: WorkbenchSave;
33
+ };
34
+ export declare function EditorWorkbench({ testId, title, status, info, controls, banners, edit, preview, rail, save, }: EditorWorkbenchProps): ReactNode;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { useTranslation } from "../../i18n.js";
4
+ import { EditorFooter } from "./editor-footer.js";
5
+ import { EditorBody, EditorFrame, EditorInfoBar } from "./editor-frame.js";
6
+ import { EditorHeader, EditorModeSwitch } from "./editor-header.js";
7
+ // The shared edit/preview mask: editors that only differ in what they edit, which preview
8
+ // renderer they mount and which fields sit in the right rail compose this instead of a form.
9
+ export function EditorWorkbench({ testId, title, status, info, controls, banners, edit, preview, rail, save, }) {
10
+ const t = useTranslation();
11
+ const [mode, setMode] = useState("edit");
12
+ const editing = mode === "edit";
13
+ return (_jsxs(EditorFrame, { testId: testId, children: [_jsx(EditorHeader, { title: title, status: status, actions: {
14
+ busy: save.busy,
15
+ canSave: save.canSave,
16
+ onSave: save.onSave,
17
+ ...(save.saveLabel !== undefined && { saveLabel: save.saveLabel }),
18
+ }, children: _jsx(EditorModeSwitch, { testIdPrefix: testId, mode: mode, onMode: setMode }) }), _jsx(EditorInfoBar, { tone: "muted", testId: `${testId}-info`, controls: controls, children: editing ? info.edit : info.preview }), banners, _jsx(EditorBody, { testId: `${testId}-${mode}`, center: editing ? edit : preview, right: editing ? rail.edit : rail.preview, ...(rail.left !== undefined && { left: rail.left }) }), _jsx(EditorFooter, { testIdPrefix: testId, message: save.dirty ? { tone: "warn", text: t("kumiko.editor.unsavedChanges") } : null, saveError: save.saveError, modifiedAt: save.modifiedAt ?? null, dirty: save.dirty, busy: save.busy, canSave: save.canSave, onDiscard: save.onDiscard, onSave: save.onSave, ...(save.saveLabel !== undefined && { saveLabel: save.saveLabel }) })] }));
19
+ }
@@ -0,0 +1,6 @@
1
+ export { type EditorActionTestIds, EditorFooter, type FooterTone } from "./editor-footer.tsx";
2
+ export { EditorBody, EditorFrame, EditorInfoBar, type InfoBarTone } from "./editor-frame.tsx";
3
+ export { EditorHeader, type EditorHeaderTestIds, EditorLocaleSwitch, type EditorMode, EditorModeSwitch, type EditorSaveActions, } from "./editor-header.tsx";
4
+ export { RailField, RailHint, RailRow, RailSection } from "./editor-rail.tsx";
5
+ export { EditorWorkbench, type EditorWorkbenchProps, type WorkbenchSave, } from "./editor-workbench.tsx";
6
+ export { formatRelativeWhen } from "./relative-when.ts";
@@ -0,0 +1,6 @@
1
+ export { EditorFooter } from "./editor-footer.js";
2
+ export { EditorBody, EditorFrame, EditorInfoBar } from "./editor-frame.js";
3
+ export { EditorHeader, EditorLocaleSwitch, EditorModeSwitch, } from "./editor-header.js";
4
+ export { RailField, RailHint, RailRow, RailSection } from "./editor-rail.js";
5
+ export { EditorWorkbench, } from "./editor-workbench.js";
6
+ export { formatRelativeWhen } from "./relative-when.js";
@@ -0,0 +1 @@
1
+ export declare function formatRelativeWhen(value: string, now?: number): string;
@@ -0,0 +1,18 @@
1
+ const UNITS = [
2
+ ["day", 86_400_000],
3
+ ["hour", 3_600_000],
4
+ ["minute", 60_000],
5
+ ];
6
+ // Falls back to the raw value for an unparseable timestamp, like formatWhen.
7
+ export function formatRelativeWhen(value, now = Date.now()) {
8
+ const then = Date.parse(value);
9
+ if (Number.isNaN(then))
10
+ return value;
11
+ const formatter = new Intl.RelativeTimeFormat(undefined, { numeric: "auto" });
12
+ const elapsed = then - now;
13
+ for (const [unit, size] of UNITS) {
14
+ if (Math.abs(elapsed) >= size)
15
+ return formatter.format(Math.round(elapsed / size), unit);
16
+ }
17
+ return formatter.format(0, "minute");
18
+ }
@@ -13,6 +13,8 @@ export { KumikoLink, useBrowserNavApi } from "./app/nav.tsx";
13
13
  export { PlainContentEditor } from "./app/plain-content-editor.tsx";
14
14
  export { useResolvers } from "./app/resolvers-context.tsx";
15
15
  export { clearRememberedListState } from "./app/session-list-state-store.ts";
16
+ export type { EditorActionTestIds, EditorHeaderTestIds, EditorMode, EditorSaveActions, EditorWorkbenchProps, FooterTone, InfoBarTone, WorkbenchSave, } from "./editor/index.ts";
17
+ export { EditorBody, EditorFooter, EditorFrame, EditorHeader, EditorInfoBar, EditorLocaleSwitch, EditorModeSwitch, EditorWorkbench, formatRelativeWhen, RailField, RailHint, RailRow, RailSection, } from "./editor/index.ts";
16
18
  export type { NavIconKey } from "./icons.tsx";
17
19
  export { Icon } from "./icons.tsx";
18
20
  export type { AppLayoutProps } from "./layout/app-layout.tsx";
@@ -27,6 +29,7 @@ export type { NavReparentOverride } from "./layout/filter-app-schema-navs.ts";
27
29
  export { filterAppSchemaNavsByAllowlist, reparentAppSchemaNavs, } from "./layout/filter-app-schema-navs.ts";
28
30
  export type { HeaderActionGroupProps } from "./layout/header-action-group.tsx";
29
31
  export { HeaderActionGroup } from "./layout/header-action-group.tsx";
32
+ export { HeaderActionPinned } from "./layout/header-action-pinned.tsx";
30
33
  export type { LanguageMenuItemsProps } from "./layout/language-menu-items.tsx";
31
34
  export { LanguageMenuItems } from "./layout/language-menu-items.tsx";
32
35
  export type { LanguageSwitcherProps, LocaleOption } from "./layout/language-switcher.tsx";
@@ -65,6 +68,9 @@ export { PresenceAvatars, PresenceNotice, usePresence, usePresenceList, } from "
65
68
  export type { ActionMenuProps, MenuItemDef } from "./primitives/action-menu.tsx";
66
69
  export { ActionMenu } from "./primitives/action-menu.tsx";
67
70
  export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuTrigger, } from "./primitives/dropdown-menu.tsx";
71
+ export type { FileMeta } from "./primitives/file-thumbnail.tsx";
72
+ export { useFileMeta } from "./primitives/file-thumbnail.tsx";
73
+ export { FileViewAction } from "./primitives/file-view-action.tsx";
68
74
  export { BareFormProvider, DefaultCard as Card, defaultPrimitives, FormScreenShell, ScreenWidthProvider, } from "./primitives/index.tsx";
69
75
  export { PageSection, Stack } from "./primitives/layout.tsx";
70
76
  export { formatMoney } from "./primitives/money-input.tsx";
@@ -79,4 +85,4 @@ export { SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarProvider } from
79
85
  export type { KumikoBuild } from "./version/update-checker.tsx";
80
86
  export { readLoadedBuild } from "./version/update-checker.tsx";
81
87
  export type { AiTextAreaProps, AiTextEndAction, AiTextFieldProps, BooleanFieldProps, ComparisonMetric, ComposerProps, DateFieldProps, DrawerProps, FeedRow, FileFieldProps, FloatingPanelGeometry, FloatingPanelPlacement, FloatingPanelProps, InfinityListProps, InfinityListSelection, MessageAttachment, MessageBody, MessageReaderProps, MessageReaderTab, MessageThreadProps, MobileTopBarProps, ModeSwitchVariant, NumberFieldProps, PdfMatchInfo, PdfPreviewProps, PdfPreviewSource, PhotoSlotSpec, PhotoSlotsProps, PlanCardActionSlot, PlanCardLinkSlot, PlanCardPrice, PlanCardProps, PlanGridProps, ProgressListRow, PublicShellProps, PublicShellVariant, QueryTableColumn, QueryTableProps, RangeFieldProps, ResultColumn, SectionNavLayoutProps, SelectFieldProps, SideBySideTableCell, SideBySideTableColumn, SideBySideTableRow, StatDelta, StatTone, StatusBadgeTone, StatusBarEntry, StatusTone, StepAction, StepListItem, StepListProps, StepListSelection, StepSelectability, StepSelectionAction, StepSource, StepStatus, StepTag, TextareaFieldProps, TextFieldProps, ThreadMessage, TimeseriesHeight, TimeseriesPoint, TimeseriesReferenceLine, TimeseriesXAxis, TimeseriesYAxis, UploadZoneProps, } from "./widgets/index.ts";
82
- export { AiSurface, AiTextArea, AiTextField, AttachmentCard, AttachmentChip, BooleanField, ChoiceCards, ClampedText, CollapsibleSection, ComparisonTable, Composer, DateField, DetailList, Drawer, EmptyState, ErrorState, FeedList, FileField, FloatingPanel, InfinityList, LoadingState, MessageReader, MessageThread, MiniStat, MobileTopBar, ModeSwitch, MoneyField, NumberField, PdfPreview, PercentField, PhotoSlots, PlanCard, PlanGrid, ProgressBar, ProgressList, PublicShell, QueryTable, RangeField, ResultPanel, ResultTable, SectionCard, SectionNavLayout, SelectField, SenderFrame, SenderSheet, SideBySideTable, Sparkline, STATUS_TONE_TEXT, StatCard, StatusBadge, StatusBarChart, StepBar, StepList, smoothPath, TextareaField, TextField, TimeseriesChart, UploadZone, useDraft, } from "./widgets/index.ts";
88
+ export { AiSurface, AiTextArea, AiTextField, AttachmentCard, AttachmentChip, BooleanField, ChoiceCards, ClampedText, CollapsibleSection, ComparisonTable, Composer, DateField, DetailList, Drawer, EmptyState, ErrorState, FeedList, FileField, FloatingPanel, HtmlMailFrame, InfinityList, LoadingState, MessageReader, MessageThread, MiniStat, MobileTopBar, ModeSwitch, MoneyField, NumberField, PdfPreview, PercentField, PhotoSlots, PlanCard, PlanGrid, type PreviewDevice, PreviewWidthFrame, ProgressBar, ProgressList, PublicShell, QueryTable, RangeField, ResultPanel, ResultTable, SectionCard, SectionNavLayout, SelectField, SenderFrame, SenderSheet, SideBySideTable, Sparkline, STATUS_TONE_TEXT, StatCard, StatusBadge, StatusBarChart, StepBar, StepList, smoothPath, TextareaField, TextField, TimeseriesChart, UploadZone, useDraft, } from "./widgets/index.ts";
package/dist/web/index.js CHANGED
@@ -12,6 +12,7 @@ export { KumikoLink, useBrowserNavApi } from "./app/nav.js";
12
12
  export { PlainContentEditor } from "./app/plain-content-editor.js";
13
13
  export { useResolvers } from "./app/resolvers-context.js";
14
14
  export { clearRememberedListState } from "./app/session-list-state-store.js";
15
+ export { EditorBody, EditorFooter, EditorFrame, EditorHeader, EditorInfoBar, EditorLocaleSwitch, EditorModeSwitch, EditorWorkbench, formatRelativeWhen, RailField, RailHint, RailRow, RailSection, } from "./editor/index.js";
15
16
  export { Icon } from "./icons.js";
16
17
  export { AppLayout } from "./layout/app-layout.js";
17
18
  export { Avatar } from "./layout/avatar.js";
@@ -19,6 +20,7 @@ export { DefaultAppShell } from "./layout/default-app-shell.js";
19
20
  export { EditorPanel } from "./layout/editor-panel.js";
20
21
  export { filterAppSchemaNavsByAllowlist, reparentAppSchemaNavs, } from "./layout/filter-app-schema-navs.js";
21
22
  export { HeaderActionGroup } from "./layout/header-action-group.js";
23
+ export { HeaderActionPinned } from "./layout/header-action-pinned.js";
22
24
  export { LanguageMenuItems } from "./layout/language-menu-items.js";
23
25
  export { LanguageSwitcher } from "./layout/language-switcher.js";
24
26
  export { buildNavRegistrySlice, buildNavRegistrySliceForApp, NavTree } from "./layout/nav-tree.js";
@@ -43,6 +45,8 @@ export { FileUploadFailedError, uploadFileRef } from "./lib/upload-file-ref.js";
43
45
  export { PresenceAvatars, PresenceNotice, usePresence, usePresenceList, } from "./presence/index.js";
44
46
  export { ActionMenu } from "./primitives/action-menu.js";
45
47
  export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuTrigger, } from "./primitives/dropdown-menu.js";
48
+ export { useFileMeta } from "./primitives/file-thumbnail.js";
49
+ export { FileViewAction } from "./primitives/file-view-action.js";
46
50
  export { BareFormProvider, DefaultCard as Card, defaultPrimitives, FormScreenShell, ScreenWidthProvider, } from "./primitives/index.js";
47
51
  export { PageSection, Stack } from "./primitives/layout.js";
48
52
  export { formatMoney } from "./primitives/money-input.js";
@@ -53,4 +57,4 @@ export { applyTokensToCssVars, defaultTokens, lightTokens, useBrowserTokensApi,
53
57
  export { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "./ui/resizable.js";
54
58
  export { SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarProvider } from "./ui/sidebar.js";
55
59
  export { readLoadedBuild } from "./version/update-checker.js";
56
- export { AiSurface, AiTextArea, AiTextField, AttachmentCard, AttachmentChip, BooleanField, ChoiceCards, ClampedText, CollapsibleSection, ComparisonTable, Composer, DateField, DetailList, Drawer, EmptyState, ErrorState, FeedList, FileField, FloatingPanel, InfinityList, LoadingState, MessageReader, MessageThread, MiniStat, MobileTopBar, ModeSwitch, MoneyField, NumberField, PdfPreview, PercentField, PhotoSlots, PlanCard, PlanGrid, ProgressBar, ProgressList, PublicShell, QueryTable, RangeField, ResultPanel, ResultTable, SectionCard, SectionNavLayout, SelectField, SenderFrame, SenderSheet, SideBySideTable, Sparkline, STATUS_TONE_TEXT, StatCard, StatusBadge, StatusBarChart, StepBar, StepList, smoothPath, TextareaField, TextField, TimeseriesChart, UploadZone, useDraft, } from "./widgets/index.js";
60
+ export { AiSurface, AiTextArea, AiTextField, AttachmentCard, AttachmentChip, BooleanField, ChoiceCards, ClampedText, CollapsibleSection, ComparisonTable, Composer, DateField, DetailList, Drawer, EmptyState, ErrorState, FeedList, FileField, FloatingPanel, HtmlMailFrame, InfinityList, LoadingState, MessageReader, MessageThread, MiniStat, MobileTopBar, ModeSwitch, MoneyField, NumberField, PdfPreview, PercentField, PhotoSlots, PlanCard, PlanGrid, PreviewWidthFrame, ProgressBar, ProgressList, PublicShell, QueryTable, RangeField, ResultPanel, ResultTable, SectionCard, SectionNavLayout, SelectField, SenderFrame, SenderSheet, SideBySideTable, Sparkline, STATUS_TONE_TEXT, StatCard, StatusBadge, StatusBarChart, StepBar, StepList, smoothPath, TextareaField, TextField, TimeseriesChart, UploadZone, useDraft, } from "./widgets/index.js";