/** * @license Angular v2.4.5 * (c) 2010-2016 Google, Inc. https://angular.io/ * License: MIT */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/operator/toPromise'), require('rxjs/Subject'), require('rxjs/Observable'), require('rxjs/observable/fromPromise')) : typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'rxjs/operator/toPromise', 'rxjs/Subject', 'rxjs/Observable', 'rxjs/observable/fromPromise'], factory) : (factory((global.ng = global.ng || {}, global.ng.forms = global.ng.forms || {}),global.ng.core,global.Rx.Observable.prototype,global.Rx,global.Rx,global.Rx.Observable)); }(this, function (exports,_angular_core,rxjs_operator_toPromise,rxjs_Subject,rxjs_Observable,rxjs_observable_fromPromise) { 'use strict'; /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * Base class for control directives. * * Only used internally in the forms module. * * \@stable * @abstract */ var AbstractControlDirective = (function () { function AbstractControlDirective() { } Object.defineProperty(AbstractControlDirective.prototype, "control", { /** * @return {?} */ get: function () { throw new Error('unimplemented'); }, enumerable: true, configurable: true }); Object.defineProperty(AbstractControlDirective.prototype, "value", { /** * @return {?} */ get: function () { return this.control ? this.control.value : null; }, enumerable: true, configurable: true }); Object.defineProperty(AbstractControlDirective.prototype, "valid", { /** * @return {?} */ get: function () { return this.control ? this.control.valid : null; }, enumerable: true, configurable: true }); Object.defineProperty(AbstractControlDirective.prototype, "invalid", { /** * @return {?} */ get: function () { return this.control ? this.control.invalid : null; }, enumerable: true, configurable: true }); Object.defineProperty(AbstractControlDirective.prototype, "pending", { /** * @return {?} */ get: function () { return this.control ? this.control.pending : null; }, enumerable: true, configurable: true }); Object.defineProperty(AbstractControlDirective.prototype, "errors", { /** * @return {?} */ get: function () { return this.control ? this.control.errors : null; }, enumerable: true, configurable: true }); Object.defineProperty(AbstractControlDirective.prototype, "pristine", { /** * @return {?} */ get: function () { return this.control ? this.control.pristine : null; }, enumerable: true, configurable: true }); Object.defineProperty(AbstractControlDirective.prototype, "dirty", { /** * @return {?} */ get: function () { return this.control ? this.control.dirty : null; }, enumerable: true, configurable: true }); Object.defineProperty(AbstractControlDirective.prototype, "touched", { /** * @return {?} */ get: function () { return this.control ? this.control.touched : null; }, enumerable: true, configurable: true }); Object.defineProperty(AbstractControlDirective.prototype, "untouched", { /** * @return {?} */ get: function () { return this.control ? this.control.untouched : null; }, enumerable: true, configurable: true }); Object.defineProperty(AbstractControlDirective.prototype, "disabled", { /** * @return {?} */ get: function () { return this.control ? this.control.disabled : null; }, enumerable: true, configurable: true }); Object.defineProperty(AbstractControlDirective.prototype, "enabled", { /** * @return {?} */ get: function () { return this.control ? this.control.enabled : null; }, enumerable: true, configurable: true }); Object.defineProperty(AbstractControlDirective.prototype, "statusChanges", { /** * @return {?} */ get: function () { return this.control ? this.control.statusChanges : null; }, enumerable: true, configurable: true }); Object.defineProperty(AbstractControlDirective.prototype, "valueChanges", { /** * @return {?} */ get: function () { return this.control ? this.control.valueChanges : null; }, enumerable: true, configurable: true }); Object.defineProperty(AbstractControlDirective.prototype, "path", { /** * @return {?} */ get: function () { return null; }, enumerable: true, configurable: true }); /** * @param {?=} value * @return {?} */ AbstractControlDirective.prototype.reset = function (value) { if (value === void 0) { value = undefined; } if (this.control) this.control.reset(value); }; /** * @param {?} errorCode * @param {?=} path * @return {?} */ AbstractControlDirective.prototype.hasError = function (errorCode, path) { if (path === void 0) { path = null; } return this.control ? this.control.hasError(errorCode, path) : false; }; /** * @param {?} errorCode * @param {?=} path * @return {?} */ AbstractControlDirective.prototype.getError = function (errorCode, path) { if (path === void 0) { path = null; } return this.control ? this.control.getError(errorCode, path) : null; }; return AbstractControlDirective; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var __extends$1 = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /** * A directive that contains multiple {\@link NgControl}s. * * Only used by the forms module. * * \@stable */ var ControlContainer = (function (_super) { __extends$1(ControlContainer, _super); function ControlContainer() { _super.apply(this, arguments); } Object.defineProperty(ControlContainer.prototype, "formDirective", { /** * Get the form to which this container belongs. * @return {?} */ get: function () { return null; }, enumerable: true, configurable: true }); Object.defineProperty(ControlContainer.prototype, "path", { /** * Get the path to this container. * @return {?} */ get: function () { return null; }, enumerable: true, configurable: true }); return ControlContainer; }(AbstractControlDirective)); /** * @param {?} obj * @return {?} */ function isPresent(obj) { return obj != null; } /** * @param {?} obj * @return {?} */ function isBlank(obj) { return obj == null; } /** * @param {?} a * @param {?} b * @return {?} */ function looseIdentical(a, b) { return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b); } /** * @param {?} o * @return {?} */ function isJsObject(o) { return o !== null && (typeof o === 'function' || typeof o === 'object'); } /** * @param {?} obj * @return {?} */ function isPrimitive(obj) { return !isJsObject(obj); } /** * Wraps Javascript Objects */ var StringMapWrapper = (function () { function StringMapWrapper() { } /** * @param {?} m1 * @param {?} m2 * @return {?} */ StringMapWrapper.merge = function (m1, m2) { var /** @type {?} */ m = {}; for (var _i = 0, _a = Object.keys(m1); _i < _a.length; _i++) { var k = _a[_i]; m[k] = m1[k]; } for (var _b = 0, _c = Object.keys(m2); _b < _c.length; _b++) { var k = _c[_b]; m[k] = m2[k]; } return m; }; /** * @param {?} m1 * @param {?} m2 * @return {?} */ StringMapWrapper.equals = function (m1, m2) { var /** @type {?} */ k1 = Object.keys(m1); var /** @type {?} */ k2 = Object.keys(m2); if (k1.length != k2.length) { return false; } for (var /** @type {?} */ i = 0; i < k1.length; i++) { var /** @type {?} */ key = k1[i]; if (m1[key] !== m2[key]) { return false; } } return true; }; return StringMapWrapper; }()); var ListWrapper = (function () { function ListWrapper() { } /** * @param {?} arr * @param {?} condition * @return {?} */ ListWrapper.findLast = function (arr, condition) { for (var /** @type {?} */ i = arr.length - 1; i >= 0; i--) { if (condition(arr[i])) { return arr[i]; } } return null; }; /** * @param {?} list * @param {?} items * @return {?} */ ListWrapper.removeAll = function (list, items) { for (var /** @type {?} */ i = 0; i < items.length; ++i) { var /** @type {?} */ index = list.indexOf(items[i]); if (index > -1) { list.splice(index, 1); } } }; /** * @param {?} list * @param {?} el * @return {?} */ ListWrapper.remove = function (list, el) { var /** @type {?} */ index = list.indexOf(el); if (index > -1) { list.splice(index, 1); return true; } return false; }; /** * @param {?} a * @param {?} b * @return {?} */ ListWrapper.equals = function (a, b) { if (a.length != b.length) return false; for (var /** @type {?} */ i = 0; i < a.length; ++i) { if (a[i] !== b[i]) return false; } return true; }; /** * @param {?} list * @return {?} */ ListWrapper.flatten = function (list) { return list.reduce(function (flat, item) { var /** @type {?} */ flatItem = Array.isArray(item) ? ListWrapper.flatten(item) : item; return ((flat)).concat(flatItem); }, []); }; return ListWrapper; }()); var /** @type {?} */ isPromise = _angular_core.__core_private__.isPromise; /** * @param {?} value * @return {?} */ function isEmptyInputValue(value) { // we don't check for string here so it also works with arrays return value == null || value.length === 0; } /** * Providers for validators to be used for {@link FormControl}s in a form. * * Provide this using `multi: true` to add validators. * * ### Example * * {@example core/forms/ts/ng_validators/ng_validators.ts region='ng_validators'} * @stable */ var /** @type {?} */ NG_VALIDATORS = new _angular_core.OpaqueToken('NgValidators'); /** * Providers for asynchronous validators to be used for {@link FormControl}s * in a form. * * Provide this using `multi: true` to add validators. * * See {@link NG_VALIDATORS} for more details. * * @stable */ var /** @type {?} */ NG_ASYNC_VALIDATORS = new _angular_core.OpaqueToken('NgAsyncValidators'); /** * Provides a set of validators used by form controls. * * A validator is a function that processes a {\@link FormControl} or collection of * controls and returns a map of errors. A null map means that validation has passed. * * ### Example * * ```typescript * var loginControl = new FormControl("", Validators.required) * ``` * * \@stable */ var Validators = (function () { function Validators() { } /** * Validator that requires controls to have a non-empty value. * @param {?} control * @return {?} */ Validators.required = function (control) { return isEmptyInputValue(control.value) ? { 'required': true } : null; }; /** * Validator that requires control value to be true. * @param {?} control * @return {?} */ Validators.requiredTrue = function (control) { return control.value === true ? null : { 'required': true }; }; /** * Validator that requires controls to have a value of a minimum length. * @param {?} minLength * @return {?} */ Validators.minLength = function (minLength) { return function (control) { if (isEmptyInputValue(control.value)) { return null; // don't validate empty values to allow optional controls } var /** @type {?} */ length = control.value ? control.value.length : 0; return length < minLength ? { 'minlength': { 'requiredLength': minLength, 'actualLength': length } } : null; }; }; /** * Validator that requires controls to have a value of a maximum length. * @param {?} maxLength * @return {?} */ Validators.maxLength = function (maxLength) { return function (control) { var /** @type {?} */ length = control.value ? control.value.length : 0; return length > maxLength ? { 'maxlength': { 'requiredLength': maxLength, 'actualLength': length } } : null; }; }; /** * Validator that requires a control to match a regex to its value. * @param {?} pattern * @return {?} */ Validators.pattern = function (pattern) { if (!pattern) return Validators.nullValidator; var /** @type {?} */ regex; var /** @type {?} */ regexStr; if (typeof pattern === 'string') { regexStr = "^" + pattern + "$"; regex = new RegExp(regexStr); } else { regexStr = pattern.toString(); regex = pattern; } return function (control) { if (isEmptyInputValue(control.value)) { return null; // don't validate empty values to allow optional controls } var /** @type {?} */ value = control.value; return regex.test(value) ? null : { 'pattern': { 'requiredPattern': regexStr, 'actualValue': value } }; }; }; /** * No-op validator. * @param {?} c * @return {?} */ Validators.nullValidator = function (c) { return null; }; /** * Compose multiple validators into a single function that returns the union * of the individual error maps. * @param {?} validators * @return {?} */ Validators.compose = function (validators) { if (!validators) return null; var /** @type {?} */ presentValidators = validators.filter(isPresent); if (presentValidators.length == 0) return null; return function (control) { return _mergeErrors(_executeValidators(control, presentValidators)); }; }; /** * @param {?} validators * @return {?} */ Validators.composeAsync = function (validators) { if (!validators) return null; var /** @type {?} */ presentValidators = validators.filter(isPresent); if (presentValidators.length == 0) return null; return function (control) { var /** @type {?} */ promises = _executeAsyncValidators(control, presentValidators).map(_convertToPromise); return Promise.all(promises).then(_mergeErrors); }; }; return Validators; }()); /** * @param {?} obj * @return {?} */ function _convertToPromise(obj) { return isPromise(obj) ? obj : rxjs_operator_toPromise.toPromise.call(obj); } /** * @param {?} control * @param {?} validators * @return {?} */ function _executeValidators(control, validators) { return validators.map(function (v) { return v(control); }); } /** * @param {?} control * @param {?} validators * @return {?} */ function _executeAsyncValidators(control, validators) { return validators.map(function (v) { return v(control); }); } /** * @param {?} arrayOfErrors * @return {?} */ function _mergeErrors(arrayOfErrors) { var /** @type {?} */ res = arrayOfErrors.reduce(function (res, errors) { return isPresent(errors) ? StringMapWrapper.merge(res, errors) : res; }, {}); return Object.keys(res).length === 0 ? null : res; } /** * Used to provide a {@link ControlValueAccessor} for form controls. * * See {@link DefaultValueAccessor} for how to implement one. * @stable */ var /** @type {?} */ NG_VALUE_ACCESSOR = new _angular_core.OpaqueToken('NgValueAccessor'); var /** @type {?} */ CHECKBOX_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: _angular_core.forwardRef(function () { return CheckboxControlValueAccessor; }), multi: true, }; /** * The accessor for writing a value and listening to changes on a checkbox input element. * * ### Example * ``` * * ``` * * \@stable */ var CheckboxControlValueAccessor = (function () { /** * @param {?} _renderer * @param {?} _elementRef */ function CheckboxControlValueAccessor(_renderer, _elementRef) { this._renderer = _renderer; this._elementRef = _elementRef; this.onChange = function (_) { }; this.onTouched = function () { }; } /** * @param {?} value * @return {?} */ CheckboxControlValueAccessor.prototype.writeValue = function (value) { this._renderer.setElementProperty(this._elementRef.nativeElement, 'checked', value); }; /** * @param {?} fn * @return {?} */ CheckboxControlValueAccessor.prototype.registerOnChange = function (fn) { this.onChange = fn; }; /** * @param {?} fn * @return {?} */ CheckboxControlValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; }; /** * @param {?} isDisabled * @return {?} */ CheckboxControlValueAccessor.prototype.setDisabledState = function (isDisabled) { this._renderer.setElementProperty(this._elementRef.nativeElement, 'disabled', isDisabled); }; CheckboxControlValueAccessor.decorators = [ { type: _angular_core.Directive, args: [{ selector: 'input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]', host: { '(change)': 'onChange($event.target.checked)', '(blur)': 'onTouched()' }, providers: [CHECKBOX_VALUE_ACCESSOR] },] }, ]; /** @nocollapse */ CheckboxControlValueAccessor.ctorParameters = function () { return [ { type: _angular_core.Renderer, }, { type: _angular_core.ElementRef, }, ]; }; return CheckboxControlValueAccessor; }()); var /** @type {?} */ DEFAULT_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: _angular_core.forwardRef(function () { return DefaultValueAccessor; }), multi: true }; /** * The default accessor for writing a value and listening to changes that is used by the * {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName} directives. * * ### Example * ``` * * ``` * * \@stable */ var DefaultValueAccessor = (function () { /** * @param {?} _renderer * @param {?} _elementRef */ function DefaultValueAccessor(_renderer, _elementRef) { this._renderer = _renderer; this._elementRef = _elementRef; this.onChange = function (_) { }; this.onTouched = function () { }; } /** * @param {?} value * @return {?} */ DefaultValueAccessor.prototype.writeValue = function (value) { var /** @type {?} */ normalizedValue = value == null ? '' : value; this._renderer.setElementProperty(this._elementRef.nativeElement, 'value', normalizedValue); }; /** * @param {?} fn * @return {?} */ DefaultValueAccessor.prototype.registerOnChange = function (fn) { this.onChange = fn; }; /** * @param {?} fn * @return {?} */ DefaultValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; }; /** * @param {?} isDisabled * @return {?} */ DefaultValueAccessor.prototype.setDisabledState = function (isDisabled) { this._renderer.setElementProperty(this._elementRef.nativeElement, 'disabled', isDisabled); }; DefaultValueAccessor.decorators = [ { type: _angular_core.Directive, args: [{ selector: 'input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]', // TODO: vsavkin replace the above selector with the one below it once // https://github.com/angular/angular/issues/3011 is implemented // selector: '[ngControl],[ngModel],[ngFormControl]', host: { '(input)': 'onChange($event.target.value)', '(blur)': 'onTouched()' }, providers: [DEFAULT_VALUE_ACCESSOR] },] }, ]; /** @nocollapse */ DefaultValueAccessor.ctorParameters = function () { return [ { type: _angular_core.Renderer, }, { type: _angular_core.ElementRef, }, ]; }; return DefaultValueAccessor; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * @param {?} validator * @return {?} */ function normalizeValidator(validator) { if (((validator)).validate) { return function (c) { return ((validator)).validate(c); }; } else { return (validator); } } /** * @param {?} validator * @return {?} */ function normalizeAsyncValidator(validator) { if (((validator)).validate) { return function (c) { return ((validator)).validate(c); }; } else { return (validator); } } var /** @type {?} */ NUMBER_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: _angular_core.forwardRef(function () { return NumberValueAccessor; }), multi: true }; /** * The accessor for writing a number value and listening to changes that is used by the * {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName} directives. * * ### Example * ``` * * ``` */ var NumberValueAccessor = (function () { /** * @param {?} _renderer * @param {?} _elementRef */ function NumberValueAccessor(_renderer, _elementRef) { this._renderer = _renderer; this._elementRef = _elementRef; this.onChange = function (_) { }; this.onTouched = function () { }; } /** * @param {?} value * @return {?} */ NumberValueAccessor.prototype.writeValue = function (value) { // The value needs to be normalized for IE9, otherwise it is set to 'null' when null var /** @type {?} */ normalizedValue = value == null ? '' : value; this._renderer.setElementProperty(this._elementRef.nativeElement, 'value', normalizedValue); }; /** * @param {?} fn * @return {?} */ NumberValueAccessor.prototype.registerOnChange = function (fn) { this.onChange = function (value) { fn(value == '' ? null : parseFloat(value)); }; }; /** * @param {?} fn * @return {?} */ NumberValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; }; /** * @param {?} isDisabled * @return {?} */ NumberValueAccessor.prototype.setDisabledState = function (isDisabled) { this._renderer.setElementProperty(this._elementRef.nativeElement, 'disabled', isDisabled); }; NumberValueAccessor.decorators = [ { type: _angular_core.Directive, args: [{ selector: 'input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]', host: { '(change)': 'onChange($event.target.value)', '(input)': 'onChange($event.target.value)', '(blur)': 'onTouched()' }, providers: [NUMBER_VALUE_ACCESSOR] },] }, ]; /** @nocollapse */ NumberValueAccessor.ctorParameters = function () { return [ { type: _angular_core.Renderer, }, { type: _angular_core.ElementRef, }, ]; }; return NumberValueAccessor; }()); /** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ var __extends$2 = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /** * @return {?} */ function unimplemented() { throw new Error('unimplemented'); } /** * A base class that all control directive extend. * It binds a {\@link FormControl} object to a DOM element. * * Used internally by Angular forms. * * \@stable * @abstract */ var NgControl = (function (_super) { __extends$2(NgControl, _super); function NgControl() { _super.apply(this, arguments); /** @internal */ this._parent = null; this.name = null; this.valueAccessor = null; /** @internal */ this._rawValidators = []; /** @internal */ this._rawAsyncValidators = []; } Object.defineProperty(NgControl.prototype, "validator", { /** * @return {?} */ get: function () { return (unimplemented()); }, enumerable: true, configurable: true }); Object.defineProperty(NgControl.prototype, "asyncValidator", { /** * @return {?} */ get: function () { return (unimplemented()); }, enumerable: true, configurable: true }); /** * @abstract * @param {?} newValue * @return {?} */ NgControl.prototype.viewToModelUpdate = function (newValue) { }; return NgControl; }(AbstractControlDirective)); var /** @type {?} */ RADIO_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: _angular_core.forwardRef(function () { return RadioControlValueAccessor; }), multi: true }; /** * Internal class used by Angular to uncheck radio buttons with the matching name. */ var RadioControlRegistry = (function () { function RadioControlRegistry() { this._accessors = []; } /** * @param {?} control * @param {?} accessor * @return {?} */ RadioControlRegistry.prototype.add = function (control, accessor) { this._accessors.push([control, accessor]); }; /** * @param {?} accessor * @return {?} */ RadioControlRegistry.prototype.remove = function (accessor) { for (var /** @type {?} */ i = this._accessors.length - 1; i >= 0; --i) { if (this._accessors[i][1] === accessor) { this._accessors.splice(i, 1); return; } } }; /** * @param {?} accessor * @return {?} */ RadioControlRegistry.prototype.select = function (accessor) { var _this = this; this._accessors.forEach(function (c) { if (_this._isSameGroup(c, accessor) && c[1] !== accessor) { c[1].fireUncheck(accessor.value); } }); }; /** * @param {?} controlPair * @param {?} accessor * @return {?} */ RadioControlRegistry.prototype._isSameGroup = function (controlPair, accessor) { if (!controlPair[0].control) return false; return controlPair[0]._parent === accessor._control._parent && controlPair[1].name === accessor.name; }; RadioControlRegistry.decorators = [ { type: _angular_core.Injectable }, ]; /** @nocollapse */ RadioControlRegistry.ctorParameters = function () { return []; }; return RadioControlRegistry; }()); /** * \@whatItDoes Writes radio control values and listens to radio control changes. * * Used by {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName} * to keep the view synced with the {\@link FormControl} model. * * \@howToUse * * If you have imported the {\@link FormsModule} or the {\@link ReactiveFormsModule}, this * value accessor will be active on any radio control that has a form directive. You do * **not** need to add a special selector to activate it. * * ### How to use radio buttons with form directives * * To use radio buttons in a template-driven form, you'll want to ensure that radio buttons * in the same group have the same `name` attribute. Radio buttons with different `name` * attributes do not affect each other. * * {\@example forms/ts/radioButtons/radio_button_example.ts region='TemplateDriven'} * * When using radio buttons in a reactive form, radio buttons in the same group should have the * same `formControlName`. You can also add a `name` attribute, but it's optional. * * {\@example forms/ts/reactiveRadioButtons/reactive_radio_button_example.ts region='Reactive'} * * * **npm package**: `\@angular/forms` * * \@stable */ var RadioControlValueAccessor = (function () { /** * @param {?} _renderer * @param {?} _elementRef * @param {?} _registry * @param {?} _injector */ function RadioControlValueAccessor(_renderer, _elementRef, _registry, _injector) { this._renderer = _renderer; this._elementRef = _elementRef; this._registry = _registry; this._injector = _injector; this.onChange = function () { }; this.onTouched = function () { }; } /** * @return {?} */ RadioControlValueAccessor.prototype.ngOnInit = function () { this._control = this._injector.get(NgControl); this._checkName(); this._registry.add(this._control, this); }; /** * @return {?} */ RadioControlValueAccessor.prototype.ngOnDestroy = function () { this._registry.remove(this); }; /** * @param {?} value * @return {?} */ RadioControlValueAccessor.prototype.writeValue = function (value) { this._state = value === this.value; this._renderer.setElementProperty(this._elementRef.nativeElement, 'checked', this._state); }; /** * @param {?} fn * @return {?} */ RadioControlValueAccessor.prototype.registerOnChange = function (fn) { var _this = this; this._fn = fn; this.onChange = function () { fn(_this.value); _this._registry.select(_this); }; }; /** * @param {?} value * @return {?} */ RadioControlValueAccessor.prototype.fireUncheck = function (value) { this.writeValue(value); }; /** * @param {?} fn * @return {?} */ RadioControlValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; }; /** * @param {?} isDisabled * @return {?} */ RadioControlValueAccessor.prototype.setDisabledState = function (isDisabled) { this._renderer.setElementProperty(this._elementRef.nativeElement, 'disabled', isDisabled); }; /** * @return {?} */ RadioControlValueAccessor.prototype._checkName = function () { if (this.name && this.formControlName && this.name !== this.formControlName) { this._throwNameError(); } if (!this.name && this.formControlName) this.name = this.formControlName; }; /** * @return {?} */ RadioControlValueAccessor.prototype._throwNameError = function () { throw new Error("\n If you define both a name and a formControlName attribute on your radio button, their values\n must match. Ex: \n "); }; RadioControlValueAccessor.decorators = [ { type: _angular_core.Directive, args: [{ selector: 'input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]', host: { '(change)': 'onChange()', '(blur)': 'onTouched()' }, providers: [RADIO_VALUE_ACCESSOR] },] }, ]; /** @nocollapse */ RadioControlValueAccessor.ctorParameters = function () { return [ { type: _angular_core.Renderer, }, { type: _angular_core.ElementRef, }, { type: RadioControlRegistry, }, { type: _angular_core.Injector, }, ]; }; RadioControlValueAccessor.propDecorators = { 'name': [{ type: _angular_core.Input },], 'formControlName': [{ type: _angular_core.Input },], 'value': [{ type: _angular_core.Input },], }; return RadioControlValueAccessor; }()); var /** @type {?} */ RANGE_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: _angular_core.forwardRef(function () { return RangeValueAccessor; }), multi: true }; /** * The accessor for writing a range value and listening to changes that is used by the * {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName} directives. * * ### Example * ``` * * ``` */ var RangeValueAccessor = (function () { /** * @param {?} _renderer * @param {?} _elementRef */ function RangeValueAccessor(_renderer, _elementRef) { this._renderer = _renderer; this._elementRef = _elementRef; this.onChange = function (_) { }; this.onTouched = function () { }; } /** * @param {?} value * @return {?} */ RangeValueAccessor.prototype.writeValue = function (value) { this._renderer.setElementProperty(this._elementRef.nativeElement, 'value', parseFloat(value)); }; /** * @param {?} fn * @return {?} */ RangeValueAccessor.prototype.registerOnChange = function (fn) { this.onChange = function (value) { fn(value == '' ? null : parseFloat(value)); }; }; /** * @param {?} fn * @return {?} */ RangeValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; }; /** * @param {?} isDisabled * @return {?} */ RangeValueAccessor.prototype.setDisabledState = function (isDisabled) { this._renderer.setElementProperty(this._elementRef.nativeElement, 'disabled', isDisabled); }; RangeValueAccessor.decorators = [ { type: _angular_core.Directive, args: [{ selector: 'input[type=range][formControlName],input[type=range][formControl],input[type=range][ngModel]', host: { '(change)': 'onChange($event.target.value)', '(input)': 'onChange($event.target.value)', '(blur)': 'onTouched()' }, providers: [RANGE_VALUE_ACCESSOR] },] }, ]; /** @nocollapse */ RangeValueAccessor.ctorParameters = function () { return [ { type: _angular_core.Renderer, }, { type: _angular_core.ElementRef, }, ]; }; return RangeValueAccessor; }()); var /** @type {?} */ SELECT_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: _angular_core.forwardRef(function () { return SelectControlValueAccessor; }), multi: true }; /** * @param {?} id * @param {?} value * @return {?} */ function _buildValueString(id, value) { if (id == null) return "" + value; if (!isPrimitive(value)) value = 'Object'; return (id + ": " + value).slice(0, 50); } /** * @param {?} valueString * @return {?} */ function _extractId(valueString) { return valueString.split(':')[0]; } /** * \@whatItDoes Writes values and listens to changes on a select element. * * Used by {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName} * to keep the view synced with the {\@link FormControl} model. * * \@howToUse * * If you have imported the {\@link FormsModule} or the {\@link ReactiveFormsModule}, this * value accessor will be active on any select control that has a form directive. You do * **not** need to add a special selector to activate it. * * ### How to use select controls with form directives * * To use a select in a template-driven form, simply add an `ngModel` and a `name` * attribute to the main `` tag. Like in the former example, you have the * choice of binding to the `value` or `ngValue` property on the select's options. * * {\@example forms/ts/reactiveSelectControl/reactive_select_control_example.ts region='Component'} * * Note: We listen to the 'change' event because 'input' events aren't fired * for selects in Firefox and IE: * https://bugzilla.mozilla.org/show_bug.cgi?id=1024350 * https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/4660045/ * * * **npm package**: `\@angular/forms` * * \@stable */ var SelectControlValueAccessor = (function () { /** * @param {?} _renderer * @param {?} _elementRef */ function SelectControlValueAccessor(_renderer, _elementRef) { this._renderer = _renderer; this._elementRef = _elementRef; /** @internal */ this._optionMap = new Map(); /** @internal */ this._idCounter = 0; this.onChange = function (_) { }; this.onTouched = function () { }; } /** * @param {?} value * @return {?} */ SelectControlValueAccessor.prototype.writeValue = function (value) { this.value = value; var /** @type {?} */ valueString = _buildValueString(this._getOptionId(value), value); this._renderer.setElementProperty(this._elementRef.nativeElement, 'value', valueString); }; /** * @param {?} fn * @return {?} */ SelectControlValueAccessor.prototype.registerOnChange = function (fn) { var _this = this; this.onChange = function (valueString) { _this.value = valueString; fn(_this._getOptionValue(valueString)); }; }; /** * @param {?} fn * @return {?} */ SelectControlValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; }; /** * @param {?} isDisabled * @return {?} */ SelectControlValueAccessor.prototype.setDisabledState = function (isDisabled) { this._renderer.setElementProperty(this._elementRef.nativeElement, 'disabled', isDisabled); }; /** * \@internal * @return {?} */ SelectControlValueAccessor.prototype._registerOption = function () { return (this._idCounter++).toString(); }; /** * \@internal * @param {?} value * @return {?} */ SelectControlValueAccessor.prototype._getOptionId = function (value) { for (var _i = 0, _a = Array.from(this._optionMap.keys()); _i < _a.length; _i++) { var id = _a[_i]; if (looseIdentical(this._optionMap.get(id), value)) return id; } return null; }; /** * \@internal * @param {?} valueString * @return {?} */ SelectControlValueAccessor.prototype._getOptionValue = function (valueString) { var /** @type {?} */ id = _extractId(valueString); return this._optionMap.has(id) ? this._optionMap.get(id) : valueString; }; SelectControlValueAccessor.decorators = [ { type: _angular_core.Directive, args: [{ selector: 'select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]', host: { '(change)': 'onChange($event.target.value)', '(blur)': 'onTouched()' }, providers: [SELECT_VALUE_ACCESSOR] },] }, ]; /** @nocollapse */ SelectControlValueAccessor.ctorParameters = function () { return [ { type: _angular_core.Renderer, }, { type: _angular_core.ElementRef, }, ]; }; return SelectControlValueAccessor; }()); /** * \@whatItDoes Marks `