@angular/forms 20.0.6 → 20.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.
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v20.0.6
2
+ * @license Angular v20.1.0-next.1
3
3
  * (c) 2010-2025 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -283,6 +283,11 @@ declare class SelectControlValueAccessor extends BuiltInControlValueAccessor imp
283
283
  */
284
284
  set compareWith(fn: (o1: any, o2: any) => boolean);
285
285
  private _compareWith;
286
+ private readonly appRefInjector;
287
+ private readonly appRefDestroyRef;
288
+ private readonly destroyRef;
289
+ private readonly cdr;
290
+ private _queuedWrite;
286
291
  /**
287
292
  * Sets the "value" property on the select element.
288
293
  * @docs-private
@@ -1346,283 +1351,240 @@ declare const UntypedFormArray: UntypedFormArrayCtor;
1346
1351
  declare const isFormArray: (control: unknown) => control is FormArray;
1347
1352
 
1348
1353
  /**
1349
- * FormGroupValue extracts the type of `.value` from a FormGroup's inner object type. The untyped
1350
- * case falls back to {[key: string]: any}.
1351
- *
1352
- * Angular uses this type internally to support Typed Forms; do not use it directly.
1354
+ * FormControlState is a boxed form value. It is an object with a `value` key and a `disabled` key.
1353
1355
  *
1354
- * For internal use only.
1356
+ * @publicApi
1355
1357
  */
1356
- type ɵFormGroupValue<T extends {
1357
- [K in keyof T]?: AbstractControl<any>;
1358
- }> = ɵTypedOrUntyped<T, Partial<{
1359
- [K in keyof T]: ɵValue<T[K]>;
1360
- }>, {
1361
- [key: string]: any;
1362
- }>;
1358
+ interface FormControlState<T> {
1359
+ value: T;
1360
+ disabled: boolean;
1361
+ }
1363
1362
  /**
1364
- * FormGroupRawValue extracts the type of `.getRawValue()` from a FormGroup's inner object type. The
1365
- * untyped case falls back to {[key: string]: any}.
1363
+ * Interface for options provided to a `FormControl`.
1366
1364
  *
1367
- * Angular uses this type internally to support Typed Forms; do not use it directly.
1365
+ * This interface extends all options from {@link AbstractControlOptions}, plus some options
1366
+ * unique to `FormControl`.
1368
1367
  *
1369
- * For internal use only.
1368
+ * @publicApi
1370
1369
  */
1371
- type ɵFormGroupRawValue<T extends {
1372
- [K in keyof T]?: AbstractControl<any>;
1373
- }> = ɵTypedOrUntyped<T, {
1374
- [K in keyof T]: ɵRawValue<T[K]>;
1375
- }, {
1376
- [key: string]: any;
1377
- }>;
1370
+ interface FormControlOptions extends AbstractControlOptions {
1371
+ /**
1372
+ * @description
1373
+ * Whether to use the initial value used to construct the `FormControl` as its default value
1374
+ * as well. If this option is false or not provided, the default value of a FormControl is `null`.
1375
+ * When a FormControl is reset without an explicit value, its value reverts to
1376
+ * its default value.
1377
+ */
1378
+ nonNullable?: boolean;
1379
+ /**
1380
+ * @deprecated Use `nonNullable` instead.
1381
+ */
1382
+ initialValueIsDefault?: boolean;
1383
+ }
1378
1384
  /**
1379
- * OptionalKeys returns the union of all optional keys in the object.
1380
- *
1381
- * Angular uses this type internally to support Typed Forms; do not use it directly.
1385
+ * Various available constructors for `FormControl`.
1386
+ * Do not use this interface directly. Instead, use `FormControl`:
1387
+ * ```ts
1388
+ * const fc = new FormControl('foo');
1389
+ * ```
1390
+ * This symbol is prefixed with ɵ to make plain that it is an internal symbol.
1382
1391
  */
1383
- type ɵOptionalKeys<T> = {
1384
- [K in keyof T]-?: undefined extends T[K] ? K : never;
1385
- }[keyof T];
1392
+ interface ɵFormControlCtor {
1393
+ /**
1394
+ * Construct a FormControl with no initial value or validators.
1395
+ */
1396
+ new (): FormControl<any>;
1397
+ /**
1398
+ * Creates a new `FormControl` instance.
1399
+ *
1400
+ * @param value Initializes the control with an initial value,
1401
+ * or an object that defines the initial value and disabled state.
1402
+ *
1403
+ * @param opts A `FormControlOptions` object that contains validation functions and a
1404
+ * validation trigger. `nonNullable` have to be `true`
1405
+ */
1406
+ new <T = any>(value: FormControlState<T> | T, opts: FormControlOptions & {
1407
+ nonNullable: true;
1408
+ }): FormControl<T>;
1409
+ /**
1410
+ * @deprecated Use `nonNullable` instead.
1411
+ */
1412
+ new <T = any>(value: FormControlState<T> | T, opts: FormControlOptions & {
1413
+ initialValueIsDefault: true;
1414
+ }): FormControl<T>;
1415
+ /**
1416
+ * @deprecated When passing an `options` argument, the `asyncValidator` argument has no effect.
1417
+ */
1418
+ new <T = any>(value: FormControlState<T> | T, opts: FormControlOptions, asyncValidator: AsyncValidatorFn | AsyncValidatorFn[]): FormControl<T | null>;
1419
+ /**
1420
+ * Creates a new `FormControl` instance.
1421
+ *
1422
+ * @param value Initializes the control with an initial value,
1423
+ * or an object that defines the initial value and disabled state.
1424
+ *
1425
+ * @param validatorOrOpts A synchronous validator function, or an array of
1426
+ * such functions, or a `FormControlOptions` object that contains validation functions
1427
+ * and a validation trigger.
1428
+ *
1429
+ * @param asyncValidator A single async validator or array of async validator functions
1430
+ */
1431
+ new <T = any>(value: FormControlState<T> | T, validatorOrOpts?: ValidatorFn | ValidatorFn[] | FormControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): FormControl<T | null>;
1432
+ /**
1433
+ * The presence of an explicit `prototype` property provides backwards-compatibility for apps that
1434
+ * manually inspect the prototype chain.
1435
+ */
1436
+ prototype: FormControl<any>;
1437
+ }
1386
1438
  /**
1387
- * Tracks the value and validity state of a group of `FormControl` instances.
1439
+ * Tracks the value and validation status of an individual form control.
1388
1440
  *
1389
- * A `FormGroup` aggregates the values of each child `FormControl` into one object,
1390
- * with each control name as the key. It calculates its status by reducing the status values
1391
- * of its children. For example, if one of the controls in a group is invalid, the entire
1392
- * group becomes invalid.
1441
+ * This is one of the four fundamental building blocks of Angular forms, along with
1442
+ * `FormGroup`, `FormArray` and `FormRecord`. It extends the `AbstractControl` class that
1443
+ * implements most of the base functionality for accessing the value, validation status,
1444
+ * user interactions and events.
1393
1445
  *
1394
- * `FormGroup` is one of the four fundamental building blocks used to define forms in Angular,
1395
- * along with `FormControl`, `FormArray`, and `FormRecord`.
1446
+ * `FormControl` takes a single generic argument, which describes the type of its value. This
1447
+ * argument always implicitly includes `null` because the control can be reset. To change this
1448
+ * behavior, set `nonNullable` or see the usage notes below.
1396
1449
  *
1397
- * When instantiating a `FormGroup`, pass in a collection of child controls as the first
1398
- * argument. The key for each child registers the name for the control.
1450
+ * See [usage examples below](#usage-notes).
1399
1451
  *
1400
- * `FormGroup` is intended for use cases where the keys are known ahead of time.
1401
- * If you need to dynamically add and remove controls, use {@link FormRecord} instead.
1452
+ * @see {@link AbstractControl}
1453
+ * @see [Reactive Forms Guide](guide/forms/reactive-forms)
1454
+ * @see [Usage Notes](#usage-notes)
1402
1455
  *
1403
- * `FormGroup` accepts an optional type parameter `TControl`, which is an object type with inner
1404
- * control types as values.
1456
+ * @publicApi
1457
+ *
1458
+ * @overriddenImplementation ɵFormControlCtor
1405
1459
  *
1406
1460
  * @usageNotes
1407
1461
  *
1408
- * ### Create a form group with 2 controls
1462
+ * ### Initializing Form Controls
1463
+ *
1464
+ * Instantiate a `FormControl`, with an initial value.
1409
1465
  *
1410
1466
  * ```ts
1411
- * const form = new FormGroup({
1412
- * first: new FormControl('Nancy', Validators.minLength(2)),
1413
- * last: new FormControl('Drew'),
1414
- * });
1467
+ * const control = new FormControl('some value');
1468
+ * console.log(control.value); // 'some value'
1469
+ * ```
1415
1470
  *
1416
- * console.log(form.value); // {first: 'Nancy', last; 'Drew'}
1417
- * console.log(form.status); // 'VALID'
1471
+ * The following example initializes the control with a form state object. The `value`
1472
+ * and `disabled` keys are required in this case.
1473
+ *
1474
+ * ```ts
1475
+ * const control = new FormControl({ value: 'n/a', disabled: true });
1476
+ * console.log(control.value); // 'n/a'
1477
+ * console.log(control.status); // 'DISABLED'
1418
1478
  * ```
1419
1479
  *
1420
- * ### The type argument, and optional controls
1480
+ * The following example initializes the control with a synchronous validator.
1421
1481
  *
1422
- * `FormGroup` accepts one generic argument, which is an object containing its inner controls.
1423
- * This type will usually be inferred automatically, but you can always specify it explicitly if you
1424
- * wish.
1482
+ * ```ts
1483
+ * const control = new FormControl('', Validators.required);
1484
+ * console.log(control.value); // ''
1485
+ * console.log(control.status); // 'INVALID'
1486
+ * ```
1425
1487
  *
1426
- * If you have controls that are optional (i.e. they can be removed, you can use the `?` in the
1427
- * type):
1488
+ * The following example initializes the control using an options object.
1428
1489
  *
1429
1490
  * ```ts
1430
- * const form = new FormGroup<{
1431
- * first: FormControl<string|null>,
1432
- * middle?: FormControl<string|null>, // Middle name is optional.
1433
- * last: FormControl<string|null>,
1434
- * }>({
1435
- * first: new FormControl('Nancy'),
1436
- * last: new FormControl('Drew'),
1491
+ * const control = new FormControl('', {
1492
+ * validators: Validators.required,
1493
+ * asyncValidators: myAsyncValidator
1437
1494
  * });
1438
1495
  * ```
1439
1496
  *
1440
- * ### Create a form group with a group-level validator
1497
+ * ### The single type argument
1441
1498
  *
1442
- * You include group-level validators as the second arg, or group-level async
1443
- * validators as the third arg. These come in handy when you want to perform validation
1444
- * that considers the value of more than one child control.
1499
+ * `FormControl` accepts a generic argument, which describes the type of its value.
1500
+ * In most cases, this argument will be inferred.
1501
+ *
1502
+ * If you are initializing the control to `null`, or you otherwise wish to provide a
1503
+ * wider type, you may specify the argument explicitly:
1445
1504
  *
1446
1505
  * ```ts
1447
- * const form = new FormGroup({
1448
- * password: new FormControl('', Validators.minLength(2)),
1449
- * passwordConfirm: new FormControl('', Validators.minLength(2)),
1450
- * }, passwordMatchValidator);
1506
+ * let fc = new FormControl<string|null>(null);
1507
+ * fc.setValue('foo');
1508
+ * ```
1451
1509
  *
1510
+ * You might notice that `null` is always added to the type of the control.
1511
+ * This is because the control will become `null` if you call `reset`. You can change
1512
+ * this behavior by setting `{nonNullable: true}`.
1452
1513
  *
1453
- * function passwordMatchValidator(g: FormGroup) {
1454
- * return g.get('password').value === g.get('passwordConfirm').value
1455
- * ? null : {'mismatch': true};
1456
- * }
1514
+ * ### Configure the control to update on a blur event
1515
+ *
1516
+ * Set the `updateOn` option to `'blur'` to update on the blur `event`.
1517
+ *
1518
+ * ```ts
1519
+ * const control = new FormControl('', { updateOn: 'blur' });
1457
1520
  * ```
1458
1521
  *
1459
- * Like `FormControl` instances, you choose to pass in
1460
- * validators and async validators as part of an options object.
1522
+ * ### Configure the control to update on a submit event
1523
+ *
1524
+ * Set the `updateOn` option to `'submit'` to update on a submit `event`.
1461
1525
  *
1462
1526
  * ```ts
1463
- * const form = new FormGroup({
1464
- * password: new FormControl('')
1465
- * passwordConfirm: new FormControl('')
1466
- * }, { validators: passwordMatchValidator, asyncValidators: otherValidator });
1527
+ * const control = new FormControl('', { updateOn: 'submit' });
1467
1528
  * ```
1468
1529
  *
1469
- * ### Set the updateOn property for all controls in a form group
1530
+ * ### Reset the control back to a specific value
1470
1531
  *
1471
- * The options object is used to set a default value for each child
1472
- * control's `updateOn` property. If you set `updateOn` to `'blur'` at the
1473
- * group level, all child controls default to 'blur', unless the child
1474
- * has explicitly specified a different `updateOn` value.
1532
+ * You reset to a specific form state by passing through a standalone
1533
+ * value or a form state object that contains both a value and a disabled state
1534
+ * (these are the only two properties that cannot be calculated).
1475
1535
  *
1476
1536
  * ```ts
1477
- * const c = new FormGroup({
1478
- * one: new FormControl()
1479
- * }, { updateOn: 'blur' });
1537
+ * const control = new FormControl('Nancy');
1538
+ *
1539
+ * console.log(control.value); // 'Nancy'
1540
+ *
1541
+ * control.reset('Drew');
1542
+ *
1543
+ * console.log(control.value); // 'Drew'
1480
1544
  * ```
1481
1545
  *
1482
- * ### Using a FormGroup with optional controls
1546
+ * ### Reset the control to its initial value
1483
1547
  *
1484
- * It is possible to have optional controls in a FormGroup. An optional control can be removed later
1485
- * using `removeControl`, and can be omitted when calling `reset`. Optional controls must be
1486
- * declared optional in the group's type.
1548
+ * If you wish to always reset the control to its initial value (instead of null),
1549
+ * you can pass the `nonNullable` option:
1487
1550
  *
1488
1551
  * ```ts
1489
- * const c = new FormGroup<{one?: FormControl<string>}>({
1490
- * one: new FormControl('')
1491
- * });
1552
+ * const control = new FormControl('Nancy', {nonNullable: true});
1553
+ *
1554
+ * console.log(control.value); // 'Nancy'
1555
+ *
1556
+ * control.reset();
1557
+ *
1558
+ * console.log(control.value); // 'Nancy'
1492
1559
  * ```
1493
1560
  *
1494
- * Notice that `c.value.one` has type `string|null|undefined`. This is because calling `c.reset({})`
1495
- * without providing the optional key `one` will cause it to become `null`.
1561
+ * ### Reset the control back to an initial value and disabled
1496
1562
  *
1497
- * @publicApi
1563
+ * ```ts
1564
+ * const control = new FormControl('Nancy');
1565
+ *
1566
+ * console.log(control.value); // 'Nancy'
1567
+ * console.log(control.status); // 'VALID'
1568
+ *
1569
+ * control.reset({ value: 'Drew', disabled: true });
1570
+ *
1571
+ * console.log(control.value); // 'Drew'
1572
+ * console.log(control.status); // 'DISABLED'
1573
+ * ```
1498
1574
  */
1499
- declare class FormGroup<TControl extends {
1500
- [K in keyof TControl]: AbstractControl<any>;
1501
- } = any> extends AbstractControl<ɵTypedOrUntyped<TControl, ɵFormGroupValue<TControl>, any>, ɵTypedOrUntyped<TControl, ɵFormGroupRawValue<TControl>, any>> {
1502
- /**
1503
- * Creates a new `FormGroup` instance.
1504
- *
1505
- * @param controls A collection of child controls. The key for each child is the name
1506
- * under which it is registered.
1507
- *
1508
- * @param validatorOrOpts A synchronous validator function, or an array of
1509
- * such functions, or an `AbstractControlOptions` object that contains validation functions
1510
- * and a validation trigger.
1511
- *
1512
- * @param asyncValidator A single async validator or array of async validator functions
1513
- *
1514
- */
1515
- constructor(controls: TControl, validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null);
1516
- controls: ɵTypedOrUntyped<TControl, TControl, {
1517
- [key: string]: AbstractControl<any>;
1518
- }>;
1519
- /**
1520
- * Registers a control with the group's list of controls. In a strongly-typed group, the control
1521
- * must be in the group's type (possibly as an optional key).
1522
- *
1523
- * This method does not update the value or validity of the control.
1524
- * Use {@link FormGroup#addControl addControl} instead.
1525
- *
1526
- * @param name The control name to register in the collection
1527
- * @param control Provides the control for the given name
1528
- */
1529
- registerControl<K extends string & keyof TControl>(name: K, control: TControl[K]): TControl[K];
1530
- registerControl(this: FormGroup<{
1531
- [key: string]: AbstractControl<any>;
1532
- }>, name: string, control: AbstractControl<any>): AbstractControl<any>;
1533
- /**
1534
- * Add a control to this group. In a strongly-typed group, the control must be in the group's type
1535
- * (possibly as an optional key).
1536
- *
1537
- * If a control with a given name already exists, it would *not* be replaced with a new one.
1538
- * If you want to replace an existing control, use the {@link FormGroup#setControl setControl}
1539
- * method instead. This method also updates the value and validity of the control.
1540
- *
1541
- * @param name The control name to add to the collection
1542
- * @param control Provides the control for the given name
1543
- * @param options Specifies whether this FormGroup instance should emit events after a new
1544
- * control is added.
1545
- * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
1546
- * `valueChanges` observables emit events with the latest status and value when the control is
1547
- * added. When false, no events are emitted.
1548
- */
1549
- addControl(this: FormGroup<{
1550
- [key: string]: AbstractControl<any>;
1551
- }>, name: string, control: AbstractControl, options?: {
1552
- emitEvent?: boolean;
1553
- }): void;
1554
- addControl<K extends string & keyof TControl>(name: K, control: Required<TControl>[K], options?: {
1555
- emitEvent?: boolean;
1556
- }): void;
1557
- removeControl(this: FormGroup<{
1558
- [key: string]: AbstractControl<any>;
1559
- }>, name: string, options?: {
1560
- emitEvent?: boolean;
1561
- }): void;
1562
- removeControl<S extends string>(name: ɵOptionalKeys<TControl> & S, options?: {
1563
- emitEvent?: boolean;
1564
- }): void;
1565
- /**
1566
- * Replace an existing control. In a strongly-typed group, the control must be in the group's type
1567
- * (possibly as an optional key).
1568
- *
1569
- * If a control with a given name does not exist in this `FormGroup`, it will be added.
1570
- *
1571
- * @param name The control name to replace in the collection
1572
- * @param control Provides the control for the given name
1573
- * @param options Specifies whether this FormGroup instance should emit events after an
1574
- * existing control is replaced.
1575
- * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
1576
- * `valueChanges` observables emit events with the latest status and value when the control is
1577
- * replaced with a new one. When false, no events are emitted.
1578
- */
1579
- setControl<K extends string & keyof TControl>(name: K, control: TControl[K], options?: {
1580
- emitEvent?: boolean;
1581
- }): void;
1582
- setControl(this: FormGroup<{
1583
- [key: string]: AbstractControl<any>;
1584
- }>, name: string, control: AbstractControl, options?: {
1585
- emitEvent?: boolean;
1586
- }): void;
1575
+ interface FormControl<TValue = any> extends AbstractControl<TValue> {
1587
1576
  /**
1588
- * Check whether there is an enabled control with the given name in the group.
1589
- *
1590
- * Reports false for disabled controls. If you'd like to check for existence in the group
1591
- * only, use {@link AbstractControl#get get} instead.
1592
- *
1593
- * @param controlName The control name to check for existence in the collection
1594
- *
1595
- * @returns false for disabled controls, true otherwise.
1577
+ * The default value of this FormControl, used whenever the control is reset without an explicit
1578
+ * value. See {@link FormControlOptions#nonNullable} for more information on configuring
1579
+ * a default value.
1596
1580
  */
1597
- contains<K extends string>(controlName: K): boolean;
1598
- contains(this: FormGroup<{
1599
- [key: string]: AbstractControl<any>;
1600
- }>, controlName: string): boolean;
1581
+ readonly defaultValue: TValue;
1601
1582
  /**
1602
- * Sets the value of the `FormGroup`. It accepts an object that matches
1603
- * the structure of the group, with control names as keys.
1604
- *
1605
- * @usageNotes
1606
- * ### Set the complete value for the form group
1607
- *
1608
- * ```ts
1609
- * const form = new FormGroup({
1610
- * first: new FormControl(),
1611
- * last: new FormControl()
1612
- * });
1613
- *
1614
- * console.log(form.value); // {first: null, last: null}
1615
- *
1616
- * form.setValue({first: 'Nancy', last: 'Drew'});
1617
- * console.log(form.value); // {first: 'Nancy', last: 'Drew'}
1618
- * ```
1619
- *
1620
- * @throws When strict checks fail, such as setting the value of a control
1621
- * that doesn't exist or if you exclude a value of a control that does exist.
1583
+ * Sets a new value for the form control.
1622
1584
  *
1623
- * @param value The new value for the control that matches the structure of the group.
1585
+ * @param value The new value for the control.
1624
1586
  * @param options Configuration options that determine how the control propagates changes
1625
- * and emits events after the value changes.
1587
+ * and emits events when the value changes.
1626
1588
  * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity
1627
1589
  * updateValueAndValidity} method.
1628
1590
  *
@@ -1632,294 +1594,694 @@ declare class FormGroup<TControl extends {
1632
1594
  * `valueChanges`
1633
1595
  * observables emit events with the latest status and value when the control value is updated.
1634
1596
  * When false, no events are emitted.
1597
+ * * `emitModelToViewChange`: When true or not supplied (the default), each change triggers an
1598
+ * `onChange` event to
1599
+ * update the view.
1600
+ * * `emitViewToModelChange`: When true or not supplied (the default), each change triggers an
1601
+ * `ngModelChange`
1602
+ * event to update the model.
1603
+ *
1635
1604
  */
1636
- setValue(value: ɵFormGroupRawValue<TControl>, options?: {
1605
+ setValue(value: TValue, options?: {
1637
1606
  onlySelf?: boolean;
1638
1607
  emitEvent?: boolean;
1608
+ emitModelToViewChange?: boolean;
1609
+ emitViewToModelChange?: boolean;
1639
1610
  }): void;
1640
1611
  /**
1641
- * Patches the value of the `FormGroup`. It accepts an object with control
1642
- * names as keys, and does its best to match the values to the correct controls
1643
- * in the group.
1644
- *
1645
- * It accepts both super-sets and sub-sets of the group without throwing an error.
1646
- *
1647
- * @usageNotes
1648
- * ### Patch the value for a form group
1649
- *
1650
- * ```ts
1651
- * const form = new FormGroup({
1652
- * first: new FormControl(),
1653
- * last: new FormControl()
1654
- * });
1655
- * console.log(form.value); // {first: null, last: null}
1612
+ * Patches the value of a control.
1656
1613
  *
1657
- * form.patchValue({first: 'Nancy'});
1658
- * console.log(form.value); // {first: 'Nancy', last: null}
1659
- * ```
1614
+ * This function is functionally the same as {@link FormControl#setValue setValue} at this level.
1615
+ * It exists for symmetry with {@link FormGroup#patchValue patchValue} on `FormGroups` and
1616
+ * `FormArrays`, where it does behave differently.
1660
1617
  *
1661
- * @param value The object that matches the structure of the group.
1662
- * @param options Configuration options that determine how the control propagates changes and
1663
- * emits events after the value is patched.
1664
- * * `onlySelf`: When true, each change only affects this control and not its parent. Default is
1665
- * true.
1666
- * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
1667
- * `valueChanges` observables emit events with the latest status and value when the control value
1668
- * is updated. When false, no events are emitted. The configuration options are passed to
1669
- * the {@link AbstractControl#updateValueAndValidity updateValueAndValidity} method.
1618
+ * @see {@link FormControl#setValue} for options
1670
1619
  */
1671
- patchValue(value: ɵFormGroupValue<TControl>, options?: {
1620
+ patchValue(value: TValue, options?: {
1672
1621
  onlySelf?: boolean;
1673
1622
  emitEvent?: boolean;
1623
+ emitModelToViewChange?: boolean;
1624
+ emitViewToModelChange?: boolean;
1674
1625
  }): void;
1675
1626
  /**
1676
- * Resets the `FormGroup`, marks all descendants `pristine` and `untouched` and sets
1677
- * the value of all descendants to their default values, or null if no defaults were provided.
1627
+ * Resets the form control, marking it `pristine` and `untouched`, and resetting
1628
+ * the value. The new value will be the provided value (if passed), `null`, or the initial value
1629
+ * if `nonNullable` was set in the constructor via {@link FormControlOptions}.
1678
1630
  *
1679
- * You reset to a specific form state by passing in a map of states
1680
- * that matches the structure of your form, with control names as keys. The state
1681
- * is a standalone value or a form state object with both a value and a disabled
1682
- * status.
1631
+ * ```ts
1632
+ * // By default, the control will reset to null.
1633
+ * const dog = new FormControl('spot');
1634
+ * dog.reset(); // dog.value is null
1683
1635
  *
1684
- * @param value Resets the control with an initial value,
1636
+ * // If this flag is set, the control will instead reset to the initial value.
1637
+ * const cat = new FormControl('tabby', {nonNullable: true});
1638
+ * cat.reset(); // cat.value is "tabby"
1639
+ *
1640
+ * // A value passed to reset always takes precedence.
1641
+ * const fish = new FormControl('finn', {nonNullable: true});
1642
+ * fish.reset('bubble'); // fish.value is "bubble"
1643
+ * ```
1644
+ *
1645
+ * @param formState Resets the control with an initial value,
1685
1646
  * or an object that defines the initial value and disabled state.
1686
1647
  *
1687
1648
  * @param options Configuration options that determine how the control propagates changes
1688
- * and emits events when the group is reset.
1649
+ * and emits events after the value changes.
1650
+ *
1689
1651
  * * `onlySelf`: When true, each change only affects this control, and not its parent. Default is
1690
1652
  * false.
1691
1653
  * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
1692
1654
  * `valueChanges`
1693
1655
  * observables emit events with the latest status and value when the control is reset.
1694
1656
  * When false, no events are emitted.
1695
- * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity
1696
- * updateValueAndValidity} method.
1697
- *
1698
- * @usageNotes
1699
- *
1700
- * ### Reset the form group values
1701
- *
1702
- * ```ts
1703
- * const form = new FormGroup({
1704
- * first: new FormControl('first name'),
1705
- * last: new FormControl('last name')
1706
- * });
1707
- *
1708
- * console.log(form.value); // {first: 'first name', last: 'last name'}
1709
- *
1710
- * form.reset({ first: 'name', last: 'last name' });
1711
- *
1712
- * console.log(form.value); // {first: 'name', last: 'last name'}
1713
- * ```
1714
- *
1715
- * ### Reset the form group values and disabled status
1716
- *
1717
- * ```ts
1718
- * const form = new FormGroup({
1719
- * first: new FormControl('first name'),
1720
- * last: new FormControl('last name')
1721
- * });
1722
- *
1723
- * form.reset({
1724
- * first: {value: 'name', disabled: true},
1725
- * last: 'last'
1726
- * });
1727
1657
  *
1728
- * console.log(form.value); // {last: 'last'}
1729
- * console.log(form.get('first').status); // 'DISABLED'
1730
- * ```
1731
1658
  */
1732
- reset(value?: ɵTypedOrUntyped<TControl, ɵFormGroupValue<TControl>, any>, options?: {
1659
+ reset(formState?: TValue | FormControlState<TValue>, options?: {
1733
1660
  onlySelf?: boolean;
1734
1661
  emitEvent?: boolean;
1735
1662
  }): void;
1736
1663
  /**
1737
- * The aggregate value of the `FormGroup`, including any disabled controls.
1738
- *
1739
- * Retrieves all values regardless of disabled status.
1664
+ * For a simple FormControl, the raw value is equivalent to the value.
1740
1665
  */
1741
- getRawValue(): ɵTypedOrUntyped<TControl, ɵFormGroupRawValue<TControl>, any>;
1742
- }
1743
- interface UntypedFormGroupCtor {
1744
- new (controls: {
1745
- [key: string]: AbstractControl;
1746
- }, validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): UntypedFormGroup;
1666
+ getRawValue(): TValue;
1667
+ /**
1668
+ * Register a listener for change events.
1669
+ *
1670
+ * @param fn The method that is called when the value changes
1671
+ */
1672
+ registerOnChange(fn: Function): void;
1673
+ /**
1674
+ * Register a listener for disabled events.
1675
+ *
1676
+ * @param fn The method that is called when the disabled status changes.
1677
+ */
1678
+ registerOnDisabledChange(fn: (isDisabled: boolean) => void): void;
1679
+ }
1680
+ declare const FormControl: ɵFormControlCtor;
1681
+ interface UntypedFormControlCtor {
1682
+ new (): UntypedFormControl;
1683
+ new (formState?: any, validatorOrOpts?: ValidatorFn | ValidatorFn[] | FormControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): UntypedFormControl;
1747
1684
  /**
1748
1685
  * The presence of an explicit `prototype` property provides backwards-compatibility for apps that
1749
1686
  * manually inspect the prototype chain.
1750
1687
  */
1751
- prototype: FormGroup<any>;
1688
+ prototype: FormControl<any>;
1752
1689
  }
1753
1690
  /**
1754
- * UntypedFormGroup is a non-strongly-typed version of `FormGroup`.
1691
+ * UntypedFormControl is a non-strongly-typed version of `FormControl`.
1755
1692
  */
1756
- type UntypedFormGroup = FormGroup<any>;
1757
- declare const UntypedFormGroup: UntypedFormGroupCtor;
1693
+ type UntypedFormControl = FormControl<any>;
1694
+ declare const UntypedFormControl: UntypedFormControlCtor;
1758
1695
  /**
1759
1696
  * @description
1760
- * Asserts that the given control is an instance of `FormGroup`
1697
+ * Asserts that the given control is an instance of `FormControl`
1761
1698
  *
1762
1699
  * @publicApi
1763
1700
  */
1764
- declare const isFormGroup: (control: unknown) => control is FormGroup;
1701
+ declare const isFormControl: (control: unknown) => control is FormControl;
1702
+
1765
1703
  /**
1766
- * Tracks the value and validity state of a collection of `FormControl` instances, each of which has
1767
- * the same value type.
1704
+ * FormGroupValue extracts the type of `.value` from a FormGroup's inner object type. The untyped
1705
+ * case falls back to {[key: string]: any}.
1768
1706
  *
1769
- * `FormRecord` is very similar to {@link FormGroup}, except it can be used with a dynamic keys,
1770
- * with controls added and removed as needed.
1707
+ * Angular uses this type internally to support Typed Forms; do not use it directly.
1771
1708
  *
1772
- * `FormRecord` accepts one generic argument, which describes the type of the controls it contains.
1709
+ * For internal use only.
1710
+ */
1711
+ type ɵFormGroupArgumentValue<T extends {
1712
+ [K in keyof T]?: AbstractControl<any>;
1713
+ }> = ɵTypedOrUntyped<T, Partial<{
1714
+ [K in keyof T]: ɵValue<T[K]> | FormControlState<ɵValue<T[K]>>;
1715
+ }>, {
1716
+ [key: string]: any;
1717
+ }>;
1718
+ type ɵFormGroupValue<T extends {
1719
+ [K in keyof T]?: AbstractControl<any>;
1720
+ }> = ɵTypedOrUntyped<T, Partial<{
1721
+ [K in keyof T]: ɵValue<T[K]>;
1722
+ }>, {
1723
+ [key: string]: any;
1724
+ }>;
1725
+ /**
1726
+ * FormGroupRawValue extracts the type of `.getRawValue()` from a FormGroup's inner object type. The
1727
+ * untyped case falls back to {[key: string]: any}.
1728
+ *
1729
+ * Angular uses this type internally to support Typed Forms; do not use it directly.
1730
+ *
1731
+ * For internal use only.
1732
+ */
1733
+ type ɵFormGroupRawValue<T extends {
1734
+ [K in keyof T]?: AbstractControl<any>;
1735
+ }> = ɵTypedOrUntyped<T, {
1736
+ [K in keyof T]: ɵRawValue<T[K]>;
1737
+ }, {
1738
+ [key: string]: any;
1739
+ }>;
1740
+ /**
1741
+ * OptionalKeys returns the union of all optional keys in the object.
1742
+ *
1743
+ * Angular uses this type internally to support Typed Forms; do not use it directly.
1744
+ */
1745
+ type ɵOptionalKeys<T> = {
1746
+ [K in keyof T]-?: undefined extends T[K] ? K : never;
1747
+ }[keyof T];
1748
+ /**
1749
+ * Tracks the value and validity state of a group of `FormControl` instances.
1750
+ *
1751
+ * A `FormGroup` aggregates the values of each child `FormControl` into one object,
1752
+ * with each control name as the key. It calculates its status by reducing the status values
1753
+ * of its children. For example, if one of the controls in a group is invalid, the entire
1754
+ * group becomes invalid.
1755
+ *
1756
+ * `FormGroup` is one of the four fundamental building blocks used to define forms in Angular,
1757
+ * along with `FormControl`, `FormArray`, and `FormRecord`.
1758
+ *
1759
+ * When instantiating a `FormGroup`, pass in a collection of child controls as the first
1760
+ * argument. The key for each child registers the name for the control.
1761
+ *
1762
+ * `FormGroup` is intended for use cases where the keys are known ahead of time.
1763
+ * If you need to dynamically add and remove controls, use {@link FormRecord} instead.
1764
+ *
1765
+ * `FormGroup` accepts an optional type parameter `TControl`, which is an object type with inner
1766
+ * control types as values.
1773
1767
  *
1774
1768
  * @usageNotes
1775
1769
  *
1770
+ * ### Create a form group with 2 controls
1771
+ *
1776
1772
  * ```ts
1777
- * let numbers = new FormRecord({bill: new FormControl('415-123-456')});
1778
- * numbers.addControl('bob', new FormControl('415-234-567'));
1779
- * numbers.removeControl('bill');
1773
+ * const form = new FormGroup({
1774
+ * first: new FormControl('Nancy', Validators.minLength(2)),
1775
+ * last: new FormControl('Drew'),
1776
+ * });
1777
+ *
1778
+ * console.log(form.value); // {first: 'Nancy', last; 'Drew'}
1779
+ * console.log(form.status); // 'VALID'
1780
+ * ```
1781
+ *
1782
+ * ### The type argument, and optional controls
1783
+ *
1784
+ * `FormGroup` accepts one generic argument, which is an object containing its inner controls.
1785
+ * This type will usually be inferred automatically, but you can always specify it explicitly if you
1786
+ * wish.
1787
+ *
1788
+ * If you have controls that are optional (i.e. they can be removed, you can use the `?` in the
1789
+ * type):
1790
+ *
1791
+ * ```ts
1792
+ * const form = new FormGroup<{
1793
+ * first: FormControl<string|null>,
1794
+ * middle?: FormControl<string|null>, // Middle name is optional.
1795
+ * last: FormControl<string|null>,
1796
+ * }>({
1797
+ * first: new FormControl('Nancy'),
1798
+ * last: new FormControl('Drew'),
1799
+ * });
1800
+ * ```
1801
+ *
1802
+ * ### Create a form group with a group-level validator
1803
+ *
1804
+ * You include group-level validators as the second arg, or group-level async
1805
+ * validators as the third arg. These come in handy when you want to perform validation
1806
+ * that considers the value of more than one child control.
1807
+ *
1808
+ * ```ts
1809
+ * const form = new FormGroup({
1810
+ * password: new FormControl('', Validators.minLength(2)),
1811
+ * passwordConfirm: new FormControl('', Validators.minLength(2)),
1812
+ * }, passwordMatchValidator);
1813
+ *
1814
+ *
1815
+ * function passwordMatchValidator(g: FormGroup) {
1816
+ * return g.get('password').value === g.get('passwordConfirm').value
1817
+ * ? null : {'mismatch': true};
1818
+ * }
1819
+ * ```
1820
+ *
1821
+ * Like `FormControl` instances, you choose to pass in
1822
+ * validators and async validators as part of an options object.
1823
+ *
1824
+ * ```ts
1825
+ * const form = new FormGroup({
1826
+ * password: new FormControl('')
1827
+ * passwordConfirm: new FormControl('')
1828
+ * }, { validators: passwordMatchValidator, asyncValidators: otherValidator });
1780
1829
  * ```
1781
1830
  *
1831
+ * ### Set the updateOn property for all controls in a form group
1832
+ *
1833
+ * The options object is used to set a default value for each child
1834
+ * control's `updateOn` property. If you set `updateOn` to `'blur'` at the
1835
+ * group level, all child controls default to 'blur', unless the child
1836
+ * has explicitly specified a different `updateOn` value.
1837
+ *
1838
+ * ```ts
1839
+ * const c = new FormGroup({
1840
+ * one: new FormControl()
1841
+ * }, { updateOn: 'blur' });
1842
+ * ```
1843
+ *
1844
+ * ### Using a FormGroup with optional controls
1845
+ *
1846
+ * It is possible to have optional controls in a FormGroup. An optional control can be removed later
1847
+ * using `removeControl`, and can be omitted when calling `reset`. Optional controls must be
1848
+ * declared optional in the group's type.
1849
+ *
1850
+ * ```ts
1851
+ * const c = new FormGroup<{one?: FormControl<string>}>({
1852
+ * one: new FormControl('')
1853
+ * });
1854
+ * ```
1855
+ *
1856
+ * Notice that `c.value.one` has type `string|null|undefined`. This is because calling `c.reset({})`
1857
+ * without providing the optional key `one` will cause it to become `null`.
1858
+ *
1782
1859
  * @publicApi
1783
1860
  */
1784
- declare class FormRecord<TControl extends AbstractControl = AbstractControl> extends FormGroup<{
1785
- [key: string]: TControl;
1786
- }> {
1787
- }
1788
- interface FormRecord<TControl> {
1861
+ declare class FormGroup<TControl extends {
1862
+ [K in keyof TControl]: AbstractControl<any>;
1863
+ } = any> extends AbstractControl<ɵTypedOrUntyped<TControl, ɵFormGroupValue<TControl>, any>, ɵTypedOrUntyped<TControl, ɵFormGroupRawValue<TControl>, any>, ɵTypedOrUntyped<TControl, ɵFormGroupArgumentValue<TControl>, any>> {
1789
1864
  /**
1790
- * Registers a control with the records's list of controls.
1865
+ * Creates a new `FormGroup` instance.
1866
+ *
1867
+ * @param controls A collection of child controls. The key for each child is the name
1868
+ * under which it is registered.
1869
+ *
1870
+ * @param validatorOrOpts A synchronous validator function, or an array of
1871
+ * such functions, or an `AbstractControlOptions` object that contains validation functions
1872
+ * and a validation trigger.
1873
+ *
1874
+ * @param asyncValidator A single async validator or array of async validator functions
1791
1875
  *
1792
- * See `FormGroup#registerControl` for additional information.
1793
1876
  */
1794
- registerControl(name: string, control: TControl): TControl;
1877
+ constructor(controls: TControl, validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null);
1878
+ controls: ɵTypedOrUntyped<TControl, TControl, {
1879
+ [key: string]: AbstractControl<any>;
1880
+ }>;
1795
1881
  /**
1796
- * Add a control to this group.
1882
+ * Registers a control with the group's list of controls. In a strongly-typed group, the control
1883
+ * must be in the group's type (possibly as an optional key).
1797
1884
  *
1798
- * See `FormGroup#addControl` for additional information.
1885
+ * This method does not update the value or validity of the control.
1886
+ * Use {@link FormGroup#addControl addControl} instead.
1887
+ *
1888
+ * @param name The control name to register in the collection
1889
+ * @param control Provides the control for the given name
1799
1890
  */
1800
- addControl(name: string, control: TControl, options?: {
1801
- emitEvent?: boolean;
1802
- }): void;
1891
+ registerControl<K extends string & keyof TControl>(name: K, control: TControl[K]): TControl[K];
1892
+ registerControl(this: FormGroup<{
1893
+ [key: string]: AbstractControl<any>;
1894
+ }>, name: string, control: AbstractControl<any>): AbstractControl<any>;
1803
1895
  /**
1804
- * Remove a control from this group.
1896
+ * Add a control to this group. In a strongly-typed group, the control must be in the group's type
1897
+ * (possibly as an optional key).
1805
1898
  *
1806
- * See `FormGroup#removeControl` for additional information.
1899
+ * If a control with a given name already exists, it would *not* be replaced with a new one.
1900
+ * If you want to replace an existing control, use the {@link FormGroup#setControl setControl}
1901
+ * method instead. This method also updates the value and validity of the control.
1902
+ *
1903
+ * @param name The control name to add to the collection
1904
+ * @param control Provides the control for the given name
1905
+ * @param options Specifies whether this FormGroup instance should emit events after a new
1906
+ * control is added.
1907
+ * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
1908
+ * `valueChanges` observables emit events with the latest status and value when the control is
1909
+ * added. When false, no events are emitted.
1807
1910
  */
1808
- removeControl(name: string, options?: {
1911
+ addControl(this: FormGroup<{
1912
+ [key: string]: AbstractControl<any>;
1913
+ }>, name: string, control: AbstractControl, options?: {
1809
1914
  emitEvent?: boolean;
1810
1915
  }): void;
1811
- /**
1812
- * Replace an existing control.
1813
- *
1814
- * See `FormGroup#setControl` for additional information.
1815
- */
1816
- setControl(name: string, control: TControl, options?: {
1916
+ addControl<K extends string & keyof TControl>(name: K, control: Required<TControl>[K], options?: {
1817
1917
  emitEvent?: boolean;
1818
1918
  }): void;
1819
- /**
1820
- * Check whether there is an enabled control with the given name in the group.
1919
+ removeControl(this: FormGroup<{
1920
+ [key: string]: AbstractControl<any>;
1921
+ }>, name: string, options?: {
1922
+ emitEvent?: boolean;
1923
+ }): void;
1924
+ removeControl<S extends string>(name: ɵOptionalKeys<TControl> & S, options?: {
1925
+ emitEvent?: boolean;
1926
+ }): void;
1927
+ /**
1928
+ * Replace an existing control. In a strongly-typed group, the control must be in the group's type
1929
+ * (possibly as an optional key).
1821
1930
  *
1822
- * See `FormGroup#contains` for additional information.
1931
+ * If a control with a given name does not exist in this `FormGroup`, it will be added.
1932
+ *
1933
+ * @param name The control name to replace in the collection
1934
+ * @param control Provides the control for the given name
1935
+ * @param options Specifies whether this FormGroup instance should emit events after an
1936
+ * existing control is replaced.
1937
+ * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
1938
+ * `valueChanges` observables emit events with the latest status and value when the control is
1939
+ * replaced with a new one. When false, no events are emitted.
1823
1940
  */
1824
- contains(controlName: string): boolean;
1941
+ setControl<K extends string & keyof TControl>(name: K, control: TControl[K], options?: {
1942
+ emitEvent?: boolean;
1943
+ }): void;
1944
+ setControl(this: FormGroup<{
1945
+ [key: string]: AbstractControl<any>;
1946
+ }>, name: string, control: AbstractControl, options?: {
1947
+ emitEvent?: boolean;
1948
+ }): void;
1825
1949
  /**
1826
- * Sets the value of the `FormRecord`. It accepts an object that matches
1950
+ * Check whether there is an enabled control with the given name in the group.
1951
+ *
1952
+ * Reports false for disabled controls. If you'd like to check for existence in the group
1953
+ * only, use {@link AbstractControl#get get} instead.
1954
+ *
1955
+ * @param controlName The control name to check for existence in the collection
1956
+ *
1957
+ * @returns false for disabled controls, true otherwise.
1958
+ */
1959
+ contains<K extends string>(controlName: K): boolean;
1960
+ contains(this: FormGroup<{
1961
+ [key: string]: AbstractControl<any>;
1962
+ }>, controlName: string): boolean;
1963
+ /**
1964
+ * Sets the value of the `FormGroup`. It accepts an object that matches
1827
1965
  * the structure of the group, with control names as keys.
1828
1966
  *
1829
- * See `FormGroup#setValue` for additional information.
1967
+ * @usageNotes
1968
+ * ### Set the complete value for the form group
1969
+ *
1970
+ * ```ts
1971
+ * const form = new FormGroup({
1972
+ * first: new FormControl(),
1973
+ * last: new FormControl()
1974
+ * });
1975
+ *
1976
+ * console.log(form.value); // {first: null, last: null}
1977
+ *
1978
+ * form.setValue({first: 'Nancy', last: 'Drew'});
1979
+ * console.log(form.value); // {first: 'Nancy', last: 'Drew'}
1980
+ * ```
1981
+ *
1982
+ * @throws When strict checks fail, such as setting the value of a control
1983
+ * that doesn't exist or if you exclude a value of a control that does exist.
1984
+ *
1985
+ * @param value The new value for the control that matches the structure of the group.
1986
+ * @param options Configuration options that determine how the control propagates changes
1987
+ * and emits events after the value changes.
1988
+ * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity
1989
+ * updateValueAndValidity} method.
1990
+ *
1991
+ * * `onlySelf`: When true, each change only affects this control, and not its parent. Default is
1992
+ * false.
1993
+ * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
1994
+ * `valueChanges`
1995
+ * observables emit events with the latest status and value when the control value is updated.
1996
+ * When false, no events are emitted.
1830
1997
  */
1831
- setValue(value: {
1832
- [key: string]: ɵRawValue<TControl>;
1833
- }, options?: {
1998
+ setValue(value: ɵFormGroupRawValue<TControl>, options?: {
1834
1999
  onlySelf?: boolean;
1835
2000
  emitEvent?: boolean;
1836
2001
  }): void;
1837
2002
  /**
1838
- * Patches the value of the `FormRecord`. It accepts an object with control
2003
+ * Patches the value of the `FormGroup`. It accepts an object with control
1839
2004
  * names as keys, and does its best to match the values to the correct controls
1840
2005
  * in the group.
1841
2006
  *
1842
- * See `FormGroup#patchValue` for additional information.
2007
+ * It accepts both super-sets and sub-sets of the group without throwing an error.
2008
+ *
2009
+ * @usageNotes
2010
+ * ### Patch the value for a form group
2011
+ *
2012
+ * ```ts
2013
+ * const form = new FormGroup({
2014
+ * first: new FormControl(),
2015
+ * last: new FormControl()
2016
+ * });
2017
+ * console.log(form.value); // {first: null, last: null}
2018
+ *
2019
+ * form.patchValue({first: 'Nancy'});
2020
+ * console.log(form.value); // {first: 'Nancy', last: null}
2021
+ * ```
2022
+ *
2023
+ * @param value The object that matches the structure of the group.
2024
+ * @param options Configuration options that determine how the control propagates changes and
2025
+ * emits events after the value is patched.
2026
+ * * `onlySelf`: When true, each change only affects this control and not its parent. Default is
2027
+ * true.
2028
+ * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
2029
+ * `valueChanges` observables emit events with the latest status and value when the control value
2030
+ * is updated. When false, no events are emitted. The configuration options are passed to
2031
+ * the {@link AbstractControl#updateValueAndValidity updateValueAndValidity} method.
1843
2032
  */
1844
- patchValue(value: {
1845
- [key: string]: ɵValue<TControl>;
1846
- }, options?: {
2033
+ patchValue(value: ɵFormGroupValue<TControl>, options?: {
1847
2034
  onlySelf?: boolean;
1848
2035
  emitEvent?: boolean;
1849
2036
  }): void;
1850
2037
  /**
1851
- * Resets the `FormRecord`, marks all descendants `pristine` and `untouched` and sets
1852
- * the value of all descendants to null.
2038
+ * Resets the `FormGroup`, marks all descendants `pristine` and `untouched` and sets
2039
+ * the value of all descendants to their default values, or null if no defaults were provided.
1853
2040
  *
1854
- * See `FormGroup#reset` for additional information.
2041
+ * You reset to a specific form state by passing in a map of states
2042
+ * that matches the structure of your form, with control names as keys. The state
2043
+ * is a standalone value or a form state object with both a value and a disabled
2044
+ * status.
2045
+ *
2046
+ * @param value Resets the control with an initial value,
2047
+ * or an object that defines the initial value and disabled state.
2048
+ *
2049
+ * @param options Configuration options that determine how the control propagates changes
2050
+ * and emits events when the group is reset.
2051
+ * * `onlySelf`: When true, each change only affects this control, and not its parent. Default is
2052
+ * false.
2053
+ * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
2054
+ * `valueChanges`
2055
+ * observables emit events with the latest status and value when the control is reset.
2056
+ * When false, no events are emitted.
2057
+ * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity
2058
+ * updateValueAndValidity} method.
2059
+ *
2060
+ * @usageNotes
2061
+ *
2062
+ * ### Reset the form group values
2063
+ *
2064
+ * ```ts
2065
+ * const form = new FormGroup({
2066
+ * first: new FormControl('first name'),
2067
+ * last: new FormControl('last name')
2068
+ * });
2069
+ *
2070
+ * console.log(form.value); // {first: 'first name', last: 'last name'}
2071
+ *
2072
+ * form.reset({ first: 'name', last: 'last name' });
2073
+ *
2074
+ * console.log(form.value); // {first: 'name', last: 'last name'}
2075
+ * ```
2076
+ *
2077
+ * ### Reset the form group values and disabled status
2078
+ *
2079
+ * ```ts
2080
+ * const form = new FormGroup({
2081
+ * first: new FormControl('first name'),
2082
+ * last: new FormControl('last name')
2083
+ * });
2084
+ *
2085
+ * form.reset({
2086
+ * first: {value: 'name', disabled: true},
2087
+ * last: 'last'
2088
+ * });
2089
+ *
2090
+ * console.log(form.value); // {last: 'last'}
2091
+ * console.log(form.get('first').status); // 'DISABLED'
2092
+ * ```
1855
2093
  */
1856
- reset(value?: {
1857
- [key: string]: ɵValue<TControl>;
1858
- }, options?: {
2094
+ reset(value?: ɵTypedOrUntyped<TControl, ɵFormGroupArgumentValue<TControl>, any>, options?: {
1859
2095
  onlySelf?: boolean;
1860
2096
  emitEvent?: boolean;
1861
2097
  }): void;
1862
2098
  /**
1863
- * The aggregate value of the `FormRecord`, including any disabled controls.
2099
+ * The aggregate value of the `FormGroup`, including any disabled controls.
1864
2100
  *
1865
- * See `FormGroup#getRawValue` for additional information.
2101
+ * Retrieves all values regardless of disabled status.
1866
2102
  */
1867
- getRawValue(): {
1868
- [key: string]: ɵRawValue<TControl>;
1869
- };
2103
+ getRawValue(): ɵTypedOrUntyped<TControl, ɵFormGroupRawValue<TControl>, any>;
2104
+ }
2105
+ interface UntypedFormGroupCtor {
2106
+ new (controls: {
2107
+ [key: string]: AbstractControl;
2108
+ }, validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): UntypedFormGroup;
2109
+ /**
2110
+ * The presence of an explicit `prototype` property provides backwards-compatibility for apps that
2111
+ * manually inspect the prototype chain.
2112
+ */
2113
+ prototype: FormGroup<any>;
1870
2114
  }
2115
+ /**
2116
+ * UntypedFormGroup is a non-strongly-typed version of `FormGroup`.
2117
+ */
2118
+ type UntypedFormGroup = FormGroup<any>;
2119
+ declare const UntypedFormGroup: UntypedFormGroupCtor;
1871
2120
  /**
1872
2121
  * @description
1873
- * Asserts that the given control is an instance of `FormRecord`
2122
+ * Asserts that the given control is an instance of `FormGroup`
1874
2123
  *
1875
2124
  * @publicApi
1876
2125
  */
1877
- declare const isFormRecord: (control: unknown) => control is FormRecord;
1878
-
2126
+ declare const isFormGroup: (control: unknown) => control is FormGroup;
1879
2127
  /**
1880
- * A form can have several different statuses. Each
1881
- * possible status is returned as a string literal.
2128
+ * Tracks the value and validity state of a collection of `FormControl` instances, each of which has
2129
+ * the same value type.
1882
2130
  *
1883
- * * **VALID**: Reports that a control is valid, meaning that no errors exist in the input
1884
- * value.
1885
- * * **INVALID**: Reports that a control is invalid, meaning that an error exists in the input
1886
- * value.
1887
- * * **PENDING**: Reports that a control is pending, meaning that async validation is
1888
- * occurring and errors are not yet available for the input value.
1889
- * * **DISABLED**: Reports that a control is
1890
- * disabled, meaning that the control is exempt from ancestor calculations of validity or value.
2131
+ * `FormRecord` is very similar to {@link FormGroup}, except it can be used with a dynamic keys,
2132
+ * with controls added and removed as needed.
1891
2133
  *
1892
- * @publicApi
1893
- */
1894
- type FormControlStatus = 'VALID' | 'INVALID' | 'PENDING' | 'DISABLED';
1895
- /**
1896
- * Base class for every event sent by `AbstractControl.events()`
2134
+ * `FormRecord` accepts one generic argument, which describes the type of the controls it contains.
2135
+ *
2136
+ * @usageNotes
2137
+ *
2138
+ * ```ts
2139
+ * let numbers = new FormRecord({bill: new FormControl('415-123-456')});
2140
+ * numbers.addControl('bob', new FormControl('415-234-567'));
2141
+ * numbers.removeControl('bill');
2142
+ * ```
1897
2143
  *
1898
2144
  * @publicApi
1899
2145
  */
1900
- declare abstract class ControlEvent<T = any> {
2146
+ declare class FormRecord<TControl extends AbstractControl = AbstractControl> extends FormGroup<{
2147
+ [key: string]: TControl;
2148
+ }> {
2149
+ }
2150
+ interface FormRecord<TControl> {
1901
2151
  /**
1902
- * Form control from which this event is originated.
2152
+ * Registers a control with the records's list of controls.
1903
2153
  *
1904
- * Note: the type of the control can't be infered from T as the event can be emitted by any of child controls
2154
+ * See `FormGroup#registerControl` for additional information.
1905
2155
  */
1906
- abstract readonly source: AbstractControl<unknown>;
1907
- }
1908
- /**
1909
- * Event fired when the value of a control changes.
1910
- *
1911
- * @publicApi
1912
- */
1913
- declare class ValueChangeEvent<T> extends ControlEvent<T> {
1914
- readonly value: T;
1915
- readonly source: AbstractControl;
1916
- constructor(value: T, source: AbstractControl);
1917
- }
1918
- /**
1919
- * Event fired when the control's pristine state changes (pristine <=> dirty).
1920
- *
1921
- * @publicApi */
1922
- declare class PristineChangeEvent extends ControlEvent {
2156
+ registerControl(name: string, control: TControl): TControl;
2157
+ /**
2158
+ * Add a control to this group.
2159
+ *
2160
+ * See `FormGroup#addControl` for additional information.
2161
+ */
2162
+ addControl(name: string, control: TControl, options?: {
2163
+ emitEvent?: boolean;
2164
+ }): void;
2165
+ /**
2166
+ * Remove a control from this group.
2167
+ *
2168
+ * See `FormGroup#removeControl` for additional information.
2169
+ */
2170
+ removeControl(name: string, options?: {
2171
+ emitEvent?: boolean;
2172
+ }): void;
2173
+ /**
2174
+ * Replace an existing control.
2175
+ *
2176
+ * See `FormGroup#setControl` for additional information.
2177
+ */
2178
+ setControl(name: string, control: TControl, options?: {
2179
+ emitEvent?: boolean;
2180
+ }): void;
2181
+ /**
2182
+ * Check whether there is an enabled control with the given name in the group.
2183
+ *
2184
+ * See `FormGroup#contains` for additional information.
2185
+ */
2186
+ contains(controlName: string): boolean;
2187
+ /**
2188
+ * Sets the value of the `FormRecord`. It accepts an object that matches
2189
+ * the structure of the group, with control names as keys.
2190
+ *
2191
+ * See `FormGroup#setValue` for additional information.
2192
+ */
2193
+ setValue(value: {
2194
+ [key: string]: ɵRawValue<TControl>;
2195
+ }, options?: {
2196
+ onlySelf?: boolean;
2197
+ emitEvent?: boolean;
2198
+ }): void;
2199
+ /**
2200
+ * Patches the value of the `FormRecord`. It accepts an object with control
2201
+ * names as keys, and does its best to match the values to the correct controls
2202
+ * in the group.
2203
+ *
2204
+ * See `FormGroup#patchValue` for additional information.
2205
+ */
2206
+ patchValue(value: {
2207
+ [key: string]: ɵValue<TControl>;
2208
+ }, options?: {
2209
+ onlySelf?: boolean;
2210
+ emitEvent?: boolean;
2211
+ }): void;
2212
+ /**
2213
+ * Resets the `FormRecord`, marks all descendants `pristine` and `untouched` and sets
2214
+ * the value of all descendants to null.
2215
+ *
2216
+ * See `FormGroup#reset` for additional information.
2217
+ */
2218
+ reset(value?: {
2219
+ [key: string]: ɵValue<TControl> | FormControlState<ɵValue<TControl>>;
2220
+ }, options?: {
2221
+ onlySelf?: boolean;
2222
+ emitEvent?: boolean;
2223
+ }): void;
2224
+ /**
2225
+ * The aggregate value of the `FormRecord`, including any disabled controls.
2226
+ *
2227
+ * See `FormGroup#getRawValue` for additional information.
2228
+ */
2229
+ getRawValue(): {
2230
+ [key: string]: ɵRawValue<TControl>;
2231
+ };
2232
+ }
2233
+ /**
2234
+ * @description
2235
+ * Asserts that the given control is an instance of `FormRecord`
2236
+ *
2237
+ * @publicApi
2238
+ */
2239
+ declare const isFormRecord: (control: unknown) => control is FormRecord;
2240
+
2241
+ /**
2242
+ * A form can have several different statuses. Each
2243
+ * possible status is returned as a string literal.
2244
+ *
2245
+ * * **VALID**: Reports that a control is valid, meaning that no errors exist in the input
2246
+ * value.
2247
+ * * **INVALID**: Reports that a control is invalid, meaning that an error exists in the input
2248
+ * value.
2249
+ * * **PENDING**: Reports that a control is pending, meaning that async validation is
2250
+ * occurring and errors are not yet available for the input value.
2251
+ * * **DISABLED**: Reports that a control is
2252
+ * disabled, meaning that the control is exempt from ancestor calculations of validity or value.
2253
+ *
2254
+ * @publicApi
2255
+ */
2256
+ type FormControlStatus = 'VALID' | 'INVALID' | 'PENDING' | 'DISABLED';
2257
+ /**
2258
+ * Base class for every event sent by `AbstractControl.events()`
2259
+ *
2260
+ * @publicApi
2261
+ */
2262
+ declare abstract class ControlEvent<T = any> {
2263
+ /**
2264
+ * Form control from which this event is originated.
2265
+ *
2266
+ * Note: the type of the control can't be infered from T as the event can be emitted by any of child controls
2267
+ */
2268
+ abstract readonly source: AbstractControl<unknown>;
2269
+ }
2270
+ /**
2271
+ * Event fired when the value of a control changes.
2272
+ *
2273
+ * @publicApi
2274
+ */
2275
+ declare class ValueChangeEvent<T> extends ControlEvent<T> {
2276
+ readonly value: T;
2277
+ readonly source: AbstractControl;
2278
+ constructor(value: T, source: AbstractControl);
2279
+ }
2280
+ /**
2281
+ * Event fired when the control's pristine state changes (pristine <=> dirty).
2282
+ *
2283
+ * @publicApi */
2284
+ declare class PristineChangeEvent extends ControlEvent {
1923
2285
  readonly pristine: boolean;
1924
2286
  readonly source: AbstractControl;
1925
2287
  constructor(pristine: boolean, source: AbstractControl);
@@ -2122,7 +2484,7 @@ type ɵGetProperty<T, K> = K extends string ? ɵGetProperty<T, ɵCoerceStrArrToN
2122
2484
  *
2123
2485
  * @publicApi
2124
2486
  */
2125
- declare abstract class AbstractControl<TValue = any, TRawValue extends TValue = TValue> {
2487
+ declare abstract class AbstractControl<TValue = any, TRawValue extends TValue = TValue, TValueWithOptionalControlStates = any> {
2126
2488
  private _parent;
2127
2489
  private _asyncValidationSubscription;
2128
2490
  /**
@@ -2634,7 +2996,7 @@ declare abstract class AbstractControl<TValue = any, TRawValue extends TValue =
2634
2996
  /**
2635
2997
  * Resets the control. Abstract method (implemented in sub-classes).
2636
2998
  */
2637
- abstract reset(value?: TValue, options?: Object): void;
2999
+ abstract reset(value?: TValueWithOptionalControlStates, options?: Object): void;
2638
3000
  /**
2639
3001
  * The raw value of this control. For most control implementations, the raw value will include
2640
3002
  * disabled children.
@@ -3111,356 +3473,6 @@ declare class RadioControlValueAccessor extends BuiltInControlValueAccessor impl
3111
3473
  static ɵdir: i0.ɵɵDirectiveDeclaration<RadioControlValueAccessor, "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", never, { "name": { "alias": "name"; "required": false; }; "formControlName": { "alias": "formControlName"; "required": false; }; "value": { "alias": "value"; "required": false; }; }, {}, never, never, false, never>;
3112
3474
  }
3113
3475
 
3114
- /**
3115
- * FormControlState is a boxed form value. It is an object with a `value` key and a `disabled` key.
3116
- *
3117
- * @publicApi
3118
- */
3119
- interface FormControlState<T> {
3120
- value: T;
3121
- disabled: boolean;
3122
- }
3123
- /**
3124
- * Interface for options provided to a `FormControl`.
3125
- *
3126
- * This interface extends all options from {@link AbstractControlOptions}, plus some options
3127
- * unique to `FormControl`.
3128
- *
3129
- * @publicApi
3130
- */
3131
- interface FormControlOptions extends AbstractControlOptions {
3132
- /**
3133
- * @description
3134
- * Whether to use the initial value used to construct the `FormControl` as its default value
3135
- * as well. If this option is false or not provided, the default value of a FormControl is `null`.
3136
- * When a FormControl is reset without an explicit value, its value reverts to
3137
- * its default value.
3138
- */
3139
- nonNullable?: boolean;
3140
- /**
3141
- * @deprecated Use `nonNullable` instead.
3142
- */
3143
- initialValueIsDefault?: boolean;
3144
- }
3145
- /**
3146
- * Various available constructors for `FormControl`.
3147
- * Do not use this interface directly. Instead, use `FormControl`:
3148
- * ```ts
3149
- * const fc = new FormControl('foo');
3150
- * ```
3151
- * This symbol is prefixed with ɵ to make plain that it is an internal symbol.
3152
- */
3153
- interface ɵFormControlCtor {
3154
- /**
3155
- * Construct a FormControl with no initial value or validators.
3156
- */
3157
- new (): FormControl<any>;
3158
- /**
3159
- * Creates a new `FormControl` instance.
3160
- *
3161
- * @param value Initializes the control with an initial value,
3162
- * or an object that defines the initial value and disabled state.
3163
- *
3164
- * @param opts A `FormControlOptions` object that contains validation functions and a
3165
- * validation trigger. `nonNullable` have to be `true`
3166
- */
3167
- new <T = any>(value: FormControlState<T> | T, opts: FormControlOptions & {
3168
- nonNullable: true;
3169
- }): FormControl<T>;
3170
- /**
3171
- * @deprecated Use `nonNullable` instead.
3172
- */
3173
- new <T = any>(value: FormControlState<T> | T, opts: FormControlOptions & {
3174
- initialValueIsDefault: true;
3175
- }): FormControl<T>;
3176
- /**
3177
- * @deprecated When passing an `options` argument, the `asyncValidator` argument has no effect.
3178
- */
3179
- new <T = any>(value: FormControlState<T> | T, opts: FormControlOptions, asyncValidator: AsyncValidatorFn | AsyncValidatorFn[]): FormControl<T | null>;
3180
- /**
3181
- * Creates a new `FormControl` instance.
3182
- *
3183
- * @param value Initializes the control with an initial value,
3184
- * or an object that defines the initial value and disabled state.
3185
- *
3186
- * @param validatorOrOpts A synchronous validator function, or an array of
3187
- * such functions, or a `FormControlOptions` object that contains validation functions
3188
- * and a validation trigger.
3189
- *
3190
- * @param asyncValidator A single async validator or array of async validator functions
3191
- */
3192
- new <T = any>(value: FormControlState<T> | T, validatorOrOpts?: ValidatorFn | ValidatorFn[] | FormControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): FormControl<T | null>;
3193
- /**
3194
- * The presence of an explicit `prototype` property provides backwards-compatibility for apps that
3195
- * manually inspect the prototype chain.
3196
- */
3197
- prototype: FormControl<any>;
3198
- }
3199
- /**
3200
- * Tracks the value and validation status of an individual form control.
3201
- *
3202
- * This is one of the four fundamental building blocks of Angular forms, along with
3203
- * `FormGroup`, `FormArray` and `FormRecord`. It extends the `AbstractControl` class that
3204
- * implements most of the base functionality for accessing the value, validation status,
3205
- * user interactions and events.
3206
- *
3207
- * `FormControl` takes a single generic argument, which describes the type of its value. This
3208
- * argument always implicitly includes `null` because the control can be reset. To change this
3209
- * behavior, set `nonNullable` or see the usage notes below.
3210
- *
3211
- * See [usage examples below](#usage-notes).
3212
- *
3213
- * @see {@link AbstractControl}
3214
- * @see [Reactive Forms Guide](guide/forms/reactive-forms)
3215
- * @see [Usage Notes](#usage-notes)
3216
- *
3217
- * @publicApi
3218
- *
3219
- * @overriddenImplementation ɵFormControlCtor
3220
- *
3221
- * @usageNotes
3222
- *
3223
- * ### Initializing Form Controls
3224
- *
3225
- * Instantiate a `FormControl`, with an initial value.
3226
- *
3227
- * ```ts
3228
- * const control = new FormControl('some value');
3229
- * console.log(control.value); // 'some value'
3230
- * ```
3231
- *
3232
- * The following example initializes the control with a form state object. The `value`
3233
- * and `disabled` keys are required in this case.
3234
- *
3235
- * ```ts
3236
- * const control = new FormControl({ value: 'n/a', disabled: true });
3237
- * console.log(control.value); // 'n/a'
3238
- * console.log(control.status); // 'DISABLED'
3239
- * ```
3240
- *
3241
- * The following example initializes the control with a synchronous validator.
3242
- *
3243
- * ```ts
3244
- * const control = new FormControl('', Validators.required);
3245
- * console.log(control.value); // ''
3246
- * console.log(control.status); // 'INVALID'
3247
- * ```
3248
- *
3249
- * The following example initializes the control using an options object.
3250
- *
3251
- * ```ts
3252
- * const control = new FormControl('', {
3253
- * validators: Validators.required,
3254
- * asyncValidators: myAsyncValidator
3255
- * });
3256
- * ```
3257
- *
3258
- * ### The single type argument
3259
- *
3260
- * `FormControl` accepts a generic argument, which describes the type of its value.
3261
- * In most cases, this argument will be inferred.
3262
- *
3263
- * If you are initializing the control to `null`, or you otherwise wish to provide a
3264
- * wider type, you may specify the argument explicitly:
3265
- *
3266
- * ```ts
3267
- * let fc = new FormControl<string|null>(null);
3268
- * fc.setValue('foo');
3269
- * ```
3270
- *
3271
- * You might notice that `null` is always added to the type of the control.
3272
- * This is because the control will become `null` if you call `reset`. You can change
3273
- * this behavior by setting `{nonNullable: true}`.
3274
- *
3275
- * ### Configure the control to update on a blur event
3276
- *
3277
- * Set the `updateOn` option to `'blur'` to update on the blur `event`.
3278
- *
3279
- * ```ts
3280
- * const control = new FormControl('', { updateOn: 'blur' });
3281
- * ```
3282
- *
3283
- * ### Configure the control to update on a submit event
3284
- *
3285
- * Set the `updateOn` option to `'submit'` to update on a submit `event`.
3286
- *
3287
- * ```ts
3288
- * const control = new FormControl('', { updateOn: 'submit' });
3289
- * ```
3290
- *
3291
- * ### Reset the control back to a specific value
3292
- *
3293
- * You reset to a specific form state by passing through a standalone
3294
- * value or a form state object that contains both a value and a disabled state
3295
- * (these are the only two properties that cannot be calculated).
3296
- *
3297
- * ```ts
3298
- * const control = new FormControl('Nancy');
3299
- *
3300
- * console.log(control.value); // 'Nancy'
3301
- *
3302
- * control.reset('Drew');
3303
- *
3304
- * console.log(control.value); // 'Drew'
3305
- * ```
3306
- *
3307
- * ### Reset the control to its initial value
3308
- *
3309
- * If you wish to always reset the control to its initial value (instead of null),
3310
- * you can pass the `nonNullable` option:
3311
- *
3312
- * ```ts
3313
- * const control = new FormControl('Nancy', {nonNullable: true});
3314
- *
3315
- * console.log(control.value); // 'Nancy'
3316
- *
3317
- * control.reset();
3318
- *
3319
- * console.log(control.value); // 'Nancy'
3320
- * ```
3321
- *
3322
- * ### Reset the control back to an initial value and disabled
3323
- *
3324
- * ```ts
3325
- * const control = new FormControl('Nancy');
3326
- *
3327
- * console.log(control.value); // 'Nancy'
3328
- * console.log(control.status); // 'VALID'
3329
- *
3330
- * control.reset({ value: 'Drew', disabled: true });
3331
- *
3332
- * console.log(control.value); // 'Drew'
3333
- * console.log(control.status); // 'DISABLED'
3334
- * ```
3335
- */
3336
- interface FormControl<TValue = any> extends AbstractControl<TValue> {
3337
- /**
3338
- * The default value of this FormControl, used whenever the control is reset without an explicit
3339
- * value. See {@link FormControlOptions#nonNullable} for more information on configuring
3340
- * a default value.
3341
- */
3342
- readonly defaultValue: TValue;
3343
- /**
3344
- * Sets a new value for the form control.
3345
- *
3346
- * @param value The new value for the control.
3347
- * @param options Configuration options that determine how the control propagates changes
3348
- * and emits events when the value changes.
3349
- * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity
3350
- * updateValueAndValidity} method.
3351
- *
3352
- * * `onlySelf`: When true, each change only affects this control, and not its parent. Default is
3353
- * false.
3354
- * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
3355
- * `valueChanges`
3356
- * observables emit events with the latest status and value when the control value is updated.
3357
- * When false, no events are emitted.
3358
- * * `emitModelToViewChange`: When true or not supplied (the default), each change triggers an
3359
- * `onChange` event to
3360
- * update the view.
3361
- * * `emitViewToModelChange`: When true or not supplied (the default), each change triggers an
3362
- * `ngModelChange`
3363
- * event to update the model.
3364
- *
3365
- */
3366
- setValue(value: TValue, options?: {
3367
- onlySelf?: boolean;
3368
- emitEvent?: boolean;
3369
- emitModelToViewChange?: boolean;
3370
- emitViewToModelChange?: boolean;
3371
- }): void;
3372
- /**
3373
- * Patches the value of a control.
3374
- *
3375
- * This function is functionally the same as {@link FormControl#setValue setValue} at this level.
3376
- * It exists for symmetry with {@link FormGroup#patchValue patchValue} on `FormGroups` and
3377
- * `FormArrays`, where it does behave differently.
3378
- *
3379
- * @see {@link FormControl#setValue} for options
3380
- */
3381
- patchValue(value: TValue, options?: {
3382
- onlySelf?: boolean;
3383
- emitEvent?: boolean;
3384
- emitModelToViewChange?: boolean;
3385
- emitViewToModelChange?: boolean;
3386
- }): void;
3387
- /**
3388
- * Resets the form control, marking it `pristine` and `untouched`, and resetting
3389
- * the value. The new value will be the provided value (if passed), `null`, or the initial value
3390
- * if `nonNullable` was set in the constructor via {@link FormControlOptions}.
3391
- *
3392
- * ```ts
3393
- * // By default, the control will reset to null.
3394
- * const dog = new FormControl('spot');
3395
- * dog.reset(); // dog.value is null
3396
- *
3397
- * // If this flag is set, the control will instead reset to the initial value.
3398
- * const cat = new FormControl('tabby', {nonNullable: true});
3399
- * cat.reset(); // cat.value is "tabby"
3400
- *
3401
- * // A value passed to reset always takes precedence.
3402
- * const fish = new FormControl('finn', {nonNullable: true});
3403
- * fish.reset('bubble'); // fish.value is "bubble"
3404
- * ```
3405
- *
3406
- * @param formState Resets the control with an initial value,
3407
- * or an object that defines the initial value and disabled state.
3408
- *
3409
- * @param options Configuration options that determine how the control propagates changes
3410
- * and emits events after the value changes.
3411
- *
3412
- * * `onlySelf`: When true, each change only affects this control, and not its parent. Default is
3413
- * false.
3414
- * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
3415
- * `valueChanges`
3416
- * observables emit events with the latest status and value when the control is reset.
3417
- * When false, no events are emitted.
3418
- *
3419
- */
3420
- reset(formState?: TValue | FormControlState<TValue>, options?: {
3421
- onlySelf?: boolean;
3422
- emitEvent?: boolean;
3423
- }): void;
3424
- /**
3425
- * For a simple FormControl, the raw value is equivalent to the value.
3426
- */
3427
- getRawValue(): TValue;
3428
- /**
3429
- * Register a listener for change events.
3430
- *
3431
- * @param fn The method that is called when the value changes
3432
- */
3433
- registerOnChange(fn: Function): void;
3434
- /**
3435
- * Register a listener for disabled events.
3436
- *
3437
- * @param fn The method that is called when the disabled status changes.
3438
- */
3439
- registerOnDisabledChange(fn: (isDisabled: boolean) => void): void;
3440
- }
3441
- declare const FormControl: ɵFormControlCtor;
3442
- interface UntypedFormControlCtor {
3443
- new (): UntypedFormControl;
3444
- new (formState?: any, validatorOrOpts?: ValidatorFn | ValidatorFn[] | FormControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): UntypedFormControl;
3445
- /**
3446
- * The presence of an explicit `prototype` property provides backwards-compatibility for apps that
3447
- * manually inspect the prototype chain.
3448
- */
3449
- prototype: FormControl<any>;
3450
- }
3451
- /**
3452
- * UntypedFormControl is a non-strongly-typed version of `FormControl`.
3453
- */
3454
- type UntypedFormControl = FormControl<any>;
3455
- declare const UntypedFormControl: UntypedFormControlCtor;
3456
- /**
3457
- * @description
3458
- * Asserts that the given control is an instance of `FormControl`
3459
- *
3460
- * @publicApi
3461
- */
3462
- declare const isFormControl: (control: unknown) => control is FormControl;
3463
-
3464
3476
  /**
3465
3477
  * @description
3466
3478
  * A base class for code shared between the `NgModelGroup` and `FormGroupName` directives.