/**
* @license Angular v5.2.11
* (c) 2010-2018 Google, Inc. https://angular.io/
* License: MIT
*/
import { __assign, __extends } from 'tslib';
import { Directive, ElementRef, EventEmitter, Host, Inject, Injectable, InjectionToken, Injector, Input, NgModule, Optional, Output, Renderer2, Self, SkipSelf, Version, forwardRef, ɵisObservable, ɵisPromise, ɵlooseIdentical } from '@angular/core';
import { forkJoin } from 'rxjs/observable/forkJoin';
import { fromPromise } from 'rxjs/observable/fromPromise';
import { map } from 'rxjs/operator/map';
import { ɵgetDOM } from '@angular/platform-browser';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @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 = /** @class */ (function () {
function AbstractControlDirective() {
}
Object.defineProperty(AbstractControlDirective.prototype, "value", {
/** The value of the control. */
get: /**
* The value of the control.
* @return {?}
*/
function () { return this.control ? this.control.value : null; },
enumerable: true,
configurable: true
});
Object.defineProperty(AbstractControlDirective.prototype, "valid", {
/**
* A control is `valid` when its `status === VALID`.
*
* In order to have this status, the control must have passed all its
* validation checks.
*/
get: /**
* A control is `valid` when its `status === VALID`.
*
* In order to have this status, the control must have passed all its
* validation checks.
* @return {?}
*/
function () { return this.control ? this.control.valid : null; },
enumerable: true,
configurable: true
});
Object.defineProperty(AbstractControlDirective.prototype, "invalid", {
/**
* A control is `invalid` when its `status === INVALID`.
*
* In order to have this status, the control must have failed
* at least one of its validation checks.
*/
get: /**
* A control is `invalid` when its `status === INVALID`.
*
* In order to have this status, the control must have failed
* at least one of its validation checks.
* @return {?}
*/
function () { return this.control ? this.control.invalid : null; },
enumerable: true,
configurable: true
});
Object.defineProperty(AbstractControlDirective.prototype, "pending", {
/**
* A control is `pending` when its `status === PENDING`.
*
* In order to have this status, the control must be in the
* middle of conducting a validation check.
*/
get: /**
* A control is `pending` when its `status === PENDING`.
*
* In order to have this status, the control must be in the
* middle of conducting a validation check.
* @return {?}
*/
function () { return this.control ? this.control.pending : null; },
enumerable: true,
configurable: true
});
Object.defineProperty(AbstractControlDirective.prototype, "disabled", {
/**
* A control is `disabled` when its `status === DISABLED`.
*
* Disabled controls are exempt from validation checks and
* are not included in the aggregate value of their ancestor
* controls.
*/
get: /**
* A control is `disabled` when its `status === DISABLED`.
*
* Disabled controls are exempt from validation checks and
* are not included in the aggregate value of their ancestor
* controls.
* @return {?}
*/
function () { return this.control ? this.control.disabled : null; },
enumerable: true,
configurable: true
});
Object.defineProperty(AbstractControlDirective.prototype, "enabled", {
/**
* A control is `enabled` as long as its `status !== DISABLED`.
*
* In other words, it has a status of `VALID`, `INVALID`, or
* `PENDING`.
*/
get: /**
* A control is `enabled` as long as its `status !== DISABLED`.
*
* In other words, it has a status of `VALID`, `INVALID`, or
* `PENDING`.
* @return {?}
*/
function () { return this.control ? this.control.enabled : null; },
enumerable: true,
configurable: true
});
Object.defineProperty(AbstractControlDirective.prototype, "errors", {
/**
* Returns any errors generated by failing validation. If there
* are no errors, it will return null.
*/
get: /**
* Returns any errors generated by failing validation. If there
* are no errors, it will return null.
* @return {?}
*/
function () { return this.control ? this.control.errors : null; },
enumerable: true,
configurable: true
});
Object.defineProperty(AbstractControlDirective.prototype, "pristine", {
/**
* A control is `pristine` if the user has not yet changed
* the value in the UI.
*
* Note that programmatic changes to a control's value will
* *not* mark it dirty.
*/
get: /**
* A control is `pristine` if the user has not yet changed
* the value in the UI.
*
* Note that programmatic changes to a control's value will
* *not* mark it dirty.
* @return {?}
*/
function () { return this.control ? this.control.pristine : null; },
enumerable: true,
configurable: true
});
Object.defineProperty(AbstractControlDirective.prototype, "dirty", {
/**
* A control is `dirty` if the user has changed the value
* in the UI.
*
* Note that programmatic changes to a control's value will
* *not* mark it dirty.
*/
get: /**
* A control is `dirty` if the user has changed the value
* in the UI.
*
* Note that programmatic changes to a control's value will
* *not* mark it dirty.
* @return {?}
*/
function () { return this.control ? this.control.dirty : null; },
enumerable: true,
configurable: true
});
Object.defineProperty(AbstractControlDirective.prototype, "touched", {
/**
* A control is marked `touched` once the user has triggered
* a `blur` event on it.
*/
get: /**
* A control is marked `touched` once the user has triggered
* a `blur` event on it.
* @return {?}
*/
function () { return this.control ? this.control.touched : null; },
enumerable: true,
configurable: true
});
Object.defineProperty(AbstractControlDirective.prototype, "status", {
get: /**
* @return {?}
*/
function () { return this.control ? this.control.status : null; },
enumerable: true,
configurable: true
});
Object.defineProperty(AbstractControlDirective.prototype, "untouched", {
/**
* A control is `untouched` if the user has not yet triggered
* a `blur` event on it.
*/
get: /**
* A control is `untouched` if the user has not yet triggered
* a `blur` event on it.
* @return {?}
*/
function () { return this.control ? this.control.untouched : null; },
enumerable: true,
configurable: true
});
Object.defineProperty(AbstractControlDirective.prototype, "statusChanges", {
/**
* Emits an event every time the validation status of the control
* is re-calculated.
*/
get: /**
* Emits an event every time the validation status of the control
* is re-calculated.
* @return {?}
*/
function () {
return this.control ? this.control.statusChanges : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(AbstractControlDirective.prototype, "valueChanges", {
/**
* Emits an event every time the value of the control changes, in
* the UI or programmatically.
*/
get: /**
* Emits an event every time the value of the control changes, in
* the UI or programmatically.
* @return {?}
*/
function () {
return this.control ? this.control.valueChanges : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(AbstractControlDirective.prototype, "path", {
/**
* Returns an array that represents the path from the top-level form
* to this control. Each index is the string name of the control on
* that level.
*/
get: /**
* Returns an array that represents the path from the top-level form
* to this control. Each index is the string name of the control on
* that level.
* @return {?}
*/
function () { return null; },
enumerable: true,
configurable: true
});
/**
* Resets the form control. This means by default:
*
* * it is marked as `pristine`
* * it is marked as `untouched`
* * value is set to null
*
* For more information, see {@link AbstractControl}.
*/
/**
* Resets the form control. This means by default:
*
* * it is marked as `pristine`
* * it is marked as `untouched`
* * value is set to null
*
* For more information, see {\@link AbstractControl}.
* @param {?=} value
* @return {?}
*/
AbstractControlDirective.prototype.reset = /**
* Resets the form control. This means by default:
*
* * it is marked as `pristine`
* * it is marked as `untouched`
* * value is set to null
*
* For more information, see {\@link AbstractControl}.
* @param {?=} value
* @return {?}
*/
function (value) {
if (value === void 0) { value = undefined; }
if (this.control)
this.control.reset(value);
};
/**
* Returns true if the control with the given path has the error specified. Otherwise
* returns false.
*
* If no path is given, it checks for the error on the present control.
*/
/**
* Returns true if the control with the given path has the error specified. Otherwise
* returns false.
*
* If no path is given, it checks for the error on the present control.
* @param {?} errorCode
* @param {?=} path
* @return {?}
*/
AbstractControlDirective.prototype.hasError = /**
* Returns true if the control with the given path has the error specified. Otherwise
* returns false.
*
* If no path is given, it checks for the error on the present control.
* @param {?} errorCode
* @param {?=} path
* @return {?}
*/
function (errorCode, path) {
return this.control ? this.control.hasError(errorCode, path) : false;
};
/**
* Returns error data if the control with the given path has the error specified. Otherwise
* returns null or undefined.
*
* If no path is given, it checks for the error on the present control.
*/
/**
* Returns error data if the control with the given path has the error specified. Otherwise
* returns null or undefined.
*
* If no path is given, it checks for the error on the present control.
* @param {?} errorCode
* @param {?=} path
* @return {?}
*/
AbstractControlDirective.prototype.getError = /**
* Returns error data if the control with the given path has the error specified. Otherwise
* returns null or undefined.
*
* If no path is given, it checks for the error on the present control.
* @param {?} errorCode
* @param {?=} path
* @return {?}
*/
function (errorCode, path) {
return this.control ? this.control.getError(errorCode, path) : null;
};
return AbstractControlDirective;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @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
*/
/**
* A directive that contains multiple {\@link NgControl}s.
*
* Only used by the forms module.
*
* \@stable
* @abstract
*/
var ControlContainer = /** @class */ (function (_super) {
__extends(ControlContainer, _super);
function ControlContainer() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(ControlContainer.prototype, "formDirective", {
/**
* Get the form to which this container belongs.
*/
get: /**
* Get the form to which this container belongs.
* @return {?}
*/
function () { return null; },
enumerable: true,
configurable: true
});
Object.defineProperty(ControlContainer.prototype, "path", {
/**
* Get the path to this container.
*/
get: /**
* Get the path to this container.
* @return {?}
*/
function () { return null; },
enumerable: true,
configurable: true
});
return ControlContainer;
}(AbstractControlDirective));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @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 {?} 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
*
* ```typescript
* \@Directive({
* selector: '[custom-validator]',
* providers: [{provide: NG_VALIDATORS, useExisting: CustomValidatorDirective, multi: true}]
* })
* class CustomValidatorDirective implements Validator {
* validate(control: AbstractControl): ValidationErrors | null {
* return {"custom": true};
* }
* }
* ```
*
* \@stable
*/
var NG_VALIDATORS = new InjectionToken('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 NG_ASYNC_VALIDATORS = new InjectionToken('NgAsyncValidators');
var EMAIL_REGEXP = /^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;
/**
* 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 = /** @class */ (function () {
function Validators() {
}
/**
* Validator that requires controls to have a value greater than a number.
*`min()` exists only as a function, not as a directive. For example,
* `control = new FormControl('', Validators.min(3));`.
*/
/**
* Validator that requires controls to have a value greater than a number.
* `min()` exists only as a function, not as a directive. For example,
* `control = new FormControl('', Validators.min(3));`.
* @param {?} min
* @return {?}
*/
Validators.min = /**
* Validator that requires controls to have a value greater than a number.
* `min()` exists only as a function, not as a directive. For example,
* `control = new FormControl('', Validators.min(3));`.
* @param {?} min
* @return {?}
*/
function (min) {
return function (control) {
if (isEmptyInputValue(control.value) || isEmptyInputValue(min)) {
return null; // don't validate empty values to allow optional controls
}
var /** @type {?} */ value = parseFloat(control.value);
// Controls with NaN values after parsing should be treated as not having a
// minimum, per the HTML forms spec: https://www.w3.org/TR/html5/forms.html#attr-input-min
return !isNaN(value) && value < min ? { 'min': { 'min': min, 'actual': control.value } } : null;
};
};
/**
* Validator that requires controls to have a value less than a number.
* `max()` exists only as a function, not as a directive. For example,
* `control = new FormControl('', Validators.max(15));`.
*/
/**
* Validator that requires controls to have a value less than a number.
* `max()` exists only as a function, not as a directive. For example,
* `control = new FormControl('', Validators.max(15));`.
* @param {?} max
* @return {?}
*/
Validators.max = /**
* Validator that requires controls to have a value less than a number.
* `max()` exists only as a function, not as a directive. For example,
* `control = new FormControl('', Validators.max(15));`.
* @param {?} max
* @return {?}
*/
function (max) {
return function (control) {
if (isEmptyInputValue(control.value) || isEmptyInputValue(max)) {
return null; // don't validate empty values to allow optional controls
}
var /** @type {?} */ value = parseFloat(control.value);
// Controls with NaN values after parsing should be treated as not having a
// maximum, per the HTML forms spec: https://www.w3.org/TR/html5/forms.html#attr-input-max
return !isNaN(value) && value > max ? { 'max': { 'max': max, 'actual': control.value } } : null;
};
};
/**
* Validator that requires controls to have a non-empty value.
*/
/**
* Validator that requires controls to have a non-empty value.
* @param {?} control
* @return {?}
*/
Validators.required = /**
* Validator that requires controls to have a non-empty value.
* @param {?} control
* @return {?}
*/
function (control) {
return isEmptyInputValue(control.value) ? { 'required': true } : null;
};
/**
* Validator that requires control value to be true.
*/
/**
* Validator that requires control value to be true.
* @param {?} control
* @return {?}
*/
Validators.requiredTrue = /**
* Validator that requires control value to be true.
* @param {?} control
* @return {?}
*/
function (control) {
return control.value === true ? null : { 'required': true };
};
/**
* Validator that performs email validation.
*/
/**
* Validator that performs email validation.
* @param {?} control
* @return {?}
*/
Validators.email = /**
* Validator that performs email validation.
* @param {?} control
* @return {?}
*/
function (control) {
return EMAIL_REGEXP.test(control.value) ? null : { 'email': true };
};
/**
* Validator that requires controls to have a value of a minimum length.
*/
/**
* Validator that requires controls to have a value of a minimum length.
* @param {?} minLength
* @return {?}
*/
Validators.minLength = /**
* Validator that requires controls to have a value of a minimum length.
* @param {?} minLength
* @return {?}
*/
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.
*/
/**
* Validator that requires controls to have a value of a maximum length.
* @param {?} maxLength
* @return {?}
*/
Validators.maxLength = /**
* Validator that requires controls to have a value of a maximum length.
* @param {?} maxLength
* @return {?}
*/
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.
*/
/**
* Validator that requires a control to match a regex to its value.
* @param {?} pattern
* @return {?}
*/
Validators.pattern = /**
* Validator that requires a control to match a regex to its value.
* @param {?} pattern
* @return {?}
*/
function (pattern) {
if (!pattern)
return Validators.nullValidator;
var /** @type {?} */ regex;
var /** @type {?} */ regexStr;
if (typeof pattern === 'string') {
regexStr = '';
if (pattern.charAt(0) !== '^')
regexStr += '^';
regexStr += pattern;
if (pattern.charAt(pattern.length - 1) !== '$')
regexStr += '$';
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.
*/
/**
* No-op validator.
* @param {?} c
* @return {?}
*/
Validators.nullValidator = /**
* No-op validator.
* @param {?} c
* @return {?}
*/
function (c) { return null; };
/**
* @param {?} validators
* @return {?}
*/
Validators.compose = /**
* @param {?} validators
* @return {?}
*/
function (validators) {
if (!validators)
return null;
var /** @type {?} */ presentValidators = /** @type {?} */ (validators.filter(isPresent));
if (presentValidators.length == 0)
return null;
return function (control) {
return _mergeErrors(_executeValidators(control, presentValidators));
};
};
/**
* @param {?} validators
* @return {?}
*/
Validators.composeAsync = /**
* @param {?} validators
* @return {?}
*/
function (validators) {
if (!validators)
return null;
var /** @type {?} */ presentValidators = /** @type {?} */ (validators.filter(isPresent));
if (presentValidators.length == 0)
return null;
return function (control) {
var /** @type {?} */ observables = _executeAsyncValidators(control, presentValidators).map(toObservable);
return map.call(forkJoin(observables), _mergeErrors);
};
};
return Validators;
}());
/**
* @param {?} o
* @return {?}
*/
function isPresent(o) {
return o != null;
}
/**
* @param {?} r
* @return {?}
*/
function toObservable(r) {
var /** @type {?} */ obs = ɵisPromise(r) ? fromPromise(r) : r;
if (!(ɵisObservable(obs))) {
throw new Error("Expected validator to return Promise or Observable.");
}
return obs;
}
/**
* @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 errors != null ? __assign({}, /** @type {?} */ ((res)), errors) : /** @type {?} */ ((res));
}, {});
return Object.keys(res).length === 0 ? null : res;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @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
*/
/**
* A `ControlValueAccessor` acts as a bridge between the Angular forms API and a
* native element in the DOM.
*
* Implement this interface if you want to create a custom form control directive
* that integrates with Angular forms.
*
* \@stable
* @record
*/
/**
* Used to provide a {\@link ControlValueAccessor} for form controls.
*
* See {\@link DefaultValueAccessor} for how to implement one.
* \@stable
*/
var NG_VALUE_ACCESSOR = new InjectionToken('NgValueAccessor');
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @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 CHECKBOX_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: 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 = /** @class */ (function () {
function CheckboxControlValueAccessor(_renderer, _elementRef) {
this._renderer = _renderer;
this._elementRef = _elementRef;
this.onChange = function (_) { };
this.onTouched = function () { };
}
/**
* @param {?} value
* @return {?}
*/
CheckboxControlValueAccessor.prototype.writeValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
this._renderer.setProperty(this._elementRef.nativeElement, 'checked', value);
};
/**
* @param {?} fn
* @return {?}
*/
CheckboxControlValueAccessor.prototype.registerOnChange = /**
* @param {?} fn
* @return {?}
*/
function (fn) { this.onChange = fn; };
/**
* @param {?} fn
* @return {?}
*/
CheckboxControlValueAccessor.prototype.registerOnTouched = /**
* @param {?} fn
* @return {?}
*/
function (fn) { this.onTouched = fn; };
/**
* @param {?} isDisabled
* @return {?}
*/
CheckboxControlValueAccessor.prototype.setDisabledState = /**
* @param {?} isDisabled
* @return {?}
*/
function (isDisabled) {
this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
};
CheckboxControlValueAccessor.decorators = [
{ type: 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: Renderer2, },
{ type: ElementRef, },
]; };
return CheckboxControlValueAccessor;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @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 DEFAULT_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(function () { return DefaultValueAccessor; }),
multi: true
};
/**
* We must check whether the agent is Android because composition events
* behave differently between iOS and Android.
* @return {?}
*/
function _isAndroid() {
var /** @type {?} */ userAgent = ɵgetDOM() ? ɵgetDOM().getUserAgent() : '';
return /android (\d+)/.test(userAgent.toLowerCase());
}
/**
* Turn this mode on if you want form directives to buffer IME input until compositionend
* \@experimental
*/
var COMPOSITION_BUFFER_MODE = new InjectionToken('CompositionEventMode');
/**
* 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 = /** @class */ (function () {
function DefaultValueAccessor(_renderer, _elementRef, _compositionMode) {
this._renderer = _renderer;
this._elementRef = _elementRef;
this._compositionMode = _compositionMode;
this.onChange = function (_) { };
this.onTouched = function () { };
/**
* Whether the user is creating a composition string (IME events).
*/
this._composing = false;
if (this._compositionMode == null) {
this._compositionMode = !_isAndroid();
}
}
/**
* @param {?} value
* @return {?}
*/
DefaultValueAccessor.prototype.writeValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
var /** @type {?} */ normalizedValue = value == null ? '' : value;
this._renderer.setProperty(this._elementRef.nativeElement, 'value', normalizedValue);
};
/**
* @param {?} fn
* @return {?}
*/
DefaultValueAccessor.prototype.registerOnChange = /**
* @param {?} fn
* @return {?}
*/
function (fn) { this.onChange = fn; };
/**
* @param {?} fn
* @return {?}
*/
DefaultValueAccessor.prototype.registerOnTouched = /**
* @param {?} fn
* @return {?}
*/
function (fn) { this.onTouched = fn; };
/**
* @param {?} isDisabled
* @return {?}
*/
DefaultValueAccessor.prototype.setDisabledState = /**
* @param {?} isDisabled
* @return {?}
*/
function (isDisabled) {
this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
};
/** @internal */
/**
* \@internal
* @param {?} value
* @return {?}
*/
DefaultValueAccessor.prototype._handleInput = /**
* \@internal
* @param {?} value
* @return {?}
*/
function (value) {
if (!this._compositionMode || (this._compositionMode && !this._composing)) {
this.onChange(value);
}
};
/** @internal */
/**
* \@internal
* @return {?}
*/
DefaultValueAccessor.prototype._compositionStart = /**
* \@internal
* @return {?}
*/
function () { this._composing = true; };
/** @internal */
/**
* \@internal
* @param {?} value
* @return {?}
*/
DefaultValueAccessor.prototype._compositionEnd = /**
* \@internal
* @param {?} value
* @return {?}
*/
function (value) {
this._composing = false;
this._compositionMode && this.onChange(value);
};
DefaultValueAccessor.decorators = [
{ type: 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: '[ngModel],[formControl],[formControlName]',
host: {
'(input)': '$any(this)._handleInput($event.target.value)',
'(blur)': 'onTouched()',
'(compositionstart)': '$any(this)._compositionStart()',
'(compositionend)': '$any(this)._compositionEnd($event.target.value)'
},
providers: [DEFAULT_VALUE_ACCESSOR]
},] },
];
/** @nocollapse */
DefaultValueAccessor.ctorParameters = function () { return [
{ type: Renderer2, },
{ type: ElementRef, },
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [COMPOSITION_BUFFER_MODE,] },] },
]; };
return DefaultValueAccessor;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @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 ((/** @type {?} */ (validator)).validate) {
return function (c) { return (/** @type {?} */ (validator)).validate(c); };
}
else {
return /** @type {?} */ (validator);
}
}
/**
* @param {?} validator
* @return {?}
*/
function normalizeAsyncValidator(validator) {
if ((/** @type {?} */ (validator)).validate) {
return function (c) { return (/** @type {?} */ (validator)).validate(c); };
}
else {
return /** @type {?} */ (validator);
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @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 NUMBER_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: 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 = /** @class */ (function () {
function NumberValueAccessor(_renderer, _elementRef) {
this._renderer = _renderer;
this._elementRef = _elementRef;
this.onChange = function (_) { };
this.onTouched = function () { };
}
/**
* @param {?} value
* @return {?}
*/
NumberValueAccessor.prototype.writeValue = /**
* @param {?} value
* @return {?}
*/
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.setProperty(this._elementRef.nativeElement, 'value', normalizedValue);
};
/**
* @param {?} fn
* @return {?}
*/
NumberValueAccessor.prototype.registerOnChange = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
this.onChange = function (value) { fn(value == '' ? null : parseFloat(value)); };
};
/**
* @param {?} fn
* @return {?}
*/
NumberValueAccessor.prototype.registerOnTouched = /**
* @param {?} fn
* @return {?}
*/
function (fn) { this.onTouched = fn; };
/**
* @param {?} isDisabled
* @return {?}
*/
NumberValueAccessor.prototype.setDisabledState = /**
* @param {?} isDisabled
* @return {?}
*/
function (isDisabled) {
this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
};
NumberValueAccessor.decorators = [
{ type: 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: Renderer2, },
{ type: ElementRef, },
]; };
return NumberValueAccessor;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @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
*/
/**
* @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 = /** @class */ (function (_super) {
__extends(NgControl, _super);
function NgControl() {
var _this = _super !== null && _super.apply(this, arguments) || this;
/**
* \@internal
*/
_this._parent = null;
_this.name = null;
_this.valueAccessor = null;
/**
* \@internal
*/
_this._rawValidators = [];
/**
* \@internal
*/
_this._rawAsyncValidators = [];
return _this;
}
Object.defineProperty(NgControl.prototype, "validator", {
get: /**
* @return {?}
*/
function () { return /** @type {?} */ (unimplemented()); },
enumerable: true,
configurable: true
});
Object.defineProperty(NgControl.prototype, "asyncValidator", {
get: /**
* @return {?}
*/
function () { return /** @type {?} */ (unimplemented()); },
enumerable: true,
configurable: true
});
return NgControl;
}(AbstractControlDirective));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @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 RADIO_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(function () { return RadioControlValueAccessor; }),
multi: true
};
/**
* Internal class used by Angular to uncheck radio buttons with the matching name.
*/
var RadioControlRegistry = /** @class */ (function () {
function RadioControlRegistry() {
this._accessors = [];
}
/**
* @param {?} control
* @param {?} accessor
* @return {?}
*/
RadioControlRegistry.prototype.add = /**
* @param {?} control
* @param {?} accessor
* @return {?}
*/
function (control, accessor) {
this._accessors.push([control, accessor]);
};
/**
* @param {?} accessor
* @return {?}
*/
RadioControlRegistry.prototype.remove = /**
* @param {?} accessor
* @return {?}
*/
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 = /**
* @param {?} accessor
* @return {?}
*/
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 = /**
* @param {?} controlPair
* @param {?} accessor
* @return {?}
*/
function (controlPair, accessor) {
if (!controlPair[0].control)
return false;
return controlPair[0]._parent === accessor._control._parent &&
controlPair[1].name === accessor.name;
};
RadioControlRegistry.decorators = [
{ type: 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 = /** @class */ (function () {
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 = /**
* @return {?}
*/
function () {
this._control = this._injector.get(NgControl);
this._checkName();
this._registry.add(this._control, this);
};
/**
* @return {?}
*/
RadioControlValueAccessor.prototype.ngOnDestroy = /**
* @return {?}
*/
function () { this._registry.remove(this); };
/**
* @param {?} value
* @return {?}
*/
RadioControlValueAccessor.prototype.writeValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
this._state = value === this.value;
this._renderer.setProperty(this._elementRef.nativeElement, 'checked', this._state);
};
/**
* @param {?} fn
* @return {?}
*/
RadioControlValueAccessor.prototype.registerOnChange = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
var _this = this;
this._fn = fn;
this.onChange = function () {
fn(_this.value);
_this._registry.select(_this);
};
};
/**
* @param {?} value
* @return {?}
*/
RadioControlValueAccessor.prototype.fireUncheck = /**
* @param {?} value
* @return {?}
*/
function (value) { this.writeValue(value); };
/**
* @param {?} fn
* @return {?}
*/
RadioControlValueAccessor.prototype.registerOnTouched = /**
* @param {?} fn
* @return {?}
*/
function (fn) { this.onTouched = fn; };
/**
* @param {?} isDisabled
* @return {?}
*/
RadioControlValueAccessor.prototype.setDisabledState = /**
* @param {?} isDisabled
* @return {?}
*/
function (isDisabled) {
this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
};
/**
* @return {?}
*/
RadioControlValueAccessor.prototype._checkName = /**
* @return {?}
*/
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 = /**
* @return {?}
*/
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: 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: Renderer2, },
{ type: ElementRef, },
{ type: RadioControlRegistry, },
{ type: Injector, },
]; };
RadioControlValueAccessor.propDecorators = {
"name": [{ type: Input },],
"formControlName": [{ type: Input },],
"value": [{ type: Input },],
};
return RadioControlValueAccessor;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @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 RANGE_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: 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 = /** @class */ (function () {
function RangeValueAccessor(_renderer, _elementRef) {
this._renderer = _renderer;
this._elementRef = _elementRef;
this.onChange = function (_) { };
this.onTouched = function () { };
}
/**
* @param {?} value
* @return {?}
*/
RangeValueAccessor.prototype.writeValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
this._renderer.setProperty(this._elementRef.nativeElement, 'value', parseFloat(value));
};
/**
* @param {?} fn
* @return {?}
*/
RangeValueAccessor.prototype.registerOnChange = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
this.onChange = function (value) { fn(value == '' ? null : parseFloat(value)); };
};
/**
* @param {?} fn
* @return {?}
*/
RangeValueAccessor.prototype.registerOnTouched = /**
* @param {?} fn
* @return {?}
*/
function (fn) { this.onTouched = fn; };
/**
* @param {?} isDisabled
* @return {?}
*/
RangeValueAccessor.prototype.setDisabledState = /**
* @param {?} isDisabled
* @return {?}
*/
function (isDisabled) {
this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
};
RangeValueAccessor.decorators = [
{ type: 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: Renderer2, },
{ type: ElementRef, },
]; };
return RangeValueAccessor;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @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 SELECT_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(function () { return SelectControlValueAccessor; }),
multi: true
};
/**
* @param {?} id
* @param {?} value
* @return {?}
*/
function _buildValueString(id, value) {
if (id == null)
return "" + value;
if (value && typeof value === 'object')
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 `