@cosmicdrift/kumiko-renderer 0.415.0 → 0.417.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 +2 -5
- package/dist/app/action-form-body.js +50 -22
- 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 +83 -82
- package/dist/app/entity-list-screen.js +1 -1
- package/dist/app/extension-sections.d.ts +2 -0
- package/dist/app/header-actions-bar.d.ts +3 -1
- package/dist/app/header-actions-bar.js +12 -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 +29 -8
- package/dist/app/projection-detail-guidance.d.ts +2 -1
- package/dist/app/projection-detail-guidance.js +45 -30
- package/dist/app/projection-detail-header-model.d.ts +1 -1
- package/dist/app/projection-detail-header-model.js +14 -6
- 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 +31 -4
- package/dist/app/projection-detail-navigation.d.ts +4 -0
- package/dist/app/projection-detail-navigation.js +5 -1
- 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/screen-shared.d.ts +1 -0
- package/dist/app/screen-shared.js +23 -3
- package/dist/app/use-projection-detail-actions.d.ts +16 -1
- package/dist/app/use-projection-detail-actions.js +23 -3
- package/dist/app/use-projection-detail-data.d.ts +2 -0
- package/dist/app/use-projection-detail-data.js +53 -10
- package/dist/app/use-projection-list-data.js +1 -1
- package/dist/card-options.d.ts +2 -0
- package/dist/components/ai-assist-payload.d.ts +2 -0
- package/dist/components/ai-assist-payload.js +8 -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 +3 -2
- package/dist/components/edit-mounts.js +2 -2
- package/dist/components/grid-cell-for-field.js +1 -1
- package/dist/components/multi-select-chips.d.ts +10 -0
- package/dist/components/multi-select-chips.js +19 -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 +52 -35
- package/dist/components/related-photo-grid.d.ts +11 -0
- package/dist/components/related-photo-grid.js +54 -0
- package/dist/components/render-edit-action-button.d.ts +2 -2
- 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.d.ts +2 -1
- package/dist/components/render-edit-header-actions.js +18 -1
- package/dist/components/render-edit-layout.js +5 -3
- package/dist/components/render-edit-logic.js +1 -0
- package/dist/components/render-edit-section-kinds.js +59 -10
- package/dist/components/render-edit-titles.js +1 -1
- package/dist/components/render-edit-types.d.ts +22 -1
- package/dist/components/render-field-ai-assist.d.ts +13 -0
- package/dist/components/render-field-ai-assist.js +90 -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 +19 -9
- package/dist/components/render-field-value-chips.d.ts +9 -0
- package/dist/components/render-field-value-chips.js +47 -0
- package/dist/components/render-field-write-only.js +12 -4
- package/dist/components/render-list-hint-columns.d.ts +2 -0
- package/dist/components/render-list-hint-columns.js +43 -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-edit-sections.js +5 -1
- 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/headless/form/form-controller.d.ts +1 -0
- package/dist/headless/form/form-controller.js +1 -1
- package/dist/headless/format/index.d.ts +1 -0
- package/dist/headless/format/index.js +21 -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 +15 -0
- package/dist/headless/format/relative-time.js +63 -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 +162 -36
- 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/list.js +6 -0
- package/dist/headless/view-model/types.d.ts +76 -5
- package/dist/hooks/use-list-table.js +11 -6
- package/dist/i18n-defaults.js +9 -2
- package/dist/index.d.ts +1 -1
- package/dist/primitives-record-guidance.d.ts +32 -1
- package/dist/primitives-share-types.d.ts +82 -0
- package/dist/primitives-share-types.js +1 -0
- package/dist/primitives.d.ts +44 -86
- 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 +8 -3
- package/dist/web/app/dashboard-list-panel.js +8 -4
- package/dist/web/app/dashboard-panel-columns.d.ts +9 -0
- package/dist/web/app/dashboard-panel-columns.js +14 -0
- package/dist/web/app/dashboard-panels.js +31 -3
- package/dist/web/app/dashboard-shared.d.ts +3 -1
- package/dist/web/app/dashboard-shared.js +4 -4
- package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -1
- package/dist/web/app/dashboard-stat-group-panel.js +24 -3
- package/dist/web/app/dashboard-text-panel.d.ts +1 -0
- package/dist/web/app/dashboard-text-panel.js +18 -11
- package/dist/web/app/relative-time.d.ts +0 -5
- package/dist/web/app/relative-time.js +11 -21
- 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/notification-bell.js +12 -3
- 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 +13 -5
- package/dist/web/primitives/banner.js +24 -8
- 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 +34 -10
- 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 +4 -1
- package/dist/web/primitives/data-table/data-cell-props.js +3 -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-click-guard.d.ts +2 -0
- package/dist/web/primitives/data-table/row-click-guard.js +19 -0
- package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
- package/dist/web/primitives/data-table/row-render-parts.js +3 -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 +3 -1
- package/dist/web/primitives/data-table/table-chrome.js +1 -3
- package/dist/web/primitives/data-table/table-content.js +6 -6
- 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-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 +17 -3
- package/dist/web/primitives/data-table-cell.js +130 -36
- 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 +15 -11
- package/dist/web/primitives/drawer.js +2 -3
- 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 +6 -3
- package/dist/web/primitives/form.js +6 -8
- package/dist/web/primitives/index.js +4 -0
- 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 +50 -13
- package/dist/web/primitives/layout.d.ts +1 -1
- package/dist/web/primitives/layout.js +1 -1
- 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 +10 -8
- package/dist/web/primitives/narrow-pinned-footer.js +7 -3
- package/dist/web/primitives/number-input.d.ts +2 -1
- package/dist/web/primitives/number-input.js +11 -5
- 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.d.ts +3 -0
- package/dist/web/primitives/photo-grid.js +6 -0
- package/dist/web/primitives/record-steps.d.ts +1 -1
- package/dist/web/primitives/record-steps.js +7 -16
- package/dist/web/primitives/record-summary.d.ts +1 -1
- package/dist/web/primitives/record-summary.js +8 -3
- package/dist/web/primitives/row-actions.js +38 -24
- package/dist/web/primitives/step-list.d.ts +3 -0
- package/dist/web/primitives/step-list.js +11 -0
- package/dist/web/primitives/use-container-narrow.d.ts +12 -0
- package/dist/web/primitives/use-container-narrow.js +42 -0
- 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 +6 -1
- package/dist/web/widgets/dashboard-list.js +12 -7
- package/dist/web/widgets/drawer-panel-class.js +1 -1
- 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 +105 -0
- package/src/web/styles.css +3 -2
|
@@ -253,25 +253,45 @@ export function resolveRedirectTarget(redirect, submittedData, schema, appFeatur
|
|
|
253
253
|
const targetId = lastSegment(redirectScreen);
|
|
254
254
|
const target = findRedirectTargetScreen(redirect, schema, appFeatures);
|
|
255
255
|
const carriesId = target !== undefined && (target.type === "entityEdit" || target.type === "projectionDetail");
|
|
256
|
+
const searchParams = redirectSearchParams(redirect, submittedData);
|
|
256
257
|
if (!carriesId)
|
|
257
|
-
return { screenId: targetId, entityId: undefined, tab: undefined };
|
|
258
|
+
return { screenId: targetId, entityId: undefined, tab: undefined, searchParams };
|
|
258
259
|
const entityId = extractIdField(submittedData, idField) ??
|
|
259
260
|
(fallbackRecord !== undefined ? extractIdField(fallbackRecord, idField) : undefined);
|
|
260
261
|
return {
|
|
261
262
|
screenId: targetId,
|
|
262
263
|
entityId,
|
|
263
264
|
tab: typeof redirect === "string" ? undefined : redirect.tab,
|
|
265
|
+
searchParams,
|
|
264
266
|
};
|
|
265
267
|
}
|
|
268
|
+
// Only the object form of an actionForm redirect declares searchParams; success
|
|
269
|
+
// links keep their own `params`. Non-string payload values leave the param out.
|
|
270
|
+
function redirectSearchParams(redirect, submittedData) {
|
|
271
|
+
const declared = typeof redirect === "string" || !("searchParams" in redirect)
|
|
272
|
+
? undefined
|
|
273
|
+
: redirect.searchParams;
|
|
274
|
+
const resolved = {};
|
|
275
|
+
for (const [param, field] of Object.entries(declared ?? {})) {
|
|
276
|
+
const value = propertyOf(submittedData, field);
|
|
277
|
+
if (typeof value === "string")
|
|
278
|
+
resolved[param] = value;
|
|
279
|
+
}
|
|
280
|
+
return resolved;
|
|
281
|
+
}
|
|
266
282
|
export function navigateToRedirectTarget(nav, target) {
|
|
267
283
|
const navTarget = {
|
|
268
284
|
screenId: target.screenId,
|
|
269
285
|
...(target.entityId !== undefined && { entityId: target.entityId }),
|
|
270
286
|
};
|
|
271
|
-
|
|
287
|
+
const searchParams = {
|
|
288
|
+
...target.searchParams,
|
|
289
|
+
...(target.tab !== undefined && { tab: target.tab }),
|
|
290
|
+
};
|
|
291
|
+
if (Object.keys(searchParams).length === 0)
|
|
272
292
|
nav.navigate(navTarget);
|
|
273
293
|
else
|
|
274
|
-
nav.navigate(navTarget, { searchParams
|
|
294
|
+
nav.navigate(navTarget, { searchParams });
|
|
275
295
|
}
|
|
276
296
|
// Links of the success box. Targets resolve like `redirect`; a link whose target
|
|
277
297
|
// needs a record id (entityEdit, projectionDetail) but whose payload field holds
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type RowAction } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
import type { RenderEditAction } from "../components/render-edit.tsx";
|
|
3
|
+
import type { WriteFormRegistry } from "../components/write-form-registry.ts";
|
|
3
4
|
import type { useOptionalDispatcher } from "../context/dispatcher-context.tsx";
|
|
4
5
|
import type { useUserRoles } from "../context/user-roles-context.tsx";
|
|
5
6
|
import type { Translate } from "../headless/index.ts";
|
|
@@ -27,11 +28,25 @@ type DetailActionsInput = {
|
|
|
27
28
|
readonly detailQuery: ReturnType<typeof useProjectionDetailData>["detailQuery"];
|
|
28
29
|
readonly reloadDetail: ReturnType<typeof useProjectionDetailData>["reloadDetail"];
|
|
29
30
|
readonly activeTabId: string | undefined;
|
|
31
|
+
readonly writeForms: WriteFormRegistry;
|
|
30
32
|
};
|
|
31
33
|
export declare function useProjectionDetailActions(input: DetailActionsInput): {
|
|
32
34
|
buildSectionActions: (actions: readonly RowAction[]) => readonly RenderEditAction[] | undefined;
|
|
33
35
|
buildItemActions: (actions: readonly RowAction[], item: Readonly<Record<string, unknown>>) => readonly RenderEditAction[] | undefined;
|
|
34
36
|
headerActions: readonly RenderEditAction[] | undefined;
|
|
37
|
+
footerActions: {
|
|
38
|
+
id: string;
|
|
39
|
+
label: string;
|
|
40
|
+
onPress: () => void | Promise<void>;
|
|
41
|
+
style?: "primary" | "secondary" | "danger";
|
|
42
|
+
display?: import("@cosmicdrift/kumiko-framework/ui-types").RowActionDisplay;
|
|
43
|
+
confirm?: string;
|
|
44
|
+
confirmLabel?: string;
|
|
45
|
+
confirmRequired?: boolean;
|
|
46
|
+
icon?: import("@cosmicdrift/kumiko-types/nav-icon").IconKey;
|
|
47
|
+
align?: "start";
|
|
48
|
+
pinnedOnPhone: true;
|
|
49
|
+
}[] | undefined;
|
|
35
50
|
};
|
|
36
51
|
export declare function omitActionsDefaultingToShownRecordId(actions: readonly RowAction[], shownRecordId: string | undefined): readonly RowAction[];
|
|
37
52
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isWriteFormEditSection, } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
1
2
|
import { resolveActionIcon } from "@cosmicdrift/kumiko-types/action-icon";
|
|
2
3
|
import { useCallback, useMemo } from "react";
|
|
3
4
|
import { lastSegment } from "./qn.js";
|
|
@@ -10,7 +11,7 @@ function isShownOnTab(action, activeTabId) {
|
|
|
10
11
|
(activeTabId !== undefined && action.showOnTabs.includes(activeTabId)));
|
|
11
12
|
}
|
|
12
13
|
export function useProjectionDetailActions(input) {
|
|
13
|
-
const { schema, screen, effectiveTranslate, effectiveEntityId, nav, host, dispatcher, clientActions, appFeatures, userRoles, returnTarget, openDrawer, detailQuery, reloadDetail, activeTabId, } = input;
|
|
14
|
+
const { schema, screen, effectiveTranslate, effectiveEntityId, nav, host, dispatcher, clientActions, appFeatures, userRoles, returnTarget, openDrawer, detailQuery, reloadDetail, activeTabId, writeForms, } = input;
|
|
14
15
|
const handleRecordLeft = useCallback((action, resultData, deletedShownRecord) => {
|
|
15
16
|
const record = detailQuery.data ?? {};
|
|
16
17
|
// Never return onto the just-deleted record.
|
|
@@ -152,7 +153,11 @@ export function useProjectionDetailActions(input) {
|
|
|
152
153
|
handleRecordLeft,
|
|
153
154
|
sameEntityScreenId,
|
|
154
155
|
]);
|
|
155
|
-
const
|
|
156
|
+
const footerIds = screen.footerActions;
|
|
157
|
+
const submitWithIds = useMemo(() => new Set(screen.layout.sections.flatMap((section) => isWriteFormEditSection(section) && section.submitWith !== undefined
|
|
158
|
+
? [section.submitWith]
|
|
159
|
+
: [])), [screen.layout.sections]);
|
|
160
|
+
const recordActions = useMemo(() => {
|
|
156
161
|
const declaredHasEdit = screen.actions?.some((a) => a.id === "edit") === true;
|
|
157
162
|
const resolved = buildRecordActions({
|
|
158
163
|
actions: (screen.actions ?? []).filter((a) => isShownOnTab(a, activeTabId)),
|
|
@@ -166,6 +171,8 @@ export function useProjectionDetailActions(input) {
|
|
|
166
171
|
onRecordLeft: handleRecordLeft,
|
|
167
172
|
sameEntityScreenId,
|
|
168
173
|
clientActions,
|
|
174
|
+
writeForms,
|
|
175
|
+
submitWithIds,
|
|
169
176
|
});
|
|
170
177
|
// skip: a declared or unavailable edit action leaves the resolved list untouched
|
|
171
178
|
if (defaultEditAction === undefined || declaredHasEdit)
|
|
@@ -185,8 +192,21 @@ export function useProjectionDetailActions(input) {
|
|
|
185
192
|
openDrawer,
|
|
186
193
|
handleRecordLeft,
|
|
187
194
|
sameEntityScreenId,
|
|
195
|
+
writeForms,
|
|
196
|
+
submitWithIds,
|
|
188
197
|
]);
|
|
189
|
-
|
|
198
|
+
// footerActions render in RenderEdit's pinned footer, so the header bar must not repeat them.
|
|
199
|
+
const headerActions = useMemo(() => footerIds === undefined
|
|
200
|
+
? recordActions
|
|
201
|
+
: recordActions?.filter((a) => !footerIds.includes(a.id)), [recordActions, footerIds]);
|
|
202
|
+
const footerActions = useMemo(() => footerIds === undefined
|
|
203
|
+
? undefined
|
|
204
|
+
: recordActions
|
|
205
|
+
?.filter((a) => footerIds.includes(a.id))
|
|
206
|
+
.map((a) => screen.actions?.find((declared) => declared.id === a.id)?.align === "start"
|
|
207
|
+
? { ...a, align: "start", pinnedOnPhone: true }
|
|
208
|
+
: { ...a, pinnedOnPhone: true }), [recordActions, footerIds, screen.actions]);
|
|
209
|
+
return { buildSectionActions, buildItemActions, headerActions, footerActions };
|
|
190
210
|
}
|
|
191
211
|
// Without a shown record id, a payload-less write or client action would fall back to the guidance item's own id (a step key, not a record id).
|
|
192
212
|
export function omitActionsDefaultingToShownRecordId(actions, shownRecordId) {
|
|
@@ -9,6 +9,8 @@ type DetailDataInput = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare function useProjectionDetailData(input: DetailDataInput): {
|
|
11
11
|
activeSection: import("@cosmicdrift/kumiko-framework/ui-types").EditSectionSpec | undefined;
|
|
12
|
+
activeSections: import("@cosmicdrift/kumiko-framework/ui-types").EditSectionSpec[];
|
|
13
|
+
visibleSections: import("@cosmicdrift/kumiko-framework/ui-types").EditSectionSpec[];
|
|
12
14
|
hasTabs: boolean;
|
|
13
15
|
entity: Pick<import("@cosmicdrift/kumiko-types/fields").EntityDefinition, "fields">;
|
|
14
16
|
detailScreen: import("@cosmicdrift/kumiko-framework/ui-types").EntityEditScreenDefinition;
|
|
@@ -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,27 @@ 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
|
-
|
|
28
|
-
|
|
40
|
+
if (activeSections.length > 0 && screen.layout.narrowTabs === false) {
|
|
41
|
+
// Below `sm` there is no tab strip: every visible section renders, the ones of the
|
|
42
|
+
// other tabs only on the phone. A `hideOnNarrow` section of another tab has no place at
|
|
43
|
+
// all (hideOnNarrow would win over showOnNarrowOnly and show it on desktop).
|
|
44
|
+
const sections = visibleSections.flatMap((section) => {
|
|
45
|
+
if (activeSections.includes(section))
|
|
46
|
+
return [section];
|
|
47
|
+
if ("hideOnNarrow" in section && section.hideOnNarrow === true)
|
|
48
|
+
return [];
|
|
49
|
+
return [{ ...section, showOnNarrowOnly: true }];
|
|
50
|
+
});
|
|
51
|
+
return synthesizeProjectionDetailScreen({
|
|
52
|
+
...screen,
|
|
53
|
+
layout: { ...screen.layout, sections },
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const source = activeSections.length > 0
|
|
57
|
+
? { ...screen, layout: { ...screen.layout, sections: activeSections } }
|
|
29
58
|
: screen;
|
|
30
59
|
return synthesizeProjectionDetailScreen(source);
|
|
31
|
-
}, [screen,
|
|
32
|
-
const live = screen.live === true;
|
|
33
|
-
const detailQuery = useQuery(screen.query, effectiveEntityId !== undefined ? { [idParam]: effectiveEntityId } : {}, { live });
|
|
60
|
+
}, [screen, activeSections, visibleSections]);
|
|
34
61
|
// A writeForm section's handler creates a new record (see EditWriteFormSection's
|
|
35
62
|
// doc) — both the outer record (header/metrics/other sections) and a sibling
|
|
36
63
|
// relatedList section's own independently-fetched rows must reflect it. A
|
|
@@ -58,5 +85,21 @@ export function useProjectionDetailData(input) {
|
|
|
58
85
|
if (previous !== undefined)
|
|
59
86
|
setReloadNonce((n) => n + 1);
|
|
60
87
|
}, [liveRecord]);
|
|
61
|
-
return {
|
|
88
|
+
return {
|
|
89
|
+
activeSection,
|
|
90
|
+
activeSections,
|
|
91
|
+
visibleSections,
|
|
92
|
+
hasTabs,
|
|
93
|
+
entity,
|
|
94
|
+
detailScreen,
|
|
95
|
+
detailQuery,
|
|
96
|
+
reloadNonce,
|
|
97
|
+
reloadDetail,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function initialTabId(rules, record, visibleSections) {
|
|
101
|
+
if (rules === undefined || record === null)
|
|
102
|
+
return undefined;
|
|
103
|
+
return rules.find((rule) => evalFieldCondition(rule.when, { ...record }) &&
|
|
104
|
+
visibleSections.some((section) => section.id === rule.tab))?.tab;
|
|
62
105
|
}
|
|
@@ -39,8 +39,8 @@ export function useProjectionListData(input) {
|
|
|
39
39
|
const filterFacets = useMemo(() => {
|
|
40
40
|
const namedFacet = buildNamedFilterFacet(screen.namedFilters, effectiveTranslate, userRoles, screen.namedFilterFacet, facetCounts);
|
|
41
41
|
return [
|
|
42
|
-
...(namedFacet !== undefined ? [namedFacet] : []),
|
|
43
42
|
...buildFilterFacets(resolvedFacetSpecs),
|
|
43
|
+
...(namedFacet !== undefined ? [namedFacet] : []),
|
|
44
44
|
];
|
|
45
45
|
}, [
|
|
46
46
|
resolvedFacetSpecs,
|
package/dist/card-options.d.ts
CHANGED
|
@@ -22,4 +22,6 @@ export type CardOptions = {
|
|
|
22
22
|
readonly screenBody?: boolean;
|
|
23
23
|
/** "inline": title and subtitle on one baseline row at 16px inset, compact padding (the board's side panel). Default "stacked". */
|
|
24
24
|
readonly headerLayout?: "stacked" | "inline";
|
|
25
|
+
/** "label": the title is a small uppercase muted label. Default "heading". */
|
|
26
|
+
readonly titleStyle?: "heading" | "label";
|
|
25
27
|
};
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function choiceChipClass(selected: boolean): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Shared look of toggle chips in forms (multiSelect chips, value chips, AI-assist chips): 26px
|
|
2
|
+
// pill with a 1px border; a chosen chip gets a primary border and a light primary fill. Passed as
|
|
3
|
+
// Button `className`; the phone keeps the same height instead of the 44px touch minimum.
|
|
4
|
+
const CHOICE_CHIP_BASE = "h-[26px] rounded-full border px-3 text-[13px] font-medium max-md:min-h-[26px]";
|
|
5
|
+
export function choiceChipClass(selected) {
|
|
6
|
+
return selected
|
|
7
|
+
? `${CHOICE_CHIP_BASE} border-primary bg-primary/10 text-primary ring-0`
|
|
8
|
+
: `${CHOICE_CHIP_BASE} border-border bg-background text-foreground`;
|
|
9
|
+
}
|
|
@@ -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" | "afterSection" | "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
|
}
|
|
@@ -38,5 +38,5 @@ export function GridCellForField({ field, columns, issues, onChange, onSuggest,
|
|
|
38
38
|
field.embeddedListCells !== undefined &&
|
|
39
39
|
field.label === sectionTitle;
|
|
40
40
|
const effectiveSpan = field.span !== undefined ? Math.min(field.span, columns) : 1;
|
|
41
|
-
return (_jsx(GridCell, { span: effectiveSpan, ...(flow === true && { width: fieldCellWidth(field) }), children: _jsx(RenderField, { field: field, ...(issues !== undefined && { issues }), onChange: onChange, ...(onSuggest !== undefined && { onSuggest }), featureName: featureName, ...(labelAppendix !== undefined && { labelAppendix }), ...(fieldAppendix !== undefined && { fieldAppendix }), ...(appendixPlacement !== undefined && { appendixPlacement }), ...(description !== undefined && { description }), ...(status !== undefined && { status }), allIssues: allIssues, valueDisplay: valueDisplay, row: row, ...(changed === true && { changed }), ...(layout !== undefined && { layout }), ...(accent === true && { accent }), ...(fillDisabled === true && { fillDisabled }), ...(hideLabel && { hideLabel }) }) }));
|
|
41
|
+
return (_jsx(GridCell, { span: effectiveSpan, ...(flow === true && { width: fieldCellWidth(field) }), ...(field.hideOnNarrow === true && { hideOnNarrow: true }), children: _jsx(RenderField, { field: field, ...(issues !== undefined && { issues }), onChange: onChange, ...(onSuggest !== undefined && { onSuggest }), featureName: featureName, ...(labelAppendix !== undefined && { labelAppendix }), ...(fieldAppendix !== undefined && { fieldAppendix }), ...(appendixPlacement !== undefined && { appendixPlacement }), ...(description !== undefined && { description }), ...(status !== undefined && { status }), allIssues: allIssues, valueDisplay: valueDisplay, row: row, ...(changed === true && { changed }), ...(layout !== undefined && { layout }), ...(accent === true && { accent }), ...(fillDisabled === true && { fillDisabled }), ...(hideLabel && { hideLabel }) }) }));
|
|
42
42
|
}
|
|
@@ -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,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { usePrimitives } from "../primitives.js";
|
|
3
|
+
import { choiceChipClass } from "./choice-chip-class.js";
|
|
4
|
+
// MultiSelectFieldDef's `display: "chips"`: every option is a toggle chip, ticked once chosen.
|
|
5
|
+
export function MultiSelectChips({ field, id, options, value, onChange, }) {
|
|
6
|
+
const { Button, Grid } = usePrimitives();
|
|
7
|
+
const selected = new Set(value);
|
|
8
|
+
// Emits in option order, like the checkbox grid, never in click order.
|
|
9
|
+
const toggle = (optionValue) => {
|
|
10
|
+
const next = new Set(selected);
|
|
11
|
+
if (!next.delete(optionValue))
|
|
12
|
+
next.add(optionValue);
|
|
13
|
+
onChange(options.filter((opt) => next.has(opt.value)).map((opt) => opt.value));
|
|
14
|
+
};
|
|
15
|
+
return (_jsx(Grid, { columns: "auto", tight: true, ariaLabelledBy: `${id}-label`, children: options.map((opt) => {
|
|
16
|
+
const isSelected = selected.has(opt.value);
|
|
17
|
+
return (_jsx(Button, { variant: "secondary", size: "sm", className: choiceChipClass(isSelected), 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));
|
|
18
|
+
}) }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { usePrimitives } from "../primitives.js";
|
|
3
|
+
function NarrowDescription({ description, descriptionNarrow, }) {
|
|
4
|
+
const { Text } = usePrimitives();
|
|
5
|
+
return _jsx(Text, { narrow: descriptionNarrow, children: description });
|
|
6
|
+
}
|
|
7
|
+
/** The full description from `sm` up, the short one on the phone. */
|
|
8
|
+
export function narrowAwareDescription(description, descriptionNarrow) {
|
|
9
|
+
if (description === undefined || descriptionNarrow === undefined)
|
|
10
|
+
return description;
|
|
11
|
+
return _jsx(NarrowDescription, { description: description, descriptionNarrow: descriptionNarrow });
|
|
12
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RowActionDrawer } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import type { EditRelatedListSectionViewModel, Translate } from "../headless/index.ts";
|
|
4
|
-
export declare function RelatedListSection({ section, parentId, record, featureName, translate, hideTitle,
|
|
4
|
+
export declare function RelatedListSection({ section, parentId, record, featureName, translate, hideTitle, labelTitle, omitTitle, onOpenDrawer, actions, anchorId, embedded, onAfterWrite, refreshToken, }: {
|
|
5
5
|
readonly section: EditRelatedListSectionViewModel;
|
|
6
6
|
readonly parentId: string;
|
|
7
7
|
/** The enclosing projectionDetail's own record (the "Akte") — evaluates
|
|
@@ -11,8 +11,10 @@ export declare function RelatedListSection({ section, parentId, record, featureN
|
|
|
11
11
|
readonly featureName: string;
|
|
12
12
|
readonly translate?: Translate;
|
|
13
13
|
readonly hideTitle?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
readonly
|
|
14
|
+
/** The stacked section title is a small uppercase label. */
|
|
15
|
+
readonly labelTitle?: boolean;
|
|
16
|
+
/** The stacked section has no title (the tab label above it says the same). */
|
|
17
|
+
readonly omitTitle?: boolean;
|
|
16
18
|
/** Opens a drawer-kind rowAction. Supplied by the parent
|
|
17
19
|
* (ProjectionDetailBody), which owns schema + the actual Drawer render —
|
|
18
20
|
* this component only ever invokes the callback. */
|
|
@@ -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
|
}
|
|
82
|
-
|
|
83
|
-
const {
|
|
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
|
+
}
|
|
118
|
+
export function RelatedListSection({ section, parentId, record, featureName, translate, hideTitle, labelTitle, omitTitle, onOpenDrawer, actions, anchorId, embedded, onAfterWrite, refreshToken, }) {
|
|
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,14 @@ 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 && {
|
|
321
|
+
scrollBody: true,
|
|
322
|
+
chromeless: true,
|
|
323
|
+
hideCountFooter: true,
|
|
324
|
+
plainPhoneCards: true,
|
|
325
|
+
}), ...(embedded === true && { chromeless: true }) }) }))] }));
|
|
304
326
|
// hideTitle (tabs mode) → the caller (render-edit.tsx) already wraps this
|
|
305
327
|
// component's own return value in the same Card frame every other tab
|
|
306
328
|
// kind gets — no card here, or the two would nest. `scrollBody` caps the
|
|
@@ -315,15 +337,10 @@ export function RelatedListSection({ section, parentId, record, featureName, tra
|
|
|
315
337
|
const countSuffix = listRows.hasData
|
|
316
338
|
? ` · ${aggregates.serverGroups?.totalCount ?? listRows.rows.length}`
|
|
317
339
|
: "";
|
|
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 })] }));
|
|
340
|
+
return (_jsxs(_Fragment, { children: [bridges, _jsx(EmbeddedRelatedListCard, { title: `${section.title}${countSuffix}`, actions: actions, testId: `related-list-${section.title}-${parentId}`, children: content })] }));
|
|
324
341
|
}
|
|
325
342
|
if (hideTitle) {
|
|
326
|
-
return (_jsxs(_Fragment, { children: [bridges, FillContainer !== undefined ? (_jsx(FillContainer, {
|
|
343
|
+
return (_jsxs(_Fragment, { children: [bridges, FillContainer !== undefined ? (_jsx(FillContainer, { testId: "related-list-card", className: "mx-6 my-3 overflow-hidden rounded-[9px] border border-border bg-card max-sm:mx-4 max-sm:rounded-none max-sm:border-0 max-sm:bg-transparent [&_thead_th]:bg-muted", children: content })) : (content)] }));
|
|
327
344
|
}
|
|
328
|
-
return (_jsxs(_Fragment, { children: [bridges, _jsx(Section, { title: section.title, ...(anchorId !== undefined && { id: anchorId }), ...(actions !== undefined && { actions }), testId: `related-list-${section.title}`, children: content })] }));
|
|
345
|
+
return (_jsxs(_Fragment, { children: [bridges, _jsx(Section, { ...(omitTitle !== true && { title: section.title }), ...(labelTitle === true && { titleStyle: "label" }), ...(anchorId !== undefined && { id: anchorId }), ...(actions !== undefined && { actions }), testId: `related-list-${section.title}`, children: content })] }));
|
|
329
346
|
}
|
|
@@ -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,54 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { fileIdsOf } from "../file-ids-of.js";
|
|
3
|
+
import { useTranslation } from "../i18n.js";
|
|
4
|
+
import { usePrimitives } from "../primitives.js";
|
|
5
|
+
import { RenderEditActionButton } from "./render-edit-action-button.js";
|
|
6
|
+
function viewModelOf(row) {
|
|
7
|
+
return { id: String(row["id"] ?? ""), values: row };
|
|
8
|
+
}
|
|
9
|
+
// One tile per row: the row's image and its row actions as buttons. The same
|
|
10
|
+
// DataTableRowAction list the table would get, so confirm and visibility behave alike.
|
|
11
|
+
export function RelatedPhotoGrid({ rows, photoGrid, rowActions, onActionError, testId, }) {
|
|
12
|
+
const t = useTranslation();
|
|
13
|
+
const { PhotoGrid, Button, Dialog } = usePrimitives();
|
|
14
|
+
if (PhotoGrid === undefined)
|
|
15
|
+
return null;
|
|
16
|
+
const { imageField, captionField, badgeField } = photoGrid;
|
|
17
|
+
const leadsOnNarrow = (row) => {
|
|
18
|
+
if (photoGrid.badgeFirst !== true || badgeField === undefined)
|
|
19
|
+
return false;
|
|
20
|
+
const value = row[badgeField];
|
|
21
|
+
return typeof value === "string" && value !== "";
|
|
22
|
+
};
|
|
23
|
+
return (_jsx(PhotoGrid, { ...(testId !== undefined && { testId }), tiles: rows.map((row, index) => {
|
|
24
|
+
const vm = viewModelOf(row);
|
|
25
|
+
const captionValue = captionField === undefined ? undefined : row[captionField];
|
|
26
|
+
const caption = typeof captionValue === "string" && captionValue !== ""
|
|
27
|
+
? captionValue
|
|
28
|
+
: t("kumiko.photo-grid.fallback-caption", { n: index + 1 });
|
|
29
|
+
const badge = badgeField === undefined ? undefined : row[badgeField];
|
|
30
|
+
const imageId = fileIdsOf(row[imageField])[0];
|
|
31
|
+
return {
|
|
32
|
+
id: vm.id === "" ? String(index) : vm.id,
|
|
33
|
+
...(imageId !== undefined && { imageId }),
|
|
34
|
+
caption,
|
|
35
|
+
...(typeof badge === "string" && badge !== "" && { badge }),
|
|
36
|
+
...(leadsOnNarrow(row) && { leadsOnNarrow: true }),
|
|
37
|
+
actions: (rowActions ?? [])
|
|
38
|
+
.filter((action) => action.isVisible?.(vm) !== false)
|
|
39
|
+
.map((action) => (_jsx(RenderEditActionButton, { action: {
|
|
40
|
+
id: action.id,
|
|
41
|
+
label: action.label,
|
|
42
|
+
onPress: () => action.onTrigger(vm),
|
|
43
|
+
...(action.style !== undefined && { style: action.style }),
|
|
44
|
+
...(action.display !== undefined && { display: action.display }),
|
|
45
|
+
...(action.confirm !== undefined && { confirm: action.confirm }),
|
|
46
|
+
...(action.confirmLabel !== undefined && { confirmLabel: action.confirmLabel }),
|
|
47
|
+
...(action.confirmRequired !== undefined && {
|
|
48
|
+
confirmRequired: action.confirmRequired,
|
|
49
|
+
}),
|
|
50
|
+
...(action.icon !== undefined && { icon: action.icon }),
|
|
51
|
+
}, Button: Button, Dialog: Dialog, onError: onActionError }, action.id))),
|
|
52
|
+
};
|
|
53
|
+
}) }));
|
|
54
|
+
}
|