@cosmicdrift/kumiko-renderer 0.416.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 (167) hide show
  1. package/dist/app/action-form-body.d.ts +1 -4
  2. package/dist/app/action-form-body.js +9 -8
  3. package/dist/app/config-edit-body.js +71 -79
  4. package/dist/app/entity-list-screen.js +1 -1
  5. package/dist/app/header-actions-bar.d.ts +3 -1
  6. package/dist/app/header-actions-bar.js +12 -4
  7. package/dist/app/locked-screen-header.d.ts +2 -0
  8. package/dist/app/locked-screen-header.js +8 -1
  9. package/dist/app/projection-detail-body.js +24 -5
  10. package/dist/app/projection-detail-guidance.d.ts +1 -0
  11. package/dist/app/projection-detail-guidance.js +7 -4
  12. package/dist/app/projection-detail-header-model.js +4 -1
  13. package/dist/app/projection-detail-header-region.js +25 -9
  14. package/dist/app/projection-detail-header.d.ts +2 -0
  15. package/dist/app/projection-detail-header.js +30 -3
  16. package/dist/app/projection-list-shim.js +1 -0
  17. package/dist/app/row-actions.d.ts +4 -0
  18. package/dist/app/row-actions.js +19 -3
  19. package/dist/app/use-projection-detail-actions.d.ts +3 -1
  20. package/dist/app/use-projection-detail-actions.js +9 -1
  21. package/dist/app/use-projection-detail-data.js +17 -1
  22. package/dist/app/use-projection-list-data.js +1 -1
  23. package/dist/card-options.d.ts +2 -0
  24. package/dist/components/choice-chip-class.d.ts +1 -0
  25. package/dist/components/choice-chip-class.js +9 -0
  26. package/dist/components/edit-mounts.d.ts +1 -1
  27. package/dist/components/grid-cell-for-field.js +1 -1
  28. package/dist/components/multi-select-chips.js +2 -1
  29. package/dist/components/narrow-description.d.ts +3 -0
  30. package/dist/components/narrow-description.js +12 -0
  31. package/dist/components/related-list-section.d.ts +5 -3
  32. package/dist/components/related-list-section.js +9 -4
  33. package/dist/components/related-photo-grid.js +17 -3
  34. package/dist/components/render-edit-field-grid.d.ts +12 -3
  35. package/dist/components/render-edit-field-grid.js +60 -18
  36. package/dist/components/render-edit-fields-section.js +45 -11
  37. package/dist/components/render-edit-header-actions.js +1 -1
  38. package/dist/components/render-edit-layout.js +4 -2
  39. package/dist/components/render-edit-section-kinds.js +50 -12
  40. package/dist/components/render-edit-titles.js +1 -1
  41. package/dist/components/render-edit-types.d.ts +11 -0
  42. package/dist/components/render-field-ai-assist.js +3 -2
  43. package/dist/components/render-field-control.js +1 -1
  44. package/dist/components/render-field-value-chips.js +4 -2
  45. package/dist/components/render-list-hint-columns.d.ts +1 -0
  46. package/dist/components/render-list-hint-columns.js +30 -5
  47. package/dist/components/render-list-reference-columns.js +2 -4
  48. package/dist/components/render-list-row-tone.d.ts +2 -0
  49. package/dist/components/render-list-row-tone.js +6 -0
  50. package/dist/components/render-list-table-props.d.ts +13 -2
  51. package/dist/components/render-list-table-props.js +9 -3
  52. package/dist/components/render-list-types.d.ts +4 -0
  53. package/dist/components/render-list.js +12 -4
  54. package/dist/components/use-render-list-columns.js +3 -3
  55. package/dist/components/write-form-registry.d.ts +13 -0
  56. package/dist/components/write-form-registry.js +6 -0
  57. package/dist/components/write-form-section.d.ts +5 -1
  58. package/dist/components/write-form-section.js +55 -16
  59. package/dist/headless/form/form-controller.d.ts +1 -0
  60. package/dist/headless/form/form-controller.js +1 -1
  61. package/dist/headless/format/index.js +5 -4
  62. package/dist/headless/format/relative-time.d.ts +2 -0
  63. package/dist/headless/format/relative-time.js +4 -1
  64. package/dist/headless/view-model/edit.js +87 -37
  65. package/dist/headless/view-model/list.js +6 -0
  66. package/dist/headless/view-model/types.d.ts +49 -4
  67. package/dist/hooks/use-list-table.js +11 -6
  68. package/dist/i18n-defaults.js +7 -2
  69. package/dist/primitives-record-guidance.d.ts +4 -0
  70. package/dist/primitives-share-types.d.ts +82 -0
  71. package/dist/primitives-share-types.js +1 -0
  72. package/dist/primitives.d.ts +34 -83
  73. package/dist/web/app/bold-markup.d.ts +3 -0
  74. package/dist/web/app/bold-markup.js +14 -0
  75. package/dist/web/app/dashboard-body.js +5 -1
  76. package/dist/web/app/dashboard-list-panel.js +7 -4
  77. package/dist/web/app/dashboard-panels.js +31 -3
  78. package/dist/web/app/dashboard-shared.d.ts +3 -1
  79. package/dist/web/app/dashboard-shared.js +3 -3
  80. package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -1
  81. package/dist/web/app/dashboard-stat-group-panel.js +16 -2
  82. package/dist/web/app/dashboard-text-panel.js +11 -6
  83. package/dist/web/app/relative-time.js +10 -1
  84. package/dist/web/components/config-cascade.d.ts +2 -1
  85. package/dist/web/components/config-cascade.js +16 -4
  86. package/dist/web/drawn-icons.js +2 -1
  87. package/dist/web/layout/header-action-pinned.d.ts +4 -2
  88. package/dist/web/layout/header-action-pinned.js +13 -4
  89. package/dist/web/layout/header-overflow-menu.d.ts +2 -0
  90. package/dist/web/layout/header-overflow-menu.js +2 -0
  91. package/dist/web/layout/notification-bell.js +12 -3
  92. package/dist/web/layout/page-header-slot.d.ts +2 -0
  93. package/dist/web/layout/page-header-slot.js +4 -0
  94. package/dist/web/layout/screen-focus.js +4 -1
  95. package/dist/web/layout/shell-header.js +13 -5
  96. package/dist/web/primitives/banner.js +14 -3
  97. package/dist/web/primitives/card.js +5 -3
  98. package/dist/web/primitives/combobox.js +2 -2
  99. package/dist/web/primitives/data-table/actions-column.js +1 -1
  100. package/dist/web/primitives/data-table/card-body.d.ts +1 -1
  101. package/dist/web/primitives/data-table/card-body.js +37 -14
  102. package/dist/web/primitives/data-table/card-frame.d.ts +2 -0
  103. package/dist/web/primitives/data-table/card-frame.js +3 -0
  104. package/dist/web/primitives/data-table/card-row.js +28 -9
  105. package/dist/web/primitives/data-table/card-sort-select.js +1 -1
  106. package/dist/web/primitives/data-table/card-view.js +1 -1
  107. package/dist/web/primitives/data-table/data-cell-props.d.ts +2 -1
  108. package/dist/web/primitives/data-table/data-cell-props.js +1 -0
  109. package/dist/web/primitives/data-table/density.d.ts +3 -1
  110. package/dist/web/primitives/data-table/density.js +11 -4
  111. package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
  112. package/dist/web/primitives/data-table/row-render-parts.js +3 -5
  113. package/dist/web/primitives/data-table/sort-options-select.js +2 -2
  114. package/dist/web/primitives/data-table/sortable-header.js +4 -4
  115. package/dist/web/primitives/data-table/table-body.js +2 -1
  116. package/dist/web/primitives/data-table/table-chrome.js +1 -3
  117. package/dist/web/primitives/data-table/table-content.js +7 -11
  118. package/dist/web/primitives/data-table/table-data-cell.js +31 -17
  119. package/dist/web/primitives/data-table/table-header-row.js +1 -1
  120. package/dist/web/primitives/data-table/table-view.js +1 -1
  121. package/dist/web/primitives/data-table/toolbar.js +6 -7
  122. package/dist/web/primitives/data-table/use-data-table-state.d.ts +6 -1
  123. package/dist/web/primitives/data-table/use-data-table-state.js +12 -2
  124. package/dist/web/primitives/data-table-cell.d.ts +13 -2
  125. package/dist/web/primitives/data-table-cell.js +123 -43
  126. package/dist/web/primitives/data-table.js +1 -1
  127. package/dist/web/primitives/default-form.d.ts +1 -1
  128. package/dist/web/primitives/default-form.js +11 -10
  129. package/dist/web/primitives/drawer.js +2 -7
  130. package/dist/web/primitives/facet-filter.d.ts +1 -1
  131. package/dist/web/primitives/facet-filter.js +2 -5
  132. package/dist/web/primitives/facet-search-filter.js +1 -1
  133. package/dist/web/primitives/facet-trigger-label.d.ts +1 -4
  134. package/dist/web/primitives/facet-trigger-label.js +4 -7
  135. package/dist/web/primitives/field.js +15 -8
  136. package/dist/web/primitives/form-footer-parts.js +2 -2
  137. package/dist/web/primitives/inline-suffix.d.ts +2 -0
  138. package/dist/web/primitives/inline-suffix.js +5 -0
  139. package/dist/web/primitives/input-choice-kinds.js +12 -2
  140. package/dist/web/primitives/input-number-kinds.js +2 -2
  141. package/dist/web/primitives/input-text-kinds.js +1 -1
  142. package/dist/web/primitives/layout-elements.d.ts +4 -4
  143. package/dist/web/primitives/layout-elements.js +49 -12
  144. package/dist/web/primitives/layout.d.ts +1 -1
  145. package/dist/web/primitives/layout.js +1 -1
  146. package/dist/web/primitives/money-input.js +8 -7
  147. package/dist/web/primitives/number-input.d.ts +2 -1
  148. package/dist/web/primitives/number-input.js +9 -4
  149. package/dist/web/primitives/page-header.d.ts +1 -1
  150. package/dist/web/primitives/page-header.js +8 -1
  151. package/dist/web/primitives/pager.js +12 -21
  152. package/dist/web/primitives/photo-grid.js +2 -1
  153. package/dist/web/primitives/record-steps.d.ts +1 -1
  154. package/dist/web/primitives/record-steps.js +6 -15
  155. package/dist/web/primitives/row-actions.js +38 -24
  156. package/dist/web/primitives/use-container-narrow.d.ts +12 -0
  157. package/dist/web/primitives/use-container-narrow.js +42 -0
  158. package/dist/web/ui/input.js +1 -1
  159. package/dist/web/ui/textarea.js +1 -1
  160. package/dist/web/widgets/dashboard-list-cards.js +6 -3
  161. package/dist/web/widgets/dashboard-list.d.ts +4 -1
  162. package/dist/web/widgets/dashboard-list.js +10 -5
  163. package/dist/web/widgets/progress-list.js +1 -1
  164. package/dist/web/widgets/stat-box-cell.js +1 -1
  165. package/package.json +5 -5
  166. package/src/changes.json +51 -0
  167. package/src/web/styles.css +3 -2
@@ -22,7 +22,7 @@ export declare function DrawerHost({ schema, drawerAction, drawerScreen, drawerI
22
22
  readonly onClose: () => void;
23
23
  readonly onSuccess: () => void;
24
24
  }): ReactNode;
25
- export declare function ActionFormBody({ schema, screen, translate, entityId, initialOverrides, onSuccess, onCancelOverride, onDirtyChange, submitLabelFallback, }: {
25
+ export declare function ActionFormBody({ schema, screen, translate, entityId, initialOverrides, onSuccess, onDirtyChange, submitLabelFallback, }: {
26
26
  readonly schema: FeatureSchema;
27
27
  readonly screen: ActionFormScreenDefinition;
28
28
  readonly translate?: Translate;
@@ -36,9 +36,6 @@ export declare function ActionFormBody({ schema, screen, translate, entityId, in
36
36
  * drawer + refetches its list; a declared `screen.redirect` then navigates
37
37
  * (without returnTo, a drawer is no navigation target). */
38
38
  readonly onSuccess?: () => void;
39
- /** Drawer-hosted usage: replaces the cancelTarget/redirect-based Cancel
40
- * handler so Cancel closes the drawer instead of navigating. */
41
- readonly onCancelOverride?: () => void;
42
39
  /** Drawer-hosted usage: reports unsaved input so the host can confirm
43
40
  * before discarding it. */
44
41
  readonly onDirtyChange?: (dirty: boolean) => void;
@@ -91,7 +91,7 @@ export function DrawerHost({ schema, drawerAction, drawerScreen, drawerInitialVa
91
91
  }), onSuccess: () => {
92
92
  setHasUnsavedInput(false);
93
93
  onSuccess();
94
- }, onCancelOverride: requestClose, onDirtyChange: setHasUnsavedInput, submitLabelFallback: drawerAction.label })) }) }) }), _jsx(Dialog, { open: confirmDiscardOpen, onOpenChange: setConfirmDiscardOpen, title: t("kumiko.drawer.discard.title"), description: t("kumiko.drawer.discard.body"), confirmLabel: t("kumiko.drawer.discard.confirm"), cancelLabel: t("kumiko.drawer.discard.cancel"), variant: "danger", initialFocus: "cancel", onConfirm: closeAndReset, testId: "drawer-discard-dialog" })] }));
94
+ }, onDirtyChange: setHasUnsavedInput, submitLabelFallback: drawerAction.label })) }) }) }), _jsx(Dialog, { open: confirmDiscardOpen, onOpenChange: setConfirmDiscardOpen, title: t("kumiko.drawer.discard.title"), description: t("kumiko.drawer.discard.body"), confirmLabel: t("kumiko.drawer.discard.confirm"), cancelLabel: t("kumiko.drawer.discard.cancel"), variant: "danger", initialFocus: "cancel", onConfirm: closeAndReset, testId: "drawer-discard-dialog" })] }));
95
95
  }
96
96
  function declaresSuccessContent(screen) {
97
97
  return ((screen.successLinks?.length ?? 0) > 0 ||
@@ -114,13 +114,13 @@ function buildSuccessState(text, screen, resultData, context) {
114
114
  // to entityEdit, only the submit path switches from the CRUD verb to the
115
115
  // author-declared handler QN + payloadMode="values" (send all form values
116
116
  // instead of only the changes).
117
- export function ActionFormBody({ schema, screen, translate, entityId, initialOverrides, onSuccess, onCancelOverride, onDirtyChange, submitLabelFallback, }) {
117
+ export function ActionFormBody({ schema, screen, translate, entityId, initialOverrides, onSuccess, onDirtyChange, submitLabelFallback, }) {
118
118
  const nav = useNav();
119
119
  const appFeatures = useAppFeatures();
120
120
  const insideDrawer = useInsideDrawer();
121
121
  const locale = useLocale().locale();
122
122
  const { Banner, StatusBadge } = usePrimitives();
123
- // Unused when drawer-hosted — onSuccess/onCancelOverride win below first.
123
+ // Unused when drawer-hosted — onSuccess wins below first.
124
124
  const returnTarget = useReturnTarget(screen.id);
125
125
  const submittableFields = useMemo(() => actionFormSubmittableFields(screen), [screen]);
126
126
  const synthEntity = useMemo(() => synthesizeActionFormEntity(submittableFields), [submittableFields]);
@@ -282,15 +282,16 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
282
282
  // `false` switches the button off explicitly (single-action screens where
283
283
  // cancel would just be submit-without-sending).
284
284
  // returnTo wins over the declared target when both are present.
285
+ // A drawer closes through its × / Esc (which confirms unsaved input), so its footer has no Cancel.
285
286
  const handleCancel = useMemo(() => {
286
- if (onCancelOverride !== undefined)
287
- return onCancelOverride;
287
+ if (insideDrawer)
288
+ return undefined;
288
289
  const target = screen.cancelTarget ??
289
290
  (screen.redirect !== undefined ? redirectScreenTarget(screen.redirect) : undefined);
290
291
  if (target === undefined || target === false)
291
292
  return undefined;
292
293
  return () => navigateToReturnOr(nav, returnTarget, () => nav.navigate({ screenId: lastSegment(target) }));
293
- }, [nav, screen.redirect, screen.cancelTarget, onCancelOverride, returnTarget]);
294
+ }, [nav, screen.redirect, screen.cancelTarget, insideDrawer, returnTarget]);
294
295
  // Rendering the form before a tenant-declared currency lands would show the
295
296
  // fallback and, on a fast click, submit it — hold instead.
296
297
  if (currencyLoading) {
@@ -309,7 +310,7 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
309
310
  extensionInitialValues: initial, ...(screen.submitPrefilled === true && {
310
311
  submitWithoutChanges: hiddenRequiredFieldsFilled(synthScreen, screen.fields, initial),
311
312
  }), ...((success !== undefined || screen.infoBand !== undefined) && {
312
- leadContent: (_jsxs(_Fragment, { children: [screen.infoBand !== undefined && (_jsx(Banner, { variant: "primary", icon: "sparkles", density: "compact", testId: "kumiko-screen-action-form-info-band", children: effectiveTranslate(screen.infoBand) })), success !== undefined && _jsx(ActionFormSuccessBanner, { success: success })] })),
313
+ leadContent: (_jsxs(_Fragment, { children: [screen.infoBand !== undefined && (_jsx(Banner, { variant: "assist", icon: "sparkles", density: "compact", testId: "kumiko-screen-action-form-info-band", children: effectiveTranslate(screen.infoBand) })), success !== undefined && _jsx(ActionFormSuccessBanner, { success: success })] })),
313
314
  }), ...(screen.fieldBadges !== undefined &&
314
315
  StatusBadge !== undefined && {
315
316
  labelAppendix: (fieldName) => {
@@ -320,7 +321,7 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
320
321
  },
321
322
  }), writeCommand: screen.handler, payloadMode: "values", onSubmit: handleSubmitted, ...(handleCancel !== undefined && { onCancel: handleCancel }), onDirtyChange: handleDirtyChange, ...((insideDrawer || screenFillsHeight(screen)) && { fillScreenHeight: true }), ...((screen.submitLabel ?? submitLabelFallback) !== undefined && {
322
323
  submitLabel: screen.submitLabel ?? submitLabelFallback,
323
- }), ...(screen.submitStyle !== undefined && { submitVariant: screen.submitStyle }), ...(screen.footerActions !== undefined && { footerActions: screen.footerActions }), ...(screen.formErrorOnTop === true && { formErrorOnTop: true }), ...(screen.fieldDescriptions !== undefined && {
324
+ }), ...(screen.submitStyle !== undefined && { submitVariant: screen.submitStyle }), ...(screen.footerActions !== undefined && { footerActions: screen.footerActions }), formErrorOnTop: true, ...(screen.fieldDescriptions !== undefined && {
324
325
  fieldDescription: (fieldName, values) => {
325
326
  const ref = screen.fieldDescriptions?.[fieldName];
326
327
  if (ref === undefined)
@@ -114,6 +114,58 @@ function isEmptyNumericFormValue(value) {
114
114
  return true;
115
115
  return typeof value === "number" && !Number.isFinite(value);
116
116
  }
117
+ // Same wire shape as a writeOnly config field: null removes, a string replaces.
118
+ function secretChangeCommand(secretKey, value, secretScopePayload) {
119
+ if (value === null) {
120
+ return { type: "secrets:write:delete", payload: { key: secretKey, ...secretScopePayload } };
121
+ }
122
+ if (typeof value === "string" && value.trim() !== "") {
123
+ return { type: "secrets:write:set", payload: { key: secretKey, value, ...secretScopePayload } };
124
+ }
125
+ return undefined;
126
+ }
127
+ // One changed form value to its write command; undefined when nothing has to be sent.
128
+ function configChangeCommand({ shortName, value, screen, secretKey, secretScopePayload, }) {
129
+ if (secretKey !== undefined)
130
+ return secretChangeCommand(secretKey, value, secretScopePayload);
131
+ const qualified = screen.configKeys[shortName];
132
+ if (qualified === undefined)
133
+ return undefined;
134
+ const fieldDef = screen.fields[shortName]; // @cast-boundary schema-walk
135
+ const ftype = fieldDef?.type;
136
+ const reset = {
137
+ type: "config:write:reset",
138
+ payload: { key: qualified, scope: screen.scope },
139
+ };
140
+ if (isWriteOnlyTextField(screen.fields[shortName])) {
141
+ // true (untouched/undone) and "" mean keep the stored secret; null removes it.
142
+ if (value === null)
143
+ return reset;
144
+ if (typeof value === "string" && value !== "") {
145
+ return {
146
+ type: "config:write:set",
147
+ payload: { key: qualified, value, scope: screen.scope },
148
+ };
149
+ }
150
+ return undefined;
151
+ }
152
+ // A query-backed select is cleared to "" when its dependent value became
153
+ // invalid. config:write:set would store that as an empty override (the
154
+ // badge shows "Mandant" with no value); reset falls back to the inherited
155
+ // value. set can't do it: deleting the row is irreversible, reset is
156
+ // the high-risk handler.
157
+ if (ftype === "select" && fieldDef?.optionsQuery !== undefined && value === "")
158
+ return reset;
159
+ // Cleared number/money: drop this scope's override instead of storing an empty value.
160
+ const storedValue = ftype === "money" ? unwrapMoneyValue(value) : value;
161
+ if ((ftype === "number" || ftype === "money") && isEmptyNumericFormValue(storedValue)) {
162
+ return reset;
163
+ }
164
+ return {
165
+ type: "config:write:set",
166
+ payload: { key: qualified, value: storedValue, scope: screen.scope },
167
+ };
168
+ }
117
169
  export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
118
170
  const { ConfigCascadeView } = usePrimitives();
119
171
  const t = useTranslation();
@@ -234,80 +286,17 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
234
286
  for (const [shortName, value] of Object.entries(snapshot.changes)) {
235
287
  if (hiddenFieldNames.has(shortName))
236
288
  continue;
237
- const secretKey = secretKeys?.[shortName];
238
- if (secretKey !== undefined) {
239
- // Same wire shape as a writeOnly config field: null removes, a string replaces.
240
- if (value === null) {
241
- commandFieldNames.push(shortName);
242
- commands.push({
243
- type: "secrets:write:delete",
244
- payload: { key: secretKey, ...secretScopePayload },
245
- });
246
- }
247
- else if (typeof value === "string" && value.trim() !== "") {
248
- commandFieldNames.push(shortName);
249
- commands.push({
250
- type: "secrets:write:set",
251
- payload: { key: secretKey, value, ...secretScopePayload },
252
- });
253
- }
254
- continue;
255
- }
256
- const qualified = screen.configKeys[shortName];
257
- if (qualified === undefined)
258
- continue;
259
- const fieldDef = screen.fields[shortName];
260
- const ftype = fieldDef?.type;
261
- if (isWriteOnlyTextField(screen.fields[shortName])) {
262
- // true (untouched/undone) and "" mean keep the stored secret; null removes it.
263
- if (value === null) {
264
- commandFieldNames.push(shortName);
265
- commands.push({
266
- type: "config:write:reset",
267
- payload: { key: qualified, scope: screen.scope },
268
- });
269
- }
270
- else if (typeof value === "string" && value !== "") {
271
- commandFieldNames.push(shortName);
272
- commands.push({
273
- type: "config:write:set",
274
- payload: { key: qualified, value, scope: screen.scope },
275
- });
276
- }
277
- continue;
278
- }
279
- // A query-backed select is cleared to "" when its dependent value became
280
- // invalid. config:write:set would store that as an empty override (the
281
- // badge shows "Mandant" with no value); reset falls back to the inherited
282
- // value. set can't do it: deleting the row is irreversible, reset is
283
- // the high-risk handler.
284
- if (ftype === "select" && fieldDef?.optionsQuery !== undefined && value === "") {
285
- commandFieldNames.push(shortName);
286
- commands.push({
287
- type: "config:write:reset",
288
- payload: { key: qualified, scope: screen.scope },
289
- });
290
- continue;
291
- }
292
- // Cleared number/money: drop this scope's override instead of storing an empty value.
293
- if ((ftype === "number" || ftype === "money") &&
294
- isEmptyNumericFormValue(ftype === "money" ? unwrapMoneyValue(value) : value)) {
295
- commandFieldNames.push(shortName);
296
- commands.push({
297
- type: "config:write:reset",
298
- payload: { key: qualified, scope: screen.scope },
299
- });
289
+ const command = configChangeCommand({
290
+ shortName,
291
+ value,
292
+ screen,
293
+ secretKey: secretKeys?.[shortName],
294
+ secretScopePayload,
295
+ });
296
+ if (command === undefined)
300
297
  continue;
301
- }
302
298
  commandFieldNames.push(shortName);
303
- commands.push({
304
- type: "config:write:set",
305
- payload: {
306
- key: qualified,
307
- value: ftype === "money" ? unwrapMoneyValue(value) : value,
308
- scope: screen.scope,
309
- },
310
- });
299
+ commands.push(command);
311
300
  }
312
301
  if (commands.length === 0) {
313
302
  return { validationBlocked: false, isSuccess: true, data: undefined };
@@ -334,9 +323,7 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
334
323
  dispatcher,
335
324
  synthScreen,
336
325
  secretKeys,
337
- screen.configKeys,
338
- screen.fields,
339
- screen.scope,
326
+ screen,
340
327
  valuesQuery.refetch,
341
328
  cascadeQuery.refetch,
342
329
  secretsQuery.refetch,
@@ -369,22 +356,27 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
369
356
  return undefined;
370
357
  return (value) => buildOptionLabels(effectiveTranslate, (option) => fieldOptionLabelKey(schema.featureName, synthScreen.entity, fieldName, option), [String(value)])[String(value)];
371
358
  };
372
- return (_jsx(RenderEdit, { screen: synthScreen, entity: synthEntity, featureName: schema.featureName, initial: initial, schema: boundsSchema, customSubmit: customSubmit, dirtyFooter: true, validateOnChange: true, ...(screenFillsHeight(screen) && { fillScreenHeight: true }), ...(screen.submitLabel !== undefined && { submitLabel: screen.submitLabel }), ...(translate !== undefined && { translate }), fieldAppendixPlacement: "below-control", fieldAccent: (fieldName) => cascades[fieldName]?.levels.find((level) => level.isActive)?.source ===
373
- CONFIG_SCOPE_SOURCE[screen.scope], markChangedFields: true, ...actionRowsAfterField(screen.actions, effectiveTranslate), ...(screen.fieldDescriptions !== undefined && {
359
+ const compact = screen.compact === true;
360
+ const form = (_jsx(RenderEdit, { screen: synthScreen, entity: synthEntity, featureName: schema.featureName, initial: initial, schema: boundsSchema, customSubmit: customSubmit, dirtyFooter: true, validateOnChange: true, ...(screenFillsHeight(screen) && { fillScreenHeight: true }), ...(screen.submitLabel !== undefined && { submitLabel: screen.submitLabel }), ...(translate !== undefined && { translate }), fieldAppendixPlacement: "below-control", ...(compact && { recordSections: { labelTitles: true } }), ...(!compact && {
361
+ fieldAccent: (fieldName) => cascades[fieldName]?.levels.find((level) => level.isActive)?.source ===
362
+ CONFIG_SCOPE_SOURCE[screen.scope],
363
+ markChangedFields: true,
364
+ }), ...actionRowsAfterField(screen.actions, effectiveTranslate), ...(screen.fieldDescriptions !== undefined && {
374
365
  fieldDescription: (fieldName) => {
375
366
  const key = screen.fieldDescriptions?.[fieldName];
376
367
  return key === undefined ? undefined : effectiveTranslate(key);
377
368
  },
378
369
  }), fieldAppendix: (fieldName) => {
379
370
  const cascade = cascades[fieldName];
380
- if (cascade === undefined)
371
+ if (compact || cascade === undefined)
381
372
  return undefined;
382
373
  const renderValue = cascadeValueRenderer(fieldName);
383
- return (_jsx(ConfigCascadeView, { cascade: cascade, screenScope: screen.scope, qualifiedKey: screen.configKeys[fieldName], required: screen.requiredFields?.includes(fieldName) ?? false, ...(renderValue !== undefined && { renderValue }), ...(!readOnlyFields.has(fieldName) && {
374
+ return (_jsx(ConfigCascadeView, { cascade: cascade, screenScope: screen.scope, qualifiedKey: screen.configKeys[fieldName], compact: true, required: screen.requiredFields?.includes(fieldName) ?? false, ...(renderValue !== undefined && { renderValue }), ...(!readOnlyFields.has(fieldName) && {
384
375
  onReset: async (key, scope) => {
385
376
  await dispatcher.write("config:write:reset", { key, scope });
386
377
  await Promise.allSettled([valuesQuery.refetch?.(), cascadeQuery.refetch?.()]);
387
378
  },
388
379
  }) }));
389
380
  } }));
381
+ return compact ? (_jsx("div", { "data-testid": "config-edit-compact", className: "h-full min-h-0 [&>form>div:first-child]:mx-0 [&>form>div:first-child]:max-w-[940px] [&_.relative>input]:pl-3 [&_.relative>svg.pointer-events-none]:hidden", children: form })) : (form);
390
382
  }
@@ -162,8 +162,8 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
162
162
  const filterFacets = useMemo(() => {
163
163
  const namedFacet = buildNamedFilterFacet(screen.namedFilters, effectiveTranslate, userRoles, screen.namedFilterFacet, facetCounts);
164
164
  return [
165
- ...(namedFacet !== undefined ? [namedFacet] : []),
166
165
  ...buildEntityFilterFacets(mergeReferenceFacetOptions(entityFacetSpecs, entityReferenceFacetOptions), screen.facets, effectiveTranslate, facetCounts),
166
+ ...(namedFacet !== undefined ? [namedFacet] : []),
167
167
  ];
168
168
  }, [
169
169
  entityFacetSpecs,
@@ -2,11 +2,13 @@ import type { ReactNode } from "react";
2
2
  import type { RenderEditAction } from "../components/render-edit-types.ts";
3
3
  import type { usePrimitives } from "../primitives.tsx";
4
4
  import type { ErrorNotice } from "./error-reference.tsx";
5
- export declare function HeaderActionsBar({ actions, Button, Dialog, ActionOverflowMenu, onError, collapseAfterPrimary, compact, preferredPrimaryId, inlineActionIds, PageHeader, overflowTestId, }: {
5
+ export declare function HeaderActionsBar({ actions, Button, Dialog, ActionOverflowMenu, onError, collapseAfterPrimary, compact, preferredPrimaryId, inlineActionIds, menuActionIds, PageHeader, overflowTestId, }: {
6
6
  /** `primaryAction` of the screen: wins over the edit/primary-style precedence. */
7
7
  readonly preferredPrimaryId?: string;
8
8
  /** `inlineActions` of the screen: stay buttons next to the primary instead of the menu. */
9
9
  readonly inlineActionIds?: readonly string[];
10
+ /** `placement: "menu"` actions of the screen: always in the menu, never a button. */
11
+ readonly menuActionIds?: readonly string[];
10
12
  /** Header slot layout: only the primary action stays a button, the rest goes into the menu. */
11
13
  readonly collapseAfterPrimary?: boolean;
12
14
  /** Phone-width shell header: an icon-only primary button, the rest in the shell's overflow menu. */
@@ -9,21 +9,29 @@ import { compactHeaderPrimary, orderPlainHeaderActions, splitHeaderActions, } fr
9
9
  // state for menu items: RenderEditActionButton already owns a per-button
10
10
  // confirm dialog for the always-visible primary action, but a menu item has
11
11
  // no button of its own to carry one.
12
- export function HeaderActionsBar({ actions, Button, Dialog, ActionOverflowMenu, onError, collapseAfterPrimary = false, compact = false, preferredPrimaryId, inlineActionIds, PageHeader, overflowTestId = "kumiko-screen-projection-detail-actions-overflow", }) {
12
+ export function HeaderActionsBar({ actions, Button, Dialog, ActionOverflowMenu, onError, collapseAfterPrimary = false, compact = false, preferredPrimaryId, inlineActionIds, menuActionIds, PageHeader, overflowTestId = "kumiko-screen-projection-detail-actions-overflow", }) {
13
13
  const t = useTranslation();
14
14
  const { toMenuItem, confirmDialog: pendingActionDialog } = useActionMenuItems({
15
15
  Dialog,
16
16
  onError,
17
17
  });
18
18
  if (compact && PageHeader !== undefined) {
19
- const compactPrimary = compactHeaderPrimary(actions, preferredPrimaryId);
19
+ const compactPrimary = compactHeaderPrimary(actions.filter((a) => !menuActionIds?.includes(a.id)), preferredPrimaryId);
20
20
  const overflowActions = actions.filter((a) => a !== compactPrimary?.action);
21
21
  return (_jsxs(_Fragment, { children: [compactPrimary !== undefined && (_jsx(RenderEditActionButton, { action: compactPrimary.action, Button: Button, Dialog: Dialog, iconOnly: compactPrimary.iconOnly, onError: onError }, compactPrimary.action.id)), overflowActions.length > 0 && (_jsx(PageHeader, { overflowItems: overflowActions.map(toMenuItem) })), pendingActionDialog] }));
22
22
  }
23
+ const dangerMenuActions = actions.filter((action) => (collapseAfterPrimary && action.style === "danger") ||
24
+ (ActionOverflowMenu !== undefined && menuActionIds?.includes(action.id) === true));
25
+ const visibleCandidates = actions.filter((action) => !dangerMenuActions.includes(action));
23
26
  const maxPlainButtons = collapseAfterPrimary ? 1 : 2;
24
- if (actions.length <= maxPlainButtons || ActionOverflowMenu === undefined) {
27
+ if (ActionOverflowMenu === undefined ||
28
+ (visibleCandidates.length <= maxPlainButtons && dangerMenuActions.length === 0)) {
25
29
  return (_jsx(_Fragment, { children: orderPlainHeaderActions(actions, preferredPrimaryId).map((action) => (_jsx(RenderEditActionButton, { action: action, Button: Button, Dialog: Dialog, hideIcon: true, onError: onError }, action.id))) }));
26
30
  }
27
- const { buttons, menu } = splitHeaderActions(actions, preferredPrimaryId, inlineActionIds);
31
+ const split = visibleCandidates.length <= maxPlainButtons
32
+ ? { buttons: orderPlainHeaderActions(visibleCandidates, preferredPrimaryId), menu: [] }
33
+ : splitHeaderActions(visibleCandidates, preferredPrimaryId, inlineActionIds);
34
+ const { buttons } = split;
35
+ const menu = [...split.menu, ...dangerMenuActions];
28
36
  return (_jsxs(_Fragment, { children: [buttons.map((action) => (_jsx(RenderEditActionButton, { action: action, Button: Button, Dialog: Dialog, hideIcon: true, onError: onError }, action.id))), menu.length > 0 && (_jsx(ActionOverflowMenu, { label: t("kumiko.list.row-actions.more"), testId: overflowTestId, items: menu.map(toMenuItem) })), pendingActionDialog] }));
29
37
  }
@@ -7,3 +7,5 @@ export declare function LockedHeaderScope({ standInScreenId, children, }: {
7
7
  readonly standInScreenId?: string;
8
8
  readonly children?: ReactNode;
9
9
  }): ReactNode;
10
+ /** True while the screen renders as the stand-in of a locked screen (`visibleWhen` + `fallback`). */
11
+ export declare function useIsStandInScreen(): boolean;
@@ -15,6 +15,9 @@ function LockedScreenHeader({ standInScreenId }) {
15
15
  // every mounted PageHeader overwrites and clears on unmount, so only the outermost scope mounts
16
16
  // a header; nested scopes report the screen that finally renders up to it.
17
17
  const ReportStandInContext = createContext(undefined);
18
+ // Separate from ReportStandInContext: the stand-in's own KumikoScreen wraps its body in a
19
+ // StandInChainBoundary, which clears the report context, so that one cannot tell a body it is a stand-in.
20
+ const StandInScreenContext = createContext(false);
18
21
  /** Screen bodies (and anything embedded in them) are not part of a fallback chain. */
19
22
  export function StandInChainBoundary({ children }) {
20
23
  return (_jsx(ReportStandInContext.Provider, { value: undefined, children: children }));
@@ -29,5 +32,9 @@ export function LockedHeaderScope({ standInScreenId, children, }) {
29
32
  reportToOuter({ screenId: effectiveScreenId });
30
33
  return () => reportToOuter(undefined);
31
34
  }, [reportToOuter, effectiveScreenId]);
32
- return (_jsxs(_Fragment, { children: [reportToOuter === undefined && (_jsx(LockedScreenHeader, { ...(effectiveScreenId !== undefined && { standInScreenId: effectiveScreenId }) })), _jsx(ReportStandInContext.Provider, { value: setInner, children: children })] }));
35
+ return (_jsxs(_Fragment, { children: [reportToOuter === undefined && (_jsx(LockedScreenHeader, { ...(effectiveScreenId !== undefined && { standInScreenId: effectiveScreenId }) })), _jsx(StandInScreenContext.Provider, { value: standInScreenId !== undefined, children: _jsx(ReportStandInContext.Provider, { value: setInner, children: children }) })] }));
36
+ }
37
+ /** True while the screen renders as the stand-in of a locked screen (`visibleWhen` + `fallback`). */
38
+ export function useIsStandInScreen() {
39
+ return useContext(StandInScreenContext);
33
40
  }
@@ -1,6 +1,8 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { evalFieldCondition } from "@cosmicdrift/kumiko-framework/ui-types";
2
3
  import { useState } from "react";
3
4
  import { RenderEdit } from "../components/render-edit.js";
5
+ import { WriteFormRegistryProvider } from "../components/write-form-registry.js";
4
6
  import { useOptionalDispatcher } from "../context/dispatcher-context.js";
5
7
  import { useUserRoles } from "../context/user-roles-context.js";
6
8
  import { useLocale, useTranslation } from "../i18n.js";
@@ -52,6 +54,8 @@ export function ProjectionDetailBody({ schema, screen, translate, entityId, }) {
52
54
  // headerActions moved out of RenderEdit's footer — this component owns
53
55
  // the failure-surfacing state RenderEdit used to own for them.
54
56
  const [actionError, setActionError] = useState(null);
57
+ // writeForm sections register here so an action with `submitWith` can send their values.
58
+ const [writeForms] = useState(() => new Map());
55
59
  const appFeatures = useAppFeatures();
56
60
  const userRoles = useUserRoles();
57
61
  const dispatcher = useOptionalDispatcher();
@@ -79,6 +83,7 @@ export function ProjectionDetailBody({ schema, screen, translate, entityId, }) {
79
83
  detailQuery,
80
84
  reloadDetail,
81
85
  activeTabId: activeSection?.id,
86
+ writeForms,
82
87
  });
83
88
  const { hasMetrics, headerActionsList, hasHeaderActions, hasHeaderCard, renderedDetailScreen } = useProjectionDetailLayout({ screen, headerActions, hasTabs, detailScreen });
84
89
  const recordId = detailQuery.data?.["id"];
@@ -103,8 +108,13 @@ export function ProjectionDetailBody({ schema, screen, translate, entityId, }) {
103
108
  if (!record) {
104
109
  return renderRecordNotFound({ schema, screen, nav, returnTarget, effectiveTranslate });
105
110
  }
111
+ const visibleMetrics = screen.metrics?.filter((metric) => metric.visibleWhen === undefined || evalFieldCondition(metric.visibleWhen, { ...record }));
106
112
  const regionModel = {
107
- screen: { ...screen, layout: { ...screen.layout, sections: visibleSections } },
113
+ screen: {
114
+ ...screen,
115
+ ...(visibleMetrics !== undefined && { metrics: visibleMetrics }),
116
+ layout: { ...screen.layout, sections: visibleSections },
117
+ },
108
118
  record,
109
119
  primitives,
110
120
  effectiveTranslate,
@@ -119,7 +129,7 @@ export function ProjectionDetailBody({ schema, screen, translate, entityId, }) {
119
129
  pageHeaderSlotAvailable,
120
130
  pageHeaderCompactContext,
121
131
  hasHeaderActions,
122
- hasMetrics,
132
+ hasMetrics: hasMetrics && (visibleMetrics?.length ?? 0) > 0,
123
133
  hasHeaderCard,
124
134
  hasTabs,
125
135
  tabCounts,
@@ -129,9 +139,18 @@ export function ProjectionDetailBody({ schema, screen, translate, entityId, }) {
129
139
  };
130
140
  const regionPieces = deriveDetailRegionPieces(regionModel);
131
141
  const renderHeaderContent = (headerSlot) => renderDetailHeaderContent(regionModel, regionPieces, headerSlot);
132
- return (_jsxs(_Fragment, { children: [refetchErrorBanner, _jsx(RenderEdit, { refreshToken: reloadNonce, screen: renderedDetailScreen, entity: entity, featureName: schema.featureName, initial: record, entityId: effectiveEntityId, customSubmit: async () => ({ isSuccess: true, validationBlocked: false, data: undefined }), onReload: reloadDetail, onRelatedListDrawerAction: openDrawer, ...(translate !== undefined && { translate }), ...(hasTabs && activeSection !== undefined && { activeTabId: activeSection.id }), ...(screen.footerHint !== undefined && {
142
+ return (_jsxs(WriteFormRegistryProvider, { value: writeForms, children: [refetchErrorBanner, _jsx(RenderEdit, { refreshToken: reloadNonce, screen: renderedDetailScreen, entity: entity, featureName: schema.featureName, initial: record, entityId: effectiveEntityId, customSubmit: async () => ({ isSuccess: true, validationBlocked: false, data: undefined }), onReload: reloadDetail, onRelatedListDrawerAction: openDrawer, ...(translate !== undefined && { translate }), ...(hasTabs && activeSection !== undefined && { activeTabId: activeSection.id }), ...(screen.footerHint !== undefined && {
133
143
  footerHint: effectiveTranslate(screen.footerHint),
134
- }), ...(hasTabs && activeSections.length === 1 && { hideSectionTitles: true }), ...(screenFillsHeight(screen) && { fillScreenHeight: true }), ...((hasHeaderCard ||
144
+ }), ...(hasTabs &&
145
+ activeSections.length === 1 &&
146
+ screen.layout.narrowTabs !== false && { hideSectionTitles: true }), recordSections: {
147
+ labelTitles: true,
148
+ ...(hasTabs &&
149
+ activeSections.length > 1 &&
150
+ activeSections[0]?.tabLabel === undefined && { omitFirstTitle: true }),
151
+ ...(screen.pageNavigation === false && { pageNavigation: false }),
152
+ ...(screen.photosBeside === true && { photosBeside: true }),
153
+ }, ...(screenFillsHeight(screen) && { fillScreenHeight: true }), ...((hasHeaderCard ||
135
154
  hasTabs ||
136
155
  hasRecordGuidance(screen) ||
137
156
  screen.slots?.header !== undefined ||
@@ -9,5 +9,6 @@ export type DetailGuidanceModel = DetailHeaderModel & {
9
9
  };
10
10
  export declare function wrapLayout(primitives: DetailGuidanceModel["primitives"], className: string, node: ReactNode): ReactNode;
11
11
  export declare function renderDetailBreadcrumb(model: DetailGuidanceModel): ReactNode;
12
+ export declare function renderDetailSummary(model: DetailGuidanceModel): ReactNode;
12
13
  /** Summary, banner, progress and steps in reading order; blocks whose record field holds nothing drop out. */
13
14
  export declare function renderDetailGuidance(model: DetailGuidanceModel): ReactNode;
@@ -77,7 +77,7 @@ export function renderDetailBreadcrumb(model) {
77
77
  }
78
78
  return (_jsx(Text, { testId: testId, children: items.map((item, index) => (_jsxs(Fragment, { children: [index > 0 && (_jsx(Text, { variant: "muted", decorative: true, children: " / " })), item.link !== undefined ? (_jsx(Link, { href: item.link.href, ...(item.link.onPress !== undefined && { onPress: item.link.onPress }), children: item.label })) : (_jsx(Text, { children: item.label }))] }, keys[index]))) }));
79
79
  }
80
- function renderSummary(model) {
80
+ export function renderDetailSummary(model) {
81
81
  const spec = model.screen.summary;
82
82
  if (spec === undefined)
83
83
  return undefined;
@@ -104,7 +104,7 @@ function renderBanner(model) {
104
104
  return undefined;
105
105
  const { Banner } = model.primitives;
106
106
  const actions = renderItemActions(model, spec.actions, notice);
107
- return wrapLayout(model.primitives, GUIDANCE_INSET, _jsx(Banner, { variant: BANNER_VARIANT[notice.tone ?? "neutral"], icon: BANNER_ICON[notice.tone ?? "neutral"], title: notice.title, ...(notice.narrowTitle !== undefined && { narrowTitle: notice.narrowTitle }), ...(notice.narrowText !== undefined && { narrowText: notice.narrowText }), inline: true, ...(actions !== undefined && { actions }), testId: "kumiko-screen-projection-detail-banner", children: notice.text }));
107
+ return wrapLayout(model.primitives, GUIDANCE_INSET, _jsx(Banner, { variant: BANNER_VARIANT[notice.tone ?? "neutral"], ...(spec.iconless !== true && { icon: BANNER_ICON[notice.tone ?? "neutral"] }), title: notice.title, ...(notice.narrowTitle !== undefined && { narrowTitle: notice.narrowTitle }), ...(notice.narrowText !== undefined && { narrowText: notice.narrowText }), inline: true, ...(actions !== undefined && { actions }), testId: "kumiko-screen-projection-detail-banner", children: notice.text }));
108
108
  }
109
109
  function buildStepItem(model, spec, step) {
110
110
  const [mainAction, ...otherActions] = resolveItemActions(model, spec.actions, step);
@@ -204,6 +204,9 @@ export function renderDetailGuidance(model) {
204
204
  const beside = progress?.placement === "beside-steps" && steps !== undefined;
205
205
  const progressNode = renderProgress(model, beside);
206
206
  const progressInset = progress?.hideOnNarrow === true ? `${PROGRESS_INSET} max-sm:hidden` : PROGRESS_INSET;
207
- return (_jsxs(_Fragment, { children: [renderSummary(model), renderBanner(model), beside ? (wrapLayout(model.primitives, "grid grid-cols-1 items-stretch gap-4 lg:grid-cols-12", _jsxs(_Fragment, { children: [wrapLayout(model.primitives, progressNode !== undefined ? "min-w-0 lg:col-span-8" : "min-w-0 lg:col-span-12", renderSteps(model)), progressNode !== undefined &&
208
- wrapLayout(model.primitives, `${progressInset} lg:col-span-4 lg:flex lg:flex-col lg:pl-0 lg:[&>*]:flex-1`, progressNode)] }))) : (_jsxs(_Fragment, { children: [progressNode !== undefined && wrapLayout(model.primitives, progressInset, progressNode), renderSteps(model)] }))] }));
207
+ const lower = (_jsx(_Fragment, { children: beside ? (wrapLayout(model.primitives, "grid grid-cols-1 items-stretch gap-4 lg:grid-cols-12", _jsxs(_Fragment, { children: [wrapLayout(model.primitives, progressNode !== undefined ? "min-w-0 lg:col-span-8" : "min-w-0 lg:col-span-12", renderSteps(model)), progressNode !== undefined &&
208
+ wrapLayout(model.primitives, `${progressInset} lg:col-span-4 lg:flex lg:flex-col lg:pl-0 lg:[&>*]:flex-1`, progressNode)] }))) : (_jsxs(_Fragment, { children: [progressNode !== undefined && wrapLayout(model.primitives, progressInset, progressNode), renderSteps(model)] })) }));
209
+ return (_jsxs(_Fragment, { children: [renderBanner(model), model.screen.metricsPlacement?.narrow === "before-steps"
210
+ ? wrapLayout(model.primitives, "max-md:order-2", lower)
211
+ : lower] }));
209
212
  }
@@ -65,7 +65,10 @@ export function buildDetailTabItems(sections, record, translate, queryCounts = {
65
65
  const count = typeof countValue === "number" && Number.isFinite(countValue) ? countValue : undefined;
66
66
  return {
67
67
  id: section.id ?? "",
68
- label: translate(section.title ?? section.id ?? ""),
68
+ label: translate(sections.find((s) => s.id === section.id && s.tabLabel !== undefined)?.tabLabel ??
69
+ section.title ??
70
+ section.id ??
71
+ ""),
69
72
  ...(count !== undefined && { count }),
70
73
  };
71
74
  });
@@ -1,8 +1,8 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { resolveRecordTitle } from "../components/render-edit-helpers.js";
3
3
  import { requestLeave } from "../leave-guard.js";
4
- import { renderDetailBreadcrumb, renderDetailGuidance, wrapLayout, } from "./projection-detail-guidance.js";
5
- import { buildMetricItems, renderActionErrorBanner, renderBandSubtitle, renderHeaderActionsContent, renderHeaderSubtitleSlot, renderHeaderTitleSlot, renderMetricsBlock, renderRecordTitleBlock, renderStatusBadge, } from "./projection-detail-header.js";
4
+ import { renderDetailBreadcrumb, renderDetailGuidance, renderDetailSummary, wrapLayout, } from "./projection-detail-guidance.js";
5
+ import { buildMetricItems, renderActionErrorBanner, renderBandSubtitle, renderHeaderActionsContent, renderHeaderSubtitleSlot, renderHeaderTitleSlot, renderMetricsBlock, renderMobileSummary, renderRecordTitleBlock, renderStatusBadge, } from "./projection-detail-header.js";
6
6
  import { buildDetailTabItems } from "./projection-detail-header-model.js";
7
7
  export function deriveDetailRegionPieces(model) {
8
8
  const { screen, record, primitives, actionError, hasHeaderActions } = model;
@@ -46,12 +46,26 @@ const NARROW_METRICS_ORDER = "max-md:order-1";
46
46
  const LEAD_BAND_SHARED_PADDING = "[&>*]:pb-0";
47
47
  const TILES_BAND_SHARED_PADDING = "[&>*]:pt-3";
48
48
  const NARROW_TABS_ORDER = "max-md:order-2";
49
+ const NARROW_TABS_ORDER_AFTER_STEPS = "max-md:order-3";
49
50
  function usesNarrowMetricsOrder(model) {
50
- return model.screen.metricsPlacement?.narrow === "after-guidance";
51
+ return model.screen.metricsPlacement?.narrow !== undefined;
52
+ }
53
+ function narrowTabsOrder(model) {
54
+ return model.screen.metricsPlacement?.narrow === "before-steps"
55
+ ? NARROW_TABS_ORDER_AFTER_STEPS
56
+ : NARROW_TABS_ORDER;
51
57
  }
52
58
  function wrapNarrowOrder(model, orderClass, node) {
53
59
  return usesNarrowMetricsOrder(model) ? wrapLayout(model.primitives, orderClass, node) : node;
54
60
  }
61
+ // `narrowTabs: false` drops the strip on the phone; the sections then stand one under the other.
62
+ function wrapTabStrip(model, strip) {
63
+ const classes = [
64
+ usesNarrowMetricsOrder(model) ? narrowTabsOrder(model) : undefined,
65
+ model.screen.layout.narrowTabs === false ? "max-sm:hidden" : undefined,
66
+ ].filter((c) => c !== undefined);
67
+ return classes.length === 0 ? strip : wrapLayout(model.primitives, classes.join(" "), strip);
68
+ }
55
69
  // Only the metric tiles move below the guidance on narrow screens; the lead and the
56
70
  // subtitle/status line stay under the title, so they get their own tile-less band.
57
71
  function renderBandWithNarrowMetrics(model, metricItems, subtitle, lead) {
@@ -79,16 +93,18 @@ function renderPageHeaderBranch(model, pieces, headerSlot, PageHeader) {
79
93
  // The title block owns chip and subtitle, so neither the shell header nor the band repeats them.
80
94
  const hasTitleBlock = titleText !== undefined;
81
95
  const bandSubtitle = hasTitleBlock ? undefined : pieces.bandSubtitle;
82
- return (_jsxs(_Fragment, { children: [_jsx(PageHeader, { ...(hasTitleBlock && { bodyTitle: true }), ...(hasTitleBlock &&
83
- !pageHeaderCompact && { recordTitle: shortTitleOf(header, record) ?? titleText }), ...(header === undefined && recordTitle !== undefined && { title: recordTitle }), ...(!pageHeaderCompact &&
96
+ return (_jsxs(_Fragment, { children: [_jsx(PageHeader, { ...(hasTitleBlock && { bodyTitle: true }), ...(hasTitleBlock && { recordTitle: shortTitleOf(header, record) ?? titleText }), ...(header?.narrowTitle !== undefined && {
97
+ narrowRecordTitle: model.effectiveTranslate(header.narrowTitle),
98
+ }), ...(header === undefined && recordTitle !== undefined && { title: recordTitle }), ...(!hasTitleBlock &&
99
+ !pageHeaderCompact &&
84
100
  statusBadge !== undefined && {
85
101
  status: statusBadge,
86
102
  }), ...(hasHeaderActions && {
87
103
  actions: renderHeaderActionsContent(model, { compact: pageHeaderCompact, PageHeader }),
88
104
  }) }), titleText !== undefined &&
89
- renderRecordTitleBlock(model, titleText, statusBadge, pieces.headerSubtitleSlot, !pageHeaderCompact), MetricBand === undefined && bandSubtitle, MetricBand === undefined && headerSlot, (hasMetrics || bandSubtitle !== undefined || headerSlot !== undefined) &&
105
+ renderRecordTitleBlock(model, titleText, statusBadge, pieces.headerSubtitleSlot, false), hasTitleBlock && renderMobileSummary(model), hasTitleBlock && renderDetailSummary(model), MetricBand === undefined && bandSubtitle, MetricBand === undefined && headerSlot, (hasMetrics || bandSubtitle !== undefined || headerSlot !== undefined) &&
90
106
  (MetricBand !== undefined || hasMetrics) &&
91
- renderBandWithNarrowMetrics(model, metricItems, bandSubtitle, MetricBand !== undefined ? headerSlot : undefined), pieces.actionErrorBanner] }));
107
+ renderBandWithNarrowMetrics(model, metricItems, bandSubtitle, MetricBand !== undefined ? headerSlot : undefined), !hasTitleBlock && renderMobileSummary(model), !hasTitleBlock && renderDetailSummary(model), pieces.actionErrorBanner] }));
92
108
  }
93
109
  function renderHeaderCardBranch(model, pieces, headerSlot) {
94
110
  const { primitives, hasHeaderActions, hasMetrics, hasHeaderCard } = model;
@@ -103,7 +119,7 @@ function renderHeaderCardBranch(model, pieces, headerSlot) {
103
119
  ...(headerSubtitleSlot !== undefined && { subtitle: headerSubtitleSlot }),
104
120
  ...(headerSlot !== undefined && { headerContent: headerSlot }),
105
121
  ...(hasHeaderActions && { headerActions: headerActionsContent }),
106
- }, children: [hasMetrics && !metricsOutsideCard && renderMetricsBlock(model, pieces.metricItems), pieces.actionErrorBanner] })), metricsOutsideCard &&
122
+ }, children: [hasMetrics && !metricsOutsideCard && renderMetricsBlock(model, pieces.metricItems), pieces.actionErrorBanner] })), renderMobileSummary(model), renderDetailSummary(model), metricsOutsideCard &&
107
123
  wrapNarrowOrder(model, NARROW_METRICS_ORDER, renderMetricsBlock(model, pieces.metricItems))] }));
108
124
  }
109
125
  function renderDetailTabs(model, activeSection, Tabs) {
@@ -119,5 +135,5 @@ export function renderDetailHeaderContent(model, pieces, headerSlot) {
119
135
  : renderHeaderCardBranch(model, pieces, headerSlot), renderDetailGuidance(model), hasTabs &&
120
136
  activeSection !== undefined &&
121
137
  Tabs !== undefined &&
122
- wrapNarrowOrder(model, NARROW_TABS_ORDER, renderDetailTabs(model, activeSection, Tabs))] }));
138
+ wrapTabStrip(model, renderDetailTabs(model, activeSection, Tabs))] }));
123
139
  }
@@ -30,6 +30,8 @@ export declare function renderRecordTitleBlock(model: DetailHeaderModel, titleTe
30
30
  export declare function renderHeaderSubtitleSlot(model: DetailHeaderModel): ReactNode;
31
31
  export declare function buildMetricItems(model: DetailHeaderModel): ReactNode[] | undefined;
32
32
  export declare function renderMetricsBlock(model: DetailHeaderModel, metricItems: ReactNode[] | undefined, subtitle?: ReactNode, lead?: ReactNode): ReactNode;
33
+ /** The phone-only line right under the title; nothing when the screen has no `mobileSummary` or the field is empty. */
34
+ export declare function renderMobileSummary(model: DetailHeaderModel): ReactNode;
33
35
  export declare function renderStatusBadge(model: DetailHeaderModel): ReactNode;
34
36
  export declare function renderBandSubtitle(model: DetailHeaderModel, statusBadge: ReactNode, headerSubtitleSlot: ReactNode, pageHeaderCompact: boolean): ReactNode;
35
37
  export declare function renderActionErrorBanner(model: DetailHeaderModel, actionError: ErrorNotice): ReactNode;