{"version":3,"file":"forms.js","sources":["../../../../../../packages/forms/src/directives/control_value_accessor.ts","../../../../../../packages/forms/src/directives/checkbox_value_accessor.ts","../../../../../../packages/forms/src/directives/default_value_accessor.ts","../../../../../../packages/forms/src/validators.ts","../../../../../../packages/forms/src/directives/abstract_control_directive.ts","../../../../../../packages/forms/src/directives/control_container.ts","../../../../../../packages/forms/src/directives/ng_control.ts","../../../../../../packages/forms/src/directives/ng_control_status.ts","../../../../../../packages/forms/src/directives/error_examples.ts","../../../../../../packages/forms/src/directives/reactive_errors.ts","../../../../../../packages/forms/src/directives/shared.ts","../../../../../../packages/forms/src/model.ts","../../../../../../packages/forms/src/directives/ng_form.ts","../../../../../../packages/forms/src/directives/abstract_form_group_directive.ts","../../../../../../packages/forms/src/directives/template_driven_errors.ts","../../../../../../packages/forms/src/directives/ng_model_group.ts","../../../../../../packages/forms/src/directives/ng_model.ts","../../../../../../packages/forms/src/directives/ng_no_validate_directive.ts","../../../../../../packages/forms/src/directives/number_value_accessor.ts","../../../../../../packages/forms/src/directives/radio_control_value_accessor.ts","../../../../../../packages/forms/src/directives/range_value_accessor.ts","../../../../../../packages/forms/src/directives/reactive_directives/form_control_directive.ts","../../../../../../packages/forms/src/directives/reactive_directives/form_group_directive.ts","../../../../../../packages/forms/src/directives/reactive_directives/form_group_name.ts","../../../../../../packages/forms/src/directives/reactive_directives/form_control_name.ts","../../../../../../packages/forms/src/directives/select_control_value_accessor.ts","../../../../../../packages/forms/src/directives/select_multiple_control_value_accessor.ts","../../../../../../packages/forms/src/directives/validators.ts","../../../../../../packages/forms/src/directives.ts","../../../../../../packages/forms/src/form_providers.ts","../../../../../../packages/forms/src/form_builder.ts","../../../../../../packages/forms/src/version.ts","../../../../../../packages/forms/src/forms.ts","../../../../../../packages/forms/public_api.ts","../../../../../../packages/forms/index.ts","../../../../../../packages/forms/forms.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Directive, ElementRef, InjectionToken, Renderer2} from '@angular/core';\n\n/**\n * @description\n * Defines an interface that acts as a bridge between the Angular forms API and a\n * native element in the DOM.\n *\n * Implement this interface to create a custom form control directive\n * that integrates with Angular forms.\n *\n * @see DefaultValueAccessor\n *\n * @publicApi\n */\nexport interface ControlValueAccessor {\n /**\n * @description\n * Writes a new value to the element.\n *\n * This method is called by the forms API to write to the view when programmatic\n * changes from model to view are requested.\n *\n * @usageNotes\n * ### Write a value to the element\n *\n * The following example writes a value to the native DOM element.\n *\n * ```ts\n * writeValue(value: any): void {\n * this._renderer.setProperty(this._elementRef.nativeElement, 'value', value);\n * }\n * ```\n *\n * @param obj The new value for the element\n */\n writeValue(obj: any): void;\n\n /**\n * @description\n * Registers a callback function that is called when the control's value\n * changes in the UI.\n *\n * This method is called by the forms API on initialization to update the form\n * model when values propagate from the view to the model.\n *\n * When implementing the `registerOnChange` method in your own value accessor,\n * save the given function so your class calls it at the appropriate time.\n *\n * @usageNotes\n * ### Store the change function\n *\n * The following example stores the provided function as an internal method.\n *\n * ```ts\n * registerOnChange(fn: (_: any) => void): void {\n * this._onChange = fn;\n * }\n * ```\n *\n * When the value changes in the UI, call the registered\n * function to allow the forms API to update itself:\n *\n * ```ts\n * host: {\n * '(change)': '_onChange($event.target.value)'\n * }\n * ```\n *\n * @param fn The callback function to register\n */\n registerOnChange(fn: any): void;\n\n /**\n * @description\n * Registers a callback function that is called by the forms API on initialization\n * to update the form model on blur.\n *\n * When implementing `registerOnTouched` in your own value accessor, save the given\n * function so your class calls it when the control should be considered\n * blurred or \"touched\".\n *\n * @usageNotes\n * ### Store the callback function\n *\n * The following example stores the provided function as an internal method.\n *\n * ```ts\n * registerOnTouched(fn: any): void {\n * this._onTouched = fn;\n * }\n * ```\n *\n * On blur (or equivalent), your class should call the registered function to allow\n * the forms API to update itself:\n *\n * ```ts\n * host: {\n * '(blur)': '_onTouched()'\n * }\n * ```\n *\n * @param fn The callback function to register\n */\n registerOnTouched(fn: any): void;\n\n /**\n * @description\n * Function that is called by the forms API when the control status changes to\n * or from 'DISABLED'. Depending on the status, it enables or disables the\n * appropriate DOM element.\n *\n * @usageNotes\n * The following is an example of writing the disabled property to a native DOM element:\n *\n * ```ts\n * setDisabledState(isDisabled: boolean): void {\n * this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);\n * }\n * ```\n *\n * @param isDisabled The disabled status to set on the element\n */\n setDisabledState?(isDisabled: boolean): void;\n}\n\n/**\n * Base class for all ControlValueAccessor classes defined in Forms package.\n * Contains common logic and utility functions.\n *\n * Note: this is an *internal-only* class and should not be extended or used directly in\n * applications code.\n */\n@Directive()\nexport class BaseControlValueAccessor {\n /**\n * The registered callback function called when a change or input event occurs on the input\n * element.\n * @nodoc\n */\n onChange = (_: any) => {};\n\n /**\n * The registered callback function called when a blur event occurs on the input element.\n * @nodoc\n */\n onTouched = () => {};\n\n constructor(private _renderer: Renderer2, private _elementRef: ElementRef) {}\n\n /**\n * Helper method that sets a property on a target element using the current Renderer\n * implementation.\n * @nodoc\n */\n protected setProperty(key: string, value: any): void {\n this._renderer.setProperty(this._elementRef.nativeElement, key, value);\n }\n\n /**\n * Registers a function called when the control is touched.\n * @nodoc\n */\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n\n /**\n * Registers a function called when the control value changes.\n * @nodoc\n */\n registerOnChange(fn: (_: any) => {}): void {\n this.onChange = fn;\n }\n\n /**\n * Sets the \"disabled\" property on the range input element.\n * @nodoc\n */\n setDisabledState(isDisabled: boolean): void {\n this.setProperty('disabled', isDisabled);\n }\n}\n\n/**\n * Base class for all built-in ControlValueAccessor classes (except DefaultValueAccessor, which is\n * used in case no other CVAs can be found). We use this class to distinguish between default CVA,\n * built-in CVAs and custom CVAs, so that Forms logic can recognize built-in CVAs and treat custom\n * ones with higher priority (when both built-in and custom CVAs are present).\n *\n * Note: this is an *internal-only* class and should not be extended or used directly in\n * applications code.\n */\n@Directive()\nexport class BuiltInControlValueAccessor extends BaseControlValueAccessor {\n}\n\n/**\n * Used to provide a `ControlValueAccessor` for form controls.\n *\n * See `DefaultValueAccessor` for how to implement one.\n *\n * @publicApi\n */\nexport const NG_VALUE_ACCESSOR =\n new InjectionToken>('NgValueAccessor');\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Directive, ElementRef, forwardRef, Renderer2} from '@angular/core';\n\nimport {BuiltInControlValueAccessor, ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';\n\nexport const CHECKBOX_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => CheckboxControlValueAccessor),\n multi: true,\n};\n\n/**\n * @description\n * A `ControlValueAccessor` for writing a value and listening to changes on a checkbox input\n * element.\n *\n * @usageNotes\n *\n * ### Using a checkbox with a reactive form.\n *\n * The following example shows how to use a checkbox with a reactive form.\n *\n * ```ts\n * const rememberLoginControl = new FormControl();\n * ```\n *\n * ```\n * \n * ```\n *\n * @ngModule ReactiveFormsModule\n * @ngModule FormsModule\n * @publicApi\n */\n@Directive({\n selector:\n 'input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]',\n host: {'(change)': 'onChange($event.target.checked)', '(blur)': 'onTouched()'},\n providers: [CHECKBOX_VALUE_ACCESSOR]\n})\nexport class CheckboxControlValueAccessor extends BuiltInControlValueAccessor implements\n ControlValueAccessor {\n /**\n * Sets the \"checked\" property on the input element.\n * @nodoc\n */\n writeValue(value: any): void {\n this.setProperty('checked', value);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {ɵgetDOM as getDOM} from '@angular/common';\nimport {Directive, ElementRef, forwardRef, Inject, InjectionToken, Optional, Renderer2} from '@angular/core';\n\nimport {BaseControlValueAccessor, ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';\n\nexport const DEFAULT_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => DefaultValueAccessor),\n multi: true\n};\n\n/**\n * We must check whether the agent is Android because composition events\n * behave differently between iOS and Android.\n */\nfunction _isAndroid(): boolean {\n const userAgent = getDOM() ? getDOM().getUserAgent() : '';\n return /android (\\d+)/.test(userAgent.toLowerCase());\n}\n\n/**\n * @description\n * Provide this token to control if form directives buffer IME input until\n * the \"compositionend\" event occurs.\n * @publicApi\n */\nexport const COMPOSITION_BUFFER_MODE = new InjectionToken('CompositionEventMode');\n\n/**\n * The default `ControlValueAccessor` for writing a value and listening to changes on input\n * elements. The accessor is used by the `FormControlDirective`, `FormControlName`, and\n * `NgModel` directives.\n *\n * {@searchKeywords ngDefaultControl}\n *\n * @usageNotes\n *\n * ### Using the default value accessor\n *\n * The following example shows how to use an input element that activates the default value accessor\n * (in this case, a text field).\n *\n * ```ts\n * const firstNameControl = new FormControl();\n * ```\n *\n * ```\n * \n * ```\n *\n * This value accessor is used by default for `` and `