@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.
- package/dist/app/action-form-body.d.ts +2 -5
- package/dist/app/action-form-body.js +50 -22
- package/dist/app/action-form-support.d.ts +4 -1
- package/dist/app/action-form-support.js +8 -4
- package/dist/app/client-actions.js +6 -4
- package/dist/app/config-edit-body.js +83 -82
- package/dist/app/entity-list-screen.js +1 -1
- package/dist/app/extension-sections.d.ts +2 -0
- package/dist/app/header-actions-bar.d.ts +3 -1
- package/dist/app/header-actions-bar.js +12 -4
- package/dist/app/locked-screen-header.d.ts +2 -0
- package/dist/app/locked-screen-header.js +8 -1
- package/dist/app/projection-detail-body.js +29 -8
- package/dist/app/projection-detail-guidance.d.ts +2 -1
- package/dist/app/projection-detail-guidance.js +45 -30
- package/dist/app/projection-detail-header-model.d.ts +1 -1
- package/dist/app/projection-detail-header-model.js +14 -6
- package/dist/app/projection-detail-header-region.js +25 -9
- package/dist/app/projection-detail-header.d.ts +2 -0
- package/dist/app/projection-detail-header.js +31 -4
- package/dist/app/projection-detail-navigation.d.ts +4 -0
- package/dist/app/projection-detail-navigation.js +5 -1
- package/dist/app/projection-list-shim.js +1 -0
- package/dist/app/row-actions.d.ts +4 -0
- package/dist/app/row-actions.js +19 -3
- package/dist/app/screen-shared.d.ts +1 -0
- package/dist/app/screen-shared.js +23 -3
- package/dist/app/use-projection-detail-actions.d.ts +16 -1
- package/dist/app/use-projection-detail-actions.js +23 -3
- package/dist/app/use-projection-detail-data.d.ts +2 -0
- package/dist/app/use-projection-detail-data.js +53 -10
- package/dist/app/use-projection-list-data.js +1 -1
- package/dist/card-options.d.ts +2 -0
- package/dist/components/ai-assist-payload.d.ts +2 -0
- package/dist/components/ai-assist-payload.js +8 -0
- package/dist/components/choice-chip-class.d.ts +1 -0
- package/dist/components/choice-chip-class.js +9 -0
- package/dist/components/edit-mounts.d.ts +3 -2
- package/dist/components/edit-mounts.js +2 -2
- package/dist/components/grid-cell-for-field.js +1 -1
- package/dist/components/multi-select-chips.d.ts +10 -0
- package/dist/components/multi-select-chips.js +19 -0
- package/dist/components/narrow-description.d.ts +3 -0
- package/dist/components/narrow-description.js +12 -0
- package/dist/components/related-list-section.d.ts +5 -3
- package/dist/components/related-list-section.js +52 -35
- package/dist/components/related-photo-grid.d.ts +11 -0
- package/dist/components/related-photo-grid.js +54 -0
- package/dist/components/render-edit-action-button.d.ts +2 -2
- package/dist/components/render-edit-field-grid.d.ts +12 -3
- package/dist/components/render-edit-field-grid.js +60 -18
- package/dist/components/render-edit-fields-section.js +45 -11
- package/dist/components/render-edit-header-actions.d.ts +2 -1
- package/dist/components/render-edit-header-actions.js +18 -1
- package/dist/components/render-edit-layout.js +5 -3
- package/dist/components/render-edit-logic.js +1 -0
- package/dist/components/render-edit-section-kinds.js +59 -10
- package/dist/components/render-edit-titles.js +1 -1
- package/dist/components/render-edit-types.d.ts +22 -1
- package/dist/components/render-field-ai-assist.d.ts +13 -0
- package/dist/components/render-field-ai-assist.js +90 -0
- package/dist/components/render-field-choice-inputs.js +4 -0
- package/dist/components/render-field-control.d.ts +1 -1
- package/dist/components/render-field-control.js +19 -9
- package/dist/components/render-field-value-chips.d.ts +9 -0
- package/dist/components/render-field-value-chips.js +47 -0
- package/dist/components/render-field-write-only.js +12 -4
- package/dist/components/render-list-hint-columns.d.ts +2 -0
- package/dist/components/render-list-hint-columns.js +43 -5
- package/dist/components/render-list-reference-columns.js +2 -4
- package/dist/components/render-list-row-tone.d.ts +2 -0
- package/dist/components/render-list-row-tone.js +6 -0
- package/dist/components/render-list-table-props.d.ts +13 -2
- package/dist/components/render-list-table-props.js +9 -3
- package/dist/components/render-list-types.d.ts +4 -0
- package/dist/components/render-list.js +12 -4
- package/dist/components/use-render-edit-sections.js +5 -1
- package/dist/components/use-render-list-columns.js +3 -3
- package/dist/components/write-form-registry.d.ts +13 -0
- package/dist/components/write-form-registry.js +6 -0
- package/dist/components/write-form-section.d.ts +5 -1
- package/dist/components/write-form-section.js +55 -16
- package/dist/headless/form/form-controller.d.ts +1 -0
- package/dist/headless/form/form-controller.js +1 -1
- package/dist/headless/format/index.d.ts +1 -0
- package/dist/headless/format/index.js +21 -0
- package/dist/headless/format/phone.d.ts +1 -0
- package/dist/headless/format/phone.js +8 -0
- package/dist/headless/format/relative-time.d.ts +15 -0
- package/dist/headless/format/relative-time.js +63 -0
- package/dist/headless/format/safe-locale.d.ts +1 -0
- package/dist/headless/format/safe-locale.js +13 -0
- package/dist/headless/index.d.ts +2 -2
- package/dist/headless/index.js +2 -2
- package/dist/headless/view-model/edit.d.ts +3 -2
- package/dist/headless/view-model/edit.js +162 -36
- package/dist/headless/view-model/field-text.d.ts +9 -0
- package/dist/headless/view-model/field-text.js +19 -0
- package/dist/headless/view-model/index.d.ts +1 -0
- package/dist/headless/view-model/index.js +1 -0
- package/dist/headless/view-model/list.js +6 -0
- package/dist/headless/view-model/types.d.ts +76 -5
- package/dist/hooks/use-list-table.js +11 -6
- package/dist/i18n-defaults.js +9 -2
- package/dist/index.d.ts +1 -1
- package/dist/primitives-record-guidance.d.ts +32 -1
- package/dist/primitives-share-types.d.ts +82 -0
- package/dist/primitives-share-types.js +1 -0
- package/dist/primitives.d.ts +44 -86
- package/dist/web/app/bold-markup.d.ts +3 -0
- package/dist/web/app/bold-markup.js +14 -0
- package/dist/web/app/dashboard-body.js +8 -3
- package/dist/web/app/dashboard-list-panel.js +8 -4
- package/dist/web/app/dashboard-panel-columns.d.ts +9 -0
- package/dist/web/app/dashboard-panel-columns.js +14 -0
- package/dist/web/app/dashboard-panels.js +31 -3
- package/dist/web/app/dashboard-shared.d.ts +3 -1
- package/dist/web/app/dashboard-shared.js +4 -4
- package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -1
- package/dist/web/app/dashboard-stat-group-panel.js +24 -3
- package/dist/web/app/dashboard-text-panel.d.ts +1 -0
- package/dist/web/app/dashboard-text-panel.js +18 -11
- package/dist/web/app/relative-time.d.ts +0 -5
- package/dist/web/app/relative-time.js +11 -21
- package/dist/web/components/config-cascade.d.ts +2 -1
- package/dist/web/components/config-cascade.js +16 -4
- package/dist/web/drawn-icons.js +2 -1
- package/dist/web/layout/header-action-pinned.d.ts +4 -2
- package/dist/web/layout/header-action-pinned.js +13 -4
- package/dist/web/layout/header-overflow-menu.d.ts +2 -0
- package/dist/web/layout/header-overflow-menu.js +2 -0
- package/dist/web/layout/notification-bell.js +12 -3
- package/dist/web/layout/page-header-slot.d.ts +2 -0
- package/dist/web/layout/page-header-slot.js +4 -0
- package/dist/web/layout/screen-focus.js +4 -1
- package/dist/web/layout/shell-header.js +13 -5
- package/dist/web/primitives/banner.js +24 -8
- package/dist/web/primitives/card.js +5 -3
- package/dist/web/primitives/combobox.js +2 -2
- package/dist/web/primitives/data-table/actions-column.js +1 -1
- package/dist/web/primitives/data-table/card-body.d.ts +1 -1
- package/dist/web/primitives/data-table/card-body.js +37 -14
- package/dist/web/primitives/data-table/card-frame.d.ts +2 -0
- package/dist/web/primitives/data-table/card-frame.js +3 -0
- package/dist/web/primitives/data-table/card-row.js +34 -10
- package/dist/web/primitives/data-table/card-sort-select.js +1 -1
- package/dist/web/primitives/data-table/card-view.js +1 -1
- package/dist/web/primitives/data-table/data-cell-props.d.ts +4 -1
- package/dist/web/primitives/data-table/data-cell-props.js +3 -0
- package/dist/web/primitives/data-table/density.d.ts +3 -1
- package/dist/web/primitives/data-table/density.js +11 -4
- package/dist/web/primitives/data-table/row-click-guard.d.ts +2 -0
- package/dist/web/primitives/data-table/row-click-guard.js +19 -0
- package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
- package/dist/web/primitives/data-table/row-render-parts.js +3 -5
- package/dist/web/primitives/data-table/sort-options-select.js +2 -2
- package/dist/web/primitives/data-table/sortable-header.js +4 -4
- package/dist/web/primitives/data-table/table-body.js +3 -1
- package/dist/web/primitives/data-table/table-chrome.js +1 -3
- package/dist/web/primitives/data-table/table-content.js +6 -6
- package/dist/web/primitives/data-table/table-data-cell.js +31 -17
- package/dist/web/primitives/data-table/table-header-row.js +1 -1
- package/dist/web/primitives/data-table/table-view.js +1 -1
- package/dist/web/primitives/data-table/toolbar.js +6 -7
- package/dist/web/primitives/data-table/use-data-table-state.d.ts +6 -1
- package/dist/web/primitives/data-table/use-data-table-state.js +12 -2
- package/dist/web/primitives/data-table-cell.d.ts +17 -3
- package/dist/web/primitives/data-table-cell.js +130 -36
- package/dist/web/primitives/data-table.js +1 -1
- package/dist/web/primitives/default-form.d.ts +1 -1
- package/dist/web/primitives/default-form.js +15 -11
- package/dist/web/primitives/drawer.js +2 -3
- package/dist/web/primitives/facet-filter.d.ts +1 -1
- package/dist/web/primitives/facet-filter.js +2 -5
- package/dist/web/primitives/facet-search-filter.js +1 -1
- package/dist/web/primitives/facet-trigger-label.d.ts +1 -4
- package/dist/web/primitives/facet-trigger-label.js +4 -7
- package/dist/web/primitives/field.js +15 -8
- package/dist/web/primitives/form-footer-parts.js +6 -3
- package/dist/web/primitives/form.js +6 -8
- package/dist/web/primitives/index.js +4 -0
- package/dist/web/primitives/inline-suffix.d.ts +2 -0
- package/dist/web/primitives/inline-suffix.js +5 -0
- package/dist/web/primitives/input-choice-kinds.js +12 -2
- package/dist/web/primitives/input-number-kinds.js +2 -2
- package/dist/web/primitives/input-text-kinds.js +1 -1
- package/dist/web/primitives/layout-elements.d.ts +4 -4
- package/dist/web/primitives/layout-elements.js +50 -13
- package/dist/web/primitives/layout.d.ts +1 -1
- package/dist/web/primitives/layout.js +1 -1
- package/dist/web/primitives/locale-number.d.ts +0 -1
- package/dist/web/primitives/locale-number.js +1 -13
- package/dist/web/primitives/money-input.js +10 -8
- package/dist/web/primitives/narrow-pinned-footer.js +7 -3
- package/dist/web/primitives/number-input.d.ts +2 -1
- package/dist/web/primitives/number-input.js +11 -5
- package/dist/web/primitives/page-header.d.ts +1 -1
- package/dist/web/primitives/page-header.js +8 -1
- package/dist/web/primitives/pager.js +12 -21
- package/dist/web/primitives/photo-grid.d.ts +3 -0
- package/dist/web/primitives/photo-grid.js +6 -0
- package/dist/web/primitives/record-steps.d.ts +1 -1
- package/dist/web/primitives/record-steps.js +7 -16
- package/dist/web/primitives/record-summary.d.ts +1 -1
- package/dist/web/primitives/record-summary.js +8 -3
- package/dist/web/primitives/row-actions.js +38 -24
- package/dist/web/primitives/step-list.d.ts +3 -0
- package/dist/web/primitives/step-list.js +11 -0
- package/dist/web/primitives/use-container-narrow.d.ts +12 -0
- package/dist/web/primitives/use-container-narrow.js +42 -0
- package/dist/web/ui/input.js +1 -1
- package/dist/web/ui/textarea.js +1 -1
- package/dist/web/widgets/dashboard-list-cards.js +6 -3
- package/dist/web/widgets/dashboard-list.d.ts +6 -1
- package/dist/web/widgets/dashboard-list.js +12 -7
- package/dist/web/widgets/drawer-panel-class.js +1 -1
- package/dist/web/widgets/progress-list.js +1 -1
- package/dist/web/widgets/stat-box-cell.js +1 -1
- package/package.json +5 -5
- package/src/changes.json +105 -0
- package/src/web/styles.css +3 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ActionFormScreenDefinition, RowActionDrawer, ToolbarAction } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
|
-
import type
|
|
3
|
+
import { type Translate } from "../headless/index.ts";
|
|
4
4
|
import type { FeatureSchema } from "./feature-schema.ts";
|
|
5
5
|
type DrawerLikeAction = Extract<ToolbarAction, {
|
|
6
6
|
kind: "drawer";
|
|
@@ -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,
|
|
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;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { AiAssistPayloadProvider } from "../components/ai-assist-payload.js";
|
|
3
4
|
import { withDerivedValues } from "../components/form-derivation-patch.js";
|
|
4
5
|
import { RenderEdit } from "../components/render-edit.js";
|
|
5
6
|
import { useDispatcher } from "../context/dispatcher-context.js";
|
|
6
7
|
import { rendererWarn } from "../dev-console.js";
|
|
8
|
+
import { resolveFieldText, } from "../headless/index.js";
|
|
7
9
|
import { useLocale, useTranslation } from "../i18n.js";
|
|
8
10
|
import { InsideDrawerProvider, useInsideDrawer } from "../inside-drawer.js";
|
|
9
11
|
import { PageHeaderSlotAvailableProvider } from "../page-header-slot.js";
|
|
10
12
|
import { usePrimitives } from "../primitives.js";
|
|
11
13
|
import { screenFillsHeight } from "../screen-fills-height.js";
|
|
14
|
+
import { statusToneForOptionTone } from "../status-tone.js";
|
|
12
15
|
import { actionFormSubmittableFields, synthesizeActionFormEntity, synthesizeActionFormScreen, } from "./action-form-shim.js";
|
|
13
|
-
import { ActionFormLoadStatus, ActionFormSuccessBanner, isSecretFormField, resolveActionFormRecordId, resolveSuccessFacts, useActionFormLoad, } from "./action-form-support.js";
|
|
16
|
+
import { ActionFormLoadStatus, ActionFormSuccessBanner, DEFAULT_LOAD_ID_PARAM, isSecretFormField, resolveActionFormRecordId, resolveSuccessFacts, useActionFormLoad, } from "./action-form-support.js";
|
|
14
17
|
import { useAppFeatures } from "./app-features-context.js";
|
|
15
18
|
import { mergeSearchParamsIntoInitial, tenantCurrencyMoneyFieldNames, useMoneyCurrencyOverrides, } from "./entity-edit-prefill.js";
|
|
16
19
|
import { hiddenRequiredFieldsFilled, layoutFieldNames } from "./layout-fields.js";
|
|
@@ -88,7 +91,7 @@ export function DrawerHost({ schema, drawerAction, drawerScreen, drawerInitialVa
|
|
|
88
91
|
}), onSuccess: () => {
|
|
89
92
|
setHasUnsavedInput(false);
|
|
90
93
|
onSuccess();
|
|
91
|
-
},
|
|
94
|
+
}, onDirtyChange: setHasUnsavedInput, submitLabelFallback: drawerAction.label })) }) }) }), _jsx(Dialog, { open: confirmDiscardOpen, onOpenChange: setConfirmDiscardOpen, title: t("kumiko.drawer.discard.title"), description: t("kumiko.drawer.discard.body"), confirmLabel: t("kumiko.drawer.discard.confirm"), cancelLabel: t("kumiko.drawer.discard.cancel"), variant: "danger", initialFocus: "cancel", onConfirm: closeAndReset, testId: "drawer-discard-dialog" })] }));
|
|
92
95
|
}
|
|
93
96
|
function declaresSuccessContent(screen) {
|
|
94
97
|
return ((screen.successLinks?.length ?? 0) > 0 ||
|
|
@@ -111,13 +114,13 @@ function buildSuccessState(text, screen, resultData, context) {
|
|
|
111
114
|
// to entityEdit, only the submit path switches from the CRUD verb to the
|
|
112
115
|
// author-declared handler QN + payloadMode="values" (send all form values
|
|
113
116
|
// instead of only the changes).
|
|
114
|
-
export function ActionFormBody({ schema, screen, translate, entityId, initialOverrides, onSuccess,
|
|
117
|
+
export function ActionFormBody({ schema, screen, translate, entityId, initialOverrides, onSuccess, onDirtyChange, submitLabelFallback, }) {
|
|
115
118
|
const nav = useNav();
|
|
116
119
|
const appFeatures = useAppFeatures();
|
|
117
120
|
const insideDrawer = useInsideDrawer();
|
|
118
121
|
const locale = useLocale().locale();
|
|
119
|
-
const { Banner } = usePrimitives();
|
|
120
|
-
// Unused when drawer-hosted — onSuccess
|
|
122
|
+
const { Banner, StatusBadge } = usePrimitives();
|
|
123
|
+
// Unused when drawer-hosted — onSuccess wins below first.
|
|
121
124
|
const returnTarget = useReturnTarget(screen.id);
|
|
122
125
|
const submittableFields = useMemo(() => actionFormSubmittableFields(screen), [screen]);
|
|
123
126
|
const synthEntity = useMemo(() => synthesizeActionFormEntity(submittableFields), [submittableFields]);
|
|
@@ -135,14 +138,22 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
|
|
|
135
138
|
const loadableFieldNames = useMemo(() => Object.entries(submittableFields)
|
|
136
139
|
.filter(([, field]) => !isSecretFormField(field))
|
|
137
140
|
.map(([name]) => name), [submittableFields]);
|
|
138
|
-
const
|
|
141
|
+
const loadRecordId = screen.load !== undefined
|
|
139
142
|
? resolveActionFormRecordId({
|
|
140
143
|
routeEntityId: entityId,
|
|
141
144
|
drawerOverrides: initialOverrides,
|
|
142
145
|
searchParams: nav.searchParams,
|
|
143
146
|
})
|
|
144
|
-
: undefined
|
|
147
|
+
: undefined;
|
|
148
|
+
const loadState = useActionFormLoad(screen.load, loadRecordId, loadableFieldNames, screen.summary?.paramsFromLoad, initialOverrides);
|
|
149
|
+
// What an aiAssist query gets besides its chip params: the same context the form loads with.
|
|
150
|
+
const aiAssistPayload = useMemo(() => screen.load === undefined
|
|
151
|
+
? (initialOverrides ?? {})
|
|
152
|
+
: screen.load.singleton === true
|
|
153
|
+
? {}
|
|
154
|
+
: { [screen.load.idParam ?? DEFAULT_LOAD_ID_PARAM]: loadRecordId }, [screen.load, initialOverrides, loadRecordId]);
|
|
145
155
|
const loadedValues = loadState?.status === "ready" ? loadState.values : undefined;
|
|
156
|
+
const summaryLoadValues = loadState?.status === "ready" ? loadState.summaryValues : undefined;
|
|
146
157
|
const refetchLoadedValues = loadState?.status === "ready" ? loadState.refetch : undefined;
|
|
147
158
|
const initial = useMemo(() => {
|
|
148
159
|
// With `load` the loaded record is the only source of values: a crafted link
|
|
@@ -177,7 +188,7 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
|
|
|
177
188
|
const derivedInitial = useMemo(() => withDerivedValues(initial, screen.derive !== undefined ? screen : undefined), [initial, screen]);
|
|
178
189
|
const t = useTranslation();
|
|
179
190
|
const effectiveTranslate = translate ?? t;
|
|
180
|
-
const summary = useMemo(() => resolveActionFormSummary(screen.summary, initialOverrides, effectiveTranslate, locale), [screen.summary, initialOverrides, effectiveTranslate, locale]);
|
|
191
|
+
const summary = useMemo(() => resolveActionFormSummary(screen.summary, { ...summaryLoadValues, ...initialOverrides }, effectiveTranslate, locale), [screen.summary, summaryLoadValues, initialOverrides, effectiveTranslate, locale]);
|
|
181
192
|
const dispatcher = useDispatcher();
|
|
182
193
|
const [success, setSuccess] = useState(undefined);
|
|
183
194
|
// Bumped after a successful submit with resetOnSuccess: remounts RenderEdit, which
|
|
@@ -271,15 +282,16 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
|
|
|
271
282
|
// `false` switches the button off explicitly (single-action screens where
|
|
272
283
|
// cancel would just be submit-without-sending).
|
|
273
284
|
// returnTo wins over the declared target when both are present.
|
|
285
|
+
// A drawer closes through its × / Esc (which confirms unsaved input), so its footer has no Cancel.
|
|
274
286
|
const handleCancel = useMemo(() => {
|
|
275
|
-
if (
|
|
276
|
-
return
|
|
287
|
+
if (insideDrawer)
|
|
288
|
+
return undefined;
|
|
277
289
|
const target = screen.cancelTarget ??
|
|
278
290
|
(screen.redirect !== undefined ? redirectScreenTarget(screen.redirect) : undefined);
|
|
279
291
|
if (target === undefined || target === false)
|
|
280
292
|
return undefined;
|
|
281
293
|
return () => navigateToReturnOr(nav, returnTarget, () => nav.navigate({ screenId: lastSegment(target) }));
|
|
282
|
-
}, [nav, screen.redirect, screen.cancelTarget,
|
|
294
|
+
}, [nav, screen.redirect, screen.cancelTarget, insideDrawer, returnTarget]);
|
|
283
295
|
// Rendering the form before a tenant-declared currency lands would show the
|
|
284
296
|
// fallback and, on a fast click, submit it — hold instead.
|
|
285
297
|
if (currencyLoading) {
|
|
@@ -291,15 +303,31 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
|
|
|
291
303
|
if (loadState !== undefined && loadState.status !== "ready") {
|
|
292
304
|
return (_jsx(ActionFormLoadStatus, { state: loadState, screenId: screen.id, translate: effectiveTranslate }));
|
|
293
305
|
}
|
|
294
|
-
return (_jsx(RenderEdit, { screen: synthScreen, entity: synthEntity, featureName: schema.featureName, initial: derivedInitial, ...(screen.derive !== undefined && { formDerivation: screen }), actionFormScreenQn: qualifyScreenId(schema.featureName, screen.id),
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
306
|
+
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),
|
|
307
|
+
// Extension sections in the actionForm see the initial form values
|
|
308
|
+
// (incl. searchParams prefill, e.g. ?incidentId=...) as initialValues;
|
|
309
|
+
// unlike entityEdit there is no record they could draw context from.
|
|
310
|
+
extensionInitialValues: initial, ...(screen.submitPrefilled === true && {
|
|
311
|
+
submitWithoutChanges: hiddenRequiredFieldsFilled(synthScreen, screen.fields, initial),
|
|
312
|
+
}), ...((success !== undefined || screen.infoBand !== undefined) && {
|
|
313
|
+
leadContent: (_jsxs(_Fragment, { children: [screen.infoBand !== undefined && (_jsx(Banner, { variant: "assist", icon: "sparkles", density: "compact", testId: "kumiko-screen-action-form-info-band", children: effectiveTranslate(screen.infoBand) })), success !== undefined && _jsx(ActionFormSuccessBanner, { success: success })] })),
|
|
314
|
+
}), ...(screen.fieldBadges !== undefined &&
|
|
315
|
+
StatusBadge !== undefined && {
|
|
316
|
+
labelAppendix: (fieldName) => {
|
|
317
|
+
const badge = screen.fieldBadges?.[fieldName];
|
|
318
|
+
if (badge === undefined)
|
|
319
|
+
return undefined;
|
|
320
|
+
return (_jsx(StatusBadge, { value: effectiveTranslate(badge.label), tone: statusToneForOptionTone(badge.tone) ?? "muted", testId: `field-badge-${fieldName}` }));
|
|
321
|
+
},
|
|
322
|
+
}), writeCommand: screen.handler, payloadMode: "values", onSubmit: handleSubmitted, ...(handleCancel !== undefined && { onCancel: handleCancel }), onDirtyChange: handleDirtyChange, ...((insideDrawer || screenFillsHeight(screen)) && { fillScreenHeight: true }), ...((screen.submitLabel ?? submitLabelFallback) !== undefined && {
|
|
323
|
+
submitLabel: screen.submitLabel ?? submitLabelFallback,
|
|
324
|
+
}), ...(screen.submitStyle !== undefined && { submitVariant: screen.submitStyle }), ...(screen.footerActions !== undefined && { footerActions: screen.footerActions }), formErrorOnTop: true, ...(screen.fieldDescriptions !== undefined && {
|
|
325
|
+
fieldDescription: (fieldName, values) => {
|
|
326
|
+
const ref = screen.fieldDescriptions?.[fieldName];
|
|
327
|
+
if (ref === undefined)
|
|
328
|
+
return undefined;
|
|
329
|
+
const { text, complete } = resolveFieldText(ref, values, effectiveTranslate);
|
|
330
|
+
return complete ? text : undefined;
|
|
331
|
+
},
|
|
332
|
+
}), ...(summary !== undefined && { summary }), ...(translate !== undefined && { translate }) }, formEpoch) }));
|
|
305
333
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ActionFormLoad, ActionFormSuccessFact } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import type { DispatcherError, Translate } from "../headless/index.ts";
|
|
4
|
+
export declare const DEFAULT_LOAD_ID_PARAM = "id";
|
|
4
5
|
/** Record id of a `load` form: the route path id, else the drawer prefill `id`
|
|
5
6
|
* (the clicked row), else the URL `id` param. Only the id is read from these
|
|
6
7
|
* sources, never another value. */
|
|
@@ -21,6 +22,8 @@ export type ActionFormLoadState = {
|
|
|
21
22
|
} | {
|
|
22
23
|
readonly status: "ready";
|
|
23
24
|
readonly values: Readonly<Record<string, unknown>>;
|
|
25
|
+
/** `summary.paramsFromLoad` picked from the raw load result. */
|
|
26
|
+
readonly summaryValues: Readonly<Record<string, unknown>>;
|
|
24
27
|
readonly refetch: () => Promise<void>;
|
|
25
28
|
};
|
|
26
29
|
/** A sensitive, writeOnly or password field never takes a value from a loaded
|
|
@@ -28,7 +31,7 @@ export type ActionFormLoadState = {
|
|
|
28
31
|
export declare function isSecretFormField(field: unknown): boolean;
|
|
29
32
|
/** Loads the initial values of an actionForm declaring `load`; undefined for a
|
|
30
33
|
* form without `load`. */
|
|
31
|
-
export declare function useActionFormLoad(load: ActionFormLoad | undefined, recordId: string | undefined, fieldNames: readonly string[]): ActionFormLoadState | undefined;
|
|
34
|
+
export declare function useActionFormLoad(load: ActionFormLoad | undefined, recordId: string | undefined, fieldNames: readonly string[], summaryFieldNames?: readonly string[], prefill?: Readonly<Record<string, unknown>>): ActionFormLoadState | undefined;
|
|
32
35
|
/** Banner for every `load` state that is not "ready". */
|
|
33
36
|
export declare function ActionFormLoadStatus({ state, screenId, translate, }: {
|
|
34
37
|
readonly state: Exclude<ActionFormLoadState, {
|
|
@@ -5,7 +5,7 @@ import { useQuery } from "../hooks/use-query.js";
|
|
|
5
5
|
import { usePrimitives } from "../primitives.js";
|
|
6
6
|
import { QueryLoadingBanner } from "./query-state-banners.js";
|
|
7
7
|
import { dispatcherErrorText } from "./write-failed-error.js";
|
|
8
|
-
const DEFAULT_LOAD_ID_PARAM = "id";
|
|
8
|
+
export const DEFAULT_LOAD_ID_PARAM = "id";
|
|
9
9
|
function nonEmptyId(value) {
|
|
10
10
|
if (typeof value === "string" && value !== "")
|
|
11
11
|
return value;
|
|
@@ -39,10 +39,14 @@ function pickDeclaredFields(record, fieldNames) {
|
|
|
39
39
|
}
|
|
40
40
|
/** Loads the initial values of an actionForm declaring `load`; undefined for a
|
|
41
41
|
* form without `load`. */
|
|
42
|
-
export function useActionFormLoad(load, recordId, fieldNames) {
|
|
42
|
+
export function useActionFormLoad(load, recordId, fieldNames, summaryFieldNames = [], prefill) {
|
|
43
43
|
const isSingleton = load?.singleton === true;
|
|
44
|
-
const query = useQuery(load?.query ?? "",
|
|
44
|
+
const query = useQuery(load?.query ?? "", {
|
|
45
|
+
...(load?.passPrefill === true && prefill),
|
|
46
|
+
...(isSingleton ? {} : { [load?.idParam ?? DEFAULT_LOAD_ID_PARAM]: recordId }),
|
|
47
|
+
}, { enabled: load !== undefined && (isSingleton || recordId !== undefined) });
|
|
45
48
|
const values = useMemo(() => pickDeclaredFields(query.data, fieldNames), [query.data, fieldNames]);
|
|
49
|
+
const summaryValues = useMemo(() => pickDeclaredFields(query.data, summaryFieldNames), [query.data, summaryFieldNames]);
|
|
46
50
|
if (load === undefined)
|
|
47
51
|
return undefined;
|
|
48
52
|
if (!isSingleton && recordId === undefined)
|
|
@@ -53,7 +57,7 @@ export function useActionFormLoad(load, recordId, fieldNames) {
|
|
|
53
57
|
return { status: "loading" };
|
|
54
58
|
if (query.data === null)
|
|
55
59
|
return { status: "missing-record" };
|
|
56
|
-
return { status: "ready", values, refetch: query.refetch };
|
|
60
|
+
return { status: "ready", values, summaryValues, refetch: query.refetch };
|
|
57
61
|
}
|
|
58
62
|
/** Banner for every `load` state that is not "ready". */
|
|
59
63
|
export function ActionFormLoadStatus({ state, screenId, translate, }) {
|
|
@@ -52,9 +52,11 @@ export async function runClientAction(options) {
|
|
|
52
52
|
}
|
|
53
53
|
if (!outcome.ok)
|
|
54
54
|
return fail(translate(outcome.message));
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
if (action.successMessage !== false) {
|
|
56
|
+
notify?.({
|
|
57
|
+
tone: "success",
|
|
58
|
+
text: translate(action.successMessage ?? "kumiko.clientAction.success"),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
59
61
|
return true;
|
|
60
62
|
}
|
|
@@ -96,6 +96,12 @@ function actionRowsAfterField(actions, translate) {
|
|
|
96
96
|
};
|
|
97
97
|
return { rowAfterField };
|
|
98
98
|
}
|
|
99
|
+
// A read-only field shows its value; resetting an override from its cascade would change it anyway.
|
|
100
|
+
function readOnlyLayoutFieldNames(screen) {
|
|
101
|
+
return new Set(layoutEditFields(screen)
|
|
102
|
+
.filter((spec) => spec.readOnly === true)
|
|
103
|
+
.map((spec) => spec.field));
|
|
104
|
+
}
|
|
99
105
|
// A field hidden by its `visible` condition (a provider's settings while another
|
|
100
106
|
// provider is picked) is not saved: the form saves what it shows.
|
|
101
107
|
function hiddenLayoutFieldNames(screen, values) {
|
|
@@ -108,6 +114,58 @@ function isEmptyNumericFormValue(value) {
|
|
|
108
114
|
return true;
|
|
109
115
|
return typeof value === "number" && !Number.isFinite(value);
|
|
110
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
|
+
}
|
|
111
169
|
export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
|
|
112
170
|
const { ConfigCascadeView } = usePrimitives();
|
|
113
171
|
const t = useTranslation();
|
|
@@ -196,6 +254,7 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
|
|
|
196
254
|
screen.configKeys,
|
|
197
255
|
screen.scope,
|
|
198
256
|
]);
|
|
257
|
+
const readOnlyFields = useMemo(() => readOnlyLayoutFieldNames(synthScreen), [synthScreen]);
|
|
199
258
|
// Cascade lookup: qualifiedKey -> ConfigCascade for the cascade display
|
|
200
259
|
// under each field. Defensive `levels` shape check so foreign query mocks
|
|
201
260
|
// (e.g. configEdit unit tests that only mock `config:query:values`) do not
|
|
@@ -227,80 +286,17 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
|
|
|
227
286
|
for (const [shortName, value] of Object.entries(snapshot.changes)) {
|
|
228
287
|
if (hiddenFieldNames.has(shortName))
|
|
229
288
|
continue;
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
else if (typeof value === "string" && value.trim() !== "") {
|
|
241
|
-
commandFieldNames.push(shortName);
|
|
242
|
-
commands.push({
|
|
243
|
-
type: "secrets:write:set",
|
|
244
|
-
payload: { key: secretKey, value, ...secretScopePayload },
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
continue;
|
|
248
|
-
}
|
|
249
|
-
const qualified = screen.configKeys[shortName];
|
|
250
|
-
if (qualified === undefined)
|
|
251
|
-
continue;
|
|
252
|
-
const fieldDef = screen.fields[shortName];
|
|
253
|
-
const ftype = fieldDef?.type;
|
|
254
|
-
if (isWriteOnlyTextField(screen.fields[shortName])) {
|
|
255
|
-
// true (untouched/undone) and "" mean keep the stored secret; null removes it.
|
|
256
|
-
if (value === null) {
|
|
257
|
-
commandFieldNames.push(shortName);
|
|
258
|
-
commands.push({
|
|
259
|
-
type: "config:write:reset",
|
|
260
|
-
payload: { key: qualified, scope: screen.scope },
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
else if (typeof value === "string" && value !== "") {
|
|
264
|
-
commandFieldNames.push(shortName);
|
|
265
|
-
commands.push({
|
|
266
|
-
type: "config:write:set",
|
|
267
|
-
payload: { key: qualified, value, scope: screen.scope },
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
272
|
-
// A query-backed select is cleared to "" when its dependent value became
|
|
273
|
-
// invalid. config:write:set would store that as an empty override (the
|
|
274
|
-
// badge shows "Mandant" with no value); reset falls back to the inherited
|
|
275
|
-
// value. set can't do it: deleting the row is irreversible, reset is
|
|
276
|
-
// the high-risk handler.
|
|
277
|
-
if (ftype === "select" && fieldDef?.optionsQuery !== undefined && value === "") {
|
|
278
|
-
commandFieldNames.push(shortName);
|
|
279
|
-
commands.push({
|
|
280
|
-
type: "config:write:reset",
|
|
281
|
-
payload: { key: qualified, scope: screen.scope },
|
|
282
|
-
});
|
|
283
|
-
continue;
|
|
284
|
-
}
|
|
285
|
-
// Cleared number/money: drop this scope's override instead of storing an empty value.
|
|
286
|
-
if ((ftype === "number" || ftype === "money") &&
|
|
287
|
-
isEmptyNumericFormValue(ftype === "money" ? unwrapMoneyValue(value) : value)) {
|
|
288
|
-
commandFieldNames.push(shortName);
|
|
289
|
-
commands.push({
|
|
290
|
-
type: "config:write:reset",
|
|
291
|
-
payload: { key: qualified, scope: screen.scope },
|
|
292
|
-
});
|
|
289
|
+
const command = configChangeCommand({
|
|
290
|
+
shortName,
|
|
291
|
+
value,
|
|
292
|
+
screen,
|
|
293
|
+
secretKey: secretKeys?.[shortName],
|
|
294
|
+
secretScopePayload,
|
|
295
|
+
});
|
|
296
|
+
if (command === undefined)
|
|
293
297
|
continue;
|
|
294
|
-
}
|
|
295
298
|
commandFieldNames.push(shortName);
|
|
296
|
-
commands.push(
|
|
297
|
-
type: "config:write:set",
|
|
298
|
-
payload: {
|
|
299
|
-
key: qualified,
|
|
300
|
-
value: ftype === "money" ? unwrapMoneyValue(value) : value,
|
|
301
|
-
scope: screen.scope,
|
|
302
|
-
},
|
|
303
|
-
});
|
|
299
|
+
commands.push(command);
|
|
304
300
|
}
|
|
305
301
|
if (commands.length === 0) {
|
|
306
302
|
return { validationBlocked: false, isSuccess: true, data: undefined };
|
|
@@ -327,9 +323,7 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
|
|
|
327
323
|
dispatcher,
|
|
328
324
|
synthScreen,
|
|
329
325
|
secretKeys,
|
|
330
|
-
screen
|
|
331
|
-
screen.fields,
|
|
332
|
-
screen.scope,
|
|
326
|
+
screen,
|
|
333
327
|
valuesQuery.refetch,
|
|
334
328
|
cascadeQuery.refetch,
|
|
335
329
|
secretsQuery.refetch,
|
|
@@ -362,20 +356,27 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
|
|
|
362
356
|
return undefined;
|
|
363
357
|
return (value) => buildOptionLabels(effectiveTranslate, (option) => fieldOptionLabelKey(schema.featureName, synthScreen.entity, fieldName, option), [String(value)])[String(value)];
|
|
364
358
|
};
|
|
365
|
-
|
|
366
|
-
|
|
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 && {
|
|
367
365
|
fieldDescription: (fieldName) => {
|
|
368
366
|
const key = screen.fieldDescriptions?.[fieldName];
|
|
369
367
|
return key === undefined ? undefined : effectiveTranslate(key);
|
|
370
368
|
},
|
|
371
369
|
}), fieldAppendix: (fieldName) => {
|
|
372
370
|
const cascade = cascades[fieldName];
|
|
373
|
-
if (cascade === undefined)
|
|
371
|
+
if (compact || cascade === undefined)
|
|
374
372
|
return undefined;
|
|
375
373
|
const renderValue = cascadeValueRenderer(fieldName);
|
|
376
|
-
return (_jsx(ConfigCascadeView, { cascade: cascade, screenScope: screen.scope, qualifiedKey: screen.configKeys[fieldName], required: screen.requiredFields?.includes(fieldName) ?? false, ...(renderValue !== undefined && { renderValue }),
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
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) && {
|
|
375
|
+
onReset: async (key, scope) => {
|
|
376
|
+
await dispatcher.write("config:write:reset", { key, scope });
|
|
377
|
+
await Promise.allSettled([valuesQuery.refetch?.(), cascadeQuery.refetch?.()]);
|
|
378
|
+
},
|
|
379
|
+
}) }));
|
|
380
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);
|
|
381
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,
|
|
@@ -66,6 +66,8 @@ export type ExtensionSectionProps = {
|
|
|
66
66
|
* (`null` while the step's data loads) with whether the step already holds
|
|
67
67
|
* its data, so the step bar shows the step as done. */
|
|
68
68
|
readonly reportStepComplete?: (complete: boolean) => void;
|
|
69
|
+
/** Id of the active tab; only set in the `afterForm` slot of a projectionDetail screen with tabs, so the component can limit itself to one tab. */
|
|
70
|
+
readonly activeTabId?: string;
|
|
69
71
|
};
|
|
70
72
|
export type ExtensionSectionComponent = ComponentType<ExtensionSectionProps>;
|
|
71
73
|
export type ExtensionSectionsMap = Readonly<Record<string, ExtensionSectionComponent>>;
|
|
@@ -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 (
|
|
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
|
|
31
|
+
const split = visibleCandidates.length <= maxPlainButtons
|
|
32
|
+
? { buttons: orderPlainHeaderActions(visibleCandidates, preferredPrimaryId), menu: [] }
|
|
33
|
+
: splitHeaderActions(visibleCandidates, preferredPrimaryId, inlineActionIds);
|
|
34
|
+
const { buttons } = split;
|
|
35
|
+
const menu = [...split.menu, ...dangerMenuActions];
|
|
28
36
|
return (_jsxs(_Fragment, { children: [buttons.map((action) => (_jsx(RenderEditActionButton, { action: action, Button: Button, Dialog: Dialog, hideIcon: true, onError: onError }, action.id))), menu.length > 0 && (_jsx(ActionOverflowMenu, { label: t("kumiko.list.row-actions.more"), testId: overflowTestId, items: menu.map(toMenuItem) })), pendingActionDialog] }));
|
|
29
37
|
}
|
|
@@ -7,3 +7,5 @@ export declare function LockedHeaderScope({ standInScreenId, children, }: {
|
|
|
7
7
|
readonly standInScreenId?: string;
|
|
8
8
|
readonly children?: ReactNode;
|
|
9
9
|
}): ReactNode;
|
|
10
|
+
/** True while the screen renders as the stand-in of a locked screen (`visibleWhen` + `fallback`). */
|
|
11
|
+
export declare function useIsStandInScreen(): boolean;
|
|
@@ -15,6 +15,9 @@ function LockedScreenHeader({ standInScreenId }) {
|
|
|
15
15
|
// every mounted PageHeader overwrites and clears on unmount, so only the outermost scope mounts
|
|
16
16
|
// a header; nested scopes report the screen that finally renders up to it.
|
|
17
17
|
const ReportStandInContext = createContext(undefined);
|
|
18
|
+
// Separate from ReportStandInContext: the stand-in's own KumikoScreen wraps its body in a
|
|
19
|
+
// StandInChainBoundary, which clears the report context, so that one cannot tell a body it is a stand-in.
|
|
20
|
+
const StandInScreenContext = createContext(false);
|
|
18
21
|
/** Screen bodies (and anything embedded in them) are not part of a fallback chain. */
|
|
19
22
|
export function StandInChainBoundary({ children }) {
|
|
20
23
|
return (_jsx(ReportStandInContext.Provider, { value: undefined, children: children }));
|
|
@@ -29,5 +32,9 @@ export function LockedHeaderScope({ standInScreenId, children, }) {
|
|
|
29
32
|
reportToOuter({ screenId: effectiveScreenId });
|
|
30
33
|
return () => reportToOuter(undefined);
|
|
31
34
|
}, [reportToOuter, effectiveScreenId]);
|
|
32
|
-
return (_jsxs(_Fragment, { children: [reportToOuter === undefined && (_jsx(LockedScreenHeader, { ...(effectiveScreenId !== undefined && { standInScreenId: effectiveScreenId }) })), _jsx(ReportStandInContext.Provider, { value: setInner, children: children })] }));
|
|
35
|
+
return (_jsxs(_Fragment, { children: [reportToOuter === undefined && (_jsx(LockedScreenHeader, { ...(effectiveScreenId !== undefined && { standInScreenId: effectiveScreenId }) })), _jsx(StandInScreenContext.Provider, { value: standInScreenId !== undefined, children: _jsx(ReportStandInContext.Provider, { value: setInner, children: children }) })] }));
|
|
36
|
+
}
|
|
37
|
+
/** True while the screen renders as the stand-in of a locked screen (`visibleWhen` + `fallback`). */
|
|
38
|
+
export function useIsStandInScreen() {
|
|
39
|
+
return useContext(StandInScreenContext);
|
|
33
40
|
}
|