UNPKG

105 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/top-app-bar", [], factory);
13 else if(typeof exports === 'object')
14 exports["top-app-bar"] = factory();
15 else
16 root["mdc"] = root["mdc"] || {}, root["mdc"]["top-app-bar"] = 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-top-app-bar/index.ts");
102/******/ })
103/************************************************************************/
104/******/ ({
105
106/***/ "./packages/mdc-base/component.ts":
107/*!****************************************!*\
108 !*** ./packages/mdc-base/component.ts ***!
109 \****************************************/
110/*! no static exports found */
111/***/ (function(module, exports, __webpack_require__) {
112
113"use strict";
114
115/**
116 * @license
117 * Copyright 2016 Google Inc.
118 *
119 * Permission is hereby granted, free of charge, to any person obtaining a copy
120 * of this software and associated documentation files (the "Software"), to deal
121 * in the Software without restriction, including without limitation the rights
122 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
123 * copies of the Software, and to permit persons to whom the Software is
124 * furnished to do so, subject to the following conditions:
125 *
126 * The above copyright notice and this permission notice shall be included in
127 * all copies or substantial portions of the Software.
128 *
129 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
130 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
131 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
132 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
133 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
134 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
135 * THE SOFTWARE.
136 */
137
138var __read = this && this.__read || function (o, n) {
139 var m = typeof Symbol === "function" && o[Symbol.iterator];
140 if (!m) return o;
141 var i = m.call(o),
142 r,
143 ar = [],
144 e;
145 try {
146 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
147 ar.push(r.value);
148 }
149 } catch (error) {
150 e = { error: error };
151 } finally {
152 try {
153 if (r && !r.done && (m = i["return"])) m.call(i);
154 } finally {
155 if (e) throw e.error;
156 }
157 }
158 return ar;
159};
160var __spreadArray = this && this.__spreadArray || function (to, from) {
161 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
162 to[j] = from[i];
163 }return to;
164};
165Object.defineProperty(exports, "__esModule", { value: true });
166exports.MDCComponent = void 0;
167var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts");
168var MDCComponent = /** @class */function () {
169 function MDCComponent(root, foundation) {
170 var args = [];
171 for (var _i = 2; _i < arguments.length; _i++) {
172 args[_i - 2] = arguments[_i];
173 }
174 this.root = root;
175 this.initialize.apply(this, __spreadArray([], __read(args)));
176 // Note that we initialize foundation here and not within the constructor's
177 // default param so that this.root is defined and can be used within the
178 // foundation class.
179 this.foundation = foundation === undefined ? this.getDefaultFoundation() : foundation;
180 this.foundation.init();
181 this.initialSyncWithDOM();
182 }
183 MDCComponent.attachTo = function (root) {
184 // Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and
185 // returns an instantiated component with its root set to that element. Also note that in the cases of
186 // subclasses, an explicit foundation class will not have to be passed in; it will simply be initialized
187 // from getDefaultFoundation().
188 return new MDCComponent(root, new foundation_1.MDCFoundation({}));
189 };
190 /* istanbul ignore next: method param only exists for typing purposes; it does not need to be unit tested */
191 MDCComponent.prototype.initialize = function () {
192 var _args = [];
193 for (var _i = 0; _i < arguments.length; _i++) {
194 _args[_i] = arguments[_i];
195 }
196 // Subclasses can override this to do any additional setup work that would be considered part of a
197 // "constructor". Essentially, it is a hook into the parent constructor before the foundation is
198 // initialized. Any additional arguments besides root and foundation will be passed in here.
199 };
200 MDCComponent.prototype.getDefaultFoundation = function () {
201 // Subclasses must override this method to return a properly configured foundation class for the
202 // component.
203 throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
204 };
205 MDCComponent.prototype.initialSyncWithDOM = function () {
206 // Subclasses should override this method if they need to perform work to synchronize with a host DOM
207 // object. An example of this would be a form control wrapper that needs to synchronize its internal state
208 // to some property or attribute of the host DOM. Please note: this is *not* the place to perform DOM
209 // reads/writes that would cause layout / paint, as this is called synchronously from within the constructor.
210 };
211 MDCComponent.prototype.destroy = function () {
212 // Subclasses may implement this method to release any resources / deregister any listeners they have
213 // attached. An example of this might be deregistering a resize event from the window object.
214 this.foundation.destroy();
215 };
216 MDCComponent.prototype.listen = function (evtType, handler, options) {
217 this.root.addEventListener(evtType, handler, options);
218 };
219 MDCComponent.prototype.unlisten = function (evtType, handler, options) {
220 this.root.removeEventListener(evtType, handler, options);
221 };
222 /**
223 * Fires a cross-browser-compatible custom event from the component root of the given type, with the given data.
224 */
225 MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) {
226 if (shouldBubble === void 0) {
227 shouldBubble = false;
228 }
229 var evt;
230 if (typeof CustomEvent === 'function') {
231 evt = new CustomEvent(evtType, {
232 bubbles: shouldBubble,
233 detail: evtData
234 });
235 } else {
236 evt = document.createEvent('CustomEvent');
237 evt.initCustomEvent(evtType, shouldBubble, false, evtData);
238 }
239 this.root.dispatchEvent(evt);
240 };
241 return MDCComponent;
242}();
243exports.MDCComponent = MDCComponent;
244// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
245exports.default = MDCComponent;
246
247/***/ }),
248
249/***/ "./packages/mdc-base/foundation.ts":
250/*!*****************************************!*\
251 !*** ./packages/mdc-base/foundation.ts ***!
252 \*****************************************/
253/*! no static exports found */
254/***/ (function(module, exports, __webpack_require__) {
255
256"use strict";
257
258/**
259 * @license
260 * Copyright 2016 Google Inc.
261 *
262 * Permission is hereby granted, free of charge, to any person obtaining a copy
263 * of this software and associated documentation files (the "Software"), to deal
264 * in the Software without restriction, including without limitation the rights
265 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
266 * copies of the Software, and to permit persons to whom the Software is
267 * furnished to do so, subject to the following conditions:
268 *
269 * The above copyright notice and this permission notice shall be included in
270 * all copies or substantial portions of the Software.
271 *
272 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
273 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
274 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
275 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
276 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
277 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
278 * THE SOFTWARE.
279 */
280
281Object.defineProperty(exports, "__esModule", { value: true });
282exports.MDCFoundation = void 0;
283var MDCFoundation = /** @class */function () {
284 function MDCFoundation(adapter) {
285 if (adapter === void 0) {
286 adapter = {};
287 }
288 this.adapter = adapter;
289 }
290 Object.defineProperty(MDCFoundation, "cssClasses", {
291 get: function get() {
292 // Classes extending MDCFoundation should implement this method to return an object which exports every
293 // CSS class the foundation class needs as a property. e.g. {ACTIVE: 'mdc-component--active'}
294 return {};
295 },
296 enumerable: false,
297 configurable: true
298 });
299 Object.defineProperty(MDCFoundation, "strings", {
300 get: function get() {
301 // Classes extending MDCFoundation should implement this method to return an object which exports all
302 // semantic strings as constants. e.g. {ARIA_ROLE: 'tablist'}
303 return {};
304 },
305 enumerable: false,
306 configurable: true
307 });
308 Object.defineProperty(MDCFoundation, "numbers", {
309 get: function get() {
310 // Classes extending MDCFoundation should implement this method to return an object which exports all
311 // of its semantic numbers as constants. e.g. {ANIMATION_DELAY_MS: 350}
312 return {};
313 },
314 enumerable: false,
315 configurable: true
316 });
317 Object.defineProperty(MDCFoundation, "defaultAdapter", {
318 get: function get() {
319 // Classes extending MDCFoundation may choose to implement this getter in order to provide a convenient
320 // way of viewing the necessary methods of an adapter. In the future, this could also be used for adapter
321 // validation.
322 return {};
323 },
324 enumerable: false,
325 configurable: true
326 });
327 MDCFoundation.prototype.init = function () {
328 // Subclasses should override this method to perform initialization routines (registering events, etc.)
329 };
330 MDCFoundation.prototype.destroy = function () {
331 // Subclasses should override this method to perform de-initialization routines (de-registering events, etc.)
332 };
333 return MDCFoundation;
334}();
335exports.MDCFoundation = MDCFoundation;
336// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
337exports.default = MDCFoundation;
338
339/***/ }),
340
341/***/ "./packages/mdc-dom/events.ts":
342/*!************************************!*\
343 !*** ./packages/mdc-dom/events.ts ***!
344 \************************************/
345/*! no static exports found */
346/***/ (function(module, exports, __webpack_require__) {
347
348"use strict";
349
350/**
351 * @license
352 * Copyright 2019 Google Inc.
353 *
354 * Permission is hereby granted, free of charge, to any person obtaining a copy
355 * of this software and associated documentation files (the "Software"), to deal
356 * in the Software without restriction, including without limitation the rights
357 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
358 * copies of the Software, and to permit persons to whom the Software is
359 * furnished to do so, subject to the following conditions:
360 *
361 * The above copyright notice and this permission notice shall be included in
362 * all copies or substantial portions of the Software.
363 *
364 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
365 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
366 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
367 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
368 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
369 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
370 * THE SOFTWARE.
371 */
372
373Object.defineProperty(exports, "__esModule", { value: true });
374exports.applyPassive = void 0;
375/**
376 * Determine whether the current browser supports passive event listeners, and
377 * if so, use them.
378 */
379function applyPassive(globalObj) {
380 if (globalObj === void 0) {
381 globalObj = window;
382 }
383 return supportsPassiveOption(globalObj) ? { passive: true } : false;
384}
385exports.applyPassive = applyPassive;
386function supportsPassiveOption(globalObj) {
387 if (globalObj === void 0) {
388 globalObj = window;
389 }
390 // See
391 // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
392 var passiveSupported = false;
393 try {
394 var options = {
395 // This function will be called when the browser
396 // attempts to access the passive property.
397 get passive() {
398 passiveSupported = true;
399 return false;
400 }
401 };
402 var handler = function handler() {};
403 globalObj.document.addEventListener('test', handler, options);
404 globalObj.document.removeEventListener('test', handler, options);
405 } catch (err) {
406 passiveSupported = false;
407 }
408 return passiveSupported;
409}
410
411/***/ }),
412
413/***/ "./packages/mdc-dom/ponyfill.ts":
414/*!**************************************!*\
415 !*** ./packages/mdc-dom/ponyfill.ts ***!
416 \**************************************/
417/*! no static exports found */
418/***/ (function(module, exports, __webpack_require__) {
419
420"use strict";
421
422/**
423 * @license
424 * Copyright 2018 Google Inc.
425 *
426 * Permission is hereby granted, free of charge, to any person obtaining a copy
427 * of this software and associated documentation files (the "Software"), to deal
428 * in the Software without restriction, including without limitation the rights
429 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
430 * copies of the Software, and to permit persons to whom the Software is
431 * furnished to do so, subject to the following conditions:
432 *
433 * The above copyright notice and this permission notice shall be included in
434 * all copies or substantial portions of the Software.
435 *
436 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
437 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
438 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
439 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
440 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
441 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
442 * THE SOFTWARE.
443 */
444
445Object.defineProperty(exports, "__esModule", { value: true });
446exports.estimateScrollWidth = exports.matches = exports.closest = void 0;
447/**
448 * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global prototype chain.
449 * This makes ponyfills safer than traditional polyfills, especially for libraries like MDC.
450 */
451function closest(element, selector) {
452 if (element.closest) {
453 return element.closest(selector);
454 }
455 var el = element;
456 while (el) {
457 if (matches(el, selector)) {
458 return el;
459 }
460 el = el.parentElement;
461 }
462 return null;
463}
464exports.closest = closest;
465function matches(element, selector) {
466 var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
467 return nativeMatches.call(element, selector);
468}
469exports.matches = matches;
470/**
471 * Used to compute the estimated scroll width of elements. When an element is
472 * hidden due to display: none; being applied to a parent element, the width is
473 * returned as 0. However, the element will have a true width once no longer
474 * inside a display: none context. This method computes an estimated width when
475 * the element is hidden or returns the true width when the element is visble.
476 * @param {Element} element the element whose width to estimate
477 */
478function estimateScrollWidth(element) {
479 // Check the offsetParent. If the element inherits display: none from any
480 // parent, the offsetParent property will be null (see
481 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent).
482 // This check ensures we only clone the node when necessary.
483 var htmlEl = element;
484 if (htmlEl.offsetParent !== null) {
485 return htmlEl.scrollWidth;
486 }
487 var clone = htmlEl.cloneNode(true);
488 clone.style.setProperty('position', 'absolute');
489 clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
490 document.documentElement.appendChild(clone);
491 var scrollWidth = clone.scrollWidth;
492 document.documentElement.removeChild(clone);
493 return scrollWidth;
494}
495exports.estimateScrollWidth = estimateScrollWidth;
496
497/***/ }),
498
499/***/ "./packages/mdc-ripple/component.ts":
500/*!******************************************!*\
501 !*** ./packages/mdc-ripple/component.ts ***!
502 \******************************************/
503/*! no static exports found */
504/***/ (function(module, exports, __webpack_require__) {
505
506"use strict";
507
508/**
509 * @license
510 * Copyright 2016 Google Inc.
511 *
512 * Permission is hereby granted, free of charge, to any person obtaining a copy
513 * of this software and associated documentation files (the "Software"), to deal
514 * in the Software without restriction, including without limitation the rights
515 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
516 * copies of the Software, and to permit persons to whom the Software is
517 * furnished to do so, subject to the following conditions:
518 *
519 * The above copyright notice and this permission notice shall be included in
520 * all copies or substantial portions of the Software.
521 *
522 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
523 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
524 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
525 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
526 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
527 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
528 * THE SOFTWARE.
529 */
530
531var __extends = this && this.__extends || function () {
532 var _extendStatics = function extendStatics(d, b) {
533 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
534 d.__proto__ = b;
535 } || function (d, b) {
536 for (var p in b) {
537 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
538 }
539 };
540 return _extendStatics(d, b);
541 };
542 return function (d, b) {
543 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
544 _extendStatics(d, b);
545 function __() {
546 this.constructor = d;
547 }
548 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
549 };
550}();
551var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
552 if (k2 === undefined) k2 = k;
553 Object.defineProperty(o, k2, { enumerable: true, get: function get() {
554 return m[k];
555 } });
556} : function (o, m, k, k2) {
557 if (k2 === undefined) k2 = k;
558 o[k2] = m[k];
559});
560var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
561 Object.defineProperty(o, "default", { enumerable: true, value: v });
562} : function (o, v) {
563 o["default"] = v;
564});
565var __importStar = this && this.__importStar || function (mod) {
566 if (mod && mod.__esModule) return mod;
567 var result = {};
568 if (mod != null) for (var k in mod) {
569 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
570 }__setModuleDefault(result, mod);
571 return result;
572};
573Object.defineProperty(exports, "__esModule", { value: true });
574exports.MDCRipple = void 0;
575var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
576var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
577var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
578var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts");
579var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
580var MDCRipple = /** @class */function (_super) {
581 __extends(MDCRipple, _super);
582 function MDCRipple() {
583 var _this = _super !== null && _super.apply(this, arguments) || this;
584 _this.disabled = false;
585 return _this;
586 }
587 MDCRipple.attachTo = function (root, opts) {
588 if (opts === void 0) {
589 opts = {
590 isUnbounded: undefined
591 };
592 }
593 var ripple = new MDCRipple(root);
594 // Only override unbounded behavior if option is explicitly specified
595 if (opts.isUnbounded !== undefined) {
596 ripple.unbounded = opts.isUnbounded;
597 }
598 return ripple;
599 };
600 MDCRipple.createAdapter = function (instance) {
601 return {
602 addClass: function addClass(className) {
603 return instance.root.classList.add(className);
604 },
605 browserSupportsCssVars: function browserSupportsCssVars() {
606 return util.supportsCssVariables(window);
607 },
608 computeBoundingRect: function computeBoundingRect() {
609 return instance.root.getBoundingClientRect();
610 },
611 containsEventTarget: function containsEventTarget(target) {
612 return instance.root.contains(target);
613 },
614 deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler(evtType, handler) {
615 return document.documentElement.removeEventListener(evtType, handler, events_1.applyPassive());
616 },
617 deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
618 return instance.root.removeEventListener(evtType, handler, events_1.applyPassive());
619 },
620 deregisterResizeHandler: function deregisterResizeHandler(handler) {
621 return window.removeEventListener('resize', handler);
622 },
623 getWindowPageOffset: function getWindowPageOffset() {
624 return { x: window.pageXOffset, y: window.pageYOffset };
625 },
626 isSurfaceActive: function isSurfaceActive() {
627 return ponyfill_1.matches(instance.root, ':active');
628 },
629 isSurfaceDisabled: function isSurfaceDisabled() {
630 return Boolean(instance.disabled);
631 },
632 isUnbounded: function isUnbounded() {
633 return Boolean(instance.unbounded);
634 },
635 registerDocumentInteractionHandler: function registerDocumentInteractionHandler(evtType, handler) {
636 return document.documentElement.addEventListener(evtType, handler, events_1.applyPassive());
637 },
638 registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
639 return instance.root.addEventListener(evtType, handler, events_1.applyPassive());
640 },
641 registerResizeHandler: function registerResizeHandler(handler) {
642 return window.addEventListener('resize', handler);
643 },
644 removeClass: function removeClass(className) {
645 return instance.root.classList.remove(className);
646 },
647 updateCssVariable: function updateCssVariable(varName, value) {
648 return instance.root.style.setProperty(varName, value);
649 }
650 };
651 };
652 Object.defineProperty(MDCRipple.prototype, "unbounded", {
653 get: function get() {
654 return Boolean(this.isUnbounded);
655 },
656 set: function set(unbounded) {
657 this.isUnbounded = Boolean(unbounded);
658 this.setUnbounded();
659 },
660 enumerable: false,
661 configurable: true
662 });
663 MDCRipple.prototype.activate = function () {
664 this.foundation.activate();
665 };
666 MDCRipple.prototype.deactivate = function () {
667 this.foundation.deactivate();
668 };
669 MDCRipple.prototype.layout = function () {
670 this.foundation.layout();
671 };
672 MDCRipple.prototype.getDefaultFoundation = function () {
673 return new foundation_1.MDCRippleFoundation(MDCRipple.createAdapter(this));
674 };
675 MDCRipple.prototype.initialSyncWithDOM = function () {
676 var root = this.root;
677 this.isUnbounded = 'mdcRippleIsUnbounded' in root.dataset;
678 };
679 /**
680 * Closure Compiler throws an access control error when directly accessing a
681 * protected or private property inside a getter/setter, like unbounded above.
682 * By accessing the protected property inside a method, we solve that problem.
683 * That's why this function exists.
684 */
685 MDCRipple.prototype.setUnbounded = function () {
686 this.foundation.setUnbounded(Boolean(this.isUnbounded));
687 };
688 return MDCRipple;
689}(component_1.MDCComponent);
690exports.MDCRipple = MDCRipple;
691
692/***/ }),
693
694/***/ "./packages/mdc-ripple/constants.ts":
695/*!******************************************!*\
696 !*** ./packages/mdc-ripple/constants.ts ***!
697 \******************************************/
698/*! no static exports found */
699/***/ (function(module, exports, __webpack_require__) {
700
701"use strict";
702
703/**
704 * @license
705 * Copyright 2016 Google Inc.
706 *
707 * Permission is hereby granted, free of charge, to any person obtaining a copy
708 * of this software and associated documentation files (the "Software"), to deal
709 * in the Software without restriction, including without limitation the rights
710 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
711 * copies of the Software, and to permit persons to whom the Software is
712 * furnished to do so, subject to the following conditions:
713 *
714 * The above copyright notice and this permission notice shall be included in
715 * all copies or substantial portions of the Software.
716 *
717 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
718 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
719 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
720 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
721 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
722 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
723 * THE SOFTWARE.
724 */
725
726Object.defineProperty(exports, "__esModule", { value: true });
727exports.numbers = exports.strings = exports.cssClasses = void 0;
728exports.cssClasses = {
729 // Ripple is a special case where the "root" component is really a "mixin" of sorts,
730 // given that it's an 'upgrade' to an existing component. That being said it is the root
731 // CSS class that all other CSS classes derive from.
732 BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
733 FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
734 FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation',
735 ROOT: 'mdc-ripple-upgraded',
736 UNBOUNDED: 'mdc-ripple-upgraded--unbounded'
737};
738exports.strings = {
739 VAR_FG_SCALE: '--mdc-ripple-fg-scale',
740 VAR_FG_SIZE: '--mdc-ripple-fg-size',
741 VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end',
742 VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
743 VAR_LEFT: '--mdc-ripple-left',
744 VAR_TOP: '--mdc-ripple-top'
745};
746exports.numbers = {
747 DEACTIVATION_TIMEOUT_MS: 225,
748 FG_DEACTIVATION_MS: 150,
749 INITIAL_ORIGIN_SCALE: 0.6,
750 PADDING: 10,
751 TAP_DELAY_MS: 300 };
752
753/***/ }),
754
755/***/ "./packages/mdc-ripple/foundation.ts":
756/*!*******************************************!*\
757 !*** ./packages/mdc-ripple/foundation.ts ***!
758 \*******************************************/
759/*! no static exports found */
760/***/ (function(module, exports, __webpack_require__) {
761
762"use strict";
763
764/**
765 * @license
766 * Copyright 2016 Google Inc.
767 *
768 * Permission is hereby granted, free of charge, to any person obtaining a copy
769 * of this software and associated documentation files (the "Software"), to deal
770 * in the Software without restriction, including without limitation the rights
771 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
772 * copies of the Software, and to permit persons to whom the Software is
773 * furnished to do so, subject to the following conditions:
774 *
775 * The above copyright notice and this permission notice shall be included in
776 * all copies or substantial portions of the Software.
777 *
778 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
779 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
780 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
781 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
782 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
783 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
784 * THE SOFTWARE.
785 */
786
787var __extends = this && this.__extends || function () {
788 var _extendStatics = function extendStatics(d, b) {
789 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
790 d.__proto__ = b;
791 } || function (d, b) {
792 for (var p in b) {
793 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
794 }
795 };
796 return _extendStatics(d, b);
797 };
798 return function (d, b) {
799 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
800 _extendStatics(d, b);
801 function __() {
802 this.constructor = d;
803 }
804 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
805 };
806}();
807var __assign = this && this.__assign || function () {
808 __assign = Object.assign || function (t) {
809 for (var s, i = 1, n = arguments.length; i < n; i++) {
810 s = arguments[i];
811 for (var p in s) {
812 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
813 }
814 }
815 return t;
816 };
817 return __assign.apply(this, arguments);
818};
819var __values = this && this.__values || function (o) {
820 var s = typeof Symbol === "function" && Symbol.iterator,
821 m = s && o[s],
822 i = 0;
823 if (m) return m.call(o);
824 if (o && typeof o.length === "number") return {
825 next: function next() {
826 if (o && i >= o.length) o = void 0;
827 return { value: o && o[i++], done: !o };
828 }
829 };
830 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
831};
832Object.defineProperty(exports, "__esModule", { value: true });
833exports.MDCRippleFoundation = void 0;
834var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
835var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts");
836var util_1 = __webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts");
837// Activation events registered on the root element of each instance for activation
838var ACTIVATION_EVENT_TYPES = ['touchstart', 'pointerdown', 'mousedown', 'keydown'];
839// Deactivation events registered on documentElement when a pointer-related down event occurs
840var POINTER_DEACTIVATION_EVENT_TYPES = ['touchend', 'pointerup', 'mouseup', 'contextmenu'];
841// simultaneous nested activations
842var activatedTargets = [];
843var MDCRippleFoundation = /** @class */function (_super) {
844 __extends(MDCRippleFoundation, _super);
845 function MDCRippleFoundation(adapter) {
846 var _this = _super.call(this, __assign(__assign({}, MDCRippleFoundation.defaultAdapter), adapter)) || this;
847 _this.activationAnimationHasEnded = false;
848 _this.activationTimer = 0;
849 _this.fgDeactivationRemovalTimer = 0;
850 _this.fgScale = '0';
851 _this.frame = { width: 0, height: 0 };
852 _this.initialSize = 0;
853 _this.layoutFrame = 0;
854 _this.maxRadius = 0;
855 _this.unboundedCoords = { left: 0, top: 0 };
856 _this.activationState = _this.defaultActivationState();
857 _this.activationTimerCallback = function () {
858 _this.activationAnimationHasEnded = true;
859 _this.runDeactivationUXLogicIfReady();
860 };
861 _this.activateHandler = function (e) {
862 _this.activateImpl(e);
863 };
864 _this.deactivateHandler = function () {
865 _this.deactivateImpl();
866 };
867 _this.focusHandler = function () {
868 _this.handleFocus();
869 };
870 _this.blurHandler = function () {
871 _this.handleBlur();
872 };
873 _this.resizeHandler = function () {
874 _this.layout();
875 };
876 return _this;
877 }
878 Object.defineProperty(MDCRippleFoundation, "cssClasses", {
879 get: function get() {
880 return constants_1.cssClasses;
881 },
882 enumerable: false,
883 configurable: true
884 });
885 Object.defineProperty(MDCRippleFoundation, "strings", {
886 get: function get() {
887 return constants_1.strings;
888 },
889 enumerable: false,
890 configurable: true
891 });
892 Object.defineProperty(MDCRippleFoundation, "numbers", {
893 get: function get() {
894 return constants_1.numbers;
895 },
896 enumerable: false,
897 configurable: true
898 });
899 Object.defineProperty(MDCRippleFoundation, "defaultAdapter", {
900 get: function get() {
901 return {
902 addClass: function addClass() {
903 return undefined;
904 },
905 browserSupportsCssVars: function browserSupportsCssVars() {
906 return true;
907 },
908 computeBoundingRect: function computeBoundingRect() {
909 return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
910 },
911 containsEventTarget: function containsEventTarget() {
912 return true;
913 },
914 deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() {
915 return undefined;
916 },
917 deregisterInteractionHandler: function deregisterInteractionHandler() {
918 return undefined;
919 },
920 deregisterResizeHandler: function deregisterResizeHandler() {
921 return undefined;
922 },
923 getWindowPageOffset: function getWindowPageOffset() {
924 return { x: 0, y: 0 };
925 },
926 isSurfaceActive: function isSurfaceActive() {
927 return true;
928 },
929 isSurfaceDisabled: function isSurfaceDisabled() {
930 return true;
931 },
932 isUnbounded: function isUnbounded() {
933 return true;
934 },
935 registerDocumentInteractionHandler: function registerDocumentInteractionHandler() {
936 return undefined;
937 },
938 registerInteractionHandler: function registerInteractionHandler() {
939 return undefined;
940 },
941 registerResizeHandler: function registerResizeHandler() {
942 return undefined;
943 },
944 removeClass: function removeClass() {
945 return undefined;
946 },
947 updateCssVariable: function updateCssVariable() {
948 return undefined;
949 }
950 };
951 },
952 enumerable: false,
953 configurable: true
954 });
955 MDCRippleFoundation.prototype.init = function () {
956 var _this = this;
957 var supportsPressRipple = this.supportsPressRipple();
958 this.registerRootHandlers(supportsPressRipple);
959 if (supportsPressRipple) {
960 var _a = MDCRippleFoundation.cssClasses,
961 ROOT_1 = _a.ROOT,
962 UNBOUNDED_1 = _a.UNBOUNDED;
963 requestAnimationFrame(function () {
964 _this.adapter.addClass(ROOT_1);
965 if (_this.adapter.isUnbounded()) {
966 _this.adapter.addClass(UNBOUNDED_1);
967 // Unbounded ripples need layout logic applied immediately to set coordinates for both shade and ripple
968 _this.layoutInternal();
969 }
970 });
971 }
972 };
973 MDCRippleFoundation.prototype.destroy = function () {
974 var _this = this;
975 if (this.supportsPressRipple()) {
976 if (this.activationTimer) {
977 clearTimeout(this.activationTimer);
978 this.activationTimer = 0;
979 this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION);
980 }
981 if (this.fgDeactivationRemovalTimer) {
982 clearTimeout(this.fgDeactivationRemovalTimer);
983 this.fgDeactivationRemovalTimer = 0;
984 this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION);
985 }
986 var _a = MDCRippleFoundation.cssClasses,
987 ROOT_2 = _a.ROOT,
988 UNBOUNDED_2 = _a.UNBOUNDED;
989 requestAnimationFrame(function () {
990 _this.adapter.removeClass(ROOT_2);
991 _this.adapter.removeClass(UNBOUNDED_2);
992 _this.removeCssVars();
993 });
994 }
995 this.deregisterRootHandlers();
996 this.deregisterDeactivationHandlers();
997 };
998 /**
999 * @param evt Optional event containing position information.
1000 */
1001 MDCRippleFoundation.prototype.activate = function (evt) {
1002 this.activateImpl(evt);
1003 };
1004 MDCRippleFoundation.prototype.deactivate = function () {
1005 this.deactivateImpl();
1006 };
1007 MDCRippleFoundation.prototype.layout = function () {
1008 var _this = this;
1009 if (this.layoutFrame) {
1010 cancelAnimationFrame(this.layoutFrame);
1011 }
1012 this.layoutFrame = requestAnimationFrame(function () {
1013 _this.layoutInternal();
1014 _this.layoutFrame = 0;
1015 });
1016 };
1017 MDCRippleFoundation.prototype.setUnbounded = function (unbounded) {
1018 var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED;
1019 if (unbounded) {
1020 this.adapter.addClass(UNBOUNDED);
1021 } else {
1022 this.adapter.removeClass(UNBOUNDED);
1023 }
1024 };
1025 MDCRippleFoundation.prototype.handleFocus = function () {
1026 var _this = this;
1027 requestAnimationFrame(function () {
1028 return _this.adapter.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
1029 });
1030 };
1031 MDCRippleFoundation.prototype.handleBlur = function () {
1032 var _this = this;
1033 requestAnimationFrame(function () {
1034 return _this.adapter.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
1035 });
1036 };
1037 /**
1038 * We compute this property so that we are not querying information about the client
1039 * until the point in time where the foundation requests it. This prevents scenarios where
1040 * client-side feature-detection may happen too early, such as when components are rendered on the server
1041 * and then initialized at mount time on the client.
1042 */
1043 MDCRippleFoundation.prototype.supportsPressRipple = function () {
1044 return this.adapter.browserSupportsCssVars();
1045 };
1046 MDCRippleFoundation.prototype.defaultActivationState = function () {
1047 return {
1048 activationEvent: undefined,
1049 hasDeactivationUXRun: false,
1050 isActivated: false,
1051 isProgrammatic: false,
1052 wasActivatedByPointer: false,
1053 wasElementMadeActive: false
1054 };
1055 };
1056 /**
1057 * supportsPressRipple Passed from init to save a redundant function call
1058 */
1059 MDCRippleFoundation.prototype.registerRootHandlers = function (supportsPressRipple) {
1060 var e_1, _a;
1061 if (supportsPressRipple) {
1062 try {
1063 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()) {
1064 var evtType = ACTIVATION_EVENT_TYPES_1_1.value;
1065 this.adapter.registerInteractionHandler(evtType, this.activateHandler);
1066 }
1067 } catch (e_1_1) {
1068 e_1 = { error: e_1_1 };
1069 } finally {
1070 try {
1071 if (ACTIVATION_EVENT_TYPES_1_1 && !ACTIVATION_EVENT_TYPES_1_1.done && (_a = ACTIVATION_EVENT_TYPES_1.return)) _a.call(ACTIVATION_EVENT_TYPES_1);
1072 } finally {
1073 if (e_1) throw e_1.error;
1074 }
1075 }
1076 if (this.adapter.isUnbounded()) {
1077 this.adapter.registerResizeHandler(this.resizeHandler);
1078 }
1079 }
1080 this.adapter.registerInteractionHandler('focus', this.focusHandler);
1081 this.adapter.registerInteractionHandler('blur', this.blurHandler);
1082 };
1083 MDCRippleFoundation.prototype.registerDeactivationHandlers = function (evt) {
1084 var e_2, _a;
1085 if (evt.type === 'keydown') {
1086 this.adapter.registerInteractionHandler('keyup', this.deactivateHandler);
1087 } else {
1088 try {
1089 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()) {
1090 var evtType = POINTER_DEACTIVATION_EVENT_TYPES_1_1.value;
1091 this.adapter.registerDocumentInteractionHandler(evtType, this.deactivateHandler);
1092 }
1093 } catch (e_2_1) {
1094 e_2 = { error: e_2_1 };
1095 } finally {
1096 try {
1097 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);
1098 } finally {
1099 if (e_2) throw e_2.error;
1100 }
1101 }
1102 }
1103 };
1104 MDCRippleFoundation.prototype.deregisterRootHandlers = function () {
1105 var e_3, _a;
1106 try {
1107 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()) {
1108 var evtType = ACTIVATION_EVENT_TYPES_2_1.value;
1109 this.adapter.deregisterInteractionHandler(evtType, this.activateHandler);
1110 }
1111 } catch (e_3_1) {
1112 e_3 = { error: e_3_1 };
1113 } finally {
1114 try {
1115 if (ACTIVATION_EVENT_TYPES_2_1 && !ACTIVATION_EVENT_TYPES_2_1.done && (_a = ACTIVATION_EVENT_TYPES_2.return)) _a.call(ACTIVATION_EVENT_TYPES_2);
1116 } finally {
1117 if (e_3) throw e_3.error;
1118 }
1119 }
1120 this.adapter.deregisterInteractionHandler('focus', this.focusHandler);
1121 this.adapter.deregisterInteractionHandler('blur', this.blurHandler);
1122 if (this.adapter.isUnbounded()) {
1123 this.adapter.deregisterResizeHandler(this.resizeHandler);
1124 }
1125 };
1126 MDCRippleFoundation.prototype.deregisterDeactivationHandlers = function () {
1127 var e_4, _a;
1128 this.adapter.deregisterInteractionHandler('keyup', this.deactivateHandler);
1129 try {
1130 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()) {
1131 var evtType = POINTER_DEACTIVATION_EVENT_TYPES_2_1.value;
1132 this.adapter.deregisterDocumentInteractionHandler(evtType, this.deactivateHandler);
1133 }
1134 } catch (e_4_1) {
1135 e_4 = { error: e_4_1 };
1136 } finally {
1137 try {
1138 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);
1139 } finally {
1140 if (e_4) throw e_4.error;
1141 }
1142 }
1143 };
1144 MDCRippleFoundation.prototype.removeCssVars = function () {
1145 var _this = this;
1146 var rippleStrings = MDCRippleFoundation.strings;
1147 var keys = Object.keys(rippleStrings);
1148 keys.forEach(function (key) {
1149 if (key.indexOf('VAR_') === 0) {
1150 _this.adapter.updateCssVariable(rippleStrings[key], null);
1151 }
1152 });
1153 };
1154 MDCRippleFoundation.prototype.activateImpl = function (evt) {
1155 var _this = this;
1156 if (this.adapter.isSurfaceDisabled()) {
1157 return;
1158 }
1159 var activationState = this.activationState;
1160 if (activationState.isActivated) {
1161 return;
1162 }
1163 // Avoid reacting to follow-on events fired by touch device after an already-processed user interaction
1164 var previousActivationEvent = this.previousActivationEvent;
1165 var isSameInteraction = previousActivationEvent && evt !== undefined && previousActivationEvent.type !== evt.type;
1166 if (isSameInteraction) {
1167 return;
1168 }
1169 activationState.isActivated = true;
1170 activationState.isProgrammatic = evt === undefined;
1171 activationState.activationEvent = evt;
1172 activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== undefined && (evt.type === 'mousedown' || evt.type === 'touchstart' || evt.type === 'pointerdown');
1173 var hasActivatedChild = evt !== undefined && activatedTargets.length > 0 && activatedTargets.some(function (target) {
1174 return _this.adapter.containsEventTarget(target);
1175 });
1176 if (hasActivatedChild) {
1177 // Immediately reset activation state, while preserving logic that prevents touch follow-on events
1178 this.resetActivationState();
1179 return;
1180 }
1181 if (evt !== undefined) {
1182 activatedTargets.push(evt.target);
1183 this.registerDeactivationHandlers(evt);
1184 }
1185 activationState.wasElementMadeActive = this.checkElementMadeActive(evt);
1186 if (activationState.wasElementMadeActive) {
1187 this.animateActivation();
1188 }
1189 requestAnimationFrame(function () {
1190 // Reset array on next frame after the current event has had a chance to bubble to prevent ancestor ripples
1191 activatedTargets = [];
1192 if (!activationState.wasElementMadeActive && evt !== undefined && (evt.key === ' ' || evt.keyCode === 32)) {
1193 // If space was pressed, try again within an rAF call to detect :active, because different UAs report
1194 // active states inconsistently when they're called within event handling code:
1195 // - https://bugs.chromium.org/p/chromium/issues/detail?id=635971
1196 // - https://bugzilla.mozilla.org/show_bug.cgi?id=1293741
1197 // We try first outside rAF to support Edge, which does not exhibit this problem, but will crash if a CSS
1198 // variable is set within a rAF callback for a submit button interaction (#2241).
1199 activationState.wasElementMadeActive = _this.checkElementMadeActive(evt);
1200 if (activationState.wasElementMadeActive) {
1201 _this.animateActivation();
1202 }
1203 }
1204 if (!activationState.wasElementMadeActive) {
1205 // Reset activation state immediately if element was not made active.
1206 _this.activationState = _this.defaultActivationState();
1207 }
1208 });
1209 };
1210 MDCRippleFoundation.prototype.checkElementMadeActive = function (evt) {
1211 return evt !== undefined && evt.type === 'keydown' ? this.adapter.isSurfaceActive() : true;
1212 };
1213 MDCRippleFoundation.prototype.animateActivation = function () {
1214 var _this = this;
1215 var _a = MDCRippleFoundation.strings,
1216 VAR_FG_TRANSLATE_START = _a.VAR_FG_TRANSLATE_START,
1217 VAR_FG_TRANSLATE_END = _a.VAR_FG_TRANSLATE_END;
1218 var _b = MDCRippleFoundation.cssClasses,
1219 FG_DEACTIVATION = _b.FG_DEACTIVATION,
1220 FG_ACTIVATION = _b.FG_ACTIVATION;
1221 var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
1222 this.layoutInternal();
1223 var translateStart = '';
1224 var translateEnd = '';
1225 if (!this.adapter.isUnbounded()) {
1226 var _c = this.getFgTranslationCoordinates(),
1227 startPoint = _c.startPoint,
1228 endPoint = _c.endPoint;
1229 translateStart = startPoint.x + "px, " + startPoint.y + "px";
1230 translateEnd = endPoint.x + "px, " + endPoint.y + "px";
1231 }
1232 this.adapter.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
1233 this.adapter.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
1234 // Cancel any ongoing activation/deactivation animations
1235 clearTimeout(this.activationTimer);
1236 clearTimeout(this.fgDeactivationRemovalTimer);
1237 this.rmBoundedActivationClasses();
1238 this.adapter.removeClass(FG_DEACTIVATION);
1239 // Force layout in order to re-trigger the animation.
1240 this.adapter.computeBoundingRect();
1241 this.adapter.addClass(FG_ACTIVATION);
1242 this.activationTimer = setTimeout(function () {
1243 _this.activationTimerCallback();
1244 }, DEACTIVATION_TIMEOUT_MS);
1245 };
1246 MDCRippleFoundation.prototype.getFgTranslationCoordinates = function () {
1247 var _a = this.activationState,
1248 activationEvent = _a.activationEvent,
1249 wasActivatedByPointer = _a.wasActivatedByPointer;
1250 var startPoint;
1251 if (wasActivatedByPointer) {
1252 startPoint = util_1.getNormalizedEventCoords(activationEvent, this.adapter.getWindowPageOffset(), this.adapter.computeBoundingRect());
1253 } else {
1254 startPoint = {
1255 x: this.frame.width / 2,
1256 y: this.frame.height / 2
1257 };
1258 }
1259 // Center the element around the start point.
1260 startPoint = {
1261 x: startPoint.x - this.initialSize / 2,
1262 y: startPoint.y - this.initialSize / 2
1263 };
1264 var endPoint = {
1265 x: this.frame.width / 2 - this.initialSize / 2,
1266 y: this.frame.height / 2 - this.initialSize / 2
1267 };
1268 return { startPoint: startPoint, endPoint: endPoint };
1269 };
1270 MDCRippleFoundation.prototype.runDeactivationUXLogicIfReady = function () {
1271 var _this = this;
1272 // This method is called both when a pointing device is released, and when the activation animation ends.
1273 // The deactivation animation should only run after both of those occur.
1274 var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
1275 var _a = this.activationState,
1276 hasDeactivationUXRun = _a.hasDeactivationUXRun,
1277 isActivated = _a.isActivated;
1278 var activationHasEnded = hasDeactivationUXRun || !isActivated;
1279 if (activationHasEnded && this.activationAnimationHasEnded) {
1280 this.rmBoundedActivationClasses();
1281 this.adapter.addClass(FG_DEACTIVATION);
1282 this.fgDeactivationRemovalTimer = setTimeout(function () {
1283 _this.adapter.removeClass(FG_DEACTIVATION);
1284 }, constants_1.numbers.FG_DEACTIVATION_MS);
1285 }
1286 };
1287 MDCRippleFoundation.prototype.rmBoundedActivationClasses = function () {
1288 var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION;
1289 this.adapter.removeClass(FG_ACTIVATION);
1290 this.activationAnimationHasEnded = false;
1291 this.adapter.computeBoundingRect();
1292 };
1293 MDCRippleFoundation.prototype.resetActivationState = function () {
1294 var _this = this;
1295 this.previousActivationEvent = this.activationState.activationEvent;
1296 this.activationState = this.defaultActivationState();
1297 // Touch devices may fire additional events for the same interaction within a short time.
1298 // Store the previous event until it's safe to assume that subsequent events are for new interactions.
1299 setTimeout(function () {
1300 return _this.previousActivationEvent = undefined;
1301 }, MDCRippleFoundation.numbers.TAP_DELAY_MS);
1302 };
1303 MDCRippleFoundation.prototype.deactivateImpl = function () {
1304 var _this = this;
1305 var activationState = this.activationState;
1306 // This can happen in scenarios such as when you have a keyup event that blurs the element.
1307 if (!activationState.isActivated) {
1308 return;
1309 }
1310 var state = __assign({}, activationState);
1311 if (activationState.isProgrammatic) {
1312 requestAnimationFrame(function () {
1313 _this.animateDeactivation(state);
1314 });
1315 this.resetActivationState();
1316 } else {
1317 this.deregisterDeactivationHandlers();
1318 requestAnimationFrame(function () {
1319 _this.activationState.hasDeactivationUXRun = true;
1320 _this.animateDeactivation(state);
1321 _this.resetActivationState();
1322 });
1323 }
1324 };
1325 MDCRippleFoundation.prototype.animateDeactivation = function (_a) {
1326 var wasActivatedByPointer = _a.wasActivatedByPointer,
1327 wasElementMadeActive = _a.wasElementMadeActive;
1328 if (wasActivatedByPointer || wasElementMadeActive) {
1329 this.runDeactivationUXLogicIfReady();
1330 }
1331 };
1332 MDCRippleFoundation.prototype.layoutInternal = function () {
1333 var _this = this;
1334 this.frame = this.adapter.computeBoundingRect();
1335 var maxDim = Math.max(this.frame.height, this.frame.width);
1336 // Surface diameter is treated differently for unbounded vs. bounded ripples.
1337 // Unbounded ripple diameter is calculated smaller since the surface is expected to already be padded appropriately
1338 // to extend the hitbox, and the ripple is expected to meet the edges of the padded hitbox (which is typically
1339 // square). Bounded ripples, on the other hand, are fully expected to expand beyond the surface's longest diameter
1340 // (calculated based on the diagonal plus a constant padding), and are clipped at the surface's border via
1341 // `overflow: hidden`.
1342 var getBoundedRadius = function getBoundedRadius() {
1343 var hypotenuse = Math.sqrt(Math.pow(_this.frame.width, 2) + Math.pow(_this.frame.height, 2));
1344 return hypotenuse + MDCRippleFoundation.numbers.PADDING;
1345 };
1346 this.maxRadius = this.adapter.isUnbounded() ? maxDim : getBoundedRadius();
1347 // Ripple is sized as a fraction of the largest dimension of the surface, then scales up using a CSS scale transform
1348 var initialSize = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
1349 // Unbounded ripple size should always be even number to equally center align.
1350 if (this.adapter.isUnbounded() && initialSize % 2 !== 0) {
1351 this.initialSize = initialSize - 1;
1352 } else {
1353 this.initialSize = initialSize;
1354 }
1355 this.fgScale = "" + this.maxRadius / this.initialSize;
1356 this.updateLayoutCssVars();
1357 };
1358 MDCRippleFoundation.prototype.updateLayoutCssVars = function () {
1359 var _a = MDCRippleFoundation.strings,
1360 VAR_FG_SIZE = _a.VAR_FG_SIZE,
1361 VAR_LEFT = _a.VAR_LEFT,
1362 VAR_TOP = _a.VAR_TOP,
1363 VAR_FG_SCALE = _a.VAR_FG_SCALE;
1364 this.adapter.updateCssVariable(VAR_FG_SIZE, this.initialSize + "px");
1365 this.adapter.updateCssVariable(VAR_FG_SCALE, this.fgScale);
1366 if (this.adapter.isUnbounded()) {
1367 this.unboundedCoords = {
1368 left: Math.round(this.frame.width / 2 - this.initialSize / 2),
1369 top: Math.round(this.frame.height / 2 - this.initialSize / 2)
1370 };
1371 this.adapter.updateCssVariable(VAR_LEFT, this.unboundedCoords.left + "px");
1372 this.adapter.updateCssVariable(VAR_TOP, this.unboundedCoords.top + "px");
1373 }
1374 };
1375 return MDCRippleFoundation;
1376}(foundation_1.MDCFoundation);
1377exports.MDCRippleFoundation = MDCRippleFoundation;
1378// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
1379exports.default = MDCRippleFoundation;
1380
1381/***/ }),
1382
1383/***/ "./packages/mdc-ripple/util.ts":
1384/*!*************************************!*\
1385 !*** ./packages/mdc-ripple/util.ts ***!
1386 \*************************************/
1387/*! no static exports found */
1388/***/ (function(module, exports, __webpack_require__) {
1389
1390"use strict";
1391
1392
1393Object.defineProperty(exports, "__esModule", { value: true });
1394exports.getNormalizedEventCoords = exports.supportsCssVariables = void 0;
1395/**
1396 * Stores result from supportsCssVariables to avoid redundant processing to
1397 * detect CSS custom variable support.
1398 */
1399var supportsCssVariables_;
1400function supportsCssVariables(windowObj, forceRefresh) {
1401 if (forceRefresh === void 0) {
1402 forceRefresh = false;
1403 }
1404 var CSS = windowObj.CSS;
1405 var supportsCssVars = supportsCssVariables_;
1406 if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
1407 return supportsCssVariables_;
1408 }
1409 var supportsFunctionPresent = CSS && typeof CSS.supports === 'function';
1410 if (!supportsFunctionPresent) {
1411 return false;
1412 }
1413 var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes');
1414 // See: https://bugs.webkit.org/show_bug.cgi?id=154669
1415 // See: README section on Safari
1416 var weAreFeatureDetectingSafari10plus = CSS.supports('(--css-vars: yes)') && CSS.supports('color', '#00000000');
1417 supportsCssVars = explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
1418 if (!forceRefresh) {
1419 supportsCssVariables_ = supportsCssVars;
1420 }
1421 return supportsCssVars;
1422}
1423exports.supportsCssVariables = supportsCssVariables;
1424function getNormalizedEventCoords(evt, pageOffset, clientRect) {
1425 if (!evt) {
1426 return { x: 0, y: 0 };
1427 }
1428 var x = pageOffset.x,
1429 y = pageOffset.y;
1430 var documentX = x + clientRect.left;
1431 var documentY = y + clientRect.top;
1432 var normalizedX;
1433 var normalizedY;
1434 // Determine touch point relative to the ripple container.
1435 if (evt.type === 'touchstart') {
1436 var touchEvent = evt;
1437 normalizedX = touchEvent.changedTouches[0].pageX - documentX;
1438 normalizedY = touchEvent.changedTouches[0].pageY - documentY;
1439 } else {
1440 var mouseEvent = evt;
1441 normalizedX = mouseEvent.pageX - documentX;
1442 normalizedY = mouseEvent.pageY - documentY;
1443 }
1444 return { x: normalizedX, y: normalizedY };
1445}
1446exports.getNormalizedEventCoords = getNormalizedEventCoords;
1447
1448/***/ }),
1449
1450/***/ "./packages/mdc-top-app-bar/adapter.ts":
1451/*!*********************************************!*\
1452 !*** ./packages/mdc-top-app-bar/adapter.ts ***!
1453 \*********************************************/
1454/*! no static exports found */
1455/***/ (function(module, exports, __webpack_require__) {
1456
1457"use strict";
1458
1459/**
1460 * @license
1461 * Copyright 2018 Google Inc.
1462 *
1463 * Permission is hereby granted, free of charge, to any person obtaining a copy
1464 * of this software and associated documentation files (the "Software"), to deal
1465 * in the Software without restriction, including without limitation the rights
1466 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1467 * copies of the Software, and to permit persons to whom the Software is
1468 * furnished to do so, subject to the following conditions:
1469 *
1470 * The above copyright notice and this permission notice shall be included in
1471 * all copies or substantial portions of the Software.
1472 *
1473 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1474 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1475 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1476 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1477 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1478 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1479 * THE SOFTWARE.
1480 */
1481
1482Object.defineProperty(exports, "__esModule", { value: true });
1483
1484/***/ }),
1485
1486/***/ "./packages/mdc-top-app-bar/component.ts":
1487/*!***********************************************!*\
1488 !*** ./packages/mdc-top-app-bar/component.ts ***!
1489 \***********************************************/
1490/*! no static exports found */
1491/***/ (function(module, exports, __webpack_require__) {
1492
1493"use strict";
1494
1495/**
1496 * @license
1497 * Copyright 2018 Google Inc.
1498 *
1499 * Permission is hereby granted, free of charge, to any person obtaining a copy
1500 * of this software and associated documentation files (the "Software"), to deal
1501 * in the Software without restriction, including without limitation the rights
1502 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1503 * copies of the Software, and to permit persons to whom the Software is
1504 * furnished to do so, subject to the following conditions:
1505 *
1506 * The above copyright notice and this permission notice shall be included in
1507 * all copies or substantial portions of the Software.
1508 *
1509 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1510 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1511 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1512 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1513 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1514 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1515 * THE SOFTWARE.
1516 */
1517
1518var __extends = this && this.__extends || function () {
1519 var _extendStatics = function extendStatics(d, b) {
1520 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
1521 d.__proto__ = b;
1522 } || function (d, b) {
1523 for (var p in b) {
1524 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
1525 }
1526 };
1527 return _extendStatics(d, b);
1528 };
1529 return function (d, b) {
1530 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1531 _extendStatics(d, b);
1532 function __() {
1533 this.constructor = d;
1534 }
1535 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1536 };
1537}();
1538var __values = this && this.__values || function (o) {
1539 var s = typeof Symbol === "function" && Symbol.iterator,
1540 m = s && o[s],
1541 i = 0;
1542 if (m) return m.call(o);
1543 if (o && typeof o.length === "number") return {
1544 next: function next() {
1545 if (o && i >= o.length) o = void 0;
1546 return { value: o && o[i++], done: !o };
1547 }
1548 };
1549 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
1550};
1551Object.defineProperty(exports, "__esModule", { value: true });
1552exports.MDCTopAppBar = void 0;
1553var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
1554var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
1555var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-top-app-bar/constants.ts");
1556var foundation_1 = __webpack_require__(/*! ./fixed/foundation */ "./packages/mdc-top-app-bar/fixed/foundation.ts");
1557var foundation_2 = __webpack_require__(/*! ./short/foundation */ "./packages/mdc-top-app-bar/short/foundation.ts");
1558var foundation_3 = __webpack_require__(/*! ./standard/foundation */ "./packages/mdc-top-app-bar/standard/foundation.ts");
1559var MDCTopAppBar = /** @class */function (_super) {
1560 __extends(MDCTopAppBar, _super);
1561 function MDCTopAppBar() {
1562 return _super !== null && _super.apply(this, arguments) || this;
1563 }
1564 MDCTopAppBar.attachTo = function (root) {
1565 return new MDCTopAppBar(root);
1566 };
1567 MDCTopAppBar.prototype.initialize = function (rippleFactory) {
1568 if (rippleFactory === void 0) {
1569 rippleFactory = function rippleFactory(el) {
1570 return component_2.MDCRipple.attachTo(el);
1571 };
1572 }
1573 this.navIcon = this.root.querySelector(constants_1.strings.NAVIGATION_ICON_SELECTOR);
1574 // Get all icons in the toolbar and instantiate the ripples
1575 var icons = [].slice.call(this.root.querySelectorAll(constants_1.strings.ACTION_ITEM_SELECTOR));
1576 if (this.navIcon) {
1577 icons.push(this.navIcon);
1578 }
1579 this.iconRipples = icons.map(function (icon) {
1580 var ripple = rippleFactory(icon);
1581 ripple.unbounded = true;
1582 return ripple;
1583 });
1584 this.scrollTarget = window;
1585 };
1586 MDCTopAppBar.prototype.initialSyncWithDOM = function () {
1587 this.handleNavigationClick = this.foundation.handleNavigationClick.bind(this.foundation);
1588 this.handleWindowResize = this.foundation.handleWindowResize.bind(this.foundation);
1589 this.handleTargetScroll = this.foundation.handleTargetScroll.bind(this.foundation);
1590 this.scrollTarget.addEventListener('scroll', this.handleTargetScroll);
1591 if (this.navIcon) {
1592 this.navIcon.addEventListener('click', this.handleNavigationClick);
1593 }
1594 var isFixed = this.root.classList.contains(constants_1.cssClasses.FIXED_CLASS);
1595 var isShort = this.root.classList.contains(constants_1.cssClasses.SHORT_CLASS);
1596 if (!isShort && !isFixed) {
1597 window.addEventListener('resize', this.handleWindowResize);
1598 }
1599 };
1600 MDCTopAppBar.prototype.destroy = function () {
1601 var e_1, _a;
1602 try {
1603 for (var _b = __values(this.iconRipples), _c = _b.next(); !_c.done; _c = _b.next()) {
1604 var iconRipple = _c.value;
1605 iconRipple.destroy();
1606 }
1607 } catch (e_1_1) {
1608 e_1 = { error: e_1_1 };
1609 } finally {
1610 try {
1611 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1612 } finally {
1613 if (e_1) throw e_1.error;
1614 }
1615 }
1616 this.scrollTarget.removeEventListener('scroll', this.handleTargetScroll);
1617 if (this.navIcon) {
1618 this.navIcon.removeEventListener('click', this.handleNavigationClick);
1619 }
1620 var isFixed = this.root.classList.contains(constants_1.cssClasses.FIXED_CLASS);
1621 var isShort = this.root.classList.contains(constants_1.cssClasses.SHORT_CLASS);
1622 if (!isShort && !isFixed) {
1623 window.removeEventListener('resize', this.handleWindowResize);
1624 }
1625 _super.prototype.destroy.call(this);
1626 };
1627 MDCTopAppBar.prototype.setScrollTarget = function (target) {
1628 // Remove scroll handler from the previous scroll target
1629 this.scrollTarget.removeEventListener('scroll', this.handleTargetScroll);
1630 this.scrollTarget = target;
1631 // Initialize scroll handler on the new scroll target
1632 this.handleTargetScroll = this.foundation.handleTargetScroll.bind(this.foundation);
1633 this.scrollTarget.addEventListener('scroll', this.handleTargetScroll);
1634 };
1635 MDCTopAppBar.prototype.getDefaultFoundation = function () {
1636 var _this = this;
1637 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
1638 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
1639 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
1640 var adapter = {
1641 hasClass: function hasClass(className) {
1642 return _this.root.classList.contains(className);
1643 },
1644 addClass: function addClass(className) {
1645 return _this.root.classList.add(className);
1646 },
1647 removeClass: function removeClass(className) {
1648 return _this.root.classList.remove(className);
1649 },
1650 setStyle: function setStyle(property, value) {
1651 return _this.root.style.setProperty(property, value);
1652 },
1653 getTopAppBarHeight: function getTopAppBarHeight() {
1654 return _this.root.clientHeight;
1655 },
1656 notifyNavigationIconClicked: function notifyNavigationIconClicked() {
1657 return _this.emit(constants_1.strings.NAVIGATION_EVENT, {});
1658 },
1659 getViewportScrollY: function getViewportScrollY() {
1660 var win = _this.scrollTarget;
1661 var el = _this.scrollTarget;
1662 return win.pageYOffset !== undefined ? win.pageYOffset : el.scrollTop;
1663 },
1664 getTotalActionItems: function getTotalActionItems() {
1665 return _this.root.querySelectorAll(constants_1.strings.ACTION_ITEM_SELECTOR).length;
1666 }
1667 };
1668 // tslint:enable:object-literal-sort-keys
1669 var foundation;
1670 if (this.root.classList.contains(constants_1.cssClasses.SHORT_CLASS)) {
1671 foundation = new foundation_2.MDCShortTopAppBarFoundation(adapter);
1672 } else if (this.root.classList.contains(constants_1.cssClasses.FIXED_CLASS)) {
1673 foundation = new foundation_1.MDCFixedTopAppBarFoundation(adapter);
1674 } else {
1675 foundation = new foundation_3.MDCTopAppBarFoundation(adapter);
1676 }
1677 return foundation;
1678 };
1679 return MDCTopAppBar;
1680}(component_1.MDCComponent);
1681exports.MDCTopAppBar = MDCTopAppBar;
1682
1683/***/ }),
1684
1685/***/ "./packages/mdc-top-app-bar/constants.ts":
1686/*!***********************************************!*\
1687 !*** ./packages/mdc-top-app-bar/constants.ts ***!
1688 \***********************************************/
1689/*! no static exports found */
1690/***/ (function(module, exports, __webpack_require__) {
1691
1692"use strict";
1693
1694/**
1695 * @license
1696 * Copyright 2018 Google Inc.
1697 *
1698 * Permission is hereby granted, free of charge, to any person obtaining a copy
1699 * of this software and associated documentation files (the "Software"), to deal
1700 * in the Software without restriction, including without limitation the rights
1701 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1702 * copies of the Software, and to permit persons to whom the Software is
1703 * furnished to do so, subject to the following conditions:
1704 *
1705 * The above copyright notice and this permission notice shall be included in
1706 * all copies or substantial portions of the Software.
1707 *
1708 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1709 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1710 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1711 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1712 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1713 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1714 * THE SOFTWARE.
1715 */
1716
1717Object.defineProperty(exports, "__esModule", { value: true });
1718exports.strings = exports.numbers = exports.cssClasses = void 0;
1719var cssClasses = {
1720 FIXED_CLASS: 'mdc-top-app-bar--fixed',
1721 FIXED_SCROLLED_CLASS: 'mdc-top-app-bar--fixed-scrolled',
1722 SHORT_CLASS: 'mdc-top-app-bar--short',
1723 SHORT_COLLAPSED_CLASS: 'mdc-top-app-bar--short-collapsed',
1724 SHORT_HAS_ACTION_ITEM_CLASS: 'mdc-top-app-bar--short-has-action-item'
1725};
1726exports.cssClasses = cssClasses;
1727var numbers = {
1728 DEBOUNCE_THROTTLE_RESIZE_TIME_MS: 100,
1729 MAX_TOP_APP_BAR_HEIGHT: 128
1730};
1731exports.numbers = numbers;
1732var strings = {
1733 ACTION_ITEM_SELECTOR: '.mdc-top-app-bar__action-item',
1734 NAVIGATION_EVENT: 'MDCTopAppBar:nav',
1735 NAVIGATION_ICON_SELECTOR: '.mdc-top-app-bar__navigation-icon',
1736 ROOT_SELECTOR: '.mdc-top-app-bar',
1737 TITLE_SELECTOR: '.mdc-top-app-bar__title'
1738};
1739exports.strings = strings;
1740
1741/***/ }),
1742
1743/***/ "./packages/mdc-top-app-bar/fixed/foundation.ts":
1744/*!******************************************************!*\
1745 !*** ./packages/mdc-top-app-bar/fixed/foundation.ts ***!
1746 \******************************************************/
1747/*! no static exports found */
1748/***/ (function(module, exports, __webpack_require__) {
1749
1750"use strict";
1751
1752/**
1753 * @license
1754 * Copyright 2018 Google Inc.
1755 *
1756 * Permission is hereby granted, free of charge, to any person obtaining a copy
1757 * of this software and associated documentation files (the "Software"), to deal
1758 * in the Software without restriction, including without limitation the rights
1759 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1760 * copies of the Software, and to permit persons to whom the Software is
1761 * furnished to do so, subject to the following conditions:
1762 *
1763 * The above copyright notice and this permission notice shall be included in
1764 * all copies or substantial portions of the Software.
1765 *
1766 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1767 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1768 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1769 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1770 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1771 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1772 * THE SOFTWARE.
1773 */
1774
1775var __extends = this && this.__extends || function () {
1776 var _extendStatics = function extendStatics(d, b) {
1777 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
1778 d.__proto__ = b;
1779 } || function (d, b) {
1780 for (var p in b) {
1781 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
1782 }
1783 };
1784 return _extendStatics(d, b);
1785 };
1786 return function (d, b) {
1787 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1788 _extendStatics(d, b);
1789 function __() {
1790 this.constructor = d;
1791 }
1792 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1793 };
1794}();
1795Object.defineProperty(exports, "__esModule", { value: true });
1796exports.MDCFixedTopAppBarFoundation = void 0;
1797var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-top-app-bar/constants.ts");
1798var foundation_1 = __webpack_require__(/*! ../standard/foundation */ "./packages/mdc-top-app-bar/standard/foundation.ts");
1799var MDCFixedTopAppBarFoundation = /** @class */function (_super) {
1800 __extends(MDCFixedTopAppBarFoundation, _super);
1801 function MDCFixedTopAppBarFoundation() {
1802 var _this = _super !== null && _super.apply(this, arguments) || this;
1803 /**
1804 * State variable for the previous scroll iteration top app bar state
1805 */
1806 _this.wasScrolled = false;
1807 return _this;
1808 }
1809 /**
1810 * Scroll handler for applying/removing the modifier class on the fixed top app bar.
1811 */
1812 MDCFixedTopAppBarFoundation.prototype.handleTargetScroll = function () {
1813 var currentScroll = this.adapter.getViewportScrollY();
1814 if (currentScroll <= 0) {
1815 if (this.wasScrolled) {
1816 this.adapter.removeClass(constants_1.cssClasses.FIXED_SCROLLED_CLASS);
1817 this.wasScrolled = false;
1818 }
1819 } else {
1820 if (!this.wasScrolled) {
1821 this.adapter.addClass(constants_1.cssClasses.FIXED_SCROLLED_CLASS);
1822 this.wasScrolled = true;
1823 }
1824 }
1825 };
1826 return MDCFixedTopAppBarFoundation;
1827}(foundation_1.MDCTopAppBarFoundation);
1828exports.MDCFixedTopAppBarFoundation = MDCFixedTopAppBarFoundation;
1829// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
1830exports.default = MDCFixedTopAppBarFoundation;
1831
1832/***/ }),
1833
1834/***/ "./packages/mdc-top-app-bar/foundation.ts":
1835/*!************************************************!*\
1836 !*** ./packages/mdc-top-app-bar/foundation.ts ***!
1837 \************************************************/
1838/*! no static exports found */
1839/***/ (function(module, exports, __webpack_require__) {
1840
1841"use strict";
1842
1843/**
1844 * @license
1845 * Copyright 2018 Google Inc.
1846 *
1847 * Permission is hereby granted, free of charge, to any person obtaining a copy
1848 * of this software and associated documentation files (the "Software"), to deal
1849 * in the Software without restriction, including without limitation the rights
1850 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1851 * copies of the Software, and to permit persons to whom the Software is
1852 * furnished to do so, subject to the following conditions:
1853 *
1854 * The above copyright notice and this permission notice shall be included in
1855 * all copies or substantial portions of the Software.
1856 *
1857 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1858 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1859 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1860 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1861 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1862 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1863 * THE SOFTWARE.
1864 */
1865
1866var __extends = this && this.__extends || function () {
1867 var _extendStatics = function extendStatics(d, b) {
1868 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
1869 d.__proto__ = b;
1870 } || function (d, b) {
1871 for (var p in b) {
1872 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
1873 }
1874 };
1875 return _extendStatics(d, b);
1876 };
1877 return function (d, b) {
1878 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1879 _extendStatics(d, b);
1880 function __() {
1881 this.constructor = d;
1882 }
1883 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1884 };
1885}();
1886var __assign = this && this.__assign || function () {
1887 __assign = Object.assign || function (t) {
1888 for (var s, i = 1, n = arguments.length; i < n; i++) {
1889 s = arguments[i];
1890 for (var p in s) {
1891 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1892 }
1893 }
1894 return t;
1895 };
1896 return __assign.apply(this, arguments);
1897};
1898Object.defineProperty(exports, "__esModule", { value: true });
1899exports.MDCTopAppBarBaseFoundation = void 0;
1900var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
1901var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-top-app-bar/constants.ts");
1902var MDCTopAppBarBaseFoundation = /** @class */function (_super) {
1903 __extends(MDCTopAppBarBaseFoundation, _super);
1904 /* istanbul ignore next: optional argument is not a branch statement */
1905 function MDCTopAppBarBaseFoundation(adapter) {
1906 return _super.call(this, __assign(__assign({}, MDCTopAppBarBaseFoundation.defaultAdapter), adapter)) || this;
1907 }
1908 Object.defineProperty(MDCTopAppBarBaseFoundation, "strings", {
1909 get: function get() {
1910 return constants_1.strings;
1911 },
1912 enumerable: false,
1913 configurable: true
1914 });
1915 Object.defineProperty(MDCTopAppBarBaseFoundation, "cssClasses", {
1916 get: function get() {
1917 return constants_1.cssClasses;
1918 },
1919 enumerable: false,
1920 configurable: true
1921 });
1922 Object.defineProperty(MDCTopAppBarBaseFoundation, "numbers", {
1923 get: function get() {
1924 return constants_1.numbers;
1925 },
1926 enumerable: false,
1927 configurable: true
1928 });
1929 Object.defineProperty(MDCTopAppBarBaseFoundation, "defaultAdapter", {
1930 /**
1931 * See {@link MDCTopAppBarAdapter} for typing information on parameters and return types.
1932 */
1933 get: function get() {
1934 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
1935 return {
1936 addClass: function addClass() {
1937 return undefined;
1938 },
1939 removeClass: function removeClass() {
1940 return undefined;
1941 },
1942 hasClass: function hasClass() {
1943 return false;
1944 },
1945 setStyle: function setStyle() {
1946 return undefined;
1947 },
1948 getTopAppBarHeight: function getTopAppBarHeight() {
1949 return 0;
1950 },
1951 notifyNavigationIconClicked: function notifyNavigationIconClicked() {
1952 return undefined;
1953 },
1954 getViewportScrollY: function getViewportScrollY() {
1955 return 0;
1956 },
1957 getTotalActionItems: function getTotalActionItems() {
1958 return 0;
1959 }
1960 };
1961 // tslint:enable:object-literal-sort-keys
1962 },
1963 enumerable: false,
1964 configurable: true
1965 });
1966 /** Other variants of TopAppBar foundation overrides this method */
1967 MDCTopAppBarBaseFoundation.prototype.handleTargetScroll = function () {}; // tslint:disable-line:no-empty
1968 /** Other variants of TopAppBar foundation overrides this method */
1969 MDCTopAppBarBaseFoundation.prototype.handleWindowResize = function () {}; // tslint:disable-line:no-empty
1970 MDCTopAppBarBaseFoundation.prototype.handleNavigationClick = function () {
1971 this.adapter.notifyNavigationIconClicked();
1972 };
1973 return MDCTopAppBarBaseFoundation;
1974}(foundation_1.MDCFoundation);
1975exports.MDCTopAppBarBaseFoundation = MDCTopAppBarBaseFoundation;
1976// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
1977exports.default = MDCTopAppBarBaseFoundation;
1978
1979/***/ }),
1980
1981/***/ "./packages/mdc-top-app-bar/index.ts":
1982/*!*******************************************!*\
1983 !*** ./packages/mdc-top-app-bar/index.ts ***!
1984 \*******************************************/
1985/*! no static exports found */
1986/***/ (function(module, exports, __webpack_require__) {
1987
1988"use strict";
1989
1990/**
1991 * @license
1992 * Copyright 2019 Google Inc.
1993 *
1994 * Permission is hereby granted, free of charge, to any person obtaining a copy
1995 * of this software and associated documentation files (the "Software"), to deal
1996 * in the Software without restriction, including without limitation the rights
1997 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1998 * copies of the Software, and to permit persons to whom the Software is
1999 * furnished to do so, subject to the following conditions:
2000 *
2001 * The above copyright notice and this permission notice shall be included in
2002 * all copies or substantial portions of the Software.
2003 *
2004 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2005 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2006 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2007 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2008 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2009 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2010 * THE SOFTWARE.
2011 */
2012
2013var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
2014 if (k2 === undefined) k2 = k;
2015 Object.defineProperty(o, k2, { enumerable: true, get: function get() {
2016 return m[k];
2017 } });
2018} : function (o, m, k, k2) {
2019 if (k2 === undefined) k2 = k;
2020 o[k2] = m[k];
2021});
2022var __exportStar = this && this.__exportStar || function (m, exports) {
2023 for (var p in m) {
2024 if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2025 }
2026};
2027Object.defineProperty(exports, "__esModule", { value: true });
2028__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-top-app-bar/adapter.ts"), exports);
2029__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-top-app-bar/component.ts"), exports);
2030__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-top-app-bar/constants.ts"), exports);
2031__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-top-app-bar/foundation.ts"), exports);
2032__exportStar(__webpack_require__(/*! ./fixed/foundation */ "./packages/mdc-top-app-bar/fixed/foundation.ts"), exports);
2033__exportStar(__webpack_require__(/*! ./short/foundation */ "./packages/mdc-top-app-bar/short/foundation.ts"), exports);
2034__exportStar(__webpack_require__(/*! ./standard/foundation */ "./packages/mdc-top-app-bar/standard/foundation.ts"), exports);
2035
2036/***/ }),
2037
2038/***/ "./packages/mdc-top-app-bar/short/foundation.ts":
2039/*!******************************************************!*\
2040 !*** ./packages/mdc-top-app-bar/short/foundation.ts ***!
2041 \******************************************************/
2042/*! no static exports found */
2043/***/ (function(module, exports, __webpack_require__) {
2044
2045"use strict";
2046
2047/**
2048 * @license
2049 * Copyright 2018 Google Inc.
2050 *
2051 * Permission is hereby granted, free of charge, to any person obtaining a copy
2052 * of this software and associated documentation files (the "Software"), to deal
2053 * in the Software without restriction, including without limitation the rights
2054 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2055 * copies of the Software, and to permit persons to whom the Software is
2056 * furnished to do so, subject to the following conditions:
2057 *
2058 * The above copyright notice and this permission notice shall be included in
2059 * all copies or substantial portions of the Software.
2060 *
2061 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2062 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2063 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2064 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2065 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2066 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2067 * THE SOFTWARE.
2068 */
2069
2070var __extends = this && this.__extends || function () {
2071 var _extendStatics = function extendStatics(d, b) {
2072 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
2073 d.__proto__ = b;
2074 } || function (d, b) {
2075 for (var p in b) {
2076 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
2077 }
2078 };
2079 return _extendStatics(d, b);
2080 };
2081 return function (d, b) {
2082 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2083 _extendStatics(d, b);
2084 function __() {
2085 this.constructor = d;
2086 }
2087 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2088 };
2089}();
2090Object.defineProperty(exports, "__esModule", { value: true });
2091exports.MDCShortTopAppBarFoundation = void 0;
2092var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-top-app-bar/constants.ts");
2093var foundation_1 = __webpack_require__(/*! ../foundation */ "./packages/mdc-top-app-bar/foundation.ts");
2094var MDCShortTopAppBarFoundation = /** @class */function (_super) {
2095 __extends(MDCShortTopAppBarFoundation, _super);
2096 /* istanbul ignore next: optional argument is not a branch statement */
2097 function MDCShortTopAppBarFoundation(adapter) {
2098 var _this = _super.call(this, adapter) || this;
2099 _this.collapsed = false;
2100 _this.isAlwaysCollapsed = false;
2101 return _this;
2102 }
2103 Object.defineProperty(MDCShortTopAppBarFoundation.prototype, "isCollapsed", {
2104 // Public visibility for backward compatibility.
2105 get: function get() {
2106 return this.collapsed;
2107 },
2108 enumerable: false,
2109 configurable: true
2110 });
2111 MDCShortTopAppBarFoundation.prototype.init = function () {
2112 _super.prototype.init.call(this);
2113 if (this.adapter.getTotalActionItems() > 0) {
2114 this.adapter.addClass(constants_1.cssClasses.SHORT_HAS_ACTION_ITEM_CLASS);
2115 }
2116 // If initialized with SHORT_COLLAPSED_CLASS, the bar should always be collapsed
2117 this.setAlwaysCollapsed(this.adapter.hasClass(constants_1.cssClasses.SHORT_COLLAPSED_CLASS));
2118 };
2119 /**
2120 * Set if the short top app bar should always be collapsed.
2121 *
2122 * @param value When `true`, bar will always be collapsed. When `false`, bar may collapse or expand based on scroll.
2123 */
2124 MDCShortTopAppBarFoundation.prototype.setAlwaysCollapsed = function (value) {
2125 this.isAlwaysCollapsed = !!value;
2126 if (this.isAlwaysCollapsed) {
2127 this.collapse();
2128 } else {
2129 // let maybeCollapseBar determine if the bar should be collapsed
2130 this.maybeCollapseBar();
2131 }
2132 };
2133 MDCShortTopAppBarFoundation.prototype.getAlwaysCollapsed = function () {
2134 return this.isAlwaysCollapsed;
2135 };
2136 /**
2137 * Scroll handler for applying/removing the collapsed modifier class on the short top app bar.
2138 */
2139 MDCShortTopAppBarFoundation.prototype.handleTargetScroll = function () {
2140 this.maybeCollapseBar();
2141 };
2142 MDCShortTopAppBarFoundation.prototype.maybeCollapseBar = function () {
2143 if (this.isAlwaysCollapsed) {
2144 return;
2145 }
2146 var currentScroll = this.adapter.getViewportScrollY();
2147 if (currentScroll <= 0) {
2148 if (this.collapsed) {
2149 this.uncollapse();
2150 }
2151 } else {
2152 if (!this.collapsed) {
2153 this.collapse();
2154 }
2155 }
2156 };
2157 MDCShortTopAppBarFoundation.prototype.uncollapse = function () {
2158 this.adapter.removeClass(constants_1.cssClasses.SHORT_COLLAPSED_CLASS);
2159 this.collapsed = false;
2160 };
2161 MDCShortTopAppBarFoundation.prototype.collapse = function () {
2162 this.adapter.addClass(constants_1.cssClasses.SHORT_COLLAPSED_CLASS);
2163 this.collapsed = true;
2164 };
2165 return MDCShortTopAppBarFoundation;
2166}(foundation_1.MDCTopAppBarBaseFoundation);
2167exports.MDCShortTopAppBarFoundation = MDCShortTopAppBarFoundation;
2168// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
2169exports.default = MDCShortTopAppBarFoundation;
2170
2171/***/ }),
2172
2173/***/ "./packages/mdc-top-app-bar/standard/foundation.ts":
2174/*!*********************************************************!*\
2175 !*** ./packages/mdc-top-app-bar/standard/foundation.ts ***!
2176 \*********************************************************/
2177/*! no static exports found */
2178/***/ (function(module, exports, __webpack_require__) {
2179
2180"use strict";
2181
2182/**
2183 * @license
2184 * Copyright 2018 Google Inc.
2185 *
2186 * Permission is hereby granted, free of charge, to any person obtaining a copy
2187 * of this software and associated documentation files (the "Software"), to deal
2188 * in the Software without restriction, including without limitation the rights
2189 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2190 * copies of the Software, and to permit persons to whom the Software is
2191 * furnished to do so, subject to the following conditions:
2192 *
2193 * The above copyright notice and this permission notice shall be included in
2194 * all copies or substantial portions of the Software.
2195 *
2196 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2197 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2198 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2199 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2200 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2201 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2202 * THE SOFTWARE.
2203 */
2204
2205var __extends = this && this.__extends || function () {
2206 var _extendStatics = function extendStatics(d, b) {
2207 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
2208 d.__proto__ = b;
2209 } || function (d, b) {
2210 for (var p in b) {
2211 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
2212 }
2213 };
2214 return _extendStatics(d, b);
2215 };
2216 return function (d, b) {
2217 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2218 _extendStatics(d, b);
2219 function __() {
2220 this.constructor = d;
2221 }
2222 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2223 };
2224}();
2225Object.defineProperty(exports, "__esModule", { value: true });
2226exports.MDCTopAppBarFoundation = void 0;
2227var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-top-app-bar/constants.ts");
2228var foundation_1 = __webpack_require__(/*! ../foundation */ "./packages/mdc-top-app-bar/foundation.ts");
2229var INITIAL_VALUE = 0;
2230var MDCTopAppBarFoundation = /** @class */function (_super) {
2231 __extends(MDCTopAppBarFoundation, _super);
2232 /* istanbul ignore next: optional argument is not a branch statement */
2233 function MDCTopAppBarFoundation(adapter) {
2234 var _this = _super.call(this, adapter) || this;
2235 /**
2236 * Indicates if the top app bar was docked in the previous scroll handler iteration.
2237 */
2238 _this.wasDocked = true;
2239 /**
2240 * Indicates if the top app bar is docked in the fully shown position.
2241 */
2242 _this.isDockedShowing = true;
2243 /**
2244 * Variable for current scroll position of the top app bar
2245 */
2246 _this.currentAppBarOffsetTop = 0;
2247 /**
2248 * Used to prevent the top app bar from being scrolled out of view during resize events
2249 */
2250 _this.isCurrentlyBeingResized = false;
2251 /**
2252 * The timeout that's used to throttle the resize events
2253 */
2254 _this.resizeThrottleId = INITIAL_VALUE;
2255 /**
2256 * The timeout that's used to debounce toggling the isCurrentlyBeingResized
2257 * variable after a resize
2258 */
2259 _this.resizeDebounceId = INITIAL_VALUE;
2260 _this.lastScrollPosition = _this.adapter.getViewportScrollY();
2261 _this.topAppBarHeight = _this.adapter.getTopAppBarHeight();
2262 return _this;
2263 }
2264 MDCTopAppBarFoundation.prototype.destroy = function () {
2265 _super.prototype.destroy.call(this);
2266 this.adapter.setStyle('top', '');
2267 };
2268 /**
2269 * Scroll handler for the default scroll behavior of the top app bar.
2270 */
2271 MDCTopAppBarFoundation.prototype.handleTargetScroll = function () {
2272 var currentScrollPosition = Math.max(this.adapter.getViewportScrollY(), 0);
2273 var diff = currentScrollPosition - this.lastScrollPosition;
2274 this.lastScrollPosition = currentScrollPosition;
2275 // If the window is being resized the lastScrollPosition needs to be updated
2276 // but the current scroll of the top app bar should stay in the same
2277 // position.
2278 if (!this.isCurrentlyBeingResized) {
2279 this.currentAppBarOffsetTop -= diff;
2280 if (this.currentAppBarOffsetTop > 0) {
2281 this.currentAppBarOffsetTop = 0;
2282 } else if (Math.abs(this.currentAppBarOffsetTop) > this.topAppBarHeight) {
2283 this.currentAppBarOffsetTop = -this.topAppBarHeight;
2284 }
2285 this.moveTopAppBar();
2286 }
2287 };
2288 /**
2289 * Top app bar resize handler that throttle/debounce functions that execute updates.
2290 */
2291 MDCTopAppBarFoundation.prototype.handleWindowResize = function () {
2292 var _this = this;
2293 // Throttle resize events 10 p/s
2294 if (!this.resizeThrottleId) {
2295 this.resizeThrottleId = setTimeout(function () {
2296 _this.resizeThrottleId = INITIAL_VALUE;
2297 _this.throttledResizeHandler();
2298 }, constants_1.numbers.DEBOUNCE_THROTTLE_RESIZE_TIME_MS);
2299 }
2300 this.isCurrentlyBeingResized = true;
2301 if (this.resizeDebounceId) {
2302 clearTimeout(this.resizeDebounceId);
2303 }
2304 this.resizeDebounceId = setTimeout(function () {
2305 _this.handleTargetScroll();
2306 _this.isCurrentlyBeingResized = false;
2307 _this.resizeDebounceId = INITIAL_VALUE;
2308 }, constants_1.numbers.DEBOUNCE_THROTTLE_RESIZE_TIME_MS);
2309 };
2310 /**
2311 * Function to determine if the DOM needs to update.
2312 */
2313 MDCTopAppBarFoundation.prototype.checkForUpdate = function () {
2314 var offscreenBoundaryTop = -this.topAppBarHeight;
2315 var hasAnyPixelsOffscreen = this.currentAppBarOffsetTop < 0;
2316 var hasAnyPixelsOnscreen = this.currentAppBarOffsetTop > offscreenBoundaryTop;
2317 var partiallyShowing = hasAnyPixelsOffscreen && hasAnyPixelsOnscreen;
2318 // If it's partially showing, it can't be docked.
2319 if (partiallyShowing) {
2320 this.wasDocked = false;
2321 } else {
2322 // Not previously docked and not partially showing, it's now docked.
2323 if (!this.wasDocked) {
2324 this.wasDocked = true;
2325 return true;
2326 } else if (this.isDockedShowing !== hasAnyPixelsOnscreen) {
2327 this.isDockedShowing = hasAnyPixelsOnscreen;
2328 return true;
2329 }
2330 }
2331 return partiallyShowing;
2332 };
2333 /**
2334 * Function to move the top app bar if needed.
2335 */
2336 MDCTopAppBarFoundation.prototype.moveTopAppBar = function () {
2337 if (this.checkForUpdate()) {
2338 // Once the top app bar is fully hidden we use the max potential top app bar height as our offset
2339 // so the top app bar doesn't show if the window resizes and the new height > the old height.
2340 var offset = this.currentAppBarOffsetTop;
2341 if (Math.abs(offset) >= this.topAppBarHeight) {
2342 offset = -constants_1.numbers.MAX_TOP_APP_BAR_HEIGHT;
2343 }
2344 this.adapter.setStyle('top', offset + 'px');
2345 }
2346 };
2347 /**
2348 * Throttled function that updates the top app bar scrolled values if the
2349 * top app bar height changes.
2350 */
2351 MDCTopAppBarFoundation.prototype.throttledResizeHandler = function () {
2352 var currentHeight = this.adapter.getTopAppBarHeight();
2353 if (this.topAppBarHeight !== currentHeight) {
2354 this.wasDocked = false;
2355 // Since the top app bar has a different height depending on the screen width, this
2356 // will ensure that the top app bar remains in the correct location if
2357 // completely hidden and a resize makes the top app bar a different height.
2358 this.currentAppBarOffsetTop -= this.topAppBarHeight - currentHeight;
2359 this.topAppBarHeight = currentHeight;
2360 }
2361 this.handleTargetScroll();
2362 };
2363 return MDCTopAppBarFoundation;
2364}(foundation_1.MDCTopAppBarBaseFoundation);
2365exports.MDCTopAppBarFoundation = MDCTopAppBarFoundation;
2366// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
2367exports.default = MDCTopAppBarFoundation;
2368
2369/***/ })
2370
2371/******/ });
2372});
2373//# sourceMappingURL=mdc.topAppBar.js.map
\No newline at end of file