| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423 |
- /**
- * @license
- * Copyright Google LLC All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://github.com/material-components/material-components-web/blob/master/LICENSE
- */
- (function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory();
- else if(typeof define === 'function' && define.amd)
- define([], factory);
- else if(typeof exports === 'object')
- exports["ripple"] = factory();
- else
- root["mdc"] = root["mdc"] || {}, root["mdc"]["ripple"] = factory();
- })(this, function() {
- return /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- /******/ }
- /******/ };
- /******/
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/
- /******/ // create a fake namespace object
- /******/ // mode & 1: value is a module id, require it
- /******/ // mode & 2: merge all properties of value into the ns
- /******/ // mode & 4: return value when already ns object
- /******/ // mode & 8|1: behave like require
- /******/ __webpack_require__.t = function(value, mode) {
- /******/ if(mode & 1) value = __webpack_require__(value);
- /******/ if(mode & 8) return value;
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- /******/ var ns = Object.create(null);
- /******/ __webpack_require__.r(ns);
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- /******/ return ns;
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = "./packages/mdc-ripple/index.ts");
- /******/ })
- /************************************************************************/
- /******/ ({
- /***/ "./packages/mdc-base/component.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-base/component.ts ***!
- \****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __read = this && this.__read || function (o, n) {
- var m = typeof Symbol === "function" && o[Symbol.iterator];
- if (!m) return o;
- var i = m.call(o),
- r,
- ar = [],
- e;
- try {
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
- ar.push(r.value);
- }
- } catch (error) {
- e = { error: error };
- } finally {
- try {
- if (r && !r.done && (m = i["return"])) m.call(i);
- } finally {
- if (e) throw e.error;
- }
- }
- return ar;
- };
- var __spread = this && this.__spread || function () {
- for (var ar = [], i = 0; i < arguments.length; i++) {
- ar = ar.concat(__read(arguments[i]));
- }return ar;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts");
- var MDCComponent = /** @class */function () {
- function MDCComponent(root, foundation) {
- var args = [];
- for (var _i = 2; _i < arguments.length; _i++) {
- args[_i - 2] = arguments[_i];
- }
- this.root_ = root;
- this.initialize.apply(this, __spread(args));
- // Note that we initialize foundation here and not within the constructor's default param so that
- // this.root_ is defined and can be used within the foundation class.
- this.foundation_ = foundation === undefined ? this.getDefaultFoundation() : foundation;
- this.foundation_.init();
- this.initialSyncWithDOM();
- }
- MDCComponent.attachTo = function (root) {
- // Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and
- // returns an instantiated component with its root set to that element. Also note that in the cases of
- // subclasses, an explicit foundation class will not have to be passed in; it will simply be initialized
- // from getDefaultFoundation().
- return new MDCComponent(root, new foundation_1.MDCFoundation({}));
- };
- /* istanbul ignore next: method param only exists for typing purposes; it does not need to be unit tested */
- MDCComponent.prototype.initialize = function () {
- var _args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- _args[_i] = arguments[_i];
- }
- // Subclasses can override this to do any additional setup work that would be considered part of a
- // "constructor". Essentially, it is a hook into the parent constructor before the foundation is
- // initialized. Any additional arguments besides root and foundation will be passed in here.
- };
- MDCComponent.prototype.getDefaultFoundation = function () {
- // Subclasses must override this method to return a properly configured foundation class for the
- // component.
- throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
- };
- MDCComponent.prototype.initialSyncWithDOM = function () {
- // Subclasses should override this method if they need to perform work to synchronize with a host DOM
- // object. An example of this would be a form control wrapper that needs to synchronize its internal state
- // to some property or attribute of the host DOM. Please note: this is *not* the place to perform DOM
- // reads/writes that would cause layout / paint, as this is called synchronously from within the constructor.
- };
- MDCComponent.prototype.destroy = function () {
- // Subclasses may implement this method to release any resources / deregister any listeners they have
- // attached. An example of this might be deregistering a resize event from the window object.
- this.foundation_.destroy();
- };
- MDCComponent.prototype.listen = function (evtType, handler, options) {
- this.root_.addEventListener(evtType, handler, options);
- };
- MDCComponent.prototype.unlisten = function (evtType, handler, options) {
- this.root_.removeEventListener(evtType, handler, options);
- };
- /**
- * Fires a cross-browser-compatible custom event from the component root of the given type, with the given data.
- */
- MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) {
- if (shouldBubble === void 0) {
- shouldBubble = false;
- }
- var evt;
- if (typeof CustomEvent === 'function') {
- evt = new CustomEvent(evtType, {
- bubbles: shouldBubble,
- detail: evtData
- });
- } else {
- evt = document.createEvent('CustomEvent');
- evt.initCustomEvent(evtType, shouldBubble, false, evtData);
- }
- this.root_.dispatchEvent(evt);
- };
- return MDCComponent;
- }();
- exports.MDCComponent = MDCComponent;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCComponent;
- /***/ }),
- /***/ "./packages/mdc-base/foundation.ts":
- /*!*****************************************!*\
- !*** ./packages/mdc-base/foundation.ts ***!
- \*****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var MDCFoundation = /** @class */function () {
- function MDCFoundation(adapter) {
- if (adapter === void 0) {
- adapter = {};
- }
- this.adapter_ = adapter;
- }
- Object.defineProperty(MDCFoundation, "cssClasses", {
- get: function get() {
- // Classes extending MDCFoundation should implement this method to return an object which exports every
- // CSS class the foundation class needs as a property. e.g. {ACTIVE: 'mdc-component--active'}
- return {};
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCFoundation, "strings", {
- get: function get() {
- // Classes extending MDCFoundation should implement this method to return an object which exports all
- // semantic strings as constants. e.g. {ARIA_ROLE: 'tablist'}
- return {};
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCFoundation, "numbers", {
- get: function get() {
- // Classes extending MDCFoundation should implement this method to return an object which exports all
- // of its semantic numbers as constants. e.g. {ANIMATION_DELAY_MS: 350}
- return {};
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCFoundation, "defaultAdapter", {
- get: function get() {
- // Classes extending MDCFoundation may choose to implement this getter in order to provide a convenient
- // way of viewing the necessary methods of an adapter. In the future, this could also be used for adapter
- // validation.
- return {};
- },
- enumerable: true,
- configurable: true
- });
- MDCFoundation.prototype.init = function () {
- // Subclasses should override this method to perform initialization routines (registering events, etc.)
- };
- MDCFoundation.prototype.destroy = function () {
- // Subclasses should override this method to perform de-initialization routines (de-registering events, etc.)
- };
- return MDCFoundation;
- }();
- exports.MDCFoundation = MDCFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCFoundation;
- /***/ }),
- /***/ "./packages/mdc-dom/events.ts":
- /*!************************************!*\
- !*** ./packages/mdc-dom/events.ts ***!
- \************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /**
- * Determine whether the current browser supports passive event listeners, and
- * if so, use them.
- */
- function applyPassive(globalObj) {
- if (globalObj === void 0) {
- globalObj = window;
- }
- return supportsPassiveOption(globalObj) ? { passive: true } : false;
- }
- exports.applyPassive = applyPassive;
- function supportsPassiveOption(globalObj) {
- if (globalObj === void 0) {
- globalObj = window;
- }
- // See
- // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
- var passiveSupported = false;
- try {
- var options = {
- // This function will be called when the browser
- // attempts to access the passive property.
- get passive() {
- passiveSupported = true;
- return false;
- }
- };
- var handler = function handler() {};
- globalObj.document.addEventListener('test', handler, options);
- globalObj.document.removeEventListener('test', handler, options);
- } catch (err) {
- passiveSupported = false;
- }
- return passiveSupported;
- }
- /***/ }),
- /***/ "./packages/mdc-dom/ponyfill.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-dom/ponyfill.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /**
- * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global prototype chain.
- * This makes ponyfills safer than traditional polyfills, especially for libraries like MDC.
- */
- function closest(element, selector) {
- if (element.closest) {
- return element.closest(selector);
- }
- var el = element;
- while (el) {
- if (matches(el, selector)) {
- return el;
- }
- el = el.parentElement;
- }
- return null;
- }
- exports.closest = closest;
- function matches(element, selector) {
- var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
- return nativeMatches.call(element, selector);
- }
- exports.matches = matches;
- /**
- * Used to compute the estimated scroll width of elements. When an element is
- * hidden due to display: none; being applied to a parent element, the width is
- * returned as 0. However, the element will have a true width once no longer
- * inside a display: none context. This method computes an estimated width when
- * the element is hidden or returns the true width when the element is visble.
- * @param {Element} element the element whose width to estimate
- */
- function estimateScrollWidth(element) {
- // Check the offsetParent. If the element inherits display: none from any
- // parent, the offsetParent property will be null (see
- // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent).
- // This check ensures we only clone the node when necessary.
- var htmlEl = element;
- if (htmlEl.offsetParent !== null) {
- return htmlEl.scrollWidth;
- }
- var clone = htmlEl.cloneNode(true);
- clone.style.setProperty('position', 'absolute');
- clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
- document.documentElement.appendChild(clone);
- var scrollWidth = clone.scrollWidth;
- document.documentElement.removeChild(clone);
- return scrollWidth;
- }
- exports.estimateScrollWidth = estimateScrollWidth;
- /***/ }),
- /***/ "./packages/mdc-ripple/component.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-ripple/component.ts ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
- var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts");
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
- var MDCRipple = /** @class */function (_super) {
- __extends(MDCRipple, _super);
- function MDCRipple() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.disabled = false;
- return _this;
- }
- MDCRipple.attachTo = function (root, opts) {
- if (opts === void 0) {
- opts = { isUnbounded: undefined };
- }
- var ripple = new MDCRipple(root);
- // Only override unbounded behavior if option is explicitly specified
- if (opts.isUnbounded !== undefined) {
- ripple.unbounded = opts.isUnbounded;
- }
- return ripple;
- };
- MDCRipple.createAdapter = function (instance) {
- return {
- addClass: function addClass(className) {
- return instance.root_.classList.add(className);
- },
- browserSupportsCssVars: function browserSupportsCssVars() {
- return util.supportsCssVariables(window);
- },
- computeBoundingRect: function computeBoundingRect() {
- return instance.root_.getBoundingClientRect();
- },
- containsEventTarget: function containsEventTarget(target) {
- return instance.root_.contains(target);
- },
- deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler(evtType, handler) {
- return document.documentElement.removeEventListener(evtType, handler, events_1.applyPassive());
- },
- deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- return instance.root_.removeEventListener(evtType, handler, events_1.applyPassive());
- },
- deregisterResizeHandler: function deregisterResizeHandler(handler) {
- return window.removeEventListener('resize', handler);
- },
- getWindowPageOffset: function getWindowPageOffset() {
- return { x: window.pageXOffset, y: window.pageYOffset };
- },
- isSurfaceActive: function isSurfaceActive() {
- return ponyfill_1.matches(instance.root_, ':active');
- },
- isSurfaceDisabled: function isSurfaceDisabled() {
- return Boolean(instance.disabled);
- },
- isUnbounded: function isUnbounded() {
- return Boolean(instance.unbounded);
- },
- registerDocumentInteractionHandler: function registerDocumentInteractionHandler(evtType, handler) {
- return document.documentElement.addEventListener(evtType, handler, events_1.applyPassive());
- },
- registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- return instance.root_.addEventListener(evtType, handler, events_1.applyPassive());
- },
- registerResizeHandler: function registerResizeHandler(handler) {
- return window.addEventListener('resize', handler);
- },
- removeClass: function removeClass(className) {
- return instance.root_.classList.remove(className);
- },
- updateCssVariable: function updateCssVariable(varName, value) {
- return instance.root_.style.setProperty(varName, value);
- }
- };
- };
- Object.defineProperty(MDCRipple.prototype, "unbounded", {
- get: function get() {
- return Boolean(this.unbounded_);
- },
- set: function set(unbounded) {
- this.unbounded_ = Boolean(unbounded);
- this.setUnbounded_();
- },
- enumerable: true,
- configurable: true
- });
- MDCRipple.prototype.activate = function () {
- this.foundation_.activate();
- };
- MDCRipple.prototype.deactivate = function () {
- this.foundation_.deactivate();
- };
- MDCRipple.prototype.layout = function () {
- this.foundation_.layout();
- };
- MDCRipple.prototype.getDefaultFoundation = function () {
- return new foundation_1.MDCRippleFoundation(MDCRipple.createAdapter(this));
- };
- MDCRipple.prototype.initialSyncWithDOM = function () {
- var root = this.root_;
- this.unbounded = 'mdcRippleIsUnbounded' in root.dataset;
- };
- /**
- * Closure Compiler throws an access control error when directly accessing a
- * protected or private property inside a getter/setter, like unbounded above.
- * By accessing the protected property inside a method, we solve that problem.
- * That's why this function exists.
- */
- MDCRipple.prototype.setUnbounded_ = function () {
- this.foundation_.setUnbounded(Boolean(this.unbounded_));
- };
- return MDCRipple;
- }(component_1.MDCComponent);
- exports.MDCRipple = MDCRipple;
- /***/ }),
- /***/ "./packages/mdc-ripple/constants.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-ripple/constants.ts ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.cssClasses = {
- // Ripple is a special case where the "root" component is really a "mixin" of sorts,
- // given that it's an 'upgrade' to an existing component. That being said it is the root
- // CSS class that all other CSS classes derive from.
- BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
- FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
- FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation',
- ROOT: 'mdc-ripple-upgraded',
- UNBOUNDED: 'mdc-ripple-upgraded--unbounded'
- };
- exports.strings = {
- VAR_FG_SCALE: '--mdc-ripple-fg-scale',
- VAR_FG_SIZE: '--mdc-ripple-fg-size',
- VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end',
- VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
- VAR_LEFT: '--mdc-ripple-left',
- VAR_TOP: '--mdc-ripple-top'
- };
- exports.numbers = {
- DEACTIVATION_TIMEOUT_MS: 225,
- FG_DEACTIVATION_MS: 150,
- INITIAL_ORIGIN_SCALE: 0.6,
- PADDING: 10,
- TAP_DELAY_MS: 300
- };
- /***/ }),
- /***/ "./packages/mdc-ripple/foundation.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-ripple/foundation.ts ***!
- \*******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts");
- var util_1 = __webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts");
- // Activation events registered on the root element of each instance for activation
- var ACTIVATION_EVENT_TYPES = ['touchstart', 'pointerdown', 'mousedown', 'keydown'];
- // Deactivation events registered on documentElement when a pointer-related down event occurs
- var POINTER_DEACTIVATION_EVENT_TYPES = ['touchend', 'pointerup', 'mouseup', 'contextmenu'];
- // simultaneous nested activations
- var activatedTargets = [];
- var MDCRippleFoundation = /** @class */function (_super) {
- __extends(MDCRippleFoundation, _super);
- function MDCRippleFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCRippleFoundation.defaultAdapter, adapter)) || this;
- _this.activationAnimationHasEnded_ = false;
- _this.activationTimer_ = 0;
- _this.fgDeactivationRemovalTimer_ = 0;
- _this.fgScale_ = '0';
- _this.frame_ = { width: 0, height: 0 };
- _this.initialSize_ = 0;
- _this.layoutFrame_ = 0;
- _this.maxRadius_ = 0;
- _this.unboundedCoords_ = { left: 0, top: 0 };
- _this.activationState_ = _this.defaultActivationState_();
- _this.activationTimerCallback_ = function () {
- _this.activationAnimationHasEnded_ = true;
- _this.runDeactivationUXLogicIfReady_();
- };
- _this.activateHandler_ = function (e) {
- return _this.activate_(e);
- };
- _this.deactivateHandler_ = function () {
- return _this.deactivate_();
- };
- _this.focusHandler_ = function () {
- return _this.handleFocus();
- };
- _this.blurHandler_ = function () {
- return _this.handleBlur();
- };
- _this.resizeHandler_ = function () {
- return _this.layout();
- };
- return _this;
- }
- Object.defineProperty(MDCRippleFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCRippleFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCRippleFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCRippleFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- browserSupportsCssVars: function browserSupportsCssVars() {
- return true;
- },
- computeBoundingRect: function computeBoundingRect() {
- return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
- },
- containsEventTarget: function containsEventTarget() {
- return true;
- },
- deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() {
- return undefined;
- },
- deregisterInteractionHandler: function deregisterInteractionHandler() {
- return undefined;
- },
- deregisterResizeHandler: function deregisterResizeHandler() {
- return undefined;
- },
- getWindowPageOffset: function getWindowPageOffset() {
- return { x: 0, y: 0 };
- },
- isSurfaceActive: function isSurfaceActive() {
- return true;
- },
- isSurfaceDisabled: function isSurfaceDisabled() {
- return true;
- },
- isUnbounded: function isUnbounded() {
- return true;
- },
- registerDocumentInteractionHandler: function registerDocumentInteractionHandler() {
- return undefined;
- },
- registerInteractionHandler: function registerInteractionHandler() {
- return undefined;
- },
- registerResizeHandler: function registerResizeHandler() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- updateCssVariable: function updateCssVariable() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCRippleFoundation.prototype.init = function () {
- var _this = this;
- var supportsPressRipple = this.supportsPressRipple_();
- this.registerRootHandlers_(supportsPressRipple);
- if (supportsPressRipple) {
- var _a = MDCRippleFoundation.cssClasses,
- ROOT_1 = _a.ROOT,
- UNBOUNDED_1 = _a.UNBOUNDED;
- requestAnimationFrame(function () {
- _this.adapter_.addClass(ROOT_1);
- if (_this.adapter_.isUnbounded()) {
- _this.adapter_.addClass(UNBOUNDED_1);
- // Unbounded ripples need layout logic applied immediately to set coordinates for both shade and ripple
- _this.layoutInternal_();
- }
- });
- }
- };
- MDCRippleFoundation.prototype.destroy = function () {
- var _this = this;
- if (this.supportsPressRipple_()) {
- if (this.activationTimer_) {
- clearTimeout(this.activationTimer_);
- this.activationTimer_ = 0;
- this.adapter_.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION);
- }
- if (this.fgDeactivationRemovalTimer_) {
- clearTimeout(this.fgDeactivationRemovalTimer_);
- this.fgDeactivationRemovalTimer_ = 0;
- this.adapter_.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION);
- }
- var _a = MDCRippleFoundation.cssClasses,
- ROOT_2 = _a.ROOT,
- UNBOUNDED_2 = _a.UNBOUNDED;
- requestAnimationFrame(function () {
- _this.adapter_.removeClass(ROOT_2);
- _this.adapter_.removeClass(UNBOUNDED_2);
- _this.removeCssVars_();
- });
- }
- this.deregisterRootHandlers_();
- this.deregisterDeactivationHandlers_();
- };
- /**
- * @param evt Optional event containing position information.
- */
- MDCRippleFoundation.prototype.activate = function (evt) {
- this.activate_(evt);
- };
- MDCRippleFoundation.prototype.deactivate = function () {
- this.deactivate_();
- };
- MDCRippleFoundation.prototype.layout = function () {
- var _this = this;
- if (this.layoutFrame_) {
- cancelAnimationFrame(this.layoutFrame_);
- }
- this.layoutFrame_ = requestAnimationFrame(function () {
- _this.layoutInternal_();
- _this.layoutFrame_ = 0;
- });
- };
- MDCRippleFoundation.prototype.setUnbounded = function (unbounded) {
- var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED;
- if (unbounded) {
- this.adapter_.addClass(UNBOUNDED);
- } else {
- this.adapter_.removeClass(UNBOUNDED);
- }
- };
- MDCRippleFoundation.prototype.handleFocus = function () {
- var _this = this;
- requestAnimationFrame(function () {
- return _this.adapter_.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
- });
- };
- MDCRippleFoundation.prototype.handleBlur = function () {
- var _this = this;
- requestAnimationFrame(function () {
- return _this.adapter_.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
- });
- };
- /**
- * We compute this property so that we are not querying information about the client
- * until the point in time where the foundation requests it. This prevents scenarios where
- * client-side feature-detection may happen too early, such as when components are rendered on the server
- * and then initialized at mount time on the client.
- */
- MDCRippleFoundation.prototype.supportsPressRipple_ = function () {
- return this.adapter_.browserSupportsCssVars();
- };
- MDCRippleFoundation.prototype.defaultActivationState_ = function () {
- return {
- activationEvent: undefined,
- hasDeactivationUXRun: false,
- isActivated: false,
- isProgrammatic: false,
- wasActivatedByPointer: false,
- wasElementMadeActive: false
- };
- };
- /**
- * supportsPressRipple Passed from init to save a redundant function call
- */
- MDCRippleFoundation.prototype.registerRootHandlers_ = function (supportsPressRipple) {
- var _this = this;
- if (supportsPressRipple) {
- ACTIVATION_EVENT_TYPES.forEach(function (evtType) {
- _this.adapter_.registerInteractionHandler(evtType, _this.activateHandler_);
- });
- if (this.adapter_.isUnbounded()) {
- this.adapter_.registerResizeHandler(this.resizeHandler_);
- }
- }
- this.adapter_.registerInteractionHandler('focus', this.focusHandler_);
- this.adapter_.registerInteractionHandler('blur', this.blurHandler_);
- };
- MDCRippleFoundation.prototype.registerDeactivationHandlers_ = function (evt) {
- var _this = this;
- if (evt.type === 'keydown') {
- this.adapter_.registerInteractionHandler('keyup', this.deactivateHandler_);
- } else {
- POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (evtType) {
- _this.adapter_.registerDocumentInteractionHandler(evtType, _this.deactivateHandler_);
- });
- }
- };
- MDCRippleFoundation.prototype.deregisterRootHandlers_ = function () {
- var _this = this;
- ACTIVATION_EVENT_TYPES.forEach(function (evtType) {
- _this.adapter_.deregisterInteractionHandler(evtType, _this.activateHandler_);
- });
- this.adapter_.deregisterInteractionHandler('focus', this.focusHandler_);
- this.adapter_.deregisterInteractionHandler('blur', this.blurHandler_);
- if (this.adapter_.isUnbounded()) {
- this.adapter_.deregisterResizeHandler(this.resizeHandler_);
- }
- };
- MDCRippleFoundation.prototype.deregisterDeactivationHandlers_ = function () {
- var _this = this;
- this.adapter_.deregisterInteractionHandler('keyup', this.deactivateHandler_);
- POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (evtType) {
- _this.adapter_.deregisterDocumentInteractionHandler(evtType, _this.deactivateHandler_);
- });
- };
- MDCRippleFoundation.prototype.removeCssVars_ = function () {
- var _this = this;
- var rippleStrings = MDCRippleFoundation.strings;
- var keys = Object.keys(rippleStrings);
- keys.forEach(function (key) {
- if (key.indexOf('VAR_') === 0) {
- _this.adapter_.updateCssVariable(rippleStrings[key], null);
- }
- });
- };
- MDCRippleFoundation.prototype.activate_ = function (evt) {
- var _this = this;
- if (this.adapter_.isSurfaceDisabled()) {
- return;
- }
- var activationState = this.activationState_;
- if (activationState.isActivated) {
- return;
- }
- // Avoid reacting to follow-on events fired by touch device after an already-processed user interaction
- var previousActivationEvent = this.previousActivationEvent_;
- var isSameInteraction = previousActivationEvent && evt !== undefined && previousActivationEvent.type !== evt.type;
- if (isSameInteraction) {
- return;
- }
- activationState.isActivated = true;
- activationState.isProgrammatic = evt === undefined;
- activationState.activationEvent = evt;
- activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== undefined && (evt.type === 'mousedown' || evt.type === 'touchstart' || evt.type === 'pointerdown');
- var hasActivatedChild = evt !== undefined && activatedTargets.length > 0 && activatedTargets.some(function (target) {
- return _this.adapter_.containsEventTarget(target);
- });
- if (hasActivatedChild) {
- // Immediately reset activation state, while preserving logic that prevents touch follow-on events
- this.resetActivationState_();
- return;
- }
- if (evt !== undefined) {
- activatedTargets.push(evt.target);
- this.registerDeactivationHandlers_(evt);
- }
- activationState.wasElementMadeActive = this.checkElementMadeActive_(evt);
- if (activationState.wasElementMadeActive) {
- this.animateActivation_();
- }
- requestAnimationFrame(function () {
- // Reset array on next frame after the current event has had a chance to bubble to prevent ancestor ripples
- activatedTargets = [];
- if (!activationState.wasElementMadeActive && evt !== undefined && (evt.key === ' ' || evt.keyCode === 32)) {
- // If space was pressed, try again within an rAF call to detect :active, because different UAs report
- // active states inconsistently when they're called within event handling code:
- // - https://bugs.chromium.org/p/chromium/issues/detail?id=635971
- // - https://bugzilla.mozilla.org/show_bug.cgi?id=1293741
- // We try first outside rAF to support Edge, which does not exhibit this problem, but will crash if a CSS
- // variable is set within a rAF callback for a submit button interaction (#2241).
- activationState.wasElementMadeActive = _this.checkElementMadeActive_(evt);
- if (activationState.wasElementMadeActive) {
- _this.animateActivation_();
- }
- }
- if (!activationState.wasElementMadeActive) {
- // Reset activation state immediately if element was not made active.
- _this.activationState_ = _this.defaultActivationState_();
- }
- });
- };
- MDCRippleFoundation.prototype.checkElementMadeActive_ = function (evt) {
- return evt !== undefined && evt.type === 'keydown' ? this.adapter_.isSurfaceActive() : true;
- };
- MDCRippleFoundation.prototype.animateActivation_ = function () {
- var _this = this;
- var _a = MDCRippleFoundation.strings,
- VAR_FG_TRANSLATE_START = _a.VAR_FG_TRANSLATE_START,
- VAR_FG_TRANSLATE_END = _a.VAR_FG_TRANSLATE_END;
- var _b = MDCRippleFoundation.cssClasses,
- FG_DEACTIVATION = _b.FG_DEACTIVATION,
- FG_ACTIVATION = _b.FG_ACTIVATION;
- var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
- this.layoutInternal_();
- var translateStart = '';
- var translateEnd = '';
- if (!this.adapter_.isUnbounded()) {
- var _c = this.getFgTranslationCoordinates_(),
- startPoint = _c.startPoint,
- endPoint = _c.endPoint;
- translateStart = startPoint.x + "px, " + startPoint.y + "px";
- translateEnd = endPoint.x + "px, " + endPoint.y + "px";
- }
- this.adapter_.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
- this.adapter_.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
- // Cancel any ongoing activation/deactivation animations
- clearTimeout(this.activationTimer_);
- clearTimeout(this.fgDeactivationRemovalTimer_);
- this.rmBoundedActivationClasses_();
- this.adapter_.removeClass(FG_DEACTIVATION);
- // Force layout in order to re-trigger the animation.
- this.adapter_.computeBoundingRect();
- this.adapter_.addClass(FG_ACTIVATION);
- this.activationTimer_ = setTimeout(function () {
- return _this.activationTimerCallback_();
- }, DEACTIVATION_TIMEOUT_MS);
- };
- MDCRippleFoundation.prototype.getFgTranslationCoordinates_ = function () {
- var _a = this.activationState_,
- activationEvent = _a.activationEvent,
- wasActivatedByPointer = _a.wasActivatedByPointer;
- var startPoint;
- if (wasActivatedByPointer) {
- startPoint = util_1.getNormalizedEventCoords(activationEvent, this.adapter_.getWindowPageOffset(), this.adapter_.computeBoundingRect());
- } else {
- startPoint = {
- x: this.frame_.width / 2,
- y: this.frame_.height / 2
- };
- }
- // Center the element around the start point.
- startPoint = {
- x: startPoint.x - this.initialSize_ / 2,
- y: startPoint.y - this.initialSize_ / 2
- };
- var endPoint = {
- x: this.frame_.width / 2 - this.initialSize_ / 2,
- y: this.frame_.height / 2 - this.initialSize_ / 2
- };
- return { startPoint: startPoint, endPoint: endPoint };
- };
- MDCRippleFoundation.prototype.runDeactivationUXLogicIfReady_ = function () {
- var _this = this;
- // This method is called both when a pointing device is released, and when the activation animation ends.
- // The deactivation animation should only run after both of those occur.
- var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
- var _a = this.activationState_,
- hasDeactivationUXRun = _a.hasDeactivationUXRun,
- isActivated = _a.isActivated;
- var activationHasEnded = hasDeactivationUXRun || !isActivated;
- if (activationHasEnded && this.activationAnimationHasEnded_) {
- this.rmBoundedActivationClasses_();
- this.adapter_.addClass(FG_DEACTIVATION);
- this.fgDeactivationRemovalTimer_ = setTimeout(function () {
- _this.adapter_.removeClass(FG_DEACTIVATION);
- }, constants_1.numbers.FG_DEACTIVATION_MS);
- }
- };
- MDCRippleFoundation.prototype.rmBoundedActivationClasses_ = function () {
- var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION;
- this.adapter_.removeClass(FG_ACTIVATION);
- this.activationAnimationHasEnded_ = false;
- this.adapter_.computeBoundingRect();
- };
- MDCRippleFoundation.prototype.resetActivationState_ = function () {
- var _this = this;
- this.previousActivationEvent_ = this.activationState_.activationEvent;
- this.activationState_ = this.defaultActivationState_();
- // Touch devices may fire additional events for the same interaction within a short time.
- // Store the previous event until it's safe to assume that subsequent events are for new interactions.
- setTimeout(function () {
- return _this.previousActivationEvent_ = undefined;
- }, MDCRippleFoundation.numbers.TAP_DELAY_MS);
- };
- MDCRippleFoundation.prototype.deactivate_ = function () {
- var _this = this;
- var activationState = this.activationState_;
- // This can happen in scenarios such as when you have a keyup event that blurs the element.
- if (!activationState.isActivated) {
- return;
- }
- var state = __assign({}, activationState);
- if (activationState.isProgrammatic) {
- requestAnimationFrame(function () {
- return _this.animateDeactivation_(state);
- });
- this.resetActivationState_();
- } else {
- this.deregisterDeactivationHandlers_();
- requestAnimationFrame(function () {
- _this.activationState_.hasDeactivationUXRun = true;
- _this.animateDeactivation_(state);
- _this.resetActivationState_();
- });
- }
- };
- MDCRippleFoundation.prototype.animateDeactivation_ = function (_a) {
- var wasActivatedByPointer = _a.wasActivatedByPointer,
- wasElementMadeActive = _a.wasElementMadeActive;
- if (wasActivatedByPointer || wasElementMadeActive) {
- this.runDeactivationUXLogicIfReady_();
- }
- };
- MDCRippleFoundation.prototype.layoutInternal_ = function () {
- var _this = this;
- this.frame_ = this.adapter_.computeBoundingRect();
- var maxDim = Math.max(this.frame_.height, this.frame_.width);
- // Surface diameter is treated differently for unbounded vs. bounded ripples.
- // Unbounded ripple diameter is calculated smaller since the surface is expected to already be padded appropriately
- // to extend the hitbox, and the ripple is expected to meet the edges of the padded hitbox (which is typically
- // square). Bounded ripples, on the other hand, are fully expected to expand beyond the surface's longest diameter
- // (calculated based on the diagonal plus a constant padding), and are clipped at the surface's border via
- // `overflow: hidden`.
- var getBoundedRadius = function getBoundedRadius() {
- var hypotenuse = Math.sqrt(Math.pow(_this.frame_.width, 2) + Math.pow(_this.frame_.height, 2));
- return hypotenuse + MDCRippleFoundation.numbers.PADDING;
- };
- this.maxRadius_ = this.adapter_.isUnbounded() ? maxDim : getBoundedRadius();
- // Ripple is sized as a fraction of the largest dimension of the surface, then scales up using a CSS scale transform
- var initialSize = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
- // Unbounded ripple size should always be even number to equally center align.
- if (this.adapter_.isUnbounded() && initialSize % 2 !== 0) {
- this.initialSize_ = initialSize - 1;
- } else {
- this.initialSize_ = initialSize;
- }
- this.fgScale_ = "" + this.maxRadius_ / this.initialSize_;
- this.updateLayoutCssVars_();
- };
- MDCRippleFoundation.prototype.updateLayoutCssVars_ = function () {
- var _a = MDCRippleFoundation.strings,
- VAR_FG_SIZE = _a.VAR_FG_SIZE,
- VAR_LEFT = _a.VAR_LEFT,
- VAR_TOP = _a.VAR_TOP,
- VAR_FG_SCALE = _a.VAR_FG_SCALE;
- this.adapter_.updateCssVariable(VAR_FG_SIZE, this.initialSize_ + "px");
- this.adapter_.updateCssVariable(VAR_FG_SCALE, this.fgScale_);
- if (this.adapter_.isUnbounded()) {
- this.unboundedCoords_ = {
- left: Math.round(this.frame_.width / 2 - this.initialSize_ / 2),
- top: Math.round(this.frame_.height / 2 - this.initialSize_ / 2)
- };
- this.adapter_.updateCssVariable(VAR_LEFT, this.unboundedCoords_.left + "px");
- this.adapter_.updateCssVariable(VAR_TOP, this.unboundedCoords_.top + "px");
- }
- };
- return MDCRippleFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCRippleFoundation = MDCRippleFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCRippleFoundation;
- /***/ }),
- /***/ "./packages/mdc-ripple/index.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-ripple/index.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
- exports.util = util;
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-ripple/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-ripple/util.ts":
- /*!*************************************!*\
- !*** ./packages/mdc-ripple/util.ts ***!
- \*************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- /**
- * Stores result from supportsCssVariables to avoid redundant processing to
- * detect CSS custom variable support.
- */
- var supportsCssVariables_;
- function supportsCssVariables(windowObj, forceRefresh) {
- if (forceRefresh === void 0) {
- forceRefresh = false;
- }
- var CSS = windowObj.CSS;
- var supportsCssVars = supportsCssVariables_;
- if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
- return supportsCssVariables_;
- }
- var supportsFunctionPresent = CSS && typeof CSS.supports === 'function';
- if (!supportsFunctionPresent) {
- return false;
- }
- var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes');
- // See: https://bugs.webkit.org/show_bug.cgi?id=154669
- // See: README section on Safari
- var weAreFeatureDetectingSafari10plus = CSS.supports('(--css-vars: yes)') && CSS.supports('color', '#00000000');
- supportsCssVars = explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
- if (!forceRefresh) {
- supportsCssVariables_ = supportsCssVars;
- }
- return supportsCssVars;
- }
- exports.supportsCssVariables = supportsCssVariables;
- function getNormalizedEventCoords(evt, pageOffset, clientRect) {
- if (!evt) {
- return { x: 0, y: 0 };
- }
- var x = pageOffset.x,
- y = pageOffset.y;
- var documentX = x + clientRect.left;
- var documentY = y + clientRect.top;
- var normalizedX;
- var normalizedY;
- // Determine touch point relative to the ripple container.
- if (evt.type === 'touchstart') {
- var touchEvent = evt;
- normalizedX = touchEvent.changedTouches[0].pageX - documentX;
- normalizedY = touchEvent.changedTouches[0].pageY - documentY;
- } else {
- var mouseEvent = evt;
- normalizedX = mouseEvent.pageX - documentX;
- normalizedY = mouseEvent.pageY - documentY;
- }
- return { x: normalizedX, y: normalizedY };
- }
- exports.getNormalizedEventCoords = getNormalizedEventCoords;
- /***/ })
- /******/ });
- });
- //# sourceMappingURL=mdc.ripple.js.map
|