@cosmicdrift/kumiko-renderer 0.406.0 → 0.410.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.js +23 -8
- package/dist/app/action-form-support.d.ts +7 -0
- package/dist/app/action-form-support.js +14 -1
- package/dist/app/config-edit-action-row.d.ts +7 -0
- package/dist/app/config-edit-action-row.js +45 -0
- package/dist/app/config-edit-body.js +32 -4
- package/dist/app/entity-list-screen.js +8 -11
- package/dist/app/nav.js +2 -1
- package/dist/app/projection-detail-body.js +3 -1
- package/dist/app/projection-detail-header.d.ts +1 -0
- package/dist/app/projection-detail-header.js +1 -1
- package/dist/app/projection-detail-navigation.d.ts +2 -1
- package/dist/app/projection-detail-navigation.js +6 -3
- package/dist/app/projection-detail-shim.js +3 -1
- package/dist/app/projection-list-render-props.d.ts +1 -1
- package/dist/app/projection-list-render-props.js +4 -2
- package/dist/app/projection-list-render.js +1 -1
- package/dist/app/screen-access.js +4 -2
- package/dist/app/screen-shared.d.ts +3 -2
- package/dist/app/screen-shared.js +30 -2
- package/dist/app/use-embedded-screen.d.ts +2 -0
- package/dist/app/use-embedded-screen.js +7 -1
- package/dist/components/edit-mounts.d.ts +3 -1
- package/dist/components/edit-mounts.js +3 -3
- package/dist/components/related-list-section.d.ts +3 -1
- package/dist/components/related-list-section.js +2 -2
- package/dist/components/render-edit-field-grid.d.ts +2 -2
- package/dist/components/render-edit-field-grid.js +12 -4
- package/dist/components/render-edit-fields-section.js +6 -7
- package/dist/components/render-edit-helpers.d.ts +4 -0
- package/dist/components/render-edit-helpers.js +5 -0
- package/dist/components/render-edit-section-kinds.js +6 -4
- package/dist/components/render-edit-submit.js +18 -1
- package/dist/components/render-edit-titles.js +6 -6
- package/dist/components/render-edit-types.d.ts +6 -0
- package/dist/components/render-field-control.d.ts +2 -0
- package/dist/components/render-field-control.js +23 -1
- package/dist/components/render-field-write-only.d.ts +1 -1
- package/dist/components/render-field-write-only.js +12 -2
- package/dist/components/render-field.js +2 -1
- package/dist/components/use-render-edit-sections.js +4 -4
- package/dist/format-when.d.ts +1 -1
- package/dist/format-when.js +2 -2
- package/dist/headless/format/escape.js +3 -2
- package/dist/headless/view-model/edit.js +0 -2
- package/dist/headless/view-model/types.d.ts +0 -3
- package/dist/i18n-defaults.js +38 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/primitives.d.ts +30 -7
- package/dist/primitives.js +1 -51
- package/dist/status-tone.d.ts +6 -0
- package/dist/status-tone.js +51 -0
- package/dist/toggle-set-member.d.ts +1 -0
- package/dist/toggle-set-member.js +8 -0
- package/dist/web/app/dashboard-header.js +5 -1
- package/dist/web/app/dashboard-screen-tiles.js +19 -3
- package/dist/web/icons.d.ts +2 -0
- package/dist/web/icons.js +3 -1
- package/dist/web/index.d.ts +3 -2
- package/dist/web/index.js +2 -1
- package/dist/web/layout/default-app-shell.d.ts +4 -1
- package/dist/web/layout/default-app-shell.js +5 -2
- package/dist/web/layout/focus-aware-sidebar.d.ts +27 -0
- package/dist/web/layout/focus-aware-sidebar.js +23 -0
- package/dist/web/layout/focus-rail.d.ts +16 -0
- package/dist/web/layout/focus-rail.js +61 -0
- package/dist/web/layout/nav-tree.d.ts +2 -1
- package/dist/web/layout/nav-tree.js +3 -9
- package/dist/web/layout/shell-focus.d.ts +19 -0
- package/dist/web/layout/shell-focus.js +35 -0
- package/dist/web/layout/shell-header.d.ts +1 -1
- package/dist/web/layout/shell-header.js +12 -9
- package/dist/web/layout/sidebar-brand.js +1 -1
- package/dist/web/layout/workspace-shell.d.ts +4 -1
- package/dist/web/layout/workspace-shell.js +5 -2
- package/dist/web/primitives/banner.js +3 -1
- package/dist/web/primitives/data-table/toolbar.js +2 -2
- package/dist/web/primitives/default-form.js +12 -5
- package/dist/web/primitives/field.js +4 -1
- package/dist/web/primitives/input-text-kinds.js +8 -2
- package/dist/web/primitives/layout-elements.js +2 -4
- package/dist/web/primitives/tabs.d.ts +1 -1
- package/dist/web/primitives/tabs.js +21 -4
- package/dist/web/theme-plugin.d.ts +1 -1
- package/dist/web/theme-plugin.js +7 -0
- package/dist/web/ui/sidebar.js +5 -2
- package/dist/web/widgets/ai-text-end-action.d.ts +12 -0
- package/dist/web/widgets/ai-text-end-action.js +15 -0
- package/dist/web/widgets/ai-text-field.d.ts +3 -0
- package/dist/web/widgets/ai-text-field.js +4 -3
- package/dist/web/widgets/attachment-card.d.ts +6 -0
- package/dist/web/widgets/attachment-card.js +11 -0
- package/dist/web/widgets/attachment-chip.d.ts +8 -0
- package/dist/web/widgets/attachment-chip.js +21 -0
- package/dist/web/widgets/clamped-text.d.ts +11 -0
- package/dist/web/widgets/clamped-text.js +38 -0
- package/dist/web/widgets/html-mail-frame.d.ts +17 -0
- package/dist/web/widgets/html-mail-frame.js +56 -0
- package/dist/web/widgets/index.d.ts +10 -1
- package/dist/web/widgets/index.js +9 -1
- package/dist/web/widgets/infinity-list.d.ts +3 -1
- package/dist/web/widgets/infinity-list.js +2 -2
- package/dist/web/widgets/message-body-view.d.ts +10 -0
- package/dist/web/widgets/message-body-view.js +36 -0
- package/dist/web/widgets/message-reader.d.ts +4 -0
- package/dist/web/widgets/message-reader.js +31 -0
- package/dist/web/widgets/message-thread.d.ts +5 -0
- package/dist/web/widgets/message-thread.js +66 -0
- package/dist/web/widgets/message-types.d.ts +68 -0
- package/dist/web/widgets/message-types.js +1 -0
- package/dist/web/widgets/mobile-top-bar.d.ts +21 -0
- package/dist/web/widgets/mobile-top-bar.js +8 -0
- package/dist/web/widgets/pdf-document.d.ts +19 -0
- package/dist/web/widgets/pdf-document.js +70 -0
- package/dist/web/widgets/pdf-page.d.ts +35 -0
- package/dist/web/widgets/pdf-page.js +155 -0
- package/dist/web/widgets/pdf-preview.d.ts +27 -7
- package/dist/web/widgets/pdf-preview.js +21 -133
- package/dist/web/widgets/pdf-search.d.ts +43 -0
- package/dist/web/widgets/pdf-search.js +178 -0
- package/dist/web/widgets/pdf-thumbnails.d.ts +10 -0
- package/dist/web/widgets/pdf-thumbnails.js +35 -0
- package/dist/web/widgets/pdf-viewer-toolbar.d.ts +22 -0
- package/dist/web/widgets/pdf-viewer-toolbar.js +35 -0
- package/dist/web/widgets/pdf-viewer.d.ts +21 -0
- package/dist/web/widgets/pdf-viewer.js +176 -0
- package/dist/web/widgets/quoted-text.d.ts +16 -0
- package/dist/web/widgets/quoted-text.js +76 -0
- package/dist/web/widgets/status-badge.js +3 -1
- package/dist/web/widgets/step-list-fit.d.ts +25 -0
- package/dist/web/widgets/step-list-fit.js +79 -0
- package/dist/web/widgets/step-list-row.d.ts +50 -0
- package/dist/web/widgets/step-list-row.js +97 -0
- package/dist/web/widgets/step-list.d.ts +33 -0
- package/dist/web/widgets/step-list.js +36 -0
- package/dist/web/widgets/surfaces.d.ts +23 -0
- package/dist/web/widgets/surfaces.js +15 -0
- package/dist/web/widgets/use-in-view.d.ts +5 -0
- package/dist/web/widgets/use-in-view.js +18 -0
- package/package.json +5 -5
- package/src/changes.json +192 -0
- package/src/web/styles.css +22 -0
|
@@ -20,7 +20,7 @@ import { qualifyScreenId } from "./qualify-screen-id.js";
|
|
|
20
20
|
import { QueryLoadingBanner } from "./query-state-banners.js";
|
|
21
21
|
import { navigateToReturn, navigateToReturnOr, useReturnTarget } from "./return-to.js";
|
|
22
22
|
import { screenAccessAllows } from "./screen-access.js";
|
|
23
|
-
import { formatSummaryParams, navigateAfterDrawerSubmit, navigateToRedirectTarget, redirectScreenTarget, resolveActionFormSummary, resolveRedirectTarget, resolveSuccessLinks, resolveSuccessMessageParams, returnToWinsOverRedirect, ScreenAccessDeniedBanner, ScreenMissingState, } from "./screen-shared.js";
|
|
23
|
+
import { formatSummaryParams, navigateAfterDrawerSubmit, navigateToRedirectTarget, redirectScreenTarget, resolveActionFormSummary, resolveRedirectTarget, resolveSuccessItems, resolveSuccessLinks, resolveSuccessMessageParams, returnToWinsOverRedirect, ScreenAccessDeniedBanner, ScreenMissingState, } from "./screen-shared.js";
|
|
24
24
|
export function useDrawerAction(schema) {
|
|
25
25
|
const [drawerState, setDrawerState] = useState(null);
|
|
26
26
|
const drawerAction = drawerState?.action ?? null;
|
|
@@ -90,6 +90,20 @@ export function DrawerHost({ schema, drawerAction, drawerScreen, drawerInitialVa
|
|
|
90
90
|
onSuccess();
|
|
91
91
|
}, onCancelOverride: requestClose, onDirtyChange: setHasUnsavedInput, submitLabelFallback: drawerAction.label })) }) }) }), _jsx(Dialog, { open: confirmDiscardOpen, onOpenChange: setConfirmDiscardOpen, title: t("kumiko.drawer.discard.title"), description: t("kumiko.drawer.discard.body"), confirmLabel: t("kumiko.drawer.discard.confirm"), cancelLabel: t("kumiko.drawer.discard.cancel"), variant: "danger", initialFocus: "cancel", onConfirm: closeAndReset, testId: "drawer-discard-dialog" })] }));
|
|
92
92
|
}
|
|
93
|
+
function declaresSuccessContent(screen) {
|
|
94
|
+
return ((screen.successLinks?.length ?? 0) > 0 ||
|
|
95
|
+
(screen.successFacts?.length ?? 0) > 0 ||
|
|
96
|
+
screen.successItems !== undefined);
|
|
97
|
+
}
|
|
98
|
+
function buildSuccessState(text, screen, resultData, context) {
|
|
99
|
+
const { schema, appFeatures, nav, translate, locale } = context;
|
|
100
|
+
return {
|
|
101
|
+
text,
|
|
102
|
+
links: resolveSuccessLinks(screen.successLinks, resultData, schema, appFeatures, nav, translate),
|
|
103
|
+
facts: resolveSuccessFacts(screen.successFacts, resultData, translate, locale),
|
|
104
|
+
items: resolveSuccessItems(screen.successItems, resultData, schema, appFeatures, nav, translate),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
93
107
|
// Action form body: non-CRUD form driven by a write handler. Reuses
|
|
94
108
|
// RenderEdit via a synthesized EntityDefinition + EntityEditScreen
|
|
95
109
|
// definition (see action-form-shim.ts for the debt doc). The form mechanics
|
|
@@ -192,15 +206,16 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
|
|
|
192
206
|
return;
|
|
193
207
|
}
|
|
194
208
|
if (screen.redirect === undefined) {
|
|
195
|
-
const hasSuccessLinks = (screen.successLinks?.length ?? 0) > 0 || (screen.successFacts?.length ?? 0) > 0;
|
|
196
209
|
const publish = (text) => {
|
|
197
210
|
if (successSequence.current !== sequence)
|
|
198
211
|
return;
|
|
199
|
-
setSuccess({
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
212
|
+
setSuccess(buildSuccessState(text, screen, result.data, {
|
|
213
|
+
schema,
|
|
214
|
+
appFeatures,
|
|
215
|
+
nav,
|
|
216
|
+
translate: effectiveTranslate,
|
|
217
|
+
locale,
|
|
218
|
+
}));
|
|
204
219
|
};
|
|
205
220
|
const messageKey = screen.successMessage;
|
|
206
221
|
if (messageKey !== undefined) {
|
|
@@ -209,7 +224,7 @@ export function ActionFormBody({ schema, screen, translate, entityId, initialOve
|
|
|
209
224
|
.then(show)
|
|
210
225
|
.catch(() => show(formatSummaryParams(values, locale)));
|
|
211
226
|
}
|
|
212
|
-
else if (
|
|
227
|
+
else if (declaresSuccessContent(screen) || screen.resetOnSuccess === true) {
|
|
213
228
|
publish(effectiveTranslate("kumiko.actionForm.success"));
|
|
214
229
|
}
|
|
215
230
|
if (screen.resetOnSuccess === true) {
|
|
@@ -48,10 +48,17 @@ export type ResolvedSuccessFact = {
|
|
|
48
48
|
readonly label: string;
|
|
49
49
|
readonly lines: readonly string[];
|
|
50
50
|
};
|
|
51
|
+
export type ResolvedSuccessItem = {
|
|
52
|
+
readonly key: string;
|
|
53
|
+
readonly label: string;
|
|
54
|
+
readonly link?: ResolvedSuccessLink;
|
|
55
|
+
};
|
|
51
56
|
export type ActionFormSuccessState = {
|
|
52
57
|
readonly text: string;
|
|
53
58
|
readonly links: readonly ResolvedSuccessLink[];
|
|
54
59
|
readonly facts: readonly ResolvedSuccessFact[];
|
|
60
|
+
/** Per-entry hints; while any is shown they replace `text`. */
|
|
61
|
+
readonly items?: readonly ResolvedSuccessItem[];
|
|
55
62
|
};
|
|
56
63
|
export declare function resolveSuccessFacts(facts: readonly ActionFormSuccessFact[] | undefined, data: unknown, translate: (key: string) => string, locale: string): readonly ResolvedSuccessFact[];
|
|
57
64
|
export declare function ActionFormSuccessBanner({ success, }: {
|
|
@@ -95,14 +95,27 @@ export function resolveSuccessFacts(facts, data, translate, locale) {
|
|
|
95
95
|
function positionedLines(lines) {
|
|
96
96
|
return lines.map((line, position) => ({ position: String(position), line }));
|
|
97
97
|
}
|
|
98
|
+
function SuccessItemHints({ items, }) {
|
|
99
|
+
const { Banner, Grid, Link, Text } = usePrimitives();
|
|
100
|
+
return (_jsx(Grid, { columns: 1, testId: "action-form-success-items", children: items.map((item) => (_jsx(Banner, { variant: "hint", testId: `action-form-success-item-${item.key}`, ...(item.link !== undefined && {
|
|
101
|
+
actions: (_jsx(Link, { href: item.link.href, onPress: item.link.onPress, className: "underline", testId: `action-form-success-item-${item.key}-link`, children: item.link.label })),
|
|
102
|
+
}), children: _jsx(Text, { children: item.label }) }, item.key))) }));
|
|
103
|
+
}
|
|
98
104
|
export function ActionFormSuccessBanner({ success, }) {
|
|
99
105
|
const { Banner, Grid, Link, Text } = usePrimitives();
|
|
106
|
+
const items = success.items ?? [];
|
|
107
|
+
const hasFactsOrLinks = success.facts.length > 0 || success.links.length > 0;
|
|
108
|
+
if (items.length > 0 && !hasFactsOrLinks)
|
|
109
|
+
return _jsx(SuccessItemHints, { items: items });
|
|
100
110
|
// Text renders inline, so the message and each fact sit in a one-column grid to get their own lines.
|
|
101
|
-
|
|
111
|
+
const banner = (_jsxs(Banner, { variant: "info", testId: "action-form-success", children: [_jsxs(Grid, { columns: 1, children: [items.length === 0 && _jsx(Text, { testId: "action-form-success-text", children: success.text }), success.facts.map((fact) => {
|
|
102
112
|
const factTestId = `action-form-success-fact-${fact.key}`;
|
|
103
113
|
if (fact.lines.length === 1) {
|
|
104
114
|
return (_jsxs(Text, { testId: factTestId, children: [fact.label, ": ", fact.lines[0]] }, fact.key));
|
|
105
115
|
}
|
|
106
116
|
return (_jsxs(Grid, { columns: 1, testId: factTestId, children: [_jsxs(Text, { children: [fact.label, ":"] }), positionedLines(fact.lines).map(({ position, line }) => (_jsx(Text, { testId: `${factTestId}-line-${position}`, children: line }, position)))] }, fact.key));
|
|
107
117
|
})] }), success.links.map((link) => (_jsx(Link, { href: link.href, onPress: link.onPress, className: "ml-2 underline", testId: `action-form-success-link-${link.key}`, children: link.label }, link.key)))] }));
|
|
118
|
+
if (items.length === 0)
|
|
119
|
+
return banner;
|
|
120
|
+
return (_jsxs(Grid, { columns: 1, children: [_jsx(SuccessItemHints, { items: items }), banner] }));
|
|
108
121
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ConfigEditAction } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
export declare function ConfigEditActionRow({ action, dirty, translate, }: {
|
|
4
|
+
readonly action: ConfigEditAction;
|
|
5
|
+
readonly dirty: boolean;
|
|
6
|
+
readonly translate?: (key: string, params?: Readonly<Record<string, unknown>>) => string;
|
|
7
|
+
}): ReactNode;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useDispatcher } from "../context/dispatcher-context.js";
|
|
4
|
+
import { useTranslation } from "../i18n.js";
|
|
5
|
+
import { usePrimitives } from "../primitives.js";
|
|
6
|
+
import { useClientActionRuntime } from "./client-actions.js";
|
|
7
|
+
import { dispatcherErrorText } from "./write-failed-error.js";
|
|
8
|
+
// Calls the handler with `{}` and never touches the form: the button waits for a saved form so
|
|
9
|
+
// the handler works on what is stored, not on what is typed.
|
|
10
|
+
export function ConfigEditActionRow({ action, dirty, translate, }) {
|
|
11
|
+
const { Field, Button, Banner, Text, Grid } = usePrimitives();
|
|
12
|
+
const t = useTranslation();
|
|
13
|
+
const translateKey = translate ?? t;
|
|
14
|
+
const dispatcher = useDispatcher();
|
|
15
|
+
const { notify } = useClientActionRuntime();
|
|
16
|
+
const [busy, setBusy] = useState(false);
|
|
17
|
+
const [outcome, setOutcome] = useState(null);
|
|
18
|
+
const report = (next) => {
|
|
19
|
+
if (notify !== undefined)
|
|
20
|
+
notify(next);
|
|
21
|
+
else
|
|
22
|
+
setOutcome(next);
|
|
23
|
+
};
|
|
24
|
+
const run = async () => {
|
|
25
|
+
setBusy(true);
|
|
26
|
+
setOutcome(null);
|
|
27
|
+
try {
|
|
28
|
+
const result = await dispatcher.write(action.handler, {});
|
|
29
|
+
if (!result.isSuccess) {
|
|
30
|
+
report({ tone: "error", text: dispatcherErrorText(result.error, translateKey) });
|
|
31
|
+
}
|
|
32
|
+
else if (action.successMessage !== undefined) {
|
|
33
|
+
report({ tone: "success", text: translateKey(action.successMessage) });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
report({ tone: "error", text: translateKey("kumiko.form.error.generic") });
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
setBusy(false);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const saveFirst = translateKey("kumiko.configEdit.action.saveFirst");
|
|
44
|
+
return (_jsxs(Field, { id: `config-edit-action-${action.id}`, label: translateKey(action.label), layout: "row", ...(action.description !== undefined && { description: translateKey(action.description) }), testId: `config-edit-action-${action.id}`, children: [_jsx(Grid, { columns: "auto", children: _jsx(Button, { type: "button", variant: "secondary", disabled: dirty || busy, loading: busy, title: dirty ? saveFirst : translateKey(action.buttonLabel), onClick: run, testId: `config-edit-action-${action.id}-button`, children: translateKey(action.buttonLabel) }) }), dirty && (_jsx(Text, { variant: "small", testId: `config-edit-action-${action.id}-hint`, children: saveFirst })), outcome !== null && (_jsx(Banner, { variant: outcome.tone === "error" ? "error" : "info", testId: `config-edit-action-${action.id}-outcome`, children: outcome.text }))] }));
|
|
45
|
+
}
|
|
@@ -10,6 +10,7 @@ import { useQuery } from "../hooks/use-query.js";
|
|
|
10
10
|
import { useTranslation } from "../i18n.js";
|
|
11
11
|
import { usePrimitives } from "../primitives.js";
|
|
12
12
|
import { screenFillsHeight } from "../screen-fills-height.js";
|
|
13
|
+
import { ConfigEditActionRow } from "./config-edit-action-row.js";
|
|
13
14
|
import { buildConfigEditSchema, synthesizeConfigEditEntity, synthesizeConfigEditScreen, } from "./config-edit-shim.js";
|
|
14
15
|
import { configEditWithoutSecretFields } from "./config-edit-without-secret-fields.js";
|
|
15
16
|
import { buildInitialValues } from "./entity-edit-prefill.js";
|
|
@@ -78,6 +79,23 @@ function buildConfigEditDefaults(fields) {
|
|
|
78
79
|
}
|
|
79
80
|
return defaults;
|
|
80
81
|
}
|
|
82
|
+
// Stable identities: the payload is a useQuery key.
|
|
83
|
+
const SYSTEM_SECRET_SCOPE = { scope: "system" };
|
|
84
|
+
const NO_SECRET_SCOPE = {};
|
|
85
|
+
function secretScopePayloadFor(scope) {
|
|
86
|
+
return scope === "system" ? SYSTEM_SECRET_SCOPE : NO_SECRET_SCOPE;
|
|
87
|
+
}
|
|
88
|
+
function actionRowsAfterField(actions, translate) {
|
|
89
|
+
if (actions === undefined)
|
|
90
|
+
return {};
|
|
91
|
+
const rowAfterField = (fieldName, { dirty }) => {
|
|
92
|
+
const here = actions.filter((action) => action.afterField === fieldName);
|
|
93
|
+
if (here.length === 0)
|
|
94
|
+
return undefined;
|
|
95
|
+
return here.map((action) => (_jsx(ConfigEditActionRow, { action: action, dirty: dirty, translate: translate }, action.id)));
|
|
96
|
+
};
|
|
97
|
+
return { rowAfterField };
|
|
98
|
+
}
|
|
81
99
|
// A field hidden by its `visible` condition (a provider's settings while another
|
|
82
100
|
// provider is picked) is not saved: the form saves what it shows.
|
|
83
101
|
function hiddenLayoutFieldNames(screen, values) {
|
|
@@ -104,7 +122,10 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
|
|
|
104
122
|
const cascadeQuery = useQuery("config:query:cascade", {
|
|
105
123
|
scope: declaredScreen.scope,
|
|
106
124
|
});
|
|
107
|
-
|
|
125
|
+
// Platform-wide secrets live under the system tenant; the server picks that target from the
|
|
126
|
+
// scope alone and only lets a SystemAdmin through.
|
|
127
|
+
const secretScopePayload = secretScopePayloadFor(declaredScreen.scope);
|
|
128
|
+
const secretsQuery = useQuery("secrets:query:list", secretScopePayload, { enabled: declaredScreen.secretKeys !== undefined });
|
|
108
129
|
// The form screen's access is the union of config and secrets access, so a viewer may write
|
|
109
130
|
// the config keys without being allowed to list secrets: that must not take the form down.
|
|
110
131
|
const secretsDenied = secretsQuery.error?.code === "access_denied";
|
|
@@ -211,11 +232,17 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
|
|
|
211
232
|
// Same wire shape as a writeOnly config field: null removes, a string replaces.
|
|
212
233
|
if (value === null) {
|
|
213
234
|
commandFieldNames.push(shortName);
|
|
214
|
-
commands.push({
|
|
235
|
+
commands.push({
|
|
236
|
+
type: "secrets:write:delete",
|
|
237
|
+
payload: { key: secretKey, ...secretScopePayload },
|
|
238
|
+
});
|
|
215
239
|
}
|
|
216
240
|
else if (typeof value === "string" && value.trim() !== "") {
|
|
217
241
|
commandFieldNames.push(shortName);
|
|
218
|
-
commands.push({
|
|
242
|
+
commands.push({
|
|
243
|
+
type: "secrets:write:set",
|
|
244
|
+
payload: { key: secretKey, value, ...secretScopePayload },
|
|
245
|
+
});
|
|
219
246
|
}
|
|
220
247
|
continue;
|
|
221
248
|
}
|
|
@@ -306,6 +333,7 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
|
|
|
306
333
|
valuesQuery.refetch,
|
|
307
334
|
cascadeQuery.refetch,
|
|
308
335
|
secretsQuery.refetch,
|
|
336
|
+
secretScopePayload,
|
|
309
337
|
]);
|
|
310
338
|
if (valuesQuery.loading && valuesQuery.data === null)
|
|
311
339
|
return _jsx(QueryLoadingBanner, {});
|
|
@@ -335,7 +363,7 @@ export function ConfigEditBody({ schema, screen: declaredScreen, translate, }) {
|
|
|
335
363
|
return (value) => buildOptionLabels(effectiveTranslate, (option) => fieldOptionLabelKey(schema.featureName, synthScreen.entity, fieldName, option), [String(value)])[String(value)];
|
|
336
364
|
};
|
|
337
365
|
return (_jsx(RenderEdit, { screen: synthScreen, entity: synthEntity, featureName: schema.featureName, initial: initial, schema: boundsSchema, customSubmit: customSubmit, dirtyFooter: true, validateOnChange: true, ...(screenFillsHeight(screen) && { fillScreenHeight: true }), ...(screen.submitLabel !== undefined && { submitLabel: screen.submitLabel }), ...(translate !== undefined && { translate }), fieldAppendixPlacement: "below-control", fieldAccent: (fieldName) => cascades[fieldName]?.levels.find((level) => level.isActive)?.source ===
|
|
338
|
-
CONFIG_SCOPE_SOURCE[screen.scope], markChangedFields: true, ...(screen.fieldDescriptions !== undefined && {
|
|
366
|
+
CONFIG_SCOPE_SOURCE[screen.scope], markChangedFields: true, ...actionRowsAfterField(screen.actions, effectiveTranslate), ...(screen.fieldDescriptions !== undefined && {
|
|
339
367
|
fieldDescription: (fieldName) => {
|
|
340
368
|
const key = screen.fieldDescriptions?.[fieldName];
|
|
341
369
|
return key === undefined ? undefined : effectiveTranslate(key);
|
|
@@ -14,6 +14,7 @@ import { useListUrlState } from "../hooks/use-list-url-state.js";
|
|
|
14
14
|
import { useTranslation } from "../i18n.js";
|
|
15
15
|
import { usePrimitives } from "../primitives.js";
|
|
16
16
|
import { screenFillsHeight } from "../screen-fills-height.js";
|
|
17
|
+
import { toggleSetMember } from "../toggle-set-member.js";
|
|
17
18
|
import { DrawerHost, useDrawerAction } from "./action-form-body.js";
|
|
18
19
|
import { useAppFeatures } from "./app-features-context.js";
|
|
19
20
|
import { useClientActionRuntime } from "./client-actions.js";
|
|
@@ -47,6 +48,10 @@ export function EntityListScreen({ schema, screen, translate, onRowClick, }) {
|
|
|
47
48
|
// dev-error state; no point hitting the server for it.
|
|
48
49
|
return (_jsx(EntityListBody, { schema: schema, screen: screen, entity: entity, ...(translate !== undefined && { translate }), ...(onRowClick !== undefined && { onRowClick }) }));
|
|
49
50
|
}
|
|
51
|
+
// An embedding tile already shows the description in its section head.
|
|
52
|
+
function toolbarDescriptionOf(description, isEmbedded, translate) {
|
|
53
|
+
return description === undefined || isEmbedded ? undefined : translate(description);
|
|
54
|
+
}
|
|
50
55
|
function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
51
56
|
const isEmbeddedScreen = useIsEmbeddedScreen();
|
|
52
57
|
const featureName = schema.featureName;
|
|
@@ -77,6 +82,7 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
77
82
|
// otherwise the hook slots collide between renders.
|
|
78
83
|
const t = useTranslation();
|
|
79
84
|
const effectiveTranslate = translate ?? t;
|
|
85
|
+
const toolbarDescription = toolbarDescriptionOf(screen.description, isEmbeddedScreen, effectiveTranslate);
|
|
80
86
|
const range = useEntityRangeFacets({
|
|
81
87
|
fields: entity.fields,
|
|
82
88
|
screen,
|
|
@@ -360,14 +366,7 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
360
366
|
: undefined, [expandableRow, effectiveTranslate]);
|
|
361
367
|
const [expandedRowIds, setExpandedRowIds] = useState(() => new Set());
|
|
362
368
|
const toggleRowExpanded = useCallback((rowId) => {
|
|
363
|
-
setExpandedRowIds((prev) =>
|
|
364
|
-
const next = new Set(prev);
|
|
365
|
-
if (next.has(rowId))
|
|
366
|
-
next.delete(rowId);
|
|
367
|
-
else
|
|
368
|
-
next.add(rowId);
|
|
369
|
-
return next;
|
|
370
|
-
});
|
|
369
|
+
setExpandedRowIds((prev) => toggleSetMember(prev, rowId));
|
|
371
370
|
}, []);
|
|
372
371
|
// Bumped after a write that ran outside the sub-list (drawer submit,
|
|
373
372
|
// title-row action) so open sub-lists remount and reload.
|
|
@@ -420,9 +419,7 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
420
419
|
// pager (the pager has its own total>0 guard).
|
|
421
420
|
const pager = listPager({ usePager, page: listRows.page, limit, urlState });
|
|
422
421
|
return (_jsxs(_Fragment, { children: [refetchErrorBanner, _jsx(ListGroupPageBridges, { ...listTable.aggregates.groupPages }), _jsx(ReferenceFacetBridges, { specs: entityFacetSpecs, selected: urlState.filters, onState: handleEntityFacetOptions }), _jsx(FacetCountBridges, { queryType: queryType, queries: facetCountQueries, onCount: handleFacetCount, refreshNonce: facetCountRefreshNonce }), _jsx(RenderList, { screen: screen, entity: entity, rows: listRows.rows, featureName: featureName, searchable: searchable, narrowed: activeNamedFilter !== undefined ||
|
|
423
|
-
isListNarrowed(urlState.q, urlState.filters, defaultFilters), defaultFilterActive: isDefaultFilterActive(urlState.q, urlState.filters, defaultFilters), ...(
|
|
424
|
-
description: effectiveTranslate(screen.description),
|
|
425
|
-
}), ...(emptyContent !== undefined && { emptyContent }), searchValue: urlState.q, onSearchChange: urlState.setQ, sort: effectiveSort, onSortChange: urlState.setSort, ...(isEmbeddedScreen
|
|
422
|
+
isListNarrowed(urlState.q, urlState.filters, defaultFilters), defaultFilterActive: isDefaultFilterActive(urlState.q, urlState.filters, defaultFilters), ...(toolbarDescription !== undefined && { description: toolbarDescription }), ...(emptyContent !== undefined && { emptyContent }), searchValue: urlState.q, onSearchChange: urlState.setQ, sort: effectiveSort, onSortChange: urlState.setSort, ...(isEmbeddedScreen
|
|
426
423
|
? { screenPadding: false, chromeless: true }
|
|
427
424
|
: { screenPadding: true }), ...(screenFillsHeight(screen) && { scrollBody: true }), ...(pager !== undefined && { pager }), ...(rowActions !== undefined && { rowActions }), ...(screen.rowActionMode !== undefined && { rowActionMode: screen.rowActionMode }), ...(bulk !== undefined && { bulk }), ...(toolbarActions !== undefined && toolbarActions.length > 0 && { toolbarActions }), ...listRows.infinite, ...(onCreate !== undefined && { onCreate }), ...(translate !== undefined && { translate }), ...(wrappedOnRowClick !== undefined && { onRowClick: wrappedOnRowClick }), ...(filterFacets.length > 0 && { filterFacets, onFilterChange }), ...(range.rangeFacets.length > 0 && {
|
|
428
425
|
rangeFacets: range.rangeFacets,
|
package/dist/app/nav.js
CHANGED
|
@@ -51,7 +51,8 @@ export function formatPath(target) {
|
|
|
51
51
|
const segments = [];
|
|
52
52
|
if (target.workspaceId !== undefined)
|
|
53
53
|
segments.push(target.workspaceId);
|
|
54
|
-
|
|
54
|
+
// Targets may arrive as <feature>:screen:<id>; the URL carries short ids only.
|
|
55
|
+
segments.push(lastSegment(target.screenId));
|
|
55
56
|
if (target.entityId !== undefined)
|
|
56
57
|
segments.push(target.entityId);
|
|
57
58
|
return `/${segments.map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
@@ -3,7 +3,7 @@ import { useState } from "react";
|
|
|
3
3
|
import { RenderEdit } from "../components/render-edit.js";
|
|
4
4
|
import { useOptionalDispatcher } from "../context/dispatcher-context.js";
|
|
5
5
|
import { useUserRoles } from "../context/user-roles-context.js";
|
|
6
|
-
import { useTranslation } from "../i18n.js";
|
|
6
|
+
import { useLocale, useTranslation } from "../i18n.js";
|
|
7
7
|
import { usePageHeaderCompact, usePageHeaderSlotAvailable } from "../page-header-slot.js";
|
|
8
8
|
import { usePrimitives } from "../primitives.js";
|
|
9
9
|
import { screenFillsHeight } from "../screen-fills-height.js";
|
|
@@ -34,6 +34,7 @@ import { useRelatedListTabCounts } from "./use-related-list-tab-counts.js";
|
|
|
34
34
|
export function ProjectionDetailBody({ schema, screen, translate, entityId, }) {
|
|
35
35
|
const primitives = usePrimitives();
|
|
36
36
|
const t = useTranslation();
|
|
37
|
+
const locale = useLocale().locale();
|
|
37
38
|
const pageHeaderSlotAvailable = usePageHeaderSlotAvailable();
|
|
38
39
|
const pageHeaderCompactContext = usePageHeaderCompact();
|
|
39
40
|
const effectiveTranslate = translate ?? t;
|
|
@@ -103,6 +104,7 @@ export function ProjectionDetailBody({ schema, screen, translate, entityId, }) {
|
|
|
103
104
|
record,
|
|
104
105
|
primitives,
|
|
105
106
|
effectiveTranslate,
|
|
107
|
+
locale,
|
|
106
108
|
nav,
|
|
107
109
|
appFeatures,
|
|
108
110
|
userRoles,
|
|
@@ -12,6 +12,7 @@ export type DetailHeaderModel = {
|
|
|
12
12
|
readonly record: Readonly<Record<string, unknown>>;
|
|
13
13
|
readonly primitives: ReturnType<typeof usePrimitives>;
|
|
14
14
|
readonly effectiveTranslate: Translate;
|
|
15
|
+
readonly locale: string;
|
|
15
16
|
readonly nav: NavApi;
|
|
16
17
|
readonly appFeatures: readonly FeatureSchema[];
|
|
17
18
|
readonly userRoles: readonly string[] | undefined;
|
|
@@ -33,7 +33,7 @@ export function renderHeaderSubtitleSlot(model) {
|
|
|
33
33
|
const { screen, record, nav, appFeatures, userRoles, host } = model;
|
|
34
34
|
const header = screen.header;
|
|
35
35
|
const subtitleParts = header !== undefined && typeof header.subtitle === "object"
|
|
36
|
-
? buildSubtitleParts(header.subtitle, record, nav, appFeatures, userRoles, host)
|
|
36
|
+
? buildSubtitleParts(header.subtitle, record, nav, appFeatures, userRoles, host, model.effectiveTranslate, model.locale)
|
|
37
37
|
: undefined;
|
|
38
38
|
return subtitleParts !== undefined
|
|
39
39
|
? subtitleParts.length > 0
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MetricNavigate, RecordHeaderSubtitlePart } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import { type Translate } from "../headless/index.ts";
|
|
2
3
|
import type { FeatureSchema } from "./feature-schema.ts";
|
|
3
4
|
import type { NavApi } from "./nav.tsx";
|
|
4
5
|
import type { ReturnHost } from "./return-to.tsx";
|
|
@@ -11,4 +12,4 @@ export type SubtitlePartView = {
|
|
|
11
12
|
readonly onPress?: () => void;
|
|
12
13
|
};
|
|
13
14
|
export declare function metricNavigateResolves(navigate: MetricNavigate, record: Readonly<Record<string, unknown>>): boolean;
|
|
14
|
-
export declare function buildSubtitleParts(parts: readonly RecordHeaderSubtitlePart[], record: Readonly<Record<string, unknown>>, nav: NavApi, appFeatures: readonly FeatureSchema[], userRoles: readonly string[] | undefined, host: ReturnHost | undefined): SubtitlePartView[];
|
|
15
|
+
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[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isSafeHref } from "../headless/index.js";
|
|
1
|
+
import { applyFormatSpec, isSafeHref } from "../headless/index.js";
|
|
2
2
|
import { requestLeave } from "../leave-guard.js";
|
|
3
3
|
import { runProjectionRowNavigate } from "./row-actions.js";
|
|
4
4
|
import { navigateTargetAllows } from "./screen-access.js";
|
|
@@ -79,10 +79,13 @@ function hrefForNavigate(nav, navigate, record) {
|
|
|
79
79
|
}
|
|
80
80
|
return undefined;
|
|
81
81
|
}
|
|
82
|
-
export function buildSubtitleParts(parts, record, nav, appFeatures, userRoles, host) {
|
|
82
|
+
export function buildSubtitleParts(parts, record, nav, appFeatures, userRoles, host, translate, locale) {
|
|
83
83
|
return parts.flatMap((part) => {
|
|
84
84
|
const field = typeof part === "string" ? part : part.field;
|
|
85
|
-
const
|
|
85
|
+
const format = typeof part === "string" ? undefined : part.format;
|
|
86
|
+
const text = format === undefined
|
|
87
|
+
? String(record[field] ?? "")
|
|
88
|
+
: applyFormatSpec({ ...format, locale: ("locale" in format ? format.locale : undefined) ?? locale }, record[field], translate);
|
|
86
89
|
// skip: empty subtitle parts render nothing
|
|
87
90
|
if (text === "")
|
|
88
91
|
return [];
|
|
@@ -32,9 +32,11 @@ export function synthesizeProjectionDetailEntity(layout) {
|
|
|
32
32
|
if (!isFieldsEditSection(section))
|
|
33
33
|
continue;
|
|
34
34
|
for (const spec of sectionFieldSpecs(section)) {
|
|
35
|
-
|
|
35
|
+
const { field, format } = normalizeEditField(spec);
|
|
36
|
+
fields[field] = {
|
|
36
37
|
type: "text",
|
|
37
38
|
allowPlaintext: SYNTHESIZED_FIELD_PII_REASON,
|
|
39
|
+
...(format !== undefined && { format }),
|
|
38
40
|
};
|
|
39
41
|
}
|
|
40
42
|
}
|
|
@@ -6,7 +6,7 @@ import type { useProjectionListData } from "./use-projection-list-data.ts";
|
|
|
6
6
|
import type { useProjectionListDefinitions } from "./use-projection-list-definitions.ts";
|
|
7
7
|
import type { useProjectionListQuery } from "./use-projection-list-query.ts";
|
|
8
8
|
import type { listPager } from "./use-screen-list-rows.ts";
|
|
9
|
-
export declare function projectionLeadProps(screen: ProjectionListScreenDefinition, effectiveTranslate: Translate, emptyContent: ReturnType<typeof useProjectionListActions>["emptyContent"]): {
|
|
9
|
+
export declare function projectionLeadProps(screen: ProjectionListScreenDefinition, effectiveTranslate: Translate, emptyContent: ReturnType<typeof useProjectionListActions>["emptyContent"], isEmbeddedScreen: boolean): {
|
|
10
10
|
description?: string | undefined;
|
|
11
11
|
emptyContent?: import("../components/list-empty-state.tsx").ListEmptyStateContent | undefined;
|
|
12
12
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { screenFillsHeight } from "../screen-fills-height.js";
|
|
2
2
|
import { routeFacetChange, withNamedFilterValues } from "./named-filter-facet.js";
|
|
3
|
-
export function projectionLeadProps(screen, effectiveTranslate, emptyContent) {
|
|
3
|
+
export function projectionLeadProps(screen, effectiveTranslate, emptyContent, isEmbeddedScreen) {
|
|
4
4
|
return {
|
|
5
|
-
|
|
5
|
+
// An embedding tile already shows the description in its section head.
|
|
6
|
+
...(screen.description !== undefined &&
|
|
7
|
+
!isEmbeddedScreen && {
|
|
6
8
|
description: effectiveTranslate(screen.description),
|
|
7
9
|
}),
|
|
8
10
|
...(emptyContent !== undefined && { emptyContent }),
|
|
@@ -17,5 +17,5 @@ export function renderProjectionList(model) {
|
|
|
17
17
|
const { filterFacets, listRows, listTable } = data;
|
|
18
18
|
const { dateRangeFacets } = query;
|
|
19
19
|
return (_jsx(RenderList, { screen: definitions.listScreen, entity: definitions.entity, rows: listRows.rows, featureName: schema.featureName, searchable: definitions.searchable, narrowed: query.activeNamedFilter !== undefined ||
|
|
20
|
-
isListNarrowed(query.activeSearch, urlState.filters), ...projectionLeadProps(screen, effectiveTranslate, actions.emptyContent), searchValue: urlState.q, onSearchChange: urlState.setQ, sort: query.activeSort, onSortChange: urlState.setSort, ...projectionLayoutProps(isEmbeddedScreen, screen, definitions.listScreen, pager, actions.rowActions), ...projectionActionProps(actions, translate, wrappedOnRowClick), ...projectionFacetProps(filterFacets, dateRangeFacets, query.handleDateRangeChange, urlState), ...listTable.props, ...projectionFilterStateProps(filterFacets, dateRangeFacets, urlState, query.activeNamedFilter) }));
|
|
20
|
+
isListNarrowed(query.activeSearch, urlState.filters), ...projectionLeadProps(screen, effectiveTranslate, actions.emptyContent, isEmbeddedScreen), searchValue: urlState.q, onSearchChange: urlState.setQ, sort: query.activeSort, onSortChange: urlState.setSort, ...projectionLayoutProps(isEmbeddedScreen, screen, definitions.listScreen, pager, actions.rowActions), ...projectionActionProps(actions, translate, wrappedOnRowClick), ...projectionFacetProps(filterFacets, dateRangeFacets, query.handleDateRangeChange, urlState), ...listTable.props, ...projectionFilterStateProps(filterFacets, dateRangeFacets, urlState, query.activeNamedFilter) }));
|
|
21
21
|
}
|
|
@@ -29,9 +29,11 @@ export function navigateTargetAllows(navigate, appFeatures, userRoles) {
|
|
|
29
29
|
if (found !== undefined)
|
|
30
30
|
return isUiAccessGranted(found.screen.access, userRoles);
|
|
31
31
|
}
|
|
32
|
-
else {
|
|
32
|
+
else if (screen !== undefined) {
|
|
33
|
+
// Qualified (<feature>:screen:<id>) and short targets resolve alike.
|
|
34
|
+
const targetId = lastSegment(screen);
|
|
33
35
|
for (const feature of appFeatures) {
|
|
34
|
-
const candidate = feature.screens.find((s) => lastSegment(s.id) ===
|
|
36
|
+
const candidate = feature.screens.find((s) => lastSegment(s.id) === targetId);
|
|
35
37
|
if (candidate !== undefined)
|
|
36
38
|
return isUiAccessGranted(candidate.access, userRoles);
|
|
37
39
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ActionFormRedirect, ActionFormScreenDefinition, ActionFormSuccessLink, ScreenDefinition } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
1
|
+
import type { ActionFormRedirect, ActionFormScreenDefinition, ActionFormSuccessItems, ActionFormSuccessLink, ScreenDefinition } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import type { Dispatcher, Translate } from "../headless/index.ts";
|
|
4
4
|
import { type ListSort } from "../hooks/use-list-url-state.ts";
|
|
5
|
-
import type { ResolvedSuccessLink } from "./action-form-support.tsx";
|
|
5
|
+
import type { ResolvedSuccessItem, ResolvedSuccessLink } from "./action-form-support.tsx";
|
|
6
6
|
import type { FeatureSchema } from "./feature-schema.ts";
|
|
7
7
|
import { type NavApi, type ScreenTarget } from "./nav.tsx";
|
|
8
8
|
/** Empty state for a screen QN that is not in the schema (feature disabled for
|
|
@@ -59,6 +59,7 @@ type ResolvedRedirectTarget = {
|
|
|
59
59
|
};
|
|
60
60
|
export declare function navigateToRedirectTarget(nav: NavApi, target: ResolvedRedirectTarget): void;
|
|
61
61
|
export declare function resolveSuccessLinks(links: readonly ActionFormSuccessLink[] | undefined, data: unknown, schema: FeatureSchema, appFeatures: readonly FeatureSchema[], nav: NavApi, translate: Translate): readonly ResolvedSuccessLink[];
|
|
62
|
+
export declare function resolveSuccessItems(items: ActionFormSuccessItems | undefined, data: unknown, schema: FeatureSchema, appFeatures: readonly FeatureSchema[], nav: NavApi, translate: Translate): readonly ResolvedSuccessItem[];
|
|
62
63
|
export declare function navigateAfterRedirect(options: {
|
|
63
64
|
readonly nav: NavApi;
|
|
64
65
|
readonly schema: FeatureSchema;
|
|
@@ -152,7 +152,7 @@ export async function resolveSuccessMessageParams(screen, featureName, values, d
|
|
|
152
152
|
export function resolveActionFormSummary(summary, prefill, translate, locale) {
|
|
153
153
|
if (summary === undefined)
|
|
154
154
|
return undefined;
|
|
155
|
-
const params = formatSummaryParams(prefill, locale);
|
|
155
|
+
const params = { ...formatSummaryParams(prefill, locale), ...summary.params };
|
|
156
156
|
return {
|
|
157
157
|
title: translate(summary.title, params),
|
|
158
158
|
...(summary.subtitle !== undefined && { subtitle: translate(summary.subtitle, params) }),
|
|
@@ -283,11 +283,18 @@ export function resolveSuccessLinks(links, data, schema, appFeatures, nav, trans
|
|
|
283
283
|
const target = resolveRedirectTarget(link, data, schema, appFeatures);
|
|
284
284
|
if (target.entityId === undefined && redirectTargetsRecord(link, schema, appFeatures))
|
|
285
285
|
return;
|
|
286
|
+
const params = Object.entries(link.params ?? {}).map(([param, field]) => [param, propertyOf(data, field)]);
|
|
287
|
+
if (params.some(([, value]) => typeof value !== "string"))
|
|
288
|
+
return;
|
|
286
289
|
const navTarget = {
|
|
287
290
|
screenId: target.screenId,
|
|
288
291
|
...(target.entityId !== undefined && { entityId: target.entityId }),
|
|
289
292
|
};
|
|
290
|
-
const
|
|
293
|
+
const searchParams = {
|
|
294
|
+
...Object.fromEntries(params),
|
|
295
|
+
...(target.tab !== undefined && { tab: target.tab }),
|
|
296
|
+
};
|
|
297
|
+
const options = Object.keys(searchParams).length === 0 ? undefined : { searchParams };
|
|
291
298
|
resolved.push({
|
|
292
299
|
key: String(index),
|
|
293
300
|
label: translate(link.label),
|
|
@@ -297,6 +304,27 @@ export function resolveSuccessLinks(links, data, schema, appFeatures, nav, trans
|
|
|
297
304
|
});
|
|
298
305
|
return resolved;
|
|
299
306
|
}
|
|
307
|
+
// Hints of the success box, one per payload entry with a string label. The link resolves
|
|
308
|
+
// against the entry like a success link against the whole payload; an entry whose link does
|
|
309
|
+
// not resolve keeps its hint without a link.
|
|
310
|
+
export function resolveSuccessItems(items, data, schema, appFeatures, nav, translate) {
|
|
311
|
+
if (items === undefined)
|
|
312
|
+
return [];
|
|
313
|
+
const entries = propertyOf(data, items.field);
|
|
314
|
+
if (!Array.isArray(entries))
|
|
315
|
+
return [];
|
|
316
|
+
const resolved = [];
|
|
317
|
+
entries.forEach((entry, index) => {
|
|
318
|
+
const label = propertyOf(entry, "label");
|
|
319
|
+
if (typeof label !== "string" || label === "")
|
|
320
|
+
return;
|
|
321
|
+
const [link] = items.link === undefined
|
|
322
|
+
? []
|
|
323
|
+
: resolveSuccessLinks([items.link], entry, schema, appFeatures, nav, translate);
|
|
324
|
+
resolved.push({ key: String(index), label, ...(link !== undefined && { link }) });
|
|
325
|
+
});
|
|
326
|
+
return resolved;
|
|
327
|
+
}
|
|
300
328
|
// Success navigation for a configured redirect — shared by entityEdit's
|
|
301
329
|
// save and writeHandler record actions. The string form navigates without an
|
|
302
330
|
// entityId; the object form resolves like actionForm's, with `record` as the
|
|
@@ -4,5 +4,7 @@ export type EmbeddedScreenTarget = {
|
|
|
4
4
|
readonly schema: FeatureSchema;
|
|
5
5
|
readonly qn: string;
|
|
6
6
|
readonly screenType: ScreenDefinition["type"];
|
|
7
|
+
readonly screenId: string;
|
|
8
|
+
readonly description: string | undefined;
|
|
7
9
|
};
|
|
8
10
|
export declare function useEmbeddedScreen(hostFeatureName: string, screen: string): EmbeddedScreenTarget | undefined;
|
|
@@ -15,5 +15,11 @@ export function useEmbeddedScreen(hostFeatureName, screen) {
|
|
|
15
15
|
return undefined;
|
|
16
16
|
if (!screenAccessAllows(target.access, userRoles))
|
|
17
17
|
return undefined;
|
|
18
|
-
return {
|
|
18
|
+
return {
|
|
19
|
+
schema,
|
|
20
|
+
qn,
|
|
21
|
+
screenType: target.type,
|
|
22
|
+
screenId: target.id,
|
|
23
|
+
description: target.description,
|
|
24
|
+
};
|
|
19
25
|
}
|
|
@@ -2,7 +2,7 @@ import type { PlatformComponent } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import type { EditExtensionSectionViewModel } from "../headless/index.ts";
|
|
4
4
|
import { type StickyPrimaryActionMarker } from "../primitives.tsx";
|
|
5
|
-
export declare function ExtensionSectionMount({ section, entityName: hostEntityName, entityId, initialValues, values, patch, validate, markSaved, hideTitle, actions, stepKey, onReportStepComplete, }: {
|
|
5
|
+
export declare function ExtensionSectionMount({ section, entityName: hostEntityName, entityId, initialValues, values, patch, validate, markSaved, hideTitle, actions, anchorId, stepKey, onReportStepComplete, }: {
|
|
6
6
|
readonly section: EditExtensionSectionViewModel;
|
|
7
7
|
readonly entityName: string;
|
|
8
8
|
readonly entityId: string | null;
|
|
@@ -14,6 +14,8 @@ export declare function ExtensionSectionMount({ section, entityName: hostEntityN
|
|
|
14
14
|
readonly hideTitle?: boolean;
|
|
15
15
|
/** section.actions, already resolved into buttons by the caller. */
|
|
16
16
|
readonly actions?: ReactNode;
|
|
17
|
+
/** DOM id the "on this page" navigation scrolls to. */
|
|
18
|
+
readonly anchorId?: string;
|
|
17
19
|
readonly stepKey?: string;
|
|
18
20
|
readonly onReportStepComplete?: (stepKey: string, complete: boolean) => void;
|
|
19
21
|
}): ReactNode;
|
|
@@ -9,7 +9,7 @@ import { usePrimitives } from "../primitives.js";
|
|
|
9
9
|
// mounts it with the host entity name + id. Hook lives in its own
|
|
10
10
|
// component so we don't call `use*` inside vm.sections.map (rules-of-
|
|
11
11
|
// hooks would punish reordering sections between renders).
|
|
12
|
-
export function ExtensionSectionMount({ section, entityName: hostEntityName, entityId, initialValues, values, patch, validate, markSaved, hideTitle, actions, stepKey, onReportStepComplete, }) {
|
|
12
|
+
export function ExtensionSectionMount({ section, entityName: hostEntityName, entityId, initialValues, values, patch, validate, markSaved, hideTitle, actions, anchorId, stepKey, onReportStepComplete, }) {
|
|
13
13
|
const { Banner, FillContainer, Section, Text } = usePrimitives();
|
|
14
14
|
const name = extensionSectionName(section.component);
|
|
15
15
|
const Component = useExtensionSectionComponent(name);
|
|
@@ -26,12 +26,12 @@ export function ExtensionSectionMount({ section, entityName: hostEntityName, ent
|
|
|
26
26
|
// fields tab (Grid sits directly in the Card there). FillContainer keeps
|
|
27
27
|
// the testId without adding chrome (same primitive RelatedListSection
|
|
28
28
|
// uses for its own hideTitle branch).
|
|
29
|
-
return hideTitle === true ? (FillContainer !== undefined ? (_jsx(FillContainer, { testId: testId, children: placeholder })) : (placeholder)) : (_jsx(Section, { title: section.title, testId: testId, children: placeholder }, section.title));
|
|
29
|
+
return hideTitle === true ? (FillContainer !== undefined ? (_jsx(FillContainer, { testId: testId, children: placeholder })) : (placeholder)) : (_jsx(Section, { ...(anchorId !== undefined && { id: anchorId }), title: section.title, testId: testId, children: placeholder }, section.title));
|
|
30
30
|
}
|
|
31
31
|
const mounted = (_jsx(Component, { entityName: section.entityName ?? hostEntityName, entityId: entityId, initialValues: initialValues, values: values, patch: patch, validate: validate, markSaved: markSaved, ...(onReportStepComplete !== undefined && { reportStepComplete }) }));
|
|
32
32
|
// Same reasoning as the placeholder branch above: tabs mode's outer Card
|
|
33
33
|
// is the only frame this content gets, no nested Section divider.
|
|
34
|
-
return hideTitle === true ? (FillContainer !== undefined ? (_jsx(FillContainer, { testId: testId, children: mounted })) : (mounted)) : (_jsx(Section, { ...(actions !== undefined && { actions }), title: section.title, testId: testId, children: mounted }));
|
|
34
|
+
return hideTitle === true ? (FillContainer !== undefined ? (_jsx(FillContainer, { testId: testId, children: mounted })) : (mounted)) : (_jsx(Section, { ...(actions !== undefined && { actions }), ...(anchorId !== undefined && { id: anchorId }), title: section.title, testId: testId, children: mounted }));
|
|
35
35
|
}
|
|
36
36
|
// Resolves an entityEdit slot's (`screen.slots.header` / `.footer`)
|
|
37
37
|
// `{ react: { __component: "X" } }` marker via the same ExtensionSectionsProvider
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RowActionDrawer } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import type { EditRelatedListSectionViewModel, Translate } from "../headless/index.ts";
|
|
4
|
-
export declare function RelatedListSection({ section, parentId, record, featureName, translate, hideTitle, grow, onOpenDrawer, actions, embedded, onAfterWrite, refreshToken, }: {
|
|
4
|
+
export declare function RelatedListSection({ section, parentId, record, featureName, translate, hideTitle, grow, onOpenDrawer, actions, anchorId, embedded, onAfterWrite, refreshToken, }: {
|
|
5
5
|
readonly section: EditRelatedListSectionViewModel;
|
|
6
6
|
readonly parentId: string;
|
|
7
7
|
/** The enclosing projectionDetail's own record (the "Akte") — evaluates
|
|
@@ -22,6 +22,8 @@ export declare function RelatedListSection({ section, parentId, record, featureN
|
|
|
22
22
|
* (non-`hideTitle`) branch below — `hideTitle` uses `FillContainer`, which
|
|
23
23
|
* has no title row to render actions into (see the comment on that branch). */
|
|
24
24
|
readonly actions?: ReactNode;
|
|
25
|
+
/** DOM id the "on this page" navigation scrolls to. */
|
|
26
|
+
readonly anchorId?: string;
|
|
25
27
|
/** Mounted inside a host row (entityList `expandableRow`): unframed, in
|
|
26
28
|
* document flow (no Section card, no scrollBody), with its own title row
|
|
27
29
|
* carrying `actions`. */
|