@cosmicdrift/kumiko-headless 0.330.2 → 0.331.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/dist/index.d.ts CHANGED
@@ -11,4 +11,4 @@ export { resolveNavigation } from "./nav/index.js";
11
11
  export type { Store, WritableStore } from "./store/index.js";
12
12
  export { createStore, shallowEqual } from "./store/index.js";
13
13
  export type { ComputeEditViewModelInput, ComputeListViewModelInput, DerivedCellRoundingTarget, EditExtensionSectionViewModel, EditFieldSpec, EditFieldsSectionViewModel, EditFieldViewModel, EditRelatedListSectionViewModel, EditSectionSpec, EditSectionViewModel, EditViewModel, EditWriteFormSectionViewModel, EmbeddedDerivedOp, EmbeddedListCellViewModel, EmbeddedListIssueGroups, FieldConditionCtx, FieldRenderer, ListColumnSpec, ListColumnViewModel, ListRowViewModel, ListViewModel, RuntimeRenderer, ScreenSlots, Translate, } from "./view-model/index.js";
14
- export { computeDerivedCellValue, computeEditViewModel, computeListViewModel, embeddedCellLabelKey, embeddedCellOptionLabelKey, fieldLabelKey, fieldOptionLabelKey, fieldOptionLabelKeyPrefix, groupEmbeddedListIssues, roundDerivedCellValue, sumEmbeddedListColumn, } from "./view-model/index.js";
14
+ export { computeDerivedCellValue, computeEditViewModel, computeListViewModel, computeRelatedListSectionViewModel, embeddedCellLabelKey, embeddedCellOptionLabelKey, fieldLabelKey, fieldOptionLabelKey, fieldOptionLabelKeyPrefix, groupEmbeddedListIssues, roundDerivedCellValue, sumEmbeddedListColumn, } from "./view-model/index.js";
package/dist/index.js CHANGED
@@ -6,4 +6,4 @@ export { createFormController, I18N_KEY_PARAM } from "./form/index.js";
6
6
  export { applyFormatSpec, currencyDecimals, escapeHtml, escapeHtmlAttr, escapeXml, html, isSafeHref, RawHtml, raw, stripControlChars, toInstant, } from "./format/index.js";
7
7
  export { resolveNavigation } from "./nav/index.js";
8
8
  export { createStore, shallowEqual } from "./store/index.js";
9
- export { computeDerivedCellValue, computeEditViewModel, computeListViewModel, embeddedCellLabelKey, embeddedCellOptionLabelKey, fieldLabelKey, fieldOptionLabelKey, fieldOptionLabelKeyPrefix, groupEmbeddedListIssues, roundDerivedCellValue, sumEmbeddedListColumn, } from "./view-model/index.js";
9
+ export { computeDerivedCellValue, computeEditViewModel, computeListViewModel, computeRelatedListSectionViewModel, embeddedCellLabelKey, embeddedCellOptionLabelKey, fieldLabelKey, fieldOptionLabelKey, fieldOptionLabelKeyPrefix, groupEmbeddedListIssues, roundDerivedCellValue, sumEmbeddedListColumn, } from "./view-model/index.js";
@@ -1,5 +1,5 @@
1
- import type { EntityDefinition, EntityEditScreenDefinition } from "@cosmicdrift/kumiko-framework/ui-types";
2
- import type { EditViewModel, Translate } from "./types.js";
1
+ import type { EditRelatedListSection, EntityDefinition, EntityEditScreenDefinition } from "@cosmicdrift/kumiko-framework/ui-types";
2
+ import type { EditRelatedListSectionViewModel, EditViewModel, Translate } from "./types.js";
3
3
  export type ComputeEditViewModelInput<TValues extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>> = {
4
4
  readonly screen: EntityEditScreenDefinition;
5
5
  readonly entity: EntityDefinition;
@@ -7,4 +7,5 @@ export type ComputeEditViewModelInput<TValues extends Readonly<Record<string, un
7
7
  readonly translate: Translate;
8
8
  readonly featureName: string;
9
9
  };
10
+ export declare function computeRelatedListSectionViewModel(sectionSpec: EditRelatedListSection, translate: Translate): EditRelatedListSectionViewModel;
10
11
  export declare function computeEditViewModel<TValues extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>>(input: ComputeEditViewModelInput<TValues>): EditViewModel;
@@ -44,7 +44,7 @@ function computeWriteFormSectionViewModel(sectionSpec, screenId, values, transla
44
44
  }
45
45
  // relatedList runs its own query — nothing here to resolve against
46
46
  // entity/values, the spec passes through verbatim (fw#2166).
47
- function computeRelatedListSectionViewModel(sectionSpec, translate) {
47
+ export function computeRelatedListSectionViewModel(sectionSpec, translate) {
48
48
  return {
49
49
  kind: "relatedList",
50
50
  title: translate(sectionSpec.title),
@@ -52,6 +52,7 @@ function computeRelatedListSectionViewModel(sectionSpec, translate) {
52
52
  ...(sectionSpec.parentParam !== undefined && { parentParam: sectionSpec.parentParam }),
53
53
  ...(sectionSpec.parentFilter !== undefined && { parentFilter: sectionSpec.parentFilter }),
54
54
  columns: sectionSpec.columns,
55
+ ...(sectionSpec.entity !== undefined && { entity: sectionSpec.entity }),
55
56
  ...(sectionSpec.description !== undefined && {
56
57
  description: translate(sectionSpec.description),
57
58
  }),
@@ -80,6 +81,16 @@ function computeRelatedListSectionViewModel(sectionSpec, translate) {
80
81
  }),
81
82
  };
82
83
  }
84
+ function deriveSelectOptionsQuery(fieldDef) {
85
+ return fieldDef.type === "select" && fieldDef.optionsQuery !== undefined
86
+ ? {
87
+ selectOptionsQuery: {
88
+ query: fieldDef.optionsQuery,
89
+ payload: fieldDef.optionsQueryPayload ?? {},
90
+ },
91
+ }
92
+ : {};
93
+ }
83
94
  function deriveSelectFieldHints(fieldDef, translate, featureName, entityName, fieldName) {
84
95
  const options = fieldDef.type === "select" || fieldDef.type === "multiSelect"
85
96
  ? (fieldDef.options ?? [])
@@ -91,6 +102,7 @@ function deriveSelectFieldHints(fieldDef, translate, featureName, entityName, fi
91
102
  const columns = fieldDef.type === "multiSelect" ? fieldDef.columns : undefined;
92
103
  const maxRows = fieldDef.type === "multiSelect" ? fieldDef.maxRows : undefined;
93
104
  return {
105
+ ...deriveSelectOptionsQuery(fieldDef),
94
106
  ...(options !== undefined && { options }),
95
107
  ...(optionLabels !== undefined && { optionLabels }),
96
108
  ...(display !== undefined && { display }),
@@ -1,5 +1,5 @@
1
1
  export type { ComputeEditViewModelInput } from "./edit.js";
2
- export { computeEditViewModel } from "./edit.js";
2
+ export { computeEditViewModel, computeRelatedListSectionViewModel } from "./edit.js";
3
3
  export type { DerivedCellRoundingTarget, EmbeddedDerivedOp, EmbeddedListIssueGroups, } from "./embedded-list.js";
4
4
  export { computeDerivedCellValue, groupEmbeddedListIssues, roundDerivedCellValue, sumEmbeddedListColumn, } from "./embedded-list.js";
5
5
  export type { ComputeListViewModelInput } from "./list.js";
@@ -1,3 +1,3 @@
1
- export { computeEditViewModel } from "./edit.js";
1
+ export { computeEditViewModel, computeRelatedListSectionViewModel } from "./edit.js";
2
2
  export { computeDerivedCellValue, groupEmbeddedListIssues, roundDerivedCellValue, sumEmbeddedListColumn, } from "./embedded-list.js";
3
3
  export { computeListViewModel, embeddedCellLabelKey, embeddedCellOptionLabelKey, fieldLabelKey, fieldOptionLabelKey, fieldOptionLabelKeyPrefix, } from "./list.js";
@@ -84,6 +84,14 @@ export type EditFieldViewModel = {
84
84
  * raw value. Convention key:
85
85
  * `<feature>:entity:<entity>:field:<field>:option:<value>`. */
86
86
  readonly optionLabels?: Readonly<Record<string, string>>;
87
+ /** Set for `type: "select"` when SelectFieldDef.optionsQuery is set: the
88
+ * renderer loads the options from this query (`{ rows: { value, label }[] }`,
89
+ * labels verbatim) instead of `options`. `payload` is the static
90
+ * optionsQueryPayload, `{}` when absent. */
91
+ readonly selectOptionsQuery?: {
92
+ readonly query: string;
93
+ readonly payload: Readonly<Record<string, string | number | boolean>>;
94
+ };
87
95
  /** Set for `type: "multiSelect"` when MultiSelectFieldDef.display is
88
96
  * "checkboxes" — the renderer shows a checkbox grid with a select-all
89
97
  * toggle instead of the default combobox dropdown. Set for
@@ -251,6 +259,7 @@ export type EditRelatedListSectionViewModel = {
251
259
  readonly field: string;
252
260
  };
253
261
  readonly columns: readonly ListColumnSpec[];
262
+ readonly entity?: string;
254
263
  readonly description?: string;
255
264
  /** Untranslated plural-forms key, resolved with the row count by the list footer. */
256
265
  readonly itemNoun?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-headless",
3
- "version": "0.330.2",
3
+ "version": "0.331.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.330.2",
39
+ "@cosmicdrift/kumiko-framework": "0.331.0",
40
40
  "temporal-polyfill": "^0.3.2",
41
41
  "zod": "^4.4.3"
42
42
  },