@material/menu-surface
Advanced tools
Comparing version 1.1.1 to 2.3.0
@@ -34,2 +34,3 @@ // Generated by dts-bundle v0.7.3 | ||
export * from '@material/menu-surface/component'; | ||
export * from '@material/menu-surface/constants'; | ||
export * from '@material/menu-surface/foundation'; | ||
@@ -36,0 +37,0 @@ export * from '@material/menu-surface/types'; |
@@ -1,1301 +0,983 @@ | ||
/*! | ||
Material Components for the Web | ||
Copyright (c) 2019 Google Inc. | ||
License: MIT | ||
*/ | ||
(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["menuSurface"] = factory(); | ||
else | ||
root["mdc"] = root["mdc"] || {}, root["mdc"]["menuSurface"] = 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, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // 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 = 32); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ({ | ||
/***/ 0: | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/** | ||
* @license | ||
* Copyright 2016 Google Inc. | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* 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. | ||
* 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 | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var MDCFoundation = /** @class */function () { | ||
function MDCFoundation(adapter) { | ||
if (adapter === void 0) { | ||
adapter = {}; | ||
(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["menuSurface"] = factory(); else root["mdc"] = root["mdc"] || {}, | ||
root["mdc"]["menuSurface"] = factory(); | ||
})(this, function() { | ||
return function(modules) { | ||
var installedModules = {}; | ||
function __webpack_require__(moduleId) { | ||
if (installedModules[moduleId]) { | ||
return installedModules[moduleId].exports; | ||
} | ||
var module = installedModules[moduleId] = { | ||
i: moduleId, | ||
l: false, | ||
exports: {} | ||
}; | ||
modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
module.l = true; | ||
return module.exports; | ||
} | ||
this.adapter_ = adapter; | ||
} | ||
Object.defineProperty(MDCFoundation, "cssClasses", { | ||
get: function get() { | ||
// Classes extending MDCFoundation should implement this method to return an object which exports every | ||
// CSS class the foundation class needs as a property. e.g. {ACTIVE: 'mdc-component--active'} | ||
return {}; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCFoundation, "strings", { | ||
get: function get() { | ||
// Classes extending MDCFoundation should implement this method to return an object which exports all | ||
// semantic strings as constants. e.g. {ARIA_ROLE: 'tablist'} | ||
return {}; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCFoundation, "numbers", { | ||
get: function get() { | ||
// Classes extending MDCFoundation should implement this method to return an object which exports all | ||
// of its semantic numbers as constants. e.g. {ANIMATION_DELAY_MS: 350} | ||
return {}; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCFoundation, "defaultAdapter", { | ||
get: function get() { | ||
// Classes extending MDCFoundation may choose to implement this getter in order to provide a convenient | ||
// way of viewing the necessary methods of an adapter. In the future, this could also be used for adapter | ||
// validation. | ||
return {}; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
MDCFoundation.prototype.init = function () { | ||
// Subclasses should override this method to perform initialization routines (registering events, etc.) | ||
}; | ||
MDCFoundation.prototype.destroy = function () { | ||
// Subclasses should override this method to perform de-initialization routines (de-registering events, etc.) | ||
}; | ||
return MDCFoundation; | ||
}(); | ||
exports.MDCFoundation = MDCFoundation; | ||
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier. | ||
exports.default = MDCFoundation; | ||
/***/ }), | ||
/***/ 1: | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/** | ||
* @license | ||
* Copyright 2016 Google Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
var __read = this && this.__read || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), | ||
r, | ||
ar = [], | ||
e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) { | ||
ar.push(r.value); | ||
} | ||
} catch (error) { | ||
e = { error: error }; | ||
} finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} finally { | ||
if (e) throw e.error; | ||
} | ||
} | ||
return ar; | ||
}; | ||
var __spread = this && this.__spread || function () { | ||
for (var ar = [], i = 0; i < arguments.length; i++) { | ||
ar = ar.concat(__read(arguments[i])); | ||
}return ar; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var foundation_1 = __webpack_require__(0); | ||
var MDCComponent = /** @class */function () { | ||
function MDCComponent(root, foundation) { | ||
var args = []; | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
args[_i - 2] = arguments[_i]; | ||
} | ||
this.root_ = root; | ||
this.initialize.apply(this, __spread(args)); | ||
// Note that we initialize foundation here and not within the constructor's default param so that | ||
// this.root_ is defined and can be used within the foundation class. | ||
this.foundation_ = foundation === undefined ? this.getDefaultFoundation() : foundation; | ||
this.foundation_.init(); | ||
this.initialSyncWithDOM(); | ||
} | ||
MDCComponent.attachTo = function (root) { | ||
// Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and | ||
// returns an instantiated component with its root set to that element. Also note that in the cases of | ||
// subclasses, an explicit foundation class will not have to be passed in; it will simply be initialized | ||
// from getDefaultFoundation(). | ||
return new MDCComponent(root, new foundation_1.MDCFoundation({})); | ||
}; | ||
/* istanbul ignore next: method param only exists for typing purposes; it does not need to be unit tested */ | ||
MDCComponent.prototype.initialize = function () { | ||
var _args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
_args[_i] = arguments[_i]; | ||
} | ||
// Subclasses can override this to do any additional setup work that would be considered part of a | ||
// "constructor". Essentially, it is a hook into the parent constructor before the foundation is | ||
// initialized. Any additional arguments besides root and foundation will be passed in here. | ||
}; | ||
MDCComponent.prototype.getDefaultFoundation = function () { | ||
// Subclasses must override this method to return a properly configured foundation class for the | ||
// component. | ||
throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class'); | ||
}; | ||
MDCComponent.prototype.initialSyncWithDOM = function () { | ||
// Subclasses should override this method if they need to perform work to synchronize with a host DOM | ||
// object. An example of this would be a form control wrapper that needs to synchronize its internal state | ||
// to some property or attribute of the host DOM. Please note: this is *not* the place to perform DOM | ||
// reads/writes that would cause layout / paint, as this is called synchronously from within the constructor. | ||
}; | ||
MDCComponent.prototype.destroy = function () { | ||
// Subclasses may implement this method to release any resources / deregister any listeners they have | ||
// attached. An example of this might be deregistering a resize event from the window object. | ||
this.foundation_.destroy(); | ||
}; | ||
MDCComponent.prototype.listen = function (evtType, handler) { | ||
this.root_.addEventListener(evtType, handler); | ||
}; | ||
MDCComponent.prototype.unlisten = function (evtType, handler) { | ||
this.root_.removeEventListener(evtType, handler); | ||
}; | ||
/** | ||
* Fires a cross-browser-compatible custom event from the component root of the given type, with the given data. | ||
*/ | ||
MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) { | ||
if (shouldBubble === void 0) { | ||
shouldBubble = false; | ||
} | ||
var evt; | ||
if (typeof CustomEvent === 'function') { | ||
evt = new CustomEvent(evtType, { | ||
bubbles: shouldBubble, | ||
detail: evtData | ||
}); | ||
} else { | ||
evt = document.createEvent('CustomEvent'); | ||
evt.initCustomEvent(evtType, shouldBubble, false, evtData); | ||
} | ||
this.root_.dispatchEvent(evt); | ||
}; | ||
return MDCComponent; | ||
}(); | ||
exports.MDCComponent = MDCComponent; | ||
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier. | ||
exports.default = MDCComponent; | ||
/***/ }), | ||
/***/ 13: | ||
/***/ (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 __extends = this && this.__extends || function () { | ||
var _extendStatics = function extendStatics(d, b) { | ||
_extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) { | ||
d.__proto__ = b; | ||
} || function (d, b) { | ||
for (var p in b) { | ||
if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
__webpack_require__.m = modules; | ||
__webpack_require__.c = installedModules; | ||
__webpack_require__.d = function(exports, name, getter) { | ||
if (!__webpack_require__.o(exports, name)) { | ||
Object.defineProperty(exports, name, { | ||
configurable: false, | ||
enumerable: true, | ||
get: getter | ||
}); | ||
} | ||
}; | ||
return _extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
_extendStatics(d, b); | ||
function __() { | ||
this.constructor = d; | ||
} | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
}(); | ||
var __assign = this && this.__assign || function () { | ||
__assign = Object.assign || function (t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) { | ||
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __values = this && this.__values || function (o) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator], | ||
i = 0; | ||
if (m) return m.call(o); | ||
return { | ||
next: function next() { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var foundation_1 = __webpack_require__(0); | ||
var constants_1 = __webpack_require__(9); | ||
var MDCMenuSurfaceFoundation = /** @class */function (_super) { | ||
__extends(MDCMenuSurfaceFoundation, _super); | ||
function MDCMenuSurfaceFoundation(adapter) { | ||
var _this = _super.call(this, __assign({}, MDCMenuSurfaceFoundation.defaultAdapter, adapter)) || this; | ||
_this.isOpen_ = false; | ||
_this.isQuickOpen_ = false; | ||
_this.isHoistedElement_ = false; | ||
_this.isFixedPosition_ = false; | ||
_this.openAnimationEndTimerId_ = 0; | ||
_this.closeAnimationEndTimerId_ = 0; | ||
_this.animationRequestId_ = 0; | ||
_this.anchorCorner_ = constants_1.Corner.TOP_START; | ||
_this.anchorMargin_ = { top: 0, right: 0, bottom: 0, left: 0 }; | ||
_this.position_ = { x: 0, y: 0 }; | ||
return _this; | ||
} | ||
Object.defineProperty(MDCMenuSurfaceFoundation, "cssClasses", { | ||
get: function get() { | ||
return constants_1.cssClasses; | ||
__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; | ||
}; | ||
__webpack_require__.o = function(object, property) { | ||
return Object.prototype.hasOwnProperty.call(object, property); | ||
}; | ||
__webpack_require__.p = ""; | ||
return __webpack_require__(__webpack_require__.s = 143); | ||
}({ | ||
0: function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var MDCFoundation = function() { | ||
function MDCFoundation(adapter) { | ||
if (adapter === void 0) { | ||
adapter = {}; | ||
} | ||
this.adapter_ = adapter; | ||
} | ||
Object.defineProperty(MDCFoundation, "cssClasses", { | ||
get: function get() { | ||
return {}; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCFoundation, "strings", { | ||
get: function get() { | ||
return {}; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCFoundation, "numbers", { | ||
get: function get() { | ||
return {}; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCFoundation, "defaultAdapter", { | ||
get: function get() { | ||
return {}; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
MDCFoundation.prototype.init = function() {}; | ||
MDCFoundation.prototype.destroy = function() {}; | ||
return MDCFoundation; | ||
}(); | ||
exports.MDCFoundation = MDCFoundation; | ||
exports.default = MDCFoundation; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCMenuSurfaceFoundation, "strings", { | ||
get: function get() { | ||
return constants_1.strings; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCMenuSurfaceFoundation, "numbers", { | ||
get: function get() { | ||
return constants_1.numbers; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCMenuSurfaceFoundation, "Corner", { | ||
get: function get() { | ||
return constants_1.Corner; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCMenuSurfaceFoundation, "defaultAdapter", { | ||
/** | ||
* @see {@link MDCMenuSurfaceAdapter} for typing information on parameters and return types. | ||
*/ | ||
get: function get() { | ||
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. | ||
return { | ||
addClass: function addClass() { | ||
return undefined; | ||
}, | ||
removeClass: function removeClass() { | ||
return undefined; | ||
}, | ||
hasClass: function hasClass() { | ||
return false; | ||
}, | ||
hasAnchor: function hasAnchor() { | ||
return false; | ||
}, | ||
isElementInContainer: function isElementInContainer() { | ||
return false; | ||
}, | ||
isFocused: function isFocused() { | ||
return false; | ||
}, | ||
isFirstElementFocused: function isFirstElementFocused() { | ||
return false; | ||
}, | ||
isLastElementFocused: function isLastElementFocused() { | ||
return false; | ||
}, | ||
isRtl: function isRtl() { | ||
return false; | ||
}, | ||
getInnerDimensions: function getInnerDimensions() { | ||
return { height: 0, width: 0 }; | ||
}, | ||
getAnchorDimensions: function getAnchorDimensions() { | ||
return null; | ||
}, | ||
getWindowDimensions: function getWindowDimensions() { | ||
return { height: 0, width: 0 }; | ||
}, | ||
getBodyDimensions: function getBodyDimensions() { | ||
return { height: 0, width: 0 }; | ||
}, | ||
getWindowScroll: function getWindowScroll() { | ||
return { x: 0, y: 0 }; | ||
}, | ||
setPosition: function setPosition() { | ||
return undefined; | ||
}, | ||
setMaxHeight: function setMaxHeight() { | ||
return undefined; | ||
}, | ||
setTransformOrigin: function setTransformOrigin() { | ||
return undefined; | ||
}, | ||
saveFocus: function saveFocus() { | ||
return undefined; | ||
}, | ||
restoreFocus: function restoreFocus() { | ||
return undefined; | ||
}, | ||
focusFirstElement: function focusFirstElement() { | ||
return undefined; | ||
}, | ||
focusLastElement: function focusLastElement() { | ||
return undefined; | ||
}, | ||
notifyClose: function notifyClose() { | ||
return undefined; | ||
}, | ||
notifyOpen: function notifyOpen() { | ||
return undefined; | ||
1: function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var __read = this && this.__read || function(o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) { | ||
ar.push(r.value); | ||
} | ||
} catch (error) { | ||
e = { | ||
error: error | ||
}; | ||
} finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} finally { | ||
if (e) throw e.error; | ||
} | ||
} | ||
return ar; | ||
}; | ||
// tslint:enable:object-literal-sort-keys | ||
var __spread = this && this.__spread || function() { | ||
for (var ar = [], i = 0; i < arguments.length; i++) { | ||
ar = ar.concat(__read(arguments[i])); | ||
} | ||
return ar; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var foundation_1 = __webpack_require__(0); | ||
var MDCComponent = function() { | ||
function MDCComponent(root, foundation) { | ||
var args = []; | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
args[_i - 2] = arguments[_i]; | ||
} | ||
this.root_ = root; | ||
this.initialize.apply(this, __spread(args)); | ||
this.foundation_ = foundation === undefined ? this.getDefaultFoundation() : foundation; | ||
this.foundation_.init(); | ||
this.initialSyncWithDOM(); | ||
} | ||
MDCComponent.attachTo = function(root) { | ||
return new MDCComponent(root, new foundation_1.MDCFoundation({})); | ||
}; | ||
MDCComponent.prototype.initialize = function() { | ||
var _args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
_args[_i] = arguments[_i]; | ||
} | ||
}; | ||
MDCComponent.prototype.getDefaultFoundation = function() { | ||
throw new Error("Subclasses must override getDefaultFoundation to return a properly configured " + "foundation class"); | ||
}; | ||
MDCComponent.prototype.initialSyncWithDOM = function() {}; | ||
MDCComponent.prototype.destroy = function() { | ||
this.foundation_.destroy(); | ||
}; | ||
MDCComponent.prototype.listen = function(evtType, handler) { | ||
this.root_.addEventListener(evtType, handler); | ||
}; | ||
MDCComponent.prototype.unlisten = function(evtType, handler) { | ||
this.root_.removeEventListener(evtType, handler); | ||
}; | ||
MDCComponent.prototype.emit = function(evtType, evtData, shouldBubble) { | ||
if (shouldBubble === void 0) { | ||
shouldBubble = false; | ||
} | ||
var evt; | ||
if (typeof CustomEvent === "function") { | ||
evt = new CustomEvent(evtType, { | ||
bubbles: shouldBubble, | ||
detail: evtData | ||
}); | ||
} else { | ||
evt = document.createEvent("CustomEvent"); | ||
evt.initCustomEvent(evtType, shouldBubble, false, evtData); | ||
} | ||
this.root_.dispatchEvent(evt); | ||
}; | ||
return MDCComponent; | ||
}(); | ||
exports.MDCComponent = MDCComponent; | ||
exports.default = MDCComponent; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
MDCMenuSurfaceFoundation.prototype.init = function () { | ||
var _a = MDCMenuSurfaceFoundation.cssClasses, | ||
ROOT = _a.ROOT, | ||
OPEN = _a.OPEN; | ||
if (!this.adapter_.hasClass(ROOT)) { | ||
throw new Error(ROOT + " class required in root element."); | ||
} | ||
if (this.adapter_.hasClass(OPEN)) { | ||
this.isOpen_ = true; | ||
} | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.destroy = function () { | ||
clearTimeout(this.openAnimationEndTimerId_); | ||
clearTimeout(this.closeAnimationEndTimerId_); | ||
// Cancel any currently running animations. | ||
cancelAnimationFrame(this.animationRequestId_); | ||
}; | ||
/** | ||
* @param corner Default anchor corner alignment of top-left menu surface corner. | ||
*/ | ||
MDCMenuSurfaceFoundation.prototype.setAnchorCorner = function (corner) { | ||
this.anchorCorner_ = corner; | ||
}; | ||
/** | ||
* @param margin Set of margin values from anchor. | ||
*/ | ||
MDCMenuSurfaceFoundation.prototype.setAnchorMargin = function (margin) { | ||
this.anchorMargin_.top = margin.top || 0; | ||
this.anchorMargin_.right = margin.right || 0; | ||
this.anchorMargin_.bottom = margin.bottom || 0; | ||
this.anchorMargin_.left = margin.left || 0; | ||
}; | ||
/** Used to indicate if the menu-surface is hoisted to the body. */ | ||
MDCMenuSurfaceFoundation.prototype.setIsHoisted = function (isHoisted) { | ||
this.isHoistedElement_ = isHoisted; | ||
}; | ||
/** Used to set the menu-surface calculations based on a fixed position menu. */ | ||
MDCMenuSurfaceFoundation.prototype.setFixedPosition = function (isFixedPosition) { | ||
this.isFixedPosition_ = isFixedPosition; | ||
}; | ||
/** Sets the menu-surface position on the page. */ | ||
MDCMenuSurfaceFoundation.prototype.setAbsolutePosition = function (x, y) { | ||
this.position_.x = this.isFinite_(x) ? x : 0; | ||
this.position_.y = this.isFinite_(y) ? y : 0; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.setQuickOpen = function (quickOpen) { | ||
this.isQuickOpen_ = quickOpen; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.isOpen = function () { | ||
return this.isOpen_; | ||
}; | ||
/** | ||
* Open the menu surface. | ||
*/ | ||
MDCMenuSurfaceFoundation.prototype.open = function () { | ||
var _this = this; | ||
this.adapter_.saveFocus(); | ||
if (!this.isQuickOpen_) { | ||
this.adapter_.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN); | ||
} | ||
this.animationRequestId_ = requestAnimationFrame(function () { | ||
_this.adapter_.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN); | ||
_this.dimensions_ = _this.adapter_.getInnerDimensions(); | ||
_this.autoPosition_(); | ||
if (_this.isQuickOpen_) { | ||
_this.adapter_.notifyOpen(); | ||
} else { | ||
_this.openAnimationEndTimerId_ = setTimeout(function () { | ||
13: function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var __extends = this && this.__extends || function() { | ||
var _extendStatics = function extendStatics(d, b) { | ||
_extendStatics = Object.setPrototypeOf || { | ||
__proto__: [] | ||
} instanceof Array && function(d, b) { | ||
d.__proto__ = b; | ||
} || function(d, b) { | ||
for (var p in b) { | ||
if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
} | ||
}; | ||
return _extendStatics(d, b); | ||
}; | ||
return function(d, b) { | ||
_extendStatics(d, b); | ||
function __() { | ||
this.constructor = d; | ||
} | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
}(); | ||
var __assign = this && this.__assign || function() { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) { | ||
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __values = this && this.__values || function(o) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; | ||
if (m) return m.call(o); | ||
return { | ||
next: function next() { | ||
if (o && i >= o.length) o = void 0; | ||
return { | ||
value: o && o[i++], | ||
done: !o | ||
}; | ||
} | ||
}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var foundation_1 = __webpack_require__(0); | ||
var constants_1 = __webpack_require__(9); | ||
var MDCMenuSurfaceFoundation = function(_super) { | ||
__extends(MDCMenuSurfaceFoundation, _super); | ||
function MDCMenuSurfaceFoundation(adapter) { | ||
var _this = _super.call(this, __assign({}, MDCMenuSurfaceFoundation.defaultAdapter, adapter)) || this; | ||
_this.isOpen_ = false; | ||
_this.isQuickOpen_ = false; | ||
_this.isHoistedElement_ = false; | ||
_this.isFixedPosition_ = false; | ||
_this.openAnimationEndTimerId_ = 0; | ||
_this.adapter_.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN); | ||
_this.adapter_.notifyOpen(); | ||
}, constants_1.numbers.TRANSITION_OPEN_DURATION); | ||
} | ||
}); | ||
this.isOpen_ = true; | ||
}; | ||
/** | ||
* Closes the menu surface. | ||
*/ | ||
MDCMenuSurfaceFoundation.prototype.close = function () { | ||
var _this = this; | ||
if (!this.isQuickOpen_) { | ||
this.adapter_.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED); | ||
} | ||
requestAnimationFrame(function () { | ||
_this.adapter_.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN); | ||
if (_this.isQuickOpen_) { | ||
_this.adapter_.notifyClose(); | ||
} else { | ||
_this.closeAnimationEndTimerId_ = setTimeout(function () { | ||
_this.closeAnimationEndTimerId_ = 0; | ||
_this.adapter_.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED); | ||
_this.adapter_.notifyClose(); | ||
}, constants_1.numbers.TRANSITION_CLOSE_DURATION); | ||
} | ||
}); | ||
this.isOpen_ = false; | ||
this.maybeRestoreFocus_(); | ||
}; | ||
/** Handle clicks and close if not within menu-surface element. */ | ||
MDCMenuSurfaceFoundation.prototype.handleBodyClick = function (evt) { | ||
var el = evt.target; | ||
if (this.adapter_.isElementInContainer(el)) { | ||
return; | ||
} | ||
this.close(); | ||
}; | ||
/** Handle keys that close the surface. */ | ||
MDCMenuSurfaceFoundation.prototype.handleKeydown = function (evt) { | ||
var keyCode = evt.keyCode, | ||
key = evt.key, | ||
shiftKey = evt.shiftKey; | ||
var isEscape = key === 'Escape' || keyCode === 27; | ||
var isTab = key === 'Tab' || keyCode === 9; | ||
if (isEscape) { | ||
this.close(); | ||
} else if (isTab) { | ||
if (this.adapter_.isLastElementFocused() && !shiftKey) { | ||
this.adapter_.focusFirstElement(); | ||
evt.preventDefault(); | ||
} else if (this.adapter_.isFirstElementFocused() && shiftKey) { | ||
this.adapter_.focusLastElement(); | ||
evt.preventDefault(); | ||
} | ||
} | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.autoPosition_ = function () { | ||
var _a; | ||
// Compute measurements for autoposition methods reuse. | ||
this.measurements_ = this.getAutoLayoutMeasurements_(); | ||
var corner = this.getOriginCorner_(); | ||
var maxMenuSurfaceHeight = this.getMenuSurfaceMaxHeight_(corner); | ||
var verticalAlignment = this.hasBit_(corner, constants_1.CornerBit.BOTTOM) ? 'bottom' : 'top'; | ||
var horizontalAlignment = this.hasBit_(corner, constants_1.CornerBit.RIGHT) ? 'right' : 'left'; | ||
var horizontalOffset = this.getHorizontalOriginOffset_(corner); | ||
var verticalOffset = this.getVerticalOriginOffset_(corner); | ||
var _b = this.measurements_, | ||
anchorSize = _b.anchorSize, | ||
surfaceSize = _b.surfaceSize; | ||
var position = (_a = {}, _a[horizontalAlignment] = horizontalOffset, _a[verticalAlignment] = verticalOffset, _a); | ||
// Center align when anchor width is comparable or greater than menu surface, otherwise keep corner. | ||
if (anchorSize.width / surfaceSize.width > constants_1.numbers.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO) { | ||
horizontalAlignment = 'center'; | ||
} | ||
// If the menu-surface has been hoisted to the body, it's no longer relative to the anchor element | ||
if (this.isHoistedElement_ || this.isFixedPosition_) { | ||
this.adjustPositionForHoistedElement_(position); | ||
} | ||
this.adapter_.setTransformOrigin(horizontalAlignment + " " + verticalAlignment); | ||
this.adapter_.setPosition(position); | ||
this.adapter_.setMaxHeight(maxMenuSurfaceHeight ? maxMenuSurfaceHeight + 'px' : ''); | ||
}; | ||
/** | ||
* @return Measurements used to position menu surface popup. | ||
*/ | ||
MDCMenuSurfaceFoundation.prototype.getAutoLayoutMeasurements_ = function () { | ||
var anchorRect = this.adapter_.getAnchorDimensions(); | ||
var bodySize = this.adapter_.getBodyDimensions(); | ||
var viewportSize = this.adapter_.getWindowDimensions(); | ||
var windowScroll = this.adapter_.getWindowScroll(); | ||
if (!anchorRect) { | ||
// tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together | ||
anchorRect = { | ||
top: this.position_.y, | ||
right: this.position_.x, | ||
bottom: this.position_.y, | ||
left: this.position_.x, | ||
width: 0, | ||
height: 0 | ||
}; | ||
// tslint:enable:object-literal-sort-keys | ||
} | ||
return { | ||
anchorSize: anchorRect, | ||
bodySize: bodySize, | ||
surfaceSize: this.dimensions_, | ||
viewportDistance: { | ||
// tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together | ||
top: anchorRect.top, | ||
right: viewportSize.width - anchorRect.right, | ||
bottom: viewportSize.height - anchorRect.bottom, | ||
left: anchorRect.left | ||
}, | ||
viewportSize: viewportSize, | ||
windowScroll: windowScroll | ||
}; | ||
}; | ||
/** | ||
* Computes the corner of the anchor from which to animate and position the menu surface. | ||
*/ | ||
MDCMenuSurfaceFoundation.prototype.getOriginCorner_ = function () { | ||
// Defaults: open from the top left. | ||
var corner = constants_1.Corner.TOP_LEFT; | ||
var _a = this.measurements_, | ||
viewportDistance = _a.viewportDistance, | ||
anchorSize = _a.anchorSize, | ||
surfaceSize = _a.surfaceSize; | ||
var isBottomAligned = this.hasBit_(this.anchorCorner_, constants_1.CornerBit.BOTTOM); | ||
var availableTop = isBottomAligned ? viewportDistance.top + anchorSize.height + this.anchorMargin_.bottom : viewportDistance.top + this.anchorMargin_.top; | ||
var availableBottom = isBottomAligned ? viewportDistance.bottom - this.anchorMargin_.bottom : viewportDistance.bottom + anchorSize.height - this.anchorMargin_.top; | ||
var topOverflow = surfaceSize.height - availableTop; | ||
var bottomOverflow = surfaceSize.height - availableBottom; | ||
if (bottomOverflow > 0 && topOverflow < bottomOverflow) { | ||
corner = this.setBit_(corner, constants_1.CornerBit.BOTTOM); | ||
} | ||
var isRtl = this.adapter_.isRtl(); | ||
var isFlipRtl = this.hasBit_(this.anchorCorner_, constants_1.CornerBit.FLIP_RTL); | ||
var avoidHorizontalOverlap = this.hasBit_(this.anchorCorner_, constants_1.CornerBit.RIGHT); | ||
var isAlignedRight = avoidHorizontalOverlap && !isRtl || !avoidHorizontalOverlap && isFlipRtl && isRtl; | ||
var availableLeft = isAlignedRight ? viewportDistance.left + anchorSize.width + this.anchorMargin_.right : viewportDistance.left + this.anchorMargin_.left; | ||
var availableRight = isAlignedRight ? viewportDistance.right - this.anchorMargin_.right : viewportDistance.right + anchorSize.width - this.anchorMargin_.left; | ||
var leftOverflow = surfaceSize.width - availableLeft; | ||
var rightOverflow = surfaceSize.width - availableRight; | ||
if (leftOverflow < 0 && isAlignedRight && isRtl || avoidHorizontalOverlap && !isAlignedRight && leftOverflow < 0 || rightOverflow > 0 && leftOverflow < rightOverflow) { | ||
corner = this.setBit_(corner, constants_1.CornerBit.RIGHT); | ||
} | ||
return corner; | ||
}; | ||
/** | ||
* @param corner Origin corner of the menu surface. | ||
* @return Maximum height of the menu surface, based on available space. 0 indicates should not be set. | ||
*/ | ||
MDCMenuSurfaceFoundation.prototype.getMenuSurfaceMaxHeight_ = function (corner) { | ||
var viewportDistance = this.measurements_.viewportDistance; | ||
var maxHeight = 0; | ||
var isBottomAligned = this.hasBit_(corner, constants_1.CornerBit.BOTTOM); | ||
var isBottomAnchored = this.hasBit_(this.anchorCorner_, constants_1.CornerBit.BOTTOM); | ||
var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE; | ||
// When maximum height is not specified, it is handled from CSS. | ||
if (isBottomAligned) { | ||
maxHeight = viewportDistance.top + this.anchorMargin_.top - MARGIN_TO_EDGE; | ||
if (!isBottomAnchored) { | ||
maxHeight += this.measurements_.anchorSize.height; | ||
} | ||
} else { | ||
maxHeight = viewportDistance.bottom - this.anchorMargin_.bottom + this.measurements_.anchorSize.height - MARGIN_TO_EDGE; | ||
if (isBottomAnchored) { | ||
maxHeight -= this.measurements_.anchorSize.height; | ||
} | ||
} | ||
return maxHeight; | ||
}; | ||
/** | ||
* @param corner Origin corner of the menu surface. | ||
* @return Horizontal offset of menu surface origin corner from corresponding anchor corner. | ||
*/ | ||
MDCMenuSurfaceFoundation.prototype.getHorizontalOriginOffset_ = function (corner) { | ||
var anchorSize = this.measurements_.anchorSize; | ||
// isRightAligned corresponds to using the 'right' property on the surface. | ||
var isRightAligned = this.hasBit_(corner, constants_1.CornerBit.RIGHT); | ||
var avoidHorizontalOverlap = this.hasBit_(this.anchorCorner_, constants_1.CornerBit.RIGHT); | ||
if (isRightAligned) { | ||
var rightOffset = avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin_.left : this.anchorMargin_.right; | ||
// For hoisted or fixed elements, adjust the offset by the difference between viewport width and body width so | ||
// when we calculate the right value (`adjustPositionForHoistedElement_`) based on the element position, | ||
// the right property is correct. | ||
if (this.isHoistedElement_ || this.isFixedPosition_) { | ||
return rightOffset - (this.measurements_.viewportSize.width - this.measurements_.bodySize.width); | ||
} | ||
return rightOffset; | ||
} | ||
return avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin_.right : this.anchorMargin_.left; | ||
}; | ||
/** | ||
* @param corner Origin corner of the menu surface. | ||
* @return Vertical offset of menu surface origin corner from corresponding anchor corner. | ||
*/ | ||
MDCMenuSurfaceFoundation.prototype.getVerticalOriginOffset_ = function (corner) { | ||
var anchorSize = this.measurements_.anchorSize; | ||
var isBottomAligned = this.hasBit_(corner, constants_1.CornerBit.BOTTOM); | ||
var avoidVerticalOverlap = this.hasBit_(this.anchorCorner_, constants_1.CornerBit.BOTTOM); | ||
var y = 0; | ||
if (isBottomAligned) { | ||
y = avoidVerticalOverlap ? anchorSize.height - this.anchorMargin_.top : -this.anchorMargin_.bottom; | ||
} else { | ||
y = avoidVerticalOverlap ? anchorSize.height + this.anchorMargin_.bottom : this.anchorMargin_.top; | ||
} | ||
return y; | ||
}; | ||
/** Calculates the offsets for positioning the menu-surface when the menu-surface has been hoisted to the body. */ | ||
MDCMenuSurfaceFoundation.prototype.adjustPositionForHoistedElement_ = function (position) { | ||
var e_1, _a; | ||
var _b = this.measurements_, | ||
windowScroll = _b.windowScroll, | ||
viewportDistance = _b.viewportDistance; | ||
var props = Object.keys(position); | ||
try { | ||
for (var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) { | ||
var prop = props_1_1.value; | ||
var value = position[prop] || 0; | ||
// Hoisted surfaces need to have the anchor elements location on the page added to the | ||
// position properties for proper alignment on the body. | ||
value += viewportDistance[prop]; | ||
// Surfaces that are absolutely positioned need to have additional calculations for scroll | ||
// and bottom positioning. | ||
if (!this.isFixedPosition_) { | ||
if (prop === 'top') { | ||
value += windowScroll.y; | ||
} else if (prop === 'bottom') { | ||
value -= windowScroll.y; | ||
} else if (prop === 'left') { | ||
value += windowScroll.x; | ||
_this.animationRequestId_ = 0; | ||
_this.anchorCorner_ = constants_1.Corner.TOP_START; | ||
_this.anchorMargin_ = { | ||
top: 0, | ||
right: 0, | ||
bottom: 0, | ||
left: 0 | ||
}; | ||
_this.position_ = { | ||
x: 0, | ||
y: 0 | ||
}; | ||
return _this; | ||
} | ||
Object.defineProperty(MDCMenuSurfaceFoundation, "cssClasses", { | ||
get: function get() { | ||
return constants_1.cssClasses; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCMenuSurfaceFoundation, "strings", { | ||
get: function get() { | ||
return constants_1.strings; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCMenuSurfaceFoundation, "numbers", { | ||
get: function get() { | ||
return constants_1.numbers; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCMenuSurfaceFoundation, "Corner", { | ||
get: function get() { | ||
return constants_1.Corner; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCMenuSurfaceFoundation, "defaultAdapter", { | ||
get: function get() { | ||
return { | ||
addClass: function addClass() { | ||
return undefined; | ||
}, | ||
removeClass: function removeClass() { | ||
return undefined; | ||
}, | ||
hasClass: function hasClass() { | ||
return false; | ||
}, | ||
hasAnchor: function hasAnchor() { | ||
return false; | ||
}, | ||
isElementInContainer: function isElementInContainer() { | ||
return false; | ||
}, | ||
isFocused: function isFocused() { | ||
return false; | ||
}, | ||
isFirstElementFocused: function isFirstElementFocused() { | ||
return false; | ||
}, | ||
isLastElementFocused: function isLastElementFocused() { | ||
return false; | ||
}, | ||
isRtl: function isRtl() { | ||
return false; | ||
}, | ||
getInnerDimensions: function getInnerDimensions() { | ||
return { | ||
height: 0, | ||
width: 0 | ||
}; | ||
}, | ||
getAnchorDimensions: function getAnchorDimensions() { | ||
return null; | ||
}, | ||
getWindowDimensions: function getWindowDimensions() { | ||
return { | ||
height: 0, | ||
width: 0 | ||
}; | ||
}, | ||
getBodyDimensions: function getBodyDimensions() { | ||
return { | ||
height: 0, | ||
width: 0 | ||
}; | ||
}, | ||
getWindowScroll: function getWindowScroll() { | ||
return { | ||
x: 0, | ||
y: 0 | ||
}; | ||
}, | ||
setPosition: function setPosition() { | ||
return undefined; | ||
}, | ||
setMaxHeight: function setMaxHeight() { | ||
return undefined; | ||
}, | ||
setTransformOrigin: function setTransformOrigin() { | ||
return undefined; | ||
}, | ||
saveFocus: function saveFocus() { | ||
return undefined; | ||
}, | ||
restoreFocus: function restoreFocus() { | ||
return undefined; | ||
}, | ||
focusFirstElement: function focusFirstElement() { | ||
return undefined; | ||
}, | ||
focusLastElement: function focusLastElement() { | ||
return undefined; | ||
}, | ||
notifyClose: function notifyClose() { | ||
return undefined; | ||
}, | ||
notifyOpen: function notifyOpen() { | ||
return undefined; | ||
} | ||
}; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
MDCMenuSurfaceFoundation.prototype.init = function() { | ||
var _a = MDCMenuSurfaceFoundation.cssClasses, ROOT = _a.ROOT, OPEN = _a.OPEN; | ||
if (!this.adapter_.hasClass(ROOT)) { | ||
throw new Error(ROOT + " class required in root element."); | ||
} | ||
if (this.adapter_.hasClass(OPEN)) { | ||
this.isOpen_ = true; | ||
} | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.destroy = function() { | ||
clearTimeout(this.openAnimationEndTimerId_); | ||
clearTimeout(this.closeAnimationEndTimerId_); | ||
cancelAnimationFrame(this.animationRequestId_); | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.setAnchorCorner = function(corner) { | ||
this.anchorCorner_ = corner; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.setAnchorMargin = function(margin) { | ||
this.anchorMargin_.top = margin.top || 0; | ||
this.anchorMargin_.right = margin.right || 0; | ||
this.anchorMargin_.bottom = margin.bottom || 0; | ||
this.anchorMargin_.left = margin.left || 0; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.setIsHoisted = function(isHoisted) { | ||
this.isHoistedElement_ = isHoisted; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.setFixedPosition = function(isFixedPosition) { | ||
this.isFixedPosition_ = isFixedPosition; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.setAbsolutePosition = function(x, y) { | ||
this.position_.x = this.isFinite_(x) ? x : 0; | ||
this.position_.y = this.isFinite_(y) ? y : 0; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.setQuickOpen = function(quickOpen) { | ||
this.isQuickOpen_ = quickOpen; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.isOpen = function() { | ||
return this.isOpen_; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.open = function() { | ||
var _this = this; | ||
this.adapter_.saveFocus(); | ||
if (!this.isQuickOpen_) { | ||
this.adapter_.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN); | ||
} | ||
this.animationRequestId_ = requestAnimationFrame(function() { | ||
_this.adapter_.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN); | ||
_this.dimensions_ = _this.adapter_.getInnerDimensions(); | ||
_this.autoPosition_(); | ||
if (_this.isQuickOpen_) { | ||
_this.adapter_.notifyOpen(); | ||
} else { | ||
_this.openAnimationEndTimerId_ = setTimeout(function() { | ||
_this.openAnimationEndTimerId_ = 0; | ||
_this.adapter_.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN); | ||
_this.adapter_.notifyOpen(); | ||
}, constants_1.numbers.TRANSITION_OPEN_DURATION); | ||
} | ||
}); | ||
this.isOpen_ = true; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.close = function() { | ||
var _this = this; | ||
if (!this.isQuickOpen_) { | ||
this.adapter_.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED); | ||
} | ||
requestAnimationFrame(function() { | ||
_this.adapter_.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN); | ||
if (_this.isQuickOpen_) { | ||
_this.adapter_.notifyClose(); | ||
} else { | ||
_this.closeAnimationEndTimerId_ = setTimeout(function() { | ||
_this.closeAnimationEndTimerId_ = 0; | ||
_this.adapter_.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED); | ||
_this.adapter_.notifyClose(); | ||
}, constants_1.numbers.TRANSITION_CLOSE_DURATION); | ||
} | ||
}); | ||
this.isOpen_ = false; | ||
this.maybeRestoreFocus_(); | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.handleBodyClick = function(evt) { | ||
var el = evt.target; | ||
if (this.adapter_.isElementInContainer(el)) { | ||
return; | ||
} | ||
this.close(); | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.handleKeydown = function(evt) { | ||
var keyCode = evt.keyCode, key = evt.key, shiftKey = evt.shiftKey; | ||
var isEscape = key === "Escape" || keyCode === 27; | ||
var isTab = key === "Tab" || keyCode === 9; | ||
if (isEscape) { | ||
this.close(); | ||
} else if (isTab) { | ||
if (this.adapter_.isLastElementFocused() && !shiftKey) { | ||
this.adapter_.focusFirstElement(); | ||
evt.preventDefault(); | ||
} else if (this.adapter_.isFirstElementFocused() && shiftKey) { | ||
this.adapter_.focusLastElement(); | ||
evt.preventDefault(); | ||
} | ||
} | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.autoPosition_ = function() { | ||
var _a; | ||
this.measurements_ = this.getAutoLayoutMeasurements_(); | ||
var corner = this.getOriginCorner_(); | ||
var maxMenuSurfaceHeight = this.getMenuSurfaceMaxHeight_(corner); | ||
var verticalAlignment = this.hasBit_(corner, constants_1.CornerBit.BOTTOM) ? "bottom" : "top"; | ||
var horizontalAlignment = this.hasBit_(corner, constants_1.CornerBit.RIGHT) ? "right" : "left"; | ||
var horizontalOffset = this.getHorizontalOriginOffset_(corner); | ||
var verticalOffset = this.getVerticalOriginOffset_(corner); | ||
var _b = this.measurements_, anchorSize = _b.anchorSize, surfaceSize = _b.surfaceSize; | ||
var position = (_a = {}, _a[horizontalAlignment] = horizontalOffset, _a[verticalAlignment] = verticalOffset, | ||
_a); | ||
if (anchorSize.width / surfaceSize.width > constants_1.numbers.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO) { | ||
horizontalAlignment = "center"; | ||
} | ||
if (this.isHoistedElement_ || this.isFixedPosition_) { | ||
this.adjustPositionForHoistedElement_(position); | ||
} | ||
this.adapter_.setTransformOrigin(horizontalAlignment + " " + verticalAlignment); | ||
this.adapter_.setPosition(position); | ||
this.adapter_.setMaxHeight(maxMenuSurfaceHeight ? maxMenuSurfaceHeight + "px" : ""); | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.getAutoLayoutMeasurements_ = function() { | ||
var anchorRect = this.adapter_.getAnchorDimensions(); | ||
var bodySize = this.adapter_.getBodyDimensions(); | ||
var viewportSize = this.adapter_.getWindowDimensions(); | ||
var windowScroll = this.adapter_.getWindowScroll(); | ||
if (!anchorRect) { | ||
anchorRect = { | ||
top: this.position_.y, | ||
right: this.position_.x, | ||
bottom: this.position_.y, | ||
left: this.position_.x, | ||
width: 0, | ||
height: 0 | ||
}; | ||
} | ||
return { | ||
anchorSize: anchorRect, | ||
bodySize: bodySize, | ||
surfaceSize: this.dimensions_, | ||
viewportDistance: { | ||
top: anchorRect.top, | ||
right: viewportSize.width - anchorRect.right, | ||
bottom: viewportSize.height - anchorRect.bottom, | ||
left: anchorRect.left | ||
}, | ||
viewportSize: viewportSize, | ||
windowScroll: windowScroll | ||
}; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.getOriginCorner_ = function() { | ||
var corner = constants_1.Corner.TOP_LEFT; | ||
var _a = this.measurements_, viewportDistance = _a.viewportDistance, anchorSize = _a.anchorSize, surfaceSize = _a.surfaceSize; | ||
var isBottomAligned = this.hasBit_(this.anchorCorner_, constants_1.CornerBit.BOTTOM); | ||
var availableTop = isBottomAligned ? viewportDistance.top + anchorSize.height + this.anchorMargin_.bottom : viewportDistance.top + this.anchorMargin_.top; | ||
var availableBottom = isBottomAligned ? viewportDistance.bottom - this.anchorMargin_.bottom : viewportDistance.bottom + anchorSize.height - this.anchorMargin_.top; | ||
var topOverflow = surfaceSize.height - availableTop; | ||
var bottomOverflow = surfaceSize.height - availableBottom; | ||
if (bottomOverflow > 0 && topOverflow < bottomOverflow) { | ||
corner = this.setBit_(corner, constants_1.CornerBit.BOTTOM); | ||
} | ||
var isRtl = this.adapter_.isRtl(); | ||
var isFlipRtl = this.hasBit_(this.anchorCorner_, constants_1.CornerBit.FLIP_RTL); | ||
var avoidHorizontalOverlap = this.hasBit_(this.anchorCorner_, constants_1.CornerBit.RIGHT); | ||
var isAlignedRight = avoidHorizontalOverlap && !isRtl || !avoidHorizontalOverlap && isFlipRtl && isRtl; | ||
var availableLeft = isAlignedRight ? viewportDistance.left + anchorSize.width + this.anchorMargin_.right : viewportDistance.left + this.anchorMargin_.left; | ||
var availableRight = isAlignedRight ? viewportDistance.right - this.anchorMargin_.right : viewportDistance.right + anchorSize.width - this.anchorMargin_.left; | ||
var leftOverflow = surfaceSize.width - availableLeft; | ||
var rightOverflow = surfaceSize.width - availableRight; | ||
if (leftOverflow < 0 && isAlignedRight && isRtl || avoidHorizontalOverlap && !isAlignedRight && leftOverflow < 0 || rightOverflow > 0 && leftOverflow < rightOverflow) { | ||
corner = this.setBit_(corner, constants_1.CornerBit.RIGHT); | ||
} | ||
return corner; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.getMenuSurfaceMaxHeight_ = function(corner) { | ||
var viewportDistance = this.measurements_.viewportDistance; | ||
var maxHeight = 0; | ||
var isBottomAligned = this.hasBit_(corner, constants_1.CornerBit.BOTTOM); | ||
var isBottomAnchored = this.hasBit_(this.anchorCorner_, constants_1.CornerBit.BOTTOM); | ||
var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE; | ||
if (isBottomAligned) { | ||
maxHeight = viewportDistance.top + this.anchorMargin_.top - MARGIN_TO_EDGE; | ||
if (!isBottomAnchored) { | ||
maxHeight += this.measurements_.anchorSize.height; | ||
} | ||
} else { | ||
// prop === 'right' | ||
value -= windowScroll.x; | ||
maxHeight = viewportDistance.bottom - this.anchorMargin_.bottom + this.measurements_.anchorSize.height - MARGIN_TO_EDGE; | ||
if (isBottomAnchored) { | ||
maxHeight -= this.measurements_.anchorSize.height; | ||
} | ||
} | ||
return maxHeight; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.getHorizontalOriginOffset_ = function(corner) { | ||
var anchorSize = this.measurements_.anchorSize; | ||
var isRightAligned = this.hasBit_(corner, constants_1.CornerBit.RIGHT); | ||
var avoidHorizontalOverlap = this.hasBit_(this.anchorCorner_, constants_1.CornerBit.RIGHT); | ||
if (isRightAligned) { | ||
var rightOffset = avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin_.left : this.anchorMargin_.right; | ||
if (this.isHoistedElement_ || this.isFixedPosition_) { | ||
return rightOffset - (this.measurements_.viewportSize.width - this.measurements_.bodySize.width); | ||
} | ||
return rightOffset; | ||
} | ||
return avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin_.right : this.anchorMargin_.left; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.getVerticalOriginOffset_ = function(corner) { | ||
var anchorSize = this.measurements_.anchorSize; | ||
var isBottomAligned = this.hasBit_(corner, constants_1.CornerBit.BOTTOM); | ||
var avoidVerticalOverlap = this.hasBit_(this.anchorCorner_, constants_1.CornerBit.BOTTOM); | ||
var y = 0; | ||
if (isBottomAligned) { | ||
y = avoidVerticalOverlap ? anchorSize.height - this.anchorMargin_.top : -this.anchorMargin_.bottom; | ||
} else { | ||
y = avoidVerticalOverlap ? anchorSize.height + this.anchorMargin_.bottom : this.anchorMargin_.top; | ||
} | ||
return y; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.adjustPositionForHoistedElement_ = function(position) { | ||
var e_1, _a; | ||
var _b = this.measurements_, windowScroll = _b.windowScroll, viewportDistance = _b.viewportDistance; | ||
var props = Object.keys(position); | ||
try { | ||
for (var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) { | ||
var prop = props_1_1.value; | ||
var value = position[prop] || 0; | ||
value += viewportDistance[prop]; | ||
if (!this.isFixedPosition_) { | ||
if (prop === "top") { | ||
value += windowScroll.y; | ||
} else if (prop === "bottom") { | ||
value -= windowScroll.y; | ||
} else if (prop === "left") { | ||
value += windowScroll.x; | ||
} else { | ||
value -= windowScroll.x; | ||
} | ||
} | ||
position[prop] = value; | ||
} | ||
} catch (e_1_1) { | ||
e_1 = { | ||
error: e_1_1 | ||
}; | ||
} finally { | ||
try { | ||
if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1); | ||
} finally { | ||
if (e_1) throw e_1.error; | ||
} | ||
} | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.maybeRestoreFocus_ = function() { | ||
var isRootFocused = this.adapter_.isFocused(); | ||
var childHasFocus = document.activeElement && this.adapter_.isElementInContainer(document.activeElement); | ||
if (isRootFocused || childHasFocus) { | ||
this.adapter_.restoreFocus(); | ||
} | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.hasBit_ = function(corner, bit) { | ||
return Boolean(corner & bit); | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.setBit_ = function(corner, bit) { | ||
return corner | bit; | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.isFinite_ = function(num) { | ||
return typeof num === "number" && isFinite(num); | ||
}; | ||
return MDCMenuSurfaceFoundation; | ||
}(foundation_1.MDCFoundation); | ||
exports.MDCMenuSurfaceFoundation = MDCMenuSurfaceFoundation; | ||
exports.default = MDCMenuSurfaceFoundation; | ||
}, | ||
143: function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) { | ||
if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
position[prop] = value; | ||
} | ||
} catch (e_1_1) { | ||
e_1 = { error: e_1_1 }; | ||
} finally { | ||
try { | ||
if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1); | ||
} finally { | ||
if (e_1) throw e_1.error; | ||
} | ||
} | ||
}; | ||
/** | ||
* The last focused element when the menu surface was opened should regain focus, if the user is | ||
* focused on or within the menu surface when it is closed. | ||
*/ | ||
MDCMenuSurfaceFoundation.prototype.maybeRestoreFocus_ = function () { | ||
var isRootFocused = this.adapter_.isFocused(); | ||
var childHasFocus = document.activeElement && this.adapter_.isElementInContainer(document.activeElement); | ||
if (isRootFocused || childHasFocus) { | ||
this.adapter_.restoreFocus(); | ||
} | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.hasBit_ = function (corner, bit) { | ||
return Boolean(corner & bit); // tslint:disable-line:no-bitwise | ||
}; | ||
MDCMenuSurfaceFoundation.prototype.setBit_ = function (corner, bit) { | ||
return corner | bit; // tslint:disable-line:no-bitwise | ||
}; | ||
/** | ||
* isFinite that doesn't force conversion to number type. | ||
* Equivalent to Number.isFinite in ES2015, which is not supported in IE. | ||
*/ | ||
MDCMenuSurfaceFoundation.prototype.isFinite_ = function (num) { | ||
return typeof num === 'number' && isFinite(num); | ||
}; | ||
return MDCMenuSurfaceFoundation; | ||
}(foundation_1.MDCFoundation); | ||
exports.MDCMenuSurfaceFoundation = MDCMenuSurfaceFoundation; | ||
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier. | ||
exports.default = MDCMenuSurfaceFoundation; | ||
/***/ }), | ||
/***/ 17: | ||
/***/ (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 }); | ||
var cachedCssTransformPropertyName_; | ||
/** | ||
* Returns the name of the correct transform property to use on the current browser. | ||
*/ | ||
function getTransformPropertyName(globalObj, forceRefresh) { | ||
if (forceRefresh === void 0) { | ||
forceRefresh = false; | ||
} | ||
if (cachedCssTransformPropertyName_ === undefined || forceRefresh) { | ||
var el = globalObj.document.createElement('div'); | ||
cachedCssTransformPropertyName_ = 'transform' in el.style ? 'transform' : 'webkitTransform'; | ||
} | ||
return cachedCssTransformPropertyName_; | ||
} | ||
exports.getTransformPropertyName = getTransformPropertyName; | ||
/***/ }), | ||
/***/ 32: | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/** | ||
* @license | ||
* Copyright 2019 Google Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
function __export(m) { | ||
for (var p in m) { | ||
if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
} | ||
var __importStar = this && this.__importStar || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) { | ||
if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
}result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var util = __importStar(__webpack_require__(17)); | ||
exports.util = util; | ||
var constants_1 = __webpack_require__(9); | ||
exports.Corner = constants_1.Corner; | ||
exports.CornerBit = constants_1.CornerBit; | ||
__export(__webpack_require__(33)); | ||
__export(__webpack_require__(13)); | ||
/***/ }), | ||
/***/ 33: | ||
/***/ (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 __extends = this && this.__extends || function () { | ||
var _extendStatics = function extendStatics(d, b) { | ||
_extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) { | ||
d.__proto__ = b; | ||
} || function (d, b) { | ||
for (var p in b) { | ||
if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
} | ||
}; | ||
return _extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
_extendStatics(d, b); | ||
function __() { | ||
this.constructor = d; | ||
} | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
}(); | ||
var __importStar = this && this.__importStar || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) { | ||
if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
}result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var component_1 = __webpack_require__(1); | ||
var constants_1 = __webpack_require__(9); | ||
var foundation_1 = __webpack_require__(13); | ||
var util = __importStar(__webpack_require__(17)); | ||
var MDCMenuSurface = /** @class */function (_super) { | ||
__extends(MDCMenuSurface, _super); | ||
function MDCMenuSurface() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
MDCMenuSurface.attachTo = function (root) { | ||
return new MDCMenuSurface(root); | ||
}; | ||
MDCMenuSurface.prototype.initialSyncWithDOM = function () { | ||
var _this = this; | ||
var parentEl = this.root_.parentElement; | ||
this.anchorElement = parentEl && parentEl.classList.contains(constants_1.cssClasses.ANCHOR) ? parentEl : null; | ||
if (this.root_.classList.contains(constants_1.cssClasses.FIXED)) { | ||
this.setFixedPosition(true); | ||
} | ||
this.handleKeydown_ = function (evt) { | ||
return _this.foundation_.handleKeydown(evt); | ||
}; | ||
this.handleBodyClick_ = function (evt) { | ||
return _this.foundation_.handleBodyClick(evt); | ||
}; | ||
this.registerBodyClickListener_ = function () { | ||
return document.body.addEventListener('click', _this.handleBodyClick_); | ||
}; | ||
this.deregisterBodyClickListener_ = function () { | ||
return document.body.removeEventListener('click', _this.handleBodyClick_); | ||
}; | ||
this.listen('keydown', this.handleKeydown_); | ||
this.listen(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener_); | ||
this.listen(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener_); | ||
}; | ||
MDCMenuSurface.prototype.destroy = function () { | ||
this.unlisten('keydown', this.handleKeydown_); | ||
this.unlisten(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener_); | ||
this.unlisten(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener_); | ||
_super.prototype.destroy.call(this); | ||
}; | ||
Object.defineProperty(MDCMenuSurface.prototype, "open", { | ||
get: function get() { | ||
return this.foundation_.isOpen(); | ||
var __importStar = this && this.__importStar || function(mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) { | ||
if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
} | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var util = __importStar(__webpack_require__(21)); | ||
exports.util = util; | ||
var constants_1 = __webpack_require__(9); | ||
exports.Corner = constants_1.Corner; | ||
exports.CornerBit = constants_1.CornerBit; | ||
__export(__webpack_require__(30)); | ||
__export(__webpack_require__(9)); | ||
__export(__webpack_require__(13)); | ||
}, | ||
set: function set(value) { | ||
if (value) { | ||
var focusableElements = this.root_.querySelectorAll(constants_1.strings.FOCUSABLE_ELEMENTS); | ||
this.firstFocusableElement_ = focusableElements[0]; | ||
this.lastFocusableElement_ = focusableElements[focusableElements.length - 1]; | ||
this.foundation_.open(); | ||
} else { | ||
this.foundation_.close(); | ||
21: function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var cachedCssTransformPropertyName_; | ||
function getTransformPropertyName(globalObj, forceRefresh) { | ||
if (forceRefresh === void 0) { | ||
forceRefresh = false; | ||
} | ||
if (cachedCssTransformPropertyName_ === undefined || forceRefresh) { | ||
var el = globalObj.document.createElement("div"); | ||
cachedCssTransformPropertyName_ = "transform" in el.style ? "transform" : "webkitTransform"; | ||
} | ||
return cachedCssTransformPropertyName_; | ||
} | ||
exports.getTransformPropertyName = getTransformPropertyName; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCMenuSurface.prototype, "quickOpen", { | ||
set: function set(quickOpen) { | ||
this.foundation_.setQuickOpen(quickOpen); | ||
30: function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var __extends = this && this.__extends || function() { | ||
var _extendStatics = function extendStatics(d, b) { | ||
_extendStatics = Object.setPrototypeOf || { | ||
__proto__: [] | ||
} instanceof Array && function(d, b) { | ||
d.__proto__ = b; | ||
} || function(d, b) { | ||
for (var p in b) { | ||
if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
} | ||
}; | ||
return _extendStatics(d, b); | ||
}; | ||
return function(d, b) { | ||
_extendStatics(d, b); | ||
function __() { | ||
this.constructor = d; | ||
} | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
}(); | ||
var __importStar = this && this.__importStar || function(mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) { | ||
if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
} | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var component_1 = __webpack_require__(1); | ||
var constants_1 = __webpack_require__(9); | ||
var foundation_1 = __webpack_require__(13); | ||
var util = __importStar(__webpack_require__(21)); | ||
var MDCMenuSurface = function(_super) { | ||
__extends(MDCMenuSurface, _super); | ||
function MDCMenuSurface() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
MDCMenuSurface.attachTo = function(root) { | ||
return new MDCMenuSurface(root); | ||
}; | ||
MDCMenuSurface.prototype.initialSyncWithDOM = function() { | ||
var _this = this; | ||
var parentEl = this.root_.parentElement; | ||
this.anchorElement = parentEl && parentEl.classList.contains(constants_1.cssClasses.ANCHOR) ? parentEl : null; | ||
if (this.root_.classList.contains(constants_1.cssClasses.FIXED)) { | ||
this.setFixedPosition(true); | ||
} | ||
this.handleKeydown_ = function(evt) { | ||
return _this.foundation_.handleKeydown(evt); | ||
}; | ||
this.handleBodyClick_ = function(evt) { | ||
return _this.foundation_.handleBodyClick(evt); | ||
}; | ||
this.registerBodyClickListener_ = function() { | ||
return document.body.addEventListener("click", _this.handleBodyClick_); | ||
}; | ||
this.deregisterBodyClickListener_ = function() { | ||
return document.body.removeEventListener("click", _this.handleBodyClick_); | ||
}; | ||
this.listen("keydown", this.handleKeydown_); | ||
this.listen(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener_); | ||
this.listen(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener_); | ||
}; | ||
MDCMenuSurface.prototype.destroy = function() { | ||
this.unlisten("keydown", this.handleKeydown_); | ||
this.unlisten(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener_); | ||
this.unlisten(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener_); | ||
_super.prototype.destroy.call(this); | ||
}; | ||
Object.defineProperty(MDCMenuSurface.prototype, "open", { | ||
get: function get() { | ||
return this.foundation_.isOpen(); | ||
}, | ||
set: function set(value) { | ||
if (value) { | ||
var focusableElements = this.root_.querySelectorAll(constants_1.strings.FOCUSABLE_ELEMENTS); | ||
this.firstFocusableElement_ = focusableElements[0]; | ||
this.lastFocusableElement_ = focusableElements[focusableElements.length - 1]; | ||
this.foundation_.open(); | ||
} else { | ||
this.foundation_.close(); | ||
} | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(MDCMenuSurface.prototype, "quickOpen", { | ||
set: function set(quickOpen) { | ||
this.foundation_.setQuickOpen(quickOpen); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
MDCMenuSurface.prototype.hoistMenuToBody = function() { | ||
document.body.appendChild(this.root_); | ||
this.setIsHoisted(true); | ||
}; | ||
MDCMenuSurface.prototype.setIsHoisted = function(isHoisted) { | ||
this.foundation_.setIsHoisted(isHoisted); | ||
}; | ||
MDCMenuSurface.prototype.setMenuSurfaceAnchorElement = function(element) { | ||
this.anchorElement = element; | ||
}; | ||
MDCMenuSurface.prototype.setFixedPosition = function(isFixed) { | ||
if (isFixed) { | ||
this.root_.classList.add(constants_1.cssClasses.FIXED); | ||
} else { | ||
this.root_.classList.remove(constants_1.cssClasses.FIXED); | ||
} | ||
this.foundation_.setFixedPosition(isFixed); | ||
}; | ||
MDCMenuSurface.prototype.setAbsolutePosition = function(x, y) { | ||
this.foundation_.setAbsolutePosition(x, y); | ||
this.setIsHoisted(true); | ||
}; | ||
MDCMenuSurface.prototype.setAnchorCorner = function(corner) { | ||
this.foundation_.setAnchorCorner(corner); | ||
}; | ||
MDCMenuSurface.prototype.setAnchorMargin = function(margin) { | ||
this.foundation_.setAnchorMargin(margin); | ||
}; | ||
MDCMenuSurface.prototype.getDefaultFoundation = function() { | ||
var _this = this; | ||
var adapter = { | ||
addClass: function addClass(className) { | ||
return _this.root_.classList.add(className); | ||
}, | ||
removeClass: function removeClass(className) { | ||
return _this.root_.classList.remove(className); | ||
}, | ||
hasClass: function hasClass(className) { | ||
return _this.root_.classList.contains(className); | ||
}, | ||
hasAnchor: function hasAnchor() { | ||
return !!_this.anchorElement; | ||
}, | ||
notifyClose: function notifyClose() { | ||
return _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.CLOSED_EVENT, {}); | ||
}, | ||
notifyOpen: function notifyOpen() { | ||
return _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, {}); | ||
}, | ||
isElementInContainer: function isElementInContainer(el) { | ||
return _this.root_.contains(el); | ||
}, | ||
isRtl: function isRtl() { | ||
return getComputedStyle(_this.root_).getPropertyValue("direction") === "rtl"; | ||
}, | ||
setTransformOrigin: function setTransformOrigin(origin) { | ||
var propertyName = util.getTransformPropertyName(window) + "-origin"; | ||
_this.root_.style.setProperty(propertyName, origin); | ||
}, | ||
isFocused: function isFocused() { | ||
return document.activeElement === _this.root_; | ||
}, | ||
saveFocus: function saveFocus() { | ||
_this.previousFocus_ = document.activeElement; | ||
}, | ||
restoreFocus: function restoreFocus() { | ||
if (_this.root_.contains(document.activeElement)) { | ||
if (_this.previousFocus_ && _this.previousFocus_.focus) { | ||
_this.previousFocus_.focus(); | ||
} | ||
} | ||
}, | ||
isFirstElementFocused: function isFirstElementFocused() { | ||
return _this.firstFocusableElement_ ? _this.firstFocusableElement_ === document.activeElement : false; | ||
}, | ||
isLastElementFocused: function isLastElementFocused() { | ||
return _this.lastFocusableElement_ ? _this.lastFocusableElement_ === document.activeElement : false; | ||
}, | ||
focusFirstElement: function focusFirstElement() { | ||
return _this.firstFocusableElement_ && _this.firstFocusableElement_.focus && _this.firstFocusableElement_.focus(); | ||
}, | ||
focusLastElement: function focusLastElement() { | ||
return _this.lastFocusableElement_ && _this.lastFocusableElement_.focus && _this.lastFocusableElement_.focus(); | ||
}, | ||
getInnerDimensions: function getInnerDimensions() { | ||
return { | ||
width: _this.root_.offsetWidth, | ||
height: _this.root_.offsetHeight | ||
}; | ||
}, | ||
getAnchorDimensions: function getAnchorDimensions() { | ||
return _this.anchorElement ? _this.anchorElement.getBoundingClientRect() : null; | ||
}, | ||
getWindowDimensions: function getWindowDimensions() { | ||
return { | ||
width: window.innerWidth, | ||
height: window.innerHeight | ||
}; | ||
}, | ||
getBodyDimensions: function getBodyDimensions() { | ||
return { | ||
width: document.body.clientWidth, | ||
height: document.body.clientHeight | ||
}; | ||
}, | ||
getWindowScroll: function getWindowScroll() { | ||
return { | ||
x: window.pageXOffset, | ||
y: window.pageYOffset | ||
}; | ||
}, | ||
setPosition: function setPosition(position) { | ||
_this.root_.style.left = "left" in position ? position.left + "px" : ""; | ||
_this.root_.style.right = "right" in position ? position.right + "px" : ""; | ||
_this.root_.style.top = "top" in position ? position.top + "px" : ""; | ||
_this.root_.style.bottom = "bottom" in position ? position.bottom + "px" : ""; | ||
}, | ||
setMaxHeight: function setMaxHeight(height) { | ||
_this.root_.style.maxHeight = height; | ||
} | ||
}; | ||
return new foundation_1.MDCMenuSurfaceFoundation(adapter); | ||
}; | ||
return MDCMenuSurface; | ||
}(component_1.MDCComponent); | ||
exports.MDCMenuSurface = MDCMenuSurface; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
9: function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var cssClasses = { | ||
ANCHOR: "mdc-menu-surface--anchor", | ||
ANIMATING_CLOSED: "mdc-menu-surface--animating-closed", | ||
ANIMATING_OPEN: "mdc-menu-surface--animating-open", | ||
FIXED: "mdc-menu-surface--fixed", | ||
OPEN: "mdc-menu-surface--open", | ||
ROOT: "mdc-menu-surface" | ||
}; | ||
exports.cssClasses = cssClasses; | ||
var strings = { | ||
CLOSED_EVENT: "MDCMenuSurface:closed", | ||
OPENED_EVENT: "MDCMenuSurface:opened", | ||
FOCUSABLE_ELEMENTS: [ "button:not(:disabled)", '[href]:not([aria-disabled="true"])', "input:not(:disabled)", "select:not(:disabled)", "textarea:not(:disabled)", '[tabindex]:not([tabindex="-1"]):not([aria-disabled="true"])' ].join(", ") | ||
}; | ||
exports.strings = strings; | ||
var numbers = { | ||
TRANSITION_OPEN_DURATION: 120, | ||
TRANSITION_CLOSE_DURATION: 75, | ||
MARGIN_TO_EDGE: 32, | ||
ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO: .67 | ||
}; | ||
exports.numbers = numbers; | ||
var CornerBit; | ||
(function(CornerBit) { | ||
CornerBit[CornerBit["BOTTOM"] = 1] = "BOTTOM"; | ||
CornerBit[CornerBit["CENTER"] = 2] = "CENTER"; | ||
CornerBit[CornerBit["RIGHT"] = 4] = "RIGHT"; | ||
CornerBit[CornerBit["FLIP_RTL"] = 8] = "FLIP_RTL"; | ||
})(CornerBit || (CornerBit = {})); | ||
exports.CornerBit = CornerBit; | ||
var Corner; | ||
(function(Corner) { | ||
Corner[Corner["TOP_LEFT"] = 0] = "TOP_LEFT"; | ||
Corner[Corner["TOP_RIGHT"] = 4] = "TOP_RIGHT"; | ||
Corner[Corner["BOTTOM_LEFT"] = 1] = "BOTTOM_LEFT"; | ||
Corner[Corner["BOTTOM_RIGHT"] = 5] = "BOTTOM_RIGHT"; | ||
Corner[Corner["TOP_START"] = 8] = "TOP_START"; | ||
Corner[Corner["TOP_END"] = 12] = "TOP_END"; | ||
Corner[Corner["BOTTOM_START"] = 9] = "BOTTOM_START"; | ||
Corner[Corner["BOTTOM_END"] = 13] = "BOTTOM_END"; | ||
})(Corner || (Corner = {})); | ||
exports.Corner = Corner; | ||
} | ||
}); | ||
/** | ||
* Removes the menu-surface from it's current location and appends it to the | ||
* body to overcome any overflow:hidden issues. | ||
*/ | ||
MDCMenuSurface.prototype.hoistMenuToBody = function () { | ||
document.body.appendChild(this.root_); | ||
this.setIsHoisted(true); | ||
}; | ||
/** Sets the foundation to use page offsets for an positioning when the menu is hoisted to the body. */ | ||
MDCMenuSurface.prototype.setIsHoisted = function (isHoisted) { | ||
this.foundation_.setIsHoisted(isHoisted); | ||
}; | ||
/** Sets the element that the menu-surface is anchored to. */ | ||
MDCMenuSurface.prototype.setMenuSurfaceAnchorElement = function (element) { | ||
this.anchorElement = element; | ||
}; | ||
/** Sets the menu-surface to position: fixed. */ | ||
MDCMenuSurface.prototype.setFixedPosition = function (isFixed) { | ||
if (isFixed) { | ||
this.root_.classList.add(constants_1.cssClasses.FIXED); | ||
} else { | ||
this.root_.classList.remove(constants_1.cssClasses.FIXED); | ||
} | ||
this.foundation_.setFixedPosition(isFixed); | ||
}; | ||
/** Sets the absolute x/y position to position based on. Requires the menu to be hoisted. */ | ||
MDCMenuSurface.prototype.setAbsolutePosition = function (x, y) { | ||
this.foundation_.setAbsolutePosition(x, y); | ||
this.setIsHoisted(true); | ||
}; | ||
/** | ||
* @param corner Default anchor corner alignment of top-left surface corner. | ||
*/ | ||
MDCMenuSurface.prototype.setAnchorCorner = function (corner) { | ||
this.foundation_.setAnchorCorner(corner); | ||
}; | ||
MDCMenuSurface.prototype.setAnchorMargin = function (margin) { | ||
this.foundation_.setAnchorMargin(margin); | ||
}; | ||
MDCMenuSurface.prototype.getDefaultFoundation = function () { | ||
var _this = this; | ||
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. | ||
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. | ||
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. | ||
var adapter = { | ||
addClass: function addClass(className) { | ||
return _this.root_.classList.add(className); | ||
}, | ||
removeClass: function removeClass(className) { | ||
return _this.root_.classList.remove(className); | ||
}, | ||
hasClass: function hasClass(className) { | ||
return _this.root_.classList.contains(className); | ||
}, | ||
hasAnchor: function hasAnchor() { | ||
return !!_this.anchorElement; | ||
}, | ||
notifyClose: function notifyClose() { | ||
return _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.CLOSED_EVENT, {}); | ||
}, | ||
notifyOpen: function notifyOpen() { | ||
return _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, {}); | ||
}, | ||
isElementInContainer: function isElementInContainer(el) { | ||
return _this.root_.contains(el); | ||
}, | ||
isRtl: function isRtl() { | ||
return getComputedStyle(_this.root_).getPropertyValue('direction') === 'rtl'; | ||
}, | ||
setTransformOrigin: function setTransformOrigin(origin) { | ||
var propertyName = util.getTransformPropertyName(window) + "-origin"; | ||
_this.root_.style.setProperty(propertyName, origin); | ||
}, | ||
isFocused: function isFocused() { | ||
return document.activeElement === _this.root_; | ||
}, | ||
saveFocus: function saveFocus() { | ||
_this.previousFocus_ = document.activeElement; | ||
}, | ||
restoreFocus: function restoreFocus() { | ||
if (_this.root_.contains(document.activeElement)) { | ||
if (_this.previousFocus_ && _this.previousFocus_.focus) { | ||
_this.previousFocus_.focus(); | ||
} | ||
} | ||
}, | ||
isFirstElementFocused: function isFirstElementFocused() { | ||
return _this.firstFocusableElement_ ? _this.firstFocusableElement_ === document.activeElement : false; | ||
}, | ||
isLastElementFocused: function isLastElementFocused() { | ||
return _this.lastFocusableElement_ ? _this.lastFocusableElement_ === document.activeElement : false; | ||
}, | ||
focusFirstElement: function focusFirstElement() { | ||
return _this.firstFocusableElement_ && _this.firstFocusableElement_.focus && _this.firstFocusableElement_.focus(); | ||
}, | ||
focusLastElement: function focusLastElement() { | ||
return _this.lastFocusableElement_ && _this.lastFocusableElement_.focus && _this.lastFocusableElement_.focus(); | ||
}, | ||
getInnerDimensions: function getInnerDimensions() { | ||
return { width: _this.root_.offsetWidth, height: _this.root_.offsetHeight }; | ||
}, | ||
getAnchorDimensions: function getAnchorDimensions() { | ||
return _this.anchorElement ? _this.anchorElement.getBoundingClientRect() : null; | ||
}, | ||
getWindowDimensions: function getWindowDimensions() { | ||
return { width: window.innerWidth, height: window.innerHeight }; | ||
}, | ||
getBodyDimensions: function getBodyDimensions() { | ||
return { width: document.body.clientWidth, height: document.body.clientHeight }; | ||
}, | ||
getWindowScroll: function getWindowScroll() { | ||
return { x: window.pageXOffset, y: window.pageYOffset }; | ||
}, | ||
setPosition: function setPosition(position) { | ||
_this.root_.style.left = 'left' in position ? position.left + "px" : ''; | ||
_this.root_.style.right = 'right' in position ? position.right + "px" : ''; | ||
_this.root_.style.top = 'top' in position ? position.top + "px" : ''; | ||
_this.root_.style.bottom = 'bottom' in position ? position.bottom + "px" : ''; | ||
}, | ||
setMaxHeight: function setMaxHeight(height) { | ||
_this.root_.style.maxHeight = height; | ||
} | ||
}; | ||
// tslint:enable:object-literal-sort-keys | ||
return new foundation_1.MDCMenuSurfaceFoundation(adapter); | ||
}; | ||
return MDCMenuSurface; | ||
}(component_1.MDCComponent); | ||
exports.MDCMenuSurface = MDCMenuSurface; | ||
/***/ }), | ||
/***/ 9: | ||
/***/ (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 }); | ||
var cssClasses = { | ||
ANCHOR: 'mdc-menu-surface--anchor', | ||
ANIMATING_CLOSED: 'mdc-menu-surface--animating-closed', | ||
ANIMATING_OPEN: 'mdc-menu-surface--animating-open', | ||
FIXED: 'mdc-menu-surface--fixed', | ||
OPEN: 'mdc-menu-surface--open', | ||
ROOT: 'mdc-menu-surface' | ||
}; | ||
exports.cssClasses = cssClasses; | ||
// tslint:disable:object-literal-sort-keys | ||
var strings = { | ||
CLOSED_EVENT: 'MDCMenuSurface:closed', | ||
OPENED_EVENT: 'MDCMenuSurface:opened', | ||
FOCUSABLE_ELEMENTS: ['button:not(:disabled)', '[href]:not([aria-disabled="true"])', 'input:not(:disabled)', 'select:not(:disabled)', 'textarea:not(:disabled)', '[tabindex]:not([tabindex="-1"]):not([aria-disabled="true"])'].join(', ') | ||
}; | ||
exports.strings = strings; | ||
// tslint:enable:object-literal-sort-keys | ||
var numbers = { | ||
/** Total duration of menu-surface open animation. */ | ||
TRANSITION_OPEN_DURATION: 120, | ||
/** Total duration of menu-surface close animation. */ | ||
TRANSITION_CLOSE_DURATION: 75, | ||
/** Margin left to the edge of the viewport when menu-surface is at maximum possible height. */ | ||
MARGIN_TO_EDGE: 32, | ||
/** Ratio of anchor width to menu-surface width for switching from corner positioning to center positioning. */ | ||
ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO: 0.67 | ||
}; | ||
exports.numbers = numbers; | ||
/** | ||
* Enum for bits in the {@see Corner) bitmap. | ||
*/ | ||
var CornerBit; | ||
(function (CornerBit) { | ||
CornerBit[CornerBit["BOTTOM"] = 1] = "BOTTOM"; | ||
CornerBit[CornerBit["CENTER"] = 2] = "CENTER"; | ||
CornerBit[CornerBit["RIGHT"] = 4] = "RIGHT"; | ||
CornerBit[CornerBit["FLIP_RTL"] = 8] = "FLIP_RTL"; | ||
})(CornerBit || (CornerBit = {})); | ||
exports.CornerBit = CornerBit; | ||
/** | ||
* Enum for representing an element corner for positioning the menu-surface. | ||
* | ||
* The START constants map to LEFT if element directionality is left | ||
* to right and RIGHT if the directionality is right to left. | ||
* Likewise END maps to RIGHT or LEFT depending on the directionality. | ||
*/ | ||
var Corner; | ||
(function (Corner) { | ||
Corner[Corner["TOP_LEFT"] = 0] = "TOP_LEFT"; | ||
Corner[Corner["TOP_RIGHT"] = 4] = "TOP_RIGHT"; | ||
Corner[Corner["BOTTOM_LEFT"] = 1] = "BOTTOM_LEFT"; | ||
Corner[Corner["BOTTOM_RIGHT"] = 5] = "BOTTOM_RIGHT"; | ||
Corner[Corner["TOP_START"] = 8] = "TOP_START"; | ||
Corner[Corner["TOP_END"] = 12] = "TOP_END"; | ||
Corner[Corner["BOTTOM_START"] = 9] = "BOTTOM_START"; | ||
Corner[Corner["BOTTOM_END"] = 13] = "BOTTOM_END"; | ||
})(Corner || (Corner = {})); | ||
exports.Corner = Corner; | ||
/***/ }) | ||
/******/ }); | ||
}); | ||
//# sourceMappingURL=mdc.menuSurface.js.map |
@@ -1,161 +0,9 @@ | ||
/*! | ||
Material Components for the Web | ||
Copyright (c) 2019 Google Inc. | ||
License: MIT | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.menuSurface=e():(t.mdc=t.mdc||{},t.mdc.menuSurface=e())}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=32)}({0:function(t,e,n){"use strict";/** | ||
/** | ||
* @license | ||
* Copyright 2016 Google Inc. | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* 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. | ||
* 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 | ||
*/ | ||
Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t){void 0===t&&(t={}),this.adapter_=t}return Object.defineProperty(t,"cssClasses",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(t,"strings",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(t,"numbers",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(t,"defaultAdapter",{get:function(){return{}},enumerable:!0,configurable:!0}),t.prototype.init=function(){},t.prototype.destroy=function(){},t}();e.MDCFoundation=i,e.default=i},1:function(t,e,n){"use strict";/** | ||
* @license | ||
* Copyright 2016 Google Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
var i=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,r=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s},o=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t};Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),s=function(){function t(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];this.root_=t,this.initialize.apply(this,o(n)),this.foundation_=void 0===e?this.getDefaultFoundation():e,this.foundation_.init(),this.initialSyncWithDOM()}return t.attachTo=function(e){return new t(e,new r.MDCFoundation({}))},t.prototype.initialize=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e]},t.prototype.getDefaultFoundation=function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")},t.prototype.initialSyncWithDOM=function(){},t.prototype.destroy=function(){this.foundation_.destroy()},t.prototype.listen=function(t,e){this.root_.addEventListener(t,e)},t.prototype.unlisten=function(t,e){this.root_.removeEventListener(t,e)},t.prototype.emit=function(t,e,n){void 0===n&&(n=!1);var i;"function"==typeof CustomEvent?i=new CustomEvent(t,{bubbles:n,detail:e}):(i=document.createEvent("CustomEvent"),i.initCustomEvent(t,n,!1,e)),this.root_.dispatchEvent(i)},t}();e.MDCComponent=s,e.default=s},13:function(t,e,n){"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 i=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},o.apply(this,arguments)},r=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}};Object.defineProperty(e,"__esModule",{value:!0});var s=n(0),a=n(9),u=function(t){function e(n){var i=t.call(this,o({},e.defaultAdapter,n))||this;return i.isOpen_=!1,i.isQuickOpen_=!1,i.isHoistedElement_=!1,i.isFixedPosition_=!1,i.openAnimationEndTimerId_=0,i.closeAnimationEndTimerId_=0,i.animationRequestId_=0,i.anchorCorner_=a.Corner.TOP_START,i.anchorMargin_={top:0,right:0,bottom:0,left:0},i.position_={x:0,y:0},i}return i(e,t),Object.defineProperty(e,"cssClasses",{get:function(){return a.cssClasses},enumerable:!0,configurable:!0}),Object.defineProperty(e,"strings",{get:function(){return a.strings},enumerable:!0,configurable:!0}),Object.defineProperty(e,"numbers",{get:function(){return a.numbers},enumerable:!0,configurable:!0}),Object.defineProperty(e,"Corner",{get:function(){return a.Corner},enumerable:!0,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{addClass:function(){},removeClass:function(){},hasClass:function(){return!1},hasAnchor:function(){return!1},isElementInContainer:function(){return!1},isFocused:function(){return!1},isFirstElementFocused:function(){return!1},isLastElementFocused:function(){return!1},isRtl:function(){return!1},getInnerDimensions:function(){return{height:0,width:0}},getAnchorDimensions:function(){return null},getWindowDimensions:function(){return{height:0,width:0}},getBodyDimensions:function(){return{height:0,width:0}},getWindowScroll:function(){return{x:0,y:0}},setPosition:function(){},setMaxHeight:function(){},setTransformOrigin:function(){},saveFocus:function(){},restoreFocus:function(){},focusFirstElement:function(){},focusLastElement:function(){},notifyClose:function(){},notifyOpen:function(){}}},enumerable:!0,configurable:!0}),e.prototype.init=function(){var t=e.cssClasses,n=t.ROOT,i=t.OPEN;if(!this.adapter_.hasClass(n))throw new Error(n+" class required in root element.");this.adapter_.hasClass(i)&&(this.isOpen_=!0)},e.prototype.destroy=function(){clearTimeout(this.openAnimationEndTimerId_),clearTimeout(this.closeAnimationEndTimerId_),cancelAnimationFrame(this.animationRequestId_)},e.prototype.setAnchorCorner=function(t){this.anchorCorner_=t},e.prototype.setAnchorMargin=function(t){this.anchorMargin_.top=t.top||0,this.anchorMargin_.right=t.right||0,this.anchorMargin_.bottom=t.bottom||0,this.anchorMargin_.left=t.left||0},e.prototype.setIsHoisted=function(t){this.isHoistedElement_=t},e.prototype.setFixedPosition=function(t){this.isFixedPosition_=t},e.prototype.setAbsolutePosition=function(t,e){this.position_.x=this.isFinite_(t)?t:0,this.position_.y=this.isFinite_(e)?e:0},e.prototype.setQuickOpen=function(t){this.isQuickOpen_=t},e.prototype.isOpen=function(){return this.isOpen_},e.prototype.open=function(){var t=this;this.adapter_.saveFocus(),this.isQuickOpen_||this.adapter_.addClass(e.cssClasses.ANIMATING_OPEN),this.animationRequestId_=requestAnimationFrame(function(){t.adapter_.addClass(e.cssClasses.OPEN),t.dimensions_=t.adapter_.getInnerDimensions(),t.autoPosition_(),t.isQuickOpen_?t.adapter_.notifyOpen():t.openAnimationEndTimerId_=setTimeout(function(){t.openAnimationEndTimerId_=0,t.adapter_.removeClass(e.cssClasses.ANIMATING_OPEN),t.adapter_.notifyOpen()},a.numbers.TRANSITION_OPEN_DURATION)}),this.isOpen_=!0},e.prototype.close=function(){var t=this;this.isQuickOpen_||this.adapter_.addClass(e.cssClasses.ANIMATING_CLOSED),requestAnimationFrame(function(){t.adapter_.removeClass(e.cssClasses.OPEN),t.isQuickOpen_?t.adapter_.notifyClose():t.closeAnimationEndTimerId_=setTimeout(function(){t.closeAnimationEndTimerId_=0,t.adapter_.removeClass(e.cssClasses.ANIMATING_CLOSED),t.adapter_.notifyClose()},a.numbers.TRANSITION_CLOSE_DURATION)}),this.isOpen_=!1,this.maybeRestoreFocus_()},e.prototype.handleBodyClick=function(t){var e=t.target;this.adapter_.isElementInContainer(e)||this.close()},e.prototype.handleKeydown=function(t){var e=t.keyCode,n=t.key,i=t.shiftKey,o="Escape"===n||27===e,r="Tab"===n||9===e;o?this.close():r&&(this.adapter_.isLastElementFocused()&&!i?(this.adapter_.focusFirstElement(),t.preventDefault()):this.adapter_.isFirstElementFocused()&&i&&(this.adapter_.focusLastElement(),t.preventDefault()))},e.prototype.autoPosition_=function(){var t;this.measurements_=this.getAutoLayoutMeasurements_();var e=this.getOriginCorner_(),n=this.getMenuSurfaceMaxHeight_(e),i=this.hasBit_(e,a.CornerBit.BOTTOM)?"bottom":"top",o=this.hasBit_(e,a.CornerBit.RIGHT)?"right":"left",r=this.getHorizontalOriginOffset_(e),s=this.getVerticalOriginOffset_(e),u=this.measurements_,c=u.anchorSize,h=u.surfaceSize,f=(t={},t[o]=r,t[i]=s,t);c.width/h.width>a.numbers.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO&&(o="center"),(this.isHoistedElement_||this.isFixedPosition_)&&this.adjustPositionForHoistedElement_(f),this.adapter_.setTransformOrigin(o+" "+i),this.adapter_.setPosition(f),this.adapter_.setMaxHeight(n?n+"px":"")},e.prototype.getAutoLayoutMeasurements_=function(){var t=this.adapter_.getAnchorDimensions(),e=this.adapter_.getBodyDimensions(),n=this.adapter_.getWindowDimensions(),i=this.adapter_.getWindowScroll();return t||(t={top:this.position_.y,right:this.position_.x,bottom:this.position_.y,left:this.position_.x,width:0,height:0}),{anchorSize:t,bodySize:e,surfaceSize:this.dimensions_,viewportDistance:{top:t.top,right:n.width-t.right,bottom:n.height-t.bottom,left:t.left},viewportSize:n,windowScroll:i}},e.prototype.getOriginCorner_=function(){var t=a.Corner.TOP_LEFT,e=this.measurements_,n=e.viewportDistance,i=e.anchorSize,o=e.surfaceSize,r=this.hasBit_(this.anchorCorner_,a.CornerBit.BOTTOM),s=r?n.top+i.height+this.anchorMargin_.bottom:n.top+this.anchorMargin_.top,u=r?n.bottom-this.anchorMargin_.bottom:n.bottom+i.height-this.anchorMargin_.top,c=o.height-s,h=o.height-u;h>0&&c<h&&(t=this.setBit_(t,a.CornerBit.BOTTOM));var f=this.adapter_.isRtl(),l=this.hasBit_(this.anchorCorner_,a.CornerBit.FLIP_RTL),d=this.hasBit_(this.anchorCorner_,a.CornerBit.RIGHT),_=d&&!f||!d&&l&&f,p=_?n.left+i.width+this.anchorMargin_.right:n.left+this.anchorMargin_.left,m=_?n.right-this.anchorMargin_.right:n.right+i.width-this.anchorMargin_.left,y=o.width-p,g=o.width-m;return(y<0&&_&&f||d&&!_&&y<0||g>0&&y<g)&&(t=this.setBit_(t,a.CornerBit.RIGHT)),t},e.prototype.getMenuSurfaceMaxHeight_=function(t){var n=this.measurements_.viewportDistance,i=0,o=this.hasBit_(t,a.CornerBit.BOTTOM),r=this.hasBit_(this.anchorCorner_,a.CornerBit.BOTTOM),s=e.numbers.MARGIN_TO_EDGE;return o?(i=n.top+this.anchorMargin_.top-s,r||(i+=this.measurements_.anchorSize.height)):(i=n.bottom-this.anchorMargin_.bottom+this.measurements_.anchorSize.height-s,r&&(i-=this.measurements_.anchorSize.height)),i},e.prototype.getHorizontalOriginOffset_=function(t){var e=this.measurements_.anchorSize,n=this.hasBit_(t,a.CornerBit.RIGHT),i=this.hasBit_(this.anchorCorner_,a.CornerBit.RIGHT);if(n){var o=i?e.width-this.anchorMargin_.left:this.anchorMargin_.right;return this.isHoistedElement_||this.isFixedPosition_?o-(this.measurements_.viewportSize.width-this.measurements_.bodySize.width):o}return i?e.width-this.anchorMargin_.right:this.anchorMargin_.left},e.prototype.getVerticalOriginOffset_=function(t){var e=this.measurements_.anchorSize,n=this.hasBit_(t,a.CornerBit.BOTTOM),i=this.hasBit_(this.anchorCorner_,a.CornerBit.BOTTOM);return n?i?e.height-this.anchorMargin_.top:-this.anchorMargin_.bottom:i?e.height+this.anchorMargin_.bottom:this.anchorMargin_.top},e.prototype.adjustPositionForHoistedElement_=function(t){var e,n,i=this.measurements_,o=i.windowScroll,s=i.viewportDistance,a=Object.keys(t);try{for(var u=r(a),c=u.next();!c.done;c=u.next()){var h=c.value,f=t[h]||0;f+=s[h],this.isFixedPosition_||("top"===h?f+=o.y:"bottom"===h?f-=o.y:"left"===h?f+=o.x:f-=o.x),t[h]=f}}catch(t){e={error:t}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}},e.prototype.maybeRestoreFocus_=function(){var t=this.adapter_.isFocused(),e=document.activeElement&&this.adapter_.isElementInContainer(document.activeElement);(t||e)&&this.adapter_.restoreFocus()},e.prototype.hasBit_=function(t,e){return Boolean(t&e)},e.prototype.setBit_=function(t,e){return t|e},e.prototype.isFinite_=function(t){return"number"==typeof t&&isFinite(t)},e}(s.MDCFoundation);e.MDCMenuSurfaceFoundation=u,e.default=u},17:function(t,e,n){"use strict";function i(t,e){if(void 0===e&&(e=!1),void 0===o||e){var n=t.document.createElement("div");o="transform"in n.style?"transform":"webkitTransform"}return o}/** | ||
* @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(e,"__esModule",{value:!0});var o;e.getTransformPropertyName=i},32:function(t,e,n){"use strict";/** | ||
* @license | ||
* Copyright 2019 Google Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
function i(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}var o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var r=o(n(17));e.util=r;var s=n(9);e.Corner=s.Corner,e.CornerBit=s.CornerBit,i(n(33)),i(n(13))},33:function(t,e,n){"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 i=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var r=n(1),s=n(9),a=n(13),u=o(n(17)),c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.attachTo=function(t){return new e(t)},e.prototype.initialSyncWithDOM=function(){var t=this,e=this.root_.parentElement;this.anchorElement=e&&e.classList.contains(s.cssClasses.ANCHOR)?e:null,this.root_.classList.contains(s.cssClasses.FIXED)&&this.setFixedPosition(!0),this.handleKeydown_=function(e){return t.foundation_.handleKeydown(e)},this.handleBodyClick_=function(e){return t.foundation_.handleBodyClick(e)},this.registerBodyClickListener_=function(){return document.body.addEventListener("click",t.handleBodyClick_)},this.deregisterBodyClickListener_=function(){return document.body.removeEventListener("click",t.handleBodyClick_)},this.listen("keydown",this.handleKeydown_),this.listen(s.strings.OPENED_EVENT,this.registerBodyClickListener_),this.listen(s.strings.CLOSED_EVENT,this.deregisterBodyClickListener_)},e.prototype.destroy=function(){this.unlisten("keydown",this.handleKeydown_),this.unlisten(s.strings.OPENED_EVENT,this.registerBodyClickListener_),this.unlisten(s.strings.CLOSED_EVENT,this.deregisterBodyClickListener_),t.prototype.destroy.call(this)},Object.defineProperty(e.prototype,"open",{get:function(){return this.foundation_.isOpen()},set:function(t){if(t){var e=this.root_.querySelectorAll(s.strings.FOCUSABLE_ELEMENTS);this.firstFocusableElement_=e[0],this.lastFocusableElement_=e[e.length-1],this.foundation_.open()}else this.foundation_.close()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"quickOpen",{set:function(t){this.foundation_.setQuickOpen(t)},enumerable:!0,configurable:!0}),e.prototype.hoistMenuToBody=function(){document.body.appendChild(this.root_),this.setIsHoisted(!0)},e.prototype.setIsHoisted=function(t){this.foundation_.setIsHoisted(t)},e.prototype.setMenuSurfaceAnchorElement=function(t){this.anchorElement=t},e.prototype.setFixedPosition=function(t){t?this.root_.classList.add(s.cssClasses.FIXED):this.root_.classList.remove(s.cssClasses.FIXED),this.foundation_.setFixedPosition(t)},e.prototype.setAbsolutePosition=function(t,e){this.foundation_.setAbsolutePosition(t,e),this.setIsHoisted(!0)},e.prototype.setAnchorCorner=function(t){this.foundation_.setAnchorCorner(t)},e.prototype.setAnchorMargin=function(t){this.foundation_.setAnchorMargin(t)},e.prototype.getDefaultFoundation=function(){var t=this,e={addClass:function(e){return t.root_.classList.add(e)},removeClass:function(e){return t.root_.classList.remove(e)},hasClass:function(e){return t.root_.classList.contains(e)},hasAnchor:function(){return!!t.anchorElement},notifyClose:function(){return t.emit(a.MDCMenuSurfaceFoundation.strings.CLOSED_EVENT,{})},notifyOpen:function(){return t.emit(a.MDCMenuSurfaceFoundation.strings.OPENED_EVENT,{})},isElementInContainer:function(e){return t.root_.contains(e)},isRtl:function(){return"rtl"===getComputedStyle(t.root_).getPropertyValue("direction")},setTransformOrigin:function(e){var n=u.getTransformPropertyName(window)+"-origin";t.root_.style.setProperty(n,e)},isFocused:function(){return document.activeElement===t.root_},saveFocus:function(){t.previousFocus_=document.activeElement},restoreFocus:function(){t.root_.contains(document.activeElement)&&t.previousFocus_&&t.previousFocus_.focus&&t.previousFocus_.focus()},isFirstElementFocused:function(){return!!t.firstFocusableElement_&&t.firstFocusableElement_===document.activeElement},isLastElementFocused:function(){return!!t.lastFocusableElement_&&t.lastFocusableElement_===document.activeElement},focusFirstElement:function(){return t.firstFocusableElement_&&t.firstFocusableElement_.focus&&t.firstFocusableElement_.focus()},focusLastElement:function(){return t.lastFocusableElement_&&t.lastFocusableElement_.focus&&t.lastFocusableElement_.focus()},getInnerDimensions:function(){return{width:t.root_.offsetWidth,height:t.root_.offsetHeight}},getAnchorDimensions:function(){return t.anchorElement?t.anchorElement.getBoundingClientRect():null},getWindowDimensions:function(){return{width:window.innerWidth,height:window.innerHeight}},getBodyDimensions:function(){return{width:document.body.clientWidth,height:document.body.clientHeight}},getWindowScroll:function(){return{x:window.pageXOffset,y:window.pageYOffset}},setPosition:function(e){t.root_.style.left="left"in e?e.left+"px":"",t.root_.style.right="right"in e?e.right+"px":"",t.root_.style.top="top"in e?e.top+"px":"",t.root_.style.bottom="bottom"in e?e.bottom+"px":""},setMaxHeight:function(e){t.root_.style.maxHeight=e}};return new a.MDCMenuSurfaceFoundation(e)},e}(r.MDCComponent);e.MDCMenuSurface=c},9:function(t,e,n){"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(e,"__esModule",{value:!0});var i={ANCHOR:"mdc-menu-surface--anchor",ANIMATING_CLOSED:"mdc-menu-surface--animating-closed",ANIMATING_OPEN:"mdc-menu-surface--animating-open",FIXED:"mdc-menu-surface--fixed",OPEN:"mdc-menu-surface--open",ROOT:"mdc-menu-surface"};e.cssClasses=i;var o={CLOSED_EVENT:"MDCMenuSurface:closed",OPENED_EVENT:"MDCMenuSurface:opened",FOCUSABLE_ELEMENTS:["button:not(:disabled)",'[href]:not([aria-disabled="true"])',"input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)",'[tabindex]:not([tabindex="-1"]):not([aria-disabled="true"])'].join(", ")};e.strings=o;var r={TRANSITION_OPEN_DURATION:120,TRANSITION_CLOSE_DURATION:75,MARGIN_TO_EDGE:32,ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO:.67};e.numbers=r;var s;!function(t){t[t.BOTTOM=1]="BOTTOM",t[t.CENTER=2]="CENTER",t[t.RIGHT=4]="RIGHT",t[t.FLIP_RTL=8]="FLIP_RTL"}(s||(s={})),e.CornerBit=s;var a;!function(t){t[t.TOP_LEFT=0]="TOP_LEFT",t[t.TOP_RIGHT=4]="TOP_RIGHT",t[t.BOTTOM_LEFT=1]="BOTTOM_LEFT",t[t.BOTTOM_RIGHT=5]="BOTTOM_RIGHT",t[t.TOP_START=8]="TOP_START",t[t.TOP_END=12]="TOP_END",t[t.BOTTOM_START=9]="BOTTOM_START",t[t.BOTTOM_END=13]="BOTTOM_END"}(a||(a={})),e.Corner=a}})}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.menuSurface=e():(t.mdc=t.mdc||{},t.mdc.menuSurface=e())}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=143)}({0:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t){void 0===t&&(t={}),this.adapter_=t}return Object.defineProperty(t,"cssClasses",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(t,"strings",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(t,"numbers",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(t,"defaultAdapter",{get:function(){return{}},enumerable:!0,configurable:!0}),t.prototype.init=function(){},t.prototype.destroy=function(){},t}();e.MDCFoundation=i,e.default=i},1:function(t,e,n){"use strict";var i=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,r=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s},o=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t};Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),s=function(){function t(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];this.root_=t,this.initialize.apply(this,o(n)),this.foundation_=void 0===e?this.getDefaultFoundation():e,this.foundation_.init(),this.initialSyncWithDOM()}return t.attachTo=function(e){return new t(e,new r.MDCFoundation({}))},t.prototype.initialize=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e]},t.prototype.getDefaultFoundation=function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")},t.prototype.initialSyncWithDOM=function(){},t.prototype.destroy=function(){this.foundation_.destroy()},t.prototype.listen=function(t,e){this.root_.addEventListener(t,e)},t.prototype.unlisten=function(t,e){this.root_.removeEventListener(t,e)},t.prototype.emit=function(t,e,n){void 0===n&&(n=!1);var i;"function"==typeof CustomEvent?i=new CustomEvent(t,{bubbles:n,detail:e}):(i=document.createEvent("CustomEvent"),i.initCustomEvent(t,n,!1,e)),this.root_.dispatchEvent(i)},t}();e.MDCComponent=s,e.default=s},13:function(t,e,n){"use strict";var i=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},o.apply(this,arguments)},r=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}};Object.defineProperty(e,"__esModule",{value:!0});var s=n(0),a=n(9),u=function(t){function e(n){var i=t.call(this,o({},e.defaultAdapter,n))||this;return i.isOpen_=!1,i.isQuickOpen_=!1,i.isHoistedElement_=!1,i.isFixedPosition_=!1,i.openAnimationEndTimerId_=0,i.closeAnimationEndTimerId_=0,i.animationRequestId_=0,i.anchorCorner_=a.Corner.TOP_START,i.anchorMargin_={top:0,right:0,bottom:0,left:0},i.position_={x:0,y:0},i}return i(e,t),Object.defineProperty(e,"cssClasses",{get:function(){return a.cssClasses},enumerable:!0,configurable:!0}),Object.defineProperty(e,"strings",{get:function(){return a.strings},enumerable:!0,configurable:!0}),Object.defineProperty(e,"numbers",{get:function(){return a.numbers},enumerable:!0,configurable:!0}),Object.defineProperty(e,"Corner",{get:function(){return a.Corner},enumerable:!0,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{addClass:function(){},removeClass:function(){},hasClass:function(){return!1},hasAnchor:function(){return!1},isElementInContainer:function(){return!1},isFocused:function(){return!1},isFirstElementFocused:function(){return!1},isLastElementFocused:function(){return!1},isRtl:function(){return!1},getInnerDimensions:function(){return{height:0,width:0}},getAnchorDimensions:function(){return null},getWindowDimensions:function(){return{height:0,width:0}},getBodyDimensions:function(){return{height:0,width:0}},getWindowScroll:function(){return{x:0,y:0}},setPosition:function(){},setMaxHeight:function(){},setTransformOrigin:function(){},saveFocus:function(){},restoreFocus:function(){},focusFirstElement:function(){},focusLastElement:function(){},notifyClose:function(){},notifyOpen:function(){}}},enumerable:!0,configurable:!0}),e.prototype.init=function(){var t=e.cssClasses,n=t.ROOT,i=t.OPEN;if(!this.adapter_.hasClass(n))throw new Error(n+" class required in root element.");this.adapter_.hasClass(i)&&(this.isOpen_=!0)},e.prototype.destroy=function(){clearTimeout(this.openAnimationEndTimerId_),clearTimeout(this.closeAnimationEndTimerId_),cancelAnimationFrame(this.animationRequestId_)},e.prototype.setAnchorCorner=function(t){this.anchorCorner_=t},e.prototype.setAnchorMargin=function(t){this.anchorMargin_.top=t.top||0,this.anchorMargin_.right=t.right||0,this.anchorMargin_.bottom=t.bottom||0,this.anchorMargin_.left=t.left||0},e.prototype.setIsHoisted=function(t){this.isHoistedElement_=t},e.prototype.setFixedPosition=function(t){this.isFixedPosition_=t},e.prototype.setAbsolutePosition=function(t,e){this.position_.x=this.isFinite_(t)?t:0,this.position_.y=this.isFinite_(e)?e:0},e.prototype.setQuickOpen=function(t){this.isQuickOpen_=t},e.prototype.isOpen=function(){return this.isOpen_},e.prototype.open=function(){var t=this;this.adapter_.saveFocus(),this.isQuickOpen_||this.adapter_.addClass(e.cssClasses.ANIMATING_OPEN),this.animationRequestId_=requestAnimationFrame(function(){t.adapter_.addClass(e.cssClasses.OPEN),t.dimensions_=t.adapter_.getInnerDimensions(),t.autoPosition_(),t.isQuickOpen_?t.adapter_.notifyOpen():t.openAnimationEndTimerId_=setTimeout(function(){t.openAnimationEndTimerId_=0,t.adapter_.removeClass(e.cssClasses.ANIMATING_OPEN),t.adapter_.notifyOpen()},a.numbers.TRANSITION_OPEN_DURATION)}),this.isOpen_=!0},e.prototype.close=function(){var t=this;this.isQuickOpen_||this.adapter_.addClass(e.cssClasses.ANIMATING_CLOSED),requestAnimationFrame(function(){t.adapter_.removeClass(e.cssClasses.OPEN),t.isQuickOpen_?t.adapter_.notifyClose():t.closeAnimationEndTimerId_=setTimeout(function(){t.closeAnimationEndTimerId_=0,t.adapter_.removeClass(e.cssClasses.ANIMATING_CLOSED),t.adapter_.notifyClose()},a.numbers.TRANSITION_CLOSE_DURATION)}),this.isOpen_=!1,this.maybeRestoreFocus_()},e.prototype.handleBodyClick=function(t){var e=t.target;this.adapter_.isElementInContainer(e)||this.close()},e.prototype.handleKeydown=function(t){var e=t.keyCode,n=t.key,i=t.shiftKey,o="Escape"===n||27===e,r="Tab"===n||9===e;o?this.close():r&&(this.adapter_.isLastElementFocused()&&!i?(this.adapter_.focusFirstElement(),t.preventDefault()):this.adapter_.isFirstElementFocused()&&i&&(this.adapter_.focusLastElement(),t.preventDefault()))},e.prototype.autoPosition_=function(){var t;this.measurements_=this.getAutoLayoutMeasurements_();var e=this.getOriginCorner_(),n=this.getMenuSurfaceMaxHeight_(e),i=this.hasBit_(e,a.CornerBit.BOTTOM)?"bottom":"top",o=this.hasBit_(e,a.CornerBit.RIGHT)?"right":"left",r=this.getHorizontalOriginOffset_(e),s=this.getVerticalOriginOffset_(e),u=this.measurements_,c=u.anchorSize,h=u.surfaceSize,f=(t={},t[o]=r,t[i]=s,t);c.width/h.width>a.numbers.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO&&(o="center"),(this.isHoistedElement_||this.isFixedPosition_)&&this.adjustPositionForHoistedElement_(f),this.adapter_.setTransformOrigin(o+" "+i),this.adapter_.setPosition(f),this.adapter_.setMaxHeight(n?n+"px":"")},e.prototype.getAutoLayoutMeasurements_=function(){var t=this.adapter_.getAnchorDimensions(),e=this.adapter_.getBodyDimensions(),n=this.adapter_.getWindowDimensions(),i=this.adapter_.getWindowScroll();return t||(t={top:this.position_.y,right:this.position_.x,bottom:this.position_.y,left:this.position_.x,width:0,height:0}),{anchorSize:t,bodySize:e,surfaceSize:this.dimensions_,viewportDistance:{top:t.top,right:n.width-t.right,bottom:n.height-t.bottom,left:t.left},viewportSize:n,windowScroll:i}},e.prototype.getOriginCorner_=function(){var t=a.Corner.TOP_LEFT,e=this.measurements_,n=e.viewportDistance,i=e.anchorSize,o=e.surfaceSize,r=this.hasBit_(this.anchorCorner_,a.CornerBit.BOTTOM),s=r?n.top+i.height+this.anchorMargin_.bottom:n.top+this.anchorMargin_.top,u=r?n.bottom-this.anchorMargin_.bottom:n.bottom+i.height-this.anchorMargin_.top,c=o.height-s,h=o.height-u;h>0&&c<h&&(t=this.setBit_(t,a.CornerBit.BOTTOM));var f=this.adapter_.isRtl(),l=this.hasBit_(this.anchorCorner_,a.CornerBit.FLIP_RTL),d=this.hasBit_(this.anchorCorner_,a.CornerBit.RIGHT),_=d&&!f||!d&&l&&f,p=_?n.left+i.width+this.anchorMargin_.right:n.left+this.anchorMargin_.left,m=_?n.right-this.anchorMargin_.right:n.right+i.width-this.anchorMargin_.left,y=o.width-p,g=o.width-m;return(y<0&&_&&f||d&&!_&&y<0||g>0&&y<g)&&(t=this.setBit_(t,a.CornerBit.RIGHT)),t},e.prototype.getMenuSurfaceMaxHeight_=function(t){var n=this.measurements_.viewportDistance,i=0,o=this.hasBit_(t,a.CornerBit.BOTTOM),r=this.hasBit_(this.anchorCorner_,a.CornerBit.BOTTOM),s=e.numbers.MARGIN_TO_EDGE;return o?(i=n.top+this.anchorMargin_.top-s,r||(i+=this.measurements_.anchorSize.height)):(i=n.bottom-this.anchorMargin_.bottom+this.measurements_.anchorSize.height-s,r&&(i-=this.measurements_.anchorSize.height)),i},e.prototype.getHorizontalOriginOffset_=function(t){var e=this.measurements_.anchorSize,n=this.hasBit_(t,a.CornerBit.RIGHT),i=this.hasBit_(this.anchorCorner_,a.CornerBit.RIGHT);if(n){var o=i?e.width-this.anchorMargin_.left:this.anchorMargin_.right;return this.isHoistedElement_||this.isFixedPosition_?o-(this.measurements_.viewportSize.width-this.measurements_.bodySize.width):o}return i?e.width-this.anchorMargin_.right:this.anchorMargin_.left},e.prototype.getVerticalOriginOffset_=function(t){var e=this.measurements_.anchorSize,n=this.hasBit_(t,a.CornerBit.BOTTOM),i=this.hasBit_(this.anchorCorner_,a.CornerBit.BOTTOM);return n?i?e.height-this.anchorMargin_.top:-this.anchorMargin_.bottom:i?e.height+this.anchorMargin_.bottom:this.anchorMargin_.top},e.prototype.adjustPositionForHoistedElement_=function(t){var e,n,i=this.measurements_,o=i.windowScroll,s=i.viewportDistance,a=Object.keys(t);try{for(var u=r(a),c=u.next();!c.done;c=u.next()){var h=c.value,f=t[h]||0;f+=s[h],this.isFixedPosition_||("top"===h?f+=o.y:"bottom"===h?f-=o.y:"left"===h?f+=o.x:f-=o.x),t[h]=f}}catch(t){e={error:t}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}},e.prototype.maybeRestoreFocus_=function(){var t=this.adapter_.isFocused(),e=document.activeElement&&this.adapter_.isElementInContainer(document.activeElement);(t||e)&&this.adapter_.restoreFocus()},e.prototype.hasBit_=function(t,e){return Boolean(t&e)},e.prototype.setBit_=function(t,e){return t|e},e.prototype.isFinite_=function(t){return"number"==typeof t&&isFinite(t)},e}(s.MDCFoundation);e.MDCMenuSurfaceFoundation=u,e.default=u},143:function(t,e,n){"use strict";function i(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}var o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var r=o(n(21));e.util=r;var s=n(9);e.Corner=s.Corner,e.CornerBit=s.CornerBit,i(n(30)),i(n(9)),i(n(13))},21:function(t,e,n){"use strict";function i(t,e){if(void 0===e&&(e=!1),void 0===o||e){var n=t.document.createElement("div");o="transform"in n.style?"transform":"webkitTransform"}return o}Object.defineProperty(e,"__esModule",{value:!0});var o;e.getTransformPropertyName=i},30:function(t,e,n){"use strict";var i=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var r=n(1),s=n(9),a=n(13),u=o(n(21)),c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.attachTo=function(t){return new e(t)},e.prototype.initialSyncWithDOM=function(){var t=this,e=this.root_.parentElement;this.anchorElement=e&&e.classList.contains(s.cssClasses.ANCHOR)?e:null,this.root_.classList.contains(s.cssClasses.FIXED)&&this.setFixedPosition(!0),this.handleKeydown_=function(e){return t.foundation_.handleKeydown(e)},this.handleBodyClick_=function(e){return t.foundation_.handleBodyClick(e)},this.registerBodyClickListener_=function(){return document.body.addEventListener("click",t.handleBodyClick_)},this.deregisterBodyClickListener_=function(){return document.body.removeEventListener("click",t.handleBodyClick_)},this.listen("keydown",this.handleKeydown_),this.listen(s.strings.OPENED_EVENT,this.registerBodyClickListener_),this.listen(s.strings.CLOSED_EVENT,this.deregisterBodyClickListener_)},e.prototype.destroy=function(){this.unlisten("keydown",this.handleKeydown_),this.unlisten(s.strings.OPENED_EVENT,this.registerBodyClickListener_),this.unlisten(s.strings.CLOSED_EVENT,this.deregisterBodyClickListener_),t.prototype.destroy.call(this)},Object.defineProperty(e.prototype,"open",{get:function(){return this.foundation_.isOpen()},set:function(t){if(t){var e=this.root_.querySelectorAll(s.strings.FOCUSABLE_ELEMENTS);this.firstFocusableElement_=e[0],this.lastFocusableElement_=e[e.length-1],this.foundation_.open()}else this.foundation_.close()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"quickOpen",{set:function(t){this.foundation_.setQuickOpen(t)},enumerable:!0,configurable:!0}),e.prototype.hoistMenuToBody=function(){document.body.appendChild(this.root_),this.setIsHoisted(!0)},e.prototype.setIsHoisted=function(t){this.foundation_.setIsHoisted(t)},e.prototype.setMenuSurfaceAnchorElement=function(t){this.anchorElement=t},e.prototype.setFixedPosition=function(t){t?this.root_.classList.add(s.cssClasses.FIXED):this.root_.classList.remove(s.cssClasses.FIXED),this.foundation_.setFixedPosition(t)},e.prototype.setAbsolutePosition=function(t,e){this.foundation_.setAbsolutePosition(t,e),this.setIsHoisted(!0)},e.prototype.setAnchorCorner=function(t){this.foundation_.setAnchorCorner(t)},e.prototype.setAnchorMargin=function(t){this.foundation_.setAnchorMargin(t)},e.prototype.getDefaultFoundation=function(){var t=this,e={addClass:function(e){return t.root_.classList.add(e)},removeClass:function(e){return t.root_.classList.remove(e)},hasClass:function(e){return t.root_.classList.contains(e)},hasAnchor:function(){return!!t.anchorElement},notifyClose:function(){return t.emit(a.MDCMenuSurfaceFoundation.strings.CLOSED_EVENT,{})},notifyOpen:function(){return t.emit(a.MDCMenuSurfaceFoundation.strings.OPENED_EVENT,{})},isElementInContainer:function(e){return t.root_.contains(e)},isRtl:function(){return"rtl"===getComputedStyle(t.root_).getPropertyValue("direction")},setTransformOrigin:function(e){var n=u.getTransformPropertyName(window)+"-origin";t.root_.style.setProperty(n,e)},isFocused:function(){return document.activeElement===t.root_},saveFocus:function(){t.previousFocus_=document.activeElement},restoreFocus:function(){t.root_.contains(document.activeElement)&&t.previousFocus_&&t.previousFocus_.focus&&t.previousFocus_.focus()},isFirstElementFocused:function(){return!!t.firstFocusableElement_&&t.firstFocusableElement_===document.activeElement},isLastElementFocused:function(){return!!t.lastFocusableElement_&&t.lastFocusableElement_===document.activeElement},focusFirstElement:function(){return t.firstFocusableElement_&&t.firstFocusableElement_.focus&&t.firstFocusableElement_.focus()},focusLastElement:function(){return t.lastFocusableElement_&&t.lastFocusableElement_.focus&&t.lastFocusableElement_.focus()},getInnerDimensions:function(){return{width:t.root_.offsetWidth,height:t.root_.offsetHeight}},getAnchorDimensions:function(){return t.anchorElement?t.anchorElement.getBoundingClientRect():null},getWindowDimensions:function(){return{width:window.innerWidth,height:window.innerHeight}},getBodyDimensions:function(){return{width:document.body.clientWidth,height:document.body.clientHeight}},getWindowScroll:function(){return{x:window.pageXOffset,y:window.pageYOffset}},setPosition:function(e){t.root_.style.left="left"in e?e.left+"px":"",t.root_.style.right="right"in e?e.right+"px":"",t.root_.style.top="top"in e?e.top+"px":"",t.root_.style.bottom="bottom"in e?e.bottom+"px":""},setMaxHeight:function(e){t.root_.style.maxHeight=e}};return new a.MDCMenuSurfaceFoundation(e)},e}(r.MDCComponent);e.MDCMenuSurface=c},9:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={ANCHOR:"mdc-menu-surface--anchor",ANIMATING_CLOSED:"mdc-menu-surface--animating-closed",ANIMATING_OPEN:"mdc-menu-surface--animating-open",FIXED:"mdc-menu-surface--fixed",OPEN:"mdc-menu-surface--open",ROOT:"mdc-menu-surface"};e.cssClasses=i;var o={CLOSED_EVENT:"MDCMenuSurface:closed",OPENED_EVENT:"MDCMenuSurface:opened",FOCUSABLE_ELEMENTS:["button:not(:disabled)",'[href]:not([aria-disabled="true"])',"input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)",'[tabindex]:not([tabindex="-1"]):not([aria-disabled="true"])'].join(", ")};e.strings=o;var r={TRANSITION_OPEN_DURATION:120,TRANSITION_CLOSE_DURATION:75,MARGIN_TO_EDGE:32,ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO:.67};e.numbers=r;var s;!function(t){t[t.BOTTOM=1]="BOTTOM",t[t.CENTER=2]="CENTER",t[t.RIGHT=4]="RIGHT",t[t.FLIP_RTL=8]="FLIP_RTL"}(s||(s={})),e.CornerBit=s;var a;!function(t){t[t.TOP_LEFT=0]="TOP_LEFT",t[t.TOP_RIGHT=4]="TOP_RIGHT",t[t.BOTTOM_LEFT=1]="BOTTOM_LEFT",t[t.BOTTOM_RIGHT=5]="BOTTOM_RIGHT",t[t.TOP_START=8]="TOP_START",t[t.TOP_END=12]="TOP_END",t[t.BOTTOM_START=9]="BOTTOM_START",t[t.BOTTOM_END=13]="BOTTOM_END"}(a||(a={})),e.Corner=a}})}); | ||
//# sourceMappingURL=mdc.menuSurface.min.js.map |
@@ -28,3 +28,4 @@ /** | ||
export * from './component'; | ||
export * from './constants'; | ||
export * from './foundation'; | ||
export * from './types'; |
@@ -27,3 +27,4 @@ /** | ||
export * from './component'; | ||
export * from './constants'; | ||
export * from './foundation'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@material/menu-surface", | ||
"version": "1.1.1", | ||
"version": "2.3.0", | ||
"description": "The Material Components for the web menu surface component", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
500651
1
2792
1