UNPKG

39.8 kBJavaScriptView Raw
1import * as i0 from '@angular/core';
2import { InjectionToken, forwardRef, EventEmitter, Directive, Output, Input, ContentChildren, ViewChild, Component, ViewEncapsulation, ChangeDetectionStrategy, Optional, Inject, Attribute, NgModule } from '@angular/core';
3import * as i3 from '@angular/material/core';
4import { mixinDisableRipple, mixinTabIndex, MatRippleModule, MatCommonModule } from '@angular/material/core';
5import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
6import { NG_VALUE_ACCESSOR } from '@angular/forms';
7import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
8import * as i1 from '@angular/cdk/a11y';
9import * as i2 from '@angular/cdk/collections';
10
11const MAT_RADIO_DEFAULT_OPTIONS = new InjectionToken('mat-radio-default-options', {
12 providedIn: 'root',
13 factory: MAT_RADIO_DEFAULT_OPTIONS_FACTORY,
14});
15function MAT_RADIO_DEFAULT_OPTIONS_FACTORY() {
16 return {
17 color: 'accent',
18 };
19}
20// Increasing integer for generating unique ids for radio components.
21let nextUniqueId = 0;
22/**
23 * Provider Expression that allows mat-radio-group to register as a ControlValueAccessor. This
24 * allows it to support [(ngModel)] and ngControl.
25 * @docs-private
26 */
27const MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR = {
28 provide: NG_VALUE_ACCESSOR,
29 useExisting: forwardRef(() => MatRadioGroup),
30 multi: true,
31};
32/** Change event object emitted by MatRadio and MatRadioGroup. */
33class MatRadioChange {
34 constructor(
35 /** The MatRadioButton that emits the change event. */
36 source,
37 /** The value of the MatRadioButton. */
38 value) {
39 this.source = source;
40 this.value = value;
41 }
42}
43/**
44 * Injection token that can be used to inject instances of `MatRadioGroup`. It serves as
45 * alternative token to the actual `MatRadioGroup` class which could cause unnecessary
46 * retention of the class and its component metadata.
47 */
48const MAT_RADIO_GROUP = new InjectionToken('MatRadioGroup');
49/**
50 * Base class with all of the `MatRadioGroup` functionality.
51 * @docs-private
52 */
53class _MatRadioGroupBase {
54 constructor(_changeDetector) {
55 this._changeDetector = _changeDetector;
56 /** Selected value for the radio group. */
57 this._value = null;
58 /** The HTML name attribute applied to radio buttons in this group. */
59 this._name = `mat-radio-group-${nextUniqueId++}`;
60 /** The currently selected radio button. Should match value. */
61 this._selected = null;
62 /** Whether the `value` has been set to its initial value. */
63 this._isInitialized = false;
64 /** Whether the labels should appear after or before the radio-buttons. Defaults to 'after' */
65 this._labelPosition = 'after';
66 /** Whether the radio group is disabled. */
67 this._disabled = false;
68 /** Whether the radio group is required. */
69 this._required = false;
70 /** The method to be called in order to update ngModel */
71 this._controlValueAccessorChangeFn = () => { };
72 /**
73 * onTouch function registered via registerOnTouch (ControlValueAccessor).
74 * @docs-private
75 */
76 this.onTouched = () => { };
77 /**
78 * Event emitted when the group value changes.
79 * Change events are only emitted when the value changes due to user interaction with
80 * a radio button (the same behavior as `<input type-"radio">`).
81 */
82 this.change = new EventEmitter();
83 }
84 /** Name of the radio button group. All radio buttons inside this group will use this name. */
85 get name() {
86 return this._name;
87 }
88 set name(value) {
89 this._name = value;
90 this._updateRadioButtonNames();
91 }
92 /** Whether the labels should appear after or before the radio-buttons. Defaults to 'after' */
93 get labelPosition() {
94 return this._labelPosition;
95 }
96 set labelPosition(v) {
97 this._labelPosition = v === 'before' ? 'before' : 'after';
98 this._markRadiosForCheck();
99 }
100 /**
101 * Value for the radio-group. Should equal the value of the selected radio button if there is
102 * a corresponding radio button with a matching value. If there is not such a corresponding
103 * radio button, this value persists to be applied in case a new radio button is added with a
104 * matching value.
105 */
106 get value() {
107 return this._value;
108 }
109 set value(newValue) {
110 if (this._value !== newValue) {
111 // Set this before proceeding to ensure no circular loop occurs with selection.
112 this._value = newValue;
113 this._updateSelectedRadioFromValue();
114 this._checkSelectedRadioButton();
115 }
116 }
117 _checkSelectedRadioButton() {
118 if (this._selected && !this._selected.checked) {
119 this._selected.checked = true;
120 }
121 }
122 /**
123 * The currently selected radio button. If set to a new radio button, the radio group value
124 * will be updated to match the new selected button.
125 */
126 get selected() {
127 return this._selected;
128 }
129 set selected(selected) {
130 this._selected = selected;
131 this.value = selected ? selected.value : null;
132 this._checkSelectedRadioButton();
133 }
134 /** Whether the radio group is disabled */
135 get disabled() {
136 return this._disabled;
137 }
138 set disabled(value) {
139 this._disabled = coerceBooleanProperty(value);
140 this._markRadiosForCheck();
141 }
142 /** Whether the radio group is required */
143 get required() {
144 return this._required;
145 }
146 set required(value) {
147 this._required = coerceBooleanProperty(value);
148 this._markRadiosForCheck();
149 }
150 /**
151 * Initialize properties once content children are available.
152 * This allows us to propagate relevant attributes to associated buttons.
153 */
154 ngAfterContentInit() {
155 // Mark this component as initialized in AfterContentInit because the initial value can
156 // possibly be set by NgModel on MatRadioGroup, and it is possible that the OnInit of the
157 // NgModel occurs *after* the OnInit of the MatRadioGroup.
158 this._isInitialized = true;
159 }
160 /**
161 * Mark this group as being "touched" (for ngModel). Meant to be called by the contained
162 * radio buttons upon their blur.
163 */
164 _touch() {
165 if (this.onTouched) {
166 this.onTouched();
167 }
168 }
169 _updateRadioButtonNames() {
170 if (this._radios) {
171 this._radios.forEach(radio => {
172 radio.name = this.name;
173 radio._markForCheck();
174 });
175 }
176 }
177 /** Updates the `selected` radio button from the internal _value state. */
178 _updateSelectedRadioFromValue() {
179 // If the value already matches the selected radio, do nothing.
180 const isAlreadySelected = this._selected !== null && this._selected.value === this._value;
181 if (this._radios && !isAlreadySelected) {
182 this._selected = null;
183 this._radios.forEach(radio => {
184 radio.checked = this.value === radio.value;
185 if (radio.checked) {
186 this._selected = radio;
187 }
188 });
189 }
190 }
191 /** Dispatch change event with current selection and group value. */
192 _emitChangeEvent() {
193 if (this._isInitialized) {
194 this.change.emit(new MatRadioChange(this._selected, this._value));
195 }
196 }
197 _markRadiosForCheck() {
198 if (this._radios) {
199 this._radios.forEach(radio => radio._markForCheck());
200 }
201 }
202 /**
203 * Sets the model value. Implemented as part of ControlValueAccessor.
204 * @param value
205 */
206 writeValue(value) {
207 this.value = value;
208 this._changeDetector.markForCheck();
209 }
210 /**
211 * Registers a callback to be triggered when the model value changes.
212 * Implemented as part of ControlValueAccessor.
213 * @param fn Callback to be registered.
214 */
215 registerOnChange(fn) {
216 this._controlValueAccessorChangeFn = fn;
217 }
218 /**
219 * Registers a callback to be triggered when the control is touched.
220 * Implemented as part of ControlValueAccessor.
221 * @param fn Callback to be registered.
222 */
223 registerOnTouched(fn) {
224 this.onTouched = fn;
225 }
226 /**
227 * Sets the disabled state of the control. Implemented as a part of ControlValueAccessor.
228 * @param isDisabled Whether the control should be disabled.
229 */
230 setDisabledState(isDisabled) {
231 this.disabled = isDisabled;
232 this._changeDetector.markForCheck();
233 }
234}
235_MatRadioGroupBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: _MatRadioGroupBase, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
236_MatRadioGroupBase.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: _MatRadioGroupBase, inputs: { color: "color", name: "name", labelPosition: "labelPosition", value: "value", selected: "selected", disabled: "disabled", required: "required" }, outputs: { change: "change" }, ngImport: i0 });
237i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: _MatRadioGroupBase, decorators: [{
238 type: Directive
239 }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { change: [{
240 type: Output
241 }], color: [{
242 type: Input
243 }], name: [{
244 type: Input
245 }], labelPosition: [{
246 type: Input
247 }], value: [{
248 type: Input
249 }], selected: [{
250 type: Input
251 }], disabled: [{
252 type: Input
253 }], required: [{
254 type: Input
255 }] } });
256/**
257 * A group of radio buttons. May contain one or more `<mat-radio-button>` elements.
258 */
259class MatRadioGroup extends _MatRadioGroupBase {
260}
261MatRadioGroup.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatRadioGroup, deps: null, target: i0.ɵɵFactoryTarget.Directive });
262MatRadioGroup.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: MatRadioGroup, selector: "mat-radio-group", host: { attributes: { "role": "radiogroup" }, classAttribute: "mat-radio-group" }, providers: [
263 MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR,
264 { provide: MAT_RADIO_GROUP, useExisting: MatRadioGroup },
265 ], queries: [{ propertyName: "_radios", predicate: i0.forwardRef(function () { return MatRadioButton; }), descendants: true }], exportAs: ["matRadioGroup"], usesInheritance: true, ngImport: i0 });
266i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatRadioGroup, decorators: [{
267 type: Directive,
268 args: [{
269 selector: 'mat-radio-group',
270 exportAs: 'matRadioGroup',
271 providers: [
272 MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR,
273 { provide: MAT_RADIO_GROUP, useExisting: MatRadioGroup },
274 ],
275 host: {
276 'role': 'radiogroup',
277 'class': 'mat-radio-group',
278 },
279 }]
280 }], propDecorators: { _radios: [{
281 type: ContentChildren,
282 args: [forwardRef(() => MatRadioButton), { descendants: true }]
283 }] } });
284// Boilerplate for applying mixins to MatRadioButton.
285/** @docs-private */
286class MatRadioButtonBase {
287 constructor(_elementRef) {
288 this._elementRef = _elementRef;
289 }
290}
291const _MatRadioButtonMixinBase = mixinDisableRipple(mixinTabIndex(MatRadioButtonBase));
292/**
293 * Base class with all of the `MatRadioButton` functionality.
294 * @docs-private
295 */
296class _MatRadioButtonBase extends _MatRadioButtonMixinBase {
297 constructor(radioGroup, elementRef, _changeDetector, _focusMonitor, _radioDispatcher, animationMode, _providerOverride, tabIndex) {
298 super(elementRef);
299 this._changeDetector = _changeDetector;
300 this._focusMonitor = _focusMonitor;
301 this._radioDispatcher = _radioDispatcher;
302 this._providerOverride = _providerOverride;
303 this._uniqueId = `mat-radio-${++nextUniqueId}`;
304 /** The unique ID for the radio button. */
305 this.id = this._uniqueId;
306 /**
307 * Event emitted when the checked state of this radio button changes.
308 * Change events are only emitted when the value changes due to user interaction with
309 * the radio button (the same behavior as `<input type-"radio">`).
310 */
311 this.change = new EventEmitter();
312 /** Whether this radio is checked. */
313 this._checked = false;
314 /** Value assigned to this radio. */
315 this._value = null;
316 /** Unregister function for _radioDispatcher */
317 this._removeUniqueSelectionListener = () => { };
318 // Assertions. Ideally these should be stripped out by the compiler.
319 // TODO(jelbourn): Assert that there's no name binding AND a parent radio group.
320 this.radioGroup = radioGroup;
321 this._noopAnimations = animationMode === 'NoopAnimations';
322 if (tabIndex) {
323 this.tabIndex = coerceNumberProperty(tabIndex, 0);
324 }
325 this._removeUniqueSelectionListener = _radioDispatcher.listen((id, name) => {
326 if (id !== this.id && name === this.name) {
327 this.checked = false;
328 }
329 });
330 }
331 /** Whether this radio button is checked. */
332 get checked() {
333 return this._checked;
334 }
335 set checked(value) {
336 const newCheckedState = coerceBooleanProperty(value);
337 if (this._checked !== newCheckedState) {
338 this._checked = newCheckedState;
339 if (newCheckedState && this.radioGroup && this.radioGroup.value !== this.value) {
340 this.radioGroup.selected = this;
341 }
342 else if (!newCheckedState && this.radioGroup && this.radioGroup.value === this.value) {
343 // When unchecking the selected radio button, update the selected radio
344 // property on the group.
345 this.radioGroup.selected = null;
346 }
347 if (newCheckedState) {
348 // Notify all radio buttons with the same name to un-check.
349 this._radioDispatcher.notify(this.id, this.name);
350 }
351 this._changeDetector.markForCheck();
352 }
353 }
354 /** The value of this radio button. */
355 get value() {
356 return this._value;
357 }
358 set value(value) {
359 if (this._value !== value) {
360 this._value = value;
361 if (this.radioGroup !== null) {
362 if (!this.checked) {
363 // Update checked when the value changed to match the radio group's value
364 this.checked = this.radioGroup.value === value;
365 }
366 if (this.checked) {
367 this.radioGroup.selected = this;
368 }
369 }
370 }
371 }
372 /** Whether the label should appear after or before the radio button. Defaults to 'after' */
373 get labelPosition() {
374 return this._labelPosition || (this.radioGroup && this.radioGroup.labelPosition) || 'after';
375 }
376 set labelPosition(value) {
377 this._labelPosition = value;
378 }
379 /** Whether the radio button is disabled. */
380 get disabled() {
381 return this._disabled || (this.radioGroup !== null && this.radioGroup.disabled);
382 }
383 set disabled(value) {
384 this._setDisabled(coerceBooleanProperty(value));
385 }
386 /** Whether the radio button is required. */
387 get required() {
388 return this._required || (this.radioGroup && this.radioGroup.required);
389 }
390 set required(value) {
391 this._required = coerceBooleanProperty(value);
392 }
393 /** Theme color of the radio button. */
394 get color() {
395 // As per Material design specifications the selection control radio should use the accent color
396 // palette by default. https://material.io/guidelines/components/selection-controls.html
397 return (this._color ||
398 (this.radioGroup && this.radioGroup.color) ||
399 (this._providerOverride && this._providerOverride.color) ||
400 'accent');
401 }
402 set color(newValue) {
403 this._color = newValue;
404 }
405 /** ID of the native input element inside `<mat-radio-button>` */
406 get inputId() {
407 return `${this.id || this._uniqueId}-input`;
408 }
409 /** Focuses the radio button. */
410 focus(options, origin) {
411 if (origin) {
412 this._focusMonitor.focusVia(this._inputElement, origin, options);
413 }
414 else {
415 this._inputElement.nativeElement.focus(options);
416 }
417 }
418 /**
419 * Marks the radio button as needing checking for change detection.
420 * This method is exposed because the parent radio group will directly
421 * update bound properties of the radio button.
422 */
423 _markForCheck() {
424 // When group value changes, the button will not be notified. Use `markForCheck` to explicit
425 // update radio button's status
426 this._changeDetector.markForCheck();
427 }
428 ngOnInit() {
429 if (this.radioGroup) {
430 // If the radio is inside a radio group, determine if it should be checked
431 this.checked = this.radioGroup.value === this._value;
432 if (this.checked) {
433 this.radioGroup.selected = this;
434 }
435 // Copy name from parent radio group
436 this.name = this.radioGroup.name;
437 }
438 }
439 ngDoCheck() {
440 this._updateTabIndex();
441 }
442 ngAfterViewInit() {
443 this._updateTabIndex();
444 this._focusMonitor.monitor(this._elementRef, true).subscribe(focusOrigin => {
445 if (!focusOrigin && this.radioGroup) {
446 this.radioGroup._touch();
447 }
448 });
449 }
450 ngOnDestroy() {
451 this._focusMonitor.stopMonitoring(this._elementRef);
452 this._removeUniqueSelectionListener();
453 }
454 /** Dispatch change event with current value. */
455 _emitChangeEvent() {
456 this.change.emit(new MatRadioChange(this, this._value));
457 }
458 _isRippleDisabled() {
459 return this.disableRipple || this.disabled;
460 }
461 _onInputClick(event) {
462 // We have to stop propagation for click events on the visual hidden input element.
463 // By default, when a user clicks on a label element, a generated click event will be
464 // dispatched on the associated input element. Since we are using a label element as our
465 // root container, the click event on the `radio-button` will be executed twice.
466 // The real click event will bubble up, and the generated click event also tries to bubble up.
467 // This will lead to multiple click events.
468 // Preventing bubbling for the second event will solve that issue.
469 event.stopPropagation();
470 }
471 /** Triggered when the radio button receives an interaction from the user. */
472 _onInputInteraction(event) {
473 // We always have to stop propagation on the change event.
474 // Otherwise the change event, from the input element, will bubble up and
475 // emit its event object to the `change` output.
476 event.stopPropagation();
477 if (!this.checked && !this.disabled) {
478 const groupValueChanged = this.radioGroup && this.value !== this.radioGroup.value;
479 this.checked = true;
480 this._emitChangeEvent();
481 if (this.radioGroup) {
482 this.radioGroup._controlValueAccessorChangeFn(this.value);
483 if (groupValueChanged) {
484 this.radioGroup._emitChangeEvent();
485 }
486 }
487 }
488 }
489 /** Sets the disabled state and marks for check if a change occurred. */
490 _setDisabled(value) {
491 if (this._disabled !== value) {
492 this._disabled = value;
493 this._changeDetector.markForCheck();
494 }
495 }
496 /** Gets the tabindex for the underlying input element. */
497 _updateTabIndex() {
498 var _a;
499 const group = this.radioGroup;
500 let value;
501 // Implement a roving tabindex if the button is inside a group. For most cases this isn't
502 // necessary, because the browser handles the tab order for inputs inside a group automatically,
503 // but we need an explicitly higher tabindex for the selected button in order for things like
504 // the focus trap to pick it up correctly.
505 if (!group || !group.selected || this.disabled) {
506 value = this.tabIndex;
507 }
508 else {
509 value = group.selected === this ? this.tabIndex : -1;
510 }
511 if (value !== this._previousTabIndex) {
512 // We have to set the tabindex directly on the DOM node, because it depends on
513 // the selected state which is prone to "changed after checked errors".
514 const input = (_a = this._inputElement) === null || _a === void 0 ? void 0 : _a.nativeElement;
515 if (input) {
516 input.setAttribute('tabindex', value + '');
517 this._previousTabIndex = value;
518 }
519 }
520 }
521}
522_MatRadioButtonBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: _MatRadioButtonBase, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
523_MatRadioButtonBase.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: _MatRadioButtonBase, inputs: { id: "id", name: "name", ariaLabel: ["aria-label", "ariaLabel"], ariaLabelledby: ["aria-labelledby", "ariaLabelledby"], ariaDescribedby: ["aria-describedby", "ariaDescribedby"], checked: "checked", value: "value", labelPosition: "labelPosition", disabled: "disabled", required: "required", color: "color" }, outputs: { change: "change" }, viewQueries: [{ propertyName: "_inputElement", first: true, predicate: ["input"], descendants: true }], usesInheritance: true, ngImport: i0 });
524i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: _MatRadioButtonBase, decorators: [{
525 type: Directive
526 }], ctorParameters: function () { return [{ type: _MatRadioGroupBase }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1.FocusMonitor }, { type: i2.UniqueSelectionDispatcher }, { type: undefined }, { type: undefined }, { type: undefined }]; }, propDecorators: { id: [{
527 type: Input
528 }], name: [{
529 type: Input
530 }], ariaLabel: [{
531 type: Input,
532 args: ['aria-label']
533 }], ariaLabelledby: [{
534 type: Input,
535 args: ['aria-labelledby']
536 }], ariaDescribedby: [{
537 type: Input,
538 args: ['aria-describedby']
539 }], checked: [{
540 type: Input
541 }], value: [{
542 type: Input
543 }], labelPosition: [{
544 type: Input
545 }], disabled: [{
546 type: Input
547 }], required: [{
548 type: Input
549 }], color: [{
550 type: Input
551 }], change: [{
552 type: Output
553 }], _inputElement: [{
554 type: ViewChild,
555 args: ['input']
556 }] } });
557/**
558 * A Material design radio-button. Typically placed inside of `<mat-radio-group>` elements.
559 */
560class MatRadioButton extends _MatRadioButtonBase {
561 constructor(radioGroup, elementRef, changeDetector, focusMonitor, radioDispatcher, animationMode, providerOverride, tabIndex) {
562 super(radioGroup, elementRef, changeDetector, focusMonitor, radioDispatcher, animationMode, providerOverride, tabIndex);
563 }
564}
565MatRadioButton.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatRadioButton, deps: [{ token: MAT_RADIO_GROUP, optional: true }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1.FocusMonitor }, { token: i2.UniqueSelectionDispatcher }, { token: ANIMATION_MODULE_TYPE, optional: true }, { token: MAT_RADIO_DEFAULT_OPTIONS, optional: true }, { token: 'tabindex', attribute: true }], target: i0.ɵɵFactoryTarget.Component });
566MatRadioButton.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.1", type: MatRadioButton, selector: "mat-radio-button", inputs: { disableRipple: "disableRipple", tabIndex: "tabIndex" }, host: { listeners: { "focus": "_inputElement.nativeElement.focus()" }, properties: { "class.mat-radio-checked": "checked", "class.mat-radio-disabled": "disabled", "class._mat-animation-noopable": "_noopAnimations", "class.mat-primary": "color === \"primary\"", "class.mat-accent": "color === \"accent\"", "class.mat-warn": "color === \"warn\"", "attr.tabindex": "null", "attr.id": "id", "attr.aria-label": "null", "attr.aria-labelledby": "null", "attr.aria-describedby": "null" }, classAttribute: "mat-radio-button" }, exportAs: ["matRadioButton"], usesInheritance: true, ngImport: i0, template: "<!-- TODO(jelbourn): render the radio on either side of the content -->\n<!-- TODO(mtlin): Evaluate trade-offs of using native radio vs. cost of additional bindings. -->\n<label [attr.for]=\"inputId\" class=\"mat-radio-label\" #label>\n <!-- The actual 'radio' part of the control. -->\n <span class=\"mat-radio-container\">\n <span class=\"mat-radio-outer-circle\"></span>\n <span class=\"mat-radio-inner-circle\"></span>\n <input #input class=\"mat-radio-input\" type=\"radio\"\n [id]=\"inputId\"\n [checked]=\"checked\"\n [disabled]=\"disabled\"\n [attr.name]=\"name\"\n [attr.value]=\"value\"\n [required]=\"required\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n [attr.aria-describedby]=\"ariaDescribedby\"\n (change)=\"_onInputInteraction($event)\"\n (click)=\"_onInputClick($event)\">\n\n <!-- The ripple comes after the input so that we can target it with a CSS\n sibling selector when the input is focused. -->\n <span mat-ripple class=\"mat-radio-ripple mat-focus-indicator\"\n [matRippleTrigger]=\"label\"\n [matRippleDisabled]=\"_isRippleDisabled()\"\n [matRippleCentered]=\"true\"\n [matRippleRadius]=\"20\"\n [matRippleAnimation]=\"{enterDuration: _noopAnimations ? 0 : 150}\">\n\n <span class=\"mat-ripple-element mat-radio-persistent-ripple\"></span>\n </span>\n </span>\n\n <!-- The label content for radio control. -->\n <span class=\"mat-radio-label-content\" [class.mat-radio-label-before]=\"labelPosition == 'before'\">\n <!-- Add an invisible span so JAWS can read the label -->\n <span style=\"display:none\">&nbsp;</span>\n <ng-content></ng-content>\n </span>\n</label>\n", styles: [".mat-radio-button{display:inline-block;-webkit-tap-highlight-color:rgba(0,0,0,0);outline:0}.mat-radio-label{-webkit-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;display:block;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;display:block;height:20px;left:0;position:absolute;top:0;opacity:0;transition:transform ease 280ms,background-color ease 280ms,opacity linear 1ms 280ms;width:20px;transform:scale(0.001);-webkit-print-color-adjust:exact;color-adjust:exact}.mat-radio-checked .mat-radio-inner-circle{transform:scale(0.5);opacity:1;transition:transform ease 280ms,background-color ease 280ms}.cdk-high-contrast-active .mat-radio-checked .mat-radio-inner-circle{border:solid 10px}._mat-animation-noopable .mat-radio-inner-circle{transition:none}.mat-radio-label-content{-webkit-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;top:0;left:0}.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-persistent-ripple,.mat-radio-disabled .mat-radio-container:hover .mat-radio-persistent-ripple{opacity:0}@media(hover: none){.mat-radio-container:hover .mat-radio-persistent-ripple{display:none}}.mat-radio-input{opacity:0;position:absolute;top:0;left:0;margin:0;width:100%;height:100%;cursor:inherit;z-index:-1}.cdk-high-contrast-active .mat-radio-button:not(.mat-radio-disabled).cdk-keyboard-focused .mat-radio-ripple,.cdk-high-contrast-active .mat-radio-button:not(.mat-radio-disabled).cdk-program-focused .mat-radio-ripple{outline:solid 3px}.cdk-high-contrast-active .mat-radio-disabled{opacity:.5}"], dependencies: [{ kind: "directive", type: i3.MatRipple, selector: "[mat-ripple], [matRipple]", inputs: ["matRippleColor", "matRippleUnbounded", "matRippleCentered", "matRippleRadius", "matRippleAnimation", "matRippleDisabled", "matRippleTrigger"], exportAs: ["matRipple"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
567i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatRadioButton, decorators: [{
568 type: Component,
569 args: [{ selector: 'mat-radio-button', inputs: ['disableRipple', 'tabIndex'], encapsulation: ViewEncapsulation.None, exportAs: 'matRadioButton', host: {
570 'class': 'mat-radio-button',
571 '[class.mat-radio-checked]': 'checked',
572 '[class.mat-radio-disabled]': 'disabled',
573 '[class._mat-animation-noopable]': '_noopAnimations',
574 '[class.mat-primary]': 'color === "primary"',
575 '[class.mat-accent]': 'color === "accent"',
576 '[class.mat-warn]': 'color === "warn"',
577 // Needs to be removed since it causes some a11y issues (see #21266).
578 '[attr.tabindex]': 'null',
579 '[attr.id]': 'id',
580 '[attr.aria-label]': 'null',
581 '[attr.aria-labelledby]': 'null',
582 '[attr.aria-describedby]': 'null',
583 // Note: under normal conditions focus shouldn't land on this element, however it may be
584 // programmatically set, for example inside of a focus trap, in this case we want to forward
585 // the focus to the native element.
586 '(focus)': '_inputElement.nativeElement.focus()',
587 }, changeDetection: ChangeDetectionStrategy.OnPush, template: "<!-- TODO(jelbourn): render the radio on either side of the content -->\n<!-- TODO(mtlin): Evaluate trade-offs of using native radio vs. cost of additional bindings. -->\n<label [attr.for]=\"inputId\" class=\"mat-radio-label\" #label>\n <!-- The actual 'radio' part of the control. -->\n <span class=\"mat-radio-container\">\n <span class=\"mat-radio-outer-circle\"></span>\n <span class=\"mat-radio-inner-circle\"></span>\n <input #input class=\"mat-radio-input\" type=\"radio\"\n [id]=\"inputId\"\n [checked]=\"checked\"\n [disabled]=\"disabled\"\n [attr.name]=\"name\"\n [attr.value]=\"value\"\n [required]=\"required\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n [attr.aria-describedby]=\"ariaDescribedby\"\n (change)=\"_onInputInteraction($event)\"\n (click)=\"_onInputClick($event)\">\n\n <!-- The ripple comes after the input so that we can target it with a CSS\n sibling selector when the input is focused. -->\n <span mat-ripple class=\"mat-radio-ripple mat-focus-indicator\"\n [matRippleTrigger]=\"label\"\n [matRippleDisabled]=\"_isRippleDisabled()\"\n [matRippleCentered]=\"true\"\n [matRippleRadius]=\"20\"\n [matRippleAnimation]=\"{enterDuration: _noopAnimations ? 0 : 150}\">\n\n <span class=\"mat-ripple-element mat-radio-persistent-ripple\"></span>\n </span>\n </span>\n\n <!-- The label content for radio control. -->\n <span class=\"mat-radio-label-content\" [class.mat-radio-label-before]=\"labelPosition == 'before'\">\n <!-- Add an invisible span so JAWS can read the label -->\n <span style=\"display:none\">&nbsp;</span>\n <ng-content></ng-content>\n </span>\n</label>\n", styles: [".mat-radio-button{display:inline-block;-webkit-tap-highlight-color:rgba(0,0,0,0);outline:0}.mat-radio-label{-webkit-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;display:block;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;display:block;height:20px;left:0;position:absolute;top:0;opacity:0;transition:transform ease 280ms,background-color ease 280ms,opacity linear 1ms 280ms;width:20px;transform:scale(0.001);-webkit-print-color-adjust:exact;color-adjust:exact}.mat-radio-checked .mat-radio-inner-circle{transform:scale(0.5);opacity:1;transition:transform ease 280ms,background-color ease 280ms}.cdk-high-contrast-active .mat-radio-checked .mat-radio-inner-circle{border:solid 10px}._mat-animation-noopable .mat-radio-inner-circle{transition:none}.mat-radio-label-content{-webkit-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;top:0;left:0}.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-persistent-ripple,.mat-radio-disabled .mat-radio-container:hover .mat-radio-persistent-ripple{opacity:0}@media(hover: none){.mat-radio-container:hover .mat-radio-persistent-ripple{display:none}}.mat-radio-input{opacity:0;position:absolute;top:0;left:0;margin:0;width:100%;height:100%;cursor:inherit;z-index:-1}.cdk-high-contrast-active .mat-radio-button:not(.mat-radio-disabled).cdk-keyboard-focused .mat-radio-ripple,.cdk-high-contrast-active .mat-radio-button:not(.mat-radio-disabled).cdk-program-focused .mat-radio-ripple{outline:solid 3px}.cdk-high-contrast-active .mat-radio-disabled{opacity:.5}"] }]
588 }], ctorParameters: function () {
589 return [{ type: MatRadioGroup, decorators: [{
590 type: Optional
591 }, {
592 type: Inject,
593 args: [MAT_RADIO_GROUP]
594 }] }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1.FocusMonitor }, { type: i2.UniqueSelectionDispatcher }, { type: undefined, decorators: [{
595 type: Optional
596 }, {
597 type: Inject,
598 args: [ANIMATION_MODULE_TYPE]
599 }] }, { type: undefined, decorators: [{
600 type: Optional
601 }, {
602 type: Inject,
603 args: [MAT_RADIO_DEFAULT_OPTIONS]
604 }] }, { type: undefined, decorators: [{
605 type: Attribute,
606 args: ['tabindex']
607 }] }];
608 } });
609
610/**
611 * @license
612 * Copyright Google LLC All Rights Reserved.
613 *
614 * Use of this source code is governed by an MIT-style license that can be
615 * found in the LICENSE file at https://angular.io/license
616 */
617class MatRadioModule {
618}
619MatRadioModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatRadioModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
620MatRadioModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.1", ngImport: i0, type: MatRadioModule, declarations: [MatRadioGroup, MatRadioButton], imports: [MatRippleModule, MatCommonModule], exports: [MatRadioGroup, MatRadioButton, MatCommonModule] });
621MatRadioModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatRadioModule, imports: [MatRippleModule, MatCommonModule, MatCommonModule] });
622i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatRadioModule, decorators: [{
623 type: NgModule,
624 args: [{
625 imports: [MatRippleModule, MatCommonModule],
626 exports: [MatRadioGroup, MatRadioButton, MatCommonModule],
627 declarations: [MatRadioGroup, MatRadioButton],
628 }]
629 }] });
630
631/**
632 * @license
633 * Copyright Google LLC All Rights Reserved.
634 *
635 * Use of this source code is governed by an MIT-style license that can be
636 * found in the LICENSE file at https://angular.io/license
637 */
638
639/**
640 * @license
641 * Copyright Google LLC All Rights Reserved.
642 *
643 * Use of this source code is governed by an MIT-style license that can be
644 * found in the LICENSE file at https://angular.io/license
645 */
646
647/**
648 * Generated bundle index. Do not edit.
649 */
650
651export { MAT_RADIO_DEFAULT_OPTIONS, MAT_RADIO_DEFAULT_OPTIONS_FACTORY, MAT_RADIO_GROUP, MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR, MatRadioButton, MatRadioChange, MatRadioGroup, MatRadioModule, _MatRadioButtonBase, _MatRadioGroupBase };
652//# sourceMappingURL=radio.mjs.map