| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946 |
- /**
- * @license
- * Copyright Google LLC 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
- */
- import { __extends } from 'tslib';
- import { FocusMonitor } from '@angular/cdk/a11y';
- import { coerceBooleanProperty } from '@angular/cdk/coercion';
- import { UniqueSelectionDispatcher } from '@angular/cdk/collections';
- import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChildren, Directive, ElementRef, EventEmitter, forwardRef, Inject, InjectionToken, Input, Optional, Output, ViewChild, ViewEncapsulation, NgModule } from '@angular/core';
- import { NG_VALUE_ACCESSOR } from '@angular/forms';
- import { mixinDisableRipple, mixinTabIndex, MatCommonModule, MatRippleModule } from '@angular/material/core';
- import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
- import { CommonModule } from '@angular/common';
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- var MAT_RADIO_DEFAULT_OPTIONS = new InjectionToken('mat-radio-default-options', {
- providedIn: 'root',
- factory: MAT_RADIO_DEFAULT_OPTIONS_FACTORY
- });
- /**
- * @return {?}
- */
- function MAT_RADIO_DEFAULT_OPTIONS_FACTORY() {
- return {
- color: 'accent'
- };
- }
- // Increasing integer for generating unique ids for radio components.
- /** @type {?} */
- var nextUniqueId = 0;
- /**
- * Provider Expression that allows mat-radio-group to register as a ControlValueAccessor. This
- * allows it to support [(ngModel)] and ngControl.
- * \@docs-private
- * @type {?}
- */
- var MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR = {
- provide: NG_VALUE_ACCESSOR,
- useExisting: forwardRef((/**
- * @return {?}
- */
- function () { return MatRadioGroup; })),
- multi: true
- };
- /**
- * Change event object emitted by MatRadio and MatRadioGroup.
- */
- var /**
- * Change event object emitted by MatRadio and MatRadioGroup.
- */
- MatRadioChange = /** @class */ (function () {
- function MatRadioChange(source, value) {
- this.source = source;
- this.value = value;
- }
- return MatRadioChange;
- }());
- /**
- * A group of radio buttons. May contain one or more `<mat-radio-button>` elements.
- */
- var MatRadioGroup = /** @class */ (function () {
- function MatRadioGroup(_changeDetector) {
- this._changeDetector = _changeDetector;
- /**
- * Selected value for the radio group.
- */
- this._value = null;
- /**
- * The HTML name attribute applied to radio buttons in this group.
- */
- this._name = "mat-radio-group-" + nextUniqueId++;
- /**
- * The currently selected radio button. Should match value.
- */
- this._selected = null;
- /**
- * Whether the `value` has been set to its initial value.
- */
- this._isInitialized = false;
- /**
- * Whether the labels should appear after or before the radio-buttons. Defaults to 'after'
- */
- this._labelPosition = 'after';
- /**
- * Whether the radio group is disabled.
- */
- this._disabled = false;
- /**
- * Whether the radio group is required.
- */
- this._required = false;
- /**
- * The method to be called in order to update ngModel
- */
- this._controlValueAccessorChangeFn = (/**
- * @return {?}
- */
- function () { });
- /**
- * onTouch function registered via registerOnTouch (ControlValueAccessor).
- * \@docs-private
- */
- this.onTouched = (/**
- * @return {?}
- */
- function () { });
- /**
- * Event emitted when the group value changes.
- * Change events are only emitted when the value changes due to user interaction with
- * a radio button (the same behavior as `<input type-"radio">`).
- */
- this.change = new EventEmitter();
- }
- Object.defineProperty(MatRadioGroup.prototype, "name", {
- /** Name of the radio button group. All radio buttons inside this group will use this name. */
- get: /**
- * Name of the radio button group. All radio buttons inside this group will use this name.
- * @return {?}
- */
- function () { return this._name; },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- this._name = value;
- this._updateRadioButtonNames();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatRadioGroup.prototype, "labelPosition", {
- /** Whether the labels should appear after or before the radio-buttons. Defaults to 'after' */
- get: /**
- * Whether the labels should appear after or before the radio-buttons. Defaults to 'after'
- * @return {?}
- */
- function () {
- return this._labelPosition;
- },
- set: /**
- * @param {?} v
- * @return {?}
- */
- function (v) {
- this._labelPosition = v === 'before' ? 'before' : 'after';
- this._markRadiosForCheck();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatRadioGroup.prototype, "value", {
- /**
- * Value for the radio-group. Should equal the value of the selected radio button if there is
- * a corresponding radio button with a matching value. If there is not such a corresponding
- * radio button, this value persists to be applied in case a new radio button is added with a
- * matching value.
- */
- get: /**
- * Value for the radio-group. Should equal the value of the selected radio button if there is
- * a corresponding radio button with a matching value. If there is not such a corresponding
- * radio button, this value persists to be applied in case a new radio button is added with a
- * matching value.
- * @return {?}
- */
- function () { return this._value; },
- set: /**
- * @param {?} newValue
- * @return {?}
- */
- function (newValue) {
- if (this._value !== newValue) {
- // Set this before proceeding to ensure no circular loop occurs with selection.
- this._value = newValue;
- this._updateSelectedRadioFromValue();
- this._checkSelectedRadioButton();
- }
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- MatRadioGroup.prototype._checkSelectedRadioButton = /**
- * @return {?}
- */
- function () {
- if (this._selected && !this._selected.checked) {
- this._selected.checked = true;
- }
- };
- Object.defineProperty(MatRadioGroup.prototype, "selected", {
- /**
- * The currently selected radio button. If set to a new radio button, the radio group value
- * will be updated to match the new selected button.
- */
- get: /**
- * The currently selected radio button. If set to a new radio button, the radio group value
- * will be updated to match the new selected button.
- * @return {?}
- */
- function () { return this._selected; },
- set: /**
- * @param {?} selected
- * @return {?}
- */
- function (selected) {
- this._selected = selected;
- this.value = selected ? selected.value : null;
- this._checkSelectedRadioButton();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatRadioGroup.prototype, "disabled", {
- /** Whether the radio group is disabled */
- get: /**
- * Whether the radio group is disabled
- * @return {?}
- */
- function () { return this._disabled; },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- this._disabled = coerceBooleanProperty(value);
- this._markRadiosForCheck();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatRadioGroup.prototype, "required", {
- /** Whether the radio group is required */
- get: /**
- * Whether the radio group is required
- * @return {?}
- */
- function () { return this._required; },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- this._required = coerceBooleanProperty(value);
- this._markRadiosForCheck();
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Initialize properties once content children are available.
- * This allows us to propagate relevant attributes to associated buttons.
- */
- /**
- * Initialize properties once content children are available.
- * This allows us to propagate relevant attributes to associated buttons.
- * @return {?}
- */
- MatRadioGroup.prototype.ngAfterContentInit = /**
- * Initialize properties once content children are available.
- * This allows us to propagate relevant attributes to associated buttons.
- * @return {?}
- */
- function () {
- // Mark this component as initialized in AfterContentInit because the initial value can
- // possibly be set by NgModel on MatRadioGroup, and it is possible that the OnInit of the
- // NgModel occurs *after* the OnInit of the MatRadioGroup.
- this._isInitialized = true;
- };
- /**
- * Mark this group as being "touched" (for ngModel). Meant to be called by the contained
- * radio buttons upon their blur.
- */
- /**
- * Mark this group as being "touched" (for ngModel). Meant to be called by the contained
- * radio buttons upon their blur.
- * @return {?}
- */
- MatRadioGroup.prototype._touch = /**
- * Mark this group as being "touched" (for ngModel). Meant to be called by the contained
- * radio buttons upon their blur.
- * @return {?}
- */
- function () {
- if (this.onTouched) {
- this.onTouched();
- }
- };
- /**
- * @private
- * @return {?}
- */
- MatRadioGroup.prototype._updateRadioButtonNames = /**
- * @private
- * @return {?}
- */
- function () {
- var _this = this;
- if (this._radios) {
- this._radios.forEach((/**
- * @param {?} radio
- * @return {?}
- */
- function (radio) {
- radio.name = _this.name;
- radio._markForCheck();
- }));
- }
- };
- /** Updates the `selected` radio button from the internal _value state. */
- /**
- * Updates the `selected` radio button from the internal _value state.
- * @private
- * @return {?}
- */
- MatRadioGroup.prototype._updateSelectedRadioFromValue = /**
- * Updates the `selected` radio button from the internal _value state.
- * @private
- * @return {?}
- */
- function () {
- var _this = this;
- // If the value already matches the selected radio, do nothing.
- /** @type {?} */
- var isAlreadySelected = this._selected !== null && this._selected.value === this._value;
- if (this._radios && !isAlreadySelected) {
- this._selected = null;
- this._radios.forEach((/**
- * @param {?} radio
- * @return {?}
- */
- function (radio) {
- radio.checked = _this.value === radio.value;
- if (radio.checked) {
- _this._selected = radio;
- }
- }));
- }
- };
- /** Dispatch change event with current selection and group value. */
- /**
- * Dispatch change event with current selection and group value.
- * @return {?}
- */
- MatRadioGroup.prototype._emitChangeEvent = /**
- * Dispatch change event with current selection and group value.
- * @return {?}
- */
- function () {
- if (this._isInitialized) {
- this.change.emit(new MatRadioChange((/** @type {?} */ (this._selected)), this._value));
- }
- };
- /**
- * @return {?}
- */
- MatRadioGroup.prototype._markRadiosForCheck = /**
- * @return {?}
- */
- function () {
- if (this._radios) {
- this._radios.forEach((/**
- * @param {?} radio
- * @return {?}
- */
- function (radio) { return radio._markForCheck(); }));
- }
- };
- /**
- * Sets the model value. Implemented as part of ControlValueAccessor.
- * @param value
- */
- /**
- * Sets the model value. Implemented as part of ControlValueAccessor.
- * @param {?} value
- * @return {?}
- */
- MatRadioGroup.prototype.writeValue = /**
- * Sets the model value. Implemented as part of ControlValueAccessor.
- * @param {?} value
- * @return {?}
- */
- function (value) {
- this.value = value;
- this._changeDetector.markForCheck();
- };
- /**
- * Registers a callback to be triggered when the model value changes.
- * Implemented as part of ControlValueAccessor.
- * @param fn Callback to be registered.
- */
- /**
- * Registers a callback to be triggered when the model value changes.
- * Implemented as part of ControlValueAccessor.
- * @param {?} fn Callback to be registered.
- * @return {?}
- */
- MatRadioGroup.prototype.registerOnChange = /**
- * Registers a callback to be triggered when the model value changes.
- * Implemented as part of ControlValueAccessor.
- * @param {?} fn Callback to be registered.
- * @return {?}
- */
- function (fn) {
- this._controlValueAccessorChangeFn = fn;
- };
- /**
- * Registers a callback to be triggered when the control is touched.
- * Implemented as part of ControlValueAccessor.
- * @param fn Callback to be registered.
- */
- /**
- * Registers a callback to be triggered when the control is touched.
- * Implemented as part of ControlValueAccessor.
- * @param {?} fn Callback to be registered.
- * @return {?}
- */
- MatRadioGroup.prototype.registerOnTouched = /**
- * Registers a callback to be triggered when the control is touched.
- * Implemented as part of ControlValueAccessor.
- * @param {?} fn Callback to be registered.
- * @return {?}
- */
- function (fn) {
- this.onTouched = fn;
- };
- /**
- * Sets the disabled state of the control. Implemented as a part of ControlValueAccessor.
- * @param isDisabled Whether the control should be disabled.
- */
- /**
- * Sets the disabled state of the control. Implemented as a part of ControlValueAccessor.
- * @param {?} isDisabled Whether the control should be disabled.
- * @return {?}
- */
- MatRadioGroup.prototype.setDisabledState = /**
- * Sets the disabled state of the control. Implemented as a part of ControlValueAccessor.
- * @param {?} isDisabled Whether the control should be disabled.
- * @return {?}
- */
- function (isDisabled) {
- this.disabled = isDisabled;
- this._changeDetector.markForCheck();
- };
- MatRadioGroup.decorators = [
- { type: Directive, args: [{
- selector: 'mat-radio-group',
- exportAs: 'matRadioGroup',
- providers: [MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR],
- host: {
- 'role': 'radiogroup',
- 'class': 'mat-radio-group',
- },
- },] },
- ];
- /** @nocollapse */
- MatRadioGroup.ctorParameters = function () { return [
- { type: ChangeDetectorRef }
- ]; };
- MatRadioGroup.propDecorators = {
- change: [{ type: Output }],
- _radios: [{ type: ContentChildren, args: [forwardRef((/**
- * @return {?}
- */
- function () { return MatRadioButton; })), { descendants: true },] }],
- color: [{ type: Input }],
- name: [{ type: Input }],
- labelPosition: [{ type: Input }],
- value: [{ type: Input }],
- selected: [{ type: Input }],
- disabled: [{ type: Input }],
- required: [{ type: Input }]
- };
- return MatRadioGroup;
- }());
- // Boilerplate for applying mixins to MatRadioButton.
- /**
- * \@docs-private
- */
- var
- // Boilerplate for applying mixins to MatRadioButton.
- /**
- * \@docs-private
- */
- MatRadioButtonBase = /** @class */ (function () {
- function MatRadioButtonBase(_elementRef) {
- this._elementRef = _elementRef;
- }
- return MatRadioButtonBase;
- }());
- // As per Material design specifications the selection control radio should use the accent color
- // palette by default. https://material.io/guidelines/components/selection-controls.html
- /** @type {?} */
- var _MatRadioButtonMixinBase = mixinDisableRipple(mixinTabIndex(MatRadioButtonBase));
- /**
- * A Material design radio-button. Typically placed inside of `<mat-radio-group>` elements.
- */
- var MatRadioButton = /** @class */ (function (_super) {
- __extends(MatRadioButton, _super);
- function MatRadioButton(radioGroup, elementRef, _changeDetector, _focusMonitor, _radioDispatcher, _animationMode, _providerOverride) {
- var _this = _super.call(this, elementRef) || this;
- _this._changeDetector = _changeDetector;
- _this._focusMonitor = _focusMonitor;
- _this._radioDispatcher = _radioDispatcher;
- _this._animationMode = _animationMode;
- _this._providerOverride = _providerOverride;
- _this._uniqueId = "mat-radio-" + ++nextUniqueId;
- /**
- * The unique ID for the radio button.
- */
- _this.id = _this._uniqueId;
- /**
- * Event emitted when the checked state of this radio button changes.
- * Change events are only emitted when the value changes due to user interaction with
- * the radio button (the same behavior as `<input type-"radio">`).
- */
- _this.change = new EventEmitter();
- /**
- * Whether this radio is checked.
- */
- _this._checked = false;
- /**
- * Value assigned to this radio.
- */
- _this._value = null;
- /**
- * Unregister function for _radioDispatcher
- */
- _this._removeUniqueSelectionListener = (/**
- * @return {?}
- */
- function () { });
- // Assertions. Ideally these should be stripped out by the compiler.
- // TODO(jelbourn): Assert that there's no name binding AND a parent radio group.
- _this.radioGroup = radioGroup;
- _this._removeUniqueSelectionListener =
- _radioDispatcher.listen((/**
- * @param {?} id
- * @param {?} name
- * @return {?}
- */
- function (id, name) {
- if (id !== _this.id && name === _this.name) {
- _this.checked = false;
- }
- }));
- return _this;
- }
- Object.defineProperty(MatRadioButton.prototype, "checked", {
- /** Whether this radio button is checked. */
- get: /**
- * Whether this radio button is checked.
- * @return {?}
- */
- function () { return this._checked; },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- /** @type {?} */
- var newCheckedState = coerceBooleanProperty(value);
- if (this._checked !== newCheckedState) {
- this._checked = newCheckedState;
- if (newCheckedState && this.radioGroup && this.radioGroup.value !== this.value) {
- this.radioGroup.selected = this;
- }
- else if (!newCheckedState && this.radioGroup && this.radioGroup.value === this.value) {
- // When unchecking the selected radio button, update the selected radio
- // property on the group.
- this.radioGroup.selected = null;
- }
- if (newCheckedState) {
- // Notify all radio buttons with the same name to un-check.
- this._radioDispatcher.notify(this.id, this.name);
- }
- this._changeDetector.markForCheck();
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatRadioButton.prototype, "value", {
- /** The value of this radio button. */
- get: /**
- * The value of this radio button.
- * @return {?}
- */
- function () { return this._value; },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- if (this._value !== value) {
- this._value = value;
- if (this.radioGroup !== null) {
- if (!this.checked) {
- // Update checked when the value changed to match the radio group's value
- this.checked = this.radioGroup.value === value;
- }
- if (this.checked) {
- this.radioGroup.selected = this;
- }
- }
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatRadioButton.prototype, "labelPosition", {
- /** Whether the label should appear after or before the radio button. Defaults to 'after' */
- get: /**
- * Whether the label should appear after or before the radio button. Defaults to 'after'
- * @return {?}
- */
- function () {
- return this._labelPosition || (this.radioGroup && this.radioGroup.labelPosition) || 'after';
- },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- this._labelPosition = value;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatRadioButton.prototype, "disabled", {
- /** Whether the radio button is disabled. */
- get: /**
- * Whether the radio button is disabled.
- * @return {?}
- */
- function () {
- return this._disabled || (this.radioGroup !== null && this.radioGroup.disabled);
- },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- /** @type {?} */
- var newDisabledState = coerceBooleanProperty(value);
- if (this._disabled !== newDisabledState) {
- this._disabled = newDisabledState;
- this._changeDetector.markForCheck();
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatRadioButton.prototype, "required", {
- /** Whether the radio button is required. */
- get: /**
- * Whether the radio button is required.
- * @return {?}
- */
- function () {
- return this._required || (this.radioGroup && this.radioGroup.required);
- },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- this._required = coerceBooleanProperty(value);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatRadioButton.prototype, "color", {
- /** Theme color of the radio button. */
- get: /**
- * Theme color of the radio button.
- * @return {?}
- */
- function () {
- return this._color ||
- (this.radioGroup && this.radioGroup.color) ||
- this._providerOverride && this._providerOverride.color || 'accent';
- },
- set: /**
- * @param {?} newValue
- * @return {?}
- */
- function (newValue) { this._color = newValue; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatRadioButton.prototype, "inputId", {
- /** ID of the native input element inside `<mat-radio-button>` */
- get: /**
- * ID of the native input element inside `<mat-radio-button>`
- * @return {?}
- */
- function () { return (this.id || this._uniqueId) + "-input"; },
- enumerable: true,
- configurable: true
- });
- /** Focuses the radio button. */
- /**
- * Focuses the radio button.
- * @param {?=} options
- * @return {?}
- */
- MatRadioButton.prototype.focus = /**
- * Focuses the radio button.
- * @param {?=} options
- * @return {?}
- */
- function (options) {
- this._focusMonitor.focusVia(this._inputElement, 'keyboard', options);
- };
- /**
- * Marks the radio button as needing checking for change detection.
- * This method is exposed because the parent radio group will directly
- * update bound properties of the radio button.
- */
- /**
- * Marks the radio button as needing checking for change detection.
- * This method is exposed because the parent radio group will directly
- * update bound properties of the radio button.
- * @return {?}
- */
- MatRadioButton.prototype._markForCheck = /**
- * Marks the radio button as needing checking for change detection.
- * This method is exposed because the parent radio group will directly
- * update bound properties of the radio button.
- * @return {?}
- */
- function () {
- // When group value changes, the button will not be notified. Use `markForCheck` to explicit
- // update radio button's status
- this._changeDetector.markForCheck();
- };
- /**
- * @return {?}
- */
- MatRadioButton.prototype.ngOnInit = /**
- * @return {?}
- */
- function () {
- if (this.radioGroup) {
- // If the radio is inside a radio group, determine if it should be checked
- this.checked = this.radioGroup.value === this._value;
- // Copy name from parent radio group
- this.name = this.radioGroup.name;
- }
- };
- /**
- * @return {?}
- */
- MatRadioButton.prototype.ngAfterViewInit = /**
- * @return {?}
- */
- function () {
- var _this = this;
- this._focusMonitor
- .monitor(this._elementRef, true)
- .subscribe((/**
- * @param {?} focusOrigin
- * @return {?}
- */
- function (focusOrigin) {
- if (!focusOrigin && _this.radioGroup) {
- _this.radioGroup._touch();
- }
- }));
- };
- /**
- * @return {?}
- */
- MatRadioButton.prototype.ngOnDestroy = /**
- * @return {?}
- */
- function () {
- this._focusMonitor.stopMonitoring(this._elementRef);
- this._removeUniqueSelectionListener();
- };
- /** Dispatch change event with current value. */
- /**
- * Dispatch change event with current value.
- * @private
- * @return {?}
- */
- MatRadioButton.prototype._emitChangeEvent = /**
- * Dispatch change event with current value.
- * @private
- * @return {?}
- */
- function () {
- this.change.emit(new MatRadioChange(this, this._value));
- };
- /**
- * @return {?}
- */
- MatRadioButton.prototype._isRippleDisabled = /**
- * @return {?}
- */
- function () {
- return this.disableRipple || this.disabled;
- };
- /**
- * @param {?} event
- * @return {?}
- */
- MatRadioButton.prototype._onInputClick = /**
- * @param {?} event
- * @return {?}
- */
- function (event) {
- // We have to stop propagation for click events on the visual hidden input element.
- // By default, when a user clicks on a label element, a generated click event will be
- // dispatched on the associated input element. Since we are using a label element as our
- // root container, the click event on the `radio-button` will be executed twice.
- // The real click event will bubble up, and the generated click event also tries to bubble up.
- // This will lead to multiple click events.
- // Preventing bubbling for the second event will solve that issue.
- event.stopPropagation();
- };
- /**
- * Triggered when the radio button received a click or the input recognized any change.
- * Clicking on a label element, will trigger a change event on the associated input.
- */
- /**
- * Triggered when the radio button received a click or the input recognized any change.
- * Clicking on a label element, will trigger a change event on the associated input.
- * @param {?} event
- * @return {?}
- */
- MatRadioButton.prototype._onInputChange = /**
- * Triggered when the radio button received a click or the input recognized any change.
- * Clicking on a label element, will trigger a change event on the associated input.
- * @param {?} event
- * @return {?}
- */
- function (event) {
- // We always have to stop propagation on the change event.
- // Otherwise the change event, from the input element, will bubble up and
- // emit its event object to the `change` output.
- event.stopPropagation();
- /** @type {?} */
- var groupValueChanged = this.radioGroup && this.value !== this.radioGroup.value;
- this.checked = true;
- this._emitChangeEvent();
- if (this.radioGroup) {
- this.radioGroup._controlValueAccessorChangeFn(this.value);
- if (groupValueChanged) {
- this.radioGroup._emitChangeEvent();
- }
- }
- };
- MatRadioButton.decorators = [
- { type: Component, args: [{selector: 'mat-radio-button',
- template: "<label [attr.for]=\"inputId\" class=\"mat-radio-label\" #label><div class=\"mat-radio-container\"><div class=\"mat-radio-outer-circle\"></div><div class=\"mat-radio-inner-circle\"></div><div mat-ripple class=\"mat-radio-ripple\" [matRippleTrigger]=\"label\" [matRippleDisabled]=\"_isRippleDisabled()\" [matRippleCentered]=\"true\" [matRippleRadius]=\"20\" [matRippleAnimation]=\"{enterDuration: 150}\"><div class=\"mat-ripple-element mat-radio-persistent-ripple\"></div></div><input #input class=\"mat-radio-input cdk-visually-hidden\" type=\"radio\" [id]=\"inputId\" [checked]=\"checked\" [disabled]=\"disabled\" [tabIndex]=\"tabIndex\" [attr.name]=\"name\" [attr.value]=\"value\" [required]=\"required\" [attr.aria-label]=\"ariaLabel\" [attr.aria-labelledby]=\"ariaLabelledby\" [attr.aria-describedby]=\"ariaDescribedby\" (change)=\"_onInputChange($event)\" (click)=\"_onInputClick($event)\"></div><div class=\"mat-radio-label-content\" [class.mat-radio-label-before]=\"labelPosition == 'before'\"><span style=\"display:none\"> </span><ng-content></ng-content></div></label>",
- styles: [".mat-radio-button{display:inline-block;-webkit-tap-highlight-color:transparent;outline:0}.mat-radio-label{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer;display:inline-flex;align-items:center;white-space:nowrap;vertical-align:middle;width:100%}.mat-radio-container{box-sizing:border-box;display:inline-block;position:relative;width:20px;height:20px;flex-shrink:0}.mat-radio-outer-circle{box-sizing:border-box;height:20px;left:0;position:absolute;top:0;transition:border-color ease 280ms;width:20px;border-width:2px;border-style:solid;border-radius:50%}._mat-animation-noopable .mat-radio-outer-circle{transition:none}.mat-radio-inner-circle{border-radius:50%;box-sizing:border-box;height:20px;left:0;position:absolute;top:0;transition:transform ease 280ms,background-color ease 280ms;width:20px;transform:scale(.001)}._mat-animation-noopable .mat-radio-inner-circle{transition:none}.mat-radio-checked .mat-radio-inner-circle{transform:scale(.5)}@media (-ms-high-contrast:active){.mat-radio-checked .mat-radio-inner-circle{border:solid 10px}}.mat-radio-label-content{-webkit-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto;display:inline-block;order:0;line-height:inherit;padding-left:8px;padding-right:0}[dir=rtl] .mat-radio-label-content{padding-right:8px;padding-left:0}.mat-radio-label-content.mat-radio-label-before{order:-1;padding-left:0;padding-right:8px}[dir=rtl] .mat-radio-label-content.mat-radio-label-before{padding-right:0;padding-left:8px}.mat-radio-disabled,.mat-radio-disabled .mat-radio-label{cursor:default}.mat-radio-button .mat-radio-ripple{position:absolute;left:calc(50% - 20px);top:calc(50% - 20px);height:40px;width:40px;z-index:1;pointer-events:none}.mat-radio-button .mat-radio-ripple .mat-ripple-element:not(.mat-radio-persistent-ripple){opacity:.16}.mat-radio-persistent-ripple{width:100%;height:100%;transform:none}.mat-radio-container:hover .mat-radio-persistent-ripple{opacity:.04}.mat-radio-button:not(.mat-radio-disabled).cdk-keyboard-focused .mat-radio-persistent-ripple,.mat-radio-button:not(.mat-radio-disabled).cdk-program-focused .mat-radio-persistent-ripple{opacity:.12}.mat-radio-disabled .mat-radio-container:hover .mat-radio-persistent-ripple,.mat-radio-persistent-ripple{opacity:0}@media (hover:none){.mat-radio-container:hover .mat-radio-persistent-ripple{display:none}}.mat-radio-input{bottom:0;left:50%}@media (-ms-high-contrast:active){.mat-radio-disabled{opacity:.5}}"],
- inputs: ['disableRipple', 'tabIndex'],
- encapsulation: ViewEncapsulation.None,
- exportAs: 'matRadioButton',
- host: {
- 'class': 'mat-radio-button',
- '[class.mat-radio-checked]': 'checked',
- '[class.mat-radio-disabled]': 'disabled',
- '[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
- '[class.mat-primary]': 'color === "primary"',
- '[class.mat-accent]': 'color === "accent"',
- '[class.mat-warn]': 'color === "warn"',
- // Needs to be -1 so the `focus` event still fires.
- '[attr.tabindex]': '-1',
- '[attr.id]': 'id',
- // Note: under normal conditions focus shouldn't land on this element, however it may be
- // programmatically set, for example inside of a focus trap, in this case we want to forward
- // the focus to the native element.
- '(focus)': '_inputElement.nativeElement.focus()',
- },
- changeDetection: ChangeDetectionStrategy.OnPush,
- },] },
- ];
- /** @nocollapse */
- MatRadioButton.ctorParameters = function () { return [
- { type: MatRadioGroup, decorators: [{ type: Optional }] },
- { type: ElementRef },
- { type: ChangeDetectorRef },
- { type: FocusMonitor },
- { type: UniqueSelectionDispatcher },
- { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] },
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_RADIO_DEFAULT_OPTIONS,] }] }
- ]; };
- MatRadioButton.propDecorators = {
- id: [{ type: Input }],
- name: [{ type: Input }],
- ariaLabel: [{ type: Input, args: ['aria-label',] }],
- ariaLabelledby: [{ type: Input, args: ['aria-labelledby',] }],
- ariaDescribedby: [{ type: Input, args: ['aria-describedby',] }],
- checked: [{ type: Input }],
- value: [{ type: Input }],
- labelPosition: [{ type: Input }],
- disabled: [{ type: Input }],
- required: [{ type: Input }],
- color: [{ type: Input }],
- change: [{ type: Output }],
- _inputElement: [{ type: ViewChild, args: ['input', { static: false },] }]
- };
- return MatRadioButton;
- }(_MatRadioButtonMixinBase));
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var MatRadioModule = /** @class */ (function () {
- function MatRadioModule() {
- }
- MatRadioModule.decorators = [
- { type: NgModule, args: [{
- imports: [CommonModule, MatRippleModule, MatCommonModule],
- exports: [MatRadioGroup, MatRadioButton, MatCommonModule],
- declarations: [MatRadioGroup, MatRadioButton],
- },] },
- ];
- return MatRadioModule;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- export { MatRadioModule, MAT_RADIO_DEFAULT_OPTIONS_FACTORY, MAT_RADIO_DEFAULT_OPTIONS, MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR, MatRadioChange, MatRadioGroup, MatRadioButton };
- //# sourceMappingURL=radio.es5.js.map
|