Socket
Socket
Sign inDemoInstall

@material/menu-surface

Package Overview
Dependencies
Maintainers
13
Versions
1656
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@material/menu-surface - npm Package Compare versions

Comparing version 3.0.0-alpha.1 to 3.0.0

CHANGELOG.md

22

dist/mdc.menuSurface.js

@@ -51,3 +51,3 @@ /**

__webpack_require__.p = "";
return __webpack_require__(__webpack_require__.s = 147);
return __webpack_require__(__webpack_require__.s = 134);
}({

@@ -162,7 +162,7 @@ 0: function(module, exports, __webpack_require__) {

};
MDCComponent.prototype.listen = function(evtType, handler) {
this.root_.addEventListener(evtType, handler);
MDCComponent.prototype.listen = function(evtType, handler, options) {
this.root_.addEventListener(evtType, handler, options);
};
MDCComponent.prototype.unlisten = function(evtType, handler) {
this.root_.removeEventListener(evtType, handler);
MDCComponent.prototype.unlisten = function(evtType, handler, options) {
this.root_.removeEventListener(evtType, handler, options);
};

@@ -646,3 +646,3 @@ MDCComponent.prototype.emit = function(evtType, evtData, shouldBubble) {

},
147: function(module, exports, __webpack_require__) {
134: function(module, exports, __webpack_require__) {
"use strict";

@@ -666,3 +666,3 @@ function __export(m) {

});
var util = __importStar(__webpack_require__(21));
var util = __importStar(__webpack_require__(22));
exports.util = util;

@@ -672,7 +672,7 @@ var constants_1 = __webpack_require__(9);

exports.CornerBit = constants_1.CornerBit;
__export(__webpack_require__(30));
__export(__webpack_require__(31));
__export(__webpack_require__(9));
__export(__webpack_require__(13));
},
21: function(module, exports, __webpack_require__) {
22: function(module, exports, __webpack_require__) {
"use strict";

@@ -695,3 +695,3 @@ Object.defineProperty(exports, "__esModule", {

},
30: function(module, exports, __webpack_require__) {
31: function(module, exports, __webpack_require__) {
"use strict";

@@ -734,3 +734,3 @@ var __extends = this && this.__extends || function() {

var foundation_1 = __webpack_require__(13);
var util = __importStar(__webpack_require__(21));
var util = __importStar(__webpack_require__(22));
var MDCMenuSurface = function(_super) {

@@ -737,0 +737,0 @@ __extends(MDCMenuSurface, _super);

@@ -8,3 +8,3 @@ /**

*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.menuSurface=e():(t.mdc=t.mdc||{},t.mdc.menuSurface=e())}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=147)}({0:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t){void 0===t&&(t={}),this.adapter_=t}return Object.defineProperty(t,"cssClasses",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(t,"strings",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(t,"numbers",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(t,"defaultAdapter",{get:function(){return{}},enumerable:!0,configurable:!0}),t.prototype.init=function(){},t.prototype.destroy=function(){},t}();e.MDCFoundation=i,e.default=i},1:function(t,e,n){"use strict";var i=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,r=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s},o=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t};Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),s=function(){function t(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];this.root_=t,this.initialize.apply(this,o(n)),this.foundation_=void 0===e?this.getDefaultFoundation():e,this.foundation_.init(),this.initialSyncWithDOM()}return t.attachTo=function(e){return new t(e,new r.MDCFoundation({}))},t.prototype.initialize=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e]},t.prototype.getDefaultFoundation=function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")},t.prototype.initialSyncWithDOM=function(){},t.prototype.destroy=function(){this.foundation_.destroy()},t.prototype.listen=function(t,e){this.root_.addEventListener(t,e)},t.prototype.unlisten=function(t,e){this.root_.removeEventListener(t,e)},t.prototype.emit=function(t,e,n){void 0===n&&(n=!1);var i;"function"==typeof CustomEvent?i=new CustomEvent(t,{bubbles:n,detail:e}):(i=document.createEvent("CustomEvent"),i.initCustomEvent(t,n,!1,e)),this.root_.dispatchEvent(i)},t}();e.MDCComponent=s,e.default=s},13:function(t,e,n){"use strict";var i=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},o.apply(this,arguments)},r=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}};Object.defineProperty(e,"__esModule",{value:!0});var s=n(0),a=n(9),u=function(t){function e(n){var i=t.call(this,o({},e.defaultAdapter,n))||this;return i.isOpen_=!1,i.isQuickOpen_=!1,i.isHoistedElement_=!1,i.isFixedPosition_=!1,i.openAnimationEndTimerId_=0,i.closeAnimationEndTimerId_=0,i.animationRequestId_=0,i.anchorCorner_=a.Corner.TOP_START,i.anchorMargin_={top:0,right:0,bottom:0,left:0},i.position_={x:0,y:0},i}return i(e,t),Object.defineProperty(e,"cssClasses",{get:function(){return a.cssClasses},enumerable:!0,configurable:!0}),Object.defineProperty(e,"strings",{get:function(){return a.strings},enumerable:!0,configurable:!0}),Object.defineProperty(e,"numbers",{get:function(){return a.numbers},enumerable:!0,configurable:!0}),Object.defineProperty(e,"Corner",{get:function(){return a.Corner},enumerable:!0,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{addClass:function(){},removeClass:function(){},hasClass:function(){return!1},hasAnchor:function(){return!1},isElementInContainer:function(){return!1},isFocused:function(){return!1},isRtl:function(){return!1},getInnerDimensions:function(){return{height:0,width:0}},getAnchorDimensions:function(){return null},getWindowDimensions:function(){return{height:0,width:0}},getBodyDimensions:function(){return{height:0,width:0}},getWindowScroll:function(){return{x:0,y:0}},setPosition:function(){},setMaxHeight:function(){},setTransformOrigin:function(){},saveFocus:function(){},restoreFocus:function(){},notifyClose:function(){},notifyOpen:function(){}}},enumerable:!0,configurable:!0}),e.prototype.init=function(){var t=e.cssClasses,n=t.ROOT,i=t.OPEN;if(!this.adapter_.hasClass(n))throw new Error(n+" class required in root element.");this.adapter_.hasClass(i)&&(this.isOpen_=!0)},e.prototype.destroy=function(){clearTimeout(this.openAnimationEndTimerId_),clearTimeout(this.closeAnimationEndTimerId_),cancelAnimationFrame(this.animationRequestId_)},e.prototype.setAnchorCorner=function(t){this.anchorCorner_=t},e.prototype.setAnchorMargin=function(t){this.anchorMargin_.top=t.top||0,this.anchorMargin_.right=t.right||0,this.anchorMargin_.bottom=t.bottom||0,this.anchorMargin_.left=t.left||0},e.prototype.setIsHoisted=function(t){this.isHoistedElement_=t},e.prototype.setFixedPosition=function(t){this.isFixedPosition_=t},e.prototype.setAbsolutePosition=function(t,e){this.position_.x=this.isFinite_(t)?t:0,this.position_.y=this.isFinite_(e)?e:0},e.prototype.setQuickOpen=function(t){this.isQuickOpen_=t},e.prototype.isOpen=function(){return this.isOpen_},e.prototype.open=function(){var t=this;this.adapter_.saveFocus(),this.isQuickOpen_||this.adapter_.addClass(e.cssClasses.ANIMATING_OPEN),this.animationRequestId_=requestAnimationFrame(function(){t.adapter_.addClass(e.cssClasses.OPEN),t.dimensions_=t.adapter_.getInnerDimensions(),t.autoPosition_(),t.isQuickOpen_?t.adapter_.notifyOpen():t.openAnimationEndTimerId_=setTimeout(function(){t.openAnimationEndTimerId_=0,t.adapter_.removeClass(e.cssClasses.ANIMATING_OPEN),t.adapter_.notifyOpen()},a.numbers.TRANSITION_OPEN_DURATION)}),this.isOpen_=!0},e.prototype.close=function(t){var n=this;void 0===t&&(t=!1),this.isQuickOpen_||this.adapter_.addClass(e.cssClasses.ANIMATING_CLOSED),requestAnimationFrame(function(){n.adapter_.removeClass(e.cssClasses.OPEN),n.isQuickOpen_?n.adapter_.notifyClose():n.closeAnimationEndTimerId_=setTimeout(function(){n.closeAnimationEndTimerId_=0,n.adapter_.removeClass(e.cssClasses.ANIMATING_CLOSED),n.adapter_.notifyClose()},a.numbers.TRANSITION_CLOSE_DURATION)}),this.isOpen_=!1,t||this.maybeRestoreFocus_()},e.prototype.handleBodyClick=function(t){var e=t.target;this.adapter_.isElementInContainer(e)||this.close()},e.prototype.handleKeydown=function(t){var e=t.keyCode;("Escape"===t.key||27===e)&&this.close()},e.prototype.autoPosition_=function(){var t;this.measurements_=this.getAutoLayoutMeasurements_();var e=this.getOriginCorner_(),n=this.getMenuSurfaceMaxHeight_(e),i=this.hasBit_(e,a.CornerBit.BOTTOM)?"bottom":"top",o=this.hasBit_(e,a.CornerBit.RIGHT)?"right":"left",r=this.getHorizontalOriginOffset_(e),s=this.getVerticalOriginOffset_(e),u=this.measurements_,c=u.anchorSize,h=u.surfaceSize,f=(t={},t[o]=r,t[i]=s,t);c.width/h.width>a.numbers.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO&&(o="center"),(this.isHoistedElement_||this.isFixedPosition_)&&this.adjustPositionForHoistedElement_(f),this.adapter_.setTransformOrigin(o+" "+i),this.adapter_.setPosition(f),this.adapter_.setMaxHeight(n?n+"px":"")},e.prototype.getAutoLayoutMeasurements_=function(){var t=this.adapter_.getAnchorDimensions(),e=this.adapter_.getBodyDimensions(),n=this.adapter_.getWindowDimensions(),i=this.adapter_.getWindowScroll();return t||(t={top:this.position_.y,right:this.position_.x,bottom:this.position_.y,left:this.position_.x,width:0,height:0}),{anchorSize:t,bodySize:e,surfaceSize:this.dimensions_,viewportDistance:{top:t.top,right:n.width-t.right,bottom:n.height-t.bottom,left:t.left},viewportSize:n,windowScroll:i}},e.prototype.getOriginCorner_=function(){var t=a.Corner.TOP_LEFT,e=this.measurements_,n=e.viewportDistance,i=e.anchorSize,o=e.surfaceSize,r=this.hasBit_(this.anchorCorner_,a.CornerBit.BOTTOM),s=r?n.top+i.height+this.anchorMargin_.bottom:n.top+this.anchorMargin_.top,u=r?n.bottom-this.anchorMargin_.bottom:n.bottom+i.height-this.anchorMargin_.top,c=o.height-s,h=o.height-u;h>0&&c<h&&(t=this.setBit_(t,a.CornerBit.BOTTOM));var f=this.adapter_.isRtl(),d=this.hasBit_(this.anchorCorner_,a.CornerBit.FLIP_RTL),_=this.hasBit_(this.anchorCorner_,a.CornerBit.RIGHT),l=_&&!f||!_&&d&&f,p=l?n.left+i.width+this.anchorMargin_.right:n.left+this.anchorMargin_.left,m=l?n.right-this.anchorMargin_.right:n.right+i.width-this.anchorMargin_.left,y=o.width-p,O=o.width-m;return(y<0&&l&&f||_&&!l&&y<0||O>0&&y<O)&&(t=this.setBit_(t,a.CornerBit.RIGHT)),t},e.prototype.getMenuSurfaceMaxHeight_=function(t){var n=this.measurements_.viewportDistance,i=0,o=this.hasBit_(t,a.CornerBit.BOTTOM),r=this.hasBit_(this.anchorCorner_,a.CornerBit.BOTTOM),s=e.numbers.MARGIN_TO_EDGE;return o?(i=n.top+this.anchorMargin_.top-s,r||(i+=this.measurements_.anchorSize.height)):(i=n.bottom-this.anchorMargin_.bottom+this.measurements_.anchorSize.height-s,r&&(i-=this.measurements_.anchorSize.height)),i},e.prototype.getHorizontalOriginOffset_=function(t){var e=this.measurements_.anchorSize,n=this.hasBit_(t,a.CornerBit.RIGHT),i=this.hasBit_(this.anchorCorner_,a.CornerBit.RIGHT);if(n){var o=i?e.width-this.anchorMargin_.left:this.anchorMargin_.right;return this.isHoistedElement_||this.isFixedPosition_?o-(this.measurements_.viewportSize.width-this.measurements_.bodySize.width):o}return i?e.width-this.anchorMargin_.right:this.anchorMargin_.left},e.prototype.getVerticalOriginOffset_=function(t){var e=this.measurements_.anchorSize,n=this.hasBit_(t,a.CornerBit.BOTTOM),i=this.hasBit_(this.anchorCorner_,a.CornerBit.BOTTOM);return n?i?e.height-this.anchorMargin_.top:-this.anchorMargin_.bottom:i?e.height+this.anchorMargin_.bottom:this.anchorMargin_.top},e.prototype.adjustPositionForHoistedElement_=function(t){var e,n,i=this.measurements_,o=i.windowScroll,s=i.viewportDistance,a=Object.keys(t);try{for(var u=r(a),c=u.next();!c.done;c=u.next()){var h=c.value,f=t[h]||0;f+=s[h],this.isFixedPosition_||("top"===h?f+=o.y:"bottom"===h?f-=o.y:"left"===h?f+=o.x:f-=o.x),t[h]=f}}catch(t){e={error:t}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}},e.prototype.maybeRestoreFocus_=function(){var t=this.adapter_.isFocused(),e=document.activeElement&&this.adapter_.isElementInContainer(document.activeElement);(t||e)&&this.adapter_.restoreFocus()},e.prototype.hasBit_=function(t,e){return Boolean(t&e)},e.prototype.setBit_=function(t,e){return t|e},e.prototype.isFinite_=function(t){return"number"==typeof t&&isFinite(t)},e}(s.MDCFoundation);e.MDCMenuSurfaceFoundation=u,e.default=u},147:function(t,e,n){"use strict";function i(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}var o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var r=o(n(21));e.util=r;var s=n(9);e.Corner=s.Corner,e.CornerBit=s.CornerBit,i(n(30)),i(n(9)),i(n(13))},21:function(t,e,n){"use strict";function i(t,e){if(void 0===e&&(e=!1),void 0===o||e){var n=t.document.createElement("div");o="transform"in n.style?"transform":"webkitTransform"}return o}Object.defineProperty(e,"__esModule",{value:!0});var o;e.getTransformPropertyName=i},30:function(t,e,n){"use strict";var i=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var r=n(1),s=n(9),a=n(13),u=o(n(21)),c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.attachTo=function(t){return new e(t)},e.prototype.initialSyncWithDOM=function(){var t=this,e=this.root_.parentElement;this.anchorElement=e&&e.classList.contains(s.cssClasses.ANCHOR)?e:null,this.root_.classList.contains(s.cssClasses.FIXED)&&this.setFixedPosition(!0),this.handleKeydown_=function(e){return t.foundation_.handleKeydown(e)},this.handleBodyClick_=function(e){return t.foundation_.handleBodyClick(e)},this.registerBodyClickListener_=function(){return document.body.addEventListener("click",t.handleBodyClick_)},this.deregisterBodyClickListener_=function(){return document.body.removeEventListener("click",t.handleBodyClick_)},this.listen("keydown",this.handleKeydown_),this.listen(s.strings.OPENED_EVENT,this.registerBodyClickListener_),this.listen(s.strings.CLOSED_EVENT,this.deregisterBodyClickListener_)},e.prototype.destroy=function(){this.unlisten("keydown",this.handleKeydown_),this.unlisten(s.strings.OPENED_EVENT,this.registerBodyClickListener_),this.unlisten(s.strings.CLOSED_EVENT,this.deregisterBodyClickListener_),t.prototype.destroy.call(this)},e.prototype.isOpen=function(){return this.foundation_.isOpen()},e.prototype.open=function(){this.foundation_.open()},e.prototype.close=function(t){void 0===t&&(t=!1),this.foundation_.close(t)},Object.defineProperty(e.prototype,"quickOpen",{set:function(t){this.foundation_.setQuickOpen(t)},enumerable:!0,configurable:!0}),e.prototype.hoistMenuToBody=function(){document.body.appendChild(this.root_),this.setIsHoisted(!0)},e.prototype.setIsHoisted=function(t){this.foundation_.setIsHoisted(t)},e.prototype.setMenuSurfaceAnchorElement=function(t){this.anchorElement=t},e.prototype.setFixedPosition=function(t){t?this.root_.classList.add(s.cssClasses.FIXED):this.root_.classList.remove(s.cssClasses.FIXED),this.foundation_.setFixedPosition(t)},e.prototype.setAbsolutePosition=function(t,e){this.foundation_.setAbsolutePosition(t,e),this.setIsHoisted(!0)},e.prototype.setAnchorCorner=function(t){this.foundation_.setAnchorCorner(t)},e.prototype.setAnchorMargin=function(t){this.foundation_.setAnchorMargin(t)},e.prototype.getDefaultFoundation=function(){var t=this,e={addClass:function(e){return t.root_.classList.add(e)},removeClass:function(e){return t.root_.classList.remove(e)},hasClass:function(e){return t.root_.classList.contains(e)},hasAnchor:function(){return!!t.anchorElement},notifyClose:function(){return t.emit(a.MDCMenuSurfaceFoundation.strings.CLOSED_EVENT,{})},notifyOpen:function(){return t.emit(a.MDCMenuSurfaceFoundation.strings.OPENED_EVENT,{})},isElementInContainer:function(e){return t.root_.contains(e)},isRtl:function(){return"rtl"===getComputedStyle(t.root_).getPropertyValue("direction")},setTransformOrigin:function(e){var n=u.getTransformPropertyName(window)+"-origin";t.root_.style.setProperty(n,e)},isFocused:function(){return document.activeElement===t.root_},saveFocus:function(){t.previousFocus_=document.activeElement},restoreFocus:function(){t.root_.contains(document.activeElement)&&t.previousFocus_&&t.previousFocus_.focus&&t.previousFocus_.focus()},getInnerDimensions:function(){return{width:t.root_.offsetWidth,height:t.root_.offsetHeight}},getAnchorDimensions:function(){return t.anchorElement?t.anchorElement.getBoundingClientRect():null},getWindowDimensions:function(){return{width:window.innerWidth,height:window.innerHeight}},getBodyDimensions:function(){return{width:document.body.clientWidth,height:document.body.clientHeight}},getWindowScroll:function(){return{x:window.pageXOffset,y:window.pageYOffset}},setPosition:function(e){t.root_.style.left="left"in e?e.left+"px":"",t.root_.style.right="right"in e?e.right+"px":"",t.root_.style.top="top"in e?e.top+"px":"",t.root_.style.bottom="bottom"in e?e.bottom+"px":""},setMaxHeight:function(e){t.root_.style.maxHeight=e}};return new a.MDCMenuSurfaceFoundation(e)},e}(r.MDCComponent);e.MDCMenuSurface=c},9:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={ANCHOR:"mdc-menu-surface--anchor",ANIMATING_CLOSED:"mdc-menu-surface--animating-closed",ANIMATING_OPEN:"mdc-menu-surface--animating-open",FIXED:"mdc-menu-surface--fixed",OPEN:"mdc-menu-surface--open",ROOT:"mdc-menu-surface"};e.cssClasses=i;var o={CLOSED_EVENT:"MDCMenuSurface:closed",OPENED_EVENT:"MDCMenuSurface:opened",FOCUSABLE_ELEMENTS:["button:not(:disabled)",'[href]:not([aria-disabled="true"])',"input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)",'[tabindex]:not([tabindex="-1"]):not([aria-disabled="true"])'].join(", ")};e.strings=o;var r={TRANSITION_OPEN_DURATION:120,TRANSITION_CLOSE_DURATION:75,MARGIN_TO_EDGE:32,ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO:.67};e.numbers=r;var s;!function(t){t[t.BOTTOM=1]="BOTTOM",t[t.CENTER=2]="CENTER",t[t.RIGHT=4]="RIGHT",t[t.FLIP_RTL=8]="FLIP_RTL"}(s||(s={})),e.CornerBit=s;var a;!function(t){t[t.TOP_LEFT=0]="TOP_LEFT",t[t.TOP_RIGHT=4]="TOP_RIGHT",t[t.BOTTOM_LEFT=1]="BOTTOM_LEFT",t[t.BOTTOM_RIGHT=5]="BOTTOM_RIGHT",t[t.TOP_START=8]="TOP_START",t[t.TOP_END=12]="TOP_END",t[t.BOTTOM_START=9]="BOTTOM_START",t[t.BOTTOM_END=13]="BOTTOM_END"}(a||(a={})),e.Corner=a}})});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.menuSurface=e():(t.mdc=t.mdc||{},t.mdc.menuSurface=e())}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=134)}({0:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t){void 0===t&&(t={}),this.adapter_=t}return Object.defineProperty(t,"cssClasses",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(t,"strings",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(t,"numbers",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(t,"defaultAdapter",{get:function(){return{}},enumerable:!0,configurable:!0}),t.prototype.init=function(){},t.prototype.destroy=function(){},t}();e.MDCFoundation=i,e.default=i},1:function(t,e,n){"use strict";var i=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,r=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s},o=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t};Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),s=function(){function t(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];this.root_=t,this.initialize.apply(this,o(n)),this.foundation_=void 0===e?this.getDefaultFoundation():e,this.foundation_.init(),this.initialSyncWithDOM()}return t.attachTo=function(e){return new t(e,new r.MDCFoundation({}))},t.prototype.initialize=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e]},t.prototype.getDefaultFoundation=function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")},t.prototype.initialSyncWithDOM=function(){},t.prototype.destroy=function(){this.foundation_.destroy()},t.prototype.listen=function(t,e,n){this.root_.addEventListener(t,e,n)},t.prototype.unlisten=function(t,e,n){this.root_.removeEventListener(t,e,n)},t.prototype.emit=function(t,e,n){void 0===n&&(n=!1);var i;"function"==typeof CustomEvent?i=new CustomEvent(t,{bubbles:n,detail:e}):(i=document.createEvent("CustomEvent"),i.initCustomEvent(t,n,!1,e)),this.root_.dispatchEvent(i)},t}();e.MDCComponent=s,e.default=s},13:function(t,e,n){"use strict";var i=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},o.apply(this,arguments)},r=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}};Object.defineProperty(e,"__esModule",{value:!0});var s=n(0),a=n(9),u=function(t){function e(n){var i=t.call(this,o({},e.defaultAdapter,n))||this;return i.isOpen_=!1,i.isQuickOpen_=!1,i.isHoistedElement_=!1,i.isFixedPosition_=!1,i.openAnimationEndTimerId_=0,i.closeAnimationEndTimerId_=0,i.animationRequestId_=0,i.anchorCorner_=a.Corner.TOP_START,i.anchorMargin_={top:0,right:0,bottom:0,left:0},i.position_={x:0,y:0},i}return i(e,t),Object.defineProperty(e,"cssClasses",{get:function(){return a.cssClasses},enumerable:!0,configurable:!0}),Object.defineProperty(e,"strings",{get:function(){return a.strings},enumerable:!0,configurable:!0}),Object.defineProperty(e,"numbers",{get:function(){return a.numbers},enumerable:!0,configurable:!0}),Object.defineProperty(e,"Corner",{get:function(){return a.Corner},enumerable:!0,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{addClass:function(){},removeClass:function(){},hasClass:function(){return!1},hasAnchor:function(){return!1},isElementInContainer:function(){return!1},isFocused:function(){return!1},isRtl:function(){return!1},getInnerDimensions:function(){return{height:0,width:0}},getAnchorDimensions:function(){return null},getWindowDimensions:function(){return{height:0,width:0}},getBodyDimensions:function(){return{height:0,width:0}},getWindowScroll:function(){return{x:0,y:0}},setPosition:function(){},setMaxHeight:function(){},setTransformOrigin:function(){},saveFocus:function(){},restoreFocus:function(){},notifyClose:function(){},notifyOpen:function(){}}},enumerable:!0,configurable:!0}),e.prototype.init=function(){var t=e.cssClasses,n=t.ROOT,i=t.OPEN;if(!this.adapter_.hasClass(n))throw new Error(n+" class required in root element.");this.adapter_.hasClass(i)&&(this.isOpen_=!0)},e.prototype.destroy=function(){clearTimeout(this.openAnimationEndTimerId_),clearTimeout(this.closeAnimationEndTimerId_),cancelAnimationFrame(this.animationRequestId_)},e.prototype.setAnchorCorner=function(t){this.anchorCorner_=t},e.prototype.setAnchorMargin=function(t){this.anchorMargin_.top=t.top||0,this.anchorMargin_.right=t.right||0,this.anchorMargin_.bottom=t.bottom||0,this.anchorMargin_.left=t.left||0},e.prototype.setIsHoisted=function(t){this.isHoistedElement_=t},e.prototype.setFixedPosition=function(t){this.isFixedPosition_=t},e.prototype.setAbsolutePosition=function(t,e){this.position_.x=this.isFinite_(t)?t:0,this.position_.y=this.isFinite_(e)?e:0},e.prototype.setQuickOpen=function(t){this.isQuickOpen_=t},e.prototype.isOpen=function(){return this.isOpen_},e.prototype.open=function(){var t=this;this.adapter_.saveFocus(),this.isQuickOpen_||this.adapter_.addClass(e.cssClasses.ANIMATING_OPEN),this.animationRequestId_=requestAnimationFrame(function(){t.adapter_.addClass(e.cssClasses.OPEN),t.dimensions_=t.adapter_.getInnerDimensions(),t.autoPosition_(),t.isQuickOpen_?t.adapter_.notifyOpen():t.openAnimationEndTimerId_=setTimeout(function(){t.openAnimationEndTimerId_=0,t.adapter_.removeClass(e.cssClasses.ANIMATING_OPEN),t.adapter_.notifyOpen()},a.numbers.TRANSITION_OPEN_DURATION)}),this.isOpen_=!0},e.prototype.close=function(t){var n=this;void 0===t&&(t=!1),this.isQuickOpen_||this.adapter_.addClass(e.cssClasses.ANIMATING_CLOSED),requestAnimationFrame(function(){n.adapter_.removeClass(e.cssClasses.OPEN),n.isQuickOpen_?n.adapter_.notifyClose():n.closeAnimationEndTimerId_=setTimeout(function(){n.closeAnimationEndTimerId_=0,n.adapter_.removeClass(e.cssClasses.ANIMATING_CLOSED),n.adapter_.notifyClose()},a.numbers.TRANSITION_CLOSE_DURATION)}),this.isOpen_=!1,t||this.maybeRestoreFocus_()},e.prototype.handleBodyClick=function(t){var e=t.target;this.adapter_.isElementInContainer(e)||this.close()},e.prototype.handleKeydown=function(t){var e=t.keyCode;("Escape"===t.key||27===e)&&this.close()},e.prototype.autoPosition_=function(){var t;this.measurements_=this.getAutoLayoutMeasurements_();var e=this.getOriginCorner_(),n=this.getMenuSurfaceMaxHeight_(e),i=this.hasBit_(e,a.CornerBit.BOTTOM)?"bottom":"top",o=this.hasBit_(e,a.CornerBit.RIGHT)?"right":"left",r=this.getHorizontalOriginOffset_(e),s=this.getVerticalOriginOffset_(e),u=this.measurements_,c=u.anchorSize,h=u.surfaceSize,f=(t={},t[o]=r,t[i]=s,t);c.width/h.width>a.numbers.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO&&(o="center"),(this.isHoistedElement_||this.isFixedPosition_)&&this.adjustPositionForHoistedElement_(f),this.adapter_.setTransformOrigin(o+" "+i),this.adapter_.setPosition(f),this.adapter_.setMaxHeight(n?n+"px":"")},e.prototype.getAutoLayoutMeasurements_=function(){var t=this.adapter_.getAnchorDimensions(),e=this.adapter_.getBodyDimensions(),n=this.adapter_.getWindowDimensions(),i=this.adapter_.getWindowScroll();return t||(t={top:this.position_.y,right:this.position_.x,bottom:this.position_.y,left:this.position_.x,width:0,height:0}),{anchorSize:t,bodySize:e,surfaceSize:this.dimensions_,viewportDistance:{top:t.top,right:n.width-t.right,bottom:n.height-t.bottom,left:t.left},viewportSize:n,windowScroll:i}},e.prototype.getOriginCorner_=function(){var t=a.Corner.TOP_LEFT,e=this.measurements_,n=e.viewportDistance,i=e.anchorSize,o=e.surfaceSize,r=this.hasBit_(this.anchorCorner_,a.CornerBit.BOTTOM),s=r?n.top+i.height+this.anchorMargin_.bottom:n.top+this.anchorMargin_.top,u=r?n.bottom-this.anchorMargin_.bottom:n.bottom+i.height-this.anchorMargin_.top,c=o.height-s,h=o.height-u;h>0&&c<h&&(t=this.setBit_(t,a.CornerBit.BOTTOM));var f=this.adapter_.isRtl(),d=this.hasBit_(this.anchorCorner_,a.CornerBit.FLIP_RTL),_=this.hasBit_(this.anchorCorner_,a.CornerBit.RIGHT),l=_&&!f||!_&&d&&f,p=l?n.left+i.width+this.anchorMargin_.right:n.left+this.anchorMargin_.left,m=l?n.right-this.anchorMargin_.right:n.right+i.width-this.anchorMargin_.left,y=o.width-p,O=o.width-m;return(y<0&&l&&f||_&&!l&&y<0||O>0&&y<O)&&(t=this.setBit_(t,a.CornerBit.RIGHT)),t},e.prototype.getMenuSurfaceMaxHeight_=function(t){var n=this.measurements_.viewportDistance,i=0,o=this.hasBit_(t,a.CornerBit.BOTTOM),r=this.hasBit_(this.anchorCorner_,a.CornerBit.BOTTOM),s=e.numbers.MARGIN_TO_EDGE;return o?(i=n.top+this.anchorMargin_.top-s,r||(i+=this.measurements_.anchorSize.height)):(i=n.bottom-this.anchorMargin_.bottom+this.measurements_.anchorSize.height-s,r&&(i-=this.measurements_.anchorSize.height)),i},e.prototype.getHorizontalOriginOffset_=function(t){var e=this.measurements_.anchorSize,n=this.hasBit_(t,a.CornerBit.RIGHT),i=this.hasBit_(this.anchorCorner_,a.CornerBit.RIGHT);if(n){var o=i?e.width-this.anchorMargin_.left:this.anchorMargin_.right;return this.isHoistedElement_||this.isFixedPosition_?o-(this.measurements_.viewportSize.width-this.measurements_.bodySize.width):o}return i?e.width-this.anchorMargin_.right:this.anchorMargin_.left},e.prototype.getVerticalOriginOffset_=function(t){var e=this.measurements_.anchorSize,n=this.hasBit_(t,a.CornerBit.BOTTOM),i=this.hasBit_(this.anchorCorner_,a.CornerBit.BOTTOM);return n?i?e.height-this.anchorMargin_.top:-this.anchorMargin_.bottom:i?e.height+this.anchorMargin_.bottom:this.anchorMargin_.top},e.prototype.adjustPositionForHoistedElement_=function(t){var e,n,i=this.measurements_,o=i.windowScroll,s=i.viewportDistance,a=Object.keys(t);try{for(var u=r(a),c=u.next();!c.done;c=u.next()){var h=c.value,f=t[h]||0;f+=s[h],this.isFixedPosition_||("top"===h?f+=o.y:"bottom"===h?f-=o.y:"left"===h?f+=o.x:f-=o.x),t[h]=f}}catch(t){e={error:t}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}},e.prototype.maybeRestoreFocus_=function(){var t=this.adapter_.isFocused(),e=document.activeElement&&this.adapter_.isElementInContainer(document.activeElement);(t||e)&&this.adapter_.restoreFocus()},e.prototype.hasBit_=function(t,e){return Boolean(t&e)},e.prototype.setBit_=function(t,e){return t|e},e.prototype.isFinite_=function(t){return"number"==typeof t&&isFinite(t)},e}(s.MDCFoundation);e.MDCMenuSurfaceFoundation=u,e.default=u},134:function(t,e,n){"use strict";function i(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}var o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var r=o(n(22));e.util=r;var s=n(9);e.Corner=s.Corner,e.CornerBit=s.CornerBit,i(n(31)),i(n(9)),i(n(13))},22:function(t,e,n){"use strict";function i(t,e){if(void 0===e&&(e=!1),void 0===o||e){var n=t.document.createElement("div");o="transform"in n.style?"transform":"webkitTransform"}return o}Object.defineProperty(e,"__esModule",{value:!0});var o;e.getTransformPropertyName=i},31:function(t,e,n){"use strict";var i=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var r=n(1),s=n(9),a=n(13),u=o(n(22)),c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.attachTo=function(t){return new e(t)},e.prototype.initialSyncWithDOM=function(){var t=this,e=this.root_.parentElement;this.anchorElement=e&&e.classList.contains(s.cssClasses.ANCHOR)?e:null,this.root_.classList.contains(s.cssClasses.FIXED)&&this.setFixedPosition(!0),this.handleKeydown_=function(e){return t.foundation_.handleKeydown(e)},this.handleBodyClick_=function(e){return t.foundation_.handleBodyClick(e)},this.registerBodyClickListener_=function(){return document.body.addEventListener("click",t.handleBodyClick_)},this.deregisterBodyClickListener_=function(){return document.body.removeEventListener("click",t.handleBodyClick_)},this.listen("keydown",this.handleKeydown_),this.listen(s.strings.OPENED_EVENT,this.registerBodyClickListener_),this.listen(s.strings.CLOSED_EVENT,this.deregisterBodyClickListener_)},e.prototype.destroy=function(){this.unlisten("keydown",this.handleKeydown_),this.unlisten(s.strings.OPENED_EVENT,this.registerBodyClickListener_),this.unlisten(s.strings.CLOSED_EVENT,this.deregisterBodyClickListener_),t.prototype.destroy.call(this)},e.prototype.isOpen=function(){return this.foundation_.isOpen()},e.prototype.open=function(){this.foundation_.open()},e.prototype.close=function(t){void 0===t&&(t=!1),this.foundation_.close(t)},Object.defineProperty(e.prototype,"quickOpen",{set:function(t){this.foundation_.setQuickOpen(t)},enumerable:!0,configurable:!0}),e.prototype.hoistMenuToBody=function(){document.body.appendChild(this.root_),this.setIsHoisted(!0)},e.prototype.setIsHoisted=function(t){this.foundation_.setIsHoisted(t)},e.prototype.setMenuSurfaceAnchorElement=function(t){this.anchorElement=t},e.prototype.setFixedPosition=function(t){t?this.root_.classList.add(s.cssClasses.FIXED):this.root_.classList.remove(s.cssClasses.FIXED),this.foundation_.setFixedPosition(t)},e.prototype.setAbsolutePosition=function(t,e){this.foundation_.setAbsolutePosition(t,e),this.setIsHoisted(!0)},e.prototype.setAnchorCorner=function(t){this.foundation_.setAnchorCorner(t)},e.prototype.setAnchorMargin=function(t){this.foundation_.setAnchorMargin(t)},e.prototype.getDefaultFoundation=function(){var t=this,e={addClass:function(e){return t.root_.classList.add(e)},removeClass:function(e){return t.root_.classList.remove(e)},hasClass:function(e){return t.root_.classList.contains(e)},hasAnchor:function(){return!!t.anchorElement},notifyClose:function(){return t.emit(a.MDCMenuSurfaceFoundation.strings.CLOSED_EVENT,{})},notifyOpen:function(){return t.emit(a.MDCMenuSurfaceFoundation.strings.OPENED_EVENT,{})},isElementInContainer:function(e){return t.root_.contains(e)},isRtl:function(){return"rtl"===getComputedStyle(t.root_).getPropertyValue("direction")},setTransformOrigin:function(e){var n=u.getTransformPropertyName(window)+"-origin";t.root_.style.setProperty(n,e)},isFocused:function(){return document.activeElement===t.root_},saveFocus:function(){t.previousFocus_=document.activeElement},restoreFocus:function(){t.root_.contains(document.activeElement)&&t.previousFocus_&&t.previousFocus_.focus&&t.previousFocus_.focus()},getInnerDimensions:function(){return{width:t.root_.offsetWidth,height:t.root_.offsetHeight}},getAnchorDimensions:function(){return t.anchorElement?t.anchorElement.getBoundingClientRect():null},getWindowDimensions:function(){return{width:window.innerWidth,height:window.innerHeight}},getBodyDimensions:function(){return{width:document.body.clientWidth,height:document.body.clientHeight}},getWindowScroll:function(){return{x:window.pageXOffset,y:window.pageYOffset}},setPosition:function(e){t.root_.style.left="left"in e?e.left+"px":"",t.root_.style.right="right"in e?e.right+"px":"",t.root_.style.top="top"in e?e.top+"px":"",t.root_.style.bottom="bottom"in e?e.bottom+"px":""},setMaxHeight:function(e){t.root_.style.maxHeight=e}};return new a.MDCMenuSurfaceFoundation(e)},e}(r.MDCComponent);e.MDCMenuSurface=c},9:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={ANCHOR:"mdc-menu-surface--anchor",ANIMATING_CLOSED:"mdc-menu-surface--animating-closed",ANIMATING_OPEN:"mdc-menu-surface--animating-open",FIXED:"mdc-menu-surface--fixed",OPEN:"mdc-menu-surface--open",ROOT:"mdc-menu-surface"};e.cssClasses=i;var o={CLOSED_EVENT:"MDCMenuSurface:closed",OPENED_EVENT:"MDCMenuSurface:opened",FOCUSABLE_ELEMENTS:["button:not(:disabled)",'[href]:not([aria-disabled="true"])',"input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)",'[tabindex]:not([tabindex="-1"]):not([aria-disabled="true"])'].join(", ")};e.strings=o;var r={TRANSITION_OPEN_DURATION:120,TRANSITION_CLOSE_DURATION:75,MARGIN_TO_EDGE:32,ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO:.67};e.numbers=r;var s;!function(t){t[t.BOTTOM=1]="BOTTOM",t[t.CENTER=2]="CENTER",t[t.RIGHT=4]="RIGHT",t[t.FLIP_RTL=8]="FLIP_RTL"}(s||(s={})),e.CornerBit=s;var a;!function(t){t[t.TOP_LEFT=0]="TOP_LEFT",t[t.TOP_RIGHT=4]="TOP_RIGHT",t[t.BOTTOM_LEFT=1]="BOTTOM_LEFT",t[t.BOTTOM_RIGHT=5]="BOTTOM_RIGHT",t[t.TOP_START=8]="TOP_START",t[t.TOP_END=12]="TOP_END",t[t.BOTTOM_START=9]="BOTTOM_START",t[t.BOTTOM_END=13]="BOTTOM_END"}(a||(a={})),e.Corner=a}})});
//# sourceMappingURL=mdc.menuSurface.min.js.map
{
"name": "@material/menu-surface",
"version": "3.0.0-alpha.1",
"version": "3.0.0",
"description": "The Material Components for the web menu surface component",

@@ -20,9 +20,9 @@ "license": "MIT",

"dependencies": {
"@material/animation": "^1.0.0",
"@material/base": "^1.0.0",
"@material/elevation": "^3.0.0-alpha.1",
"@material/feature-targeting": "^0.44.1",
"@material/rtl": "^0.42.0",
"@material/shape": "^3.0.0-alpha.1",
"@material/theme": "^3.0.0-alpha.1",
"@material/animation": "^3.0.0",
"@material/base": "^3.0.0",
"@material/elevation": "^3.0.0",
"@material/feature-targeting": "^3.0.0",
"@material/rtl": "^3.0.0",
"@material/shape": "^3.0.0",
"@material/theme": "^3.0.0",
"tslib": "^1.9.3"

@@ -33,3 +33,3 @@ },

},
"gitHead": "dae97b98c21bb93075a9688cf1f9076a4fe5a85d"
"gitHead": "747f6ed544e3a3bb3fde71ceaa51359f2212bfb9"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc