@cosmicdrift/kumiko-renderer 0.415.0 → 0.417.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 (221) hide show
  1. package/dist/app/action-form-body.d.ts +2 -5
  2. package/dist/app/action-form-body.js +50 -22
  3. package/dist/app/action-form-support.d.ts +4 -1
  4. package/dist/app/action-form-support.js +8 -4
  5. package/dist/app/client-actions.js +6 -4
  6. package/dist/app/config-edit-body.js +83 -82
  7. package/dist/app/entity-list-screen.js +1 -1
  8. package/dist/app/extension-sections.d.ts +2 -0
  9. package/dist/app/header-actions-bar.d.ts +3 -1
  10. package/dist/app/header-actions-bar.js +12 -4
  11. package/dist/app/locked-screen-header.d.ts +2 -0
  12. package/dist/app/locked-screen-header.js +8 -1
  13. package/dist/app/projection-detail-body.js +29 -8
  14. package/dist/app/projection-detail-guidance.d.ts +2 -1
  15. package/dist/app/projection-detail-guidance.js +45 -30
  16. package/dist/app/projection-detail-header-model.d.ts +1 -1
  17. package/dist/app/projection-detail-header-model.js +14 -6
  18. package/dist/app/projection-detail-header-region.js +25 -9
  19. package/dist/app/projection-detail-header.d.ts +2 -0
  20. package/dist/app/projection-detail-header.js +31 -4
  21. package/dist/app/projection-detail-navigation.d.ts +4 -0
  22. package/dist/app/projection-detail-navigation.js +5 -1
  23. package/dist/app/projection-list-shim.js +1 -0
  24. package/dist/app/row-actions.d.ts +4 -0
  25. package/dist/app/row-actions.js +19 -3
  26. package/dist/app/screen-shared.d.ts +1 -0
  27. package/dist/app/screen-shared.js +23 -3
  28. package/dist/app/use-projection-detail-actions.d.ts +16 -1
  29. package/dist/app/use-projection-detail-actions.js +23 -3
  30. package/dist/app/use-projection-detail-data.d.ts +2 -0
  31. package/dist/app/use-projection-detail-data.js +53 -10
  32. package/dist/app/use-projection-list-data.js +1 -1
  33. package/dist/card-options.d.ts +2 -0
  34. package/dist/components/ai-assist-payload.d.ts +2 -0
  35. package/dist/components/ai-assist-payload.js +8 -0
  36. package/dist/components/choice-chip-class.d.ts +1 -0
  37. package/dist/components/choice-chip-class.js +9 -0
  38. package/dist/components/edit-mounts.d.ts +3 -2
  39. package/dist/components/edit-mounts.js +2 -2
  40. package/dist/components/grid-cell-for-field.js +1 -1
  41. package/dist/components/multi-select-chips.d.ts +10 -0
  42. package/dist/components/multi-select-chips.js +19 -0
  43. package/dist/components/narrow-description.d.ts +3 -0
  44. package/dist/components/narrow-description.js +12 -0
  45. package/dist/components/related-list-section.d.ts +5 -3
  46. package/dist/components/related-list-section.js +52 -35
  47. package/dist/components/related-photo-grid.d.ts +11 -0
  48. package/dist/components/related-photo-grid.js +54 -0
  49. package/dist/components/render-edit-action-button.d.ts +2 -2
  50. package/dist/components/render-edit-field-grid.d.ts +12 -3
  51. package/dist/components/render-edit-field-grid.js +60 -18
  52. package/dist/components/render-edit-fields-section.js +45 -11
  53. package/dist/components/render-edit-header-actions.d.ts +2 -1
  54. package/dist/components/render-edit-header-actions.js +18 -1
  55. package/dist/components/render-edit-layout.js +5 -3
  56. package/dist/components/render-edit-logic.js +1 -0
  57. package/dist/components/render-edit-section-kinds.js +59 -10
  58. package/dist/components/render-edit-titles.js +1 -1
  59. package/dist/components/render-edit-types.d.ts +22 -1
  60. package/dist/components/render-field-ai-assist.d.ts +13 -0
  61. package/dist/components/render-field-ai-assist.js +90 -0
  62. package/dist/components/render-field-choice-inputs.js +4 -0
  63. package/dist/components/render-field-control.d.ts +1 -1
  64. package/dist/components/render-field-control.js +19 -9
  65. package/dist/components/render-field-value-chips.d.ts +9 -0
  66. package/dist/components/render-field-value-chips.js +47 -0
  67. package/dist/components/render-field-write-only.js +12 -4
  68. package/dist/components/render-list-hint-columns.d.ts +2 -0
  69. package/dist/components/render-list-hint-columns.js +43 -5
  70. package/dist/components/render-list-reference-columns.js +2 -4
  71. package/dist/components/render-list-row-tone.d.ts +2 -0
  72. package/dist/components/render-list-row-tone.js +6 -0
  73. package/dist/components/render-list-table-props.d.ts +13 -2
  74. package/dist/components/render-list-table-props.js +9 -3
  75. package/dist/components/render-list-types.d.ts +4 -0
  76. package/dist/components/render-list.js +12 -4
  77. package/dist/components/use-render-edit-sections.js +5 -1
  78. package/dist/components/use-render-list-columns.js +3 -3
  79. package/dist/components/write-form-registry.d.ts +13 -0
  80. package/dist/components/write-form-registry.js +6 -0
  81. package/dist/components/write-form-section.d.ts +5 -1
  82. package/dist/components/write-form-section.js +55 -16
  83. package/dist/headless/form/form-controller.d.ts +1 -0
  84. package/dist/headless/form/form-controller.js +1 -1
  85. package/dist/headless/format/index.d.ts +1 -0
  86. package/dist/headless/format/index.js +21 -0
  87. package/dist/headless/format/phone.d.ts +1 -0
  88. package/dist/headless/format/phone.js +8 -0
  89. package/dist/headless/format/relative-time.d.ts +15 -0
  90. package/dist/headless/format/relative-time.js +63 -0
  91. package/dist/headless/format/safe-locale.d.ts +1 -0
  92. package/dist/headless/format/safe-locale.js +13 -0
  93. package/dist/headless/index.d.ts +2 -2
  94. package/dist/headless/index.js +2 -2
  95. package/dist/headless/view-model/edit.d.ts +3 -2
  96. package/dist/headless/view-model/edit.js +162 -36
  97. package/dist/headless/view-model/field-text.d.ts +9 -0
  98. package/dist/headless/view-model/field-text.js +19 -0
  99. package/dist/headless/view-model/index.d.ts +1 -0
  100. package/dist/headless/view-model/index.js +1 -0
  101. package/dist/headless/view-model/list.js +6 -0
  102. package/dist/headless/view-model/types.d.ts +76 -5
  103. package/dist/hooks/use-list-table.js +11 -6
  104. package/dist/i18n-defaults.js +9 -2
  105. package/dist/index.d.ts +1 -1
  106. package/dist/primitives-record-guidance.d.ts +32 -1
  107. package/dist/primitives-share-types.d.ts +82 -0
  108. package/dist/primitives-share-types.js +1 -0
  109. package/dist/primitives.d.ts +44 -86
  110. package/dist/web/app/bold-markup.d.ts +3 -0
  111. package/dist/web/app/bold-markup.js +14 -0
  112. package/dist/web/app/dashboard-body.js +8 -3
  113. package/dist/web/app/dashboard-list-panel.js +8 -4
  114. package/dist/web/app/dashboard-panel-columns.d.ts +9 -0
  115. package/dist/web/app/dashboard-panel-columns.js +14 -0
  116. package/dist/web/app/dashboard-panels.js +31 -3
  117. package/dist/web/app/dashboard-shared.d.ts +3 -1
  118. package/dist/web/app/dashboard-shared.js +4 -4
  119. package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -1
  120. package/dist/web/app/dashboard-stat-group-panel.js +24 -3
  121. package/dist/web/app/dashboard-text-panel.d.ts +1 -0
  122. package/dist/web/app/dashboard-text-panel.js +18 -11
  123. package/dist/web/app/relative-time.d.ts +0 -5
  124. package/dist/web/app/relative-time.js +11 -21
  125. package/dist/web/components/config-cascade.d.ts +2 -1
  126. package/dist/web/components/config-cascade.js +16 -4
  127. package/dist/web/drawn-icons.js +2 -1
  128. package/dist/web/layout/header-action-pinned.d.ts +4 -2
  129. package/dist/web/layout/header-action-pinned.js +13 -4
  130. package/dist/web/layout/header-overflow-menu.d.ts +2 -0
  131. package/dist/web/layout/header-overflow-menu.js +2 -0
  132. package/dist/web/layout/notification-bell.js +12 -3
  133. package/dist/web/layout/page-header-slot.d.ts +2 -0
  134. package/dist/web/layout/page-header-slot.js +4 -0
  135. package/dist/web/layout/screen-focus.js +4 -1
  136. package/dist/web/layout/shell-header.js +13 -5
  137. package/dist/web/primitives/banner.js +24 -8
  138. package/dist/web/primitives/card.js +5 -3
  139. package/dist/web/primitives/combobox.js +2 -2
  140. package/dist/web/primitives/data-table/actions-column.js +1 -1
  141. package/dist/web/primitives/data-table/card-body.d.ts +1 -1
  142. package/dist/web/primitives/data-table/card-body.js +37 -14
  143. package/dist/web/primitives/data-table/card-frame.d.ts +2 -0
  144. package/dist/web/primitives/data-table/card-frame.js +3 -0
  145. package/dist/web/primitives/data-table/card-row.js +34 -10
  146. package/dist/web/primitives/data-table/card-sort-select.js +1 -1
  147. package/dist/web/primitives/data-table/card-view.js +1 -1
  148. package/dist/web/primitives/data-table/data-cell-props.d.ts +4 -1
  149. package/dist/web/primitives/data-table/data-cell-props.js +3 -0
  150. package/dist/web/primitives/data-table/density.d.ts +3 -1
  151. package/dist/web/primitives/data-table/density.js +11 -4
  152. package/dist/web/primitives/data-table/row-click-guard.d.ts +2 -0
  153. package/dist/web/primitives/data-table/row-click-guard.js +19 -0
  154. package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
  155. package/dist/web/primitives/data-table/row-render-parts.js +3 -5
  156. package/dist/web/primitives/data-table/sort-options-select.js +2 -2
  157. package/dist/web/primitives/data-table/sortable-header.js +4 -4
  158. package/dist/web/primitives/data-table/table-body.js +3 -1
  159. package/dist/web/primitives/data-table/table-chrome.js +1 -3
  160. package/dist/web/primitives/data-table/table-content.js +6 -6
  161. package/dist/web/primitives/data-table/table-data-cell.js +31 -17
  162. package/dist/web/primitives/data-table/table-header-row.js +1 -1
  163. package/dist/web/primitives/data-table/table-view.js +1 -1
  164. package/dist/web/primitives/data-table/toolbar.js +6 -7
  165. package/dist/web/primitives/data-table/use-data-table-state.d.ts +6 -1
  166. package/dist/web/primitives/data-table/use-data-table-state.js +12 -2
  167. package/dist/web/primitives/data-table-cell.d.ts +17 -3
  168. package/dist/web/primitives/data-table-cell.js +130 -36
  169. package/dist/web/primitives/data-table.js +1 -1
  170. package/dist/web/primitives/default-form.d.ts +1 -1
  171. package/dist/web/primitives/default-form.js +15 -11
  172. package/dist/web/primitives/drawer.js +2 -3
  173. package/dist/web/primitives/facet-filter.d.ts +1 -1
  174. package/dist/web/primitives/facet-filter.js +2 -5
  175. package/dist/web/primitives/facet-search-filter.js +1 -1
  176. package/dist/web/primitives/facet-trigger-label.d.ts +1 -4
  177. package/dist/web/primitives/facet-trigger-label.js +4 -7
  178. package/dist/web/primitives/field.js +15 -8
  179. package/dist/web/primitives/form-footer-parts.js +6 -3
  180. package/dist/web/primitives/form.js +6 -8
  181. package/dist/web/primitives/index.js +4 -0
  182. package/dist/web/primitives/inline-suffix.d.ts +2 -0
  183. package/dist/web/primitives/inline-suffix.js +5 -0
  184. package/dist/web/primitives/input-choice-kinds.js +12 -2
  185. package/dist/web/primitives/input-number-kinds.js +2 -2
  186. package/dist/web/primitives/input-text-kinds.js +1 -1
  187. package/dist/web/primitives/layout-elements.d.ts +4 -4
  188. package/dist/web/primitives/layout-elements.js +50 -13
  189. package/dist/web/primitives/layout.d.ts +1 -1
  190. package/dist/web/primitives/layout.js +1 -1
  191. package/dist/web/primitives/locale-number.d.ts +0 -1
  192. package/dist/web/primitives/locale-number.js +1 -13
  193. package/dist/web/primitives/money-input.js +10 -8
  194. package/dist/web/primitives/narrow-pinned-footer.js +7 -3
  195. package/dist/web/primitives/number-input.d.ts +2 -1
  196. package/dist/web/primitives/number-input.js +11 -5
  197. package/dist/web/primitives/page-header.d.ts +1 -1
  198. package/dist/web/primitives/page-header.js +8 -1
  199. package/dist/web/primitives/pager.js +12 -21
  200. package/dist/web/primitives/photo-grid.d.ts +3 -0
  201. package/dist/web/primitives/photo-grid.js +6 -0
  202. package/dist/web/primitives/record-steps.d.ts +1 -1
  203. package/dist/web/primitives/record-steps.js +7 -16
  204. package/dist/web/primitives/record-summary.d.ts +1 -1
  205. package/dist/web/primitives/record-summary.js +8 -3
  206. package/dist/web/primitives/row-actions.js +38 -24
  207. package/dist/web/primitives/step-list.d.ts +3 -0
  208. package/dist/web/primitives/step-list.js +11 -0
  209. package/dist/web/primitives/use-container-narrow.d.ts +12 -0
  210. package/dist/web/primitives/use-container-narrow.js +42 -0
  211. package/dist/web/ui/input.js +1 -1
  212. package/dist/web/ui/textarea.js +1 -1
  213. package/dist/web/widgets/dashboard-list-cards.js +6 -3
  214. package/dist/web/widgets/dashboard-list.d.ts +6 -1
  215. package/dist/web/widgets/dashboard-list.js +12 -7
  216. package/dist/web/widgets/drawer-panel-class.js +1 -1
  217. package/dist/web/widgets/progress-list.js +1 -1
  218. package/dist/web/widgets/stat-box-cell.js +1 -1
  219. package/package.json +5 -5
  220. package/src/changes.json +105 -0
  221. package/src/web/styles.css +3 -2
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { createContext, useCallback, useContext, useEffect, useRef, useState, } from "react";
3
+ import { resolveSafeLocale } from "../../headless/format/safe-locale.js";
3
4
  import { currencyDecimals } from "../../headless/index.js";
4
5
  import { dispatcherErrorText, useLocale, usePrimitives, useQuery, useTranslation, } from "../../index.js";
5
6
  import { serverNowMs } from "../../server-clock.js";
6
7
  import { cn } from "../lib/cn.js";
7
- import { resolveSafeLocale } from "../primitives/locale-number.js";
8
8
  import { formatMoney } from "../primitives/money-input.js";
9
9
  import { Skeleton } from "../ui/skeleton.js";
10
10
  import { EmptyState, LoadingState } from "../widgets/states.js";
@@ -119,7 +119,7 @@ export function useDashboardFormats() {
119
119
  };
120
120
  }
121
121
  export function PanelShell({ testId, title, subtitle, action, footer, children, }) {
122
- return (_jsxs("section", { "data-testid": testId, className: "flex h-full flex-col rounded-lg border border-border bg-card text-card-foreground shadow-[var(--card-shadow)]", children: [(title !== undefined || action !== undefined) && (_jsxs("header", { className: "flex shrink-0 flex-wrap items-baseline justify-between gap-x-3 gap-y-2 px-4 pt-3.5", 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-2.5", children: [title !== undefined && _jsx("h2", { className: "text-sm font-semibold break-words", children: title }), subtitle !== undefined && (_jsx("p", { className: "text-[12.5px] text-muted-foreground", children: subtitle }))] }), action !== undefined && _jsx("div", { className: "shrink-0", children: action })] })), _jsx("div", { className: cn("grow px-4 pt-3", footer === undefined && "pb-4"), children: children }), footer !== undefined && (_jsx("footer", { className: "mx-4 mb-4 mt-2.5 flex shrink-0 flex-wrap items-center gap-x-1 border-t border-border-row pt-2.5 text-[12.5px] text-muted-foreground", children: footer }))] }));
122
+ return (_jsxs("section", { "data-testid": testId, className: "flex h-full flex-col rounded-lg border border-border bg-card text-card-foreground shadow-[var(--card-shadow)]", children: [(title !== undefined || action !== undefined) && (_jsxs("header", { className: "flex shrink-0 flex-wrap items-baseline justify-between gap-x-3 gap-y-2 px-4 pt-3.5", children: [_jsx("div", { className: "flex min-w-0 flex-col gap-0.5", children: title !== undefined && _jsx("h2", { className: "text-sm font-semibold break-words", children: title }) }), (subtitle !== undefined || action !== undefined) && (_jsxs("div", { className: "ml-auto flex min-w-0 items-baseline gap-3 max-sm:ml-0 max-sm:w-full max-sm:flex-col max-sm:items-start max-sm:gap-2", children: [subtitle !== undefined && (_jsx("p", { "data-slot": "panel-subtitle", className: "text-[12.5px] tabular-nums text-muted-foreground", children: subtitle })), action] }))] })), _jsx("div", { className: cn("grow px-4 pt-3", footer === undefined && "pb-4"), children: children }), footer !== undefined && (_jsx("footer", { className: "mx-4 mb-4 mt-2.5 flex shrink-0 flex-wrap items-center gap-x-1 border-t border-border-row pt-2.5 text-[12.5px] text-muted-foreground", children: footer }))] }));
123
123
  }
124
124
  export function PanelError({ label, error, onRetry, testId, }) {
125
125
  const { Button } = usePrimitives();
@@ -142,7 +142,7 @@ function resolveSubtitle(subtitle, fallback, data) {
142
142
  return subtitle;
143
143
  return data === undefined ? fallback : subtitle(data);
144
144
  }
145
- export function QueryPanel({ panel, label, subtitle, staticSubtitle, action, footer, replaceShell, screenParams, translate, skeleton, isEmpty, children, }) {
145
+ export function QueryPanel({ panel, label, titleFrom, subtitle, staticSubtitle, action, footer, replaceShell, screenParams, translate, skeleton, isEmpty, children, }) {
146
146
  const formats = useDashboardFormats();
147
147
  const { data, error, loading, refetch } = useDashboardQuery(panel.query, panelPayload(panel, screenParams));
148
148
  useReportPanelLoaded(data, loading);
@@ -163,7 +163,7 @@ export function QueryPanel({ panel, label, subtitle, staticSubtitle, action, foo
163
163
  }
164
164
  if (shown !== undefined && replaceShell !== undefined)
165
165
  return replaceShell(shown);
166
- 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 }));
166
+ return (_jsx(PanelShell, { testId: `dashboard-panel-${panel.id}`, title: (shown !== undefined ? titleFrom?.(shown) : undefined) ?? label, subtitle: resolveSubtitle(subtitle, staticSubtitle, shown), action: action, footer: shown !== undefined ? footer?.(shown) : undefined, children: body }));
167
167
  }
168
168
  // Starts at render time and restarts whenever the merged query params change;
169
169
  // panels additionally report each successful (re)load, so live refetches and
@@ -1,5 +1,5 @@
1
1
  import type { DashboardStatGroupPanel } from "@cosmicdrift/kumiko-framework/ui-types";
2
- import type { ReactNode } from "react";
2
+ import { type ReactNode } from "react";
3
3
  import type { Translate } from "../../headless/index.ts";
4
4
  import "../react-css-custom-properties.ts";
5
5
  import { type ScreenParams } from "./dashboard-shared.tsx";
@@ -1,9 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { ChevronRight } from "lucide-react";
3
+ import { Fragment } from "react";
3
4
  import { useNav } from "../../app/nav.js";
4
5
  import { navigateTargetAllows } from "../../app/screen-access.js";
5
6
  import { extensionSectionName, useAppFeatures, useExtensionSectionComponent, usePrimitives, useUserRoles, } from "../../index.js";
6
7
  import { cn } from "../lib/cn.js";
8
+ import { useIsBelowSmViewport } from "../primitives/use-narrow-viewport.js";
7
9
  import "../react-css-custom-properties.js";
8
10
  import { STAT_CARD_GRID_CLASSES } from "../widgets/stat.js";
9
11
  import { dashboardNavigationLink } from "./dashboard-navigation-link.js";
@@ -36,12 +38,30 @@ function StatGroupLink({ link, translate, stretchOnNarrow, }) {
36
38
  ? "ml-auto flex shrink-0 items-center gap-1 text-sm font-medium max-sm:after:absolute max-sm:after:inset-0"
37
39
  : "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" })] }));
38
40
  }
41
+ /** A child with `hideOnNarrow` is not mounted on a phone, so it runs no query and leaves no gap. */
42
+ function statsForViewport(stats, belowSm) {
43
+ return belowSm ? stats.filter((stat) => stat.hideOnNarrow !== true) : stats;
44
+ }
39
45
  function StatCells({ panel, screenId, screenParams, translate, variant, }) {
40
- return panel.stats.map((stat) => (_jsx(StatPanelBody, { panel: stat, label: translate(stat.label), screenId: screenId, screenParams: screenParams, translate: translate, variant: variant }, stat.id)));
46
+ const belowSm = useIsBelowSmViewport();
47
+ return statsForViewport(panel.stats, belowSm).map((stat) => {
48
+ const body = (_jsx(StatPanelBody, { panel: stat, label: translate(stat.label), screenId: screenId, screenParams: screenParams, translate: translate, variant: variant }, stat.id));
49
+ return variant === "strip" ? (_jsx("div", { "data-stat-card": "true", className: "min-w-0 rounded-lg border border-border bg-card empty:hidden", children: body }, stat.id)) : (_jsx(Fragment, { children: body }, stat.id));
50
+ });
51
+ }
52
+ // Phone: the untitled strip is one text line ("2 Interessenten 2 Vorschläge 1 Antwort"), not tiles.
53
+ function PhoneStatLine(props) {
54
+ const { panel, translate } = props;
55
+ const navigateAllowed = useStatNavigateAllowed();
56
+ const stats = statsForViewport(panel.stats, true).filter(navigateAllowed);
57
+ return (_jsx("div", { "data-testid": `dashboard-panel-${panel.id}`, "data-stat-line": "true", className: "flex flex-wrap justify-between gap-x-3 gap-y-1 rounded-lg border border-border bg-card px-3 py-2 text-sm", children: stats.map((stat) => (_jsx("span", { className: "[&_a]:inline", children: _jsx(StatPanelBody, { panel: stat, label: translate(stat.label), screenId: props.screenId, screenParams: props.screenParams, translate: translate, variant: "strip-compact" }) }, stat.id))) }));
41
58
  }
42
59
  function FlatStatStrip(props) {
43
60
  const { panel, translate } = props;
44
- 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 }) }))] }));
61
+ const belowSm = useIsBelowSmViewport();
62
+ if (belowSm)
63
+ return _jsx(PhoneStatLine, { ...props });
64
+ return (_jsxs("div", { "data-testid": `dashboard-panel-${panel.id}`, className: "lg:flex lg:items-center lg:gap-3", children: [_jsx("div", { className: "grid grow grid-cols-2 gap-3 lg:auto-cols-fr lg:grid-flow-col", 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 }) }))] }));
45
65
  }
46
66
  function PhoneStripIcon({ panel, screenId, screenParams, }) {
47
67
  const Icon = useExtensionSectionComponent(panel.icon !== undefined ? extensionSectionName(panel.icon) : undefined);
@@ -52,7 +72,8 @@ function PhoneStripIcon({ panel, screenId, screenParams, }) {
52
72
  function TitledStatStrip(props) {
53
73
  const { panel, label, translate } = props;
54
74
  const navigateAllowed = useStatNavigateAllowed();
55
- const stats = panel.stats.filter(navigateAllowed);
75
+ const belowSm = useIsBelowSmViewport();
76
+ const stats = statsForViewport(panel.stats, belowSm).filter(navigateAllowed);
56
77
  return (_jsxs("div", { "data-testid": `dashboard-panel-${panel.id}`, "data-narrow-tone": panel.narrow?.tone, style: { "--stat-count": stats.length }, className: cn(
57
78
  // Board grid: title column, one equal column per stat, link column.
58
79
  panel.link === undefined
@@ -5,6 +5,7 @@ import { type ScreenParams } from "./dashboard-shared.tsx";
5
5
  type TextPanelBodyProps = {
6
6
  readonly panel: DashboardTextPanel;
7
7
  readonly label: string | undefined;
8
+ readonly screenId: string;
8
9
  readonly screenParams: ScreenParams;
9
10
  readonly translate: Translate;
10
11
  };
@@ -1,8 +1,9 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { navigateTargetAllows } from "../../app/screen-access.js";
3
- import { lastSegment, useAppFeatures, useNav, usePrimitives, useUserRoles } from "../../index.js";
3
+ import { extensionSectionName, lastSegment, useAppFeatures, useExtensionSectionComponent, useNav, usePrimitives, useUserRoles, } from "../../index.js";
4
4
  import { cn } from "../lib/cn.js";
5
5
  import { useIsBelowSmViewport } from "../primitives/use-narrow-viewport.js";
6
+ import { renderBoldMarkup } from "./bold-markup.js";
6
7
  import { PanelError, PanelShell, PanelSkeleton, panelPayload, useDashboardFormats, useDashboardQuery, useReportPanelLoaded, } from "./dashboard-shared.js";
7
8
  import { isDashboardI18nText, isRecord, resolveDashboardText } from "./dashboard-text.js";
8
9
  function isDashboardText(value) {
@@ -62,7 +63,7 @@ function resolveBlockText(text, translate, formats) {
62
63
  const PARAGRAPH_CLASS_NAMES = {
63
64
  muted: "text-sm text-muted-foreground",
64
65
  strong: "text-sm font-medium text-foreground",
65
- lead: "font-heading text-[15.5px] leading-[1.5] sm:text-[17px] sm:leading-relaxed text-foreground",
66
+ lead: "font-heading text-sm leading-5 sm:text-[17px] sm:leading-relaxed text-foreground",
66
67
  };
67
68
  function isLeadParagraph(block) {
68
69
  return block?.kind === "paragraph" && block.emphasis === "lead";
@@ -74,7 +75,7 @@ function TextBlockView({ block, translate, followsLead = false, }) {
74
75
  case "heading":
75
76
  return (_jsx("h3", { "data-block": "heading", className: "text-sm font-semibold text-foreground", children: resolve(block.text) }));
76
77
  case "paragraph":
77
- return (_jsx("p", { "data-block": "paragraph", className: PARAGRAPH_CLASS_NAMES[block.emphasis ?? "muted"], children: resolve(block.text) }));
78
+ return (_jsx("p", { "data-block": "paragraph", className: PARAGRAPH_CLASS_NAMES[block.emphasis ?? "muted"], children: renderBoldMarkup(resolve(block.text)) }));
78
79
  case "list":
79
80
  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))) }));
80
81
  case "code":
@@ -121,27 +122,33 @@ function textBlockKey(block) {
121
122
  return `${block.kind}:${textKey(block.text)}`;
122
123
  }
123
124
  }
124
- function TextPanelFrame({ panel, label, children, }) {
125
+ function startsWithLead(blocks) {
126
+ return isLeadParagraph(blocks[0]);
127
+ }
128
+ function TextPanelFrame({ panel, label, screenId, screenParams, accented = false, children, }) {
125
129
  const testId = `dashboard-panel-${panel.id}`;
130
+ const Icon = useExtensionSectionComponent(panel.icon !== undefined ? extensionSectionName(panel.icon) : undefined);
131
+ const content = Icon === undefined ? (children) : (_jsxs("div", { className: "flex items-start gap-3", children: [_jsx("span", { "data-testid": `${testId}-icon`, className: "flex shrink-0 items-center pt-0.5", children: _jsx(Icon, { entityName: screenId, entityId: null, screenId: screenId, filterParams: screenParams.filterParams }) }), _jsx("div", { className: "min-w-0 grow", children: children })] }));
126
132
  if (label !== undefined) {
127
- return (_jsx(PanelShell, { testId: testId, title: label, children: children }));
133
+ return (_jsx(PanelShell, { testId: testId, title: label, children: content }));
128
134
  }
129
- return (_jsx("section", { "data-testid": testId, className: "h-full rounded-lg border border-border bg-card p-4 text-card-foreground max-sm:px-3.5 max-sm:py-3", children: children }));
135
+ return (_jsx("section", { "data-testid": testId, className: cn("h-full rounded-lg border border-border bg-card p-4 text-card-foreground max-sm:px-3 max-sm:py-2.5", accented && "border-l-[3px] border-l-primary"), children: content }));
130
136
  }
131
137
  function TextBlockList({ blocks, translate, }) {
132
138
  return (_jsx("div", { className: "flex flex-col gap-3", children: withOccurrenceKeys(blocks, textBlockKey).map(({ entry, key }, index) => (_jsx(TextBlockView, { block: entry, translate: translate, followsLead: isLeadParagraph(blocks[index - 1]) }, key))) }));
133
139
  }
134
140
  export function TextPanelBody(props) {
135
- const { panel, label, translate } = props;
141
+ const { panel, label, translate, screenId, screenParams } = props;
136
142
  const narrow = useIsBelowSmViewport();
143
+ const staticBlocks = (narrow ? panel.narrowBlocks : undefined) ?? panel.blocks ?? [];
137
144
  if (panel.query === undefined) {
138
- return (_jsx(TextPanelFrame, { panel: panel, label: label, children: _jsx(TextBlockList, { blocks: (narrow ? panel.narrowBlocks : undefined) ?? panel.blocks ?? [], translate: translate }) }));
145
+ return (_jsx(TextPanelFrame, { panel: panel, label: label, screenId: screenId, screenParams: screenParams, accented: startsWithLead(staticBlocks), children: _jsx(TextBlockList, { blocks: staticBlocks, translate: translate }) }));
139
146
  }
140
147
  return _jsx(QueryTextPanelBody, { ...props, query: panel.query });
141
148
  }
142
149
  // Not QueryPanel: that shell shows a skeleton/error/empty state instead of content, but the
143
150
  // static blocks are the fallback here and must stay visible while the query loads, fails or is empty.
144
- function QueryTextPanelBody({ panel, query, label, screenParams, translate, }) {
151
+ function QueryTextPanelBody({ panel, query, label, screenId, screenParams, translate, }) {
145
152
  const { data, error, loading, refetch } = useDashboardQuery(query, panelPayload(panel, screenParams));
146
153
  useReportPanelLoaded(data, loading);
147
154
  const narrow = useIsBelowSmViewport();
@@ -163,5 +170,5 @@ function QueryTextPanelBody({ panel, query, label, screenParams, translate, }) {
163
170
  else {
164
171
  body = null;
165
172
  }
166
- return (_jsx(TextPanelFrame, { panel: panel, label: label, children: body }));
173
+ return (_jsx(TextPanelFrame, { panel: panel, label: label, screenId: screenId, screenParams: screenParams, accented: startsWithLead(blocks), children: body }));
167
174
  }
@@ -1,8 +1,3 @@
1
- /** "5 minutes ago" / "in 30 seconds" in the given locale. The unit grows with the
2
- * distance (seconds below a minute, minutes below an hour, hours below a day,
3
- * days beyond); each step is chosen on the already rounded value so 59.6 minutes
4
- * reads "1 hour" instead of "60 minutes". `numeric: "auto"` yields "now" and "yesterday". */
5
- export declare function formatRelativeTime(atMs: number, nowMs: number, locale: string): string;
6
1
  /** Interval at which a relative text at `distanceMs` from now needs a redraw. */
7
2
  export declare function relativeTickIntervalMs(distanceMs: number): number;
8
3
  /** Returns a formatter for relative times that redraws its component on a timer, but
@@ -1,26 +1,14 @@
1
1
  import { useEffect, useRef, useState } from "react";
2
+ import { formatRelativeTime } from "../../headless/format/relative-time.js";
3
+ import { useTranslation } from "../../i18n.js";
2
4
  import { serverNowMs } from "../../server-clock.js";
3
- import { resolveSafeLocale } from "../primitives/locale-number.js";
4
5
  const SECONDS_PER_MINUTE = 60;
5
- const MINUTES_PER_HOUR = 60;
6
- const HOURS_PER_DAY = 24;
7
- /** "5 minutes ago" / "in 30 seconds" in the given locale. The unit grows with the
8
- * distance (seconds below a minute, minutes below an hour, hours below a day,
9
- * days beyond); each step is chosen on the already rounded value so 59.6 minutes
10
- * reads "1 hour" instead of "60 minutes". `numeric: "auto"` yields "now" and "yesterday". */
11
- export function formatRelativeTime(atMs, nowMs, locale) {
12
- const formatter = new Intl.RelativeTimeFormat(resolveSafeLocale(locale), { numeric: "auto" });
13
- const seconds = Math.round((atMs - nowMs) / 1000);
14
- if (Math.abs(seconds) < SECONDS_PER_MINUTE)
15
- return formatter.format(seconds, "second");
16
- const minutes = Math.round(seconds / SECONDS_PER_MINUTE);
17
- if (Math.abs(minutes) < MINUTES_PER_HOUR)
18
- return formatter.format(minutes, "minute");
19
- const hours = Math.round(minutes / MINUTES_PER_HOUR);
20
- if (Math.abs(hours) < HOURS_PER_DAY)
21
- return formatter.format(hours, "hour");
22
- return formatter.format(Math.round(hours / HOURS_PER_DAY), "day");
23
- }
6
+ // One look for relative times everywhere: short units, yesterday with clock, absolute after a week.
7
+ const LIST_RELATIVE_OPTIONS = {
8
+ style: "short",
9
+ withTime: true,
10
+ absoluteAfterDays: 7,
11
+ };
24
12
  const SECOND_TICK_MS = 1000;
25
13
  // Above a minute the text changes at most once per minute; half a minute keeps it
26
14
  // at most 30 s late without waking the page every second for a "5 minutes ago".
@@ -33,6 +21,8 @@ export function relativeTickIntervalMs(distanceMs) {
33
21
  /** Returns a formatter for relative times that redraws its component on a timer, but
34
22
  * only while a render actually called it: no relative output on screen, no timer. */
35
23
  export function useRelativeTimeFormatter(locale) {
24
+ const t = useTranslation();
25
+ const justNow = t("kumiko.time.justNow");
36
26
  const [, setTick] = useState(0);
37
27
  const [intervalMs, setIntervalMs] = useState(null);
38
28
  const nearestDistanceMs = useRef(Number.POSITIVE_INFINITY);
@@ -52,6 +42,6 @@ export function useRelativeTimeFormatter(locale) {
52
42
  return (atMs) => {
53
43
  const nowMs = serverNowMs();
54
44
  nearestDistanceMs.current = Math.min(nearestDistanceMs.current, Math.abs(atMs - nowMs));
55
- return formatRelativeTime(atMs, nowMs, locale);
45
+ return formatRelativeTime(atMs, nowMs, locale, { ...LIST_RELATIVE_OPTIONS, justNow });
56
46
  };
57
47
  }
@@ -8,6 +8,7 @@ type ConfigCascadeViewProps = {
8
8
  readonly qualifiedKey?: string;
9
9
  readonly required?: boolean;
10
10
  readonly renderValue?: CascadeValueRenderer;
11
+ readonly compact?: boolean;
11
12
  };
12
- export declare function ConfigCascadeView({ cascade, screenScope, onReset, qualifiedKey, required, renderValue, }: ConfigCascadeViewProps): ReactNode;
13
+ export declare function ConfigCascadeView({ cascade, screenScope, onReset, qualifiedKey, required, renderValue, compact, }: ConfigCascadeViewProps): ReactNode;
13
14
  export {};
@@ -3,6 +3,7 @@ import { useId, useState } from "react";
3
3
  import { usePrimitives, useTranslation } from "../../index.js";
4
4
  import { Icon } from "../icons.js";
5
5
  import { cn } from "../lib/cn.js";
6
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../ui/tooltip.js";
6
7
  const SOURCE_I18N_KEY = {
7
8
  "user-row": "kumiko.config.source.user",
8
9
  "tenant-row": "kumiko.config.source.tenant",
@@ -91,7 +92,7 @@ const OWN_LEVEL_ORIGIN_NO_DEFAULT_KEY = {
91
92
  user: "kumiko.config.cascade.originNoDefault.user",
92
93
  system: "kumiko.config.cascade.originNoDefault.system",
93
94
  };
94
- export function ConfigCascadeView({ cascade, screenScope, onReset, qualifiedKey, required = false, renderValue, }) {
95
+ export function ConfigCascadeView({ cascade, screenScope, onReset, qualifiedKey, required = false, renderValue, compact = false, }) {
95
96
  const t = useTranslation();
96
97
  const { Button } = usePrimitives();
97
98
  const [expanded, setExpanded] = useState(false);
@@ -143,9 +144,20 @@ export function ConfigCascadeView({ cascade, screenScope, onReset, qualifiedKey,
143
144
  : t("kumiko.config.cascade.origin.default"),
144
145
  className: "text-muted-foreground",
145
146
  };
146
- return (_jsxs("div", { className: "flex flex-col gap-1 text-xs", "data-testid": "config-cascade", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-x-1 gap-y-1", children: [_jsx("span", { className: cn("inline-flex items-center gap-1.5", origin.className), children: origin.text }), hasOverride && onReset !== undefined && qualifiedKey !== undefined ? (_jsx(Button, { variant: "ghost", size: "sm", onClick: () => onReset(qualifiedKey, screenScope), testId: "config-cascade-reset", className: "h-auto px-1.5 py-0.5 text-xs text-muted-foreground hover:bg-transparent hover:text-foreground", children: t(screenScope === "system"
147
- ? "kumiko.config.cascade.resetToApp"
148
- : "kumiko.config.cascade.resetTo") })) : null] }), expandable && (cascade.levels.length > 2 || screenScope === "system") ? (_jsxs("button", { type: "button", onClick: () => setExpanded((v) => !v), "aria-expanded": expanded, ...(expanded && { "aria-controls": panelId }), className: "inline-flex cursor-pointer items-center gap-1 self-start rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring", children: [_jsx(Icon, { name: "chevron-right", className: cn("size-3.5 transition-transform motion-reduce:transition-none", expanded && "rotate-90") }), t(expanded ? "kumiko.config.cascade.hideLevels" : "kumiko.config.cascade.showLevels")] })) : null, expanded && expandable && (cascade.levels.length > 2 || screenScope === "system") ? (_jsx("ul", { id: panelId, className: "flex flex-col gap-0.5 border-l border-border pl-3", children: displayLevels.map((display) => (_jsx(CascadeLevelRow, { display: display, ...(renderValue !== undefined && { renderValue }) }, display.level.source))) })) : null] }));
147
+ const resetButton = hasOverride && onReset !== undefined && qualifiedKey !== undefined ? (_jsx(Button, { variant: "ghost", size: "sm", onClick: () => onReset(qualifiedKey, screenScope), testId: "config-cascade-reset", className: "h-auto px-1.5 py-0.5 text-xs text-muted-foreground hover:bg-transparent hover:text-foreground", children: t(screenScope === "system"
148
+ ? "kumiko.config.cascade.resetToApp"
149
+ : "kumiko.config.cascade.resetTo") })) : null;
150
+ const showsLevels = expandable && (cascade.levels.length > 2 || screenScope === "system");
151
+ const levelsPanel = expanded && showsLevels ? (_jsx("ul", { id: panelId, className: "flex flex-col gap-0.5 border-l border-border pl-3", children: displayLevels.map((display) => (_jsx(CascadeLevelRow, { display: display, ...(renderValue !== undefined && { renderValue }) }, display.level.source))) })) : null;
152
+ if (compact) {
153
+ return (_jsxs("div", { className: "flex flex-col gap-1 text-xs", "data-testid": "config-cascade", children: [_jsxs("div", { className: "flex items-center gap-1", children: [_jsx(TooltipProvider, { children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs("button", { type: "button", "data-testid": "config-cascade-origin", onClick: showsLevels ? () => setExpanded((v) => !v) : undefined, ...(showsLevels && {
154
+ "aria-expanded": expanded,
155
+ ...(expanded && { "aria-controls": panelId }),
156
+ }), className: cn("inline-flex size-5 items-center justify-center rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-ring", showsLevels ? "cursor-pointer" : "cursor-help", origin.className), children: [_jsx(Icon, { name: "info", className: "size-3.5" }), showsLevels && (_jsx("span", { className: "sr-only", children: t(expanded
157
+ ? "kumiko.config.cascade.hideLevels"
158
+ : "kumiko.config.cascade.showLevels") }))] }) }), _jsx(TooltipContent, { children: origin.text })] }) }), _jsx("span", { className: "sr-only", children: origin.text }), resetButton] }), levelsPanel] }));
159
+ }
160
+ return (_jsxs("div", { className: "flex flex-col gap-1 text-xs", "data-testid": "config-cascade", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-x-1 gap-y-1", children: [_jsx("span", { className: cn("inline-flex items-center gap-1.5", origin.className), children: origin.text }), resetButton] }), showsLevels ? (_jsxs("button", { type: "button", onClick: () => setExpanded((v) => !v), "aria-expanded": expanded, ...(expanded && { "aria-controls": panelId }), className: "inline-flex cursor-pointer items-center gap-1 self-start rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring", children: [_jsx(Icon, { name: "chevron-right", className: cn("size-3.5 transition-transform motion-reduce:transition-none", expanded && "rotate-90") }), t(expanded ? "kumiko.config.cascade.hideLevels" : "kumiko.config.cascade.showLevels")] })) : null, levelsPanel] }));
149
161
  }
150
162
  function CascadeLevelRow({ display, renderValue, }) {
151
163
  const t = useTranslation();
@@ -13,7 +13,8 @@ export const DrawnPencil = createLucideIcon("drawn-pencil", [
13
13
  ["path", { d: "m13 7 4 4", key: "tip" }],
14
14
  ]);
15
15
  export const DrawnFilter = createLucideIcon("drawn-filter", [
16
- ["path", { d: "M4 6h16l-6 7v5l-4 2v-7z", key: "funnel" }],
16
+ ["path", { d: "M21 4h-7M10 4H3M21 12h-9M8 12H3M21 20h-5M12 20H3", key: "lines" }],
17
+ ["path", { d: "M14 2v4M8 10v4M16 18v4", key: "knobs" }],
17
18
  ]);
18
19
  export const DrawnWand = createLucideIcon("drawn-wand", [
19
20
  [
@@ -1,8 +1,10 @@
1
1
  import { type ReactNode } from "react";
2
2
  /** Marks an app header action (e.g. the assistant trigger) that stays in the bar on a phone, next to the
3
- * bell; the rest of `headerActions` folds into the "…" menu. Inside the menu it renders nothing. */
4
- export declare function HeaderActionPinned({ children }: {
3
+ * bell; the rest of `headerActions` folds into the "…" menu. Inside the menu it renders nothing.
4
+ * `hideOnListScreens` drops it on phone entityList/projectionList screens, whose rows carry their own AI action. */
5
+ export declare function HeaderActionPinned({ children, hideOnListScreens, }: {
5
6
  readonly children: ReactNode;
7
+ readonly hideOnListScreens?: boolean;
6
8
  }): ReactNode;
7
9
  export declare function collectPinnedHeaderActions(node: ReactNode): readonly ReactNode[];
8
10
  export declare function isOnlyPinnedHeaderActions(node: ReactNode): boolean;
@@ -1,10 +1,19 @@
1
1
  import { Children, Fragment, isValidElement, useContext } from "react";
2
- import { HeaderOverflowMenuContext } from "./header-overflow-menu.js";
2
+ import { usePageHeaderCompact } from "../../index.js";
3
+ import { HeaderOverflowMenuContext, HeaderScreenTypeContext } from "./header-overflow-menu.js";
4
+ const LIST_SCREEN_TYPES = new Set([
5
+ "entityList",
6
+ "projectionList",
7
+ ]);
3
8
  /** Marks an app header action (e.g. the assistant trigger) that stays in the bar on a phone, next to the
4
- * bell; the rest of `headerActions` folds into the "…" menu. Inside the menu it renders nothing. */
5
- export function HeaderActionPinned({ children }) {
9
+ * bell; the rest of `headerActions` folds into the "…" menu. Inside the menu it renders nothing.
10
+ * `hideOnListScreens` drops it on phone entityList/projectionList screens, whose rows carry their own AI action. */
11
+ export function HeaderActionPinned({ children, hideOnListScreens = false, }) {
6
12
  const inMenu = useContext(HeaderOverflowMenuContext);
7
- return inMenu ? null : children;
13
+ const screenType = useContext(HeaderScreenTypeContext);
14
+ const compact = usePageHeaderCompact();
15
+ const onListScreen = screenType !== undefined && LIST_SCREEN_TYPES.has(screenType);
16
+ return inMenu || (hideOnListScreens && compact && onListScreen) ? null : children;
8
17
  }
9
18
  function isPinnedElement(node) {
10
19
  return isValidElement(node) && node.type === HeaderActionPinned;
@@ -2,3 +2,5 @@
2
2
  * like ThemeToggle can draw a labelled menu row instead of an icon button. */
3
3
  export declare const HeaderOverflowMenuContext: import("react").Context<boolean>;
4
4
  export declare const headerOverflowMenuItemClass: string;
5
+ /** The type of the screen the shell header currently sits above; read by HeaderActionPinned. */
6
+ export declare const HeaderScreenTypeContext: import("react").Context<"actionForm" | "configEdit" | "custom" | "dashboard" | "entityEdit" | "entityList" | "projectionDetail" | "projectionList" | "secretMint" | "secretsEdit" | undefined>;
@@ -6,3 +6,5 @@ export const HeaderOverflowMenuContext = createContext(false);
6
6
  export const headerOverflowMenuItemClass = "relative flex min-h-10 w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm " +
7
7
  "outline-none transition-colors hover:bg-accent focus:bg-accent focus:text-accent-foreground " +
8
8
  "disabled:pointer-events-none disabled:opacity-50";
9
+ /** The type of the screen the shell header currently sits above; read by HeaderActionPinned. */
10
+ export const HeaderScreenTypeContext = createContext(undefined);
@@ -13,6 +13,13 @@ const triggerClass = "relative inline-flex size-8 shrink-0 items-center justify-
13
13
  "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";
14
14
  const panelClass = "z-50 flex max-h-[28rem] w-[min(22rem,calc(100vw-1.5rem))] flex-col overflow-hidden rounded-md border " +
15
15
  "bg-popover text-popover-foreground shadow-md";
16
+ function NotificationRowItem({ row, createdLabel, onOpen, }) {
17
+ const t = useTranslation();
18
+ return (_jsx("li", { children: _jsxs("button", { type: "button", "data-unread": row.isRead ? undefined : "true", className: "flex w-full items-start gap-2 border-b border-border px-3 py-2 text-left hover:bg-accent focus-visible:bg-accent focus-visible:outline-none", onClick: onOpen, children: [_jsx("span", { "aria-hidden": "true", className: cn("mt-1.5 size-2 shrink-0 rounded-full", row.isRead ? "bg-transparent" : "bg-primary") }), !row.isRead && _jsx("span", { className: "sr-only", children: t("kumiko.notifications.unread") }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: cn("block truncate text-sm", !row.isRead && "font-semibold"), children: row.title }), row.body !== null && (_jsx("span", { className: "block truncate text-xs text-muted-foreground", children: row.body })), _jsx("span", { className: "block text-xs text-muted-foreground", children: createdLabel })] })] }) }));
19
+ }
20
+ function unreadBadgeText(unreadCount) {
21
+ return unreadCount > MAX_BADGE_COUNT ? `${MAX_BADGE_COUNT}+` : String(unreadCount);
22
+ }
16
23
  export function NotificationBell({ screens, menuEntry, }) {
17
24
  const t = useTranslation();
18
25
  const nav = useNav();
@@ -20,7 +27,7 @@ export function NotificationBell({ screens, menuEntry, }) {
20
27
  const formatRelative = useRelativeTimeFormatter(locale);
21
28
  const [open, setOpen] = useState(false);
22
29
  const inbox = useInAppInbox(open);
23
- const badge = inbox.unreadCount > MAX_BADGE_COUNT ? `${MAX_BADGE_COUNT}+` : String(inbox.unreadCount);
30
+ const badge = unreadBadgeText(inbox.unreadCount);
24
31
  const label = inbox.unreadCount > 0
25
32
  ? t("kumiko.notifications.labelUnread", { count: badge })
26
33
  : t("kumiko.notifications.label");
@@ -42,8 +49,10 @@ export function NotificationBell({ screens, menuEntry, }) {
42
49
  event.preventDefault();
43
50
  menuEntry.anchorRef.current?.focus();
44
51
  },
45
- }), children: [_jsxs("div", { className: "flex items-center justify-between gap-2 border-b border-border px-3 py-2", children: [_jsx("h2", { className: "text-sm font-semibold", children: t("kumiko.notifications.title") }), inbox.unreadCount > 0 && (_jsx("button", { type: "button", className: "text-xs text-primary hover:underline", onClick: () => void inbox.markAllRead(), children: t("kumiko.notifications.markAllRead") }))] }), _jsxs("div", { className: "min-h-0 flex-1 overflow-y-auto", children: [inbox.failed && (_jsx("p", { role: "alert", className: "px-3 py-4 text-sm text-destructive", children: t("kumiko.notifications.loadFailed") })), !inbox.failed && !inbox.loading && inbox.rows.length === 0 && (_jsx("p", { className: "px-3 py-6 text-center text-sm text-muted-foreground", children: t("kumiko.notifications.empty") })), _jsx("ul", { children: inbox.rows.map((row) => (_jsx("li", { children: _jsxs("button", { type: "button", "data-unread": row.isRead ? undefined : "true", className: "flex w-full items-start gap-2 border-b border-border px-3 py-2 text-left hover:bg-accent focus-visible:bg-accent focus-visible:outline-none", onClick: () => void openRow(row), children: [_jsx("span", { "aria-hidden": "true", className: cn("mt-1.5 size-2 shrink-0 rounded-full", row.isRead ? "bg-transparent" : "bg-primary") }), !row.isRead && (_jsx("span", { className: "sr-only", children: t("kumiko.notifications.unread") })), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: cn("block truncate text-sm", !row.isRead && "font-semibold"), children: row.title }), row.body !== null && (_jsx("span", { className: "block truncate text-xs text-muted-foreground", children: row.body })), _jsx("span", { className: "block text-xs text-muted-foreground", children: formatRelative(Date.parse(row.createdAt)) })] })] }) }, row.id))) }), inbox.hasMore && (_jsx("button", { type: "button", className: "w-full px-3 py-2 text-sm text-primary hover:bg-accent", onClick: () => void inbox.loadMore(), children: t("kumiko.notifications.loadMore") }))] })] }) }));
46
- return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [menuEntry === undefined ? (_jsx(PopoverPrimitive.Trigger, { asChild: true, children: _jsxs("button", { type: "button", "aria-label": label, "data-kumiko-layout": "notification-bell", className: triggerClass, children: [_jsx(Bell, { className: "size-4", "aria-hidden": "true" }), inbox.unreadCount > 0 && (_jsx("span", { "data-kumiko-layout": "notification-bell-badge", className: "absolute right-[3px] top-[3px] rounded-full bg-destructive px-1 py-0.5 text-[9.5px] font-semibold leading-none text-destructive-foreground", children: badge }))] }) })) : (_jsxs(_Fragment, { children: [_jsx(PopoverPrimitive.Anchor, { virtualRef: menuEntry.anchorRef }), _jsxs("button", { type: "button", role: "menuitem", "data-testid": "notification-bell-menu-item", className: headerOverflowMenuItemClass, onClick: () => {
52
+ }), children: [_jsxs("div", { className: "flex items-center justify-between gap-2 border-b border-border px-3 py-2", children: [_jsx("h2", { className: "text-sm font-semibold", children: t("kumiko.notifications.title") }), inbox.unreadCount > 0 && (_jsx("button", { type: "button", className: "text-xs text-primary hover:underline", onClick: () => void inbox.markAllRead(), children: t("kumiko.notifications.markAllRead") }))] }), _jsxs("div", { className: "min-h-0 flex-1 overflow-y-auto", children: [inbox.failed && (_jsx("p", { role: "alert", className: "px-3 py-4 text-sm text-destructive", children: t("kumiko.notifications.loadFailed") })), !inbox.failed && !inbox.loading && inbox.rows.length === 0 && (_jsx("p", { className: "px-3 py-6 text-center text-sm text-muted-foreground", children: t("kumiko.notifications.empty") })), _jsx("ul", { children: inbox.rows.map((row) => (_jsx(NotificationRowItem, { row: row, createdLabel: formatRelative(Date.parse(row.createdAt)), onOpen: () => void openRow(row) }, row.id))) }), inbox.hasMore && (_jsx("button", { type: "button", className: "w-full px-3 py-2 text-sm text-primary hover:bg-accent", onClick: () => void inbox.loadMore(), children: t("kumiko.notifications.loadMore") }))] })] }) }));
53
+ return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [menuEntry === undefined ? (
54
+ // Stays mounted while the list is open, else "mark all read" would pull the anchor away.
55
+ inbox.unreadCount > 0 || open ? (_jsx(PopoverPrimitive.Trigger, { asChild: true, children: _jsxs("button", { type: "button", "aria-label": label, "data-kumiko-layout": "notification-bell", className: triggerClass, children: [_jsx(Bell, { className: "size-4", "aria-hidden": "true" }), inbox.unreadCount > 0 && (_jsx("span", { "data-kumiko-layout": "notification-bell-badge", className: "absolute right-[3px] top-[3px] rounded-full bg-destructive px-1 py-0.5 text-[9.5px] font-semibold leading-none text-destructive-foreground", children: badge }))] }) })) : null) : (_jsxs(_Fragment, { children: [_jsx(PopoverPrimitive.Anchor, { virtualRef: menuEntry.anchorRef }), _jsxs("button", { type: "button", role: "menuitem", "data-testid": "notification-bell-menu-item", className: headerOverflowMenuItemClass, onClick: () => {
47
56
  setOpen(true);
48
57
  menuEntry.onSelect();
49
58
  }, children: [_jsx(Bell, { className: "size-4", "aria-hidden": "true" }), _jsx("span", { className: "flex-1", children: t("kumiko.notifications.label") }), inbox.unreadCount > 0 && (_jsx("span", { "data-kumiko-layout": "notification-bell-badge", className: "rounded-full bg-destructive px-1.5 py-0.5 text-[9.5px] font-semibold leading-none text-destructive-foreground", children: badge }))] })] })), panel] }));
@@ -10,6 +10,8 @@ export type PageHeaderSlot = {
10
10
  readonly setTitle: (title: string | undefined) => void;
11
11
  readonly recordTitle: string | undefined;
12
12
  readonly setRecordTitle: (recordTitle: string | undefined) => void;
13
+ readonly narrowRecordTitle: string | undefined;
14
+ readonly setNarrowRecordTitle: (title: string | undefined) => void;
13
15
  readonly bodyTitle: boolean;
14
16
  readonly setBodyTitle: (bodyTitle: boolean) => void;
15
17
  readonly breadcrumbHidden: boolean;
@@ -18,6 +18,7 @@ export function PageHeaderSlotProvider({ children }) {
18
18
  const [actionsElement, setActionsElement] = useState(null);
19
19
  const [title, setTitle] = useState(undefined);
20
20
  const [recordTitle, setRecordTitle] = useState(undefined);
21
+ const [narrowRecordTitle, setNarrowRecordTitle] = useState(undefined);
21
22
  const [bodyTitle, setBodyTitle] = useState(false);
22
23
  const [breadcrumbHidden, setBreadcrumbHidden] = useState(false);
23
24
  const [breadcrumbScreenId, setBreadcrumbScreenId] = useState(undefined);
@@ -32,6 +33,8 @@ export function PageHeaderSlotProvider({ children }) {
32
33
  setTitle,
33
34
  recordTitle,
34
35
  setRecordTitle,
36
+ narrowRecordTitle,
37
+ setNarrowRecordTitle,
35
38
  bodyTitle,
36
39
  setBodyTitle,
37
40
  breadcrumbHidden,
@@ -45,6 +48,7 @@ export function PageHeaderSlotProvider({ children }) {
45
48
  actionsElement,
46
49
  title,
47
50
  recordTitle,
51
+ narrowRecordTitle,
48
52
  bodyTitle,
49
53
  breadcrumbHidden,
50
54
  breadcrumbScreenId,
@@ -25,7 +25,10 @@ function FocusedScreenFrame({ screen, screens, children, }) {
25
25
  const hasActions = topbarActions !== undefined || overflowItems.length > 0;
26
26
  return (_jsxs(_Fragment, { children: [focused && (_jsx(MobileTopBar, { label: parentScreenId !== undefined
27
27
  ? t(screenTitleKey(parentScreenId))
28
- : (slot?.recordTitle ?? slot?.title ?? t(screenTitleKey(shortId))), back: {
28
+ : (slot?.narrowRecordTitle ??
29
+ slot?.recordTitle ??
30
+ slot?.title ??
31
+ t(screenTitleKey(shortId))), back: {
29
32
  label: t("kumiko.actions.back"),
30
33
  onClick: () => parentScreenId !== undefined
31
34
  ? nav.navigate({ screenId: parentScreenId })
@@ -3,13 +3,13 @@ import { IN_APP_NOTIFICATION_FEATURE } from "@cosmicdrift/kumiko-types/in-app-no
3
3
  import { ChevronLeft, MoreHorizontal } from "lucide-react";
4
4
  import { Fragment, useEffect, useId, useMemo, useRef, useState, } from "react";
5
5
  import { resolveNavigation } from "../../headless/index.js";
6
- import { toAppSchema, useNav, usePageHeaderCompact, useTranslation, } from "../../index.js";
6
+ import { lastSegment, toAppSchema, useNav, usePageHeaderCompact, useTranslation, } from "../../index.js";
7
7
  import { Icon, NAV_ICONS } from "../icons.js";
8
8
  import { cn } from "../lib/cn.js";
9
9
  import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "../ui/breadcrumb.js";
10
10
  import { SidebarTrigger } from "../ui/sidebar.js";
11
11
  import { collectPinnedHeaderActions, isOnlyPinnedHeaderActions } from "./header-action-pinned.js";
12
- import { HeaderOverflowMenuContext, headerOverflowMenuItemClass } from "./header-overflow-menu.js";
12
+ import { HeaderOverflowMenuContext, HeaderScreenTypeContext, headerOverflowMenuItemClass, } from "./header-overflow-menu.js";
13
13
  import { buildNavRegistrySliceForApp } from "./nav-tree.js";
14
14
  import { NotificationBell } from "./notification-bell.js";
15
15
  import { usePageHeaderSlot } from "./page-header-slot.js";
@@ -43,6 +43,9 @@ export function ShellHeader({ schema, user, headerActions: appHeaderActions, all
43
43
  const slot = usePageHeaderSlot();
44
44
  const standInScreenId = slot?.breadcrumbScreenId;
45
45
  const screenId = standInScreenId ?? nav.route?.screenId;
46
+ // The qualified id wins: two features can share a short screen id.
47
+ const screenType = (allScreens.find((s) => s.id === screenId) ??
48
+ allScreens.find((s) => lastSegment(s.id) === screenId))?.type;
46
49
  const entityId = standInScreenId !== undefined ? undefined : nav.route?.entityId;
47
50
  const crumbs = useMemo(() => {
48
51
  if (screenId === undefined)
@@ -85,8 +88,13 @@ export function ShellHeader({ schema, user, headerActions: appHeaderActions, all
85
88
  // A screen that draws its own breadcrumb hides the bar's crumbs, but its parent link stays.
86
89
  const titleCrumbs = standInUntitled ? undefined : crumbs;
87
90
  const parentCrumb = titleCrumbs !== undefined && titleCrumbs.length > 1 ? titleCrumbs.at(-2) : undefined;
88
- const parentOnly = bodyTitle && compact && parentCrumb !== undefined;
91
+ // A record's short title replaces the "‹ parent" link on the phone; going back is the gesture or menu.
92
+ const phoneRecordTitle = slot?.narrowRecordTitle ?? recordTitle;
93
+ const phoneShowsRecordTitle = bodyTitle && compact && phoneRecordTitle !== undefined;
94
+ const parentOnly = bodyTitle && compact && parentCrumb !== undefined && !phoneShowsRecordTitle;
89
95
  const bodyTitleCrumbs = () => {
96
+ if (phoneShowsRecordTitle)
97
+ return [{ label: phoneRecordTitle }];
90
98
  if (compact)
91
99
  return parentCrumb === undefined ? [] : [parentCrumb];
92
100
  const ownTitle = recordTitle ?? titleCrumbs?.at(-1)?.label;
@@ -96,7 +104,7 @@ export function ShellHeader({ schema, user, headerActions: appHeaderActions, all
96
104
  ];
97
105
  };
98
106
  const shownCrumbs = bodyTitle ? bodyTitleCrumbs() : visibleCrumbs;
99
- return (_jsxs("header", { "data-kumiko-layout": "shell-header", ...(plainNav && { "data-nav-style": "plain" }), className: cn("flex h-14 shrink-0 items-center gap-3 border-b border-border pl-1.5 pr-3 md:pl-4 md:pr-6", plainNav && "h-[58px] md:gap-2.5 md:px-5", (compact || bellInOverflow) && "relative", focused && "max-md:hidden"), children: [_jsxs("div", { className: "@container flex min-w-0 flex-1 items-center gap-3", children: [_jsx(ShellSidebarTrigger, { focused: focused, plainNav: plainNav }), _jsxs("div", { className: cn("flex min-w-0", compact ? "flex-col justify-center" : "items-center gap-3"), children: [_jsx(ShellBreadcrumb, { crumbs: shownCrumbs, parentOnly: parentOnly, bodyTitle: bodyTitle, titleOverride: titleOverride }), _jsx("div", { ref: setStatusElement, "data-kumiko-layout": "page-header-status", className: cn("flex items-center gap-2 empty:hidden", compact ? "min-w-0 max-w-full overflow-hidden whitespace-nowrap text-xs" : "shrink-0") })] })] }), _jsx(ShellHeaderEnd, { compact: compact, actionsRef: setActionsElement, headerActions: headerActions, overflowItems: slot?.overflowItems ?? [], bellScreens: showsBell ? allScreens : undefined, bellInOverflow: bellInOverflow })] }));
107
+ return (_jsxs("header", { "data-kumiko-layout": "shell-header", ...(plainNav && { "data-nav-style": "plain" }), className: cn("flex h-14 shrink-0 items-center gap-3 border-b border-border pl-1.5 pr-3 md:pl-4 md:pr-6", plainNav && "h-[58px] md:gap-2.5 md:px-5", (compact || bellInOverflow) && "relative", focused && "max-md:hidden"), children: [_jsxs("div", { className: "@container flex min-w-0 flex-1 items-center gap-3", children: [_jsx(ShellSidebarTrigger, { focused: focused, plainNav: plainNav }), _jsxs("div", { className: cn("flex min-w-0", compact ? "flex-col justify-center" : "items-center gap-3"), children: [_jsx(ShellBreadcrumb, { crumbs: shownCrumbs, parentOnly: parentOnly, bodyTitle: bodyTitle, titleOverride: titleOverride }), _jsx("div", { ref: setStatusElement, "data-kumiko-layout": "page-header-status", className: cn("flex items-center gap-2 empty:hidden", compact ? "min-w-0 max-w-full overflow-hidden whitespace-nowrap text-xs" : "shrink-0") })] })] }), _jsx(HeaderScreenTypeContext.Provider, { value: screenType, children: _jsx(ShellHeaderEnd, { compact: compact, actionsRef: setActionsElement, headerActions: headerActions, overflowItems: slot?.overflowItems ?? [], bellScreens: showsBell ? allScreens : undefined, bellInOverflow: bellInOverflow }) })] }));
100
108
  }
101
109
  function foldsIntoOverflow(overflowItems, headerActions) {
102
110
  if (overflowItems.length > 0)
@@ -117,7 +125,7 @@ function VisibleHeaderActions({ compact, headerActions, }) {
117
125
  }
118
126
  function ShellHeaderEnd({ compact, actionsRef, headerActions, overflowItems, bellScreens, bellInOverflow, }) {
119
127
  const hasOverflow = bellInOverflow || (compact && foldsIntoOverflow(overflowItems, headerActions));
120
- return (_jsxs("div", { className: cn("ml-auto flex items-center gap-2", compact ? "min-w-0 max-w-[60%]" : "min-w-0 max-w-[50%] shrink-0 sm:max-w-none"), children: [_jsx("div", { ref: actionsRef, "data-kumiko-layout": "page-header-actions", className: cn(SHELL_HEADER_CONTROLS_CLASSES, "flex min-w-0 items-center gap-2 empty:hidden [&_*]:min-w-0 [&_*]:max-w-full [&_button]:overflow-hidden [&_button]:whitespace-nowrap", compact && "overflow-hidden") }), bellScreens !== undefined && !bellInOverflow && _jsx(NotificationBell, { screens: bellScreens }), _jsx(VisibleHeaderActions, { compact: compact, headerActions: headerActions }), hasOverflow && (_jsx(HeaderOverflow, { items: compact ? overflowItems : [], headerActions: compact ? headerActions : undefined, ...(bellInOverflow && bellScreens !== undefined && { bellScreens }) }))] }));
128
+ return (_jsxs("div", { className: cn("ml-auto flex items-center gap-2", compact ? "min-w-0 max-w-[60%]" : "min-w-0 max-w-[50%] shrink-0 sm:max-w-none"), children: [!compact && _jsx(VisibleHeaderActions, { compact: compact, headerActions: headerActions }), _jsx("div", { ref: actionsRef, "data-kumiko-layout": "page-header-actions", className: cn(SHELL_HEADER_CONTROLS_CLASSES, "flex min-w-0 items-center gap-2 empty:hidden [&_*]:min-w-0 [&_*]:max-w-full [&_button]:overflow-hidden [&_button]:whitespace-nowrap", compact && "overflow-hidden") }), bellScreens !== undefined && !bellInOverflow && _jsx(NotificationBell, { screens: bellScreens }), compact && _jsx(VisibleHeaderActions, { compact: compact, headerActions: headerActions }), hasOverflow && (_jsx(HeaderOverflow, { items: compact ? overflowItems : [], headerActions: compact ? headerActions : undefined, ...(bellInOverflow && bellScreens !== undefined && { bellScreens }) }))] }));
121
129
  }
122
130
  function ShellSidebarTrigger({ focused, plainNav, }) {
123
131
  const t = useTranslation();