@angular/forms 21.0.0-next.8 → 21.0.0-next.9

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.0.0-next.8",
3
+ "version": "21.0.0-next.9",
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.8",
15
- "@angular/common": "21.0.0-next.8",
16
- "@angular/platform-browser": "21.0.0-next.8",
14
+ "@angular/core": "21.0.0-next.9",
15
+ "@angular/common": "21.0.0-next.9",
16
+ "@angular/platform-browser": "21.0.0-next.9",
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
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v21.0.0-next.8
2
+ * @license Angular v21.0.0-next.9
3
3
  * (c) 2010-2025 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
@@ -1285,6 +1285,7 @@ declare class FormArray<TControl extends AbstractControl<any> = any> extends Abs
1285
1285
  reset(value?: ɵTypedOrUntyped<TControl, ɵFormArrayValue<TControl>, any>, options?: {
1286
1286
  onlySelf?: boolean;
1287
1287
  emitEvent?: boolean;
1288
+ overwriteDefaultValue?: boolean;
1288
1289
  }): void;
1289
1290
  /**
1290
1291
  * The aggregate value of the array, including any disabled controls.
@@ -1585,7 +1586,7 @@ interface FormControl<TValue = any> extends AbstractControl<TValue> {
1585
1586
  * value. See {@link FormControlOptions#nonNullable} for more information on configuring
1586
1587
  * a default value.
1587
1588
  */
1588
- readonly defaultValue: TValue;
1589
+ defaultValue: TValue;
1589
1590
  /**
1590
1591
  * Sets a new value for the form control.
1591
1592
  *
@@ -1661,11 +1662,13 @@ interface FormControl<TValue = any> extends AbstractControl<TValue> {
1661
1662
  * `valueChanges`
1662
1663
  * observables emit events with the latest status and value when the control is reset.
1663
1664
  * When false, no events are emitted.
1665
+ * * `overwriteDefaultValue`: When true, the value used to reset the control becomes the new default value of the control.
1664
1666
  *
1665
1667
  */
1666
1668
  reset(formState?: TValue | FormControlState<TValue>, options?: {
1667
1669
  onlySelf?: boolean;
1668
1670
  emitEvent?: boolean;
1671
+ overwriteDefaultValue?: boolean;
1669
1672
  }): void;
1670
1673
  /**
1671
1674
  * For a simple FormControl, the raw value is equivalent to the value.
@@ -2103,6 +2106,7 @@ declare class FormGroup<TControl extends {
2103
2106
  reset(value?: ɵTypedOrUntyped<TControl, ɵFormGroupArgumentValue<TControl>, any>, options?: {
2104
2107
  onlySelf?: boolean;
2105
2108
  emitEvent?: boolean;
2109
+ overwriteDefaultValue?: boolean;
2106
2110
  }): void;
2107
2111
  /**
2108
2112
  * The aggregate value of the `FormGroup`, including any disabled controls.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v21.0.0-next.8
2
+ * @license Angular v21.0.0-next.9
3
3
  * (c) 2010-2025 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
@@ -7,8 +7,41 @@
7
7
  import { HttpResourceRequest, HttpResourceOptions } from '@angular/common/http';
8
8
  import * as i0 from '@angular/core';
9
9
  import { InjectionToken, ɵControl as _Control, ɵCONTROL as _CONTROL, ɵFieldState as _FieldState, Signal, ResourceRef, InputSignal, ModelSignal, OutputRef, WritableSignal, DestroyableInjector, Injector } from '@angular/core';
10
+ import { NgControl, AbstractControl, ValidationErrors, FormControlStatus, ControlValueAccessor, ValidatorFn } from '@angular/forms';
10
11
  import { StandardSchemaV1 } from '@standard-schema/spec';
11
12
 
13
+ /**
14
+ * Properties of both NgControl & AbstractControl that are supported by the InteropNgControl.
15
+ */
16
+ type InteropSharedKeys = 'value' | 'valid' | 'invalid' | 'touched' | 'untouched' | 'disabled' | 'enabled' | 'errors' | 'pristine' | 'dirty' | 'status';
17
+ /**
18
+ * A fake version of `NgControl` provided by the `Field` directive. This allows interoperability
19
+ * with a wider range of components designed to work with reactive forms, in particular ones that
20
+ * inject the `NgControl`. The interop control does not implement *all* properties and methods of
21
+ * the real `NgControl`, but does implement some of the most commonly used ones that have a clear
22
+ * equivalent in signal forms.
23
+ */
24
+ declare class InteropNgControl implements Pick<NgControl, InteropSharedKeys | 'control' | 'valueAccessor'>, Pick<AbstractControl<unknown>, InteropSharedKeys | 'hasValidator'> {
25
+ protected field: () => FieldState<unknown>;
26
+ constructor(field: () => FieldState<unknown>);
27
+ readonly control: AbstractControl<any, any>;
28
+ get value(): any;
29
+ get valid(): boolean;
30
+ get invalid(): boolean;
31
+ get pending(): boolean | null;
32
+ get disabled(): boolean;
33
+ get enabled(): boolean;
34
+ get errors(): ValidationErrors | null;
35
+ get pristine(): boolean;
36
+ get dirty(): boolean;
37
+ get touched(): boolean;
38
+ get untouched(): boolean;
39
+ get status(): FormControlStatus;
40
+ valueAccessor: ControlValueAccessor | null;
41
+ hasValidator(validator: ValidatorFn): boolean;
42
+ updateValueAndValidity(): void;
43
+ }
44
+
12
45
  /**
13
46
  * Lightweight DI token provided by the {@link Field} directive.
14
47
  */
@@ -17,16 +50,14 @@ declare const FIELD: InjectionToken<Field<unknown>>;
17
50
  * Binds a form `FieldTree` to a UI control that edits it. A UI control can be one of several things:
18
51
  * 1. A native HTML input or textarea
19
52
  * 2. A signal forms custom control that implements `FormValueControl` or `FormCheckboxControl`
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
53
+ * 3. A component that provides a `ControlValueAccessor`. This should only be used for backwards
22
54
  * compatibility with reactive forms. Prefer options (1) and (2).
23
55
  *
24
56
  * This directive has several responsibilities:
25
57
  * 1. Two-way binds the field's value with the UI control's value
26
58
  * 2. Binds additional forms related state on the field to the UI control (disabled, required, etc.)
27
59
  * 3. Relays relevant events on the control to the field (e.g. marks field touched on blur)
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
60
+ * 4. Provides a fake `NgControl` that implements a subset of the features available on the
30
61
  * reactive forms `NgControl`. This is provided to improve interoperability with controls
31
62
  * designed to work with reactive forms. It should not be used by controls written for signal
32
63
  * forms.
@@ -39,7 +70,18 @@ declare class Field<T> implements _Control<T> {
39
70
  readonly field: i0.InputSignal<FieldTree<T>>;
40
71
  readonly state: i0.Signal<FieldState<T, string | number>>;
41
72
  readonly [_CONTROL]: undefined;
42
- register(): void;
73
+ /** Any `ControlValueAccessor` instances provided on the host element. */
74
+ private readonly controlValueAccessors;
75
+ /** A lazily instantiated fake `NgControl`. */
76
+ private interopNgControl;
77
+ /** A `ControlValueAccessor`, if configured, for the host component. */
78
+ private get controlValueAccessor();
79
+ get ɵhasInteropControl(): boolean;
80
+ /** Lazily instantiates a fake `NgControl` for this field. */
81
+ ɵgetOrCreateNgControl(): InteropNgControl;
82
+ ɵinteropControlCreate(): void;
83
+ ɵinteropControlUpdate(): void;
84
+ ɵregister(): void;
43
85
  static ɵfac: i0.ɵɵFactoryDeclaration<Field<any>, never>;
44
86
  static ɵdir: i0.ɵɵDirectiveDeclaration<Field<any>, "[field]", never, { "field": { "alias": "field"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
45
87
  }
@@ -518,15 +560,6 @@ type NgValidationError = RequiredValidationError | MinValidationError | MaxValid
518
560
  * Symbol used to retain generic type information when it would otherwise be lost.
519
561
  */
520
562
  declare const ɵɵTYPE: unique symbol;
521
- /**
522
- * Creates a type based on the given type T, but with all readonly properties made writable.
523
- * @template T The type to create a mutable version of.
524
- *
525
- * @experimental 21.0.0
526
- */
527
- type Mutable<T> = {
528
- -readonly [P in keyof T]: T[P];
529
- };
530
563
  /**
531
564
  * A type that represents either a single value of type `T` or a readonly array of `T`.
532
565
  * @template T The type of the value(s).
@@ -1445,7 +1478,7 @@ declare class LogicContainer {
1445
1478
  */
1446
1479
  constructor(predicates: ReadonlyArray<BoundPredicate>);
1447
1480
  /** Checks whether there is logic for the given aggregate property. */
1448
- hasAggregateProperty(prop: AggregateProperty<unknown, unknown>): boolean;
1481
+ hasAggregateProperty(prop: AggregateProperty<any, any>): boolean;
1449
1482
  /**
1450
1483
  * Gets an iterable of [aggregate property, logic function] pairs.
1451
1484
  * @returns An iterable of aggregate property entries.
@@ -1682,7 +1715,7 @@ declare class FieldPropertyState {
1682
1715
  * @param prop
1683
1716
  * @returns
1684
1717
  */
1685
- has(prop: Property<unknown> | AggregateProperty<unknown, unknown>): boolean;
1718
+ has(prop: Property<any> | AggregateProperty<any, any>): boolean;
1686
1719
  }
1687
1720
 
1688
1721
  /**
@@ -1935,15 +1968,16 @@ declare class FieldNode implements FieldState<unknown> {
1935
1968
  get fieldBindings(): Signal<readonly Field<unknown>[]>;
1936
1969
  get submitting(): Signal<boolean>;
1937
1970
  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>;
1971
+ private propertyOrUndefined;
1972
+ get max(): Signal<number | undefined> | undefined;
1973
+ get maxLength(): Signal<number | undefined> | undefined;
1974
+ get min(): Signal<number | undefined> | undefined;
1975
+ get minLength(): Signal<number | undefined> | undefined;
1976
+ get pattern(): Signal<readonly RegExp[]> | undefined;
1977
+ get required(): Signal<boolean> | undefined;
1944
1978
  property<M>(prop: AggregateProperty<M, any>): Signal<M>;
1945
1979
  property<M>(prop: Property<M>): M | undefined;
1946
- hasProperty(prop: Property<unknown> | AggregateProperty<unknown, any>): boolean;
1980
+ hasProperty(prop: Property<any> | AggregateProperty<any, any>): boolean;
1947
1981
  /**
1948
1982
  * Marks this specific field as touched.
1949
1983
  */
@@ -2651,4 +2685,4 @@ type IgnoreUnknownProperties<T> = T extends Record<PropertyKey, unknown> ? {
2651
2685
  declare function validateStandardSchema<TSchema, TValue extends IgnoreUnknownProperties<TSchema>>(path: FieldPath<TValue>, schema: StandardSchemaV1<TSchema>): void;
2652
2686
 
2653
2687
  export { AggregateProperty, CustomValidationError, EmailValidationError, FIELD, Field, 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 };
2688
+ export type { AsyncValidationResult, AsyncValidatorOptions, ChildFieldContext, DisabledReason, FieldContext, FieldPath, FieldState, FieldTree, FieldValidationResult, FieldValidator, FormCheckboxControl, FormOptions, FormUiControl, FormValueControl, HttpValidatorOptions, IgnoreUnknownProperties, ItemFieldContext, LogicFn, MapToErrorsFn, MaybeFieldPath, MaybeFieldTree, OneOrMany, ReadonlyArrayLike, RemoveStringIndexUnknownKey, RootFieldContext, Schema, SchemaFn, SchemaOrSchemaFn, Subfields, SubmittedStatus, TreeValidationResult, TreeValidator, ValidationError, ValidationResult, ValidationSuccess, Validator, WithField, WithOptionalField, WithoutField };