@angular/forms 21.2.0-next.1 → 21.2.0-next.2
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/fesm2022/_structure-chunk.mjs +116 -26
- package/fesm2022/_structure-chunk.mjs.map +1 -1
- package/fesm2022/forms.mjs +128 -128
- package/fesm2022/forms.mjs.map +1 -1
- package/fesm2022/signals-compat.mjs +386 -47
- package/fesm2022/signals-compat.mjs.map +1 -1
- package/fesm2022/signals.mjs +402 -68
- package/fesm2022/signals.mjs.map +1 -1
- package/package.json +4 -4
- package/resources/code-examples.db +0 -0
- package/types/_structure-chunk.d.ts +253 -1039
- package/types/forms.d.ts +1 -1
- package/types/signals-compat.d.ts +131 -8
- package/types/signals.d.ts +6 -41
package/types/forms.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.2.0-next.
|
|
2
|
+
* @license Angular v21.2.0-next.2
|
|
3
3
|
* (c) 2010-2026 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { WritableSignal } from '@angular/core';
|
|
8
|
-
import { FormOptions, FieldTree, SchemaOrSchemaFn, ValidationError, SignalFormsConfig } from './_structure-chunk.js';
|
|
9
|
-
import { AbstractControl } from '@angular/forms';
|
|
7
|
+
import { WritableSignal, EventEmitter } from '@angular/core';
|
|
8
|
+
import { FormOptions, FieldTree, SchemaOrSchemaFn, ValidationError, SignalFormsConfig, SchemaFn } from './_structure-chunk.js';
|
|
9
|
+
import { AbstractControl, FormControlStatus, FormControlState } from '@angular/forms';
|
|
10
10
|
import '@standard-schema/spec';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -15,7 +15,7 @@ import '@standard-schema/spec';
|
|
|
15
15
|
* @category interop
|
|
16
16
|
* @experimental 21.0.0
|
|
17
17
|
*/
|
|
18
|
-
type CompatFormOptions = Omit<FormOptions
|
|
18
|
+
type CompatFormOptions<TModel> = Omit<FormOptions<TModel>, 'adapter'>;
|
|
19
19
|
/**
|
|
20
20
|
* Creates a compatibility form wrapped around the given model data.
|
|
21
21
|
*
|
|
@@ -78,7 +78,7 @@ declare function compatForm<TModel>(model: WritableSignal<TModel>): FieldTree<TM
|
|
|
78
78
|
* @category interop
|
|
79
79
|
* @experimental 21.0.0
|
|
80
80
|
*/
|
|
81
|
-
declare function compatForm<TModel>(model: WritableSignal<TModel>, schemaOrOptions: SchemaOrSchemaFn<TModel> | CompatFormOptions): FieldTree<TModel>;
|
|
81
|
+
declare function compatForm<TModel>(model: WritableSignal<TModel>, schemaOrOptions: SchemaOrSchemaFn<TModel> | CompatFormOptions<TModel>): FieldTree<TModel>;
|
|
82
82
|
/**
|
|
83
83
|
* Creates a compatibility form wrapped around the given model data.
|
|
84
84
|
*
|
|
@@ -110,7 +110,7 @@ declare function compatForm<TModel>(model: WritableSignal<TModel>, schemaOrOptio
|
|
|
110
110
|
* @category interop
|
|
111
111
|
* @experimental 21.0.0
|
|
112
112
|
*/
|
|
113
|
-
declare function compatForm<TModel>(model: WritableSignal<TModel>, schema: SchemaOrSchemaFn<TModel>, options: CompatFormOptions): FieldTree<TModel>;
|
|
113
|
+
declare function compatForm<TModel>(model: WritableSignal<TModel>, schema: SchemaOrSchemaFn<TModel>, options: CompatFormOptions<TModel>): FieldTree<TModel>;
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
116
|
* An error used for compat errors.
|
|
@@ -139,5 +139,128 @@ declare class CompatValidationError<T = unknown> implements ValidationError {
|
|
|
139
139
|
*/
|
|
140
140
|
declare const NG_STATUS_CLASSES: SignalFormsConfig['classes'];
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
/** Options used to update the control value. */
|
|
143
|
+
type ValueUpdateOptions = {
|
|
144
|
+
onlySelf?: boolean;
|
|
145
|
+
emitEvent?: boolean;
|
|
146
|
+
emitModelToViewChange?: boolean;
|
|
147
|
+
emitViewToModelChange?: boolean;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* A `FormControl` that is backed by signal forms rules.
|
|
151
|
+
*
|
|
152
|
+
* This class provides a bridge between Signal Forms and Reactive Forms, allowing
|
|
153
|
+
* signal-based controls to be used within a standard `FormGroup` or `FormArray`.
|
|
154
|
+
*
|
|
155
|
+
* A control could be created using signal forms, and integrated with an existing FormGroup
|
|
156
|
+
* propagating all the statuses and validity.
|
|
157
|
+
*
|
|
158
|
+
* @usageNotes
|
|
159
|
+
*
|
|
160
|
+
* ### Basic usage
|
|
161
|
+
*
|
|
162
|
+
* ```angular-ts
|
|
163
|
+
* const form = new FormGroup({
|
|
164
|
+
* // You can create SignalFormControl with signal form rules, and add it to a FormGroup.
|
|
165
|
+
* name: new SignalFormControl('Alice', p => {
|
|
166
|
+
* required(p);
|
|
167
|
+
* }),
|
|
168
|
+
* age: new FormControl(25),
|
|
169
|
+
* });
|
|
170
|
+
* ```
|
|
171
|
+
* In the template you can get the underlying `fieldTree` and bind it:
|
|
172
|
+
*
|
|
173
|
+
* ```angular-html
|
|
174
|
+
* <form [formGroup]="form">
|
|
175
|
+
* <input [formField]="nameControl.fieldTree" />
|
|
176
|
+
* <input formControlName="age" />
|
|
177
|
+
* </form>
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @experimental
|
|
181
|
+
*/
|
|
182
|
+
declare class SignalFormControl<T> extends AbstractControl {
|
|
183
|
+
/** Source FieldTree. */
|
|
184
|
+
readonly fieldTree: FieldTree<T>;
|
|
185
|
+
/** The raw signal driving the control value. */
|
|
186
|
+
readonly sourceValue: WritableSignal<T>;
|
|
187
|
+
private readonly fieldState;
|
|
188
|
+
private readonly initialValue;
|
|
189
|
+
private pendingParentNotifications;
|
|
190
|
+
private readonly onChangeCallbacks;
|
|
191
|
+
private readonly onDisabledChangeCallbacks;
|
|
192
|
+
readonly valueChanges: EventEmitter<T>;
|
|
193
|
+
readonly statusChanges: EventEmitter<FormControlStatus>;
|
|
194
|
+
constructor(value: T, schemaOrOptions?: SchemaFn<T> | FormOptions<T>, options?: FormOptions<T>);
|
|
195
|
+
/**
|
|
196
|
+
* Defines properties using closure-safe names to prevent issues with property renaming optimizations.
|
|
197
|
+
*
|
|
198
|
+
* AbstractControl have `value` and `errors` as readonly prop, which doesn't allow getters.
|
|
199
|
+
**/
|
|
200
|
+
private defineCompatProperties;
|
|
201
|
+
private emitControlEvent;
|
|
202
|
+
setValue(value: any, options?: ValueUpdateOptions): void;
|
|
203
|
+
patchValue(value: any, options?: ValueUpdateOptions): void;
|
|
204
|
+
private updateValue;
|
|
205
|
+
registerOnChange(fn: (value?: any, emitModelEvent?: boolean) => void): void;
|
|
206
|
+
registerOnDisabledChange(fn: (isDisabled: boolean) => void): void;
|
|
207
|
+
getRawValue(): T;
|
|
208
|
+
reset(value?: T | FormControlState<T>, options?: ValueUpdateOptions): void;
|
|
209
|
+
private scheduleParentUpdate;
|
|
210
|
+
private notifyParentUnlessPending;
|
|
211
|
+
private updateParentValueAndValidity;
|
|
212
|
+
private propagateToParent;
|
|
213
|
+
get status(): FormControlStatus;
|
|
214
|
+
get valid(): boolean;
|
|
215
|
+
get invalid(): boolean;
|
|
216
|
+
get pending(): boolean;
|
|
217
|
+
get disabled(): boolean;
|
|
218
|
+
get enabled(): boolean;
|
|
219
|
+
get dirty(): boolean;
|
|
220
|
+
set dirty(_: boolean);
|
|
221
|
+
get pristine(): boolean;
|
|
222
|
+
set pristine(_: boolean);
|
|
223
|
+
get touched(): boolean;
|
|
224
|
+
set touched(_: boolean);
|
|
225
|
+
get untouched(): boolean;
|
|
226
|
+
set untouched(_: boolean);
|
|
227
|
+
markAsTouched(opts?: {
|
|
228
|
+
onlySelf?: boolean;
|
|
229
|
+
}): void;
|
|
230
|
+
markAsDirty(opts?: {
|
|
231
|
+
onlySelf?: boolean;
|
|
232
|
+
}): void;
|
|
233
|
+
markAsPristine(opts?: {
|
|
234
|
+
onlySelf?: boolean;
|
|
235
|
+
}): void;
|
|
236
|
+
markAsUntouched(opts?: {
|
|
237
|
+
onlySelf?: boolean;
|
|
238
|
+
}): void;
|
|
239
|
+
updateValueAndValidity(_opts?: Object): void;
|
|
240
|
+
disable(_opts?: {
|
|
241
|
+
onlySelf?: boolean;
|
|
242
|
+
emitEvent?: boolean;
|
|
243
|
+
}): void;
|
|
244
|
+
enable(_opts?: {
|
|
245
|
+
onlySelf?: boolean;
|
|
246
|
+
emitEvent?: boolean;
|
|
247
|
+
}): void;
|
|
248
|
+
setValidators(_validators: any): void;
|
|
249
|
+
setAsyncValidators(_validators: any): void;
|
|
250
|
+
addValidators(_validators: any): void;
|
|
251
|
+
addAsyncValidators(_validators: any): void;
|
|
252
|
+
removeValidators(_validators: any): void;
|
|
253
|
+
removeAsyncValidators(_validators: any): void;
|
|
254
|
+
clearValidators(): void;
|
|
255
|
+
clearAsyncValidators(): void;
|
|
256
|
+
setErrors(_errors: any, _opts?: {
|
|
257
|
+
emitEvent?: boolean;
|
|
258
|
+
}): void;
|
|
259
|
+
markAsPending(_opts?: {
|
|
260
|
+
onlySelf?: boolean;
|
|
261
|
+
emitEvent?: boolean;
|
|
262
|
+
}): void;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export { CompatValidationError, NG_STATUS_CLASSES, SignalFormControl, compatForm };
|
|
143
266
|
export type { CompatFormOptions };
|
package/types/signals.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.2.0-next.
|
|
2
|
+
* @license Angular v21.2.0-next.2
|
|
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
|
-
import { PathKind, SchemaPath, SchemaPathRules, LogicFn, OneOrMany, ValidationError,
|
|
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, WithFieldTree, WithOptionalField, WithoutField, WithoutFieldTree, apply, applyEach, applyWhen, applyWhenValue, createManagedMetadataKey, createMetadataKey, emailError, form, maxError, maxLengthError, metadata, minError, minLengthError, patternError, provideSignalFormsConfig, requiredError, schema, standardSchemaError, submit } from './_structure-chunk.js';
|
|
10
|
-
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
8
|
+
import { PathKind, SchemaPath, SchemaPathRules, LogicFn, OneOrMany, ValidationError, FieldValidator, FieldContext, TreeValidationResult, TreeValidator, WithOptionalFieldTree, DisabledReason, Debouncer } from './_structure-chunk.js';
|
|
9
|
+
export { AsyncValidationResult, BaseNgValidationError, ChildFieldContext, CompatFieldState, CompatSchemaPath, EmailValidationError, FORM_FIELD, FieldState, FieldTree, 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';
|
|
11
10
|
import { HttpResourceRequest, HttpResourceOptions } from '@angular/common/http';
|
|
12
11
|
import '@angular/forms';
|
|
12
|
+
import '@standard-schema/spec';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Adds logic to a field to conditionally disable it. A disabled field does not contribute to the
|
|
@@ -216,41 +216,6 @@ declare function required<TValue, TPathKind extends PathKind = PathKind.Root>(pa
|
|
|
216
216
|
when?: NoInfer<LogicFn<TValue, boolean, TPathKind>>;
|
|
217
217
|
}): void;
|
|
218
218
|
|
|
219
|
-
/**
|
|
220
|
-
* Utility type that removes a string index key when its value is `unknown`,
|
|
221
|
-
* i.e. `{[key: string]: unknown}`. It allows specific string keys to pass through, even if their
|
|
222
|
-
* value is `unknown`, e.g. `{key: unknown}`.
|
|
223
|
-
*
|
|
224
|
-
* @experimental 21.0.0
|
|
225
|
-
*/
|
|
226
|
-
type RemoveStringIndexUnknownKey<K, V> = string extends K ? unknown extends V ? never : K : K;
|
|
227
|
-
/**
|
|
228
|
-
* Utility type that recursively ignores unknown string index properties on the given object.
|
|
229
|
-
* We use this on the `TSchema` type in `validateStandardSchema` in order to accommodate Zod's
|
|
230
|
-
* `looseObject` which includes `{[key: string]: unknown}` as part of the type.
|
|
231
|
-
*
|
|
232
|
-
* @experimental 21.0.0
|
|
233
|
-
*/
|
|
234
|
-
type IgnoreUnknownProperties<T> = T extends Record<PropertyKey, unknown> ? {
|
|
235
|
-
[K in keyof T as RemoveStringIndexUnknownKey<K, T[K]>]: IgnoreUnknownProperties<T[K]>;
|
|
236
|
-
} : T;
|
|
237
|
-
/**
|
|
238
|
-
* Validates a field using a `StandardSchemaV1` compatible validator (e.g. a Zod validator).
|
|
239
|
-
*
|
|
240
|
-
* See https://github.com/standard-schema/standard-schema for more about standard schema.
|
|
241
|
-
*
|
|
242
|
-
* @param path The `FieldPath` to the field to validate.
|
|
243
|
-
* @param schema The standard schema compatible validator to use for validation.
|
|
244
|
-
* @template TSchema The type validated by the schema. This may be either the full `TValue` type,
|
|
245
|
-
* or a partial of it.
|
|
246
|
-
* @template TValue The type of value stored in the field being validated.
|
|
247
|
-
*
|
|
248
|
-
* @see [Signal Form Schema Validation](guide/forms/signals/validation#integration-with-schema-validation-libraries)
|
|
249
|
-
* @category validation
|
|
250
|
-
* @experimental 21.0.0
|
|
251
|
-
*/
|
|
252
|
-
declare function validateStandardSchema<TSchema, TModel extends IgnoreUnknownProperties<TSchema>>(path: SchemaPath<TModel> & SchemaPathTree<TModel>, schema: StandardSchemaV1<TSchema>): void;
|
|
253
|
-
|
|
254
219
|
/**
|
|
255
220
|
* Adds logic to a field to determine if the field has validation errors.
|
|
256
221
|
*
|
|
@@ -583,5 +548,5 @@ interface FormCheckboxControl extends FormUiControl<boolean> {
|
|
|
583
548
|
*/
|
|
584
549
|
declare function debounce<TValue, TPathKind extends PathKind = PathKind.Root>(path: SchemaPath<TValue, SchemaPathRules.Supported, TPathKind>, durationOrDebouncer: number | Debouncer<TValue, TPathKind>): void;
|
|
585
550
|
|
|
586
|
-
export { Debouncer, DisabledReason, FieldContext, FieldValidator, LogicFn, OneOrMany, PathKind, SchemaPath, SchemaPathRules,
|
|
587
|
-
export type { AsyncValidatorOptions, FormCheckboxControl, FormUiControl, FormValueControl, HttpValidatorOptions,
|
|
551
|
+
export { Debouncer, DisabledReason, FieldContext, FieldValidator, LogicFn, OneOrMany, PathKind, SchemaPath, SchemaPathRules, TreeValidationResult, TreeValidator, ValidationError, WithOptionalFieldTree, debounce, disabled, email, hidden, max, maxLength, min, minLength, pattern, readonly, required, validate, validateAsync, validateHttp, validateTree };
|
|
552
|
+
export type { AsyncValidatorOptions, FormCheckboxControl, FormUiControl, FormValueControl, HttpValidatorOptions, MapToErrorsFn };
|