UNPKG

53.4 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/snackbar", [], factory);
13 else if(typeof exports === 'object')
14 exports["snackbar"] = factory();
15 else
16 root["mdc"] = root["mdc"] || {}, root["mdc"]["snackbar"] = 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-snackbar/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/ponyfill.ts":
342/*!**************************************!*\
343 !*** ./packages/mdc-dom/ponyfill.ts ***!
344 \**************************************/
345/*! no static exports found */
346/***/ (function(module, exports, __webpack_require__) {
347
348"use strict";
349
350/**
351 * @license
352 * Copyright 2018 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.estimateScrollWidth = exports.matches = exports.closest = void 0;
375/**
376 * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global prototype chain.
377 * This makes ponyfills safer than traditional polyfills, especially for libraries like MDC.
378 */
379function closest(element, selector) {
380 if (element.closest) {
381 return element.closest(selector);
382 }
383 var el = element;
384 while (el) {
385 if (matches(el, selector)) {
386 return el;
387 }
388 el = el.parentElement;
389 }
390 return null;
391}
392exports.closest = closest;
393function matches(element, selector) {
394 var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
395 return nativeMatches.call(element, selector);
396}
397exports.matches = matches;
398/**
399 * Used to compute the estimated scroll width of elements. When an element is
400 * hidden due to display: none; being applied to a parent element, the width is
401 * returned as 0. However, the element will have a true width once no longer
402 * inside a display: none context. This method computes an estimated width when
403 * the element is hidden or returns the true width when the element is visble.
404 * @param {Element} element the element whose width to estimate
405 */
406function estimateScrollWidth(element) {
407 // Check the offsetParent. If the element inherits display: none from any
408 // parent, the offsetParent property will be null (see
409 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent).
410 // This check ensures we only clone the node when necessary.
411 var htmlEl = element;
412 if (htmlEl.offsetParent !== null) {
413 return htmlEl.scrollWidth;
414 }
415 var clone = htmlEl.cloneNode(true);
416 clone.style.setProperty('position', 'absolute');
417 clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
418 document.documentElement.appendChild(clone);
419 var scrollWidth = clone.scrollWidth;
420 document.documentElement.removeChild(clone);
421 return scrollWidth;
422}
423exports.estimateScrollWidth = estimateScrollWidth;
424
425/***/ }),
426
427/***/ "./packages/mdc-snackbar/adapter.ts":
428/*!******************************************!*\
429 !*** ./packages/mdc-snackbar/adapter.ts ***!
430 \******************************************/
431/*! no static exports found */
432/***/ (function(module, exports, __webpack_require__) {
433
434"use strict";
435
436/**
437 * @license
438 * Copyright 2018 Google Inc.
439 *
440 * Permission is hereby granted, free of charge, to any person obtaining a copy
441 * of this software and associated documentation files (the "Software"), to deal
442 * in the Software without restriction, including without limitation the rights
443 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
444 * copies of the Software, and to permit persons to whom the Software is
445 * furnished to do so, subject to the following conditions:
446 *
447 * The above copyright notice and this permission notice shall be included in
448 * all copies or substantial portions of the Software.
449 *
450 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
451 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
452 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
453 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
454 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
455 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
456 * THE SOFTWARE.
457 */
458
459Object.defineProperty(exports, "__esModule", { value: true });
460
461/***/ }),
462
463/***/ "./packages/mdc-snackbar/component.ts":
464/*!********************************************!*\
465 !*** ./packages/mdc-snackbar/component.ts ***!
466 \********************************************/
467/*! no static exports found */
468/***/ (function(module, exports, __webpack_require__) {
469
470"use strict";
471
472/**
473 * @license
474 * Copyright 2018 Google Inc.
475 *
476 * Permission is hereby granted, free of charge, to any person obtaining a copy
477 * of this software and associated documentation files (the "Software"), to deal
478 * in the Software without restriction, including without limitation the rights
479 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
480 * copies of the Software, and to permit persons to whom the Software is
481 * furnished to do so, subject to the following conditions:
482 *
483 * The above copyright notice and this permission notice shall be included in
484 * all copies or substantial portions of the Software.
485 *
486 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
487 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
488 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
489 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
490 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
491 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
492 * THE SOFTWARE.
493 */
494
495var __extends = this && this.__extends || function () {
496 var _extendStatics = function extendStatics(d, b) {
497 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
498 d.__proto__ = b;
499 } || function (d, b) {
500 for (var p in b) {
501 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
502 }
503 };
504 return _extendStatics(d, b);
505 };
506 return function (d, b) {
507 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
508 _extendStatics(d, b);
509 function __() {
510 this.constructor = d;
511 }
512 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
513 };
514}();
515var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
516 if (k2 === undefined) k2 = k;
517 Object.defineProperty(o, k2, { enumerable: true, get: function get() {
518 return m[k];
519 } });
520} : function (o, m, k, k2) {
521 if (k2 === undefined) k2 = k;
522 o[k2] = m[k];
523});
524var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
525 Object.defineProperty(o, "default", { enumerable: true, value: v });
526} : function (o, v) {
527 o["default"] = v;
528});
529var __importStar = this && this.__importStar || function (mod) {
530 if (mod && mod.__esModule) return mod;
531 var result = {};
532 if (mod != null) for (var k in mod) {
533 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
534 }__setModuleDefault(result, mod);
535 return result;
536};
537Object.defineProperty(exports, "__esModule", { value: true });
538exports.MDCSnackbar = void 0;
539var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
540var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
541var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
542var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-snackbar/foundation.ts");
543var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-snackbar/util.ts"));
544var SURFACE_SELECTOR = constants_1.strings.SURFACE_SELECTOR,
545 LABEL_SELECTOR = constants_1.strings.LABEL_SELECTOR,
546 ACTION_SELECTOR = constants_1.strings.ACTION_SELECTOR,
547 DISMISS_SELECTOR = constants_1.strings.DISMISS_SELECTOR,
548 OPENING_EVENT = constants_1.strings.OPENING_EVENT,
549 OPENED_EVENT = constants_1.strings.OPENED_EVENT,
550 CLOSING_EVENT = constants_1.strings.CLOSING_EVENT,
551 CLOSED_EVENT = constants_1.strings.CLOSED_EVENT;
552var MDCSnackbar = /** @class */function (_super) {
553 __extends(MDCSnackbar, _super);
554 function MDCSnackbar() {
555 return _super !== null && _super.apply(this, arguments) || this;
556 }
557 MDCSnackbar.attachTo = function (root) {
558 return new MDCSnackbar(root);
559 };
560 MDCSnackbar.prototype.initialize = function (announcerFactory) {
561 if (announcerFactory === void 0) {
562 announcerFactory = function announcerFactory() {
563 return util.announce;
564 };
565 }
566 this.announce = announcerFactory();
567 };
568 MDCSnackbar.prototype.initialSyncWithDOM = function () {
569 var _this = this;
570 this.surfaceEl = this.root.querySelector(SURFACE_SELECTOR);
571 this.labelEl = this.root.querySelector(LABEL_SELECTOR);
572 this.actionEl = this.root.querySelector(ACTION_SELECTOR);
573 this.handleKeyDown = function (evt) {
574 _this.foundation.handleKeyDown(evt);
575 };
576 this.handleSurfaceClick = function (evt) {
577 var target = evt.target;
578 if (_this.isActionButton(target)) {
579 _this.foundation.handleActionButtonClick(evt);
580 } else if (_this.isActionIcon(target)) {
581 _this.foundation.handleActionIconClick(evt);
582 }
583 };
584 this.registerKeyDownHandler(this.handleKeyDown);
585 this.registerSurfaceClickHandler(this.handleSurfaceClick);
586 };
587 MDCSnackbar.prototype.destroy = function () {
588 _super.prototype.destroy.call(this);
589 this.deregisterKeyDownHandler(this.handleKeyDown);
590 this.deregisterSurfaceClickHandler(this.handleSurfaceClick);
591 };
592 MDCSnackbar.prototype.open = function () {
593 this.foundation.open();
594 };
595 /**
596 * @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the
597 * `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom
598 * client-specific values may also be used if desired.
599 */
600 MDCSnackbar.prototype.close = function (reason) {
601 if (reason === void 0) {
602 reason = '';
603 }
604 this.foundation.close(reason);
605 };
606 MDCSnackbar.prototype.getDefaultFoundation = function () {
607 var _this = this;
608 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
609 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
610 var adapter = {
611 addClass: function addClass(className) {
612 _this.root.classList.add(className);
613 },
614 announce: function announce() {
615 _this.announce(_this.labelEl);
616 },
617 notifyClosed: function notifyClosed(reason) {
618 return _this.emit(CLOSED_EVENT, reason ? { reason: reason } : {});
619 },
620 notifyClosing: function notifyClosing(reason) {
621 return _this.emit(CLOSING_EVENT, reason ? { reason: reason } : {});
622 },
623 notifyOpened: function notifyOpened() {
624 return _this.emit(OPENED_EVENT, {});
625 },
626 notifyOpening: function notifyOpening() {
627 return _this.emit(OPENING_EVENT, {});
628 },
629 removeClass: function removeClass(className) {
630 return _this.root.classList.remove(className);
631 }
632 };
633 return new foundation_1.MDCSnackbarFoundation(adapter);
634 };
635 Object.defineProperty(MDCSnackbar.prototype, "timeoutMs", {
636 get: function get() {
637 return this.foundation.getTimeoutMs();
638 },
639 set: function set(timeoutMs) {
640 this.foundation.setTimeoutMs(timeoutMs);
641 },
642 enumerable: false,
643 configurable: true
644 });
645 Object.defineProperty(MDCSnackbar.prototype, "closeOnEscape", {
646 get: function get() {
647 return this.foundation.getCloseOnEscape();
648 },
649 set: function set(closeOnEscape) {
650 this.foundation.setCloseOnEscape(closeOnEscape);
651 },
652 enumerable: false,
653 configurable: true
654 });
655 Object.defineProperty(MDCSnackbar.prototype, "isOpen", {
656 get: function get() {
657 return this.foundation.isOpen();
658 },
659 enumerable: false,
660 configurable: true
661 });
662 Object.defineProperty(MDCSnackbar.prototype, "labelText", {
663 get: function get() {
664 // This property only returns null if the node is a document, DOCTYPE,
665 // or notation. On Element nodes, it always returns a string.
666 return this.labelEl.textContent;
667 },
668 set: function set(labelText) {
669 this.labelEl.textContent = labelText;
670 },
671 enumerable: false,
672 configurable: true
673 });
674 Object.defineProperty(MDCSnackbar.prototype, "actionButtonText", {
675 get: function get() {
676 return this.actionEl.textContent;
677 },
678 set: function set(actionButtonText) {
679 this.actionEl.textContent = actionButtonText;
680 },
681 enumerable: false,
682 configurable: true
683 });
684 MDCSnackbar.prototype.registerKeyDownHandler = function (handler) {
685 this.listen('keydown', handler);
686 };
687 MDCSnackbar.prototype.deregisterKeyDownHandler = function (handler) {
688 this.unlisten('keydown', handler);
689 };
690 MDCSnackbar.prototype.registerSurfaceClickHandler = function (handler) {
691 this.surfaceEl.addEventListener('click', handler);
692 };
693 MDCSnackbar.prototype.deregisterSurfaceClickHandler = function (handler) {
694 this.surfaceEl.removeEventListener('click', handler);
695 };
696 MDCSnackbar.prototype.isActionButton = function (target) {
697 return Boolean(ponyfill_1.closest(target, ACTION_SELECTOR));
698 };
699 MDCSnackbar.prototype.isActionIcon = function (target) {
700 return Boolean(ponyfill_1.closest(target, DISMISS_SELECTOR));
701 };
702 return MDCSnackbar;
703}(component_1.MDCComponent);
704exports.MDCSnackbar = MDCSnackbar;
705
706/***/ }),
707
708/***/ "./packages/mdc-snackbar/constants.ts":
709/*!********************************************!*\
710 !*** ./packages/mdc-snackbar/constants.ts ***!
711 \********************************************/
712/*! no static exports found */
713/***/ (function(module, exports, __webpack_require__) {
714
715"use strict";
716
717/**
718 * @license
719 * Copyright 2018 Google Inc.
720 *
721 * Permission is hereby granted, free of charge, to any person obtaining a copy
722 * of this software and associated documentation files (the "Software"), to deal
723 * in the Software without restriction, including without limitation the rights
724 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
725 * copies of the Software, and to permit persons to whom the Software is
726 * furnished to do so, subject to the following conditions:
727 *
728 * The above copyright notice and this permission notice shall be included in
729 * all copies or substantial portions of the Software.
730 *
731 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
732 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
733 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
734 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
735 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
736 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
737 * THE SOFTWARE.
738 */
739
740Object.defineProperty(exports, "__esModule", { value: true });
741exports.numbers = exports.strings = exports.cssClasses = void 0;
742var cssClasses = {
743 CLOSING: 'mdc-snackbar--closing',
744 OPEN: 'mdc-snackbar--open',
745 OPENING: 'mdc-snackbar--opening'
746};
747exports.cssClasses = cssClasses;
748var strings = {
749 ACTION_SELECTOR: '.mdc-snackbar__action',
750 ARIA_LIVE_LABEL_TEXT_ATTR: 'data-mdc-snackbar-label-text',
751 CLOSED_EVENT: 'MDCSnackbar:closed',
752 CLOSING_EVENT: 'MDCSnackbar:closing',
753 DISMISS_SELECTOR: '.mdc-snackbar__dismiss',
754 LABEL_SELECTOR: '.mdc-snackbar__label',
755 OPENED_EVENT: 'MDCSnackbar:opened',
756 OPENING_EVENT: 'MDCSnackbar:opening',
757 REASON_ACTION: 'action',
758 REASON_DISMISS: 'dismiss',
759 SURFACE_SELECTOR: '.mdc-snackbar__surface'
760};
761exports.strings = strings;
762var numbers = {
763 DEFAULT_AUTO_DISMISS_TIMEOUT_MS: 5000,
764 INDETERMINATE: -1,
765 MAX_AUTO_DISMISS_TIMEOUT_MS: 10000,
766 MIN_AUTO_DISMISS_TIMEOUT_MS: 4000,
767 // These variables need to be kept in sync with the values in _variables.scss.
768 SNACKBAR_ANIMATION_CLOSE_TIME_MS: 75,
769 SNACKBAR_ANIMATION_OPEN_TIME_MS: 150,
770 /**
771 * Number of milliseconds to wait between temporarily clearing the label text
772 * in the DOM and subsequently restoring it. This is necessary to force IE 11
773 * to pick up the `aria-live` content change and announce it to the user.
774 */
775 ARIA_LIVE_DELAY_MS: 1000
776};
777exports.numbers = numbers;
778
779/***/ }),
780
781/***/ "./packages/mdc-snackbar/foundation.ts":
782/*!*********************************************!*\
783 !*** ./packages/mdc-snackbar/foundation.ts ***!
784 \*********************************************/
785/*! no static exports found */
786/***/ (function(module, exports, __webpack_require__) {
787
788"use strict";
789
790/**
791 * @license
792 * Copyright 2018 Google Inc.
793 *
794 * Permission is hereby granted, free of charge, to any person obtaining a copy
795 * of this software and associated documentation files (the "Software"), to deal
796 * in the Software without restriction, including without limitation the rights
797 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
798 * copies of the Software, and to permit persons to whom the Software is
799 * furnished to do so, subject to the following conditions:
800 *
801 * The above copyright notice and this permission notice shall be included in
802 * all copies or substantial portions of the Software.
803 *
804 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
805 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
806 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
807 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
808 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
809 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
810 * THE SOFTWARE.
811 */
812
813var __extends = this && this.__extends || function () {
814 var _extendStatics = function extendStatics(d, b) {
815 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
816 d.__proto__ = b;
817 } || function (d, b) {
818 for (var p in b) {
819 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
820 }
821 };
822 return _extendStatics(d, b);
823 };
824 return function (d, b) {
825 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
826 _extendStatics(d, b);
827 function __() {
828 this.constructor = d;
829 }
830 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
831 };
832}();
833var __assign = this && this.__assign || function () {
834 __assign = Object.assign || function (t) {
835 for (var s, i = 1, n = arguments.length; i < n; i++) {
836 s = arguments[i];
837 for (var p in s) {
838 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
839 }
840 }
841 return t;
842 };
843 return __assign.apply(this, arguments);
844};
845Object.defineProperty(exports, "__esModule", { value: true });
846exports.MDCSnackbarFoundation = void 0;
847var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
848var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
849var OPENING = constants_1.cssClasses.OPENING,
850 OPEN = constants_1.cssClasses.OPEN,
851 CLOSING = constants_1.cssClasses.CLOSING;
852var REASON_ACTION = constants_1.strings.REASON_ACTION,
853 REASON_DISMISS = constants_1.strings.REASON_DISMISS;
854var MDCSnackbarFoundation = /** @class */function (_super) {
855 __extends(MDCSnackbarFoundation, _super);
856 function MDCSnackbarFoundation(adapter) {
857 var _this = _super.call(this, __assign(__assign({}, MDCSnackbarFoundation.defaultAdapter), adapter)) || this;
858 _this.opened = false;
859 _this.animationFrame = 0;
860 _this.animationTimer = 0;
861 _this.autoDismissTimer = 0;
862 _this.autoDismissTimeoutMs = constants_1.numbers.DEFAULT_AUTO_DISMISS_TIMEOUT_MS;
863 _this.closeOnEscape = true;
864 return _this;
865 }
866 Object.defineProperty(MDCSnackbarFoundation, "cssClasses", {
867 get: function get() {
868 return constants_1.cssClasses;
869 },
870 enumerable: false,
871 configurable: true
872 });
873 Object.defineProperty(MDCSnackbarFoundation, "strings", {
874 get: function get() {
875 return constants_1.strings;
876 },
877 enumerable: false,
878 configurable: true
879 });
880 Object.defineProperty(MDCSnackbarFoundation, "numbers", {
881 get: function get() {
882 return constants_1.numbers;
883 },
884 enumerable: false,
885 configurable: true
886 });
887 Object.defineProperty(MDCSnackbarFoundation, "defaultAdapter", {
888 get: function get() {
889 return {
890 addClass: function addClass() {
891 return undefined;
892 },
893 announce: function announce() {
894 return undefined;
895 },
896 notifyClosed: function notifyClosed() {
897 return undefined;
898 },
899 notifyClosing: function notifyClosing() {
900 return undefined;
901 },
902 notifyOpened: function notifyOpened() {
903 return undefined;
904 },
905 notifyOpening: function notifyOpening() {
906 return undefined;
907 },
908 removeClass: function removeClass() {
909 return undefined;
910 }
911 };
912 },
913 enumerable: false,
914 configurable: true
915 });
916 MDCSnackbarFoundation.prototype.destroy = function () {
917 this.clearAutoDismissTimer();
918 cancelAnimationFrame(this.animationFrame);
919 this.animationFrame = 0;
920 clearTimeout(this.animationTimer);
921 this.animationTimer = 0;
922 this.adapter.removeClass(OPENING);
923 this.adapter.removeClass(OPEN);
924 this.adapter.removeClass(CLOSING);
925 };
926 MDCSnackbarFoundation.prototype.open = function () {
927 var _this = this;
928 this.clearAutoDismissTimer();
929 this.opened = true;
930 this.adapter.notifyOpening();
931 this.adapter.removeClass(CLOSING);
932 this.adapter.addClass(OPENING);
933 this.adapter.announce();
934 // Wait a frame once display is no longer "none", to establish basis for animation
935 this.runNextAnimationFrame(function () {
936 _this.adapter.addClass(OPEN);
937 _this.animationTimer = setTimeout(function () {
938 var timeoutMs = _this.getTimeoutMs();
939 _this.handleAnimationTimerEnd();
940 _this.adapter.notifyOpened();
941 if (timeoutMs !== constants_1.numbers.INDETERMINATE) {
942 _this.autoDismissTimer = setTimeout(function () {
943 _this.close(REASON_DISMISS);
944 }, timeoutMs);
945 }
946 }, constants_1.numbers.SNACKBAR_ANIMATION_OPEN_TIME_MS);
947 });
948 };
949 /**
950 * @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the
951 * `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom
952 * client-specific values may also be used if desired.
953 */
954 MDCSnackbarFoundation.prototype.close = function (reason) {
955 var _this = this;
956 if (reason === void 0) {
957 reason = '';
958 }
959 if (!this.opened) {
960 // Avoid redundant close calls (and events), e.g. repeated interactions as the snackbar is animating closed
961 return;
962 }
963 cancelAnimationFrame(this.animationFrame);
964 this.animationFrame = 0;
965 this.clearAutoDismissTimer();
966 this.opened = false;
967 this.adapter.notifyClosing(reason);
968 this.adapter.addClass(constants_1.cssClasses.CLOSING);
969 this.adapter.removeClass(constants_1.cssClasses.OPEN);
970 this.adapter.removeClass(constants_1.cssClasses.OPENING);
971 clearTimeout(this.animationTimer);
972 this.animationTimer = setTimeout(function () {
973 _this.handleAnimationTimerEnd();
974 _this.adapter.notifyClosed(reason);
975 }, constants_1.numbers.SNACKBAR_ANIMATION_CLOSE_TIME_MS);
976 };
977 MDCSnackbarFoundation.prototype.isOpen = function () {
978 return this.opened;
979 };
980 MDCSnackbarFoundation.prototype.getTimeoutMs = function () {
981 return this.autoDismissTimeoutMs;
982 };
983 MDCSnackbarFoundation.prototype.setTimeoutMs = function (timeoutMs) {
984 // Use shorter variable names to make the code more readable
985 var minValue = constants_1.numbers.MIN_AUTO_DISMISS_TIMEOUT_MS;
986 var maxValue = constants_1.numbers.MAX_AUTO_DISMISS_TIMEOUT_MS;
987 var indeterminateValue = constants_1.numbers.INDETERMINATE;
988 if (timeoutMs === constants_1.numbers.INDETERMINATE || timeoutMs <= maxValue && timeoutMs >= minValue) {
989 this.autoDismissTimeoutMs = timeoutMs;
990 } else {
991 throw new Error("\n timeoutMs must be an integer in the range " + minValue + "\u2013" + maxValue + "\n (or " + indeterminateValue + " to disable), but got '" + timeoutMs + "'");
992 }
993 };
994 MDCSnackbarFoundation.prototype.getCloseOnEscape = function () {
995 return this.closeOnEscape;
996 };
997 MDCSnackbarFoundation.prototype.setCloseOnEscape = function (closeOnEscape) {
998 this.closeOnEscape = closeOnEscape;
999 };
1000 MDCSnackbarFoundation.prototype.handleKeyDown = function (evt) {
1001 var isEscapeKey = evt.key === 'Escape' || evt.keyCode === 27;
1002 if (isEscapeKey && this.getCloseOnEscape()) {
1003 this.close(REASON_DISMISS);
1004 }
1005 };
1006 MDCSnackbarFoundation.prototype.handleActionButtonClick = function (_evt) {
1007 this.close(REASON_ACTION);
1008 };
1009 MDCSnackbarFoundation.prototype.handleActionIconClick = function (_evt) {
1010 this.close(REASON_DISMISS);
1011 };
1012 MDCSnackbarFoundation.prototype.clearAutoDismissTimer = function () {
1013 clearTimeout(this.autoDismissTimer);
1014 this.autoDismissTimer = 0;
1015 };
1016 MDCSnackbarFoundation.prototype.handleAnimationTimerEnd = function () {
1017 this.animationTimer = 0;
1018 this.adapter.removeClass(constants_1.cssClasses.OPENING);
1019 this.adapter.removeClass(constants_1.cssClasses.CLOSING);
1020 };
1021 /**
1022 * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
1023 */
1024 MDCSnackbarFoundation.prototype.runNextAnimationFrame = function (callback) {
1025 var _this = this;
1026 cancelAnimationFrame(this.animationFrame);
1027 this.animationFrame = requestAnimationFrame(function () {
1028 _this.animationFrame = 0;
1029 clearTimeout(_this.animationTimer);
1030 _this.animationTimer = setTimeout(callback, 0);
1031 });
1032 };
1033 return MDCSnackbarFoundation;
1034}(foundation_1.MDCFoundation);
1035exports.MDCSnackbarFoundation = MDCSnackbarFoundation;
1036// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
1037exports.default = MDCSnackbarFoundation;
1038
1039/***/ }),
1040
1041/***/ "./packages/mdc-snackbar/index.ts":
1042/*!****************************************!*\
1043 !*** ./packages/mdc-snackbar/index.ts ***!
1044 \****************************************/
1045/*! no static exports found */
1046/***/ (function(module, exports, __webpack_require__) {
1047
1048"use strict";
1049
1050/**
1051 * @license
1052 * Copyright 2019 Google Inc.
1053 *
1054 * Permission is hereby granted, free of charge, to any person obtaining a copy
1055 * of this software and associated documentation files (the "Software"), to deal
1056 * in the Software without restriction, including without limitation the rights
1057 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1058 * copies of the Software, and to permit persons to whom the Software is
1059 * furnished to do so, subject to the following conditions:
1060 *
1061 * The above copyright notice and this permission notice shall be included in
1062 * all copies or substantial portions of the Software.
1063 *
1064 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1065 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1066 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1067 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1068 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1069 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1070 * THE SOFTWARE.
1071 */
1072
1073var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
1074 if (k2 === undefined) k2 = k;
1075 Object.defineProperty(o, k2, { enumerable: true, get: function get() {
1076 return m[k];
1077 } });
1078} : function (o, m, k, k2) {
1079 if (k2 === undefined) k2 = k;
1080 o[k2] = m[k];
1081});
1082var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
1083 Object.defineProperty(o, "default", { enumerable: true, value: v });
1084} : function (o, v) {
1085 o["default"] = v;
1086});
1087var __importStar = this && this.__importStar || function (mod) {
1088 if (mod && mod.__esModule) return mod;
1089 var result = {};
1090 if (mod != null) for (var k in mod) {
1091 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1092 }__setModuleDefault(result, mod);
1093 return result;
1094};
1095var __exportStar = this && this.__exportStar || function (m, exports) {
1096 for (var p in m) {
1097 if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1098 }
1099};
1100Object.defineProperty(exports, "__esModule", { value: true });
1101exports.util = void 0;
1102var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-snackbar/util.ts"));
1103exports.util = util;
1104__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-snackbar/adapter.ts"), exports);
1105__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-snackbar/component.ts"), exports);
1106__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts"), exports);
1107__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-snackbar/foundation.ts"), exports);
1108__exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-snackbar/types.ts"), exports);
1109
1110/***/ }),
1111
1112/***/ "./packages/mdc-snackbar/types.ts":
1113/*!****************************************!*\
1114 !*** ./packages/mdc-snackbar/types.ts ***!
1115 \****************************************/
1116/*! no static exports found */
1117/***/ (function(module, exports, __webpack_require__) {
1118
1119"use strict";
1120
1121/**
1122 * @license
1123 * Copyright 2019 Google Inc.
1124 *
1125 * Permission is hereby granted, free of charge, to any person obtaining a copy
1126 * of this software and associated documentation files (the "Software"), to deal
1127 * in the Software without restriction, including without limitation the rights
1128 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1129 * copies of the Software, and to permit persons to whom the Software is
1130 * furnished to do so, subject to the following conditions:
1131 *
1132 * The above copyright notice and this permission notice shall be included in
1133 * all copies or substantial portions of the Software.
1134 *
1135 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1136 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1137 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1138 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1139 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1140 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1141 * THE SOFTWARE.
1142 */
1143
1144Object.defineProperty(exports, "__esModule", { value: true });
1145
1146/***/ }),
1147
1148/***/ "./packages/mdc-snackbar/util.ts":
1149/*!***************************************!*\
1150 !*** ./packages/mdc-snackbar/util.ts ***!
1151 \***************************************/
1152/*! no static exports found */
1153/***/ (function(module, exports, __webpack_require__) {
1154
1155"use strict";
1156
1157/**
1158 * @license
1159 * Copyright 2018 Google Inc.
1160 *
1161 * Permission is hereby granted, free of charge, to any person obtaining a copy
1162 * of this software and associated documentation files (the "Software"), to deal
1163 * in the Software without restriction, including without limitation the rights
1164 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1165 * copies of the Software, and to permit persons to whom the Software is
1166 * furnished to do so, subject to the following conditions:
1167 *
1168 * The above copyright notice and this permission notice shall be included in
1169 * all copies or substantial portions of the Software.
1170 *
1171 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1172 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1173 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1174 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1175 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1176 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1177 * THE SOFTWARE.
1178 */
1179
1180Object.defineProperty(exports, "__esModule", { value: true });
1181exports.announce = void 0;
1182var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
1183var ARIA_LIVE_DELAY_MS = constants_1.numbers.ARIA_LIVE_DELAY_MS;
1184var ARIA_LIVE_LABEL_TEXT_ATTR = constants_1.strings.ARIA_LIVE_LABEL_TEXT_ATTR;
1185function announce(ariaEl, labelEl) {
1186 if (labelEl === void 0) {
1187 labelEl = ariaEl;
1188 }
1189 var priority = ariaEl.getAttribute('aria-live');
1190 // Trim text to ignore `&nbsp;` (see below).
1191 // textContent is only null if the node is a document, DOCTYPE, or notation.
1192 var labelText = labelEl.textContent.trim();
1193 if (!labelText || !priority) {
1194 return;
1195 }
1196 // Temporarily disable `aria-live` to prevent JAWS+Firefox from announcing the message twice.
1197 ariaEl.setAttribute('aria-live', 'off');
1198 // Temporarily clear `textContent` to force a DOM mutation event that will be detected by screen readers.
1199 // `aria-live` elements are only announced when the element's `textContent` *changes*, so snackbars
1200 // sent to the browser in the initial HTML response won't be read unless we clear the element's `textContent` first.
1201 // Similarly, displaying the same snackbar message twice in a row doesn't trigger a DOM mutation event,
1202 // so screen readers won't announce the second message unless we first clear `textContent`.
1203 //
1204 // We have to clear the label text two different ways to make it work in all browsers and screen readers:
1205 //
1206 // 1. `textContent = ''` is required for IE11 + JAWS
1207 // 2. `innerHTML = '&nbsp;'` is required for Chrome + JAWS and NVDA
1208 //
1209 // All other browser/screen reader combinations support both methods.
1210 //
1211 // The wrapper `<span>` visually hides the space character so that it doesn't cause jank when added/removed.
1212 // N.B.: Setting `position: absolute`, `opacity: 0`, or `height: 0` prevents Chrome from detecting the DOM change.
1213 //
1214 // This technique has been tested in:
1215 //
1216 // * JAWS 2019:
1217 // - Chrome 70
1218 // - Firefox 60 (ESR)
1219 // - IE 11
1220 // * NVDA 2018:
1221 // - Chrome 70
1222 // - Firefox 60 (ESR)
1223 // - IE 11
1224 // * ChromeVox 53
1225 labelEl.textContent = '';
1226 labelEl.innerHTML = '<span style="display: inline-block; width: 0; height: 1px;">&nbsp;</span>';
1227 // Prevent visual jank by temporarily displaying the label text in the ::before pseudo-element.
1228 // CSS generated content is normally announced by screen readers
1229 // (except in IE 11; see https://tink.uk/accessibility-support-for-css-generated-content/);
1230 // however, `aria-live` is turned off, so this DOM update will be ignored by screen readers.
1231 labelEl.setAttribute(ARIA_LIVE_LABEL_TEXT_ATTR, labelText);
1232 setTimeout(function () {
1233 // Allow screen readers to announce changes to the DOM again.
1234 ariaEl.setAttribute('aria-live', priority);
1235 // Remove the message from the ::before pseudo-element.
1236 labelEl.removeAttribute(ARIA_LIVE_LABEL_TEXT_ATTR);
1237 // Restore the original label text, which will be announced by screen readers.
1238 labelEl.textContent = labelText;
1239 }, ARIA_LIVE_DELAY_MS);
1240}
1241exports.announce = announce;
1242
1243/***/ })
1244
1245/******/ });
1246});
1247//# sourceMappingURL=mdc.snackbar.js.map
\No newline at end of file