UNPKG

122 kBJavaScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://github.com/material-components/material-components-web/blob/master/LICENSE
7 */
8(function webpackUniversalModuleDefinition(root, factory) {
9 if(typeof exports === 'object' && typeof module === 'object')
10 module.exports = factory();
11 else if(typeof define === 'function' && define.amd)
12 define("@material/dialog", [], factory);
13 else if(typeof exports === 'object')
14 exports["dialog"] = factory();
15 else
16 root["mdc"] = root["mdc"] || {}, root["mdc"]["dialog"] = 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-dialog/index.ts");
102/******/ })
103/************************************************************************/
104/******/ ({
105
106/***/ "./packages/mdc-animation/animationframe.ts":
107/*!**************************************************!*\
108 !*** ./packages/mdc-animation/animationframe.ts ***!
109 \**************************************************/
110/*! no static exports found */
111/***/ (function(module, exports, __webpack_require__) {
112
113"use strict";
114
115/**
116 * @license
117 * Copyright 2020 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
138Object.defineProperty(exports, "__esModule", { value: true });
139exports.AnimationFrame = void 0;
140/**
141 * AnimationFrame provides a user-friendly abstraction around requesting
142 * and canceling animation frames.
143 */
144var AnimationFrame = /** @class */function () {
145 function AnimationFrame() {
146 this.rafIDs = new Map();
147 }
148 /**
149 * Requests an animation frame. Cancels any existing frame with the same key.
150 * @param {string} key The key for this callback.
151 * @param {FrameRequestCallback} callback The callback to be executed.
152 */
153 AnimationFrame.prototype.request = function (key, callback) {
154 var _this = this;
155 this.cancel(key);
156 var frameID = requestAnimationFrame(function (frame) {
157 _this.rafIDs.delete(key);
158 // Callback must come *after* the key is deleted so that nested calls to
159 // request with the same key are not deleted.
160 callback(frame);
161 });
162 this.rafIDs.set(key, frameID);
163 };
164 /**
165 * Cancels a queued callback with the given key.
166 * @param {string} key The key for this callback.
167 */
168 AnimationFrame.prototype.cancel = function (key) {
169 var rafID = this.rafIDs.get(key);
170 if (rafID) {
171 cancelAnimationFrame(rafID);
172 this.rafIDs.delete(key);
173 }
174 };
175 /**
176 * Cancels all queued callback.
177 */
178 AnimationFrame.prototype.cancelAll = function () {
179 var _this = this;
180 // Need to use forEach because it's the only iteration method supported
181 // by IE11. Suppress the underscore because we don't need it.
182 // tslint:disable-next-line:enforce-name-casing
183 this.rafIDs.forEach(function (_, key) {
184 _this.cancel(key);
185 });
186 };
187 /**
188 * Returns the queue of unexecuted callback keys.
189 */
190 AnimationFrame.prototype.getQueue = function () {
191 var queue = [];
192 // Need to use forEach because it's the only iteration method supported
193 // by IE11. Suppress the underscore because we don't need it.
194 // tslint:disable-next-line:enforce-name-casing
195 this.rafIDs.forEach(function (_, key) {
196 queue.push(key);
197 });
198 return queue;
199 };
200 return AnimationFrame;
201}();
202exports.AnimationFrame = AnimationFrame;
203
204/***/ }),
205
206/***/ "./packages/mdc-base/component.ts":
207/*!****************************************!*\
208 !*** ./packages/mdc-base/component.ts ***!
209 \****************************************/
210/*! no static exports found */
211/***/ (function(module, exports, __webpack_require__) {
212
213"use strict";
214
215/**
216 * @license
217 * Copyright 2016 Google Inc.
218 *
219 * Permission is hereby granted, free of charge, to any person obtaining a copy
220 * of this software and associated documentation files (the "Software"), to deal
221 * in the Software without restriction, including without limitation the rights
222 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
223 * copies of the Software, and to permit persons to whom the Software is
224 * furnished to do so, subject to the following conditions:
225 *
226 * The above copyright notice and this permission notice shall be included in
227 * all copies or substantial portions of the Software.
228 *
229 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
230 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
231 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
232 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
233 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
234 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
235 * THE SOFTWARE.
236 */
237
238var __read = this && this.__read || function (o, n) {
239 var m = typeof Symbol === "function" && o[Symbol.iterator];
240 if (!m) return o;
241 var i = m.call(o),
242 r,
243 ar = [],
244 e;
245 try {
246 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
247 ar.push(r.value);
248 }
249 } catch (error) {
250 e = { error: error };
251 } finally {
252 try {
253 if (r && !r.done && (m = i["return"])) m.call(i);
254 } finally {
255 if (e) throw e.error;
256 }
257 }
258 return ar;
259};
260var __spreadArray = this && this.__spreadArray || function (to, from) {
261 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
262 to[j] = from[i];
263 }return to;
264};
265Object.defineProperty(exports, "__esModule", { value: true });
266exports.MDCComponent = void 0;
267var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts");
268var MDCComponent = /** @class */function () {
269 function MDCComponent(root, foundation) {
270 var args = [];
271 for (var _i = 2; _i < arguments.length; _i++) {
272 args[_i - 2] = arguments[_i];
273 }
274 this.root = root;
275 this.initialize.apply(this, __spreadArray([], __read(args)));
276 // Note that we initialize foundation here and not within the constructor's
277 // default param so that this.root is defined and can be used within the
278 // foundation class.
279 this.foundation = foundation === undefined ? this.getDefaultFoundation() : foundation;
280 this.foundation.init();
281 this.initialSyncWithDOM();
282 }
283 MDCComponent.attachTo = function (root) {
284 // Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and
285 // returns an instantiated component with its root set to that element. Also note that in the cases of
286 // subclasses, an explicit foundation class will not have to be passed in; it will simply be initialized
287 // from getDefaultFoundation().
288 return new MDCComponent(root, new foundation_1.MDCFoundation({}));
289 };
290 /* istanbul ignore next: method param only exists for typing purposes; it does not need to be unit tested */
291 MDCComponent.prototype.initialize = function () {
292 var _args = [];
293 for (var _i = 0; _i < arguments.length; _i++) {
294 _args[_i] = arguments[_i];
295 }
296 // Subclasses can override this to do any additional setup work that would be considered part of a
297 // "constructor". Essentially, it is a hook into the parent constructor before the foundation is
298 // initialized. Any additional arguments besides root and foundation will be passed in here.
299 };
300 MDCComponent.prototype.getDefaultFoundation = function () {
301 // Subclasses must override this method to return a properly configured foundation class for the
302 // component.
303 throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
304 };
305 MDCComponent.prototype.initialSyncWithDOM = function () {
306 // Subclasses should override this method if they need to perform work to synchronize with a host DOM
307 // object. An example of this would be a form control wrapper that needs to synchronize its internal state
308 // to some property or attribute of the host DOM. Please note: this is *not* the place to perform DOM
309 // reads/writes that would cause layout / paint, as this is called synchronously from within the constructor.
310 };
311 MDCComponent.prototype.destroy = function () {
312 // Subclasses may implement this method to release any resources / deregister any listeners they have
313 // attached. An example of this might be deregistering a resize event from the window object.
314 this.foundation.destroy();
315 };
316 MDCComponent.prototype.listen = function (evtType, handler, options) {
317 this.root.addEventListener(evtType, handler, options);
318 };
319 MDCComponent.prototype.unlisten = function (evtType, handler, options) {
320 this.root.removeEventListener(evtType, handler, options);
321 };
322 /**
323 * Fires a cross-browser-compatible custom event from the component root of the given type, with the given data.
324 */
325 MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) {
326 if (shouldBubble === void 0) {
327 shouldBubble = false;
328 }
329 var evt;
330 if (typeof CustomEvent === 'function') {
331 evt = new CustomEvent(evtType, {
332 bubbles: shouldBubble,
333 detail: evtData
334 });
335 } else {
336 evt = document.createEvent('CustomEvent');
337 evt.initCustomEvent(evtType, shouldBubble, false, evtData);
338 }
339 this.root.dispatchEvent(evt);
340 };
341 return MDCComponent;
342}();
343exports.MDCComponent = MDCComponent;
344// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
345exports.default = MDCComponent;
346
347/***/ }),
348
349/***/ "./packages/mdc-base/foundation.ts":
350/*!*****************************************!*\
351 !*** ./packages/mdc-base/foundation.ts ***!
352 \*****************************************/
353/*! no static exports found */
354/***/ (function(module, exports, __webpack_require__) {
355
356"use strict";
357
358/**
359 * @license
360 * Copyright 2016 Google Inc.
361 *
362 * Permission is hereby granted, free of charge, to any person obtaining a copy
363 * of this software and associated documentation files (the "Software"), to deal
364 * in the Software without restriction, including without limitation the rights
365 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
366 * copies of the Software, and to permit persons to whom the Software is
367 * furnished to do so, subject to the following conditions:
368 *
369 * The above copyright notice and this permission notice shall be included in
370 * all copies or substantial portions of the Software.
371 *
372 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
373 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
374 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
375 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
376 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
377 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
378 * THE SOFTWARE.
379 */
380
381Object.defineProperty(exports, "__esModule", { value: true });
382exports.MDCFoundation = void 0;
383var MDCFoundation = /** @class */function () {
384 function MDCFoundation(adapter) {
385 if (adapter === void 0) {
386 adapter = {};
387 }
388 this.adapter = adapter;
389 }
390 Object.defineProperty(MDCFoundation, "cssClasses", {
391 get: function get() {
392 // Classes extending MDCFoundation should implement this method to return an object which exports every
393 // CSS class the foundation class needs as a property. e.g. {ACTIVE: 'mdc-component--active'}
394 return {};
395 },
396 enumerable: false,
397 configurable: true
398 });
399 Object.defineProperty(MDCFoundation, "strings", {
400 get: function get() {
401 // Classes extending MDCFoundation should implement this method to return an object which exports all
402 // semantic strings as constants. e.g. {ARIA_ROLE: 'tablist'}
403 return {};
404 },
405 enumerable: false,
406 configurable: true
407 });
408 Object.defineProperty(MDCFoundation, "numbers", {
409 get: function get() {
410 // Classes extending MDCFoundation should implement this method to return an object which exports all
411 // of its semantic numbers as constants. e.g. {ANIMATION_DELAY_MS: 350}
412 return {};
413 },
414 enumerable: false,
415 configurable: true
416 });
417 Object.defineProperty(MDCFoundation, "defaultAdapter", {
418 get: function get() {
419 // Classes extending MDCFoundation may choose to implement this getter in order to provide a convenient
420 // way of viewing the necessary methods of an adapter. In the future, this could also be used for adapter
421 // validation.
422 return {};
423 },
424 enumerable: false,
425 configurable: true
426 });
427 MDCFoundation.prototype.init = function () {
428 // Subclasses should override this method to perform initialization routines (registering events, etc.)
429 };
430 MDCFoundation.prototype.destroy = function () {
431 // Subclasses should override this method to perform de-initialization routines (de-registering events, etc.)
432 };
433 return MDCFoundation;
434}();
435exports.MDCFoundation = MDCFoundation;
436// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
437exports.default = MDCFoundation;
438
439/***/ }),
440
441/***/ "./packages/mdc-dialog/adapter.ts":
442/*!****************************************!*\
443 !*** ./packages/mdc-dialog/adapter.ts ***!
444 \****************************************/
445/*! no static exports found */
446/***/ (function(module, exports, __webpack_require__) {
447
448"use strict";
449
450/**
451 * @license
452 * Copyright 2018 Google Inc.
453 *
454 * Permission is hereby granted, free of charge, to any person obtaining a copy
455 * of this software and associated documentation files (the "Software"), to deal
456 * in the Software without restriction, including without limitation the rights
457 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
458 * copies of the Software, and to permit persons to whom the Software is
459 * furnished to do so, subject to the following conditions:
460 *
461 * The above copyright notice and this permission notice shall be included in
462 * all copies or substantial portions of the Software.
463 *
464 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
465 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
466 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
467 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
468 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
469 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
470 * THE SOFTWARE.
471 */
472
473Object.defineProperty(exports, "__esModule", { value: true });
474
475/***/ }),
476
477/***/ "./packages/mdc-dialog/component.ts":
478/*!******************************************!*\
479 !*** ./packages/mdc-dialog/component.ts ***!
480 \******************************************/
481/*! no static exports found */
482/***/ (function(module, exports, __webpack_require__) {
483
484"use strict";
485
486/**
487 * @license
488 * Copyright 2017 Google Inc.
489 *
490 * Permission is hereby granted, free of charge, to any person obtaining a copy
491 * of this software and associated documentation files (the "Software"), to deal
492 * in the Software without restriction, including without limitation the rights
493 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
494 * copies of the Software, and to permit persons to whom the Software is
495 * furnished to do so, subject to the following conditions:
496 *
497 * The above copyright notice and this permission notice shall be included in
498 * all copies or substantial portions of the Software.
499 *
500 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
501 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
502 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
503 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
504 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
505 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
506 * THE SOFTWARE.
507 */
508
509var __extends = this && this.__extends || function () {
510 var _extendStatics = function extendStatics(d, b) {
511 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
512 d.__proto__ = b;
513 } || function (d, b) {
514 for (var p in b) {
515 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
516 }
517 };
518 return _extendStatics(d, b);
519 };
520 return function (d, b) {
521 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
522 _extendStatics(d, b);
523 function __() {
524 this.constructor = d;
525 }
526 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
527 };
528}();
529var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
530 if (k2 === undefined) k2 = k;
531 Object.defineProperty(o, k2, { enumerable: true, get: function get() {
532 return m[k];
533 } });
534} : function (o, m, k, k2) {
535 if (k2 === undefined) k2 = k;
536 o[k2] = m[k];
537});
538var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
539 Object.defineProperty(o, "default", { enumerable: true, value: v });
540} : function (o, v) {
541 o["default"] = v;
542});
543var __importStar = this && this.__importStar || function (mod) {
544 if (mod && mod.__esModule) return mod;
545 var result = {};
546 if (mod != null) for (var k in mod) {
547 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
548 }__setModuleDefault(result, mod);
549 return result;
550};
551var __values = this && this.__values || function (o) {
552 var s = typeof Symbol === "function" && Symbol.iterator,
553 m = s && o[s],
554 i = 0;
555 if (m) return m.call(o);
556 if (o && typeof o.length === "number") return {
557 next: function next() {
558 if (o && i >= o.length) o = void 0;
559 return { value: o && o[i++], done: !o };
560 }
561 };
562 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
563};
564Object.defineProperty(exports, "__esModule", { value: true });
565exports.MDCDialog = void 0;
566var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
567var focus_trap_1 = __webpack_require__(/*! @material/dom/focus-trap */ "./packages/mdc-dom/focus-trap.ts");
568var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
569var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
570var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-dialog/foundation.ts");
571var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-dialog/util.ts"));
572var strings = foundation_1.MDCDialogFoundation.strings;
573var MDCDialog = /** @class */function (_super) {
574 __extends(MDCDialog, _super);
575 function MDCDialog() {
576 return _super !== null && _super.apply(this, arguments) || this;
577 }
578 Object.defineProperty(MDCDialog.prototype, "isOpen", {
579 get: function get() {
580 return this.foundation.isOpen();
581 },
582 enumerable: false,
583 configurable: true
584 });
585 Object.defineProperty(MDCDialog.prototype, "escapeKeyAction", {
586 get: function get() {
587 return this.foundation.getEscapeKeyAction();
588 },
589 set: function set(action) {
590 this.foundation.setEscapeKeyAction(action);
591 },
592 enumerable: false,
593 configurable: true
594 });
595 Object.defineProperty(MDCDialog.prototype, "scrimClickAction", {
596 get: function get() {
597 return this.foundation.getScrimClickAction();
598 },
599 set: function set(action) {
600 this.foundation.setScrimClickAction(action);
601 },
602 enumerable: false,
603 configurable: true
604 });
605 Object.defineProperty(MDCDialog.prototype, "autoStackButtons", {
606 get: function get() {
607 return this.foundation.getAutoStackButtons();
608 },
609 set: function set(autoStack) {
610 this.foundation.setAutoStackButtons(autoStack);
611 },
612 enumerable: false,
613 configurable: true
614 });
615 MDCDialog.attachTo = function (root) {
616 return new MDCDialog(root);
617 };
618 MDCDialog.prototype.initialize = function (focusTrapFactory) {
619 var e_1, _a;
620 if (focusTrapFactory === void 0) {
621 focusTrapFactory = function focusTrapFactory(el, focusOptions) {
622 return new focus_trap_1.FocusTrap(el, focusOptions);
623 };
624 }
625 var container = this.root.querySelector(strings.CONTAINER_SELECTOR);
626 if (!container) {
627 throw new Error("Dialog component requires a " + strings.CONTAINER_SELECTOR + " container element");
628 }
629 this.container = container;
630 this.content = this.root.querySelector(strings.CONTENT_SELECTOR);
631 this.buttons = [].slice.call(this.root.querySelectorAll(strings.BUTTON_SELECTOR));
632 this.defaultButton = this.root.querySelector("[" + strings.BUTTON_DEFAULT_ATTRIBUTE + "]");
633 this.focusTrapFactory = focusTrapFactory;
634 this.buttonRipples = [];
635 try {
636 for (var _b = __values(this.buttons), _c = _b.next(); !_c.done; _c = _b.next()) {
637 var buttonEl = _c.value;
638 this.buttonRipples.push(new component_2.MDCRipple(buttonEl));
639 }
640 } catch (e_1_1) {
641 e_1 = { error: e_1_1 };
642 } finally {
643 try {
644 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
645 } finally {
646 if (e_1) throw e_1.error;
647 }
648 }
649 };
650 MDCDialog.prototype.initialSyncWithDOM = function () {
651 var _this = this;
652 this.focusTrap = util.createFocusTrapInstance(this.container, this.focusTrapFactory, this.getInitialFocusEl() || undefined);
653 this.handleClick = this.foundation.handleClick.bind(this.foundation);
654 this.handleKeydown = this.foundation.handleKeydown.bind(this.foundation);
655 this.handleDocumentKeydown = this.foundation.handleDocumentKeydown.bind(this.foundation);
656 // this.handleLayout = this.layout.bind(this);
657 this.handleOpening = function () {
658 document.addEventListener('keydown', _this.handleDocumentKeydown);
659 };
660 this.handleClosing = function () {
661 document.removeEventListener('keydown', _this.handleDocumentKeydown);
662 };
663 this.listen('click', this.handleClick);
664 this.listen('keydown', this.handleKeydown);
665 this.listen(strings.OPENING_EVENT, this.handleOpening);
666 this.listen(strings.CLOSING_EVENT, this.handleClosing);
667 };
668 MDCDialog.prototype.destroy = function () {
669 this.unlisten('click', this.handleClick);
670 this.unlisten('keydown', this.handleKeydown);
671 this.unlisten(strings.OPENING_EVENT, this.handleOpening);
672 this.unlisten(strings.CLOSING_EVENT, this.handleClosing);
673 this.handleClosing();
674 this.buttonRipples.forEach(function (ripple) {
675 ripple.destroy();
676 });
677 _super.prototype.destroy.call(this);
678 };
679 MDCDialog.prototype.layout = function () {
680 this.foundation.layout();
681 };
682 MDCDialog.prototype.open = function () {
683 this.foundation.open();
684 };
685 MDCDialog.prototype.close = function (action) {
686 if (action === void 0) {
687 action = '';
688 }
689 this.foundation.close(action);
690 };
691 MDCDialog.prototype.getDefaultFoundation = function () {
692 var _this = this;
693 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
694 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
695 var adapter = {
696 addBodyClass: function addBodyClass(className) {
697 return document.body.classList.add(className);
698 },
699 addClass: function addClass(className) {
700 return _this.root.classList.add(className);
701 },
702 areButtonsStacked: function areButtonsStacked() {
703 return util.areTopsMisaligned(_this.buttons);
704 },
705 clickDefaultButton: function clickDefaultButton() {
706 if (_this.defaultButton && !_this.defaultButton.disabled) {
707 _this.defaultButton.click();
708 }
709 },
710 eventTargetMatches: function eventTargetMatches(target, selector) {
711 return target ? ponyfill_1.matches(target, selector) : false;
712 },
713 getActionFromEvent: function getActionFromEvent(evt) {
714 if (!evt.target) {
715 return '';
716 }
717 var element = ponyfill_1.closest(evt.target, "[" + strings.ACTION_ATTRIBUTE + "]");
718 return element && element.getAttribute(strings.ACTION_ATTRIBUTE);
719 },
720 getInitialFocusEl: function getInitialFocusEl() {
721 return _this.getInitialFocusEl();
722 },
723 hasClass: function hasClass(className) {
724 return _this.root.classList.contains(className);
725 },
726 isContentScrollable: function isContentScrollable() {
727 return util.isScrollable(_this.content);
728 },
729 notifyClosed: function notifyClosed(action) {
730 return _this.emit(strings.CLOSED_EVENT, action ? { action: action } : {});
731 },
732 notifyClosing: function notifyClosing(action) {
733 return _this.emit(strings.CLOSING_EVENT, action ? { action: action } : {});
734 },
735 notifyOpened: function notifyOpened() {
736 return _this.emit(strings.OPENED_EVENT, {});
737 },
738 notifyOpening: function notifyOpening() {
739 return _this.emit(strings.OPENING_EVENT, {});
740 },
741 releaseFocus: function releaseFocus() {
742 _this.focusTrap.releaseFocus();
743 },
744 removeBodyClass: function removeBodyClass(className) {
745 return document.body.classList.remove(className);
746 },
747 removeClass: function removeClass(className) {
748 return _this.root.classList.remove(className);
749 },
750 reverseButtons: function reverseButtons() {
751 _this.buttons.reverse();
752 _this.buttons.forEach(function (button) {
753 button.parentElement.appendChild(button);
754 });
755 },
756 trapFocus: function trapFocus() {
757 _this.focusTrap.trapFocus();
758 },
759 registerContentEventHandler: function registerContentEventHandler(evt, handler) {
760 if (_this.content instanceof HTMLElement) {
761 _this.content.addEventListener(evt, handler);
762 }
763 },
764 deregisterContentEventHandler: function deregisterContentEventHandler(evt, handler) {
765 if (_this.content instanceof HTMLElement) {
766 _this.content.removeEventListener(evt, handler);
767 }
768 },
769 isScrollableContentAtTop: function isScrollableContentAtTop() {
770 return util.isScrollAtTop(_this.content);
771 },
772 isScrollableContentAtBottom: function isScrollableContentAtBottom() {
773 return util.isScrollAtBottom(_this.content);
774 },
775 registerWindowEventHandler: function registerWindowEventHandler(evt, handler) {
776 window.addEventListener(evt, handler);
777 },
778 deregisterWindowEventHandler: function deregisterWindowEventHandler(evt, handler) {
779 window.removeEventListener(evt, handler);
780 }
781 };
782 return new foundation_1.MDCDialogFoundation(adapter);
783 };
784 MDCDialog.prototype.getInitialFocusEl = function () {
785 return this.root.querySelector("[" + strings.INITIAL_FOCUS_ATTRIBUTE + "]");
786 };
787 return MDCDialog;
788}(component_1.MDCComponent);
789exports.MDCDialog = MDCDialog;
790
791/***/ }),
792
793/***/ "./packages/mdc-dialog/constants.ts":
794/*!******************************************!*\
795 !*** ./packages/mdc-dialog/constants.ts ***!
796 \******************************************/
797/*! no static exports found */
798/***/ (function(module, exports, __webpack_require__) {
799
800"use strict";
801
802/**
803 * @license
804 * Copyright 2016 Google Inc.
805 *
806 * Permission is hereby granted, free of charge, to any person obtaining a copy
807 * of this software and associated documentation files (the "Software"), to deal
808 * in the Software without restriction, including without limitation the rights
809 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
810 * copies of the Software, and to permit persons to whom the Software is
811 * furnished to do so, subject to the following conditions:
812 *
813 * The above copyright notice and this permission notice shall be included in
814 * all copies or substantial portions of the Software.
815 *
816 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
817 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
818 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
819 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
820 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
821 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
822 * THE SOFTWARE.
823 */
824
825Object.defineProperty(exports, "__esModule", { value: true });
826exports.numbers = exports.strings = exports.cssClasses = void 0;
827exports.cssClasses = {
828 CLOSING: 'mdc-dialog--closing',
829 OPEN: 'mdc-dialog--open',
830 OPENING: 'mdc-dialog--opening',
831 SCROLLABLE: 'mdc-dialog--scrollable',
832 SCROLL_LOCK: 'mdc-dialog-scroll-lock',
833 STACKED: 'mdc-dialog--stacked',
834 FULLSCREEN: 'mdc-dialog--fullscreen',
835 // Class for showing a scroll divider on full-screen dialog header element.
836 // Should only be displayed on scrollable content, when the dialog content is
837 // scrolled "underneath" the header.
838 SCROLL_DIVIDER_HEADER: 'mdc-dialog-scroll-divider-header',
839 // Class for showing a scroll divider on a full-screen dialog footer element.
840 // Should only be displayed on scrolalble content, when the dialog content is
841 // obscured "underneath" the footer.
842 SCROLL_DIVIDER_FOOTER: 'mdc-dialog-scroll-divider-footer',
843 // The "surface scrim" is a scrim covering only the surface of a dialog. This
844 // is used in situations where a confirmation dialog is shown over an already
845 // opened full-screen dialog. On larger screen-sizes, the full-screen dialog
846 // is sized as a modal and so in these situations we display a "surface scrim"
847 // to prevent a "double scrim" (where the scrim from the secondary
848 // confirmation dialog would overlap with the scrim from the full-screen
849 // dialog).
850 SURFACE_SCRIM_SHOWN: 'mdc-dialog__surface-scrim--shown',
851 // "Showing" animating class for the surface-scrim.
852 SURFACE_SCRIM_SHOWING: 'mdc-dialog__surface-scrim--showing',
853 // "Hiding" animating class for the surface-scrim.
854 SURFACE_SCRIM_HIDING: 'mdc-dialog__surface-scrim--hiding',
855 // Class to hide a dialog's scrim (used in conjunction with a surface-scrim).
856 // Note that we only hide the original scrim rather than removing it entirely
857 // to prevent interactions with the content behind this scrim, and to capture
858 // scrim clicks.
859 SCRIM_HIDDEN: 'mdc-dialog__scrim--hidden'
860};
861exports.strings = {
862 ACTION_ATTRIBUTE: 'data-mdc-dialog-action',
863 BUTTON_DEFAULT_ATTRIBUTE: 'data-mdc-dialog-button-default',
864 BUTTON_SELECTOR: '.mdc-dialog__button',
865 CLOSED_EVENT: 'MDCDialog:closed',
866 CLOSE_ACTION: 'close',
867 CLOSING_EVENT: 'MDCDialog:closing',
868 CONTAINER_SELECTOR: '.mdc-dialog__container',
869 CONTENT_SELECTOR: '.mdc-dialog__content',
870 DESTROY_ACTION: 'destroy',
871 INITIAL_FOCUS_ATTRIBUTE: 'data-mdc-dialog-initial-focus',
872 OPENED_EVENT: 'MDCDialog:opened',
873 OPENING_EVENT: 'MDCDialog:opening',
874 SCRIM_SELECTOR: '.mdc-dialog__scrim',
875 SUPPRESS_DEFAULT_PRESS_SELECTOR: ['textarea', '.mdc-menu .mdc-list-item', '.mdc-menu .mdc-deprecated-list-item'].join(', '),
876 SURFACE_SELECTOR: '.mdc-dialog__surface'
877};
878exports.numbers = {
879 DIALOG_ANIMATION_CLOSE_TIME_MS: 75,
880 DIALOG_ANIMATION_OPEN_TIME_MS: 150
881};
882
883/***/ }),
884
885/***/ "./packages/mdc-dialog/foundation.ts":
886/*!*******************************************!*\
887 !*** ./packages/mdc-dialog/foundation.ts ***!
888 \*******************************************/
889/*! no static exports found */
890/***/ (function(module, exports, __webpack_require__) {
891
892"use strict";
893
894/**
895 * @license
896 * Copyright 2017 Google Inc.
897 *
898 * Permission is hereby granted, free of charge, to any person obtaining a copy
899 * of this software and associated documentation files (the "Software"), to deal
900 * in the Software without restriction, including without limitation the rights
901 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
902 * copies of the Software, and to permit persons to whom the Software is
903 * furnished to do so, subject to the following conditions:
904 *
905 * The above copyright notice and this permission notice shall be included in
906 * all copies or substantial portions of the Software.
907 *
908 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
909 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
910 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
911 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
912 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
913 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
914 * THE SOFTWARE.
915 */
916
917var __extends = this && this.__extends || function () {
918 var _extendStatics = function extendStatics(d, b) {
919 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
920 d.__proto__ = b;
921 } || function (d, b) {
922 for (var p in b) {
923 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
924 }
925 };
926 return _extendStatics(d, b);
927 };
928 return function (d, b) {
929 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
930 _extendStatics(d, b);
931 function __() {
932 this.constructor = d;
933 }
934 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
935 };
936}();
937var __assign = this && this.__assign || function () {
938 __assign = Object.assign || function (t) {
939 for (var s, i = 1, n = arguments.length; i < n; i++) {
940 s = arguments[i];
941 for (var p in s) {
942 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
943 }
944 }
945 return t;
946 };
947 return __assign.apply(this, arguments);
948};
949Object.defineProperty(exports, "__esModule", { value: true });
950exports.MDCDialogFoundation = void 0;
951var animationframe_1 = __webpack_require__(/*! @material/animation/animationframe */ "./packages/mdc-animation/animationframe.ts");
952var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
953var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-dialog/constants.ts");
954var AnimationKeys;
955(function (AnimationKeys) {
956 AnimationKeys["POLL_SCROLL_POS"] = "poll_scroll_position";
957 AnimationKeys["POLL_LAYOUT_CHANGE"] = "poll_layout_change";
958})(AnimationKeys || (AnimationKeys = {}));
959var MDCDialogFoundation = /** @class */function (_super) {
960 __extends(MDCDialogFoundation, _super);
961 function MDCDialogFoundation(adapter) {
962 var _this = _super.call(this, __assign(__assign({}, MDCDialogFoundation.defaultAdapter), adapter)) || this;
963 _this.dialogOpen = false;
964 _this.isFullscreen = false;
965 _this.animationFrame = 0;
966 _this.animationTimer = 0;
967 _this.escapeKeyAction = constants_1.strings.CLOSE_ACTION;
968 _this.scrimClickAction = constants_1.strings.CLOSE_ACTION;
969 _this.autoStackButtons = true;
970 _this.areButtonsStacked = false;
971 _this.suppressDefaultPressSelector = constants_1.strings.SUPPRESS_DEFAULT_PRESS_SELECTOR;
972 _this.animFrame = new animationframe_1.AnimationFrame();
973 _this.contentScrollHandler = function () {
974 _this.handleScrollEvent();
975 };
976 _this.windowResizeHandler = function () {
977 _this.layout();
978 };
979 _this.windowOrientationChangeHandler = function () {
980 _this.layout();
981 };
982 return _this;
983 }
984 Object.defineProperty(MDCDialogFoundation, "cssClasses", {
985 get: function get() {
986 return constants_1.cssClasses;
987 },
988 enumerable: false,
989 configurable: true
990 });
991 Object.defineProperty(MDCDialogFoundation, "strings", {
992 get: function get() {
993 return constants_1.strings;
994 },
995 enumerable: false,
996 configurable: true
997 });
998 Object.defineProperty(MDCDialogFoundation, "numbers", {
999 get: function get() {
1000 return constants_1.numbers;
1001 },
1002 enumerable: false,
1003 configurable: true
1004 });
1005 Object.defineProperty(MDCDialogFoundation, "defaultAdapter", {
1006 get: function get() {
1007 return {
1008 addBodyClass: function addBodyClass() {
1009 return undefined;
1010 },
1011 addClass: function addClass() {
1012 return undefined;
1013 },
1014 areButtonsStacked: function areButtonsStacked() {
1015 return false;
1016 },
1017 clickDefaultButton: function clickDefaultButton() {
1018 return undefined;
1019 },
1020 eventTargetMatches: function eventTargetMatches() {
1021 return false;
1022 },
1023 getActionFromEvent: function getActionFromEvent() {
1024 return '';
1025 },
1026 getInitialFocusEl: function getInitialFocusEl() {
1027 return null;
1028 },
1029 hasClass: function hasClass() {
1030 return false;
1031 },
1032 isContentScrollable: function isContentScrollable() {
1033 return false;
1034 },
1035 notifyClosed: function notifyClosed() {
1036 return undefined;
1037 },
1038 notifyClosing: function notifyClosing() {
1039 return undefined;
1040 },
1041 notifyOpened: function notifyOpened() {
1042 return undefined;
1043 },
1044 notifyOpening: function notifyOpening() {
1045 return undefined;
1046 },
1047 releaseFocus: function releaseFocus() {
1048 return undefined;
1049 },
1050 removeBodyClass: function removeBodyClass() {
1051 return undefined;
1052 },
1053 removeClass: function removeClass() {
1054 return undefined;
1055 },
1056 reverseButtons: function reverseButtons() {
1057 return undefined;
1058 },
1059 trapFocus: function trapFocus() {
1060 return undefined;
1061 },
1062 registerContentEventHandler: function registerContentEventHandler() {
1063 return undefined;
1064 },
1065 deregisterContentEventHandler: function deregisterContentEventHandler() {
1066 return undefined;
1067 },
1068 isScrollableContentAtTop: function isScrollableContentAtTop() {
1069 return false;
1070 },
1071 isScrollableContentAtBottom: function isScrollableContentAtBottom() {
1072 return false;
1073 },
1074 registerWindowEventHandler: function registerWindowEventHandler() {
1075 return undefined;
1076 },
1077 deregisterWindowEventHandler: function deregisterWindowEventHandler() {
1078 return undefined;
1079 }
1080 };
1081 },
1082 enumerable: false,
1083 configurable: true
1084 });
1085 MDCDialogFoundation.prototype.init = function () {
1086 if (this.adapter.hasClass(constants_1.cssClasses.STACKED)) {
1087 this.setAutoStackButtons(false);
1088 }
1089 this.isFullscreen = this.adapter.hasClass(constants_1.cssClasses.FULLSCREEN);
1090 };
1091 MDCDialogFoundation.prototype.destroy = function () {
1092 if (this.animationTimer) {
1093 clearTimeout(this.animationTimer);
1094 this.handleAnimationTimerEnd();
1095 }
1096 if (this.isFullscreen) {
1097 this.adapter.deregisterContentEventHandler('scroll', this.contentScrollHandler);
1098 }
1099 this.animFrame.cancelAll();
1100 this.adapter.deregisterWindowEventHandler('resize', this.windowResizeHandler);
1101 this.adapter.deregisterWindowEventHandler('orientationchange', this.windowOrientationChangeHandler);
1102 };
1103 MDCDialogFoundation.prototype.open = function (dialogOptions) {
1104 var _this = this;
1105 this.dialogOpen = true;
1106 this.adapter.notifyOpening();
1107 this.adapter.addClass(constants_1.cssClasses.OPENING);
1108 if (this.isFullscreen) {
1109 // A scroll event listener is registered even if the dialog is not
1110 // scrollable on open, since the window resize event, or orientation
1111 // change may make the dialog scrollable after it is opened.
1112 this.adapter.registerContentEventHandler('scroll', this.contentScrollHandler);
1113 }
1114 if (dialogOptions && dialogOptions.isAboveFullscreenDialog) {
1115 this.adapter.addClass(constants_1.cssClasses.SCRIM_HIDDEN);
1116 }
1117 this.adapter.registerWindowEventHandler('resize', this.windowResizeHandler);
1118 this.adapter.registerWindowEventHandler('orientationchange', this.windowOrientationChangeHandler);
1119 // Wait a frame once display is no longer "none", to establish basis for
1120 // animation
1121 this.runNextAnimationFrame(function () {
1122 _this.adapter.addClass(constants_1.cssClasses.OPEN);
1123 _this.adapter.addBodyClass(constants_1.cssClasses.SCROLL_LOCK);
1124 _this.layout();
1125 _this.animationTimer = setTimeout(function () {
1126 _this.handleAnimationTimerEnd();
1127 _this.adapter.trapFocus(_this.adapter.getInitialFocusEl());
1128 _this.adapter.notifyOpened();
1129 }, constants_1.numbers.DIALOG_ANIMATION_OPEN_TIME_MS);
1130 });
1131 };
1132 MDCDialogFoundation.prototype.close = function (action) {
1133 var _this = this;
1134 if (action === void 0) {
1135 action = '';
1136 }
1137 if (!this.dialogOpen) {
1138 // Avoid redundant close calls (and events), e.g. from keydown on elements
1139 // that inherently emit click
1140 return;
1141 }
1142 this.dialogOpen = false;
1143 this.adapter.notifyClosing(action);
1144 this.adapter.addClass(constants_1.cssClasses.CLOSING);
1145 this.adapter.removeClass(constants_1.cssClasses.OPEN);
1146 this.adapter.removeBodyClass(constants_1.cssClasses.SCROLL_LOCK);
1147 if (this.isFullscreen) {
1148 this.adapter.deregisterContentEventHandler('scroll', this.contentScrollHandler);
1149 }
1150 this.adapter.deregisterWindowEventHandler('resize', this.windowResizeHandler);
1151 this.adapter.deregisterWindowEventHandler('orientationchange', this.windowOrientationChangeHandler);
1152 cancelAnimationFrame(this.animationFrame);
1153 this.animationFrame = 0;
1154 clearTimeout(this.animationTimer);
1155 this.animationTimer = setTimeout(function () {
1156 _this.adapter.releaseFocus();
1157 _this.handleAnimationTimerEnd();
1158 _this.adapter.notifyClosed(action);
1159 }, constants_1.numbers.DIALOG_ANIMATION_CLOSE_TIME_MS);
1160 };
1161 /**
1162 * Used only in instances of showing a secondary dialog over a full-screen
1163 * dialog. Shows the "surface scrim" displayed over the full-screen dialog.
1164 */
1165 MDCDialogFoundation.prototype.showSurfaceScrim = function () {
1166 var _this = this;
1167 this.adapter.addClass(constants_1.cssClasses.SURFACE_SCRIM_SHOWING);
1168 this.runNextAnimationFrame(function () {
1169 _this.adapter.addClass(constants_1.cssClasses.SURFACE_SCRIM_SHOWN);
1170 });
1171 };
1172 /**
1173 * Used only in instances of showing a secondary dialog over a full-screen
1174 * dialog. Hides the "surface scrim" displayed over the full-screen dialog.
1175 */
1176 MDCDialogFoundation.prototype.hideSurfaceScrim = function () {
1177 this.adapter.removeClass(constants_1.cssClasses.SURFACE_SCRIM_SHOWN);
1178 this.adapter.addClass(constants_1.cssClasses.SURFACE_SCRIM_HIDING);
1179 };
1180 /**
1181 * Handles `transitionend` event triggered when surface scrim animation is
1182 * finished.
1183 */
1184 MDCDialogFoundation.prototype.handleSurfaceScrimTransitionEnd = function () {
1185 this.adapter.removeClass(constants_1.cssClasses.SURFACE_SCRIM_HIDING);
1186 this.adapter.removeClass(constants_1.cssClasses.SURFACE_SCRIM_SHOWING);
1187 };
1188 MDCDialogFoundation.prototype.isOpen = function () {
1189 return this.dialogOpen;
1190 };
1191 MDCDialogFoundation.prototype.getEscapeKeyAction = function () {
1192 return this.escapeKeyAction;
1193 };
1194 MDCDialogFoundation.prototype.setEscapeKeyAction = function (action) {
1195 this.escapeKeyAction = action;
1196 };
1197 MDCDialogFoundation.prototype.getScrimClickAction = function () {
1198 return this.scrimClickAction;
1199 };
1200 MDCDialogFoundation.prototype.setScrimClickAction = function (action) {
1201 this.scrimClickAction = action;
1202 };
1203 MDCDialogFoundation.prototype.getAutoStackButtons = function () {
1204 return this.autoStackButtons;
1205 };
1206 MDCDialogFoundation.prototype.setAutoStackButtons = function (autoStack) {
1207 this.autoStackButtons = autoStack;
1208 };
1209 MDCDialogFoundation.prototype.getSuppressDefaultPressSelector = function () {
1210 return this.suppressDefaultPressSelector;
1211 };
1212 MDCDialogFoundation.prototype.setSuppressDefaultPressSelector = function (selector) {
1213 this.suppressDefaultPressSelector = selector;
1214 };
1215 MDCDialogFoundation.prototype.layout = function () {
1216 var _this = this;
1217 this.animFrame.request(AnimationKeys.POLL_LAYOUT_CHANGE, function () {
1218 _this.layoutInternal();
1219 });
1220 };
1221 /** Handles click on the dialog root element. */
1222 MDCDialogFoundation.prototype.handleClick = function (evt) {
1223 var isScrim = this.adapter.eventTargetMatches(evt.target, constants_1.strings.SCRIM_SELECTOR);
1224 // Check for scrim click first since it doesn't require querying ancestors.
1225 if (isScrim && this.scrimClickAction !== '') {
1226 this.close(this.scrimClickAction);
1227 } else {
1228 var action = this.adapter.getActionFromEvent(evt);
1229 if (action) {
1230 this.close(action);
1231 }
1232 }
1233 };
1234 /** Handles keydown on the dialog root element. */
1235 MDCDialogFoundation.prototype.handleKeydown = function (evt) {
1236 var isEnter = evt.key === 'Enter' || evt.keyCode === 13;
1237 if (!isEnter) {
1238 return;
1239 }
1240 var action = this.adapter.getActionFromEvent(evt);
1241 if (action) {
1242 // Action button callback is handled in `handleClick`,
1243 // since space/enter keydowns on buttons trigger click events.
1244 return;
1245 }
1246 // `composedPath` is used here, when available, to account for use cases
1247 // where a target meant to suppress the default press behaviour
1248 // may exist in a shadow root.
1249 // For example, a textarea inside a web component:
1250 // <mwc-dialog>
1251 // <horizontal-layout>
1252 // #shadow-root (open)
1253 // <mwc-textarea>
1254 // #shadow-root (open)
1255 // <textarea></textarea>
1256 // </mwc-textarea>
1257 // </horizontal-layout>
1258 // </mwc-dialog>
1259 var target = evt.composedPath ? evt.composedPath()[0] : evt.target;
1260 var isDefault = this.suppressDefaultPressSelector ? !this.adapter.eventTargetMatches(target, this.suppressDefaultPressSelector) : true;
1261 if (isEnter && isDefault) {
1262 this.adapter.clickDefaultButton();
1263 }
1264 };
1265 /** Handles keydown on the document. */
1266 MDCDialogFoundation.prototype.handleDocumentKeydown = function (evt) {
1267 var isEscape = evt.key === 'Escape' || evt.keyCode === 27;
1268 if (isEscape && this.escapeKeyAction !== '') {
1269 this.close(this.escapeKeyAction);
1270 }
1271 };
1272 /**
1273 * Handles scroll event on the dialog's content element -- showing a scroll
1274 * divider on the header or footer based on the scroll position. This handler
1275 * should only be registered on full-screen dialogs with scrollable content.
1276 */
1277 MDCDialogFoundation.prototype.handleScrollEvent = function () {
1278 var _this = this;
1279 // Since scroll events can fire at a high rate, we throttle these events by
1280 // using requestAnimationFrame.
1281 this.animFrame.request(AnimationKeys.POLL_SCROLL_POS, function () {
1282 _this.toggleScrollDividerHeader();
1283 _this.toggleScrollDividerFooter();
1284 });
1285 };
1286 MDCDialogFoundation.prototype.layoutInternal = function () {
1287 if (this.autoStackButtons) {
1288 this.detectStackedButtons();
1289 }
1290 this.toggleScrollableClasses();
1291 };
1292 MDCDialogFoundation.prototype.handleAnimationTimerEnd = function () {
1293 this.animationTimer = 0;
1294 this.adapter.removeClass(constants_1.cssClasses.OPENING);
1295 this.adapter.removeClass(constants_1.cssClasses.CLOSING);
1296 };
1297 /**
1298 * Runs the given logic on the next animation frame, using setTimeout to
1299 * factor in Firefox reflow behavior.
1300 */
1301 MDCDialogFoundation.prototype.runNextAnimationFrame = function (callback) {
1302 var _this = this;
1303 cancelAnimationFrame(this.animationFrame);
1304 this.animationFrame = requestAnimationFrame(function () {
1305 _this.animationFrame = 0;
1306 clearTimeout(_this.animationTimer);
1307 _this.animationTimer = setTimeout(callback, 0);
1308 });
1309 };
1310 MDCDialogFoundation.prototype.detectStackedButtons = function () {
1311 // Remove the class first to let us measure the buttons' natural positions.
1312 this.adapter.removeClass(constants_1.cssClasses.STACKED);
1313 var areButtonsStacked = this.adapter.areButtonsStacked();
1314 if (areButtonsStacked) {
1315 this.adapter.addClass(constants_1.cssClasses.STACKED);
1316 }
1317 if (areButtonsStacked !== this.areButtonsStacked) {
1318 this.adapter.reverseButtons();
1319 this.areButtonsStacked = areButtonsStacked;
1320 }
1321 };
1322 MDCDialogFoundation.prototype.toggleScrollableClasses = function () {
1323 // Remove the class first to let us measure the natural height of the
1324 // content.
1325 this.adapter.removeClass(constants_1.cssClasses.SCROLLABLE);
1326 if (this.adapter.isContentScrollable()) {
1327 this.adapter.addClass(constants_1.cssClasses.SCROLLABLE);
1328 if (this.isFullscreen) {
1329 // If dialog is full-screen and scrollable, check if a scroll divider
1330 // should be shown.
1331 this.toggleScrollDividerHeader();
1332 this.toggleScrollDividerFooter();
1333 }
1334 }
1335 };
1336 MDCDialogFoundation.prototype.toggleScrollDividerHeader = function () {
1337 if (!this.adapter.isScrollableContentAtTop()) {
1338 this.adapter.addClass(constants_1.cssClasses.SCROLL_DIVIDER_HEADER);
1339 } else if (this.adapter.hasClass(constants_1.cssClasses.SCROLL_DIVIDER_HEADER)) {
1340 this.adapter.removeClass(constants_1.cssClasses.SCROLL_DIVIDER_HEADER);
1341 }
1342 };
1343 MDCDialogFoundation.prototype.toggleScrollDividerFooter = function () {
1344 if (!this.adapter.isScrollableContentAtBottom()) {
1345 this.adapter.addClass(constants_1.cssClasses.SCROLL_DIVIDER_FOOTER);
1346 } else if (this.adapter.hasClass(constants_1.cssClasses.SCROLL_DIVIDER_FOOTER)) {
1347 this.adapter.removeClass(constants_1.cssClasses.SCROLL_DIVIDER_FOOTER);
1348 }
1349 };
1350 return MDCDialogFoundation;
1351}(foundation_1.MDCFoundation);
1352exports.MDCDialogFoundation = MDCDialogFoundation;
1353// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
1354exports.default = MDCDialogFoundation;
1355
1356/***/ }),
1357
1358/***/ "./packages/mdc-dialog/index.ts":
1359/*!**************************************!*\
1360 !*** ./packages/mdc-dialog/index.ts ***!
1361 \**************************************/
1362/*! no static exports found */
1363/***/ (function(module, exports, __webpack_require__) {
1364
1365"use strict";
1366
1367/**
1368 * @license
1369 * Copyright 2019 Google Inc.
1370 *
1371 * Permission is hereby granted, free of charge, to any person obtaining a copy
1372 * of this software and associated documentation files (the "Software"), to deal
1373 * in the Software without restriction, including without limitation the rights
1374 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1375 * copies of the Software, and to permit persons to whom the Software is
1376 * furnished to do so, subject to the following conditions:
1377 *
1378 * The above copyright notice and this permission notice shall be included in
1379 * all copies or substantial portions of the Software.
1380 *
1381 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1382 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1383 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1384 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1385 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1386 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1387 * THE SOFTWARE.
1388 */
1389
1390var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
1391 if (k2 === undefined) k2 = k;
1392 Object.defineProperty(o, k2, { enumerable: true, get: function get() {
1393 return m[k];
1394 } });
1395} : function (o, m, k, k2) {
1396 if (k2 === undefined) k2 = k;
1397 o[k2] = m[k];
1398});
1399var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
1400 Object.defineProperty(o, "default", { enumerable: true, value: v });
1401} : function (o, v) {
1402 o["default"] = v;
1403});
1404var __importStar = this && this.__importStar || function (mod) {
1405 if (mod && mod.__esModule) return mod;
1406 var result = {};
1407 if (mod != null) for (var k in mod) {
1408 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1409 }__setModuleDefault(result, mod);
1410 return result;
1411};
1412var __exportStar = this && this.__exportStar || function (m, exports) {
1413 for (var p in m) {
1414 if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1415 }
1416};
1417Object.defineProperty(exports, "__esModule", { value: true });
1418exports.util = void 0;
1419var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-dialog/util.ts"));
1420exports.util = util;
1421__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-dialog/adapter.ts"), exports);
1422__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-dialog/component.ts"), exports);
1423__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-dialog/constants.ts"), exports);
1424__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-dialog/foundation.ts"), exports);
1425__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-dialog/types.ts"), exports);
1426
1427/***/ }),
1428
1429/***/ "./packages/mdc-dialog/types.ts":
1430/*!**************************************!*\
1431 !*** ./packages/mdc-dialog/types.ts ***!
1432 \**************************************/
1433/*! no static exports found */
1434/***/ (function(module, exports, __webpack_require__) {
1435
1436"use strict";
1437
1438/**
1439 * @license
1440 * Copyright 2019 Google Inc.
1441 *
1442 * Permission is hereby granted, free of charge, to any person obtaining a copy
1443 * of this software and associated documentation files (the "Software"), to deal
1444 * in the Software without restriction, including without limitation the rights
1445 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1446 * copies of the Software, and to permit persons to whom the Software is
1447 * furnished to do so, subject to the following conditions:
1448 *
1449 * The above copyright notice and this permission notice shall be included in
1450 * all copies or substantial portions of the Software.
1451 *
1452 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1453 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1454 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1455 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1456 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1457 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1458 * THE SOFTWARE.
1459 */
1460
1461Object.defineProperty(exports, "__esModule", { value: true });
1462
1463/***/ }),
1464
1465/***/ "./packages/mdc-dialog/util.ts":
1466/*!*************************************!*\
1467 !*** ./packages/mdc-dialog/util.ts ***!
1468 \*************************************/
1469/*! no static exports found */
1470/***/ (function(module, exports, __webpack_require__) {
1471
1472"use strict";
1473
1474/**
1475 * @license
1476 * Copyright 2016 Google Inc.
1477 *
1478 * Permission is hereby granted, free of charge, to any person obtaining a copy
1479 * of this software and associated documentation files (the "Software"), to deal
1480 * in the Software without restriction, including without limitation the rights
1481 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1482 * copies of the Software, and to permit persons to whom the Software is
1483 * furnished to do so, subject to the following conditions:
1484 *
1485 * The above copyright notice and this permission notice shall be included in
1486 * all copies or substantial portions of the Software.
1487 *
1488 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1489 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1490 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1491 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1492 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1493 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1494 * THE SOFTWARE.
1495 */
1496
1497Object.defineProperty(exports, "__esModule", { value: true });
1498exports.areTopsMisaligned = exports.isScrollAtBottom = exports.isScrollAtTop = exports.isScrollable = exports.createFocusTrapInstance = void 0;
1499function createFocusTrapInstance(surfaceEl, focusTrapFactory, initialFocusEl) {
1500 return focusTrapFactory(surfaceEl, { initialFocusEl: initialFocusEl });
1501}
1502exports.createFocusTrapInstance = createFocusTrapInstance;
1503function isScrollable(el) {
1504 return el ? el.scrollHeight > el.offsetHeight : false;
1505}
1506exports.isScrollable = isScrollable;
1507/**
1508 * For scrollable content, returns true if the content has not been scrolled
1509 * (that is, the scroll content is as the "top"). This is used in full-screen
1510 * dialogs, where the scroll divider is expected only to appear once the
1511 * content has been scrolled "underneath" the header bar.
1512 */
1513function isScrollAtTop(el) {
1514 return el ? el.scrollTop === 0 : false;
1515}
1516exports.isScrollAtTop = isScrollAtTop;
1517/**
1518 * For scrollable content, returns true if the content has been scrolled all the
1519 * way to the bottom. This is used in full-screen dialogs, where the footer
1520 * scroll divider is expected only to appear when the content is "cut-off" by
1521 * the footer bar.
1522 */
1523function isScrollAtBottom(el) {
1524 return el ? Math.ceil(el.scrollHeight - el.scrollTop) === el.clientHeight : false;
1525}
1526exports.isScrollAtBottom = isScrollAtBottom;
1527function areTopsMisaligned(els) {
1528 var tops = new Set();
1529 [].forEach.call(els, function (el) {
1530 return tops.add(el.offsetTop);
1531 });
1532 return tops.size > 1;
1533}
1534exports.areTopsMisaligned = areTopsMisaligned;
1535
1536/***/ }),
1537
1538/***/ "./packages/mdc-dom/events.ts":
1539/*!************************************!*\
1540 !*** ./packages/mdc-dom/events.ts ***!
1541 \************************************/
1542/*! no static exports found */
1543/***/ (function(module, exports, __webpack_require__) {
1544
1545"use strict";
1546
1547/**
1548 * @license
1549 * Copyright 2019 Google Inc.
1550 *
1551 * Permission is hereby granted, free of charge, to any person obtaining a copy
1552 * of this software and associated documentation files (the "Software"), to deal
1553 * in the Software without restriction, including without limitation the rights
1554 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1555 * copies of the Software, and to permit persons to whom the Software is
1556 * furnished to do so, subject to the following conditions:
1557 *
1558 * The above copyright notice and this permission notice shall be included in
1559 * all copies or substantial portions of the Software.
1560 *
1561 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1562 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1563 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1564 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1565 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1566 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1567 * THE SOFTWARE.
1568 */
1569
1570Object.defineProperty(exports, "__esModule", { value: true });
1571exports.applyPassive = void 0;
1572/**
1573 * Determine whether the current browser supports passive event listeners, and
1574 * if so, use them.
1575 */
1576function applyPassive(globalObj) {
1577 if (globalObj === void 0) {
1578 globalObj = window;
1579 }
1580 return supportsPassiveOption(globalObj) ? { passive: true } : false;
1581}
1582exports.applyPassive = applyPassive;
1583function supportsPassiveOption(globalObj) {
1584 if (globalObj === void 0) {
1585 globalObj = window;
1586 }
1587 // See
1588 // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
1589 var passiveSupported = false;
1590 try {
1591 var options = {
1592 // This function will be called when the browser
1593 // attempts to access the passive property.
1594 get passive() {
1595 passiveSupported = true;
1596 return false;
1597 }
1598 };
1599 var handler = function handler() {};
1600 globalObj.document.addEventListener('test', handler, options);
1601 globalObj.document.removeEventListener('test', handler, options);
1602 } catch (err) {
1603 passiveSupported = false;
1604 }
1605 return passiveSupported;
1606}
1607
1608/***/ }),
1609
1610/***/ "./packages/mdc-dom/focus-trap.ts":
1611/*!****************************************!*\
1612 !*** ./packages/mdc-dom/focus-trap.ts ***!
1613 \****************************************/
1614/*! no static exports found */
1615/***/ (function(module, exports, __webpack_require__) {
1616
1617"use strict";
1618
1619/**
1620 * @license
1621 * Copyright 2020 Google Inc.
1622 *
1623 * Permission is hereby granted, free of charge, to any person obtaining a copy
1624 * of this software and associated documentation files (the "Software"), to deal
1625 * in the Software without restriction, including without limitation the rights
1626 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1627 * copies of the Software, and to permit persons to whom the Software is
1628 * furnished to do so, subject to the following conditions:
1629 *
1630 * The above copyright notice and this permission notice shall be included in
1631 * all copies or substantial portions of the Software.
1632 *
1633 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1634 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1635 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1636 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1637 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1638 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1639 * THE SOFTWARE.
1640 */
1641
1642Object.defineProperty(exports, "__esModule", { value: true });
1643exports.FocusTrap = void 0;
1644var FOCUS_SENTINEL_CLASS = 'mdc-dom-focus-sentinel';
1645/**
1646 * Utility to trap focus in a given root element, e.g. for modal components such
1647 * as dialogs. The root should have at least one focusable child element,
1648 * for setting initial focus when trapping focus.
1649 * Also tracks the previously focused element, and restores focus to that
1650 * element when releasing focus.
1651 */
1652var FocusTrap = /** @class */function () {
1653 function FocusTrap(root, options) {
1654 if (options === void 0) {
1655 options = {};
1656 }
1657 this.root = root;
1658 this.options = options;
1659 // Previously focused element before trapping focus.
1660 this.elFocusedBeforeTrapFocus = null;
1661 }
1662 /**
1663 * Traps focus in `root`. Also focuses on either `initialFocusEl` if set;
1664 * otherwises sets initial focus to the first focusable child element.
1665 */
1666 FocusTrap.prototype.trapFocus = function () {
1667 var focusableEls = this.getFocusableElements(this.root);
1668 if (focusableEls.length === 0) {
1669 throw new Error('FocusTrap: Element must have at least one focusable child.');
1670 }
1671 this.elFocusedBeforeTrapFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
1672 this.wrapTabFocus(this.root);
1673 if (!this.options.skipInitialFocus) {
1674 this.focusInitialElement(focusableEls, this.options.initialFocusEl);
1675 }
1676 };
1677 /**
1678 * Releases focus from `root`. Also restores focus to the previously focused
1679 * element.
1680 */
1681 FocusTrap.prototype.releaseFocus = function () {
1682 [].slice.call(this.root.querySelectorAll("." + FOCUS_SENTINEL_CLASS)).forEach(function (sentinelEl) {
1683 sentinelEl.parentElement.removeChild(sentinelEl);
1684 });
1685 if (!this.options.skipRestoreFocus && this.elFocusedBeforeTrapFocus) {
1686 this.elFocusedBeforeTrapFocus.focus();
1687 }
1688 };
1689 /**
1690 * Wraps tab focus within `el` by adding two hidden sentinel divs which are
1691 * used to mark the beginning and the end of the tabbable region. When
1692 * focused, these sentinel elements redirect focus to the first/last
1693 * children elements of the tabbable region, ensuring that focus is trapped
1694 * within that region.
1695 */
1696 FocusTrap.prototype.wrapTabFocus = function (el) {
1697 var _this = this;
1698 var sentinelStart = this.createSentinel();
1699 var sentinelEnd = this.createSentinel();
1700 sentinelStart.addEventListener('focus', function () {
1701 var focusableEls = _this.getFocusableElements(el);
1702 if (focusableEls.length > 0) {
1703 focusableEls[focusableEls.length - 1].focus();
1704 }
1705 });
1706 sentinelEnd.addEventListener('focus', function () {
1707 var focusableEls = _this.getFocusableElements(el);
1708 if (focusableEls.length > 0) {
1709 focusableEls[0].focus();
1710 }
1711 });
1712 el.insertBefore(sentinelStart, el.children[0]);
1713 el.appendChild(sentinelEnd);
1714 };
1715 /**
1716 * Focuses on `initialFocusEl` if defined and a child of the root element.
1717 * Otherwise, focuses on the first focusable child element of the root.
1718 */
1719 FocusTrap.prototype.focusInitialElement = function (focusableEls, initialFocusEl) {
1720 var focusIndex = 0;
1721 if (initialFocusEl) {
1722 focusIndex = Math.max(focusableEls.indexOf(initialFocusEl), 0);
1723 }
1724 focusableEls[focusIndex].focus();
1725 };
1726 FocusTrap.prototype.getFocusableElements = function (root) {
1727 var focusableEls = [].slice.call(root.querySelectorAll('[autofocus], [tabindex], a, input, textarea, select, button'));
1728 return focusableEls.filter(function (el) {
1729 var isDisabledOrHidden = el.getAttribute('aria-disabled') === 'true' || el.getAttribute('disabled') != null || el.getAttribute('hidden') != null || el.getAttribute('aria-hidden') === 'true';
1730 var isTabbableAndVisible = el.tabIndex >= 0 && el.getBoundingClientRect().width > 0 && !el.classList.contains(FOCUS_SENTINEL_CLASS) && !isDisabledOrHidden;
1731 var isProgrammaticallyHidden = false;
1732 if (isTabbableAndVisible) {
1733 var style = getComputedStyle(el);
1734 isProgrammaticallyHidden = style.display === 'none' || style.visibility === 'hidden';
1735 }
1736 return isTabbableAndVisible && !isProgrammaticallyHidden;
1737 });
1738 };
1739 FocusTrap.prototype.createSentinel = function () {
1740 var sentinel = document.createElement('div');
1741 sentinel.setAttribute('tabindex', '0');
1742 // Don't announce in screen readers.
1743 sentinel.setAttribute('aria-hidden', 'true');
1744 sentinel.classList.add(FOCUS_SENTINEL_CLASS);
1745 return sentinel;
1746 };
1747 return FocusTrap;
1748}();
1749exports.FocusTrap = FocusTrap;
1750
1751/***/ }),
1752
1753/***/ "./packages/mdc-dom/ponyfill.ts":
1754/*!**************************************!*\
1755 !*** ./packages/mdc-dom/ponyfill.ts ***!
1756 \**************************************/
1757/*! no static exports found */
1758/***/ (function(module, exports, __webpack_require__) {
1759
1760"use strict";
1761
1762/**
1763 * @license
1764 * Copyright 2018 Google Inc.
1765 *
1766 * Permission is hereby granted, free of charge, to any person obtaining a copy
1767 * of this software and associated documentation files (the "Software"), to deal
1768 * in the Software without restriction, including without limitation the rights
1769 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1770 * copies of the Software, and to permit persons to whom the Software is
1771 * furnished to do so, subject to the following conditions:
1772 *
1773 * The above copyright notice and this permission notice shall be included in
1774 * all copies or substantial portions of the Software.
1775 *
1776 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1777 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1778 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1779 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1780 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1781 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1782 * THE SOFTWARE.
1783 */
1784
1785Object.defineProperty(exports, "__esModule", { value: true });
1786exports.estimateScrollWidth = exports.matches = exports.closest = void 0;
1787/**
1788 * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global prototype chain.
1789 * This makes ponyfills safer than traditional polyfills, especially for libraries like MDC.
1790 */
1791function closest(element, selector) {
1792 if (element.closest) {
1793 return element.closest(selector);
1794 }
1795 var el = element;
1796 while (el) {
1797 if (matches(el, selector)) {
1798 return el;
1799 }
1800 el = el.parentElement;
1801 }
1802 return null;
1803}
1804exports.closest = closest;
1805function matches(element, selector) {
1806 var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
1807 return nativeMatches.call(element, selector);
1808}
1809exports.matches = matches;
1810/**
1811 * Used to compute the estimated scroll width of elements. When an element is
1812 * hidden due to display: none; being applied to a parent element, the width is
1813 * returned as 0. However, the element will have a true width once no longer
1814 * inside a display: none context. This method computes an estimated width when
1815 * the element is hidden or returns the true width when the element is visble.
1816 * @param {Element} element the element whose width to estimate
1817 */
1818function estimateScrollWidth(element) {
1819 // Check the offsetParent. If the element inherits display: none from any
1820 // parent, the offsetParent property will be null (see
1821 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent).
1822 // This check ensures we only clone the node when necessary.
1823 var htmlEl = element;
1824 if (htmlEl.offsetParent !== null) {
1825 return htmlEl.scrollWidth;
1826 }
1827 var clone = htmlEl.cloneNode(true);
1828 clone.style.setProperty('position', 'absolute');
1829 clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
1830 document.documentElement.appendChild(clone);
1831 var scrollWidth = clone.scrollWidth;
1832 document.documentElement.removeChild(clone);
1833 return scrollWidth;
1834}
1835exports.estimateScrollWidth = estimateScrollWidth;
1836
1837/***/ }),
1838
1839/***/ "./packages/mdc-ripple/component.ts":
1840/*!******************************************!*\
1841 !*** ./packages/mdc-ripple/component.ts ***!
1842 \******************************************/
1843/*! no static exports found */
1844/***/ (function(module, exports, __webpack_require__) {
1845
1846"use strict";
1847
1848/**
1849 * @license
1850 * Copyright 2016 Google Inc.
1851 *
1852 * Permission is hereby granted, free of charge, to any person obtaining a copy
1853 * of this software and associated documentation files (the "Software"), to deal
1854 * in the Software without restriction, including without limitation the rights
1855 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1856 * copies of the Software, and to permit persons to whom the Software is
1857 * furnished to do so, subject to the following conditions:
1858 *
1859 * The above copyright notice and this permission notice shall be included in
1860 * all copies or substantial portions of the Software.
1861 *
1862 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1863 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1864 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1865 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1866 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1867 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1868 * THE SOFTWARE.
1869 */
1870
1871var __extends = this && this.__extends || function () {
1872 var _extendStatics = function extendStatics(d, b) {
1873 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
1874 d.__proto__ = b;
1875 } || function (d, b) {
1876 for (var p in b) {
1877 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
1878 }
1879 };
1880 return _extendStatics(d, b);
1881 };
1882 return function (d, b) {
1883 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1884 _extendStatics(d, b);
1885 function __() {
1886 this.constructor = d;
1887 }
1888 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1889 };
1890}();
1891var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
1892 if (k2 === undefined) k2 = k;
1893 Object.defineProperty(o, k2, { enumerable: true, get: function get() {
1894 return m[k];
1895 } });
1896} : function (o, m, k, k2) {
1897 if (k2 === undefined) k2 = k;
1898 o[k2] = m[k];
1899});
1900var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
1901 Object.defineProperty(o, "default", { enumerable: true, value: v });
1902} : function (o, v) {
1903 o["default"] = v;
1904});
1905var __importStar = this && this.__importStar || function (mod) {
1906 if (mod && mod.__esModule) return mod;
1907 var result = {};
1908 if (mod != null) for (var k in mod) {
1909 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1910 }__setModuleDefault(result, mod);
1911 return result;
1912};
1913Object.defineProperty(exports, "__esModule", { value: true });
1914exports.MDCRipple = void 0;
1915var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
1916var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
1917var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
1918var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts");
1919var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
1920var MDCRipple = /** @class */function (_super) {
1921 __extends(MDCRipple, _super);
1922 function MDCRipple() {
1923 var _this = _super !== null && _super.apply(this, arguments) || this;
1924 _this.disabled = false;
1925 return _this;
1926 }
1927 MDCRipple.attachTo = function (root, opts) {
1928 if (opts === void 0) {
1929 opts = {
1930 isUnbounded: undefined
1931 };
1932 }
1933 var ripple = new MDCRipple(root);
1934 // Only override unbounded behavior if option is explicitly specified
1935 if (opts.isUnbounded !== undefined) {
1936 ripple.unbounded = opts.isUnbounded;
1937 }
1938 return ripple;
1939 };
1940 MDCRipple.createAdapter = function (instance) {
1941 return {
1942 addClass: function addClass(className) {
1943 return instance.root.classList.add(className);
1944 },
1945 browserSupportsCssVars: function browserSupportsCssVars() {
1946 return util.supportsCssVariables(window);
1947 },
1948 computeBoundingRect: function computeBoundingRect() {
1949 return instance.root.getBoundingClientRect();
1950 },
1951 containsEventTarget: function containsEventTarget(target) {
1952 return instance.root.contains(target);
1953 },
1954 deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler(evtType, handler) {
1955 return document.documentElement.removeEventListener(evtType, handler, events_1.applyPassive());
1956 },
1957 deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
1958 return instance.root.removeEventListener(evtType, handler, events_1.applyPassive());
1959 },
1960 deregisterResizeHandler: function deregisterResizeHandler(handler) {
1961 return window.removeEventListener('resize', handler);
1962 },
1963 getWindowPageOffset: function getWindowPageOffset() {
1964 return { x: window.pageXOffset, y: window.pageYOffset };
1965 },
1966 isSurfaceActive: function isSurfaceActive() {
1967 return ponyfill_1.matches(instance.root, ':active');
1968 },
1969 isSurfaceDisabled: function isSurfaceDisabled() {
1970 return Boolean(instance.disabled);
1971 },
1972 isUnbounded: function isUnbounded() {
1973 return Boolean(instance.unbounded);
1974 },
1975 registerDocumentInteractionHandler: function registerDocumentInteractionHandler(evtType, handler) {
1976 return document.documentElement.addEventListener(evtType, handler, events_1.applyPassive());
1977 },
1978 registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
1979 return instance.root.addEventListener(evtType, handler, events_1.applyPassive());
1980 },
1981 registerResizeHandler: function registerResizeHandler(handler) {
1982 return window.addEventListener('resize', handler);
1983 },
1984 removeClass: function removeClass(className) {
1985 return instance.root.classList.remove(className);
1986 },
1987 updateCssVariable: function updateCssVariable(varName, value) {
1988 return instance.root.style.setProperty(varName, value);
1989 }
1990 };
1991 };
1992 Object.defineProperty(MDCRipple.prototype, "unbounded", {
1993 get: function get() {
1994 return Boolean(this.isUnbounded);
1995 },
1996 set: function set(unbounded) {
1997 this.isUnbounded = Boolean(unbounded);
1998 this.setUnbounded();
1999 },
2000 enumerable: false,
2001 configurable: true
2002 });
2003 MDCRipple.prototype.activate = function () {
2004 this.foundation.activate();
2005 };
2006 MDCRipple.prototype.deactivate = function () {
2007 this.foundation.deactivate();
2008 };
2009 MDCRipple.prototype.layout = function () {
2010 this.foundation.layout();
2011 };
2012 MDCRipple.prototype.getDefaultFoundation = function () {
2013 return new foundation_1.MDCRippleFoundation(MDCRipple.createAdapter(this));
2014 };
2015 MDCRipple.prototype.initialSyncWithDOM = function () {
2016 var root = this.root;
2017 this.isUnbounded = 'mdcRippleIsUnbounded' in root.dataset;
2018 };
2019 /**
2020 * Closure Compiler throws an access control error when directly accessing a
2021 * protected or private property inside a getter/setter, like unbounded above.
2022 * By accessing the protected property inside a method, we solve that problem.
2023 * That's why this function exists.
2024 */
2025 MDCRipple.prototype.setUnbounded = function () {
2026 this.foundation.setUnbounded(Boolean(this.isUnbounded));
2027 };
2028 return MDCRipple;
2029}(component_1.MDCComponent);
2030exports.MDCRipple = MDCRipple;
2031
2032/***/ }),
2033
2034/***/ "./packages/mdc-ripple/constants.ts":
2035/*!******************************************!*\
2036 !*** ./packages/mdc-ripple/constants.ts ***!
2037 \******************************************/
2038/*! no static exports found */
2039/***/ (function(module, exports, __webpack_require__) {
2040
2041"use strict";
2042
2043/**
2044 * @license
2045 * Copyright 2016 Google Inc.
2046 *
2047 * Permission is hereby granted, free of charge, to any person obtaining a copy
2048 * of this software and associated documentation files (the "Software"), to deal
2049 * in the Software without restriction, including without limitation the rights
2050 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2051 * copies of the Software, and to permit persons to whom the Software is
2052 * furnished to do so, subject to the following conditions:
2053 *
2054 * The above copyright notice and this permission notice shall be included in
2055 * all copies or substantial portions of the Software.
2056 *
2057 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2058 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2059 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2060 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2061 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2062 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2063 * THE SOFTWARE.
2064 */
2065
2066Object.defineProperty(exports, "__esModule", { value: true });
2067exports.numbers = exports.strings = exports.cssClasses = void 0;
2068exports.cssClasses = {
2069 // Ripple is a special case where the "root" component is really a "mixin" of sorts,
2070 // given that it's an 'upgrade' to an existing component. That being said it is the root
2071 // CSS class that all other CSS classes derive from.
2072 BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
2073 FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
2074 FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation',
2075 ROOT: 'mdc-ripple-upgraded',
2076 UNBOUNDED: 'mdc-ripple-upgraded--unbounded'
2077};
2078exports.strings = {
2079 VAR_FG_SCALE: '--mdc-ripple-fg-scale',
2080 VAR_FG_SIZE: '--mdc-ripple-fg-size',
2081 VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end',
2082 VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
2083 VAR_LEFT: '--mdc-ripple-left',
2084 VAR_TOP: '--mdc-ripple-top'
2085};
2086exports.numbers = {
2087 DEACTIVATION_TIMEOUT_MS: 225,
2088 FG_DEACTIVATION_MS: 150,
2089 INITIAL_ORIGIN_SCALE: 0.6,
2090 PADDING: 10,
2091 TAP_DELAY_MS: 300 };
2092
2093/***/ }),
2094
2095/***/ "./packages/mdc-ripple/foundation.ts":
2096/*!*******************************************!*\
2097 !*** ./packages/mdc-ripple/foundation.ts ***!
2098 \*******************************************/
2099/*! no static exports found */
2100/***/ (function(module, exports, __webpack_require__) {
2101
2102"use strict";
2103
2104/**
2105 * @license
2106 * Copyright 2016 Google Inc.
2107 *
2108 * Permission is hereby granted, free of charge, to any person obtaining a copy
2109 * of this software and associated documentation files (the "Software"), to deal
2110 * in the Software without restriction, including without limitation the rights
2111 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2112 * copies of the Software, and to permit persons to whom the Software is
2113 * furnished to do so, subject to the following conditions:
2114 *
2115 * The above copyright notice and this permission notice shall be included in
2116 * all copies or substantial portions of the Software.
2117 *
2118 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2119 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2120 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2121 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2122 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2123 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2124 * THE SOFTWARE.
2125 */
2126
2127var __extends = this && this.__extends || function () {
2128 var _extendStatics = function extendStatics(d, b) {
2129 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
2130 d.__proto__ = b;
2131 } || function (d, b) {
2132 for (var p in b) {
2133 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
2134 }
2135 };
2136 return _extendStatics(d, b);
2137 };
2138 return function (d, b) {
2139 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2140 _extendStatics(d, b);
2141 function __() {
2142 this.constructor = d;
2143 }
2144 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2145 };
2146}();
2147var __assign = this && this.__assign || function () {
2148 __assign = Object.assign || function (t) {
2149 for (var s, i = 1, n = arguments.length; i < n; i++) {
2150 s = arguments[i];
2151 for (var p in s) {
2152 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
2153 }
2154 }
2155 return t;
2156 };
2157 return __assign.apply(this, arguments);
2158};
2159var __values = this && this.__values || function (o) {
2160 var s = typeof Symbol === "function" && Symbol.iterator,
2161 m = s && o[s],
2162 i = 0;
2163 if (m) return m.call(o);
2164 if (o && typeof o.length === "number") return {
2165 next: function next() {
2166 if (o && i >= o.length) o = void 0;
2167 return { value: o && o[i++], done: !o };
2168 }
2169 };
2170 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
2171};
2172Object.defineProperty(exports, "__esModule", { value: true });
2173exports.MDCRippleFoundation = void 0;
2174var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
2175var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts");
2176var util_1 = __webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts");
2177// Activation events registered on the root element of each instance for activation
2178var ACTIVATION_EVENT_TYPES = ['touchstart', 'pointerdown', 'mousedown', 'keydown'];
2179// Deactivation events registered on documentElement when a pointer-related down event occurs
2180var POINTER_DEACTIVATION_EVENT_TYPES = ['touchend', 'pointerup', 'mouseup', 'contextmenu'];
2181// simultaneous nested activations
2182var activatedTargets = [];
2183var MDCRippleFoundation = /** @class */function (_super) {
2184 __extends(MDCRippleFoundation, _super);
2185 function MDCRippleFoundation(adapter) {
2186 var _this = _super.call(this, __assign(__assign({}, MDCRippleFoundation.defaultAdapter), adapter)) || this;
2187 _this.activationAnimationHasEnded = false;
2188 _this.activationTimer = 0;
2189 _this.fgDeactivationRemovalTimer = 0;
2190 _this.fgScale = '0';
2191 _this.frame = { width: 0, height: 0 };
2192 _this.initialSize = 0;
2193 _this.layoutFrame = 0;
2194 _this.maxRadius = 0;
2195 _this.unboundedCoords = { left: 0, top: 0 };
2196 _this.activationState = _this.defaultActivationState();
2197 _this.activationTimerCallback = function () {
2198 _this.activationAnimationHasEnded = true;
2199 _this.runDeactivationUXLogicIfReady();
2200 };
2201 _this.activateHandler = function (e) {
2202 _this.activateImpl(e);
2203 };
2204 _this.deactivateHandler = function () {
2205 _this.deactivateImpl();
2206 };
2207 _this.focusHandler = function () {
2208 _this.handleFocus();
2209 };
2210 _this.blurHandler = function () {
2211 _this.handleBlur();
2212 };
2213 _this.resizeHandler = function () {
2214 _this.layout();
2215 };
2216 return _this;
2217 }
2218 Object.defineProperty(MDCRippleFoundation, "cssClasses", {
2219 get: function get() {
2220 return constants_1.cssClasses;
2221 },
2222 enumerable: false,
2223 configurable: true
2224 });
2225 Object.defineProperty(MDCRippleFoundation, "strings", {
2226 get: function get() {
2227 return constants_1.strings;
2228 },
2229 enumerable: false,
2230 configurable: true
2231 });
2232 Object.defineProperty(MDCRippleFoundation, "numbers", {
2233 get: function get() {
2234 return constants_1.numbers;
2235 },
2236 enumerable: false,
2237 configurable: true
2238 });
2239 Object.defineProperty(MDCRippleFoundation, "defaultAdapter", {
2240 get: function get() {
2241 return {
2242 addClass: function addClass() {
2243 return undefined;
2244 },
2245 browserSupportsCssVars: function browserSupportsCssVars() {
2246 return true;
2247 },
2248 computeBoundingRect: function computeBoundingRect() {
2249 return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
2250 },
2251 containsEventTarget: function containsEventTarget() {
2252 return true;
2253 },
2254 deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() {
2255 return undefined;
2256 },
2257 deregisterInteractionHandler: function deregisterInteractionHandler() {
2258 return undefined;
2259 },
2260 deregisterResizeHandler: function deregisterResizeHandler() {
2261 return undefined;
2262 },
2263 getWindowPageOffset: function getWindowPageOffset() {
2264 return { x: 0, y: 0 };
2265 },
2266 isSurfaceActive: function isSurfaceActive() {
2267 return true;
2268 },
2269 isSurfaceDisabled: function isSurfaceDisabled() {
2270 return true;
2271 },
2272 isUnbounded: function isUnbounded() {
2273 return true;
2274 },
2275 registerDocumentInteractionHandler: function registerDocumentInteractionHandler() {
2276 return undefined;
2277 },
2278 registerInteractionHandler: function registerInteractionHandler() {
2279 return undefined;
2280 },
2281 registerResizeHandler: function registerResizeHandler() {
2282 return undefined;
2283 },
2284 removeClass: function removeClass() {
2285 return undefined;
2286 },
2287 updateCssVariable: function updateCssVariable() {
2288 return undefined;
2289 }
2290 };
2291 },
2292 enumerable: false,
2293 configurable: true
2294 });
2295 MDCRippleFoundation.prototype.init = function () {
2296 var _this = this;
2297 var supportsPressRipple = this.supportsPressRipple();
2298 this.registerRootHandlers(supportsPressRipple);
2299 if (supportsPressRipple) {
2300 var _a = MDCRippleFoundation.cssClasses,
2301 ROOT_1 = _a.ROOT,
2302 UNBOUNDED_1 = _a.UNBOUNDED;
2303 requestAnimationFrame(function () {
2304 _this.adapter.addClass(ROOT_1);
2305 if (_this.adapter.isUnbounded()) {
2306 _this.adapter.addClass(UNBOUNDED_1);
2307 // Unbounded ripples need layout logic applied immediately to set coordinates for both shade and ripple
2308 _this.layoutInternal();
2309 }
2310 });
2311 }
2312 };
2313 MDCRippleFoundation.prototype.destroy = function () {
2314 var _this = this;
2315 if (this.supportsPressRipple()) {
2316 if (this.activationTimer) {
2317 clearTimeout(this.activationTimer);
2318 this.activationTimer = 0;
2319 this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION);
2320 }
2321 if (this.fgDeactivationRemovalTimer) {
2322 clearTimeout(this.fgDeactivationRemovalTimer);
2323 this.fgDeactivationRemovalTimer = 0;
2324 this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION);
2325 }
2326 var _a = MDCRippleFoundation.cssClasses,
2327 ROOT_2 = _a.ROOT,
2328 UNBOUNDED_2 = _a.UNBOUNDED;
2329 requestAnimationFrame(function () {
2330 _this.adapter.removeClass(ROOT_2);
2331 _this.adapter.removeClass(UNBOUNDED_2);
2332 _this.removeCssVars();
2333 });
2334 }
2335 this.deregisterRootHandlers();
2336 this.deregisterDeactivationHandlers();
2337 };
2338 /**
2339 * @param evt Optional event containing position information.
2340 */
2341 MDCRippleFoundation.prototype.activate = function (evt) {
2342 this.activateImpl(evt);
2343 };
2344 MDCRippleFoundation.prototype.deactivate = function () {
2345 this.deactivateImpl();
2346 };
2347 MDCRippleFoundation.prototype.layout = function () {
2348 var _this = this;
2349 if (this.layoutFrame) {
2350 cancelAnimationFrame(this.layoutFrame);
2351 }
2352 this.layoutFrame = requestAnimationFrame(function () {
2353 _this.layoutInternal();
2354 _this.layoutFrame = 0;
2355 });
2356 };
2357 MDCRippleFoundation.prototype.setUnbounded = function (unbounded) {
2358 var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED;
2359 if (unbounded) {
2360 this.adapter.addClass(UNBOUNDED);
2361 } else {
2362 this.adapter.removeClass(UNBOUNDED);
2363 }
2364 };
2365 MDCRippleFoundation.prototype.handleFocus = function () {
2366 var _this = this;
2367 requestAnimationFrame(function () {
2368 return _this.adapter.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
2369 });
2370 };
2371 MDCRippleFoundation.prototype.handleBlur = function () {
2372 var _this = this;
2373 requestAnimationFrame(function () {
2374 return _this.adapter.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
2375 });
2376 };
2377 /**
2378 * We compute this property so that we are not querying information about the client
2379 * until the point in time where the foundation requests it. This prevents scenarios where
2380 * client-side feature-detection may happen too early, such as when components are rendered on the server
2381 * and then initialized at mount time on the client.
2382 */
2383 MDCRippleFoundation.prototype.supportsPressRipple = function () {
2384 return this.adapter.browserSupportsCssVars();
2385 };
2386 MDCRippleFoundation.prototype.defaultActivationState = function () {
2387 return {
2388 activationEvent: undefined,
2389 hasDeactivationUXRun: false,
2390 isActivated: false,
2391 isProgrammatic: false,
2392 wasActivatedByPointer: false,
2393 wasElementMadeActive: false
2394 };
2395 };
2396 /**
2397 * supportsPressRipple Passed from init to save a redundant function call
2398 */
2399 MDCRippleFoundation.prototype.registerRootHandlers = function (supportsPressRipple) {
2400 var e_1, _a;
2401 if (supportsPressRipple) {
2402 try {
2403 for (var ACTIVATION_EVENT_TYPES_1 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next(); !ACTIVATION_EVENT_TYPES_1_1.done; ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next()) {
2404 var evtType = ACTIVATION_EVENT_TYPES_1_1.value;
2405 this.adapter.registerInteractionHandler(evtType, this.activateHandler);
2406 }
2407 } catch (e_1_1) {
2408 e_1 = { error: e_1_1 };
2409 } finally {
2410 try {
2411 if (ACTIVATION_EVENT_TYPES_1_1 && !ACTIVATION_EVENT_TYPES_1_1.done && (_a = ACTIVATION_EVENT_TYPES_1.return)) _a.call(ACTIVATION_EVENT_TYPES_1);
2412 } finally {
2413 if (e_1) throw e_1.error;
2414 }
2415 }
2416 if (this.adapter.isUnbounded()) {
2417 this.adapter.registerResizeHandler(this.resizeHandler);
2418 }
2419 }
2420 this.adapter.registerInteractionHandler('focus', this.focusHandler);
2421 this.adapter.registerInteractionHandler('blur', this.blurHandler);
2422 };
2423 MDCRippleFoundation.prototype.registerDeactivationHandlers = function (evt) {
2424 var e_2, _a;
2425 if (evt.type === 'keydown') {
2426 this.adapter.registerInteractionHandler('keyup', this.deactivateHandler);
2427 } else {
2428 try {
2429 for (var POINTER_DEACTIVATION_EVENT_TYPES_1 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next(); !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done; POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next()) {
2430 var evtType = POINTER_DEACTIVATION_EVENT_TYPES_1_1.value;
2431 this.adapter.registerDocumentInteractionHandler(evtType, this.deactivateHandler);
2432 }
2433 } catch (e_2_1) {
2434 e_2 = { error: e_2_1 };
2435 } finally {
2436 try {
2437 if (POINTER_DEACTIVATION_EVENT_TYPES_1_1 && !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done && (_a = POINTER_DEACTIVATION_EVENT_TYPES_1.return)) _a.call(POINTER_DEACTIVATION_EVENT_TYPES_1);
2438 } finally {
2439 if (e_2) throw e_2.error;
2440 }
2441 }
2442 }
2443 };
2444 MDCRippleFoundation.prototype.deregisterRootHandlers = function () {
2445 var e_3, _a;
2446 try {
2447 for (var ACTIVATION_EVENT_TYPES_2 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next(); !ACTIVATION_EVENT_TYPES_2_1.done; ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next()) {
2448 var evtType = ACTIVATION_EVENT_TYPES_2_1.value;
2449 this.adapter.deregisterInteractionHandler(evtType, this.activateHandler);
2450 }
2451 } catch (e_3_1) {
2452 e_3 = { error: e_3_1 };
2453 } finally {
2454 try {
2455 if (ACTIVATION_EVENT_TYPES_2_1 && !ACTIVATION_EVENT_TYPES_2_1.done && (_a = ACTIVATION_EVENT_TYPES_2.return)) _a.call(ACTIVATION_EVENT_TYPES_2);
2456 } finally {
2457 if (e_3) throw e_3.error;
2458 }
2459 }
2460 this.adapter.deregisterInteractionHandler('focus', this.focusHandler);
2461 this.adapter.deregisterInteractionHandler('blur', this.blurHandler);
2462 if (this.adapter.isUnbounded()) {
2463 this.adapter.deregisterResizeHandler(this.resizeHandler);
2464 }
2465 };
2466 MDCRippleFoundation.prototype.deregisterDeactivationHandlers = function () {
2467 var e_4, _a;
2468 this.adapter.deregisterInteractionHandler('keyup', this.deactivateHandler);
2469 try {
2470 for (var POINTER_DEACTIVATION_EVENT_TYPES_2 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next(); !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done; POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next()) {
2471 var evtType = POINTER_DEACTIVATION_EVENT_TYPES_2_1.value;
2472 this.adapter.deregisterDocumentInteractionHandler(evtType, this.deactivateHandler);
2473 }
2474 } catch (e_4_1) {
2475 e_4 = { error: e_4_1 };
2476 } finally {
2477 try {
2478 if (POINTER_DEACTIVATION_EVENT_TYPES_2_1 && !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done && (_a = POINTER_DEACTIVATION_EVENT_TYPES_2.return)) _a.call(POINTER_DEACTIVATION_EVENT_TYPES_2);
2479 } finally {
2480 if (e_4) throw e_4.error;
2481 }
2482 }
2483 };
2484 MDCRippleFoundation.prototype.removeCssVars = function () {
2485 var _this = this;
2486 var rippleStrings = MDCRippleFoundation.strings;
2487 var keys = Object.keys(rippleStrings);
2488 keys.forEach(function (key) {
2489 if (key.indexOf('VAR_') === 0) {
2490 _this.adapter.updateCssVariable(rippleStrings[key], null);
2491 }
2492 });
2493 };
2494 MDCRippleFoundation.prototype.activateImpl = function (evt) {
2495 var _this = this;
2496 if (this.adapter.isSurfaceDisabled()) {
2497 return;
2498 }
2499 var activationState = this.activationState;
2500 if (activationState.isActivated) {
2501 return;
2502 }
2503 // Avoid reacting to follow-on events fired by touch device after an already-processed user interaction
2504 var previousActivationEvent = this.previousActivationEvent;
2505 var isSameInteraction = previousActivationEvent && evt !== undefined && previousActivationEvent.type !== evt.type;
2506 if (isSameInteraction) {
2507 return;
2508 }
2509 activationState.isActivated = true;
2510 activationState.isProgrammatic = evt === undefined;
2511 activationState.activationEvent = evt;
2512 activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== undefined && (evt.type === 'mousedown' || evt.type === 'touchstart' || evt.type === 'pointerdown');
2513 var hasActivatedChild = evt !== undefined && activatedTargets.length > 0 && activatedTargets.some(function (target) {
2514 return _this.adapter.containsEventTarget(target);
2515 });
2516 if (hasActivatedChild) {
2517 // Immediately reset activation state, while preserving logic that prevents touch follow-on events
2518 this.resetActivationState();
2519 return;
2520 }
2521 if (evt !== undefined) {
2522 activatedTargets.push(evt.target);
2523 this.registerDeactivationHandlers(evt);
2524 }
2525 activationState.wasElementMadeActive = this.checkElementMadeActive(evt);
2526 if (activationState.wasElementMadeActive) {
2527 this.animateActivation();
2528 }
2529 requestAnimationFrame(function () {
2530 // Reset array on next frame after the current event has had a chance to bubble to prevent ancestor ripples
2531 activatedTargets = [];
2532 if (!activationState.wasElementMadeActive && evt !== undefined && (evt.key === ' ' || evt.keyCode === 32)) {
2533 // If space was pressed, try again within an rAF call to detect :active, because different UAs report
2534 // active states inconsistently when they're called within event handling code:
2535 // - https://bugs.chromium.org/p/chromium/issues/detail?id=635971
2536 // - https://bugzilla.mozilla.org/show_bug.cgi?id=1293741
2537 // We try first outside rAF to support Edge, which does not exhibit this problem, but will crash if a CSS
2538 // variable is set within a rAF callback for a submit button interaction (#2241).
2539 activationState.wasElementMadeActive = _this.checkElementMadeActive(evt);
2540 if (activationState.wasElementMadeActive) {
2541 _this.animateActivation();
2542 }
2543 }
2544 if (!activationState.wasElementMadeActive) {
2545 // Reset activation state immediately if element was not made active.
2546 _this.activationState = _this.defaultActivationState();
2547 }
2548 });
2549 };
2550 MDCRippleFoundation.prototype.checkElementMadeActive = function (evt) {
2551 return evt !== undefined && evt.type === 'keydown' ? this.adapter.isSurfaceActive() : true;
2552 };
2553 MDCRippleFoundation.prototype.animateActivation = function () {
2554 var _this = this;
2555 var _a = MDCRippleFoundation.strings,
2556 VAR_FG_TRANSLATE_START = _a.VAR_FG_TRANSLATE_START,
2557 VAR_FG_TRANSLATE_END = _a.VAR_FG_TRANSLATE_END;
2558 var _b = MDCRippleFoundation.cssClasses,
2559 FG_DEACTIVATION = _b.FG_DEACTIVATION,
2560 FG_ACTIVATION = _b.FG_ACTIVATION;
2561 var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
2562 this.layoutInternal();
2563 var translateStart = '';
2564 var translateEnd = '';
2565 if (!this.adapter.isUnbounded()) {
2566 var _c = this.getFgTranslationCoordinates(),
2567 startPoint = _c.startPoint,
2568 endPoint = _c.endPoint;
2569 translateStart = startPoint.x + "px, " + startPoint.y + "px";
2570 translateEnd = endPoint.x + "px, " + endPoint.y + "px";
2571 }
2572 this.adapter.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
2573 this.adapter.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
2574 // Cancel any ongoing activation/deactivation animations
2575 clearTimeout(this.activationTimer);
2576 clearTimeout(this.fgDeactivationRemovalTimer);
2577 this.rmBoundedActivationClasses();
2578 this.adapter.removeClass(FG_DEACTIVATION);
2579 // Force layout in order to re-trigger the animation.
2580 this.adapter.computeBoundingRect();
2581 this.adapter.addClass(FG_ACTIVATION);
2582 this.activationTimer = setTimeout(function () {
2583 _this.activationTimerCallback();
2584 }, DEACTIVATION_TIMEOUT_MS);
2585 };
2586 MDCRippleFoundation.prototype.getFgTranslationCoordinates = function () {
2587 var _a = this.activationState,
2588 activationEvent = _a.activationEvent,
2589 wasActivatedByPointer = _a.wasActivatedByPointer;
2590 var startPoint;
2591 if (wasActivatedByPointer) {
2592 startPoint = util_1.getNormalizedEventCoords(activationEvent, this.adapter.getWindowPageOffset(), this.adapter.computeBoundingRect());
2593 } else {
2594 startPoint = {
2595 x: this.frame.width / 2,
2596 y: this.frame.height / 2
2597 };
2598 }
2599 // Center the element around the start point.
2600 startPoint = {
2601 x: startPoint.x - this.initialSize / 2,
2602 y: startPoint.y - this.initialSize / 2
2603 };
2604 var endPoint = {
2605 x: this.frame.width / 2 - this.initialSize / 2,
2606 y: this.frame.height / 2 - this.initialSize / 2
2607 };
2608 return { startPoint: startPoint, endPoint: endPoint };
2609 };
2610 MDCRippleFoundation.prototype.runDeactivationUXLogicIfReady = function () {
2611 var _this = this;
2612 // This method is called both when a pointing device is released, and when the activation animation ends.
2613 // The deactivation animation should only run after both of those occur.
2614 var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
2615 var _a = this.activationState,
2616 hasDeactivationUXRun = _a.hasDeactivationUXRun,
2617 isActivated = _a.isActivated;
2618 var activationHasEnded = hasDeactivationUXRun || !isActivated;
2619 if (activationHasEnded && this.activationAnimationHasEnded) {
2620 this.rmBoundedActivationClasses();
2621 this.adapter.addClass(FG_DEACTIVATION);
2622 this.fgDeactivationRemovalTimer = setTimeout(function () {
2623 _this.adapter.removeClass(FG_DEACTIVATION);
2624 }, constants_1.numbers.FG_DEACTIVATION_MS);
2625 }
2626 };
2627 MDCRippleFoundation.prototype.rmBoundedActivationClasses = function () {
2628 var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION;
2629 this.adapter.removeClass(FG_ACTIVATION);
2630 this.activationAnimationHasEnded = false;
2631 this.adapter.computeBoundingRect();
2632 };
2633 MDCRippleFoundation.prototype.resetActivationState = function () {
2634 var _this = this;
2635 this.previousActivationEvent = this.activationState.activationEvent;
2636 this.activationState = this.defaultActivationState();
2637 // Touch devices may fire additional events for the same interaction within a short time.
2638 // Store the previous event until it's safe to assume that subsequent events are for new interactions.
2639 setTimeout(function () {
2640 return _this.previousActivationEvent = undefined;
2641 }, MDCRippleFoundation.numbers.TAP_DELAY_MS);
2642 };
2643 MDCRippleFoundation.prototype.deactivateImpl = function () {
2644 var _this = this;
2645 var activationState = this.activationState;
2646 // This can happen in scenarios such as when you have a keyup event that blurs the element.
2647 if (!activationState.isActivated) {
2648 return;
2649 }
2650 var state = __assign({}, activationState);
2651 if (activationState.isProgrammatic) {
2652 requestAnimationFrame(function () {
2653 _this.animateDeactivation(state);
2654 });
2655 this.resetActivationState();
2656 } else {
2657 this.deregisterDeactivationHandlers();
2658 requestAnimationFrame(function () {
2659 _this.activationState.hasDeactivationUXRun = true;
2660 _this.animateDeactivation(state);
2661 _this.resetActivationState();
2662 });
2663 }
2664 };
2665 MDCRippleFoundation.prototype.animateDeactivation = function (_a) {
2666 var wasActivatedByPointer = _a.wasActivatedByPointer,
2667 wasElementMadeActive = _a.wasElementMadeActive;
2668 if (wasActivatedByPointer || wasElementMadeActive) {
2669 this.runDeactivationUXLogicIfReady();
2670 }
2671 };
2672 MDCRippleFoundation.prototype.layoutInternal = function () {
2673 var _this = this;
2674 this.frame = this.adapter.computeBoundingRect();
2675 var maxDim = Math.max(this.frame.height, this.frame.width);
2676 // Surface diameter is treated differently for unbounded vs. bounded ripples.
2677 // Unbounded ripple diameter is calculated smaller since the surface is expected to already be padded appropriately
2678 // to extend the hitbox, and the ripple is expected to meet the edges of the padded hitbox (which is typically
2679 // square). Bounded ripples, on the other hand, are fully expected to expand beyond the surface's longest diameter
2680 // (calculated based on the diagonal plus a constant padding), and are clipped at the surface's border via
2681 // `overflow: hidden`.
2682 var getBoundedRadius = function getBoundedRadius() {
2683 var hypotenuse = Math.sqrt(Math.pow(_this.frame.width, 2) + Math.pow(_this.frame.height, 2));
2684 return hypotenuse + MDCRippleFoundation.numbers.PADDING;
2685 };
2686 this.maxRadius = this.adapter.isUnbounded() ? maxDim : getBoundedRadius();
2687 // Ripple is sized as a fraction of the largest dimension of the surface, then scales up using a CSS scale transform
2688 var initialSize = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
2689 // Unbounded ripple size should always be even number to equally center align.
2690 if (this.adapter.isUnbounded() && initialSize % 2 !== 0) {
2691 this.initialSize = initialSize - 1;
2692 } else {
2693 this.initialSize = initialSize;
2694 }
2695 this.fgScale = "" + this.maxRadius / this.initialSize;
2696 this.updateLayoutCssVars();
2697 };
2698 MDCRippleFoundation.prototype.updateLayoutCssVars = function () {
2699 var _a = MDCRippleFoundation.strings,
2700 VAR_FG_SIZE = _a.VAR_FG_SIZE,
2701 VAR_LEFT = _a.VAR_LEFT,
2702 VAR_TOP = _a.VAR_TOP,
2703 VAR_FG_SCALE = _a.VAR_FG_SCALE;
2704 this.adapter.updateCssVariable(VAR_FG_SIZE, this.initialSize + "px");
2705 this.adapter.updateCssVariable(VAR_FG_SCALE, this.fgScale);
2706 if (this.adapter.isUnbounded()) {
2707 this.unboundedCoords = {
2708 left: Math.round(this.frame.width / 2 - this.initialSize / 2),
2709 top: Math.round(this.frame.height / 2 - this.initialSize / 2)
2710 };
2711 this.adapter.updateCssVariable(VAR_LEFT, this.unboundedCoords.left + "px");
2712 this.adapter.updateCssVariable(VAR_TOP, this.unboundedCoords.top + "px");
2713 }
2714 };
2715 return MDCRippleFoundation;
2716}(foundation_1.MDCFoundation);
2717exports.MDCRippleFoundation = MDCRippleFoundation;
2718// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
2719exports.default = MDCRippleFoundation;
2720
2721/***/ }),
2722
2723/***/ "./packages/mdc-ripple/util.ts":
2724/*!*************************************!*\
2725 !*** ./packages/mdc-ripple/util.ts ***!
2726 \*************************************/
2727/*! no static exports found */
2728/***/ (function(module, exports, __webpack_require__) {
2729
2730"use strict";
2731
2732
2733Object.defineProperty(exports, "__esModule", { value: true });
2734exports.getNormalizedEventCoords = exports.supportsCssVariables = void 0;
2735/**
2736 * Stores result from supportsCssVariables to avoid redundant processing to
2737 * detect CSS custom variable support.
2738 */
2739var supportsCssVariables_;
2740function supportsCssVariables(windowObj, forceRefresh) {
2741 if (forceRefresh === void 0) {
2742 forceRefresh = false;
2743 }
2744 var CSS = windowObj.CSS;
2745 var supportsCssVars = supportsCssVariables_;
2746 if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
2747 return supportsCssVariables_;
2748 }
2749 var supportsFunctionPresent = CSS && typeof CSS.supports === 'function';
2750 if (!supportsFunctionPresent) {
2751 return false;
2752 }
2753 var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes');
2754 // See: https://bugs.webkit.org/show_bug.cgi?id=154669
2755 // See: README section on Safari
2756 var weAreFeatureDetectingSafari10plus = CSS.supports('(--css-vars: yes)') && CSS.supports('color', '#00000000');
2757 supportsCssVars = explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
2758 if (!forceRefresh) {
2759 supportsCssVariables_ = supportsCssVars;
2760 }
2761 return supportsCssVars;
2762}
2763exports.supportsCssVariables = supportsCssVariables;
2764function getNormalizedEventCoords(evt, pageOffset, clientRect) {
2765 if (!evt) {
2766 return { x: 0, y: 0 };
2767 }
2768 var x = pageOffset.x,
2769 y = pageOffset.y;
2770 var documentX = x + clientRect.left;
2771 var documentY = y + clientRect.top;
2772 var normalizedX;
2773 var normalizedY;
2774 // Determine touch point relative to the ripple container.
2775 if (evt.type === 'touchstart') {
2776 var touchEvent = evt;
2777 normalizedX = touchEvent.changedTouches[0].pageX - documentX;
2778 normalizedY = touchEvent.changedTouches[0].pageY - documentY;
2779 } else {
2780 var mouseEvent = evt;
2781 normalizedX = mouseEvent.pageX - documentX;
2782 normalizedY = mouseEvent.pageY - documentY;
2783 }
2784 return { x: normalizedX, y: normalizedY };
2785}
2786exports.getNormalizedEventCoords = getNormalizedEventCoords;
2787
2788/***/ })
2789
2790/******/ });
2791});
2792//# sourceMappingURL=mdc.dialog.js.map
\No newline at end of file