@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
@@ -22,7 +22,7 @@ export declare function DrawerHost({ schema, drawerAction, drawerScreen, drawerI
22
22
  readonly onClose: () => void;
23
23
  readonly onSuccess: () => void;
24
24
  }): ReactNode;
25
- export declare function ActionFormBody({ schema, screen, translate, entityId, initialOverrides, onSuccess, onCancelOverride, onDirtyChange, submitLabelFallback, }: {
25
+ export declare function ActionFormBody({ schema, screen, translate, entityId, initialOverrides, onSuccess, onDirtyChange, submitLabelFallback, }: {
26
26
  readonly schema: FeatureSchema;
27
27
  readonly screen: ActionFormScreenDefinition;
28
28
  readonly translate?: Translate;
@@ -36,9 +36,6 @@ export declare function ActionFormBody({ schema, screen, translate, entityId, in
36
36
  * drawer + refetches its list; a declared `screen.redirect` then navigates
37
37
  * (without returnTo, a drawer is no navigation target). */
38
38
  readonly onSuccess?: () => void;
39
- /** Drawer-hosted usage: replaces the cancelTarget/redirect-based Cancel
40
- * handler so Cancel closes the drawer instead of navigating. */
41
- readonly onCancelOverride?: () => void;
42
39
  /** Drawer-hosted usage: reports unsaved input so the host can confirm
43
40
  * before discarding it. */
44
41
  readonly onDirtyChange?: (dirty: boolean) => void;
@@ -12,6 +12,7 @@ import { PageHeaderSlotAvailableProvider } from "../page-header-slot.js";
12
12
  import { usePrimitives } from "../primitives.js";
13
13
  import { screenFillsHeight } from "../screen-fills-height.js";
14
14
  import { statusToneForOptionTone } from "../status-tone.js";
15
+ import { ActionFormPreviewPanel } from "./action-form-preview.js";
15
16
  import { actionFormSubmittableFields, synthesizeActionFormEntity, synthesizeActionFormScreen, } from "./action-form-shim.js";
16
17
  import { ActionFormLoadStatus, ActionFormSuccessBanner, DEFAULT_LOAD_ID_PARAM, isSecretFormField, resolveActionFormRecordId, resolveSuccessFacts, useActionFormLoad, } from "./action-form-support.js";
17
18
  import { useAppFeatures } from "./app-features-context.js";
@@ -91,7 +92,7 @@ export function DrawerHost({ schema, drawerAction, drawerScreen, drawerInitialVa
91
92
  }), onSuccess: () => {
92
93
  setHasUnsavedInput(false);
93
94
  onSuccess();
94
- }, onCancelOverride: requestClose, onDirtyChange: setHasUnsavedInput, submitLabelFallback: drawerAction.label })) }) }) }), _jsx(Dialog, { open: confirmDiscardOpen, onOpenChange: setConfirmDiscardOpen, title: t("kumiko.drawer.discard.title"), description: t("kumiko.drawer.discard.body"), confirmLabel: t("kumiko.drawer.discard.confirm"), cancelLabel: t("kumiko.drawer.discard.cancel"), variant: "danger", initialFocus: "cancel", onConfirm: closeAndReset, testId: "drawer-discard-dialog" })] }));
95
+ }, onDirtyChange: setHasUnsavedInput, submitLabelFallback: drawerAction.label })) }) }) }), _jsx(Dialog, { open: confirmDiscardOpen, onOpenChange: setConfirmDiscardOpen, title: t("kumiko.drawer.discard.title"), description: t("kumiko.drawer.discard.body"), confirmLabel: t("kumiko.drawer.discard.confirm"), cancelLabel: t("kumiko.drawer.discard.cancel"), variant: "danger", initialFocus: "cancel", onConfirm: closeAndReset, testId: "drawer-discard-dialog" })] }));
95
96
  }
96
97
  function declaresSuccessContent(screen) {
97
98
  return ((screen.successLinks?.length ?? 0) > 0 ||
@@ -114,13 +115,13 @@ function buildSuccessState(text, screen, resultData, context) {
114
115
  // to entityEdit, only the submit path switches from the CRUD verb to the
115
116
  // author-declared handler QN + payloadMode="values" (send all form values
116
117
  // instead of only the changes).
117
- export function ActionFormBody({ schema, screen, translate, entityId, initialOverrides, onSuccess, onCancelOverride, onDirtyChange, submitLabelFallback, }) {
118
+ export function ActionFormBody({ schema, screen, translate, entityId, initialOverrides, onSuccess, onDirtyChange, submitLabelFallback, }) {
118
119
  const nav = useNav();
119
120
  const appFeatures = useAppFeatures();
120
121
  const insideDrawer = useInsideDrawer();
121
122
  const locale = useLocale().locale();
122
123
  const { Banner, StatusBadge } = usePrimitives();
123
- // Unused when drawer-hosted — onSuccess/onCancelOverride win below first.
124
+ // Unused when drawer-hosted — onSuccess wins below first.
124
125
  const returnTarget = useReturnTarget(screen.id);
125
126
  const submittableFields = useMemo(() => actionFormSubmittableFields(screen), [screen]);
126
127
  const synthEntity = useMemo(() => synthesizeActionFormEntity(submittableFields), [submittableFields]);
@@ -282,15 +283,16 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
282
283
  // `false` switches the button off explicitly (single-action screens where
283
284
  // cancel would just be submit-without-sending).
284
285
  // returnTo wins over the declared target when both are present.
286
+ // A drawer closes through its × / Esc (which confirms unsaved input), so its footer has no Cancel.
285
287
  const handleCancel = useMemo(() => {
286
- if (onCancelOverride !== undefined)
287
- return onCancelOverride;
288
+ if (insideDrawer)
289
+ return undefined;
288
290
  const target = screen.cancelTarget ??
289
291
  (screen.redirect !== undefined ? redirectScreenTarget(screen.redirect) : undefined);
290
292
  if (target === undefined || target === false)
291
293
  return undefined;
292
294
  return () => navigateToReturnOr(nav, returnTarget, () => nav.navigate({ screenId: lastSegment(target) }));
293
- }, [nav, screen.redirect, screen.cancelTarget, onCancelOverride, returnTarget]);
295
+ }, [nav, screen.redirect, screen.cancelTarget, insideDrawer, returnTarget]);
294
296
  // Rendering the form before a tenant-declared currency lands would show the
295
297
  // fallback and, on a fast click, submit it — hold instead.
296
298
  if (currencyLoading) {
@@ -302,6 +304,7 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
302
304
  if (loadState !== undefined && loadState.status !== "ready") {
303
305
  return (_jsx(ActionFormLoadStatus, { state: loadState, screenId: screen.id, translate: effectiveTranslate }));
304
306
  }
307
+ const { preview } = screen;
305
308
  return (_jsx(AiAssistPayloadProvider, { value: aiAssistPayload, children: _jsx(RenderEdit, { screen: synthScreen, entity: synthEntity, featureName: schema.featureName, initial: derivedInitial, ...(screen.derive !== undefined && { formDerivation: screen }), actionFormScreenQn: qualifyScreenId(schema.featureName, screen.id),
306
309
  // Extension sections in the actionForm see the initial form values
307
310
  // (incl. searchParams prefill, e.g. ?incidentId=...) as initialValues;
@@ -309,7 +312,7 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
309
312
  extensionInitialValues: initial, ...(screen.submitPrefilled === true && {
310
313
  submitWithoutChanges: hiddenRequiredFieldsFilled(synthScreen, screen.fields, initial),
311
314
  }), ...((success !== undefined || screen.infoBand !== undefined) && {
312
- leadContent: (_jsxs(_Fragment, { children: [screen.infoBand !== undefined && (_jsx(Banner, { variant: "primary", icon: "sparkles", density: "compact", testId: "kumiko-screen-action-form-info-band", children: effectiveTranslate(screen.infoBand) })), success !== undefined && _jsx(ActionFormSuccessBanner, { success: success })] })),
315
+ leadContent: (_jsxs(_Fragment, { children: [screen.infoBand !== undefined && (_jsx(Banner, { variant: "assist", icon: "sparkles", density: "compact", testId: "kumiko-screen-action-form-info-band", children: effectiveTranslate(screen.infoBand) })), success !== undefined && _jsx(ActionFormSuccessBanner, { success: success })] })),
313
316
  }), ...(screen.fieldBadges !== undefined &&
314
317
  StatusBadge !== undefined && {
315
318
  labelAppendix: (fieldName) => {
@@ -320,7 +323,7 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
320
323
  },
321
324
  }), writeCommand: screen.handler, payloadMode: "values", onSubmit: handleSubmitted, ...(handleCancel !== undefined && { onCancel: handleCancel }), onDirtyChange: handleDirtyChange, ...((insideDrawer || screenFillsHeight(screen)) && { fillScreenHeight: true }), ...((screen.submitLabel ?? submitLabelFallback) !== undefined && {
322
325
  submitLabel: screen.submitLabel ?? submitLabelFallback,
323
- }), ...(screen.submitStyle !== undefined && { submitVariant: screen.submitStyle }), ...(screen.footerActions !== undefined && { footerActions: screen.footerActions }), ...(screen.formErrorOnTop === true && { formErrorOnTop: true }), ...(screen.fieldDescriptions !== undefined && {
326
+ }), ...(screen.submitStyle !== undefined && { submitVariant: screen.submitStyle }), ...(screen.footerActions !== undefined && { footerActions: screen.footerActions }), formErrorOnTop: true, ...(screen.fieldDescriptions !== undefined && {
324
327
  fieldDescription: (fieldName, values) => {
325
328
  const ref = screen.fieldDescriptions?.[fieldName];
326
329
  if (ref === undefined)
@@ -328,5 +331,7 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
328
331
  const { text, complete } = resolveFieldText(ref, values, effectiveTranslate);
329
332
  return complete ? text : undefined;
330
333
  },
331
- }), ...(summary !== undefined && { summary }), ...(translate !== undefined && { translate }) }, formEpoch) }));
334
+ }), ...(summary !== undefined && { summary }), ...(preview !== undefined && {
335
+ belowSections: (values) => (_jsx(ActionFormPreviewPanel, { preview: preview, fields: screen.fields, values: values, translate: effectiveTranslate, locale: locale })),
336
+ }), ...(translate !== undefined && { translate }) }, formEpoch) }));
332
337
  }
@@ -0,0 +1,13 @@
1
+ import type { ActionFormPreview } from "@cosmicdrift/kumiko-framework/ui-types";
2
+ import { type ReactNode } from "react";
3
+ import type { Translate } from "../headless/index.ts";
4
+ type FormValueMap = Readonly<Record<string, unknown>>;
5
+ /** Shows what the submit would do, from a query over the live form values. A failed query is a hint only. */
6
+ export declare function ActionFormPreviewPanel({ preview, fields, values, translate, locale, }: {
7
+ readonly preview: ActionFormPreview;
8
+ readonly fields: Readonly<Record<string, unknown>>;
9
+ readonly values: FormValueMap;
10
+ readonly translate: Translate;
11
+ readonly locale: string;
12
+ }): ReactNode;
13
+ export {};
@@ -0,0 +1,66 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { isPlainObject, propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
3
+ import { useMemo } from "react";
4
+ import { isCurrencyOnlyMoney } from "../headless/form/form-controller.js";
5
+ import { REFERENCE_SEARCH_DEBOUNCE_MS } from "../hooks/reference-limits.js";
6
+ import { useDebouncedValue } from "../hooks/use-debounced-value.js";
7
+ import { useQuery } from "../hooks/use-query.js";
8
+ import { usePrimitives } from "../primitives.js";
9
+ import { ActionFormFacts, resolveSuccessFacts } from "./action-form-support.js";
10
+ import { QueryLoadingBanner } from "./query-state-banners.js";
11
+ import { dispatcherErrorText } from "./write-failed-error.js";
12
+ function isEmptyValue(value) {
13
+ return (value === undefined ||
14
+ value === null ||
15
+ value === "" ||
16
+ (Array.isArray(value) && value.length === 0) ||
17
+ isCurrencyOnlyMoney(value));
18
+ }
19
+ /** Empty optional fields stay out: an untouched date input holds "", which a query schema rejects instead of reading it as absent. */
20
+ function pickPayload(values, fieldNames) {
21
+ const payload = {};
22
+ for (const name of fieldNames) {
23
+ if (Object.hasOwn(values, name) && !isEmptyValue(values[name]))
24
+ payload[name] = values[name];
25
+ }
26
+ return payload;
27
+ }
28
+ /** Required fields of the payload that are still empty: the query would only answer a validation error. */
29
+ function missingRequired(payload, fieldNames, fields) {
30
+ return fieldNames.some((name) => propertyOf(fields[name], "required") === true && isEmptyValue(payload[name]));
31
+ }
32
+ function parsePayload(serialized) {
33
+ const parsed = JSON.parse(serialized);
34
+ return isPlainObject(parsed) ? parsed : {};
35
+ }
36
+ function previewRows(data, listField) {
37
+ const entries = propertyOf(data, listField);
38
+ if (!Array.isArray(entries))
39
+ return [];
40
+ return entries.flatMap((entry, index) => isPlainObject(entry) ? [{ id: String(index), values: entry }] : []);
41
+ }
42
+ /** Shows what the submit would do, from a query over the live form values. A failed query is a hint only. */
43
+ export function ActionFormPreviewPanel({ preview, fields, values, translate, locale, }) {
44
+ const { Banner, DataTable, Grid } = usePrimitives();
45
+ const fieldNames = useMemo(() => preview.fields ?? Object.keys(fields), [preview.fields, fields]);
46
+ const serialized = useDebouncedValue(JSON.stringify(pickPayload(values, fieldNames)), REFERENCE_SEARCH_DEBOUNCE_MS);
47
+ const payload = useMemo(() => parsePayload(serialized), [serialized]);
48
+ const incomplete = missingRequired(payload, fieldNames, fields);
49
+ const query = useQuery(preview.query, payload, { enabled: !incomplete });
50
+ const facts = useMemo(() => resolveSuccessFacts(preview.facts, query.data, translate, locale), [preview.facts, query.data, translate, locale]);
51
+ const columns = useMemo(() => (preview.list?.columns ?? []).map((column) => ({
52
+ field: column.field,
53
+ label: translate(column.label),
54
+ type: column.type ?? "text",
55
+ sortable: false,
56
+ })), [preview.list, translate]);
57
+ const rows = useMemo(() => (preview.list === undefined ? [] : previewRows(query.data, preview.list.field)), [preview.list, query.data]);
58
+ if (incomplete)
59
+ return null;
60
+ if (query.error !== null) {
61
+ return (_jsx(Banner, { variant: "warning", testId: "action-form-preview-error", children: dispatcherErrorText(query.error, translate) }));
62
+ }
63
+ if (query.data === null)
64
+ return query.loading ? _jsx(QueryLoadingBanner, {}) : null;
65
+ return (_jsx(Banner, { variant: "hint", testId: "action-form-preview", ...(preview.title !== undefined && { title: translate(preview.title) }), children: _jsxs(Grid, { columns: 1, children: [_jsx(ActionFormFacts, { facts: facts, testIdPrefix: "action-form-preview-fact" }), preview.list !== undefined && _jsx(DataTable, { columns: columns, rows: rows })] }) }));
66
+ }
@@ -1,6 +1,6 @@
1
1
  import type { ActionFormLoad, ActionFormSuccessFact } from "@cosmicdrift/kumiko-framework/ui-types";
2
2
  import { type ReactNode } from "react";
3
- import type { DispatcherError, Translate } from "../headless/index.ts";
3
+ import { type DispatcherError, type Translate } from "../headless/index.ts";
4
4
  export declare const DEFAULT_LOAD_ID_PARAM = "id";
5
5
  /** Record id of a `load` form: the route path id, else the drawer prefill `id`
6
6
  * (the clicked row), else the URL `id` param. Only the id is read from these
@@ -64,6 +64,11 @@ export type ActionFormSuccessState = {
64
64
  readonly items?: readonly ResolvedSuccessItem[];
65
65
  };
66
66
  export declare function resolveSuccessFacts(facts: readonly ActionFormSuccessFact[] | undefined, data: unknown, translate: (key: string) => string, locale: string): readonly ResolvedSuccessFact[];
67
+ /** One line per fact, a list of values as a block; shared by the success box and the preview panel. */
68
+ export declare function ActionFormFacts({ testIdPrefix, facts, }: {
69
+ readonly facts: readonly ResolvedSuccessFact[];
70
+ readonly testIdPrefix?: string;
71
+ }): ReactNode;
67
72
  export declare function ActionFormSuccessBanner({ success, }: {
68
73
  readonly success: ActionFormSuccessState;
69
74
  }): ReactNode;
@@ -1,8 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
3
3
  import { useMemo } from "react";
4
+ import { applyFormatSpec, formatMoneyValue, } from "../headless/index.js";
4
5
  import { useQuery } from "../hooks/use-query.js";
5
6
  import { usePrimitives } from "../primitives.js";
7
+ import { isMoneyValue } from "./entity-edit-prefill.js";
6
8
  import { QueryLoadingBanner } from "./query-state-banners.js";
7
9
  import { dispatcherErrorText } from "./write-failed-error.js";
8
10
  export const DEFAULT_LOAD_ID_PARAM = "id";
@@ -37,9 +39,10 @@ function pickDeclaredFields(record, fieldNames) {
37
39
  }
38
40
  return picked;
39
41
  }
42
+ const NO_FIELDS = [];
40
43
  /** Loads the initial values of an actionForm declaring `load`; undefined for a
41
44
  * form without `load`. */
42
- export function useActionFormLoad(load, recordId, fieldNames, summaryFieldNames = [], prefill) {
45
+ export function useActionFormLoad(load, recordId, fieldNames, summaryFieldNames = NO_FIELDS, prefill) {
43
46
  const isSingleton = load?.singleton === true;
44
47
  const query = useQuery(load?.query ?? "", {
45
48
  ...(load?.passPrefill === true && prefill),
@@ -77,6 +80,15 @@ export function ActionFormLoadStatus({ state, screenId, translate, }) {
77
80
  }
78
81
  }
79
82
  }
83
+ function formatTypedFact(entry, type, locale) {
84
+ if (type === "money" && isMoneyValue(entry)) {
85
+ return formatMoneyValue(entry, locale);
86
+ }
87
+ if ((type === "date" || type === "timestamp") && typeof entry === "string") {
88
+ return applyFormatSpec({ format: type, locale }, entry);
89
+ }
90
+ return undefined;
91
+ }
80
92
  function factLine(entry, locale) {
81
93
  if (typeof entry === "number")
82
94
  return entry.toLocaleString(locale);
@@ -92,7 +104,7 @@ export function resolveSuccessFacts(facts, data, translate, locale) {
92
104
  (facts ?? []).forEach((fact, index) => {
93
105
  const value = propertyOf(data, fact.field);
94
106
  const entries = Array.isArray(value) ? value : [value];
95
- const lines = entries.flatMap((entry) => factLine(entry, locale) ?? []);
107
+ const lines = entries.flatMap((entry) => formatTypedFact(entry, fact.type, locale) ?? factLine(entry, locale) ?? []);
96
108
  if (lines.length > 0) {
97
109
  resolved.push({ key: String(index), label: translate(fact.label), lines });
98
110
  }
@@ -109,6 +121,17 @@ function SuccessItemHints({ items, }) {
109
121
  actions: (_jsx(Link, { href: item.link.href, onPress: item.link.onPress, className: "underline", testId: `action-form-success-item-${item.key}-link`, children: item.link.label })),
110
122
  }), children: _jsx(Text, { children: item.label }) }, item.key))) }));
111
123
  }
124
+ /** One line per fact, a list of values as a block; shared by the success box and the preview panel. */
125
+ export function ActionFormFacts({ testIdPrefix = "action-form-success-fact", facts, }) {
126
+ const { Grid, Text } = usePrimitives();
127
+ return facts.map((fact) => {
128
+ const factTestId = `${testIdPrefix}-${fact.key}`;
129
+ if (fact.lines.length === 1) {
130
+ return (_jsxs(Text, { testId: factTestId, children: [fact.label, ": ", fact.lines[0]] }, fact.key));
131
+ }
132
+ return (_jsxs(Grid, { columns: 1, testId: factTestId, children: [_jsxs(Text, { children: [fact.label, ":"] }), positionedLines(fact.lines).map(({ position, line }) => (_jsx(Text, { testId: `${factTestId}-line-${position}`, children: line }, position)))] }, fact.key));
133
+ });
134
+ }
112
135
  export function ActionFormSuccessBanner({ success, }) {
113
136
  const { Banner, Grid, Link, Text } = usePrimitives();
114
137
  const items = success.items ?? [];
@@ -116,13 +139,7 @@ export function ActionFormSuccessBanner({ success, }) {
116
139
  if (items.length > 0 && !hasFactsOrLinks)
117
140
  return _jsx(SuccessItemHints, { items: items });
118
141
  // Text renders inline, so the message and each fact sit in a one-column grid to get their own lines.
119
- const banner = (_jsxs(Banner, { variant: "info", testId: "action-form-success", children: [_jsxs(Grid, { columns: 1, children: [items.length === 0 && _jsx(Text, { testId: "action-form-success-text", children: success.text }), success.facts.map((fact) => {
120
- const factTestId = `action-form-success-fact-${fact.key}`;
121
- if (fact.lines.length === 1) {
122
- return (_jsxs(Text, { testId: factTestId, children: [fact.label, ": ", fact.lines[0]] }, fact.key));
123
- }
124
- return (_jsxs(Grid, { columns: 1, testId: factTestId, children: [_jsxs(Text, { children: [fact.label, ":"] }), positionedLines(fact.lines).map(({ position, line }) => (_jsx(Text, { testId: `${factTestId}-line-${position}`, children: line }, position)))] }, fact.key));
125
- })] }), success.links.map((link) => (_jsx(Link, { href: link.href, onPress: link.onPress, className: "ml-2 underline", testId: `action-form-success-link-${link.key}`, children: link.label }, link.key)))] }));
142
+ const banner = (_jsxs(Banner, { variant: "info", testId: "action-form-success", children: [_jsxs(Grid, { columns: 1, children: [items.length === 0 && _jsx(Text, { testId: "action-form-success-text", children: success.text }), _jsx(ActionFormFacts, { facts: success.facts })] }), success.links.map((link) => (_jsx(Link, { href: link.href, onPress: link.onPress, className: "ml-2 underline", testId: `action-form-success-link-${link.key}`, children: link.label }, link.key)))] }));
126
143
  if (items.length === 0)
127
144
  return banner;
128
145
  return (_jsxs(Grid, { columns: 1, children: [_jsx(SuccessItemHints, { items: items }), banner] }));
@@ -114,6 +114,58 @@ function isEmptyNumericFormValue(value) {
114
114
  return true;
115
115
  return typeof value === "number" && !Number.isFinite(value);
116
116
  }
117
+ // Same wire shape as a writeOnly config field: null removes, a string replaces.
118
+ function secretChangeCommand(secretKey, value, secretScopePayload) {
119
+ if (value === null) {
120
+ return { type: "secrets:write:delete", payload: { key: secretKey, ...secretScopePayload } };
121
+ }
122
+ if (typeof value === "string" && value.trim() !== "") {
123
+ return { type: "secrets:write:set", payload: { key: secretKey, value, ...secretScopePayload } };
124
+ }
125
+ return undefined;
126
+ }
127
+ // One changed form value to its write command; undefined when nothing has to be sent.
128
+ function configChangeCommand({ shortName, value, screen, secretKey, secretScopePayload, }) {
129
+ if (secretKey !== undefined)
130
+ return secretChangeCommand(secretKey, value, secretScopePayload);
131
+ const qualified = screen.configKeys[shortName];
132
+ if (qualified === undefined)
133
+ return undefined;
134
+ const fieldDef = screen.fields[shortName]; // @cast-boundary schema-walk
135
+ const ftype = fieldDef?.type;
136
+ const reset = {
137
+ type: "config:write:reset",
138
+ payload: { key: qualified, scope: screen.scope },
139
+ };
140
+ if (isWriteOnlyTextField(screen.fields[shortName])) {
141
+ // true (untouched/undone) and "" mean keep the stored secret; null removes it.
142
+ if (value === null)
143
+ return reset;
144
+ if (typeof value === "string" && value !== "") {
145
+ return {
146
+ type: "config:write:set",
147
+ payload: { key: qualified, value, scope: screen.scope },
148
+ };
149
+ }
150
+ return undefined;
151
+ }
152
+ // A query-backed select is cleared to "" when its dependent value became
153
+ // invalid. config:write:set would store that as an empty override (the
154
+ // badge shows "Mandant" with no value); reset falls back to the inherited
155
+ // value. set can't do it: deleting the row is irreversible, reset is
156
+ // the high-risk handler.
157
+ if (ftype === "select" && fieldDef?.optionsQuery !== undefined && value === "")
158
+ return reset;
159
+ // Cleared number/money: drop this scope's override instead of storing an empty value.
160
+ const storedValue = ftype === "money" ? unwrapMoneyValue(value) : value;
161
+ if ((ftype === "number" || ftype === "money") && isEmptyNumericFormValue(storedValue)) {
162
+ return reset;
163
+ }
164
+ return {
165
+ type: "config:write:set",
166
+ payload: { key: qualified, value: storedValue, scope: screen.scope },
167
+ };
168
+ }
117
169
  export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
118
170
  const { ConfigCascadeView } = usePrimitives();
119
171
  const t = useTranslation();
@@ -234,80 +286,17 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
234
286
  for (const [shortName, value] of Object.entries(snapshot.changes)) {
235
287
  if (hiddenFieldNames.has(shortName))
236
288
  continue;
237
- const secretKey = secretKeys?.[shortName];
238
- if (secretKey !== undefined) {
239
- // Same wire shape as a writeOnly config field: null removes, a string replaces.
240
- if (value === null) {
241
- commandFieldNames.push(shortName);
242
- commands.push({
243
- type: "secrets:write:delete",
244
- payload: { key: secretKey, ...secretScopePayload },
245
- });
246
- }
247
- else if (typeof value === "string" && value.trim() !== "") {
248
- commandFieldNames.push(shortName);
249
- commands.push({
250
- type: "secrets:write:set",
251
- payload: { key: secretKey, value, ...secretScopePayload },
252
- });
253
- }
254
- continue;
255
- }
256
- const qualified = screen.configKeys[shortName];
257
- if (qualified === undefined)
258
- continue;
259
- const fieldDef = screen.fields[shortName];
260
- const ftype = fieldDef?.type;
261
- if (isWriteOnlyTextField(screen.fields[shortName])) {
262
- // true (untouched/undone) and "" mean keep the stored secret; null removes it.
263
- if (value === null) {
264
- commandFieldNames.push(shortName);
265
- commands.push({
266
- type: "config:write:reset",
267
- payload: { key: qualified, scope: screen.scope },
268
- });
269
- }
270
- else if (typeof value === "string" && value !== "") {
271
- commandFieldNames.push(shortName);
272
- commands.push({
273
- type: "config:write:set",
274
- payload: { key: qualified, value, scope: screen.scope },
275
- });
276
- }
277
- continue;
278
- }
279
- // A query-backed select is cleared to "" when its dependent value became
280
- // invalid. config:write:set would store that as an empty override (the
281
- // badge shows "Mandant" with no value); reset falls back to the inherited
282
- // value. set can't do it: deleting the row is irreversible, reset is
283
- // the high-risk handler.
284
- if (ftype === "select" && fieldDef?.optionsQuery !== undefined && value === "") {
285
- commandFieldNames.push(shortName);
286
- commands.push({
287
- type: "config:write:reset",
288
- payload: { key: qualified, scope: screen.scope },
289
- });
290
- continue;
291
- }
292
- // Cleared number/money: drop this scope's override instead of storing an empty value.
293
- if ((ftype === "number" || ftype === "money") &&
294
- isEmptyNumericFormValue(ftype === "money" ? unwrapMoneyValue(value) : value)) {
295
- commandFieldNames.push(shortName);
296
- commands.push({
297
- type: "config:write:reset",
298
- payload: { key: qualified, scope: screen.scope },
299
- });
289
+ const command = configChangeCommand({
290
+ shortName,
291
+ value,
292
+ screen,
293
+ secretKey: secretKeys?.[shortName],
294
+ secretScopePayload,
295
+ });
296
+ if (command === undefined)
300
297
  continue;
301
- }
302
298
  commandFieldNames.push(shortName);
303
- commands.push({
304
- type: "config:write:set",
305
- payload: {
306
- key: qualified,
307
- value: ftype === "money" ? unwrapMoneyValue(value) : value,
308
- scope: screen.scope,
309
- },
310
- });
299
+ commands.push(command);
311
300
  }
312
301
  if (commands.length === 0) {
313
302
  return { validationBlocked: false, isSuccess: true, data: undefined };
@@ -334,9 +323,7 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
334
323
  dispatcher,
335
324
  synthScreen,
336
325
  secretKeys,
337
- screen.configKeys,
338
- screen.fields,
339
- screen.scope,
326
+ screen,
340
327
  valuesQuery.refetch,
341
328
  cascadeQuery.refetch,
342
329
  secretsQuery.refetch,
@@ -369,22 +356,27 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
369
356
  return undefined;
370
357
  return (value) => buildOptionLabels(effectiveTranslate, (option) => fieldOptionLabelKey(schema.featureName, synthScreen.entity, fieldName, option), [String(value)])[String(value)];
371
358
  };
372
- return (_jsx(RenderEdit, { screen: synthScreen, entity: synthEntity, featureName: schema.featureName, initial: initial, schema: boundsSchema, customSubmit: customSubmit, dirtyFooter: true, validateOnChange: true, ...(screenFillsHeight(screen) && { fillScreenHeight: true }), ...(screen.submitLabel !== undefined && { submitLabel: screen.submitLabel }), ...(translate !== undefined && { translate }), fieldAppendixPlacement: "below-control", fieldAccent: (fieldName) => cascades[fieldName]?.levels.find((level) => level.isActive)?.source ===
373
- CONFIG_SCOPE_SOURCE[screen.scope], markChangedFields: true, ...actionRowsAfterField(screen.actions, effectiveTranslate), ...(screen.fieldDescriptions !== undefined && {
359
+ const compact = screen.compact === true;
360
+ const form = (_jsx(RenderEdit, { screen: synthScreen, entity: synthEntity, featureName: schema.featureName, initial: initial, schema: boundsSchema, customSubmit: customSubmit, dirtyFooter: true, validateOnChange: true, ...(screenFillsHeight(screen) && { fillScreenHeight: true }), ...(screen.submitLabel !== undefined && { submitLabel: screen.submitLabel }), ...(translate !== undefined && { translate }), fieldAppendixPlacement: "below-control", ...(compact && { recordSections: { labelTitles: true } }), ...(!compact && {
361
+ fieldAccent: (fieldName) => cascades[fieldName]?.levels.find((level) => level.isActive)?.source ===
362
+ CONFIG_SCOPE_SOURCE[screen.scope],
363
+ markChangedFields: true,
364
+ }), ...actionRowsAfterField(screen.actions, effectiveTranslate), ...(screen.fieldDescriptions !== undefined && {
374
365
  fieldDescription: (fieldName) => {
375
366
  const key = screen.fieldDescriptions?.[fieldName];
376
367
  return key === undefined ? undefined : effectiveTranslate(key);
377
368
  },
378
369
  }), fieldAppendix: (fieldName) => {
379
370
  const cascade = cascades[fieldName];
380
- if (cascade === undefined)
371
+ if (compact || cascade === undefined)
381
372
  return undefined;
382
373
  const renderValue = cascadeValueRenderer(fieldName);
383
- return (_jsx(ConfigCascadeView, { cascade: cascade, screenScope: screen.scope, qualifiedKey: screen.configKeys[fieldName], required: screen.requiredFields?.includes(fieldName) ?? false, ...(renderValue !== undefined && { renderValue }), ...(!readOnlyFields.has(fieldName) && {
374
+ return (_jsx(ConfigCascadeView, { cascade: cascade, screenScope: screen.scope, qualifiedKey: screen.configKeys[fieldName], compact: true, required: screen.requiredFields?.includes(fieldName) ?? false, ...(renderValue !== undefined && { renderValue }), ...(!readOnlyFields.has(fieldName) && {
384
375
  onReset: async (key, scope) => {
385
376
  await dispatcher.write("config:write:reset", { key, scope });
386
377
  await Promise.allSettled([valuesQuery.refetch?.(), cascadeQuery.refetch?.()]);
387
378
  },
388
379
  }) }));
389
380
  } }));
381
+ return compact ? (_jsx("div", { "data-testid": "config-edit-compact", className: "h-full min-h-0 [&>form>div:first-child]:mx-0 [&>form>div:first-child]:max-w-[940px] [&_.relative>input]:pl-3 [&_.relative>svg.pointer-events-none]:hidden", children: form })) : (form);
390
382
  }
@@ -162,8 +162,8 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
162
162
  const filterFacets = useMemo(() => {
163
163
  const namedFacet = buildNamedFilterFacet(screen.namedFilters, effectiveTranslate, userRoles, screen.namedFilterFacet, facetCounts);
164
164
  return [
165
- ...(namedFacet !== undefined ? [namedFacet] : []),
166
165
  ...buildEntityFilterFacets(mergeReferenceFacetOptions(entityFacetSpecs, entityReferenceFacetOptions), screen.facets, effectiveTranslate, facetCounts),
166
+ ...(namedFacet !== undefined ? [namedFacet] : []),
167
167
  ];
168
168
  }, [
169
169
  entityFacetSpecs,
@@ -2,11 +2,13 @@ import type { ReactNode } from "react";
2
2
  import type { RenderEditAction } from "../components/render-edit-types.ts";
3
3
  import type { usePrimitives } from "../primitives.tsx";
4
4
  import type { ErrorNotice } from "./error-reference.tsx";
5
- export declare function HeaderActionsBar({ actions, Button, Dialog, ActionOverflowMenu, onError, collapseAfterPrimary, compact, preferredPrimaryId, inlineActionIds, PageHeader, overflowTestId, }: {
5
+ export declare function HeaderActionsBar({ actions, Button, Dialog, ActionOverflowMenu, onError, collapseAfterPrimary, compact, preferredPrimaryId, inlineActionIds, menuActionIds, PageHeader, overflowTestId, }: {
6
6
  /** `primaryAction` of the screen: wins over the edit/primary-style precedence. */
7
7
  readonly preferredPrimaryId?: string;
8
8
  /** `inlineActions` of the screen: stay buttons next to the primary instead of the menu. */
9
9
  readonly inlineActionIds?: readonly string[];
10
+ /** `placement: "menu"` actions of the screen: always in the menu, never a button. */
11
+ readonly menuActionIds?: readonly string[];
10
12
  /** Header slot layout: only the primary action stays a button, the rest goes into the menu. */
11
13
  readonly collapseAfterPrimary?: boolean;
12
14
  /** Phone-width shell header: an icon-only primary button, the rest in the shell's overflow menu. */
@@ -9,21 +9,29 @@ import { compactHeaderPrimary, orderPlainHeaderActions, splitHeaderActions, } fr
9
9
  // state for menu items: RenderEditActionButton already owns a per-button
10
10
  // confirm dialog for the always-visible primary action, but a menu item has
11
11
  // no button of its own to carry one.
12
- export function HeaderActionsBar({ actions, Button, Dialog, ActionOverflowMenu, onError, collapseAfterPrimary = false, compact = false, preferredPrimaryId, inlineActionIds, PageHeader, overflowTestId = "kumiko-screen-projection-detail-actions-overflow", }) {
12
+ export function HeaderActionsBar({ actions, Button, Dialog, ActionOverflowMenu, onError, collapseAfterPrimary = false, compact = false, preferredPrimaryId, inlineActionIds, menuActionIds, PageHeader, overflowTestId = "kumiko-screen-projection-detail-actions-overflow", }) {
13
13
  const t = useTranslation();
14
14
  const { toMenuItem, confirmDialog: pendingActionDialog } = useActionMenuItems({
15
15
  Dialog,
16
16
  onError,
17
17
  });
18
18
  if (compact && PageHeader !== undefined) {
19
- const compactPrimary = compactHeaderPrimary(actions, preferredPrimaryId);
19
+ const compactPrimary = compactHeaderPrimary(actions.filter((a) => !menuActionIds?.includes(a.id)), preferredPrimaryId);
20
20
  const overflowActions = actions.filter((a) => a !== compactPrimary?.action);
21
21
  return (_jsxs(_Fragment, { children: [compactPrimary !== undefined && (_jsx(RenderEditActionButton, { action: compactPrimary.action, Button: Button, Dialog: Dialog, iconOnly: compactPrimary.iconOnly, onError: onError }, compactPrimary.action.id)), overflowActions.length > 0 && (_jsx(PageHeader, { overflowItems: overflowActions.map(toMenuItem) })), pendingActionDialog] }));
22
22
  }
23
+ const dangerMenuActions = actions.filter((action) => (collapseAfterPrimary && action.style === "danger") ||
24
+ (ActionOverflowMenu !== undefined && menuActionIds?.includes(action.id) === true));
25
+ const visibleCandidates = actions.filter((action) => !dangerMenuActions.includes(action));
23
26
  const maxPlainButtons = collapseAfterPrimary ? 1 : 2;
24
- if (actions.length <= maxPlainButtons || ActionOverflowMenu === undefined) {
27
+ if (ActionOverflowMenu === undefined ||
28
+ (visibleCandidates.length <= maxPlainButtons && dangerMenuActions.length === 0)) {
25
29
  return (_jsx(_Fragment, { children: orderPlainHeaderActions(actions, preferredPrimaryId).map((action) => (_jsx(RenderEditActionButton, { action: action, Button: Button, Dialog: Dialog, hideIcon: true, onError: onError }, action.id))) }));
26
30
  }
27
- const { buttons, menu } = splitHeaderActions(actions, preferredPrimaryId, inlineActionIds);
31
+ const split = visibleCandidates.length <= maxPlainButtons
32
+ ? { buttons: orderPlainHeaderActions(visibleCandidates, preferredPrimaryId), menu: [] }
33
+ : splitHeaderActions(visibleCandidates, preferredPrimaryId, inlineActionIds);
34
+ const { buttons } = split;
35
+ const menu = [...split.menu, ...dangerMenuActions];
28
36
  return (_jsxs(_Fragment, { children: [buttons.map((action) => (_jsx(RenderEditActionButton, { action: action, Button: Button, Dialog: Dialog, hideIcon: true, onError: onError }, action.id))), menu.length > 0 && (_jsx(ActionOverflowMenu, { label: t("kumiko.list.row-actions.more"), testId: overflowTestId, items: menu.map(toMenuItem) })), pendingActionDialog] }));
29
37
  }
@@ -1,12 +1,18 @@
1
1
  import type { ListBulkAction, RowAction } from "@cosmicdrift/kumiko-framework/ui-types";
2
2
  import type { DataTableBulk, DataTableBulkAction } from "../data-table-bulk-types.ts";
3
3
  import type { Dispatcher, Translate } from "../headless/index.ts";
4
- /** Resolves each bulk action against its writeHandler row action; one that resolves to nothing is dropped. */
4
+ type BulkFormAction = Extract<ListBulkAction, {
5
+ readonly screen: string;
6
+ }>;
7
+ /** Opens the form of a bulk form action with the ids of the selected rows. */
8
+ export type OpenBulkForm = (action: BulkFormAction, ids: readonly string[]) => void;
9
+ /** Resolves each bulk action against its writeHandler row action; one that resolves to nothing is dropped. Form actions need `openBulkForm`. */
5
10
  export declare function buildListBulkActions(options: {
6
11
  readonly bulkActions: readonly ListBulkAction[];
7
12
  readonly rowActions: readonly RowAction[] | undefined;
8
13
  readonly translate: Translate;
9
14
  readonly dispatcher: Dispatcher;
15
+ readonly openBulkForm?: OpenBulkForm;
10
16
  }): readonly DataTableBulkAction[];
11
17
  /** DataTable `bulk` prop of a list screen; undefined without bulk actions or dispatcher. */
12
18
  export declare function useListBulk(options: {
@@ -16,3 +22,4 @@ export declare function useListBulk(options: {
16
22
  readonly dispatcher: Dispatcher | undefined;
17
23
  readonly reload: () => Promise<unknown>;
18
24
  }): DataTableBulk | undefined;
25
+ export {};