source: trip-planner-front/node_modules/@angular/material/bundles/material-radio.umd.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 48.7 KB
RevLine 
[6a3a178]1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/material/core'), require('@angular/cdk/a11y'), require('@angular/cdk/coercion'), require('@angular/cdk/collections'), require('@angular/forms'), require('@angular/platform-browser/animations')) :
3 typeof define === 'function' && define.amd ? define('@angular/material/radio', ['exports', '@angular/core', '@angular/material/core', '@angular/cdk/a11y', '@angular/cdk/coercion', '@angular/cdk/collections', '@angular/forms', '@angular/platform-browser/animations'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.radio = {}), global.ng.core, global.ng.material.core, global.ng.cdk.a11y, global.ng.cdk.coercion, global.ng.cdk.collections, global.ng.forms, global.ng.platformBrowser.animations));
5}(this, (function (exports, core, core$1, a11y, coercion, collections, forms, animations) { 'use strict';
6
7 /*! *****************************************************************************
8 Copyright (c) Microsoft Corporation.
9
10 Permission to use, copy, modify, and/or distribute this software for any
11 purpose with or without fee is hereby granted.
12
13 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 PERFORMANCE OF THIS SOFTWARE.
20 ***************************************************************************** */
21 /* global Reflect, Promise */
22 var extendStatics = function (d, b) {
23 extendStatics = Object.setPrototypeOf ||
24 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25 function (d, b) { for (var p in b)
26 if (Object.prototype.hasOwnProperty.call(b, p))
27 d[p] = b[p]; };
28 return extendStatics(d, b);
29 };
30 function __extends(d, b) {
31 if (typeof b !== "function" && b !== null)
32 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
33 extendStatics(d, b);
34 function __() { this.constructor = d; }
35 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36 }
37 var __assign = function () {
38 __assign = Object.assign || function __assign(t) {
39 for (var s, i = 1, n = arguments.length; i < n; i++) {
40 s = arguments[i];
41 for (var p in s)
42 if (Object.prototype.hasOwnProperty.call(s, p))
43 t[p] = s[p];
44 }
45 return t;
46 };
47 return __assign.apply(this, arguments);
48 };
49 function __rest(s, e) {
50 var t = {};
51 for (var p in s)
52 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
53 t[p] = s[p];
54 if (s != null && typeof Object.getOwnPropertySymbols === "function")
55 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
56 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
57 t[p[i]] = s[p[i]];
58 }
59 return t;
60 }
61 function __decorate(decorators, target, key, desc) {
62 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
63 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
64 r = Reflect.decorate(decorators, target, key, desc);
65 else
66 for (var i = decorators.length - 1; i >= 0; i--)
67 if (d = decorators[i])
68 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
69 return c > 3 && r && Object.defineProperty(target, key, r), r;
70 }
71 function __param(paramIndex, decorator) {
72 return function (target, key) { decorator(target, key, paramIndex); };
73 }
74 function __metadata(metadataKey, metadataValue) {
75 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
76 return Reflect.metadata(metadataKey, metadataValue);
77 }
78 function __awaiter(thisArg, _arguments, P, generator) {
79 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
80 return new (P || (P = Promise))(function (resolve, reject) {
81 function fulfilled(value) { try {
82 step(generator.next(value));
83 }
84 catch (e) {
85 reject(e);
86 } }
87 function rejected(value) { try {
88 step(generator["throw"](value));
89 }
90 catch (e) {
91 reject(e);
92 } }
93 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
94 step((generator = generator.apply(thisArg, _arguments || [])).next());
95 });
96 }
97 function __generator(thisArg, body) {
98 var _ = { label: 0, sent: function () { if (t[0] & 1)
99 throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
100 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
101 function verb(n) { return function (v) { return step([n, v]); }; }
102 function step(op) {
103 if (f)
104 throw new TypeError("Generator is already executing.");
105 while (_)
106 try {
107 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
108 return t;
109 if (y = 0, t)
110 op = [op[0] & 2, t.value];
111 switch (op[0]) {
112 case 0:
113 case 1:
114 t = op;
115 break;
116 case 4:
117 _.label++;
118 return { value: op[1], done: false };
119 case 5:
120 _.label++;
121 y = op[1];
122 op = [0];
123 continue;
124 case 7:
125 op = _.ops.pop();
126 _.trys.pop();
127 continue;
128 default:
129 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
130 _ = 0;
131 continue;
132 }
133 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
134 _.label = op[1];
135 break;
136 }
137 if (op[0] === 6 && _.label < t[1]) {
138 _.label = t[1];
139 t = op;
140 break;
141 }
142 if (t && _.label < t[2]) {
143 _.label = t[2];
144 _.ops.push(op);
145 break;
146 }
147 if (t[2])
148 _.ops.pop();
149 _.trys.pop();
150 continue;
151 }
152 op = body.call(thisArg, _);
153 }
154 catch (e) {
155 op = [6, e];
156 y = 0;
157 }
158 finally {
159 f = t = 0;
160 }
161 if (op[0] & 5)
162 throw op[1];
163 return { value: op[0] ? op[1] : void 0, done: true };
164 }
165 }
166 var __createBinding = Object.create ? (function (o, m, k, k2) {
167 if (k2 === undefined)
168 k2 = k;
169 Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
170 }) : (function (o, m, k, k2) {
171 if (k2 === undefined)
172 k2 = k;
173 o[k2] = m[k];
174 });
175 function __exportStar(m, o) {
176 for (var p in m)
177 if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
178 __createBinding(o, m, p);
179 }
180 function __values(o) {
181 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
182 if (m)
183 return m.call(o);
184 if (o && typeof o.length === "number")
185 return {
186 next: function () {
187 if (o && i >= o.length)
188 o = void 0;
189 return { value: o && o[i++], done: !o };
190 }
191 };
192 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
193 }
194 function __read(o, n) {
195 var m = typeof Symbol === "function" && o[Symbol.iterator];
196 if (!m)
197 return o;
198 var i = m.call(o), r, ar = [], e;
199 try {
200 while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
201 ar.push(r.value);
202 }
203 catch (error) {
204 e = { error: error };
205 }
206 finally {
207 try {
208 if (r && !r.done && (m = i["return"]))
209 m.call(i);
210 }
211 finally {
212 if (e)
213 throw e.error;
214 }
215 }
216 return ar;
217 }
218 /** @deprecated */
219 function __spread() {
220 for (var ar = [], i = 0; i < arguments.length; i++)
221 ar = ar.concat(__read(arguments[i]));
222 return ar;
223 }
224 /** @deprecated */
225 function __spreadArrays() {
226 for (var s = 0, i = 0, il = arguments.length; i < il; i++)
227 s += arguments[i].length;
228 for (var r = Array(s), k = 0, i = 0; i < il; i++)
229 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
230 r[k] = a[j];
231 return r;
232 }
233 function __spreadArray(to, from, pack) {
234 if (pack || arguments.length === 2)
235 for (var i = 0, l = from.length, ar; i < l; i++) {
236 if (ar || !(i in from)) {
237 if (!ar)
238 ar = Array.prototype.slice.call(from, 0, i);
239 ar[i] = from[i];
240 }
241 }
242 return to.concat(ar || from);
243 }
244 function __await(v) {
245 return this instanceof __await ? (this.v = v, this) : new __await(v);
246 }
247 function __asyncGenerator(thisArg, _arguments, generator) {
248 if (!Symbol.asyncIterator)
249 throw new TypeError("Symbol.asyncIterator is not defined.");
250 var g = generator.apply(thisArg, _arguments || []), i, q = [];
251 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
252 function verb(n) { if (g[n])
253 i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
254 function resume(n, v) { try {
255 step(g[n](v));
256 }
257 catch (e) {
258 settle(q[0][3], e);
259 } }
260 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
261 function fulfill(value) { resume("next", value); }
262 function reject(value) { resume("throw", value); }
263 function settle(f, v) { if (f(v), q.shift(), q.length)
264 resume(q[0][0], q[0][1]); }
265 }
266 function __asyncDelegator(o) {
267 var i, p;
268 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
269 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
270 }
271 function __asyncValues(o) {
272 if (!Symbol.asyncIterator)
273 throw new TypeError("Symbol.asyncIterator is not defined.");
274 var m = o[Symbol.asyncIterator], i;
275 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
276 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
277 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
278 }
279 function __makeTemplateObject(cooked, raw) {
280 if (Object.defineProperty) {
281 Object.defineProperty(cooked, "raw", { value: raw });
282 }
283 else {
284 cooked.raw = raw;
285 }
286 return cooked;
287 }
288 ;
289 var __setModuleDefault = Object.create ? (function (o, v) {
290 Object.defineProperty(o, "default", { enumerable: true, value: v });
291 }) : function (o, v) {
292 o["default"] = v;
293 };
294 function __importStar(mod) {
295 if (mod && mod.__esModule)
296 return mod;
297 var result = {};
298 if (mod != null)
299 for (var k in mod)
300 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
301 __createBinding(result, mod, k);
302 __setModuleDefault(result, mod);
303 return result;
304 }
305 function __importDefault(mod) {
306 return (mod && mod.__esModule) ? mod : { default: mod };
307 }
308 function __classPrivateFieldGet(receiver, state, kind, f) {
309 if (kind === "a" && !f)
310 throw new TypeError("Private accessor was defined without a getter");
311 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
312 throw new TypeError("Cannot read private member from an object whose class did not declare it");
313 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
314 }
315 function __classPrivateFieldSet(receiver, state, value, kind, f) {
316 if (kind === "m")
317 throw new TypeError("Private method is not writable");
318 if (kind === "a" && !f)
319 throw new TypeError("Private accessor was defined without a setter");
320 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
321 throw new TypeError("Cannot write private member to an object whose class did not declare it");
322 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
323 }
324
325 var MAT_RADIO_DEFAULT_OPTIONS = new core.InjectionToken('mat-radio-default-options', {
326 providedIn: 'root',
327 factory: MAT_RADIO_DEFAULT_OPTIONS_FACTORY
328 });
329 function MAT_RADIO_DEFAULT_OPTIONS_FACTORY() {
330 return {
331 color: 'accent'
332 };
333 }
334 // Increasing integer for generating unique ids for radio components.
335 var nextUniqueId = 0;
336 /**
337 * Provider Expression that allows mat-radio-group to register as a ControlValueAccessor. This
338 * allows it to support [(ngModel)] and ngControl.
339 * @docs-private
340 */
341 var MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR = {
342 provide: forms.NG_VALUE_ACCESSOR,
343 useExisting: core.forwardRef(function () { return MatRadioGroup; }),
344 multi: true
345 };
346 /** Change event object emitted by MatRadio and MatRadioGroup. */
347 var MatRadioChange = /** @class */ (function () {
348 function MatRadioChange(
349 /** The MatRadioButton that emits the change event. */
350 source,
351 /** The value of the MatRadioButton. */
352 value) {
353 this.source = source;
354 this.value = value;
355 }
356 return MatRadioChange;
357 }());
358 /**
359 * Injection token that can be used to inject instances of `MatRadioGroup`. It serves as
360 * alternative token to the actual `MatRadioGroup` class which could cause unnecessary
361 * retention of the class and its component metadata.
362 */
363 var MAT_RADIO_GROUP = new core.InjectionToken('MatRadioGroup');
364 /**
365 * Base class with all of the `MatRadioGroup` functionality.
366 * @docs-private
367 */
368 var _MatRadioGroupBase = /** @class */ (function () {
369 function _MatRadioGroupBase(_changeDetector) {
370 this._changeDetector = _changeDetector;
371 /** Selected value for the radio group. */
372 this._value = null;
373 /** The HTML name attribute applied to radio buttons in this group. */
374 this._name = "mat-radio-group-" + nextUniqueId++;
375 /** The currently selected radio button. Should match value. */
376 this._selected = null;
377 /** Whether the `value` has been set to its initial value. */
378 this._isInitialized = false;
379 /** Whether the labels should appear after or before the radio-buttons. Defaults to 'after' */
380 this._labelPosition = 'after';
381 /** Whether the radio group is disabled. */
382 this._disabled = false;
383 /** Whether the radio group is required. */
384 this._required = false;
385 /** The method to be called in order to update ngModel */
386 this._controlValueAccessorChangeFn = function () { };
387 /**
388 * onTouch function registered via registerOnTouch (ControlValueAccessor).
389 * @docs-private
390 */
391 this.onTouched = function () { };
392 /**
393 * Event emitted when the group value changes.
394 * Change events are only emitted when the value changes due to user interaction with
395 * a radio button (the same behavior as `<input type-"radio">`).
396 */
397 this.change = new core.EventEmitter();
398 }
399 Object.defineProperty(_MatRadioGroupBase.prototype, "name", {
400 /** Name of the radio button group. All radio buttons inside this group will use this name. */
401 get: function () { return this._name; },
402 set: function (value) {
403 this._name = value;
404 this._updateRadioButtonNames();
405 },
406 enumerable: false,
407 configurable: true
408 });
409 Object.defineProperty(_MatRadioGroupBase.prototype, "labelPosition", {
410 /** Whether the labels should appear after or before the radio-buttons. Defaults to 'after' */
411 get: function () {
412 return this._labelPosition;
413 },
414 set: function (v) {
415 this._labelPosition = v === 'before' ? 'before' : 'after';
416 this._markRadiosForCheck();
417 },
418 enumerable: false,
419 configurable: true
420 });
421 Object.defineProperty(_MatRadioGroupBase.prototype, "value", {
422 /**
423 * Value for the radio-group. Should equal the value of the selected radio button if there is
424 * a corresponding radio button with a matching value. If there is not such a corresponding
425 * radio button, this value persists to be applied in case a new radio button is added with a
426 * matching value.
427 */
428 get: function () { return this._value; },
429 set: function (newValue) {
430 if (this._value !== newValue) {
431 // Set this before proceeding to ensure no circular loop occurs with selection.
432 this._value = newValue;
433 this._updateSelectedRadioFromValue();
434 this._checkSelectedRadioButton();
435 }
436 },
437 enumerable: false,
438 configurable: true
439 });
440 _MatRadioGroupBase.prototype._checkSelectedRadioButton = function () {
441 if (this._selected && !this._selected.checked) {
442 this._selected.checked = true;
443 }
444 };
445 Object.defineProperty(_MatRadioGroupBase.prototype, "selected", {
446 /**
447 * The currently selected radio button. If set to a new radio button, the radio group value
448 * will be updated to match the new selected button.
449 */
450 get: function () { return this._selected; },
451 set: function (selected) {
452 this._selected = selected;
453 this.value = selected ? selected.value : null;
454 this._checkSelectedRadioButton();
455 },
456 enumerable: false,
457 configurable: true
458 });
459 Object.defineProperty(_MatRadioGroupBase.prototype, "disabled", {
460 /** Whether the radio group is disabled */
461 get: function () { return this._disabled; },
462 set: function (value) {
463 this._disabled = coercion.coerceBooleanProperty(value);
464 this._markRadiosForCheck();
465 },
466 enumerable: false,
467 configurable: true
468 });
469 Object.defineProperty(_MatRadioGroupBase.prototype, "required", {
470 /** Whether the radio group is required */
471 get: function () { return this._required; },
472 set: function (value) {
473 this._required = coercion.coerceBooleanProperty(value);
474 this._markRadiosForCheck();
475 },
476 enumerable: false,
477 configurable: true
478 });
479 /**
480 * Initialize properties once content children are available.
481 * This allows us to propagate relevant attributes to associated buttons.
482 */
483 _MatRadioGroupBase.prototype.ngAfterContentInit = function () {
484 // Mark this component as initialized in AfterContentInit because the initial value can
485 // possibly be set by NgModel on MatRadioGroup, and it is possible that the OnInit of the
486 // NgModel occurs *after* the OnInit of the MatRadioGroup.
487 this._isInitialized = true;
488 };
489 /**
490 * Mark this group as being "touched" (for ngModel). Meant to be called by the contained
491 * radio buttons upon their blur.
492 */
493 _MatRadioGroupBase.prototype._touch = function () {
494 if (this.onTouched) {
495 this.onTouched();
496 }
497 };
498 _MatRadioGroupBase.prototype._updateRadioButtonNames = function () {
499 var _this = this;
500 if (this._radios) {
501 this._radios.forEach(function (radio) {
502 radio.name = _this.name;
503 radio._markForCheck();
504 });
505 }
506 };
507 /** Updates the `selected` radio button from the internal _value state. */
508 _MatRadioGroupBase.prototype._updateSelectedRadioFromValue = function () {
509 var _this = this;
510 // If the value already matches the selected radio, do nothing.
511 var isAlreadySelected = this._selected !== null && this._selected.value === this._value;
512 if (this._radios && !isAlreadySelected) {
513 this._selected = null;
514 this._radios.forEach(function (radio) {
515 radio.checked = _this.value === radio.value;
516 if (radio.checked) {
517 _this._selected = radio;
518 }
519 });
520 }
521 };
522 /** Dispatch change event with current selection and group value. */
523 _MatRadioGroupBase.prototype._emitChangeEvent = function () {
524 if (this._isInitialized) {
525 this.change.emit(new MatRadioChange(this._selected, this._value));
526 }
527 };
528 _MatRadioGroupBase.prototype._markRadiosForCheck = function () {
529 if (this._radios) {
530 this._radios.forEach(function (radio) { return radio._markForCheck(); });
531 }
532 };
533 /**
534 * Sets the model value. Implemented as part of ControlValueAccessor.
535 * @param value
536 */
537 _MatRadioGroupBase.prototype.writeValue = function (value) {
538 this.value = value;
539 this._changeDetector.markForCheck();
540 };
541 /**
542 * Registers a callback to be triggered when the model value changes.
543 * Implemented as part of ControlValueAccessor.
544 * @param fn Callback to be registered.
545 */
546 _MatRadioGroupBase.prototype.registerOnChange = function (fn) {
547 this._controlValueAccessorChangeFn = fn;
548 };
549 /**
550 * Registers a callback to be triggered when the control is touched.
551 * Implemented as part of ControlValueAccessor.
552 * @param fn Callback to be registered.
553 */
554 _MatRadioGroupBase.prototype.registerOnTouched = function (fn) {
555 this.onTouched = fn;
556 };
557 /**
558 * Sets the disabled state of the control. Implemented as a part of ControlValueAccessor.
559 * @param isDisabled Whether the control should be disabled.
560 */
561 _MatRadioGroupBase.prototype.setDisabledState = function (isDisabled) {
562 this.disabled = isDisabled;
563 this._changeDetector.markForCheck();
564 };
565 return _MatRadioGroupBase;
566 }());
567 _MatRadioGroupBase.decorators = [
568 { type: core.Directive }
569 ];
570 _MatRadioGroupBase.ctorParameters = function () { return [
571 { type: core.ChangeDetectorRef }
572 ]; };
573 _MatRadioGroupBase.propDecorators = {
574 change: [{ type: core.Output }],
575 color: [{ type: core.Input }],
576 name: [{ type: core.Input }],
577 labelPosition: [{ type: core.Input }],
578 value: [{ type: core.Input }],
579 selected: [{ type: core.Input }],
580 disabled: [{ type: core.Input }],
581 required: [{ type: core.Input }]
582 };
583 /**
584 * A group of radio buttons. May contain one or more `<mat-radio-button>` elements.
585 */
586 var MatRadioGroup = /** @class */ (function (_super) {
587 __extends(MatRadioGroup, _super);
588 function MatRadioGroup() {
589 return _super !== null && _super.apply(this, arguments) || this;
590 }
591 return MatRadioGroup;
592 }(_MatRadioGroupBase));
593 MatRadioGroup.decorators = [
594 { type: core.Directive, args: [{
595 selector: 'mat-radio-group',
596 exportAs: 'matRadioGroup',
597 providers: [
598 MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR,
599 { provide: MAT_RADIO_GROUP, useExisting: MatRadioGroup },
600 ],
601 host: {
602 'role': 'radiogroup',
603 'class': 'mat-radio-group',
604 },
605 },] }
606 ];
607 MatRadioGroup.propDecorators = {
608 _radios: [{ type: core.ContentChildren, args: [core.forwardRef(function () { return MatRadioButton; }), { descendants: true },] }]
609 };
610 // Boilerplate for applying mixins to MatRadioButton.
611 /** @docs-private */
612 var MatRadioButtonBase = /** @class */ (function () {
613 function MatRadioButtonBase(_elementRef) {
614 this._elementRef = _elementRef;
615 }
616 return MatRadioButtonBase;
617 }());
618 var _MatRadioButtonMixinBase = core$1.mixinDisableRipple(core$1.mixinTabIndex(MatRadioButtonBase));
619 /**
620 * Base class with all of the `MatRadioButton` functionality.
621 * @docs-private
622 */
623 var _MatRadioButtonBase = /** @class */ (function (_super) {
624 __extends(_MatRadioButtonBase, _super);
625 function _MatRadioButtonBase(radioGroup, elementRef, _changeDetector, _focusMonitor, _radioDispatcher, animationMode, _providerOverride, tabIndex) {
626 var _this = _super.call(this, elementRef) || this;
627 _this._changeDetector = _changeDetector;
628 _this._focusMonitor = _focusMonitor;
629 _this._radioDispatcher = _radioDispatcher;
630 _this._providerOverride = _providerOverride;
631 _this._uniqueId = "mat-radio-" + ++nextUniqueId;
632 /** The unique ID for the radio button. */
633 _this.id = _this._uniqueId;
634 /**
635 * Event emitted when the checked state of this radio button changes.
636 * Change events are only emitted when the value changes due to user interaction with
637 * the radio button (the same behavior as `<input type-"radio">`).
638 */
639 _this.change = new core.EventEmitter();
640 /** Whether this radio is checked. */
641 _this._checked = false;
642 /** Value assigned to this radio. */
643 _this._value = null;
644 /** Unregister function for _radioDispatcher */
645 _this._removeUniqueSelectionListener = function () { };
646 // Assertions. Ideally these should be stripped out by the compiler.
647 // TODO(jelbourn): Assert that there's no name binding AND a parent radio group.
648 _this.radioGroup = radioGroup;
649 _this._noopAnimations = animationMode === 'NoopAnimations';
650 if (tabIndex) {
651 _this.tabIndex = coercion.coerceNumberProperty(tabIndex, 0);
652 }
653 _this._removeUniqueSelectionListener =
654 _radioDispatcher.listen(function (id, name) {
655 if (id !== _this.id && name === _this.name) {
656 _this.checked = false;
657 }
658 });
659 return _this;
660 }
661 Object.defineProperty(_MatRadioButtonBase.prototype, "checked", {
662 /** Whether this radio button is checked. */
663 get: function () { return this._checked; },
664 set: function (value) {
665 var newCheckedState = coercion.coerceBooleanProperty(value);
666 if (this._checked !== newCheckedState) {
667 this._checked = newCheckedState;
668 if (newCheckedState && this.radioGroup && this.radioGroup.value !== this.value) {
669 this.radioGroup.selected = this;
670 }
671 else if (!newCheckedState && this.radioGroup && this.radioGroup.value === this.value) {
672 // When unchecking the selected radio button, update the selected radio
673 // property on the group.
674 this.radioGroup.selected = null;
675 }
676 if (newCheckedState) {
677 // Notify all radio buttons with the same name to un-check.
678 this._radioDispatcher.notify(this.id, this.name);
679 }
680 this._changeDetector.markForCheck();
681 }
682 },
683 enumerable: false,
684 configurable: true
685 });
686 Object.defineProperty(_MatRadioButtonBase.prototype, "value", {
687 /** The value of this radio button. */
688 get: function () { return this._value; },
689 set: function (value) {
690 if (this._value !== value) {
691 this._value = value;
692 if (this.radioGroup !== null) {
693 if (!this.checked) {
694 // Update checked when the value changed to match the radio group's value
695 this.checked = this.radioGroup.value === value;
696 }
697 if (this.checked) {
698 this.radioGroup.selected = this;
699 }
700 }
701 }
702 },
703 enumerable: false,
704 configurable: true
705 });
706 Object.defineProperty(_MatRadioButtonBase.prototype, "labelPosition", {
707 /** Whether the label should appear after or before the radio button. Defaults to 'after' */
708 get: function () {
709 return this._labelPosition || (this.radioGroup && this.radioGroup.labelPosition) || 'after';
710 },
711 set: function (value) {
712 this._labelPosition = value;
713 },
714 enumerable: false,
715 configurable: true
716 });
717 Object.defineProperty(_MatRadioButtonBase.prototype, "disabled", {
718 /** Whether the radio button is disabled. */
719 get: function () {
720 return this._disabled || (this.radioGroup !== null && this.radioGroup.disabled);
721 },
722 set: function (value) {
723 this._setDisabled(coercion.coerceBooleanProperty(value));
724 },
725 enumerable: false,
726 configurable: true
727 });
728 Object.defineProperty(_MatRadioButtonBase.prototype, "required", {
729 /** Whether the radio button is required. */
730 get: function () {
731 return this._required || (this.radioGroup && this.radioGroup.required);
732 },
733 set: function (value) {
734 this._required = coercion.coerceBooleanProperty(value);
735 },
736 enumerable: false,
737 configurable: true
738 });
739 Object.defineProperty(_MatRadioButtonBase.prototype, "color", {
740 /** Theme color of the radio button. */
741 get: function () {
742 // As per Material design specifications the selection control radio should use the accent color
743 // palette by default. https://material.io/guidelines/components/selection-controls.html
744 return this._color ||
745 (this.radioGroup && this.radioGroup.color) ||
746 this._providerOverride && this._providerOverride.color || 'accent';
747 },
748 set: function (newValue) { this._color = newValue; },
749 enumerable: false,
750 configurable: true
751 });
752 Object.defineProperty(_MatRadioButtonBase.prototype, "inputId", {
753 /** ID of the native input element inside `<mat-radio-button>` */
754 get: function () { return (this.id || this._uniqueId) + "-input"; },
755 enumerable: false,
756 configurable: true
757 });
758 /** Focuses the radio button. */
759 _MatRadioButtonBase.prototype.focus = function (options, origin) {
760 if (origin) {
761 this._focusMonitor.focusVia(this._inputElement, origin, options);
762 }
763 else {
764 this._inputElement.nativeElement.focus(options);
765 }
766 };
767 /**
768 * Marks the radio button as needing checking for change detection.
769 * This method is exposed because the parent radio group will directly
770 * update bound properties of the radio button.
771 */
772 _MatRadioButtonBase.prototype._markForCheck = function () {
773 // When group value changes, the button will not be notified. Use `markForCheck` to explicit
774 // update radio button's status
775 this._changeDetector.markForCheck();
776 };
777 _MatRadioButtonBase.prototype.ngOnInit = function () {
778 if (this.radioGroup) {
779 // If the radio is inside a radio group, determine if it should be checked
780 this.checked = this.radioGroup.value === this._value;
781 if (this.checked) {
782 this.radioGroup.selected = this;
783 }
784 // Copy name from parent radio group
785 this.name = this.radioGroup.name;
786 }
787 };
788 _MatRadioButtonBase.prototype.ngAfterViewInit = function () {
789 var _this = this;
790 this._focusMonitor
791 .monitor(this._elementRef, true)
792 .subscribe(function (focusOrigin) {
793 if (!focusOrigin && _this.radioGroup) {
794 _this.radioGroup._touch();
795 }
796 });
797 };
798 _MatRadioButtonBase.prototype.ngOnDestroy = function () {
799 this._focusMonitor.stopMonitoring(this._elementRef);
800 this._removeUniqueSelectionListener();
801 };
802 /** Dispatch change event with current value. */
803 _MatRadioButtonBase.prototype._emitChangeEvent = function () {
804 this.change.emit(new MatRadioChange(this, this._value));
805 };
806 _MatRadioButtonBase.prototype._isRippleDisabled = function () {
807 return this.disableRipple || this.disabled;
808 };
809 _MatRadioButtonBase.prototype._onInputClick = function (event) {
810 // We have to stop propagation for click events on the visual hidden input element.
811 // By default, when a user clicks on a label element, a generated click event will be
812 // dispatched on the associated input element. Since we are using a label element as our
813 // root container, the click event on the `radio-button` will be executed twice.
814 // The real click event will bubble up, and the generated click event also tries to bubble up.
815 // This will lead to multiple click events.
816 // Preventing bubbling for the second event will solve that issue.
817 event.stopPropagation();
818 };
819 /** Triggered when the radio button receives an interaction from the user. */
820 _MatRadioButtonBase.prototype._onInputInteraction = function (event) {
821 // We always have to stop propagation on the change event.
822 // Otherwise the change event, from the input element, will bubble up and
823 // emit its event object to the `change` output.
824 event.stopPropagation();
825 if (!this.checked && !this.disabled) {
826 var groupValueChanged = this.radioGroup && this.value !== this.radioGroup.value;
827 this.checked = true;
828 this._emitChangeEvent();
829 if (this.radioGroup) {
830 this.radioGroup._controlValueAccessorChangeFn(this.value);
831 if (groupValueChanged) {
832 this.radioGroup._emitChangeEvent();
833 }
834 }
835 }
836 };
837 /** Sets the disabled state and marks for check if a change occurred. */
838 _MatRadioButtonBase.prototype._setDisabled = function (value) {
839 if (this._disabled !== value) {
840 this._disabled = value;
841 this._changeDetector.markForCheck();
842 }
843 };
844 return _MatRadioButtonBase;
845 }(_MatRadioButtonMixinBase));
846 _MatRadioButtonBase.decorators = [
847 { type: core.Directive }
848 ];
849 _MatRadioButtonBase.ctorParameters = function () { return [
850 { type: _MatRadioGroupBase },
851 { type: core.ElementRef },
852 { type: core.ChangeDetectorRef },
853 { type: a11y.FocusMonitor },
854 { type: collections.UniqueSelectionDispatcher },
855 { type: String },
856 { type: undefined },
857 { type: String }
858 ]; };
859 _MatRadioButtonBase.propDecorators = {
860 id: [{ type: core.Input }],
861 name: [{ type: core.Input }],
862 ariaLabel: [{ type: core.Input, args: ['aria-label',] }],
863 ariaLabelledby: [{ type: core.Input, args: ['aria-labelledby',] }],
864 ariaDescribedby: [{ type: core.Input, args: ['aria-describedby',] }],
865 checked: [{ type: core.Input }],
866 value: [{ type: core.Input }],
867 labelPosition: [{ type: core.Input }],
868 disabled: [{ type: core.Input }],
869 required: [{ type: core.Input }],
870 color: [{ type: core.Input }],
871 change: [{ type: core.Output }],
872 _inputElement: [{ type: core.ViewChild, args: ['input',] }]
873 };
874 /**
875 * A Material design radio-button. Typically placed inside of `<mat-radio-group>` elements.
876 */
877 var MatRadioButton = /** @class */ (function (_super) {
878 __extends(MatRadioButton, _super);
879 function MatRadioButton(radioGroup, elementRef, changeDetector, focusMonitor, radioDispatcher, animationMode, providerOverride, tabIndex) {
880 return _super.call(this, radioGroup, elementRef, changeDetector, focusMonitor, radioDispatcher, animationMode, providerOverride, tabIndex) || this;
881 }
882 return MatRadioButton;
883 }(_MatRadioButtonBase));
884 MatRadioButton.decorators = [
885 { type: core.Component, args: [{
886 selector: 'mat-radio-button',
887 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 cdk-visually-hidden\" type=\"radio\"\n [id]=\"inputId\"\n [checked]=\"checked\"\n [disabled]=\"disabled\"\n [tabIndex]=\"tabIndex\"\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",
888 inputs: ['disableRipple', 'tabIndex'],
889 encapsulation: core.ViewEncapsulation.None,
890 exportAs: 'matRadioButton',
891 host: {
892 'class': 'mat-radio-button',
893 '[class.mat-radio-checked]': 'checked',
894 '[class.mat-radio-disabled]': 'disabled',
895 '[class._mat-animation-noopable]': '_noopAnimations',
896 '[class.mat-primary]': 'color === "primary"',
897 '[class.mat-accent]': 'color === "accent"',
898 '[class.mat-warn]': 'color === "warn"',
899 // Needs to be removed since it causes some a11y issues (see #21266).
900 '[attr.tabindex]': 'null',
901 '[attr.id]': 'id',
902 '[attr.aria-label]': 'null',
903 '[attr.aria-labelledby]': 'null',
904 '[attr.aria-describedby]': 'null',
905 // Note: under normal conditions focus shouldn't land on this element, however it may be
906 // programmatically set, for example inside of a focus trap, in this case we want to forward
907 // the focus to the native element.
908 '(focus)': '_inputElement.nativeElement.focus()',
909 },
910 changeDetection: core.ChangeDetectionStrategy.OnPush,
911 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;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;-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;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{bottom:0;left:50%}.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}\n"]
912 },] }
913 ];
914 MatRadioButton.ctorParameters = function () { return [
915 { type: MatRadioGroup, decorators: [{ type: core.Optional }, { type: core.Inject, args: [MAT_RADIO_GROUP,] }] },
916 { type: core.ElementRef },
917 { type: core.ChangeDetectorRef },
918 { type: a11y.FocusMonitor },
919 { type: collections.UniqueSelectionDispatcher },
920 { type: String, decorators: [{ type: core.Optional }, { type: core.Inject, args: [animations.ANIMATION_MODULE_TYPE,] }] },
921 { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [MAT_RADIO_DEFAULT_OPTIONS,] }] },
922 { type: String, decorators: [{ type: core.Attribute, args: ['tabindex',] }] }
923 ]; };
924
925 /**
926 * @license
927 * Copyright Google LLC All Rights Reserved.
928 *
929 * Use of this source code is governed by an MIT-style license that can be
930 * found in the LICENSE file at https://angular.io/license
931 */
932 var MatRadioModule = /** @class */ (function () {
933 function MatRadioModule() {
934 }
935 return MatRadioModule;
936 }());
937 MatRadioModule.decorators = [
938 { type: core.NgModule, args: [{
939 imports: [core$1.MatRippleModule, core$1.MatCommonModule],
940 exports: [MatRadioGroup, MatRadioButton, core$1.MatCommonModule],
941 declarations: [MatRadioGroup, MatRadioButton],
942 },] }
943 ];
944
945 /**
946 * @license
947 * Copyright Google LLC All Rights Reserved.
948 *
949 * Use of this source code is governed by an MIT-style license that can be
950 * found in the LICENSE file at https://angular.io/license
951 */
952
953 /**
954 * Generated bundle index. Do not edit.
955 */
956
957 exports.MAT_RADIO_DEFAULT_OPTIONS = MAT_RADIO_DEFAULT_OPTIONS;
958 exports.MAT_RADIO_DEFAULT_OPTIONS_FACTORY = MAT_RADIO_DEFAULT_OPTIONS_FACTORY;
959 exports.MAT_RADIO_GROUP = MAT_RADIO_GROUP;
960 exports.MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR = MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR;
961 exports.MatRadioButton = MatRadioButton;
962 exports.MatRadioChange = MatRadioChange;
963 exports.MatRadioGroup = MatRadioGroup;
964 exports.MatRadioModule = MatRadioModule;
965 exports._MatRadioButtonBase = _MatRadioButtonBase;
966 exports._MatRadioGroupBase = _MatRadioGroupBase;
967
968 Object.defineProperty(exports, '__esModule', { value: true });
969
970})));
971//# sourceMappingURL=material-radio.umd.js.map
Note: See TracBrowser for help on using the repository browser.