@cosmicdrift/kumiko-renderer 0.416.0 → 0.418.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 (191) hide show
  1. package/dist/app/action-form-body.d.ts +1 -4
  2. package/dist/app/action-form-body.js +14 -9
  3. package/dist/app/action-form-preview.d.ts +13 -0
  4. package/dist/app/action-form-preview.js +66 -0
  5. package/dist/app/action-form-support.d.ts +6 -1
  6. package/dist/app/action-form-support.js +26 -9
  7. package/dist/app/config-edit-body.js +71 -79
  8. package/dist/app/entity-list-screen.js +1 -1
  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/list-bulk-actions.d.ts +8 -1
  12. package/dist/app/list-bulk-actions.js +28 -4
  13. package/dist/app/locked-screen-header.d.ts +2 -0
  14. package/dist/app/locked-screen-header.js +8 -1
  15. package/dist/app/projection-detail-body.js +24 -5
  16. package/dist/app/projection-detail-guidance.d.ts +1 -0
  17. package/dist/app/projection-detail-guidance.js +7 -4
  18. package/dist/app/projection-detail-header-model.js +4 -1
  19. package/dist/app/projection-detail-header-region.js +25 -9
  20. package/dist/app/projection-detail-header.d.ts +2 -0
  21. package/dist/app/projection-detail-header.js +30 -3
  22. package/dist/app/projection-list-shim.js +1 -0
  23. package/dist/app/row-actions.d.ts +4 -0
  24. package/dist/app/row-actions.js +19 -3
  25. package/dist/app/use-projection-detail-actions.d.ts +3 -1
  26. package/dist/app/use-projection-detail-actions.js +9 -1
  27. package/dist/app/use-projection-detail-data.js +17 -1
  28. package/dist/app/use-projection-list-data.js +1 -1
  29. package/dist/card-options.d.ts +2 -0
  30. package/dist/components/choice-chip-class.d.ts +1 -0
  31. package/dist/components/choice-chip-class.js +9 -0
  32. package/dist/components/edit-mounts.d.ts +1 -1
  33. package/dist/components/embedded-list-paste.js +2 -2
  34. package/dist/components/grid-cell-for-field.js +1 -1
  35. package/dist/components/multi-select-chips.js +7 -2
  36. package/dist/components/multi-select-count.d.ts +5 -0
  37. package/dist/components/multi-select-count.js +10 -0
  38. package/dist/components/narrow-description.d.ts +3 -0
  39. package/dist/components/narrow-description.js +12 -0
  40. package/dist/components/related-list-section.d.ts +5 -3
  41. package/dist/components/related-list-section.js +9 -4
  42. package/dist/components/related-photo-grid.js +17 -3
  43. package/dist/components/render-edit-field-grid.d.ts +12 -3
  44. package/dist/components/render-edit-field-grid.js +60 -18
  45. package/dist/components/render-edit-fields-section.js +45 -11
  46. package/dist/components/render-edit-header-actions.js +1 -1
  47. package/dist/components/render-edit-layout.js +5 -3
  48. package/dist/components/render-edit-section-kinds.js +50 -12
  49. package/dist/components/render-edit-titles.js +1 -1
  50. package/dist/components/render-edit-types.d.ts +13 -0
  51. package/dist/components/render-field-ai-assist.js +26 -7
  52. package/dist/components/render-field-choice-inputs.js +3 -0
  53. package/dist/components/render-field-control.js +1 -1
  54. package/dist/components/render-field-value-chips.js +6 -4
  55. package/dist/components/render-field-values.js +3 -3
  56. package/dist/components/render-list-hint-columns.d.ts +1 -0
  57. package/dist/components/render-list-hint-columns.js +30 -5
  58. package/dist/components/render-list-reference-columns.js +2 -4
  59. package/dist/components/render-list-row-tone.d.ts +2 -0
  60. package/dist/components/render-list-row-tone.js +6 -0
  61. package/dist/components/render-list-table-props.d.ts +13 -2
  62. package/dist/components/render-list-table-props.js +9 -3
  63. package/dist/components/render-list-types.d.ts +4 -0
  64. package/dist/components/render-list.js +12 -4
  65. package/dist/components/use-render-list-columns.js +3 -3
  66. package/dist/components/write-form-registry.d.ts +13 -0
  67. package/dist/components/write-form-registry.js +6 -0
  68. package/dist/components/write-form-section.d.ts +5 -1
  69. package/dist/components/write-form-section.js +55 -16
  70. package/dist/data-table-bulk-types.d.ts +11 -2
  71. package/dist/data-table-bulk-types.js +3 -1
  72. package/dist/headless/form/form-controller.d.ts +2 -0
  73. package/dist/headless/form/form-controller.js +2 -2
  74. package/dist/headless/format/index.d.ts +1 -1
  75. package/dist/headless/format/index.js +6 -5
  76. package/dist/headless/format/money.d.ts +5 -0
  77. package/dist/headless/format/money.js +10 -0
  78. package/dist/headless/format/relative-time.d.ts +2 -0
  79. package/dist/headless/format/relative-time.js +4 -1
  80. package/dist/headless/index.d.ts +1 -1
  81. package/dist/headless/index.js +1 -1
  82. package/dist/headless/view-model/edit.js +87 -37
  83. package/dist/headless/view-model/list.js +6 -0
  84. package/dist/headless/view-model/types.d.ts +50 -5
  85. package/dist/hooks/use-bulk-run.d.ts +2 -2
  86. package/dist/hooks/use-list-table.js +11 -6
  87. package/dist/i18n-defaults.js +8 -2
  88. package/dist/primitives-record-guidance.d.ts +4 -0
  89. package/dist/primitives-share-types.d.ts +82 -0
  90. package/dist/primitives-share-types.js +1 -0
  91. package/dist/primitives.d.ts +34 -83
  92. package/dist/web/app/bold-markup.d.ts +3 -0
  93. package/dist/web/app/bold-markup.js +14 -0
  94. package/dist/web/app/dashboard-body.js +5 -1
  95. package/dist/web/app/dashboard-list-panel.js +7 -4
  96. package/dist/web/app/dashboard-panels.js +31 -3
  97. package/dist/web/app/dashboard-shared.d.ts +3 -1
  98. package/dist/web/app/dashboard-shared.js +3 -3
  99. package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -1
  100. package/dist/web/app/dashboard-stat-group-panel.js +16 -2
  101. package/dist/web/app/dashboard-text-panel.js +11 -6
  102. package/dist/web/app/relative-time.js +10 -1
  103. package/dist/web/components/config-cascade.d.ts +2 -1
  104. package/dist/web/components/config-cascade.js +16 -4
  105. package/dist/web/drawn-icons.js +2 -1
  106. package/dist/web/layout/header-action-pinned.d.ts +4 -2
  107. package/dist/web/layout/header-action-pinned.js +13 -4
  108. package/dist/web/layout/header-overflow-menu.d.ts +2 -0
  109. package/dist/web/layout/header-overflow-menu.js +2 -0
  110. package/dist/web/layout/nav-tree.js +1 -1
  111. package/dist/web/layout/notification-bell.js +13 -4
  112. package/dist/web/layout/page-header-slot.d.ts +2 -0
  113. package/dist/web/layout/page-header-slot.js +4 -0
  114. package/dist/web/layout/screen-focus.js +4 -1
  115. package/dist/web/layout/shell-header.js +15 -7
  116. package/dist/web/primitives/banner.js +14 -3
  117. package/dist/web/primitives/card.js +5 -3
  118. package/dist/web/primitives/combobox.js +2 -2
  119. package/dist/web/primitives/data-table/actions-column.js +1 -1
  120. package/dist/web/primitives/data-table/card-body.d.ts +1 -1
  121. package/dist/web/primitives/data-table/card-body.js +37 -14
  122. package/dist/web/primitives/data-table/card-frame.d.ts +2 -0
  123. package/dist/web/primitives/data-table/card-frame.js +3 -0
  124. package/dist/web/primitives/data-table/card-row.js +28 -9
  125. package/dist/web/primitives/data-table/card-sort-select.js +1 -1
  126. package/dist/web/primitives/data-table/card-view.js +1 -1
  127. package/dist/web/primitives/data-table/data-cell-props.d.ts +2 -1
  128. package/dist/web/primitives/data-table/data-cell-props.js +1 -0
  129. package/dist/web/primitives/data-table/density.d.ts +3 -1
  130. package/dist/web/primitives/data-table/density.js +11 -4
  131. package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
  132. package/dist/web/primitives/data-table/row-render-parts.js +3 -5
  133. package/dist/web/primitives/data-table/sort-options-select.js +2 -2
  134. package/dist/web/primitives/data-table/sortable-header.js +4 -4
  135. package/dist/web/primitives/data-table/table-body.js +2 -1
  136. package/dist/web/primitives/data-table/table-chrome.js +1 -3
  137. package/dist/web/primitives/data-table/table-content.js +7 -11
  138. package/dist/web/primitives/data-table/table-data-cell.js +31 -17
  139. package/dist/web/primitives/data-table/table-header-row.js +1 -1
  140. package/dist/web/primitives/data-table/table-view.js +1 -1
  141. package/dist/web/primitives/data-table/toolbar.js +6 -7
  142. package/dist/web/primitives/data-table/use-bulk-selection.d.ts +1 -1
  143. package/dist/web/primitives/data-table/use-bulk-selection.js +5 -0
  144. package/dist/web/primitives/data-table/use-data-table-state.d.ts +6 -1
  145. package/dist/web/primitives/data-table/use-data-table-state.js +12 -2
  146. package/dist/web/primitives/data-table-cell.d.ts +13 -2
  147. package/dist/web/primitives/data-table-cell.js +125 -53
  148. package/dist/web/primitives/data-table.js +1 -1
  149. package/dist/web/primitives/default-form.d.ts +1 -1
  150. package/dist/web/primitives/default-form.js +11 -10
  151. package/dist/web/primitives/drawer.js +2 -7
  152. package/dist/web/primitives/facet-filter.d.ts +1 -1
  153. package/dist/web/primitives/facet-filter.js +2 -5
  154. package/dist/web/primitives/facet-search-filter.js +1 -1
  155. package/dist/web/primitives/facet-trigger-label.d.ts +1 -4
  156. package/dist/web/primitives/facet-trigger-label.js +4 -7
  157. package/dist/web/primitives/field.js +15 -8
  158. package/dist/web/primitives/form-footer-parts.js +2 -2
  159. package/dist/web/primitives/inline-suffix.d.ts +2 -0
  160. package/dist/web/primitives/inline-suffix.js +5 -0
  161. package/dist/web/primitives/input-choice-kinds.js +12 -2
  162. package/dist/web/primitives/input-number-kinds.js +2 -2
  163. package/dist/web/primitives/input-text-kinds.js +1 -1
  164. package/dist/web/primitives/layout-elements.d.ts +4 -4
  165. package/dist/web/primitives/layout-elements.js +49 -12
  166. package/dist/web/primitives/layout.d.ts +1 -1
  167. package/dist/web/primitives/layout.js +1 -1
  168. package/dist/web/primitives/metric.js +4 -5
  169. package/dist/web/primitives/money-input.js +8 -7
  170. package/dist/web/primitives/number-input.d.ts +2 -1
  171. package/dist/web/primitives/number-input.js +9 -4
  172. package/dist/web/primitives/page-header.d.ts +1 -1
  173. package/dist/web/primitives/page-header.js +8 -1
  174. package/dist/web/primitives/pager.js +12 -21
  175. package/dist/web/primitives/photo-grid.js +2 -1
  176. package/dist/web/primitives/record-steps.d.ts +1 -1
  177. package/dist/web/primitives/record-steps.js +6 -15
  178. package/dist/web/primitives/row-actions.js +38 -24
  179. package/dist/web/primitives/use-container-narrow.d.ts +12 -0
  180. package/dist/web/primitives/use-container-narrow.js +42 -0
  181. package/dist/web/pwa/pwa-support.js +13 -7
  182. package/dist/web/ui/input.js +1 -1
  183. package/dist/web/ui/textarea.js +1 -1
  184. package/dist/web/widgets/dashboard-list-cards.js +6 -3
  185. package/dist/web/widgets/dashboard-list.d.ts +4 -1
  186. package/dist/web/widgets/dashboard-list.js +10 -5
  187. package/dist/web/widgets/progress-list.js +1 -1
  188. package/dist/web/widgets/stat-box-cell.js +1 -1
  189. package/package.json +5 -5
  190. package/src/changes.json +51 -0
  191. package/src/web/styles.css +3 -2
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { usePrimitives } from "../primitives.js";
3
+ import { choiceChipClass } from "./choice-chip-class.js";
3
4
  // MultiSelectFieldDef's `display: "chips"`: every option is a toggle chip, ticked once chosen.
4
5
  export function MultiSelectChips({ field, id, options, value, onChange, }) {
5
6
  const { Button, Grid } = usePrimitives();
@@ -9,10 +10,14 @@ export function MultiSelectChips({ field, id, options, value, onChange, }) {
9
10
  const next = new Set(selected);
10
11
  if (!next.delete(optionValue))
11
12
  next.add(optionValue);
12
- onChange(options.filter((opt) => next.has(opt.value)).map((opt) => opt.value));
13
+ const optionValues = new Set(options.map((opt) => opt.value));
14
+ onChange([
15
+ ...options.filter((opt) => next.has(opt.value)).map((opt) => opt.value),
16
+ ...value.filter((stored) => !optionValues.has(stored) && next.has(stored)),
17
+ ]);
13
18
  };
14
19
  return (_jsx(Grid, { columns: "auto", tight: true, ariaLabelledBy: `${id}-label`, children: options.map((opt) => {
15
20
  const isSelected = selected.has(opt.value);
16
- return (_jsx(Button, { variant: isSelected ? "primary" : "secondary", size: "sm", pressed: isSelected, disabled: field.readOnly === true || opt.disabled === true, testId: `${id}-chip-${opt.value}`, onClick: () => toggle(opt.value), children: isSelected ? `✓ ${opt.label}` : opt.label }, opt.value));
21
+ return (_jsx(Button, { variant: "secondary", size: "sm", className: choiceChipClass(isSelected), pressed: isSelected, disabled: field.readOnly === true || opt.disabled === true, testId: `${id}-chip-${opt.value}`, onClick: () => toggle(opt.value), children: isSelected ? `✓ ${opt.label}` : opt.label }, opt.value));
17
22
  }) }));
18
23
  }
@@ -0,0 +1,5 @@
1
+ import type { ReactNode } from "react";
2
+ export declare function MultiSelectCount({ id, value, }: {
3
+ readonly id: string;
4
+ readonly value: readonly string[];
5
+ }): ReactNode;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useOptionalTranslation } from "../i18n.js";
3
+ import { usePrimitives } from "../primitives.js";
4
+ const keyAsText = (key) => key;
5
+ // MultiSelectFieldDef's `display: "count"`: the held values are not listed, only how many there are.
6
+ export function MultiSelectCount({ id, value, }) {
7
+ const t = useOptionalTranslation() ?? keyAsText;
8
+ const { Text } = usePrimitives();
9
+ return (_jsx(Text, { variant: "small", testId: `${id}-count`, children: t("kumiko.form.selection-count", { count: value.length }) }));
10
+ }
@@ -0,0 +1,3 @@
1
+ import type { ReactNode } from "react";
2
+ /** The full description from `sm` up, the short one on the phone. */
3
+ export declare function narrowAwareDescription(description: string | undefined, descriptionNarrow: string | undefined): ReactNode;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { usePrimitives } from "../primitives.js";
3
+ function NarrowDescription({ description, descriptionNarrow, }) {
4
+ const { Text } = usePrimitives();
5
+ return _jsx(Text, { narrow: descriptionNarrow, children: description });
6
+ }
7
+ /** The full description from `sm` up, the short one on the phone. */
8
+ export function narrowAwareDescription(description, descriptionNarrow) {
9
+ if (description === undefined || descriptionNarrow === undefined)
10
+ return description;
11
+ return _jsx(NarrowDescription, { description: description, descriptionNarrow: descriptionNarrow });
12
+ }
@@ -1,7 +1,7 @@
1
1
  import type { RowActionDrawer } from "@cosmicdrift/kumiko-framework/ui-types";
2
2
  import { type ReactNode } from "react";
3
3
  import type { EditRelatedListSectionViewModel, Translate } from "../headless/index.ts";
4
- export declare function RelatedListSection({ section, parentId, record, featureName, translate, hideTitle, grow, onOpenDrawer, actions, anchorId, embedded, onAfterWrite, refreshToken, }: {
4
+ export declare function RelatedListSection({ section, parentId, record, featureName, translate, hideTitle, labelTitle, omitTitle, onOpenDrawer, actions, anchorId, embedded, onAfterWrite, refreshToken, }: {
5
5
  readonly section: EditRelatedListSectionViewModel;
6
6
  readonly parentId: string;
7
7
  /** The enclosing projectionDetail's own record (the "Akte") — evaluates
@@ -11,8 +11,10 @@ export declare function RelatedListSection({ section, parentId, record, featureN
11
11
  readonly featureName: string;
12
12
  readonly translate?: Translate;
13
13
  readonly hideTitle?: boolean;
14
- /** Under a fixed-height screen the tab panel chain stretches so the count footer sits at the bottom. */
15
- readonly grow?: boolean;
14
+ /** The stacked section title is a small uppercase label. */
15
+ readonly labelTitle?: boolean;
16
+ /** The stacked section has no title (the tab label above it says the same). */
17
+ readonly omitTitle?: boolean;
16
18
  /** Opens a drawer-kind rowAction. Supplied by the parent
17
19
  * (ProjectionDetailBody), which owns schema + the actual Drawer render —
18
20
  * this component only ever invokes the callback. */
@@ -115,7 +115,7 @@ function buildRelatedListRowClick(section, nav, host, onOpenDrawer) {
115
115
  }
116
116
  };
117
117
  }
118
- export function RelatedListSection({ section, parentId, record, featureName, translate, hideTitle, grow, onOpenDrawer, actions, anchorId, embedded, onAfterWrite, refreshToken, }) {
118
+ export function RelatedListSection({ section, parentId, record, featureName, translate, hideTitle, labelTitle, omitTitle, onOpenDrawer, actions, anchorId, embedded, onAfterWrite, refreshToken, }) {
119
119
  const { Banner, Section, FillContainer, PhotoGrid } = usePrimitives();
120
120
  const [emptyStateActionError, setEmptyStateActionError] = useState(null);
121
121
  const t = useTranslation();
@@ -317,7 +317,12 @@ export function RelatedListSection({ section, parentId, record, featureName, tra
317
317
  onFilterReset,
318
318
  }), ...(onRowClick !== undefined && { onRowClick }), ...(rowActions !== undefined && { rowActions }), ...(section.rowActionMode !== undefined && { rowActionMode: section.rowActionMode }), ...(bulk !== undefined && { bulk }), ...(rowTone !== undefined && { rowTone }), ...(toolbarActionButtons !== undefined && { toolbarActions: toolbarActionButtons }), ...(emptyStateContent !== undefined && { emptyState: emptyStateContent }), ...listTable, ...(aggregates.serverGroups !== undefined && {
319
319
  serverGroups: aggregates.serverGroups,
320
- }), ...(aggregates.totals !== undefined && { totals: aggregates.totals }), ...(aggregates.notice !== undefined && { notice: aggregates.notice }), screenPadding: false, ...(hideTitle === true && { scrollBody: true, chromeless: true }), ...(embedded === true && { chromeless: true }) }) }))] }));
320
+ }), ...(aggregates.totals !== undefined && { totals: aggregates.totals }), ...(aggregates.notice !== undefined && { notice: aggregates.notice }), screenPadding: false, ...(hideTitle === true && {
321
+ scrollBody: true,
322
+ chromeless: true,
323
+ hideCountFooter: true,
324
+ plainPhoneCards: true,
325
+ }), ...(embedded === true && { chromeless: true }) }) }))] }));
321
326
  // hideTitle (tabs mode) → the caller (render-edit.tsx) already wraps this
322
327
  // component's own return value in the same Card frame every other tab
323
328
  // kind gets — no card here, or the two would nest. `scrollBody` caps the
@@ -335,7 +340,7 @@ export function RelatedListSection({ section, parentId, record, featureName, tra
335
340
  return (_jsxs(_Fragment, { children: [bridges, _jsx(EmbeddedRelatedListCard, { title: `${section.title}${countSuffix}`, actions: actions, testId: `related-list-${section.title}-${parentId}`, children: content })] }));
336
341
  }
337
342
  if (hideTitle) {
338
- return (_jsxs(_Fragment, { children: [bridges, FillContainer !== undefined ? (_jsx(FillContainer, { ...(grow === true && { grow: true }), children: content })) : (content)] }));
343
+ return (_jsxs(_Fragment, { children: [bridges, FillContainer !== undefined ? (_jsx(FillContainer, { testId: "related-list-card", className: "mx-6 my-3 overflow-hidden rounded-[9px] border border-border bg-card max-sm:mx-4 max-sm:rounded-none max-sm:border-0 max-sm:bg-transparent [&_thead_th]:bg-muted", children: content })) : (content)] }));
339
344
  }
340
- return (_jsxs(_Fragment, { children: [bridges, _jsx(Section, { title: section.title, ...(anchorId !== undefined && { id: anchorId }), ...(actions !== undefined && { actions }), testId: `related-list-${section.title}`, children: content })] }));
345
+ return (_jsxs(_Fragment, { children: [bridges, _jsx(Section, { ...(omitTitle !== true && { title: section.title }), ...(labelTitle === true && { titleStyle: "label" }), ...(anchorId !== undefined && { id: anchorId }), ...(actions !== undefined && { actions }), testId: `related-list-${section.title}`, children: content })] }));
341
346
  }
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { fileIdsOf } from "../file-ids-of.js";
3
+ import { useTranslation } from "../i18n.js";
3
4
  import { usePrimitives } from "../primitives.js";
4
5
  import { RenderEditActionButton } from "./render-edit-action-button.js";
5
6
  function viewModelOf(row) {
@@ -8,18 +9,31 @@ function viewModelOf(row) {
8
9
  // One tile per row: the row's image and its row actions as buttons. The same
9
10
  // DataTableRowAction list the table would get, so confirm and visibility behave alike.
10
11
  export function RelatedPhotoGrid({ rows, photoGrid, rowActions, onActionError, testId, }) {
12
+ const t = useTranslation();
11
13
  const { PhotoGrid, Button, Dialog } = usePrimitives();
12
14
  if (PhotoGrid === undefined)
13
15
  return null;
14
- const { imageField, captionField } = photoGrid;
16
+ const { imageField, captionField, badgeField } = photoGrid;
17
+ const leadsOnNarrow = (row) => {
18
+ if (photoGrid.badgeFirst !== true || badgeField === undefined)
19
+ return false;
20
+ const value = row[badgeField];
21
+ return typeof value === "string" && value !== "";
22
+ };
15
23
  return (_jsx(PhotoGrid, { ...(testId !== undefined && { testId }), tiles: rows.map((row, index) => {
16
24
  const vm = viewModelOf(row);
17
- const caption = captionField === undefined ? undefined : row[captionField];
25
+ const captionValue = captionField === undefined ? undefined : row[captionField];
26
+ const caption = typeof captionValue === "string" && captionValue !== ""
27
+ ? captionValue
28
+ : t("kumiko.photo-grid.fallback-caption", { n: index + 1 });
29
+ const badge = badgeField === undefined ? undefined : row[badgeField];
18
30
  const imageId = fileIdsOf(row[imageField])[0];
19
31
  return {
20
32
  id: vm.id === "" ? String(index) : vm.id,
21
33
  ...(imageId !== undefined && { imageId }),
22
- ...(typeof caption === "string" && caption !== "" && { caption }),
34
+ caption,
35
+ ...(typeof badge === "string" && badge !== "" && { badge }),
36
+ ...(leadsOnNarrow(row) && { leadsOnNarrow: true }),
23
37
  actions: (rowActions ?? [])
24
38
  .filter((action) => action.isVisible?.(vm) !== false)
25
39
  .map((action) => (_jsx(RenderEditActionButton, { action: {
@@ -1,4 +1,13 @@
1
- import { type ReactNode } from "react";
1
+ import { type ComponentType, type ReactNode } from "react";
2
2
  import type { EditFieldViewModel, FormValues } from "../headless/index.ts";
3
- import type { FieldsSection, RenderEditModel } from "./render-edit-render-model.ts";
4
- export declare function renderFieldGrid<TValues extends FormValues, TCtx>(model: RenderEditModel<TValues, TCtx>, section: FieldsSection, fields: readonly EditFieldViewModel[], columns: number, gridKey: string): ReactNode;
3
+ import type { StatusBadgeProps } from "../primitives.tsx";
4
+ import type { FieldsSection, RenderEditModel, ResolvedRenderEditProps } from "./render-edit-render-model.ts";
5
+ type AppendixProps = Pick<ResolvedRenderEditProps<FormValues>, "labelAppendix" | "fieldAppendix" | "fieldAppendixPlacement" | "fieldDescription">;
6
+ export declare function appendixCellProps(props: AppendixProps, field: EditFieldViewModel, values: Readonly<Record<string, unknown>>, StatusBadge: ComponentType<StatusBadgeProps> | undefined): {
7
+ labelAppendix?: ReactNode;
8
+ fieldAppendix?: ReactNode;
9
+ appendixPlacement?: "above-control" | "below-control" | undefined;
10
+ description?: string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | undefined;
11
+ };
12
+ export declare function renderFieldGrid<TValues extends FormValues, TCtx>(model: RenderEditModel<TValues, TCtx>, section: FieldsSection, fields: readonly EditFieldViewModel[], columns: number, gridKey: string, columnsDeclared?: boolean): ReactNode;
13
+ export {};
@@ -1,21 +1,48 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Fragment } from "react";
3
- import { GridCellForField } from "./grid-cell-for-field.js";
4
- function appendixCellProps(props, fieldName, values) {
3
+ import { statusToneForOptionTone } from "../status-tone.js";
4
+ import { fieldCellWidth, GridCellForField } from "./grid-cell-for-field.js";
5
+ function nonEmptyText(value) {
6
+ return typeof value === "string" && value.trim() !== "" ? value : undefined;
7
+ }
8
+ function declaredBadge(field, values, StatusBadge) {
9
+ if (field.badge === undefined || StatusBadge === undefined)
10
+ return undefined;
11
+ const text = "label" in field.badge ? field.badge.label : nonEmptyText(values[field.badge.field]);
12
+ if (text === undefined)
13
+ return undefined;
14
+ return (_jsx(StatusBadge, { value: text, tone: statusToneForOptionTone(field.badge.tone) ?? "muted", testId: `field-badge-${field.field}` }));
15
+ }
16
+ export function appendixCellProps(props, field, values, StatusBadge) {
5
17
  const { labelAppendix, fieldAppendix, fieldAppendixPlacement, fieldDescription } = props;
18
+ const fieldName = field.field;
19
+ const badge = declaredBadge(field, values, StatusBadge);
20
+ const hint = field.hintField !== undefined ? nonEmptyText(values[field.hintField]) : undefined;
21
+ const declaredDescription = fieldDescription?.(fieldName, values);
6
22
  return {
7
23
  ...(labelAppendix !== undefined && { labelAppendix: labelAppendix(fieldName) }),
24
+ ...(labelAppendix === undefined && badge !== undefined && { labelAppendix: badge }),
8
25
  ...(fieldAppendix !== undefined && { fieldAppendix: fieldAppendix(fieldName) }),
9
26
  ...(fieldAppendixPlacement !== undefined && { appendixPlacement: fieldAppendixPlacement }),
10
- ...(fieldDescription !== undefined && { description: fieldDescription(fieldName, values) }),
27
+ ...((declaredDescription ?? hint) !== undefined && {
28
+ description: declaredDescription ?? hint,
29
+ }),
11
30
  };
12
31
  }
13
- function createFieldCellRenderer(model, section, columns) {
32
+ // Multi-line and wide kinds (textarea, lists, files) take the whole row of a facts grid; a plain
33
+ // read-only text would also count as full width, so the width is asked as if the field were editable.
34
+ function spanLongValue(field, columns) {
35
+ if (field.span !== undefined || fieldCellWidth({ ...field, readOnly: false }) !== "full") {
36
+ return field;
37
+ }
38
+ return { ...field, span: columns };
39
+ }
40
+ function createFieldCellRenderer(model, section, columns, facts) {
14
41
  const { props, state, form } = model.engine;
15
42
  const { snapshot } = form;
16
43
  const { GridCell } = state.primitives;
17
44
  const { isSettingsList, isCreate } = model.footer;
18
- const { usesFieldFlow } = model.titles;
45
+ const usesFieldFlow = model.titles.usesFieldFlow && !facts;
19
46
  const { disabled, fieldAccent } = props;
20
47
  const showsChangedMarker = !isCreate || props.markChangedFields;
21
48
  const clearErrorsAndValidate = (fieldName) => {
@@ -23,25 +50,40 @@ function createFieldCellRenderer(model, section, columns) {
23
50
  if (props.validateOnChange === true)
24
51
  form.controller.validate([fieldName]);
25
52
  };
26
- return (field) => (_jsx(GridCellForField, { field: disabled ? { ...field, readOnly: true } : field, columns: columns, ...(!isSettingsList && usesFieldFlow && { flow: true }), ...(isSettingsList && {
27
- layout: "row",
28
- accent: fieldAccent?.(field.field) === true,
29
- }), issues: snapshot.errors[field.field], onChange: (v) => {
30
- model.setFieldUntyped(field.field, v);
31
- clearErrorsAndValidate(field.field);
32
- }, ...(props.actionFormScreenQn !== undefined && {
33
- onSuggest: (value) => form.controller.seedField(field.field, value),
34
- }), GridCell: GridCell, featureName: props.featureName, ...appendixCellProps(props, field.field, snapshot.values), allIssues: snapshot.errors, valueDisplay: props.valueDisplay, row: snapshot.values, ...(disabled && { fillDisabled: true }), ...(props.hideSectionTitles !== true &&
35
- section.title !== undefined && { sectionTitle: section.title }), ...(showsChangedMarker && field.field in snapshot.changes && { changed: true }) }, field.field));
53
+ return (rawField) => {
54
+ const field = facts ? spanLongValue(rawField, columns) : rawField;
55
+ return (_jsx(GridCellForField, { field: disabled ? { ...field, readOnly: true } : field, columns: columns, ...(!isSettingsList && usesFieldFlow && { flow: true }), ...(isSettingsList && {
56
+ layout: "row",
57
+ accent: fieldAccent?.(field.field) === true,
58
+ }), issues: snapshot.errors[field.field], onChange: (v) => {
59
+ model.setFieldUntyped(field.field, v);
60
+ clearErrorsAndValidate(field.field);
61
+ }, ...(props.actionFormScreenQn !== undefined && {
62
+ onSuggest: (value) => form.controller.seedField(field.field, value),
63
+ }), GridCell: GridCell, featureName: props.featureName, ...appendixCellProps(props, field, snapshot.values, state.primitives.StatusBadge), allIssues: snapshot.errors, valueDisplay: props.valueDisplay, row: snapshot.values, ...(disabled && { fillDisabled: true }), ...(props.hideSectionTitles !== true &&
64
+ section.title !== undefined && { sectionTitle: section.title }), ...(showsChangedMarker && field.field in snapshot.changes && { changed: true }) }, field.field));
65
+ };
66
+ }
67
+ // Read-only text values with a declared column count form a label/value grid; the flow layout
68
+ // would ignore `columns` and give every value the full width. Without a declared count the
69
+ // stacked layout stays, so existing records do not reflow.
70
+ function isReadOnlyFactsGrid(model, fields, columns, columnsDeclared) {
71
+ return (columnsDeclared &&
72
+ columns > 1 &&
73
+ !model.footer.isSettingsList &&
74
+ model.engine.props.valueDisplay === "text" &&
75
+ fields.length > 0 &&
76
+ fields.every((field) => field.readOnly));
36
77
  }
37
- export function renderFieldGrid(model, section, fields, columns, gridKey) {
78
+ export function renderFieldGrid(model, section, fields, columns, gridKey, columnsDeclared = false) {
38
79
  const { Grid, GridCell } = model.engine.state.primitives;
39
80
  const { rowAfterField } = model.engine.props;
40
81
  const dirty = Object.keys(model.engine.form.snapshot.changes).length > 0;
41
82
  const { isSettingsList } = model.footer;
42
83
  const { usesFieldFlow } = model.titles;
43
- const renderCell = createFieldCellRenderer(model, section, columns);
44
- return (_jsx(Grid, { columns: columns, ...(isSettingsList ? { list: true } : usesFieldFlow && { flow: true }), children: fields.map((field) => {
84
+ const facts = isReadOnlyFactsGrid(model, fields, columns, columnsDeclared);
85
+ const renderCell = createFieldCellRenderer(model, section, columns, facts);
86
+ return (_jsx(Grid, { columns: columns, ...(facts && { facts: true }), ...(isSettingsList ? { list: true } : usesFieldFlow && !facts && { flow: true }), children: fields.map((field) => {
45
87
  const extraRow = rowAfterField?.(field.field, { dirty });
46
88
  if (extraRow === undefined)
47
89
  return renderCell(field);
@@ -1,16 +1,21 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { narrowAwareDescription } from "./narrow-description.js";
2
3
  import { renderAllRequiredHint } from "./render-edit-banners.js";
3
4
  import { renderFieldGrid } from "./render-edit-field-grid.js";
4
5
  import { sectionNavAnchorId } from "./render-edit-helpers.js";
5
6
  function renderTabbedGroupsSection(rc, section, sectionKey) {
6
7
  const { Grid, Card } = rc.model.engine.state.primitives;
7
- const groupsGrid = (_jsx(Grid, { columns: 1, children: section.groups?.map((group, groupIndex) => (_jsx(Card, { slots: { title: group.title }, testId: `section-${sectionKey}-group-${groupIndex}`, children: renderFieldGrid(rc.model, section, group.fields, group.columns, `${sectionKey}-group-${groupIndex}-grid`) }, group.title))) }, `${sectionKey}-groups`));
8
+ const groupsGrid = (_jsx(Grid, { columns: 1, children: section.groups?.map((group, groupIndex) => (_jsx(Card, { slots: { title: group.title }, ...(rc.model.engine.props.recordSections?.labelTitles === true && {
9
+ options: { titleStyle: "label" },
10
+ }), testId: `section-${sectionKey}-group-${groupIndex}`, children: renderFieldGrid(rc.model, section, group.fields, group.columns, `${sectionKey}-group-${groupIndex}-grid`, group.columnsDeclared === true) }, group.title))) }, `${sectionKey}-groups`));
8
11
  // `actions` on a `groups` section has no group of its own to
9
12
  // sit in and would need an extra title-less Card around the
10
13
  // group cards (Card-in-Card) — the boot-validator rejects that
11
14
  // combination in tabs mode, so `sectionActionsEl` is always
12
15
  // undefined here at runtime.
13
- return rc.wrapWizardStep(sectionKey, _jsx(Card, { options: { framed: false }, ...(section.description !== undefined && { slots: { subtitle: section.description } }), children: groupsGrid }, sectionKey));
16
+ return rc.wrapWizardStep(sectionKey, _jsx(Card, { options: { framed: false }, ...(section.description !== undefined && {
17
+ slots: { subtitle: narrowAwareDescription(section.description, section.descriptionNarrow) },
18
+ }), children: groupsGrid }, sectionKey));
14
19
  }
15
20
  function renderTabbedFieldsSection(rc, section, sectionKey) {
16
21
  if (section.groups !== undefined)
@@ -23,10 +28,12 @@ function renderTabbedFieldsSection(rc, section, sectionKey) {
23
28
  // description and actions, never the title text.
24
29
  const cardEl = (_jsx(Card, { options: { framed: false }, ...((sectionActionsEl !== undefined || section.description !== undefined) && {
25
30
  slots: {
26
- ...(section.description !== undefined && { subtitle: section.description }),
31
+ ...(section.description !== undefined && {
32
+ subtitle: narrowAwareDescription(section.description, section.descriptionNarrow),
33
+ }),
27
34
  ...(sectionActionsEl !== undefined && { headerActions: sectionActionsEl }),
28
35
  },
29
- }), testId: `section-${sectionKey}`, children: renderFieldGrid(rc.model, section, section.fields, section.columns, `${sectionKey}-grid`) }, sectionKey));
36
+ }), testId: `section-${sectionKey}`, children: renderFieldGrid(rc.model, section, section.fields, section.columns, `${sectionKey}-grid`, section.columnsDeclared === true) }, sectionKey));
30
37
  return rc.wrapWizardStep(sectionKey, cardEl);
31
38
  }
32
39
  // Suppress the section header when it would just repeat the form
@@ -36,26 +43,53 @@ function renderTabbedFieldsSection(rc, section, sectionKey) {
36
43
  function resolveSectionTitle({ model, sectionIndex }, section) {
37
44
  const { titles } = model;
38
45
  const { state } = model.engine;
39
- const repeatsTabLabel = state.isTabs && state.isStepped;
46
+ const repeatsTabLabel = (state.isTabs && state.isStepped) ||
47
+ (sectionIndex === 0 && model.engine.props.recordSections?.omitFirstTitle === true);
40
48
  if (titles.titleInSettingsHeader && sectionIndex === 0)
41
49
  return section.title ?? titles.formTitle;
42
50
  return section.title === titles.formTitle || repeatsTabLabel ? undefined : section.title;
43
51
  }
44
52
  function resolveSectionSubtitle({ model, sectionIndex }, section) {
45
53
  const headerFallback = model.titles.titleInSettingsHeader && sectionIndex === 0;
46
- return section.description ?? (headerFallback ? model.titles.formSubtitle : undefined);
54
+ return (narrowAwareDescription(section.description, section.descriptionNarrow) ??
55
+ (headerFallback ? model.titles.formSubtitle : undefined));
56
+ }
57
+ function renderSectionFieldBody(model, section, sectionKey) {
58
+ const { Section } = model.engine.state.primitives;
59
+ if (section.groups === undefined) {
60
+ return renderFieldGrid(model, section, section.fields, section.columns, `${sectionKey}-grid`, section.columnsDeclared === true);
61
+ }
62
+ return section.groups.map((group, groupIndex) => (_jsx(Section, { title: group.title, titleStyle: "label", testId: `section-${sectionKey}-group-${groupIndex}`, children: renderFieldGrid(model, section, group.fields, group.columns, `${sectionKey}-group-${groupIndex}-grid`, group.columnsDeclared === true) }, group.title)));
63
+ }
64
+ function firstSectionRequiredHint(model, sectionIndex) {
65
+ const showsHint = model.engine.sections.showsAllRequiredHint &&
66
+ model.engine.state.insideDrawer &&
67
+ sectionIndex === 0;
68
+ return showsHint ? renderAllRequiredHint(model) : null;
69
+ }
70
+ function sectionHintProp(section, sectionKey, hintBelow) {
71
+ if (!hintBelow || typeof section.description !== "string")
72
+ return {};
73
+ return {
74
+ hint: {
75
+ text: section.description,
76
+ ...(section.descriptionNarrow !== undefined && { textNarrow: section.descriptionNarrow }),
77
+ testId: `section-${sectionKey}-hint`,
78
+ },
79
+ };
47
80
  }
48
81
  function renderDefaultFieldsSection(rc, section, sectionKey) {
49
82
  const { model, sectionIndex, sectionActionsEl } = rc;
50
83
  const { Section } = model.engine.state.primitives;
51
84
  const anchorId = sectionNavAnchorId(model.titles.sectionNavItems, sectionIndex);
52
85
  const sectionTitle = resolveSectionTitle(rc, section);
53
- const sectionSubtitle = resolveSectionSubtitle(rc, section);
86
+ // Record pages print the hint under the data (muted, first sentence bold)
87
+ // instead of between the label and the fields.
88
+ const labelTitles = model.engine.props.recordSections?.labelTitles === true;
89
+ const hintBelow = labelTitles && typeof section.description === "string";
90
+ const sectionSubtitle = hintBelow ? undefined : resolveSectionSubtitle(rc, section);
54
91
  const sectionEl = (_jsxs(Section, { ...(anchorId !== undefined && { id: anchorId }), ...(sectionTitle !== undefined && { title: sectionTitle }), ...(sectionSubtitle !== undefined && { subtitle: sectionSubtitle }), ...(model.titles.stepRail &&
55
- section.description !== undefined && { subtitleBelowLgOnly: true }), ...(section.icon !== undefined && { icon: section.icon }), ...(sectionActionsEl !== undefined && { actions: sectionActionsEl }), ...(model.footer.isSettingsList && { layout: "settings-list" }), testId: `section-${sectionKey}`, children: [model.engine.sections.showsAllRequiredHint &&
56
- model.engine.state.insideDrawer &&
57
- sectionIndex === 0 &&
58
- renderAllRequiredHint(model), renderFieldGrid(model, section, section.fields, section.columns, `${sectionKey}-grid`)] }, sectionKey));
92
+ section.description !== undefined && { subtitleBelowLgOnly: true }), ...(section.icon !== undefined && { icon: section.icon }), ...(labelTitles && { titleStyle: "label" }), ...sectionHintProp(section, sectionKey, hintBelow), ...(sectionActionsEl !== undefined && { actions: sectionActionsEl }), ...(model.footer.isSettingsList && { layout: "settings-list" }), testId: `section-${sectionKey}`, children: [firstSectionRequiredHint(model, sectionIndex), renderSectionFieldBody(model, section, sectionKey)] }, sectionKey));
59
93
  return rc.wrapWizardStep(sectionKey, sectionEl);
60
94
  }
61
95
  export function renderFieldsSection(rc, section) {
@@ -82,7 +82,7 @@ function FooterStartGroup({ children, }) {
82
82
  }
83
83
  function renderCustomActions({ engine: { props, state }, layout, }) {
84
84
  const { Button, Dialog } = state.primitives;
85
- const button = (action) => (_jsx(RenderEditActionButton, { action: action, iconOnly: layout.iconOnlyMidActions, ...(action.pinnedOnPhone === true && { [FOOTER_ACTION_ROLE_PROP]: "inline" }), Button: Button, Dialog: Dialog, onError: state.setActionError }, action.id));
85
+ const button = (action) => (_jsx(RenderEditActionButton, { action: action, iconOnly: layout.iconOnlyMidActions, ...(action.pinnedOnPhone === true && { hideIcon: true }), ...(action.pinnedOnPhone === true && { [FOOTER_ACTION_ROLE_PROP]: "inline" }), Button: Button, Dialog: Dialog, onError: state.setActionError }, action.id));
86
86
  const startActions = props.actions?.filter((action) => action.align === "start") ?? [];
87
87
  const otherActions = props.actions?.filter((action) => action.align !== "start");
88
88
  return (_jsxs(_Fragment, { children: [props.footerHint !== undefined && (_jsx("span", { "data-testid": "render-edit-footer-hint", className: "mr-auto min-w-0 text-[13px] text-muted-foreground max-sm:hidden", children: props.footerHint })), startActions.length > 0 && (_jsx(FooterStartGroup, { ...(startActions.some((action) => action.pinnedOnPhone === true) && {
@@ -57,7 +57,8 @@ function buildFormActionProps(model, header) {
57
57
  layout.hasSecondaryFormActions && { secondaryActions: header.secondaryFormActions }),
58
58
  };
59
59
  }
60
- function buildFormChromeProps({ engine: { props, sections } }, { formHeaderRegion, titleActionMount }) {
60
+ function buildFormChromeProps(model, { formHeaderRegion, titleActionMount }) {
61
+ const { props, sections } = model.engine;
61
62
  const { summary } = props;
62
63
  return {
63
64
  ...(props.screen.layout.width !== undefined && { width: props.screen.layout.width }),
@@ -66,11 +67,12 @@ function buildFormChromeProps({ engine: { props, sections } }, { formHeaderRegio
66
67
  ...(sections.fillHeight && { fillHeight: sections.fillHeight }),
67
68
  ...(props.hideSectionTitles === true && { chromeless: true }),
68
69
  ...(summary !== undefined && { summary }),
70
+ ...(props.formErrorOnTop === true && { topBanner: renderFormErrorBanner(model) }),
69
71
  };
70
72
  }
71
73
  export function renderEditLayout(model) {
72
- const { props, state, sections, handleSubmit } = model.engine;
74
+ const { props, state, sections, form, handleSubmit } = model.engine;
73
75
  const header = buildHeaderActions(model);
74
76
  const { Form } = state.primitives;
75
- return (_jsx(ExtensionFormRegistryProvider, { value: state.extensionFormRegistry, children: _jsxs(FormUploadTrackerProvider, { value: state.trackUpload, children: [state.menuActionConfirmDialog, renderPageHeader(model, header), _jsx(Form, { onSubmit: () => void handleSubmit(), ...(state.focusFirstErrorKey > 0 && { focusFirstErrorKey: state.focusFirstErrorKey }), ...buildFormHeadingProps(model), ...buildFormActionProps(model, header), testId: "render-edit-form", stickyActions: state.isWizard || props.fillScreenHeight === true, ...buildFormChromeProps(model, header), children: _jsxs(AllFieldsRequiredProvider, { value: sections.showsAllRequiredHint || props.screen.layout.hideRequiredMarker === true, children: [props.leadContent, sections.showsAllRequiredHint && !state.insideDrawer && renderAllRequiredHint(model), renderDraftPicker(model), renderWizardProgress(model), state.isTabs && state.isStepped && renderTabStrip(model), props.formErrorOnTop === true && renderFormErrorBanner(model), renderEditSections(model), renderAfterFormSlot(model), props.formErrorOnTop !== true && renderFormErrorBanner(model), renderRootIssueBanners(model), renderExtensionErrorBanner(model), renderActionErrorBanner(model), renderDeleteDialog(model)] }) })] }) }));
77
+ return (_jsx(ExtensionFormRegistryProvider, { value: state.extensionFormRegistry, children: _jsxs(FormUploadTrackerProvider, { value: state.trackUpload, children: [state.menuActionConfirmDialog, renderPageHeader(model, header), _jsx(Form, { onSubmit: () => void handleSubmit(), ...(state.focusFirstErrorKey > 0 && { focusFirstErrorKey: state.focusFirstErrorKey }), ...buildFormHeadingProps(model), ...buildFormActionProps(model, header), testId: "render-edit-form", stickyActions: state.isWizard || props.fillScreenHeight === true, ...buildFormChromeProps(model, header), children: _jsxs(AllFieldsRequiredProvider, { value: sections.showsAllRequiredHint || props.screen.layout.hideRequiredMarker === true, children: [props.leadContent, sections.showsAllRequiredHint && !state.insideDrawer && renderAllRequiredHint(model), renderDraftPicker(model), renderWizardProgress(model), state.isTabs && state.isStepped && renderTabStrip(model), renderEditSections(model), props.belowSections?.(form.snapshot.values), renderAfterFormSlot(model), props.formErrorOnTop !== true && renderFormErrorBanner(model), renderRootIssueBanners(model), renderExtensionErrorBanner(model), renderActionErrorBanner(model), renderDeleteDialog(model)] }) })] }) }));
76
78
  }
@@ -1,5 +1,5 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ExtensionSectionMount } from "./edit-mounts.js";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { EditSlotMount, ExtensionSectionMount } from "./edit-mounts.js";
3
3
  import { RelatedListSection } from "./related-list-section.js";
4
4
  import { RenderEditActionButton } from "./render-edit-action-button.js";
5
5
  import { renderFieldsSection } from "./render-edit-fields-section.js";
@@ -39,7 +39,8 @@ function renderRelatedListSection({ model, sectionIndex, sectionActionsEl }, sec
39
39
  const anchorId = sectionNavAnchorId(model.titles.sectionNavItems, sectionIndex);
40
40
  const mount = (_jsx(RelatedListSection, { ...(anchorId !== undefined && { anchorId }), section: section, parentId: parentId,
41
41
  // @cast-boundary form-values: TValues is structurally a Record.
42
- record: form.snapshot.values, featureName: props.featureName, translate: model.engine.state.translate, hideTitle: hideSectionTitles, ...(refreshToken !== undefined && { refreshToken }), ...(fillScreenHeight === true && { grow: true }), ...(hideSectionTitles !== true &&
42
+ record: form.snapshot.values, featureName: props.featureName, translate: model.engine.state.translate, hideTitle: hideSectionTitles, ...(props.recordSections?.labelTitles === true && { labelTitle: true }), ...(sectionIndex === 0 &&
43
+ props.recordSections?.omitFirstTitle === true && { omitTitle: true }), ...(refreshToken !== undefined && { refreshToken }), ...(hideSectionTitles !== true &&
43
44
  sectionActionsEl !== undefined && { actions: sectionActionsEl }), ...(onRelatedListDrawerAction !== undefined && {
44
45
  onOpenDrawer: onRelatedListDrawerAction,
45
46
  }) }, section.title));
@@ -52,16 +53,20 @@ function renderStepListSection({ model, sectionIndex }, section) {
52
53
  if (StepList === undefined || section.items.length === 0)
53
54
  return null;
54
55
  const items = section.items.map((item, index) => ({ id: String(index), ...item }));
55
- return (_jsx(Section, { ...(section.title !== undefined && !model.engine.props.hideSectionTitles
56
+ return (_jsx(Section, { ...(section.title !== undefined &&
57
+ !model.engine.props.hideSectionTitles &&
58
+ !(sectionIndex === 0 && model.engine.props.recordSections?.omitFirstTitle === true)
56
59
  ? { title: section.title }
57
- : {}), testId: "step-list-section", children: _jsx(StepList, { items: items, testId: "step-list" }) }, section.title ?? `step-list-${sectionIndex}`));
60
+ : {}), ...(model.engine.props.recordSections?.labelTitles === true && {
61
+ titleStyle: "label",
62
+ }), testId: "step-list-section", children: _jsx(StepList, { items: items, testId: "step-list" }) }, section.title ?? `step-list-${sectionIndex}`));
58
63
  }
59
64
  function renderWriteFormSection({ model, sectionIndex, sectionActionsEl }, section) {
60
65
  const { props, state, sections } = model.engine;
61
66
  // Own submit button + dispatcher call, entirely independent of
62
67
  // this screen's (nonexistent, on projectionDetail) form submit —
63
68
  // rejected at boot in wizard layouts, so no WizardStepGroup here.
64
- return (_jsx(WriteFormSection, { section: section, featureName: props.featureName, translate: state.translate, hideTitle: props.hideSectionTitles, onSubmitted: () => props.onReload?.(), ...(sections.isLoneWriteFormTab && { onFooterAction: sections.setWriteFormFooterAction }), ...(sectionActionsEl !== undefined && { actions: sectionActionsEl }) }, section.title ?? `write-form-${sectionIndex}`));
69
+ return (_jsx(WriteFormSection, { section: section, featureName: props.featureName, translate: state.translate, hideTitle: props.hideSectionTitles, ...(props.recordSections?.labelTitles === true && { labelTitle: true }), onSubmitted: () => props.onReload?.(), recordValues: model.engine.form.snapshot.values, ...(sections.isLoneWriteFormTab && { onFooterAction: sections.setWriteFormFooterAction }), ...(sectionActionsEl !== undefined && { actions: sectionActionsEl }) }, section.title ?? `write-form-${sectionIndex}`));
65
70
  }
66
71
  function renderSectionByKind(rc, section) {
67
72
  switch (section.kind) {
@@ -118,11 +123,44 @@ function createWizardStepWrapper({ engine: { props, state, steps } }, sectionInd
118
123
  return (_jsx(WizardStepGroup, { hidden: stepHidden, ...(props.hideSectionTitles === true && { inset: true }), children: el }, key));
119
124
  };
120
125
  }
126
+ // `after` stands directly under its section card; the narrow options are CSS-only so the
127
+ // section stays mounted (its form state and queries survive a resize).
128
+ function withSectionPresentation(model, section, sectionIndex, node) {
129
+ const { props, form, sections, state } = model.engine;
130
+ const { FillContainer } = state.primitives;
131
+ if (node === null || FillContainer === undefined)
132
+ return node;
133
+ const narrowClass = section.hideOnNarrow === true
134
+ ? "max-sm:hidden"
135
+ : section.showOnNarrowOnly === true
136
+ ? "sm:hidden"
137
+ : undefined;
138
+ const titleClass = section.titleOnNarrow === false ? "max-sm:[&_[data-section-title]]:hidden" : undefined;
139
+ if (section.after === undefined && narrowClass === undefined && titleClass === undefined) {
140
+ return node;
141
+ }
142
+ return (_jsxs(FillContainer, { className: [narrowClass, titleClass, "gap-3"].filter((c) => c !== undefined).join(" "), children: [node, section.after !== undefined && (_jsx(EditSlotMount, { slot: section.after, slotName: "afterSection", screenId: props.screen.id, entityName: sections.vm.entityName, entityId: resolveExtensionEntityId(props.entityId, sections.vm.id), values: form.snapshot.values, ...(props.activeTabId !== undefined && { activeTabId: props.activeTabId }) }))] }, `section-presentation-${sectionIndex}`));
143
+ }
121
144
  export function renderEditSections(model) {
122
- return model.engine.sections.filteredSections.map((section, sectionIndex) => renderSectionByKind({
123
- model,
124
- sectionIndex,
125
- sectionActionsEl: renderSectionActions(model, section),
126
- wrapWizardStep: createWizardStepWrapper(model, sectionIndex),
127
- }, section));
145
+ const rendered = model.engine.sections.filteredSections.map((section, sectionIndex) => ({
146
+ section,
147
+ node: withSectionPresentation(model, section, sectionIndex, renderSectionByKind({
148
+ model,
149
+ sectionIndex,
150
+ sectionActionsEl: renderSectionActions(model, section),
151
+ wrapWizardStep: createWizardStepWrapper(model, sectionIndex),
152
+ }, section)),
153
+ }));
154
+ const { FillContainer } = model.engine.state.primitives;
155
+ if (model.engine.props.recordSections?.photosBeside !== true || FillContainer === undefined) {
156
+ return rendered.map(({ node }) => node);
157
+ }
158
+ const photos = rendered.filter(({ section }) => isPhotoGridSection(section));
159
+ const rest = rendered.filter(({ section }) => !isPhotoGridSection(section));
160
+ if (photos.length === 0 || rest.length === 0)
161
+ return rendered.map(({ node }) => node);
162
+ return (_jsxs(FillContainer, { testId: "record-photos-beside", className: "grid grid-cols-1 items-start gap-x-8 gap-y-6 lg:grid-cols-[minmax(0,380px)_minmax(0,1fr)]", children: [_jsx(FillContainer, { className: "gap-6", children: rest.map(({ node }) => node) }), _jsx(FillContainer, { className: "gap-6", children: photos.map(({ node }) => node) })] }, "photos-beside"));
163
+ }
164
+ function isPhotoGridSection(section) {
165
+ return section.kind === "relatedList" && section.photoGrid !== undefined;
128
166
  }
@@ -87,7 +87,7 @@ export function deriveTitles(engine, layout, footer) {
87
87
  // or, without one, the screen title, so a form title above the sections repeats it.
88
88
  titleInHeaderRegion: headerRegion !== undefined && PageHeader !== undefined && state.pageHeaderSlotAvailable,
89
89
  stepRail: state.isWizard && layout.isScreenForm && StepBar !== undefined,
90
- sectionNavItems: layout.isScreenForm && !state.isStepped
90
+ sectionNavItems: layout.isScreenForm && !state.isStepped && props.recordSections?.pageNavigation !== false
91
91
  ? deriveSectionNavItems(filteredSections, formTitle)
92
92
  : [],
93
93
  compactStepLabel: deriveCompactStepLabel(translate, filteredSections[currentStep]?.title, currentStep, lastStepIndex),
@@ -203,6 +203,17 @@ export type RenderEditProps<TValues extends FormValues, TCtx = unknown> = {
203
203
  readonly hideSectionTitles?: boolean;
204
204
  /** Id of the active tab of a tabbed projectionDetail; handed to the `afterForm` slot. */
205
205
  readonly activeTabId?: string;
206
+ /** Record-view look of a projectionDetail; each key is opt-in. */
207
+ readonly recordSections?: {
208
+ /** Section titles render as small uppercase labels without separators. */
209
+ readonly labelTitles?: true;
210
+ /** The first section's title is the tab label right above it and is left out. */
211
+ readonly omitFirstTitle?: true;
212
+ /** `false` leaves out the "On this page" navigation. */
213
+ readonly pageNavigation?: false;
214
+ /** Fields sections and the photo-grid relatedList sit side by side from `lg` up. */
215
+ readonly photosBeside?: true;
216
+ };
206
217
  /** Screen body fills the shell height: the form gets `fillHeight` and
207
218
  * `stickyActions` (sections scroll, footer pinned). Set by KumikoScreen for
208
219
  * screens with `fillHeight !== false`; dialogs and other embedded hosts
@@ -212,6 +223,8 @@ export type RenderEditProps<TValues extends FormValues, TCtx = unknown> = {
212
223
  * rhythm — for content that belongs to the form but is no field (e.g. the
213
224
  * secret a confirm step refers to). */
214
225
  readonly leadContent?: ReactNode;
226
+ /** Rendered after the sections, above the form actions, with the live form values. */
227
+ readonly belowSections?: (values: Readonly<Record<string, unknown>>) => ReactNode;
215
228
  /** Blocks submit (button and Enter) while fields stay editable — unlike
216
229
  * `disabled`, which locks the whole form. For a gate the host owns, e.g.
217
230
  * an acknowledgement checkbox in `leadContent`. */