UNPKG

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