@angular/forms 21.1.0 → 21.2.0-next.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.
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license Angular v21.1.0
2
+ * @license Angular v21.2.0-next.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
- import { InjectionToken, Injector, ɵCONTROL as _CONTROL, ɵɵcontrolCreate as __controlCreate, ɵcontrolUpdate as _controlUpdate, Signal, ɵFieldState as _FieldState, Provider, WritableSignal, DestroyableInjector } from '@angular/core';
8
+ import { ɵFormFieldBindingOptions as _FormFieldBindingOptions, InjectionToken, Injector, ɵCONTROL as _CONTROL, ɵɵcontrolCreate as __controlCreate, ɵcontrolUpdate as _controlUpdate, Signal, ɵFieldState as _FieldState, Provider, WritableSignal, DestroyableInjector } from '@angular/core';
9
9
  import * as _angular_forms from '@angular/forms';
10
10
  import { NgControl, AbstractControl, ValidationErrors, FormControlStatus, ControlValueAccessor, ValidatorFn } from '@angular/forms';
11
11
  import { StandardSchemaV1 } from '@standard-schema/spec';
@@ -42,6 +42,15 @@ declare class InteropNgControl implements Pick<NgControl, InteropSharedKeys | 'c
42
42
  updateValueAndValidity(): void;
43
43
  }
44
44
 
45
+ interface FormFieldBindingOptions extends _FormFieldBindingOptions {
46
+ /**
47
+ * Focuses the binding.
48
+ *
49
+ * If not specified, Signal Forms will attempt to focus the host element of the `FormField` when
50
+ * asked to focus this binding.
51
+ */
52
+ focus?(options?: FocusOptions): void;
53
+ }
45
54
  /**
46
55
  * Lightweight DI token provided by the {@link FormField} directive.
47
56
  *
@@ -73,6 +82,7 @@ declare class FormField<T> {
73
82
  readonly injector: Injector;
74
83
  readonly formField: i0.InputSignal<FieldTree<T>>;
75
84
  readonly state: i0.Signal<[T] extends [_angular_forms.AbstractControl<any, any, any>] ? CompatFieldState<T, string | number> : FieldState<T, string | number>>;
85
+ private readonly bindingOptions;
76
86
  readonly [_CONTROL]: {
77
87
  readonly create: typeof __controlCreate;
78
88
  readonly update: typeof _controlUpdate;
@@ -84,8 +94,15 @@ declare class FormField<T> {
84
94
  private interopNgControl;
85
95
  /** Lazily instantiates a fake `NgControl` for this form field. */
86
96
  protected getOrCreateNgControl(): InteropNgControl;
97
+ /**
98
+ * Registers this `FormField` as a binding on its associated `FieldState`.
99
+ *
100
+ * This method should be called at most once for a given `FormField`. A `FormField` placed on a
101
+ * custom control (`FormUiControl`) automatically registers that custom control as a binding.
102
+ */
103
+ registerAsBinding(bindingOptions?: FormFieldBindingOptions): void;
87
104
  /** Focuses this UI control. */
88
- focus?(): void;
105
+ focus(options?: FocusOptions): void;
89
106
  static ɵfac: i0.ɵɵFactoryDeclaration<FormField<any>, never>;
90
107
  static ɵdir: i0.ɵɵDirectiveDeclaration<FormField<any>, "[formField]", never, { "formField": { "alias": "formField"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
91
108
  }
@@ -298,13 +315,6 @@ declare namespace PathKind {
298
315
  [ɵɵTYPE]: 'item';
299
316
  }
300
317
  }
301
- /**
302
- * A status indicating whether a field is unsubmitted, submitted, or currently submitting.
303
- *
304
- * @category types
305
- * @experimental 21.0.0
306
- */
307
- type SubmittedStatus = 'unsubmitted' | 'submitted' | 'submitting';
308
318
  /**
309
319
  * A reason for a field's disablement.
310
320
  *
@@ -501,8 +511,9 @@ interface FieldState<TValue, TKey extends string | number = string | number> ext
501
511
  /**
502
512
  * Focuses the first UI control in the DOM that is bound to this field state.
503
513
  * If no UI control is bound, does nothing.
514
+ * @param options Optional focus options to pass to the native focus() method.
504
515
  */
505
- focusBoundControl(): void;
516
+ focusBoundControl(options?: FocusOptions): void;
506
517
  }
507
518
  /**
508
519
  * This is FieldState also providing access to the wrapped FormControl.
@@ -1734,7 +1745,7 @@ declare class FieldNode implements FieldState<unknown> {
1734
1745
  readonly fieldProxy: FieldTree<any>;
1735
1746
  private readonly pathNode;
1736
1747
  constructor(options: FieldNodeOptions);
1737
- focusBoundControl(): void;
1748
+ focusBoundControl(options?: FocusOptions): void;
1738
1749
  /**
1739
1750
  * Gets the Field directive binding that should be focused when the developer calls
1740
1751
  * `focusBoundControl` on this node.
@@ -1805,6 +1816,10 @@ declare class FieldNode implements FieldState<unknown> {
1805
1816
  * Synchronizes the {@link controlValue} with the {@link value} signal immediately.
1806
1817
  */
1807
1818
  private sync;
1819
+ /**
1820
+ * If there is a pending sync, abort it and sync immediately.
1821
+ */
1822
+ private flushSync;
1808
1823
  /**
1809
1824
  * Initiates a debounced {@link sync}.
1810
1825
  *
@@ -2373,4 +2388,4 @@ declare function submit<TModel>(form: FieldTree<TModel>, action: (form: FieldTre
2373
2388
  declare function schema<TValue>(fn: SchemaFn<TValue>): Schema<TValue>;
2374
2389
 
2375
2390
  export { 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 };
2376
- 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 };
2391
+ export type { AsyncValidationResult, ChildFieldContext, CompatFieldState, CompatSchemaPath, Debouncer, DisabledReason, FieldContext, FieldState, FieldTree, FieldValidator, FormFieldBindingOptions, FormOptions, ItemFieldContext, ItemType, LogicFn, MaybeFieldTree, MaybeSchemaPathTree, MetadataSetterType, OneOrMany, ReadonlyArrayLike, RootFieldContext, Schema, SchemaFn, SchemaOrSchemaFn, SchemaPath, SchemaPathTree, SignalFormsConfig, Subfields, TreeValidationResult, TreeValidator, ValidationResult, ValidationSuccess, Validator, WithField, WithOptionalField, WithoutField };
package/types/forms.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v21.1.0
2
+ * @license Angular v21.2.0-next.0
3
3
  * (c) 2010-2026 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
@@ -4538,7 +4538,7 @@ declare class NgForm extends ControlContainer implements Form, AfterViewInit {
4538
4538
  * and `FormArray` instances to child `FormControlName`, `FormGroupName`,
4539
4539
  * and `FormArrayName` directives.
4540
4540
  *
4541
- * @see [Reactive Forms Guide](guide/reactive-forms)
4541
+ * @see [Reactive Forms Guide](guide/forms/reactive-forms)
4542
4542
  * @see {@link AbstractControl}
4543
4543
  *
4544
4544
  * @usageNotes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v21.1.0
2
+ * @license Angular v21.2.0-next.0
3
3
  * (c) 2010-2026 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
@@ -1,12 +1,12 @@
1
1
  /**
2
- * @license Angular v21.1.0
2
+ * @license Angular v21.2.0-next.0
3
3
  * (c) 2010-2026 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import { Signal, ResourceRef, InputSignal, InputSignalWithTransform, ModelSignal, OutputRef } from '@angular/core';
8
8
  import { PathKind, SchemaPath, SchemaPathRules, LogicFn, OneOrMany, ValidationError, SchemaPathTree, FieldValidator, FieldContext, TreeValidationResult, TreeValidator, WithOptionalField, DisabledReason, Debouncer } from './_structure-chunk.js';
9
- export { AsyncValidationResult, ChildFieldContext, CompatFieldState, CompatSchemaPath, EmailValidationError, FORM_FIELD, FieldState, FieldTree, FormField, FormOptions, ItemFieldContext, ItemType, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MaybeFieldTree, MaybeSchemaPathTree, MetadataKey, MetadataReducer, MetadataSetterType, MinLengthValidationError, MinValidationError, NgValidationError, PATTERN, PatternValidationError, REQUIRED, ReadonlyArrayLike, RequiredValidationError, RootFieldContext, Schema, SchemaFn, SchemaOrSchemaFn, SignalFormsConfig, StandardSchemaValidationError, Subfields, SubmittedStatus, ValidationResult, ValidationSuccess, Validator, WithField, WithoutField, apply, applyEach, applyWhen, applyWhenValue, createManagedMetadataKey, createMetadataKey, emailError, form, maxError, maxLengthError, metadata, minError, minLengthError, patternError, provideSignalFormsConfig, requiredError, schema, standardSchemaError, submit } from './_structure-chunk.js';
9
+ export { AsyncValidationResult, ChildFieldContext, CompatFieldState, CompatSchemaPath, EmailValidationError, FORM_FIELD, FieldState, FieldTree, FormField, FormFieldBindingOptions, FormOptions, ItemFieldContext, ItemType, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MaybeFieldTree, MaybeSchemaPathTree, MetadataKey, MetadataReducer, MetadataSetterType, MinLengthValidationError, MinValidationError, NgValidationError, PATTERN, PatternValidationError, REQUIRED, ReadonlyArrayLike, RequiredValidationError, RootFieldContext, Schema, SchemaFn, SchemaOrSchemaFn, SignalFormsConfig, StandardSchemaValidationError, Subfields, ValidationResult, ValidationSuccess, Validator, WithField, WithoutField, apply, applyEach, applyWhen, applyWhenValue, createManagedMetadataKey, createMetadataKey, emailError, form, maxError, maxLengthError, metadata, minError, minLengthError, patternError, provideSignalFormsConfig, requiredError, schema, standardSchemaError, submit } from './_structure-chunk.js';
10
10
  import { StandardSchemaV1 } from '@standard-schema/spec';
11
11
  import { HttpResourceRequest, HttpResourceOptions } from '@angular/common/http';
12
12
  import '@angular/forms';
@@ -504,6 +504,13 @@ interface FormUiControl {
504
504
  * will automatically bind the value patterns from the bound field to this input.
505
505
  */
506
506
  readonly pattern?: InputSignal<readonly RegExp[]> | InputSignalWithTransform<readonly RegExp[], unknown>;
507
+ /**
508
+ * Focuses the UI control.
509
+ *
510
+ * If the focus method is not implemented, Signal Forms will attempt to focus the host element
511
+ * when asked to focus this control.
512
+ */
513
+ focus?(options?: FocusOptions): void;
507
514
  }
508
515
  /**
509
516
  * A contract for a form control that edits a `FieldTree` of type `TValue`. Any component that