@angular/forms 21.1.0-next.0 → 21.1.0-next.1

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-next.0
2
+ * @license Angular v21.1.0-next.1
3
3
  * (c) 2010-2025 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import * as i0 from '@angular/core';
8
- import { InjectionToken, ɵControl as _Control, ɵCONTROL as _CONTROL, ɵInteropControl as _InteropControl, ɵFieldState as _FieldState, Signal, Provider, WritableSignal, DestroyableInjector, Injector } from '@angular/core';
8
+ import { InjectionToken, ɵControl as _Control, ɵCONTROL as _CONTROL, ɵɵcontrolCreate as __controlCreate, ɵcontrolUpdate as _controlUpdate, ɵInteropControl as _InteropControl, ɵFieldState as _FieldState, Signal, Provider, WritableSignal, DestroyableInjector, Injector } 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';
@@ -74,7 +74,10 @@ declare class Field<T> implements _Control<T> {
74
74
  readonly classes: (readonly [string, i0.Signal<boolean>])[];
75
75
  readonly field: i0.InputSignal<FieldTree<T>>;
76
76
  readonly state: i0.Signal<[T] extends [_angular_forms.AbstractControl<any, any, any>] ? CompatFieldState<T, string | number> : FieldState<T, string | number>>;
77
- readonly [_CONTROL]: undefined;
77
+ readonly [_CONTROL]: {
78
+ readonly create: typeof __controlCreate;
79
+ readonly update: typeof _controlUpdate;
80
+ };
78
81
  /** Any `ControlValueAccessor` instances provided on the host element. */
79
82
  private readonly controlValueAccessors;
80
83
  /** A lazily instantiated fake `NgControl`. */
@@ -569,7 +572,7 @@ declare class StandardSchemaValidationError extends _NgValidationError {
569
572
  * is one of the standard kinds, allowing you to switch on the kind to further narrow the type.
570
573
  *
571
574
  * @example
572
- * ```
575
+ * ```ts
573
576
  * const f = form(...);
574
577
  * for (const e of form().errors()) {
575
578
  * if (e instanceof NgValidationError) {
@@ -2022,7 +2025,7 @@ interface FormOptions {
2022
2025
  * as well.
2023
2026
  *
2024
2027
  * @example
2025
- * ```
2028
+ * ```ts
2026
2029
  * const nameModel = signal({first: '', last: ''});
2027
2030
  * const nameForm = form(nameModel);
2028
2031
  * nameForm.first().value.set('John');
@@ -2049,7 +2052,7 @@ declare function form<TModel>(model: WritableSignal<TModel>): FieldTree<TModel>;
2049
2052
  * as well.
2050
2053
  *
2051
2054
  * @example
2052
- * ```
2055
+ * ```ts
2053
2056
  * const nameModel = signal({first: '', last: ''});
2054
2057
  * const nameForm = form(nameModel);
2055
2058
  * nameForm.first().value.set('John');
@@ -2062,7 +2065,7 @@ declare function form<TModel>(model: WritableSignal<TModel>): FieldTree<TModel>;
2062
2065
  * function that builds the schema by binding logic to a parts of the field structure.
2063
2066
  *
2064
2067
  * @example
2065
- * ```
2068
+ * ```ts
2066
2069
  * const nameForm = form(signal({first: '', last: ''}), (name) => {
2067
2070
  * required(name.first);
2068
2071
  * pattern(name.last, /^[a-z]+$/i, {message: 'Alphabet characters only'});
@@ -2095,7 +2098,7 @@ declare function form<TModel>(model: WritableSignal<TModel>, schemaOrOptions: Sc
2095
2098
  * as well.
2096
2099
  *
2097
2100
  * @example
2098
- * ```
2101
+ * ```ts
2099
2102
  * const nameModel = signal({first: '', last: ''});
2100
2103
  * const nameForm = form(nameModel);
2101
2104
  * nameForm.first().value.set('John');
@@ -2108,7 +2111,7 @@ declare function form<TModel>(model: WritableSignal<TModel>, schemaOrOptions: Sc
2108
2111
  * function that builds the schema by binding logic to a parts of the field structure.
2109
2112
  *
2110
2113
  * @example
2111
- * ```
2114
+ * ```ts
2112
2115
  * const nameForm = form(signal({first: '', last: ''}), (name) => {
2113
2116
  * required(name.first);
2114
2117
  * validate(name.last, ({value}) => !/^[a-z]+$/i.test(value()) ? customError({kind: 'alphabet-only'}) : undefined);
@@ -2134,7 +2137,7 @@ declare function form<TModel>(model: WritableSignal<TModel>, schema: SchemaOrSch
2134
2137
  * Applies a schema to each item of an array.
2135
2138
  *
2136
2139
  * @example
2137
- * ```
2140
+ * ```ts
2138
2141
  * const nameSchema = schema<{first: string, last: string}>((name) => {
2139
2142
  * required(name.first);
2140
2143
  * required(name.last);
@@ -2158,7 +2161,7 @@ declare function applyEach<TValue extends Object>(path: SchemaPath<TValue>, sche
2158
2161
  * Applies a predefined schema to a given `FieldPath`.
2159
2162
  *
2160
2163
  * @example
2161
- * ```
2164
+ * ```ts
2162
2165
  * const nameSchema = schema<{first: string, last: string}>((name) => {
2163
2166
  * required(name.first);
2164
2167
  * required(name.last);
@@ -2222,7 +2225,7 @@ declare function applyWhenValue<TValue>(path: SchemaPath<TValue>, predicate: (va
2222
2225
  * server error.
2223
2226
  *
2224
2227
  * @example
2225
- * ```
2228
+ * ```ts
2226
2229
  * async function registerNewUser(registrationForm: FieldTree<{username: string, password: string}>) {
2227
2230
  * const result = await myClient.registerNewUser(registrationForm().value());
2228
2231
  * if (result.errorCode === myClient.ErrorCode.USERNAME_TAKEN) {
package/types/forms.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v21.1.0-next.0
2
+ * @license Angular v21.1.0-next.1
3
3
  * (c) 2010-2025 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v21.1.0-next.0
2
+ * @license Angular v21.1.0-next.1
3
3
  * (c) 2010-2025 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
@@ -23,7 +23,7 @@ type CompatFormOptions = Omit<FormOptions, 'adapter'>;
23
23
  * compatibility with Reactive forms by accepting Reactive controls as a part of the data.
24
24
  *
25
25
  * @example
26
- * ```
26
+ * ```ts
27
27
  * const lastName = new FormControl('lastName');
28
28
  *
29
29
  * const nameModel = signal({
@@ -36,6 +36,7 @@ type CompatFormOptions = Omit<FormOptions, 'adapter'>;
36
36
  * });
37
37
  *
38
38
  * nameForm.last().value(); // lastName, not FormControl
39
+ * ```
39
40
  *
40
41
  * @param model A writable signal that contains the model data for the form. The resulting field
41
42
  * structure will match the shape of the model and any changes to the form data will be written to
@@ -52,7 +53,7 @@ declare function compatForm<TModel>(model: WritableSignal<TModel>): FieldTree<TM
52
53
  * compatibility with Reactive forms by accepting Reactive controls as a part of the data.
53
54
  *
54
55
  * @example
55
- * ```
56
+ * ```ts
56
57
  * const lastName = new FormControl('lastName');
57
58
  *
58
59
  * const nameModel = signal({
@@ -85,7 +86,7 @@ declare function compatForm<TModel>(model: WritableSignal<TModel>, schemaOrOptio
85
86
  * compatibility with Reactive forms by accepting Reactive controls as a part of the data.
86
87
  *
87
88
  * @example
88
- * ```
89
+ * ```ts
89
90
  * const lastName = new FormControl('lastName');
90
91
  *
91
92
  * const nameModel = signal({
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license Angular v21.1.0-next.0
2
+ * @license Angular v21.1.0-next.1
3
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
- import { Signal, ResourceRef, InputSignal, ModelSignal, OutputRef } from '@angular/core';
8
+ import { Signal, ResourceRef, InputSignal, InputSignalWithTransform, ModelSignal, OutputRef } from '@angular/core';
9
9
  import { PathKind, FieldContext, TreeValidationResult, SchemaPath, SchemaPathRules, WithOptionalField, ValidationError, DisabledReason, Debouncer, LogicFn, FieldValidator, TreeValidator, AggregateMetadataKey, MetadataKey, OneOrMany, SchemaPathTree } from './_structure-chunk.js';
10
10
  export { AsyncValidationResult, ChildFieldContext, CompatFieldState, CompatSchemaPath, CustomValidationError, EmailValidationError, FIELD, Field, FieldState, FieldTree, FormOptions, ItemFieldContext, ItemType, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MaybeFieldTree, MaybeSchemaPathTree, MinLengthValidationError, MinValidationError, NgValidationError, PATTERN, PatternValidationError, REQUIRED, ReadonlyArrayLike, RequiredValidationError, RootFieldContext, Schema, SchemaFn, SchemaOrSchemaFn, SignalFormsConfig, StandardSchemaValidationError, Subfields, SubmittedStatus, ValidationResult, ValidationSuccess, Validator, WithField, WithoutField, andMetadataKey, apply, applyEach, applyWhen, applyWhenValue, createMetadataKey, customError, emailError, form, listMetadataKey, maxError, maxLengthError, maxMetadataKey, minError, minLengthError, minMetadataKey, orMetadataKey, patternError, provideSignalFormsConfig, reducedMetadataKey, requiredError, schema, standardSchemaError, submit } from './_structure-chunk.js';
11
11
  import { StandardSchemaV1 } from '@standard-schema/spec';
@@ -158,82 +158,82 @@ interface FormUiControl {
158
158
  * An input to receive the errors for the field. If implemented, the `Field` directive will
159
159
  * automatically bind errors from the bound field to this input.
160
160
  */
161
- readonly errors?: InputSignal<readonly WithOptionalField<ValidationError>[]>;
161
+ readonly errors?: InputSignal<readonly WithOptionalField<ValidationError>[]> | InputSignalWithTransform<readonly WithOptionalField<ValidationError>[], unknown>;
162
162
  /**
163
163
  * An input to receive the disabled status for the field. If implemented, the `Field` directive
164
164
  * will automatically bind the disabled status from the bound field to this input.
165
165
  */
166
- readonly disabled?: InputSignal<boolean>;
166
+ readonly disabled?: InputSignal<boolean> | InputSignalWithTransform<boolean, unknown>;
167
167
  /**
168
168
  * An input to receive the reasons for the disablement of the field. If implemented, the `Field`
169
169
  * directive will automatically bind the disabled reason from the bound field to this input.
170
170
  */
171
- readonly disabledReasons?: InputSignal<readonly WithOptionalField<DisabledReason>[]>;
171
+ readonly disabledReasons?: InputSignal<readonly WithOptionalField<DisabledReason>[]> | InputSignalWithTransform<readonly WithOptionalField<DisabledReason>[], unknown>;
172
172
  /**
173
173
  * An input to receive the readonly status for the field. If implemented, the `Field` directive
174
174
  * will automatically bind the readonly status from the bound field to this input.
175
175
  */
176
- readonly readonly?: InputSignal<boolean>;
176
+ readonly readonly?: InputSignal<boolean> | InputSignalWithTransform<boolean, unknown>;
177
177
  /**
178
178
  * An input to receive the hidden status for the field. If implemented, the `Field` directive
179
179
  * will automatically bind the hidden status from the bound field to this input.
180
180
  */
181
- readonly hidden?: InputSignal<boolean>;
181
+ readonly hidden?: InputSignal<boolean> | InputSignalWithTransform<boolean, unknown>;
182
182
  /**
183
183
  * An input to receive the invalid status for the field. If implemented, the `Field` directive
184
184
  * will automatically bind the invalid status from the bound field to this input.
185
185
  */
186
- readonly invalid?: InputSignal<boolean>;
186
+ readonly invalid?: InputSignal<boolean> | InputSignalWithTransform<boolean, unknown>;
187
187
  /**
188
188
  * An input to receive the pending status for the field. If implemented, the `Field` directive
189
189
  * will automatically bind the pending status from the bound field to this input.
190
190
  */
191
- readonly pending?: InputSignal<boolean>;
191
+ readonly pending?: InputSignal<boolean> | InputSignalWithTransform<boolean, unknown>;
192
192
  /**
193
193
  * An input to receive the touched status for the field. If implemented, the `Field` directive
194
194
  * will automatically bind the touched status from the bound field to this input.
195
195
  */
196
- readonly touched?: ModelSignal<boolean> | InputSignal<boolean> | OutputRef<boolean>;
196
+ readonly touched?: ModelSignal<boolean> | InputSignal<boolean> | InputSignalWithTransform<boolean, unknown> | OutputRef<boolean>;
197
197
  /**
198
198
  * An input to receive the dirty status for the field. If implemented, the `Field` directive
199
199
  * will automatically bind the dirty status from the bound field to this input.
200
200
  */
201
- readonly dirty?: InputSignal<boolean>;
201
+ readonly dirty?: InputSignal<boolean> | InputSignalWithTransform<boolean, unknown>;
202
202
  /**
203
203
  * An input to receive the name for the field. If implemented, the `Field` directive will
204
204
  * automatically bind the name from the bound field to this input.
205
205
  */
206
- readonly name?: InputSignal<string>;
206
+ readonly name?: InputSignal<string> | InputSignalWithTransform<string, unknown>;
207
207
  /**
208
208
  * An input to receive the required status for the field. If implemented, the `Field` directive
209
209
  * will automatically bind the required status from the bound field to this input.
210
210
  */
211
- readonly required?: InputSignal<boolean>;
211
+ readonly required?: InputSignal<boolean> | InputSignalWithTransform<boolean, unknown>;
212
212
  /**
213
213
  * An input to receive the min value for the field. If implemented, the `Field` directive will
214
214
  * automatically bind the min value from the bound field to this input.
215
215
  */
216
- readonly min?: InputSignal<number | undefined>;
216
+ readonly min?: InputSignal<number | undefined> | InputSignalWithTransform<number | undefined, unknown>;
217
217
  /**
218
218
  * An input to receive the min length for the field. If implemented, the `Field` directive will
219
219
  * automatically bind the min length from the bound field to this input.
220
220
  */
221
- readonly minLength?: InputSignal<number | undefined>;
221
+ readonly minLength?: InputSignal<number | undefined> | InputSignalWithTransform<number | undefined, unknown>;
222
222
  /**
223
223
  * An input to receive the max value for the field. If implemented, the `Field` directive will
224
224
  * automatically bind the max value from the bound field to this input.
225
225
  */
226
- readonly max?: InputSignal<number | undefined>;
226
+ readonly max?: InputSignal<number | undefined> | InputSignalWithTransform<number | undefined, unknown>;
227
227
  /**
228
228
  * An input to receive the max length for the field. If implemented, the `Field` directive will
229
229
  * automatically bind the max length from the bound field to this input.
230
230
  */
231
- readonly maxLength?: InputSignal<number | undefined>;
231
+ readonly maxLength?: InputSignal<number | undefined> | InputSignalWithTransform<number | undefined, unknown>;
232
232
  /**
233
233
  * An input to receive the value patterns for the field. If implemented, the `Field` directive
234
234
  * will automatically bind the value patterns from the bound field to this input.
235
235
  */
236
- readonly pattern?: InputSignal<readonly RegExp[]>;
236
+ readonly pattern?: InputSignal<readonly RegExp[]> | InputSignalWithTransform<readonly RegExp[], unknown>;
237
237
  }
238
238
  /**
239
239
  * A contract for a form control that edits a `FieldTree` of type `TValue`. Any component that