@cosmicdrift/kumiko-headless 0.186.2 → 0.187.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.187.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.187.0",
|
|
40
40
|
"temporal-polyfill": "^0.3.2",
|
|
41
41
|
"zod": "^4.4.3"
|
|
42
42
|
},
|
package/src/index.ts
CHANGED
|
@@ -79,6 +79,7 @@ export { createStore, shallowEqual } from "./store";
|
|
|
79
79
|
export type {
|
|
80
80
|
ComputeEditViewModelInput,
|
|
81
81
|
ComputeListViewModelInput,
|
|
82
|
+
DerivedCellRoundingTarget,
|
|
82
83
|
EditExtensionSectionViewModel,
|
|
83
84
|
EditFieldSpec,
|
|
84
85
|
EditFieldsSectionViewModel,
|
|
@@ -107,5 +108,6 @@ export {
|
|
|
107
108
|
embeddedCellOptionLabelKey,
|
|
108
109
|
fieldLabelKey,
|
|
109
110
|
groupEmbeddedListIssues,
|
|
111
|
+
roundDerivedCellValue,
|
|
110
112
|
sumEmbeddedListColumn,
|
|
111
113
|
} from "./view-model";
|
|
@@ -3,6 +3,7 @@ import type { FieldIssue } from "../../dispatcher";
|
|
|
3
3
|
import {
|
|
4
4
|
computeDerivedCellValue,
|
|
5
5
|
groupEmbeddedListIssues,
|
|
6
|
+
roundDerivedCellValue,
|
|
6
7
|
sumEmbeddedListColumn,
|
|
7
8
|
} from "../embedded-list";
|
|
8
9
|
|
|
@@ -40,6 +41,17 @@ describe("computeDerivedCellValue", () => {
|
|
|
40
41
|
});
|
|
41
42
|
});
|
|
42
43
|
|
|
44
|
+
describe("roundDerivedCellValue", () => {
|
|
45
|
+
test("rounds a money target to whole minor units, kaufmännisch", () => {
|
|
46
|
+
expect(roundDerivedCellValue(2307.58, { type: "money" })).toBe(2308);
|
|
47
|
+
expect(roundDerivedCellValue(-2307.5, { type: "money" })).toBe(-2308);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("leaves a number target unrounded", () => {
|
|
51
|
+
expect(roundDerivedCellValue(1.5, { type: "number" })).toBe(1.5);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
43
55
|
describe("sumEmbeddedListColumn", () => {
|
|
44
56
|
test("sums a numeric column across rows", () => {
|
|
45
57
|
const rows = [{ amount: 100 }, { amount: 250 }, { amount: 50 }];
|
package/src/view-model/edit.ts
CHANGED
|
@@ -44,6 +44,7 @@ type EmbeddedSubFieldShape = {
|
|
|
44
44
|
readonly options?: readonly string[];
|
|
45
45
|
readonly entity?: string;
|
|
46
46
|
readonly labelField?: string;
|
|
47
|
+
readonly scale?: number;
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
export type ComputeEditViewModelInput<
|
|
@@ -224,6 +225,8 @@ export function computeEditViewModel<
|
|
|
224
225
|
...(cellRefTarget !== undefined && { refFeature: cellRefTarget.featureName }),
|
|
225
226
|
...(subField.type === "reference" &&
|
|
226
227
|
subField.labelField !== undefined && { refLabelField: subField.labelField }),
|
|
228
|
+
...(subField.type === "decimal" &&
|
|
229
|
+
subField.scale !== undefined && { scale: subField.scale }),
|
|
227
230
|
};
|
|
228
231
|
return cell;
|
|
229
232
|
})
|
|
@@ -2,9 +2,13 @@ import type { FieldIssue } from "../dispatcher";
|
|
|
2
2
|
|
|
3
3
|
export type EmbeddedDerivedOp = "multiply" | "sum" | "subtract";
|
|
4
4
|
|
|
5
|
+
export type { DerivedCellRoundingTarget } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
5
6
|
// Canonical implementation moved to packages/framework/src/engine/embedded-derived.ts
|
|
6
7
|
// (the write-schema preprocess needs it server-side too).
|
|
7
|
-
export {
|
|
8
|
+
export {
|
|
9
|
+
computeDerivedCellValue,
|
|
10
|
+
roundDerivedCellValue,
|
|
11
|
+
} from "@cosmicdrift/kumiko-framework/ui-types";
|
|
8
12
|
|
|
9
13
|
/** Sums a numeric/money/decimal column across all rows. Non-numeric or
|
|
10
14
|
* missing values count as 0. Money columns are minor-unit integers —
|
package/src/view-model/index.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
export type { ComputeEditViewModelInput } from "./edit";
|
|
2
2
|
export { computeEditViewModel } from "./edit";
|
|
3
|
-
export type {
|
|
3
|
+
export type {
|
|
4
|
+
DerivedCellRoundingTarget,
|
|
5
|
+
EmbeddedDerivedOp,
|
|
6
|
+
EmbeddedListIssueGroups,
|
|
7
|
+
} from "./embedded-list";
|
|
4
8
|
export {
|
|
5
9
|
computeDerivedCellValue,
|
|
6
10
|
groupEmbeddedListIssues,
|
|
11
|
+
roundDerivedCellValue,
|
|
7
12
|
sumEmbeddedListColumn,
|
|
8
13
|
} from "./embedded-list";
|
|
9
14
|
export type { ComputeListViewModelInput } from "./list";
|
package/src/view-model/types.ts
CHANGED
|
@@ -56,6 +56,11 @@ export type ListColumnViewModel = {
|
|
|
56
56
|
/** Nur bei `type: "reference"` — Welches Feld der referenced Entity
|
|
57
57
|
* als Display-Wert in der Cell erscheint (Default "id"). */
|
|
58
58
|
readonly refLabelField?: string;
|
|
59
|
+
/** Set by the caller at runtime (not schema-derived) to emphasize one
|
|
60
|
+
* column — e.g. the currently selected base-year column in a
|
|
61
|
+
* multi-year statement grid. DataTable renders it with a distinct
|
|
62
|
+
* header/cell background. */
|
|
63
|
+
readonly highlighted?: boolean;
|
|
59
64
|
};
|
|
60
65
|
|
|
61
66
|
export type ListRowViewModel = {
|
|
@@ -100,6 +105,8 @@ export type EmbeddedListCellViewModel = {
|
|
|
100
105
|
readonly refEntity?: string;
|
|
101
106
|
readonly refFeature?: string;
|
|
102
107
|
readonly refLabelField?: string;
|
|
108
|
+
/** Only for `type: "decimal"`. */
|
|
109
|
+
readonly scale?: number;
|
|
103
110
|
};
|
|
104
111
|
|
|
105
112
|
// Resolved field — all predicates evaluated, labels translated. The
|