@cosmicdrift/kumiko-renderer 0.34.2 → 0.36.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/package.json +3 -3
- package/src/app/kumiko-screen.tsx +6 -4
- package/src/components/render-list.tsx +14 -3
- package/src/index.ts +1 -0
- package/src/primitives.tsx +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"description": "Platform-agnostic React renderer for Kumiko screens. Contains the shared logic — primitives-contract, hooks, KumikoScreen, navigation & SSE abstractions — that any platform-specific renderer (web, native) composes. No DOM, no EventSource, no react-dom.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@cosmicdrift/kumiko-framework": "0.
|
|
19
|
-
"@cosmicdrift/kumiko-headless": "0.
|
|
18
|
+
"@cosmicdrift/kumiko-framework": "0.35.0",
|
|
19
|
+
"@cosmicdrift/kumiko-headless": "0.35.0",
|
|
20
20
|
"react": "^19.2.6"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
@@ -699,6 +699,7 @@ function EntityListBody({
|
|
|
699
699
|
const targetIsEntityEdit = schema.screens.some(
|
|
700
700
|
(s) => s.type === "entityEdit" && lastSegment(s.id) === action.screen,
|
|
701
701
|
);
|
|
702
|
+
const actionVisible = action.visible;
|
|
702
703
|
return {
|
|
703
704
|
id: action.id,
|
|
704
705
|
label: effectiveTranslate(action.label),
|
|
@@ -733,14 +734,15 @@ function EntityListBody({
|
|
|
733
734
|
nav.setSearchParams(stringified);
|
|
734
735
|
}
|
|
735
736
|
},
|
|
736
|
-
...(
|
|
737
|
-
isVisible: (row: ListRowViewModel) => evalFieldCondition(
|
|
737
|
+
...(actionVisible !== undefined && {
|
|
738
|
+
isVisible: (row: ListRowViewModel) => evalFieldCondition(actionVisible, row.values),
|
|
738
739
|
}),
|
|
739
740
|
};
|
|
740
741
|
}
|
|
741
742
|
if (dispatcher === undefined) return null;
|
|
742
743
|
if (action.kind !== "writeHandler" && action.kind !== undefined) return null;
|
|
743
744
|
const writeAction = action as RowActionWriteHandler;
|
|
745
|
+
const writeActionVisible = writeAction.visible;
|
|
744
746
|
return {
|
|
745
747
|
id: writeAction.id,
|
|
746
748
|
label: effectiveTranslate(writeAction.label),
|
|
@@ -769,8 +771,8 @@ function EntityListBody({
|
|
|
769
771
|
}
|
|
770
772
|
},
|
|
771
773
|
isVisible:
|
|
772
|
-
|
|
773
|
-
? (row: ListRowViewModel) => evalFieldCondition(
|
|
774
|
+
writeActionVisible !== undefined
|
|
775
|
+
? (row: ListRowViewModel) => evalFieldCondition(writeActionVisible, row.values)
|
|
774
776
|
: undefined,
|
|
775
777
|
};
|
|
776
778
|
})
|
|
@@ -6,6 +6,8 @@ import type {
|
|
|
6
6
|
import type {
|
|
7
7
|
ListColumnViewModel,
|
|
8
8
|
ListRowViewModel,
|
|
9
|
+
ListViewModel,
|
|
10
|
+
RuntimeRenderer,
|
|
9
11
|
Translate,
|
|
10
12
|
} from "@cosmicdrift/kumiko-headless";
|
|
11
13
|
import { computeListViewModel } from "@cosmicdrift/kumiko-headless";
|
|
@@ -185,7 +187,7 @@ export function RenderList(props: RenderListProps): ReactNode {
|
|
|
185
187
|
return { ...prev, [field]: map };
|
|
186
188
|
});
|
|
187
189
|
}, []);
|
|
188
|
-
const enrichedColumns = useMemo(() => {
|
|
190
|
+
const enrichedColumns = useMemo((): readonly ListColumnViewModel[] => {
|
|
189
191
|
if (referenceColumns.length === 0) return vm.columns;
|
|
190
192
|
return vm.columns.map((col: ListColumnViewModel) => {
|
|
191
193
|
if (col.type !== "reference") return col;
|
|
@@ -194,7 +196,10 @@ export function RenderList(props: RenderListProps): ReactNode {
|
|
|
194
196
|
if (col.renderer !== undefined) return col;
|
|
195
197
|
const map = referenceLookups[col.field];
|
|
196
198
|
const labelField = col.refLabelField ?? "id";
|
|
197
|
-
const renderer = (
|
|
199
|
+
const renderer: RuntimeRenderer = (
|
|
200
|
+
value: unknown,
|
|
201
|
+
row?: Readonly<Record<string, unknown>>,
|
|
202
|
+
): string => {
|
|
198
203
|
// Tier 2.7e Server-Eagerload: wenn der Server _refs mit-
|
|
199
204
|
// schickt, lesen wir den Display-Wert direkt aus der
|
|
200
205
|
// resolved Row — kein Roundtrip durch die Bridge-Map nötig
|
|
@@ -221,7 +226,13 @@ export function RenderList(props: RenderListProps): ReactNode {
|
|
|
221
226
|
return { ...col, renderer };
|
|
222
227
|
});
|
|
223
228
|
}, [vm.columns, referenceColumns, referenceLookups]);
|
|
224
|
-
const enrichedVm = useMemo(
|
|
229
|
+
const enrichedVm = useMemo(
|
|
230
|
+
(): Omit<ListViewModel, "columns"> & { columns: readonly ListColumnViewModel[] } => ({
|
|
231
|
+
...vm,
|
|
232
|
+
columns: enrichedColumns,
|
|
233
|
+
}),
|
|
234
|
+
[vm, enrichedColumns],
|
|
235
|
+
);
|
|
225
236
|
|
|
226
237
|
// i18n-Defaults für Toolbar/Empty-State Strings — Caller kann jeden
|
|
227
238
|
// einzeln per Prop überschreiben, sonst kommen die Framework-Bundles
|
package/src/index.ts
CHANGED
package/src/primitives.tsx
CHANGED
|
@@ -38,6 +38,7 @@ import type {
|
|
|
38
38
|
FieldIssue,
|
|
39
39
|
ListColumnViewModel,
|
|
40
40
|
ListRowViewModel,
|
|
41
|
+
RuntimeRenderer,
|
|
41
42
|
} from "@cosmicdrift/kumiko-headless";
|
|
42
43
|
import {
|
|
43
44
|
type ComponentType,
|
|
@@ -47,6 +48,8 @@ import {
|
|
|
47
48
|
useContext,
|
|
48
49
|
} from "react";
|
|
49
50
|
|
|
51
|
+
export type { RuntimeRenderer };
|
|
52
|
+
|
|
50
53
|
// ---- Prop-Types (die Primitive-Contract-Oberfläche) ----
|
|
51
54
|
|
|
52
55
|
/** Standard-Button. `loading` zeigt einen Spinner statt der Children
|