@cosmicdrift/kumiko-headless 0.48.0 → 0.50.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.48.0",
3
+ "version": "0.50.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>",
@@ -75,6 +75,25 @@ describe("computeEditViewModel", () => {
75
75
  ]);
76
76
  });
77
77
 
78
+ test("fieldLabels override the convention key per field; absent fields fall back", () => {
79
+ const vm = computeEditViewModel({
80
+ screen: editScreen(
81
+ { sections: [{ title: "Main", fields: ["customerName", "notes"] }] },
82
+ { fieldLabels: { customerName: "config:mask:customer-name" } },
83
+ ),
84
+ entity: orderEntity,
85
+ values: {},
86
+ translate,
87
+ featureName: "orders",
88
+ });
89
+
90
+ const fields = asFields(vm.sections[0]).fields;
91
+ // overridden field uses the injected i18n key (the Settings-Hub puts mask.title here)
92
+ expect(fields[0]?.label).toBe("config:mask:customer-name");
93
+ // un-overridden field stays on the `<feature>:entity:<entity>:field:<name>` convention
94
+ expect(fields[1]?.label).toBe("orders:entity:order:field:notes");
95
+ });
96
+
78
97
  test("section.columns override is respected; defaults to 1 when absent", () => {
79
98
  const vm = computeEditViewModel({
80
99
  screen: editScreen({
@@ -46,7 +46,10 @@ export function computeEditViewModel<
46
46
  `computeEditViewModel: screen "${screen.id}" references unknown field "${normalized.field}" on entity "${screen.entity}"`,
47
47
  );
48
48
  }
49
- const label = translate(fieldLabelKey(featureName, screen.entity, normalized.field));
49
+ const label = translate(
50
+ screen.fieldLabels?.[normalized.field] ??
51
+ fieldLabelKey(featureName, screen.entity, normalized.field),
52
+ );
50
53
  const visible = evalCondition(normalized.visible, true, values);
51
54
  // `readOnly` (camelCase) is the name on both sides: EditFieldSpec
52
55
  // in the engine, and the view-model emitted here. One convention