@cosmicdrift/kumiko-renderer 0.414.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/entity-list-screen.js +12 -9
- package/dist/app/extension-sections.d.ts +2 -0
- package/dist/app/list-facets.d.ts +1 -0
- package/dist/app/list-facets.js +10 -1
- package/dist/app/named-filter-facet.d.ts +0 -1
- package/dist/app/named-filter-facet.js +19 -10
- package/dist/app/projection-detail-body.js +8 -6
- package/dist/app/projection-detail-guidance-data.js +3 -1
- package/dist/app/projection-detail-guidance.d.ts +1 -1
- package/dist/app/projection-detail-guidance.js +45 -33
- 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 +5 -4
- package/dist/app/projection-detail-navigation.d.ts +6 -0
- package/dist/app/projection-detail-navigation.js +18 -4
- package/dist/app/screen-access.js +1 -2
- package/dist/app/screen-shared.d.ts +1 -0
- package/dist/app/screen-shared.js +23 -3
- package/dist/app/use-entity-list-payload.d.ts +2 -1
- package/dist/app/use-entity-list-payload.js +4 -2
- package/dist/app/use-projection-detail-actions.d.ts +14 -0
- package/dist/app/use-projection-detail-actions.js +40 -16
- package/dist/app/use-projection-detail-data.d.ts +2 -0
- package/dist/app/use-projection-detail-data.js +37 -10
- package/dist/app/use-row-decoration.d.ts +6 -4
- package/dist/app/use-row-decoration.js +67 -19
- package/dist/app/use-screen-list-rows.js +1 -1
- package/dist/card-options.d.ts +25 -0
- package/dist/card-options.js +1 -0
- 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/list-empty-state.d.ts +5 -0
- package/dist/components/list-empty-state.js +17 -1
- 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 +2 -0
- package/dist/components/render-list-hint-columns.js +23 -0
- package/dist/components/render-list-toolbar-model.d.ts +2 -2
- package/dist/components/use-render-edit-sections.js +5 -1
- package/dist/components/use-render-list-columns.js +3 -3
- package/dist/context/screen-focus-context.d.ts +1 -1
- package/dist/context/screen-focus-context.js +3 -3
- package/dist/data-table-facet-types.d.ts +4 -0
- 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 +3 -3
- package/dist/headless/index.js +3 -3
- package/dist/headless/pwa-service-worker-meta.d.ts +3 -0
- package/dist/headless/pwa-service-worker-meta.js +10 -0
- 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 +33 -3
- package/dist/i18n-defaults.js +4 -1
- package/dist/index.d.ts +1 -1
- package/dist/metric-types.d.ts +2 -0
- package/dist/primitives-record-guidance.d.ts +30 -1
- package/dist/primitives.d.ts +17 -27
- package/dist/web/app/dashboard-body.js +3 -2
- package/dist/web/app/dashboard-header.js +1 -1
- package/dist/web/app/dashboard-list-panel.js +9 -13
- package/dist/web/app/dashboard-panel-columns.d.ts +9 -0
- package/dist/web/app/dashboard-panel-columns.js +14 -0
- package/dist/web/app/dashboard-panels.d.ts +1 -0
- package/dist/web/app/dashboard-panels.js +9 -7
- package/dist/web/app/dashboard-reference-list-table.js +1 -0
- package/dist/web/app/dashboard-shared.js +3 -2
- package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -0
- package/dist/web/app/dashboard-stat-group-panel.js +22 -8
- package/dist/web/app/dashboard-text-panel.d.ts +1 -0
- package/dist/web/app/dashboard-text-panel.js +18 -12
- package/dist/web/app/relative-time.d.ts +0 -5
- package/dist/web/app/relative-time.js +1 -20
- package/dist/web/drawn-icons.d.ts +6 -0
- package/dist/web/drawn-icons.js +30 -0
- package/dist/web/icons.js +6 -5
- package/dist/web/index.d.ts +2 -0
- package/dist/web/index.js +2 -0
- package/dist/web/layout/default-app-shell.js +3 -3
- package/dist/web/layout/nav-collapse-state.d.ts +2 -0
- package/dist/web/layout/nav-collapse-state.js +10 -0
- package/dist/web/layout/nav-tree.js +46 -23
- package/dist/web/layout/notification-bell.d.ts +7 -2
- package/dist/web/layout/notification-bell.js +16 -5
- package/dist/web/layout/shell-focus.d.ts +2 -2
- package/dist/web/layout/shell-focus.js +7 -3
- package/dist/web/layout/shell-header.d.ts +2 -1
- package/dist/web/layout/shell-header.js +56 -27
- package/dist/web/layout/shell-style.d.ts +3 -0
- package/dist/web/layout/shell-style.js +6 -0
- package/dist/web/layout/workspace-shell.d.ts +11 -1
- package/dist/web/layout/workspace-shell.js +6 -4
- package/dist/web/primitives/banner.d.ts +1 -1
- package/dist/web/primitives/banner.js +19 -9
- package/dist/web/primitives/card.js +18 -8
- package/dist/web/primitives/data-table/actions-column.d.ts +1 -1
- package/dist/web/primitives/data-table/actions-column.js +3 -1
- package/dist/web/primitives/data-table/card-body.d.ts +1 -1
- package/dist/web/primitives/data-table/card-body.js +11 -6
- package/dist/web/primitives/data-table/card-row.js +27 -18
- 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/hint-cell.d.ts +1 -3
- package/dist/web/primitives/data-table/hint-cell.js +4 -10
- package/dist/web/primitives/data-table/row-click-guard.d.ts +2 -0
- package/dist/web/primitives/data-table/row-click-guard.js +19 -0
- package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
- package/dist/web/primitives/data-table/row-render-parts.js +3 -2
- package/dist/web/primitives/data-table/sort-options-select.js +3 -3
- package/dist/web/primitives/data-table/table-body.js +2 -1
- package/dist/web/primitives/data-table/table-content.js +10 -6
- package/dist/web/primitives/data-table/table-view.js +8 -3
- package/dist/web/primitives/data-table/toolbar.d.ts +2 -0
- package/dist/web/primitives/data-table/toolbar.js +44 -9
- package/dist/web/primitives/data-table/totals-footer.js +4 -3
- package/dist/web/primitives/data-table-cell.d.ts +4 -1
- package/dist/web/primitives/data-table-cell.js +60 -20
- package/dist/web/primitives/default-form.js +6 -3
- package/dist/web/primitives/drawer.js +5 -1
- package/dist/web/primitives/facet-filter.d.ts +1 -1
- package/dist/web/primitives/facet-filter.js +16 -8
- package/dist/web/primitives/facet-search-filter.d.ts +2 -1
- package/dist/web/primitives/facet-search-filter.js +3 -2
- package/dist/web/primitives/facet-trigger-label.d.ts +8 -0
- package/dist/web/primitives/facet-trigger-label.js +9 -0
- package/dist/web/primitives/file-view-action.js +4 -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 +3 -3
- package/dist/web/primitives/locale-number.d.ts +0 -1
- package/dist/web/primitives/locale-number.js +1 -13
- package/dist/web/primitives/metric.js +17 -5
- 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/page-header.js +3 -2
- package/dist/web/primitives/pager.d.ts +3 -2
- package/dist/web/primitives/pager.js +16 -20
- package/dist/web/primitives/photo-grid.d.ts +3 -0
- package/dist/web/primitives/photo-grid.js +5 -0
- package/dist/web/primitives/record-breadcrumb.js +1 -1
- package/dist/web/primitives/record-steps.d.ts +1 -1
- package/dist/web/primitives/record-steps.js +11 -6
- package/dist/web/primitives/record-summary.d.ts +1 -1
- package/dist/web/primitives/record-summary.js +8 -3
- package/dist/web/primitives/segmented-select.js +6 -3
- package/dist/web/primitives/step-list.d.ts +3 -0
- package/dist/web/primitives/step-list.js +11 -0
- package/dist/web/primitives/tabs.js +6 -1
- package/dist/web/pwa/pwa-support.js +19 -1
- package/dist/web/ui/sidebar.d.ts +2 -1
- package/dist/web/ui/sidebar.js +4 -3
- package/dist/web/widgets/ai-text-field.js +3 -2
- package/dist/web/widgets/dashboard-list-cards.js +6 -14
- package/dist/web/widgets/dashboard-list.d.ts +10 -0
- package/dist/web/widgets/dashboard-list.js +36 -10
- package/dist/web/widgets/drawer-panel-class.d.ts +1 -0
- package/dist/web/widgets/drawer-panel-class.js +9 -1
- package/dist/web/widgets/drawer.js +2 -2
- package/dist/web/widgets/pdf-viewer-toolbar.js +3 -2
- package/dist/web/widgets/sheet-parts.js +3 -1
- package/dist/web/widgets/stat-box-cell.js +1 -1
- package/dist/web/widgets/stat.d.ts +7 -1
- package/dist/web/widgets/stat.js +12 -4
- package/dist/web/widgets/step-list-row.d.ts +4 -0
- package/dist/web/widgets/step-list-row.js +22 -14
- package/dist/web/widgets/step-list.d.ts +12 -4
- package/dist/web/widgets/step-list.js +38 -20
- package/package.json +5 -5
- package/src/changes.json +126 -0
- package/src/web/styles.css +6 -0
|
@@ -1,6 +1,8 @@
|
|
|
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";
|
|
5
|
+
import { pluralKey } from "../headless/plural-key.js";
|
|
4
6
|
import { isRecordProgressArray, readBreadcrumbItems, readNotice, readSteps, readTone, } from "./projection-detail-guidance-data.js";
|
|
5
7
|
import { uniqueLabelKeys } from "./unique-label-keys.js";
|
|
6
8
|
const BANNER_VARIANT = {
|
|
@@ -89,7 +91,7 @@ function renderSummary(model) {
|
|
|
89
91
|
const { RecordSummary, Text } = model.primitives;
|
|
90
92
|
const testId = "kumiko-screen-projection-detail-summary";
|
|
91
93
|
if (RecordSummary !== undefined) {
|
|
92
|
-
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 }));
|
|
93
95
|
}
|
|
94
96
|
return _jsx(Text, { testId: testId, children: text });
|
|
95
97
|
}
|
|
@@ -102,47 +104,57 @@ function renderBanner(model) {
|
|
|
102
104
|
return undefined;
|
|
103
105
|
const { Banner } = model.primitives;
|
|
104
106
|
const actions = renderItemActions(model, spec.actions, notice);
|
|
105
|
-
return wrapLayout(model.primitives, GUIDANCE_INSET, _jsx(Banner, { variant: BANNER_VARIANT[notice.tone ?? "neutral"], icon: BANNER_ICON[notice.tone ?? "neutral"], title: notice.title, inline: true, ...(actions !== undefined && { actions }), testId: "kumiko-screen-projection-detail-banner", children: notice.text }));
|
|
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 }));
|
|
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
|
+
};
|
|
106
138
|
}
|
|
107
139
|
function renderSteps(model) {
|
|
108
140
|
const spec = model.screen.steps;
|
|
109
141
|
if (spec === undefined)
|
|
110
142
|
return undefined;
|
|
143
|
+
if (spec.visibleWhen !== undefined &&
|
|
144
|
+
!evalFieldCondition(spec.visibleWhen, { ...model.record })) {
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
111
147
|
const { effectiveTranslate: t, record } = model;
|
|
112
148
|
const steps = readSteps(record[spec.field]);
|
|
113
149
|
const title = t(spec.title ?? "kumiko.detail.steps.title");
|
|
114
150
|
const subtitleRaw = spec.subtitleField !== undefined ? record[spec.subtitleField] : undefined;
|
|
115
151
|
const subtitle = typeof subtitleRaw === "string" && subtitleRaw !== "" ? subtitleRaw : undefined;
|
|
116
152
|
const emptyLabel = t(spec.emptyLabel ?? "kumiko.detail.steps.empty");
|
|
117
|
-
const items = steps.map((step) =>
|
|
118
|
-
const [mainAction, ...otherActions] = resolveItemActions(model, spec.actions, step);
|
|
119
|
-
return {
|
|
120
|
-
id: step.id,
|
|
121
|
-
title: step.title,
|
|
122
|
-
...(step.detail !== undefined && { detail: step.detail }),
|
|
123
|
-
...(step.narrowDetail !== undefined && { narrowDetail: step.narrowDetail }),
|
|
124
|
-
...(step.tone !== undefined && { tone: step.tone }),
|
|
125
|
-
...(step.why !== undefined && { reason: step.why }),
|
|
126
|
-
...(step.why !== undefined && step.whyOpen === true && { reasonOpen: true }),
|
|
127
|
-
...(step.why !== undefined && step.whyTitle !== undefined && { reasonTitle: step.whyTitle }),
|
|
128
|
-
...(mainAction !== undefined && {
|
|
129
|
-
actions: renderActionButtons(model, [mainAction], spec.actions),
|
|
130
|
-
}),
|
|
131
|
-
...(otherActions.length > 0 && {
|
|
132
|
-
moreActions: renderActionButtons(model, otherActions, spec.actions),
|
|
133
|
-
}),
|
|
134
|
-
};
|
|
135
|
-
});
|
|
153
|
+
const items = steps.map((step) => buildStepItem(model, spec, step));
|
|
136
154
|
const { RecordSteps, Card, Text } = model.primitives;
|
|
137
155
|
const testId = "kumiko-screen-projection-detail-steps";
|
|
138
156
|
if (RecordSteps !== undefined) {
|
|
139
|
-
return (_jsx(RecordSteps, { title: title, ...(subtitle !== undefined && { subtitle }), emptyLabel: emptyLabel, reasonLabel: t("kumiko.detail.steps.reason"), ...(spec.
|
|
140
|
-
narrowLimit: spec.narrowLimit,
|
|
141
|
-
moreLabel: (count) => count === 1
|
|
142
|
-
? t("kumiko.detail.steps.more.one")
|
|
143
|
-
: t("kumiko.detail.steps.more.other", { 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
|
}
|
|
@@ -171,7 +183,7 @@ function renderProgress(model, stacked) {
|
|
|
171
183
|
total: chain.steps.length,
|
|
172
184
|
}),
|
|
173
185
|
}),
|
|
174
|
-
}, testId: testId, children: [_jsx(StepBar, { steps: chain.steps.map((step) => step.label), currentIndex: currentIndex, doneSteps: chain.steps.map((step) => step.done), narrowLayout: "steps", ...(stacked && {
|
|
186
|
+
}, options: { headerLayout: "inline" }, testId: testId, children: [_jsx(StepBar, { steps: chain.steps.map((step) => step.label), currentIndex: currentIndex, doneSteps: chain.steps.map((step) => step.done), narrowLayout: "steps", ...(stacked && {
|
|
175
187
|
orientation: "stacked",
|
|
176
188
|
subtitles: chain.steps.map((step) => step.detail),
|
|
177
189
|
}), compactLabel: t("kumiko.wizard.step-with-title", {
|
|
@@ -184,14 +196,14 @@ function renderProgress(model, stacked) {
|
|
|
184
196
|
return cards.length === 0 ? undefined : cards;
|
|
185
197
|
}
|
|
186
198
|
// RecordSteps and the summary carry their own px-6; the progress cards and the banner are bare, so they need the same inset to line up with the metric tiles.
|
|
187
|
-
const GUIDANCE_INSET = "px-6";
|
|
188
|
-
const PROGRESS_INSET = "flex min-w-0 flex-col gap-4 px-6 py-2";
|
|
199
|
+
const GUIDANCE_INSET = "px-6 max-sm:px-4";
|
|
200
|
+
const PROGRESS_INSET = "flex min-w-0 flex-col gap-4 px-6 py-2 max-sm:px-4";
|
|
189
201
|
/** Summary, banner, progress and steps in reading order; blocks whose record field holds nothing drop out. */
|
|
190
202
|
export function renderDetailGuidance(model) {
|
|
191
203
|
const { progress, steps } = model.screen;
|
|
192
204
|
const beside = progress?.placement === "beside-steps" && steps !== undefined;
|
|
193
205
|
const progressNode = renderProgress(model, beside);
|
|
194
206
|
const progressInset = progress?.hideOnNarrow === true ? `${PROGRESS_INSET} max-sm:hidden` : PROGRESS_INSET;
|
|
195
|
-
return (_jsxs(_Fragment, { children: [renderSummary(model), renderBanner(model), beside ? (wrapLayout(model.primitives, "grid grid-cols-1 gap-4 lg:grid-cols-12", _jsxs(_Fragment, { children: [wrapLayout(model.primitives, progressNode !== undefined ? "min-w-0 lg:col-span-8" : "min-w-0 lg:col-span-12", renderSteps(model)), progressNode !== undefined &&
|
|
196
|
-
wrapLayout(model.primitives, `${progressInset} lg:col-span-4 lg:pl-0`, progressNode)] }))) : (_jsxs(_Fragment, { children: [progressNode !== undefined && wrapLayout(model.primitives, progressInset, progressNode), renderSteps(model)] }))] }));
|
|
207
|
+
return (_jsxs(_Fragment, { children: [renderSummary(model), renderBanner(model), beside ? (wrapLayout(model.primitives, "grid grid-cols-1 items-stretch gap-4 lg:grid-cols-12", _jsxs(_Fragment, { children: [wrapLayout(model.primitives, progressNode !== undefined ? "min-w-0 lg:col-span-8" : "min-w-0 lg:col-span-12", renderSteps(model)), progressNode !== undefined &&
|
|
208
|
+
wrapLayout(model.primitives, `${progressInset} lg:col-span-4 lg:flex lg:flex-col lg:pl-0 lg:[&>*]:flex-1`, progressNode)] }))) : (_jsxs(_Fragment, { children: [progressNode !== undefined && wrapLayout(model.primitives, progressInset, progressNode), renderSteps(model)] }))] }));
|
|
197
209
|
}
|
|
@@ -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 {
|
|
@@ -29,11 +29,11 @@ export function renderHeaderTitleSlot(model) {
|
|
|
29
29
|
export function renderRecordTitleBlock(model, titleText, statusBadge, subtitle, chipInBar) {
|
|
30
30
|
const { Grid, Heading, FillContainer } = model.primitives;
|
|
31
31
|
const block = (_jsxs(_Fragment, { children: [_jsxs(Grid, { columns: "auto", testId: "kumiko-screen-projection-detail-title-block", children: [_jsx(Heading, { variant: "page", testId: "kumiko-screen-projection-detail-title", children: titleText }), !chipInBar && statusBadge] }), subtitle] }));
|
|
32
|
-
return FillContainer !== undefined ? (_jsx(FillContainer, { className: "flex flex-col gap-1 px-6 pt-2", children: block })) : (block);
|
|
32
|
+
return FillContainer !== undefined ? (_jsx(FillContainer, { className: "flex flex-col gap-1 px-6 pt-2 max-sm:px-4", children: block })) : (block);
|
|
33
33
|
}
|
|
34
34
|
function renderSubtitleParts(model, subtitleParts) {
|
|
35
35
|
const { Text, Link } = model.primitives;
|
|
36
|
-
return (_jsx(Text, { variant: "muted", testId: "kumiko-screen-projection-detail-subtitle", children: subtitleParts.map((part, index) => (_jsxs(Fragment, { children: [index > 0 && (_jsx(Text, { variant: "muted", decorative: true, children: " · " })), part.href !== undefined ? (_jsx(Link, { href: part.href, ...(part.onPress !== undefined && { onPress: part.onPress }), className: "underline", testId: `kumiko-screen-projection-detail-subtitle-${part.field}`, children: part.text })) : (_jsx(Text, { testId: `kumiko-screen-projection-detail-subtitle-${part.field}`, children: part.text }))] }, part.field))) }));
|
|
36
|
+
return (_jsx(Text, { variant: "muted", testId: "kumiko-screen-projection-detail-subtitle", children: subtitleParts.map((part, index) => (_jsxs(Fragment, { children: [index > 0 && (_jsx(Text, { variant: "muted", decorative: true, children: " · " })), part.prefix !== undefined && (_jsx(Text, { testId: `kumiko-screen-projection-detail-subtitle-${part.field}-prefix`, children: `${part.prefix} ` })), part.href !== undefined ? (_jsx(Link, { href: part.href, ...(part.onPress !== undefined && { onPress: part.onPress }), className: "underline", testId: `kumiko-screen-projection-detail-subtitle-${part.field}`, children: part.text })) : (_jsx(Text, { testId: `kumiko-screen-projection-detail-subtitle-${part.field}`, children: part.text }))] }, part.field))) }));
|
|
37
37
|
}
|
|
38
38
|
function renderSubtitleField(model, subtitleField, testId = "kumiko-screen-projection-detail-subtitle") {
|
|
39
39
|
const { screen, record, primitives } = model;
|
|
@@ -115,13 +115,14 @@ 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);
|
|
122
|
+
const narrowSub = metricSubline(metric.subFieldNarrow, record);
|
|
122
123
|
const testId = `kumiko-screen-projection-detail-metric-${field}`;
|
|
123
124
|
const onPress = metricPressHandler(model, metric);
|
|
124
|
-
const item = Metric !== undefined ? (_jsx(Metric, { label: label, value: value, testId: testId, ...(onPress !== undefined && { onPress }), ...(tiles && { tile: true }), ...(tone !== undefined && { tone }), ...(metric.icon !== undefined && { icon: metric.icon }), ...(sub !== undefined && { sub }) }, field)) : (_jsxs(GridCell, { children: [_jsx(Text, { variant: "small", testId: `${testId}-label`, children: label }), _jsx(Text, { testId: `${testId}-value`, children: value })] }, field));
|
|
125
|
+
const item = Metric !== undefined ? (_jsx(Metric, { label: label, value: value, testId: testId, ...(onPress !== undefined && { onPress }), ...(tiles && { tile: true }), ...(tone !== undefined && { tone }), ...(metric.icon !== undefined && { icon: metric.icon }), ...(sub !== undefined && { sub }), ...(narrowSub !== undefined && { narrowSub }) }, field)) : (_jsxs(GridCell, { children: [_jsx(Text, { variant: "small", testId: `${testId}-label`, children: label }), _jsx(Text, { testId: `${testId}-value`, children: value })] }, field));
|
|
125
126
|
const { FillContainer } = primitives;
|
|
126
127
|
return metric.hideOnNarrow === true && FillContainer !== undefined ? (_jsx(FillContainer, { className: "max-sm:hidden", children: item }, field)) : (item);
|
|
127
128
|
});
|
|
@@ -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";
|
|
@@ -10,6 +11,11 @@ export type SubtitlePartView = {
|
|
|
10
11
|
readonly text: string;
|
|
11
12
|
readonly href?: string;
|
|
12
13
|
readonly onPress?: () => void;
|
|
14
|
+
/** Translated text before the value; outside the link. */
|
|
15
|
+
readonly prefix?: string;
|
|
13
16
|
};
|
|
14
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>>;
|
|
15
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,24 +79,38 @@ 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 [];
|
|
96
|
+
const prefixKey = typeof part === "string" ? undefined : part.prefix;
|
|
97
|
+
const prefix = prefixKey === undefined ? {} : { prefix: translate(prefixKey) };
|
|
92
98
|
const navigate = typeof part === "string" ? undefined : part.navigate;
|
|
93
99
|
if (navigate === undefined || !navigateTargetAllows(navigate, appFeatures, userRoles)) {
|
|
94
|
-
return [{ field, text }];
|
|
100
|
+
return [{ field, text, ...prefix }];
|
|
95
101
|
}
|
|
96
102
|
const href = hrefForNavigate(nav, navigate, record);
|
|
97
103
|
// skip: unresolvable targets fall back to plain text
|
|
98
104
|
if (href === undefined)
|
|
99
|
-
return [{ field, text }];
|
|
100
|
-
return [
|
|
105
|
+
return [{ field, text, ...prefix }];
|
|
106
|
+
return [
|
|
107
|
+
{
|
|
108
|
+
field,
|
|
109
|
+
text,
|
|
110
|
+
...prefix,
|
|
111
|
+
href,
|
|
112
|
+
onPress: () => runMetricNavigate(nav, navigate, record, host),
|
|
113
|
+
},
|
|
114
|
+
];
|
|
101
115
|
});
|
|
102
116
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isUiAccessGranted } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
-
import { isNamedFilterOffered } from "./named-filter-facet.js";
|
|
3
2
|
import { findDetailForScreen } from "./nav.js";
|
|
4
3
|
import { lastSegment } from "./qn.js";
|
|
5
4
|
// Shared UI-visibility predicate for the screen-render path — nav
|
|
@@ -57,7 +56,7 @@ export function namedFilterNavigateAllows(navigate, appFeatures, userRoles) {
|
|
|
57
56
|
if (target.type !== "entityList" && target.type !== "projectionList")
|
|
58
57
|
return true;
|
|
59
58
|
const ref = target.namedFilters?.find((candidate) => candidate.id === namedFilter);
|
|
60
|
-
return ref === undefined ||
|
|
59
|
+
return ref === undefined || isUiAccessGranted(ref.access, userRoles);
|
|
61
60
|
}
|
|
62
61
|
return true;
|
|
63
62
|
}
|
|
@@ -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
|
|
@@ -5,6 +5,7 @@ type EntityListPayloadInput = {
|
|
|
5
5
|
readonly screen: EntityListScreenDefinition;
|
|
6
6
|
readonly entity: EntityDefinition;
|
|
7
7
|
readonly urlState: ListUrlStateApi;
|
|
8
|
+
readonly searchable: boolean;
|
|
8
9
|
readonly rangeFilters: readonly RangeFilter[];
|
|
9
10
|
readonly activeNamedFilter: string | undefined;
|
|
10
11
|
readonly limit: number;
|
|
@@ -12,7 +13,7 @@ type EntityListPayloadInput = {
|
|
|
12
13
|
readonly useInfinite: boolean;
|
|
13
14
|
};
|
|
14
15
|
/** The list payload as a function of the named filter, so the list and every filter count share one path. */
|
|
15
|
-
export declare function useEntityListPayload({ screen, entity, urlState, rangeFilters, activeNamedFilter, limit, usePager, useInfinite, }: EntityListPayloadInput): {
|
|
16
|
+
export declare function useEntityListPayload({ screen, entity, urlState, searchable, rangeFilters, activeNamedFilter, limit, usePager, useInfinite, }: EntityListPayloadInput): {
|
|
16
17
|
filterPayload: {
|
|
17
18
|
field: string;
|
|
18
19
|
op: "in";
|
|
@@ -4,7 +4,7 @@ import { buildFilterPayload } from "./list-facets.js";
|
|
|
4
4
|
import { resolveListSort } from "./named-filter-facet.js";
|
|
5
5
|
import { buildListQueryPayload } from "./screen-shared.js";
|
|
6
6
|
/** The list payload as a function of the named filter, so the list and every filter count share one path. */
|
|
7
|
-
export function useEntityListPayload({ screen, entity, urlState, rangeFilters, activeNamedFilter, limit, usePager, useInfinite, }) {
|
|
7
|
+
export function useEntityListPayload({ screen, entity, urlState, searchable, rangeFilters, activeNamedFilter, limit, usePager, useInfinite, }) {
|
|
8
8
|
// typeOf reads the field type straight from entity.fields (not gated on
|
|
9
9
|
// filterable, deliberately permissive; see the buildFilterPayload doc).
|
|
10
10
|
const filterPayloadFor = useCallback((filters) => buildFilterPayload(filters, (field) => {
|
|
@@ -14,7 +14,9 @@ export function useEntityListPayload({ screen, entity, urlState, rangeFilters, a
|
|
|
14
14
|
return typeof type === "string" ? type : undefined;
|
|
15
15
|
}), [entity.fields]);
|
|
16
16
|
const filterPayload = useMemo(() => filterPayloadFor(urlState.filters), [filterPayloadFor, urlState.filters]);
|
|
17
|
-
const { filtersFor, sort: urlSort,
|
|
17
|
+
const { filtersFor, sort: urlSort, page } = urlState;
|
|
18
|
+
// A stale or hand-crafted ?q= on a non-searchable list must not reach the query.
|
|
19
|
+
const q = searchable ? urlState.q : "";
|
|
18
20
|
const listPayloadFor = useCallback((namedFilter) => {
|
|
19
21
|
const payload = buildListQueryPayload({
|
|
20
22
|
limit,
|
|
@@ -32,5 +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
|
};
|
|
49
|
+
export declare function omitActionsDefaultingToShownRecordId(actions: readonly RowAction[], shownRecordId: string | undefined): readonly RowAction[];
|
|
36
50
|
export {};
|
|
@@ -123,20 +123,23 @@ export function useProjectionDetailActions(input) {
|
|
|
123
123
|
handleRecordLeft,
|
|
124
124
|
sameEntityScreenId,
|
|
125
125
|
]);
|
|
126
|
-
const buildItemActions = useCallback((actions, item) =>
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
126
|
+
const buildItemActions = useCallback((actions, item) => {
|
|
127
|
+
const shownRecordId = effectiveEntityId ?? stringId(detailQuery.data?.["id"]);
|
|
128
|
+
return buildRecordActions({
|
|
129
|
+
actions: omitActionsDefaultingToShownRecordId(actions, shownRecordId),
|
|
130
|
+
record: item,
|
|
131
|
+
translate: effectiveTranslate,
|
|
132
|
+
nav,
|
|
133
|
+
host,
|
|
134
|
+
dispatcher,
|
|
135
|
+
openDrawer,
|
|
136
|
+
onWriteSuccess: reloadDetail,
|
|
137
|
+
onRecordLeft: handleRecordLeft,
|
|
138
|
+
sameEntityScreenId,
|
|
139
|
+
clientActions,
|
|
140
|
+
defaultWritePayloadId: shownRecordId,
|
|
141
|
+
});
|
|
142
|
+
}, [
|
|
140
143
|
detailQuery.data,
|
|
141
144
|
effectiveEntityId,
|
|
142
145
|
reloadDetail,
|
|
@@ -149,7 +152,8 @@ export function useProjectionDetailActions(input) {
|
|
|
149
152
|
handleRecordLeft,
|
|
150
153
|
sameEntityScreenId,
|
|
151
154
|
]);
|
|
152
|
-
const
|
|
155
|
+
const footerIds = screen.footerActions;
|
|
156
|
+
const recordActions = useMemo(() => {
|
|
153
157
|
const declaredHasEdit = screen.actions?.some((a) => a.id === "edit") === true;
|
|
154
158
|
const resolved = buildRecordActions({
|
|
155
159
|
actions: (screen.actions ?? []).filter((a) => isShownOnTab(a, activeTabId)),
|
|
@@ -183,7 +187,27 @@ export function useProjectionDetailActions(input) {
|
|
|
183
187
|
handleRecordLeft,
|
|
184
188
|
sameEntityScreenId,
|
|
185
189
|
]);
|
|
186
|
-
|
|
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 };
|
|
202
|
+
}
|
|
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).
|
|
204
|
+
export function omitActionsDefaultingToShownRecordId(actions, shownRecordId) {
|
|
205
|
+
if (shownRecordId !== undefined)
|
|
206
|
+
return actions;
|
|
207
|
+
return actions.filter((action) => !((action.kind === undefined ||
|
|
208
|
+
action.kind === "writeHandler" ||
|
|
209
|
+
action.kind === "clientAction") &&
|
|
210
|
+
action.payload === undefined));
|
|
187
211
|
}
|
|
188
212
|
function stringId(value) {
|
|
189
213
|
return typeof value === "string" && value !== "" ? value : undefined;
|
|
@@ -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;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { evalFieldCondition } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
1
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
3
|
import { rendererWarn } from "../dev-console.js";
|
|
3
4
|
import { useQuery } from "../hooks/use-query.js";
|
|
@@ -7,13 +8,25 @@ export function useProjectionDetailData(input) {
|
|
|
7
8
|
const { screen, Tabs, nav, effectiveEntityId } = input;
|
|
8
9
|
const idParam = screen.idParam ?? "id";
|
|
9
10
|
const isTabsMode = screen.layout.mode === "tabs";
|
|
10
|
-
const
|
|
11
|
+
const live = screen.live === true;
|
|
12
|
+
const detailQuery = useQuery(screen.query, effectiveEntityId !== undefined ? { [idParam]: effectiveEntityId } : {}, { live });
|
|
13
|
+
const record = detailQuery.data;
|
|
14
|
+
// A section hidden by `visibleWhen` drops out of the tab strip and the body alike; until the
|
|
15
|
+
// record is loaded nothing is evaluated (the loading banner shows instead).
|
|
16
|
+
const visibleSections = useMemo(() => screen.layout.sections.filter((section) => section.visibleWhen === undefined ||
|
|
17
|
+
(record !== null && evalFieldCondition(section.visibleWhen, { ...record }))), [screen.layout.sections, record]);
|
|
18
|
+
// Adjacent sections sharing one `id` form a single tab (several blocks under one tab label).
|
|
19
|
+
const activeSections = useMemo(() => {
|
|
11
20
|
// skip: only tabs mode with a registered Tabs primitive has an active section
|
|
12
21
|
if (!isTabsMode || Tabs === undefined)
|
|
13
|
-
return
|
|
22
|
+
return [];
|
|
14
23
|
const tabParam = nav.searchParams["tab"];
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
const activeId = visibleSections.find((section) => section.id === tabParam)?.id ??
|
|
25
|
+
initialTabId(screen.initialTab, record, visibleSections) ??
|
|
26
|
+
visibleSections[0]?.id;
|
|
27
|
+
return visibleSections.filter((section) => section.id === activeId);
|
|
28
|
+
}, [isTabsMode, Tabs, visibleSections, nav.searchParams, screen.initialTab, record]);
|
|
29
|
+
const activeSection = activeSections[0];
|
|
17
30
|
const hasTabs = isTabsMode && Tabs !== undefined && activeSection !== undefined;
|
|
18
31
|
// Tabs is an optional Core-Primitive: without it the screen falls back to
|
|
19
32
|
// the stacked all-sections layout instead of silently truncating to section 1.
|
|
@@ -24,13 +37,11 @@ export function useProjectionDetailData(input) {
|
|
|
24
37
|
}, [isTabsMode, Tabs, screen.id]);
|
|
25
38
|
const entity = useMemo(() => synthesizeProjectionDetailEntity(screen.layout), [screen.layout]);
|
|
26
39
|
const detailScreen = useMemo(() => {
|
|
27
|
-
const source =
|
|
28
|
-
? { ...screen, layout: { ...screen.layout, sections:
|
|
40
|
+
const source = activeSections.length > 0
|
|
41
|
+
? { ...screen, layout: { ...screen.layout, sections: activeSections } }
|
|
29
42
|
: screen;
|
|
30
43
|
return synthesizeProjectionDetailScreen(source);
|
|
31
|
-
}, [screen,
|
|
32
|
-
const live = screen.live === true;
|
|
33
|
-
const detailQuery = useQuery(screen.query, effectiveEntityId !== undefined ? { [idParam]: effectiveEntityId } : {}, { live });
|
|
44
|
+
}, [screen, activeSections]);
|
|
34
45
|
// A writeForm section's handler creates a new record (see EditWriteFormSection's
|
|
35
46
|
// doc) — both the outer record (header/metrics/other sections) and a sibling
|
|
36
47
|
// relatedList section's own independently-fetched rows must reflect it. A
|
|
@@ -58,5 +69,21 @@ export function useProjectionDetailData(input) {
|
|
|
58
69
|
if (previous !== undefined)
|
|
59
70
|
setReloadNonce((n) => n + 1);
|
|
60
71
|
}, [liveRecord]);
|
|
61
|
-
return {
|
|
72
|
+
return {
|
|
73
|
+
activeSection,
|
|
74
|
+
activeSections,
|
|
75
|
+
visibleSections,
|
|
76
|
+
hasTabs,
|
|
77
|
+
entity,
|
|
78
|
+
detailScreen,
|
|
79
|
+
detailQuery,
|
|
80
|
+
reloadNonce,
|
|
81
|
+
reloadDetail,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function initialTabId(rules, record, visibleSections) {
|
|
85
|
+
if (rules === undefined || record === null)
|
|
86
|
+
return undefined;
|
|
87
|
+
return rules.find((rule) => evalFieldCondition(rule.when, { ...record }) &&
|
|
88
|
+
visibleSections.some((section) => section.id === rule.tab))?.tab;
|
|
62
89
|
}
|
|
@@ -3,9 +3,11 @@ type Row = Readonly<Record<string, unknown>>;
|
|
|
3
3
|
/** Decoration fields win over same-named row fields; the row id is kept. Entries for ids not in `rows` and malformed entries are ignored. */
|
|
4
4
|
export declare function mergeRowDecoration(rows: readonly Row[], answer: unknown): readonly Row[];
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Sends only ids that have no answer yet, so an infinite list asks once per new page and the
|
|
7
|
+
* answers are kept across calls. `resetKey` drops them (filter or sort changed); a new list
|
|
8
|
+
* answer that is not an append (reload after a write) asks for every id again, in batches of
|
|
9
|
+
* the first send's size.
|
|
10
|
+
* Loading and error show the plain rows.
|
|
9
11
|
*/
|
|
10
|
-
export declare function useRowDecoration(decoration: ListRowDecoration | undefined, rows: readonly Row[], answerToken: unknown): readonly Row[];
|
|
12
|
+
export declare function useRowDecoration(decoration: ListRowDecoration | undefined, rows: readonly Row[], answerToken: unknown, resetKey: string): readonly Row[];
|
|
11
13
|
export {};
|