@cosmicdrift/kumiko-headless 0.250.0 → 0.251.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.250.0",
3
+ "version": "0.251.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.250.0",
39
+ "@cosmicdrift/kumiko-framework": "0.251.0",
40
40
  "temporal-polyfill": "^0.3.2",
41
41
  "zod": "^4.4.3"
42
42
  },
@@ -794,6 +794,59 @@ describe("computeEditViewModel — relatedList rowActions passthrough (fw editab
794
794
  });
795
795
  });
796
796
 
797
+ describe("computeEditViewModel — relatedList searchable/facets passthrough (fw#2740)", () => {
798
+ test("searchable and facets pass through onto the relatedList section view-model untranslated", () => {
799
+ const facets = [
800
+ {
801
+ field: "status",
802
+ type: "select" as const,
803
+ label: "app:facet.status.label",
804
+ options: [{ value: "active", label: "app:facet.status.active" }],
805
+ },
806
+ ];
807
+ const vm = computeEditViewModel({
808
+ screen: editScreen({
809
+ sections: [
810
+ {
811
+ kind: "relatedList",
812
+ title: "History",
813
+ query: "app:query:history",
814
+ columns: ["name", "status"],
815
+ searchable: true,
816
+ facets,
817
+ },
818
+ ],
819
+ }),
820
+ entity: orderEntity,
821
+ values: {},
822
+ translate,
823
+ featureName: "orders",
824
+ });
825
+
826
+ const section = asRelatedList(vm.sections[0]);
827
+ expect(section.searchable).toBe(true);
828
+ expect(section.facets).toEqual(facets);
829
+ });
830
+
831
+ test("searchable and facets are absent from the view-model when the section spec has none", () => {
832
+ const vm = computeEditViewModel({
833
+ screen: editScreen({
834
+ sections: [
835
+ { kind: "relatedList", title: "History", query: "app:query:history", columns: ["name"] },
836
+ ],
837
+ }),
838
+ entity: orderEntity,
839
+ values: {},
840
+ translate,
841
+ featureName: "orders",
842
+ });
843
+
844
+ const section = asRelatedList(vm.sections[0]);
845
+ expect(section.searchable).toBeUndefined();
846
+ expect(section.facets).toBeUndefined();
847
+ });
848
+ });
849
+
797
850
  describe("computeEditViewModel — writeForm sections (fw editable-detail-screens)", () => {
798
851
  test("resolves the section's own fieldDefs/fields through the same per-field pipeline as a fields section", () => {
799
852
  const vm = computeEditViewModel({
@@ -1,4 +1,5 @@
1
1
  import type {
2
+ EditRelatedListSection,
2
3
  EditWriteFormSection,
3
4
  EntityDefinition,
4
5
  EntityEditScreenDefinition,
@@ -22,6 +23,7 @@ import {
22
23
  } from "./list";
23
24
  import type {
24
25
  EditFieldViewModel,
26
+ EditRelatedListSectionViewModel,
25
27
  EditSectionViewModel,
26
28
  EditViewModel,
27
29
  EditWriteFormSectionViewModel,
@@ -110,6 +112,27 @@ function computeWriteFormSectionViewModel<TValues extends Readonly<Record<string
110
112
  };
111
113
  }
112
114
 
115
+ // relatedList runs its own query — nothing here to resolve against
116
+ // entity/values, the spec passes through verbatim (fw#2166).
117
+ function computeRelatedListSectionViewModel(
118
+ sectionSpec: EditRelatedListSection,
119
+ translate: Translate,
120
+ ): EditRelatedListSectionViewModel {
121
+ return {
122
+ kind: "relatedList" as const,
123
+ title: translate(sectionSpec.title),
124
+ query: sectionSpec.query,
125
+ ...(sectionSpec.parentParam !== undefined && { parentParam: sectionSpec.parentParam }),
126
+ columns: sectionSpec.columns,
127
+ ...(sectionSpec.pageSize !== undefined && { pageSize: sectionSpec.pageSize }),
128
+ ...(sectionSpec.defaultSort !== undefined && { defaultSort: sectionSpec.defaultSort }),
129
+ ...(sectionSpec.searchable !== undefined && { searchable: sectionSpec.searchable }),
130
+ ...(sectionSpec.facets !== undefined && { facets: sectionSpec.facets }),
131
+ ...(sectionSpec.rowClick !== undefined && { rowClick: sectionSpec.rowClick }),
132
+ ...(sectionSpec.rowActions !== undefined && { rowActions: sectionSpec.rowActions }),
133
+ };
134
+ }
135
+
113
136
  // Pure transform from screen-def + entity-def + row-values to the flat
114
137
  // section/field tree the renderer draws. FieldConditions are evaluated here
115
138
  // so the renderer never re-runs them during React render.
@@ -138,19 +161,7 @@ export function computeEditViewModel<
138
161
  );
139
162
  }
140
163
  if (!isFieldsEditSection(sectionSpec)) {
141
- // relatedList runs its own query — nothing here to resolve against
142
- // entity/values, the spec passes through verbatim (fw#2166).
143
- return {
144
- kind: "relatedList" as const,
145
- title: translate(sectionSpec.title),
146
- query: sectionSpec.query,
147
- ...(sectionSpec.parentParam !== undefined && { parentParam: sectionSpec.parentParam }),
148
- columns: sectionSpec.columns,
149
- ...(sectionSpec.pageSize !== undefined && { pageSize: sectionSpec.pageSize }),
150
- ...(sectionSpec.defaultSort !== undefined && { defaultSort: sectionSpec.defaultSort }),
151
- ...(sectionSpec.rowClick !== undefined && { rowClick: sectionSpec.rowClick }),
152
- ...(sectionSpec.rowActions !== undefined && { rowActions: sectionSpec.rowActions }),
153
- };
164
+ return computeRelatedListSectionViewModel(sectionSpec, translate);
154
165
  }
155
166
  const fields: EditFieldViewModel[] = sectionSpec.fields.map((fieldSpec) => {
156
167
  const normalized = normalizeEditField(fieldSpec);
@@ -5,6 +5,7 @@ import type {
5
5
  FieldRenderer,
6
6
  IconKey,
7
7
  ListColumnSpec,
8
+ ListFacetSpec,
8
9
  ListSortSpec,
9
10
  PlatformComponent,
10
11
  RowAction,
@@ -292,6 +293,8 @@ export type EditRelatedListSectionViewModel = {
292
293
  readonly columns: readonly ListColumnSpec[];
293
294
  readonly pageSize?: number;
294
295
  readonly defaultSort?: ListSortSpec;
296
+ readonly searchable?: boolean;
297
+ readonly facets?: readonly ListFacetSpec[];
295
298
  readonly rowClick?: { readonly entity: string; readonly idColumn?: string };
296
299
  readonly rowActions?: readonly RowAction[];
297
300
  };