@cosmicdrift/kumiko-framework 0.34.1 → 0.35.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-framework",
3
- "version": "0.34.1",
3
+ "version": "0.35.0",
4
4
  "description": "Framework core — engine, pipeline, API, DB, and every other bit that makes Kumiko go.",
5
5
  "license": "BUSL-1.1",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -213,7 +213,9 @@ export type {
213
213
  EntityEditScreenDefinition,
214
214
  EntityListScreenDefinition,
215
215
  FieldCondition,
216
+ FieldFormatRegistry,
216
217
  FieldRenderer,
218
+ FormatSpec,
217
219
  ListColumnSpec,
218
220
  PlatformComponent,
219
221
  RowAction,
@@ -24,18 +24,31 @@ export type PlatformComponent = {
24
24
  readonly native?: unknown;
25
25
  };
26
26
 
27
+ // Built-in value formatters. Apps extend via module augmentation:
28
+ // declare module "@cosmicdrift/kumiko-framework" {
29
+ // interface FieldFormatRegistry { myFormat: { myOption?: string } }
30
+ // }
31
+ // renderer-web handles all built-in keys; unknown app-specific keys fall back
32
+ // to String(value).
33
+ export interface FieldFormatRegistry {
34
+ timestamp: Record<never, never>;
35
+ date: Record<never, never>;
36
+ boolean: { readonly trueLabel?: string; readonly falseLabel?: string };
37
+ currency: { readonly symbol?: string };
38
+ priority: { readonly emptyLabel?: string; readonly prefix?: string };
39
+ }
40
+
41
+ // Discriminated union derived from the registry — one variant per key.
42
+ // JSON-safe: no function members, survives buildAppSchema → window.__KUMIKO_SCHEMA__.
43
+ export type FormatSpec = {
44
+ [K in keyof FieldFormatRegistry]: { readonly format: K } & FieldFormatRegistry[K];
45
+ }[keyof FieldFormatRegistry];
46
+
27
47
  // Level-2 field renderer (ui-architecture.md §Renderer Customization):
28
48
  // - PlatformComponent → platform-specific component from the same feature
29
- // - string → cross-feature QN reference (resolved by the renderer)
30
- // - function inline value formatter (e.g. `v => `${v} €``)
31
- // Function-Form bekommt optional die ganze Row als 2. Argument —
32
- // nützlich für context-aware Renderer (Tier 2.7e-Eagerload nutzt das
33
- // um aus row._refs den resolved Display-Wert zu lesen). Renderer die
34
- // nur den value brauchen ignorieren das Argument einfach.
35
- export type FieldRenderer =
36
- | PlatformComponent
37
- | string
38
- | ((value: unknown, row?: Readonly<Record<string, unknown>>) => string);
49
+ // - string → cross-feature QN reference (resolved at mount-time)
50
+ // - FormatSpec declarative value formatter, JSON-safe ({ format: "timestamp" } etc.)
51
+ export type FieldRenderer = PlatformComponent | string | FormatSpec;
39
52
 
40
53
  // Declarative field-state condition. Evaluated by the renderer against the
41
54
  // current row/form values. Three forms: