@signaltree/ng-forms 7.3.2 → 7.3.4

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": "@signaltree/ng-forms",
3
- "version": "7.3.2",
3
+ "version": "7.3.4",
4
4
  "description": "Angular forms as reactive JSON. Seamless SignalTree integration with FormTree creation, validators, and form state tracking.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,12 @@
1
1
  import { DestroyRef, EventEmitter, OnInit, Signal, WritableSignal } from '@angular/core';
2
- import { AbstractControl, ControlValueAccessor, FormArray, FormGroup } from '@angular/forms';
2
+ import { AbstractControl, ControlValueAccessor, FormArray, FormControl, FormGroup } from '@angular/forms';
3
3
  import { Observable } from 'rxjs';
4
+ type ToFormControl<T> = T extends (infer U)[] ? FormArray<ToFormControl<U>> : T extends Record<string, unknown> ? FormGroup<{
5
+ [K in keyof T]: ToFormControl<T[K]>;
6
+ }> : FormControl<T>;
7
+ export type TypedFormGroup<T extends Record<string, unknown>> = FormGroup<{
8
+ [K in keyof T]: ToFormControl<T[K]>;
9
+ }>;
4
10
  import type { ISignalTree, TreeConfig, TreeNode } from '@signaltree/core';
5
11
  export type FormTreeAsyncValidatorFn<T> = (value: T) => Observable<string | null> | Promise<string | null>;
6
12
  export type EnhancedArraySignal<T> = WritableSignal<T[]> & {
@@ -35,7 +41,7 @@ export interface FormTreeOptions<T extends Record<string, unknown>> extends Tree
35
41
  export type FormTree<T extends Record<string, unknown>> = {
36
42
  state: TreeNode<T>;
37
43
  $: TreeNode<T>;
38
- form: FormGroup;
44
+ form: TypedFormGroup<T>;
39
45
  errors: WritableSignal<Record<string, string>>;
40
46
  asyncErrors: WritableSignal<Record<string, string>>;
41
47
  touched: WritableSignal<Record<string, boolean>>;