UNPKG

92.8 kBJavaScriptView Raw
1/*!
2 Material Components for the Web
3 Copyright (c) 2019 Google Inc.
4 License: MIT
5*/
6(function webpackUniversalModuleDefinition(root, factory) {
7 if(typeof exports === 'object' && typeof module === 'object')
8 module.exports = factory();
9 else if(typeof define === 'function' && define.amd)
10 define([], factory);
11 else if(typeof exports === 'object')
12 exports["iconToggle"] = factory();
13 else
14 root["mdc"] = root["mdc"] || {}, root["mdc"]["iconToggle"] = factory();
15})(this, function() {
16return /******/ (function(modules) { // webpackBootstrap
17/******/ // The module cache
18/******/ var installedModules = {};
19/******/
20/******/ // The require function
21/******/ function __webpack_require__(moduleId) {
22/******/
23/******/ // Check if module is in cache
24/******/ if(installedModules[moduleId]) {
25/******/ return installedModules[moduleId].exports;
26/******/ }
27/******/ // Create a new module (and put it into the cache)
28/******/ var module = installedModules[moduleId] = {
29/******/ i: moduleId,
30/******/ l: false,
31/******/ exports: {}
32/******/ };
33/******/
34/******/ // Execute the module function
35/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
36/******/
37/******/ // Flag the module as loaded
38/******/ module.l = true;
39/******/
40/******/ // Return the exports of the module
41/******/ return module.exports;
42/******/ }
43/******/
44/******/
45/******/ // expose the modules object (__webpack_modules__)
46/******/ __webpack_require__.m = modules;
47/******/
48/******/ // expose the module cache
49/******/ __webpack_require__.c = installedModules;
50/******/
51/******/ // define getter function for harmony exports
52/******/ __webpack_require__.d = function(exports, name, getter) {
53/******/ if(!__webpack_require__.o(exports, name)) {
54/******/ Object.defineProperty(exports, name, {
55/******/ configurable: false,
56/******/ enumerable: true,
57/******/ get: getter
58/******/ });
59/******/ }
60/******/ };
61/******/
62/******/ // getDefaultExport function for compatibility with non-harmony modules
63/******/ __webpack_require__.n = function(module) {
64/******/ var getter = module && module.__esModule ?
65/******/ function getDefault() { return module['default']; } :
66/******/ function getModuleExports() { return module; };
67/******/ __webpack_require__.d(getter, 'a', getter);
68/******/ return getter;
69/******/ };
70/******/
71/******/ // Object.prototype.hasOwnProperty.call
72/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
73/******/
74/******/ // __webpack_public_path__
75/******/ __webpack_require__.p = "";
76/******/
77/******/ // Load entry module and return exports
78/******/ return __webpack_require__(__webpack_require__.s = 122);
79/******/ })
80/************************************************************************/
81/******/ ({
82
83/***/ 0:
84/***/ (function(module, __webpack_exports__, __webpack_require__) {
85
86"use strict";
87var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
88
89function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
90
91/**
92 * @license
93 * Copyright 2016 Google Inc.
94 *
95 * Permission is hereby granted, free of charge, to any person obtaining a copy
96 * of this software and associated documentation files (the "Software"), to deal
97 * in the Software without restriction, including without limitation the rights
98 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99 * copies of the Software, and to permit persons to whom the Software is
100 * furnished to do so, subject to the following conditions:
101 *
102 * The above copyright notice and this permission notice shall be included in
103 * all copies or substantial portions of the Software.
104 *
105 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
106 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
107 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
108 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
109 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
110 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
111 * THE SOFTWARE.
112 */
113
114/**
115 * @template A
116 */
117var MDCFoundation = function () {
118 _createClass(MDCFoundation, null, [{
119 key: "cssClasses",
120
121 /** @return enum{cssClasses} */
122 get: function get() {
123 // Classes extending MDCFoundation should implement this method to return an object which exports every
124 // CSS class the foundation class needs as a property. e.g. {ACTIVE: 'mdc-component--active'}
125 return {};
126 }
127
128 /** @return enum{strings} */
129
130 }, {
131 key: "strings",
132 get: function get() {
133 // Classes extending MDCFoundation should implement this method to return an object which exports all
134 // semantic strings as constants. e.g. {ARIA_ROLE: 'tablist'}
135 return {};
136 }
137
138 /** @return enum{numbers} */
139
140 }, {
141 key: "numbers",
142 get: function get() {
143 // Classes extending MDCFoundation should implement this method to return an object which exports all
144 // of its semantic numbers as constants. e.g. {ANIMATION_DELAY_MS: 350}
145 return {};
146 }
147
148 /** @return {!Object} */
149
150 }, {
151 key: "defaultAdapter",
152 get: function get() {
153 // Classes extending MDCFoundation may choose to implement this getter in order to provide a convenient
154 // way of viewing the necessary methods of an adapter. In the future, this could also be used for adapter
155 // validation.
156 return {};
157 }
158
159 /**
160 * @param {A=} adapter
161 */
162
163 }]);
164
165 function MDCFoundation() {
166 var adapter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
167
168 _classCallCheck(this, MDCFoundation);
169
170 /** @protected {!A} */
171 this.adapter_ = adapter;
172 }
173
174 _createClass(MDCFoundation, [{
175 key: "init",
176 value: function init() {
177 // Subclasses should override this method to perform initialization routines (registering events, etc.)
178 }
179 }, {
180 key: "destroy",
181 value: function destroy() {
182 // Subclasses should override this method to perform de-initialization routines (de-registering events, etc.)
183 }
184 }]);
185
186 return MDCFoundation;
187}();
188
189/* harmony default export */ __webpack_exports__["a"] = (MDCFoundation);
190
191/***/ }),
192
193/***/ 1:
194/***/ (function(module, __webpack_exports__, __webpack_require__) {
195
196"use strict";
197/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__foundation__ = __webpack_require__(0);
198var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
199
200function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
201
202/**
203 * @license
204 * Copyright 2016 Google Inc.
205 *
206 * Permission is hereby granted, free of charge, to any person obtaining a copy
207 * of this software and associated documentation files (the "Software"), to deal
208 * in the Software without restriction, including without limitation the rights
209 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
210 * copies of the Software, and to permit persons to whom the Software is
211 * furnished to do so, subject to the following conditions:
212 *
213 * The above copyright notice and this permission notice shall be included in
214 * all copies or substantial portions of the Software.
215 *
216 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
217 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
218 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
219 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
220 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
221 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
222 * THE SOFTWARE.
223 */
224
225
226
227/**
228 * @template F
229 */
230
231var MDCComponent = function () {
232 _createClass(MDCComponent, null, [{
233 key: 'attachTo',
234
235 /**
236 * @param {!Element} root
237 * @return {!MDCComponent}
238 */
239 value: function attachTo(root) {
240 // Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and
241 // returns an instantiated component with its root set to that element. Also note that in the cases of
242 // subclasses, an explicit foundation class will not have to be passed in; it will simply be initialized
243 // from getDefaultFoundation().
244 return new MDCComponent(root, new __WEBPACK_IMPORTED_MODULE_0__foundation__["a" /* default */]());
245 }
246
247 /**
248 * @param {!Element} root
249 * @param {F=} foundation
250 * @param {...?} args
251 */
252
253 }]);
254
255 function MDCComponent(root) {
256 var foundation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
257
258 _classCallCheck(this, MDCComponent);
259
260 /** @protected {!Element} */
261 this.root_ = root;
262
263 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
264 args[_key - 2] = arguments[_key];
265 }
266
267 this.initialize.apply(this, args);
268 // Note that we initialize foundation here and not within the constructor's default param so that
269 // this.root_ is defined and can be used within the foundation class.
270 /** @protected {!F} */
271 this.foundation_ = foundation === undefined ? this.getDefaultFoundation() : foundation;
272 this.foundation_.init();
273 this.initialSyncWithDOM();
274 }
275
276 _createClass(MDCComponent, [{
277 key: 'initialize',
278 value: function initialize() /* ...args */{}
279 // Subclasses can override this to do any additional setup work that would be considered part of a
280 // "constructor". Essentially, it is a hook into the parent constructor before the foundation is
281 // initialized. Any additional arguments besides root and foundation will be passed in here.
282
283
284 /**
285 * @return {!F} foundation
286 */
287
288 }, {
289 key: 'getDefaultFoundation',
290 value: function getDefaultFoundation() {
291 // Subclasses must override this method to return a properly configured foundation class for the
292 // component.
293 throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
294 }
295 }, {
296 key: 'initialSyncWithDOM',
297 value: function initialSyncWithDOM() {
298 // Subclasses should override this method if they need to perform work to synchronize with a host DOM
299 // object. An example of this would be a form control wrapper that needs to synchronize its internal state
300 // to some property or attribute of the host DOM. Please note: this is *not* the place to perform DOM
301 // reads/writes that would cause layout / paint, as this is called synchronously from within the constructor.
302 }
303 }, {
304 key: 'destroy',
305 value: function destroy() {
306 // Subclasses may implement this method to release any resources / deregister any listeners they have
307 // attached. An example of this might be deregistering a resize event from the window object.
308 this.foundation_.destroy();
309 }
310
311 /**
312 * Wrapper method to add an event listener to the component's root element. This is most useful when
313 * listening for custom events.
314 * @param {string} evtType
315 * @param {!Function} handler
316 */
317
318 }, {
319 key: 'listen',
320 value: function listen(evtType, handler) {
321 this.root_.addEventListener(evtType, handler);
322 }
323
324 /**
325 * Wrapper method to remove an event listener to the component's root element. This is most useful when
326 * unlistening for custom events.
327 * @param {string} evtType
328 * @param {!Function} handler
329 */
330
331 }, {
332 key: 'unlisten',
333 value: function unlisten(evtType, handler) {
334 this.root_.removeEventListener(evtType, handler);
335 }
336
337 /**
338 * Fires a cross-browser-compatible custom event from the component root of the given type,
339 * with the given data.
340 * @param {string} evtType
341 * @param {!Object} evtData
342 * @param {boolean=} shouldBubble
343 */
344
345 }, {
346 key: 'emit',
347 value: function emit(evtType, evtData) {
348 var shouldBubble = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
349
350 var evt = void 0;
351 if (typeof CustomEvent === 'function') {
352 evt = new CustomEvent(evtType, {
353 detail: evtData,
354 bubbles: shouldBubble
355 });
356 } else {
357 evt = document.createEvent('CustomEvent');
358 evt.initCustomEvent(evtType, shouldBubble, false, evtData);
359 }
360
361 this.root_.dispatchEvent(evt);
362 }
363 }]);
364
365 return MDCComponent;
366}();
367
368/* harmony default export */ __webpack_exports__["a"] = (MDCComponent);
369
370/***/ }),
371
372/***/ 122:
373/***/ (function(module, __webpack_exports__, __webpack_require__) {
374
375"use strict";
376Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
377/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MDCIconToggle", function() { return MDCIconToggle; });
378/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__material_base_component__ = __webpack_require__(1);
379/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__foundation__ = __webpack_require__(123);
380/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__material_ripple_index__ = __webpack_require__(4);
381/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "MDCIconToggleFoundation", function() { return __WEBPACK_IMPORTED_MODULE_1__foundation__["a"]; });
382var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
383
384var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
385
386var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
387
388function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
389
390function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
391
392function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
393
394/**
395 * @license
396 * Copyright 2016 Google Inc.
397 *
398 * Permission is hereby granted, free of charge, to any person obtaining a copy
399 * of this software and associated documentation files (the "Software"), to deal
400 * in the Software without restriction, including without limitation the rights
401 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
402 * copies of the Software, and to permit persons to whom the Software is
403 * furnished to do so, subject to the following conditions:
404 *
405 * The above copyright notice and this permission notice shall be included in
406 * all copies or substantial portions of the Software.
407 *
408 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
409 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
410 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
411 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
412 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
413 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
414 * THE SOFTWARE.
415 */
416
417
418
419
420
421/**
422 * @extends {MDCComponent<!MDCIconToggleFoundation>}
423 */
424
425var MDCIconToggle = function (_MDCComponent) {
426 _inherits(MDCIconToggle, _MDCComponent);
427
428 _createClass(MDCIconToggle, null, [{
429 key: 'attachTo',
430 value: function attachTo(root) {
431 return new MDCIconToggle(root);
432 }
433 }]);
434
435 function MDCIconToggle() {
436 var _ref;
437
438 _classCallCheck(this, MDCIconToggle);
439
440 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
441 args[_key] = arguments[_key];
442 }
443
444 /** @private {!MDCRipple} */
445 var _this = _possibleConstructorReturn(this, (_ref = MDCIconToggle.__proto__ || Object.getPrototypeOf(MDCIconToggle)).call.apply(_ref, [this].concat(args)));
446
447 _this.ripple_ = _this.initRipple_();
448 return _this;
449 }
450
451 /** @return {!Element} */
452
453
454 _createClass(MDCIconToggle, [{
455 key: 'initRipple_',
456
457
458 /**
459 * @return {!MDCRipple}
460 * @private
461 */
462 value: function initRipple_() {
463 var _this2 = this;
464
465 var adapter = _extends(__WEBPACK_IMPORTED_MODULE_2__material_ripple_index__["MDCRipple"].createAdapter(this), {
466 isUnbounded: function isUnbounded() {
467 return true;
468 },
469 isSurfaceActive: function isSurfaceActive() {
470 return _this2.foundation_.isKeyboardActivated();
471 }
472 });
473 var foundation = new __WEBPACK_IMPORTED_MODULE_2__material_ripple_index__["MDCRippleFoundation"](adapter);
474 return new __WEBPACK_IMPORTED_MODULE_2__material_ripple_index__["MDCRipple"](this.root_, foundation);
475 }
476 }, {
477 key: 'destroy',
478 value: function destroy() {
479 this.ripple_.destroy();
480 _get(MDCIconToggle.prototype.__proto__ || Object.getPrototypeOf(MDCIconToggle.prototype), 'destroy', this).call(this);
481 }
482
483 /** @return {!MDCIconToggleFoundation} */
484
485 }, {
486 key: 'getDefaultFoundation',
487 value: function getDefaultFoundation() {
488 var _this3 = this;
489
490 return new __WEBPACK_IMPORTED_MODULE_1__foundation__["a" /* default */]({
491 addClass: function addClass(className) {
492 return _this3.iconEl_.classList.add(className);
493 },
494 removeClass: function removeClass(className) {
495 return _this3.iconEl_.classList.remove(className);
496 },
497 registerInteractionHandler: function registerInteractionHandler(type, handler) {
498 return _this3.root_.addEventListener(type, handler);
499 },
500 deregisterInteractionHandler: function deregisterInteractionHandler(type, handler) {
501 return _this3.root_.removeEventListener(type, handler);
502 },
503 setText: function setText(text) {
504 return _this3.iconEl_.textContent = text;
505 },
506 getTabIndex: function getTabIndex() {
507 return (/* number */_this3.root_.tabIndex
508 );
509 },
510 setTabIndex: function setTabIndex(tabIndex) {
511 return _this3.root_.tabIndex = tabIndex;
512 },
513 getAttr: function getAttr(name, value) {
514 return _this3.root_.getAttribute(name, value);
515 },
516 setAttr: function setAttr(name, value) {
517 return _this3.root_.setAttribute(name, value);
518 },
519 rmAttr: function rmAttr(name) {
520 return _this3.root_.removeAttribute(name);
521 },
522 notifyChange: function notifyChange(evtData) {
523 return _this3.emit(__WEBPACK_IMPORTED_MODULE_1__foundation__["a" /* default */].strings.CHANGE_EVENT, evtData);
524 }
525 });
526 }
527 }, {
528 key: 'initialSyncWithDOM',
529 value: function initialSyncWithDOM() {
530 this.on = this.root_.getAttribute(__WEBPACK_IMPORTED_MODULE_1__foundation__["a" /* default */].strings.ARIA_PRESSED) === 'true';
531 this.disabled = this.root_.getAttribute(__WEBPACK_IMPORTED_MODULE_1__foundation__["a" /* default */].strings.ARIA_DISABLED) === 'true';
532 }
533
534 /** @return {!MDCRipple} */
535
536 }, {
537 key: 'refreshToggleData',
538 value: function refreshToggleData() {
539 this.foundation_.refreshToggleData();
540 }
541 }, {
542 key: 'iconEl_',
543 get: function get() {
544 var sel = this.root_.dataset['iconInnerSelector'];
545
546 return sel ?
547 /** @type {!Element} */this.root_.querySelector(sel) : this.root_;
548 }
549 }, {
550 key: 'ripple',
551 get: function get() {
552 return this.ripple_;
553 }
554
555 /** @return {boolean} */
556
557 }, {
558 key: 'on',
559 get: function get() {
560 return this.foundation_.isOn();
561 }
562
563 /** @param {boolean} isOn */
564 ,
565 set: function set(isOn) {
566 this.foundation_.toggle(isOn);
567 }
568
569 /** @return {boolean} */
570
571 }, {
572 key: 'disabled',
573 get: function get() {
574 return this.foundation_.isDisabled();
575 }
576
577 /** @param {boolean} isDisabled */
578 ,
579 set: function set(isDisabled) {
580 this.foundation_.setDisabled(isDisabled);
581 }
582 }]);
583
584 return MDCIconToggle;
585}(__WEBPACK_IMPORTED_MODULE_0__material_base_component__["a" /* default */]);
586
587
588
589/***/ }),
590
591/***/ 123:
592/***/ (function(module, __webpack_exports__, __webpack_require__) {
593
594"use strict";
595/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__material_base_foundation__ = __webpack_require__(0);
596/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__adapter__ = __webpack_require__(124);
597/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__constants__ = __webpack_require__(125);
598var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
599
600var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
601
602function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
603
604function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
605
606function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
607
608/**
609 * @license
610 * Copyright 2016 Google Inc.
611 *
612 * Permission is hereby granted, free of charge, to any person obtaining a copy
613 * of this software and associated documentation files (the "Software"), to deal
614 * in the Software without restriction, including without limitation the rights
615 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
616 * copies of the Software, and to permit persons to whom the Software is
617 * furnished to do so, subject to the following conditions:
618 *
619 * The above copyright notice and this permission notice shall be included in
620 * all copies or substantial portions of the Software.
621 *
622 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
623 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
624 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
625 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
626 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
627 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
628 * THE SOFTWARE.
629 */
630
631
632/* eslint-disable no-unused-vars */
633
634
635
636/**
637 * @extends {MDCFoundation<!MDCIconToggleAdapter>}
638 */
639
640var MDCIconToggleFoundation = function (_MDCFoundation) {
641 _inherits(MDCIconToggleFoundation, _MDCFoundation);
642
643 _createClass(MDCIconToggleFoundation, null, [{
644 key: 'cssClasses',
645 get: function get() {
646 return __WEBPACK_IMPORTED_MODULE_2__constants__["a" /* cssClasses */];
647 }
648 }, {
649 key: 'strings',
650 get: function get() {
651 return __WEBPACK_IMPORTED_MODULE_2__constants__["b" /* strings */];
652 }
653 }, {
654 key: 'defaultAdapter',
655 get: function get() {
656 return {
657 addClass: function addClass() /* className: string */{},
658 removeClass: function removeClass() /* className: string */{},
659 registerInteractionHandler: function registerInteractionHandler() /* type: string, handler: EventListener */{},
660 deregisterInteractionHandler: function deregisterInteractionHandler() /* type: string, handler: EventListener */{},
661 setText: function setText() /* text: string */{},
662 getTabIndex: function getTabIndex() {
663 return (/* number */0
664 );
665 },
666 setTabIndex: function setTabIndex() /* tabIndex: number */{},
667 getAttr: function getAttr() {
668 return (/* name: string */ /* string */''
669 );
670 },
671 setAttr: function setAttr() /* name: string, value: string */{},
672 rmAttr: function rmAttr() /* name: string */{},
673 notifyChange: function notifyChange() /* evtData: IconToggleEvent */{}
674 };
675 }
676 }]);
677
678 function MDCIconToggleFoundation(adapter) {
679 _classCallCheck(this, MDCIconToggleFoundation);
680
681 /** @private {boolean} */
682 var _this = _possibleConstructorReturn(this, (MDCIconToggleFoundation.__proto__ || Object.getPrototypeOf(MDCIconToggleFoundation)).call(this, _extends(MDCIconToggleFoundation.defaultAdapter, adapter)));
683
684 _this.on_ = false;
685
686 /** @private {boolean} */
687 _this.disabled_ = false;
688
689 /** @private {number} */
690 _this.savedTabIndex_ = -1;
691
692 /** @private {?IconToggleState} */
693 _this.toggleOnData_ = null;
694
695 /** @private {?IconToggleState} */
696 _this.toggleOffData_ = null;
697
698 _this.clickHandler_ = /** @private {!EventListener} */function () {
699 return _this.toggleFromEvt_();
700 };
701
702 /** @private {boolean} */
703 _this.isHandlingKeydown_ = false;
704
705 _this.keydownHandler_ = /** @private {!EventListener} */function ( /** @type {!KeyboardKey} */evt) {
706 if (isSpace(evt)) {
707 _this.isHandlingKeydown_ = true;
708 return evt.preventDefault();
709 }
710 };
711
712 _this.keyupHandler_ = /** @private {!EventListener} */function ( /** @type {!KeyboardKey} */evt) {
713 if (isSpace(evt)) {
714 _this.isHandlingKeydown_ = false;
715 _this.toggleFromEvt_();
716 }
717 };
718 return _this;
719 }
720
721 _createClass(MDCIconToggleFoundation, [{
722 key: 'init',
723 value: function init() {
724 this.refreshToggleData();
725 this.savedTabIndex_ = this.adapter_.getTabIndex();
726 this.adapter_.registerInteractionHandler('click', this.clickHandler_);
727 this.adapter_.registerInteractionHandler('keydown', this.keydownHandler_);
728 this.adapter_.registerInteractionHandler('keyup', this.keyupHandler_);
729 }
730 }, {
731 key: 'refreshToggleData',
732 value: function refreshToggleData() {
733 var _MDCIconToggleFoundat = MDCIconToggleFoundation.strings,
734 DATA_TOGGLE_ON = _MDCIconToggleFoundat.DATA_TOGGLE_ON,
735 DATA_TOGGLE_OFF = _MDCIconToggleFoundat.DATA_TOGGLE_OFF;
736
737 this.toggleOnData_ = this.parseJsonDataAttr_(DATA_TOGGLE_ON);
738 this.toggleOffData_ = this.parseJsonDataAttr_(DATA_TOGGLE_OFF);
739 }
740 }, {
741 key: 'destroy',
742 value: function destroy() {
743 this.adapter_.deregisterInteractionHandler('click', this.clickHandler_);
744 this.adapter_.deregisterInteractionHandler('keydown', this.keydownHandler_);
745 this.adapter_.deregisterInteractionHandler('keyup', this.keyupHandler_);
746 }
747
748 /** @private */
749
750 }, {
751 key: 'toggleFromEvt_',
752 value: function toggleFromEvt_() {
753 this.toggle();
754 var isOn = this.on_;
755
756 this.adapter_.notifyChange( /** @type {!IconToggleEvent} */{ isOn: isOn });
757 }
758
759 /** @return {boolean} */
760
761 }, {
762 key: 'isOn',
763 value: function isOn() {
764 return this.on_;
765 }
766
767 /** @param {boolean=} isOn */
768
769 }, {
770 key: 'toggle',
771 value: function toggle() {
772 var isOn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !this.on_;
773
774 this.on_ = isOn;
775
776 var _MDCIconToggleFoundat2 = MDCIconToggleFoundation.strings,
777 ARIA_LABEL = _MDCIconToggleFoundat2.ARIA_LABEL,
778 ARIA_PRESSED = _MDCIconToggleFoundat2.ARIA_PRESSED;
779
780
781 if (this.on_) {
782 this.adapter_.setAttr(ARIA_PRESSED, 'true');
783 } else {
784 this.adapter_.setAttr(ARIA_PRESSED, 'false');
785 }
786
787 var _ref = this.on_ ? this.toggleOffData_ : this.toggleOnData_,
788 classToRemove = _ref.cssClass;
789
790 if (classToRemove) {
791 this.adapter_.removeClass(classToRemove);
792 }
793
794 var _ref2 = this.on_ ? this.toggleOnData_ : this.toggleOffData_,
795 content = _ref2.content,
796 label = _ref2.label,
797 cssClass = _ref2.cssClass;
798
799 if (cssClass) {
800 this.adapter_.addClass(cssClass);
801 }
802 if (content) {
803 this.adapter_.setText(content);
804 }
805 if (label) {
806 this.adapter_.setAttr(ARIA_LABEL, label);
807 }
808 }
809
810 /**
811 * @param {string} dataAttr
812 * @return {!IconToggleState}
813 */
814
815 }, {
816 key: 'parseJsonDataAttr_',
817 value: function parseJsonDataAttr_(dataAttr) {
818 var val = this.adapter_.getAttr(dataAttr);
819 if (!val) {
820 return {};
821 }
822 return (/** @type {!IconToggleState} */JSON.parse(val)
823 );
824 }
825
826 /** @return {boolean} */
827
828 }, {
829 key: 'isDisabled',
830 value: function isDisabled() {
831 return this.disabled_;
832 }
833
834 /** @param {boolean} isDisabled */
835
836 }, {
837 key: 'setDisabled',
838 value: function setDisabled(isDisabled) {
839 this.disabled_ = isDisabled;
840
841 var DISABLED = MDCIconToggleFoundation.cssClasses.DISABLED;
842 var ARIA_DISABLED = MDCIconToggleFoundation.strings.ARIA_DISABLED;
843
844
845 if (this.disabled_) {
846 this.savedTabIndex_ = this.adapter_.getTabIndex();
847 this.adapter_.setTabIndex(-1);
848 this.adapter_.setAttr(ARIA_DISABLED, 'true');
849 this.adapter_.addClass(DISABLED);
850 } else {
851 this.adapter_.setTabIndex(this.savedTabIndex_);
852 this.adapter_.rmAttr(ARIA_DISABLED);
853 this.adapter_.removeClass(DISABLED);
854 }
855 }
856
857 /** @return {boolean} */
858
859 }, {
860 key: 'isKeyboardActivated',
861 value: function isKeyboardActivated() {
862 return this.isHandlingKeydown_;
863 }
864 }]);
865
866 return MDCIconToggleFoundation;
867}(__WEBPACK_IMPORTED_MODULE_0__material_base_foundation__["a" /* default */]);
868
869/**
870 * @typedef {{
871 * key: string,
872 * keyCode: number
873 * }}
874 */
875
876
877var KeyboardKey = void 0;
878
879/**
880 * @param {!KeyboardKey} keyboardKey
881 * @return {boolean}
882 */
883function isSpace(keyboardKey) {
884 return keyboardKey.key === 'Space' || keyboardKey.keyCode === 32;
885}
886
887/** @record */
888
889var IconToggleState = function IconToggleState() {
890 _classCallCheck(this, IconToggleState);
891};
892
893/**
894 * The aria-label value of the icon toggle, or undefined if there is no aria-label.
895 * @export {string|undefined}
896 */
897
898
899IconToggleState.prototype.label;
900
901/**
902 * The text for the icon toggle, or undefined if there is no text.
903 * @export {string|undefined}
904 */
905IconToggleState.prototype.content;
906
907/**
908 * The CSS class to add to the icon toggle, or undefined if there is no CSS class.
909 * @export {string|undefined}
910 */
911IconToggleState.prototype.cssClass;
912
913/* harmony default export */ __webpack_exports__["a"] = (MDCIconToggleFoundation);
914
915/***/ }),
916
917/***/ 124:
918/***/ (function(module, __webpack_exports__, __webpack_require__) {
919
920"use strict";
921/* unused harmony export MDCIconToggleAdapter */
922/* unused harmony export IconToggleEvent */
923var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
924
925function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
926
927/**
928 * @license
929 * Copyright 2017 Google Inc.
930 *
931 * Permission is hereby granted, free of charge, to any person obtaining a copy
932 * of this software and associated documentation files (the "Software"), to deal
933 * in the Software without restriction, including without limitation the rights
934 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
935 * copies of the Software, and to permit persons to whom the Software is
936 * furnished to do so, subject to the following conditions:
937 *
938 * The above copyright notice and this permission notice shall be included in
939 * all copies or substantial portions of the Software.
940 *
941 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
942 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
943 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
944 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
945 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
946 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
947 * THE SOFTWARE.
948 */
949
950/* eslint no-unused-vars: [2, {"args": "none"}] */
951
952/**
953 * Adapter for MDC Icon Toggle. Provides an interface for managing
954 * - classes
955 * - dom
956 * - inner text
957 * - event handlers
958 * - event dispatch
959 *
960 * Additionally, provides type information for the adapter to the Closure
961 * compiler.
962 *
963 * Implement this adapter for your framework of choice to delegate updates to
964 * the component in your framework of choice. See architecture documentation
965 * for more details.
966 * https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md
967 *
968 * @record
969 */
970
971var MDCIconToggleAdapter = function () {
972 function MDCIconToggleAdapter() {
973 _classCallCheck(this, MDCIconToggleAdapter);
974 }
975
976 _createClass(MDCIconToggleAdapter, [{
977 key: "addClass",
978
979 /** @param {string} className */
980 value: function addClass(className) {}
981
982 /** @param {string} className */
983
984 }, {
985 key: "removeClass",
986 value: function removeClass(className) {}
987
988 /**
989 * @param {string} type
990 * @param {!EventListener} handler
991 */
992
993 }, {
994 key: "registerInteractionHandler",
995 value: function registerInteractionHandler(type, handler) {}
996
997 /**
998 * @param {string} type
999 * @param {!EventListener} handler
1000 */
1001
1002 }, {
1003 key: "deregisterInteractionHandler",
1004 value: function deregisterInteractionHandler(type, handler) {}
1005
1006 /** @param {string} text */
1007
1008 }, {
1009 key: "setText",
1010 value: function setText(text) {}
1011
1012 /** @return {number} */
1013
1014 }, {
1015 key: "getTabIndex",
1016 value: function getTabIndex() {}
1017
1018 /** @param {number} tabIndex */
1019
1020 }, {
1021 key: "setTabIndex",
1022 value: function setTabIndex(tabIndex) {}
1023
1024 /**
1025 * @param {string} name
1026 * @return {string}
1027 */
1028
1029 }, {
1030 key: "getAttr",
1031 value: function getAttr(name) {}
1032
1033 /**
1034 * @param {string} name
1035 * @param {string} value
1036 */
1037
1038 }, {
1039 key: "setAttr",
1040 value: function setAttr(name, value) {}
1041
1042 /** @param {string} name */
1043
1044 }, {
1045 key: "rmAttr",
1046 value: function rmAttr(name) {}
1047
1048 /** @param {!IconToggleEvent} evtData */
1049
1050 }, {
1051 key: "notifyChange",
1052 value: function notifyChange(evtData) {}
1053 }]);
1054
1055 return MDCIconToggleAdapter;
1056}();
1057
1058/**
1059 * @typedef {{
1060 * isOn: boolean,
1061 * }}
1062 */
1063
1064
1065var IconToggleEvent = void 0;
1066
1067
1068
1069/***/ }),
1070
1071/***/ 125:
1072/***/ (function(module, __webpack_exports__, __webpack_require__) {
1073
1074"use strict";
1075/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return cssClasses; });
1076/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return strings; });
1077/**
1078 * @license
1079 * Copyright 2016 Google Inc.
1080 *
1081 * Permission is hereby granted, free of charge, to any person obtaining a copy
1082 * of this software and associated documentation files (the "Software"), to deal
1083 * in the Software without restriction, including without limitation the rights
1084 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1085 * copies of the Software, and to permit persons to whom the Software is
1086 * furnished to do so, subject to the following conditions:
1087 *
1088 * The above copyright notice and this permission notice shall be included in
1089 * all copies or substantial portions of the Software.
1090 *
1091 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1092 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1093 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1094 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1095 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1096 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1097 * THE SOFTWARE.
1098 */
1099
1100/** @enum {string} */
1101var cssClasses = {
1102 ROOT: 'mdc-icon-toggle',
1103 DISABLED: 'mdc-icon-toggle--disabled'
1104};
1105
1106/** @enum {string} */
1107var strings = {
1108 DATA_TOGGLE_ON: 'data-toggle-on',
1109 DATA_TOGGLE_OFF: 'data-toggle-off',
1110 ARIA_PRESSED: 'aria-pressed',
1111 ARIA_DISABLED: 'aria-disabled',
1112 ARIA_LABEL: 'aria-label',
1113 CHANGE_EVENT: 'MDCIconToggle:change'
1114};
1115
1116
1117
1118/***/ }),
1119
1120/***/ 2:
1121/***/ (function(module, __webpack_exports__, __webpack_require__) {
1122
1123"use strict";
1124Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
1125/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "supportsCssVariables", function() { return supportsCssVariables; });
1126/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "applyPassive", function() { return applyPassive; });
1127/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMatchesProperty", function() { return getMatchesProperty; });
1128/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNormalizedEventCoords", function() { return getNormalizedEventCoords; });
1129/**
1130 * @license
1131 * Copyright 2016 Google Inc.
1132 *
1133 * Permission is hereby granted, free of charge, to any person obtaining a copy
1134 * of this software and associated documentation files (the "Software"), to deal
1135 * in the Software without restriction, including without limitation the rights
1136 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1137 * copies of the Software, and to permit persons to whom the Software is
1138 * furnished to do so, subject to the following conditions:
1139 *
1140 * The above copyright notice and this permission notice shall be included in
1141 * all copies or substantial portions of the Software.
1142 *
1143 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1144 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1145 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1146 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1147 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1148 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1149 * THE SOFTWARE.
1150 */
1151
1152/**
1153 * Stores result from supportsCssVariables to avoid redundant processing to detect CSS custom variable support.
1154 * @private {boolean|undefined}
1155 */
1156var supportsCssVariables_ = void 0;
1157
1158/**
1159 * Stores result from applyPassive to avoid redundant processing to detect passive event listener support.
1160 * @private {boolean|undefined}
1161 */
1162var supportsPassive_ = void 0;
1163
1164/**
1165 * @param {!Window} windowObj
1166 * @return {boolean}
1167 */
1168function detectEdgePseudoVarBug(windowObj) {
1169 // Detect versions of Edge with buggy var() support
1170 // See: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/11495448/
1171 var document = windowObj.document;
1172 var node = document.createElement('div');
1173 node.className = 'mdc-ripple-surface--test-edge-var-bug';
1174 document.body.appendChild(node);
1175
1176 // The bug exists if ::before style ends up propagating to the parent element.
1177 // Additionally, getComputedStyle returns null in iframes with display: "none" in Firefox,
1178 // but Firefox is known to support CSS custom properties correctly.
1179 // See: https://bugzilla.mozilla.org/show_bug.cgi?id=548397
1180 var computedStyle = windowObj.getComputedStyle(node);
1181 var hasPseudoVarBug = computedStyle !== null && computedStyle.borderTopStyle === 'solid';
1182 node.remove();
1183 return hasPseudoVarBug;
1184}
1185
1186/**
1187 * @param {!Window} windowObj
1188 * @param {boolean=} forceRefresh
1189 * @return {boolean|undefined}
1190 */
1191
1192function supportsCssVariables(windowObj) {
1193 var forceRefresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1194
1195 var supportsCssVariables = supportsCssVariables_;
1196 if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
1197 return supportsCssVariables;
1198 }
1199
1200 var supportsFunctionPresent = windowObj.CSS && typeof windowObj.CSS.supports === 'function';
1201 if (!supportsFunctionPresent) {
1202 return;
1203 }
1204
1205 var explicitlySupportsCssVars = windowObj.CSS.supports('--css-vars', 'yes');
1206 // See: https://bugs.webkit.org/show_bug.cgi?id=154669
1207 // See: README section on Safari
1208 var weAreFeatureDetectingSafari10plus = windowObj.CSS.supports('(--css-vars: yes)') && windowObj.CSS.supports('color', '#00000000');
1209
1210 if (explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus) {
1211 supportsCssVariables = !detectEdgePseudoVarBug(windowObj);
1212 } else {
1213 supportsCssVariables = false;
1214 }
1215
1216 if (!forceRefresh) {
1217 supportsCssVariables_ = supportsCssVariables;
1218 }
1219 return supportsCssVariables;
1220}
1221
1222//
1223/**
1224 * Determine whether the current browser supports passive event listeners, and if so, use them.
1225 * @param {!Window=} globalObj
1226 * @param {boolean=} forceRefresh
1227 * @return {boolean|!EventListenerOptions}
1228 */
1229function applyPassive() {
1230 var globalObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
1231 var forceRefresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1232
1233 if (supportsPassive_ === undefined || forceRefresh) {
1234 var isSupported = false;
1235 try {
1236 globalObj.document.addEventListener('test', null, { get passive() {
1237 isSupported = true;
1238 return isSupported;
1239 } });
1240 } catch (e) {}
1241
1242 supportsPassive_ = isSupported;
1243 }
1244
1245 return supportsPassive_ ? /** @type {!EventListenerOptions} */{ passive: true } : false;
1246}
1247
1248/**
1249 * @param {!Object} HTMLElementPrototype
1250 * @return {string}
1251 */
1252function getMatchesProperty(HTMLElementPrototype) {
1253 /**
1254 * Order is important because we return the first existing method we find.
1255 * Do not change the order of the items in the below array.
1256 */
1257 var matchesMethods = ['matches', 'webkitMatchesSelector', 'msMatchesSelector'];
1258 var method = 'matches';
1259 for (var i = 0; i < matchesMethods.length; i++) {
1260 var matchesMethod = matchesMethods[i];
1261 if (matchesMethod in HTMLElementPrototype) {
1262 method = matchesMethod;
1263 break;
1264 }
1265 }
1266
1267 return method;
1268}
1269
1270/**
1271 * @param {!Event} ev
1272 * @param {{x: number, y: number}} pageOffset
1273 * @param {!ClientRect} clientRect
1274 * @return {{x: number, y: number}}
1275 */
1276function getNormalizedEventCoords(ev, pageOffset, clientRect) {
1277 var x = pageOffset.x,
1278 y = pageOffset.y;
1279
1280 var documentX = x + clientRect.left;
1281 var documentY = y + clientRect.top;
1282
1283 var normalizedX = void 0;
1284 var normalizedY = void 0;
1285 // Determine touch point relative to the ripple container.
1286 if (ev.type === 'touchstart') {
1287 ev = /** @type {!TouchEvent} */ev;
1288 normalizedX = ev.changedTouches[0].pageX - documentX;
1289 normalizedY = ev.changedTouches[0].pageY - documentY;
1290 } else {
1291 ev = /** @type {!MouseEvent} */ev;
1292 normalizedX = ev.pageX - documentX;
1293 normalizedY = ev.pageY - documentY;
1294 }
1295
1296 return { x: normalizedX, y: normalizedY };
1297}
1298
1299
1300
1301/***/ }),
1302
1303/***/ 3:
1304/***/ (function(module, __webpack_exports__, __webpack_require__) {
1305
1306"use strict";
1307var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1308
1309function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1310
1311/**
1312 * @license
1313 * Copyright 2016 Google Inc.
1314 *
1315 * Permission is hereby granted, free of charge, to any person obtaining a copy
1316 * of this software and associated documentation files (the "Software"), to deal
1317 * in the Software without restriction, including without limitation the rights
1318 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1319 * copies of the Software, and to permit persons to whom the Software is
1320 * furnished to do so, subject to the following conditions:
1321 *
1322 * The above copyright notice and this permission notice shall be included in
1323 * all copies or substantial portions of the Software.
1324 *
1325 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1326 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1327 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1328 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1329 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1330 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1331 * THE SOFTWARE.
1332 */
1333
1334/* eslint no-unused-vars: [2, {"args": "none"}] */
1335
1336/**
1337 * Adapter for MDC Ripple. Provides an interface for managing
1338 * - classes
1339 * - dom
1340 * - CSS variables
1341 * - position
1342 * - dimensions
1343 * - scroll position
1344 * - event handlers
1345 * - unbounded, active and disabled states
1346 *
1347 * Additionally, provides type information for the adapter to the Closure
1348 * compiler.
1349 *
1350 * Implement this adapter for your framework of choice to delegate updates to
1351 * the component in your framework of choice. See architecture documentation
1352 * for more details.
1353 * https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md
1354 *
1355 * @record
1356 */
1357var MDCRippleAdapter = function () {
1358 function MDCRippleAdapter() {
1359 _classCallCheck(this, MDCRippleAdapter);
1360 }
1361
1362 _createClass(MDCRippleAdapter, [{
1363 key: "browserSupportsCssVars",
1364
1365 /** @return {boolean} */
1366 value: function browserSupportsCssVars() {}
1367
1368 /** @return {boolean} */
1369
1370 }, {
1371 key: "isUnbounded",
1372 value: function isUnbounded() {}
1373
1374 /** @return {boolean} */
1375
1376 }, {
1377 key: "isSurfaceActive",
1378 value: function isSurfaceActive() {}
1379
1380 /** @return {boolean} */
1381
1382 }, {
1383 key: "isSurfaceDisabled",
1384 value: function isSurfaceDisabled() {}
1385
1386 /** @param {string} className */
1387
1388 }, {
1389 key: "addClass",
1390 value: function addClass(className) {}
1391
1392 /** @param {string} className */
1393
1394 }, {
1395 key: "removeClass",
1396 value: function removeClass(className) {}
1397
1398 /** @param {!EventTarget} target */
1399
1400 }, {
1401 key: "containsEventTarget",
1402 value: function containsEventTarget(target) {}
1403
1404 /**
1405 * @param {string} evtType
1406 * @param {!Function} handler
1407 */
1408
1409 }, {
1410 key: "registerInteractionHandler",
1411 value: function registerInteractionHandler(evtType, handler) {}
1412
1413 /**
1414 * @param {string} evtType
1415 * @param {!Function} handler
1416 */
1417
1418 }, {
1419 key: "deregisterInteractionHandler",
1420 value: function deregisterInteractionHandler(evtType, handler) {}
1421
1422 /**
1423 * @param {string} evtType
1424 * @param {!Function} handler
1425 */
1426
1427 }, {
1428 key: "registerDocumentInteractionHandler",
1429 value: function registerDocumentInteractionHandler(evtType, handler) {}
1430
1431 /**
1432 * @param {string} evtType
1433 * @param {!Function} handler
1434 */
1435
1436 }, {
1437 key: "deregisterDocumentInteractionHandler",
1438 value: function deregisterDocumentInteractionHandler(evtType, handler) {}
1439
1440 /**
1441 * @param {!Function} handler
1442 */
1443
1444 }, {
1445 key: "registerResizeHandler",
1446 value: function registerResizeHandler(handler) {}
1447
1448 /**
1449 * @param {!Function} handler
1450 */
1451
1452 }, {
1453 key: "deregisterResizeHandler",
1454 value: function deregisterResizeHandler(handler) {}
1455
1456 /**
1457 * @param {string} varName
1458 * @param {?number|string} value
1459 */
1460
1461 }, {
1462 key: "updateCssVariable",
1463 value: function updateCssVariable(varName, value) {}
1464
1465 /** @return {!ClientRect} */
1466
1467 }, {
1468 key: "computeBoundingRect",
1469 value: function computeBoundingRect() {}
1470
1471 /** @return {{x: number, y: number}} */
1472
1473 }, {
1474 key: "getWindowPageOffset",
1475 value: function getWindowPageOffset() {}
1476 }]);
1477
1478 return MDCRippleAdapter;
1479}();
1480
1481/* unused harmony default export */ var _unused_webpack_default_export = (MDCRippleAdapter);
1482
1483/***/ }),
1484
1485/***/ 4:
1486/***/ (function(module, __webpack_exports__, __webpack_require__) {
1487
1488"use strict";
1489Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
1490/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MDCRipple", function() { return MDCRipple; });
1491/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RippleCapableSurface", function() { return RippleCapableSurface; });
1492/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__material_base_component__ = __webpack_require__(1);
1493/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__adapter__ = __webpack_require__(3);
1494/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__foundation__ = __webpack_require__(5);
1495/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util__ = __webpack_require__(2);
1496/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "MDCRippleFoundation", function() { return __WEBPACK_IMPORTED_MODULE_2__foundation__["a"]; });
1497/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "util", function() { return __WEBPACK_IMPORTED_MODULE_3__util__; });
1498var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1499
1500function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1501
1502function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
1503
1504function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
1505
1506/**
1507 * @license
1508 * Copyright 2016 Google Inc.
1509 *
1510 * Permission is hereby granted, free of charge, to any person obtaining a copy
1511 * of this software and associated documentation files (the "Software"), to deal
1512 * in the Software without restriction, including without limitation the rights
1513 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1514 * copies of the Software, and to permit persons to whom the Software is
1515 * furnished to do so, subject to the following conditions:
1516 *
1517 * The above copyright notice and this permission notice shall be included in
1518 * all copies or substantial portions of the Software.
1519 *
1520 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1521 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1522 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1523 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1524 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1525 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1526 * THE SOFTWARE.
1527 */
1528
1529
1530
1531
1532
1533
1534/**
1535 * @extends MDCComponent<!MDCRippleFoundation>
1536 */
1537
1538var MDCRipple = function (_MDCComponent) {
1539 _inherits(MDCRipple, _MDCComponent);
1540
1541 /** @param {...?} args */
1542 function MDCRipple() {
1543 var _ref;
1544
1545 _classCallCheck(this, MDCRipple);
1546
1547 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
1548 args[_key] = arguments[_key];
1549 }
1550
1551 /** @type {boolean} */
1552 var _this = _possibleConstructorReturn(this, (_ref = MDCRipple.__proto__ || Object.getPrototypeOf(MDCRipple)).call.apply(_ref, [this].concat(args)));
1553
1554 _this.disabled = false;
1555
1556 /** @private {boolean} */
1557 _this.unbounded_;
1558 return _this;
1559 }
1560
1561 /**
1562 * @param {!Element} root
1563 * @param {{isUnbounded: (boolean|undefined)}=} options
1564 * @return {!MDCRipple}
1565 */
1566
1567
1568 _createClass(MDCRipple, [{
1569 key: 'setUnbounded_',
1570
1571
1572 /**
1573 * Closure Compiler throws an access control error when directly accessing a
1574 * protected or private property inside a getter/setter, like unbounded above.
1575 * By accessing the protected property inside a method, we solve that problem.
1576 * That's why this function exists.
1577 * @private
1578 */
1579 value: function setUnbounded_() {
1580 this.foundation_.setUnbounded(this.unbounded_);
1581 }
1582 }, {
1583 key: 'activate',
1584 value: function activate() {
1585 this.foundation_.activate();
1586 }
1587 }, {
1588 key: 'deactivate',
1589 value: function deactivate() {
1590 this.foundation_.deactivate();
1591 }
1592 }, {
1593 key: 'layout',
1594 value: function layout() {
1595 this.foundation_.layout();
1596 }
1597
1598 /**
1599 * @return {!MDCRippleFoundation}
1600 * @override
1601 */
1602
1603 }, {
1604 key: 'getDefaultFoundation',
1605 value: function getDefaultFoundation() {
1606 return new __WEBPACK_IMPORTED_MODULE_2__foundation__["a" /* default */](MDCRipple.createAdapter(this));
1607 }
1608
1609 /** @override */
1610
1611 }, {
1612 key: 'initialSyncWithDOM',
1613 value: function initialSyncWithDOM() {
1614 this.unbounded = 'mdcRippleIsUnbounded' in this.root_.dataset;
1615 }
1616 }, {
1617 key: 'unbounded',
1618
1619
1620 /** @return {boolean} */
1621 get: function get() {
1622 return this.unbounded_;
1623 }
1624
1625 /** @param {boolean} unbounded */
1626 ,
1627 set: function set(unbounded) {
1628 this.unbounded_ = Boolean(unbounded);
1629 this.setUnbounded_();
1630 }
1631 }], [{
1632 key: 'attachTo',
1633 value: function attachTo(root) {
1634 var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
1635 _ref2$isUnbounded = _ref2.isUnbounded,
1636 isUnbounded = _ref2$isUnbounded === undefined ? undefined : _ref2$isUnbounded;
1637
1638 var ripple = new MDCRipple(root);
1639 // Only override unbounded behavior if option is explicitly specified
1640 if (isUnbounded !== undefined) {
1641 ripple.unbounded = /** @type {boolean} */isUnbounded;
1642 }
1643 return ripple;
1644 }
1645
1646 /**
1647 * @param {!RippleCapableSurface} instance
1648 * @return {!MDCRippleAdapter}
1649 */
1650
1651 }, {
1652 key: 'createAdapter',
1653 value: function createAdapter(instance) {
1654 var MATCHES = __WEBPACK_IMPORTED_MODULE_3__util__["getMatchesProperty"](HTMLElement.prototype);
1655
1656 return {
1657 browserSupportsCssVars: function browserSupportsCssVars() {
1658 return __WEBPACK_IMPORTED_MODULE_3__util__["supportsCssVariables"](window);
1659 },
1660 isUnbounded: function isUnbounded() {
1661 return instance.unbounded;
1662 },
1663 isSurfaceActive: function isSurfaceActive() {
1664 return instance.root_[MATCHES](':active');
1665 },
1666 isSurfaceDisabled: function isSurfaceDisabled() {
1667 return instance.disabled;
1668 },
1669 addClass: function addClass(className) {
1670 return instance.root_.classList.add(className);
1671 },
1672 removeClass: function removeClass(className) {
1673 return instance.root_.classList.remove(className);
1674 },
1675 containsEventTarget: function containsEventTarget(target) {
1676 return instance.root_.contains(target);
1677 },
1678 registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
1679 return instance.root_.addEventListener(evtType, handler, __WEBPACK_IMPORTED_MODULE_3__util__["applyPassive"]());
1680 },
1681 deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
1682 return instance.root_.removeEventListener(evtType, handler, __WEBPACK_IMPORTED_MODULE_3__util__["applyPassive"]());
1683 },
1684 registerDocumentInteractionHandler: function registerDocumentInteractionHandler(evtType, handler) {
1685 return document.documentElement.addEventListener(evtType, handler, __WEBPACK_IMPORTED_MODULE_3__util__["applyPassive"]());
1686 },
1687 deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler(evtType, handler) {
1688 return document.documentElement.removeEventListener(evtType, handler, __WEBPACK_IMPORTED_MODULE_3__util__["applyPassive"]());
1689 },
1690 registerResizeHandler: function registerResizeHandler(handler) {
1691 return window.addEventListener('resize', handler);
1692 },
1693 deregisterResizeHandler: function deregisterResizeHandler(handler) {
1694 return window.removeEventListener('resize', handler);
1695 },
1696 updateCssVariable: function updateCssVariable(varName, value) {
1697 return instance.root_.style.setProperty(varName, value);
1698 },
1699 computeBoundingRect: function computeBoundingRect() {
1700 return instance.root_.getBoundingClientRect();
1701 },
1702 getWindowPageOffset: function getWindowPageOffset() {
1703 return { x: window.pageXOffset, y: window.pageYOffset };
1704 }
1705 };
1706 }
1707 }]);
1708
1709 return MDCRipple;
1710}(__WEBPACK_IMPORTED_MODULE_0__material_base_component__["a" /* default */]);
1711
1712/**
1713 * See Material Design spec for more details on when to use ripples.
1714 * https://material.io/guidelines/motion/choreography.html#choreography-creation
1715 * @record
1716 */
1717
1718
1719var RippleCapableSurface = function RippleCapableSurface() {
1720 _classCallCheck(this, RippleCapableSurface);
1721};
1722
1723/** @protected {!Element} */
1724
1725
1726RippleCapableSurface.prototype.root_;
1727
1728/**
1729 * Whether or not the ripple bleeds out of the bounds of the element.
1730 * @type {boolean|undefined}
1731 */
1732RippleCapableSurface.prototype.unbounded;
1733
1734/**
1735 * Whether or not the ripple is attached to a disabled component.
1736 * @type {boolean|undefined}
1737 */
1738RippleCapableSurface.prototype.disabled;
1739
1740
1741
1742/***/ }),
1743
1744/***/ 5:
1745/***/ (function(module, __webpack_exports__, __webpack_require__) {
1746
1747"use strict";
1748/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__material_base_foundation__ = __webpack_require__(0);
1749/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__adapter__ = __webpack_require__(3);
1750/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__constants__ = __webpack_require__(6);
1751/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util__ = __webpack_require__(2);
1752var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
1753
1754var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1755
1756function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1757
1758function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
1759
1760function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
1761
1762/**
1763 * @license
1764 * Copyright 2016 Google Inc.
1765 *
1766 * Permission is hereby granted, free of charge, to any person obtaining a copy
1767 * of this software and associated documentation files (the "Software"), to deal
1768 * in the Software without restriction, including without limitation the rights
1769 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1770 * copies of the Software, and to permit persons to whom the Software is
1771 * furnished to do so, subject to the following conditions:
1772 *
1773 * The above copyright notice and this permission notice shall be included in
1774 * all copies or substantial portions of the Software.
1775 *
1776 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1777 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1778 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1779 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1780 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1781 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1782 * THE SOFTWARE.
1783 */
1784
1785
1786
1787
1788
1789
1790/**
1791 * @typedef {{
1792 * isActivated: (boolean|undefined),
1793 * hasDeactivationUXRun: (boolean|undefined),
1794 * wasActivatedByPointer: (boolean|undefined),
1795 * wasElementMadeActive: (boolean|undefined),
1796 * activationEvent: (!Event|undefined),
1797 * isProgrammatic: (boolean|undefined)
1798 * }}
1799 */
1800var ActivationStateType = void 0;
1801
1802/**
1803 * @typedef {{
1804 * activate: (string|undefined),
1805 * deactivate: (string|undefined),
1806 * focus: (string|undefined),
1807 * blur: (string|undefined)
1808 * }}
1809 */
1810var ListenerInfoType = void 0;
1811
1812/**
1813 * @typedef {{
1814 * activate: function(!Event),
1815 * deactivate: function(!Event=),
1816 * focus: function(),
1817 * blur: function()
1818 * }}
1819 */
1820var ListenersType = void 0;
1821
1822/**
1823 * @typedef {{
1824 * x: number,
1825 * y: number
1826 * }}
1827 */
1828var PointType = void 0;
1829
1830// Activation events registered on the root element of each instance for activation
1831var ACTIVATION_EVENT_TYPES = ['touchstart', 'pointerdown', 'mousedown', 'keydown'];
1832
1833// Deactivation events registered on documentElement when a pointer-related down event occurs
1834var POINTER_DEACTIVATION_EVENT_TYPES = ['touchend', 'pointerup', 'mouseup', 'contextmenu'];
1835
1836// Tracks activations that have occurred on the current frame, to avoid simultaneous nested activations
1837/** @type {!Array<!EventTarget>} */
1838var activatedTargets = [];
1839
1840/**
1841 * @extends {MDCFoundation<!MDCRippleAdapter>}
1842 */
1843
1844var MDCRippleFoundation = function (_MDCFoundation) {
1845 _inherits(MDCRippleFoundation, _MDCFoundation);
1846
1847 _createClass(MDCRippleFoundation, null, [{
1848 key: 'cssClasses',
1849 get: function get() {
1850 return __WEBPACK_IMPORTED_MODULE_2__constants__["a" /* cssClasses */];
1851 }
1852 }, {
1853 key: 'strings',
1854 get: function get() {
1855 return __WEBPACK_IMPORTED_MODULE_2__constants__["c" /* strings */];
1856 }
1857 }, {
1858 key: 'numbers',
1859 get: function get() {
1860 return __WEBPACK_IMPORTED_MODULE_2__constants__["b" /* numbers */];
1861 }
1862 }, {
1863 key: 'defaultAdapter',
1864 get: function get() {
1865 return {
1866 browserSupportsCssVars: function browserSupportsCssVars() /* boolean - cached */{},
1867 isUnbounded: function isUnbounded() /* boolean */{},
1868 isSurfaceActive: function isSurfaceActive() /* boolean */{},
1869 isSurfaceDisabled: function isSurfaceDisabled() /* boolean */{},
1870 addClass: function addClass() /* className: string */{},
1871 removeClass: function removeClass() /* className: string */{},
1872 containsEventTarget: function containsEventTarget() /* target: !EventTarget */{},
1873 registerInteractionHandler: function registerInteractionHandler() /* evtType: string, handler: EventListener */{},
1874 deregisterInteractionHandler: function deregisterInteractionHandler() /* evtType: string, handler: EventListener */{},
1875 registerDocumentInteractionHandler: function registerDocumentInteractionHandler() /* evtType: string, handler: EventListener */{},
1876 deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() /* evtType: string, handler: EventListener */{},
1877 registerResizeHandler: function registerResizeHandler() /* handler: EventListener */{},
1878 deregisterResizeHandler: function deregisterResizeHandler() /* handler: EventListener */{},
1879 updateCssVariable: function updateCssVariable() /* varName: string, value: string */{},
1880 computeBoundingRect: function computeBoundingRect() /* ClientRect */{},
1881 getWindowPageOffset: function getWindowPageOffset() /* {x: number, y: number} */{}
1882 };
1883 }
1884 }]);
1885
1886 function MDCRippleFoundation(adapter) {
1887 _classCallCheck(this, MDCRippleFoundation);
1888
1889 /** @private {number} */
1890 var _this = _possibleConstructorReturn(this, (MDCRippleFoundation.__proto__ || Object.getPrototypeOf(MDCRippleFoundation)).call(this, _extends(MDCRippleFoundation.defaultAdapter, adapter)));
1891
1892 _this.layoutFrame_ = 0;
1893
1894 /** @private {!ClientRect} */
1895 _this.frame_ = /** @type {!ClientRect} */{ width: 0, height: 0 };
1896
1897 /** @private {!ActivationStateType} */
1898 _this.activationState_ = _this.defaultActivationState_();
1899
1900 /** @private {number} */
1901 _this.initialSize_ = 0;
1902
1903 /** @private {number} */
1904 _this.maxRadius_ = 0;
1905
1906 /** @private {function(!Event)} */
1907 _this.activateHandler_ = function (e) {
1908 return _this.activate_(e);
1909 };
1910
1911 /** @private {function(!Event=)} */
1912 _this.deactivateHandler_ = function () {
1913 return _this.deactivate_();
1914 };
1915
1916 /** @private {function(!Event=)} */
1917 _this.focusHandler_ = function () {
1918 return _this.handleFocus();
1919 };
1920
1921 /** @private {function(!Event=)} */
1922 _this.blurHandler_ = function () {
1923 return _this.handleBlur();
1924 };
1925
1926 /** @private {!Function} */
1927 _this.resizeHandler_ = function () {
1928 return _this.layout();
1929 };
1930
1931 /** @private {{left: number, top:number}} */
1932 _this.unboundedCoords_ = {
1933 left: 0,
1934 top: 0
1935 };
1936
1937 /** @private {number} */
1938 _this.fgScale_ = 0;
1939
1940 /** @private {number} */
1941 _this.activationTimer_ = 0;
1942
1943 /** @private {number} */
1944 _this.fgDeactivationRemovalTimer_ = 0;
1945
1946 /** @private {boolean} */
1947 _this.activationAnimationHasEnded_ = false;
1948
1949 /** @private {!Function} */
1950 _this.activationTimerCallback_ = function () {
1951 _this.activationAnimationHasEnded_ = true;
1952 _this.runDeactivationUXLogicIfReady_();
1953 };
1954
1955 /** @private {!Event|undefined} */
1956 _this.previousActivationEvent_;
1957 return _this;
1958 }
1959
1960 /**
1961 * We compute this property so that we are not querying information about the client
1962 * until the point in time where the foundation requests it. This prevents scenarios where
1963 * client-side feature-detection may happen too early, such as when components are rendered on the server
1964 * and then initialized at mount time on the client.
1965 * @return {boolean}
1966 * @private
1967 */
1968
1969
1970 _createClass(MDCRippleFoundation, [{
1971 key: 'supportsPressRipple_',
1972 value: function supportsPressRipple_() {
1973 return this.adapter_.browserSupportsCssVars();
1974 }
1975
1976 /**
1977 * @return {!ActivationStateType}
1978 */
1979
1980 }, {
1981 key: 'defaultActivationState_',
1982 value: function defaultActivationState_() {
1983 return {
1984 isActivated: false,
1985 hasDeactivationUXRun: false,
1986 wasActivatedByPointer: false,
1987 wasElementMadeActive: false,
1988 activationEvent: undefined,
1989 isProgrammatic: false
1990 };
1991 }
1992
1993 /** @override */
1994
1995 }, {
1996 key: 'init',
1997 value: function init() {
1998 var _this2 = this;
1999
2000 var supportsPressRipple = this.supportsPressRipple_();
2001
2002 this.registerRootHandlers_(supportsPressRipple);
2003
2004 if (supportsPressRipple) {
2005 var _MDCRippleFoundation$ = MDCRippleFoundation.cssClasses,
2006 ROOT = _MDCRippleFoundation$.ROOT,
2007 UNBOUNDED = _MDCRippleFoundation$.UNBOUNDED;
2008
2009 requestAnimationFrame(function () {
2010 _this2.adapter_.addClass(ROOT);
2011 if (_this2.adapter_.isUnbounded()) {
2012 _this2.adapter_.addClass(UNBOUNDED);
2013 // Unbounded ripples need layout logic applied immediately to set coordinates for both shade and ripple
2014 _this2.layoutInternal_();
2015 }
2016 });
2017 }
2018 }
2019
2020 /** @override */
2021
2022 }, {
2023 key: 'destroy',
2024 value: function destroy() {
2025 var _this3 = this;
2026
2027 if (this.supportsPressRipple_()) {
2028 if (this.activationTimer_) {
2029 clearTimeout(this.activationTimer_);
2030 this.activationTimer_ = 0;
2031 this.adapter_.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION);
2032 }
2033
2034 if (this.fgDeactivationRemovalTimer_) {
2035 clearTimeout(this.fgDeactivationRemovalTimer_);
2036 this.fgDeactivationRemovalTimer_ = 0;
2037 this.adapter_.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION);
2038 }
2039
2040 var _MDCRippleFoundation$2 = MDCRippleFoundation.cssClasses,
2041 ROOT = _MDCRippleFoundation$2.ROOT,
2042 UNBOUNDED = _MDCRippleFoundation$2.UNBOUNDED;
2043
2044 requestAnimationFrame(function () {
2045 _this3.adapter_.removeClass(ROOT);
2046 _this3.adapter_.removeClass(UNBOUNDED);
2047 _this3.removeCssVars_();
2048 });
2049 }
2050
2051 this.deregisterRootHandlers_();
2052 this.deregisterDeactivationHandlers_();
2053 }
2054
2055 /**
2056 * @param {boolean} supportsPressRipple Passed from init to save a redundant function call
2057 * @private
2058 */
2059
2060 }, {
2061 key: 'registerRootHandlers_',
2062 value: function registerRootHandlers_(supportsPressRipple) {
2063 var _this4 = this;
2064
2065 if (supportsPressRipple) {
2066 ACTIVATION_EVENT_TYPES.forEach(function (type) {
2067 _this4.adapter_.registerInteractionHandler(type, _this4.activateHandler_);
2068 });
2069 if (this.adapter_.isUnbounded()) {
2070 this.adapter_.registerResizeHandler(this.resizeHandler_);
2071 }
2072 }
2073
2074 this.adapter_.registerInteractionHandler('focus', this.focusHandler_);
2075 this.adapter_.registerInteractionHandler('blur', this.blurHandler_);
2076 }
2077
2078 /**
2079 * @param {!Event} e
2080 * @private
2081 */
2082
2083 }, {
2084 key: 'registerDeactivationHandlers_',
2085 value: function registerDeactivationHandlers_(e) {
2086 var _this5 = this;
2087
2088 if (e.type === 'keydown') {
2089 this.adapter_.registerInteractionHandler('keyup', this.deactivateHandler_);
2090 } else {
2091 POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (type) {
2092 _this5.adapter_.registerDocumentInteractionHandler(type, _this5.deactivateHandler_);
2093 });
2094 }
2095 }
2096
2097 /** @private */
2098
2099 }, {
2100 key: 'deregisterRootHandlers_',
2101 value: function deregisterRootHandlers_() {
2102 var _this6 = this;
2103
2104 ACTIVATION_EVENT_TYPES.forEach(function (type) {
2105 _this6.adapter_.deregisterInteractionHandler(type, _this6.activateHandler_);
2106 });
2107 this.adapter_.deregisterInteractionHandler('focus', this.focusHandler_);
2108 this.adapter_.deregisterInteractionHandler('blur', this.blurHandler_);
2109
2110 if (this.adapter_.isUnbounded()) {
2111 this.adapter_.deregisterResizeHandler(this.resizeHandler_);
2112 }
2113 }
2114
2115 /** @private */
2116
2117 }, {
2118 key: 'deregisterDeactivationHandlers_',
2119 value: function deregisterDeactivationHandlers_() {
2120 var _this7 = this;
2121
2122 this.adapter_.deregisterInteractionHandler('keyup', this.deactivateHandler_);
2123 POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (type) {
2124 _this7.adapter_.deregisterDocumentInteractionHandler(type, _this7.deactivateHandler_);
2125 });
2126 }
2127
2128 /** @private */
2129
2130 }, {
2131 key: 'removeCssVars_',
2132 value: function removeCssVars_() {
2133 var _this8 = this;
2134
2135 var strings = MDCRippleFoundation.strings;
2136
2137 Object.keys(strings).forEach(function (k) {
2138 if (k.indexOf('VAR_') === 0) {
2139 _this8.adapter_.updateCssVariable(strings[k], null);
2140 }
2141 });
2142 }
2143
2144 /**
2145 * @param {!Event=} e
2146 * @private
2147 */
2148
2149 }, {
2150 key: 'activate_',
2151 value: function activate_(e) {
2152 var _this9 = this;
2153
2154 if (this.adapter_.isSurfaceDisabled()) {
2155 return;
2156 }
2157
2158 var activationState = this.activationState_;
2159 if (activationState.isActivated) {
2160 return;
2161 }
2162
2163 // Avoid reacting to follow-on events fired by touch device after an already-processed user interaction
2164 var previousActivationEvent = this.previousActivationEvent_;
2165 var isSameInteraction = previousActivationEvent && e !== undefined && previousActivationEvent.type !== e.type;
2166 if (isSameInteraction) {
2167 return;
2168 }
2169
2170 activationState.isActivated = true;
2171 activationState.isProgrammatic = e === undefined;
2172 activationState.activationEvent = e;
2173 activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : e !== undefined && (e.type === 'mousedown' || e.type === 'touchstart' || e.type === 'pointerdown');
2174
2175 var hasActivatedChild = e !== undefined && activatedTargets.length > 0 && activatedTargets.some(function (target) {
2176 return _this9.adapter_.containsEventTarget(target);
2177 });
2178 if (hasActivatedChild) {
2179 // Immediately reset activation state, while preserving logic that prevents touch follow-on events
2180 this.resetActivationState_();
2181 return;
2182 }
2183
2184 if (e !== undefined) {
2185 activatedTargets.push( /** @type {!EventTarget} */e.target);
2186 this.registerDeactivationHandlers_(e);
2187 }
2188
2189 activationState.wasElementMadeActive = this.checkElementMadeActive_(e);
2190 if (activationState.wasElementMadeActive) {
2191 this.animateActivation_();
2192 }
2193
2194 requestAnimationFrame(function () {
2195 // Reset array on next frame after the current event has had a chance to bubble to prevent ancestor ripples
2196 activatedTargets = [];
2197
2198 if (!activationState.wasElementMadeActive && e !== undefined && (e.key === ' ' || e.keyCode === 32)) {
2199 // If space was pressed, try again within an rAF call to detect :active, because different UAs report
2200 // active states inconsistently when they're called within event handling code:
2201 // - https://bugs.chromium.org/p/chromium/issues/detail?id=635971
2202 // - https://bugzilla.mozilla.org/show_bug.cgi?id=1293741
2203 // We try first outside rAF to support Edge, which does not exhibit this problem, but will crash if a CSS
2204 // variable is set within a rAF callback for a submit button interaction (#2241).
2205 activationState.wasElementMadeActive = _this9.checkElementMadeActive_(e);
2206 if (activationState.wasElementMadeActive) {
2207 _this9.animateActivation_();
2208 }
2209 }
2210
2211 if (!activationState.wasElementMadeActive) {
2212 // Reset activation state immediately if element was not made active.
2213 _this9.activationState_ = _this9.defaultActivationState_();
2214 }
2215 });
2216 }
2217
2218 /**
2219 * @param {!Event=} e
2220 * @private
2221 */
2222
2223 }, {
2224 key: 'checkElementMadeActive_',
2225 value: function checkElementMadeActive_(e) {
2226 return e !== undefined && e.type === 'keydown' ? this.adapter_.isSurfaceActive() : true;
2227 }
2228
2229 /**
2230 * @param {!Event=} event Optional event containing position information.
2231 */
2232
2233 }, {
2234 key: 'activate',
2235 value: function activate(event) {
2236 this.activate_(event);
2237 }
2238
2239 /** @private */
2240
2241 }, {
2242 key: 'animateActivation_',
2243 value: function animateActivation_() {
2244 var _this10 = this;
2245
2246 var _MDCRippleFoundation$3 = MDCRippleFoundation.strings,
2247 VAR_FG_TRANSLATE_START = _MDCRippleFoundation$3.VAR_FG_TRANSLATE_START,
2248 VAR_FG_TRANSLATE_END = _MDCRippleFoundation$3.VAR_FG_TRANSLATE_END;
2249 var _MDCRippleFoundation$4 = MDCRippleFoundation.cssClasses,
2250 FG_DEACTIVATION = _MDCRippleFoundation$4.FG_DEACTIVATION,
2251 FG_ACTIVATION = _MDCRippleFoundation$4.FG_ACTIVATION;
2252 var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
2253
2254
2255 this.layoutInternal_();
2256
2257 var translateStart = '';
2258 var translateEnd = '';
2259
2260 if (!this.adapter_.isUnbounded()) {
2261 var _getFgTranslationCoor = this.getFgTranslationCoordinates_(),
2262 startPoint = _getFgTranslationCoor.startPoint,
2263 endPoint = _getFgTranslationCoor.endPoint;
2264
2265 translateStart = startPoint.x + 'px, ' + startPoint.y + 'px';
2266 translateEnd = endPoint.x + 'px, ' + endPoint.y + 'px';
2267 }
2268
2269 this.adapter_.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
2270 this.adapter_.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
2271 // Cancel any ongoing activation/deactivation animations
2272 clearTimeout(this.activationTimer_);
2273 clearTimeout(this.fgDeactivationRemovalTimer_);
2274 this.rmBoundedActivationClasses_();
2275 this.adapter_.removeClass(FG_DEACTIVATION);
2276
2277 // Force layout in order to re-trigger the animation.
2278 this.adapter_.computeBoundingRect();
2279 this.adapter_.addClass(FG_ACTIVATION);
2280 this.activationTimer_ = setTimeout(function () {
2281 return _this10.activationTimerCallback_();
2282 }, DEACTIVATION_TIMEOUT_MS);
2283 }
2284
2285 /**
2286 * @private
2287 * @return {{startPoint: PointType, endPoint: PointType}}
2288 */
2289
2290 }, {
2291 key: 'getFgTranslationCoordinates_',
2292 value: function getFgTranslationCoordinates_() {
2293 var _activationState_ = this.activationState_,
2294 activationEvent = _activationState_.activationEvent,
2295 wasActivatedByPointer = _activationState_.wasActivatedByPointer;
2296
2297
2298 var startPoint = void 0;
2299 if (wasActivatedByPointer) {
2300 startPoint = Object(__WEBPACK_IMPORTED_MODULE_3__util__["getNormalizedEventCoords"])(
2301 /** @type {!Event} */activationEvent, this.adapter_.getWindowPageOffset(), this.adapter_.computeBoundingRect());
2302 } else {
2303 startPoint = {
2304 x: this.frame_.width / 2,
2305 y: this.frame_.height / 2
2306 };
2307 }
2308 // Center the element around the start point.
2309 startPoint = {
2310 x: startPoint.x - this.initialSize_ / 2,
2311 y: startPoint.y - this.initialSize_ / 2
2312 };
2313
2314 var endPoint = {
2315 x: this.frame_.width / 2 - this.initialSize_ / 2,
2316 y: this.frame_.height / 2 - this.initialSize_ / 2
2317 };
2318
2319 return { startPoint: startPoint, endPoint: endPoint };
2320 }
2321
2322 /** @private */
2323
2324 }, {
2325 key: 'runDeactivationUXLogicIfReady_',
2326 value: function runDeactivationUXLogicIfReady_() {
2327 var _this11 = this;
2328
2329 // This method is called both when a pointing device is released, and when the activation animation ends.
2330 // The deactivation animation should only run after both of those occur.
2331 var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
2332 var _activationState_2 = this.activationState_,
2333 hasDeactivationUXRun = _activationState_2.hasDeactivationUXRun,
2334 isActivated = _activationState_2.isActivated;
2335
2336 var activationHasEnded = hasDeactivationUXRun || !isActivated;
2337
2338 if (activationHasEnded && this.activationAnimationHasEnded_) {
2339 this.rmBoundedActivationClasses_();
2340 this.adapter_.addClass(FG_DEACTIVATION);
2341 this.fgDeactivationRemovalTimer_ = setTimeout(function () {
2342 _this11.adapter_.removeClass(FG_DEACTIVATION);
2343 }, __WEBPACK_IMPORTED_MODULE_2__constants__["b" /* numbers */].FG_DEACTIVATION_MS);
2344 }
2345 }
2346
2347 /** @private */
2348
2349 }, {
2350 key: 'rmBoundedActivationClasses_',
2351 value: function rmBoundedActivationClasses_() {
2352 var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION;
2353
2354 this.adapter_.removeClass(FG_ACTIVATION);
2355 this.activationAnimationHasEnded_ = false;
2356 this.adapter_.computeBoundingRect();
2357 }
2358 }, {
2359 key: 'resetActivationState_',
2360 value: function resetActivationState_() {
2361 var _this12 = this;
2362
2363 this.previousActivationEvent_ = this.activationState_.activationEvent;
2364 this.activationState_ = this.defaultActivationState_();
2365 // Touch devices may fire additional events for the same interaction within a short time.
2366 // Store the previous event until it's safe to assume that subsequent events are for new interactions.
2367 setTimeout(function () {
2368 return _this12.previousActivationEvent_ = undefined;
2369 }, MDCRippleFoundation.numbers.TAP_DELAY_MS);
2370 }
2371
2372 /**
2373 * @private
2374 */
2375
2376 }, {
2377 key: 'deactivate_',
2378 value: function deactivate_() {
2379 var _this13 = this;
2380
2381 var activationState = this.activationState_;
2382 // This can happen in scenarios such as when you have a keyup event that blurs the element.
2383 if (!activationState.isActivated) {
2384 return;
2385 }
2386
2387 var state = /** @type {!ActivationStateType} */_extends({}, activationState);
2388
2389 if (activationState.isProgrammatic) {
2390 requestAnimationFrame(function () {
2391 return _this13.animateDeactivation_(state);
2392 });
2393 this.resetActivationState_();
2394 } else {
2395 this.deregisterDeactivationHandlers_();
2396 requestAnimationFrame(function () {
2397 _this13.activationState_.hasDeactivationUXRun = true;
2398 _this13.animateDeactivation_(state);
2399 _this13.resetActivationState_();
2400 });
2401 }
2402 }
2403 }, {
2404 key: 'deactivate',
2405 value: function deactivate() {
2406 this.deactivate_();
2407 }
2408
2409 /**
2410 * @param {!ActivationStateType} options
2411 * @private
2412 */
2413
2414 }, {
2415 key: 'animateDeactivation_',
2416 value: function animateDeactivation_(_ref) {
2417 var wasActivatedByPointer = _ref.wasActivatedByPointer,
2418 wasElementMadeActive = _ref.wasElementMadeActive;
2419
2420 if (wasActivatedByPointer || wasElementMadeActive) {
2421 this.runDeactivationUXLogicIfReady_();
2422 }
2423 }
2424 }, {
2425 key: 'layout',
2426 value: function layout() {
2427 var _this14 = this;
2428
2429 if (this.layoutFrame_) {
2430 cancelAnimationFrame(this.layoutFrame_);
2431 }
2432 this.layoutFrame_ = requestAnimationFrame(function () {
2433 _this14.layoutInternal_();
2434 _this14.layoutFrame_ = 0;
2435 });
2436 }
2437
2438 /** @private */
2439
2440 }, {
2441 key: 'layoutInternal_',
2442 value: function layoutInternal_() {
2443 var _this15 = this;
2444
2445 this.frame_ = this.adapter_.computeBoundingRect();
2446 var maxDim = Math.max(this.frame_.height, this.frame_.width);
2447
2448 // Surface diameter is treated differently for unbounded vs. bounded ripples.
2449 // Unbounded ripple diameter is calculated smaller since the surface is expected to already be padded appropriately
2450 // to extend the hitbox, and the ripple is expected to meet the edges of the padded hitbox (which is typically
2451 // square). Bounded ripples, on the other hand, are fully expected to expand beyond the surface's longest diameter
2452 // (calculated based on the diagonal plus a constant padding), and are clipped at the surface's border via
2453 // `overflow: hidden`.
2454 var getBoundedRadius = function getBoundedRadius() {
2455 var hypotenuse = Math.sqrt(Math.pow(_this15.frame_.width, 2) + Math.pow(_this15.frame_.height, 2));
2456 return hypotenuse + MDCRippleFoundation.numbers.PADDING;
2457 };
2458
2459 this.maxRadius_ = this.adapter_.isUnbounded() ? maxDim : getBoundedRadius();
2460
2461 // Ripple is sized as a fraction of the largest dimension of the surface, then scales up using a CSS scale transform
2462 this.initialSize_ = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
2463 this.fgScale_ = this.maxRadius_ / this.initialSize_;
2464
2465 this.updateLayoutCssVars_();
2466 }
2467
2468 /** @private */
2469
2470 }, {
2471 key: 'updateLayoutCssVars_',
2472 value: function updateLayoutCssVars_() {
2473 var _MDCRippleFoundation$5 = MDCRippleFoundation.strings,
2474 VAR_FG_SIZE = _MDCRippleFoundation$5.VAR_FG_SIZE,
2475 VAR_LEFT = _MDCRippleFoundation$5.VAR_LEFT,
2476 VAR_TOP = _MDCRippleFoundation$5.VAR_TOP,
2477 VAR_FG_SCALE = _MDCRippleFoundation$5.VAR_FG_SCALE;
2478
2479
2480 this.adapter_.updateCssVariable(VAR_FG_SIZE, this.initialSize_ + 'px');
2481 this.adapter_.updateCssVariable(VAR_FG_SCALE, this.fgScale_);
2482
2483 if (this.adapter_.isUnbounded()) {
2484 this.unboundedCoords_ = {
2485 left: Math.round(this.frame_.width / 2 - this.initialSize_ / 2),
2486 top: Math.round(this.frame_.height / 2 - this.initialSize_ / 2)
2487 };
2488
2489 this.adapter_.updateCssVariable(VAR_LEFT, this.unboundedCoords_.left + 'px');
2490 this.adapter_.updateCssVariable(VAR_TOP, this.unboundedCoords_.top + 'px');
2491 }
2492 }
2493
2494 /** @param {boolean} unbounded */
2495
2496 }, {
2497 key: 'setUnbounded',
2498 value: function setUnbounded(unbounded) {
2499 var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED;
2500
2501 if (unbounded) {
2502 this.adapter_.addClass(UNBOUNDED);
2503 } else {
2504 this.adapter_.removeClass(UNBOUNDED);
2505 }
2506 }
2507 }, {
2508 key: 'handleFocus',
2509 value: function handleFocus() {
2510 var _this16 = this;
2511
2512 requestAnimationFrame(function () {
2513 return _this16.adapter_.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
2514 });
2515 }
2516 }, {
2517 key: 'handleBlur',
2518 value: function handleBlur() {
2519 var _this17 = this;
2520
2521 requestAnimationFrame(function () {
2522 return _this17.adapter_.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
2523 });
2524 }
2525 }]);
2526
2527 return MDCRippleFoundation;
2528}(__WEBPACK_IMPORTED_MODULE_0__material_base_foundation__["a" /* default */]);
2529
2530/* harmony default export */ __webpack_exports__["a"] = (MDCRippleFoundation);
2531
2532/***/ }),
2533
2534/***/ 6:
2535/***/ (function(module, __webpack_exports__, __webpack_require__) {
2536
2537"use strict";
2538/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return cssClasses; });
2539/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return strings; });
2540/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return numbers; });
2541/**
2542 * @license
2543 * Copyright 2016 Google Inc.
2544 *
2545 * Permission is hereby granted, free of charge, to any person obtaining a copy
2546 * of this software and associated documentation files (the "Software"), to deal
2547 * in the Software without restriction, including without limitation the rights
2548 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2549 * copies of the Software, and to permit persons to whom the Software is
2550 * furnished to do so, subject to the following conditions:
2551 *
2552 * The above copyright notice and this permission notice shall be included in
2553 * all copies or substantial portions of the Software.
2554 *
2555 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2556 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2557 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2558 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2559 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2560 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2561 * THE SOFTWARE.
2562 */
2563
2564var cssClasses = {
2565 // Ripple is a special case where the "root" component is really a "mixin" of sorts,
2566 // given that it's an 'upgrade' to an existing component. That being said it is the root
2567 // CSS class that all other CSS classes derive from.
2568 ROOT: 'mdc-ripple-upgraded',
2569 UNBOUNDED: 'mdc-ripple-upgraded--unbounded',
2570 BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
2571 FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
2572 FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation'
2573};
2574
2575var strings = {
2576 VAR_LEFT: '--mdc-ripple-left',
2577 VAR_TOP: '--mdc-ripple-top',
2578 VAR_FG_SIZE: '--mdc-ripple-fg-size',
2579 VAR_FG_SCALE: '--mdc-ripple-fg-scale',
2580 VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
2581 VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end'
2582};
2583
2584var numbers = {
2585 PADDING: 10,
2586 INITIAL_ORIGIN_SCALE: 0.6,
2587 DEACTIVATION_TIMEOUT_MS: 225, // Corresponds to $mdc-ripple-translate-duration (i.e. activation animation duration)
2588 FG_DEACTIVATION_MS: 150, // Corresponds to $mdc-ripple-fade-out-duration (i.e. deactivation animation duration)
2589 TAP_DELAY_MS: 300 };
2590
2591
2592
2593/***/ })
2594
2595/******/ });
2596});
2597//# sourceMappingURL=mdc.iconToggle.js.map
\No newline at end of file