@angular/forms 21.2.0-next.3 → 21.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/forms",
3
- "version": "21.2.0-next.3",
3
+ "version": "21.2.0-rc.0",
4
4
  "description": "Angular - directives and services for creating forms",
5
5
  "author": "angular",
6
6
  "license": "MIT",
@@ -12,9 +12,9 @@
12
12
  "@standard-schema/spec": "^1.0.0"
13
13
  },
14
14
  "peerDependencies": {
15
- "@angular/core": "21.2.0-next.3",
16
- "@angular/common": "21.2.0-next.3",
17
- "@angular/platform-browser": "21.2.0-next.3",
15
+ "@angular/core": "21.2.0-rc.0",
16
+ "@angular/common": "21.2.0-rc.0",
17
+ "@angular/platform-browser": "21.2.0-rc.0",
18
18
  "rxjs": "^6.5.3 || ^7.4.0"
19
19
  },
20
20
  "repository": {
Binary file
@@ -1,12 +1,11 @@
1
1
  /**
2
- * @license Angular v21.2.0-next.3
2
+ * @license Angular v21.2.0-rc.0
3
3
  * (c) 2010-2026 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import * as i0 from '@angular/core';
8
8
  import { WritableSignal, Signal, InjectionToken, Injector, Provider } from '@angular/core';
9
- import * as _angular_forms from '@angular/forms';
10
9
  import { AbstractControl, ValidationErrors, FormControlStatus, ControlValueAccessor, ValidatorFn } from '@angular/forms';
11
10
  import { StandardSchemaV1 } from '@standard-schema/spec';
12
11
 
@@ -153,6 +152,16 @@ type ValidationResult<E extends ValidationError = ValidationError> = ValidationS
153
152
  * @experimental 21.0.0
154
153
  */
155
154
  type AsyncValidationResult<E extends ValidationError = ValidationError> = ValidationResult<E> | 'pending';
155
+ /**
156
+ * A field accessor function that returns the state of the field.
157
+ *
158
+ * @template TValue The type of the value stored in the field.
159
+ * @template TKey The type of the property key which this field resides under in its parent.
160
+ *
161
+ * @category types
162
+ * @experimental 21.2.0
163
+ */
164
+ type Field<TValue, TKey extends string | number = string | number> = () => FieldState<TValue, TKey>;
156
165
  /**
157
166
  * An object that represents a tree of fields in a form. This includes both primitive value fields
158
167
  * (e.g. fields that contain a `string` or `number`), as well as "grouping fields" that contain
@@ -956,11 +965,11 @@ declare const FORM_FIELD: InjectionToken<FormField<unknown>>;
956
965
  * @experimental 21.0.0
957
966
  */
958
967
  declare class FormField<T> {
959
- readonly fieldTree: i0.InputSignal<FieldTree<T>>;
968
+ readonly field: i0.InputSignal<Field<T>>;
960
969
  /**
961
970
  * `FieldState` for the currently bound field.
962
971
  */
963
- readonly state: Signal<[T] extends [_angular_forms.AbstractControl<any, any, any>] ? CompatFieldState<T, string | number> : FieldState<T, string | number>>;
972
+ readonly state: Signal<FieldState<T, string | number>>;
964
973
  /**
965
974
  * The node injector for the element this field binding.
966
975
  */
@@ -1015,7 +1024,7 @@ declare class FormField<T> {
1015
1024
  */
1016
1025
  readonly [ɵNgFieldDirective]: true;
1017
1026
  static ɵfac: i0.ɵɵFactoryDeclaration<FormField<any>, never>;
1018
- static ɵdir: i0.ɵɵDirectiveDeclaration<FormField<any>, "[formField]", ["formField"], { "fieldTree": { "alias": "formField"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
1027
+ static ɵdir: i0.ɵɵDirectiveDeclaration<FormField<any>, "[formField]", ["formField"], { "field": { "alias": "formField"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
1019
1028
  }
1020
1029
 
1021
1030
  /**
@@ -1333,6 +1342,15 @@ declare class PatternValidationError extends BaseNgValidationError {
1333
1342
  declare class EmailValidationError extends BaseNgValidationError {
1334
1343
  readonly kind = "email";
1335
1344
  }
1345
+ /**
1346
+ * An error used to indicate that a value entered in a native input does not parse.
1347
+ *
1348
+ * @category validation
1349
+ * @experimental 21.2.0
1350
+ */
1351
+ declare class NativeInputParseError extends BaseNgValidationError {
1352
+ readonly kind = "parse";
1353
+ }
1336
1354
  /**
1337
1355
  * The base class for all built-in, non-custom errors. This class can be used to check if an error
1338
1356
  * is one of the standard kinds, allowing you to switch on the kind to further narrow the type.
@@ -1359,7 +1377,7 @@ declare class EmailValidationError extends BaseNgValidationError {
1359
1377
  * @experimental 21.0.0
1360
1378
  */
1361
1379
  declare const NgValidationError: abstract new () => NgValidationError;
1362
- type NgValidationError = RequiredValidationError | MinValidationError | MaxValidationError | MinLengthValidationError | MaxLengthValidationError | PatternValidationError | EmailValidationError | StandardSchemaValidationError;
1380
+ type NgValidationError = RequiredValidationError | MinValidationError | MaxValidationError | MinLengthValidationError | MaxLengthValidationError | PatternValidationError | EmailValidationError | StandardSchemaValidationError | NativeInputParseError;
1363
1381
 
1364
1382
  /**
1365
1383
  * Configuration options for signal forms.
@@ -1648,5 +1666,5 @@ declare function submit<TModel>(form: FieldTree<TModel>, action: NoInfer<FormSub
1648
1666
  */
1649
1667
  declare function schema<TValue>(fn: SchemaFn<TValue>): Schema<TValue>;
1650
1668
 
1651
- export { BaseNgValidationError, EmailValidationError, FORM_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, validateStandardSchema, ɵNgFieldDirective };
1652
- export type { AsyncValidationResult, ChildFieldContext, CompatFieldState, CompatSchemaPath, Debouncer, DisabledReason, FieldContext, FieldState, FieldTree, FieldValidator, FormFieldBindingOptions, FormOptions, FormSubmitOptions, IgnoreUnknownProperties, ItemFieldContext, ItemType, LogicFn, MaybeFieldTree, MaybeSchemaPathTree, MetadataSetterType, OneOrMany, ReadonlyArrayLike, RemoveStringIndexUnknownKey, RootFieldContext, Schema, SchemaFn, SchemaOrSchemaFn, SchemaPath, SchemaPathTree, SignalFormsConfig, Subfields, TreeValidationResult, TreeValidator, ValidationErrorOptions, ValidationResult, ValidationSuccess, Validator, WithField, WithFieldTree, WithOptionalField, WithOptionalFieldTree, WithoutField, WithoutFieldTree };
1669
+ export { BaseNgValidationError, EmailValidationError, FORM_FIELD, FormField, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MetadataKey, MetadataReducer, MinLengthValidationError, MinValidationError, NativeInputParseError, 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, validateStandardSchema, ɵNgFieldDirective };
1670
+ export type { AsyncValidationResult, ChildFieldContext, CompatFieldState, CompatSchemaPath, Debouncer, DisabledReason, Field, FieldContext, FieldState, FieldTree, FieldValidator, FormFieldBindingOptions, FormOptions, FormSubmitOptions, IgnoreUnknownProperties, ItemFieldContext, ItemType, LogicFn, MaybeFieldTree, MaybeSchemaPathTree, MetadataSetterType, OneOrMany, ReadonlyArrayLike, RemoveStringIndexUnknownKey, RootFieldContext, Schema, SchemaFn, SchemaOrSchemaFn, SchemaPath, SchemaPathTree, SignalFormsConfig, Subfields, TreeValidationResult, TreeValidator, ValidationErrorOptions, ValidationResult, ValidationSuccess, Validator, WithField, WithFieldTree, WithOptionalField, WithOptionalFieldTree, WithoutField, WithoutFieldTree };
package/types/forms.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v21.2.0-next.3
2
+ * @license Angular v21.2.0-rc.0
3
3
  * (c) 2010-2026 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v21.2.0-next.3
2
+ * @license Angular v21.2.0-rc.0
3
3
  * (c) 2010-2026 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v21.2.0-next.3
2
+ * @license Angular v21.2.0-rc.0
3
3
  * (c) 2010-2026 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
@@ -7,7 +7,7 @@
7
7
  import * as i0 from '@angular/core';
8
8
  import { Signal, ResourceRef, InputSignal, InputSignalWithTransform, ModelSignal, OutputRef, WritableSignal } from '@angular/core';
9
9
  import { PathKind, SchemaPath, SchemaPathRules, LogicFn, OneOrMany, ValidationError, FieldValidator, FieldContext, TreeValidationResult, TreeValidator, WithOptionalFieldTree, DisabledReason, Debouncer, FieldTree } from './_structure-chunk.js';
10
- export { AsyncValidationResult, BaseNgValidationError, ChildFieldContext, CompatFieldState, CompatSchemaPath, EmailValidationError, FORM_FIELD, FieldState, FormField, FormFieldBindingOptions, FormOptions, FormSubmitOptions, IgnoreUnknownProperties, ItemFieldContext, ItemType, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MaybeFieldTree, MaybeSchemaPathTree, MetadataKey, MetadataReducer, MetadataSetterType, MinLengthValidationError, MinValidationError, NgValidationError, PATTERN, PatternValidationError, REQUIRED, ReadonlyArrayLike, RemoveStringIndexUnknownKey, RequiredValidationError, RootFieldContext, Schema, SchemaFn, SchemaOrSchemaFn, SchemaPathTree, SignalFormsConfig, StandardSchemaValidationError, Subfields, ValidationErrorOptions, ValidationResult, ValidationSuccess, Validator, WithField, WithFieldTree, WithOptionalField, WithoutField, WithoutFieldTree, apply, applyEach, applyWhen, applyWhenValue, createManagedMetadataKey, createMetadataKey, emailError, form, maxError, maxLengthError, metadata, minError, minLengthError, patternError, provideSignalFormsConfig, requiredError, schema, standardSchemaError, submit, validateStandardSchema, ɵNgFieldDirective } from './_structure-chunk.js';
10
+ export { AsyncValidationResult, BaseNgValidationError, ChildFieldContext, CompatFieldState, CompatSchemaPath, EmailValidationError, FORM_FIELD, Field, FieldState, FormField, FormFieldBindingOptions, FormOptions, FormSubmitOptions, IgnoreUnknownProperties, ItemFieldContext, ItemType, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MaybeFieldTree, MaybeSchemaPathTree, MetadataKey, MetadataReducer, MetadataSetterType, MinLengthValidationError, MinValidationError, NativeInputParseError, NgValidationError, PATTERN, PatternValidationError, REQUIRED, ReadonlyArrayLike, RemoveStringIndexUnknownKey, RequiredValidationError, RootFieldContext, Schema, SchemaFn, SchemaOrSchemaFn, SchemaPathTree, SignalFormsConfig, StandardSchemaValidationError, Subfields, ValidationErrorOptions, ValidationResult, ValidationSuccess, Validator, WithField, WithFieldTree, WithOptionalField, WithoutField, WithoutFieldTree, apply, applyEach, applyWhen, applyWhenValue, createManagedMetadataKey, createMetadataKey, emailError, form, maxError, maxLengthError, metadata, minError, minLengthError, patternError, provideSignalFormsConfig, requiredError, schema, standardSchemaError, submit, validateStandardSchema, ɵNgFieldDirective } from './_structure-chunk.js';
11
11
  import { HttpResourceRequest, HttpResourceOptions } from '@angular/common/http';
12
12
  import '@angular/forms';
13
13
  import '@standard-schema/spec';
@@ -389,7 +389,7 @@ declare function validateTree<TValue, TPathKind extends PathKind = PathKind.Root
389
389
  * @category control
390
390
  * @experimental 21.0.0
391
391
  */
392
- interface FormUiControl<TValue> {
392
+ interface FormUiControl {
393
393
  /**
394
394
  * An input to receive the errors for the field. If implemented, the `Field` directive will
395
395
  * automatically bind errors from the bound field to this input.
@@ -491,7 +491,7 @@ interface FormUiControl<TValue> {
491
491
  * @category control
492
492
  * @experimental 21.0.0
493
493
  */
494
- interface FormValueControl<TValue> extends FormUiControl<TValue> {
494
+ interface FormValueControl<TValue> extends FormUiControl {
495
495
  /**
496
496
  * The value is the only required property in this contract. A component that wants to integrate
497
497
  * with the `Field` directive via this contract, *must* provide a `model()` that will be kept in
@@ -515,7 +515,7 @@ interface FormValueControl<TValue> extends FormUiControl<TValue> {
515
515
  * @category control
516
516
  * @experimental 21.0.0
517
517
  */
518
- interface FormCheckboxControl extends FormUiControl<boolean> {
518
+ interface FormCheckboxControl extends FormUiControl {
519
519
  /**
520
520
  * The checked is the only required property in this contract. A component that wants to integrate
521
521
  * with the `Field` directive, *must* provide a `model()` that will be kept in sync with the
@@ -543,6 +543,19 @@ interface FormCheckboxControl extends FormUiControl<boolean> {
543
543
  */
544
544
  declare function debounce<TValue, TPathKind extends PathKind = PathKind.Root>(path: SchemaPath<TValue, SchemaPathRules.Supported, TPathKind>, durationOrDebouncer: number | Debouncer<TValue, TPathKind>): void;
545
545
 
546
+ /**
547
+ * Result of parsing a raw value into a model value.
548
+ */
549
+ interface ParseResult<TValue> {
550
+ /**
551
+ * The parsed value, if parsing was successful.
552
+ */
553
+ readonly value?: TValue;
554
+ /**
555
+ * Errors encountered during parsing, if any.
556
+ */
557
+ readonly errors?: readonly ValidationError.WithoutFieldTree[];
558
+ }
546
559
  /**
547
560
  * Options for `transformedValue`.
548
561
  *
@@ -556,10 +569,7 @@ interface TransformedValueOptions<TValue, TRaw> {
556
569
  * - `value`: The parsed model value. If `undefined`, the model will not be updated.
557
570
  * - `errors`: Any parse errors encountered. If `undefined`, no errors are reported.
558
571
  */
559
- parse: (rawValue: TRaw) => {
560
- value?: TValue;
561
- errors?: readonly ValidationError.WithoutFieldTree[];
562
- };
572
+ parse: (rawValue: TRaw) => ParseResult<TValue>;
563
573
  /**
564
574
  * Format the model value into the raw value.
565
575
  */
@@ -643,4 +653,4 @@ declare class FormRoot<T> {
643
653
  }
644
654
 
645
655
  export { Debouncer, DisabledReason, FieldContext, FieldTree, FieldValidator, FormRoot, LogicFn, OneOrMany, PathKind, SchemaPath, SchemaPathRules, TreeValidationResult, TreeValidator, ValidationError, WithOptionalFieldTree, debounce, disabled, email, hidden, max, maxLength, min, minLength, pattern, readonly, required, transformedValue, validate, validateAsync, validateHttp, validateTree };
646
- export type { AsyncValidatorOptions, FormCheckboxControl, FormUiControl, FormValueControl, HttpValidatorOptions, MapToErrorsFn, TransformedValueOptions, TransformedValueSignal };
656
+ export type { AsyncValidatorOptions, FormCheckboxControl, FormUiControl, FormValueControl, HttpValidatorOptions, MapToErrorsFn, ParseResult, TransformedValueOptions, TransformedValueSignal };