@cosmicdrift/kumiko-renderer 0.416.0 → 0.418.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/action-form-body.d.ts +1 -4
- package/dist/app/action-form-body.js +14 -9
- package/dist/app/action-form-preview.d.ts +13 -0
- package/dist/app/action-form-preview.js +66 -0
- package/dist/app/action-form-support.d.ts +6 -1
- package/dist/app/action-form-support.js +26 -9
- package/dist/app/config-edit-body.js +71 -79
- package/dist/app/entity-list-screen.js +1 -1
- package/dist/app/header-actions-bar.d.ts +3 -1
- package/dist/app/header-actions-bar.js +12 -4
- package/dist/app/list-bulk-actions.d.ts +8 -1
- package/dist/app/list-bulk-actions.js +28 -4
- package/dist/app/locked-screen-header.d.ts +2 -0
- package/dist/app/locked-screen-header.js +8 -1
- package/dist/app/projection-detail-body.js +24 -5
- package/dist/app/projection-detail-guidance.d.ts +1 -0
- package/dist/app/projection-detail-guidance.js +7 -4
- package/dist/app/projection-detail-header-model.js +4 -1
- package/dist/app/projection-detail-header-region.js +25 -9
- package/dist/app/projection-detail-header.d.ts +2 -0
- package/dist/app/projection-detail-header.js +30 -3
- package/dist/app/projection-list-shim.js +1 -0
- package/dist/app/row-actions.d.ts +4 -0
- package/dist/app/row-actions.js +19 -3
- package/dist/app/use-projection-detail-actions.d.ts +3 -1
- package/dist/app/use-projection-detail-actions.js +9 -1
- package/dist/app/use-projection-detail-data.js +17 -1
- package/dist/app/use-projection-list-data.js +1 -1
- package/dist/card-options.d.ts +2 -0
- package/dist/components/choice-chip-class.d.ts +1 -0
- package/dist/components/choice-chip-class.js +9 -0
- package/dist/components/edit-mounts.d.ts +1 -1
- package/dist/components/embedded-list-paste.js +2 -2
- package/dist/components/grid-cell-for-field.js +1 -1
- package/dist/components/multi-select-chips.js +7 -2
- package/dist/components/multi-select-count.d.ts +5 -0
- package/dist/components/multi-select-count.js +10 -0
- package/dist/components/narrow-description.d.ts +3 -0
- package/dist/components/narrow-description.js +12 -0
- package/dist/components/related-list-section.d.ts +5 -3
- package/dist/components/related-list-section.js +9 -4
- package/dist/components/related-photo-grid.js +17 -3
- package/dist/components/render-edit-field-grid.d.ts +12 -3
- package/dist/components/render-edit-field-grid.js +60 -18
- package/dist/components/render-edit-fields-section.js +45 -11
- package/dist/components/render-edit-header-actions.js +1 -1
- package/dist/components/render-edit-layout.js +5 -3
- package/dist/components/render-edit-section-kinds.js +50 -12
- package/dist/components/render-edit-titles.js +1 -1
- package/dist/components/render-edit-types.d.ts +13 -0
- package/dist/components/render-field-ai-assist.js +26 -7
- package/dist/components/render-field-choice-inputs.js +3 -0
- package/dist/components/render-field-control.js +1 -1
- package/dist/components/render-field-value-chips.js +6 -4
- package/dist/components/render-field-values.js +3 -3
- package/dist/components/render-list-hint-columns.d.ts +1 -0
- package/dist/components/render-list-hint-columns.js +30 -5
- package/dist/components/render-list-reference-columns.js +2 -4
- package/dist/components/render-list-row-tone.d.ts +2 -0
- package/dist/components/render-list-row-tone.js +6 -0
- package/dist/components/render-list-table-props.d.ts +13 -2
- package/dist/components/render-list-table-props.js +9 -3
- package/dist/components/render-list-types.d.ts +4 -0
- package/dist/components/render-list.js +12 -4
- package/dist/components/use-render-list-columns.js +3 -3
- package/dist/components/write-form-registry.d.ts +13 -0
- package/dist/components/write-form-registry.js +6 -0
- package/dist/components/write-form-section.d.ts +5 -1
- package/dist/components/write-form-section.js +55 -16
- package/dist/data-table-bulk-types.d.ts +11 -2
- package/dist/data-table-bulk-types.js +3 -1
- package/dist/headless/form/form-controller.d.ts +2 -0
- package/dist/headless/form/form-controller.js +2 -2
- package/dist/headless/format/index.d.ts +1 -1
- package/dist/headless/format/index.js +6 -5
- package/dist/headless/format/money.d.ts +5 -0
- package/dist/headless/format/money.js +10 -0
- package/dist/headless/format/relative-time.d.ts +2 -0
- package/dist/headless/format/relative-time.js +4 -1
- package/dist/headless/index.d.ts +1 -1
- package/dist/headless/index.js +1 -1
- package/dist/headless/view-model/edit.js +87 -37
- package/dist/headless/view-model/list.js +6 -0
- package/dist/headless/view-model/types.d.ts +50 -5
- package/dist/hooks/use-bulk-run.d.ts +2 -2
- package/dist/hooks/use-list-table.js +11 -6
- package/dist/i18n-defaults.js +8 -2
- package/dist/primitives-record-guidance.d.ts +4 -0
- package/dist/primitives-share-types.d.ts +82 -0
- package/dist/primitives-share-types.js +1 -0
- package/dist/primitives.d.ts +34 -83
- package/dist/web/app/bold-markup.d.ts +3 -0
- package/dist/web/app/bold-markup.js +14 -0
- package/dist/web/app/dashboard-body.js +5 -1
- package/dist/web/app/dashboard-list-panel.js +7 -4
- package/dist/web/app/dashboard-panels.js +31 -3
- package/dist/web/app/dashboard-shared.d.ts +3 -1
- package/dist/web/app/dashboard-shared.js +3 -3
- package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -1
- package/dist/web/app/dashboard-stat-group-panel.js +16 -2
- package/dist/web/app/dashboard-text-panel.js +11 -6
- package/dist/web/app/relative-time.js +10 -1
- package/dist/web/components/config-cascade.d.ts +2 -1
- package/dist/web/components/config-cascade.js +16 -4
- package/dist/web/drawn-icons.js +2 -1
- package/dist/web/layout/header-action-pinned.d.ts +4 -2
- package/dist/web/layout/header-action-pinned.js +13 -4
- package/dist/web/layout/header-overflow-menu.d.ts +2 -0
- package/dist/web/layout/header-overflow-menu.js +2 -0
- package/dist/web/layout/nav-tree.js +1 -1
- package/dist/web/layout/notification-bell.js +13 -4
- package/dist/web/layout/page-header-slot.d.ts +2 -0
- package/dist/web/layout/page-header-slot.js +4 -0
- package/dist/web/layout/screen-focus.js +4 -1
- package/dist/web/layout/shell-header.js +15 -7
- package/dist/web/primitives/banner.js +14 -3
- package/dist/web/primitives/card.js +5 -3
- package/dist/web/primitives/combobox.js +2 -2
- package/dist/web/primitives/data-table/actions-column.js +1 -1
- package/dist/web/primitives/data-table/card-body.d.ts +1 -1
- package/dist/web/primitives/data-table/card-body.js +37 -14
- package/dist/web/primitives/data-table/card-frame.d.ts +2 -0
- package/dist/web/primitives/data-table/card-frame.js +3 -0
- package/dist/web/primitives/data-table/card-row.js +28 -9
- package/dist/web/primitives/data-table/card-sort-select.js +1 -1
- package/dist/web/primitives/data-table/card-view.js +1 -1
- package/dist/web/primitives/data-table/data-cell-props.d.ts +2 -1
- package/dist/web/primitives/data-table/data-cell-props.js +1 -0
- package/dist/web/primitives/data-table/density.d.ts +3 -1
- package/dist/web/primitives/data-table/density.js +11 -4
- package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
- package/dist/web/primitives/data-table/row-render-parts.js +3 -5
- package/dist/web/primitives/data-table/sort-options-select.js +2 -2
- package/dist/web/primitives/data-table/sortable-header.js +4 -4
- package/dist/web/primitives/data-table/table-body.js +2 -1
- package/dist/web/primitives/data-table/table-chrome.js +1 -3
- package/dist/web/primitives/data-table/table-content.js +7 -11
- package/dist/web/primitives/data-table/table-data-cell.js +31 -17
- package/dist/web/primitives/data-table/table-header-row.js +1 -1
- package/dist/web/primitives/data-table/table-view.js +1 -1
- package/dist/web/primitives/data-table/toolbar.js +6 -7
- package/dist/web/primitives/data-table/use-bulk-selection.d.ts +1 -1
- package/dist/web/primitives/data-table/use-bulk-selection.js +5 -0
- package/dist/web/primitives/data-table/use-data-table-state.d.ts +6 -1
- package/dist/web/primitives/data-table/use-data-table-state.js +12 -2
- package/dist/web/primitives/data-table-cell.d.ts +13 -2
- package/dist/web/primitives/data-table-cell.js +125 -53
- package/dist/web/primitives/data-table.js +1 -1
- package/dist/web/primitives/default-form.d.ts +1 -1
- package/dist/web/primitives/default-form.js +11 -10
- package/dist/web/primitives/drawer.js +2 -7
- package/dist/web/primitives/facet-filter.d.ts +1 -1
- package/dist/web/primitives/facet-filter.js +2 -5
- package/dist/web/primitives/facet-search-filter.js +1 -1
- package/dist/web/primitives/facet-trigger-label.d.ts +1 -4
- package/dist/web/primitives/facet-trigger-label.js +4 -7
- package/dist/web/primitives/field.js +15 -8
- package/dist/web/primitives/form-footer-parts.js +2 -2
- package/dist/web/primitives/inline-suffix.d.ts +2 -0
- package/dist/web/primitives/inline-suffix.js +5 -0
- package/dist/web/primitives/input-choice-kinds.js +12 -2
- package/dist/web/primitives/input-number-kinds.js +2 -2
- package/dist/web/primitives/input-text-kinds.js +1 -1
- package/dist/web/primitives/layout-elements.d.ts +4 -4
- package/dist/web/primitives/layout-elements.js +49 -12
- package/dist/web/primitives/layout.d.ts +1 -1
- package/dist/web/primitives/layout.js +1 -1
- package/dist/web/primitives/metric.js +4 -5
- package/dist/web/primitives/money-input.js +8 -7
- package/dist/web/primitives/number-input.d.ts +2 -1
- package/dist/web/primitives/number-input.js +9 -4
- package/dist/web/primitives/page-header.d.ts +1 -1
- package/dist/web/primitives/page-header.js +8 -1
- package/dist/web/primitives/pager.js +12 -21
- package/dist/web/primitives/photo-grid.js +2 -1
- package/dist/web/primitives/record-steps.d.ts +1 -1
- package/dist/web/primitives/record-steps.js +6 -15
- package/dist/web/primitives/row-actions.js +38 -24
- package/dist/web/primitives/use-container-narrow.d.ts +12 -0
- package/dist/web/primitives/use-container-narrow.js +42 -0
- package/dist/web/pwa/pwa-support.js +13 -7
- package/dist/web/ui/input.js +1 -1
- package/dist/web/ui/textarea.js +1 -1
- package/dist/web/widgets/dashboard-list-cards.js +6 -3
- package/dist/web/widgets/dashboard-list.d.ts +4 -1
- package/dist/web/widgets/dashboard-list.js +10 -5
- package/dist/web/widgets/progress-list.js +1 -1
- package/dist/web/widgets/stat-box-cell.js +1 -1
- package/package.json +5 -5
- package/src/changes.json +51 -0
- package/src/web/styles.css +3 -2
|
@@ -4,13 +4,17 @@ import * as z from "zod";
|
|
|
4
4
|
import { ErrorReference } from "../app/error-reference.js";
|
|
5
5
|
import { isPresent, REQUIRED_FIELD_I18N_KEY } from "../app/form-schema.js";
|
|
6
6
|
import { dispatcherErrorText } from "../app/write-failed-error.js";
|
|
7
|
+
import { stripUntouchedEmptyStrings } from "../headless/form/form-controller.js";
|
|
7
8
|
import { I18N_KEY_PARAM } from "../headless/index.js";
|
|
8
9
|
import { useForm } from "../hooks/use-form.js";
|
|
9
10
|
import { useTranslation } from "../i18n.js";
|
|
10
11
|
import { useUnsavedInputSource } from "../leave-guard.js";
|
|
11
12
|
import { STICKY_PRIMARY_ACTION_PROP, usePrimitives } from "../primitives.js";
|
|
12
13
|
import { GridCellForField } from "./grid-cell-for-field.js";
|
|
14
|
+
import { narrowAwareDescription } from "./narrow-description.js";
|
|
15
|
+
import { appendixCellProps } from "./render-edit-field-grid.js";
|
|
13
16
|
import { hasIssueWithoutVisibleField, issuesAfterEdit } from "./render-edit-logic.js";
|
|
17
|
+
import { useWriteFormRegistry } from "./write-form-registry.js";
|
|
14
18
|
function buildWriteFormSchema(fields) {
|
|
15
19
|
return z
|
|
16
20
|
.object({})
|
|
@@ -30,13 +34,47 @@ function buildWriteFormSchema(fields) {
|
|
|
30
34
|
}
|
|
31
35
|
});
|
|
32
36
|
}
|
|
37
|
+
// Only an error no rendered field can show gets the banner.
|
|
38
|
+
function submitErrorNotice(error, fields, translate) {
|
|
39
|
+
const issuePaths = (error.details?.fields ?? []).map((i) => i.path);
|
|
40
|
+
if (!hasIssueWithoutVisibleField(issuePaths, fields))
|
|
41
|
+
return null;
|
|
42
|
+
return {
|
|
43
|
+
message: dispatcherErrorText(error, translate),
|
|
44
|
+
...(error.requestId !== undefined && { requestId: error.requestId }),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function useRegisterWriteForm(submitWith, controller, fields) {
|
|
48
|
+
const registry = useWriteFormRegistry();
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (submitWith === undefined || registry === null)
|
|
51
|
+
return;
|
|
52
|
+
registry.set(submitWith, {
|
|
53
|
+
validate: () => controller.validate(),
|
|
54
|
+
invalidFieldLabels: () => Object.keys(controller.getSnapshot().errors).map((path) => fields.find((f) => f.field === path)?.label ?? path),
|
|
55
|
+
// Same as controller.submit: an untouched "" would fail an optional enum/email/date in the schema.
|
|
56
|
+
getValues: () => {
|
|
57
|
+
const { values, initial } = controller.getSnapshot();
|
|
58
|
+
return stripUntouchedEmptyStrings(values, initial, new Set());
|
|
59
|
+
},
|
|
60
|
+
rebase: () => controller.rebase(),
|
|
61
|
+
});
|
|
62
|
+
return () => {
|
|
63
|
+
registry.delete(submitWith);
|
|
64
|
+
};
|
|
65
|
+
}, [registry, submitWith, controller, fields]);
|
|
66
|
+
}
|
|
67
|
+
function WriteFormFeedback({ error, submitRow, }) {
|
|
68
|
+
const { Banner, Card } = usePrimitives();
|
|
69
|
+
return (_jsxs(_Fragment, { children: [error !== null && (_jsxs(Banner, { variant: "error", testId: "write-form-section-error", children: [error.message, _jsx(ErrorReference, { requestId: error.requestId })] })), submitRow !== null && (_jsx(Card, { options: { framed: false, footerBordered: false, footerInset: false }, slots: { footer: submitRow }, testId: "write-form-section-submit-row" }))] }));
|
|
70
|
+
}
|
|
33
71
|
// A self-persisting form section for projectionDetail (see
|
|
34
72
|
// EditWriteFormSection's doc). Deliberately NOT a nested <RenderEdit> — that
|
|
35
73
|
// would render a second, invalid nested <form> inside the host's own form
|
|
36
74
|
// element — so this mounts its own independent useForm() controller and
|
|
37
75
|
// submits via a plain button click instead of native form submission.
|
|
38
|
-
export function WriteFormSection({ section, featureName, translate, hideTitle, onSubmitted, actions, onFooterAction, }) {
|
|
39
|
-
const { Section, Card, Grid, GridCell, Button,
|
|
76
|
+
export function WriteFormSection({ section, featureName, translate, hideTitle, labelTitle, onSubmitted, recordValues, actions, onFooterAction, }) {
|
|
77
|
+
const { Section, Card, Grid, GridCell, Button, StatusBadge } = usePrimitives();
|
|
40
78
|
const t = useTranslation();
|
|
41
79
|
const effectiveTranslate = translate ?? t;
|
|
42
80
|
const initial = useMemo(() => Object.fromEntries(section.fields.map((f) => [f.field, f.value])), [section.fields]);
|
|
@@ -49,6 +87,8 @@ export function WriteFormSection({ section, featureName, translate, hideTitle, o
|
|
|
49
87
|
useUnsavedInputSource(() => controller.getSnapshot().isDirty);
|
|
50
88
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
51
89
|
const [error, setError] = useState(null);
|
|
90
|
+
const { submitWith } = section;
|
|
91
|
+
useRegisterWriteForm(submitWith, controller, section.fields);
|
|
52
92
|
async function handleSubmit() {
|
|
53
93
|
if (isSubmitting)
|
|
54
94
|
return;
|
|
@@ -71,13 +111,7 @@ export function WriteFormSection({ section, featureName, translate, hideTitle, o
|
|
|
71
111
|
// GridCellForField/RenderField path RenderEdit uses) — the banner stays
|
|
72
112
|
// for anything no rendered field can show (`version`, `id`, a root
|
|
73
113
|
// refine, a hidden field).
|
|
74
|
-
|
|
75
|
-
setError(hasIssueWithoutVisibleField(issuePaths, section.fields)
|
|
76
|
-
? {
|
|
77
|
-
message: dispatcherErrorText(result.error, effectiveTranslate),
|
|
78
|
-
...(result.error.requestId !== undefined && { requestId: result.error.requestId }),
|
|
79
|
-
}
|
|
80
|
-
: null);
|
|
114
|
+
setError(submitErrorNotice(result.error, section.fields, effectiveTranslate));
|
|
81
115
|
}
|
|
82
116
|
finally {
|
|
83
117
|
setIsSubmitting(false);
|
|
@@ -90,15 +124,16 @@ export function WriteFormSection({ section, featureName, translate, hideTitle, o
|
|
|
90
124
|
// latest handleSubmit through a ref instead of capturing a stale closure.
|
|
91
125
|
const handleSubmitRef = useRef(handleSubmit);
|
|
92
126
|
handleSubmitRef.current = handleSubmit;
|
|
127
|
+
const sectionTestId = `write-form-${section.title ?? section.handler}`;
|
|
93
128
|
const submitLabel = section.submitLabel ?? effectiveTranslate("kumiko.actions.save");
|
|
94
129
|
const submitButton = (_jsx(Button, { type: "button", variant: "primary", disabled: isSubmitting, loading: isSubmitting, onClick: () => void handleSubmitRef.current(), testId: "write-form-section-submit", [STICKY_PRIMARY_ACTION_PROP]: true, children: submitLabel }));
|
|
95
130
|
// biome-ignore lint/correctness/useExhaustiveDependencies: submitButton is rebuilt every render; isSubmitting and submitLabel are everything it shows.
|
|
96
131
|
useEffect(() => {
|
|
97
|
-
if (onFooterAction === undefined)
|
|
132
|
+
if (onFooterAction === undefined || submitWith !== undefined)
|
|
98
133
|
return;
|
|
99
134
|
onFooterAction(submitButton);
|
|
100
135
|
return () => onFooterAction(undefined);
|
|
101
|
-
}, [onFooterAction, isSubmitting, submitLabel]);
|
|
136
|
+
}, [onFooterAction, submitWith, isSubmitting, submitLabel]);
|
|
102
137
|
const content = (_jsxs(_Fragment, { children: [_jsx(Grid, { columns: section.columns, children: section.fields.map((field) => (_jsx(GridCellForField, { field: { ...field, value: snapshot.values[field.field] }, columns: section.columns, issues: snapshot.errors[field.field], onChange: (v) => {
|
|
103
138
|
controller.setField(field.field, v);
|
|
104
139
|
const errors = controller.getSnapshot().errors;
|
|
@@ -106,16 +141,20 @@ export function WriteFormSection({ section, featureName, translate, hideTitle, o
|
|
|
106
141
|
if (remaining !== errors)
|
|
107
142
|
controller.setErrors(remaining);
|
|
108
143
|
setError(null);
|
|
109
|
-
}, GridCell: GridCell, featureName: featureName, allIssues: snapshot.errors, valueDisplay: "form", row: snapshot.values, ...(hideTitle !== true &&
|
|
110
|
-
section.title !== undefined && { sectionTitle: section.title }) }, field.field))) }),
|
|
144
|
+
}, GridCell: GridCell, featureName: featureName, ...appendixCellProps({}, field, { ...recordValues, ...snapshot.values }, StatusBadge), allIssues: snapshot.errors, valueDisplay: "form", row: snapshot.values, ...(hideTitle !== true &&
|
|
145
|
+
section.title !== undefined && { sectionTitle: section.title }) }, field.field))) }), _jsx(WriteFormFeedback, { error: error, submitRow: onFooterAction === undefined && submitWith === undefined ? submitButton : null })] }));
|
|
111
146
|
// Section always flattens to a borderless divider when rendered inside
|
|
112
147
|
// RenderEdit's own <Form> in tabs mode (hideTitle) — an unframed Card panel
|
|
113
148
|
// stands in, like render-edit.tsx's tabs-mode fields/extension branches.
|
|
114
149
|
if (hideTitle) {
|
|
115
150
|
return (_jsx(Card, { options: { framed: false }, slots: {
|
|
116
|
-
...(section.description !== undefined && {
|
|
151
|
+
...(section.description !== undefined && {
|
|
152
|
+
subtitle: narrowAwareDescription(section.description, section.descriptionNarrow),
|
|
153
|
+
}),
|
|
117
154
|
...(actions !== undefined && { headerActions: actions }),
|
|
118
|
-
}, testId:
|
|
155
|
+
}, testId: sectionTestId, children: content }));
|
|
119
156
|
}
|
|
120
|
-
return (_jsx(Section, { ...(section.title !== undefined && { title: section.title }), ...(
|
|
157
|
+
return (_jsx(Section, { ...(section.title !== undefined && { title: section.title }), ...(labelTitle === true && { titleStyle: "label" }), ...(section.description !== undefined && {
|
|
158
|
+
subtitle: narrowAwareDescription(section.description, section.descriptionNarrow),
|
|
159
|
+
}), ...(section.icon !== undefined && { icon: section.icon }), ...(actions !== undefined && { actions }), testId: sectionTestId, children: content }));
|
|
121
160
|
}
|
|
@@ -6,22 +6,31 @@ export type BulkRowOutcome = {
|
|
|
6
6
|
readonly kind: "failed";
|
|
7
7
|
readonly message: string;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
type DataTableBulkActionBase = {
|
|
10
10
|
readonly id: string;
|
|
11
|
-
/** Translated label of the underlying row action. */
|
|
11
|
+
/** Translated label of the underlying row action or form action. */
|
|
12
12
|
readonly label: string;
|
|
13
13
|
readonly style?: "primary" | "secondary" | "danger";
|
|
14
14
|
readonly icon?: IconKey;
|
|
15
15
|
/** Present: one confirm dialog for the whole selection, with this text for `count` rows. */
|
|
16
16
|
readonly confirmText?: (count: number) => string;
|
|
17
17
|
readonly confirmLabel?: string;
|
|
18
|
+
};
|
|
19
|
+
export type DataTableBulkWriteAction = DataTableBulkActionBase & {
|
|
18
20
|
/** False: the row action's `visible` hides it for this row; the run skips the row. */
|
|
19
21
|
readonly appliesTo: (row: ListRowViewModel) => boolean;
|
|
20
22
|
/** Exactly one server write for one row. Never throws for a rejected write. */
|
|
21
23
|
readonly writeRow: (row: ListRowViewModel) => Promise<BulkRowOutcome>;
|
|
22
24
|
};
|
|
25
|
+
export type DataTableBulkFormAction = DataTableBulkActionBase & {
|
|
26
|
+
/** Hands the whole selection to one form instead of running writes in the table. */
|
|
27
|
+
readonly openForm: (rows: readonly ListRowViewModel[]) => void;
|
|
28
|
+
};
|
|
29
|
+
export type DataTableBulkAction = DataTableBulkWriteAction | DataTableBulkFormAction;
|
|
30
|
+
export declare function isBulkFormAction(action: DataTableBulkAction): action is DataTableBulkFormAction;
|
|
23
31
|
export type DataTableBulk = {
|
|
24
32
|
readonly actions: readonly DataTableBulkAction[];
|
|
25
33
|
/** Reloads the list once after a run. */
|
|
26
34
|
readonly reload: () => Promise<void>;
|
|
27
35
|
};
|
|
36
|
+
export {};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { FormController, FormControllerOptions, FormValues } from "./types.ts";
|
|
2
|
+
export declare function isCurrencyOnlyMoney(value: unknown): boolean;
|
|
3
|
+
export declare function stripUntouchedEmptyStrings<TValues extends FormValues>(values: TValues, initial: TValues, forceIncludeEmpty: ReadonlySet<string>): TValues;
|
|
2
4
|
export declare function createFormController<TValues extends FormValues, TCtx = unknown>(options: FormControllerOptions<TValues, TCtx>): FormController<TValues>;
|
|
@@ -65,13 +65,13 @@ function valuesDiff(current, initial) {
|
|
|
65
65
|
// The seed of an untouched optional money field (buildInitialValues); never a valid payload value.
|
|
66
66
|
// Stripped only while the initial value was that seed too: clearing a stored amount must reach the
|
|
67
67
|
// server, which rejects it visibly instead of keeping the old amount silently.
|
|
68
|
-
function isCurrencyOnlyMoney(value) {
|
|
68
|
+
export function isCurrencyOnlyMoney(value) {
|
|
69
69
|
return (typeof value === "object" &&
|
|
70
70
|
value !== null &&
|
|
71
71
|
"currency" in value &&
|
|
72
72
|
!("amount" in value && value.amount !== undefined));
|
|
73
73
|
}
|
|
74
|
-
function stripUntouchedEmptyStrings(values, initial, forceIncludeEmpty) {
|
|
74
|
+
export function stripUntouchedEmptyStrings(values, initial, forceIncludeEmpty) {
|
|
75
75
|
const v = values; // @cast-boundary form-values
|
|
76
76
|
const ini = initial; // @cast-boundary form-values
|
|
77
77
|
let out;
|
|
@@ -6,7 +6,7 @@ export declare const UNIT_FORMAT_KEYS: readonly string[];
|
|
|
6
6
|
export { DOCUMENT_FALLBACK_CURRENCY, type DocumentDateOptions, formatDocumentDate, formatDocumentMoney, formatDocumentPercent, } from "./document-values.ts";
|
|
7
7
|
export { escapeHtml, escapeHtmlAttr, escapeXml, isSafeHref, stripControlChars } from "./escape.ts";
|
|
8
8
|
export { type HtmlValue, html, RawHtml, raw } from "./html-template.ts";
|
|
9
|
-
export { currencyDecimals, formatMoney, resolveSafeMoneyLocale } from "./money.ts";
|
|
9
|
+
export { currencyDecimals, formatMoney, formatMoneyValue, moneyAmountToMinor, resolveSafeMoneyLocale, } from "./money.ts";
|
|
10
10
|
export { telHref } from "./phone.ts";
|
|
11
11
|
export declare function applyFormatSpec(spec: {
|
|
12
12
|
format: string;
|
|
@@ -134,7 +134,7 @@ export const UNIT_FORMAT_KEYS = [
|
|
|
134
134
|
export { DOCUMENT_FALLBACK_CURRENCY, formatDocumentDate, formatDocumentMoney, formatDocumentPercent, } from "./document-values.js";
|
|
135
135
|
export { escapeHtml, escapeHtmlAttr, escapeXml, isSafeHref, stripControlChars } from "./escape.js";
|
|
136
136
|
export { html, RawHtml, raw } from "./html-template.js";
|
|
137
|
-
export { currencyDecimals, formatMoney, resolveSafeMoneyLocale } from "./money.js";
|
|
137
|
+
export { currencyDecimals, formatMoney, formatMoneyValue, moneyAmountToMinor, resolveSafeMoneyLocale, } from "./money.js";
|
|
138
138
|
export { telHref } from "./phone.js";
|
|
139
139
|
// JSON.stringify throws on BigInt and circular values; a cell must degrade to text instead of crashing the screen.
|
|
140
140
|
function stringifyJsonOrString(value, indent) {
|
|
@@ -280,7 +280,7 @@ function formatJsonCell(spec, value) {
|
|
|
280
280
|
return stringifyJsonOrString(value, typeof spec["indent"] === "number" ? spec["indent"] : 2);
|
|
281
281
|
}
|
|
282
282
|
const RELATIVE_TIME_STYLES = ["long", "short", "narrow"];
|
|
283
|
-
function formatRelativeTimeCell(spec, value) {
|
|
283
|
+
function formatRelativeTimeCell(spec, value, translate) {
|
|
284
284
|
const atMs = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
|
|
285
285
|
if (!Number.isFinite(atMs))
|
|
286
286
|
return String(value);
|
|
@@ -288,9 +288,10 @@ function formatRelativeTimeCell(spec, value) {
|
|
|
288
288
|
const absoluteAfterDays = spec["absoluteAfterDays"];
|
|
289
289
|
const timeZone = stringSpec(spec, "timeZone");
|
|
290
290
|
return formatRelativeTime(atMs, serverNowMs(), stringSpec(spec, "locale"), {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
291
|
+
style: isOneOf(RELATIVE_TIME_STYLES, style) ? style : "short",
|
|
292
|
+
absoluteAfterDays: typeof absoluteAfterDays === "number" ? absoluteAfterDays : 7,
|
|
293
|
+
withTime: spec["withTime"] !== false,
|
|
294
|
+
...(translate !== undefined && { justNow: translate("kumiko.time.justNow") }),
|
|
294
295
|
...(timeZone !== undefined && { timeZone }),
|
|
295
296
|
});
|
|
296
297
|
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export declare function currencyDecimals(code: string): number;
|
|
2
|
+
export declare function moneyAmountToMinor(amount: number, currency: string): number;
|
|
3
|
+
export declare function formatMoneyValue(value: {
|
|
4
|
+
readonly amount: number;
|
|
5
|
+
readonly currency: string;
|
|
6
|
+
}, locale?: string): string;
|
|
2
7
|
export declare function resolveSafeMoneyLocale(locale: string | undefined): string;
|
|
3
8
|
export declare function formatMoney(amountMinor: number, currency: string, locale?: string, fractionDigits?: number): string;
|
|
@@ -10,6 +10,16 @@ export function currencyDecimals(code) {
|
|
|
10
10
|
return 3;
|
|
11
11
|
return 2;
|
|
12
12
|
}
|
|
13
|
+
// Major-unit amount → minor units scaled by currencyDecimals(currency), as
|
|
14
|
+
// formatMoney expects. Deliberately not rehydrateMoney's `amountMinor`: that
|
|
15
|
+
// uses a flat MINOR_UNIT_SCALE=100, which is wrong for JPY (0 decimals) and
|
|
16
|
+
// BHD (3 decimals).
|
|
17
|
+
export function moneyAmountToMinor(amount, currency) {
|
|
18
|
+
return Math.round(amount * 10 ** currencyDecimals(currency));
|
|
19
|
+
}
|
|
20
|
+
export function formatMoneyValue(value, locale) {
|
|
21
|
+
return formatMoney(moneyAmountToMinor(value.amount, value.currency), value.currency, locale);
|
|
22
|
+
}
|
|
13
23
|
const FALLBACK_MONEY_LOCALE = "en-US";
|
|
14
24
|
// An invalid tag makes Intl constructors throw a RangeError; canonicalizing up
|
|
15
25
|
// front keeps server renders and client cells safe. No navigator lookup, so it
|
|
@@ -3,6 +3,8 @@ export type RelativeTimeOptions = {
|
|
|
3
3
|
readonly absoluteAfterDays?: number;
|
|
4
4
|
readonly withTime?: boolean;
|
|
5
5
|
readonly timeZone?: string;
|
|
6
|
+
/** Translated text for past moments below a minute ("just now") instead of "N seconds ago". */
|
|
7
|
+
readonly justNow?: string;
|
|
6
8
|
};
|
|
7
9
|
/** "5 minutes ago" / "in 30 seconds" in the given locale. The unit grows with the
|
|
8
10
|
* distance (seconds below a minute, minutes below an hour, hours below a day);
|
|
@@ -38,8 +38,11 @@ export function formatRelativeTime(atMs, nowMs, locale, options = {}) {
|
|
|
38
38
|
style: options.style ?? "long",
|
|
39
39
|
});
|
|
40
40
|
const seconds = Math.round((atMs - nowMs) / 1000);
|
|
41
|
-
if (Math.abs(seconds) < SECONDS_PER_MINUTE)
|
|
41
|
+
if (Math.abs(seconds) < SECONDS_PER_MINUTE) {
|
|
42
|
+
if (options.justNow !== undefined && seconds <= 0)
|
|
43
|
+
return options.justNow;
|
|
42
44
|
return formatter.format(seconds, "second");
|
|
45
|
+
}
|
|
43
46
|
const minutes = Math.round(seconds / SECONDS_PER_MINUTE);
|
|
44
47
|
if (Math.abs(minutes) < MINUTES_PER_HOUR)
|
|
45
48
|
return formatter.format(minutes, "minute");
|
package/dist/headless/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type { BatchResult, Command, Dispatcher, DispatcherError, DispatcherStatu
|
|
|
5
5
|
export { generateRequestId, StreamFrame, type StreamFrameEvent } from "./dispatcher/index.ts";
|
|
6
6
|
export type { FieldConditionPredicate, FieldConditions, FieldConditionValue, FieldState, FormController, FormControllerOptions, FormSnapshot, FormValues, SubmitConfig, SubmitPayloadMode, SubmitResult, } from "./form/index.ts";
|
|
7
7
|
export { createFormController, groupIssuesByPath, I18N_KEY_PARAM, relevantFieldIssues, zodErrorToFieldIssues, } from "./form/index.ts";
|
|
8
|
-
export { applyFormatSpec, currencyDecimals, DOCUMENT_FALLBACK_CURRENCY, EMPTY_VALUE_PLACEHOLDER, escapeHtml, escapeHtmlAttr, escapeXml, formatDocumentDate, formatDocumentMoney, formatDocumentPercent, formatMoney, type HtmlValue, html, isSafeHref, RawHtml, raw, resolveSafeMoneyLocale, stripControlChars, telHref, toInstant, } from "./format/index.ts";
|
|
8
|
+
export { applyFormatSpec, currencyDecimals, DOCUMENT_FALLBACK_CURRENCY, EMPTY_VALUE_PLACEHOLDER, escapeHtml, escapeHtmlAttr, escapeXml, formatDocumentDate, formatDocumentMoney, formatDocumentPercent, formatMoney, formatMoneyValue, type HtmlValue, html, isSafeHref, moneyAmountToMinor, RawHtml, raw, resolveSafeMoneyLocale, stripControlChars, telHref, toInstant, } from "./format/index.ts";
|
|
9
9
|
export type { NavDefinition, NavNode, NavRegistrySlice, NavTree, ResolveNavigationOptions, } from "./nav/index.ts";
|
|
10
10
|
export { resolveNavigation } from "./nav/index.ts";
|
|
11
11
|
export { pluralKey } from "./plural-key.ts";
|
package/dist/headless/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
export { parseRefTarget } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
4
4
|
export { generateRequestId, StreamFrame } from "./dispatcher/index.js";
|
|
5
5
|
export { createFormController, groupIssuesByPath, I18N_KEY_PARAM, relevantFieldIssues, zodErrorToFieldIssues, } from "./form/index.js";
|
|
6
|
-
export { applyFormatSpec, currencyDecimals, DOCUMENT_FALLBACK_CURRENCY, EMPTY_VALUE_PLACEHOLDER, escapeHtml, escapeHtmlAttr, escapeXml, formatDocumentDate, formatDocumentMoney, formatDocumentPercent, formatMoney, html, isSafeHref, RawHtml, raw, resolveSafeMoneyLocale, stripControlChars, telHref, toInstant, } from "./format/index.js";
|
|
6
|
+
export { applyFormatSpec, currencyDecimals, DOCUMENT_FALLBACK_CURRENCY, EMPTY_VALUE_PLACEHOLDER, escapeHtml, escapeHtmlAttr, escapeXml, formatDocumentDate, formatDocumentMoney, formatDocumentPercent, formatMoney, formatMoneyValue, html, isSafeHref, moneyAmountToMinor, RawHtml, raw, resolveSafeMoneyLocale, stripControlChars, telHref, toInstant, } from "./format/index.js";
|
|
7
7
|
export { resolveNavigation } from "./nav/index.js";
|
|
8
8
|
export { pluralKey } from "./plural-key.js";
|
|
9
9
|
export { PWA_CACHE_NAME_PREFIX, PWA_CACHE_SCOPE_HASH_LENGTH, PWA_SERVICE_WORKER_META_NAME, pwaCacheScopePrefixOf, } from "./pwa-service-worker-meta.js";
|
|
@@ -36,6 +36,9 @@ function computeWriteFormSectionViewModel(sectionSpec, screenId, values, transla
|
|
|
36
36
|
...(sectionSpec.description !== undefined && {
|
|
37
37
|
description: translate(sectionSpec.description),
|
|
38
38
|
}),
|
|
39
|
+
...(sectionSpec.descriptionNarrow !== undefined && {
|
|
40
|
+
descriptionNarrow: translate(sectionSpec.descriptionNarrow),
|
|
41
|
+
}),
|
|
39
42
|
columns: sectionSpec.columns ?? 1,
|
|
40
43
|
fields,
|
|
41
44
|
...(sectionSpec.icon !== undefined && { icon: sectionSpec.icon }),
|
|
@@ -43,6 +46,7 @@ function computeWriteFormSectionViewModel(sectionSpec, screenId, values, transla
|
|
|
43
46
|
...(sectionSpec.submitLabel !== undefined && {
|
|
44
47
|
submitLabel: translate(sectionSpec.submitLabel),
|
|
45
48
|
}),
|
|
49
|
+
...(sectionSpec.submitWith !== undefined && { submitWith: sectionSpec.submitWith }),
|
|
46
50
|
...(sectionSpec.actions !== undefined && { actions: sectionSpec.actions }),
|
|
47
51
|
};
|
|
48
52
|
}
|
|
@@ -114,19 +118,30 @@ export function computeRelatedListSectionViewModel(sectionSpec, translate) {
|
|
|
114
118
|
...(sectionSpec.id !== undefined && { id: sectionSpec.id }),
|
|
115
119
|
title: translate(sectionSpec.title),
|
|
116
120
|
query: sectionSpec.query,
|
|
117
|
-
...(sectionSpec.parentParam !== undefined && { parentParam: sectionSpec.parentParam }),
|
|
118
|
-
...(sectionSpec.parentFilter !== undefined && { parentFilter: sectionSpec.parentFilter }),
|
|
119
121
|
columns: sectionSpec.columns,
|
|
120
|
-
...(sectionSpec.entity !== undefined && { entity: sectionSpec.entity }),
|
|
121
122
|
...(sectionSpec.description !== undefined && {
|
|
122
123
|
description: translate(sectionSpec.description),
|
|
123
124
|
}),
|
|
125
|
+
...relatedListQueryProps(sectionSpec),
|
|
126
|
+
...relatedListRowProps(sectionSpec),
|
|
127
|
+
...relatedListEmptyStateProps(sectionSpec, translate),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function relatedListQueryProps(sectionSpec) {
|
|
131
|
+
return {
|
|
132
|
+
...(sectionSpec.parentParam !== undefined && { parentParam: sectionSpec.parentParam }),
|
|
133
|
+
...(sectionSpec.parentFilter !== undefined && { parentFilter: sectionSpec.parentFilter }),
|
|
134
|
+
...(sectionSpec.entity !== undefined && { entity: sectionSpec.entity }),
|
|
124
135
|
...(sectionSpec.itemNoun !== undefined && { itemNoun: sectionSpec.itemNoun }),
|
|
125
136
|
...(sectionSpec.pageSize !== undefined && { pageSize: sectionSpec.pageSize }),
|
|
126
137
|
...(sectionSpec.table !== undefined && { table: sectionSpec.table }),
|
|
127
138
|
...(sectionSpec.defaultSort !== undefined && { defaultSort: sectionSpec.defaultSort }),
|
|
128
139
|
...(sectionSpec.searchable !== undefined && { searchable: sectionSpec.searchable }),
|
|
129
140
|
...(sectionSpec.facets !== undefined && { facets: sectionSpec.facets }),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function relatedListRowProps(sectionSpec) {
|
|
144
|
+
return {
|
|
130
145
|
...(sectionSpec.rowClick !== undefined && { rowClick: sectionSpec.rowClick }),
|
|
131
146
|
...(sectionSpec.rowActions !== undefined && { rowActions: sectionSpec.rowActions }),
|
|
132
147
|
...(sectionSpec.rowActionMode !== undefined && { rowActionMode: sectionSpec.rowActionMode }),
|
|
@@ -135,29 +150,32 @@ export function computeRelatedListSectionViewModel(sectionSpec, translate) {
|
|
|
135
150
|
...(sectionSpec.toolbarActions !== undefined && { toolbarActions: sectionSpec.toolbarActions }),
|
|
136
151
|
...(sectionSpec.actions !== undefined && { actions: sectionSpec.actions }),
|
|
137
152
|
...(sectionSpec.photoGrid !== undefined && { photoGrid: sectionSpec.photoGrid }),
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function relatedListEmptyStateProps(sectionSpec, translate) {
|
|
156
|
+
const { emptyState } = sectionSpec;
|
|
157
|
+
if (emptyState === undefined)
|
|
158
|
+
return {};
|
|
159
|
+
return {
|
|
160
|
+
emptyState: {
|
|
161
|
+
title: translate(emptyState.title),
|
|
162
|
+
...(emptyState.description !== undefined && {
|
|
163
|
+
description: translate(emptyState.description),
|
|
164
|
+
}),
|
|
165
|
+
// Action stays untranslated, same convention as rowActions/
|
|
166
|
+
// toolbarActions above — the renderer's row-actions builder
|
|
167
|
+
// translates `action.label` at button-build time.
|
|
168
|
+
...(emptyState.action !== undefined && { action: emptyState.action }),
|
|
169
|
+
...(emptyState.variants !== undefined && {
|
|
170
|
+
variants: emptyState.variants.map((variant) => ({
|
|
171
|
+
when: variant.when,
|
|
172
|
+
title: translate(variant.title),
|
|
173
|
+
...(variant.description !== undefined && {
|
|
174
|
+
description: translate(variant.description),
|
|
175
|
+
}),
|
|
176
|
+
})),
|
|
177
|
+
}),
|
|
178
|
+
},
|
|
161
179
|
};
|
|
162
180
|
}
|
|
163
181
|
function translateAffix(affix, translate) {
|
|
@@ -202,6 +220,14 @@ function deriveFieldAffixHints(normalized, translate) {
|
|
|
202
220
|
},
|
|
203
221
|
}),
|
|
204
222
|
...(normalized.valueChips !== undefined && { valueChips: normalized.valueChips }),
|
|
223
|
+
...(normalized.concealed === true && { concealed: true }),
|
|
224
|
+
...(normalized.badge !== undefined && {
|
|
225
|
+
badge: "label" in normalized.badge
|
|
226
|
+
? { label: translate(normalized.badge.label), tone: normalized.badge.tone }
|
|
227
|
+
: normalized.badge,
|
|
228
|
+
}),
|
|
229
|
+
...(normalized.hintField !== undefined && { hintField: normalized.hintField }),
|
|
230
|
+
...(normalized.hideOnNarrow === true && { hideOnNarrow: true }),
|
|
205
231
|
};
|
|
206
232
|
}
|
|
207
233
|
function deriveSelectOptionsQuery(fieldDef) {
|
|
@@ -457,22 +483,25 @@ function isEditFieldRequired(normalized, fieldDef, values) {
|
|
|
457
483
|
? evalFieldCondition(normalized.required, values)
|
|
458
484
|
: isFieldRequired(fieldDef, values);
|
|
459
485
|
}
|
|
486
|
+
function computeNonFieldsSectionViewModel(sectionSpec, screenId, values, translate, featureName) {
|
|
487
|
+
if (isExtensionEditSection(sectionSpec)) {
|
|
488
|
+
return buildExtensionSectionViewModel(sectionSpec, translate);
|
|
489
|
+
}
|
|
490
|
+
if (isWriteFormEditSection(sectionSpec)) {
|
|
491
|
+
return computeWriteFormSectionViewModel(sectionSpec, screenId, values, translate, featureName);
|
|
492
|
+
}
|
|
493
|
+
if (sectionSpec.kind === "stepList") {
|
|
494
|
+
return computeStepListSectionViewModel(sectionSpec, values, translate);
|
|
495
|
+
}
|
|
496
|
+
return computeRelatedListSectionViewModel(sectionSpec, translate);
|
|
497
|
+
}
|
|
460
498
|
export function computeEditViewModel(input) {
|
|
461
499
|
const { screen, entity, values, translate, featureName, mode, entityId, derivation, actionFormScreenQn, } = input;
|
|
462
500
|
const excludedFields = new Set(mode === undefined ? [] : screen.writeExcludedFields?.[mode]);
|
|
463
501
|
const isHiddenByExclusion = (fieldSpec) => mode === "create" && excludedFields.has(normalizeEditField(fieldSpec).field);
|
|
464
|
-
const
|
|
465
|
-
if (isExtensionEditSection(sectionSpec)) {
|
|
466
|
-
return buildExtensionSectionViewModel(sectionSpec, translate);
|
|
467
|
-
}
|
|
468
|
-
if (isWriteFormEditSection(sectionSpec)) {
|
|
469
|
-
return computeWriteFormSectionViewModel(sectionSpec, screen.id, values, translate, featureName);
|
|
470
|
-
}
|
|
471
|
-
if (sectionSpec.kind === "stepList") {
|
|
472
|
-
return computeStepListSectionViewModel(sectionSpec, values, translate);
|
|
473
|
-
}
|
|
502
|
+
const baseSections = screen.layout.sections.map((sectionSpec) => {
|
|
474
503
|
if (!isFieldsEditSection(sectionSpec)) {
|
|
475
|
-
return
|
|
504
|
+
return computeNonFieldsSectionViewModel(sectionSpec, screen.id, values, translate, featureName);
|
|
476
505
|
}
|
|
477
506
|
// `groups` flattens into the same per-field pipeline as plain `fields`;
|
|
478
507
|
// the group structure below just re-groups the computed views by name.
|
|
@@ -561,6 +590,7 @@ export function computeEditViewModel(input) {
|
|
|
561
590
|
.map((group) => ({
|
|
562
591
|
title: translate(group.title),
|
|
563
592
|
columns: group.columns ?? 2,
|
|
593
|
+
...(group.columns !== undefined && { columnsDeclared: true }),
|
|
564
594
|
fields: group.fields.map((fieldSpec) => {
|
|
565
595
|
const fieldName = normalizeEditField(fieldSpec).field;
|
|
566
596
|
const fieldView = fields.find((f) => f.field === fieldName);
|
|
@@ -577,14 +607,24 @@ export function computeEditViewModel(input) {
|
|
|
577
607
|
visible,
|
|
578
608
|
emptiedByWriteExclusion: wasEmptiedByWriteExclusion(declaredFieldSpecs, fields),
|
|
579
609
|
...translateSectionTexts(sectionSpec, translate),
|
|
610
|
+
...(sectionSpec.descriptionNarrow !== undefined && {
|
|
611
|
+
descriptionNarrow: translate(sectionSpec.descriptionNarrow),
|
|
612
|
+
}),
|
|
580
613
|
...(sectionSpec.summaryField !== undefined && { summaryField: sectionSpec.summaryField }),
|
|
581
614
|
columns: sectionSpec.columns ?? defaultColumns,
|
|
615
|
+
...(sectionSpec.columns !== undefined && { columnsDeclared: true }),
|
|
582
616
|
fields,
|
|
583
617
|
...(groups !== undefined && { groups }),
|
|
584
618
|
...(sectionSpec.icon !== undefined && { icon: sectionSpec.icon }),
|
|
585
619
|
...(sectionSpec.actions !== undefined && { actions: sectionSpec.actions }),
|
|
586
620
|
};
|
|
587
621
|
});
|
|
622
|
+
const sections = baseSections.map((section, index) => {
|
|
623
|
+
const sectionSpec = screen.layout.sections[index];
|
|
624
|
+
return sectionSpec === undefined
|
|
625
|
+
? section
|
|
626
|
+
: withSectionPresentation(section, sectionSpec, translate);
|
|
627
|
+
});
|
|
588
628
|
const idValue = values["id"];
|
|
589
629
|
const id = typeof idValue === "string" ? idValue : null;
|
|
590
630
|
return {
|
|
@@ -595,6 +635,16 @@ export function computeEditViewModel(input) {
|
|
|
595
635
|
...(screen.slots && { slots: screen.slots }),
|
|
596
636
|
};
|
|
597
637
|
}
|
|
638
|
+
function withSectionPresentation(section, spec, translate) {
|
|
639
|
+
return {
|
|
640
|
+
...section,
|
|
641
|
+
...(spec.tabLabel !== undefined && { tabLabel: translate(spec.tabLabel) }),
|
|
642
|
+
...(spec.after !== undefined && { after: spec.after }),
|
|
643
|
+
...(spec.hideOnNarrow === true && { hideOnNarrow: true }),
|
|
644
|
+
...(spec.showOnNarrowOnly === true && { showOnNarrowOnly: true }),
|
|
645
|
+
...(spec.titleOnNarrow === false && { titleOnNarrow: false }),
|
|
646
|
+
};
|
|
647
|
+
}
|
|
598
648
|
// Resolves a FieldCondition against the current row values.
|
|
599
649
|
// `undefined` means "not declared" — caller substitutes the default.
|
|
600
650
|
function evalCondition(condition, fallback, values) {
|
|
@@ -74,6 +74,7 @@ function declaredReferenceColumn(input, column) {
|
|
|
74
74
|
refLabelField: column.refLabelField ?? "id",
|
|
75
75
|
...(column.renderer !== undefined && { renderer: column.renderer }),
|
|
76
76
|
...(column.hideOnNarrow === true && { hideOnNarrow: true }),
|
|
77
|
+
...(column.hideWhenDocked === true && { hideWhenDocked: true }),
|
|
77
78
|
};
|
|
78
79
|
}
|
|
79
80
|
function storedFieldColumn(input, column) {
|
|
@@ -89,6 +90,7 @@ function storedFieldColumn(input, column) {
|
|
|
89
90
|
...(column.renderer !== undefined && { renderer: column.renderer }),
|
|
90
91
|
...storedFieldMetadata(input, column, fieldDef),
|
|
91
92
|
...(column.hideOnNarrow === true && { hideOnNarrow: true }),
|
|
93
|
+
...(column.hideWhenDocked === true && { hideWhenDocked: true }),
|
|
92
94
|
};
|
|
93
95
|
}
|
|
94
96
|
// Key order is part of the serialized view model, so it stays fixed here.
|
|
@@ -141,6 +143,7 @@ function derivedFieldColumn(input, column) {
|
|
|
141
143
|
sortable: "sortable" in derivedDef && derivedDef.sortable === true,
|
|
142
144
|
...(column.renderer !== undefined && { renderer: column.renderer }),
|
|
143
145
|
...(column.hideOnNarrow === true && { hideOnNarrow: true }),
|
|
146
|
+
...(column.hideWhenDocked === true && { hideWhenDocked: true }),
|
|
144
147
|
};
|
|
145
148
|
}
|
|
146
149
|
// Row-meta column (id/tenantId/version/insertedAt/modifiedAt/...) —
|
|
@@ -163,6 +166,7 @@ function rowMetaColumn(input, column) {
|
|
|
163
166
|
sortable: rowMetaRef === undefined,
|
|
164
167
|
...(column.renderer !== undefined && { renderer: column.renderer }),
|
|
165
168
|
...(column.hideOnNarrow === true && { hideOnNarrow: true }),
|
|
169
|
+
...(column.hideWhenDocked === true && { hideWhenDocked: true }),
|
|
166
170
|
...(rowMetaRef !== undefined && {
|
|
167
171
|
refEntity: rowMetaRef.refEntity,
|
|
168
172
|
refFeature: rowMetaRef.refFeature,
|
|
@@ -187,6 +191,7 @@ function virtualRendererColumn(input, column) {
|
|
|
187
191
|
sortable: false,
|
|
188
192
|
renderer: column.renderer,
|
|
189
193
|
...(column.hideOnNarrow === true && { hideOnNarrow: true }),
|
|
194
|
+
...(column.hideWhenDocked === true && { hideWhenDocked: true }),
|
|
190
195
|
};
|
|
191
196
|
}
|
|
192
197
|
// A column naming a field of the screen's rowDecoration query: the value lives
|
|
@@ -202,6 +207,7 @@ function rowDecorationColumn(input, column) {
|
|
|
202
207
|
sortable: false,
|
|
203
208
|
...(column.renderer !== undefined && { renderer: column.renderer }),
|
|
204
209
|
...(column.hideOnNarrow === true && { hideOnNarrow: true }),
|
|
210
|
+
...(column.hideWhenDocked === true && { hideWhenDocked: true }),
|
|
205
211
|
};
|
|
206
212
|
}
|
|
207
213
|
// The wire carries `true` (set) / `null` (empty) for writeOnly fields; the cell shows a word, not "true".
|