@material/menu
Advanced tools
Comparing version 0.30.0 to 0.31.0
/*! | ||
Material Components for the web | ||
Material Components for the Web | ||
Copyright (c) 2018 Google Inc. | ||
License: Apache-2.0 | ||
*/ | ||
!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.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=93)}({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},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=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},12:function(e,t,n){"use strict";n.d(t,"c",function(){return r}),n.d(t,"e",function(){return i}),n.d(t,"d",function(){return o}),n.d(t,"b",function(){return a}),n.d(t,"a",function(){return s});/** | ||
!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.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=94)}({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},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=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},12:function(e,t,n){"use strict";n.d(t,"c",function(){return r}),n.d(t,"e",function(){return i}),n.d(t,"d",function(){return o}),n.d(t,"b",function(){return a}),n.d(t,"a",function(){return s});/** | ||
* @license | ||
@@ -22,3 +22,3 @@ * Copyright 2016 Google Inc. All Rights Reserved. | ||
*/ | ||
var r={ROOT:"mdc-menu",OPEN:"mdc-menu--open",ANIMATING_OPEN:"mdc-menu--animating-open",ANIMATING_CLOSED:"mdc-menu--animating-closed",SELECTED_LIST_ITEM:"mdc-list-item--selected"},i={ITEMS_SELECTOR:".mdc-menu__items",SELECTED_EVENT:"MDCMenu:selected",CANCEL_EVENT:"MDCMenu:cancel",ARIA_DISABLED_ATTR:"aria-disabled"},o={SELECTED_TRIGGER_DELAY:50,TRANSITION_OPEN_DURATION:120,TRANSITION_CLOSE_DURATION:75,MARGIN_TO_EDGE:32,ANCHOR_TO_MENU_WIDTH_RATIO:.67,OFFSET_TO_MENU_HEIGHT_RATIO:.1},a={BOTTOM:1,CENTER:2,RIGHT:4,FLIP_RTL:8},s={TOP_LEFT:0,TOP_RIGHT:a.RIGHT,BOTTOM_LEFT:a.BOTTOM,BOTTOM_RIGHT:a.BOTTOM|a.RIGHT,TOP_START:a.FLIP_RTL,TOP_END:a.FLIP_RTL|a.RIGHT,BOTTOM_START:a.BOTTOM|a.FLIP_RTL,BOTTOM_END:a.BOTTOM|a.RIGHT|a.FLIP_RTL}},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)}Object.defineProperty(t,"__esModule",{value:!0}),n.d(t,"MDCMenu",function(){return d});var a=n(1),s=n(18),u=n(19),c=n(12);n.d(t,"MDCMenuFoundation",function(){return u.b}),n.d(t,"AnchorMargin",function(){return u.a}),n.d(t,"Corner",function(){return c.a}),n.d(t,"CornerBit",function(){return c.b});var l=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(){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),l(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:"setAnchorCorner",value:function(e){this.foundation_.setAnchorCorner(e)}},{key:"setAnchorMargin",value:function(e){this.foundation_.setAnchorMargin(e)}},{key:"getOptionByIndex",value:function(e){return e<this.items.length?this.items[e]:null}},{key:"getDefaultFoundation",value:function(){var e=this;return new u.b({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}},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)},getIndexForEventTarget:function(t){return e.items.indexOf(t)},notifySelected:function(t){return e.emit(u.b.strings.SELECTED_EVENT,{index:t.index,item:e.items[t.index]})},notifyCancel:function(){return e.emit(u.b.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[Object(s.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},setMaxHeight:function(t){e.root_.style.maxHeight=t},setAttrForOptionAtIndex:function(t,n,r){return e.items[t].setAttribute(n,r)},rmAttrForOptionAtIndex:function(t,n){return e.items[t].removeAttribute(n)},addClassForOptionAtIndex:function(t,n){return e.items[t].classList.add(n)},rmClassForOptionAtIndex:function(t,n){return e.items[t].classList.remove(n)}})}},{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(u.b.strings.ITEMS_SELECTOR)}},{key:"items",get:function(){var e=this.itemsContainer_;return[].slice.call(e.querySelectorAll(".mdc-list-item[role]"))}},{key:"selectedItemIndex",set:function(e){this.foundation_.setSelectedIndex(e)},get:function(){return this.foundation_.getSelectedIndex()}},{key:"rememberSelection",set:function(e){this.foundation_.setRememberSelection(e)}},{key:"quickOpen",set:function(e){this.foundation_.setQuickOpen(e)}}],[{key:"attachTo",value:function(e){return new t(e)}}]),t}(a.a)},18:function(e,t,n){"use strict";function r(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0===i||t){var n=e.document.createElement("div"),r="transform"in n.style?"transform":"webkitTransform";i=r}return i}n.d(t,"a",function(){return r});var i=void 0},19: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)}n.d(t,"b",function(){return f}),n.d(t,"a",function(){return d});var s=n(0),u=(n(20),n(12)),c=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},l=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=void 0,f=function(e){function t(e){i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,c(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){return n.handleDocumentClick_(e)},n.isOpen_=!1,n.openAnimationEndTimerId_=0,n.closeAnimationEndTimerId_=0,n.selectedTriggerTimerId_=0,n.animationRequestId_=0,n.dimensions_,n.itemHeight_,n.anchorCorner_=u.a.TOP_START,n.anchorMargin_={top:0,right:0,bottom:0,left:0},n.measures_=null,n.selectedIndex_=-1,n.rememberSelection_=!1,n.quickOpen_=!1,n.keyDownWithinMenu_=!1,n}return a(t,e),l(t,null,[{key:"cssClasses",get:function(){return u.c}},{key:"strings",get:function(){return u.e}},{key:"numbers",get:function(){return u.d}},{key:"Corner",get:function(){return u.a}},{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{}},getNumberOfItems:function(){return 0},registerInteractionHandler:function(){},deregisterInteractionHandler:function(){},registerBodyClickHandler:function(){},deregisterBodyClickHandler: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(){},setMaxHeight:function(){},setAttrForOptionAtIndex:function(){},rmAttrForOptionAtIndex:function(){},addClassForOptionAtIndex:function(){},rmClassForOptionAtIndex:function(){}}}}]),l(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_),clearTimeout(this.openAnimationEndTimerId_),clearTimeout(this.closeAnimationEndTimerId_),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:"setAnchorCorner",value:function(e){this.anchorCorner_=e}},{key:"setAnchorMargin",value:function(e){this.anchorMargin_.top="number"==typeof e.top?e.top:0,this.anchorMargin_.right="number"==typeof e.right?e.right:0,this.anchorMargin_.bottom="number"==typeof e.bottom?e.bottom:0,this.anchorMargin_.left="number"==typeof e.left?e.left:0}},{key:"setRememberSelection",value:function(e){this.rememberSelection_=e,this.setSelectedIndex(-1)}},{key:"setQuickOpen",value:function(e){this.quickOpen_=e}},{key:"focusOnOpen_",value:function(e){if(null===e){if(this.rememberSelection_&&this.selectedIndex_>=0)return void this.adapter_.focusItemAtIndex(this.selectedIndex_);this.adapter_.focus(),this.adapter_.isFocused()||this.adapter_.focusItemAtIndex(0)}else this.adapter_.focusItemAtIndex(e)}},{key:"handleDocumentClick_",value:function(e){for(var t=e.target;t&&t!==document.documentElement;){if(-1!==this.adapter_.getIndexForEventTarget(t))return;t=t.parentNode}this.adapter_.notifyCancel(),this.close(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="Enter"===n||13===t;this.keyDownWithinMenu_=u||s;var c=this.adapter_.getFocusedItemIndex(),l=this.adapter_.getNumberOfItems()-1;return r&&i&&0===c?(this.adapter_.focusItemAtIndex(l),e.preventDefault(),!1):!r&&i&&c===l?(this.adapter_.focusItemAtIndex(0),e.preventDefault(),!1):((o||a||s)&&e.preventDefault(),o?0===c||this.adapter_.isFocused()?this.adapter_.focusItemAtIndex(l):this.adapter_.focusItemAtIndex(c-1):a&&(c===l||this.adapter_.isFocused()?this.adapter_.focusItemAtIndex(0):this.adapter_.focusItemAtIndex(c+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.keyDownWithinMenu_&&this.handlePossibleSelected_(e),this.keyDownWithinMenu_=!1),o&&(this.adapter_.notifyCancel(),this.close()),!0}},{key:"handlePossibleSelected_",value:function(e){var t=this;if("true"!==this.adapter_.getAttributeForEventTarget(e.target,u.e.ARIA_DISABLED_ATTR)){var n=this.adapter_.getIndexForEventTarget(e.target);n<0||this.selectedTriggerTimerId_||(this.selectedTriggerTimerId_=setTimeout(function(){t.selectedTriggerTimerId_=0,t.close(),t.rememberSelection_&&t.setSelectedIndex(n),t.adapter_.notifySelected({index:n})},u.d.SELECTED_TRIGGER_DELAY))}}},{key:"getAutoLayoutMeasurements_",value:function(){var e=this.adapter_.getAnchorDimensions(),t=this.adapter_.getWindowDimensions();return{viewport:t,viewportDistance:{top:e.top,right:t.width-e.right,left:e.left,bottom:t.height-e.bottom},anchorHeight:e.height,anchorWidth:e.width,menuHeight:this.dimensions_.height,menuWidth:this.dimensions_.width}}},{key:"getOriginCorner_",value:function(){var e=u.a.TOP_LEFT,t=this.measures_,n=t.viewportDistance,r=t.anchorHeight,i=t.anchorWidth,o=t.menuHeight,a=t.menuWidth,s=Boolean(this.anchorCorner_&u.b.BOTTOM),c=s?n.top+r+this.anchorMargin_.bottom:n.top+this.anchorMargin_.top,l=s?n.bottom-this.anchorMargin_.bottom:n.bottom+r-this.anchorMargin_.top,d=o-c,f=o-l;f>0&&d<f&&(e|=u.b.BOTTOM);var h=this.adapter_.isRtl(),_=Boolean(this.anchorCorner_&u.b.FLIP_RTL),m=Boolean(this.anchorCorner_&u.b.RIGHT),p=m&&!h||!m&&_&&h,g=p?n.left+i+this.anchorMargin_.right:n.left+this.anchorMargin_.left,y=p?n.right-this.anchorMargin_.right:n.right+i-this.anchorMargin_.left,v=a-g,T=a-y;return(v<0&&p&&h||m&&!p&&v<0||T>0&&v<T)&&(e|=u.b.RIGHT),e}},{key:"getHorizontalOriginOffset_",value:function(e){var t=this.measures_.anchorWidth,n=Boolean(e&u.b.RIGHT),r=Boolean(this.anchorCorner_&u.b.RIGHT),i=0;if(n){i=r?t-this.anchorMargin_.left:this.anchorMargin_.right}else{i=r?t-this.anchorMargin_.right:this.anchorMargin_.left}return i}},{key:"getVerticalOriginOffset_",value:function(e){var n=this.measures_,r=n.viewport,i=n.viewportDistance,o=n.anchorHeight,a=n.menuHeight,s=Boolean(e&u.b.BOTTOM),c=t.numbers.MARGIN_TO_EDGE,l=Boolean(this.anchorCorner_&u.b.BOTTOM),d=!l,f=0;return s?(f=l?o-this.anchorMargin_.top:-this.anchorMargin_.bottom,d&&a>i.top+o&&(f=-(Math.min(a,r.height-c)-(i.top+o)))):(f=l?o+this.anchorMargin_.bottom:this.anchorMargin_.top,d&&a>i.bottom+o&&(f=-(Math.min(a,r.height-c)-(i.bottom+o)))),f}},{key:"getMenuMaxHeight_",value:function(e){var t=0,n=this.measures_.viewportDistance,r=Boolean(e&u.b.BOTTOM);return this.anchorCorner_&u.b.BOTTOM&&(t=r?n.top+this.anchorMargin_.top:n.bottom-this.anchorMargin_.bottom),t}},{key:"autoPosition_",value:function(){var e;if(this.adapter_.hasAnchor()){this.measures_=this.getAutoLayoutMeasurements_();var t=this.getOriginCorner_(),n=this.getMenuMaxHeight_(t),i=t&u.b.BOTTOM?"bottom":"top",o=t&u.b.RIGHT?"right":"left",a=this.getHorizontalOriginOffset_(t),s=this.getVerticalOriginOffset_(t),c=(e={},r(e,o,a?a+"px":"0"),r(e,i,s?s+"px":"0"),e),l=this.measures_,d=l.anchorWidth,f=l.menuHeight;if(d/l.menuWidth>u.d.ANCHOR_TO_MENU_WIDTH_RATIO&&(o="center"),!(this.anchorCorner_&u.b.BOTTOM)&&Math.abs(s/f)>u.d.OFFSET_TO_MENU_HEIGHT_RATIO){var h=100*Math.abs(s/f),_=t&u.b.BOTTOM?100-h:h;i=Math.round(100*_)/100+"%"}this.adapter_.setTransformOrigin(o+" "+i),this.adapter_.setPosition(c),this.adapter_.setMaxHeight(n?n+"px":""),this.measures_=null}}},{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.quickOpen_||this.adapter_.addClass(t.cssClasses.ANIMATING_OPEN),this.animationRequestId_=requestAnimationFrame(function(){e.dimensions_=e.adapter_.getInnerDimensions(),e.autoPosition_(),e.adapter_.addClass(t.cssClasses.OPEN),e.focusOnOpen_(i),e.adapter_.registerBodyClickHandler(e.documentClickHandler_),e.quickOpen_||(e.openAnimationEndTimerId_=setTimeout(function(){e.openAnimationEndTimerId_=0,e.adapter_.removeClass(t.cssClasses.ANIMATING_OPEN)},u.d.TRANSITION_OPEN_DURATION))}),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.e.ARIA_DISABLED_ATTR)||(this.adapter_.deregisterBodyClickHandler(this.documentClickHandler_),this.quickOpen_||this.adapter_.addClass(t.cssClasses.ANIMATING_CLOSED),requestAnimationFrame(function(){e.adapter_.removeClass(t.cssClasses.OPEN),e.quickOpen_||(e.closeAnimationEndTimerId_=setTimeout(function(){e.closeAnimationEndTimerId_=0,e.adapter_.removeClass(t.cssClasses.ANIMATING_CLOSED)},u.d.TRANSITION_CLOSE_DURATION))}),this.isOpen_=!1,this.adapter_.restoreFocus())}},{key:"isOpen",value:function(){return this.isOpen_}},{key:"getSelectedIndex",value:function(){return this.selectedIndex_}},{key:"setSelectedIndex",value:function(e){if(e!==this.selectedIndex_){var t=this.selectedIndex_;t>=0&&(this.adapter_.rmAttrForOptionAtIndex(t,"aria-selected"),this.adapter_.rmClassForOptionAtIndex(t,u.c.SELECTED_LIST_ITEM)),this.selectedIndex_=e>=0&&e<this.adapter_.getNumberOfItems()?e:-1,this.selectedIndex_>=0&&(this.adapter_.setAttrForOptionAtIndex(this.selectedIndex_,"aria-selected","true"),this.adapter_.addClassForOptionAtIndex(this.selectedIndex_,u.c.SELECTED_LIST_ITEM))}}}]),t}(s.a)},20: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:"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:"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:"setMaxHeight",value:function(e){}},{key:"setAttrForOptionAtIndex",value:function(e,t,n){}},{key:"rmAttrForOptionAtIndex",value:function(e,t){}},{key:"addClassForOptionAtIndex",value:function(e,t){}},{key:"rmClassForOptionAtIndex",value:function(e,t){}}])}()},93:function(e,t,n){e.exports=n(14)}})}); | ||
var r={ROOT:"mdc-menu",OPEN:"mdc-menu--open",ANIMATING_OPEN:"mdc-menu--animating-open",ANIMATING_CLOSED:"mdc-menu--animating-closed",SELECTED_LIST_ITEM:"mdc-list-item--selected"},i={ITEMS_SELECTOR:".mdc-menu__items",SELECTED_EVENT:"MDCMenu:selected",CANCEL_EVENT:"MDCMenu:cancel",ARIA_DISABLED_ATTR:"aria-disabled"},o={SELECTED_TRIGGER_DELAY:50,TRANSITION_OPEN_DURATION:120,TRANSITION_CLOSE_DURATION:75,MARGIN_TO_EDGE:32,ANCHOR_TO_MENU_WIDTH_RATIO:.67,OFFSET_TO_MENU_HEIGHT_RATIO:.1},a={BOTTOM:1,CENTER:2,RIGHT:4,FLIP_RTL:8},s={TOP_LEFT:0,TOP_RIGHT:a.RIGHT,BOTTOM_LEFT:a.BOTTOM,BOTTOM_RIGHT:a.BOTTOM|a.RIGHT,TOP_START:a.FLIP_RTL,TOP_END:a.FLIP_RTL|a.RIGHT,BOTTOM_START:a.BOTTOM|a.FLIP_RTL,BOTTOM_END:a.BOTTOM|a.RIGHT|a.FLIP_RTL}},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)}Object.defineProperty(t,"__esModule",{value:!0}),n.d(t,"MDCMenu",function(){return d});var a=n(1),s=n(18),u=n(19),c=n(12);n.d(t,"MDCMenuFoundation",function(){return u.b}),n.d(t,"AnchorMargin",function(){return u.a}),n.d(t,"Corner",function(){return c.a}),n.d(t,"CornerBit",function(){return c.b});var l=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(){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),l(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:"setAnchorCorner",value:function(e){this.foundation_.setAnchorCorner(e)}},{key:"setAnchorMargin",value:function(e){this.foundation_.setAnchorMargin(e)}},{key:"getOptionByIndex",value:function(e){return e<this.items.length?this.items[e]:null}},{key:"getDefaultFoundation",value:function(){var e=this;return new u.b({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}},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)},getIndexForEventTarget:function(t){return e.items.indexOf(t)},notifySelected:function(t){return e.emit(u.b.strings.SELECTED_EVENT,{index:t.index,item:e.items[t.index]})},notifyCancel:function(){return e.emit(u.b.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[Object(s.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},setMaxHeight:function(t){e.root_.style.maxHeight=t},setAttrForOptionAtIndex:function(t,n,r){return e.items[t].setAttribute(n,r)},rmAttrForOptionAtIndex:function(t,n){return e.items[t].removeAttribute(n)},addClassForOptionAtIndex:function(t,n){return e.items[t].classList.add(n)},rmClassForOptionAtIndex:function(t,n){return e.items[t].classList.remove(n)}})}},{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(u.b.strings.ITEMS_SELECTOR)}},{key:"items",get:function(){var e=this.itemsContainer_;return[].slice.call(e.querySelectorAll(".mdc-list-item[role]"))}},{key:"selectedItemIndex",set:function(e){this.foundation_.setSelectedIndex(e)},get:function(){return this.foundation_.getSelectedIndex()}},{key:"rememberSelection",set:function(e){this.foundation_.setRememberSelection(e)}},{key:"quickOpen",set:function(e){this.foundation_.setQuickOpen(e)}}],[{key:"attachTo",value:function(e){return new t(e)}}]),t}(a.a)},18:function(e,t,n){"use strict";function r(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0===i||t){var n=e.document.createElement("div"),r="transform"in n.style?"transform":"webkitTransform";i=r}return i}n.d(t,"a",function(){return r});var i=void 0},19: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)}n.d(t,"b",function(){return f}),n.d(t,"a",function(){return d});var s=n(0),u=(n(20),n(12)),c=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},l=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=void 0,f=function(e){function t(e){i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,c(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){return n.handleDocumentClick_(e)},n.isOpen_=!1,n.openAnimationEndTimerId_=0,n.closeAnimationEndTimerId_=0,n.selectedTriggerTimerId_=0,n.animationRequestId_=0,n.dimensions_,n.itemHeight_,n.anchorCorner_=u.a.TOP_START,n.anchorMargin_={top:0,right:0,bottom:0,left:0},n.measures_=null,n.selectedIndex_=-1,n.rememberSelection_=!1,n.quickOpen_=!1,n.keyDownWithinMenu_=!1,n}return a(t,e),l(t,null,[{key:"cssClasses",get:function(){return u.c}},{key:"strings",get:function(){return u.e}},{key:"numbers",get:function(){return u.d}},{key:"Corner",get:function(){return u.a}},{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{}},getNumberOfItems:function(){return 0},registerInteractionHandler:function(){},deregisterInteractionHandler:function(){},registerBodyClickHandler:function(){},deregisterBodyClickHandler: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(){},setMaxHeight:function(){},setAttrForOptionAtIndex:function(){},rmAttrForOptionAtIndex:function(){},addClassForOptionAtIndex:function(){},rmClassForOptionAtIndex:function(){}}}}]),l(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_),clearTimeout(this.openAnimationEndTimerId_),clearTimeout(this.closeAnimationEndTimerId_),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:"setAnchorCorner",value:function(e){this.anchorCorner_=e}},{key:"setAnchorMargin",value:function(e){this.anchorMargin_.top="number"==typeof e.top?e.top:0,this.anchorMargin_.right="number"==typeof e.right?e.right:0,this.anchorMargin_.bottom="number"==typeof e.bottom?e.bottom:0,this.anchorMargin_.left="number"==typeof e.left?e.left:0}},{key:"setRememberSelection",value:function(e){this.rememberSelection_=e,this.setSelectedIndex(-1)}},{key:"setQuickOpen",value:function(e){this.quickOpen_=e}},{key:"focusOnOpen_",value:function(e){if(null===e){if(this.rememberSelection_&&this.selectedIndex_>=0)return void this.adapter_.focusItemAtIndex(this.selectedIndex_);this.adapter_.focus(),this.adapter_.isFocused()||this.adapter_.focusItemAtIndex(0)}else this.adapter_.focusItemAtIndex(e)}},{key:"handleDocumentClick_",value:function(e){for(var t=e.target;t&&t!==document.documentElement;){if(-1!==this.adapter_.getIndexForEventTarget(t))return;t=t.parentNode}this.adapter_.notifyCancel(),this.close(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="Enter"===n||13===t;this.keyDownWithinMenu_=u||s;var c=this.adapter_.getFocusedItemIndex(),l=this.adapter_.getNumberOfItems()-1;return r&&i&&0===c?(this.adapter_.focusItemAtIndex(l),e.preventDefault(),!1):!r&&i&&c===l?(this.adapter_.focusItemAtIndex(0),e.preventDefault(),!1):((o||a||s)&&e.preventDefault(),o?0===c||this.adapter_.isFocused()?this.adapter_.focusItemAtIndex(l):this.adapter_.focusItemAtIndex(c-1):a&&(c===l||this.adapter_.isFocused()?this.adapter_.focusItemAtIndex(0):this.adapter_.focusItemAtIndex(c+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.keyDownWithinMenu_&&this.handlePossibleSelected_(e),this.keyDownWithinMenu_=!1),o&&(this.adapter_.notifyCancel(),this.close()),!0}},{key:"handlePossibleSelected_",value:function(e){var t=this;if("true"!==this.adapter_.getAttributeForEventTarget(e.target,u.e.ARIA_DISABLED_ATTR)){var n=this.adapter_.getIndexForEventTarget(e.target);n<0||this.selectedTriggerTimerId_||(this.selectedTriggerTimerId_=setTimeout(function(){t.selectedTriggerTimerId_=0,t.close(),t.rememberSelection_&&t.setSelectedIndex(n),t.adapter_.notifySelected({index:n})},u.d.SELECTED_TRIGGER_DELAY))}}},{key:"getAutoLayoutMeasurements_",value:function(){var e=this.adapter_.getAnchorDimensions(),t=this.adapter_.getWindowDimensions();return{viewport:t,viewportDistance:{top:e.top,right:t.width-e.right,left:e.left,bottom:t.height-e.bottom},anchorHeight:e.height,anchorWidth:e.width,menuHeight:this.dimensions_.height,menuWidth:this.dimensions_.width}}},{key:"getOriginCorner_",value:function(){var e=u.a.TOP_LEFT,t=this.measures_,n=t.viewportDistance,r=t.anchorHeight,i=t.anchorWidth,o=t.menuHeight,a=t.menuWidth,s=Boolean(this.anchorCorner_&u.b.BOTTOM),c=s?n.top+r+this.anchorMargin_.bottom:n.top+this.anchorMargin_.top,l=s?n.bottom-this.anchorMargin_.bottom:n.bottom+r-this.anchorMargin_.top,d=o-c,f=o-l;f>0&&d<f&&(e|=u.b.BOTTOM);var h=this.adapter_.isRtl(),_=Boolean(this.anchorCorner_&u.b.FLIP_RTL),m=Boolean(this.anchorCorner_&u.b.RIGHT),p=m&&!h||!m&&_&&h,g=p?n.left+i+this.anchorMargin_.right:n.left+this.anchorMargin_.left,y=p?n.right-this.anchorMargin_.right:n.right+i-this.anchorMargin_.left,v=a-g,T=a-y;return(v<0&&p&&h||m&&!p&&v<0||T>0&&v<T)&&(e|=u.b.RIGHT),e}},{key:"getHorizontalOriginOffset_",value:function(e){var t=this.measures_.anchorWidth,n=Boolean(e&u.b.RIGHT),r=Boolean(this.anchorCorner_&u.b.RIGHT),i=0;if(n){i=r?t-this.anchorMargin_.left:this.anchorMargin_.right}else{i=r?t-this.anchorMargin_.right:this.anchorMargin_.left}return i}},{key:"getVerticalOriginOffset_",value:function(e){var n=this.measures_,r=n.viewport,i=n.viewportDistance,o=n.anchorHeight,a=n.menuHeight,s=Boolean(e&u.b.BOTTOM),c=t.numbers.MARGIN_TO_EDGE,l=Boolean(this.anchorCorner_&u.b.BOTTOM),d=!l,f=0;return s?(f=l?o-this.anchorMargin_.top:-this.anchorMargin_.bottom,d&&a>i.top+o&&(f=-(Math.min(a,r.height-c)-(i.top+o)))):(f=l?o+this.anchorMargin_.bottom:this.anchorMargin_.top,d&&a>i.bottom+o&&(f=-(Math.min(a,r.height-c)-(i.bottom+o)))),f}},{key:"getMenuMaxHeight_",value:function(e){var t=0,n=this.measures_.viewportDistance,r=Boolean(e&u.b.BOTTOM);return this.anchorCorner_&u.b.BOTTOM&&(t=r?n.top+this.anchorMargin_.top:n.bottom-this.anchorMargin_.bottom),t}},{key:"autoPosition_",value:function(){var e;if(this.adapter_.hasAnchor()){this.measures_=this.getAutoLayoutMeasurements_();var t=this.getOriginCorner_(),n=this.getMenuMaxHeight_(t),i=t&u.b.BOTTOM?"bottom":"top",o=t&u.b.RIGHT?"right":"left",a=this.getHorizontalOriginOffset_(t),s=this.getVerticalOriginOffset_(t),c=(e={},r(e,o,a?a+"px":"0"),r(e,i,s?s+"px":"0"),e),l=this.measures_,d=l.anchorWidth,f=l.menuHeight;if(d/l.menuWidth>u.d.ANCHOR_TO_MENU_WIDTH_RATIO&&(o="center"),!(this.anchorCorner_&u.b.BOTTOM)&&Math.abs(s/f)>u.d.OFFSET_TO_MENU_HEIGHT_RATIO){var h=100*Math.abs(s/f),_=t&u.b.BOTTOM?100-h:h;i=Math.round(100*_)/100+"%"}this.adapter_.setTransformOrigin(o+" "+i),this.adapter_.setPosition(c),this.adapter_.setMaxHeight(n?n+"px":""),this.measures_=null}}},{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.quickOpen_||this.adapter_.addClass(t.cssClasses.ANIMATING_OPEN),this.animationRequestId_=requestAnimationFrame(function(){e.dimensions_=e.adapter_.getInnerDimensions(),e.autoPosition_(),e.adapter_.addClass(t.cssClasses.OPEN),e.focusOnOpen_(i),e.adapter_.registerBodyClickHandler(e.documentClickHandler_),e.quickOpen_||(e.openAnimationEndTimerId_=setTimeout(function(){e.openAnimationEndTimerId_=0,e.adapter_.removeClass(t.cssClasses.ANIMATING_OPEN)},u.d.TRANSITION_OPEN_DURATION))}),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.e.ARIA_DISABLED_ATTR)||(this.adapter_.deregisterBodyClickHandler(this.documentClickHandler_),this.quickOpen_||this.adapter_.addClass(t.cssClasses.ANIMATING_CLOSED),requestAnimationFrame(function(){e.adapter_.removeClass(t.cssClasses.OPEN),e.quickOpen_||(e.closeAnimationEndTimerId_=setTimeout(function(){e.closeAnimationEndTimerId_=0,e.adapter_.removeClass(t.cssClasses.ANIMATING_CLOSED)},u.d.TRANSITION_CLOSE_DURATION))}),this.isOpen_=!1,this.adapter_.restoreFocus())}},{key:"isOpen",value:function(){return this.isOpen_}},{key:"getSelectedIndex",value:function(){return this.selectedIndex_}},{key:"setSelectedIndex",value:function(e){if(e!==this.selectedIndex_){var t=this.selectedIndex_;t>=0&&(this.adapter_.rmAttrForOptionAtIndex(t,"aria-selected"),this.adapter_.rmClassForOptionAtIndex(t,u.c.SELECTED_LIST_ITEM)),this.selectedIndex_=e>=0&&e<this.adapter_.getNumberOfItems()?e:-1,this.selectedIndex_>=0&&(this.adapter_.setAttrForOptionAtIndex(this.selectedIndex_,"aria-selected","true"),this.adapter_.addClassForOptionAtIndex(this.selectedIndex_,u.c.SELECTED_LIST_ITEM))}}}]),t}(s.a)},20: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:"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:"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:"setMaxHeight",value:function(e){}},{key:"setAttrForOptionAtIndex",value:function(e,t,n){}},{key:"rmAttrForOptionAtIndex",value:function(e,t){}},{key:"addClassForOptionAtIndex",value:function(e,t){}},{key:"rmClassForOptionAtIndex",value:function(e,t){}}])}()},94:function(e,t,n){e.exports=n(14)}})}); | ||
//# sourceMappingURL=mdc.menu.min.js.map |
{ | ||
"name": "@material/menu", | ||
"version": "0.30.0", | ||
"version": "0.31.0", | ||
"description": "The Material Components for the web menu component", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -21,4 +21,3 @@ <!--docs: | ||
[Material Design menu specification](https://material.io/guidelines/components/menus.html). | ||
Menus require JavaScript to work correctly, but the open and closed states are correct on | ||
first render. | ||
Menus require JavaScript to properly position themselves when opening. | ||
@@ -44,5 +43,5 @@ ## Design & API Documentation | ||
### HTML Structure | ||
### HTML Structure | ||
A menu is usually closed, appearing when opened. It is appropriate for any display size. | ||
A menu is initially hidden, appearing when opened via the JS API. It is appropriate for any display size. | ||
@@ -62,15 +61,5 @@ ```html | ||
#### Opened Menu | ||
The menu can be configured to start in the opened state by adding the `mdc-menu--open` class to the element. | ||
```html | ||
<div class="mdc-menu mdc-menu--open"> | ||
... | ||
</div> | ||
``` | ||
#### Anchor To Parent | ||
The menu can be positioned to automatically anchor to a parent element when opened. | ||
The menu can be positioned to automatically anchor to a parent element when opened. | ||
@@ -87,3 +76,3 @@ ```html | ||
The menu can be positioned to automatically anchor to another element, by wrapping the other element with the anchor class. | ||
The menu can be positioned to automatically anchor to another element, by wrapping the other element with the anchor class. | ||
@@ -122,5 +111,5 @@ ```html | ||
`mdc-menu` | Mandatory | ||
`mdc-menu--animating-open` | Indicates the menu is currently animating open. This class is removed once the animation completes. | ||
`mdc-menu--open` | Indicates the menu is currently open, or is currently animating open. | ||
`mdc-menu--animating-closed` | Indicates the menu is currently animating closed. This class is removed once the animation completes. | ||
`mdc-menu--animating-open` | Indicates the menu is currently animating open. This class is removed once the animation completes. | ||
`mdc-menu--open` | Indicates the menu is currently open, or is currently animating open. | ||
`mdc-menu--animating-closed` | Indicates the menu is currently animating closed. This class is removed once the animation completes. | ||
@@ -134,3 +123,3 @@ ### JS Examples | ||
var menuButtonEl = document.querySelector('#menu-button'); | ||
// Toggle menu open | ||
@@ -140,3 +129,3 @@ menuButtonEl.addEventListener('click', function() { | ||
}); | ||
// Listen for selected item | ||
@@ -146,8 +135,8 @@ menuEl.addEventListener('MDCMenu:selected', function(evt) { | ||
}); | ||
// Set Anchor Corner to Bottom End | ||
menu.setAnchorCorner(Corner.BOTTOM_END); | ||
menu.setAnchorCorner(Corner.BOTTOM_END); | ||
// Turn off menu open animations | ||
menu.quickOpen = false; | ||
menu.quickOpen = true; | ||
``` | ||
@@ -161,6 +150,6 @@ | ||
--- | --- | --- | ||
`open` | Boolean | Proxies to the foundation's `isOpen`/(`open`, `close`) methods. | ||
`open` | Boolean | Proxies to the foundation's `isOpen`/(`open`, `close`) methods. | ||
`items` | Array<Element> | Proxies to the foundation's container to query for all `.mdc-list-item[role]` elements. | ||
`itemsContainer` | Element | Queries the foundation's root element for the `mdc-menu__items` container element. | ||
`quickOpen` | Boolean | Proxies to the foundation's `setQuickOpen()` method. | ||
`quickOpen` | Boolean | Proxies to the foundation's `setQuickOpen()` method. | ||
@@ -173,3 +162,3 @@ Method Signature | Description | ||
`setAnchorMargin(AnchorMargin) => void` | Proxies to the foundation's `setAnchorMargin(AnchorMargin)` method. | ||
`getDefaultFoundation() => MDCMenuFoundation` | Returns the foundation. | ||
`getDefaultFoundation() => MDCMenuFoundation` | Returns the foundation. | ||
@@ -213,7 +202,7 @@ ### `MDCMenuAdapter` | ||
`setAnchorCorner(corder: Corner) => void` | Sets the corner that the menu will be anchored to. See [constants.js](https://github.com/material-components/material-components-web/blob/cc299230728ba5a994866ebd31aaaf1a0f4cc87f/packages/mdc-menu/constants.js#L73) | ||
`setAnchorMargin(margin: AnchorMargin) => void` | Sets the distance from the anchor point that the menu should be shown. | ||
`open({focusIndex: ?number}) => void` | Opens the menu. Optionally accepts an object with a `focusIndex` parameter to indicate which list item should receive focus when the menu is opened. | ||
`close(evt: ?Event)` | Closes the menu. Optionally accepts the event to check if the target is disabled before closing the menu. | ||
`isOpen() => boolean` | Returns a boolean indicating whether the menu is open. | ||
`setQuickOpen(quickOpen: boolean) => void` | Sets whether the menu should open and close without animation when the `open`/`close` methods are called. | ||
`setAnchorMargin(margin: AnchorMargin) => void` | Sets the distance from the anchor point that the menu should be shown. | ||
`open({focusIndex: ?number}) => void` | Opens the menu. Optionally accepts an object with a `focusIndex` parameter to indicate which list item should receive focus when the menu is opened. | ||
`close(evt: ?Event)` | Closes the menu. Optionally accepts the event to check if the target is disabled before closing the menu. | ||
`isOpen() => boolean` | Returns a boolean indicating whether the menu is open. | ||
`setQuickOpen(quickOpen: boolean) => void` | Sets whether the menu should open and close without animation when the `open`/`close` methods are called. | ||
@@ -225,2 +214,2 @@ ### Events | ||
`MDCMenu:selected` | `{detail: {item: HTMLElement, index: number}}` | Used to indicate when an element has been selected. This event also includes the item selected and the list index of that item. | ||
`MDCMenu:cancel` | none | Event emitted when the menu is closed with no selection made (e.g. if the user hits `Esc` while it's open, or clicks somewhere else on the page). | ||
`MDCMenu:cancel` | none | Event emitted when the menu is closed with no selection made (e.g. if the user hits `Esc` while it's open, or clicks somewhere else on the page). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
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
3087
156218
204
1