@material/menu
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -81,3 +81,3 @@ /*! | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 85); | ||
/******/ return __webpack_require__(__webpack_require__.s = 86); | ||
/******/ }) | ||
@@ -91,32 +91,2 @@ /************************************************************************/ | ||
"use strict"; | ||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__foundation__ = __webpack_require__(1); | ||
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "MDCFoundation", function() { return __WEBPACK_IMPORTED_MODULE_0__foundation__["a"]; }); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component__ = __webpack_require__(2); | ||
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "MDCComponent", function() { return __WEBPACK_IMPORTED_MODULE_1__component__["a"]; }); | ||
/** | ||
* Copyright 2016 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/***/ }), | ||
/***/ 1: | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -226,2 +196,267 @@ | ||
"use strict"; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/** | ||
* Copyright 2016 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/* eslint no-unused-vars: [2, {"args": "none"}] */ | ||
/** | ||
* Adapter for MDC Simple Menu. Provides an interface for managing | ||
* - classes | ||
* - dom | ||
* - focus | ||
* - position | ||
* - dimensions | ||
* - event handlers | ||
* | ||
* Additionally, provides type information for the adapter to the Closure | ||
* compiler. | ||
* | ||
* Implement this adapter for your framework of choice to delegate updates to | ||
* the component in your framework of choice. See architecture documentation | ||
* for more details. | ||
* https://github.com/material-components/material-components-web/blob/master/docs/architecture.md | ||
* | ||
* @record | ||
*/ | ||
var MDCSimpleMenuAdapter = function () { | ||
function MDCSimpleMenuAdapter() { | ||
_classCallCheck(this, MDCSimpleMenuAdapter); | ||
} | ||
_createClass(MDCSimpleMenuAdapter, [{ | ||
key: "addClass", | ||
/** @param {string} className */ | ||
value: function addClass(className) {} | ||
/** @param {string} className */ | ||
}, { | ||
key: "removeClass", | ||
value: function removeClass(className) {} | ||
/** | ||
* @param {string} className | ||
* @return {boolean} | ||
*/ | ||
}, { | ||
key: "hasClass", | ||
value: function hasClass(className) {} | ||
/** @return {boolean} */ | ||
}, { | ||
key: "hasNecessaryDom", | ||
value: function hasNecessaryDom() {} | ||
/** | ||
* @param {EventTarget} target | ||
* @param {string} attributeName | ||
* @return {string} | ||
*/ | ||
}, { | ||
key: "getAttributeForEventTarget", | ||
value: function getAttributeForEventTarget(target, attributeName) {} | ||
/** @return {{ width: number, height: number }} */ | ||
}, { | ||
key: "getInnerDimensions", | ||
value: function getInnerDimensions() {} | ||
/** @return {boolean} */ | ||
}, { | ||
key: "hasAnchor", | ||
value: function hasAnchor() {} | ||
/** @return {{width: number, height: number, top: number, right: number, bottom: number, left: number}} */ | ||
}, { | ||
key: "getAnchorDimensions", | ||
value: function getAnchorDimensions() {} | ||
/** @return {{ width: number, height: number }} */ | ||
}, { | ||
key: "getWindowDimensions", | ||
value: function getWindowDimensions() {} | ||
/** | ||
* @param {number} x | ||
* @param {number} y | ||
*/ | ||
}, { | ||
key: "setScale", | ||
value: function setScale(x, y) {} | ||
/** | ||
* @param {number} x | ||
* @param {number} y | ||
*/ | ||
}, { | ||
key: "setInnerScale", | ||
value: function setInnerScale(x, y) {} | ||
/** @return {number} */ | ||
}, { | ||
key: "getNumberOfItems", | ||
value: function getNumberOfItems() {} | ||
/** | ||
* @param {string} type | ||
* @param {function(!Event)} handler | ||
*/ | ||
}, { | ||
key: "registerInteractionHandler", | ||
value: function registerInteractionHandler(type, handler) {} | ||
/** | ||
* @param {string} type | ||
* @param {function(!Event)} handler | ||
*/ | ||
}, { | ||
key: "deregisterInteractionHandler", | ||
value: function deregisterInteractionHandler(type, handler) {} | ||
/** @param {function(!Event)} handler */ | ||
}, { | ||
key: "registerBodyClickHandler", | ||
value: function registerBodyClickHandler(handler) {} | ||
/** @param {function(!Event)} handler */ | ||
}, { | ||
key: "deregisterBodyClickHandler", | ||
value: function deregisterBodyClickHandler(handler) {} | ||
/** | ||
* @param {number} index | ||
* @return {{top: number, height: number}} | ||
*/ | ||
}, { | ||
key: "getYParamsForItemAtIndex", | ||
value: function getYParamsForItemAtIndex(index) {} | ||
/** | ||
* @param {number} index | ||
* @param {string|null} value | ||
*/ | ||
}, { | ||
key: "setTransitionDelayForItemAtIndex", | ||
value: function setTransitionDelayForItemAtIndex(index, value) {} | ||
/** | ||
* @param {EventTarget} target | ||
* @return {number} | ||
*/ | ||
}, { | ||
key: "getIndexForEventTarget", | ||
value: function getIndexForEventTarget(target) {} | ||
/** @param {{index: number}} evtData */ | ||
}, { | ||
key: "notifySelected", | ||
value: function notifySelected(evtData) {} | ||
}, { | ||
key: "notifyCancel", | ||
value: function notifyCancel() {} | ||
}, { | ||
key: "saveFocus", | ||
value: function saveFocus() {} | ||
}, { | ||
key: "restoreFocus", | ||
value: function restoreFocus() {} | ||
/** @return {boolean} */ | ||
}, { | ||
key: "isFocused", | ||
value: function isFocused() {} | ||
}, { | ||
key: "focus", | ||
value: function focus() {} | ||
/** @return {number} */ | ||
}, { | ||
key: "getFocusedItemIndex", | ||
value: function getFocusedItemIndex() /* number */{} | ||
/** @param {number} index */ | ||
}, { | ||
key: "focusItemAtIndex", | ||
value: function focusItemAtIndex(index) {} | ||
/** @return {boolean} */ | ||
}, { | ||
key: "isRtl", | ||
value: function isRtl() {} | ||
/** @param {string} origin */ | ||
}, { | ||
key: "setTransformOrigin", | ||
value: function setTransformOrigin(origin) {} | ||
/** @param {{ | ||
* top: (string|undefined), | ||
* right: (string|undefined), | ||
* bottom: (string|undefined), | ||
* left: (string|undefined) | ||
* }} position */ | ||
}, { | ||
key: "setPosition", | ||
value: function setPosition(position) {} | ||
/** @return {number} */ | ||
}, { | ||
key: "getAccurateTime", | ||
value: function getAccurateTime() {} | ||
}]); | ||
return MDCSimpleMenuAdapter; | ||
}(); | ||
/* unused harmony default export */ var _unused_webpack_default_export = (MDCSimpleMenuAdapter); | ||
/***/ }), | ||
/***/ 13: | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return cssClasses; }); | ||
@@ -245,2 +480,4 @@ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return strings; }); | ||
*/ | ||
/** @enum {string} */ | ||
var cssClasses = { | ||
@@ -255,2 +492,3 @@ ROOT: 'mdc-simple-menu', | ||
/** @enum {string} */ | ||
var strings = { | ||
@@ -263,2 +501,3 @@ ITEMS_SELECTOR: '.mdc-simple-menu__items', | ||
/** @enum {number} */ | ||
var numbers = { | ||
@@ -284,9 +523,10 @@ // Amount of time to wait before triggering a selected event on the menu. Note that this time | ||
/***/ 13: | ||
/***/ 14: | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__material_base__ = __webpack_require__(0); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__constants__ = __webpack_require__(12); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util__ = __webpack_require__(8); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__material_base_foundation__ = __webpack_require__(0); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__adapter__ = __webpack_require__(12); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__constants__ = __webpack_require__(13); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util__ = __webpack_require__(8); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -324,2 +564,7 @@ | ||
/** | ||
* @extends {MDCFoundation<!MDCSimpleMenuAdapter>} | ||
*/ | ||
var MDCSimpleMenuFoundation = function (_MDCFoundation) { | ||
@@ -330,89 +575,97 @@ _inherits(MDCSimpleMenuFoundation, _MDCFoundation); | ||
key: 'cssClasses', | ||
/** @return enum{cssClasses} */ | ||
get: function get() { | ||
return __WEBPACK_IMPORTED_MODULE_1__constants__["a" /* cssClasses */]; | ||
return __WEBPACK_IMPORTED_MODULE_2__constants__["a" /* cssClasses */]; | ||
} | ||
/** @return enum{strings} */ | ||
}, { | ||
key: 'strings', | ||
get: function get() { | ||
return __WEBPACK_IMPORTED_MODULE_1__constants__["b" /* strings */]; | ||
return __WEBPACK_IMPORTED_MODULE_2__constants__["b" /* strings */]; | ||
} | ||
/** @return enum{numbers} */ | ||
}, { | ||
key: 'numbers', | ||
get: function get() { | ||
return __WEBPACK_IMPORTED_MODULE_1__constants__["c" /* numbers */]; | ||
return __WEBPACK_IMPORTED_MODULE_2__constants__["c" /* numbers */]; | ||
} | ||
/** | ||
* {@see MDCSimpleMenuAdapter} for typing information on parameters and return | ||
* types. | ||
* @return {!MDCSimpleMenuAdapter} | ||
*/ | ||
}, { | ||
key: 'defaultAdapter', | ||
get: function get() { | ||
return { | ||
addClass: function addClass() /* className: string */{}, | ||
removeClass: function removeClass() /* className: string */{}, | ||
hasClass: function hasClass() /* className: string */{}, | ||
hasNecessaryDom: function hasNecessaryDom() { | ||
return (/* boolean */false | ||
); | ||
}, | ||
getAttributeForEventTarget: function getAttributeForEventTarget() /* target: EventTarget, attributeName: string */{}, | ||
getInnerDimensions: function getInnerDimensions() { | ||
return (/* { width: number, height: number } */{} | ||
); | ||
}, | ||
hasAnchor: function hasAnchor() { | ||
return (/* boolean */false | ||
); | ||
}, | ||
getAnchorDimensions: function getAnchorDimensions() { | ||
return ( | ||
/* { width: number, height: number, top: number, right: number, bottom: number, left: number } */{} | ||
); | ||
}, | ||
getWindowDimensions: function getWindowDimensions() { | ||
return (/* { width: number, height: number } */{} | ||
); | ||
}, | ||
setScale: function setScale() /* x: number, y: number */{}, | ||
setInnerScale: function setInnerScale() /* x: number, y: number */{}, | ||
getNumberOfItems: function getNumberOfItems() { | ||
return (/* number */0 | ||
); | ||
}, | ||
registerInteractionHandler: function registerInteractionHandler() /* type: string, handler: EventListener */{}, | ||
deregisterInteractionHandler: function deregisterInteractionHandler() /* type: string, handler: EventListener */{}, | ||
registerBodyClickHandler: function registerBodyClickHandler() /* handler: EventListener */{}, | ||
deregisterBodyClickHandler: function deregisterBodyClickHandler() /* handler: EventListener */{}, | ||
getYParamsForItemAtIndex: function getYParamsForItemAtIndex() { | ||
return (/* index: number */ /* {top: number, height: number} */{} | ||
); | ||
}, | ||
setTransitionDelayForItemAtIndex: function setTransitionDelayForItemAtIndex() /* index: number, value: string */{}, | ||
getIndexForEventTarget: function getIndexForEventTarget() { | ||
return (/* target: EventTarget */ /* number */0 | ||
); | ||
}, | ||
notifySelected: function notifySelected() /* evtData: {index: number} */{}, | ||
notifyCancel: function notifyCancel() {}, | ||
saveFocus: function saveFocus() {}, | ||
restoreFocus: function restoreFocus() {}, | ||
isFocused: function isFocused() { | ||
return (/* boolean */false | ||
); | ||
}, | ||
focus: function focus() {}, | ||
getFocusedItemIndex: function getFocusedItemIndex() { | ||
return (/* number */-1 | ||
); | ||
}, | ||
focusItemAtIndex: function focusItemAtIndex() /* index: number */{}, | ||
isRtl: function isRtl() { | ||
return (/* boolean */false | ||
); | ||
}, | ||
setTransformOrigin: function setTransformOrigin() /* origin: string */{}, | ||
setPosition: function setPosition() /* position: { top: string, right: string, bottom: string, left: string } */{}, | ||
getAccurateTime: function getAccurateTime() { | ||
return (/* number */0 | ||
); | ||
return (/** @type {!MDCSimpleMenuAdapter} */{ | ||
addClass: function addClass() {}, | ||
removeClass: function removeClass() {}, | ||
hasClass: function hasClass() { | ||
return false; | ||
}, | ||
hasNecessaryDom: function hasNecessaryDom() { | ||
return false; | ||
}, | ||
getAttributeForEventTarget: function getAttributeForEventTarget() {}, | ||
getInnerDimensions: function getInnerDimensions() { | ||
return {}; | ||
}, | ||
hasAnchor: function hasAnchor() { | ||
return false; | ||
}, | ||
getAnchorDimensions: function getAnchorDimensions() { | ||
return {}; | ||
}, | ||
getWindowDimensions: function getWindowDimensions() { | ||
return {}; | ||
}, | ||
setScale: function setScale() {}, | ||
setInnerScale: function setInnerScale() {}, | ||
getNumberOfItems: function getNumberOfItems() { | ||
return 0; | ||
}, | ||
registerInteractionHandler: function registerInteractionHandler() {}, | ||
deregisterInteractionHandler: function deregisterInteractionHandler() {}, | ||
registerBodyClickHandler: function registerBodyClickHandler() {}, | ||
deregisterBodyClickHandler: function deregisterBodyClickHandler() {}, | ||
getYParamsForItemAtIndex: function getYParamsForItemAtIndex() { | ||
return {}; | ||
}, | ||
setTransitionDelayForItemAtIndex: function setTransitionDelayForItemAtIndex() {}, | ||
getIndexForEventTarget: function getIndexForEventTarget() { | ||
return 0; | ||
}, | ||
notifySelected: function notifySelected() {}, | ||
notifyCancel: function notifyCancel() {}, | ||
saveFocus: function saveFocus() {}, | ||
restoreFocus: function restoreFocus() {}, | ||
isFocused: function isFocused() { | ||
return false; | ||
}, | ||
focus: function focus() {}, | ||
getFocusedItemIndex: function getFocusedItemIndex() { | ||
return -1; | ||
}, | ||
focusItemAtIndex: function focusItemAtIndex() {}, | ||
isRtl: function isRtl() { | ||
return false; | ||
}, | ||
setTransformOrigin: function setTransformOrigin() {}, | ||
setPosition: function setPosition() {}, | ||
getAccurateTime: function getAccurateTime() { | ||
return 0; | ||
} | ||
} | ||
}; | ||
); | ||
} | ||
/** @param {!MDCSimpleMenuAdapter} adapter */ | ||
}]); | ||
@@ -423,2 +676,3 @@ | ||
/** @private {function(!Event)} */ | ||
var _this = _possibleConstructorReturn(this, (MDCSimpleMenuFoundation.__proto__ || Object.getPrototypeOf(MDCSimpleMenuFoundation)).call(this, _extends(MDCSimpleMenuFoundation.defaultAdapter, adapter))); | ||
@@ -429,8 +683,11 @@ | ||
}; | ||
/** @private {function(!Event)} */ | ||
_this.keydownHandler_ = function (evt) { | ||
return _this.handleKeyboardDown_(evt); | ||
}; | ||
/** @private {function(!Event)} */ | ||
_this.keyupHandler_ = function (evt) { | ||
return _this.handleKeyboardUp_(evt); | ||
}; | ||
/** @private {function(!Event)} */ | ||
_this.documentClickHandler_ = function (evt) { | ||
@@ -440,11 +697,26 @@ _this.adapter_.notifyCancel(); | ||
}; | ||
/** @private {boolean} */ | ||
_this.isOpen_ = false; | ||
/** @private {number} */ | ||
_this.startScaleX_ = 0; | ||
/** @private {number} */ | ||
_this.startScaleY_ = 0; | ||
/** @private {number} */ | ||
_this.targetScale_ = 1; | ||
/** @private {number} */ | ||
_this.scaleX_ = 0; | ||
/** @private {number} */ | ||
_this.scaleY_ = 0; | ||
/** @private {boolean} */ | ||
_this.running_ = false; | ||
/** @private {number} */ | ||
_this.selectedTriggerTimerId_ = 0; | ||
/** @private {number} */ | ||
_this.animationRequestId_ = 0; | ||
/** @private {!{ width: number, height: number }} */ | ||
_this.dimensions_; | ||
/** @private {number} */ | ||
_this.startTime_; | ||
/** @private {number} */ | ||
_this.itemHeight_; | ||
return _this; | ||
@@ -489,3 +761,6 @@ } | ||
// Calculate transition delays for individual menu items, so that they fade in one at a time. | ||
/** | ||
* Calculates transition delays for individual menu items, so that they fade in one at a time. | ||
* @private | ||
*/ | ||
@@ -521,3 +796,6 @@ }, { | ||
// Remove transition delays from menu items. | ||
/** | ||
* Removes transition delays from menu items. | ||
* @private | ||
*/ | ||
@@ -533,3 +811,6 @@ }, { | ||
// Animate menu opening or closing. | ||
/** | ||
* Animates menu opening or closing. | ||
* @private | ||
*/ | ||
@@ -551,6 +832,6 @@ }, { | ||
var currentTime = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__util__["b" /* clamp */])((time - this.startTime_) / TRANSITION_DURATION_MS); | ||
var currentTime = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["clamp"])((time - this.startTime_) / TRANSITION_DURATION_MS); | ||
// Animate X axis very slowly, so that only the Y axis animation is visible during fade-out. | ||
var currentTimeX = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__util__["b" /* clamp */])((currentTime - TRANSITION_SCALE_ADJUSTMENT_X) / (1 - TRANSITION_SCALE_ADJUSTMENT_X)); | ||
var currentTimeX = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["clamp"])((currentTime - TRANSITION_SCALE_ADJUSTMENT_X) / (1 - TRANSITION_SCALE_ADJUSTMENT_X)); | ||
// No time-shifting on the Y axis when closing. | ||
@@ -566,10 +847,10 @@ var currentTimeY = currentTime; | ||
// X axis moves faster, so time-shift forward. | ||
currentTimeX = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__util__["b" /* clamp */])(currentTime + TRANSITION_SCALE_ADJUSTMENT_X); | ||
currentTimeX = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["clamp"])(currentTime + TRANSITION_SCALE_ADJUSTMENT_X); | ||
// Y axis moves slower, so time-shift backwards and adjust speed by the difference. | ||
currentTimeY = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__util__["b" /* clamp */])((currentTime - TRANSITION_SCALE_ADJUSTMENT_Y) / (1 - TRANSITION_SCALE_ADJUSTMENT_Y)); | ||
currentTimeY = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["clamp"])((currentTime - TRANSITION_SCALE_ADJUSTMENT_Y) / (1 - TRANSITION_SCALE_ADJUSTMENT_Y)); | ||
} | ||
// Apply cubic bezier easing independently to each axis. | ||
var easeX = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__util__["c" /* bezierProgress */])(currentTimeX, TRANSITION_X1, TRANSITION_Y1, TRANSITION_X2, TRANSITION_Y2); | ||
var easeY = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__util__["c" /* bezierProgress */])(currentTimeY, TRANSITION_X1, TRANSITION_Y1, TRANSITION_X2, TRANSITION_Y2); | ||
var easeX = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["bezierProgress"])(currentTimeX, TRANSITION_X1, TRANSITION_Y1, TRANSITION_X2, TRANSITION_Y2); | ||
var easeY = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["bezierProgress"])(currentTimeY, TRANSITION_X1, TRANSITION_Y1, TRANSITION_X2, TRANSITION_Y2); | ||
@@ -598,3 +879,6 @@ // Calculate the scales to apply to the outer container and inner container. | ||
// Starts the open or close animation. | ||
/** | ||
* Starts the open or close animation. | ||
* @private | ||
*/ | ||
@@ -619,2 +903,8 @@ }, { | ||
} | ||
/** | ||
* @param {?number} focusIndex | ||
* @private | ||
*/ | ||
}, { | ||
@@ -635,3 +925,8 @@ key: 'focusOnOpen_', | ||
// Handle keys that we want to repeat on hold (tab and arrows). | ||
/** | ||
* Handle keys that we want to repeat on hold (tab and arrows). | ||
* @param {!Event} evt | ||
* @return {boolean} | ||
* @private | ||
*/ | ||
@@ -692,3 +987,8 @@ }, { | ||
// Handle keys that we don't want to repeat on hold (Enter, Space, Escape). | ||
/** | ||
* Handle keys that we don't want to repeat on hold (Enter, Space, Escape). | ||
* @param {!Event} evt | ||
* @return {boolean} | ||
* @private | ||
*/ | ||
@@ -721,2 +1021,8 @@ }, { | ||
} | ||
/** | ||
* @param {!Event} evt | ||
* @private | ||
*/ | ||
}, { | ||
@@ -727,3 +1033,3 @@ key: 'handlePossibleSelected_', | ||
if (this.adapter_.getAttributeForEventTarget(evt.target, __WEBPACK_IMPORTED_MODULE_1__constants__["b" /* strings */].ARIA_DISABLED_ATTR) === 'true') { | ||
if (this.adapter_.getAttributeForEventTarget(evt.target, __WEBPACK_IMPORTED_MODULE_2__constants__["b" /* strings */].ARIA_DISABLED_ATTR) === 'true') { | ||
return; | ||
@@ -743,4 +1049,7 @@ } | ||
_this4.adapter_.notifySelected({ index: targetIndex }); | ||
}, __WEBPACK_IMPORTED_MODULE_1__constants__["c" /* numbers */].SELECTED_TRIGGER_DELAY); | ||
}, __WEBPACK_IMPORTED_MODULE_2__constants__["c" /* numbers */].SELECTED_TRIGGER_DELAY); | ||
} | ||
/** @private */ | ||
}, { | ||
@@ -793,3 +1102,6 @@ key: 'autoPosition_', | ||
// Open the menu. | ||
/** | ||
* Open the menu. | ||
* @param {{focusIndex: ?number}=} options | ||
*/ | ||
@@ -819,3 +1131,6 @@ }, { | ||
// Close the menu. | ||
/** | ||
* Closes the menu. | ||
* @param {Event=} evt | ||
*/ | ||
@@ -829,3 +1144,3 @@ }, { | ||
var targetIsDisabled = evt ? this.adapter_.getAttributeForEventTarget(evt.target, __WEBPACK_IMPORTED_MODULE_1__constants__["b" /* strings */].ARIA_DISABLED_ATTR) === 'true' : false; | ||
var targetIsDisabled = evt ? this.adapter_.getAttributeForEventTarget(evt.target, __WEBPACK_IMPORTED_MODULE_2__constants__["b" /* strings */].ARIA_DISABLED_ATTR) === 'true' : false; | ||
@@ -846,2 +1161,5 @@ if (targetIsDisabled) { | ||
} | ||
/** @return {boolean} */ | ||
}, { | ||
@@ -855,3 +1173,3 @@ key: 'isOpen', | ||
return MDCSimpleMenuFoundation; | ||
}(__WEBPACK_IMPORTED_MODULE_0__material_base__["MDCFoundation"]); | ||
}(__WEBPACK_IMPORTED_MODULE_0__material_base_foundation__["a" /* default */]); | ||
@@ -862,3 +1180,3 @@ /* harmony default export */ __webpack_exports__["a"] = (MDCSimpleMenuFoundation); | ||
/***/ 14: | ||
/***/ 15: | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
@@ -868,4 +1186,4 @@ | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return MDCSimpleMenu; }); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__material_base__ = __webpack_require__(0); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__foundation__ = __webpack_require__(13); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__material_base_component__ = __webpack_require__(2); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__foundation__ = __webpack_require__(14); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util__ = __webpack_require__(8); | ||
@@ -903,17 +1221,40 @@ /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return __WEBPACK_IMPORTED_MODULE_1__foundation__["a"]; }); | ||
/** | ||
* @extends MDCComponent<!MDCSimpleMenuFoundation> | ||
*/ | ||
var MDCSimpleMenu = function (_MDCComponent) { | ||
_inherits(MDCSimpleMenu, _MDCComponent); | ||
/** @param {...?} args */ | ||
function MDCSimpleMenu() { | ||
var _ref; | ||
_classCallCheck(this, MDCSimpleMenu); | ||
return _possibleConstructorReturn(this, (MDCSimpleMenu.__proto__ || Object.getPrototypeOf(MDCSimpleMenu)).apply(this, arguments)); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
/** @private {!Element} */ | ||
var _this = _possibleConstructorReturn(this, (_ref = MDCSimpleMenu.__proto__ || Object.getPrototypeOf(MDCSimpleMenu)).call.apply(_ref, [this].concat(args))); | ||
_this.previousFocus_; | ||
return _this; | ||
} | ||
/** | ||
* @param {!Element} root | ||
* @return {!MDCSimpleMenu} | ||
*/ | ||
_createClass(MDCSimpleMenu, [{ | ||
key: 'show', | ||
/** @param {{focusIndex: ?number}=} options */ | ||
value: function show() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
_ref$focusIndex = _ref.focusIndex, | ||
focusIndex = _ref$focusIndex === undefined ? null : _ref$focusIndex; | ||
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
_ref2$focusIndex = _ref2.focusIndex, | ||
focusIndex = _ref2$focusIndex === undefined ? null : _ref2$focusIndex; | ||
@@ -928,6 +1269,12 @@ this.foundation_.open({ focusIndex: focusIndex }); | ||
/* Return the item container element inside the component. */ | ||
/** | ||
* Return the item container element inside the component. | ||
* @return {?Element} | ||
*/ | ||
}, { | ||
key: 'getDefaultFoundation', | ||
/** @return {!MDCSimpleMenuFoundation} */ | ||
value: function getDefaultFoundation() { | ||
@@ -967,6 +1314,6 @@ var _this2 = this; | ||
setScale: function setScale(x, y) { | ||
_this2.root_.style[__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__util__["a" /* getTransformPropertyName */])(window)] = 'scale(' + x + ', ' + y + ')'; | ||
_this2.root_.style[__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__util__["getTransformPropertyName"])(window)] = 'scale(' + x + ', ' + y + ')'; | ||
}, | ||
setInnerScale: function setInnerScale(x, y) { | ||
_this2.itemsContainer_.style[__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__util__["a" /* getTransformPropertyName */])(window)] = 'scale(' + x + ', ' + y + ')'; | ||
_this2.itemsContainer_.style[__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__util__["getTransformPropertyName"])(window)] = 'scale(' + x + ', ' + y + ')'; | ||
}, | ||
@@ -1008,3 +1355,3 @@ getNumberOfItems: function getNumberOfItems() { | ||
notifyCancel: function notifyCancel() { | ||
return _this2.emit(__WEBPACK_IMPORTED_MODULE_1__foundation__["a" /* default */].strings.CANCEL_EVENT); | ||
return _this2.emit(__WEBPACK_IMPORTED_MODULE_1__foundation__["a" /* default */].strings.CANCEL_EVENT, {}); | ||
}, | ||
@@ -1035,3 +1382,3 @@ saveFocus: function saveFocus() { | ||
setTransformOrigin: function setTransformOrigin(origin) { | ||
_this2.root_.style[__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__util__["a" /* getTransformPropertyName */])(window) + '-origin'] = origin; | ||
_this2.root_.style[__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__util__["getTransformPropertyName"])(window) + '-origin'] = origin; | ||
}, | ||
@@ -1051,5 +1398,11 @@ setPosition: function setPosition(position) { | ||
key: 'open', | ||
/** @return {boolean} */ | ||
get: function get() { | ||
return this.foundation_.isOpen(); | ||
}, | ||
} | ||
/** @param {boolean} value */ | ||
, | ||
set: function set(value) { | ||
@@ -1068,5 +1421,7 @@ if (value) { | ||
/* Return the items within the menu. Note that this only contains the set of elements within | ||
/** | ||
* Return the items within the menu. Note that this only contains the set of elements within | ||
* the items container that are proper list items, and not supplemental / presentational DOM | ||
* elements. | ||
* @return {!Array<!Element>} | ||
*/ | ||
@@ -1089,3 +1444,3 @@ | ||
return MDCSimpleMenu; | ||
}(__WEBPACK_IMPORTED_MODULE_0__material_base__["MDCComponent"]); | ||
}(__WEBPACK_IMPORTED_MODULE_0__material_base_component__["a" /* default */]); | ||
@@ -1098,3 +1453,3 @@ /***/ }), | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__foundation__ = __webpack_require__(1); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__foundation__ = __webpack_require__(0); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -1156,3 +1511,3 @@ | ||
/** @private {!Element} */ | ||
/** @protected {!Element} */ | ||
this.root_ = root; | ||
@@ -1239,3 +1594,3 @@ | ||
* @param {!Object} evtData | ||
* @param {boolean} shouldBubble | ||
* @param {boolean=} shouldBubble | ||
*/ | ||
@@ -1274,5 +1629,6 @@ | ||
"use strict"; | ||
/* harmony export (immutable) */ __webpack_exports__["a"] = getTransformPropertyName; | ||
/* harmony export (immutable) */ __webpack_exports__["b"] = clamp; | ||
/* harmony export (immutable) */ __webpack_exports__["c"] = bezierProgress; | ||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | ||
/* harmony export (immutable) */ __webpack_exports__["getTransformPropertyName"] = getTransformPropertyName; | ||
/* harmony export (immutable) */ __webpack_exports__["clamp"] = clamp; | ||
/* harmony export (immutable) */ __webpack_exports__["bezierProgress"] = bezierProgress; | ||
/** | ||
@@ -1294,5 +1650,11 @@ * Copyright 2016 Google Inc. All Rights Reserved. | ||
/** @type {string|undefined} */ | ||
var storedTransformPropertyName_ = void 0; | ||
// Returns the name of the correct transform property to use on the current browser. | ||
/** | ||
* Returns the name of the correct transform property to use on the current browser. | ||
* @param {!Window} globalObj | ||
* @param {boolean=} forceRefresh | ||
* @return {string} | ||
*/ | ||
function getTransformPropertyName(globalObj) { | ||
@@ -1310,3 +1672,9 @@ var forceRefresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
// Clamps a value between the minimum and the maximum, returning the clamped value. | ||
/** | ||
* Clamps a value between the minimum and the maximum, returning the clamped value. | ||
* @param {number} value | ||
* @param {number} min | ||
* @param {number} max | ||
* @return {number} | ||
*/ | ||
function clamp(value) { | ||
@@ -1319,10 +1687,18 @@ var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
// Returns the easing value to apply at time t, for a given cubic bezier curve. | ||
// Control points P0 and P3 are assumed to be (0,0) and (1,1), respectively. | ||
// Paramters are as follows: | ||
// - time: The current time in the animation, scaled between 0 and 1. | ||
// - x1: The x value of control point P1. | ||
// - y1: The y value of control point P1. | ||
// - x2: The x value of control point P2. | ||
// - y2: The y value of control point P2. | ||
/** | ||
* Returns the easing value to apply at time t, for a given cubic bezier curve. | ||
* Control points P0 and P3 are assumed to be (0,0) and (1,1), respectively. | ||
* Parameters are as follows: | ||
* - time: The current time in the animation, scaled between 0 and 1. | ||
* - x1: The x value of control point P1. | ||
* - y1: The y value of control point P1. | ||
* - x2: The x value of control point P2. | ||
* - y2: The y value of control point P2. | ||
* @param {number} time | ||
* @param {number} x1 | ||
* @param {number} y1 | ||
* @param {number} x2 | ||
* @param {number} y2 | ||
* @return {number} | ||
*/ | ||
function bezierProgress(time, x1, y1, x2, y2) { | ||
@@ -1332,6 +1708,12 @@ return getBezierCoordinate_(solvePositionFromXValue_(time, x1, x2), y1, y2); | ||
// Compute a single coordinate at a position point between 0 and 1. | ||
// c1 and c2 are the matching coordinate on control points P1 and P2, respectively. | ||
// Control points P0 and P3 are assumed to be (0,0) and (1,1), respectively. | ||
// Adapted from https://github.com/google/closure-library/blob/master/closure/goog/math/bezier.js. | ||
/** | ||
* Compute a single coordinate at a position point between 0 and 1. | ||
* c1 and c2 are the matching coordinate on control points P1 and P2, respectively. | ||
* Control points P0 and P3 are assumed to be (0,0) and (1,1), respectively. | ||
* Adapted from https://github.com/google/closure-library/blob/master/closure/goog/math/bezier.js. | ||
* @param {number} t | ||
* @param {number} c1 | ||
* @param {number} c2 | ||
* @return {number} | ||
*/ | ||
function getBezierCoordinate_(t, c1, c2) { | ||
@@ -1356,4 +1738,10 @@ // Special case start and end. | ||
// Project a point onto the Bezier curve, from a given X. Calculates the position t along the curve. | ||
// Adapted from https://github.com/google/closure-library/blob/master/closure/goog/math/bezier.js. | ||
/** | ||
* Project a point onto the Bezier curve, from a given X. Calculates the position t along the curve. | ||
* Adapted from https://github.com/google/closure-library/blob/master/closure/goog/math/bezier.js. | ||
* @param {number} xVal | ||
* @param {number} x1 | ||
* @param {number} x2 | ||
* @return {number} | ||
*/ | ||
function solvePositionFromXValue_(xVal, x1, x2) { | ||
@@ -1411,3 +1799,3 @@ var EPSILON = 1e-6; | ||
/***/ 85: | ||
/***/ 86: | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1425,5 +1813,7 @@ | ||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__simple__ = __webpack_require__(14); | ||
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "MDCSimpleMenu", function() { return __WEBPACK_IMPORTED_MODULE_0__simple__["a"]; }); | ||
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "MDCSimpleMenuFoundation", function() { return __WEBPACK_IMPORTED_MODULE_0__simple__["b"]; }); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util__ = __webpack_require__(8); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__simple__ = __webpack_require__(15); | ||
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "MDCSimpleMenu", function() { return __WEBPACK_IMPORTED_MODULE_1__simple__["a"]; }); | ||
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "MDCSimpleMenuFoundation", function() { return __WEBPACK_IMPORTED_MODULE_1__simple__["b"]; }); | ||
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "util", function() { return __WEBPACK_IMPORTED_MODULE_0__util__; }); | ||
/** | ||
@@ -1447,2 +1837,4 @@ * Copyright 2016 Google Inc. All Rights Reserved. | ||
/***/ }) | ||
@@ -1449,0 +1841,0 @@ |
@@ -6,2 +6,2 @@ /*! | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.menu=t():(e.mdc=e.mdc||{},e.mdc.menu=t())}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/assets/",t(t.s=85)}({0:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1);n.d(t,"MDCFoundation",function(){return r.a});var i=n(2);n.d(t,"MDCComponent",function(){return i.a})},1:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.adapter_=t}return i(e,null,[{key:"cssClasses",get:function(){return{}}},{key:"strings",get:function(){return{}}},{key:"numbers",get:function(){return{}}},{key:"defaultAdapter",get:function(){return{}}}]),i(e,[{key:"init",value:function(){}},{key:"destroy",value:function(){}}]),e}();t.a=o},12:function(e,t,n){"use strict";n.d(t,"a",function(){return r}),n.d(t,"b",function(){return i}),n.d(t,"c",function(){return o});var r={ROOT:"mdc-simple-menu",OPEN:"mdc-simple-menu--open",ANIMATING:"mdc-simple-menu--animating",TOP_RIGHT:"mdc-simple-menu--open-from-top-right",BOTTOM_LEFT:"mdc-simple-menu--open-from-bottom-left",BOTTOM_RIGHT:"mdc-simple-menu--open-from-bottom-right"},i={ITEMS_SELECTOR:".mdc-simple-menu__items",SELECTED_EVENT:"MDCSimpleMenu:selected",CANCEL_EVENT:"MDCSimpleMenu:cancel",ARIA_DISABLED_ATTR:"aria-disabled"},o={SELECTED_TRIGGER_DELAY:50,TRANSITION_DURATION_MS:300,TRANSITION_SCALE_ADJUSTMENT_X:.5,TRANSITION_SCALE_ADJUSTMENT_Y:.2,TRANSITION_X1:0,TRANSITION_Y1:0,TRANSITION_X2:.2,TRANSITION_Y2:1}},13:function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=n(0),u=n(12),c=n(8),l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},f=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),d=function(e){function t(e){i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,l(t.defaultAdapter,e)));return n.clickHandler_=function(e){return n.handlePossibleSelected_(e)},n.keydownHandler_=function(e){return n.handleKeyboardDown_(e)},n.keyupHandler_=function(e){return n.handleKeyboardUp_(e)},n.documentClickHandler_=function(e){n.adapter_.notifyCancel(),n.close(e)},n.isOpen_=!1,n.startScaleX_=0,n.startScaleY_=0,n.targetScale_=1,n.scaleX_=0,n.scaleY_=0,n.running_=!1,n.selectedTriggerTimerId_=0,n.animationRequestId_=0,n}return a(t,e),f(t,null,[{key:"cssClasses",get:function(){return u.a}},{key:"strings",get:function(){return u.b}},{key:"numbers",get:function(){return u.c}},{key:"defaultAdapter",get:function(){return{addClass:function(){},removeClass:function(){},hasClass:function(){},hasNecessaryDom:function(){return!1},getAttributeForEventTarget:function(){},getInnerDimensions:function(){return{}},hasAnchor:function(){return!1},getAnchorDimensions:function(){return{}},getWindowDimensions:function(){return{}},setScale:function(){},setInnerScale:function(){},getNumberOfItems:function(){return 0},registerInteractionHandler:function(){},deregisterInteractionHandler:function(){},registerBodyClickHandler:function(){},deregisterBodyClickHandler:function(){},getYParamsForItemAtIndex:function(){return{}},setTransitionDelayForItemAtIndex:function(){},getIndexForEventTarget:function(){return 0},notifySelected:function(){},notifyCancel:function(){},saveFocus:function(){},restoreFocus:function(){},isFocused:function(){return!1},focus:function(){},getFocusedItemIndex:function(){return-1},focusItemAtIndex:function(){},isRtl:function(){return!1},setTransformOrigin:function(){},setPosition:function(){},getAccurateTime:function(){return 0}}}}]),f(t,[{key:"init",value:function(){var e=t.cssClasses,n=e.ROOT,r=e.OPEN;if(!this.adapter_.hasClass(n))throw new Error(n+" class required in root element.");if(!this.adapter_.hasNecessaryDom())throw new Error("Required DOM nodes missing in "+n+" component.");this.adapter_.hasClass(r)&&(this.isOpen_=!0),this.adapter_.registerInteractionHandler("click",this.clickHandler_),this.adapter_.registerInteractionHandler("keyup",this.keyupHandler_),this.adapter_.registerInteractionHandler("keydown",this.keydownHandler_)}},{key:"destroy",value:function(){clearTimeout(this.selectedTriggerTimerId_),cancelAnimationFrame(this.animationRequestId_),this.adapter_.deregisterInteractionHandler("click",this.clickHandler_),this.adapter_.deregisterInteractionHandler("keyup",this.keyupHandler_),this.adapter_.deregisterInteractionHandler("keydown",this.keydownHandler_),this.adapter_.deregisterBodyClickHandler(this.documentClickHandler_)}},{key:"applyTransitionDelays_",value:function(){for(var e=t.cssClasses,n=e.BOTTOM_LEFT,r=e.BOTTOM_RIGHT,i=this.adapter_.getNumberOfItems(),o=this.dimensions_.height,a=t.numbers.TRANSITION_DURATION_MS/1e3,s=t.numbers.TRANSITION_SCALE_ADJUSTMENT_Y,u=0;u<i;u++){var c=this.adapter_.getYParamsForItemAtIndex(u),l=c.top,f=c.height;this.itemHeight_=f;var d=l/o;(this.adapter_.hasClass(n)||this.adapter_.hasClass(r))&&(d=(o-l-f)/o);var _=(s+d*(1-s))*a;this.adapter_.setTransitionDelayForItemAtIndex(u,_.toFixed(3)+"s")}}},{key:"removeTransitionDelays_",value:function(){for(var e=this.adapter_.getNumberOfItems(),t=0;t<e;t++)this.adapter_.setTransitionDelayForItemAtIndex(t,null)}},{key:"animationLoop_",value:function(){var e=this,r=this.adapter_.getAccurateTime(),i=t.numbers,o=i.TRANSITION_DURATION_MS,a=i.TRANSITION_X1,s=i.TRANSITION_Y1,u=i.TRANSITION_X2,l=i.TRANSITION_Y2,f=i.TRANSITION_SCALE_ADJUSTMENT_X,d=i.TRANSITION_SCALE_ADJUSTMENT_Y,_=n.i(c.b)((r-this.startTime_)/o),h=n.i(c.b)((_-f)/(1-f)),m=_,p=this.startScaleY_;1===this.targetScale_&&(this.itemHeight_&&(p=Math.max(this.itemHeight_/this.dimensions_.height,p)),h=n.i(c.b)(_+f),m=n.i(c.b)((_-d)/(1-d)));var y=n.i(c.c)(h,a,s,u,l),g=n.i(c.c)(m,a,s,u,l);this.scaleX_=this.startScaleX_+(this.targetScale_-this.startScaleX_)*y;var v=1/(0===this.scaleX_?1:this.scaleX_);this.scaleY_=p+(this.targetScale_-p)*g;var I=1/(0===this.scaleY_?1:this.scaleY_);this.adapter_.setScale(this.scaleX_,this.scaleY_),this.adapter_.setInnerScale(v,I),_<1?this.animationRequestId_=requestAnimationFrame(function(){return e.animationLoop_()}):(this.animationRequestId_=0,this.running_=!1,this.adapter_.removeClass(t.cssClasses.ANIMATING))}},{key:"animateMenu_",value:function(){var e=this;this.startTime_=this.adapter_.getAccurateTime(),this.startScaleX_=this.scaleX_,this.startScaleY_=this.scaleY_,this.targetScale_=this.isOpen_?1:0,this.running_||(this.running_=!0,this.animationRequestId_=requestAnimationFrame(function(){return e.animationLoop_()}))}},{key:"focusOnOpen_",value:function(e){null===e?(this.adapter_.focus(),this.adapter_.isFocused()||this.adapter_.focusItemAtIndex(0)):this.adapter_.focusItemAtIndex(e)}},{key:"handleKeyboardDown_",value:function(e){if(e.altKey||e.ctrlKey||e.metaKey)return!0;var t=e.keyCode,n=e.key,r=e.shiftKey,i="Tab"===n||9===t,o="ArrowUp"===n||38===t,a="ArrowDown"===n||40===t,s="Space"===n||32===t,u=this.adapter_.getFocusedItemIndex(),c=this.adapter_.getNumberOfItems()-1;return r&&i&&0===u?(this.adapter_.focusItemAtIndex(c),e.preventDefault(),!1):!r&&i&&u===c?(this.adapter_.focusItemAtIndex(0),e.preventDefault(),!1):((o||a||s)&&e.preventDefault(),o?0===u||this.adapter_.isFocused()?this.adapter_.focusItemAtIndex(c):this.adapter_.focusItemAtIndex(u-1):a&&(u===c||this.adapter_.isFocused()?this.adapter_.focusItemAtIndex(0):this.adapter_.focusItemAtIndex(u+1)),!0)}},{key:"handleKeyboardUp_",value:function(e){if(e.altKey||e.ctrlKey||e.metaKey)return!0;var t=e.keyCode,n=e.key,r="Enter"===n||13===t,i="Space"===n||32===t,o="Escape"===n||27===t;return(r||i)&&this.handlePossibleSelected_(e),o&&(this.adapter_.notifyCancel(),this.close()),!0}},{key:"handlePossibleSelected_",value:function(e){var t=this;if("true"!==this.adapter_.getAttributeForEventTarget(e.target,u.b.ARIA_DISABLED_ATTR)){var n=this.adapter_.getIndexForEventTarget(e.target);n<0||this.selectedTriggerTimerId_||(this.selectedTriggerTimerId_=setTimeout(function(){t.selectedTriggerTimerId_=0,t.close(),t.adapter_.notifySelected({index:n})},u.c.SELECTED_TRIGGER_DELAY))}}},{key:"autoPosition_",value:function(){var e;if(this.adapter_.hasAnchor()){var t="top",n="left",i=this.adapter_.getAnchorDimensions(),o=this.adapter_.getWindowDimensions(),a=i.top+this.dimensions_.height-o.height,s=this.dimensions_.height-i.bottom;a>0&&s<a&&(t="bottom");var u=i.left+this.dimensions_.width-o.width,c=this.dimensions_.width-i.right,l=u>0,f=c>0;this.adapter_.isRtl()?(n="right",f&&u<c&&(n="left")):l&&c<u&&(n="right");var d=(e={},r(e,n,"0"),r(e,t,"0"),e);this.adapter_.setTransformOrigin(t+" "+n),this.adapter_.setPosition(d)}}},{key:"open",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.focusIndex,i=void 0===r?null:r;this.adapter_.saveFocus(),this.adapter_.addClass(t.cssClasses.ANIMATING),this.animationRequestId_=requestAnimationFrame(function(){e.dimensions_=e.adapter_.getInnerDimensions(),e.applyTransitionDelays_(),e.autoPosition_(),e.animateMenu_(),e.adapter_.addClass(t.cssClasses.OPEN),e.focusOnOpen_(i),e.adapter_.registerBodyClickHandler(e.documentClickHandler_)}),this.isOpen_=!0}},{key:"close",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;!!n&&"true"===this.adapter_.getAttributeForEventTarget(n.target,u.b.ARIA_DISABLED_ATTR)||(this.adapter_.deregisterBodyClickHandler(this.documentClickHandler_),this.adapter_.addClass(t.cssClasses.ANIMATING),requestAnimationFrame(function(){e.removeTransitionDelays_(),e.animateMenu_(),e.adapter_.removeClass(t.cssClasses.OPEN)}),this.isOpen_=!1,this.adapter_.restoreFocus())}},{key:"isOpen",value:function(){return this.isOpen_}}]),t}(s.MDCFoundation);t.a=d},14:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}n.d(t,"a",function(){return l});var a=n(0),s=n(13),u=n(8);n.d(t,"b",function(){return s.a});var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),c(t,[{key:"show",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.focusIndex,n=void 0===t?null:t;this.foundation_.open({focusIndex:n})}},{key:"hide",value:function(){this.foundation_.close()}},{key:"getDefaultFoundation",value:function(){var e=this;return new s.a({addClass:function(t){return e.root_.classList.add(t)},removeClass:function(t){return e.root_.classList.remove(t)},hasClass:function(t){return e.root_.classList.contains(t)},hasNecessaryDom:function(){return Boolean(e.itemsContainer_)},getAttributeForEventTarget:function(e,t){return e.getAttribute(t)},getInnerDimensions:function(){var t=e.itemsContainer_;return{width:t.offsetWidth,height:t.offsetHeight}},hasAnchor:function(){return e.root_.parentElement&&e.root_.parentElement.classList.contains("mdc-menu-anchor")},getAnchorDimensions:function(){return e.root_.parentElement.getBoundingClientRect()},getWindowDimensions:function(){return{width:window.innerWidth,height:window.innerHeight}},setScale:function(t,r){e.root_.style[n.i(u.a)(window)]="scale("+t+", "+r+")"},setInnerScale:function(t,r){e.itemsContainer_.style[n.i(u.a)(window)]="scale("+t+", "+r+")"},getNumberOfItems:function(){return e.items.length},registerInteractionHandler:function(t,n){return e.root_.addEventListener(t,n)},deregisterInteractionHandler:function(t,n){return e.root_.removeEventListener(t,n)},registerBodyClickHandler:function(e){return document.body.addEventListener("click",e)},deregisterBodyClickHandler:function(e){return document.body.removeEventListener("click",e)},getYParamsForItemAtIndex:function(t){var n=e.items[t];return{top:n.offsetTop,height:n.offsetHeight}},setTransitionDelayForItemAtIndex:function(t,n){return e.items[t].style.setProperty("transition-delay",n)},getIndexForEventTarget:function(t){return e.items.indexOf(t)},notifySelected:function(t){return e.emit(s.a.strings.SELECTED_EVENT,{index:t.index,item:e.items[t.index]})},notifyCancel:function(){return e.emit(s.a.strings.CANCEL_EVENT)},saveFocus:function(){e.previousFocus_=document.activeElement},restoreFocus:function(){e.previousFocus_&&e.previousFocus_.focus()},isFocused:function(){return document.activeElement===e.root_},focus:function(){return e.root_.focus()},getFocusedItemIndex:function(){return e.items.indexOf(document.activeElement)},focusItemAtIndex:function(t){return e.items[t].focus()},isRtl:function(){return"rtl"===getComputedStyle(e.root_).getPropertyValue("direction")},setTransformOrigin:function(t){e.root_.style[n.i(u.a)(window)+"-origin"]=t},setPosition:function(t){e.root_.style.left="left"in t?t.left:null,e.root_.style.right="right"in t?t.right:null,e.root_.style.top="top"in t?t.top:null,e.root_.style.bottom="bottom"in t?t.bottom:null},getAccurateTime:function(){return window.performance.now()}})}},{key:"open",get:function(){return this.foundation_.isOpen()},set:function(e){e?this.foundation_.open():this.foundation_.close()}},{key:"itemsContainer_",get:function(){return this.root_.querySelector(s.a.strings.ITEMS_SELECTOR)}},{key:"items",get:function(){var e=this.itemsContainer_;return[].slice.call(e.querySelectorAll(".mdc-list-item[role]"))}}],[{key:"attachTo",value:function(e){return new t(e)}}]),t}(a.MDCComponent)},2:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(1),o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;r(this,e),this.root_=t;for(var i=arguments.length,o=Array(i>2?i-2:0),a=2;a<i;a++)o[a-2]=arguments[a];this.initialize.apply(this,o),this.foundation_=void 0===n?this.getDefaultFoundation():n,this.foundation_.init(),this.initialSyncWithDOM()}return o(e,null,[{key:"attachTo",value:function(t){return new e(t,new i.a)}}]),o(e,[{key:"initialize",value:function(){}},{key:"getDefaultFoundation",value:function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")}},{key:"initialSyncWithDOM",value:function(){}},{key:"destroy",value:function(){this.foundation_.destroy()}},{key:"listen",value:function(e,t){this.root_.addEventListener(e,t)}},{key:"unlisten",value:function(e,t){this.root_.removeEventListener(e,t)}},{key:"emit",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=void 0;"function"==typeof CustomEvent?r=new CustomEvent(e,{detail:t,bubbles:n}):(r=document.createEvent("CustomEvent"),r.initCustomEvent(e,n,!1,t)),this.root_.dispatchEvent(r)}}]),e}();t.a=a},8:function(e,t,n){"use strict";function r(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0===u||t){var n=e.document.createElement("div"),r="transform"in n.style?"transform":"webkitTransform";u=r}return u}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Math.min(n,Math.max(t,e))}function o(e,t,n,r,i){return a(s(e,t,r),n,i)}function a(e,t,n){if(0===e||1===e)return e;var r=e*t,i=t+e*(n-t),o=n+e*(1-n);return r+=e*(i-r),i+=e*(o-i),r+e*(i-r)}function s(e,t,n){if(e<=0)return 0;if(e>=1)return 1;for(var r=e,i=0,o=1,s=0,u=0;u<8;u++){s=a(r,t,n);var c=(a(r+1e-6,t,n)-s)/1e-6;if(Math.abs(s-e)<1e-6)return r;if(Math.abs(c)<1e-6)break;s<e?i=r:o=r,r-=(s-e)/c}for(var l=0;Math.abs(s-e)>1e-6&&l<8;l++)s<e?(i=r,r=(r+o)/2):(o=r,r=(r+i)/2),s=a(r,t,n);return r}t.a=r,t.b=i,t.c=o;var u=void 0},85:function(e,t,n){e.exports=n(9)},9:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(14);n.d(t,"MDCSimpleMenu",function(){return r.a}),n.d(t,"MDCSimpleMenuFoundation",function(){return r.b})}})}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.menu=t():(e.mdc=e.mdc||{},e.mdc.menu=t())}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/assets/",t(t.s=86)}({0:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.adapter_=t}return i(e,null,[{key:"cssClasses",get:function(){return{}}},{key:"strings",get:function(){return{}}},{key:"numbers",get:function(){return{}}},{key:"defaultAdapter",get:function(){return{}}}]),i(e,[{key:"init",value:function(){}},{key:"destroy",value:function(){}}]),e}();t.a=o},12:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();!function(){function e(){r(this,e)}i(e,[{key:"addClass",value:function(e){}},{key:"removeClass",value:function(e){}},{key:"hasClass",value:function(e){}},{key:"hasNecessaryDom",value:function(){}},{key:"getAttributeForEventTarget",value:function(e,t){}},{key:"getInnerDimensions",value:function(){}},{key:"hasAnchor",value:function(){}},{key:"getAnchorDimensions",value:function(){}},{key:"getWindowDimensions",value:function(){}},{key:"setScale",value:function(e,t){}},{key:"setInnerScale",value:function(e,t){}},{key:"getNumberOfItems",value:function(){}},{key:"registerInteractionHandler",value:function(e,t){}},{key:"deregisterInteractionHandler",value:function(e,t){}},{key:"registerBodyClickHandler",value:function(e){}},{key:"deregisterBodyClickHandler",value:function(e){}},{key:"getYParamsForItemAtIndex",value:function(e){}},{key:"setTransitionDelayForItemAtIndex",value:function(e,t){}},{key:"getIndexForEventTarget",value:function(e){}},{key:"notifySelected",value:function(e){}},{key:"notifyCancel",value:function(){}},{key:"saveFocus",value:function(){}},{key:"restoreFocus",value:function(){}},{key:"isFocused",value:function(){}},{key:"focus",value:function(){}},{key:"getFocusedItemIndex",value:function(){}},{key:"focusItemAtIndex",value:function(e){}},{key:"isRtl",value:function(){}},{key:"setTransformOrigin",value:function(e){}},{key:"setPosition",value:function(e){}},{key:"getAccurateTime",value:function(){}}])}()},13:function(e,t,n){"use strict";n.d(t,"a",function(){return r}),n.d(t,"b",function(){return i}),n.d(t,"c",function(){return o});var r={ROOT:"mdc-simple-menu",OPEN:"mdc-simple-menu--open",ANIMATING:"mdc-simple-menu--animating",TOP_RIGHT:"mdc-simple-menu--open-from-top-right",BOTTOM_LEFT:"mdc-simple-menu--open-from-bottom-left",BOTTOM_RIGHT:"mdc-simple-menu--open-from-bottom-right"},i={ITEMS_SELECTOR:".mdc-simple-menu__items",SELECTED_EVENT:"MDCSimpleMenu:selected",CANCEL_EVENT:"MDCSimpleMenu:cancel",ARIA_DISABLED_ATTR:"aria-disabled"},o={SELECTED_TRIGGER_DELAY:50,TRANSITION_DURATION_MS:300,TRANSITION_SCALE_ADJUSTMENT_X:.5,TRANSITION_SCALE_ADJUSTMENT_Y:.2,TRANSITION_X1:0,TRANSITION_Y1:0,TRANSITION_X2:.2,TRANSITION_Y2:1}},14:function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=n(0),u=(n(12),n(13)),c=n(8),l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},f=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),d=function(e){function t(e){i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,l(t.defaultAdapter,e)));return n.clickHandler_=function(e){return n.handlePossibleSelected_(e)},n.keydownHandler_=function(e){return n.handleKeyboardDown_(e)},n.keyupHandler_=function(e){return n.handleKeyboardUp_(e)},n.documentClickHandler_=function(e){n.adapter_.notifyCancel(),n.close(e)},n.isOpen_=!1,n.startScaleX_=0,n.startScaleY_=0,n.targetScale_=1,n.scaleX_=0,n.scaleY_=0,n.running_=!1,n.selectedTriggerTimerId_=0,n.animationRequestId_=0,n.dimensions_,n.startTime_,n.itemHeight_,n}return a(t,e),f(t,null,[{key:"cssClasses",get:function(){return u.a}},{key:"strings",get:function(){return u.b}},{key:"numbers",get:function(){return u.c}},{key:"defaultAdapter",get:function(){return{addClass:function(){},removeClass:function(){},hasClass:function(){return!1},hasNecessaryDom:function(){return!1},getAttributeForEventTarget:function(){},getInnerDimensions:function(){return{}},hasAnchor:function(){return!1},getAnchorDimensions:function(){return{}},getWindowDimensions:function(){return{}},setScale:function(){},setInnerScale:function(){},getNumberOfItems:function(){return 0},registerInteractionHandler:function(){},deregisterInteractionHandler:function(){},registerBodyClickHandler:function(){},deregisterBodyClickHandler:function(){},getYParamsForItemAtIndex:function(){return{}},setTransitionDelayForItemAtIndex:function(){},getIndexForEventTarget:function(){return 0},notifySelected:function(){},notifyCancel:function(){},saveFocus:function(){},restoreFocus:function(){},isFocused:function(){return!1},focus:function(){},getFocusedItemIndex:function(){return-1},focusItemAtIndex:function(){},isRtl:function(){return!1},setTransformOrigin:function(){},setPosition:function(){},getAccurateTime:function(){return 0}}}}]),f(t,[{key:"init",value:function(){var e=t.cssClasses,n=e.ROOT,r=e.OPEN;if(!this.adapter_.hasClass(n))throw new Error(n+" class required in root element.");if(!this.adapter_.hasNecessaryDom())throw new Error("Required DOM nodes missing in "+n+" component.");this.adapter_.hasClass(r)&&(this.isOpen_=!0),this.adapter_.registerInteractionHandler("click",this.clickHandler_),this.adapter_.registerInteractionHandler("keyup",this.keyupHandler_),this.adapter_.registerInteractionHandler("keydown",this.keydownHandler_)}},{key:"destroy",value:function(){clearTimeout(this.selectedTriggerTimerId_),cancelAnimationFrame(this.animationRequestId_),this.adapter_.deregisterInteractionHandler("click",this.clickHandler_),this.adapter_.deregisterInteractionHandler("keyup",this.keyupHandler_),this.adapter_.deregisterInteractionHandler("keydown",this.keydownHandler_),this.adapter_.deregisterBodyClickHandler(this.documentClickHandler_)}},{key:"applyTransitionDelays_",value:function(){for(var e=t.cssClasses,n=e.BOTTOM_LEFT,r=e.BOTTOM_RIGHT,i=this.adapter_.getNumberOfItems(),o=this.dimensions_.height,a=t.numbers.TRANSITION_DURATION_MS/1e3,s=t.numbers.TRANSITION_SCALE_ADJUSTMENT_Y,u=0;u<i;u++){var c=this.adapter_.getYParamsForItemAtIndex(u),l=c.top,f=c.height;this.itemHeight_=f;var d=l/o;(this.adapter_.hasClass(n)||this.adapter_.hasClass(r))&&(d=(o-l-f)/o);var h=(s+d*(1-s))*a;this.adapter_.setTransitionDelayForItemAtIndex(u,h.toFixed(3)+"s")}}},{key:"removeTransitionDelays_",value:function(){for(var e=this.adapter_.getNumberOfItems(),t=0;t<e;t++)this.adapter_.setTransitionDelayForItemAtIndex(t,null)}},{key:"animationLoop_",value:function(){var e=this,r=this.adapter_.getAccurateTime(),i=t.numbers,o=i.TRANSITION_DURATION_MS,a=i.TRANSITION_X1,s=i.TRANSITION_Y1,u=i.TRANSITION_X2,l=i.TRANSITION_Y2,f=i.TRANSITION_SCALE_ADJUSTMENT_X,d=i.TRANSITION_SCALE_ADJUSTMENT_Y,h=n.i(c.clamp)((r-this.startTime_)/o),_=n.i(c.clamp)((h-f)/(1-f)),m=h,p=this.startScaleY_;1===this.targetScale_&&(this.itemHeight_&&(p=Math.max(this.itemHeight_/this.dimensions_.height,p)),_=n.i(c.clamp)(h+f),m=n.i(c.clamp)((h-d)/(1-d)));var y=n.i(c.bezierProgress)(_,a,s,u,l),v=n.i(c.bezierProgress)(m,a,s,u,l);this.scaleX_=this.startScaleX_+(this.targetScale_-this.startScaleX_)*y;var g=1/(0===this.scaleX_?1:this.scaleX_);this.scaleY_=p+(this.targetScale_-p)*v;var I=1/(0===this.scaleY_?1:this.scaleY_);this.adapter_.setScale(this.scaleX_,this.scaleY_),this.adapter_.setInnerScale(g,I),h<1?this.animationRequestId_=requestAnimationFrame(function(){return e.animationLoop_()}):(this.animationRequestId_=0,this.running_=!1,this.adapter_.removeClass(t.cssClasses.ANIMATING))}},{key:"animateMenu_",value:function(){var e=this;this.startTime_=this.adapter_.getAccurateTime(),this.startScaleX_=this.scaleX_,this.startScaleY_=this.scaleY_,this.targetScale_=this.isOpen_?1:0,this.running_||(this.running_=!0,this.animationRequestId_=requestAnimationFrame(function(){return e.animationLoop_()}))}},{key:"focusOnOpen_",value:function(e){null===e?(this.adapter_.focus(),this.adapter_.isFocused()||this.adapter_.focusItemAtIndex(0)):this.adapter_.focusItemAtIndex(e)}},{key:"handleKeyboardDown_",value:function(e){if(e.altKey||e.ctrlKey||e.metaKey)return!0;var t=e.keyCode,n=e.key,r=e.shiftKey,i="Tab"===n||9===t,o="ArrowUp"===n||38===t,a="ArrowDown"===n||40===t,s="Space"===n||32===t,u=this.adapter_.getFocusedItemIndex(),c=this.adapter_.getNumberOfItems()-1;return r&&i&&0===u?(this.adapter_.focusItemAtIndex(c),e.preventDefault(),!1):!r&&i&&u===c?(this.adapter_.focusItemAtIndex(0),e.preventDefault(),!1):((o||a||s)&&e.preventDefault(),o?0===u||this.adapter_.isFocused()?this.adapter_.focusItemAtIndex(c):this.adapter_.focusItemAtIndex(u-1):a&&(u===c||this.adapter_.isFocused()?this.adapter_.focusItemAtIndex(0):this.adapter_.focusItemAtIndex(u+1)),!0)}},{key:"handleKeyboardUp_",value:function(e){if(e.altKey||e.ctrlKey||e.metaKey)return!0;var t=e.keyCode,n=e.key,r="Enter"===n||13===t,i="Space"===n||32===t,o="Escape"===n||27===t;return(r||i)&&this.handlePossibleSelected_(e),o&&(this.adapter_.notifyCancel(),this.close()),!0}},{key:"handlePossibleSelected_",value:function(e){var t=this;if("true"!==this.adapter_.getAttributeForEventTarget(e.target,u.b.ARIA_DISABLED_ATTR)){var n=this.adapter_.getIndexForEventTarget(e.target);n<0||this.selectedTriggerTimerId_||(this.selectedTriggerTimerId_=setTimeout(function(){t.selectedTriggerTimerId_=0,t.close(),t.adapter_.notifySelected({index:n})},u.c.SELECTED_TRIGGER_DELAY))}}},{key:"autoPosition_",value:function(){var e;if(this.adapter_.hasAnchor()){var t="top",n="left",i=this.adapter_.getAnchorDimensions(),o=this.adapter_.getWindowDimensions(),a=i.top+this.dimensions_.height-o.height,s=this.dimensions_.height-i.bottom;a>0&&s<a&&(t="bottom");var u=i.left+this.dimensions_.width-o.width,c=this.dimensions_.width-i.right,l=u>0,f=c>0;this.adapter_.isRtl()?(n="right",f&&u<c&&(n="left")):l&&c<u&&(n="right");var d=(e={},r(e,n,"0"),r(e,t,"0"),e);this.adapter_.setTransformOrigin(t+" "+n),this.adapter_.setPosition(d)}}},{key:"open",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.focusIndex,i=void 0===r?null:r;this.adapter_.saveFocus(),this.adapter_.addClass(t.cssClasses.ANIMATING),this.animationRequestId_=requestAnimationFrame(function(){e.dimensions_=e.adapter_.getInnerDimensions(),e.applyTransitionDelays_(),e.autoPosition_(),e.animateMenu_(),e.adapter_.addClass(t.cssClasses.OPEN),e.focusOnOpen_(i),e.adapter_.registerBodyClickHandler(e.documentClickHandler_)}),this.isOpen_=!0}},{key:"close",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;!!n&&"true"===this.adapter_.getAttributeForEventTarget(n.target,u.b.ARIA_DISABLED_ATTR)||(this.adapter_.deregisterBodyClickHandler(this.documentClickHandler_),this.adapter_.addClass(t.cssClasses.ANIMATING),requestAnimationFrame(function(){e.removeTransitionDelays_(),e.animateMenu_(),e.adapter_.removeClass(t.cssClasses.OPEN)}),this.isOpen_=!1,this.adapter_.restoreFocus())}},{key:"isOpen",value:function(){return this.isOpen_}}]),t}(s.a);t.a=d},15:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}n.d(t,"a",function(){return l});var a=n(2),s=n(14),u=n(8);n.d(t,"b",function(){return s.a});var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=function(e){function t(){var e;r(this,t);for(var n=arguments.length,o=Array(n),a=0;a<n;a++)o[a]=arguments[a];var s=i(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(o)));return s.previousFocus_,s}return o(t,e),c(t,[{key:"show",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.focusIndex,n=void 0===t?null:t;this.foundation_.open({focusIndex:n})}},{key:"hide",value:function(){this.foundation_.close()}},{key:"getDefaultFoundation",value:function(){var e=this;return new s.a({addClass:function(t){return e.root_.classList.add(t)},removeClass:function(t){return e.root_.classList.remove(t)},hasClass:function(t){return e.root_.classList.contains(t)},hasNecessaryDom:function(){return Boolean(e.itemsContainer_)},getAttributeForEventTarget:function(e,t){return e.getAttribute(t)},getInnerDimensions:function(){var t=e.itemsContainer_;return{width:t.offsetWidth,height:t.offsetHeight}},hasAnchor:function(){return e.root_.parentElement&&e.root_.parentElement.classList.contains("mdc-menu-anchor")},getAnchorDimensions:function(){return e.root_.parentElement.getBoundingClientRect()},getWindowDimensions:function(){return{width:window.innerWidth,height:window.innerHeight}},setScale:function(t,r){e.root_.style[n.i(u.getTransformPropertyName)(window)]="scale("+t+", "+r+")"},setInnerScale:function(t,r){e.itemsContainer_.style[n.i(u.getTransformPropertyName)(window)]="scale("+t+", "+r+")"},getNumberOfItems:function(){return e.items.length},registerInteractionHandler:function(t,n){return e.root_.addEventListener(t,n)},deregisterInteractionHandler:function(t,n){return e.root_.removeEventListener(t,n)},registerBodyClickHandler:function(e){return document.body.addEventListener("click",e)},deregisterBodyClickHandler:function(e){return document.body.removeEventListener("click",e)},getYParamsForItemAtIndex:function(t){var n=e.items[t];return{top:n.offsetTop,height:n.offsetHeight}},setTransitionDelayForItemAtIndex:function(t,n){return e.items[t].style.setProperty("transition-delay",n)},getIndexForEventTarget:function(t){return e.items.indexOf(t)},notifySelected:function(t){return e.emit(s.a.strings.SELECTED_EVENT,{index:t.index,item:e.items[t.index]})},notifyCancel:function(){return e.emit(s.a.strings.CANCEL_EVENT,{})},saveFocus:function(){e.previousFocus_=document.activeElement},restoreFocus:function(){e.previousFocus_&&e.previousFocus_.focus()},isFocused:function(){return document.activeElement===e.root_},focus:function(){return e.root_.focus()},getFocusedItemIndex:function(){return e.items.indexOf(document.activeElement)},focusItemAtIndex:function(t){return e.items[t].focus()},isRtl:function(){return"rtl"===getComputedStyle(e.root_).getPropertyValue("direction")},setTransformOrigin:function(t){e.root_.style[n.i(u.getTransformPropertyName)(window)+"-origin"]=t},setPosition:function(t){e.root_.style.left="left"in t?t.left:null,e.root_.style.right="right"in t?t.right:null,e.root_.style.top="top"in t?t.top:null,e.root_.style.bottom="bottom"in t?t.bottom:null},getAccurateTime:function(){return window.performance.now()}})}},{key:"open",get:function(){return this.foundation_.isOpen()},set:function(e){e?this.foundation_.open():this.foundation_.close()}},{key:"itemsContainer_",get:function(){return this.root_.querySelector(s.a.strings.ITEMS_SELECTOR)}},{key:"items",get:function(){var e=this.itemsContainer_;return[].slice.call(e.querySelectorAll(".mdc-list-item[role]"))}}],[{key:"attachTo",value:function(e){return new t(e)}}]),t}(a.a)},2:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(0),o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;r(this,e),this.root_=t;for(var i=arguments.length,o=Array(i>2?i-2:0),a=2;a<i;a++)o[a-2]=arguments[a];this.initialize.apply(this,o),this.foundation_=void 0===n?this.getDefaultFoundation():n,this.foundation_.init(),this.initialSyncWithDOM()}return o(e,null,[{key:"attachTo",value:function(t){return new e(t,new i.a)}}]),o(e,[{key:"initialize",value:function(){}},{key:"getDefaultFoundation",value:function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")}},{key:"initialSyncWithDOM",value:function(){}},{key:"destroy",value:function(){this.foundation_.destroy()}},{key:"listen",value:function(e,t){this.root_.addEventListener(e,t)}},{key:"unlisten",value:function(e,t){this.root_.removeEventListener(e,t)}},{key:"emit",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=void 0;"function"==typeof CustomEvent?r=new CustomEvent(e,{detail:t,bubbles:n}):(r=document.createEvent("CustomEvent"),r.initCustomEvent(e,n,!1,t)),this.root_.dispatchEvent(r)}}]),e}();t.a=a},8:function(e,t,n){"use strict";function r(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0===u||t){var n=e.document.createElement("div"),r="transform"in n.style?"transform":"webkitTransform";u=r}return u}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Math.min(n,Math.max(t,e))}function o(e,t,n,r,i){return a(s(e,t,r),n,i)}function a(e,t,n){if(0===e||1===e)return e;var r=e*t,i=t+e*(n-t),o=n+e*(1-n);return r+=e*(i-r),i+=e*(o-i),r+e*(i-r)}function s(e,t,n){if(e<=0)return 0;if(e>=1)return 1;for(var r=e,i=0,o=1,s=0,u=0;u<8;u++){s=a(r,t,n);var c=(a(r+1e-6,t,n)-s)/1e-6;if(Math.abs(s-e)<1e-6)return r;if(Math.abs(c)<1e-6)break;s<e?i=r:o=r,r-=(s-e)/c}for(var l=0;Math.abs(s-e)>1e-6&&l<8;l++)s<e?(i=r,r=(r+o)/2):(o=r,r=(r+i)/2),s=a(r,t,n);return r}Object.defineProperty(t,"__esModule",{value:!0}),t.getTransformPropertyName=r,t.clamp=i,t.bezierProgress=o;var u=void 0},86:function(e,t,n){e.exports=n(9)},9:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(8),i=n(15);n.d(t,"MDCSimpleMenu",function(){return i.a}),n.d(t,"MDCSimpleMenuFoundation",function(){return i.b}),n.d(t,"util",function(){return r})}})}); |
@@ -17,2 +17,4 @@ /** | ||
import * as util from './util'; | ||
export {MDCSimpleMenu, MDCSimpleMenuFoundation} from './simple'; | ||
export {util}; |
{ | ||
"name": "@material/menu", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "The Material Components for the web menu component", | ||
@@ -18,4 +18,4 @@ "license": "Apache-2.0", | ||
"@material/animation": "^0.2.3", | ||
"@material/base": "^0.2.0", | ||
"@material/elevation": "^0.1.8", | ||
"@material/base": "^0.2.1", | ||
"@material/elevation": "^0.1.9", | ||
"@material/theme": "^0.1.5", | ||
@@ -22,0 +22,0 @@ "@material/typography": "^0.2.2" |
@@ -198,3 +198,3 @@ <!--docs: | ||
```javascript | ||
import {MDCSimpleMenu, MDCSimpleMenuFoundation} from 'mdc-menu'; | ||
import {MDCSimpleMenu, MDCSimpleMenuFoundation, util} from 'mdc-menu'; | ||
``` | ||
@@ -208,2 +208,3 @@ | ||
const MDCSimpleMenuFoundation = mdcMenu.MDCSimpleMenuFoundation; | ||
const util = mdcMenu.util; | ||
``` | ||
@@ -217,2 +218,3 @@ | ||
const MDCSimpleMenuFoundation = mdcMenu.MDCSimpleMenuFoundation; | ||
const util = mdcMenu.util; | ||
}); | ||
@@ -226,2 +228,3 @@ ``` | ||
const MDCSimpleMenuFoundation = mdc.Menu.MDCSimpleMenuFoundation; | ||
const util = mdc.menu.util; | ||
``` | ||
@@ -313,1 +316,27 @@ | ||
Returns whether or not the menu is open. | ||
### The util API | ||
External frameworks and libraries can use the following utility methods when integrating a component. | ||
#### util.getTransformPropertyName(globalObj, forceRefresh = false) => String | ||
Returns the name of the correct transform property to use on the current browser. | ||
#### util.clamp(value, min = 0, max = 1) => Number | ||
Clamps a value between the minimum and the maximum, returning the clamped value. | ||
#### util.bezierProgress(time, x1, y1, x2, y2) => Number | ||
Returns the easing value to apply at time t, for a given cubic bezier curve. | ||
``` | ||
Control points P0 and P3 are assumed to be (0,0) and (1,1), respectively. | ||
Parameters are as follows: | ||
- time: The current time in the animation, scaled between 0 and 1. | ||
- x1: The x value of control point P1. | ||
- y1: The y value of control point P1. | ||
- x2: The x value of control point P2. | ||
- y2: The y value of control point P2. | ||
``` |
@@ -16,2 +16,4 @@ /** | ||
*/ | ||
/** @enum {string} */ | ||
export const cssClasses = { | ||
@@ -26,2 +28,3 @@ ROOT: 'mdc-simple-menu', | ||
/** @enum {string} */ | ||
export const strings = { | ||
@@ -34,2 +37,3 @@ ITEMS_SELECTOR: '.mdc-simple-menu__items', | ||
/** @enum {number} */ | ||
export const numbers = { | ||
@@ -36,0 +40,0 @@ // Amount of time to wait before triggering a selected event on the menu. Note that this time |
@@ -17,7 +17,12 @@ /** | ||
import {MDCFoundation} from '@material/base'; | ||
import MDCFoundation from '@material/base/foundation'; | ||
import MDCSimpleMenuAdapter from './adapter'; | ||
import {cssClasses, strings, numbers} from './constants'; | ||
import {clamp, bezierProgress} from '../util'; | ||
/** | ||
* @extends {MDCFoundation<!MDCSimpleMenuAdapter>} | ||
*/ | ||
export default class MDCSimpleMenuFoundation extends MDCFoundation { | ||
/** @return enum{cssClasses} */ | ||
static get cssClasses() { | ||
@@ -27,2 +32,3 @@ return cssClasses; | ||
/** @return enum{strings} */ | ||
static get strings() { | ||
@@ -32,2 +38,3 @@ return strings; | ||
/** @return enum{numbers} */ | ||
static get numbers() { | ||
@@ -37,44 +44,54 @@ return numbers; | ||
/** | ||
* {@see MDCSimpleMenuAdapter} for typing information on parameters and return | ||
* types. | ||
* @return {!MDCSimpleMenuAdapter} | ||
*/ | ||
static get defaultAdapter() { | ||
return { | ||
addClass: (/* className: string */) => {}, | ||
removeClass: (/* className: string */) => {}, | ||
hasClass: (/* className: string */) => {}, | ||
hasNecessaryDom: () => /* boolean */ false, | ||
getAttributeForEventTarget: (/* target: EventTarget, attributeName: string */) => {}, | ||
getInnerDimensions: () => /* { width: number, height: number } */ ({}), | ||
hasAnchor: () => /* boolean */ false, | ||
getAnchorDimensions: () => | ||
/* { width: number, height: number, top: number, right: number, bottom: number, left: number } */ ({}), | ||
getWindowDimensions: () => /* { width: number, height: number } */ ({}), | ||
setScale: (/* x: number, y: number */) => {}, | ||
setInnerScale: (/* x: number, y: number */) => {}, | ||
getNumberOfItems: () => /* number */ 0, | ||
registerInteractionHandler: (/* type: string, handler: EventListener */) => {}, | ||
deregisterInteractionHandler: (/* type: string, handler: EventListener */) => {}, | ||
registerBodyClickHandler: (/* handler: EventListener */) => {}, | ||
deregisterBodyClickHandler: (/* handler: EventListener */) => {}, | ||
getYParamsForItemAtIndex: (/* index: number */) => /* {top: number, height: number} */ ({}), | ||
setTransitionDelayForItemAtIndex: (/* index: number, value: string */) => {}, | ||
getIndexForEventTarget: (/* target: EventTarget */) => /* number */ 0, | ||
notifySelected: (/* evtData: {index: number} */) => {}, | ||
return /** @type {!MDCSimpleMenuAdapter} */ ({ | ||
addClass: () => {}, | ||
removeClass: () => {}, | ||
hasClass: () => false, | ||
hasNecessaryDom: () => false, | ||
getAttributeForEventTarget: () => {}, | ||
getInnerDimensions: () => ({}), | ||
hasAnchor: () => false, | ||
getAnchorDimensions: () => ({}), | ||
getWindowDimensions: () => ({}), | ||
setScale: () => {}, | ||
setInnerScale: () => {}, | ||
getNumberOfItems: () => 0, | ||
registerInteractionHandler: () => {}, | ||
deregisterInteractionHandler: () => {}, | ||
registerBodyClickHandler: () => {}, | ||
deregisterBodyClickHandler: () => {}, | ||
getYParamsForItemAtIndex: () => ({}), | ||
setTransitionDelayForItemAtIndex: () => {}, | ||
getIndexForEventTarget: () => 0, | ||
notifySelected: () => {}, | ||
notifyCancel: () => {}, | ||
saveFocus: () => {}, | ||
restoreFocus: () => {}, | ||
isFocused: () => /* boolean */ false, | ||
isFocused: () => false, | ||
focus: () => {}, | ||
getFocusedItemIndex: () => /* number */ -1, | ||
focusItemAtIndex: (/* index: number */) => {}, | ||
isRtl: () => /* boolean */ false, | ||
setTransformOrigin: (/* origin: string */) => {}, | ||
setPosition: (/* position: { top: string, right: string, bottom: string, left: string } */) => {}, | ||
getAccurateTime: () => /* number */ 0, | ||
}; | ||
getFocusedItemIndex: () => -1, | ||
focusItemAtIndex: () => {}, | ||
isRtl: () => false, | ||
setTransformOrigin: () => {}, | ||
setPosition: () => {}, | ||
getAccurateTime: () => 0, | ||
}); | ||
} | ||
/** @param {!MDCSimpleMenuAdapter} adapter */ | ||
constructor(adapter) { | ||
super(Object.assign(MDCSimpleMenuFoundation.defaultAdapter, adapter)); | ||
/** @private {function(!Event)} */ | ||
this.clickHandler_ = (evt) => this.handlePossibleSelected_(evt); | ||
/** @private {function(!Event)} */ | ||
this.keydownHandler_ = (evt) => this.handleKeyboardDown_(evt); | ||
/** @private {function(!Event)} */ | ||
this.keyupHandler_ = (evt) => this.handleKeyboardUp_(evt); | ||
/** @private {function(!Event)} */ | ||
this.documentClickHandler_ = (evt) => { | ||
@@ -84,11 +101,26 @@ this.adapter_.notifyCancel(); | ||
}; | ||
/** @private {boolean} */ | ||
this.isOpen_ = false; | ||
/** @private {number} */ | ||
this.startScaleX_ = 0; | ||
/** @private {number} */ | ||
this.startScaleY_ = 0; | ||
/** @private {number} */ | ||
this.targetScale_ = 1; | ||
/** @private {number} */ | ||
this.scaleX_ = 0; | ||
/** @private {number} */ | ||
this.scaleY_ = 0; | ||
/** @private {boolean} */ | ||
this.running_ = false; | ||
/** @private {number} */ | ||
this.selectedTriggerTimerId_ = 0; | ||
/** @private {number} */ | ||
this.animationRequestId_ = 0; | ||
/** @private {!{ width: number, height: number }} */ | ||
this.dimensions_; | ||
/** @private {number} */ | ||
this.startTime_; | ||
/** @private {number} */ | ||
this.itemHeight_; | ||
} | ||
@@ -126,3 +158,6 @@ | ||
// Calculate transition delays for individual menu items, so that they fade in one at a time. | ||
/** | ||
* Calculates transition delays for individual menu items, so that they fade in one at a time. | ||
* @private | ||
*/ | ||
applyTransitionDelays_() { | ||
@@ -148,3 +183,6 @@ const {BOTTOM_LEFT, BOTTOM_RIGHT} = MDCSimpleMenuFoundation.cssClasses; | ||
// Remove transition delays from menu items. | ||
/** | ||
* Removes transition delays from menu items. | ||
* @private | ||
*/ | ||
removeTransitionDelays_() { | ||
@@ -157,3 +195,6 @@ const numItems = this.adapter_.getNumberOfItems(); | ||
// Animate menu opening or closing. | ||
/** | ||
* Animates menu opening or closing. | ||
* @private | ||
*/ | ||
animationLoop_() { | ||
@@ -210,3 +251,6 @@ const time = this.adapter_.getAccurateTime(); | ||
// Starts the open or close animation. | ||
/** | ||
* Starts the open or close animation. | ||
* @private | ||
*/ | ||
animateMenu_() { | ||
@@ -225,2 +269,6 @@ this.startTime_ = this.adapter_.getAccurateTime(); | ||
/** | ||
* @param {?number} focusIndex | ||
* @private | ||
*/ | ||
focusOnOpen_(focusIndex) { | ||
@@ -239,3 +287,8 @@ if (focusIndex === null) { | ||
// Handle keys that we want to repeat on hold (tab and arrows). | ||
/** | ||
* Handle keys that we want to repeat on hold (tab and arrows). | ||
* @param {!Event} evt | ||
* @return {boolean} | ||
* @private | ||
*/ | ||
handleKeyboardDown_(evt) { | ||
@@ -290,3 +343,8 @@ // Do nothing if Alt, Ctrl or Meta are pressed. | ||
// Handle keys that we don't want to repeat on hold (Enter, Space, Escape). | ||
/** | ||
* Handle keys that we don't want to repeat on hold (Enter, Space, Escape). | ||
* @param {!Event} evt | ||
* @return {boolean} | ||
* @private | ||
*/ | ||
handleKeyboardUp_(evt) { | ||
@@ -315,2 +373,6 @@ // Do nothing if Alt, Ctrl or Meta are pressed. | ||
/** | ||
* @param {!Event} evt | ||
* @private | ||
*/ | ||
handlePossibleSelected_(evt) { | ||
@@ -335,2 +397,3 @@ if (this.adapter_.getAttributeForEventTarget(evt.target, strings.ARIA_DISABLED_ATTR) === 'true') { | ||
/** @private */ | ||
autoPosition_() { | ||
@@ -382,3 +445,7 @@ if (!this.adapter_.hasAnchor()) { | ||
// Open the menu. | ||
/** | ||
* Open the menu. | ||
* @param {{focusIndex: ?number}=} options | ||
*/ | ||
open({focusIndex = null} = {}) { | ||
@@ -399,3 +466,6 @@ this.adapter_.saveFocus(); | ||
// Close the menu. | ||
/** | ||
* Closes the menu. | ||
* @param {Event=} evt | ||
*/ | ||
close(evt = null) { | ||
@@ -421,2 +491,3 @@ const targetIsDisabled = evt ? | ||
/** @return {boolean} */ | ||
isOpen() { | ||
@@ -426,1 +497,3 @@ return this.isOpen_; | ||
} | ||
@@ -17,3 +17,3 @@ /** | ||
import {MDCComponent} from '@material/base'; | ||
import MDCComponent from '@material/base/component'; | ||
import MDCSimpleMenuFoundation from './foundation'; | ||
@@ -24,3 +24,17 @@ import {getTransformPropertyName} from '../util'; | ||
/** | ||
* @extends MDCComponent<!MDCSimpleMenuFoundation> | ||
*/ | ||
export class MDCSimpleMenu extends MDCComponent { | ||
/** @param {...?} args */ | ||
constructor(...args) { | ||
super(...args); | ||
/** @private {!Element} */ | ||
this.previousFocus_; | ||
} | ||
/** | ||
* @param {!Element} root | ||
* @return {!MDCSimpleMenu} | ||
*/ | ||
static attachTo(root) { | ||
@@ -30,2 +44,3 @@ return new MDCSimpleMenu(root); | ||
/** @return {boolean} */ | ||
get open() { | ||
@@ -35,2 +50,3 @@ return this.foundation_.isOpen(); | ||
/** @param {boolean} value */ | ||
set open(value) { | ||
@@ -44,2 +60,3 @@ if (value) { | ||
/** @param {{focusIndex: ?number}=} options */ | ||
show({focusIndex = null} = {}) { | ||
@@ -53,3 +70,6 @@ this.foundation_.open({focusIndex: focusIndex}); | ||
/* Return the item container element inside the component. */ | ||
/** | ||
* Return the item container element inside the component. | ||
* @return {?Element} | ||
*/ | ||
get itemsContainer_() { | ||
@@ -59,5 +79,7 @@ return this.root_.querySelector(MDCSimpleMenuFoundation.strings.ITEMS_SELECTOR); | ||
/* Return the items within the menu. Note that this only contains the set of elements within | ||
/** | ||
* Return the items within the menu. Note that this only contains the set of elements within | ||
* the items container that are proper list items, and not supplemental / presentational DOM | ||
* elements. | ||
* @return {!Array<!Element>} | ||
*/ | ||
@@ -69,2 +91,3 @@ get items() { | ||
/** @return {!MDCSimpleMenuFoundation} */ | ||
getDefaultFoundation() { | ||
@@ -108,3 +131,3 @@ return new MDCSimpleMenuFoundation({ | ||
}), | ||
notifyCancel: () => this.emit(MDCSimpleMenuFoundation.strings.CANCEL_EVENT), | ||
notifyCancel: () => this.emit(MDCSimpleMenuFoundation.strings.CANCEL_EVENT, {}), | ||
saveFocus: () => { | ||
@@ -111,0 +134,0 @@ this.previousFocus_ = document.activeElement; |
65
util.js
@@ -17,5 +17,11 @@ /** | ||
/** @type {string|undefined} */ | ||
let storedTransformPropertyName_; | ||
// Returns the name of the correct transform property to use on the current browser. | ||
/** | ||
* Returns the name of the correct transform property to use on the current browser. | ||
* @param {!Window} globalObj | ||
* @param {boolean=} forceRefresh | ||
* @return {string} | ||
*/ | ||
export function getTransformPropertyName(globalObj, forceRefresh = false) { | ||
@@ -31,3 +37,9 @@ if (storedTransformPropertyName_ === undefined || forceRefresh) { | ||
// Clamps a value between the minimum and the maximum, returning the clamped value. | ||
/** | ||
* Clamps a value between the minimum and the maximum, returning the clamped value. | ||
* @param {number} value | ||
* @param {number} min | ||
* @param {number} max | ||
* @return {number} | ||
*/ | ||
export function clamp(value, min = 0, max = 1) { | ||
@@ -37,10 +49,19 @@ return Math.min(max, Math.max(min, value)); | ||
// Returns the easing value to apply at time t, for a given cubic bezier curve. | ||
// Control points P0 and P3 are assumed to be (0,0) and (1,1), respectively. | ||
// Paramters are as follows: | ||
// - time: The current time in the animation, scaled between 0 and 1. | ||
// - x1: The x value of control point P1. | ||
// - y1: The y value of control point P1. | ||
// - x2: The x value of control point P2. | ||
// - y2: The y value of control point P2. | ||
/** | ||
* Returns the easing value to apply at time t, for a given cubic bezier curve. | ||
* Control points P0 and P3 are assumed to be (0,0) and (1,1), respectively. | ||
* Parameters are as follows: | ||
* - time: The current time in the animation, scaled between 0 and 1. | ||
* - x1: The x value of control point P1. | ||
* - y1: The y value of control point P1. | ||
* - x2: The x value of control point P2. | ||
* - y2: The y value of control point P2. | ||
* @param {number} time | ||
* @param {number} x1 | ||
* @param {number} y1 | ||
* @param {number} x2 | ||
* @param {number} y2 | ||
* @return {number} | ||
*/ | ||
export function bezierProgress(time, x1, y1, x2, y2) { | ||
@@ -50,6 +71,12 @@ return getBezierCoordinate_(solvePositionFromXValue_(time, x1, x2), y1, y2); | ||
// Compute a single coordinate at a position point between 0 and 1. | ||
// c1 and c2 are the matching coordinate on control points P1 and P2, respectively. | ||
// Control points P0 and P3 are assumed to be (0,0) and (1,1), respectively. | ||
// Adapted from https://github.com/google/closure-library/blob/master/closure/goog/math/bezier.js. | ||
/** | ||
* Compute a single coordinate at a position point between 0 and 1. | ||
* c1 and c2 are the matching coordinate on control points P1 and P2, respectively. | ||
* Control points P0 and P3 are assumed to be (0,0) and (1,1), respectively. | ||
* Adapted from https://github.com/google/closure-library/blob/master/closure/goog/math/bezier.js. | ||
* @param {number} t | ||
* @param {number} c1 | ||
* @param {number} c2 | ||
* @return {number} | ||
*/ | ||
function getBezierCoordinate_(t, c1, c2) { | ||
@@ -74,4 +101,10 @@ // Special case start and end. | ||
// Project a point onto the Bezier curve, from a given X. Calculates the position t along the curve. | ||
// Adapted from https://github.com/google/closure-library/blob/master/closure/goog/math/bezier.js. | ||
/** | ||
* Project a point onto the Bezier curve, from a given X. Calculates the position t along the curve. | ||
* Adapted from https://github.com/google/closure-library/blob/master/closure/goog/math/bezier.js. | ||
* @param {number} xVal | ||
* @param {number} x1 | ||
* @param {number} x2 | ||
* @return {number} | ||
*/ | ||
function solvePositionFromXValue_(xVal, x1, x2) { | ||
@@ -78,0 +111,0 @@ const EPSILON = 1e-6; |
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
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
150528
14
2668
338
Updated@material/base@^0.2.1
Updated@material/elevation@^0.1.9