@angular/forms 21.0.0-next.6 → 21.0.0-next.7
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/fesm2022/forms.mjs +129 -129
- package/fesm2022/forms.mjs.map +1 -1
- package/fesm2022/signals.mjs +52 -505
- package/fesm2022/signals.mjs.map +1 -1
- package/package.json +4 -4
- package/types/forms.d.ts +2 -2
- package/types/signals.d.ts +78 -134
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/forms",
|
|
3
|
-
"version": "21.0.0-next.
|
|
3
|
+
"version": "21.0.0-next.7",
|
|
4
4
|
"description": "Angular - directives and services for creating forms",
|
|
5
5
|
"author": "angular",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"tslib": "^2.3.0"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@angular/core": "21.0.0-next.
|
|
15
|
-
"@angular/common": "21.0.0-next.
|
|
16
|
-
"@angular/platform-browser": "21.0.0-next.
|
|
14
|
+
"@angular/core": "21.0.0-next.7",
|
|
15
|
+
"@angular/common": "21.0.0-next.7",
|
|
16
|
+
"@angular/platform-browser": "21.0.0-next.7",
|
|
17
17
|
"@standard-schema/spec": "^1.0.0",
|
|
18
18
|
"rxjs": "^6.5.3 || ^7.4.0"
|
|
19
19
|
},
|
package/types/forms.d.ts
CHANGED
package/types/signals.d.ts
CHANGED
|
@@ -1,74 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.0.0-next.
|
|
3
|
-
* (c) 2010-2025 Google LLC. https://angular.
|
|
2
|
+
* @license Angular v21.0.0-next.7
|
|
3
|
+
* (c) 2010-2025 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { HttpResourceRequest, HttpResourceOptions } from '@angular/common/http';
|
|
8
8
|
import * as i0 from '@angular/core';
|
|
9
|
-
import {
|
|
10
|
-
import { ControlValueAccessor, NgControl } from '@angular/forms';
|
|
9
|
+
import { InjectionToken, ɵControl as _Control, ɵCONTROL as _CONTROL, ɵFieldState as _FieldState, Signal, ResourceRef, InputSignal, ModelSignal, OutputRef, WritableSignal, DestroyableInjector, Injector } from '@angular/core';
|
|
11
10
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
13
|
+
* Lightweight DI token provided by the {@link Control} directive.
|
|
14
|
+
*/
|
|
15
|
+
declare const CONTROL: InjectionToken<Control<unknown>>;
|
|
16
|
+
/**
|
|
17
|
+
* Binds a form `FieldTree` to a UI control that edits it. A UI control can be one of several things:
|
|
15
18
|
* 1. A native HTML input or textarea
|
|
16
19
|
* 2. A signal forms custom control that implements `FormValueControl` or `FormCheckboxControl`
|
|
17
|
-
* 3.
|
|
20
|
+
* 3. TODO: https://github.com/orgs/angular/projects/60/views/1?pane=issue&itemId=131712274. A
|
|
21
|
+
* component that provides a ControlValueAccessor. This should only be used to backwards
|
|
18
22
|
* compatibility with reactive forms. Prefer options (1) and (2).
|
|
19
23
|
*
|
|
20
24
|
* This directive has several responsibilities:
|
|
21
25
|
* 1. Two-way binds the field's value with the UI control's value
|
|
22
26
|
* 2. Binds additional forms related state on the field to the UI control (disabled, required, etc.)
|
|
23
27
|
* 3. Relays relevant events on the control to the field (e.g. marks field touched on blur)
|
|
24
|
-
* 4.
|
|
25
|
-
*
|
|
26
|
-
*
|
|
28
|
+
* 4. TODO: https://github.com/orgs/angular/projects/60/views/1?pane=issue&itemId=131712274.
|
|
29
|
+
* Provides a fake `NgControl` that implements a subset of the features available on the
|
|
30
|
+
* reactive forms `NgControl`. This is provided to improve interoperability with controls
|
|
31
|
+
* designed to work with reactive forms. It should not be used by controls written for signal
|
|
32
|
+
* forms.
|
|
27
33
|
*
|
|
28
34
|
* @category control
|
|
29
35
|
* @experimental 21.0.0
|
|
30
36
|
*/
|
|
31
|
-
declare class Control<T> {
|
|
32
|
-
/** The injector for this component. */
|
|
37
|
+
declare class Control<T> implements _Control<T> {
|
|
33
38
|
private readonly injector;
|
|
34
|
-
|
|
35
|
-
/** Whether state synchronization with the field has been setup yet. */
|
|
36
|
-
private initialized;
|
|
37
|
-
/** The field that is bound to this control. */
|
|
38
|
-
readonly field: i0.WritableSignal<Field<T>>;
|
|
39
|
-
set _field(value: Field<T>);
|
|
40
|
-
/** The field state of the bound field. */
|
|
39
|
+
readonly field: i0.InputSignal<FieldTree<T>>;
|
|
41
40
|
readonly state: i0.Signal<FieldState<T, string | number>>;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/** The NG_VALUE_ACCESSOR array for the host component. */
|
|
45
|
-
readonly cvaArray: ControlValueAccessor[] | null;
|
|
46
|
-
/** The Cached value for the lazily created interop NgControl. */
|
|
47
|
-
private _ngControl;
|
|
48
|
-
/** A fake NgControl provided for better interop with reactive forms. */
|
|
49
|
-
get ngControl(): NgControl;
|
|
50
|
-
/** The ControlValueAccessor for the host component. */
|
|
51
|
-
get cva(): ControlValueAccessor | undefined;
|
|
52
|
-
/** Initializes state synchronization between the field and the host UI control. */
|
|
53
|
-
private initialize;
|
|
54
|
-
/**
|
|
55
|
-
* Set up state synchronization between the field and a native <input>, <textarea>, or <select>.
|
|
56
|
-
*/
|
|
57
|
-
private setupNativeInput;
|
|
58
|
-
/** Set up state synchronization between the field and a ControlValueAccessor. */
|
|
59
|
-
private setupControlValueAccessor;
|
|
60
|
-
/** Set up state synchronization between the field and a FormUiControl. */
|
|
61
|
-
private setupCustomUiControl;
|
|
62
|
-
/** Synchronize a value from a reactive source to a given sink. */
|
|
63
|
-
private maybeSynchronize;
|
|
64
|
-
/** Creates a reactive value source by reading the given AggregateProperty from the field. */
|
|
65
|
-
private propertySource;
|
|
66
|
-
/** Creates a (non-boolean) value sync that writes the given attribute of the given element. */
|
|
67
|
-
private withAttribute;
|
|
68
|
-
/** Creates a boolean value sync that writes the given attribute of the given element. */
|
|
69
|
-
private withBooleanAttribute;
|
|
41
|
+
readonly [_CONTROL]: undefined;
|
|
42
|
+
register(): void;
|
|
70
43
|
static ɵfac: i0.ɵɵFactoryDeclaration<Control<any>, never>;
|
|
71
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<Control<any>, "[control]", never, { "
|
|
44
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<Control<any>, "[control]", never, { "field": { "alias": "control"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
72
45
|
}
|
|
73
46
|
|
|
74
47
|
/**
|
|
@@ -200,7 +173,7 @@ interface ValidationErrorOptions {
|
|
|
200
173
|
* @experimental 21.0.0
|
|
201
174
|
*/
|
|
202
175
|
type WithField<T> = T & {
|
|
203
|
-
field:
|
|
176
|
+
field: FieldTree<unknown>;
|
|
204
177
|
};
|
|
205
178
|
/**
|
|
206
179
|
* A type that allows the given type `T` to optionally have a `field` property.
|
|
@@ -209,7 +182,7 @@ type WithField<T> = T & {
|
|
|
209
182
|
* @experimental 21.0.0
|
|
210
183
|
*/
|
|
211
184
|
type WithOptionalField<T> = Omit<T, 'field'> & {
|
|
212
|
-
field?:
|
|
185
|
+
field?: FieldTree<unknown>;
|
|
213
186
|
};
|
|
214
187
|
/**
|
|
215
188
|
* A type that ensures the given type `T` does not have a `field` property.
|
|
@@ -387,7 +360,7 @@ interface ValidationError {
|
|
|
387
360
|
/** Identifies the kind of error. */
|
|
388
361
|
readonly kind: string;
|
|
389
362
|
/** The field associated with this error. */
|
|
390
|
-
readonly field:
|
|
363
|
+
readonly field: FieldTree<unknown>;
|
|
391
364
|
/** Human readable error message. */
|
|
392
365
|
readonly message?: string;
|
|
393
366
|
}
|
|
@@ -407,7 +380,7 @@ declare class CustomValidationError implements ValidationError {
|
|
|
407
380
|
/** Identifies the kind of error. */
|
|
408
381
|
readonly kind: string;
|
|
409
382
|
/** The field associated with this error. */
|
|
410
|
-
readonly field:
|
|
383
|
+
readonly field: FieldTree<unknown>;
|
|
411
384
|
/** Human readable error message. */
|
|
412
385
|
readonly message?: string;
|
|
413
386
|
constructor(options?: ValidationErrorOptions);
|
|
@@ -424,7 +397,7 @@ declare abstract class _NgValidationError implements ValidationError {
|
|
|
424
397
|
/** Identifies the kind of error. */
|
|
425
398
|
readonly kind: string;
|
|
426
399
|
/** The field associated with this error. */
|
|
427
|
-
readonly field:
|
|
400
|
+
readonly field: FieldTree<unknown>;
|
|
428
401
|
/** Human readable error message. */
|
|
429
402
|
readonly message?: string;
|
|
430
403
|
constructor(options?: ValidationErrorOptions);
|
|
@@ -607,7 +580,7 @@ type SubmittedStatus = 'unsubmitted' | 'submitted' | 'submitting';
|
|
|
607
580
|
*/
|
|
608
581
|
interface DisabledReason {
|
|
609
582
|
/** The field that is disabled. */
|
|
610
|
-
readonly field:
|
|
583
|
+
readonly field: FieldTree<unknown>;
|
|
611
584
|
/** A user-facing message describing the reason for the disablement. */
|
|
612
585
|
readonly message?: string;
|
|
613
586
|
}
|
|
@@ -676,11 +649,11 @@ type ValidationResult<E extends ValidationError = ValidationError> = ValidationS
|
|
|
676
649
|
*/
|
|
677
650
|
type AsyncValidationResult<E extends ValidationError = ValidationError> = ValidationResult<E> | 'pending';
|
|
678
651
|
/**
|
|
679
|
-
* An object that represents a
|
|
652
|
+
* An object that represents a tree of fields in a form. This includes both primitive value fields
|
|
680
653
|
* (e.g. fields that contain a `string` or `number`), as well as "grouping fields" that contain
|
|
681
|
-
* sub-fields. `
|
|
682
|
-
* underlying data. For example a `
|
|
683
|
-
* `
|
|
654
|
+
* sub-fields. `FieldTree` objects are arranged in a tree whose structure mimics the structure of the
|
|
655
|
+
* underlying data. For example a `FieldTree<{x: number}>` has a property `x` which contains a
|
|
656
|
+
* `FieldTree<number>`. To access the state associated with a field, call it as a function.
|
|
684
657
|
*
|
|
685
658
|
* @template TValue The type of the data which the field is wrapped around.
|
|
686
659
|
* @template TKey The type of the property key which this field resides under in its parent.
|
|
@@ -688,16 +661,16 @@ type AsyncValidationResult<E extends ValidationError = ValidationError> = Valida
|
|
|
688
661
|
* @category types
|
|
689
662
|
* @experimental 21.0.0
|
|
690
663
|
*/
|
|
691
|
-
type
|
|
664
|
+
type FieldTree<TValue, TKey extends string | number = string | number> = (() => FieldState<TValue, TKey>) & (TValue extends Array<infer U> ? ReadonlyArrayLike<MaybeFieldTree<U, number>> : TValue extends Record<string, any> ? Subfields<TValue> : unknown);
|
|
692
665
|
/**
|
|
693
|
-
* The sub-fields that a user can navigate to from a `
|
|
666
|
+
* The sub-fields that a user can navigate to from a `FieldTree<TValue>`.
|
|
694
667
|
*
|
|
695
668
|
* @template TValue The type of the data which the parent field is wrapped around.
|
|
696
669
|
*
|
|
697
670
|
* @experimental 21.0.0
|
|
698
671
|
*/
|
|
699
672
|
type Subfields<TValue> = {
|
|
700
|
-
readonly [K in keyof TValue as TValue[K] extends Function ? never : K]:
|
|
673
|
+
readonly [K in keyof TValue as TValue[K] extends Function ? never : K]: MaybeFieldTree<TValue[K], string>;
|
|
701
674
|
};
|
|
702
675
|
/**
|
|
703
676
|
* An iterable object with the same shape as a readonly array.
|
|
@@ -708,35 +681,26 @@ type Subfields<TValue> = {
|
|
|
708
681
|
*/
|
|
709
682
|
type ReadonlyArrayLike<T> = Pick<ReadonlyArray<T>, number | 'length' | typeof Symbol.iterator>;
|
|
710
683
|
/**
|
|
711
|
-
* Helper type for defining `
|
|
712
|
-
* the `undefined` outside the `
|
|
684
|
+
* Helper type for defining `FieldTree`. Given a type `TValue` that may include `undefined`, it extracts
|
|
685
|
+
* the `undefined` outside the `FieldTree` type.
|
|
713
686
|
*
|
|
714
687
|
* For example `MaybeField<{a: number} | undefined, TKey>` would be equivalent to
|
|
715
|
-
* `undefined |
|
|
688
|
+
* `undefined | FieldTree<{a: number}, TKey>`.
|
|
716
689
|
*
|
|
717
690
|
* @template TValue The type of the data which the field is wrapped around.
|
|
718
691
|
* @template TKey The type of the property key which this field resides under in its parent.
|
|
719
692
|
*
|
|
720
693
|
* @experimental 21.0.0
|
|
721
694
|
*/
|
|
722
|
-
type
|
|
695
|
+
type MaybeFieldTree<TValue, TKey extends string | number = string | number> = (TValue & undefined) | FieldTree<Exclude<TValue, undefined>, TKey>;
|
|
723
696
|
/**
|
|
724
|
-
* Contains all of the state (e.g. value, statuses, etc.) associated with a `
|
|
697
|
+
* Contains all of the state (e.g. value, statuses, etc.) associated with a `FieldTree`, exposed as
|
|
725
698
|
* signals.
|
|
726
699
|
*
|
|
727
700
|
* @category structure
|
|
728
701
|
* @experimental 21.0.0
|
|
729
702
|
*/
|
|
730
|
-
interface FieldState<TValue, TKey extends string | number = string | number> {
|
|
731
|
-
/**
|
|
732
|
-
* A writable signal containing the value for this field. Updating this signal will update the
|
|
733
|
-
* data model that the field is bound to.
|
|
734
|
-
*/
|
|
735
|
-
readonly value: WritableSignal<TValue>;
|
|
736
|
-
/**
|
|
737
|
-
* A signal indicating whether the field has been touched by the user.
|
|
738
|
-
*/
|
|
739
|
-
readonly touched: Signal<boolean>;
|
|
703
|
+
interface FieldState<TValue, TKey extends string | number = string | number> extends _FieldState<TValue> {
|
|
740
704
|
/**
|
|
741
705
|
* A signal indicating whether field value has been changed by user.
|
|
742
706
|
*/
|
|
@@ -754,21 +718,7 @@ interface FieldState<TValue, TKey extends string | number = string | number> {
|
|
|
754
718
|
* ```
|
|
755
719
|
*/
|
|
756
720
|
readonly hidden: Signal<boolean>;
|
|
757
|
-
/**
|
|
758
|
-
* A signal indicating whether the field is currently disabled.
|
|
759
|
-
*/
|
|
760
|
-
readonly disabled: Signal<boolean>;
|
|
761
|
-
/**
|
|
762
|
-
* A signal containing the reasons why the field is currently disabled.
|
|
763
|
-
*/
|
|
764
721
|
readonly disabledReasons: Signal<readonly DisabledReason[]>;
|
|
765
|
-
/**
|
|
766
|
-
* A signal indicating whether the field is currently readonly.
|
|
767
|
-
*/
|
|
768
|
-
readonly readonly: Signal<boolean>;
|
|
769
|
-
/**
|
|
770
|
-
* A signal containing the current errors for the field.
|
|
771
|
-
*/
|
|
772
722
|
readonly errors: Signal<ValidationError[]>;
|
|
773
723
|
/**
|
|
774
724
|
* A signal containing the {@link errors} of the field and its descendants.
|
|
@@ -806,10 +756,6 @@ interface FieldState<TValue, TKey extends string | number = string | number> {
|
|
|
806
756
|
* A signal indicating whether the field is currently in the process of being submitted.
|
|
807
757
|
*/
|
|
808
758
|
readonly submitting: Signal<boolean>;
|
|
809
|
-
/**
|
|
810
|
-
* A signal of a unique name for the field, by default based on the name of its parent field.
|
|
811
|
-
*/
|
|
812
|
-
readonly name: Signal<string>;
|
|
813
759
|
/**
|
|
814
760
|
* The property key in the parent field under which this field is stored. If the parent field is
|
|
815
761
|
* array-valued, for example, this is the index of this field in that array.
|
|
@@ -833,14 +779,6 @@ interface FieldState<TValue, TKey extends string | number = string | number> {
|
|
|
833
779
|
* Checks whether the given metadata key has been defined for this field.
|
|
834
780
|
*/
|
|
835
781
|
hasProperty(key: Property<any> | AggregateProperty<any, any>): boolean;
|
|
836
|
-
/**
|
|
837
|
-
* Sets the touched status of the field to `true`.
|
|
838
|
-
*/
|
|
839
|
-
markAsTouched(): void;
|
|
840
|
-
/**
|
|
841
|
-
* Sets the dirty status of the field to `true`.
|
|
842
|
-
*/
|
|
843
|
-
markAsDirty(): void;
|
|
844
782
|
/**
|
|
845
783
|
* Resets the {@link touched} and {@link dirty} state of the field and its descendants.
|
|
846
784
|
*
|
|
@@ -849,7 +787,7 @@ interface FieldState<TValue, TKey extends string | number = string | number> {
|
|
|
849
787
|
reset(): void;
|
|
850
788
|
}
|
|
851
789
|
/**
|
|
852
|
-
* An object that represents a location in the `
|
|
790
|
+
* An object that represents a location in the `FieldTree` tree structure and is used to bind logic to a
|
|
853
791
|
* particular part of the structure prior to the creation of the form. Because the `FieldPath`
|
|
854
792
|
* exists prior to the form's creation, it cannot be used to access any of the field state.
|
|
855
793
|
*
|
|
@@ -869,7 +807,7 @@ type FieldPath<TValue, TPathKind extends PathKind = PathKind.Root> = {
|
|
|
869
807
|
* extracts the `undefined` outside the `FieldPath` type.
|
|
870
808
|
*
|
|
871
809
|
* For example `MaybeFieldPath<{a: number} | undefined, PathKind.Child>` would be equivalent to
|
|
872
|
-
* `undefined |
|
|
810
|
+
* `undefined | FieldTree<{a: number}, PathKind.child>`.
|
|
873
811
|
*
|
|
874
812
|
* @template TValue The type of the data which the field is wrapped around.
|
|
875
813
|
* @template TPathKind The kind of path (root field, child field, or item of an array)
|
|
@@ -973,13 +911,13 @@ interface RootFieldContext<TValue> {
|
|
|
973
911
|
/** The state of the current field. */
|
|
974
912
|
readonly state: FieldState<TValue>;
|
|
975
913
|
/** The current field. */
|
|
976
|
-
readonly field:
|
|
914
|
+
readonly field: FieldTree<TValue>;
|
|
977
915
|
/** Gets the value of the field represented by the given path. */
|
|
978
916
|
readonly valueOf: <P>(p: FieldPath<P>) => P;
|
|
979
917
|
/** Gets the state of the field represented by the given path. */
|
|
980
918
|
readonly stateOf: <P>(p: FieldPath<P>) => FieldState<P>;
|
|
981
919
|
/** Gets the field represented by the given path. */
|
|
982
|
-
readonly fieldOf: <P>(p: FieldPath<P>) =>
|
|
920
|
+
readonly fieldOf: <P>(p: FieldPath<P>) => FieldTree<P>;
|
|
983
921
|
}
|
|
984
922
|
/**
|
|
985
923
|
* Field context that is available for all fields that are a child of another field.
|
|
@@ -1216,14 +1154,14 @@ interface FormUiControl {
|
|
|
1216
1154
|
readonly pattern?: InputSignal<readonly RegExp[]>;
|
|
1217
1155
|
}
|
|
1218
1156
|
/**
|
|
1219
|
-
* A contract for a form control that edits a `
|
|
1157
|
+
* A contract for a form control that edits a `FieldTree` of type `TValue`. Any component that
|
|
1220
1158
|
* implements this contract can be used with the `Control` directive.
|
|
1221
1159
|
*
|
|
1222
1160
|
* Many of the properties declared on this contract are optional. They do not need to be
|
|
1223
1161
|
* implemented, but if they are will be kept in sync with the field state of the field bound to the
|
|
1224
1162
|
* `Control` directive.
|
|
1225
1163
|
*
|
|
1226
|
-
* @template TValue The type of `
|
|
1164
|
+
* @template TValue The type of `FieldTree` that the implementing component can edit.
|
|
1227
1165
|
*
|
|
1228
1166
|
* @category control
|
|
1229
1167
|
* @experimental 21.0.0
|
|
@@ -1232,7 +1170,7 @@ interface FormValueControl<TValue> extends FormUiControl {
|
|
|
1232
1170
|
/**
|
|
1233
1171
|
* The value is the only required property in this contract. A component that wants to integrate
|
|
1234
1172
|
* with the `Control` directive via this contract, *must* provide a `model()` that will be kept in
|
|
1235
|
-
* sync with the value of the bound `
|
|
1173
|
+
* sync with the value of the bound `FieldTree`.
|
|
1236
1174
|
*/
|
|
1237
1175
|
readonly value: ModelSignal<TValue>;
|
|
1238
1176
|
/**
|
|
@@ -1242,7 +1180,7 @@ interface FormValueControl<TValue> extends FormUiControl {
|
|
|
1242
1180
|
readonly checked?: undefined;
|
|
1243
1181
|
}
|
|
1244
1182
|
/**
|
|
1245
|
-
* A contract for a form control that edits a boolean checkbox `
|
|
1183
|
+
* A contract for a form control that edits a boolean checkbox `FieldTree`. Any component that
|
|
1246
1184
|
* implements this contract can be used with the `Control` directive.
|
|
1247
1185
|
*
|
|
1248
1186
|
* Many of the properties declared on this contract are optional. They do not need to be
|
|
@@ -1256,7 +1194,7 @@ interface FormCheckboxControl extends FormUiControl {
|
|
|
1256
1194
|
/**
|
|
1257
1195
|
* The checked is the only required property in this contract. A component that wants to integrate
|
|
1258
1196
|
* with the `Control` directive, *must* provide a `model()` that will be kept in sync with the
|
|
1259
|
-
* value of the bound `
|
|
1197
|
+
* value of the bound `FieldTree`.
|
|
1260
1198
|
*/
|
|
1261
1199
|
readonly checked: ModelSignal<boolean>;
|
|
1262
1200
|
/**
|
|
@@ -1978,7 +1916,7 @@ declare class FieldNode implements FieldState<unknown> {
|
|
|
1978
1916
|
/**
|
|
1979
1917
|
* Proxy to this node which allows navigation of the form graph below it.
|
|
1980
1918
|
*/
|
|
1981
|
-
readonly fieldProxy:
|
|
1919
|
+
readonly fieldProxy: FieldTree<any>;
|
|
1982
1920
|
constructor(options: FieldNodeOptions);
|
|
1983
1921
|
get logicNode(): LogicNode;
|
|
1984
1922
|
get value(): WritableSignal<unknown>;
|
|
@@ -1997,6 +1935,12 @@ declare class FieldNode implements FieldState<unknown> {
|
|
|
1997
1935
|
get controls(): Signal<readonly Control<unknown>[]>;
|
|
1998
1936
|
get submitting(): Signal<boolean>;
|
|
1999
1937
|
get name(): Signal<string>;
|
|
1938
|
+
get max(): Signal<number | undefined>;
|
|
1939
|
+
get maxLength(): Signal<number | undefined>;
|
|
1940
|
+
get min(): Signal<number | undefined>;
|
|
1941
|
+
get minLength(): Signal<number | undefined>;
|
|
1942
|
+
get pattern(): Signal<readonly RegExp[]>;
|
|
1943
|
+
get required(): Signal<boolean>;
|
|
2000
1944
|
property<M>(prop: AggregateProperty<M, any>): Signal<M>;
|
|
2001
1945
|
property<M>(prop: Property<M>): M | undefined;
|
|
2002
1946
|
hasProperty(prop: Property<unknown> | AggregateProperty<unknown, any>): boolean;
|
|
@@ -2263,8 +2207,8 @@ interface FormOptions {
|
|
|
2263
2207
|
adapter?: FieldAdapter;
|
|
2264
2208
|
}
|
|
2265
2209
|
/**
|
|
2266
|
-
* Creates a form wrapped around the given model data. A form is represented as simply a `
|
|
2267
|
-
* the model data.
|
|
2210
|
+
* Creates a form wrapped around the given model data. A form is represented as simply a `FieldTree`
|
|
2211
|
+
* of the model data.
|
|
2268
2212
|
*
|
|
2269
2213
|
* `form` uses the given model as the source of truth and *does not* maintain its own copy of the
|
|
2270
2214
|
* data. This means that updating the value on a `FieldState` updates the originally passed in model
|
|
@@ -2282,16 +2226,16 @@ interface FormOptions {
|
|
|
2282
2226
|
* @param model A writable signal that contains the model data for the form. The resulting field
|
|
2283
2227
|
* structure will match the shape of the model and any changes to the form data will be written to
|
|
2284
2228
|
* the model.
|
|
2285
|
-
* @return A `
|
|
2229
|
+
* @return A `FieldTree` representing a form around the data model.
|
|
2286
2230
|
* @template TValue The type of the data model.
|
|
2287
2231
|
*
|
|
2288
2232
|
* @category structure
|
|
2289
2233
|
* @experimental 21.0.0
|
|
2290
2234
|
*/
|
|
2291
|
-
declare function form<TValue>(model: WritableSignal<TValue>):
|
|
2235
|
+
declare function form<TValue>(model: WritableSignal<TValue>): FieldTree<TValue>;
|
|
2292
2236
|
/**
|
|
2293
|
-
* Creates a form wrapped around the given model data. A form is represented as simply a `
|
|
2294
|
-
* the model data.
|
|
2237
|
+
* Creates a form wrapped around the given model data. A form is represented as simply a `FieldTree`
|
|
2238
|
+
* of the model data.
|
|
2295
2239
|
*
|
|
2296
2240
|
* `form` uses the given model as the source of truth and *does not* maintain its own copy of the
|
|
2297
2241
|
* data. This means that updating the value on a `FieldState` updates the originally passed in model
|
|
@@ -2328,16 +2272,16 @@ declare function form<TValue>(model: WritableSignal<TValue>): Field<TValue>;
|
|
|
2328
2272
|
* 1. A schema or a function used to specify logic for the form (e.g. validation, disabled fields, etc.).
|
|
2329
2273
|
* When passing a schema, the form options can be passed as a third argument if needed.
|
|
2330
2274
|
* 2. The form options
|
|
2331
|
-
* @return A `
|
|
2275
|
+
* @return A `FieldTree` representing a form around the data model
|
|
2332
2276
|
* @template TValue The type of the data model.
|
|
2333
2277
|
*
|
|
2334
2278
|
* @category structure
|
|
2335
2279
|
* @experimental 21.0.0
|
|
2336
2280
|
*/
|
|
2337
|
-
declare function form<TValue>(model: WritableSignal<TValue>, schemaOrOptions: SchemaOrSchemaFn<TValue> | FormOptions):
|
|
2281
|
+
declare function form<TValue>(model: WritableSignal<TValue>, schemaOrOptions: SchemaOrSchemaFn<TValue> | FormOptions): FieldTree<TValue>;
|
|
2338
2282
|
/**
|
|
2339
|
-
* Creates a form wrapped around the given model data. A form is represented as simply a `
|
|
2340
|
-
* the model data.
|
|
2283
|
+
* Creates a form wrapped around the given model data. A form is represented as simply a `FieldTree`
|
|
2284
|
+
* of the model data.
|
|
2341
2285
|
*
|
|
2342
2286
|
* `form` uses the given model as the source of truth and *does not* maintain its own copy of the
|
|
2343
2287
|
* data. This means that updating the value on a `FieldState` updates the originally passed in model
|
|
@@ -2372,13 +2316,13 @@ declare function form<TValue>(model: WritableSignal<TValue>, schemaOrOptions: Sc
|
|
|
2372
2316
|
* the model.
|
|
2373
2317
|
* @param schema A schema or a function used to specify logic for the form (e.g. validation, disabled fields, etc.)
|
|
2374
2318
|
* @param options The form options
|
|
2375
|
-
* @return A `
|
|
2319
|
+
* @return A `FieldTree` representing a form around the data model.
|
|
2376
2320
|
* @template TValue The type of the data model.
|
|
2377
2321
|
*
|
|
2378
2322
|
* @category structure
|
|
2379
2323
|
* @experimental 21.0.0
|
|
2380
2324
|
*/
|
|
2381
|
-
declare function form<TValue>(model: WritableSignal<TValue>, schema: SchemaOrSchemaFn<TValue>, options: FormOptions):
|
|
2325
|
+
declare function form<TValue>(model: WritableSignal<TValue>, schema: SchemaOrSchemaFn<TValue>, options: FormOptions): FieldTree<TValue>;
|
|
2382
2326
|
/**
|
|
2383
2327
|
* Applies a schema to each item of an array.
|
|
2384
2328
|
*
|
|
@@ -2393,8 +2337,8 @@ declare function form<TValue>(model: WritableSignal<TValue>, schema: SchemaOrSch
|
|
|
2393
2337
|
* });
|
|
2394
2338
|
* ```
|
|
2395
2339
|
*
|
|
2396
|
-
* When binding logic to the array items, the `
|
|
2397
|
-
* argument. This can be used to reference other properties on the item.
|
|
2340
|
+
* When binding logic to the array items, the `FieldTree` for the array item is passed as an
|
|
2341
|
+
* additional argument. This can be used to reference other properties on the item.
|
|
2398
2342
|
*
|
|
2399
2343
|
* @example
|
|
2400
2344
|
* ```
|
|
@@ -2480,14 +2424,14 @@ declare function applyWhenValue<TValue, TNarrowed extends TValue>(path: FieldPat
|
|
|
2480
2424
|
*/
|
|
2481
2425
|
declare function applyWhenValue<TValue>(path: FieldPath<TValue>, predicate: (value: TValue) => boolean, schema: NoInfer<SchemaOrSchemaFn<TValue>>): void;
|
|
2482
2426
|
/**
|
|
2483
|
-
* Submits a given `
|
|
2484
|
-
* from the action to the field. Server errors returned by the `action` will be integrated
|
|
2485
|
-
* field as a `ValidationError` on the sub-field indicated by the `field` property of the
|
|
2486
|
-
* error.
|
|
2427
|
+
* Submits a given `FieldTree` using the given action function and applies any server errors
|
|
2428
|
+
* resulting from the action to the field. Server errors returned by the `action` will be integrated
|
|
2429
|
+
* into the field as a `ValidationError` on the sub-field indicated by the `field` property of the
|
|
2430
|
+
* server error.
|
|
2487
2431
|
*
|
|
2488
2432
|
* @example
|
|
2489
2433
|
* ```
|
|
2490
|
-
* async function registerNewUser(registrationForm:
|
|
2434
|
+
* async function registerNewUser(registrationForm: FieldTree<{username: string, password: string}>) {
|
|
2491
2435
|
* const result = await myClient.registerNewUser(registrationForm().value());
|
|
2492
2436
|
* if (result.errorCode === myClient.ErrorCode.USERNAME_TAKEN) {
|
|
2493
2437
|
* return [{
|
|
@@ -2513,12 +2457,12 @@ declare function applyWhenValue<TValue>(path: FieldPath<TValue>, predicate: (val
|
|
|
2513
2457
|
* @category submission
|
|
2514
2458
|
* @experimental 21.0.0
|
|
2515
2459
|
*/
|
|
2516
|
-
declare function submit<TValue>(form:
|
|
2460
|
+
declare function submit<TValue>(form: FieldTree<TValue>, action: (form: FieldTree<TValue>) => Promise<TreeValidationResult>): Promise<void>;
|
|
2517
2461
|
/**
|
|
2518
2462
|
* Creates a `Schema` that adds logic rules to a form.
|
|
2519
2463
|
* @param fn A **non-reactive** function that sets up reactive logic rules for the form.
|
|
2520
2464
|
* @returns A schema object that implements the given logic.
|
|
2521
|
-
* @template TValue The value type of a `
|
|
2465
|
+
* @template TValue The value type of a `FieldTree` that this schema binds to.
|
|
2522
2466
|
*
|
|
2523
2467
|
* @category structure
|
|
2524
2468
|
* @experimental 21.0.0
|
|
@@ -2706,5 +2650,5 @@ type IgnoreUnknownProperties<T> = T extends Record<PropertyKey, unknown> ? {
|
|
|
2706
2650
|
*/
|
|
2707
2651
|
declare function validateStandardSchema<TSchema, TValue extends IgnoreUnknownProperties<TSchema>>(path: FieldPath<TValue>, schema: StandardSchemaV1<TSchema>): void;
|
|
2708
2652
|
|
|
2709
|
-
export { AggregateProperty, Control, CustomValidationError, EmailValidationError, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MinLengthValidationError, MinValidationError, NgValidationError, PATTERN, PathKind, PatternValidationError, Property, REQUIRED, RequiredValidationError, StandardSchemaValidationError, aggregateProperty, andProperty, apply, applyEach, applyWhen, applyWhenValue, createProperty, customError, disabled, email, emailError, form, hidden, listProperty, max, maxError, maxLength, maxLengthError, maxProperty, min, minError, minLength, minLengthError, minProperty, orProperty, pattern, patternError, property, readonly, reducedProperty, required, requiredError, schema, standardSchemaError, submit, validate, validateAsync, validateHttp, validateStandardSchema, validateTree };
|
|
2710
|
-
export type { AsyncValidationResult, AsyncValidatorOptions, ChildFieldContext, DisabledReason,
|
|
2653
|
+
export { AggregateProperty, CONTROL, Control, CustomValidationError, EmailValidationError, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MinLengthValidationError, MinValidationError, NgValidationError, PATTERN, PathKind, PatternValidationError, Property, REQUIRED, RequiredValidationError, StandardSchemaValidationError, aggregateProperty, andProperty, apply, applyEach, applyWhen, applyWhenValue, createProperty, customError, disabled, email, emailError, form, hidden, listProperty, max, maxError, maxLength, maxLengthError, maxProperty, min, minError, minLength, minLengthError, minProperty, orProperty, pattern, patternError, property, readonly, reducedProperty, required, requiredError, schema, standardSchemaError, submit, validate, validateAsync, validateHttp, validateStandardSchema, validateTree };
|
|
2654
|
+
export type { AsyncValidationResult, AsyncValidatorOptions, ChildFieldContext, DisabledReason, FieldContext, FieldPath, FieldState, FieldTree, FieldValidationResult, FieldValidator, FormCheckboxControl, FormOptions, FormUiControl, FormValueControl, HttpValidatorOptions, IgnoreUnknownProperties, ItemFieldContext, LogicFn, MapToErrorsFn, MaybeFieldPath, MaybeFieldTree, Mutable, OneOrMany, ReadonlyArrayLike, RemoveStringIndexUnknownKey, RootFieldContext, Schema, SchemaFn, SchemaOrSchemaFn, Subfields, SubmittedStatus, TreeValidationResult, TreeValidator, ValidationError, ValidationResult, ValidationSuccess, Validator, WithField, WithOptionalField, WithoutField };
|