@angular/forms 21.1.0-next.3 → 21.1.0-rc.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/LICENSE +1 -1
- package/fesm2022/_structure-chunk.mjs +34 -34
- package/fesm2022/_structure-chunk.mjs.map +1 -1
- package/fesm2022/forms.mjs +133 -132
- package/fesm2022/forms.mjs.map +1 -1
- package/fesm2022/signals-compat.mjs +26 -12
- package/fesm2022/signals-compat.mjs.map +1 -1
- package/fesm2022/signals.mjs +159 -78
- package/fesm2022/signals.mjs.map +1 -1
- package/package.json +12 -6
- package/resources/code-examples.db +0 -0
- package/types/_structure-chunk.d.ts +129 -73
- package/types/forms.d.ts +26 -9
- package/types/signals-compat.d.ts +3 -3
- package/types/signals.d.ts +155 -145
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.1.0-
|
|
3
|
-
* (c) 2010-
|
|
2
|
+
* @license Angular v21.1.0-rc.0
|
|
3
|
+
* (c) 2010-2026 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -88,6 +88,52 @@ declare class Field<T> {
|
|
|
88
88
|
static ɵdir: i0.ɵɵDirectiveDeclaration<Field<any>, "[field]", never, { "field": { "alias": "field"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Lightweight DI token provided by the {@link FormField} directive.
|
|
93
|
+
*
|
|
94
|
+
* @category control
|
|
95
|
+
* @experimental 21.0.0
|
|
96
|
+
*/
|
|
97
|
+
declare const FORM_FIELD: InjectionToken<FormField<unknown>>;
|
|
98
|
+
/**
|
|
99
|
+
* Binds a form `FieldTree` to a UI control that edits it. A UI control can be one of several things:
|
|
100
|
+
* 1. A native HTML input or textarea
|
|
101
|
+
* 2. A signal forms custom control that implements `FormValueControl` or `FormCheckboxControl`
|
|
102
|
+
* 3. A component that provides a `ControlValueAccessor`. This should only be used for backwards
|
|
103
|
+
* compatibility with reactive forms. Prefer options (1) and (2).
|
|
104
|
+
*
|
|
105
|
+
* This directive has several responsibilities:
|
|
106
|
+
* 1. Two-way binds the field state's value with the UI control's value
|
|
107
|
+
* 2. Binds additional forms related state on the field state to the UI control (disabled, required, etc.)
|
|
108
|
+
* 3. Relays relevant events on the control to the field state (e.g. marks touched on blur)
|
|
109
|
+
* 4. Provides a fake `NgControl` that implements a subset of the features available on the
|
|
110
|
+
* reactive forms `NgControl`. This is provided to improve interoperability with controls
|
|
111
|
+
* designed to work with reactive forms. It should not be used by controls written for signal
|
|
112
|
+
* forms.
|
|
113
|
+
*
|
|
114
|
+
* @category control
|
|
115
|
+
* @experimental 21.0.0
|
|
116
|
+
*/
|
|
117
|
+
declare class FormField<T> {
|
|
118
|
+
readonly element: HTMLElement;
|
|
119
|
+
readonly injector: Injector;
|
|
120
|
+
readonly formField: i0.InputSignal<FieldTree<T>>;
|
|
121
|
+
readonly state: i0.Signal<[T] extends [_angular_forms.AbstractControl<any, any, any>] ? CompatFieldState<T, string | number> : FieldState<T, string | number>>;
|
|
122
|
+
readonly [_CONTROL]: {
|
|
123
|
+
readonly create: typeof __controlCreate;
|
|
124
|
+
readonly update: typeof _controlUpdate;
|
|
125
|
+
};
|
|
126
|
+
private config;
|
|
127
|
+
/** Any `ControlValueAccessor` instances provided on the host element. */
|
|
128
|
+
private readonly controlValueAccessors;
|
|
129
|
+
/** A lazily instantiated fake `NgControl`. */
|
|
130
|
+
private interopNgControl;
|
|
131
|
+
/** Lazily instantiates a fake `NgControl` for this form field. */
|
|
132
|
+
protected getOrCreateNgControl(): InteropNgControl;
|
|
133
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FormField<any>, never>;
|
|
134
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<FormField<any>, "[formField]", never, { "formField": { "alias": "formField"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
135
|
+
}
|
|
136
|
+
|
|
91
137
|
/**
|
|
92
138
|
* Sets a value for the {@link MetadataKey} for this field.
|
|
93
139
|
*
|
|
@@ -311,7 +357,7 @@ type SubmittedStatus = 'unsubmitted' | 'submitted' | 'submitting';
|
|
|
311
357
|
*/
|
|
312
358
|
interface DisabledReason {
|
|
313
359
|
/** The field that is disabled. */
|
|
314
|
-
readonly
|
|
360
|
+
readonly fieldTree: FieldTree<unknown>;
|
|
315
361
|
/** A user-facing message describing the reason for the disablement. */
|
|
316
362
|
readonly message?: string;
|
|
317
363
|
}
|
|
@@ -377,7 +423,7 @@ type AsyncValidationResult<E extends ValidationError = ValidationError> = Valida
|
|
|
377
423
|
* @category types
|
|
378
424
|
* @experimental 21.0.0
|
|
379
425
|
*/
|
|
380
|
-
type FieldTree<TModel, TKey extends string | number = string | number> = (() => [TModel] extends [AbstractControl] ? CompatFieldState<TModel, TKey> : FieldState<TModel, TKey>) & ([TModel] extends [AbstractControl] ? object : [TModel] extends [
|
|
426
|
+
type FieldTree<TModel, TKey extends string | number = string | number> = (() => [TModel] extends [AbstractControl] ? CompatFieldState<TModel, TKey> : FieldState<TModel, TKey>) & ([TModel] extends [AbstractControl] ? object : [TModel] extends [ReadonlyArray<infer U>] ? ReadonlyArrayLike<MaybeFieldTree<U, number>> : TModel extends Record<string, any> ? Subfields<TModel> : object);
|
|
381
427
|
/**
|
|
382
428
|
* The sub-fields that a user can navigate to from a `FieldTree<TModel>`.
|
|
383
429
|
*
|
|
@@ -482,7 +528,7 @@ interface FieldState<TValue, TKey extends string | number = string | number> ext
|
|
|
482
528
|
/**
|
|
483
529
|
* The {@link Field} directives that bind this field to a UI control.
|
|
484
530
|
*/
|
|
485
|
-
readonly
|
|
531
|
+
readonly formFieldBindings: Signal<readonly (Field<unknown> | FormField<unknown>)[]>;
|
|
486
532
|
/**
|
|
487
533
|
* Reads a metadata value from the field.
|
|
488
534
|
* @param key The metadata key to read.
|
|
@@ -559,7 +605,7 @@ type CompatSchemaPath<TControl extends AbstractControl, TPathKind extends PathKi
|
|
|
559
605
|
*
|
|
560
606
|
* @experimental 21.0.0
|
|
561
607
|
*/
|
|
562
|
-
type SchemaPathTree<TModel, TPathKind extends PathKind = PathKind.Root> = ([TModel] extends [AbstractControl] ? CompatSchemaPath<TModel, TPathKind> : SchemaPath<TModel, SchemaPathRules.Supported, TPathKind>) & (TModel extends AbstractControl ? unknown : TModel extends
|
|
608
|
+
type SchemaPathTree<TModel, TPathKind extends PathKind = PathKind.Root> = ([TModel] extends [AbstractControl] ? CompatSchemaPath<TModel, TPathKind> : SchemaPath<TModel, SchemaPathRules.Supported, TPathKind>) & (TModel extends AbstractControl ? unknown : TModel extends ReadonlyArray<any> ? unknown : TModel extends Record<string, any> ? {
|
|
563
609
|
[K in keyof TModel]: MaybeSchemaPathTree<TModel[K], PathKind.Child>;
|
|
564
610
|
} : unknown);
|
|
565
611
|
/**
|
|
@@ -576,9 +622,42 @@ type SchemaPathTree<TModel, TPathKind extends PathKind = PathKind.Root> = ([TMod
|
|
|
576
622
|
*/
|
|
577
623
|
type MaybeSchemaPathTree<TModel, TPathKind extends PathKind = PathKind.Root> = (TModel & undefined) | SchemaPathTree<Exclude<TModel, undefined>, TPathKind>;
|
|
578
624
|
/**
|
|
579
|
-
*
|
|
625
|
+
* A reusable schema that defines behavior and rules for a form.
|
|
626
|
+
*
|
|
627
|
+
* A `Schema` encapsulates form logic such as validation rules, disabled states, readonly states,
|
|
628
|
+
* and other field-level behaviors.
|
|
580
629
|
*
|
|
581
|
-
*
|
|
630
|
+
* Unlike raw {@link SchemaFn}, a `Schema` is created using
|
|
631
|
+
* the {@link schema} function and is cached per-form, even when applied to multiple fields.
|
|
632
|
+
*
|
|
633
|
+
* ### Creating a reusable schema
|
|
634
|
+
*
|
|
635
|
+
* ```typescript
|
|
636
|
+
* interface Address {
|
|
637
|
+
* street: string;
|
|
638
|
+
* city: string;
|
|
639
|
+
* }
|
|
640
|
+
*
|
|
641
|
+
* // Create a reusable schema for address fields
|
|
642
|
+
* const addressSchema = schema<Address>((p) => {
|
|
643
|
+
* required(p.street);
|
|
644
|
+
* required(p.city);
|
|
645
|
+
* });
|
|
646
|
+
*
|
|
647
|
+
* // Apply the schema to multiple forms
|
|
648
|
+
* const shippingForm = form(shippingModel, addressSchema, {injector});
|
|
649
|
+
* const billingForm = form(billingModel, addressSchema, {injector});
|
|
650
|
+
* ```
|
|
651
|
+
*
|
|
652
|
+
* ### Passing a schema to a form
|
|
653
|
+
*
|
|
654
|
+
* A schema can also be passed as a second argument to the {@link form} function.
|
|
655
|
+
*
|
|
656
|
+
* ```typescript
|
|
657
|
+
* readonly userForm = form(addressModel, addressSchema);
|
|
658
|
+
* ```
|
|
659
|
+
*
|
|
660
|
+
* @template TModel Data type.
|
|
582
661
|
*
|
|
583
662
|
* @category types
|
|
584
663
|
* @experimental 21.0.0
|
|
@@ -587,9 +666,21 @@ type Schema<in TModel> = {
|
|
|
587
666
|
[ɵɵTYPE]: SchemaFn<TModel, PathKind.Root>;
|
|
588
667
|
};
|
|
589
668
|
/**
|
|
590
|
-
*
|
|
669
|
+
* A function that receives a {@link SchemaPathTree} and applies rules to fields.
|
|
591
670
|
*
|
|
592
|
-
*
|
|
671
|
+
* A `SchemaFn` can be passed directly to {@link form} or to the {@link schema} function to create a
|
|
672
|
+
* cached {@link Schema}.
|
|
673
|
+
*
|
|
674
|
+
* ```typescript
|
|
675
|
+
* const userFormSchema: SchemaFn<User> = (p) => {
|
|
676
|
+
* required(p.name);
|
|
677
|
+
* disabled(p.email, ({valueOf}) => valueOf(p.name) === '');
|
|
678
|
+
* };
|
|
679
|
+
*
|
|
680
|
+
* const f = form(userModel, userFormSchema, {injector});
|
|
681
|
+
* ```
|
|
682
|
+
*
|
|
683
|
+
* @template TModel Data type.
|
|
593
684
|
* @template TPathKind The kind of path this schema function can be bound to.
|
|
594
685
|
*
|
|
595
686
|
* @category types
|
|
@@ -597,7 +688,7 @@ type Schema<in TModel> = {
|
|
|
597
688
|
*/
|
|
598
689
|
type SchemaFn<TModel, TPathKind extends PathKind = PathKind.Root> = (p: SchemaPathTree<TModel, TPathKind>) => void;
|
|
599
690
|
/**
|
|
600
|
-
* A
|
|
691
|
+
* A {@link Schema} or {@link SchemaFn}.
|
|
601
692
|
*
|
|
602
693
|
* @template TModel The type of data stored in the form that this schema function is attached to.
|
|
603
694
|
* @template TPathKind The kind of path this schema function can be bound to.
|
|
@@ -647,7 +738,7 @@ type TreeValidator<TValue, TPathKind extends PathKind = PathKind.Root> = LogicFn
|
|
|
647
738
|
*
|
|
648
739
|
* @template TValue The type of value stored in the field being validated
|
|
649
740
|
* @template TPathKind The kind of path being validated (root field, child field, or item of an array)
|
|
650
|
-
*
|
|
741
|
+
* @see [Signal Form Validation](/guide/forms/signals/validation)
|
|
651
742
|
* @category types
|
|
652
743
|
* @experimental 21.0.0
|
|
653
744
|
*/
|
|
@@ -671,7 +762,7 @@ interface RootFieldContext<TValue> {
|
|
|
671
762
|
/** The state of the current field. */
|
|
672
763
|
readonly state: FieldState<TValue>;
|
|
673
764
|
/** The current field. */
|
|
674
|
-
readonly
|
|
765
|
+
readonly fieldTree: FieldTree<TValue>;
|
|
675
766
|
/** Gets the value of the field represented by the given path. */
|
|
676
767
|
valueOf<PValue>(p: SchemaPath<PValue, SchemaPathRules>): PValue;
|
|
677
768
|
/** Gets the state of the field represented by the given path. */
|
|
@@ -734,7 +825,7 @@ interface ValidationErrorOptions {
|
|
|
734
825
|
* @experimental 21.0.0
|
|
735
826
|
*/
|
|
736
827
|
type WithField<T> = T & {
|
|
737
|
-
|
|
828
|
+
fieldTree: FieldTree<unknown>;
|
|
738
829
|
};
|
|
739
830
|
/**
|
|
740
831
|
* A type that allows the given type `T` to optionally have a `field` property.
|
|
@@ -742,8 +833,8 @@ type WithField<T> = T & {
|
|
|
742
833
|
*
|
|
743
834
|
* @experimental 21.0.0
|
|
744
835
|
*/
|
|
745
|
-
type WithOptionalField<T> = Omit<T, '
|
|
746
|
-
|
|
836
|
+
type WithOptionalField<T> = Omit<T, 'fieldTree'> & {
|
|
837
|
+
fieldTree?: FieldTree<unknown>;
|
|
747
838
|
};
|
|
748
839
|
/**
|
|
749
840
|
* A type that ensures the given type `T` does not have a `field` property.
|
|
@@ -752,7 +843,7 @@ type WithOptionalField<T> = Omit<T, 'field'> & {
|
|
|
752
843
|
* @experimental 21.0.0
|
|
753
844
|
*/
|
|
754
845
|
type WithoutField<T> = T & {
|
|
755
|
-
|
|
846
|
+
fieldTree: never;
|
|
756
847
|
};
|
|
757
848
|
/**
|
|
758
849
|
* Create a required error associated with the target field
|
|
@@ -893,22 +984,6 @@ declare function standardSchemaError(issue: StandardSchemaV1.Issue, options: Wit
|
|
|
893
984
|
* @experimental 21.0.0
|
|
894
985
|
*/
|
|
895
986
|
declare function standardSchemaError(issue: StandardSchemaV1.Issue, options?: ValidationErrorOptions): WithoutField<StandardSchemaValidationError>;
|
|
896
|
-
/**
|
|
897
|
-
* Create a custom error associated with the target field
|
|
898
|
-
* @param obj The object to create an error from
|
|
899
|
-
*
|
|
900
|
-
* @category validation
|
|
901
|
-
* @experimental 21.0.0
|
|
902
|
-
*/
|
|
903
|
-
declare function customError<E extends Partial<ValidationError.WithField>>(obj: WithField<E>): CustomValidationError;
|
|
904
|
-
/**
|
|
905
|
-
* Create a custom error
|
|
906
|
-
* @param obj The object to create an error from
|
|
907
|
-
*
|
|
908
|
-
* @category validation
|
|
909
|
-
* @experimental 21.0.0
|
|
910
|
-
*/
|
|
911
|
-
declare function customError<E extends Partial<ValidationError.WithField>>(obj?: E): WithoutField<CustomValidationError>;
|
|
912
987
|
/**
|
|
913
988
|
* Common interface for all validation errors.
|
|
914
989
|
*
|
|
@@ -917,6 +992,8 @@ declare function customError<E extends Partial<ValidationError.WithField>>(obj?:
|
|
|
917
992
|
* It's also used by the creation functions to create an instance
|
|
918
993
|
* (e.g. `requiredError`, `minError`, etc.).
|
|
919
994
|
*
|
|
995
|
+
* @see [Signal Form Validation](guide/forms/signals/validation)
|
|
996
|
+
* @see [Signal Form Validation Errors](guide/forms/signals/validation#validation-errors)
|
|
920
997
|
* @category validation
|
|
921
998
|
* @experimental 21.0.0
|
|
922
999
|
*/
|
|
@@ -935,7 +1012,7 @@ declare namespace ValidationError {
|
|
|
935
1012
|
*/
|
|
936
1013
|
interface WithField extends ValidationError {
|
|
937
1014
|
/** The field associated with this error. */
|
|
938
|
-
readonly
|
|
1015
|
+
readonly fieldTree: FieldTree<unknown>;
|
|
939
1016
|
}
|
|
940
1017
|
/**
|
|
941
1018
|
* Validation error with optional field.
|
|
@@ -945,7 +1022,7 @@ declare namespace ValidationError {
|
|
|
945
1022
|
*/
|
|
946
1023
|
interface WithOptionalField extends ValidationError {
|
|
947
1024
|
/** The field associated with this error. */
|
|
948
|
-
readonly
|
|
1025
|
+
readonly fieldTree?: FieldTree<unknown>;
|
|
949
1026
|
}
|
|
950
1027
|
/**
|
|
951
1028
|
* Validation error with no field.
|
|
@@ -954,30 +1031,9 @@ declare namespace ValidationError {
|
|
|
954
1031
|
*/
|
|
955
1032
|
interface WithoutField extends ValidationError {
|
|
956
1033
|
/** The field associated with this error. */
|
|
957
|
-
readonly
|
|
1034
|
+
readonly fieldTree?: never;
|
|
958
1035
|
}
|
|
959
1036
|
}
|
|
960
|
-
/**
|
|
961
|
-
* A custom error that may contain additional properties
|
|
962
|
-
*
|
|
963
|
-
* @category validation
|
|
964
|
-
* @experimental 21.0.0
|
|
965
|
-
*/
|
|
966
|
-
declare class CustomValidationError implements ValidationError {
|
|
967
|
-
/** Brand the class to avoid Typescript structural matching */
|
|
968
|
-
private __brand;
|
|
969
|
-
/**
|
|
970
|
-
* Allow the user to attach arbitrary other properties.
|
|
971
|
-
*/
|
|
972
|
-
[key: PropertyKey]: unknown;
|
|
973
|
-
/** Identifies the kind of error. */
|
|
974
|
-
readonly kind: string;
|
|
975
|
-
/** The field associated with this error. */
|
|
976
|
-
readonly field: FieldTree<unknown>;
|
|
977
|
-
/** Human readable error message. */
|
|
978
|
-
readonly message?: string;
|
|
979
|
-
constructor(options?: ValidationErrorOptions);
|
|
980
|
-
}
|
|
981
1037
|
/**
|
|
982
1038
|
* Internal version of `NgValidationError`, we create this separately so we can change its type on
|
|
983
1039
|
* the exported version to a type union of the possible sub-classes.
|
|
@@ -990,7 +1046,7 @@ declare abstract class _NgValidationError implements ValidationError {
|
|
|
990
1046
|
/** Identifies the kind of error. */
|
|
991
1047
|
readonly kind: string;
|
|
992
1048
|
/** The field associated with this error. */
|
|
993
|
-
readonly
|
|
1049
|
+
readonly fieldTree: FieldTree<unknown>;
|
|
994
1050
|
/** Human readable error message. */
|
|
995
1051
|
readonly message?: string;
|
|
996
1052
|
constructor(options?: ValidationErrorOptions);
|
|
@@ -1115,7 +1171,7 @@ type NgValidationError = RequiredValidationError | MinValidationError | MaxValid
|
|
|
1115
1171
|
interface SignalFormsConfig {
|
|
1116
1172
|
/** A map of CSS class names to predicate functions that determine when to apply them. */
|
|
1117
1173
|
classes?: {
|
|
1118
|
-
[className: string]: (state:
|
|
1174
|
+
[className: string]: (state: Field<unknown> | FormField<unknown>) => boolean;
|
|
1119
1175
|
};
|
|
1120
1176
|
}
|
|
1121
1177
|
/**
|
|
@@ -1147,7 +1203,7 @@ interface Predicate {
|
|
|
1147
1203
|
*
|
|
1148
1204
|
* Consider the following example:
|
|
1149
1205
|
*
|
|
1150
|
-
* ```
|
|
1206
|
+
* ```ts
|
|
1151
1207
|
* const s = schema(p => {
|
|
1152
1208
|
* disabled(p.data);
|
|
1153
1209
|
* applyWhen(p.next, ({valueOf}) => valueOf(p.data) === 1, s);
|
|
@@ -1515,8 +1571,8 @@ declare class FieldNodeState {
|
|
|
1515
1571
|
* Marks this specific field as not touched.
|
|
1516
1572
|
*/
|
|
1517
1573
|
markAsUntouched(): void;
|
|
1518
|
-
/** The {@link
|
|
1519
|
-
readonly
|
|
1574
|
+
/** The {@link FormField} directives that bind this field to a UI control. */
|
|
1575
|
+
readonly formFieldBindings: i0.WritableSignal<readonly (Field<unknown> | FormField<unknown>)[]>;
|
|
1520
1576
|
constructor(node: FieldNode);
|
|
1521
1577
|
/**
|
|
1522
1578
|
* Whether this field is considered dirty.
|
|
@@ -1590,8 +1646,8 @@ declare class FieldSubmitState {
|
|
|
1590
1646
|
* and is still in the process of submitting.
|
|
1591
1647
|
*/
|
|
1592
1648
|
readonly selfSubmitting: WritableSignal<boolean>;
|
|
1593
|
-
/**
|
|
1594
|
-
readonly
|
|
1649
|
+
/** Submission errors that are associated with this field. */
|
|
1650
|
+
readonly submissionErrors: WritableSignal<readonly ValidationError.WithField[]>;
|
|
1595
1651
|
constructor(node: FieldNode);
|
|
1596
1652
|
/**
|
|
1597
1653
|
* Whether this form is currently in the process of being submitted.
|
|
@@ -1607,8 +1663,8 @@ interface ValidationState {
|
|
|
1607
1663
|
*/
|
|
1608
1664
|
rawSyncTreeErrors: Signal<ValidationError.WithField[]>;
|
|
1609
1665
|
/**
|
|
1610
|
-
* The full set of synchronous errors for this field, including synchronous tree errors and
|
|
1611
|
-
* errors.
|
|
1666
|
+
* The full set of synchronous errors for this field, including synchronous tree errors and submission
|
|
1667
|
+
* errors. Submission errors are considered "synchronous" because they are imperatively added. From
|
|
1612
1668
|
* the perspective of the field state they are either there or not, they are never in a pending
|
|
1613
1669
|
* state.
|
|
1614
1670
|
*/
|
|
@@ -1741,7 +1797,7 @@ declare class FieldNode implements FieldState<unknown> {
|
|
|
1741
1797
|
get disabledReasons(): Signal<readonly DisabledReason[]>;
|
|
1742
1798
|
get hidden(): Signal<boolean>;
|
|
1743
1799
|
get readonly(): Signal<boolean>;
|
|
1744
|
-
get
|
|
1800
|
+
get formFieldBindings(): Signal<readonly (Field<unknown> | FormField<unknown>)[]>;
|
|
1745
1801
|
get submitting(): Signal<boolean>;
|
|
1746
1802
|
get name(): Signal<string>;
|
|
1747
1803
|
get max(): Signal<number | undefined> | undefined;
|
|
@@ -2194,7 +2250,7 @@ declare function form<TModel>(model: WritableSignal<TModel>, schemaOrOptions: Sc
|
|
|
2194
2250
|
* ```ts
|
|
2195
2251
|
* const nameForm = form(signal({first: '', last: ''}), (name) => {
|
|
2196
2252
|
* required(name.first);
|
|
2197
|
-
* validate(name.last, ({value}) => !/^[a-z]+$/i.test(value()) ?
|
|
2253
|
+
* validate(name.last, ({value}) => !/^[a-z]+$/i.test(value()) ? {kind: 'alphabet-only'} : undefined);
|
|
2198
2254
|
* });
|
|
2199
2255
|
* nameForm().valid(); // false
|
|
2200
2256
|
* nameForm().value.set({first: 'John', last: 'Doe'});
|
|
@@ -2299,10 +2355,10 @@ declare function applyWhenValue<TValue, TNarrowed extends TValue>(path: SchemaPa
|
|
|
2299
2355
|
*/
|
|
2300
2356
|
declare function applyWhenValue<TValue>(path: SchemaPath<TValue>, predicate: (value: TValue) => boolean, schema: NoInfer<SchemaOrSchemaFn<TValue>>): void;
|
|
2301
2357
|
/**
|
|
2302
|
-
* Submits a given `FieldTree` using the given action function and applies any
|
|
2303
|
-
* resulting from the action to the field.
|
|
2358
|
+
* Submits a given `FieldTree` using the given action function and applies any submission errors
|
|
2359
|
+
* resulting from the action to the field. Submission errors returned by the `action` will be integrated
|
|
2304
2360
|
* into the field as a `ValidationError` on the sub-field indicated by the `field` property of the
|
|
2305
|
-
*
|
|
2361
|
+
* submission error.
|
|
2306
2362
|
*
|
|
2307
2363
|
* @example
|
|
2308
2364
|
* ```ts
|
|
@@ -2325,7 +2381,7 @@ declare function applyWhenValue<TValue>(path: SchemaPath<TValue>, predicate: (va
|
|
|
2325
2381
|
* ```
|
|
2326
2382
|
*
|
|
2327
2383
|
* @param form The field to submit.
|
|
2328
|
-
* @param action An asynchronous action used to submit the field. The action may return
|
|
2384
|
+
* @param action An asynchronous action used to submit the field. The action may return submission
|
|
2329
2385
|
* errors.
|
|
2330
2386
|
* @template TModel The data type of the field being submitted.
|
|
2331
2387
|
*
|
|
@@ -2344,5 +2400,5 @@ declare function submit<TModel>(form: FieldTree<TModel>, action: (form: FieldTre
|
|
|
2344
2400
|
*/
|
|
2345
2401
|
declare function schema<TValue>(fn: SchemaFn<TValue>): Schema<TValue>;
|
|
2346
2402
|
|
|
2347
|
-
export {
|
|
2403
|
+
export { EmailValidationError, FIELD, FORM_FIELD, Field, FormField, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MetadataKey, MetadataReducer, MinLengthValidationError, MinValidationError, NgValidationError, PATTERN, PathKind, PatternValidationError, REQUIRED, RequiredValidationError, SchemaPathRules, StandardSchemaValidationError, ValidationError, apply, applyEach, applyWhen, applyWhenValue, createManagedMetadataKey, createMetadataKey, emailError, form, maxError, maxLengthError, metadata, minError, minLengthError, patternError, provideSignalFormsConfig, requiredError, schema, standardSchemaError, submit };
|
|
2348
2404
|
export type { AsyncValidationResult, ChildFieldContext, CompatFieldState, CompatSchemaPath, Debouncer, DisabledReason, FieldContext, FieldState, FieldTree, FieldValidator, FormOptions, ItemFieldContext, ItemType, LogicFn, MaybeFieldTree, MaybeSchemaPathTree, MetadataSetterType, OneOrMany, ReadonlyArrayLike, RootFieldContext, Schema, SchemaFn, SchemaOrSchemaFn, SchemaPath, SchemaPathTree, SignalFormsConfig, Subfields, SubmittedStatus, TreeValidationResult, TreeValidator, ValidationResult, ValidationSuccess, Validator, WithField, WithOptionalField, WithoutField };
|
package/types/forms.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.1.0-
|
|
3
|
-
* (c) 2010-
|
|
2
|
+
* @license Angular v21.1.0-rc.0
|
|
3
|
+
* (c) 2010-2026 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -1073,7 +1073,7 @@ type ɵFormArrayRawValue<T extends AbstractControl<any>> = ɵTypedOrUntyped<T, A
|
|
|
1073
1073
|
* the `FormArray` directly, as that result in strange and unexpected behavior such
|
|
1074
1074
|
* as broken change detection.
|
|
1075
1075
|
*
|
|
1076
|
-
* @see [FormArray: Dynamic, Homogenous Collections](guide/forms/typed-forms#
|
|
1076
|
+
* @see [FormArray: Dynamic, Homogenous Collections](guide/forms/typed-forms#formarray-dynamic-homogenous-collections)
|
|
1077
1077
|
* @see [Creating dynamic forms](guide/forms/reactive-forms#creating-dynamic-forms)
|
|
1078
1078
|
*
|
|
1079
1079
|
* @publicApi
|
|
@@ -2769,9 +2769,7 @@ declare abstract class AbstractControl<TValue = any, TRawValue extends TValue =
|
|
|
2769
2769
|
*
|
|
2770
2770
|
* @usageNotes
|
|
2771
2771
|
*
|
|
2772
|
-
*
|
|
2773
|
-
*
|
|
2774
|
-
* ```
|
|
2772
|
+
* ```ts
|
|
2775
2773
|
* // Reference to the RequiredValidator
|
|
2776
2774
|
* const ctrl = new FormControl<string | null>('', Validators.required);
|
|
2777
2775
|
* ctrl.removeValidators(Validators.required);
|
|
@@ -2809,9 +2807,7 @@ declare abstract class AbstractControl<TValue = any, TRawValue extends TValue =
|
|
|
2809
2807
|
*
|
|
2810
2808
|
* @usageNotes
|
|
2811
2809
|
*
|
|
2812
|
-
*
|
|
2813
|
-
*
|
|
2814
|
-
* ```
|
|
2810
|
+
* ```ts
|
|
2815
2811
|
* // Reference to the RequiredValidator
|
|
2816
2812
|
* const ctrl = new FormControl<number | null>(0, Validators.required);
|
|
2817
2813
|
* expect(ctrl.hasValidator(Validators.required)).toEqual(true)
|
|
@@ -2867,6 +2863,9 @@ declare abstract class AbstractControl<TValue = any, TRawValue extends TValue =
|
|
|
2867
2863
|
* * `emitEvent`: When true or not supplied (the default), the `events`
|
|
2868
2864
|
* observable emits a `TouchedChangeEvent` with the `touched` property being `true`.
|
|
2869
2865
|
* When false, no events are emitted.
|
|
2866
|
+
*
|
|
2867
|
+
* @see [Managing form control state](guide/forms/reactive-forms#managing-form-control-state)
|
|
2868
|
+
*
|
|
2870
2869
|
*/
|
|
2871
2870
|
markAsTouched(opts?: {
|
|
2872
2871
|
onlySelf?: boolean;
|
|
@@ -2881,6 +2880,9 @@ declare abstract class AbstractControl<TValue = any, TRawValue extends TValue =
|
|
|
2881
2880
|
* * `emitEvent`: When true or not supplied (the default), the `events`
|
|
2882
2881
|
* observable emits a `PristineChangeEvent` with the `pristine` property being `false`.
|
|
2883
2882
|
* When false, no events are emitted.
|
|
2883
|
+
*
|
|
2884
|
+
* @see [Managing form control state](guide/forms/reactive-forms#managing-form-control-state)
|
|
2885
|
+
*
|
|
2884
2886
|
*/
|
|
2885
2887
|
markAllAsDirty(opts?: {
|
|
2886
2888
|
emitEvent?: boolean;
|
|
@@ -2894,6 +2896,9 @@ declare abstract class AbstractControl<TValue = any, TRawValue extends TValue =
|
|
|
2894
2896
|
* * `emitEvent`: When true or not supplied (the default), the `events`
|
|
2895
2897
|
* observable emits a `TouchedChangeEvent` with the `touched` property being `true`.
|
|
2896
2898
|
* When false, no events are emitted.
|
|
2899
|
+
*
|
|
2900
|
+
* @see [Managing form control state](guide/forms/reactive-forms#managing-form-control-state)
|
|
2901
|
+
*
|
|
2897
2902
|
*/
|
|
2898
2903
|
markAllAsTouched(opts?: {
|
|
2899
2904
|
emitEvent?: boolean;
|
|
@@ -2915,6 +2920,9 @@ declare abstract class AbstractControl<TValue = any, TRawValue extends TValue =
|
|
|
2915
2920
|
* * `emitEvent`: When true or not supplied (the default), the `events`
|
|
2916
2921
|
* observable emits a `TouchedChangeEvent` with the `touched` property being `false`.
|
|
2917
2922
|
* When false, no events are emitted.
|
|
2923
|
+
*
|
|
2924
|
+
* @see [Managing form control state](guide/forms/reactive-forms#managing-form-control-state)
|
|
2925
|
+
*
|
|
2918
2926
|
*/
|
|
2919
2927
|
markAsUntouched(opts?: {
|
|
2920
2928
|
onlySelf?: boolean;
|
|
@@ -2935,6 +2943,9 @@ declare abstract class AbstractControl<TValue = any, TRawValue extends TValue =
|
|
|
2935
2943
|
* * `emitEvent`: When true or not supplied (the default), the `events`
|
|
2936
2944
|
* observable emits a `PristineChangeEvent` with the `pristine` property being `false`.
|
|
2937
2945
|
* When false, no events are emitted.
|
|
2946
|
+
*
|
|
2947
|
+
* @see [Managing form control state](guide/forms/reactive-forms#managing-form-control-state)
|
|
2948
|
+
*
|
|
2938
2949
|
*/
|
|
2939
2950
|
markAsDirty(opts?: {
|
|
2940
2951
|
onlySelf?: boolean;
|
|
@@ -2958,6 +2969,9 @@ declare abstract class AbstractControl<TValue = any, TRawValue extends TValue =
|
|
|
2958
2969
|
* * `emitEvent`: When true or not supplied (the default), the `events`
|
|
2959
2970
|
* observable emits a `PristineChangeEvent` with the `pristine` property being `true`.
|
|
2960
2971
|
* When false, no events are emitted.
|
|
2972
|
+
*
|
|
2973
|
+
* @see [Managing form control state](guide/forms/reactive-forms#managing-form-control-state)
|
|
2974
|
+
*
|
|
2961
2975
|
*/
|
|
2962
2976
|
markAsPristine(opts?: {
|
|
2963
2977
|
onlySelf?: boolean;
|
|
@@ -3064,6 +3078,9 @@ declare abstract class AbstractControl<TValue = any, TRawValue extends TValue =
|
|
|
3064
3078
|
* `valueChanges` and `events`
|
|
3065
3079
|
* observables emit events with the latest status and value when the control is updated.
|
|
3066
3080
|
* When false, no events are emitted.
|
|
3081
|
+
*
|
|
3082
|
+
* @see [Understanding propagation control](guide/forms/reactive-forms#understanding-event-emission)
|
|
3083
|
+
*
|
|
3067
3084
|
*/
|
|
3068
3085
|
updateValueAndValidity(opts?: {
|
|
3069
3086
|
onlySelf?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.1.0-
|
|
3
|
-
* (c) 2010-
|
|
2
|
+
* @license Angular v21.1.0-rc.0
|
|
3
|
+
* (c) 2010-2026 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -121,7 +121,7 @@ declare function compatForm<TModel>(model: WritableSignal<TModel>, schema: Schem
|
|
|
121
121
|
declare class CompatValidationError<T = unknown> implements ValidationError {
|
|
122
122
|
readonly kind: string;
|
|
123
123
|
readonly control: AbstractControl;
|
|
124
|
-
readonly
|
|
124
|
+
readonly fieldTree: FieldTree<unknown>;
|
|
125
125
|
readonly context: T;
|
|
126
126
|
readonly message?: string;
|
|
127
127
|
constructor({ context, kind, control }: {
|