@cosmicdrift/kumiko-headless 0.167.1 → 0.170.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-headless",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.170.0",
|
|
4
4
|
"description": "Headless UI logic for Kumiko — Dispatcher contract, Form-Controller, View-Model, Nav-Resolver. Plattform- und React-frei; jeder Renderer (renderer, renderer-web, renderer-native, …) komponiert darauf.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@cosmicdrift/kumiko-framework": "0.
|
|
39
|
+
"@cosmicdrift/kumiko-framework": "0.170.0",
|
|
40
40
|
"temporal-polyfill": "^0.3.2",
|
|
41
41
|
"zod": "^4.4.3"
|
|
42
42
|
},
|
|
@@ -19,6 +19,7 @@ const orderEntity = {
|
|
|
19
19
|
notes: { type: "text" },
|
|
20
20
|
vatExempt: { type: "boolean" },
|
|
21
21
|
vatReason: { type: "text" },
|
|
22
|
+
kind: { type: "text" },
|
|
22
23
|
},
|
|
23
24
|
} as unknown as EntityDefinition;
|
|
24
25
|
|
|
@@ -152,6 +153,34 @@ describe("computeEditViewModel", () => {
|
|
|
152
153
|
expect(reasonShown?.required).toBe(true);
|
|
153
154
|
});
|
|
154
155
|
|
|
156
|
+
test("section with all fields hidden by visible condition → section.visible is false but section stays in the array (key stability)", () => {
|
|
157
|
+
const screen = editScreen({
|
|
158
|
+
sections: [
|
|
159
|
+
{
|
|
160
|
+
title: "Person",
|
|
161
|
+
fields: [{ field: "customerName", visible: { field: "kind", eq: "person" } }],
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
title: "Firma",
|
|
165
|
+
fields: [{ field: "notes", visible: { field: "kind", eq: "company" } }],
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const vm = computeEditViewModel({
|
|
171
|
+
screen,
|
|
172
|
+
entity: orderEntity,
|
|
173
|
+
values: { kind: "person", customerName: "Acme" },
|
|
174
|
+
translate,
|
|
175
|
+
featureName: "orders",
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
expect(vm.sections).toHaveLength(2);
|
|
179
|
+
expect(asFields(vm.sections[0]).visible).toBe(true);
|
|
180
|
+
expect(asFields(vm.sections[1]).visible).toBe(false);
|
|
181
|
+
expect(vm.sections[1]?.title).toBe("Firma");
|
|
182
|
+
});
|
|
183
|
+
|
|
155
184
|
test("readonly condition { field, ne } evaluates against form values", () => {
|
|
156
185
|
const screen = editScreen({
|
|
157
186
|
sections: [
|
package/src/view-model/edit.ts
CHANGED
|
@@ -154,8 +154,12 @@ export function computeEditViewModel<
|
|
|
154
154
|
};
|
|
155
155
|
return view;
|
|
156
156
|
});
|
|
157
|
+
// Boot-validator rejects fields.length === 0 (screens.ts), so an empty
|
|
158
|
+
// section never reaches this code.
|
|
159
|
+
const visible = fields.some((field) => field.visible);
|
|
157
160
|
return {
|
|
158
161
|
kind: "fields" as const,
|
|
162
|
+
visible,
|
|
159
163
|
// Titellose Section (flache Form) → kein h3; nur übersetzen wenn gesetzt.
|
|
160
164
|
...(sectionSpec.title !== undefined && { title: translate(sectionSpec.title) }),
|
|
161
165
|
columns: sectionSpec.columns ?? 1,
|
package/src/view-model/types.ts
CHANGED
|
@@ -152,6 +152,10 @@ export type EditSectionViewModel = EditFieldsSectionViewModel | EditExtensionSec
|
|
|
152
152
|
|
|
153
153
|
export type EditFieldsSectionViewModel = {
|
|
154
154
|
readonly kind: "fields";
|
|
155
|
+
/** False when the section has fields but none of them is visible.
|
|
156
|
+
* The renderer then draws nothing, but the section stays in the array
|
|
157
|
+
* (key stability). */
|
|
158
|
+
readonly visible: boolean;
|
|
155
159
|
/** Optional — eine titellose Section rendert nur ihre Felder (flache Form). */
|
|
156
160
|
readonly title?: string;
|
|
157
161
|
readonly columns: number;
|