@cosmicdrift/kumiko-renderer 0.415.0 → 0.416.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/action-form-body.d.ts +1 -1
- package/dist/app/action-form-body.js +43 -16
- package/dist/app/action-form-support.d.ts +4 -1
- package/dist/app/action-form-support.js +8 -4
- package/dist/app/client-actions.js +6 -4
- package/dist/app/config-edit-body.js +13 -4
- package/dist/app/extension-sections.d.ts +2 -0
- package/dist/app/projection-detail-body.js +8 -6
- package/dist/app/projection-detail-guidance.d.ts +1 -1
- package/dist/app/projection-detail-guidance.js +38 -26
- package/dist/app/projection-detail-header-model.d.ts +1 -1
- package/dist/app/projection-detail-header-model.js +10 -5
- package/dist/app/projection-detail-header.js +1 -1
- package/dist/app/projection-detail-navigation.d.ts +4 -0
- package/dist/app/projection-detail-navigation.js +5 -1
- package/dist/app/screen-shared.d.ts +1 -0
- package/dist/app/screen-shared.js +23 -3
- package/dist/app/use-projection-detail-actions.d.ts +13 -0
- package/dist/app/use-projection-detail-actions.js +14 -2
- package/dist/app/use-projection-detail-data.d.ts +2 -0
- package/dist/app/use-projection-detail-data.js +37 -10
- package/dist/components/ai-assist-payload.d.ts +2 -0
- package/dist/components/ai-assist-payload.js +8 -0
- package/dist/components/edit-mounts.d.ts +3 -2
- package/dist/components/edit-mounts.js +2 -2
- package/dist/components/multi-select-chips.d.ts +10 -0
- package/dist/components/multi-select-chips.js +18 -0
- package/dist/components/related-list-section.js +44 -32
- package/dist/components/related-photo-grid.d.ts +11 -0
- package/dist/components/related-photo-grid.js +40 -0
- package/dist/components/render-edit-action-button.d.ts +2 -2
- package/dist/components/render-edit-field-grid.js +3 -3
- package/dist/components/render-edit-header-actions.d.ts +2 -1
- package/dist/components/render-edit-header-actions.js +18 -1
- package/dist/components/render-edit-layout.js +2 -2
- package/dist/components/render-edit-logic.js +1 -0
- package/dist/components/render-edit-section-kinds.js +11 -0
- package/dist/components/render-edit-types.d.ts +11 -1
- package/dist/components/render-field-ai-assist.d.ts +13 -0
- package/dist/components/render-field-ai-assist.js +89 -0
- package/dist/components/render-field-choice-inputs.js +4 -0
- package/dist/components/render-field-control.d.ts +1 -1
- package/dist/components/render-field-control.js +18 -8
- package/dist/components/render-field-value-chips.d.ts +9 -0
- package/dist/components/render-field-value-chips.js +45 -0
- package/dist/components/render-field-write-only.js +12 -4
- package/dist/components/render-list-hint-columns.d.ts +1 -0
- package/dist/components/render-list-hint-columns.js +13 -0
- package/dist/components/use-render-edit-sections.js +5 -1
- package/dist/components/use-render-list-columns.js +3 -3
- package/dist/headless/format/index.d.ts +1 -0
- package/dist/headless/format/index.js +20 -0
- package/dist/headless/format/phone.d.ts +1 -0
- package/dist/headless/format/phone.js +8 -0
- package/dist/headless/format/relative-time.d.ts +13 -0
- package/dist/headless/format/relative-time.js +60 -0
- package/dist/headless/format/safe-locale.d.ts +1 -0
- package/dist/headless/format/safe-locale.js +13 -0
- package/dist/headless/index.d.ts +2 -2
- package/dist/headless/index.js +2 -2
- package/dist/headless/view-model/edit.d.ts +3 -2
- package/dist/headless/view-model/edit.js +78 -2
- package/dist/headless/view-model/field-text.d.ts +9 -0
- package/dist/headless/view-model/field-text.js +19 -0
- package/dist/headless/view-model/index.d.ts +1 -0
- package/dist/headless/view-model/index.js +1 -0
- package/dist/headless/view-model/types.d.ts +29 -3
- package/dist/i18n-defaults.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/primitives-record-guidance.d.ts +28 -1
- package/dist/primitives.d.ts +10 -3
- package/dist/web/app/dashboard-body.js +3 -2
- package/dist/web/app/dashboard-list-panel.js +1 -0
- package/dist/web/app/dashboard-panel-columns.d.ts +9 -0
- package/dist/web/app/dashboard-panel-columns.js +14 -0
- package/dist/web/app/dashboard-shared.js +1 -1
- package/dist/web/app/dashboard-stat-group-panel.js +9 -2
- package/dist/web/app/dashboard-text-panel.d.ts +1 -0
- package/dist/web/app/dashboard-text-panel.js +11 -9
- package/dist/web/app/relative-time.d.ts +0 -5
- package/dist/web/app/relative-time.js +1 -20
- package/dist/web/primitives/banner.js +11 -6
- package/dist/web/primitives/data-table/card-body.js +2 -2
- package/dist/web/primitives/data-table/card-row.js +7 -2
- package/dist/web/primitives/data-table/data-cell-props.d.ts +2 -0
- package/dist/web/primitives/data-table/data-cell-props.js +2 -0
- package/dist/web/primitives/data-table/row-click-guard.d.ts +2 -0
- package/dist/web/primitives/data-table/row-click-guard.js +19 -0
- package/dist/web/primitives/data-table/table-body.js +2 -1
- package/dist/web/primitives/data-table/table-content.js +6 -2
- package/dist/web/primitives/data-table-cell.d.ts +4 -1
- package/dist/web/primitives/data-table-cell.js +16 -2
- package/dist/web/primitives/default-form.js +6 -3
- package/dist/web/primitives/drawer.js +5 -1
- package/dist/web/primitives/form-footer-parts.js +4 -1
- package/dist/web/primitives/form.js +6 -8
- package/dist/web/primitives/index.js +4 -0
- package/dist/web/primitives/layout-elements.d.ts +1 -1
- package/dist/web/primitives/layout-elements.js +2 -2
- package/dist/web/primitives/locale-number.d.ts +0 -1
- package/dist/web/primitives/locale-number.js +1 -13
- package/dist/web/primitives/money-input.js +2 -1
- package/dist/web/primitives/narrow-pinned-footer.js +7 -3
- package/dist/web/primitives/number-input.js +2 -1
- package/dist/web/primitives/photo-grid.d.ts +3 -0
- package/dist/web/primitives/photo-grid.js +5 -0
- package/dist/web/primitives/record-steps.d.ts +1 -1
- package/dist/web/primitives/record-steps.js +4 -4
- package/dist/web/primitives/record-summary.d.ts +1 -1
- package/dist/web/primitives/record-summary.js +8 -3
- package/dist/web/primitives/step-list.d.ts +3 -0
- package/dist/web/primitives/step-list.js +11 -0
- package/dist/web/widgets/dashboard-list.d.ts +2 -0
- package/dist/web/widgets/dashboard-list.js +2 -2
- package/dist/web/widgets/drawer-panel-class.js +1 -1
- package/package.json +5 -5
- package/src/changes.json +54 -0
|
@@ -1,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
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
// Context payload every aiAssist query of the surrounding form receives; set by the screen that
|
|
3
|
+
// knows what the form is about (actionForm: its load id or drawer row values).
|
|
4
|
+
const AiAssistPayloadContext = createContext({});
|
|
5
|
+
export const AiAssistPayloadProvider = AiAssistPayloadContext.Provider;
|
|
6
|
+
export function useAiAssistPayload() {
|
|
7
|
+
return useContext(AiAssistPayloadContext);
|
|
8
|
+
}
|
|
@@ -19,9 +19,9 @@ export declare function ExtensionSectionMount({ section, entityName: hostEntityN
|
|
|
19
19
|
readonly stepKey?: string;
|
|
20
20
|
readonly onReportStepComplete?: (stepKey: string, complete: boolean) => void;
|
|
21
21
|
}): ReactNode;
|
|
22
|
-
export declare function EditSlotMount({ slot, slotName, screenId, entityName, entityId, values, markSaved, hasUnsavedChanges, wizardStep, }: {
|
|
22
|
+
export declare function EditSlotMount({ slot, slotName, screenId, entityName, entityId, values, markSaved, hasUnsavedChanges, wizardStep, activeTabId, }: {
|
|
23
23
|
readonly slot: PlatformComponent;
|
|
24
|
-
readonly slotName: "header" | "titleAction" | "footer";
|
|
24
|
+
readonly slotName: "header" | "titleAction" | "afterForm" | "footer";
|
|
25
25
|
readonly screenId: string;
|
|
26
26
|
readonly entityName: string;
|
|
27
27
|
readonly entityId: string | null;
|
|
@@ -32,4 +32,5 @@ export declare function EditSlotMount({ slot, slotName, screenId, entityName, en
|
|
|
32
32
|
readonly index: number;
|
|
33
33
|
readonly isLast: boolean;
|
|
34
34
|
};
|
|
35
|
+
readonly activeTabId?: string;
|
|
35
36
|
} & StickyPrimaryActionMarker): ReactNode;
|
|
@@ -39,7 +39,7 @@ export function ExtensionSectionMount({ section, entityName: hostEntityName, ent
|
|
|
39
39
|
// component for both slots — header passes no hasUnsavedChanges/wizardStep,
|
|
40
40
|
// footer does. Own component for rules-of-hooks (useExtensionSectionComponent
|
|
41
41
|
// must not run conditionally inside RenderEdit's render body).
|
|
42
|
-
export function EditSlotMount({ slot, slotName, screenId, entityName, entityId, values, markSaved, hasUnsavedChanges, wizardStep, }) {
|
|
42
|
+
export function EditSlotMount({ slot, slotName, screenId, entityName, entityId, values, markSaved, hasUnsavedChanges, wizardStep, activeTabId, }) {
|
|
43
43
|
const name = extensionSectionName(slot);
|
|
44
44
|
const Component = useExtensionSectionComponent(name);
|
|
45
45
|
useEffect(() => {
|
|
@@ -49,5 +49,5 @@ export function EditSlotMount({ slot, slotName, screenId, entityName, entityId,
|
|
|
49
49
|
}, [name, Component, screenId, slotName]);
|
|
50
50
|
if (Component === undefined)
|
|
51
51
|
return null;
|
|
52
|
-
return (_jsx(Component, { entityName: entityName, entityId: entityId, values: values, ...(markSaved !== undefined && { markSaved }), ...(hasUnsavedChanges !== undefined && { hasUnsavedChanges }), ...(wizardStep !== undefined && { wizardStep }) }));
|
|
52
|
+
return (_jsx(Component, { entityName: entityName, entityId: entityId, values: values, ...(markSaved !== undefined && { markSaved }), ...(hasUnsavedChanges !== undefined && { hasUnsavedChanges }), ...(wizardStep !== undefined && { wizardStep }), ...(activeTabId !== undefined && { activeTabId }) }));
|
|
53
53
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { EditFieldViewModel } from "../headless/index.ts";
|
|
3
|
+
import type { MultiSelectCheckboxOption } from "./multi-select-checkboxes.tsx";
|
|
4
|
+
export declare function MultiSelectChips({ field, id, options, value, onChange, }: {
|
|
5
|
+
readonly field: EditFieldViewModel;
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly options: readonly MultiSelectCheckboxOption[];
|
|
8
|
+
readonly value: readonly string[];
|
|
9
|
+
readonly onChange: (value: readonly string[]) => void;
|
|
10
|
+
}): ReactNode;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { usePrimitives } from "../primitives.js";
|
|
3
|
+
// MultiSelectFieldDef's `display: "chips"`: every option is a toggle chip, ticked once chosen.
|
|
4
|
+
export function MultiSelectChips({ field, id, options, value, onChange, }) {
|
|
5
|
+
const { Button, Grid } = usePrimitives();
|
|
6
|
+
const selected = new Set(value);
|
|
7
|
+
// Emits in option order, like the checkbox grid, never in click order.
|
|
8
|
+
const toggle = (optionValue) => {
|
|
9
|
+
const next = new Set(selected);
|
|
10
|
+
if (!next.delete(optionValue))
|
|
11
|
+
next.add(optionValue);
|
|
12
|
+
onChange(options.filter((opt) => next.has(opt.value)).map((opt) => opt.value));
|
|
13
|
+
};
|
|
14
|
+
return (_jsx(Grid, { columns: "auto", tight: true, ariaLabelledBy: `${id}-label`, children: options.map((opt) => {
|
|
15
|
+
const isSelected = selected.has(opt.value);
|
|
16
|
+
return (_jsx(Button, { variant: isSelected ? "primary" : "secondary", size: "sm", pressed: isSelected, disabled: field.readOnly === true || opt.disabled === true, testId: `${id}-chip-${opt.value}`, onClick: () => toggle(opt.value), children: isSelected ? `✓ ${opt.label}` : opt.label }, opt.value));
|
|
17
|
+
}) }));
|
|
18
|
+
}
|
|
@@ -23,6 +23,7 @@ import { useOptionalLocale, useTranslation } from "../i18n.js";
|
|
|
23
23
|
import { PageHeaderSlotAvailableProvider } from "../page-header-slot.js";
|
|
24
24
|
import { usePrimitives } from "../primitives.js";
|
|
25
25
|
import { ListGroupPageBridges } from "./list-group-page-bridges.js";
|
|
26
|
+
import { RelatedPhotoGrid } from "./related-photo-grid.js";
|
|
26
27
|
import { RenderEditActionButton } from "./render-edit-action-button.js";
|
|
27
28
|
import { RenderList } from "./render-list.js";
|
|
28
29
|
// Keyed on the type, not on key presence: most factories omit `sortable`
|
|
@@ -79,8 +80,43 @@ function buildRowTone(rule) {
|
|
|
79
80
|
return undefined;
|
|
80
81
|
return (row) => (evalFieldCondition(rule, { ...row.values }) ? rule.tone : undefined);
|
|
81
82
|
}
|
|
83
|
+
function RelatedListEmptyState({ text, actionButton, onActionError, }) {
|
|
84
|
+
const { Text, Button, Dialog } = usePrimitives();
|
|
85
|
+
return (_jsxs(_Fragment, { children: [_jsx(Text, { children: text.title }), text.description !== undefined && _jsx(Text, { variant: "small", children: text.description }), actionButton !== undefined && (_jsx(RenderEditActionButton, { action: actionButton, Button: Button, Dialog: Dialog, onError: onActionError }))] }));
|
|
86
|
+
}
|
|
87
|
+
function EmbeddedRelatedListCard({ title, actions, testId, children, }) {
|
|
88
|
+
const { Card } = usePrimitives();
|
|
89
|
+
return (_jsx(Card, { options: { framed: false, padded: false },
|
|
90
|
+
// Trim the default header inset: the host row already pads the area.
|
|
91
|
+
className: "[&>div:first-child]:px-0 [&>div:first-child]:pt-1 [&>div:first-child]:pb-2", slots: { title, ...(actions !== undefined && { headerActions: actions }) }, testId: testId, children: children }));
|
|
92
|
+
}
|
|
93
|
+
// A row-body click target comes from EITHER the legacy `rowClick` field OR
|
|
94
|
+
// a `rowActions` entry marked rowClick:true — the boot-validator rejects
|
|
95
|
+
// both being set, so this order is just a fallback, not a precedence rule.
|
|
96
|
+
function buildRelatedListRowClick(section, nav, host, onOpenDrawer) {
|
|
97
|
+
const rowClick = section.rowClick;
|
|
98
|
+
if (rowClick !== undefined) {
|
|
99
|
+
return (row) => {
|
|
100
|
+
const id = String(row.values[rowClick.idColumn ?? "id"] ?? "");
|
|
101
|
+
if (id === "")
|
|
102
|
+
return;
|
|
103
|
+
navigateWithReturnTo(nav, { entity: rowClick.entity, id }, host);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const rowClickAction = findRowClickAction(section.rowActions);
|
|
107
|
+
if (rowClickAction === undefined)
|
|
108
|
+
return undefined;
|
|
109
|
+
return (row) => {
|
|
110
|
+
if (rowClickAction.kind === "navigate") {
|
|
111
|
+
runProjectionRowNavigate(nav, rowClickAction, row, host);
|
|
112
|
+
}
|
|
113
|
+
else if (onOpenDrawer !== undefined) {
|
|
114
|
+
runDrawerRowAction(rowClickAction, onOpenDrawer, row);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
82
118
|
export function RelatedListSection({ section, parentId, record, featureName, translate, hideTitle, grow, onOpenDrawer, actions, anchorId, embedded, onAfterWrite, refreshToken, }) {
|
|
83
|
-
const { Banner, Section,
|
|
119
|
+
const { Banner, Section, FillContainer, PhotoGrid } = usePrimitives();
|
|
84
120
|
const [emptyStateActionError, setEmptyStateActionError] = useState(null);
|
|
85
121
|
const t = useTranslation();
|
|
86
122
|
const effectiveTranslate = translate ?? t;
|
|
@@ -162,28 +198,7 @@ export function RelatedListSection({ section, parentId, record, featureName, tra
|
|
|
162
198
|
const { refetchSelfAndHost, aggregates } = listRows;
|
|
163
199
|
const onFilterChange = useCallback((field, values) => setFilters((prev) => ({ ...prev, [field]: values })), [setFilters]);
|
|
164
200
|
const onFilterReset = useCallback(() => setFilters({}), [setFilters]);
|
|
165
|
-
const
|
|
166
|
-
// A row-body click target comes from EITHER the legacy `rowClick` field OR
|
|
167
|
-
// a `rowActions` entry marked rowClick:true — the boot-validator rejects
|
|
168
|
-
// both being set, so this order is just a fallback, not a precedence rule.
|
|
169
|
-
const rowClickAction = findRowClickAction(section.rowActions);
|
|
170
|
-
const onRowClick = rowClick !== undefined
|
|
171
|
-
? (row) => {
|
|
172
|
-
const id = String(row.values[rowClick.idColumn ?? "id"] ?? "");
|
|
173
|
-
if (id === "")
|
|
174
|
-
return;
|
|
175
|
-
navigateWithReturnTo(nav, { entity: rowClick.entity, id }, host);
|
|
176
|
-
}
|
|
177
|
-
: rowClickAction !== undefined
|
|
178
|
-
? (row) => {
|
|
179
|
-
if (rowClickAction.kind === "navigate") {
|
|
180
|
-
runProjectionRowNavigate(nav, rowClickAction, row, host);
|
|
181
|
-
}
|
|
182
|
-
else if (onOpenDrawer !== undefined) {
|
|
183
|
-
runDrawerRowAction(rowClickAction, onOpenDrawer, row);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
: undefined;
|
|
201
|
+
const onRowClick = buildRelatedListRowClick(section, nav, host, onOpenDrawer);
|
|
187
202
|
// Same execution path as projectionList's rowActions (kumiko-screen.tsx) —
|
|
188
203
|
// a relatedList row has the identical "no guaranteed id field" shape a
|
|
189
204
|
// query-projection row has, so navigate/writeHandler dispatch is shared
|
|
@@ -286,12 +301,12 @@ export function RelatedListSection({ section, parentId, record, featureName, tra
|
|
|
286
301
|
refetchSelfAndHost,
|
|
287
302
|
]);
|
|
288
303
|
const emptyStateText = pickEmptyStateText(section.emptyState, record);
|
|
289
|
-
const emptyStateContent = emptyStateText !== undefined ? (
|
|
304
|
+
const emptyStateContent = emptyStateText !== undefined ? (_jsx(RelatedListEmptyState, { text: emptyStateText, actionButton: emptyStateActionButton, onActionError: setEmptyStateActionError })) : undefined;
|
|
290
305
|
// Without a cursor-driven pager the client-side sort covers only the fetched
|
|
291
306
|
// rows; the banner keeps it from claiming "these are the top N".
|
|
292
307
|
const content = listRows.firstLoad ? (_jsx(Banner, { padded: true, variant: "loading", testId: "related-list-loading", children: t("kumiko.widget.loading") })) : listRows.error ? (_jsx(Banner, { padded: true, variant: "error", testId: "related-list-error", children: dispatcherErrorText(listRows.error, effectiveTranslate) })) : (_jsxs(_Fragment, { children: [listRows.truncated && (_jsx(Banner, { variant: "info", testId: "related-list-truncated", children: effectiveTranslate("kumiko.list.related-list-truncated", {
|
|
293
308
|
count: listRows.rows.length,
|
|
294
|
-
}) })), emptyStateActionError !== null && (_jsxs(Banner, { variant: "error", testId: "related-list-empty-state-action-error", children: [emptyStateActionError.message, _jsx(ErrorReference, { requestId: emptyStateActionError.requestId })] })), _jsx(ListGroupPageBridges, { ...aggregates.groupPages }), _jsx(PageHeaderSlotAvailableProvider, { value: false, children: _jsx(RenderList, { screen: listScreen, entity: entity, rows: listRows.rows, featureName: listFeatureName ?? featureName, translate: effectiveTranslate, ...(section.description !== undefined && { description: section.description }), ...(section.itemNoun !== undefined && { itemNounKey: section.itemNoun }), sort: sort, onSortChange: setSort, ...(section.searchable === true && {
|
|
309
|
+
}) })), emptyStateActionError !== null && (_jsxs(Banner, { variant: "error", testId: "related-list-empty-state-action-error", children: [emptyStateActionError.message, _jsx(ErrorReference, { requestId: emptyStateActionError.requestId })] })), _jsx(ListGroupPageBridges, { ...aggregates.groupPages }), section.photoGrid !== undefined && PhotoGrid !== undefined ? (listRows.rows.length === 0 ? (emptyStateContent) : (_jsx(RelatedPhotoGrid, { rows: listRows.rows, photoGrid: section.photoGrid, rowActions: rowActions, onActionError: setEmptyStateActionError, testId: "related-photo-grid" }))) : (_jsx(PageHeaderSlotAvailableProvider, { value: false, children: _jsx(RenderList, { screen: listScreen, entity: entity, rows: listRows.rows, featureName: listFeatureName ?? featureName, translate: effectiveTranslate, ...(section.description !== undefined && { description: section.description }), ...(section.itemNoun !== undefined && { itemNounKey: section.itemNoun }), sort: sort, onSortChange: setSort, ...(section.searchable === true && {
|
|
295
310
|
searchable: true,
|
|
296
311
|
searchValue: search,
|
|
297
312
|
onSearchChange: setSearch,
|
|
@@ -300,7 +315,9 @@ export function RelatedListSection({ section, parentId, record, featureName, tra
|
|
|
300
315
|
filterValues: filters,
|
|
301
316
|
onFilterChange,
|
|
302
317
|
onFilterReset,
|
|
303
|
-
}), ...(onRowClick !== undefined && { onRowClick }), ...(rowActions !== undefined && { rowActions }), ...(section.rowActionMode !== undefined && { rowActionMode: section.rowActionMode }), ...(bulk !== undefined && { bulk }), ...(rowTone !== undefined && { rowTone }), ...(toolbarActionButtons !== undefined && { toolbarActions: toolbarActionButtons }), ...(emptyStateContent !== undefined && { emptyState: emptyStateContent }), ...listTable, ...(aggregates.serverGroups !== undefined && {
|
|
318
|
+
}), ...(onRowClick !== undefined && { onRowClick }), ...(rowActions !== undefined && { rowActions }), ...(section.rowActionMode !== undefined && { rowActionMode: section.rowActionMode }), ...(bulk !== undefined && { bulk }), ...(rowTone !== undefined && { rowTone }), ...(toolbarActionButtons !== undefined && { toolbarActions: toolbarActionButtons }), ...(emptyStateContent !== undefined && { emptyState: emptyStateContent }), ...listTable, ...(aggregates.serverGroups !== undefined && {
|
|
319
|
+
serverGroups: aggregates.serverGroups,
|
|
320
|
+
}), ...(aggregates.totals !== undefined && { totals: aggregates.totals }), ...(aggregates.notice !== undefined && { notice: aggregates.notice }), screenPadding: false, ...(hideTitle === true && { scrollBody: true, chromeless: true }), ...(embedded === true && { chromeless: true }) }) }))] }));
|
|
304
321
|
// hideTitle (tabs mode) → the caller (render-edit.tsx) already wraps this
|
|
305
322
|
// component's own return value in the same Card frame every other tab
|
|
306
323
|
// kind gets — no card here, or the two would nest. `scrollBody` caps the
|
|
@@ -315,12 +332,7 @@ export function RelatedListSection({ section, parentId, record, featureName, tra
|
|
|
315
332
|
const countSuffix = listRows.hasData
|
|
316
333
|
? ` · ${aggregates.serverGroups?.totalCount ?? listRows.rows.length}`
|
|
317
334
|
: "";
|
|
318
|
-
return (_jsxs(_Fragment, { children: [bridges, _jsx(
|
|
319
|
-
// Trim the default header inset: the host row already pads the area.
|
|
320
|
-
className: "[&>div:first-child]:px-0 [&>div:first-child]:pt-1 [&>div:first-child]:pb-2", slots: {
|
|
321
|
-
title: `${section.title}${countSuffix}`,
|
|
322
|
-
...(actions !== undefined && { headerActions: actions }),
|
|
323
|
-
}, testId: `related-list-${section.title}-${parentId}`, children: content })] }));
|
|
335
|
+
return (_jsxs(_Fragment, { children: [bridges, _jsx(EmbeddedRelatedListCard, { title: `${section.title}${countSuffix}`, actions: actions, testId: `related-list-${section.title}-${parentId}`, children: content })] }));
|
|
324
336
|
}
|
|
325
337
|
if (hideTitle) {
|
|
326
338
|
return (_jsxs(_Fragment, { children: [bridges, FillContainer !== undefined ? (_jsx(FillContainer, { ...(grow === true && { grow: true }), children: content })) : (content)] }));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EditRelatedListSection } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { ErrorNotice } from "../app/error-reference.tsx";
|
|
4
|
+
import { type DataTableRowAction } from "../primitives.tsx";
|
|
5
|
+
export declare function RelatedPhotoGrid({ rows, photoGrid, rowActions, onActionError, testId, }: {
|
|
6
|
+
readonly rows: readonly Readonly<Record<string, unknown>>[];
|
|
7
|
+
readonly photoGrid: NonNullable<EditRelatedListSection["photoGrid"]>;
|
|
8
|
+
readonly rowActions: readonly DataTableRowAction[] | undefined;
|
|
9
|
+
readonly onActionError: (notice: ErrorNotice | null) => void;
|
|
10
|
+
readonly testId?: string;
|
|
11
|
+
}): ReactNode;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { fileIdsOf } from "../file-ids-of.js";
|
|
3
|
+
import { usePrimitives } from "../primitives.js";
|
|
4
|
+
import { RenderEditActionButton } from "./render-edit-action-button.js";
|
|
5
|
+
function viewModelOf(row) {
|
|
6
|
+
return { id: String(row["id"] ?? ""), values: row };
|
|
7
|
+
}
|
|
8
|
+
// One tile per row: the row's image and its row actions as buttons. The same
|
|
9
|
+
// DataTableRowAction list the table would get, so confirm and visibility behave alike.
|
|
10
|
+
export function RelatedPhotoGrid({ rows, photoGrid, rowActions, onActionError, testId, }) {
|
|
11
|
+
const { PhotoGrid, Button, Dialog } = usePrimitives();
|
|
12
|
+
if (PhotoGrid === undefined)
|
|
13
|
+
return null;
|
|
14
|
+
const { imageField, captionField } = photoGrid;
|
|
15
|
+
return (_jsx(PhotoGrid, { ...(testId !== undefined && { testId }), tiles: rows.map((row, index) => {
|
|
16
|
+
const vm = viewModelOf(row);
|
|
17
|
+
const caption = captionField === undefined ? undefined : row[captionField];
|
|
18
|
+
const imageId = fileIdsOf(row[imageField])[0];
|
|
19
|
+
return {
|
|
20
|
+
id: vm.id === "" ? String(index) : vm.id,
|
|
21
|
+
...(imageId !== undefined && { imageId }),
|
|
22
|
+
...(typeof caption === "string" && caption !== "" && { caption }),
|
|
23
|
+
actions: (rowActions ?? [])
|
|
24
|
+
.filter((action) => action.isVisible?.(vm) !== false)
|
|
25
|
+
.map((action) => (_jsx(RenderEditActionButton, { action: {
|
|
26
|
+
id: action.id,
|
|
27
|
+
label: action.label,
|
|
28
|
+
onPress: () => action.onTrigger(vm),
|
|
29
|
+
...(action.style !== undefined && { style: action.style }),
|
|
30
|
+
...(action.display !== undefined && { display: action.display }),
|
|
31
|
+
...(action.confirm !== undefined && { confirm: action.confirm }),
|
|
32
|
+
...(action.confirmLabel !== undefined && { confirmLabel: action.confirmLabel }),
|
|
33
|
+
...(action.confirmRequired !== undefined && {
|
|
34
|
+
confirmRequired: action.confirmRequired,
|
|
35
|
+
}),
|
|
36
|
+
...(action.icon !== undefined && { icon: action.icon }),
|
|
37
|
+
}, Button: Button, Dialog: Dialog, onError: onActionError }, action.id))),
|
|
38
|
+
};
|
|
39
|
+
}) }));
|
|
40
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import { type ErrorNotice } from "../app/error-reference.tsx";
|
|
3
|
-
import type { usePrimitives } from "../primitives.tsx";
|
|
3
|
+
import type { FooterActionMarker, usePrimitives } from "../primitives.tsx";
|
|
4
4
|
import type { RenderEditAction } from "./render-edit-types.ts";
|
|
5
5
|
export declare function needsActionConfirm(action: Pick<RenderEditAction, "confirm" | "confirmRequired" | "style">): boolean;
|
|
6
6
|
export declare function RenderEditActionConfirmDialog({ action, open, onOpenChange, onConfirm, Dialog, }: {
|
|
@@ -22,4 +22,4 @@ export declare function RenderEditActionButton({ action, iconOnly, hideIcon, siz
|
|
|
22
22
|
readonly Button: ReturnType<typeof usePrimitives>["Button"];
|
|
23
23
|
readonly Dialog: ReturnType<typeof usePrimitives>["Dialog"];
|
|
24
24
|
readonly onError: (notice: ErrorNotice | null) => void;
|
|
25
|
-
}): ReactNode;
|
|
25
|
+
} & FooterActionMarker): ReactNode;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment } from "react";
|
|
3
3
|
import { GridCellForField } from "./grid-cell-for-field.js";
|
|
4
|
-
function appendixCellProps(props, fieldName) {
|
|
4
|
+
function appendixCellProps(props, fieldName, values) {
|
|
5
5
|
const { labelAppendix, fieldAppendix, fieldAppendixPlacement, fieldDescription } = props;
|
|
6
6
|
return {
|
|
7
7
|
...(labelAppendix !== undefined && { labelAppendix: labelAppendix(fieldName) }),
|
|
8
8
|
...(fieldAppendix !== undefined && { fieldAppendix: fieldAppendix(fieldName) }),
|
|
9
9
|
...(fieldAppendixPlacement !== undefined && { appendixPlacement: fieldAppendixPlacement }),
|
|
10
|
-
...(fieldDescription !== undefined && { description: fieldDescription(fieldName) }),
|
|
10
|
+
...(fieldDescription !== undefined && { description: fieldDescription(fieldName, values) }),
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
function createFieldCellRenderer(model, section, columns) {
|
|
@@ -31,7 +31,7 @@ function createFieldCellRenderer(model, section, columns) {
|
|
|
31
31
|
clearErrorsAndValidate(field.field);
|
|
32
32
|
}, ...(props.actionFormScreenQn !== undefined && {
|
|
33
33
|
onSuggest: (value) => form.controller.seedField(field.field, value),
|
|
34
|
-
}), GridCell: GridCell, featureName: props.featureName, ...appendixCellProps(props, field.field), allIssues: snapshot.errors, valueDisplay: props.valueDisplay, row: snapshot.values, ...(disabled && { fillDisabled: true }), ...(props.hideSectionTitles !== true &&
|
|
34
|
+
}), GridCell: GridCell, featureName: props.featureName, ...appendixCellProps(props, field.field, snapshot.values), allIssues: snapshot.errors, valueDisplay: props.valueDisplay, row: snapshot.values, ...(disabled && { fillDisabled: true }), ...(props.hideSectionTitles !== true &&
|
|
35
35
|
section.title !== undefined && { sectionTitle: section.title }), ...(showsChangedMarker && field.field in snapshot.changes && { changed: true }) }, field.field));
|
|
36
36
|
}
|
|
37
37
|
export function renderFieldGrid(model, section, fields, columns, gridKey) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { FormValues } from "../headless/index.ts";
|
|
3
|
-
import type
|
|
3
|
+
import { type ActionMenuItemSpec } from "../primitives.tsx";
|
|
4
4
|
import type { RenderEditModel } from "./render-edit-render-model.ts";
|
|
5
5
|
export type HeaderActionsModel = {
|
|
6
6
|
readonly headerMenuItems: readonly ActionMenuItemSpec[];
|
|
@@ -8,4 +8,5 @@ export type HeaderActionsModel = {
|
|
|
8
8
|
readonly formHeaderRegion: ReactNode;
|
|
9
9
|
readonly titleActionMount: ReactNode;
|
|
10
10
|
};
|
|
11
|
+
export declare function renderAfterFormSlot<TValues extends FormValues, TCtx>(model: RenderEditModel<TValues, TCtx>): ReactNode;
|
|
11
12
|
export declare function buildHeaderActions<TValues extends FormValues, TCtx>(model: RenderEditModel<TValues, TCtx>): HeaderActionsModel;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FOOTER_ACTION_ROLE_PROP, } from "../primitives.js";
|
|
2
3
|
import { EditSlotMount } from "./edit-mounts.js";
|
|
3
4
|
import { RenderEditActionButton } from "./render-edit-action-button.js";
|
|
4
5
|
import { resolveExtensionEntityId } from "./render-edit-logic.js";
|
|
@@ -75,9 +76,18 @@ function renderCopyLinkButton({ engine: { props, state }, layout, }) {
|
|
|
75
76
|
? null
|
|
76
77
|
: translate(linkCopied ? "kumiko.actions.copyLinkCopied" : "kumiko.actions.copyLink") })));
|
|
77
78
|
}
|
|
79
|
+
// The role prop is read by NarrowPinnedFooter from the element, so the DOM span needs a component in between.
|
|
80
|
+
function FooterStartGroup({ children, }) {
|
|
81
|
+
return (_jsx("span", { className: "mr-auto inline-flex gap-2 max-sm:flex max-sm:w-full max-sm:[&>button]:flex-1", "data-footer-align": "start", "data-testid": "render-edit-footer-start", children: children }));
|
|
82
|
+
}
|
|
78
83
|
function renderCustomActions({ engine: { props, state }, layout, }) {
|
|
79
84
|
const { Button, Dialog } = state.primitives;
|
|
80
|
-
|
|
85
|
+
const button = (action) => (_jsx(RenderEditActionButton, { action: action, iconOnly: layout.iconOnlyMidActions, ...(action.pinnedOnPhone === true && { [FOOTER_ACTION_ROLE_PROP]: "inline" }), Button: Button, Dialog: Dialog, onError: state.setActionError }, action.id));
|
|
86
|
+
const startActions = props.actions?.filter((action) => action.align === "start") ?? [];
|
|
87
|
+
const otherActions = props.actions?.filter((action) => action.align !== "start");
|
|
88
|
+
return (_jsxs(_Fragment, { children: [props.footerHint !== undefined && (_jsx("span", { "data-testid": "render-edit-footer-hint", className: "mr-auto min-w-0 text-[13px] text-muted-foreground max-sm:hidden", children: props.footerHint })), startActions.length > 0 && (_jsx(FooterStartGroup, { ...(startActions.some((action) => action.pinnedOnPhone === true) && {
|
|
89
|
+
[FOOTER_ACTION_ROLE_PROP]: "inline",
|
|
90
|
+
}), children: startActions.map(button) })), otherActions?.map(button)] }));
|
|
81
91
|
}
|
|
82
92
|
function renderMenuActionButtons({ engine: { props, state }, layout, }) {
|
|
83
93
|
const { Button, Dialog } = state.primitives;
|
|
@@ -98,6 +108,13 @@ function renderEditSlot({ engine: { props, form, sections } }, slot, slotName) {
|
|
|
98
108
|
return undefined;
|
|
99
109
|
return (_jsx(EditSlotMount, { slot: slot, slotName: slotName, screenId: props.screen.id, entityName: sections.vm.entityName, entityId: resolveExtensionEntityId(props.entityId, sections.vm.id), values: form.snapshot.values }));
|
|
100
110
|
}
|
|
111
|
+
export function renderAfterFormSlot(model) {
|
|
112
|
+
const { props, form, sections } = model.engine;
|
|
113
|
+
const slot = props.screen.slots?.afterForm;
|
|
114
|
+
if (slot === undefined)
|
|
115
|
+
return undefined;
|
|
116
|
+
return (_jsx(EditSlotMount, { slot: slot, slotName: "afterForm", screenId: props.screen.id, entityName: sections.vm.entityName, entityId: resolveExtensionEntityId(props.entityId, sections.vm.id), values: form.snapshot.values, ...(props.activeTabId !== undefined && { activeTabId: props.activeTabId }) }));
|
|
117
|
+
}
|
|
101
118
|
// A function headerRegion places the slot itself (projectionDetail puts it
|
|
102
119
|
// into its header card next to the actions); otherwise the slot renders
|
|
103
120
|
// above the caller's own headerRegion.
|
|
@@ -3,7 +3,7 @@ import { ExtensionFormRegistryProvider } from "../app/extension-form-submit.js";
|
|
|
3
3
|
import { FormUploadTrackerProvider } from "./form-pending-uploads.js";
|
|
4
4
|
import { renderActionErrorBanner, renderAllRequiredHint, renderDeleteDialog, renderDraftPicker, renderExtensionErrorBanner, renderFormErrorBanner, renderRootIssueBanners, renderTabStrip, renderWizardProgress, } from "./render-edit-banners.js";
|
|
5
5
|
import { renderFormActions } from "./render-edit-form-actions.js";
|
|
6
|
-
import { buildHeaderActions } from "./render-edit-header-actions.js";
|
|
6
|
+
import { buildHeaderActions, renderAfterFormSlot, } from "./render-edit-header-actions.js";
|
|
7
7
|
import { renderEditSections } from "./render-edit-section-kinds.js";
|
|
8
8
|
import { deriveWizardRail } from "./render-edit-wizard-rail.js";
|
|
9
9
|
import { AllFieldsRequiredProvider } from "./render-field.js";
|
|
@@ -72,5 +72,5 @@ export function renderEditLayout(model) {
|
|
|
72
72
|
const { props, state, sections, handleSubmit } = model.engine;
|
|
73
73
|
const header = buildHeaderActions(model);
|
|
74
74
|
const { Form } = state.primitives;
|
|
75
|
-
return (_jsx(ExtensionFormRegistryProvider, { value: state.extensionFormRegistry, children: _jsxs(FormUploadTrackerProvider, { value: state.trackUpload, children: [state.menuActionConfirmDialog, renderPageHeader(model, header), _jsx(Form, { onSubmit: () => void handleSubmit(), ...(state.focusFirstErrorKey > 0 && { focusFirstErrorKey: state.focusFirstErrorKey }), ...buildFormHeadingProps(model), ...buildFormActionProps(model, header), testId: "render-edit-form", stickyActions: state.isWizard || props.fillScreenHeight === true, ...buildFormChromeProps(model, header), children: _jsxs(AllFieldsRequiredProvider, { value: sections.showsAllRequiredHint || props.screen.layout.hideRequiredMarker === true, children: [props.leadContent, sections.showsAllRequiredHint && !state.insideDrawer && renderAllRequiredHint(model), renderDraftPicker(model), renderWizardProgress(model), state.isTabs && state.isStepped && renderTabStrip(model), renderEditSections(model), renderFormErrorBanner(model), renderRootIssueBanners(model), renderExtensionErrorBanner(model), renderActionErrorBanner(model), renderDeleteDialog(model)] }) })] }) }));
|
|
75
|
+
return (_jsx(ExtensionFormRegistryProvider, { value: state.extensionFormRegistry, children: _jsxs(FormUploadTrackerProvider, { value: state.trackUpload, children: [state.menuActionConfirmDialog, renderPageHeader(model, header), _jsx(Form, { onSubmit: () => void handleSubmit(), ...(state.focusFirstErrorKey > 0 && { focusFirstErrorKey: state.focusFirstErrorKey }), ...buildFormHeadingProps(model), ...buildFormActionProps(model, header), testId: "render-edit-form", stickyActions: state.isWizard || props.fillScreenHeight === true, ...buildFormChromeProps(model, header), children: _jsxs(AllFieldsRequiredProvider, { value: sections.showsAllRequiredHint || props.screen.layout.hideRequiredMarker === true, children: [props.leadContent, sections.showsAllRequiredHint && !state.insideDrawer && renderAllRequiredHint(model), renderDraftPicker(model), renderWizardProgress(model), state.isTabs && state.isStepped && renderTabStrip(model), props.formErrorOnTop === true && renderFormErrorBanner(model), renderEditSections(model), renderAfterFormSlot(model), props.formErrorOnTop !== true && renderFormErrorBanner(model), renderRootIssueBanners(model), renderExtensionErrorBanner(model), renderActionErrorBanner(model), renderDeleteDialog(model)] }) })] }) }));
|
|
76
76
|
}
|
|
@@ -93,6 +93,7 @@ export function filterEditSections(sections, fieldsFilter) {
|
|
|
93
93
|
for (const section of sections) {
|
|
94
94
|
if (section.kind === "extension" ||
|
|
95
95
|
section.kind === "relatedList" ||
|
|
96
|
+
section.kind === "stepList" ||
|
|
96
97
|
section.kind === "writeForm") {
|
|
97
98
|
result.push(section);
|
|
98
99
|
continue;
|
|
@@ -47,6 +47,15 @@ function renderRelatedListSection({ model, sectionIndex, sectionActionsEl }, sec
|
|
|
47
47
|
// layout); the toolbar buttons live in the list's own toolbar.
|
|
48
48
|
return hideSectionTitles === true ? (_jsx("div", { className: fillScreenHeight === true ? "flex min-h-0 flex-1 flex-col" : undefined, children: mount }, section.title)) : (mount);
|
|
49
49
|
}
|
|
50
|
+
function renderStepListSection({ model, sectionIndex }, section) {
|
|
51
|
+
const { Section, StepList } = model.engine.state.primitives;
|
|
52
|
+
if (StepList === undefined || section.items.length === 0)
|
|
53
|
+
return null;
|
|
54
|
+
const items = section.items.map((item, index) => ({ id: String(index), ...item }));
|
|
55
|
+
return (_jsx(Section, { ...(section.title !== undefined && !model.engine.props.hideSectionTitles
|
|
56
|
+
? { title: section.title }
|
|
57
|
+
: {}), testId: "step-list-section", children: _jsx(StepList, { items: items, testId: "step-list" }) }, section.title ?? `step-list-${sectionIndex}`));
|
|
58
|
+
}
|
|
50
59
|
function renderWriteFormSection({ model, sectionIndex, sectionActionsEl }, section) {
|
|
51
60
|
const { props, state, sections } = model.engine;
|
|
52
61
|
// Own submit button + dispatcher call, entirely independent of
|
|
@@ -62,6 +71,8 @@ function renderSectionByKind(rc, section) {
|
|
|
62
71
|
return renderRelatedListSection(rc, section);
|
|
63
72
|
case "writeForm":
|
|
64
73
|
return renderWriteFormSection(rc, section);
|
|
74
|
+
case "stepList":
|
|
75
|
+
return renderStepListSection(rc, section);
|
|
65
76
|
case "fields":
|
|
66
77
|
return renderFieldsSection(rc, section);
|
|
67
78
|
}
|
|
@@ -69,6 +69,8 @@ export type RenderEditProps<TValues extends FormValues, TCtx = unknown> = {
|
|
|
69
69
|
* same split as `onCopyLink`) — RenderEdit only wires the button, its
|
|
70
70
|
* busy state and its confirm dialog. */
|
|
71
71
|
readonly actions?: readonly RenderEditAction[];
|
|
72
|
+
/** Translated note on the left of the form footer (hidden below `sm`). */
|
|
73
|
+
readonly footerHint?: string;
|
|
72
74
|
/** Record actions declared with `placement: "menu"`, resolved like `actions`.
|
|
73
75
|
* Rendered in the header "…" menu ahead of copy-link/delete; without a
|
|
74
76
|
* header menu (drawer, card form, shell without a header slot) they fall
|
|
@@ -110,8 +112,10 @@ export type RenderEditProps<TValues extends FormValues, TCtx = unknown> = {
|
|
|
110
112
|
* above-control; below-control keeps the inputs of neighbouring fields
|
|
111
113
|
* on one line when an appendix expands. */
|
|
112
114
|
readonly fieldAppendixPlacement?: "above-control" | "below-control";
|
|
115
|
+
/** Renders the form-error banner above the sections instead of below them. */
|
|
116
|
+
readonly formErrorOnTop?: boolean;
|
|
113
117
|
/** Per-field help text rendered under the label (translated by the caller). */
|
|
114
|
-
readonly fieldDescription?: (fieldName: string) => ReactNode | undefined;
|
|
118
|
+
readonly fieldDescription?: (fieldName: string, values: Readonly<Record<string, unknown>>) => ReactNode | undefined;
|
|
115
119
|
/** Extra full-width row drawn right after a field's cell (configEdit actions). `dirty` is true
|
|
116
120
|
* while the form has unsaved changes. Called with the field name, returns a ReactNode or
|
|
117
121
|
* undefined. */
|
|
@@ -197,6 +201,8 @@ export type RenderEditProps<TValues extends FormValues, TCtx = unknown> = {
|
|
|
197
201
|
* redundant title above its content. Omitting this prop keeps unchanged
|
|
198
202
|
* behavior. */
|
|
199
203
|
readonly hideSectionTitles?: boolean;
|
|
204
|
+
/** Id of the active tab of a tabbed projectionDetail; handed to the `afterForm` slot. */
|
|
205
|
+
readonly activeTabId?: string;
|
|
200
206
|
/** Screen body fills the shell height: the form gets `fillHeight` and
|
|
201
207
|
* `stickyActions` (sections scroll, footer pinned). Set by KumikoScreen for
|
|
202
208
|
* screens with `fillHeight !== false`; dialogs and other embedded hosts
|
|
@@ -256,6 +262,10 @@ export type RenderEditAction = {
|
|
|
256
262
|
* drives both the icon-left-of-text render and the icon-only collapse
|
|
257
263
|
* rule (see `shouldRenderActionsIconOnly`). */
|
|
258
264
|
readonly icon?: IconKey;
|
|
265
|
+
/** "start" sets the button apart on the left of the form footer. */
|
|
266
|
+
readonly align?: "start";
|
|
267
|
+
/** Stays a visible button in the pinned footer below `sm` instead of folding into the "…" menu. */
|
|
268
|
+
readonly pinnedOnPhone?: true;
|
|
259
269
|
};
|
|
260
270
|
export type RenderEditChangeState<TValues extends FormValues> = {
|
|
261
271
|
readonly values: TValues;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { EditFieldViewModel } from "../headless/index.ts";
|
|
3
|
+
type AiAssist = NonNullable<EditFieldViewModel["aiAssist"]>;
|
|
4
|
+
type AiAssistControlProps = {
|
|
5
|
+
readonly field: EditFieldViewModel;
|
|
6
|
+
readonly aiAssist: AiAssist;
|
|
7
|
+
readonly onChange: (value: unknown) => void;
|
|
8
|
+
readonly input: ReactNode;
|
|
9
|
+
/** Current form values; `aiAssist.contextFields` are read from here. */
|
|
10
|
+
readonly row?: Readonly<Record<string, unknown>>;
|
|
11
|
+
};
|
|
12
|
+
export declare function AiAssistControl(props: AiAssistControlProps): ReactNode;
|
|
13
|
+
export {};
|