UNPKG

81.9 kBJavaScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://github.com/material-components/material-components-web/blob/master/LICENSE
7 */
8(function webpackUniversalModuleDefinition(root, factory) {
9 if(typeof exports === 'object' && typeof module === 'object')
10 module.exports = factory();
11 else if(typeof define === 'function' && define.amd)
12 define("@material/radio", [], factory);
13 else if(typeof exports === 'object')
14 exports["radio"] = factory();
15 else
16 root["mdc"] = root["mdc"] || {}, root["mdc"]["radio"] = factory();
17})(this, function() {
18return /******/ (function(modules) { // webpackBootstrap
19/******/ // The module cache
20/******/ var installedModules = {};
21/******/
22/******/ // The require function
23/******/ function __webpack_require__(moduleId) {
24/******/
25/******/ // Check if module is in cache
26/******/ if(installedModules[moduleId]) {
27/******/ return installedModules[moduleId].exports;
28/******/ }
29/******/ // Create a new module (and put it into the cache)
30/******/ var module = installedModules[moduleId] = {
31/******/ i: moduleId,
32/******/ l: false,
33/******/ exports: {}
34/******/ };
35/******/
36/******/ // Execute the module function
37/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
38/******/
39/******/ // Flag the module as loaded
40/******/ module.l = true;
41/******/
42/******/ // Return the exports of the module
43/******/ return module.exports;
44/******/ }
45/******/
46/******/
47/******/ // expose the modules object (__webpack_modules__)
48/******/ __webpack_require__.m = modules;
49/******/
50/******/ // expose the module cache
51/******/ __webpack_require__.c = installedModules;
52/******/
53/******/ // define getter function for harmony exports
54/******/ __webpack_require__.d = function(exports, name, getter) {
55/******/ if(!__webpack_require__.o(exports, name)) {
56/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
57/******/ }
58/******/ };
59/******/
60/******/ // define __esModule on exports
61/******/ __webpack_require__.r = function(exports) {
62/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
63/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
64/******/ }
65/******/ Object.defineProperty(exports, '__esModule', { value: true });
66/******/ };
67/******/
68/******/ // create a fake namespace object
69/******/ // mode & 1: value is a module id, require it
70/******/ // mode & 2: merge all properties of value into the ns
71/******/ // mode & 4: return value when already ns object
72/******/ // mode & 8|1: behave like require
73/******/ __webpack_require__.t = function(value, mode) {
74/******/ if(mode & 1) value = __webpack_require__(value);
75/******/ if(mode & 8) return value;
76/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
77/******/ var ns = Object.create(null);
78/******/ __webpack_require__.r(ns);
79/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
80/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
81/******/ return ns;
82/******/ };
83/******/
84/******/ // getDefaultExport function for compatibility with non-harmony modules
85/******/ __webpack_require__.n = function(module) {
86/******/ var getter = module && module.__esModule ?
87/******/ function getDefault() { return module['default']; } :
88/******/ function getModuleExports() { return module; };
89/******/ __webpack_require__.d(getter, 'a', getter);
90/******/ return getter;
91/******/ };
92/******/
93/******/ // Object.prototype.hasOwnProperty.call
94/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
95/******/
96/******/ // __webpack_public_path__
97/******/ __webpack_require__.p = "";
98/******/
99/******/
100/******/ // Load entry module and return exports
101/******/ return __webpack_require__(__webpack_require__.s = "./packages/mdc-radio/index.ts");
102/******/ })
103/************************************************************************/
104/******/ ({
105
106/***/ "./packages/mdc-base/component.ts":
107/*!****************************************!*\
108 !*** ./packages/mdc-base/component.ts ***!
109 \****************************************/
110/*! no static exports found */
111/***/ (function(module, exports, __webpack_require__) {
112
113"use strict";
114
115/**
116 * @license
117 * Copyright 2016 Google Inc.
118 *
119 * Permission is hereby granted, free of charge, to any person obtaining a copy
120 * of this software and associated documentation files (the "Software"), to deal
121 * in the Software without restriction, including without limitation the rights
122 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
123 * copies of the Software, and to permit persons to whom the Software is
124 * furnished to do so, subject to the following conditions:
125 *
126 * The above copyright notice and this permission notice shall be included in
127 * all copies or substantial portions of the Software.
128 *
129 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
130 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
131 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
132 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
133 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
134 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
135 * THE SOFTWARE.
136 */
137
138var __read = this && this.__read || function (o, n) {
139 var m = typeof Symbol === "function" && o[Symbol.iterator];
140 if (!m) return o;
141 var i = m.call(o),
142 r,
143 ar = [],
144 e;
145 try {
146 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
147 ar.push(r.value);
148 }
149 } catch (error) {
150 e = { error: error };
151 } finally {
152 try {
153 if (r && !r.done && (m = i["return"])) m.call(i);
154 } finally {
155 if (e) throw e.error;
156 }
157 }
158 return ar;
159};
160var __spreadArray = this && this.__spreadArray || function (to, from) {
161 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
162 to[j] = from[i];
163 }return to;
164};
165Object.defineProperty(exports, "__esModule", { value: true });
166exports.MDCComponent = void 0;
167var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts");
168var MDCComponent = /** @class */function () {
169 function MDCComponent(root, foundation) {
170 var args = [];
171 for (var _i = 2; _i < arguments.length; _i++) {
172 args[_i - 2] = arguments[_i];
173 }
174 this.root = root;
175 this.initialize.apply(this, __spreadArray([], __read(args)));
176 // Note that we initialize foundation here and not within the constructor's
177 // default param so that this.root is defined and can be used within the
178 // foundation class.
179 this.foundation = foundation === undefined ? this.getDefaultFoundation() : foundation;
180 this.foundation.init();
181 this.initialSyncWithDOM();
182 }
183 MDCComponent.attachTo = function (root) {
184 // Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and
185 // returns an instantiated component with its root set to that element. Also note that in the cases of
186 // subclasses, an explicit foundation class will not have to be passed in; it will simply be initialized
187 // from getDefaultFoundation().
188 return new MDCComponent(root, new foundation_1.MDCFoundation({}));
189 };
190 /* istanbul ignore next: method param only exists for typing purposes; it does not need to be unit tested */
191 MDCComponent.prototype.initialize = function () {
192 var _args = [];
193 for (var _i = 0; _i < arguments.length; _i++) {
194 _args[_i] = arguments[_i];
195 }
196 // Subclasses can override this to do any additional setup work that would be considered part of a
197 // "constructor". Essentially, it is a hook into the parent constructor before the foundation is
198 // initialized. Any additional arguments besides root and foundation will be passed in here.
199 };
200 MDCComponent.prototype.getDefaultFoundation = function () {
201 // Subclasses must override this method to return a properly configured foundation class for the
202 // component.
203 throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
204 };
205 MDCComponent.prototype.initialSyncWithDOM = function () {
206 // Subclasses should override this method if they need to perform work to synchronize with a host DOM
207 // object. An example of this would be a form control wrapper that needs to synchronize its internal state
208 // to some property or attribute of the host DOM. Please note: this is *not* the place to perform DOM
209 // reads/writes that would cause layout / paint, as this is called synchronously from within the constructor.
210 };
211 MDCComponent.prototype.destroy = function () {
212 // Subclasses may implement this method to release any resources / deregister any listeners they have
213 // attached. An example of this might be deregistering a resize event from the window object.
214 this.foundation.destroy();
215 };
216 MDCComponent.prototype.listen = function (evtType, handler, options) {
217 this.root.addEventListener(evtType, handler, options);
218 };
219 MDCComponent.prototype.unlisten = function (evtType, handler, options) {
220 this.root.removeEventListener(evtType, handler, options);
221 };
222 /**
223 * Fires a cross-browser-compatible custom event from the component root of the given type, with the given data.
224 */
225 MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) {
226 if (shouldBubble === void 0) {
227 shouldBubble = false;
228 }
229 var evt;
230 if (typeof CustomEvent === 'function') {
231 evt = new CustomEvent(evtType, {
232 bubbles: shouldBubble,
233 detail: evtData
234 });
235 } else {
236 evt = document.createEvent('CustomEvent');
237 evt.initCustomEvent(evtType, shouldBubble, false, evtData);
238 }
239 this.root.dispatchEvent(evt);
240 };
241 return MDCComponent;
242}();
243exports.MDCComponent = MDCComponent;
244// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
245exports.default = MDCComponent;
246
247/***/ }),
248
249/***/ "./packages/mdc-base/foundation.ts":
250/*!*****************************************!*\
251 !*** ./packages/mdc-base/foundation.ts ***!
252 \*****************************************/
253/*! no static exports found */
254/***/ (function(module, exports, __webpack_require__) {
255
256"use strict";
257
258/**
259 * @license
260 * Copyright 2016 Google Inc.
261 *
262 * Permission is hereby granted, free of charge, to any person obtaining a copy
263 * of this software and associated documentation files (the "Software"), to deal
264 * in the Software without restriction, including without limitation the rights
265 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
266 * copies of the Software, and to permit persons to whom the Software is
267 * furnished to do so, subject to the following conditions:
268 *
269 * The above copyright notice and this permission notice shall be included in
270 * all copies or substantial portions of the Software.
271 *
272 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
273 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
274 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
275 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
276 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
277 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
278 * THE SOFTWARE.
279 */
280
281Object.defineProperty(exports, "__esModule", { value: true });
282exports.MDCFoundation = void 0;
283var MDCFoundation = /** @class */function () {
284 function MDCFoundation(adapter) {
285 if (adapter === void 0) {
286 adapter = {};
287 }
288 this.adapter = adapter;
289 }
290 Object.defineProperty(MDCFoundation, "cssClasses", {
291 get: function get() {
292 // Classes extending MDCFoundation should implement this method to return an object which exports every
293 // CSS class the foundation class needs as a property. e.g. {ACTIVE: 'mdc-component--active'}
294 return {};
295 },
296 enumerable: false,
297 configurable: true
298 });
299 Object.defineProperty(MDCFoundation, "strings", {
300 get: function get() {
301 // Classes extending MDCFoundation should implement this method to return an object which exports all
302 // semantic strings as constants. e.g. {ARIA_ROLE: 'tablist'}
303 return {};
304 },
305 enumerable: false,
306 configurable: true
307 });
308 Object.defineProperty(MDCFoundation, "numbers", {
309 get: function get() {
310 // Classes extending MDCFoundation should implement this method to return an object which exports all
311 // of its semantic numbers as constants. e.g. {ANIMATION_DELAY_MS: 350}
312 return {};
313 },
314 enumerable: false,
315 configurable: true
316 });
317 Object.defineProperty(MDCFoundation, "defaultAdapter", {
318 get: function get() {
319 // Classes extending MDCFoundation may choose to implement this getter in order to provide a convenient
320 // way of viewing the necessary methods of an adapter. In the future, this could also be used for adapter
321 // validation.
322 return {};
323 },
324 enumerable: false,
325 configurable: true
326 });
327 MDCFoundation.prototype.init = function () {
328 // Subclasses should override this method to perform initialization routines (registering events, etc.)
329 };
330 MDCFoundation.prototype.destroy = function () {
331 // Subclasses should override this method to perform de-initialization routines (de-registering events, etc.)
332 };
333 return MDCFoundation;
334}();
335exports.MDCFoundation = MDCFoundation;
336// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
337exports.default = MDCFoundation;
338
339/***/ }),
340
341/***/ "./packages/mdc-dom/events.ts":
342/*!************************************!*\
343 !*** ./packages/mdc-dom/events.ts ***!
344 \************************************/
345/*! no static exports found */
346/***/ (function(module, exports, __webpack_require__) {
347
348"use strict";
349
350/**
351 * @license
352 * Copyright 2019 Google Inc.
353 *
354 * Permission is hereby granted, free of charge, to any person obtaining a copy
355 * of this software and associated documentation files (the "Software"), to deal
356 * in the Software without restriction, including without limitation the rights
357 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
358 * copies of the Software, and to permit persons to whom the Software is
359 * furnished to do so, subject to the following conditions:
360 *
361 * The above copyright notice and this permission notice shall be included in
362 * all copies or substantial portions of the Software.
363 *
364 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
365 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
366 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
367 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
368 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
369 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
370 * THE SOFTWARE.
371 */
372
373Object.defineProperty(exports, "__esModule", { value: true });
374exports.applyPassive = void 0;
375/**
376 * Determine whether the current browser supports passive event listeners, and
377 * if so, use them.
378 */
379function applyPassive(globalObj) {
380 if (globalObj === void 0) {
381 globalObj = window;
382 }
383 return supportsPassiveOption(globalObj) ? { passive: true } : false;
384}
385exports.applyPassive = applyPassive;
386function supportsPassiveOption(globalObj) {
387 if (globalObj === void 0) {
388 globalObj = window;
389 }
390 // See
391 // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
392 var passiveSupported = false;
393 try {
394 var options = {
395 // This function will be called when the browser
396 // attempts to access the passive property.
397 get passive() {
398 passiveSupported = true;
399 return false;
400 }
401 };
402 var handler = function handler() {};
403 globalObj.document.addEventListener('test', handler, options);
404 globalObj.document.removeEventListener('test', handler, options);
405 } catch (err) {
406 passiveSupported = false;
407 }
408 return passiveSupported;
409}
410
411/***/ }),
412
413/***/ "./packages/mdc-dom/ponyfill.ts":
414/*!**************************************!*\
415 !*** ./packages/mdc-dom/ponyfill.ts ***!
416 \**************************************/
417/*! no static exports found */
418/***/ (function(module, exports, __webpack_require__) {
419
420"use strict";
421
422/**
423 * @license
424 * Copyright 2018 Google Inc.
425 *
426 * Permission is hereby granted, free of charge, to any person obtaining a copy
427 * of this software and associated documentation files (the "Software"), to deal
428 * in the Software without restriction, including without limitation the rights
429 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
430 * copies of the Software, and to permit persons to whom the Software is
431 * furnished to do so, subject to the following conditions:
432 *
433 * The above copyright notice and this permission notice shall be included in
434 * all copies or substantial portions of the Software.
435 *
436 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
437 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
438 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
439 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
440 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
441 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
442 * THE SOFTWARE.
443 */
444
445Object.defineProperty(exports, "__esModule", { value: true });
446exports.estimateScrollWidth = exports.matches = exports.closest = void 0;
447/**
448 * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global prototype chain.
449 * This makes ponyfills safer than traditional polyfills, especially for libraries like MDC.
450 */
451function closest(element, selector) {
452 if (element.closest) {
453 return element.closest(selector);
454 }
455 var el = element;
456 while (el) {
457 if (matches(el, selector)) {
458 return el;
459 }
460 el = el.parentElement;
461 }
462 return null;
463}
464exports.closest = closest;
465function matches(element, selector) {
466 var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
467 return nativeMatches.call(element, selector);
468}
469exports.matches = matches;
470/**
471 * Used to compute the estimated scroll width of elements. When an element is
472 * hidden due to display: none; being applied to a parent element, the width is
473 * returned as 0. However, the element will have a true width once no longer
474 * inside a display: none context. This method computes an estimated width when
475 * the element is hidden or returns the true width when the element is visble.
476 * @param {Element} element the element whose width to estimate
477 */
478function estimateScrollWidth(element) {
479 // Check the offsetParent. If the element inherits display: none from any
480 // parent, the offsetParent property will be null (see
481 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent).
482 // This check ensures we only clone the node when necessary.
483 var htmlEl = element;
484 if (htmlEl.offsetParent !== null) {
485 return htmlEl.scrollWidth;
486 }
487 var clone = htmlEl.cloneNode(true);
488 clone.style.setProperty('position', 'absolute');
489 clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
490 document.documentElement.appendChild(clone);
491 var scrollWidth = clone.scrollWidth;
492 document.documentElement.removeChild(clone);
493 return scrollWidth;
494}
495exports.estimateScrollWidth = estimateScrollWidth;
496
497/***/ }),
498
499/***/ "./packages/mdc-radio/adapter.ts":
500/*!***************************************!*\
501 !*** ./packages/mdc-radio/adapter.ts ***!
502 \***************************************/
503/*! no static exports found */
504/***/ (function(module, exports, __webpack_require__) {
505
506"use strict";
507
508/**
509 * @license
510 * Copyright 2016 Google Inc.
511 *
512 * Permission is hereby granted, free of charge, to any person obtaining a copy
513 * of this software and associated documentation files (the "Software"), to deal
514 * in the Software without restriction, including without limitation the rights
515 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
516 * copies of the Software, and to permit persons to whom the Software is
517 * furnished to do so, subject to the following conditions:
518 *
519 * The above copyright notice and this permission notice shall be included in
520 * all copies or substantial portions of the Software.
521 *
522 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
523 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
524 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
525 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
526 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
527 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
528 * THE SOFTWARE.
529 */
530
531Object.defineProperty(exports, "__esModule", { value: true });
532
533/***/ }),
534
535/***/ "./packages/mdc-radio/component.ts":
536/*!*****************************************!*\
537 !*** ./packages/mdc-radio/component.ts ***!
538 \*****************************************/
539/*! no static exports found */
540/***/ (function(module, exports, __webpack_require__) {
541
542"use strict";
543
544/**
545 * @license
546 * Copyright 2016 Google Inc.
547 *
548 * Permission is hereby granted, free of charge, to any person obtaining a copy
549 * of this software and associated documentation files (the "Software"), to deal
550 * in the Software without restriction, including without limitation the rights
551 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
552 * copies of the Software, and to permit persons to whom the Software is
553 * furnished to do so, subject to the following conditions:
554 *
555 * The above copyright notice and this permission notice shall be included in
556 * all copies or substantial portions of the Software.
557 *
558 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
559 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
560 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
561 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
562 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
563 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
564 * THE SOFTWARE.
565 */
566
567var __extends = this && this.__extends || function () {
568 var _extendStatics = function extendStatics(d, b) {
569 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
570 d.__proto__ = b;
571 } || function (d, b) {
572 for (var p in b) {
573 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
574 }
575 };
576 return _extendStatics(d, b);
577 };
578 return function (d, b) {
579 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
580 _extendStatics(d, b);
581 function __() {
582 this.constructor = d;
583 }
584 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
585 };
586}();
587var __assign = this && this.__assign || function () {
588 __assign = Object.assign || function (t) {
589 for (var s, i = 1, n = arguments.length; i < n; i++) {
590 s = arguments[i];
591 for (var p in s) {
592 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
593 }
594 }
595 return t;
596 };
597 return __assign.apply(this, arguments);
598};
599Object.defineProperty(exports, "__esModule", { value: true });
600exports.MDCRadio = void 0;
601var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
602var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
603var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
604var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
605var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-radio/foundation.ts");
606var MDCRadio = /** @class */function (_super) {
607 __extends(MDCRadio, _super);
608 function MDCRadio() {
609 var _this = _super !== null && _super.apply(this, arguments) || this;
610 _this.rippleSurface = _this.createRipple();
611 return _this;
612 }
613 MDCRadio.attachTo = function (root) {
614 return new MDCRadio(root);
615 };
616 Object.defineProperty(MDCRadio.prototype, "checked", {
617 get: function get() {
618 return this.nativeControl.checked;
619 },
620 set: function set(checked) {
621 this.nativeControl.checked = checked;
622 },
623 enumerable: false,
624 configurable: true
625 });
626 Object.defineProperty(MDCRadio.prototype, "disabled", {
627 get: function get() {
628 return this.nativeControl.disabled;
629 },
630 set: function set(disabled) {
631 this.foundation.setDisabled(disabled);
632 },
633 enumerable: false,
634 configurable: true
635 });
636 Object.defineProperty(MDCRadio.prototype, "value", {
637 get: function get() {
638 return this.nativeControl.value;
639 },
640 set: function set(value) {
641 this.nativeControl.value = value;
642 },
643 enumerable: false,
644 configurable: true
645 });
646 Object.defineProperty(MDCRadio.prototype, "ripple", {
647 get: function get() {
648 return this.rippleSurface;
649 },
650 enumerable: false,
651 configurable: true
652 });
653 MDCRadio.prototype.destroy = function () {
654 this.rippleSurface.destroy();
655 _super.prototype.destroy.call(this);
656 };
657 MDCRadio.prototype.getDefaultFoundation = function () {
658 var _this = this;
659 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
660 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
661 var adapter = {
662 addClass: function addClass(className) {
663 return _this.root.classList.add(className);
664 },
665 removeClass: function removeClass(className) {
666 return _this.root.classList.remove(className);
667 },
668 setNativeControlDisabled: function setNativeControlDisabled(disabled) {
669 return _this.nativeControl.disabled = disabled;
670 }
671 };
672 return new foundation_2.MDCRadioFoundation(adapter);
673 };
674 MDCRadio.prototype.createRipple = function () {
675 var _this = this;
676 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
677 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
678 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
679 var adapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
680 _this.nativeControl.addEventListener(evtType, handler, events_1.applyPassive());
681 }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
682 _this.nativeControl.removeEventListener(evtType, handler, events_1.applyPassive());
683 },
684 // Radio buttons technically go "active" whenever there is *any* keyboard
685 // interaction. This is not the UI we desire.
686 isSurfaceActive: function isSurfaceActive() {
687 return false;
688 }, isUnbounded: function isUnbounded() {
689 return true;
690 } });
691 // tslint:enable:object-literal-sort-keys
692 return new component_2.MDCRipple(this.root, new foundation_1.MDCRippleFoundation(adapter));
693 };
694 Object.defineProperty(MDCRadio.prototype, "nativeControl", {
695 get: function get() {
696 var NATIVE_CONTROL_SELECTOR = foundation_2.MDCRadioFoundation.strings.NATIVE_CONTROL_SELECTOR;
697 var el = this.root.querySelector(NATIVE_CONTROL_SELECTOR);
698 if (!el) {
699 throw new Error("Radio component requires a " + NATIVE_CONTROL_SELECTOR + " element");
700 }
701 return el;
702 },
703 enumerable: false,
704 configurable: true
705 });
706 return MDCRadio;
707}(component_1.MDCComponent);
708exports.MDCRadio = MDCRadio;
709
710/***/ }),
711
712/***/ "./packages/mdc-radio/constants.ts":
713/*!*****************************************!*\
714 !*** ./packages/mdc-radio/constants.ts ***!
715 \*****************************************/
716/*! no static exports found */
717/***/ (function(module, exports, __webpack_require__) {
718
719"use strict";
720
721/**
722 * @license
723 * Copyright 2016 Google Inc.
724 *
725 * Permission is hereby granted, free of charge, to any person obtaining a copy
726 * of this software and associated documentation files (the "Software"), to deal
727 * in the Software without restriction, including without limitation the rights
728 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
729 * copies of the Software, and to permit persons to whom the Software is
730 * furnished to do so, subject to the following conditions:
731 *
732 * The above copyright notice and this permission notice shall be included in
733 * all copies or substantial portions of the Software.
734 *
735 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
736 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
737 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
738 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
739 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
740 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
741 * THE SOFTWARE.
742 */
743
744Object.defineProperty(exports, "__esModule", { value: true });
745exports.cssClasses = exports.strings = void 0;
746var strings = {
747 NATIVE_CONTROL_SELECTOR: '.mdc-radio__native-control'
748};
749exports.strings = strings;
750var cssClasses = {
751 DISABLED: 'mdc-radio--disabled',
752 ROOT: 'mdc-radio'
753};
754exports.cssClasses = cssClasses;
755
756/***/ }),
757
758/***/ "./packages/mdc-radio/foundation.ts":
759/*!******************************************!*\
760 !*** ./packages/mdc-radio/foundation.ts ***!
761 \******************************************/
762/*! no static exports found */
763/***/ (function(module, exports, __webpack_require__) {
764
765"use strict";
766
767/**
768 * @license
769 * Copyright 2016 Google Inc.
770 *
771 * Permission is hereby granted, free of charge, to any person obtaining a copy
772 * of this software and associated documentation files (the "Software"), to deal
773 * in the Software without restriction, including without limitation the rights
774 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
775 * copies of the Software, and to permit persons to whom the Software is
776 * furnished to do so, subject to the following conditions:
777 *
778 * The above copyright notice and this permission notice shall be included in
779 * all copies or substantial portions of the Software.
780 *
781 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
782 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
783 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
784 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
785 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
786 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
787 * THE SOFTWARE.
788 */
789
790var __extends = this && this.__extends || function () {
791 var _extendStatics = function extendStatics(d, b) {
792 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
793 d.__proto__ = b;
794 } || function (d, b) {
795 for (var p in b) {
796 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
797 }
798 };
799 return _extendStatics(d, b);
800 };
801 return function (d, b) {
802 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
803 _extendStatics(d, b);
804 function __() {
805 this.constructor = d;
806 }
807 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
808 };
809}();
810var __assign = this && this.__assign || function () {
811 __assign = Object.assign || function (t) {
812 for (var s, i = 1, n = arguments.length; i < n; i++) {
813 s = arguments[i];
814 for (var p in s) {
815 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
816 }
817 }
818 return t;
819 };
820 return __assign.apply(this, arguments);
821};
822Object.defineProperty(exports, "__esModule", { value: true });
823exports.MDCRadioFoundation = void 0;
824var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
825var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-radio/constants.ts");
826var MDCRadioFoundation = /** @class */function (_super) {
827 __extends(MDCRadioFoundation, _super);
828 function MDCRadioFoundation(adapter) {
829 return _super.call(this, __assign(__assign({}, MDCRadioFoundation.defaultAdapter), adapter)) || this;
830 }
831 Object.defineProperty(MDCRadioFoundation, "cssClasses", {
832 get: function get() {
833 return constants_1.cssClasses;
834 },
835 enumerable: false,
836 configurable: true
837 });
838 Object.defineProperty(MDCRadioFoundation, "strings", {
839 get: function get() {
840 return constants_1.strings;
841 },
842 enumerable: false,
843 configurable: true
844 });
845 Object.defineProperty(MDCRadioFoundation, "defaultAdapter", {
846 get: function get() {
847 return {
848 addClass: function addClass() {
849 return undefined;
850 },
851 removeClass: function removeClass() {
852 return undefined;
853 },
854 setNativeControlDisabled: function setNativeControlDisabled() {
855 return undefined;
856 }
857 };
858 },
859 enumerable: false,
860 configurable: true
861 });
862 MDCRadioFoundation.prototype.setDisabled = function (disabled) {
863 var DISABLED = MDCRadioFoundation.cssClasses.DISABLED;
864 this.adapter.setNativeControlDisabled(disabled);
865 if (disabled) {
866 this.adapter.addClass(DISABLED);
867 } else {
868 this.adapter.removeClass(DISABLED);
869 }
870 };
871 return MDCRadioFoundation;
872}(foundation_1.MDCFoundation);
873exports.MDCRadioFoundation = MDCRadioFoundation;
874// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
875exports.default = MDCRadioFoundation;
876
877/***/ }),
878
879/***/ "./packages/mdc-radio/index.ts":
880/*!*************************************!*\
881 !*** ./packages/mdc-radio/index.ts ***!
882 \*************************************/
883/*! no static exports found */
884/***/ (function(module, exports, __webpack_require__) {
885
886"use strict";
887
888/**
889 * @license
890 * Copyright 2019 Google Inc.
891 *
892 * Permission is hereby granted, free of charge, to any person obtaining a copy
893 * of this software and associated documentation files (the "Software"), to deal
894 * in the Software without restriction, including without limitation the rights
895 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
896 * copies of the Software, and to permit persons to whom the Software is
897 * furnished to do so, subject to the following conditions:
898 *
899 * The above copyright notice and this permission notice shall be included in
900 * all copies or substantial portions of the Software.
901 *
902 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
903 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
904 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
905 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
906 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
907 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
908 * THE SOFTWARE.
909 */
910
911var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
912 if (k2 === undefined) k2 = k;
913 Object.defineProperty(o, k2, { enumerable: true, get: function get() {
914 return m[k];
915 } });
916} : function (o, m, k, k2) {
917 if (k2 === undefined) k2 = k;
918 o[k2] = m[k];
919});
920var __exportStar = this && this.__exportStar || function (m, exports) {
921 for (var p in m) {
922 if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
923 }
924};
925Object.defineProperty(exports, "__esModule", { value: true });
926__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-radio/adapter.ts"), exports);
927__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-radio/component.ts"), exports);
928__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-radio/constants.ts"), exports);
929__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-radio/foundation.ts"), exports);
930
931/***/ }),
932
933/***/ "./packages/mdc-ripple/component.ts":
934/*!******************************************!*\
935 !*** ./packages/mdc-ripple/component.ts ***!
936 \******************************************/
937/*! no static exports found */
938/***/ (function(module, exports, __webpack_require__) {
939
940"use strict";
941
942/**
943 * @license
944 * Copyright 2016 Google Inc.
945 *
946 * Permission is hereby granted, free of charge, to any person obtaining a copy
947 * of this software and associated documentation files (the "Software"), to deal
948 * in the Software without restriction, including without limitation the rights
949 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
950 * copies of the Software, and to permit persons to whom the Software is
951 * furnished to do so, subject to the following conditions:
952 *
953 * The above copyright notice and this permission notice shall be included in
954 * all copies or substantial portions of the Software.
955 *
956 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
957 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
958 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
959 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
960 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
961 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
962 * THE SOFTWARE.
963 */
964
965var __extends = this && this.__extends || function () {
966 var _extendStatics = function extendStatics(d, b) {
967 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
968 d.__proto__ = b;
969 } || function (d, b) {
970 for (var p in b) {
971 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
972 }
973 };
974 return _extendStatics(d, b);
975 };
976 return function (d, b) {
977 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
978 _extendStatics(d, b);
979 function __() {
980 this.constructor = d;
981 }
982 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
983 };
984}();
985var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
986 if (k2 === undefined) k2 = k;
987 Object.defineProperty(o, k2, { enumerable: true, get: function get() {
988 return m[k];
989 } });
990} : function (o, m, k, k2) {
991 if (k2 === undefined) k2 = k;
992 o[k2] = m[k];
993});
994var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
995 Object.defineProperty(o, "default", { enumerable: true, value: v });
996} : function (o, v) {
997 o["default"] = v;
998});
999var __importStar = this && this.__importStar || function (mod) {
1000 if (mod && mod.__esModule) return mod;
1001 var result = {};
1002 if (mod != null) for (var k in mod) {
1003 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1004 }__setModuleDefault(result, mod);
1005 return result;
1006};
1007Object.defineProperty(exports, "__esModule", { value: true });
1008exports.MDCRipple = void 0;
1009var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
1010var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
1011var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
1012var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts");
1013var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
1014var MDCRipple = /** @class */function (_super) {
1015 __extends(MDCRipple, _super);
1016 function MDCRipple() {
1017 var _this = _super !== null && _super.apply(this, arguments) || this;
1018 _this.disabled = false;
1019 return _this;
1020 }
1021 MDCRipple.attachTo = function (root, opts) {
1022 if (opts === void 0) {
1023 opts = {
1024 isUnbounded: undefined
1025 };
1026 }
1027 var ripple = new MDCRipple(root);
1028 // Only override unbounded behavior if option is explicitly specified
1029 if (opts.isUnbounded !== undefined) {
1030 ripple.unbounded = opts.isUnbounded;
1031 }
1032 return ripple;
1033 };
1034 MDCRipple.createAdapter = function (instance) {
1035 return {
1036 addClass: function addClass(className) {
1037 return instance.root.classList.add(className);
1038 },
1039 browserSupportsCssVars: function browserSupportsCssVars() {
1040 return util.supportsCssVariables(window);
1041 },
1042 computeBoundingRect: function computeBoundingRect() {
1043 return instance.root.getBoundingClientRect();
1044 },
1045 containsEventTarget: function containsEventTarget(target) {
1046 return instance.root.contains(target);
1047 },
1048 deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler(evtType, handler) {
1049 return document.documentElement.removeEventListener(evtType, handler, events_1.applyPassive());
1050 },
1051 deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
1052 return instance.root.removeEventListener(evtType, handler, events_1.applyPassive());
1053 },
1054 deregisterResizeHandler: function deregisterResizeHandler(handler) {
1055 return window.removeEventListener('resize', handler);
1056 },
1057 getWindowPageOffset: function getWindowPageOffset() {
1058 return { x: window.pageXOffset, y: window.pageYOffset };
1059 },
1060 isSurfaceActive: function isSurfaceActive() {
1061 return ponyfill_1.matches(instance.root, ':active');
1062 },
1063 isSurfaceDisabled: function isSurfaceDisabled() {
1064 return Boolean(instance.disabled);
1065 },
1066 isUnbounded: function isUnbounded() {
1067 return Boolean(instance.unbounded);
1068 },
1069 registerDocumentInteractionHandler: function registerDocumentInteractionHandler(evtType, handler) {
1070 return document.documentElement.addEventListener(evtType, handler, events_1.applyPassive());
1071 },
1072 registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
1073 return instance.root.addEventListener(evtType, handler, events_1.applyPassive());
1074 },
1075 registerResizeHandler: function registerResizeHandler(handler) {
1076 return window.addEventListener('resize', handler);
1077 },
1078 removeClass: function removeClass(className) {
1079 return instance.root.classList.remove(className);
1080 },
1081 updateCssVariable: function updateCssVariable(varName, value) {
1082 return instance.root.style.setProperty(varName, value);
1083 }
1084 };
1085 };
1086 Object.defineProperty(MDCRipple.prototype, "unbounded", {
1087 get: function get() {
1088 return Boolean(this.isUnbounded);
1089 },
1090 set: function set(unbounded) {
1091 this.isUnbounded = Boolean(unbounded);
1092 this.setUnbounded();
1093 },
1094 enumerable: false,
1095 configurable: true
1096 });
1097 MDCRipple.prototype.activate = function () {
1098 this.foundation.activate();
1099 };
1100 MDCRipple.prototype.deactivate = function () {
1101 this.foundation.deactivate();
1102 };
1103 MDCRipple.prototype.layout = function () {
1104 this.foundation.layout();
1105 };
1106 MDCRipple.prototype.getDefaultFoundation = function () {
1107 return new foundation_1.MDCRippleFoundation(MDCRipple.createAdapter(this));
1108 };
1109 MDCRipple.prototype.initialSyncWithDOM = function () {
1110 var root = this.root;
1111 this.isUnbounded = 'mdcRippleIsUnbounded' in root.dataset;
1112 };
1113 /**
1114 * Closure Compiler throws an access control error when directly accessing a
1115 * protected or private property inside a getter/setter, like unbounded above.
1116 * By accessing the protected property inside a method, we solve that problem.
1117 * That's why this function exists.
1118 */
1119 MDCRipple.prototype.setUnbounded = function () {
1120 this.foundation.setUnbounded(Boolean(this.isUnbounded));
1121 };
1122 return MDCRipple;
1123}(component_1.MDCComponent);
1124exports.MDCRipple = MDCRipple;
1125
1126/***/ }),
1127
1128/***/ "./packages/mdc-ripple/constants.ts":
1129/*!******************************************!*\
1130 !*** ./packages/mdc-ripple/constants.ts ***!
1131 \******************************************/
1132/*! no static exports found */
1133/***/ (function(module, exports, __webpack_require__) {
1134
1135"use strict";
1136
1137/**
1138 * @license
1139 * Copyright 2016 Google Inc.
1140 *
1141 * Permission is hereby granted, free of charge, to any person obtaining a copy
1142 * of this software and associated documentation files (the "Software"), to deal
1143 * in the Software without restriction, including without limitation the rights
1144 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1145 * copies of the Software, and to permit persons to whom the Software is
1146 * furnished to do so, subject to the following conditions:
1147 *
1148 * The above copyright notice and this permission notice shall be included in
1149 * all copies or substantial portions of the Software.
1150 *
1151 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1152 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1153 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1154 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1155 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1156 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1157 * THE SOFTWARE.
1158 */
1159
1160Object.defineProperty(exports, "__esModule", { value: true });
1161exports.numbers = exports.strings = exports.cssClasses = void 0;
1162exports.cssClasses = {
1163 // Ripple is a special case where the "root" component is really a "mixin" of sorts,
1164 // given that it's an 'upgrade' to an existing component. That being said it is the root
1165 // CSS class that all other CSS classes derive from.
1166 BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
1167 FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
1168 FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation',
1169 ROOT: 'mdc-ripple-upgraded',
1170 UNBOUNDED: 'mdc-ripple-upgraded--unbounded'
1171};
1172exports.strings = {
1173 VAR_FG_SCALE: '--mdc-ripple-fg-scale',
1174 VAR_FG_SIZE: '--mdc-ripple-fg-size',
1175 VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end',
1176 VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
1177 VAR_LEFT: '--mdc-ripple-left',
1178 VAR_TOP: '--mdc-ripple-top'
1179};
1180exports.numbers = {
1181 DEACTIVATION_TIMEOUT_MS: 225,
1182 FG_DEACTIVATION_MS: 150,
1183 INITIAL_ORIGIN_SCALE: 0.6,
1184 PADDING: 10,
1185 TAP_DELAY_MS: 300 };
1186
1187/***/ }),
1188
1189/***/ "./packages/mdc-ripple/foundation.ts":
1190/*!*******************************************!*\
1191 !*** ./packages/mdc-ripple/foundation.ts ***!
1192 \*******************************************/
1193/*! no static exports found */
1194/***/ (function(module, exports, __webpack_require__) {
1195
1196"use strict";
1197
1198/**
1199 * @license
1200 * Copyright 2016 Google Inc.
1201 *
1202 * Permission is hereby granted, free of charge, to any person obtaining a copy
1203 * of this software and associated documentation files (the "Software"), to deal
1204 * in the Software without restriction, including without limitation the rights
1205 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1206 * copies of the Software, and to permit persons to whom the Software is
1207 * furnished to do so, subject to the following conditions:
1208 *
1209 * The above copyright notice and this permission notice shall be included in
1210 * all copies or substantial portions of the Software.
1211 *
1212 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1213 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1214 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1215 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1216 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1217 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1218 * THE SOFTWARE.
1219 */
1220
1221var __extends = this && this.__extends || function () {
1222 var _extendStatics = function extendStatics(d, b) {
1223 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
1224 d.__proto__ = b;
1225 } || function (d, b) {
1226 for (var p in b) {
1227 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
1228 }
1229 };
1230 return _extendStatics(d, b);
1231 };
1232 return function (d, b) {
1233 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1234 _extendStatics(d, b);
1235 function __() {
1236 this.constructor = d;
1237 }
1238 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1239 };
1240}();
1241var __assign = this && this.__assign || function () {
1242 __assign = Object.assign || function (t) {
1243 for (var s, i = 1, n = arguments.length; i < n; i++) {
1244 s = arguments[i];
1245 for (var p in s) {
1246 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1247 }
1248 }
1249 return t;
1250 };
1251 return __assign.apply(this, arguments);
1252};
1253var __values = this && this.__values || function (o) {
1254 var s = typeof Symbol === "function" && Symbol.iterator,
1255 m = s && o[s],
1256 i = 0;
1257 if (m) return m.call(o);
1258 if (o && typeof o.length === "number") return {
1259 next: function next() {
1260 if (o && i >= o.length) o = void 0;
1261 return { value: o && o[i++], done: !o };
1262 }
1263 };
1264 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
1265};
1266Object.defineProperty(exports, "__esModule", { value: true });
1267exports.MDCRippleFoundation = void 0;
1268var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
1269var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts");
1270var util_1 = __webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts");
1271// Activation events registered on the root element of each instance for activation
1272var ACTIVATION_EVENT_TYPES = ['touchstart', 'pointerdown', 'mousedown', 'keydown'];
1273// Deactivation events registered on documentElement when a pointer-related down event occurs
1274var POINTER_DEACTIVATION_EVENT_TYPES = ['touchend', 'pointerup', 'mouseup', 'contextmenu'];
1275// simultaneous nested activations
1276var activatedTargets = [];
1277var MDCRippleFoundation = /** @class */function (_super) {
1278 __extends(MDCRippleFoundation, _super);
1279 function MDCRippleFoundation(adapter) {
1280 var _this = _super.call(this, __assign(__assign({}, MDCRippleFoundation.defaultAdapter), adapter)) || this;
1281 _this.activationAnimationHasEnded = false;
1282 _this.activationTimer = 0;
1283 _this.fgDeactivationRemovalTimer = 0;
1284 _this.fgScale = '0';
1285 _this.frame = { width: 0, height: 0 };
1286 _this.initialSize = 0;
1287 _this.layoutFrame = 0;
1288 _this.maxRadius = 0;
1289 _this.unboundedCoords = { left: 0, top: 0 };
1290 _this.activationState = _this.defaultActivationState();
1291 _this.activationTimerCallback = function () {
1292 _this.activationAnimationHasEnded = true;
1293 _this.runDeactivationUXLogicIfReady();
1294 };
1295 _this.activateHandler = function (e) {
1296 _this.activateImpl(e);
1297 };
1298 _this.deactivateHandler = function () {
1299 _this.deactivateImpl();
1300 };
1301 _this.focusHandler = function () {
1302 _this.handleFocus();
1303 };
1304 _this.blurHandler = function () {
1305 _this.handleBlur();
1306 };
1307 _this.resizeHandler = function () {
1308 _this.layout();
1309 };
1310 return _this;
1311 }
1312 Object.defineProperty(MDCRippleFoundation, "cssClasses", {
1313 get: function get() {
1314 return constants_1.cssClasses;
1315 },
1316 enumerable: false,
1317 configurable: true
1318 });
1319 Object.defineProperty(MDCRippleFoundation, "strings", {
1320 get: function get() {
1321 return constants_1.strings;
1322 },
1323 enumerable: false,
1324 configurable: true
1325 });
1326 Object.defineProperty(MDCRippleFoundation, "numbers", {
1327 get: function get() {
1328 return constants_1.numbers;
1329 },
1330 enumerable: false,
1331 configurable: true
1332 });
1333 Object.defineProperty(MDCRippleFoundation, "defaultAdapter", {
1334 get: function get() {
1335 return {
1336 addClass: function addClass() {
1337 return undefined;
1338 },
1339 browserSupportsCssVars: function browserSupportsCssVars() {
1340 return true;
1341 },
1342 computeBoundingRect: function computeBoundingRect() {
1343 return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
1344 },
1345 containsEventTarget: function containsEventTarget() {
1346 return true;
1347 },
1348 deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() {
1349 return undefined;
1350 },
1351 deregisterInteractionHandler: function deregisterInteractionHandler() {
1352 return undefined;
1353 },
1354 deregisterResizeHandler: function deregisterResizeHandler() {
1355 return undefined;
1356 },
1357 getWindowPageOffset: function getWindowPageOffset() {
1358 return { x: 0, y: 0 };
1359 },
1360 isSurfaceActive: function isSurfaceActive() {
1361 return true;
1362 },
1363 isSurfaceDisabled: function isSurfaceDisabled() {
1364 return true;
1365 },
1366 isUnbounded: function isUnbounded() {
1367 return true;
1368 },
1369 registerDocumentInteractionHandler: function registerDocumentInteractionHandler() {
1370 return undefined;
1371 },
1372 registerInteractionHandler: function registerInteractionHandler() {
1373 return undefined;
1374 },
1375 registerResizeHandler: function registerResizeHandler() {
1376 return undefined;
1377 },
1378 removeClass: function removeClass() {
1379 return undefined;
1380 },
1381 updateCssVariable: function updateCssVariable() {
1382 return undefined;
1383 }
1384 };
1385 },
1386 enumerable: false,
1387 configurable: true
1388 });
1389 MDCRippleFoundation.prototype.init = function () {
1390 var _this = this;
1391 var supportsPressRipple = this.supportsPressRipple();
1392 this.registerRootHandlers(supportsPressRipple);
1393 if (supportsPressRipple) {
1394 var _a = MDCRippleFoundation.cssClasses,
1395 ROOT_1 = _a.ROOT,
1396 UNBOUNDED_1 = _a.UNBOUNDED;
1397 requestAnimationFrame(function () {
1398 _this.adapter.addClass(ROOT_1);
1399 if (_this.adapter.isUnbounded()) {
1400 _this.adapter.addClass(UNBOUNDED_1);
1401 // Unbounded ripples need layout logic applied immediately to set coordinates for both shade and ripple
1402 _this.layoutInternal();
1403 }
1404 });
1405 }
1406 };
1407 MDCRippleFoundation.prototype.destroy = function () {
1408 var _this = this;
1409 if (this.supportsPressRipple()) {
1410 if (this.activationTimer) {
1411 clearTimeout(this.activationTimer);
1412 this.activationTimer = 0;
1413 this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION);
1414 }
1415 if (this.fgDeactivationRemovalTimer) {
1416 clearTimeout(this.fgDeactivationRemovalTimer);
1417 this.fgDeactivationRemovalTimer = 0;
1418 this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION);
1419 }
1420 var _a = MDCRippleFoundation.cssClasses,
1421 ROOT_2 = _a.ROOT,
1422 UNBOUNDED_2 = _a.UNBOUNDED;
1423 requestAnimationFrame(function () {
1424 _this.adapter.removeClass(ROOT_2);
1425 _this.adapter.removeClass(UNBOUNDED_2);
1426 _this.removeCssVars();
1427 });
1428 }
1429 this.deregisterRootHandlers();
1430 this.deregisterDeactivationHandlers();
1431 };
1432 /**
1433 * @param evt Optional event containing position information.
1434 */
1435 MDCRippleFoundation.prototype.activate = function (evt) {
1436 this.activateImpl(evt);
1437 };
1438 MDCRippleFoundation.prototype.deactivate = function () {
1439 this.deactivateImpl();
1440 };
1441 MDCRippleFoundation.prototype.layout = function () {
1442 var _this = this;
1443 if (this.layoutFrame) {
1444 cancelAnimationFrame(this.layoutFrame);
1445 }
1446 this.layoutFrame = requestAnimationFrame(function () {
1447 _this.layoutInternal();
1448 _this.layoutFrame = 0;
1449 });
1450 };
1451 MDCRippleFoundation.prototype.setUnbounded = function (unbounded) {
1452 var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED;
1453 if (unbounded) {
1454 this.adapter.addClass(UNBOUNDED);
1455 } else {
1456 this.adapter.removeClass(UNBOUNDED);
1457 }
1458 };
1459 MDCRippleFoundation.prototype.handleFocus = function () {
1460 var _this = this;
1461 requestAnimationFrame(function () {
1462 return _this.adapter.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
1463 });
1464 };
1465 MDCRippleFoundation.prototype.handleBlur = function () {
1466 var _this = this;
1467 requestAnimationFrame(function () {
1468 return _this.adapter.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
1469 });
1470 };
1471 /**
1472 * We compute this property so that we are not querying information about the client
1473 * until the point in time where the foundation requests it. This prevents scenarios where
1474 * client-side feature-detection may happen too early, such as when components are rendered on the server
1475 * and then initialized at mount time on the client.
1476 */
1477 MDCRippleFoundation.prototype.supportsPressRipple = function () {
1478 return this.adapter.browserSupportsCssVars();
1479 };
1480 MDCRippleFoundation.prototype.defaultActivationState = function () {
1481 return {
1482 activationEvent: undefined,
1483 hasDeactivationUXRun: false,
1484 isActivated: false,
1485 isProgrammatic: false,
1486 wasActivatedByPointer: false,
1487 wasElementMadeActive: false
1488 };
1489 };
1490 /**
1491 * supportsPressRipple Passed from init to save a redundant function call
1492 */
1493 MDCRippleFoundation.prototype.registerRootHandlers = function (supportsPressRipple) {
1494 var e_1, _a;
1495 if (supportsPressRipple) {
1496 try {
1497 for (var ACTIVATION_EVENT_TYPES_1 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next(); !ACTIVATION_EVENT_TYPES_1_1.done; ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next()) {
1498 var evtType = ACTIVATION_EVENT_TYPES_1_1.value;
1499 this.adapter.registerInteractionHandler(evtType, this.activateHandler);
1500 }
1501 } catch (e_1_1) {
1502 e_1 = { error: e_1_1 };
1503 } finally {
1504 try {
1505 if (ACTIVATION_EVENT_TYPES_1_1 && !ACTIVATION_EVENT_TYPES_1_1.done && (_a = ACTIVATION_EVENT_TYPES_1.return)) _a.call(ACTIVATION_EVENT_TYPES_1);
1506 } finally {
1507 if (e_1) throw e_1.error;
1508 }
1509 }
1510 if (this.adapter.isUnbounded()) {
1511 this.adapter.registerResizeHandler(this.resizeHandler);
1512 }
1513 }
1514 this.adapter.registerInteractionHandler('focus', this.focusHandler);
1515 this.adapter.registerInteractionHandler('blur', this.blurHandler);
1516 };
1517 MDCRippleFoundation.prototype.registerDeactivationHandlers = function (evt) {
1518 var e_2, _a;
1519 if (evt.type === 'keydown') {
1520 this.adapter.registerInteractionHandler('keyup', this.deactivateHandler);
1521 } else {
1522 try {
1523 for (var POINTER_DEACTIVATION_EVENT_TYPES_1 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next(); !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done; POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next()) {
1524 var evtType = POINTER_DEACTIVATION_EVENT_TYPES_1_1.value;
1525 this.adapter.registerDocumentInteractionHandler(evtType, this.deactivateHandler);
1526 }
1527 } catch (e_2_1) {
1528 e_2 = { error: e_2_1 };
1529 } finally {
1530 try {
1531 if (POINTER_DEACTIVATION_EVENT_TYPES_1_1 && !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done && (_a = POINTER_DEACTIVATION_EVENT_TYPES_1.return)) _a.call(POINTER_DEACTIVATION_EVENT_TYPES_1);
1532 } finally {
1533 if (e_2) throw e_2.error;
1534 }
1535 }
1536 }
1537 };
1538 MDCRippleFoundation.prototype.deregisterRootHandlers = function () {
1539 var e_3, _a;
1540 try {
1541 for (var ACTIVATION_EVENT_TYPES_2 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next(); !ACTIVATION_EVENT_TYPES_2_1.done; ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next()) {
1542 var evtType = ACTIVATION_EVENT_TYPES_2_1.value;
1543 this.adapter.deregisterInteractionHandler(evtType, this.activateHandler);
1544 }
1545 } catch (e_3_1) {
1546 e_3 = { error: e_3_1 };
1547 } finally {
1548 try {
1549 if (ACTIVATION_EVENT_TYPES_2_1 && !ACTIVATION_EVENT_TYPES_2_1.done && (_a = ACTIVATION_EVENT_TYPES_2.return)) _a.call(ACTIVATION_EVENT_TYPES_2);
1550 } finally {
1551 if (e_3) throw e_3.error;
1552 }
1553 }
1554 this.adapter.deregisterInteractionHandler('focus', this.focusHandler);
1555 this.adapter.deregisterInteractionHandler('blur', this.blurHandler);
1556 if (this.adapter.isUnbounded()) {
1557 this.adapter.deregisterResizeHandler(this.resizeHandler);
1558 }
1559 };
1560 MDCRippleFoundation.prototype.deregisterDeactivationHandlers = function () {
1561 var e_4, _a;
1562 this.adapter.deregisterInteractionHandler('keyup', this.deactivateHandler);
1563 try {
1564 for (var POINTER_DEACTIVATION_EVENT_TYPES_2 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next(); !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done; POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next()) {
1565 var evtType = POINTER_DEACTIVATION_EVENT_TYPES_2_1.value;
1566 this.adapter.deregisterDocumentInteractionHandler(evtType, this.deactivateHandler);
1567 }
1568 } catch (e_4_1) {
1569 e_4 = { error: e_4_1 };
1570 } finally {
1571 try {
1572 if (POINTER_DEACTIVATION_EVENT_TYPES_2_1 && !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done && (_a = POINTER_DEACTIVATION_EVENT_TYPES_2.return)) _a.call(POINTER_DEACTIVATION_EVENT_TYPES_2);
1573 } finally {
1574 if (e_4) throw e_4.error;
1575 }
1576 }
1577 };
1578 MDCRippleFoundation.prototype.removeCssVars = function () {
1579 var _this = this;
1580 var rippleStrings = MDCRippleFoundation.strings;
1581 var keys = Object.keys(rippleStrings);
1582 keys.forEach(function (key) {
1583 if (key.indexOf('VAR_') === 0) {
1584 _this.adapter.updateCssVariable(rippleStrings[key], null);
1585 }
1586 });
1587 };
1588 MDCRippleFoundation.prototype.activateImpl = function (evt) {
1589 var _this = this;
1590 if (this.adapter.isSurfaceDisabled()) {
1591 return;
1592 }
1593 var activationState = this.activationState;
1594 if (activationState.isActivated) {
1595 return;
1596 }
1597 // Avoid reacting to follow-on events fired by touch device after an already-processed user interaction
1598 var previousActivationEvent = this.previousActivationEvent;
1599 var isSameInteraction = previousActivationEvent && evt !== undefined && previousActivationEvent.type !== evt.type;
1600 if (isSameInteraction) {
1601 return;
1602 }
1603 activationState.isActivated = true;
1604 activationState.isProgrammatic = evt === undefined;
1605 activationState.activationEvent = evt;
1606 activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== undefined && (evt.type === 'mousedown' || evt.type === 'touchstart' || evt.type === 'pointerdown');
1607 var hasActivatedChild = evt !== undefined && activatedTargets.length > 0 && activatedTargets.some(function (target) {
1608 return _this.adapter.containsEventTarget(target);
1609 });
1610 if (hasActivatedChild) {
1611 // Immediately reset activation state, while preserving logic that prevents touch follow-on events
1612 this.resetActivationState();
1613 return;
1614 }
1615 if (evt !== undefined) {
1616 activatedTargets.push(evt.target);
1617 this.registerDeactivationHandlers(evt);
1618 }
1619 activationState.wasElementMadeActive = this.checkElementMadeActive(evt);
1620 if (activationState.wasElementMadeActive) {
1621 this.animateActivation();
1622 }
1623 requestAnimationFrame(function () {
1624 // Reset array on next frame after the current event has had a chance to bubble to prevent ancestor ripples
1625 activatedTargets = [];
1626 if (!activationState.wasElementMadeActive && evt !== undefined && (evt.key === ' ' || evt.keyCode === 32)) {
1627 // If space was pressed, try again within an rAF call to detect :active, because different UAs report
1628 // active states inconsistently when they're called within event handling code:
1629 // - https://bugs.chromium.org/p/chromium/issues/detail?id=635971
1630 // - https://bugzilla.mozilla.org/show_bug.cgi?id=1293741
1631 // We try first outside rAF to support Edge, which does not exhibit this problem, but will crash if a CSS
1632 // variable is set within a rAF callback for a submit button interaction (#2241).
1633 activationState.wasElementMadeActive = _this.checkElementMadeActive(evt);
1634 if (activationState.wasElementMadeActive) {
1635 _this.animateActivation();
1636 }
1637 }
1638 if (!activationState.wasElementMadeActive) {
1639 // Reset activation state immediately if element was not made active.
1640 _this.activationState = _this.defaultActivationState();
1641 }
1642 });
1643 };
1644 MDCRippleFoundation.prototype.checkElementMadeActive = function (evt) {
1645 return evt !== undefined && evt.type === 'keydown' ? this.adapter.isSurfaceActive() : true;
1646 };
1647 MDCRippleFoundation.prototype.animateActivation = function () {
1648 var _this = this;
1649 var _a = MDCRippleFoundation.strings,
1650 VAR_FG_TRANSLATE_START = _a.VAR_FG_TRANSLATE_START,
1651 VAR_FG_TRANSLATE_END = _a.VAR_FG_TRANSLATE_END;
1652 var _b = MDCRippleFoundation.cssClasses,
1653 FG_DEACTIVATION = _b.FG_DEACTIVATION,
1654 FG_ACTIVATION = _b.FG_ACTIVATION;
1655 var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
1656 this.layoutInternal();
1657 var translateStart = '';
1658 var translateEnd = '';
1659 if (!this.adapter.isUnbounded()) {
1660 var _c = this.getFgTranslationCoordinates(),
1661 startPoint = _c.startPoint,
1662 endPoint = _c.endPoint;
1663 translateStart = startPoint.x + "px, " + startPoint.y + "px";
1664 translateEnd = endPoint.x + "px, " + endPoint.y + "px";
1665 }
1666 this.adapter.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
1667 this.adapter.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
1668 // Cancel any ongoing activation/deactivation animations
1669 clearTimeout(this.activationTimer);
1670 clearTimeout(this.fgDeactivationRemovalTimer);
1671 this.rmBoundedActivationClasses();
1672 this.adapter.removeClass(FG_DEACTIVATION);
1673 // Force layout in order to re-trigger the animation.
1674 this.adapter.computeBoundingRect();
1675 this.adapter.addClass(FG_ACTIVATION);
1676 this.activationTimer = setTimeout(function () {
1677 _this.activationTimerCallback();
1678 }, DEACTIVATION_TIMEOUT_MS);
1679 };
1680 MDCRippleFoundation.prototype.getFgTranslationCoordinates = function () {
1681 var _a = this.activationState,
1682 activationEvent = _a.activationEvent,
1683 wasActivatedByPointer = _a.wasActivatedByPointer;
1684 var startPoint;
1685 if (wasActivatedByPointer) {
1686 startPoint = util_1.getNormalizedEventCoords(activationEvent, this.adapter.getWindowPageOffset(), this.adapter.computeBoundingRect());
1687 } else {
1688 startPoint = {
1689 x: this.frame.width / 2,
1690 y: this.frame.height / 2
1691 };
1692 }
1693 // Center the element around the start point.
1694 startPoint = {
1695 x: startPoint.x - this.initialSize / 2,
1696 y: startPoint.y - this.initialSize / 2
1697 };
1698 var endPoint = {
1699 x: this.frame.width / 2 - this.initialSize / 2,
1700 y: this.frame.height / 2 - this.initialSize / 2
1701 };
1702 return { startPoint: startPoint, endPoint: endPoint };
1703 };
1704 MDCRippleFoundation.prototype.runDeactivationUXLogicIfReady = function () {
1705 var _this = this;
1706 // This method is called both when a pointing device is released, and when the activation animation ends.
1707 // The deactivation animation should only run after both of those occur.
1708 var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
1709 var _a = this.activationState,
1710 hasDeactivationUXRun = _a.hasDeactivationUXRun,
1711 isActivated = _a.isActivated;
1712 var activationHasEnded = hasDeactivationUXRun || !isActivated;
1713 if (activationHasEnded && this.activationAnimationHasEnded) {
1714 this.rmBoundedActivationClasses();
1715 this.adapter.addClass(FG_DEACTIVATION);
1716 this.fgDeactivationRemovalTimer = setTimeout(function () {
1717 _this.adapter.removeClass(FG_DEACTIVATION);
1718 }, constants_1.numbers.FG_DEACTIVATION_MS);
1719 }
1720 };
1721 MDCRippleFoundation.prototype.rmBoundedActivationClasses = function () {
1722 var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION;
1723 this.adapter.removeClass(FG_ACTIVATION);
1724 this.activationAnimationHasEnded = false;
1725 this.adapter.computeBoundingRect();
1726 };
1727 MDCRippleFoundation.prototype.resetActivationState = function () {
1728 var _this = this;
1729 this.previousActivationEvent = this.activationState.activationEvent;
1730 this.activationState = this.defaultActivationState();
1731 // Touch devices may fire additional events for the same interaction within a short time.
1732 // Store the previous event until it's safe to assume that subsequent events are for new interactions.
1733 setTimeout(function () {
1734 return _this.previousActivationEvent = undefined;
1735 }, MDCRippleFoundation.numbers.TAP_DELAY_MS);
1736 };
1737 MDCRippleFoundation.prototype.deactivateImpl = function () {
1738 var _this = this;
1739 var activationState = this.activationState;
1740 // This can happen in scenarios such as when you have a keyup event that blurs the element.
1741 if (!activationState.isActivated) {
1742 return;
1743 }
1744 var state = __assign({}, activationState);
1745 if (activationState.isProgrammatic) {
1746 requestAnimationFrame(function () {
1747 _this.animateDeactivation(state);
1748 });
1749 this.resetActivationState();
1750 } else {
1751 this.deregisterDeactivationHandlers();
1752 requestAnimationFrame(function () {
1753 _this.activationState.hasDeactivationUXRun = true;
1754 _this.animateDeactivation(state);
1755 _this.resetActivationState();
1756 });
1757 }
1758 };
1759 MDCRippleFoundation.prototype.animateDeactivation = function (_a) {
1760 var wasActivatedByPointer = _a.wasActivatedByPointer,
1761 wasElementMadeActive = _a.wasElementMadeActive;
1762 if (wasActivatedByPointer || wasElementMadeActive) {
1763 this.runDeactivationUXLogicIfReady();
1764 }
1765 };
1766 MDCRippleFoundation.prototype.layoutInternal = function () {
1767 var _this = this;
1768 this.frame = this.adapter.computeBoundingRect();
1769 var maxDim = Math.max(this.frame.height, this.frame.width);
1770 // Surface diameter is treated differently for unbounded vs. bounded ripples.
1771 // Unbounded ripple diameter is calculated smaller since the surface is expected to already be padded appropriately
1772 // to extend the hitbox, and the ripple is expected to meet the edges of the padded hitbox (which is typically
1773 // square). Bounded ripples, on the other hand, are fully expected to expand beyond the surface's longest diameter
1774 // (calculated based on the diagonal plus a constant padding), and are clipped at the surface's border via
1775 // `overflow: hidden`.
1776 var getBoundedRadius = function getBoundedRadius() {
1777 var hypotenuse = Math.sqrt(Math.pow(_this.frame.width, 2) + Math.pow(_this.frame.height, 2));
1778 return hypotenuse + MDCRippleFoundation.numbers.PADDING;
1779 };
1780 this.maxRadius = this.adapter.isUnbounded() ? maxDim : getBoundedRadius();
1781 // Ripple is sized as a fraction of the largest dimension of the surface, then scales up using a CSS scale transform
1782 var initialSize = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
1783 // Unbounded ripple size should always be even number to equally center align.
1784 if (this.adapter.isUnbounded() && initialSize % 2 !== 0) {
1785 this.initialSize = initialSize - 1;
1786 } else {
1787 this.initialSize = initialSize;
1788 }
1789 this.fgScale = "" + this.maxRadius / this.initialSize;
1790 this.updateLayoutCssVars();
1791 };
1792 MDCRippleFoundation.prototype.updateLayoutCssVars = function () {
1793 var _a = MDCRippleFoundation.strings,
1794 VAR_FG_SIZE = _a.VAR_FG_SIZE,
1795 VAR_LEFT = _a.VAR_LEFT,
1796 VAR_TOP = _a.VAR_TOP,
1797 VAR_FG_SCALE = _a.VAR_FG_SCALE;
1798 this.adapter.updateCssVariable(VAR_FG_SIZE, this.initialSize + "px");
1799 this.adapter.updateCssVariable(VAR_FG_SCALE, this.fgScale);
1800 if (this.adapter.isUnbounded()) {
1801 this.unboundedCoords = {
1802 left: Math.round(this.frame.width / 2 - this.initialSize / 2),
1803 top: Math.round(this.frame.height / 2 - this.initialSize / 2)
1804 };
1805 this.adapter.updateCssVariable(VAR_LEFT, this.unboundedCoords.left + "px");
1806 this.adapter.updateCssVariable(VAR_TOP, this.unboundedCoords.top + "px");
1807 }
1808 };
1809 return MDCRippleFoundation;
1810}(foundation_1.MDCFoundation);
1811exports.MDCRippleFoundation = MDCRippleFoundation;
1812// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
1813exports.default = MDCRippleFoundation;
1814
1815/***/ }),
1816
1817/***/ "./packages/mdc-ripple/util.ts":
1818/*!*************************************!*\
1819 !*** ./packages/mdc-ripple/util.ts ***!
1820 \*************************************/
1821/*! no static exports found */
1822/***/ (function(module, exports, __webpack_require__) {
1823
1824"use strict";
1825
1826
1827Object.defineProperty(exports, "__esModule", { value: true });
1828exports.getNormalizedEventCoords = exports.supportsCssVariables = void 0;
1829/**
1830 * Stores result from supportsCssVariables to avoid redundant processing to
1831 * detect CSS custom variable support.
1832 */
1833var supportsCssVariables_;
1834function supportsCssVariables(windowObj, forceRefresh) {
1835 if (forceRefresh === void 0) {
1836 forceRefresh = false;
1837 }
1838 var CSS = windowObj.CSS;
1839 var supportsCssVars = supportsCssVariables_;
1840 if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
1841 return supportsCssVariables_;
1842 }
1843 var supportsFunctionPresent = CSS && typeof CSS.supports === 'function';
1844 if (!supportsFunctionPresent) {
1845 return false;
1846 }
1847 var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes');
1848 // See: https://bugs.webkit.org/show_bug.cgi?id=154669
1849 // See: README section on Safari
1850 var weAreFeatureDetectingSafari10plus = CSS.supports('(--css-vars: yes)') && CSS.supports('color', '#00000000');
1851 supportsCssVars = explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
1852 if (!forceRefresh) {
1853 supportsCssVariables_ = supportsCssVars;
1854 }
1855 return supportsCssVars;
1856}
1857exports.supportsCssVariables = supportsCssVariables;
1858function getNormalizedEventCoords(evt, pageOffset, clientRect) {
1859 if (!evt) {
1860 return { x: 0, y: 0 };
1861 }
1862 var x = pageOffset.x,
1863 y = pageOffset.y;
1864 var documentX = x + clientRect.left;
1865 var documentY = y + clientRect.top;
1866 var normalizedX;
1867 var normalizedY;
1868 // Determine touch point relative to the ripple container.
1869 if (evt.type === 'touchstart') {
1870 var touchEvent = evt;
1871 normalizedX = touchEvent.changedTouches[0].pageX - documentX;
1872 normalizedY = touchEvent.changedTouches[0].pageY - documentY;
1873 } else {
1874 var mouseEvent = evt;
1875 normalizedX = mouseEvent.pageX - documentX;
1876 normalizedY = mouseEvent.pageY - documentY;
1877 }
1878 return { x: normalizedX, y: normalizedY };
1879}
1880exports.getNormalizedEventCoords = getNormalizedEventCoords;
1881
1882/***/ })
1883
1884/******/ });
1885});
1886//# sourceMappingURL=mdc.radio.js.map
\No newline at end of file