@cosmicdrift/kumiko-renderer 0.34.1 → 0.34.2

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-renderer",
3
- "version": "0.34.1",
3
+ "version": "0.34.2",
4
4
  "description": "Platform-agnostic React renderer for Kumiko screens. Contains the shared logic — primitives-contract, hooks, KumikoScreen, navigation & SSE abstractions — that any platform-specific renderer (web, native) composes. No DOM, no EventSource, no react-dom.",
5
5
  "license": "BUSL-1.1",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -29,6 +29,11 @@ export function extensionSectionName(component: PlatformComponent): string | und
29
29
  export type ExtensionSectionProps = {
30
30
  readonly entityName: string;
31
31
  readonly entityId: string | null;
32
+ /** Bereits gespeicherte Extension-Werte der Entity (aus der geladenen
33
+ * detail-row durchgereicht). `undefined` im Create-Mode oder wenn der
34
+ * Host-Screen keine Werte liefert. Erlaubt der Section, den Bestand
35
+ * beim Edit anzuzeigen statt write-only zu sein. */
36
+ readonly initialValues?: Readonly<Record<string, unknown>>;
32
37
  };
33
38
 
34
39
  export type ExtensionSectionComponent = ComponentType<ExtensionSectionProps>;
@@ -421,6 +421,15 @@ function EntityEditUpdateForm({
421
421
  return out as FormValues;
422
422
  }, [entity.fields, record]);
423
423
 
424
+ // Extension-Werte (z.B. customFields-jsonb) an extension-sections geben,
425
+ // damit sie beim Edit den Bestand zeigen statt write-only zu sein.
426
+ const extensionInitialValues = useMemo((): Readonly<Record<string, unknown>> | undefined => {
427
+ const cf = record["customFields"];
428
+ return cf !== null && typeof cf === "object" && !Array.isArray(cf)
429
+ ? (cf as Record<string, unknown>)
430
+ : undefined;
431
+ }, [record]);
432
+
424
433
  const writeCommand = entityWriteCommand(schema.featureName, screen.entity, "update");
425
434
  const deleteCommand = entityWriteCommand(schema.featureName, screen.entity, "delete");
426
435
  const buildPayload = useMemo(
@@ -456,6 +465,9 @@ function EntityEditUpdateForm({
456
465
  // Update-Form lässt `id` bewusst aus den Form-values, daher braucht
457
466
  // die Section die id explizit — sonst create-mode trotz Edit.
458
467
  entityId={entityId}
468
+ // customFields-Bestand an die extension-section, damit sie beim Edit
469
+ // die gespeicherten Werte zeigt (nicht write-only).
470
+ extensionInitialValues={extensionInitialValues}
459
471
  writeCommand={writeCommand}
460
472
  payloadMode="changes"
461
473
  buildPayload={buildPayload}
@@ -42,6 +42,10 @@ export type RenderEditProps<TValues extends FormValues, TCtx = unknown> = {
42
42
  * die Section bliebe dann fälschlich im create-mode. Weglassen
43
43
  * (undefined) = create-mode / kein extension-Kontext (vm.id-Fallback). */
44
44
  readonly entityId?: string | null;
45
+ /** Bereits gespeicherte Extension-Werte (z.B. `record.customFields`) für
46
+ * extension-section-Mounts. Erlaubt der Section, den Bestand beim Edit
47
+ * anzuzeigen. Nur der Update-Body liefert das. */
48
+ readonly extensionInitialValues?: Readonly<Record<string, unknown>>;
45
49
  /** Standard single-write Submit-Pfad. Ignoriert wenn `customSubmit`
46
50
  * gesetzt ist (configEdit-Screens dispatchen mehrere Writes pro
47
51
  * Submit, da macht writeCommand keinen Sinn). */
@@ -118,10 +122,12 @@ function ExtensionSectionMount({
118
122
  section,
119
123
  entityName,
120
124
  entityId,
125
+ initialValues,
121
126
  }: {
122
127
  readonly section: EditExtensionSectionViewModel;
123
128
  readonly entityName: string;
124
129
  readonly entityId: string | null;
130
+ readonly initialValues?: Readonly<Record<string, unknown>>;
125
131
  }): ReactNode {
126
132
  const { Banner, Section, Text } = usePrimitives();
127
133
  const name = extensionSectionName(section.component);
@@ -145,7 +151,7 @@ function ExtensionSectionMount({
145
151
  }
146
152
  return (
147
153
  <Section title={section.title} testId={`section-extension-${section.title}`}>
148
- <Component entityName={entityName} entityId={entityId} />
154
+ <Component entityName={entityName} entityId={entityId} initialValues={initialValues} />
149
155
  </Section>
150
156
  );
151
157
  }
@@ -171,6 +177,7 @@ export function RenderEdit<TValues extends FormValues, TCtx = unknown>(
171
177
  submitLabel,
172
178
  fieldAppendix,
173
179
  entityId: entityIdProp,
180
+ extensionInitialValues,
174
181
  } = props;
175
182
  const { customSubmit } = props;
176
183
  // Translate-Fallback: wenn der Caller keine Translate-Fn übergibt,
@@ -331,6 +338,7 @@ export function RenderEdit<TValues extends FormValues, TCtx = unknown>(
331
338
  section={section}
332
339
  entityName={vm.entityName}
333
340
  entityId={entityIdProp !== undefined ? entityIdProp : vm.id}
341
+ initialValues={extensionInitialValues}
334
342
  />
335
343
  );
336
344
  }