@cosmicdrift/kumiko-renderer 0.328.0 → 0.328.1
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-shim.d.ts +14 -0
- package/{src/app/action-form-shim.ts → dist/app/action-form-shim.js} +26 -46
- package/dist/app/app-features-context.d.ts +8 -0
- package/dist/app/app-features-context.js +16 -0
- package/dist/app/column-renderers.d.ts +30 -0
- package/dist/app/column-renderers.js +34 -0
- package/dist/app/config-edit-shim.d.ts +11 -0
- package/{src/app/config-edit-shim.ts → dist/app/config-edit-shim.js} +12 -25
- package/dist/app/content-editors.d.ts +38 -0
- package/dist/app/content-editors.js +26 -0
- package/dist/app/content-preview.d.ts +11 -0
- package/dist/app/content-preview.js +30 -0
- package/dist/app/custom-screens.d.ts +11 -0
- package/dist/app/custom-screens.js +20 -0
- package/dist/app/dashboard-body.d.ts +16 -0
- package/dist/app/dashboard-body.js +11 -0
- package/dist/app/extension-form-submit.d.ts +32 -0
- package/dist/app/extension-form-submit.js +73 -0
- package/dist/app/extension-sections.d.ts +72 -0
- package/dist/app/extension-sections.js +34 -0
- package/dist/app/feature-schema.d.ts +4 -0
- package/{src/app/feature-schema.ts → dist/app/feature-schema.js} +12 -22
- package/dist/app/form-schema.d.ts +4 -0
- package/dist/app/form-schema.js +85 -0
- package/dist/app/kumiko-screen.d.ts +43 -0
- package/dist/app/kumiko-screen.js +2206 -0
- package/dist/app/layout-fields.d.ts +3 -0
- package/dist/app/layout-fields.js +20 -0
- package/dist/app/list-facets.d.ts +48 -0
- package/dist/app/list-facets.js +185 -0
- package/dist/app/nav.d.ts +61 -0
- package/dist/app/nav.js +139 -0
- package/dist/app/projection-detail-shim.d.ts +8 -0
- package/dist/app/projection-detail-shim.js +71 -0
- package/dist/app/projection-list-shim.d.ts +13 -0
- package/{src/app/projection-list-shim.ts → dist/app/projection-list-shim.js} +26 -41
- package/dist/app/qn.d.ts +7 -0
- package/{src/app/qn.ts → dist/app/qn.js} +9 -11
- package/dist/app/qualify-screen-id.d.ts +2 -0
- package/{src/app/qualify-screen-id.ts → dist/app/qualify-screen-id.js} +5 -6
- package/dist/app/reference-facet-bridge.d.ts +10 -0
- package/dist/app/reference-facet-bridge.js +22 -0
- package/dist/app/return-to.d.ts +31 -0
- package/dist/app/return-to.js +188 -0
- package/dist/app/row-actions.d.ts +77 -0
- package/dist/app/row-actions.js +416 -0
- package/dist/app/screen-access.d.ts +8 -0
- package/dist/app/screen-access.js +48 -0
- package/dist/app/secret-mint-body.d.ts +10 -0
- package/dist/app/secret-mint-body.js +140 -0
- package/dist/app/secrets-edit-body.d.ts +8 -0
- package/dist/app/secrets-edit-body.js +76 -0
- package/dist/app/use-embedded-screen.d.ts +6 -0
- package/dist/app/use-embedded-screen.js +19 -0
- package/dist/app/variable-chips.d.ts +7 -0
- package/dist/app/variable-chips.js +16 -0
- package/dist/app/write-failed-error.d.ts +6 -0
- package/dist/app/write-failed-error.js +21 -0
- package/dist/components/embedded-list-field.d.ts +10 -0
- package/dist/components/embedded-list-field.js +259 -0
- package/dist/components/grid-cell-for-field.d.ts +25 -0
- package/dist/components/grid-cell-for-field.js +31 -0
- package/dist/components/multi-select-checkboxes.d.ts +14 -0
- package/dist/components/multi-select-checkboxes.js +36 -0
- package/dist/components/reference-create-dialog.d.ts +13 -0
- package/dist/components/reference-create-dialog.js +46 -0
- package/dist/components/related-list-section.d.ts +25 -0
- package/dist/components/related-list-section.js +273 -0
- package/dist/components/render-edit-action-button.d.ts +22 -0
- package/dist/components/render-edit-action-button.js +43 -0
- package/dist/components/render-edit-logic.d.ts +6 -0
- package/dist/components/render-edit-logic.js +63 -0
- package/dist/components/render-edit-types.d.ts +209 -0
- package/dist/components/render-edit-types.js +1 -0
- package/dist/components/render-edit.d.ts +6 -0
- package/dist/components/render-edit.js +1169 -0
- package/dist/components/render-field.d.ts +38 -0
- package/dist/components/render-field.js +544 -0
- package/dist/components/render-list.d.ts +117 -0
- package/dist/components/render-list.js +232 -0
- package/dist/components/write-form-section.d.ts +17 -0
- package/dist/components/write-form-section.js +104 -0
- package/dist/context/dispatcher-context.d.ts +10 -0
- package/{src/context/dispatcher-context.tsx → dist/context/dispatcher-context.js} +16 -29
- package/dist/context/draft-storage-context.d.ts +12 -0
- package/dist/context/draft-storage-context.js +18 -0
- package/dist/context/user-roles-context.d.ts +7 -0
- package/{src/context/user-roles-context.tsx → dist/context/user-roles-context.js} +7 -15
- package/dist/format-when.d.ts +1 -0
- package/{src/format-when.ts → dist/format-when.js} +7 -7
- package/dist/hooks/reference-limits.d.ts +3 -0
- package/{src/hooks/reference-limits.ts → dist/hooks/reference-limits.js} +0 -1
- package/dist/hooks/use-ai-text.d.ts +52 -0
- package/dist/hooks/use-ai-text.js +90 -0
- package/dist/hooks/use-disclosure.d.ts +7 -0
- package/dist/hooks/use-disclosure.js +8 -0
- package/dist/hooks/use-form.d.ts +7 -0
- package/dist/hooks/use-form.js +36 -0
- package/dist/hooks/use-list-url-state.d.ts +43 -0
- package/dist/hooks/use-list-url-state.js +131 -0
- package/dist/hooks/use-mutation.d.ts +9 -0
- package/dist/hooks/use-mutation.js +37 -0
- package/dist/hooks/use-query.d.ts +14 -0
- package/dist/hooks/use-query.js +118 -0
- package/dist/hooks/use-reference-lookup.d.ts +14 -0
- package/dist/hooks/use-reference-lookup.js +63 -0
- package/dist/hooks/use-store.d.ts +3 -0
- package/dist/hooks/use-store.js +38 -0
- package/dist/hooks/use-stream-handler.d.ts +14 -0
- package/dist/hooks/use-stream-handler.js +93 -0
- package/dist/i18n-defaults.d.ts +2 -0
- package/dist/i18n-defaults.js +201 -0
- package/dist/i18n.d.ts +64 -0
- package/dist/i18n.js +166 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.js +55 -0
- package/dist/inside-drawer.d.ts +2 -0
- package/{src/inside-drawer.ts → dist/inside-drawer.js} +2 -5
- package/dist/page-header-slot.d.ts +2 -0
- package/{src/page-header-slot.ts → dist/page-header-slot.js} +2 -5
- package/dist/primitives.d.ts +1351 -0
- package/dist/primitives.js +73 -0
- package/dist/screen-fills-height.d.ts +3 -0
- package/dist/screen-fills-height.js +3 -0
- package/dist/share-links.d.ts +4 -0
- package/dist/share-links.js +11 -0
- package/dist/sort-by-accessor.d.ts +5 -0
- package/dist/sort-by-accessor.js +16 -0
- package/dist/sse/live-events.d.ts +23 -0
- package/dist/sse/live-events.js +28 -0
- package/dist/tokens.d.ts +83 -0
- package/dist/tokens.js +80 -0
- package/package.json +16 -9
- package/src/__tests__/error-i18n-defaults.test.ts +0 -82
- package/src/__tests__/format-when.test.ts +0 -12
- package/src/__tests__/i18n.test.tsx +0 -283
- package/src/__tests__/merge-search-params-into-initial.test.ts +0 -525
- package/src/__tests__/qn.test.ts +0 -83
- package/src/__tests__/share-links.test.ts +0 -26
- package/src/__tests__/sort-by-accessor.test.ts +0 -48
- package/src/__tests__/stringify-nav-params.test.ts +0 -33
- package/src/__tests__/use-list-url-state.test.tsx +0 -250
- package/src/app/__tests__/action-form-field-labels.test.tsx +0 -92
- package/src/app/__tests__/action-form-shim.test.ts +0 -137
- package/src/app/__tests__/build-list-query-payload.test.ts +0 -107
- package/src/app/__tests__/config-edit-shim.test.ts +0 -57
- package/src/app/__tests__/content-editors.test.tsx +0 -128
- package/src/app/__tests__/content-preview.test.tsx +0 -184
- package/src/app/__tests__/entity-edit-create-search-params.test.tsx +0 -236
- package/src/app/__tests__/entity-edit-fill-height.test.tsx +0 -118
- package/src/app/__tests__/entity-edit-jsonb-embedded-submit.test.tsx +0 -239
- package/src/app/__tests__/entity-list-create-singleton.test.tsx +0 -128
- package/src/app/__tests__/entity-list-row-action-entity-target.test.tsx +0 -424
- package/src/app/__tests__/entity-list-row-action-icon.test.tsx +0 -248
- package/src/app/__tests__/entity-list-row-action-kumiko-actions-view.test.tsx +0 -162
- package/src/app/__tests__/entity-list-row-action-refetch.test.tsx +0 -401
- package/src/app/__tests__/entity-list-screen-padding.test.tsx +0 -128
- package/src/app/__tests__/feature-schema.test.ts +0 -40
- package/src/app/__tests__/form-schema.test.ts +0 -247
- package/src/app/__tests__/list-daterange-facet.test.ts +0 -165
- package/src/app/__tests__/list-filter-facets.test.tsx +0 -521
- package/src/app/__tests__/nav.test.ts +0 -198
- package/src/app/__tests__/projection-detail-actions.test.tsx +0 -719
- package/src/app/__tests__/projection-detail-reference-field.test.tsx +0 -165
- package/src/app/__tests__/projection-detail-shim.test.ts +0 -188
- package/src/app/__tests__/projection-detail-singleton.test.tsx +0 -191
- package/src/app/__tests__/projection-list-bad-shape.test.tsx +0 -152
- package/src/app/__tests__/projection-list-reference-column.test.tsx +0 -219
- package/src/app/__tests__/projection-list-search-sort.test.tsx +0 -212
- package/src/app/__tests__/qualified-names.test.ts +0 -37
- package/src/app/__tests__/return-to.test.ts +0 -396
- package/src/app/__tests__/row-actions-navigate-tab.test.ts +0 -223
- package/src/app/__tests__/row-default-edit-action.test.tsx +0 -324
- package/src/app/__tests__/screen-access-allows.test.ts +0 -34
- package/src/app/__tests__/secret-mint-body.test.tsx +0 -404
- package/src/app/__tests__/variable-chips.test.tsx +0 -70
- package/src/app/app-features-context.tsx +0 -25
- package/src/app/column-renderers.tsx +0 -68
- package/src/app/content-editors.tsx +0 -85
- package/src/app/content-preview.tsx +0 -67
- package/src/app/custom-screens.tsx +0 -29
- package/src/app/dashboard-body.tsx +0 -33
- package/src/app/extension-form-submit.tsx +0 -123
- package/src/app/extension-sections.tsx +0 -111
- package/src/app/form-schema.ts +0 -91
- package/src/app/kumiko-screen.tsx +0 -3801
- package/src/app/layout-fields.ts +0 -31
- package/src/app/list-facets.ts +0 -259
- package/src/app/nav.tsx +0 -258
- package/src/app/projection-detail-shim.ts +0 -86
- package/src/app/reference-facet-bridge.tsx +0 -58
- package/src/app/return-to.tsx +0 -234
- package/src/app/row-actions.ts +0 -640
- package/src/app/screen-access.ts +0 -63
- package/src/app/secret-mint-body.tsx +0 -259
- package/src/app/secrets-edit-body.tsx +0 -194
- package/src/app/use-embedded-screen.ts +0 -27
- package/src/app/variable-chips.tsx +0 -39
- package/src/app/write-failed-error.ts +0 -27
- package/src/components/__tests__/embedded-list-field.test.tsx +0 -531
- package/src/components/__tests__/multi-select-checkboxes.test.tsx +0 -162
- package/src/components/__tests__/related-list-section-empty-state.test.tsx +0 -143
- package/src/components/__tests__/related-list-section.test.tsx +0 -1733
- package/src/components/__tests__/render-edit-action-button.test.tsx +0 -205
- package/src/components/__tests__/render-edit-hidden-section.test.tsx +0 -128
- package/src/components/__tests__/render-edit-logic.test.ts +0 -314
- package/src/components/__tests__/render-edit-screen-description.test.tsx +0 -152
- package/src/components/__tests__/render-edit-submit-actions.test.tsx +0 -460
- package/src/components/__tests__/render-field-app-locale.test.tsx +0 -142
- package/src/components/__tests__/render-field-enum-option.test.tsx +0 -99
- package/src/components/__tests__/render-field-icon-derivation.test.tsx +0 -119
- package/src/components/__tests__/render-field-json-format.test.tsx +0 -164
- package/src/components/__tests__/render-field-money-embedded-list-consistency.test.tsx +0 -212
- package/src/components/__tests__/render-field-money-roundtrip.test.tsx +0 -217
- package/src/components/__tests__/render-field-number-grouping.test.tsx +0 -76
- package/src/components/__tests__/render-field-number-unit.test.tsx +0 -227
- package/src/components/__tests__/render-field-password-format.test.tsx +0 -101
- package/src/components/__tests__/render-field-select-display.test.tsx +0 -134
- package/src/components/__tests__/render-field-unit-format.test.tsx +0 -107
- package/src/components/__tests__/render-field-unsupported-types.test.tsx +0 -195
- package/src/components/__tests__/render-list-toolbar-icon-only.test.tsx +0 -146
- package/src/components/__tests__/write-form-section.test.tsx +0 -375
- package/src/components/embedded-list-field.tsx +0 -354
- package/src/components/grid-cell-for-field.tsx +0 -88
- package/src/components/multi-select-checkboxes.tsx +0 -93
- package/src/components/reference-create-dialog.tsx +0 -91
- package/src/components/related-list-section.tsx +0 -491
- package/src/components/render-edit-action-button.tsx +0 -109
- package/src/components/render-edit-logic.ts +0 -85
- package/src/components/render-edit-types.ts +0 -226
- package/src/components/render-edit.tsx +0 -1871
- package/src/components/render-field.tsx +0 -951
- package/src/components/render-list.tsx +0 -593
- package/src/components/write-form-section.tsx +0 -198
- package/src/context/draft-storage-context.tsx +0 -39
- package/src/hooks/__tests__/use-ai-text.test.tsx +0 -177
- package/src/hooks/__tests__/use-disclosure.test.tsx +0 -25
- package/src/hooks/__tests__/use-form.test.tsx +0 -65
- package/src/hooks/__tests__/use-mutation.test.tsx +0 -77
- package/src/hooks/__tests__/use-query.test.tsx +0 -149
- package/src/hooks/__tests__/use-stream-handler.test.tsx +0 -107
- package/src/hooks/use-ai-text.ts +0 -172
- package/src/hooks/use-disclosure.ts +0 -20
- package/src/hooks/use-form.ts +0 -78
- package/src/hooks/use-list-url-state.ts +0 -207
- package/src/hooks/use-mutation.ts +0 -61
- package/src/hooks/use-query.ts +0 -166
- package/src/hooks/use-reference-lookup.ts +0 -76
- package/src/hooks/use-store.ts +0 -48
- package/src/hooks/use-stream-handler.ts +0 -134
- package/src/i18n-defaults.ts +0 -240
- package/src/i18n.tsx +0 -286
- package/src/index.ts +0 -279
- package/src/primitives.tsx +0 -1567
- package/src/screen-fills-height.ts +0 -3
- package/src/share-links.ts +0 -12
- package/src/sort-by-accessor.ts +0 -20
- package/src/sse/live-events.tsx +0 -56
- package/src/tokens.tsx +0 -170
|
@@ -1,593 +0,0 @@
|
|
|
1
|
-
import type { EagerloadedRow } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
-
import type {
|
|
3
|
-
EntityDefinition,
|
|
4
|
-
EntityListScreenDefinition,
|
|
5
|
-
IconKey,
|
|
6
|
-
} from "@cosmicdrift/kumiko-framework/ui-types";
|
|
7
|
-
import type {
|
|
8
|
-
ListColumnViewModel,
|
|
9
|
-
ListRowViewModel,
|
|
10
|
-
ListViewModel,
|
|
11
|
-
RuntimeRenderer,
|
|
12
|
-
Translate,
|
|
13
|
-
} from "@cosmicdrift/kumiko-headless";
|
|
14
|
-
import { computeListViewModel } from "@cosmicdrift/kumiko-headless";
|
|
15
|
-
import { type ReactNode, useCallback, useEffect, useMemo, useState } from "react";
|
|
16
|
-
import { extensionSectionName, useExtensionSectionComponent } from "../app/extension-sections";
|
|
17
|
-
import type { ListSort } from "../hooks/use-list-url-state";
|
|
18
|
-
import { type ReferenceLookupMap, useReferenceLookup } from "../hooks/use-reference-lookup";
|
|
19
|
-
import { useTranslation } from "../i18n";
|
|
20
|
-
import { usePageHeaderSlotAvailable } from "../page-header-slot";
|
|
21
|
-
import {
|
|
22
|
-
type DataTableDateRangeFacet,
|
|
23
|
-
type DataTableFacet,
|
|
24
|
-
type DataTableRowAction,
|
|
25
|
-
type DataTableRowActionMode,
|
|
26
|
-
shouldRenderActionsIconOnly,
|
|
27
|
-
usePrimitives,
|
|
28
|
-
} from "../primitives";
|
|
29
|
-
|
|
30
|
-
// RenderList — präsentationaler View für entityList-Screens.
|
|
31
|
-
//
|
|
32
|
-
// Daten + State sind komplett controlled vom Caller (KumikoScreen):
|
|
33
|
-
// - rows kommen aus dem Server (durch useQuery + URL-State-Payload)
|
|
34
|
-
// - sort/q sind Props, RenderList ruft onSortChange/onQChange wenn
|
|
35
|
-
// der User UI-Aktionen macht
|
|
36
|
-
// - Search ist serverseitig (via SearchAdapter / Meilisearch). Lokaler
|
|
37
|
-
// State im Search-Input ist nur Debounce-Buffer, keine Filterung.
|
|
38
|
-
//
|
|
39
|
-
// Apps die RenderList ohne Server-State nutzen wollen (z.B. ein
|
|
40
|
-
// statischer Lookup) liefern stabile rows + lassen sort/q weg —
|
|
41
|
-
// DataTable fällt dann auf "kein Sort-Wiring + kein Search" zurück.
|
|
42
|
-
|
|
43
|
-
export type RenderListProps = {
|
|
44
|
-
readonly screen: EntityListScreenDefinition;
|
|
45
|
-
readonly entity: EntityDefinition;
|
|
46
|
-
readonly rows: readonly Readonly<Record<string, unknown>>[];
|
|
47
|
-
readonly featureName: string;
|
|
48
|
-
readonly translate?: Translate;
|
|
49
|
-
readonly onRowClick?: (row: ListRowViewModel) => void;
|
|
50
|
-
/** Override der Default-Empty-Box. Wenn gesetzt, wird der Auto-CTA
|
|
51
|
-
* via `onCreate` ignoriert — Caller-Inhalt gewinnt. */
|
|
52
|
-
readonly emptyState?: ReactNode;
|
|
53
|
-
/** Setzt einen "+ Neu" Button in die Toolbar UND dient als CTA in
|
|
54
|
-
* der Default-Empty-Box. Caller liefert die Action selber (z. B.
|
|
55
|
-
* navigate auf den Edit-Screen). */
|
|
56
|
-
readonly onCreate?: () => void;
|
|
57
|
-
/** Label für den + Neu Button. Default kommt aus dem i18n-Bundle
|
|
58
|
-
* (`kumiko.actions.create`). Caller kann durch eigenen String
|
|
59
|
-
* überschreiben. */
|
|
60
|
-
readonly createLabel?: string;
|
|
61
|
-
/** Aktiviert ein Search-Input in der Toolbar. Server-side Filter
|
|
62
|
-
* via Caller's onSearchChange — RenderList filtert NICHT lokal. */
|
|
63
|
-
readonly searchable?: boolean;
|
|
64
|
-
/** Placeholder für das Search-Input. Default kommt aus dem i18n-
|
|
65
|
-
* Bundle (`kumiko.list.search-placeholder`). */
|
|
66
|
-
readonly searchPlaceholder?: string;
|
|
67
|
-
/** Hint at the left of the toolbar when there is no search box (already translated). */
|
|
68
|
-
readonly description?: string;
|
|
69
|
-
/** Plural-forms key for the footer count noun; default is the entity's `:noun` convention key. */
|
|
70
|
-
readonly itemNounKey?: string;
|
|
71
|
-
/** Aktueller Search-Term (vom URL-State / Parent). RenderList puffert
|
|
72
|
-
* Tipps lokal mit 300ms Debounce, bevor onSearchChange gefeuert
|
|
73
|
-
* wird — sonst macht jeder Tastendruck einen Server-Roundtrip. */
|
|
74
|
-
readonly searchValue?: string;
|
|
75
|
-
/** Wird gerufen wenn der debounced Search-Term sich ändert. Caller
|
|
76
|
-
* setzt damit URL-State (?<id>.q=…) und triggert ein refetch. */
|
|
77
|
-
readonly onSearchChange?: (next: string) => void;
|
|
78
|
-
/** Aktuelle Sortierung (oder null = Server-Default-Order). */
|
|
79
|
-
readonly sort?: ListSort | null;
|
|
80
|
-
/** Wird gerufen mit dem nächsten Sort-State nach einem Header-Klick. */
|
|
81
|
-
readonly onSortChange?: (next: ListSort | null) => void;
|
|
82
|
-
/** Pager-Props für pagination="pages". Wenn undefined, kein Pager-
|
|
83
|
-
* UI — Default oder infinite-Mode. KumikoScreen liefert das je nach
|
|
84
|
-
* screen.pagination. */
|
|
85
|
-
readonly pager?: {
|
|
86
|
-
readonly page: number;
|
|
87
|
-
readonly limit: number;
|
|
88
|
-
readonly total: number;
|
|
89
|
-
readonly onPageChange: (next: number) => void;
|
|
90
|
-
};
|
|
91
|
-
/** Infinite-Scroll-Wiring für pagination="infinite". KumikoScreen
|
|
92
|
-
* hält accumulated rows + cursor, RenderList reicht die Callbacks
|
|
93
|
-
* einfach durch an DataTable. */
|
|
94
|
-
readonly onReachEnd?: () => void;
|
|
95
|
-
readonly loadingMore?: boolean;
|
|
96
|
-
readonly hasMore?: boolean;
|
|
97
|
-
/** Pro-Row-Aktionen — Resolved-Form (KumikoScreen baut das aus
|
|
98
|
-
* EntityListScreenDefinition.rowActions: handler-QN → dispatcher-Call,
|
|
99
|
-
* i18n-Keys → translated Strings). */
|
|
100
|
-
readonly rowActions?: readonly DataTableRowAction[];
|
|
101
|
-
/** How the row-action column renders (see `DataTableProps.rowActionMode`).
|
|
102
|
-
* KumikoScreen derives it from the actions themselves; without it the
|
|
103
|
-
* DataTable falls back to its adaptive default. */
|
|
104
|
-
readonly rowActionMode?: DataTableRowActionMode;
|
|
105
|
-
/** Toolbar-Aktionen im List-Header — Resolved-Form (KumikoScreen baut
|
|
106
|
-
* das aus EntityListScreenDefinition.toolbarActions: navigate-target
|
|
107
|
-
* → useNav, handler-QN → dispatcher-Call). RenderList rendert die
|
|
108
|
-
* Buttons rechts in der Toolbar, vor "+ Neu". */
|
|
109
|
-
readonly toolbarActions?: readonly ToolbarActionButton[];
|
|
110
|
-
/** Faceted-Filter-Dropdowns — KumikoScreen baut sie aus den filterable
|
|
111
|
-
* select/boolean-Feldern; RenderList reicht sie an die DataTable durch. */
|
|
112
|
-
readonly filterFacets?: readonly DataTableFacet[];
|
|
113
|
-
/** Aktuell gewählte Facet-Werte je Feld (vom URL-State). */
|
|
114
|
-
readonly filterValues?: Readonly<Record<string, readonly string[]>>;
|
|
115
|
-
/** Toggle eines Facet-Werts (URL-State setzen + refetch). */
|
|
116
|
-
readonly onFilterChange?: (field: string, values: readonly string[]) => void;
|
|
117
|
-
/** Reset aller aktiven Facets. */
|
|
118
|
-
readonly onFilterReset?: () => void;
|
|
119
|
-
/** Time-range filters (fw#3104) — forwarded to the DataTable. */
|
|
120
|
-
readonly dateRangeFacets?: readonly DataTableDateRangeFacet[];
|
|
121
|
-
/** One bound changed (set URL state + refetch). */
|
|
122
|
-
readonly onDateRangeChange?: (field: string, bound: "from" | "to", value: string) => void;
|
|
123
|
-
/** Forwarded to `DataTableProps.chromeless` — drops the table's own card
|
|
124
|
-
* frame for a host that already provides one (relatedList in a tabs-mode
|
|
125
|
-
* section, fw#2722). Default false. */
|
|
126
|
-
readonly chromeless?: boolean;
|
|
127
|
-
/** Forwarded to `DataTableProps.scrollBody` — bounds the table height and
|
|
128
|
-
* scrolls rows internally instead of growing the page (relatedList in a
|
|
129
|
-
* tabs-mode section, fw#2722). Default false. */
|
|
130
|
-
readonly scrollBody?: boolean;
|
|
131
|
-
/** Forwarded to `DataTableProps.screenPadding` — `true`: the table carries
|
|
132
|
-
* the shared screen padding because it is the screen body (entityList/
|
|
133
|
-
* projectionList, fw#2640). Explicit `false`: no padding at all — the
|
|
134
|
-
* host already pads its own children (relatedList in a tabs-mode Card,
|
|
135
|
-
* fw#3234). Omitted: legacy `p-6` fallback for a standalone table with no
|
|
136
|
-
* padded host. */
|
|
137
|
-
readonly screenPadding?: boolean;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
// Resolved-Form einer Toolbar-Action: KumikoScreen baut das aus dem
|
|
141
|
-
// Schema (entweder navigate- oder writeHandler-kind), RenderList sieht
|
|
142
|
-
// nur einen onTrigger-Callback + Label/Style — keine kind-Discrimination
|
|
143
|
-
// mehr.
|
|
144
|
-
export type ToolbarActionButton = {
|
|
145
|
-
readonly id: string;
|
|
146
|
-
readonly label: string;
|
|
147
|
-
readonly style?: "primary" | "secondary" | "danger";
|
|
148
|
-
readonly confirm?: string;
|
|
149
|
-
readonly confirmLabel?: string;
|
|
150
|
-
/** Overrides the default "danger implies a confirm dialog" rule. Schema-driven
|
|
151
|
-
* navigate/drawer actions set it to false: the colour marks the action as
|
|
152
|
-
* destructive, but the target form is the confirmation. */
|
|
153
|
-
readonly confirmRequired?: boolean;
|
|
154
|
-
readonly onTrigger: () => Promise<void> | void;
|
|
155
|
-
/** Id-derived default icon (ACTION_ICON_BY_ID in kumiko-screen.tsx) —
|
|
156
|
-
* ToolbarAction has no author-declared icon field, unlike RowAction. */
|
|
157
|
-
readonly icon?: IconKey;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const SEARCH_DEBOUNCE_MS = 300;
|
|
161
|
-
|
|
162
|
-
export function RenderList(props: RenderListProps): ReactNode {
|
|
163
|
-
const {
|
|
164
|
-
screen,
|
|
165
|
-
entity,
|
|
166
|
-
rows,
|
|
167
|
-
featureName,
|
|
168
|
-
translate: translateProp,
|
|
169
|
-
onRowClick,
|
|
170
|
-
emptyState,
|
|
171
|
-
onCreate,
|
|
172
|
-
createLabel,
|
|
173
|
-
searchable = false,
|
|
174
|
-
searchPlaceholder,
|
|
175
|
-
description,
|
|
176
|
-
itemNounKey,
|
|
177
|
-
searchValue,
|
|
178
|
-
onSearchChange,
|
|
179
|
-
sort,
|
|
180
|
-
onSortChange,
|
|
181
|
-
pager,
|
|
182
|
-
onReachEnd,
|
|
183
|
-
loadingMore,
|
|
184
|
-
hasMore,
|
|
185
|
-
rowActions,
|
|
186
|
-
rowActionMode,
|
|
187
|
-
toolbarActions,
|
|
188
|
-
filterFacets,
|
|
189
|
-
filterValues,
|
|
190
|
-
onFilterChange,
|
|
191
|
-
onFilterReset,
|
|
192
|
-
dateRangeFacets,
|
|
193
|
-
onDateRangeChange,
|
|
194
|
-
chromeless,
|
|
195
|
-
scrollBody,
|
|
196
|
-
screenPadding,
|
|
197
|
-
} = props;
|
|
198
|
-
// Wie RenderEdit: Translate-Fallback aus dem i18next-Context, sonst
|
|
199
|
-
// wären Column-Header raw i18n-Keys.
|
|
200
|
-
const t = useTranslation();
|
|
201
|
-
const translate: Translate = translateProp ?? t;
|
|
202
|
-
const { DataTable, Button, Dialog, Input, Text, Banner, PageHeader } = usePrimitives();
|
|
203
|
-
const pageHeaderSlotAvailable = usePageHeaderSlotAvailable();
|
|
204
|
-
const createInPageHeader =
|
|
205
|
-
onCreate !== undefined && PageHeader !== undefined && pageHeaderSlotAvailable;
|
|
206
|
-
|
|
207
|
-
// Local search buffer + debounce. External changes (browser back,
|
|
208
|
-
// cross-component reset) are mirrored back; typing only fires
|
|
209
|
-
// onSearchChange after 300ms without further keystrokes.
|
|
210
|
-
const [localQ, setLocalQ] = useState(searchValue ?? "");
|
|
211
|
-
// Sync during render, not in a useEffect: the passive effect also fires on
|
|
212
|
-
// mount and can flush after a keystroke landing in the same commit,
|
|
213
|
-
// resetting localQ and swallowing the input.
|
|
214
|
-
const [syncedSearchValue, setSyncedSearchValue] = useState(searchValue);
|
|
215
|
-
if (searchValue !== syncedSearchValue) {
|
|
216
|
-
setSyncedSearchValue(searchValue);
|
|
217
|
-
setLocalQ(searchValue ?? "");
|
|
218
|
-
}
|
|
219
|
-
useEffect(() => {
|
|
220
|
-
if (onSearchChange === undefined) return;
|
|
221
|
-
if (localQ === (searchValue ?? "")) return;
|
|
222
|
-
const timer = setTimeout(() => onSearchChange(localQ), SEARCH_DEBOUNCE_MS);
|
|
223
|
-
return () => clearTimeout(timer);
|
|
224
|
-
}, [localQ, searchValue, onSearchChange]);
|
|
225
|
-
|
|
226
|
-
const vm = useMemo(
|
|
227
|
-
() => computeListViewModel({ screen, entity, rows, translate, featureName }),
|
|
228
|
-
[screen, entity, rows, translate, featureName],
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
// Tier 2.7e-4: Reference-Field-Eagerload via Bridge-Component-Pattern.
|
|
232
|
-
// Hooks-Rule-Konflikt: pro reference-Spalte muss useReferenceLookup
|
|
233
|
-
// gerufen werden, aber die Anzahl varriiert per Schema. Lösung —
|
|
234
|
-
// ReferenceLookupBridge-Komponenten pro Spalte gemountet, die ihre
|
|
235
|
-
// Map über onMap-Callback in einen lokalen State veröffentlichen.
|
|
236
|
-
// Anzahl der Hook-Calls pro Bridge-Component ist konstant (1), und
|
|
237
|
-
// React verwaltet die mounted/unmounted Lifecycles beim Schema-
|
|
238
|
-
// Wechsel über die key-Property automatisch.
|
|
239
|
-
const referenceColumns = useMemo(
|
|
240
|
-
() =>
|
|
241
|
-
vm.columns
|
|
242
|
-
.filter((c: ListColumnViewModel) => c.type === "reference" && c.refEntity !== undefined)
|
|
243
|
-
.map((c: ListColumnViewModel) => ({
|
|
244
|
-
field: c.field,
|
|
245
|
-
refEntity: c.refEntity ?? "",
|
|
246
|
-
// Tier 2.7e Cross-Feature: refFeature kommt aus parseRefTarget
|
|
247
|
-
// im ViewModel (default = current featureName).
|
|
248
|
-
refFeature: c.refFeature ?? featureName,
|
|
249
|
-
labelField: c.refLabelField ?? "id",
|
|
250
|
-
})),
|
|
251
|
-
[vm.columns, featureName],
|
|
252
|
-
);
|
|
253
|
-
const [referenceLookups, setReferenceLookups] = useState<Record<string, ReferenceLookupMap>>({});
|
|
254
|
-
const handleLookupMap = useCallback((field: string, map: ReferenceLookupMap) => {
|
|
255
|
-
setReferenceLookups((prev) => {
|
|
256
|
-
// skip-update wenn die Map identisch ist (Render-Loop-Schutz —
|
|
257
|
-
// Bridge-Component re-rendert sonst und schickt die gleiche Map
|
|
258
|
-
// wieder rein bis React in eine Endlosschleife geht).
|
|
259
|
-
if (prev[field] === map) return prev;
|
|
260
|
-
return { ...prev, [field]: map };
|
|
261
|
-
});
|
|
262
|
-
}, []);
|
|
263
|
-
const enrichedColumns = useMemo((): readonly ListColumnViewModel[] => {
|
|
264
|
-
if (referenceColumns.length === 0) return vm.columns;
|
|
265
|
-
return vm.columns.map((col: ListColumnViewModel) => {
|
|
266
|
-
if (col.type !== "reference") return col;
|
|
267
|
-
// Author-deklarierter Renderer übersteuert immer — Default greift
|
|
268
|
-
// nur wenn keiner gesetzt ist.
|
|
269
|
-
if (col.renderer !== undefined) return col;
|
|
270
|
-
const map = referenceLookups[col.field];
|
|
271
|
-
const labelField = col.refLabelField ?? "id";
|
|
272
|
-
const renderer: RuntimeRenderer = (
|
|
273
|
-
value: unknown,
|
|
274
|
-
row?: Readonly<Record<string, unknown>>,
|
|
275
|
-
): string => {
|
|
276
|
-
// Tier 2.7e Server-Eagerload: wenn der Server _refs mit-
|
|
277
|
-
// schickt, lesen wir den Display-Wert direkt aus der
|
|
278
|
-
// resolved Row — kein Roundtrip durch die Bridge-Map nötig
|
|
279
|
-
// und keine limit:200-Constraint. EagerloadedRow-Type aus
|
|
280
|
-
// @cosmicdrift/kumiko-framework/db pinnt die Form von _refs.
|
|
281
|
-
const eagerloadedRow = row as EagerloadedRow | undefined;
|
|
282
|
-
const resolved = eagerloadedRow?._refs?.[col.field];
|
|
283
|
-
if (Array.isArray(resolved) && resolved.length > 0) {
|
|
284
|
-
return resolved.map((r) => String(r[labelField] ?? r["id"] ?? "")).join(", ");
|
|
285
|
-
}
|
|
286
|
-
if (resolved !== undefined && !Array.isArray(resolved)) {
|
|
287
|
-
const single = resolved as Record<string, unknown>; // @cast-boundary render-helper
|
|
288
|
-
return String(single[labelField] ?? single["id"] ?? "");
|
|
289
|
-
}
|
|
290
|
-
// Renderer-Side-Fallback (kein Server-Eagerload aktiv).
|
|
291
|
-
if (Array.isArray(value)) {
|
|
292
|
-
if (value.length === 0) return "—";
|
|
293
|
-
return value.map((v) => map?.get(String(v)) ?? String(v)).join(", ");
|
|
294
|
-
}
|
|
295
|
-
if (value === null || value === undefined || value === "") return "—";
|
|
296
|
-
const idStr = String(value);
|
|
297
|
-
return map?.get(idStr) ?? idStr;
|
|
298
|
-
};
|
|
299
|
-
return { ...col, renderer };
|
|
300
|
-
});
|
|
301
|
-
}, [vm.columns, referenceColumns, referenceLookups]);
|
|
302
|
-
const enrichedVm = useMemo(
|
|
303
|
-
(): Omit<ListViewModel, "columns"> & { columns: readonly ListColumnViewModel[] } => ({
|
|
304
|
-
...vm,
|
|
305
|
-
columns: enrichedColumns,
|
|
306
|
-
}),
|
|
307
|
-
[vm, enrichedColumns],
|
|
308
|
-
);
|
|
309
|
-
|
|
310
|
-
// i18n-Defaults für Toolbar/Empty-State Strings — Caller kann jeden
|
|
311
|
-
// einzeln per Prop überschreiben, sonst kommen die Framework-Bundles
|
|
312
|
-
// (kumiko.actions.create, kumiko.list.search-placeholder, …).
|
|
313
|
-
const effectiveCreateLabel = translate(
|
|
314
|
-
createLabel ?? screen.createLabel ?? "kumiko.actions.create",
|
|
315
|
-
);
|
|
316
|
-
const effectiveSearchPlaceholder = translate(
|
|
317
|
-
searchPlaceholder ?? screen.searchPlaceholder ?? "kumiko.list.search-placeholder",
|
|
318
|
-
);
|
|
319
|
-
|
|
320
|
-
const nounKey = itemNounKey ?? `${featureName}:entity:${screen.entity}:noun`;
|
|
321
|
-
const itemNoun =
|
|
322
|
-
(itemNounKey !== undefined || !screen.entity.startsWith("__")) &&
|
|
323
|
-
translate(nounKey, { count: 2 }) !== nounKey
|
|
324
|
-
? (count: number): string => translate(nounKey, { count })
|
|
325
|
-
: undefined;
|
|
326
|
-
|
|
327
|
-
const toolbarStart = searchable ? (
|
|
328
|
-
<Input
|
|
329
|
-
kind="text"
|
|
330
|
-
id="render-list-search"
|
|
331
|
-
name="search"
|
|
332
|
-
value={localQ}
|
|
333
|
-
onChange={setLocalQ}
|
|
334
|
-
placeholder={effectiveSearchPlaceholder}
|
|
335
|
-
/>
|
|
336
|
-
) : undefined;
|
|
337
|
-
|
|
338
|
-
// Toolbar-End-Slot: optionaler Header-Slot (z.B. Cap-Counter, links im
|
|
339
|
-
// rechten Cluster) + Toolbar-Actions (List-Header-Buttons aus dem Schema)
|
|
340
|
-
// + optional "+ Neu" am rechten Edge. Der Header-Slot lebt IN der Toolbar-
|
|
341
|
-
// Zeile (gleicher Card-Rahmen), nicht als loser Text über dem Screen-Titel
|
|
342
|
-
// (Bug-Bash 3 #12). Reihenfolge = Array-Reihenfolge (Schema-deklariert),
|
|
343
|
-
// "+ Neu" zuletzt weil das die häufigste/auffälligste CTA ist.
|
|
344
|
-
const hasToolbarActions = toolbarActions !== undefined && toolbarActions.length > 0;
|
|
345
|
-
const hasHeaderSlot = screen.slots?.header !== undefined;
|
|
346
|
-
const toolbarIconOnly = hasToolbarActions && shouldRenderActionsIconOnly(toolbarActions);
|
|
347
|
-
const createButton =
|
|
348
|
-
onCreate !== undefined ? (
|
|
349
|
-
<Button
|
|
350
|
-
variant="primary"
|
|
351
|
-
icon="plus"
|
|
352
|
-
onClick={onCreate}
|
|
353
|
-
testId="render-list-create"
|
|
354
|
-
className="px-3.5"
|
|
355
|
-
>
|
|
356
|
-
{effectiveCreateLabel}
|
|
357
|
-
</Button>
|
|
358
|
-
) : undefined;
|
|
359
|
-
const toolbarEnd =
|
|
360
|
-
hasHeaderSlot || hasToolbarActions || (onCreate !== undefined && !createInPageHeader) ? (
|
|
361
|
-
<>
|
|
362
|
-
{hasHeaderSlot && <ListHeaderSlotMount screen={screen} />}
|
|
363
|
-
{hasToolbarActions &&
|
|
364
|
-
toolbarActions.map((a) => (
|
|
365
|
-
<ToolbarActionView
|
|
366
|
-
key={a.id}
|
|
367
|
-
action={a}
|
|
368
|
-
iconOnly={toolbarIconOnly}
|
|
369
|
-
Button={Button}
|
|
370
|
-
Dialog={Dialog}
|
|
371
|
-
Banner={Banner}
|
|
372
|
-
/>
|
|
373
|
-
))}
|
|
374
|
-
{!createInPageHeader && createButton}
|
|
375
|
-
</>
|
|
376
|
-
) : undefined;
|
|
377
|
-
|
|
378
|
-
// Empty-State: Default zeigt Heading + Description + optional CTA-
|
|
379
|
-
// Button. Caller kann via emptyState-Prop komplett überschreiben.
|
|
380
|
-
// Wenn weder onCreate noch ein Override gegeben ist, fällt die
|
|
381
|
-
// DataTable auf den DataTable-Default zurück (`kumiko.list.no-entries`).
|
|
382
|
-
const composedEmptyState =
|
|
383
|
-
emptyState ??
|
|
384
|
-
(onCreate !== undefined ? (
|
|
385
|
-
<>
|
|
386
|
-
<Text>{translate("kumiko.list.empty.title")}</Text>
|
|
387
|
-
<Text variant="small">{translate("kumiko.list.empty.hint")}</Text>
|
|
388
|
-
<Button variant="primary" icon="plus" onClick={onCreate} testId="render-list-empty-create">
|
|
389
|
-
{effectiveCreateLabel}
|
|
390
|
-
</Button>
|
|
391
|
-
</>
|
|
392
|
-
) : undefined);
|
|
393
|
-
|
|
394
|
-
// Title-Resolution: ein konventioneller i18n-Key `screen:<id>.title`.
|
|
395
|
-
// Wenn das Bundle den Key kennt, schöner Titel; sonst kommt der
|
|
396
|
-
// screenId selber raus (kein "Untitled"-Fallback — der App-Dev sieht
|
|
397
|
-
// dann dass die Übersetzung fehlt).
|
|
398
|
-
const titleKey = `screen:${screen.id}.title`;
|
|
399
|
-
const resolvedTitle = translate(titleKey);
|
|
400
|
-
const toolbarTitle = resolvedTitle === titleKey ? screen.id : resolvedTitle;
|
|
401
|
-
|
|
402
|
-
// ListSort = DataTableSort (use-list-url-state aliased) — kein Cast nötig.
|
|
403
|
-
return (
|
|
404
|
-
<>
|
|
405
|
-
{createInPageHeader && PageHeader !== undefined && <PageHeader actions={createButton} />}
|
|
406
|
-
{referenceColumns.map(
|
|
407
|
-
(rc: { field: string; refEntity: string; refFeature: string; labelField: string }) => (
|
|
408
|
-
<ReferenceLookupBridge
|
|
409
|
-
key={rc.field}
|
|
410
|
-
field={rc.field}
|
|
411
|
-
refEntity={rc.refEntity}
|
|
412
|
-
labelField={rc.labelField}
|
|
413
|
-
featureName={rc.refFeature}
|
|
414
|
-
onMap={handleLookupMap}
|
|
415
|
-
/>
|
|
416
|
-
),
|
|
417
|
-
)}
|
|
418
|
-
<DataTable
|
|
419
|
-
columns={enrichedVm.columns}
|
|
420
|
-
rows={enrichedVm.rows}
|
|
421
|
-
toolbarTitle={toolbarTitle}
|
|
422
|
-
{...(onRowClick !== undefined && { onRowClick })}
|
|
423
|
-
{...(composedEmptyState !== undefined && { emptyState: composedEmptyState })}
|
|
424
|
-
{...(toolbarStart !== undefined && { toolbarStart })}
|
|
425
|
-
{...(description !== undefined && !searchable && { toolbarDescription: description })}
|
|
426
|
-
{...(toolbarEnd !== undefined && { toolbarEnd })}
|
|
427
|
-
{...(sort !== undefined && { sort })}
|
|
428
|
-
{...(onSortChange !== undefined && { onSortChange })}
|
|
429
|
-
{...(pager !== undefined && { pager })}
|
|
430
|
-
{...(onReachEnd !== undefined && { onReachEnd })}
|
|
431
|
-
{...(loadingMore !== undefined && { loadingMore })}
|
|
432
|
-
{...(hasMore !== undefined && { hasMore })}
|
|
433
|
-
{...(itemNoun !== undefined && { itemNoun })}
|
|
434
|
-
{...(rowActions !== undefined && { rowActions })}
|
|
435
|
-
{...(rowActionMode !== undefined && { rowActionMode })}
|
|
436
|
-
{...(filterFacets !== undefined && { filterFacets })}
|
|
437
|
-
{...(filterValues !== undefined && { filterValues })}
|
|
438
|
-
{...(onFilterChange !== undefined && { onFilterChange })}
|
|
439
|
-
{...(onFilterReset !== undefined && { onFilterReset })}
|
|
440
|
-
{...(dateRangeFacets !== undefined && { dateRangeFacets })}
|
|
441
|
-
{...(onDateRangeChange !== undefined && { onDateRangeChange })}
|
|
442
|
-
{...(chromeless !== undefined && { chromeless })}
|
|
443
|
-
{...(scrollBody !== undefined && { scrollBody })}
|
|
444
|
-
{...(screenPadding !== undefined && { screenPadding })}
|
|
445
|
-
testId="render-list-table"
|
|
446
|
-
/>
|
|
447
|
-
</>
|
|
448
|
-
);
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
// Header-Slot in der Listen-Toolbar (toolbarEnd): `screen.slots.header` ist
|
|
452
|
-
// eine PlatformComponent (`{ react: { __component: "X" } }`), aufgelöst über
|
|
453
|
-
// dieselbe ExtensionSectionsProvider-Registry wie entityEdit-Sections.
|
|
454
|
-
// entityId ist null (Listen-Kontext, keine Row); die Component lädt ihre
|
|
455
|
-
// Daten selbst (z.B. ein Cap-Counter aus einer usage-Query). Eigene
|
|
456
|
-
// Component wegen Rules-of-Hooks — useExtensionSectionComponent darf nicht
|
|
457
|
-
// konditional im RenderList-Body laufen.
|
|
458
|
-
function ListHeaderSlotMount({
|
|
459
|
-
screen,
|
|
460
|
-
}: {
|
|
461
|
-
readonly screen: EntityListScreenDefinition;
|
|
462
|
-
}): ReactNode {
|
|
463
|
-
const header = screen.slots?.header;
|
|
464
|
-
const name = header !== undefined ? extensionSectionName(header) : undefined;
|
|
465
|
-
const Component = useExtensionSectionComponent(name);
|
|
466
|
-
// A declared-but-unregistered header slot renders nothing; warn so the author
|
|
467
|
-
// finds the typo / missing clientFeatures.extensionSectionComponents entry,
|
|
468
|
-
// mirroring the diagnostic banner in render-edit's ExtensionSectionMount
|
|
469
|
-
// (the toolbar has no room for a banner, so a dev-warn it is).
|
|
470
|
-
useEffect(() => {
|
|
471
|
-
if (name !== undefined && Component === undefined) {
|
|
472
|
-
// biome-ignore lint/suspicious/noConsole: dev-warning für Setup-Fehler
|
|
473
|
-
console.warn(
|
|
474
|
-
`[kumiko] List header slot component "${name}" on screen "${screen.id}" is not registered in clientFeatures.extensionSectionComponents — the header slot renders nothing.`,
|
|
475
|
-
);
|
|
476
|
-
}
|
|
477
|
-
}, [name, Component, screen.id]);
|
|
478
|
-
if (Component === undefined) return null;
|
|
479
|
-
// screenId lets a header control drive this list's URL-filter state
|
|
480
|
-
// (useListUrlState) — e.g. a tag filter narrowing the list to an id-set.
|
|
481
|
-
return <Component entityName={screen.entity} entityId={null} screenId={screen.id} />;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
// Tier 2.7e-4: Bridge-Component pro reference-Spalte. Mounted für jede
|
|
485
|
-
// Spalte einmal, ruft useReferenceLookup unconditional (Hook-Rules
|
|
486
|
-
// happy), und published die Map über onMap an den Parent. React
|
|
487
|
-
// verwaltet das Mounting/Unmounting beim Schema-Wechsel über die
|
|
488
|
-
// key-Prop im map-Loop des Parents.
|
|
489
|
-
function ReferenceLookupBridge({
|
|
490
|
-
field,
|
|
491
|
-
refEntity,
|
|
492
|
-
labelField,
|
|
493
|
-
featureName,
|
|
494
|
-
onMap,
|
|
495
|
-
}: {
|
|
496
|
-
readonly field: string;
|
|
497
|
-
readonly refEntity: string;
|
|
498
|
-
readonly labelField: string;
|
|
499
|
-
readonly featureName: string;
|
|
500
|
-
readonly onMap: (field: string, map: ReferenceLookupMap) => void;
|
|
501
|
-
}): null {
|
|
502
|
-
const lookup = useReferenceLookup(featureName, refEntity, labelField);
|
|
503
|
-
// useEffect statt direktem call damit setState außerhalb des Render-
|
|
504
|
-
// Pfads passiert (sonst React-Warning "Cannot update a component
|
|
505
|
-
// while rendering a different component").
|
|
506
|
-
useEffect(() => {
|
|
507
|
-
onMap(field, lookup.map);
|
|
508
|
-
}, [field, lookup.map, onMap]);
|
|
509
|
-
return null;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
// ToolbarActionView — pro Toolbar-Action ein Button (+ Confirm-Dialog
|
|
513
|
-
// wenn confirm gesetzt). Same Pattern wie RowAction (Inline-Variante)
|
|
514
|
-
// aber ohne row-Context. busy-State während async onTrigger; Dialog
|
|
515
|
-
// öffnet sich vor dem Trigger wenn confirm/danger gesetzt.
|
|
516
|
-
function ToolbarActionView({
|
|
517
|
-
action,
|
|
518
|
-
iconOnly = false,
|
|
519
|
-
Button,
|
|
520
|
-
Dialog,
|
|
521
|
-
Banner,
|
|
522
|
-
}: {
|
|
523
|
-
readonly action: ToolbarActionButton;
|
|
524
|
-
/** Group-level collapse (see `shouldRenderActionsIconOnly`) — only takes
|
|
525
|
-
* effect when this action actually resolved an icon. */
|
|
526
|
-
readonly iconOnly?: boolean;
|
|
527
|
-
readonly Button: ReturnType<typeof usePrimitives>["Button"];
|
|
528
|
-
readonly Dialog: ReturnType<typeof usePrimitives>["Dialog"];
|
|
529
|
-
readonly Banner: ReturnType<typeof usePrimitives>["Banner"];
|
|
530
|
-
}): ReactNode {
|
|
531
|
-
const [busy, setBusy] = useState(false);
|
|
532
|
-
const [confirmOpen, setConfirmOpen] = useState(false);
|
|
533
|
-
// Toolbar-Actions haben (anders als rowActions, die über die DataTable-
|
|
534
|
-
// Primitive laufen) keine Toast-Primitive zur Verfügung — ein inline
|
|
535
|
-
// Error-Banner ist der surfacing-Pfad hier. Gleicher Grund wie bei
|
|
536
|
-
// rowActions (Prod-Bug 2026-06-07): ein verschlucktes Failure-Result
|
|
537
|
-
// sieht für den User wie "nichts passiert" aus.
|
|
538
|
-
const [errorText, setErrorText] = useState<string | null>(null);
|
|
539
|
-
|
|
540
|
-
const trigger = async (): Promise<void> => {
|
|
541
|
-
setBusy(true);
|
|
542
|
-
setErrorText(null);
|
|
543
|
-
try {
|
|
544
|
-
await action.onTrigger();
|
|
545
|
-
} catch (e) {
|
|
546
|
-
setErrorText(e instanceof Error ? e.message : String(e));
|
|
547
|
-
} finally {
|
|
548
|
-
setBusy(false);
|
|
549
|
-
}
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
const variant: "primary" | "secondary" | "danger" = action.style ?? "secondary";
|
|
553
|
-
const needsConfirm =
|
|
554
|
-
action.confirm !== undefined || (action.confirmRequired ?? action.style === "danger");
|
|
555
|
-
const showIconOnly = iconOnly && action.icon !== undefined;
|
|
556
|
-
|
|
557
|
-
return (
|
|
558
|
-
<>
|
|
559
|
-
<Button
|
|
560
|
-
variant={variant}
|
|
561
|
-
loading={busy}
|
|
562
|
-
{...(action.icon !== undefined && { icon: action.icon })}
|
|
563
|
-
size={showIconOnly ? "icon" : "sm"}
|
|
564
|
-
{...(showIconOnly && { ariaLabel: action.label })}
|
|
565
|
-
onClick={() => {
|
|
566
|
-
if (needsConfirm) {
|
|
567
|
-
setConfirmOpen(true);
|
|
568
|
-
} else {
|
|
569
|
-
void trigger();
|
|
570
|
-
}
|
|
571
|
-
}}
|
|
572
|
-
testId={`render-list-toolbar-action-${action.id}`}
|
|
573
|
-
>
|
|
574
|
-
{showIconOnly ? null : action.label}
|
|
575
|
-
</Button>
|
|
576
|
-
<Dialog
|
|
577
|
-
open={confirmOpen}
|
|
578
|
-
onOpenChange={setConfirmOpen}
|
|
579
|
-
title={action.label}
|
|
580
|
-
{...(action.confirm !== undefined && { description: action.confirm })}
|
|
581
|
-
confirmLabel={action.confirmLabel ?? action.label}
|
|
582
|
-
{...(action.style === "danger" && { variant: "danger" as const })}
|
|
583
|
-
onConfirm={trigger}
|
|
584
|
-
testId={`render-list-toolbar-action-${action.id}-dialog`}
|
|
585
|
-
/>
|
|
586
|
-
{errorText !== null && (
|
|
587
|
-
<Banner variant="error" testId={`render-list-toolbar-action-${action.id}-error`}>
|
|
588
|
-
{errorText}
|
|
589
|
-
</Banner>
|
|
590
|
-
)}
|
|
591
|
-
</>
|
|
592
|
-
);
|
|
593
|
-
}
|