@cosmicdrift/kumiko-headless 0.232.0 → 0.234.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.234.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.234.0",
|
|
40
40
|
"temporal-polyfill": "^0.3.2",
|
|
41
41
|
"zod": "^4.4.3"
|
|
42
42
|
},
|
|
@@ -121,6 +121,17 @@ describe("applyFormatSpec — unit (fw#2187)", () => {
|
|
|
121
121
|
);
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
+
test("mi (Meilen) geht über Intl.NumberFormat(style:'unit') genau wie km", () => {
|
|
125
|
+
expect(applyFormatSpec({ format: "unit", unit: "mi" }, 58)).toBe(
|
|
126
|
+
new Intl.NumberFormat(undefined, {
|
|
127
|
+
style: "unit",
|
|
128
|
+
unit: "mile",
|
|
129
|
+
unitDisplay: "short",
|
|
130
|
+
}).format(58),
|
|
131
|
+
);
|
|
132
|
+
expect(applyFormatSpec({ format: "unit", unit: "mi", locale: "en-US" }, 12)).toBe("12 mi");
|
|
133
|
+
});
|
|
134
|
+
|
|
124
135
|
test("m2 hat kein ECMA-402-sanktioniertes Intl-Unit (RangeError für 'square-meter') — Zahl + literales Suffix", () => {
|
|
125
136
|
expect(applyFormatSpec({ format: "unit", unit: "m2", locale: "de-DE" }, 58)).toBe("58 m²");
|
|
126
137
|
expect(applyFormatSpec({ format: "unit", unit: "m2", locale: "de-DE" }, 1234.5)).toBe(
|
|
@@ -201,7 +212,7 @@ describe("applyFormatSpec — enumOption (fw#2315)", () => {
|
|
|
201
212
|
describe("unit format keys stay in lockstep with UnitKey", () => {
|
|
202
213
|
// Mirror of packages/types/src/screen.ts UnitKey — keep lists equal without
|
|
203
214
|
// adding a kumiko-types dependency to headless.
|
|
204
|
-
const TYPE_UNIT_KEYS = ["m2", "km", "m", "kg", "percent"] as const;
|
|
215
|
+
const TYPE_UNIT_KEYS = ["m2", "km", "m", "kg", "percent", "mi"] as const;
|
|
205
216
|
test("every UnitKey formats with a non-bare number", () => {
|
|
206
217
|
for (const k of TYPE_UNIT_KEYS) {
|
|
207
218
|
expect(UNIT_FORMAT_KEYS.includes(k)).toBe(true);
|
package/src/format/index.ts
CHANGED
package/src/view-model/edit.ts
CHANGED
|
@@ -316,6 +316,7 @@ export function computeEditViewModel<
|
|
|
316
316
|
// per row — one value for the whole embedded list.
|
|
317
317
|
...(embeddedListDef !== undefined && { embeddedListCurrency: resolvedCurrency }),
|
|
318
318
|
...(fieldDef.type === "money" && { currency: resolvedCurrency }),
|
|
319
|
+
...(fieldDef.type === "number" && fieldDef.unit !== undefined && { unit: fieldDef.unit }),
|
|
319
320
|
};
|
|
320
321
|
return view;
|
|
321
322
|
});
|
|
@@ -332,6 +333,7 @@ export function computeEditViewModel<
|
|
|
332
333
|
}),
|
|
333
334
|
columns: sectionSpec.columns ?? 1,
|
|
334
335
|
fields,
|
|
336
|
+
...(sectionSpec.icon !== undefined && { icon: sectionSpec.icon }),
|
|
335
337
|
};
|
|
336
338
|
});
|
|
337
339
|
|
package/src/view-model/types.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
EditSectionSpec,
|
|
4
4
|
FieldIconKey,
|
|
5
5
|
FieldRenderer,
|
|
6
|
+
IconKey,
|
|
6
7
|
ListColumnSpec,
|
|
7
8
|
PlatformComponent,
|
|
8
9
|
ScreenSlots,
|
|
@@ -234,6 +235,10 @@ export type EditFieldViewModel = {
|
|
|
234
235
|
* falls back to "EUR"). The renderer needs this to build the payload's
|
|
235
236
|
* `{amount, currency}` shape (kumiko-framework#1923). */
|
|
236
237
|
readonly currency?: string;
|
|
238
|
+
/** Only set for `type: "number"` when NumberFieldDef.unit is set — a static
|
|
239
|
+
* suffix string, or a sibling-field reference the renderer resolves against
|
|
240
|
+
* the live row values. Display-only, never converts the stored number. */
|
|
241
|
+
readonly unit?: string | { readonly field: string };
|
|
237
242
|
};
|
|
238
243
|
|
|
239
244
|
// Discriminated by `kind` — mirrors EditSectionSpec on the engine side.
|
|
@@ -257,6 +262,9 @@ export type EditFieldsSectionViewModel = {
|
|
|
257
262
|
readonly description?: string;
|
|
258
263
|
readonly columns: number;
|
|
259
264
|
readonly fields: readonly EditFieldViewModel[];
|
|
265
|
+
/** From `EditFieldsSection.icon` — closed IconKey vocabulary, renders
|
|
266
|
+
* left of the title. No effect without `title`. */
|
|
267
|
+
readonly icon?: IconKey;
|
|
260
268
|
};
|
|
261
269
|
|
|
262
270
|
export type EditExtensionSectionViewModel = {
|