@angular/forms 18.0.0-next.1 → 18.0.0-next.3

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.
Files changed (31) hide show
  1. package/esm2022/src/directives/abstract_form_group_directive.mjs +3 -3
  2. package/esm2022/src/directives/checkbox_value_accessor.mjs +3 -3
  3. package/esm2022/src/directives/control_value_accessor.mjs +6 -6
  4. package/esm2022/src/directives/default_value_accessor.mjs +3 -3
  5. package/esm2022/src/directives/ng_control_status.mjs +6 -6
  6. package/esm2022/src/directives/ng_form.mjs +3 -3
  7. package/esm2022/src/directives/ng_model.mjs +3 -3
  8. package/esm2022/src/directives/ng_model_group.mjs +3 -3
  9. package/esm2022/src/directives/ng_no_validate_directive.mjs +3 -3
  10. package/esm2022/src/directives/number_value_accessor.mjs +3 -3
  11. package/esm2022/src/directives/radio_control_value_accessor.mjs +6 -6
  12. package/esm2022/src/directives/range_value_accessor.mjs +3 -3
  13. package/esm2022/src/directives/reactive_directives/form_control_directive.mjs +3 -3
  14. package/esm2022/src/directives/reactive_directives/form_control_name.mjs +3 -3
  15. package/esm2022/src/directives/reactive_directives/form_group_directive.mjs +3 -3
  16. package/esm2022/src/directives/reactive_directives/form_group_name.mjs +6 -6
  17. package/esm2022/src/directives/select_control_value_accessor.mjs +6 -6
  18. package/esm2022/src/directives/select_multiple_control_value_accessor.mjs +6 -6
  19. package/esm2022/src/directives/validators.mjs +27 -27
  20. package/esm2022/src/directives.mjs +4 -4
  21. package/esm2022/src/form_builder.mjs +9 -9
  22. package/esm2022/src/form_providers.mjs +8 -8
  23. package/esm2022/src/forms.mjs +2 -2
  24. package/esm2022/src/model/abstract_model.mjs +137 -129
  25. package/esm2022/src/model/form_array.mjs +3 -3
  26. package/esm2022/src/model/form_group.mjs +3 -3
  27. package/esm2022/src/version.mjs +1 -1
  28. package/fesm2022/forms.mjs +263 -256
  29. package/fesm2022/forms.mjs.map +1 -1
  30. package/index.d.ts +86 -2
  31. package/package.json +4 -4
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.0.0-next.1
2
+ * @license Angular v18.0.0-next.3
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -175,6 +175,19 @@ export declare abstract class AbstractControl<TValue = any, TRawValue extends TV
175
175
  * a `blur` event on it.
176
176
  */
177
177
  get untouched(): boolean;
178
+ /**
179
+ * A multicasting observable that emits an event every time the state of the control changes.
180
+ * It emits for value, status, pristine or touched changes.
181
+ *
182
+ * **Note**: On value change, the emit happens right after a value of this control is updated. The
183
+ * value of a parent control (for example if this FormControl is a part of a FormGroup) is updated
184
+ * later, so accessing a value of a parent control (using the `value` property) from the callback
185
+ * of this event might result in getting a value that has not been updated yet. Subscribe to the
186
+ * `events` of the parent control instead.
187
+ * For other event types, the events are emitted after the parent control has been updated.
188
+ *
189
+ */
190
+ readonly events: Observable<ControlEvent<TValue>>;
178
191
  /**
179
192
  * A multicasting observable that emits an event every time the value of the control changes, in
180
193
  * the UI or programmatically. It also emits an event each time you call enable() or disable()
@@ -185,6 +198,8 @@ export declare abstract class AbstractControl<TValue = any, TRawValue extends TV
185
198
  * accessing a value of a parent control (using the `value` property) from the callback of this
186
199
  * event might result in getting a value that has not been updated yet. Subscribe to the
187
200
  * `valueChanges` event of the parent control instead.
201
+ *
202
+ * TODO: this should be piped from events() but is breaking in G3
188
203
  */
189
204
  readonly valueChanges: Observable<TValue>;
190
205
  /**
@@ -194,6 +209,7 @@ export declare abstract class AbstractControl<TValue = any, TRawValue extends TV
194
209
  * @see {@link FormControlStatus}
195
210
  * @see {@link AbstractControl.status}
196
211
  *
212
+ * TODO: this should be piped from events() but is breaking in G3
197
213
  */
198
214
  readonly statusChanges: Observable<FormControlStatus>;
199
215
  /**
@@ -356,12 +372,15 @@ export declare abstract class AbstractControl<TValue = any, TRawValue extends TV
356
372
  */
357
373
  markAsTouched(opts?: {
358
374
  onlySelf?: boolean;
375
+ emitEvent?: boolean;
359
376
  }): void;
360
377
  /**
361
378
  * Marks the control and all its descendant controls as `touched`.
362
379
  * @see {@link markAsTouched()}
363
380
  */
364
- markAllAsTouched(): void;
381
+ markAllAsTouched(opts?: {
382
+ emitEvent?: boolean;
383
+ }): void;
365
384
  /**
366
385
  * Marks the control as `untouched`.
367
386
  *
@@ -379,6 +398,7 @@ export declare abstract class AbstractControl<TValue = any, TRawValue extends TV
379
398
  */
380
399
  markAsUntouched(opts?: {
381
400
  onlySelf?: boolean;
401
+ emitEvent?: boolean;
382
402
  }): void;
383
403
  /**
384
404
  * Marks the control as `dirty`. A control becomes dirty when
@@ -392,9 +412,13 @@ export declare abstract class AbstractControl<TValue = any, TRawValue extends TV
392
412
  * and emits events after marking is applied.
393
413
  * * `onlySelf`: When true, mark only this control. When false or not supplied,
394
414
  * marks all direct ancestors. Default is false.
415
+ * * `emitEvent`: When true or not supplied (the default), the `events`
416
+ * observable emits a `PristineChangeEvent` with the `pristine` property being `false`.
417
+ * When false, no events are emitted.
395
418
  */
396
419
  markAsDirty(opts?: {
397
420
  onlySelf?: boolean;
421
+ emitEvent?: boolean;
398
422
  }): void;
399
423
  /**
400
424
  * Marks the control as `pristine`.
@@ -411,9 +435,13 @@ export declare abstract class AbstractControl<TValue = any, TRawValue extends TV
411
435
  * marking is applied.
412
436
  * * `onlySelf`: When true, mark only this control. When false or not supplied,
413
437
  * marks all direct ancestors. Default is false.
438
+ * * `emitEvent`: When true or not supplied (the default), the `events`
439
+ * observable emits a `PristineChangeEvent` with the `pristine` property being `true`.
440
+ * When false, no events are emitted.
414
441
  */
415
442
  markAsPristine(opts?: {
416
443
  onlySelf?: boolean;
444
+ emitEvent?: boolean;
417
445
  }): void;
418
446
  /**
419
447
  * Marks the control as `pending`.
@@ -1164,6 +1192,18 @@ export declare abstract class ControlContainer extends AbstractControlDirective
1164
1192
  get path(): string[] | null;
1165
1193
  }
1166
1194
 
1195
+ /**
1196
+ * Base class for every event sent by `AbstractControl.events()`
1197
+ *
1198
+ * @publicApi
1199
+ */
1200
+ export declare abstract class ControlEvent<T = any> {
1201
+ /**
1202
+ * Form control from which this event is originated.
1203
+ */
1204
+ abstract readonly source: AbstractControl<unknown>;
1205
+ }
1206
+
1167
1207
  /**
1168
1208
  * @description
1169
1209
  * Defines an interface that acts as a bridge between the Angular forms API and a
@@ -4294,6 +4334,17 @@ declare interface PermissiveAbstractControlOptions extends Omit<AbstractControlO
4294
4334
  */
4295
4335
  declare type PermissiveControlConfig<T> = Array<T | FormControlState<T> | ValidatorConfig>;
4296
4336
 
4337
+ /**
4338
+ * Event fired when the control's pristine state changes (pristine <=> dirty).
4339
+ *
4340
+ * @publicApi
4341
+ */
4342
+ export declare class PristineEvent extends ControlEvent {
4343
+ readonly pristine: boolean;
4344
+ readonly source: AbstractControl;
4345
+ constructor(pristine: boolean, source: AbstractControl);
4346
+ }
4347
+
4297
4348
  /**
4298
4349
  * @description
4299
4350
  * Class used by Angular to track radio buttons. For internal use only.
@@ -4659,8 +4710,30 @@ export declare type SetDisabledStateOption = 'whenDisabledForLegacyCode' | 'alwa
4659
4710
 
4660
4711
  declare const SHARED_FORM_DIRECTIVES: Type<any>[];
4661
4712
 
4713
+ /**
4714
+ * Event fired when the control's status changes.
4715
+ *
4716
+ * @publicApi
4717
+ */
4718
+ export declare class StatusEvent extends ControlEvent {
4719
+ readonly status: FormControlStatus;
4720
+ readonly source: AbstractControl;
4721
+ constructor(status: FormControlStatus, source: AbstractControl);
4722
+ }
4723
+
4662
4724
  declare const TEMPLATE_DRIVEN_DIRECTIVES: Type<any>[];
4663
4725
 
4726
+ /**
4727
+ * Event fired when the control's touched status changes (touched <=> untouched).
4728
+ *
4729
+ * @publicApi
4730
+ */
4731
+ export declare class TouchedEvent extends ControlEvent {
4732
+ readonly touched: boolean;
4733
+ readonly source: AbstractControl;
4734
+ constructor(touched: boolean, source: AbstractControl);
4735
+ }
4736
+
4664
4737
  /**
4665
4738
  * UntypedFormArray is a non-strongly-typed version of `FormArray`, which
4666
4739
  * permits heterogenous controls.
@@ -5093,6 +5166,17 @@ export declare class Validators {
5093
5166
  static composeAsync(validators: (AsyncValidatorFn | null)[]): AsyncValidatorFn | null;
5094
5167
  }
5095
5168
 
5169
+ /**
5170
+ * Event fired when the value of a control changes.
5171
+ *
5172
+ * @publicApi
5173
+ */
5174
+ export declare class ValueChangeEvent<T> extends ControlEvent<T> {
5175
+ readonly value: T;
5176
+ readonly source: AbstractControl;
5177
+ constructor(value: T, source: AbstractControl);
5178
+ }
5179
+
5096
5180
  /**
5097
5181
  * @publicApi
5098
5182
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/forms",
3
- "version": "18.0.0-next.1",
3
+ "version": "18.0.0-next.3",
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": "18.0.0-next.1",
15
- "@angular/common": "18.0.0-next.1",
16
- "@angular/platform-browser": "18.0.0-next.1",
14
+ "@angular/core": "18.0.0-next.3",
15
+ "@angular/common": "18.0.0-next.3",
16
+ "@angular/platform-browser": "18.0.0-next.3",
17
17
  "rxjs": "^6.5.3 || ^7.4.0"
18
18
  },
19
19
  "repository": {