/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/material-components/material-components-web/blob/master/LICENSE */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["dom"] = factory(); else root["mdc"] = root["mdc"] || {}, root["mdc"]["dom"] = factory(); })(this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "./packages/mdc-dom/index.ts"); /******/ }) /************************************************************************/ /******/ ({ /***/ "./packages/mdc-dom/events.ts": /*!************************************!*\ !*** ./packages/mdc-dom/events.ts ***! \************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * @license * Copyright 2019 Google Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ Object.defineProperty(exports, "__esModule", { value: true }); /** * Determine whether the current browser supports passive event listeners, and * if so, use them. */ function applyPassive(globalObj) { if (globalObj === void 0) { globalObj = window; } return supportsPassiveOption(globalObj) ? { passive: true } : false; } exports.applyPassive = applyPassive; function supportsPassiveOption(globalObj) { if (globalObj === void 0) { globalObj = window; } // See // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener var passiveSupported = false; try { var options = { // This function will be called when the browser // attempts to access the passive property. get passive() { passiveSupported = true; return false; } }; var handler = function handler() {}; globalObj.document.addEventListener('test', handler, options); globalObj.document.removeEventListener('test', handler, options); } catch (err) { passiveSupported = false; } return passiveSupported; } /***/ }), /***/ "./packages/mdc-dom/focus-trap.ts": /*!****************************************!*\ !*** ./packages/mdc-dom/focus-trap.ts ***! \****************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * @license * Copyright 2020 Google Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ Object.defineProperty(exports, "__esModule", { value: true }); var FOCUS_SENTINEL_CLASS = 'mdc-dom-focus-sentinel'; /** * Utility to trap focus in a given root element, e.g. for modal components such * as dialogs. The root should have at least one focusable child element, * for setting initial focus when trapping focus. * Also tracks the previously focused element, and restores focus to that * element when releasing focus. */ var FocusTrap = /** @class */function () { function FocusTrap(root, options) { if (options === void 0) { options = {}; } this.root = root; this.options = options; // Previously focused element before trapping focus. this.elFocusedBeforeTrapFocus = null; } /** * Traps focus in `root`. Also focuses on either `initialFocusEl` if set; * otherwises sets initial focus to the first focusable child element. */ FocusTrap.prototype.trapFocus = function () { var focusableEls = this.getFocusableElements(this.root); if (focusableEls.length === 0) { throw new Error('FocusTrap: Element must have at least one focusable child.'); } this.elFocusedBeforeTrapFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null; this.wrapTabFocus(this.root, focusableEls); if (!this.options.skipInitialFocus) { this.focusInitialElement(focusableEls, this.options.initialFocusEl); } }; /** * Releases focus from `root`. Also restores focus to the previously focused * element. */ FocusTrap.prototype.releaseFocus = function () { [].slice.call(this.root.querySelectorAll("." + FOCUS_SENTINEL_CLASS)).forEach(function (sentinelEl) { sentinelEl.parentElement.removeChild(sentinelEl); }); if (this.elFocusedBeforeTrapFocus) { this.elFocusedBeforeTrapFocus.focus(); } }; /** * Wraps tab focus within `el` by adding two hidden sentinel divs which are * used to mark the beginning and the end of the tabbable region. When * focused, these sentinel elements redirect focus to the first/last * children elements of the tabbable region, ensuring that focus is trapped * within that region. */ FocusTrap.prototype.wrapTabFocus = function (el, focusableEls) { var sentinelStart = this.createSentinel(); var sentinelEnd = this.createSentinel(); sentinelStart.addEventListener('focus', function () { if (focusableEls.length > 0) { focusableEls[focusableEls.length - 1].focus(); } }); sentinelEnd.addEventListener('focus', function () { if (focusableEls.length > 0) { focusableEls[0].focus(); } }); el.insertBefore(sentinelStart, el.children[0]); el.appendChild(sentinelEnd); }; /** * Focuses on `initialFocusEl` if defined and a child of the root element. * Otherwise, focuses on the first focusable child element of the root. */ FocusTrap.prototype.focusInitialElement = function (focusableEls, initialFocusEl) { var focusIndex = 0; if (initialFocusEl) { focusIndex = Math.max(focusableEls.indexOf(initialFocusEl), 0); } focusableEls[focusIndex].focus(); }; FocusTrap.prototype.getFocusableElements = function (root) { var focusableEls = [].slice.call(root.querySelectorAll('[autofocus], [tabindex], a, input, textarea, select, button')); return focusableEls.filter(function (el) { var isDisabledOrHidden = el.getAttribute('aria-disabled') === 'true' || el.getAttribute('disabled') != null || el.getAttribute('hidden') != null || el.getAttribute('aria-hidden') === 'true'; var isTabbableAndVisible = el.tabIndex >= 0 && el.getBoundingClientRect().width > 0 && !el.classList.contains(FOCUS_SENTINEL_CLASS) && !isDisabledOrHidden; var isProgrammaticallyHidden = false; if (isTabbableAndVisible) { var style = getComputedStyle(el); isProgrammaticallyHidden = style.display === 'none' || style.visibility === 'hidden'; } return isTabbableAndVisible && !isProgrammaticallyHidden; }); }; FocusTrap.prototype.createSentinel = function () { var sentinel = document.createElement('div'); sentinel.setAttribute('tabindex', '0'); // Don't announce in screen readers. sentinel.setAttribute('aria-hidden', 'true'); sentinel.classList.add(FOCUS_SENTINEL_CLASS); return sentinel; }; return FocusTrap; }(); exports.FocusTrap = FocusTrap; /***/ }), /***/ "./packages/mdc-dom/index.ts": /*!***********************************!*\ !*** ./packages/mdc-dom/index.ts ***! \***********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * @license * Copyright 2018 Google Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ var __importStar = this && this.__importStar || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) { if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; }result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); var events = __importStar(__webpack_require__(/*! ./events */ "./packages/mdc-dom/events.ts")); exports.events = events; var focusTrap = __importStar(__webpack_require__(/*! ./focus-trap */ "./packages/mdc-dom/focus-trap.ts")); exports.focusTrap = focusTrap; var ponyfill = __importStar(__webpack_require__(/*! ./ponyfill */ "./packages/mdc-dom/ponyfill.ts")); exports.ponyfill = ponyfill; /***/ }), /***/ "./packages/mdc-dom/ponyfill.ts": /*!**************************************!*\ !*** ./packages/mdc-dom/ponyfill.ts ***! \**************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * @license * Copyright 2018 Google Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ Object.defineProperty(exports, "__esModule", { value: true }); /** * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global prototype chain. * This makes ponyfills safer than traditional polyfills, especially for libraries like MDC. */ function closest(element, selector) { if (element.closest) { return element.closest(selector); } var el = element; while (el) { if (matches(el, selector)) { return el; } el = el.parentElement; } return null; } exports.closest = closest; function matches(element, selector) { var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector; return nativeMatches.call(element, selector); } exports.matches = matches; /** * Used to compute the estimated scroll width of elements. When an element is * hidden due to display: none; being applied to a parent element, the width is * returned as 0. However, the element will have a true width once no longer * inside a display: none context. This method computes an estimated width when * the element is hidden or returns the true width when the element is visble. * @param {Element} element the element whose width to estimate */ function estimateScrollWidth(element) { // Check the offsetParent. If the element inherits display: none from any // parent, the offsetParent property will be null (see // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent). // This check ensures we only clone the node when necessary. var htmlEl = element; if (htmlEl.offsetParent !== null) { return htmlEl.scrollWidth; } var clone = htmlEl.cloneNode(true); clone.style.setProperty('position', 'absolute'); clone.style.setProperty('transform', 'translate(-9999px, -9999px)'); document.documentElement.appendChild(clone); var scrollWidth = clone.scrollWidth; document.documentElement.removeChild(clone); return scrollWidth; } exports.estimateScrollWidth = estimateScrollWidth; /***/ }) /******/ }); }); //# sourceMappingURL=mdc.dom.js.map