@cosmicdrift/kumiko-renderer 0.415.0 → 0.416.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 +1 -1
- package/dist/app/action-form-body.js +43 -16
- 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 +13 -4
- package/dist/app/extension-sections.d.ts +2 -0
- package/dist/app/projection-detail-body.js +8 -6
- package/dist/app/projection-detail-guidance.d.ts +1 -1
- package/dist/app/projection-detail-guidance.js +38 -26
- package/dist/app/projection-detail-header-model.d.ts +1 -1
- package/dist/app/projection-detail-header-model.js +10 -5
- package/dist/app/projection-detail-header.js +1 -1
- package/dist/app/projection-detail-navigation.d.ts +4 -0
- package/dist/app/projection-detail-navigation.js +5 -1
- 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 +13 -0
- package/dist/app/use-projection-detail-actions.js +14 -2
- package/dist/app/use-projection-detail-data.d.ts +2 -0
- package/dist/app/use-projection-detail-data.js +37 -10
- package/dist/components/ai-assist-payload.d.ts +2 -0
- package/dist/components/ai-assist-payload.js +8 -0
- package/dist/components/edit-mounts.d.ts +3 -2
- package/dist/components/edit-mounts.js +2 -2
- package/dist/components/multi-select-chips.d.ts +10 -0
- package/dist/components/multi-select-chips.js +18 -0
- package/dist/components/related-list-section.js +44 -32
- package/dist/components/related-photo-grid.d.ts +11 -0
- package/dist/components/related-photo-grid.js +40 -0
- package/dist/components/render-edit-action-button.d.ts +2 -2
- package/dist/components/render-edit-field-grid.js +3 -3
- 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 +2 -2
- package/dist/components/render-edit-logic.js +1 -0
- package/dist/components/render-edit-section-kinds.js +11 -0
- package/dist/components/render-edit-types.d.ts +11 -1
- package/dist/components/render-field-ai-assist.d.ts +13 -0
- package/dist/components/render-field-ai-assist.js +89 -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 +18 -8
- package/dist/components/render-field-value-chips.d.ts +9 -0
- package/dist/components/render-field-value-chips.js +45 -0
- package/dist/components/render-field-write-only.js +12 -4
- package/dist/components/render-list-hint-columns.d.ts +1 -0
- package/dist/components/render-list-hint-columns.js +13 -0
- package/dist/components/use-render-edit-sections.js +5 -1
- package/dist/components/use-render-list-columns.js +3 -3
- package/dist/headless/format/index.d.ts +1 -0
- package/dist/headless/format/index.js +20 -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 +13 -0
- package/dist/headless/format/relative-time.js +60 -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 +78 -2
- 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/types.d.ts +29 -3
- package/dist/i18n-defaults.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/primitives-record-guidance.d.ts +28 -1
- package/dist/primitives.d.ts +10 -3
- package/dist/web/app/dashboard-body.js +3 -2
- package/dist/web/app/dashboard-list-panel.js +1 -0
- 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-shared.js +1 -1
- package/dist/web/app/dashboard-stat-group-panel.js +9 -2
- package/dist/web/app/dashboard-text-panel.d.ts +1 -0
- package/dist/web/app/dashboard-text-panel.js +11 -9
- package/dist/web/app/relative-time.d.ts +0 -5
- package/dist/web/app/relative-time.js +1 -20
- package/dist/web/primitives/banner.js +11 -6
- package/dist/web/primitives/data-table/card-body.js +2 -2
- package/dist/web/primitives/data-table/card-row.js +7 -2
- package/dist/web/primitives/data-table/data-cell-props.d.ts +2 -0
- package/dist/web/primitives/data-table/data-cell-props.js +2 -0
- 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/table-body.js +2 -1
- package/dist/web/primitives/data-table/table-content.js +6 -2
- package/dist/web/primitives/data-table-cell.d.ts +4 -1
- package/dist/web/primitives/data-table-cell.js +16 -2
- package/dist/web/primitives/default-form.js +6 -3
- package/dist/web/primitives/drawer.js +5 -1
- package/dist/web/primitives/form-footer-parts.js +4 -1
- package/dist/web/primitives/form.js +6 -8
- package/dist/web/primitives/index.js +4 -0
- package/dist/web/primitives/layout-elements.d.ts +1 -1
- package/dist/web/primitives/layout-elements.js +2 -2
- 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 +2 -1
- package/dist/web/primitives/narrow-pinned-footer.js +7 -3
- package/dist/web/primitives/number-input.js +2 -1
- package/dist/web/primitives/photo-grid.d.ts +3 -0
- package/dist/web/primitives/photo-grid.js +5 -0
- package/dist/web/primitives/record-steps.d.ts +1 -1
- package/dist/web/primitives/record-steps.js +4 -4
- package/dist/web/primitives/record-summary.d.ts +1 -1
- package/dist/web/primitives/record-summary.js +8 -3
- package/dist/web/primitives/step-list.d.ts +3 -0
- package/dist/web/primitives/step-list.js +11 -0
- package/dist/web/widgets/dashboard-list.d.ts +2 -0
- package/dist/web/widgets/dashboard-list.js +2 -2
- package/dist/web/widgets/drawer-panel-class.js +1 -1
- package/package.json +5 -5
- package/src/changes.json +54 -0
|
@@ -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";
|
|
@@ -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";
|
|
@@ -116,7 +119,7 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
|
|
|
116
119
|
const appFeatures = useAppFeatures();
|
|
117
120
|
const insideDrawer = useInsideDrawer();
|
|
118
121
|
const locale = useLocale().locale();
|
|
119
|
-
const { Banner } = usePrimitives();
|
|
122
|
+
const { Banner, StatusBadge } = usePrimitives();
|
|
120
123
|
// Unused when drawer-hosted — onSuccess/onCancelOverride win below first.
|
|
121
124
|
const returnTarget = useReturnTarget(screen.id);
|
|
122
125
|
const submittableFields = useMemo(() => actionFormSubmittableFields(screen), [screen]);
|
|
@@ -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
|
|
@@ -291,15 +302,31 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
|
|
|
291
302
|
if (loadState !== undefined && loadState.status !== "ready") {
|
|
292
303
|
return (_jsx(ActionFormLoadStatus, { state: loadState, screenId: screen.id, translate: effectiveTranslate }));
|
|
293
304
|
}
|
|
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
|
-
|
|
305
|
+
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
|
+
// Extension sections in the actionForm see the initial form values
|
|
307
|
+
// (incl. searchParams prefill, e.g. ?incidentId=...) as initialValues;
|
|
308
|
+
// unlike entityEdit there is no record they could draw context from.
|
|
309
|
+
extensionInitialValues: initial, ...(screen.submitPrefilled === true && {
|
|
310
|
+
submitWithoutChanges: hiddenRequiredFieldsFilled(synthScreen, screen.fields, initial),
|
|
311
|
+
}), ...((success !== undefined || screen.infoBand !== undefined) && {
|
|
312
|
+
leadContent: (_jsxs(_Fragment, { children: [screen.infoBand !== undefined && (_jsx(Banner, { variant: "primary", icon: "sparkles", density: "compact", testId: "kumiko-screen-action-form-info-band", children: effectiveTranslate(screen.infoBand) })), success !== undefined && _jsx(ActionFormSuccessBanner, { success: success })] })),
|
|
313
|
+
}), ...(screen.fieldBadges !== undefined &&
|
|
314
|
+
StatusBadge !== undefined && {
|
|
315
|
+
labelAppendix: (fieldName) => {
|
|
316
|
+
const badge = screen.fieldBadges?.[fieldName];
|
|
317
|
+
if (badge === undefined)
|
|
318
|
+
return undefined;
|
|
319
|
+
return (_jsx(StatusBadge, { value: effectiveTranslate(badge.label), tone: statusToneForOptionTone(badge.tone) ?? "muted", testId: `field-badge-${fieldName}` }));
|
|
320
|
+
},
|
|
321
|
+
}), writeCommand: screen.handler, payloadMode: "values", onSubmit: handleSubmitted, ...(handleCancel !== undefined && { onCancel: handleCancel }), onDirtyChange: handleDirtyChange, ...((insideDrawer || screenFillsHeight(screen)) && { fillScreenHeight: true }), ...((screen.submitLabel ?? submitLabelFallback) !== undefined && {
|
|
322
|
+
submitLabel: screen.submitLabel ?? submitLabelFallback,
|
|
323
|
+
}), ...(screen.submitStyle !== undefined && { submitVariant: screen.submitStyle }), ...(screen.footerActions !== undefined && { footerActions: screen.footerActions }), ...(screen.formErrorOnTop === true && { formErrorOnTop: true }), ...(screen.fieldDescriptions !== undefined && {
|
|
324
|
+
fieldDescription: (fieldName, values) => {
|
|
325
|
+
const ref = screen.fieldDescriptions?.[fieldName];
|
|
326
|
+
if (ref === undefined)
|
|
327
|
+
return undefined;
|
|
328
|
+
const { text, complete } = resolveFieldText(ref, values, effectiveTranslate);
|
|
329
|
+
return complete ? text : undefined;
|
|
330
|
+
},
|
|
331
|
+
}), ...(summary !== undefined && { summary }), ...(translate !== undefined && { translate }) }, formEpoch) }));
|
|
305
332
|
}
|
|
@@ -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) {
|
|
@@ -196,6 +202,7 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
|
|
|
196
202
|
screen.configKeys,
|
|
197
203
|
screen.scope,
|
|
198
204
|
]);
|
|
205
|
+
const readOnlyFields = useMemo(() => readOnlyLayoutFieldNames(synthScreen), [synthScreen]);
|
|
199
206
|
// Cascade lookup: qualifiedKey -> ConfigCascade for the cascade display
|
|
200
207
|
// under each field. Defensive `levels` shape check so foreign query mocks
|
|
201
208
|
// (e.g. configEdit unit tests that only mock `config:query:values`) do not
|
|
@@ -373,9 +380,11 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
|
|
|
373
380
|
if (cascade === undefined)
|
|
374
381
|
return undefined;
|
|
375
382
|
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
|
-
|
|
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) && {
|
|
384
|
+
onReset: async (key, scope) => {
|
|
385
|
+
await dispatcher.write("config:write:reset", { key, scope });
|
|
386
|
+
await Promise.allSettled([valuesQuery.refetch?.(), cascadeQuery.refetch?.()]);
|
|
387
|
+
},
|
|
388
|
+
}) }));
|
|
380
389
|
} }));
|
|
381
390
|
}
|
|
@@ -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>>;
|
|
@@ -47,7 +47,7 @@ export function ProjectionDetailBody({ schema, screen, translate, entityId, }) {
|
|
|
47
47
|
// entityId fallback (resolveExtensionEntityId in render-edit.tsx) would
|
|
48
48
|
// let a client-controlled value leak where none is meant to reach.
|
|
49
49
|
const effectiveEntityId = screen.singleton === true ? undefined : entityId;
|
|
50
|
-
const { activeSection, hasTabs, entity, detailScreen, detailQuery, reloadNonce, reloadDetail } = useProjectionDetailData({ screen, Tabs: primitives.Tabs, nav, effectiveEntityId });
|
|
50
|
+
const { activeSection, activeSections, visibleSections, hasTabs, entity, detailScreen, detailQuery, reloadNonce, reloadDetail, } = useProjectionDetailData({ screen, Tabs: primitives.Tabs, nav, effectiveEntityId });
|
|
51
51
|
// Header actions render directly via RenderEditActionButton
|
|
52
52
|
// headerActions moved out of RenderEdit's footer — this component owns
|
|
53
53
|
// the failure-surfacing state RenderEdit used to own for them.
|
|
@@ -63,7 +63,7 @@ export function ProjectionDetailBody({ schema, screen, translate, entityId, }) {
|
|
|
63
63
|
const returnTarget = screen.singleton === true ? undefined : returnTargetParam;
|
|
64
64
|
const drawer = useDrawerAction(schema);
|
|
65
65
|
const { openDrawer } = drawer;
|
|
66
|
-
const { buildSectionActions, buildItemActions, headerActions } = useProjectionDetailActions({
|
|
66
|
+
const { buildSectionActions, buildItemActions, headerActions, footerActions } = useProjectionDetailActions({
|
|
67
67
|
schema,
|
|
68
68
|
screen,
|
|
69
69
|
effectiveTranslate,
|
|
@@ -83,7 +83,7 @@ export function ProjectionDetailBody({ schema, screen, translate, entityId, }) {
|
|
|
83
83
|
const { hasMetrics, headerActionsList, hasHeaderActions, hasHeaderCard, renderedDetailScreen } = useProjectionDetailLayout({ screen, headerActions, hasTabs, detailScreen });
|
|
84
84
|
const recordId = detailQuery.data?.["id"];
|
|
85
85
|
const tabCounts = useRelatedListTabCounts({
|
|
86
|
-
sections: hasTabs ?
|
|
86
|
+
sections: hasTabs ? visibleSections : [],
|
|
87
87
|
parentId: effectiveEntityId ?? (typeof recordId === "string" ? recordId : undefined),
|
|
88
88
|
});
|
|
89
89
|
if (effectiveEntityId === undefined && screen.singleton !== true) {
|
|
@@ -104,7 +104,7 @@ export function ProjectionDetailBody({ schema, screen, translate, entityId, }) {
|
|
|
104
104
|
return renderRecordNotFound({ schema, screen, nav, returnTarget, effectiveTranslate });
|
|
105
105
|
}
|
|
106
106
|
const regionModel = {
|
|
107
|
-
screen,
|
|
107
|
+
screen: { ...screen, layout: { ...screen.layout, sections: visibleSections } },
|
|
108
108
|
record,
|
|
109
109
|
primitives,
|
|
110
110
|
effectiveTranslate,
|
|
@@ -129,13 +129,15 @@ export function ProjectionDetailBody({ schema, screen, translate, entityId, }) {
|
|
|
129
129
|
};
|
|
130
130
|
const regionPieces = deriveDetailRegionPieces(regionModel);
|
|
131
131
|
const renderHeaderContent = (headerSlot) => renderDetailHeaderContent(regionModel, regionPieces, headerSlot);
|
|
132
|
-
return (_jsxs(_Fragment, { children: [refetchErrorBanner, _jsx(RenderEdit, { refreshToken: reloadNonce, screen: renderedDetailScreen, entity: entity, featureName: schema.featureName, initial: record, entityId: effectiveEntityId, customSubmit: async () => ({ isSuccess: true, validationBlocked: false, data: undefined }), onReload: reloadDetail, onRelatedListDrawerAction: openDrawer, ...(translate !== undefined && { translate }), ...(hasTabs &&
|
|
132
|
+
return (_jsxs(_Fragment, { children: [refetchErrorBanner, _jsx(RenderEdit, { refreshToken: reloadNonce, screen: renderedDetailScreen, entity: entity, featureName: schema.featureName, initial: record, entityId: effectiveEntityId, customSubmit: async () => ({ isSuccess: true, validationBlocked: false, data: undefined }), onReload: reloadDetail, onRelatedListDrawerAction: openDrawer, ...(translate !== undefined && { translate }), ...(hasTabs && activeSection !== undefined && { activeTabId: activeSection.id }), ...(screen.footerHint !== undefined && {
|
|
133
|
+
footerHint: effectiveTranslate(screen.footerHint),
|
|
134
|
+
}), ...(hasTabs && activeSections.length === 1 && { hideSectionTitles: true }), ...(screenFillsHeight(screen) && { fillScreenHeight: true }), ...((hasHeaderCard ||
|
|
133
135
|
hasTabs ||
|
|
134
136
|
hasRecordGuidance(screen) ||
|
|
135
137
|
screen.slots?.header !== undefined ||
|
|
136
138
|
screen.recordTitleField !== undefined) && {
|
|
137
139
|
headerRegion: renderHeaderContent,
|
|
138
|
-
}), buildSectionActions: buildSectionActions, valueDisplay: screen.valueDisplay ?? "text" }, entityId), renderProjectionDrawerHost({
|
|
140
|
+
}), ...(footerActions !== undefined && footerActions.length > 0 && { actions: footerActions }), buildSectionActions: buildSectionActions, valueDisplay: screen.valueDisplay ?? "text" }, entityId), renderProjectionDrawerHost({
|
|
139
141
|
schema,
|
|
140
142
|
translate,
|
|
141
143
|
userRoles,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type RowAction } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import type { RenderEditAction } from "../components/render-edit-types.ts";
|
|
4
4
|
import type { DetailHeaderModel } from "./projection-detail-header.tsx";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { evalFieldCondition, } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
3
|
import { Fragment } from "react";
|
|
3
4
|
import { RenderEditActionButton } from "../components/render-edit-action-button.js";
|
|
4
5
|
import { pluralKey } from "../headless/plural-key.js";
|
|
@@ -90,7 +91,7 @@ function renderSummary(model) {
|
|
|
90
91
|
const { RecordSummary, Text } = model.primitives;
|
|
91
92
|
const testId = "kumiko-screen-projection-detail-summary";
|
|
92
93
|
if (RecordSummary !== undefined) {
|
|
93
|
-
return (_jsx(RecordSummary, { text: text, ...(narrowText !== undefined && { narrowText }), ...(tone !== undefined && { tone }), testId: testId }));
|
|
94
|
+
return (_jsx(RecordSummary, { text: text, ...(narrowText !== undefined && { narrowText }), ...(tone !== undefined && { tone }), ...(spec.icon !== undefined && { icon: spec.icon }), testId: testId }));
|
|
94
95
|
}
|
|
95
96
|
return _jsx(Text, { testId: testId, children: text });
|
|
96
97
|
}
|
|
@@ -105,44 +106,55 @@ function renderBanner(model) {
|
|
|
105
106
|
const actions = renderItemActions(model, spec.actions, notice);
|
|
106
107
|
return wrapLayout(model.primitives, GUIDANCE_INSET, _jsx(Banner, { variant: BANNER_VARIANT[notice.tone ?? "neutral"], icon: BANNER_ICON[notice.tone ?? "neutral"], title: notice.title, ...(notice.narrowTitle !== undefined && { narrowTitle: notice.narrowTitle }), ...(notice.narrowText !== undefined && { narrowText: notice.narrowText }), inline: true, ...(actions !== undefined && { actions }), testId: "kumiko-screen-projection-detail-banner", children: notice.text }));
|
|
107
108
|
}
|
|
109
|
+
function buildStepItem(model, spec, step) {
|
|
110
|
+
const [mainAction, ...otherActions] = resolveItemActions(model, spec.actions, step);
|
|
111
|
+
return {
|
|
112
|
+
id: step.id,
|
|
113
|
+
title: step.title,
|
|
114
|
+
...(step.narrowTitle !== undefined && { narrowTitle: step.narrowTitle }),
|
|
115
|
+
...(step.detail !== undefined && { detail: step.detail }),
|
|
116
|
+
...(step.narrowDetail !== undefined && { narrowDetail: step.narrowDetail }),
|
|
117
|
+
...(step.tone !== undefined && { tone: step.tone }),
|
|
118
|
+
...(step.why !== undefined && { reason: step.why }),
|
|
119
|
+
...(step.why !== undefined && step.whyOpen === true && { reasonOpen: true }),
|
|
120
|
+
...(step.why !== undefined && step.whyTitle !== undefined && { reasonTitle: step.whyTitle }),
|
|
121
|
+
...(mainAction !== undefined && {
|
|
122
|
+
actions: renderActionButtons(model, [mainAction], spec.actions),
|
|
123
|
+
}),
|
|
124
|
+
...(otherActions.length > 0 && {
|
|
125
|
+
moreActions: renderActionButtons(model, otherActions, spec.actions),
|
|
126
|
+
}),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function stepsCollapseProps(spec, t) {
|
|
130
|
+
return {
|
|
131
|
+
...(spec.moreActionsLabel !== undefined && { moreActionsLabel: t(spec.moreActionsLabel) }),
|
|
132
|
+
...(spec.narrowLimit !== undefined && {
|
|
133
|
+
narrowLimit: spec.narrowLimit,
|
|
134
|
+
moreLabel: (count) => t(pluralKey(spec.narrowMoreLabel ?? "kumiko.detail.steps.more", count), { count }),
|
|
135
|
+
lessLabel: t("kumiko.detail.steps.less"),
|
|
136
|
+
}),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
108
139
|
function renderSteps(model) {
|
|
109
140
|
const spec = model.screen.steps;
|
|
110
141
|
if (spec === undefined)
|
|
111
142
|
return undefined;
|
|
143
|
+
if (spec.visibleWhen !== undefined &&
|
|
144
|
+
!evalFieldCondition(spec.visibleWhen, { ...model.record })) {
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
112
147
|
const { effectiveTranslate: t, record } = model;
|
|
113
148
|
const steps = readSteps(record[spec.field]);
|
|
114
149
|
const title = t(spec.title ?? "kumiko.detail.steps.title");
|
|
115
150
|
const subtitleRaw = spec.subtitleField !== undefined ? record[spec.subtitleField] : undefined;
|
|
116
151
|
const subtitle = typeof subtitleRaw === "string" && subtitleRaw !== "" ? subtitleRaw : undefined;
|
|
117
152
|
const emptyLabel = t(spec.emptyLabel ?? "kumiko.detail.steps.empty");
|
|
118
|
-
const items = steps.map((step) =>
|
|
119
|
-
const [mainAction, ...otherActions] = resolveItemActions(model, spec.actions, step);
|
|
120
|
-
return {
|
|
121
|
-
id: step.id,
|
|
122
|
-
title: step.title,
|
|
123
|
-
...(step.narrowTitle !== undefined && { narrowTitle: step.narrowTitle }),
|
|
124
|
-
...(step.detail !== undefined && { detail: step.detail }),
|
|
125
|
-
...(step.narrowDetail !== undefined && { narrowDetail: step.narrowDetail }),
|
|
126
|
-
...(step.tone !== undefined && { tone: step.tone }),
|
|
127
|
-
...(step.why !== undefined && { reason: step.why }),
|
|
128
|
-
...(step.why !== undefined && step.whyOpen === true && { reasonOpen: true }),
|
|
129
|
-
...(step.why !== undefined && step.whyTitle !== undefined && { reasonTitle: step.whyTitle }),
|
|
130
|
-
...(mainAction !== undefined && {
|
|
131
|
-
actions: renderActionButtons(model, [mainAction], spec.actions),
|
|
132
|
-
}),
|
|
133
|
-
...(otherActions.length > 0 && {
|
|
134
|
-
moreActions: renderActionButtons(model, otherActions, spec.actions),
|
|
135
|
-
}),
|
|
136
|
-
};
|
|
137
|
-
});
|
|
153
|
+
const items = steps.map((step) => buildStepItem(model, spec, step));
|
|
138
154
|
const { RecordSteps, Card, Text } = model.primitives;
|
|
139
155
|
const testId = "kumiko-screen-projection-detail-steps";
|
|
140
156
|
if (RecordSteps !== undefined) {
|
|
141
|
-
return (_jsx(RecordSteps, { title: title, ...(subtitle !== undefined && { subtitle }), emptyLabel: emptyLabel, reasonLabel: t("kumiko.detail.steps.reason"), ...(spec.
|
|
142
|
-
narrowLimit: spec.narrowLimit,
|
|
143
|
-
moreLabel: (count) => t(pluralKey(spec.narrowMoreLabel ?? "kumiko.detail.steps.more", count), { count }),
|
|
144
|
-
lessLabel: t("kumiko.detail.steps.less"),
|
|
145
|
-
}), items: items, count: items.length, testId: testId }));
|
|
157
|
+
return (_jsx(RecordSteps, { title: title, ...(subtitle !== undefined && { subtitle }), emptyLabel: emptyLabel, reasonLabel: t("kumiko.detail.steps.reason"), ...stepsCollapseProps(spec, t), items: items, count: items.length, testId: testId }));
|
|
146
158
|
}
|
|
147
159
|
return (_jsx(Card, { slots: { title, ...(subtitle !== undefined && { subtitle }) }, testId: testId, children: items.length === 0 ? (_jsx(Text, { variant: "muted", children: emptyLabel })) : (items.map((item) => (_jsxs(Fragment, { children: [_jsx(Text, { children: item.title }), item.detail !== undefined && _jsx(Text, { variant: "muted", children: item.detail }), item.reason !== undefined && _jsx(Text, { variant: "muted", children: item.reason }), item.actions, item.moreActions] }, item.id)))) }));
|
|
148
160
|
}
|
|
@@ -4,7 +4,7 @@ import { type Translate } from "../headless/index.ts";
|
|
|
4
4
|
import { type StatusBadgeOptionTone } from "../primitives.tsx";
|
|
5
5
|
export declare function headerStatusTone(header: NonNullable<ProjectionDetailScreenDefinition["header"]>, record: Readonly<Record<string, unknown>>): StatusBadgeOptionTone | undefined;
|
|
6
6
|
export declare function resolveHeaderStatusText(screen: ProjectionDetailScreenDefinition, record: Readonly<Record<string, unknown>>, translate: Translate): string;
|
|
7
|
-
export declare function formatOrRaw(format: FormatSpec | undefined, raw: unknown, translate: Translate): string;
|
|
7
|
+
export declare function formatOrRaw(format: FormatSpec | undefined, raw: unknown, translate: Translate, uiLocale?: string): string;
|
|
8
8
|
export declare function resolveSubtitleHref(header: ProjectionDetailScreenDefinition["header"], record: Readonly<Record<string, unknown>>): string | undefined;
|
|
9
9
|
export type DetailTabItem = {
|
|
10
10
|
readonly id: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isFieldsEditSection, isFormatSpec, isWriteFormEditSection, normalizeEditField, sectionFieldSpecs, } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
import { applyFormatSpec } from "../headless/index.js";
|
|
3
3
|
import { statusToneForOptionTone, statusToneForValue, } from "../primitives.js";
|
|
4
|
-
import { isAbsoluteHttpUrl } from "./projection-detail-navigation.js";
|
|
4
|
+
import { isAbsoluteHttpUrl, withUiLocale } from "./projection-detail-navigation.js";
|
|
5
5
|
export function headerStatusTone(header, record) {
|
|
6
6
|
// skip: a header without status has no tone
|
|
7
7
|
if (header.status === undefined)
|
|
@@ -39,11 +39,11 @@ export function resolveHeaderStatusText(screen, record, translate) {
|
|
|
39
39
|
const format = screen.header?.statusFormat ?? layoutStatusFormat(screen, statusField);
|
|
40
40
|
return formatOrRaw(format, raw, translate);
|
|
41
41
|
}
|
|
42
|
-
export function formatOrRaw(format, raw, translate) {
|
|
42
|
+
export function formatOrRaw(format, raw, translate, uiLocale) {
|
|
43
43
|
const rawText = String(raw ?? "");
|
|
44
44
|
if (format === undefined)
|
|
45
45
|
return rawText;
|
|
46
|
-
const formatted = applyFormatSpec(format, raw, translate);
|
|
46
|
+
const formatted = applyFormatSpec(uiLocale === undefined ? format : withUiLocale(format, uiLocale), raw, translate);
|
|
47
47
|
return formatted === "" ? rawText : formatted;
|
|
48
48
|
}
|
|
49
49
|
export function resolveSubtitleHref(header, record) {
|
|
@@ -54,8 +54,13 @@ export function resolveSubtitleHref(header, record) {
|
|
|
54
54
|
return typeof value === "string" && isAbsoluteHttpUrl(value) ? value : undefined;
|
|
55
55
|
}
|
|
56
56
|
export function buildDetailTabItems(sections, record, translate, queryCounts = {}) {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
// Adjacent sections sharing an id are one tab; its label and count come from the first.
|
|
58
|
+
return sections
|
|
59
|
+
.filter((section, index) => section.id !== sections[index - 1]?.id)
|
|
60
|
+
.map((section) => {
|
|
61
|
+
const countField = isWriteFormEditSection(section) || section.kind === "stepList"
|
|
62
|
+
? undefined
|
|
63
|
+
: section.countField;
|
|
59
64
|
const countValue = countField !== undefined ? record[countField] : queryCounts[section.id ?? ""];
|
|
60
65
|
const count = typeof countValue === "number" && Number.isFinite(countValue) ? countValue : undefined;
|
|
61
66
|
return {
|
|
@@ -115,7 +115,7 @@ export function buildMetricItems(model) {
|
|
|
115
115
|
const field = metric.field;
|
|
116
116
|
const label = metricLabel(metric, record, effectiveTranslate);
|
|
117
117
|
const rawValue = record[field];
|
|
118
|
-
const value = formatOrRaw(metric.format, rawValue, effectiveTranslate);
|
|
118
|
+
const value = formatOrRaw(metric.format, rawValue, effectiveTranslate, model.locale);
|
|
119
119
|
const tiles = screen.metricsStyle === "tiles";
|
|
120
120
|
const tone = metricTone(metric, record, rawValue);
|
|
121
121
|
const sub = metricSubline(metric.subField, record);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MetricNavigate, RecordHeaderSubtitlePart } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import type { FormatSpec } from "@cosmicdrift/kumiko-types/screen";
|
|
2
3
|
import { type Translate } from "../headless/index.ts";
|
|
3
4
|
import type { FeatureSchema } from "./feature-schema.ts";
|
|
4
5
|
import type { NavApi } from "./nav.tsx";
|
|
@@ -14,4 +15,7 @@ export type SubtitlePartView = {
|
|
|
14
15
|
readonly prefix?: string;
|
|
15
16
|
};
|
|
16
17
|
export declare function metricNavigateResolves(navigate: MetricNavigate, record: Readonly<Record<string, unknown>>): boolean;
|
|
18
|
+
export declare function withUiLocale(format: FormatSpec, uiLocale: string): {
|
|
19
|
+
readonly format: string;
|
|
20
|
+
} & Readonly<Record<string, unknown>>;
|
|
17
21
|
export declare function buildSubtitleParts(parts: readonly RecordHeaderSubtitlePart[], record: Readonly<Record<string, unknown>>, nav: NavApi, appFeatures: readonly FeatureSchema[], userRoles: readonly string[] | undefined, host: ReturnHost | undefined, translate: Translate, locale: string): SubtitlePartView[];
|
|
@@ -79,13 +79,17 @@ function hrefForNavigate(nav, navigate, record) {
|
|
|
79
79
|
}
|
|
80
80
|
return undefined;
|
|
81
81
|
}
|
|
82
|
+
// The format keeps its own locale; otherwise it follows the UI locale instead of the browser's.
|
|
83
|
+
export function withUiLocale(format, uiLocale) {
|
|
84
|
+
return { ...format, locale: ("locale" in format ? format.locale : undefined) ?? uiLocale };
|
|
85
|
+
}
|
|
82
86
|
export function buildSubtitleParts(parts, record, nav, appFeatures, userRoles, host, translate, locale) {
|
|
83
87
|
return parts.flatMap((part) => {
|
|
84
88
|
const field = typeof part === "string" ? part : part.field;
|
|
85
89
|
const format = typeof part === "string" ? undefined : part.format;
|
|
86
90
|
const text = format === undefined
|
|
87
91
|
? String(record[field] ?? "")
|
|
88
|
-
: applyFormatSpec(
|
|
92
|
+
: applyFormatSpec(withUiLocale(format, locale), record[field], translate);
|
|
89
93
|
// skip: empty subtitle parts render nothing
|
|
90
94
|
if (text === "")
|
|
91
95
|
return [];
|
|
@@ -56,6 +56,7 @@ type ResolvedRedirectTarget = {
|
|
|
56
56
|
readonly screenId: string;
|
|
57
57
|
readonly entityId: string | undefined;
|
|
58
58
|
readonly tab: string | undefined;
|
|
59
|
+
readonly searchParams: Readonly<Record<string, string>>;
|
|
59
60
|
};
|
|
60
61
|
export declare function navigateToRedirectTarget(nav: NavApi, target: ResolvedRedirectTarget): void;
|
|
61
62
|
export declare function resolveSuccessLinks(links: readonly ActionFormSuccessLink[] | undefined, data: unknown, schema: FeatureSchema, appFeatures: readonly FeatureSchema[], nav: NavApi, translate: Translate): readonly ResolvedSuccessLink[];
|
|
@@ -253,25 +253,45 @@ export function resolveRedirectTarget(redirect, submittedData, schema, appFeatur
|
|
|
253
253
|
const targetId = lastSegment(redirectScreen);
|
|
254
254
|
const target = findRedirectTargetScreen(redirect, schema, appFeatures);
|
|
255
255
|
const carriesId = target !== undefined && (target.type === "entityEdit" || target.type === "projectionDetail");
|
|
256
|
+
const searchParams = redirectSearchParams(redirect, submittedData);
|
|
256
257
|
if (!carriesId)
|
|
257
|
-
return { screenId: targetId, entityId: undefined, tab: undefined };
|
|
258
|
+
return { screenId: targetId, entityId: undefined, tab: undefined, searchParams };
|
|
258
259
|
const entityId = extractIdField(submittedData, idField) ??
|
|
259
260
|
(fallbackRecord !== undefined ? extractIdField(fallbackRecord, idField) : undefined);
|
|
260
261
|
return {
|
|
261
262
|
screenId: targetId,
|
|
262
263
|
entityId,
|
|
263
264
|
tab: typeof redirect === "string" ? undefined : redirect.tab,
|
|
265
|
+
searchParams,
|
|
264
266
|
};
|
|
265
267
|
}
|
|
268
|
+
// Only the object form of an actionForm redirect declares searchParams; success
|
|
269
|
+
// links keep their own `params`. Non-string payload values leave the param out.
|
|
270
|
+
function redirectSearchParams(redirect, submittedData) {
|
|
271
|
+
const declared = typeof redirect === "string" || !("searchParams" in redirect)
|
|
272
|
+
? undefined
|
|
273
|
+
: redirect.searchParams;
|
|
274
|
+
const resolved = {};
|
|
275
|
+
for (const [param, field] of Object.entries(declared ?? {})) {
|
|
276
|
+
const value = propertyOf(submittedData, field);
|
|
277
|
+
if (typeof value === "string")
|
|
278
|
+
resolved[param] = value;
|
|
279
|
+
}
|
|
280
|
+
return resolved;
|
|
281
|
+
}
|
|
266
282
|
export function navigateToRedirectTarget(nav, target) {
|
|
267
283
|
const navTarget = {
|
|
268
284
|
screenId: target.screenId,
|
|
269
285
|
...(target.entityId !== undefined && { entityId: target.entityId }),
|
|
270
286
|
};
|
|
271
|
-
|
|
287
|
+
const searchParams = {
|
|
288
|
+
...target.searchParams,
|
|
289
|
+
...(target.tab !== undefined && { tab: target.tab }),
|
|
290
|
+
};
|
|
291
|
+
if (Object.keys(searchParams).length === 0)
|
|
272
292
|
nav.navigate(navTarget);
|
|
273
293
|
else
|
|
274
|
-
nav.navigate(navTarget, { searchParams
|
|
294
|
+
nav.navigate(navTarget, { searchParams });
|
|
275
295
|
}
|
|
276
296
|
// Links of the success box. Targets resolve like `redirect`; a link whose target
|
|
277
297
|
// needs a record id (entityEdit, projectionDetail) but whose payload field holds
|
|
@@ -32,6 +32,19 @@ export declare function useProjectionDetailActions(input: DetailActionsInput): {
|
|
|
32
32
|
buildSectionActions: (actions: readonly RowAction[]) => readonly RenderEditAction[] | undefined;
|
|
33
33
|
buildItemActions: (actions: readonly RowAction[], item: Readonly<Record<string, unknown>>) => readonly RenderEditAction[] | undefined;
|
|
34
34
|
headerActions: readonly RenderEditAction[] | undefined;
|
|
35
|
+
footerActions: {
|
|
36
|
+
id: string;
|
|
37
|
+
label: string;
|
|
38
|
+
onPress: () => void | Promise<void>;
|
|
39
|
+
style?: "primary" | "secondary" | "danger";
|
|
40
|
+
display?: import("@cosmicdrift/kumiko-framework/ui-types").RowActionDisplay;
|
|
41
|
+
confirm?: string;
|
|
42
|
+
confirmLabel?: string;
|
|
43
|
+
confirmRequired?: boolean;
|
|
44
|
+
icon?: import("@cosmicdrift/kumiko-types/nav-icon").IconKey;
|
|
45
|
+
align?: "start";
|
|
46
|
+
pinnedOnPhone: true;
|
|
47
|
+
}[] | undefined;
|
|
35
48
|
};
|
|
36
49
|
export declare function omitActionsDefaultingToShownRecordId(actions: readonly RowAction[], shownRecordId: string | undefined): readonly RowAction[];
|
|
37
50
|
export {};
|
|
@@ -152,7 +152,8 @@ export function useProjectionDetailActions(input) {
|
|
|
152
152
|
handleRecordLeft,
|
|
153
153
|
sameEntityScreenId,
|
|
154
154
|
]);
|
|
155
|
-
const
|
|
155
|
+
const footerIds = screen.footerActions;
|
|
156
|
+
const recordActions = useMemo(() => {
|
|
156
157
|
const declaredHasEdit = screen.actions?.some((a) => a.id === "edit") === true;
|
|
157
158
|
const resolved = buildRecordActions({
|
|
158
159
|
actions: (screen.actions ?? []).filter((a) => isShownOnTab(a, activeTabId)),
|
|
@@ -186,7 +187,18 @@ export function useProjectionDetailActions(input) {
|
|
|
186
187
|
handleRecordLeft,
|
|
187
188
|
sameEntityScreenId,
|
|
188
189
|
]);
|
|
189
|
-
|
|
190
|
+
// footerActions render in RenderEdit's pinned footer, so the header bar must not repeat them.
|
|
191
|
+
const headerActions = useMemo(() => footerIds === undefined
|
|
192
|
+
? recordActions
|
|
193
|
+
: recordActions?.filter((a) => !footerIds.includes(a.id)), [recordActions, footerIds]);
|
|
194
|
+
const footerActions = useMemo(() => footerIds === undefined
|
|
195
|
+
? undefined
|
|
196
|
+
: recordActions
|
|
197
|
+
?.filter((a) => footerIds.includes(a.id))
|
|
198
|
+
.map((a) => screen.actions?.find((declared) => declared.id === a.id)?.align === "start"
|
|
199
|
+
? { ...a, align: "start", pinnedOnPhone: true }
|
|
200
|
+
: { ...a, pinnedOnPhone: true }), [recordActions, footerIds, screen.actions]);
|
|
201
|
+
return { buildSectionActions, buildItemActions, headerActions, footerActions };
|
|
190
202
|
}
|
|
191
203
|
// Without a shown record id, a payload-less write or client action would fall back to the guidance item's own id (a step key, not a record id).
|
|
192
204
|
export function omitActionsDefaultingToShownRecordId(actions, shownRecordId) {
|
|
@@ -9,6 +9,8 @@ type DetailDataInput = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare function useProjectionDetailData(input: DetailDataInput): {
|
|
11
11
|
activeSection: import("@cosmicdrift/kumiko-framework/ui-types").EditSectionSpec | undefined;
|
|
12
|
+
activeSections: import("@cosmicdrift/kumiko-framework/ui-types").EditSectionSpec[];
|
|
13
|
+
visibleSections: import("@cosmicdrift/kumiko-framework/ui-types").EditSectionSpec[];
|
|
12
14
|
hasTabs: boolean;
|
|
13
15
|
entity: Pick<import("@cosmicdrift/kumiko-types/fields").EntityDefinition, "fields">;
|
|
14
16
|
detailScreen: import("@cosmicdrift/kumiko-framework/ui-types").EntityEditScreenDefinition;
|