@cosmicdrift/kumiko-renderer 0.415.0 → 0.417.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/dist/app/action-form-body.d.ts +2 -5
  2. package/dist/app/action-form-body.js +50 -22
  3. package/dist/app/action-form-support.d.ts +4 -1
  4. package/dist/app/action-form-support.js +8 -4
  5. package/dist/app/client-actions.js +6 -4
  6. package/dist/app/config-edit-body.js +83 -82
  7. package/dist/app/entity-list-screen.js +1 -1
  8. package/dist/app/extension-sections.d.ts +2 -0
  9. package/dist/app/header-actions-bar.d.ts +3 -1
  10. package/dist/app/header-actions-bar.js +12 -4
  11. package/dist/app/locked-screen-header.d.ts +2 -0
  12. package/dist/app/locked-screen-header.js +8 -1
  13. package/dist/app/projection-detail-body.js +29 -8
  14. package/dist/app/projection-detail-guidance.d.ts +2 -1
  15. package/dist/app/projection-detail-guidance.js +45 -30
  16. package/dist/app/projection-detail-header-model.d.ts +1 -1
  17. package/dist/app/projection-detail-header-model.js +14 -6
  18. package/dist/app/projection-detail-header-region.js +25 -9
  19. package/dist/app/projection-detail-header.d.ts +2 -0
  20. package/dist/app/projection-detail-header.js +31 -4
  21. package/dist/app/projection-detail-navigation.d.ts +4 -0
  22. package/dist/app/projection-detail-navigation.js +5 -1
  23. package/dist/app/projection-list-shim.js +1 -0
  24. package/dist/app/row-actions.d.ts +4 -0
  25. package/dist/app/row-actions.js +19 -3
  26. package/dist/app/screen-shared.d.ts +1 -0
  27. package/dist/app/screen-shared.js +23 -3
  28. package/dist/app/use-projection-detail-actions.d.ts +16 -1
  29. package/dist/app/use-projection-detail-actions.js +23 -3
  30. package/dist/app/use-projection-detail-data.d.ts +2 -0
  31. package/dist/app/use-projection-detail-data.js +53 -10
  32. package/dist/app/use-projection-list-data.js +1 -1
  33. package/dist/card-options.d.ts +2 -0
  34. package/dist/components/ai-assist-payload.d.ts +2 -0
  35. package/dist/components/ai-assist-payload.js +8 -0
  36. package/dist/components/choice-chip-class.d.ts +1 -0
  37. package/dist/components/choice-chip-class.js +9 -0
  38. package/dist/components/edit-mounts.d.ts +3 -2
  39. package/dist/components/edit-mounts.js +2 -2
  40. package/dist/components/grid-cell-for-field.js +1 -1
  41. package/dist/components/multi-select-chips.d.ts +10 -0
  42. package/dist/components/multi-select-chips.js +19 -0
  43. package/dist/components/narrow-description.d.ts +3 -0
  44. package/dist/components/narrow-description.js +12 -0
  45. package/dist/components/related-list-section.d.ts +5 -3
  46. package/dist/components/related-list-section.js +52 -35
  47. package/dist/components/related-photo-grid.d.ts +11 -0
  48. package/dist/components/related-photo-grid.js +54 -0
  49. package/dist/components/render-edit-action-button.d.ts +2 -2
  50. package/dist/components/render-edit-field-grid.d.ts +12 -3
  51. package/dist/components/render-edit-field-grid.js +60 -18
  52. package/dist/components/render-edit-fields-section.js +45 -11
  53. package/dist/components/render-edit-header-actions.d.ts +2 -1
  54. package/dist/components/render-edit-header-actions.js +18 -1
  55. package/dist/components/render-edit-layout.js +5 -3
  56. package/dist/components/render-edit-logic.js +1 -0
  57. package/dist/components/render-edit-section-kinds.js +59 -10
  58. package/dist/components/render-edit-titles.js +1 -1
  59. package/dist/components/render-edit-types.d.ts +22 -1
  60. package/dist/components/render-field-ai-assist.d.ts +13 -0
  61. package/dist/components/render-field-ai-assist.js +90 -0
  62. package/dist/components/render-field-choice-inputs.js +4 -0
  63. package/dist/components/render-field-control.d.ts +1 -1
  64. package/dist/components/render-field-control.js +19 -9
  65. package/dist/components/render-field-value-chips.d.ts +9 -0
  66. package/dist/components/render-field-value-chips.js +47 -0
  67. package/dist/components/render-field-write-only.js +12 -4
  68. package/dist/components/render-list-hint-columns.d.ts +2 -0
  69. package/dist/components/render-list-hint-columns.js +43 -5
  70. package/dist/components/render-list-reference-columns.js +2 -4
  71. package/dist/components/render-list-row-tone.d.ts +2 -0
  72. package/dist/components/render-list-row-tone.js +6 -0
  73. package/dist/components/render-list-table-props.d.ts +13 -2
  74. package/dist/components/render-list-table-props.js +9 -3
  75. package/dist/components/render-list-types.d.ts +4 -0
  76. package/dist/components/render-list.js +12 -4
  77. package/dist/components/use-render-edit-sections.js +5 -1
  78. package/dist/components/use-render-list-columns.js +3 -3
  79. package/dist/components/write-form-registry.d.ts +13 -0
  80. package/dist/components/write-form-registry.js +6 -0
  81. package/dist/components/write-form-section.d.ts +5 -1
  82. package/dist/components/write-form-section.js +55 -16
  83. package/dist/headless/form/form-controller.d.ts +1 -0
  84. package/dist/headless/form/form-controller.js +1 -1
  85. package/dist/headless/format/index.d.ts +1 -0
  86. package/dist/headless/format/index.js +21 -0
  87. package/dist/headless/format/phone.d.ts +1 -0
  88. package/dist/headless/format/phone.js +8 -0
  89. package/dist/headless/format/relative-time.d.ts +15 -0
  90. package/dist/headless/format/relative-time.js +63 -0
  91. package/dist/headless/format/safe-locale.d.ts +1 -0
  92. package/dist/headless/format/safe-locale.js +13 -0
  93. package/dist/headless/index.d.ts +2 -2
  94. package/dist/headless/index.js +2 -2
  95. package/dist/headless/view-model/edit.d.ts +3 -2
  96. package/dist/headless/view-model/edit.js +162 -36
  97. package/dist/headless/view-model/field-text.d.ts +9 -0
  98. package/dist/headless/view-model/field-text.js +19 -0
  99. package/dist/headless/view-model/index.d.ts +1 -0
  100. package/dist/headless/view-model/index.js +1 -0
  101. package/dist/headless/view-model/list.js +6 -0
  102. package/dist/headless/view-model/types.d.ts +76 -5
  103. package/dist/hooks/use-list-table.js +11 -6
  104. package/dist/i18n-defaults.js +9 -2
  105. package/dist/index.d.ts +1 -1
  106. package/dist/primitives-record-guidance.d.ts +32 -1
  107. package/dist/primitives-share-types.d.ts +82 -0
  108. package/dist/primitives-share-types.js +1 -0
  109. package/dist/primitives.d.ts +44 -86
  110. package/dist/web/app/bold-markup.d.ts +3 -0
  111. package/dist/web/app/bold-markup.js +14 -0
  112. package/dist/web/app/dashboard-body.js +8 -3
  113. package/dist/web/app/dashboard-list-panel.js +8 -4
  114. package/dist/web/app/dashboard-panel-columns.d.ts +9 -0
  115. package/dist/web/app/dashboard-panel-columns.js +14 -0
  116. package/dist/web/app/dashboard-panels.js +31 -3
  117. package/dist/web/app/dashboard-shared.d.ts +3 -1
  118. package/dist/web/app/dashboard-shared.js +4 -4
  119. package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -1
  120. package/dist/web/app/dashboard-stat-group-panel.js +24 -3
  121. package/dist/web/app/dashboard-text-panel.d.ts +1 -0
  122. package/dist/web/app/dashboard-text-panel.js +18 -11
  123. package/dist/web/app/relative-time.d.ts +0 -5
  124. package/dist/web/app/relative-time.js +11 -21
  125. package/dist/web/components/config-cascade.d.ts +2 -1
  126. package/dist/web/components/config-cascade.js +16 -4
  127. package/dist/web/drawn-icons.js +2 -1
  128. package/dist/web/layout/header-action-pinned.d.ts +4 -2
  129. package/dist/web/layout/header-action-pinned.js +13 -4
  130. package/dist/web/layout/header-overflow-menu.d.ts +2 -0
  131. package/dist/web/layout/header-overflow-menu.js +2 -0
  132. package/dist/web/layout/notification-bell.js +12 -3
  133. package/dist/web/layout/page-header-slot.d.ts +2 -0
  134. package/dist/web/layout/page-header-slot.js +4 -0
  135. package/dist/web/layout/screen-focus.js +4 -1
  136. package/dist/web/layout/shell-header.js +13 -5
  137. package/dist/web/primitives/banner.js +24 -8
  138. package/dist/web/primitives/card.js +5 -3
  139. package/dist/web/primitives/combobox.js +2 -2
  140. package/dist/web/primitives/data-table/actions-column.js +1 -1
  141. package/dist/web/primitives/data-table/card-body.d.ts +1 -1
  142. package/dist/web/primitives/data-table/card-body.js +37 -14
  143. package/dist/web/primitives/data-table/card-frame.d.ts +2 -0
  144. package/dist/web/primitives/data-table/card-frame.js +3 -0
  145. package/dist/web/primitives/data-table/card-row.js +34 -10
  146. package/dist/web/primitives/data-table/card-sort-select.js +1 -1
  147. package/dist/web/primitives/data-table/card-view.js +1 -1
  148. package/dist/web/primitives/data-table/data-cell-props.d.ts +4 -1
  149. package/dist/web/primitives/data-table/data-cell-props.js +3 -0
  150. package/dist/web/primitives/data-table/density.d.ts +3 -1
  151. package/dist/web/primitives/data-table/density.js +11 -4
  152. package/dist/web/primitives/data-table/row-click-guard.d.ts +2 -0
  153. package/dist/web/primitives/data-table/row-click-guard.js +19 -0
  154. package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
  155. package/dist/web/primitives/data-table/row-render-parts.js +3 -5
  156. package/dist/web/primitives/data-table/sort-options-select.js +2 -2
  157. package/dist/web/primitives/data-table/sortable-header.js +4 -4
  158. package/dist/web/primitives/data-table/table-body.js +3 -1
  159. package/dist/web/primitives/data-table/table-chrome.js +1 -3
  160. package/dist/web/primitives/data-table/table-content.js +6 -6
  161. package/dist/web/primitives/data-table/table-data-cell.js +31 -17
  162. package/dist/web/primitives/data-table/table-header-row.js +1 -1
  163. package/dist/web/primitives/data-table/table-view.js +1 -1
  164. package/dist/web/primitives/data-table/toolbar.js +6 -7
  165. package/dist/web/primitives/data-table/use-data-table-state.d.ts +6 -1
  166. package/dist/web/primitives/data-table/use-data-table-state.js +12 -2
  167. package/dist/web/primitives/data-table-cell.d.ts +17 -3
  168. package/dist/web/primitives/data-table-cell.js +130 -36
  169. package/dist/web/primitives/data-table.js +1 -1
  170. package/dist/web/primitives/default-form.d.ts +1 -1
  171. package/dist/web/primitives/default-form.js +15 -11
  172. package/dist/web/primitives/drawer.js +2 -3
  173. package/dist/web/primitives/facet-filter.d.ts +1 -1
  174. package/dist/web/primitives/facet-filter.js +2 -5
  175. package/dist/web/primitives/facet-search-filter.js +1 -1
  176. package/dist/web/primitives/facet-trigger-label.d.ts +1 -4
  177. package/dist/web/primitives/facet-trigger-label.js +4 -7
  178. package/dist/web/primitives/field.js +15 -8
  179. package/dist/web/primitives/form-footer-parts.js +6 -3
  180. package/dist/web/primitives/form.js +6 -8
  181. package/dist/web/primitives/index.js +4 -0
  182. package/dist/web/primitives/inline-suffix.d.ts +2 -0
  183. package/dist/web/primitives/inline-suffix.js +5 -0
  184. package/dist/web/primitives/input-choice-kinds.js +12 -2
  185. package/dist/web/primitives/input-number-kinds.js +2 -2
  186. package/dist/web/primitives/input-text-kinds.js +1 -1
  187. package/dist/web/primitives/layout-elements.d.ts +4 -4
  188. package/dist/web/primitives/layout-elements.js +50 -13
  189. package/dist/web/primitives/layout.d.ts +1 -1
  190. package/dist/web/primitives/layout.js +1 -1
  191. package/dist/web/primitives/locale-number.d.ts +0 -1
  192. package/dist/web/primitives/locale-number.js +1 -13
  193. package/dist/web/primitives/money-input.js +10 -8
  194. package/dist/web/primitives/narrow-pinned-footer.js +7 -3
  195. package/dist/web/primitives/number-input.d.ts +2 -1
  196. package/dist/web/primitives/number-input.js +11 -5
  197. package/dist/web/primitives/page-header.d.ts +1 -1
  198. package/dist/web/primitives/page-header.js +8 -1
  199. package/dist/web/primitives/pager.js +12 -21
  200. package/dist/web/primitives/photo-grid.d.ts +3 -0
  201. package/dist/web/primitives/photo-grid.js +6 -0
  202. package/dist/web/primitives/record-steps.d.ts +1 -1
  203. package/dist/web/primitives/record-steps.js +7 -16
  204. package/dist/web/primitives/record-summary.d.ts +1 -1
  205. package/dist/web/primitives/record-summary.js +8 -3
  206. package/dist/web/primitives/row-actions.js +38 -24
  207. package/dist/web/primitives/step-list.d.ts +3 -0
  208. package/dist/web/primitives/step-list.js +11 -0
  209. package/dist/web/primitives/use-container-narrow.d.ts +12 -0
  210. package/dist/web/primitives/use-container-narrow.js +42 -0
  211. package/dist/web/ui/input.js +1 -1
  212. package/dist/web/ui/textarea.js +1 -1
  213. package/dist/web/widgets/dashboard-list-cards.js +6 -3
  214. package/dist/web/widgets/dashboard-list.d.ts +6 -1
  215. package/dist/web/widgets/dashboard-list.js +12 -7
  216. package/dist/web/widgets/drawer-panel-class.js +1 -1
  217. package/dist/web/widgets/progress-list.js +1 -1
  218. package/dist/web/widgets/stat-box-cell.js +1 -1
  219. package/package.json +5 -5
  220. package/src/changes.json +105 -0
  221. package/src/web/styles.css +3 -2
@@ -1,6 +1,6 @@
1
1
  import type { ReactNode } from "react";
2
2
  import { type ErrorNotice } from "../app/error-reference.tsx";
3
- import type { usePrimitives } from "../primitives.tsx";
3
+ import type { FooterActionMarker, usePrimitives } from "../primitives.tsx";
4
4
  import type { RenderEditAction } from "./render-edit-types.ts";
5
5
  export declare function needsActionConfirm(action: Pick<RenderEditAction, "confirm" | "confirmRequired" | "style">): boolean;
6
6
  export declare function RenderEditActionConfirmDialog({ action, open, onOpenChange, onConfirm, Dialog, }: {
@@ -22,4 +22,4 @@ export declare function RenderEditActionButton({ action, iconOnly, hideIcon, siz
22
22
  readonly Button: ReturnType<typeof usePrimitives>["Button"];
23
23
  readonly Dialog: ReturnType<typeof usePrimitives>["Dialog"];
24
24
  readonly onError: (notice: ErrorNotice | null) => void;
25
- }): ReactNode;
25
+ } & FooterActionMarker): ReactNode;
@@ -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) {
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) }),
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), 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) {
@@ -1,6 +1,6 @@
1
1
  import type { ReactNode } from "react";
2
2
  import type { FormValues } from "../headless/index.ts";
3
- import type { ActionMenuItemSpec } from "../primitives.tsx";
3
+ import { type ActionMenuItemSpec } from "../primitives.tsx";
4
4
  import type { RenderEditModel } from "./render-edit-render-model.ts";
5
5
  export type HeaderActionsModel = {
6
6
  readonly headerMenuItems: readonly ActionMenuItemSpec[];
@@ -8,4 +8,5 @@ export type HeaderActionsModel = {
8
8
  readonly formHeaderRegion: ReactNode;
9
9
  readonly titleActionMount: ReactNode;
10
10
  };
11
+ export declare function renderAfterFormSlot<TValues extends FormValues, TCtx>(model: RenderEditModel<TValues, TCtx>): ReactNode;
11
12
  export declare function buildHeaderActions<TValues extends FormValues, TCtx>(model: RenderEditModel<TValues, TCtx>): HeaderActionsModel;
@@ -1,4 +1,5 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { FOOTER_ACTION_ROLE_PROP, } from "../primitives.js";
2
3
  import { EditSlotMount } from "./edit-mounts.js";
3
4
  import { RenderEditActionButton } from "./render-edit-action-button.js";
4
5
  import { resolveExtensionEntityId } from "./render-edit-logic.js";
@@ -75,9 +76,18 @@ function renderCopyLinkButton({ engine: { props, state }, layout, }) {
75
76
  ? null
76
77
  : translate(linkCopied ? "kumiko.actions.copyLinkCopied" : "kumiko.actions.copyLink") })));
77
78
  }
79
+ // The role prop is read by NarrowPinnedFooter from the element, so the DOM span needs a component in between.
80
+ function FooterStartGroup({ children, }) {
81
+ return (_jsx("span", { className: "mr-auto inline-flex gap-2 max-sm:flex max-sm:w-full max-sm:[&>button]:flex-1", "data-footer-align": "start", "data-testid": "render-edit-footer-start", children: children }));
82
+ }
78
83
  function renderCustomActions({ engine: { props, state }, layout, }) {
79
84
  const { Button, Dialog } = state.primitives;
80
- return props.actions?.map((action) => (_jsx(RenderEditActionButton, { action: action, iconOnly: layout.iconOnlyMidActions, 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
+ const startActions = props.actions?.filter((action) => action.align === "start") ?? [];
87
+ const otherActions = props.actions?.filter((action) => action.align !== "start");
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) && {
89
+ [FOOTER_ACTION_ROLE_PROP]: "inline",
90
+ }), children: startActions.map(button) })), otherActions?.map(button)] }));
81
91
  }
82
92
  function renderMenuActionButtons({ engine: { props, state }, layout, }) {
83
93
  const { Button, Dialog } = state.primitives;
@@ -98,6 +108,13 @@ function renderEditSlot({ engine: { props, form, sections } }, slot, slotName) {
98
108
  return undefined;
99
109
  return (_jsx(EditSlotMount, { slot: slot, slotName: slotName, screenId: props.screen.id, entityName: sections.vm.entityName, entityId: resolveExtensionEntityId(props.entityId, sections.vm.id), values: form.snapshot.values }));
100
110
  }
111
+ export function renderAfterFormSlot(model) {
112
+ const { props, form, sections } = model.engine;
113
+ const slot = props.screen.slots?.afterForm;
114
+ if (slot === undefined)
115
+ return undefined;
116
+ return (_jsx(EditSlotMount, { slot: slot, slotName: "afterForm", 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 }) }));
117
+ }
101
118
  // A function headerRegion places the slot itself (projectionDetail puts it
102
119
  // into its header card next to the actions); otherwise the slot renders
103
120
  // above the caller's own headerRegion.
@@ -3,7 +3,7 @@ import { ExtensionFormRegistryProvider } from "../app/extension-form-submit.js";
3
3
  import { FormUploadTrackerProvider } from "./form-pending-uploads.js";
4
4
  import { renderActionErrorBanner, renderAllRequiredHint, renderDeleteDialog, renderDraftPicker, renderExtensionErrorBanner, renderFormErrorBanner, renderRootIssueBanners, renderTabStrip, renderWizardProgress, } from "./render-edit-banners.js";
5
5
  import { renderFormActions } from "./render-edit-form-actions.js";
6
- import { buildHeaderActions } from "./render-edit-header-actions.js";
6
+ import { buildHeaderActions, renderAfterFormSlot, } from "./render-edit-header-actions.js";
7
7
  import { renderEditSections } from "./render-edit-section-kinds.js";
8
8
  import { deriveWizardRail } from "./render-edit-wizard-rail.js";
9
9
  import { AllFieldsRequiredProvider } from "./render-field.js";
@@ -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
74
  const { props, state, sections, 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), renderEditSections(model), 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), renderAfterFormSlot(model), props.formErrorOnTop !== true && renderFormErrorBanner(model), renderRootIssueBanners(model), renderExtensionErrorBanner(model), renderActionErrorBanner(model), renderDeleteDialog(model)] }) })] }) }));
76
78
  }
@@ -93,6 +93,7 @@ export function filterEditSections(sections, fieldsFilter) {
93
93
  for (const section of sections) {
94
94
  if (section.kind === "extension" ||
95
95
  section.kind === "relatedList" ||
96
+ section.kind === "stepList" ||
96
97
  section.kind === "writeForm") {
97
98
  result.push(section);
98
99
  continue;
@@ -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));
@@ -47,12 +48,25 @@ function renderRelatedListSection({ model, sectionIndex, sectionActionsEl }, sec
47
48
  // layout); the toolbar buttons live in the list's own toolbar.
48
49
  return hideSectionTitles === true ? (_jsx("div", { className: fillScreenHeight === true ? "flex min-h-0 flex-1 flex-col" : undefined, children: mount }, section.title)) : (mount);
49
50
  }
51
+ function renderStepListSection({ model, sectionIndex }, section) {
52
+ const { Section, StepList } = model.engine.state.primitives;
53
+ if (StepList === undefined || section.items.length === 0)
54
+ return null;
55
+ const items = section.items.map((item, index) => ({ id: String(index), ...item }));
56
+ return (_jsx(Section, { ...(section.title !== undefined &&
57
+ !model.engine.props.hideSectionTitles &&
58
+ !(sectionIndex === 0 && model.engine.props.recordSections?.omitFirstTitle === true)
59
+ ? { title: section.title }
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}`));
63
+ }
50
64
  function renderWriteFormSection({ model, sectionIndex, sectionActionsEl }, section) {
51
65
  const { props, state, sections } = model.engine;
52
66
  // Own submit button + dispatcher call, entirely independent of
53
67
  // this screen's (nonexistent, on projectionDetail) form submit —
54
68
  // rejected at boot in wizard layouts, so no WizardStepGroup here.
55
- 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}`));
56
70
  }
57
71
  function renderSectionByKind(rc, section) {
58
72
  switch (section.kind) {
@@ -62,6 +76,8 @@ function renderSectionByKind(rc, section) {
62
76
  return renderRelatedListSection(rc, section);
63
77
  case "writeForm":
64
78
  return renderWriteFormSection(rc, section);
79
+ case "stepList":
80
+ return renderStepListSection(rc, section);
65
81
  case "fields":
66
82
  return renderFieldsSection(rc, section);
67
83
  }
@@ -107,11 +123,44 @@ function createWizardStepWrapper({ engine: { props, state, steps } }, sectionInd
107
123
  return (_jsx(WizardStepGroup, { hidden: stepHidden, ...(props.hideSectionTitles === true && { inset: true }), children: el }, key));
108
124
  };
109
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
+ }
110
144
  export function renderEditSections(model) {
111
- return model.engine.sections.filteredSections.map((section, sectionIndex) => renderSectionByKind({
112
- model,
113
- sectionIndex,
114
- sectionActionsEl: renderSectionActions(model, section),
115
- wrapWizardStep: createWizardStepWrapper(model, sectionIndex),
116
- }, 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;
117
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),
@@ -69,6 +69,8 @@ export type RenderEditProps<TValues extends FormValues, TCtx = unknown> = {
69
69
  * same split as `onCopyLink`) — RenderEdit only wires the button, its
70
70
  * busy state and its confirm dialog. */
71
71
  readonly actions?: readonly RenderEditAction[];
72
+ /** Translated note on the left of the form footer (hidden below `sm`). */
73
+ readonly footerHint?: string;
72
74
  /** Record actions declared with `placement: "menu"`, resolved like `actions`.
73
75
  * Rendered in the header "…" menu ahead of copy-link/delete; without a
74
76
  * header menu (drawer, card form, shell without a header slot) they fall
@@ -110,8 +112,10 @@ export type RenderEditProps<TValues extends FormValues, TCtx = unknown> = {
110
112
  * above-control; below-control keeps the inputs of neighbouring fields
111
113
  * on one line when an appendix expands. */
112
114
  readonly fieldAppendixPlacement?: "above-control" | "below-control";
115
+ /** Renders the form-error banner above the sections instead of below them. */
116
+ readonly formErrorOnTop?: boolean;
113
117
  /** Per-field help text rendered under the label (translated by the caller). */
114
- readonly fieldDescription?: (fieldName: string) => ReactNode | undefined;
118
+ readonly fieldDescription?: (fieldName: string, values: Readonly<Record<string, unknown>>) => ReactNode | undefined;
115
119
  /** Extra full-width row drawn right after a field's cell (configEdit actions). `dirty` is true
116
120
  * while the form has unsaved changes. Called with the field name, returns a ReactNode or
117
121
  * undefined. */
@@ -197,6 +201,19 @@ export type RenderEditProps<TValues extends FormValues, TCtx = unknown> = {
197
201
  * redundant title above its content. Omitting this prop keeps unchanged
198
202
  * behavior. */
199
203
  readonly hideSectionTitles?: boolean;
204
+ /** Id of the active tab of a tabbed projectionDetail; handed to the `afterForm` slot. */
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
+ };
200
217
  /** Screen body fills the shell height: the form gets `fillHeight` and
201
218
  * `stickyActions` (sections scroll, footer pinned). Set by KumikoScreen for
202
219
  * screens with `fillHeight !== false`; dialogs and other embedded hosts
@@ -256,6 +273,10 @@ export type RenderEditAction = {
256
273
  * drives both the icon-left-of-text render and the icon-only collapse
257
274
  * rule (see `shouldRenderActionsIconOnly`). */
258
275
  readonly icon?: IconKey;
276
+ /** "start" sets the button apart on the left of the form footer. */
277
+ readonly align?: "start";
278
+ /** Stays a visible button in the pinned footer below `sm` instead of folding into the "…" menu. */
279
+ readonly pinnedOnPhone?: true;
259
280
  };
260
281
  export type RenderEditChangeState<TValues extends FormValues> = {
261
282
  readonly values: TValues;
@@ -0,0 +1,13 @@
1
+ import { type ReactNode } from "react";
2
+ import type { EditFieldViewModel } from "../headless/index.ts";
3
+ type AiAssist = NonNullable<EditFieldViewModel["aiAssist"]>;
4
+ type AiAssistControlProps = {
5
+ readonly field: EditFieldViewModel;
6
+ readonly aiAssist: AiAssist;
7
+ readonly onChange: (value: unknown) => void;
8
+ readonly input: ReactNode;
9
+ /** Current form values; `aiAssist.contextFields` are read from here. */
10
+ readonly row?: Readonly<Record<string, unknown>>;
11
+ };
12
+ export declare function AiAssistControl(props: AiAssistControlProps): ReactNode;
13
+ export {};
@@ -0,0 +1,90 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { useOptionalDispatcher } from "../context/dispatcher-context.js";
5
+ import { useTranslation } from "../i18n.js";
6
+ import { usePrimitives } from "../primitives.js";
7
+ import { useAiAssistPayload } from "./ai-assist-payload.js";
8
+ import { choiceChipClass } from "./choice-chip-class.js";
9
+ // Mounted only with a dispatcher; without one the field stays a plain input.
10
+ export function AiAssistControl(props) {
11
+ const dispatcher = useOptionalDispatcher();
12
+ return dispatcher === undefined ? props.input : _jsx(AiAssistChips, { ...props });
13
+ }
14
+ // Chips stack: every active chip contributes its params, so "shorter" and "mention warranty"
15
+ // can be combined. A click toggles the chip and re-runs the query with the new set.
16
+ function AiAssistChips({ field, aiAssist, onChange, input, row }) {
17
+ const { Button, Input, Banner } = usePrimitives();
18
+ const t = useTranslation();
19
+ const dispatcher = useOptionalDispatcher();
20
+ const contextPayload = useAiAssistPayload();
21
+ const [active, setActive] = useState(new Set());
22
+ const [instruction, setInstruction] = useState("");
23
+ const [busy, setBusy] = useState(false);
24
+ const [failed, setFailed] = useState(false);
25
+ const [note, setNote] = useState(undefined);
26
+ const activeRun = useRef(null);
27
+ const contextValues = Object.fromEntries((aiAssist.contextFields ?? []).map((name) => [name, row?.[name]]));
28
+ // Changed context (e.g. another selection) replaces the text; the first render never fetches.
29
+ const contextKey = JSON.stringify(contextValues);
30
+ const seenContextKey = useRef(contextKey);
31
+ const run = async (chips, typed) => {
32
+ if (dispatcher === undefined)
33
+ return;
34
+ activeRun.current?.abort();
35
+ const ctrl = new AbortController();
36
+ activeRun.current = ctrl;
37
+ const chipParams = Object.assign({}, ...[...chips].map((index) => aiAssist.chips?.[index]?.params));
38
+ const payload = {
39
+ ...contextPayload,
40
+ ...contextValues,
41
+ ...chipParams,
42
+ ...(typed !== undefined &&
43
+ aiAssist.prompt !== undefined && { [aiAssist.prompt.param]: typed }),
44
+ };
45
+ setBusy(true);
46
+ setFailed(false);
47
+ const result = await dispatcher.query(aiAssist.query, payload, {
48
+ signal: ctrl.signal,
49
+ });
50
+ if (ctrl.signal.aborted)
51
+ return;
52
+ setBusy(false);
53
+ const noteText = result.isSuccess && aiAssist.noteField !== undefined
54
+ ? propertyOf(result.data, aiAssist.noteField)
55
+ : undefined;
56
+ setNote(typeof noteText === "string" && noteText !== "" ? noteText : undefined);
57
+ const text = result.isSuccess ? propertyOf(result.data, aiAssist.resultField) : undefined;
58
+ if (typeof text !== "string") {
59
+ setFailed(true);
60
+ return;
61
+ }
62
+ onChange(text);
63
+ };
64
+ // The effect reads the latest run/active through a ref so it only fires when the context changes.
65
+ const rerunWithCurrentChips = useRef(() => { });
66
+ rerunWithCurrentChips.current = () => void run(active, undefined);
67
+ useEffect(() => {
68
+ // skip: nothing changed since the last run (or since mount).
69
+ if (seenContextKey.current === contextKey)
70
+ return;
71
+ seenContextKey.current = contextKey;
72
+ rerunWithCurrentChips.current();
73
+ }, [contextKey]);
74
+ const toggle = (index) => {
75
+ const next = new Set(active);
76
+ if (!next.delete(index))
77
+ next.add(index);
78
+ setActive(next);
79
+ void run(next, undefined);
80
+ };
81
+ return (_jsxs(_Fragment, { children: [input, _jsxs("div", { className: "order-2 flex flex-wrap items-center gap-2", "data-testid": `field-ai-assist-${field.field}`, children: [aiAssist.chips?.map((chip, index) => (_jsx(Button, { variant: "secondary", size: "sm", className: choiceChipClass(active.has(index)), pressed: active.has(index), disabled: busy || field.readOnly, testId: `field-ai-chip-${field.field}-${index}`, onClick: () => toggle(index), children: active.has(index) ? `✓ ${chip.label}` : chip.label }, chip.label))), aiAssist.prompt !== undefined && (_jsx(Input, { kind: "text", id: `${field.field}-ai-instruction`, name: `${field.field}-ai-instruction`, value: instruction, onChange: setInstruction, onKeyDown: (event) => {
82
+ if (event.key !== "Enter")
83
+ return;
84
+ // Enter must not submit the host form.
85
+ event.preventDefault();
86
+ if (busy || field.readOnly || instruction.trim() === "")
87
+ return;
88
+ void run(active, instruction.trim());
89
+ }, disabled: busy || field.readOnly, placeholder: aiAssist.prompt.placeholder ?? t("kumiko.field.aiAssist.prompt"), testId: `field-ai-prompt-${field.field}` }))] }), note !== undefined && (_jsx("span", { className: "order-2 text-xs text-muted-foreground", "data-testid": `field-ai-note-${field.field}`, children: note })), failed && (_jsx(Banner, { variant: "error", testId: `field-ai-error-${field.field}`, children: t("kumiko.field.aiAssist.failed") }))] }));
90
+ }