ng-form-foundry 0.3.1 → 0.3.3

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/index.d.ts CHANGED
@@ -206,9 +206,10 @@ type DFormGroup<T extends NodeGroup> = FormGroup<FormGroupType<T>>;
206
206
  declare function caseFields(body: ChoiceCase): Record<string, NodeType>;
207
207
  /**
208
208
  * The active case of a choice: an explicit `__case` in the initial value, else
209
- * the case whose fields best match the initial data (inline wire data carries no
210
- * `__case`), else the schema `default`. This lets a choice seed from real
211
- * instance data whose branch is discriminated by which fields are present.
209
+ * the case {@link inferChoiceCase} ranks best against the initial data (inline
210
+ * wire data carries no `__case`), else the schema `default`. This lets a choice
211
+ * seed from real instance data whose branch is discriminated by which fields
212
+ * are present and required.
212
213
  */
213
214
  declare function resolveChoiceCase(choice: NodeChoice, initial?: Record<string, unknown> | null): string | undefined;
214
215
  /**
@@ -275,6 +276,27 @@ declare function buildControl<T extends NodeType>(node: T, initial?: unknown | n
275
276
  * names and value types.
276
277
  */
277
278
  declare function buildFormFromSchema<S extends NodeGroup>(schema: S, initial?: Record<string, unknown> | null): DFormGroup<S>;
279
+ /**
280
+ * The wire value at `node`: `value` rebuilt with every choice discriminator
281
+ * removed.
282
+ *
283
+ * A choice's form value is `{ __case, ...fields }` ({@link CASE_KEY}); its wire
284
+ * encoding is the active case's fields inline, with no discriminator — the case
285
+ * is recovered from the field shape when the data is seeded back in
286
+ * ({@link resolveChoiceCase}). The walk is schema-driven: only positions the
287
+ * schema declares as choices are stripped, so a group child or map entry that
288
+ * happens to be named `__case` passes through untouched. Values at positions
289
+ * the schema does not describe pass through unchanged.
290
+ */
291
+ declare function toWireValue(node: NodeType, value: unknown): unknown;
292
+ /**
293
+ * Serialize a form built by {@link buildFormFromSchema} to its wire value:
294
+ * `form.getRawValue()` with every choice's {@link CASE_KEY} discriminator
295
+ * stripped (see {@link toWireValue}). The result is the inline encoding that
296
+ * `buildFormFromSchema` accepts back as `initial`, so serialize → rebuild
297
+ * round-trips the value.
298
+ */
299
+ declare function serializeForm(schema: NodeGroup, form: FormGroup): Record<string, unknown>;
278
300
  /**
279
301
  * Capture a schema literal with its exact type while checking it against
280
302
  * `NodeGroup`.
@@ -715,5 +737,5 @@ declare class NodeMapRendererComponent implements OnChanges {
715
737
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<NodeMapRendererComponent, "nff-node-map-renderer", never, { "nodeMap": { "alias": "nodeMap"; "required": false; }; "formGroup": { "alias": "formGroup"; "required": false; }; "editable": { "alias": "editable"; "required": false; }; }, {}, never, never, true, never>;
716
738
  }
717
739
 
718
- export { CASE_KEY, ConfigEditorComponent, DynamicRecursiveFormComponent, LeafEnumRendererComponent, LeafListRendererComponent, LeafRendererComponent, NodeGroupListRendererComponent, NodeMapRendererComponent, addMapEntry, buildControl, buildFormFromSchema, caseFields, defineSchema, removeMapEntry, renameMapEntry, resolveChoiceCase, switchChoiceCase };
740
+ export { CASE_KEY, ConfigEditorComponent, DynamicRecursiveFormComponent, LeafEnumRendererComponent, LeafListRendererComponent, LeafRendererComponent, NodeGroupListRendererComponent, NodeMapRendererComponent, addMapEntry, buildControl, buildFormFromSchema, caseFields, defineSchema, removeMapEntry, renameMapEntry, resolveChoiceCase, serializeForm, switchChoiceCase, toWireValue };
719
741
  export type { AnonLeaf, Appearance, ChoiceCase, DFormControl, DFormGroup, FormGroupType, Leaf, LeafBase, LeafBoolean, LeafEnum, LeafList, LeafNumber, LeafRuntimeType, LeafString, NodeChoice, NodeGroup, NodeGroupList, NodeMap, NodeType };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-form-foundry",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Build fully-typed Angular Reactive Forms and Angular Material UI from a declarative, recursive form-description schema.",
5
5
  "keywords": [
6
6
  "angular",