UNPKG

@caofeilong/vue-menu

Version:

Vue component for menu & contextmenu

1 lines 38.2 kB
!function(t,e){for(var n in e)t[n]=e[n]}(exports,function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=9)}([function(t,e){t.exports=require("vue-property-decorator")},function(t,e){t.exports=require("@caofeilong/keybind")},function(t,e,n){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n=function(t,e){var n=t[1]||"",o=t[3];if(!o)return n;if(e&&"function"==typeof btoa){var r=(u=o,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(u))))+" */"),i=o.sources.map(function(t){return"/*# sourceURL="+o.sourceRoot+t+" */"});return[n].concat(i).concat([r]).join("\n")}var u;return[n].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+n+"}":n}).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var o={},r=0;r<this.length;r++){var i=this[r][0];null!=i&&(o[i]=!0)}for(r=0;r<t.length;r++){var u=t[r];null!=u[0]&&o[u[0]]||(n&&!u[2]?u[2]=n:n&&(u[2]="("+u[2]+") and ("+n+")"),e.push(u))}},e}},function(t,e,n){var o,r,i={},u=(o=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===r&&(r=o.apply(this,arguments)),r}),c=function(t){var e={};return function(t,n){if("function"==typeof t)return t();if(void 0===e[t]){var o=function(t,e){return e?e.querySelector(t):document.querySelector(t)}.call(this,t,n);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(t){o=null}e[t]=o}return e[t]}}(),a=null,s=0,l=[],p=n(13);function f(t,e){for(var n=0;n<t.length;n++){var o=t[n],r=i[o.id];if(r){r.refs++;for(var u=0;u<r.parts.length;u++)r.parts[u](o.parts[u]);for(;u<o.parts.length;u++)r.parts.push(b(o.parts[u],e))}else{var c=[];for(u=0;u<o.parts.length;u++)c.push(b(o.parts[u],e));i[o.id]={id:o.id,refs:1,parts:c}}}}function d(t,e){for(var n=[],o={},r=0;r<t.length;r++){var i=t[r],u=e.base?i[0]+e.base:i[0],c={css:i[1],media:i[2],sourceMap:i[3]};o[u]?o[u].parts.push(c):n.push(o[u]={id:u,parts:[c]})}return n}function h(t,e){var n=c(t.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var o=l[l.length-1];if("top"===t.insertAt)o?o.nextSibling?n.insertBefore(e,o.nextSibling):n.appendChild(e):n.insertBefore(e,n.firstChild),l.push(e);else if("bottom"===t.insertAt)n.appendChild(e);else{if("object"!=typeof t.insertAt||!t.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var r=c(t.insertAt.before,n);n.insertBefore(e,r)}}function v(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t);var e=l.indexOf(t);e>=0&&l.splice(e,1)}function y(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var o=function(){0;return n.nc}();o&&(t.attrs.nonce=o)}return m(e,t.attrs),h(t,e),e}function m(t,e){Object.keys(e).forEach(function(n){t.setAttribute(n,e[n])})}function b(t,e){var n,o,r,i;if(e.transform&&t.css){if(!(i="function"==typeof e.transform?e.transform(t.css):e.transform.default(t.css)))return function(){};t.css=i}if(e.singleton){var u=s++;n=a||(a=y(e)),o=_.bind(null,n,u,!1),r=_.bind(null,n,u,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",m(e,t.attrs),h(t,e),e}(e),o=function(t,e,n){var o=n.css,r=n.sourceMap,i=void 0===e.convertToAbsoluteUrls&&r;(e.convertToAbsoluteUrls||i)&&(o=p(o));r&&(o+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var u=new Blob([o],{type:"text/css"}),c=t.href;t.href=URL.createObjectURL(u),c&&URL.revokeObjectURL(c)}.bind(null,n,e),r=function(){v(n),n.href&&URL.revokeObjectURL(n.href)}):(n=y(e),o=function(t,e){var n=e.css,o=e.media;o&&t.setAttribute("media",o);if(t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}.bind(null,n),r=function(){v(n)});return o(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;o(t=e)}else r()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=u()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var n=d(t,e);return f(n,e),function(t){for(var o=[],r=0;r<n.length;r++){var u=n[r];(c=i[u.id]).refs--,o.push(c)}t&&f(d(t,e),e);for(r=0;r<o.length;r++){var c;if(0===(c=o[r]).refs){for(var a=0;a<c.parts.length;a++)c.parts[a]();delete i[c.id]}}}};var g,w=(g=[],function(t,e){return g[t]=e,g.filter(Boolean).join("\n")});function _(t,e,n,o){var r=n?"":o.css;if(t.styleSheet)t.styleSheet.cssText=w(e,r);else{var i=document.createTextNode(r),u=t.childNodes;u[e]&&t.removeChild(u[e]),u.length?t.insertBefore(i,u[e]):t.appendChild(i)}}},function(t,e,n){var o=n(12);"string"==typeof o&&(o=[[t.i,o,""]]);var r={hmr:!0,transform:void 0,insertInto:void 0};n(3)(o,r);o.locals&&(t.exports=o.locals)},function(t,e,n){var o=n(15);"string"==typeof o&&(o=[[t.i,o,""]]);var r={hmr:!0,transform:void 0,insertInto:void 0};n(3)(o,r);o.locals&&(t.exports=o.locals)},function(t,e,n){var o=n(17);"string"==typeof o&&(o=[[t.i,o,""]]);var r={hmr:!0,transform:void 0,insertInto:void 0};n(3)(o,r);o.locals&&(t.exports=o.locals)},function(t,e,n){var o=n(19);"string"==typeof o&&(o=[[t.i,o,""]]);var r={hmr:!0,transform:void 0,insertInto:void 0};n(3)(o,r);o.locals&&(t.exports=o.locals)},function(t,e,n){var o=n(21);"string"==typeof o&&(o=[[t.i,o,""]]);var r={hmr:!0,transform:void 0,insertInto:void 0};n(3)(o,r);o.locals&&(t.exports=o.locals)},function(t,e,n){n(10),t.exports=n(22)},function(t,e){t.exports=require("es6-promise/auto")},function(t,e,n){"use strict";var o=n(4);n.n(o).a},function(t,e,n){(t.exports=n(2)(!1)).push([t.i,".menubar[data-v-56fd8264] {\n display: table;\n font-family: sans-serif;\n padding: 0 0.5em;\n user-select: none;\n cursor: default;\n}\n",""])},function(t,e){t.exports=function(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var n=e.protocol+"//"+e.host,o=n+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(t,e){var r,i=e.trim().replace(/^"(.*)"$/,function(t,e){return e}).replace(/^'(.*)'$/,function(t,e){return e});return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(i)?t:(r=0===i.indexOf("//")?i:0===i.indexOf("/")?n+i:o+i.replace(/^\.\//,""),"url("+JSON.stringify(r)+")")})}},function(t,e,n){"use strict";var o=n(5);n.n(o).a},function(t,e,n){(t.exports=n(2)(!1)).push([t.i,".menu[data-v-7fd2e88a] {\n font-family: sans-serif;\n border-radius: 4pt;\n cursor: default;\n user-select: none;\n overflow: auto;\n}\n.fixed[data-v-7fd2e88a] {\n position: fixed;\n top: 0;\n left: 0;\n}\n.fade-leave-active[data-v-7fd2e88a] {\n transition: opacity .2s ease;\n}\n.fade-leave-to[data-v-7fd2e88a] {\n opacity: 0;\n}\n",""])},function(t,e,n){"use strict";var o=n(6);n.n(o).a},function(t,e,n){(t.exports=n(2)(!1)).push([t.i,".menubaritem[data-v-72252ca1] {\n display: table-cell;\n padding: 6pt 0.5em 4pt 0.5em;\n}\n",""])},function(t,e,n){"use strict";var o=n(7);n.n(o).a},function(t,e,n){(t.exports=n(2)(!1)).push([t.i,".menuitem[data-v-717f89e4] {\n display: flex;\n align-items: baseline;\n padding: 2px 8pt 2px 4pt;\n white-space: nowrap;\n}\n.label[data-v-717f89e4] {\n flex-grow: 1;\n}\n",""])},function(t,e,n){"use strict";var o=n(8);n.n(o).a},function(t,e,n){(t.exports=n(2)(!1)).push([t.i,".separator[data-v-469f5cdc] {\n height: 1pt;\n margin: 4pt 0;\n}\n",""])},function(t,e,n){"use strict";n.r(e);var o=function(){var t=this,e=t.$createElement;return(t._self._c||e)("div",{staticClass:"menubar",style:t.menuStyle.menubar,on:{mousedown:function(e){return e.preventDefault(),t.mousedown(e)}}},[t._t("default")],2)};o._withStripped=!0;var r=n(0),i=function(){function t(t){this.menuitem=t}return t.type="menuitemactivate",t}(),u=function(){function t(t){void 0===t&&(t=!1),this.fromChild=t}return t.type="menuclose",t}(),c=function(){function t(t){this.menubaritem=t}return t.type="menubaritemactivate",t}(),a=function(){function t(){}return t.type="menubardeactivate",t}();function s(t,e,n){var o=function(t){n(t),r()},r=function(){t.removeEventListener(e,o)};return t.addEventListener(e,o),r}var l="@hscmap/vue-menu/menuStyle";function p(t){return{provide:function(){var e;return null==t.animation&&(t.animation=!0),(e={})[l]=t,e},render:function(t){return t("div",this.$slots.default)}}}var f,d,h=p({menu:f={backgroundColor:"rgba(31, 31, 31, 0.9)",color:"white",boxShadow:"0 0 4pt rgba(255, 255, 255, 0.25)"},menubar:f,separator:{backgroundColor:"rgba(127, 127, 127, 0.5)"},active:{backgroundColor:"rgba(127, 127, 127, 0.75)"},disabled:{opacity:"0.5"},animation:!0}),v=p(function(){var t={backgroundColor:"rgba(255, 255, 255, 0.9)",color:"black",boxShadow:"0 2pt 6pt rgba(0, 0, 0, 0.5)"};return{menu:t,menubar:t,separator:{backgroundColor:"rgba(127, 127, 127, 0.5)"},active:{backgroundColor:"rgba(127, 127, 127, 0.75)",color:"#fff"},disabled:{opacity:"0.5"},animation:!0}}()),y=p({menu:{backgroundColor:"rgb(215, 215, 215)",color:"black",boxShadow:"0 2pt 6pt rgba(0, 0, 0, 0.5)"},menubar:{background:"linear-gradient(to bottom, rgb(215, 215, 215), rgb(191, 191, 191))",color:"black",boxShadow:"0 2pt 6pt rgba(0, 0, 0, 0.5)"},separator:{backgroundColor:"rgba(127, 127, 127, 0.5)"},active:{backgroundColor:"rgba(127, 127, 127, 0.75)",color:"#fff"},disabled:{opacity:"0.5"},animation:!0}),m=(d=function(t,e){return(d=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])})(t,e)},function(t,e){function n(){this.constructor=t}d(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),b=function(t,e,n,o){var r,i=arguments.length,u=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,n,o);else for(var c=t.length-1;c>=0;c--)(r=t[c])&&(u=(i<3?r(u):i>3?r(e,n,u):r(e,n))||u);return i>3&&u&&Object.defineProperty(e,n,u),u},g=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.active=!1,e}return m(e,t),e.prototype.deactivate=function(){this.active=!1,this.$emit(a.type,new a),this.clearCancellers()},e.prototype.beforeDestroy=function(){this.clearCancellers()},e.prototype.mousedown=function(t){var e=this;if(this.active)return this.deactivate();this.active=!0,this.clearCancellers(),this.cancelMouseup=s(document,"mouseup",function(n){e.cancelMouseup=void 0,n.timeStamp-t.timeStamp>=500?e.deactivate():e.cancelMousedown=s(document,"mousedown",function(){e.cancelMousedown=void 0,e.deactivate()})})},e.prototype.clearCancellers=function(){this.cancelMouseup&&this.cancelMouseup(),this.cancelMousedown&&this.cancelMousedown()},b([Object(r.Inject)(l)],e.prototype,"menuStyle",void 0),b([Object(r.Prop)({default:0})],e.prototype,"paddingTop",void 0),e=b([Object(r.Component)({provide:function(){var t;return(t={})["@hscmap/vue-menu/menubar"]=this,t}})],e)}(r.Vue),w=g;n(11);function _(t,e,n,o,r,i,u,c){var a,s="function"==typeof t?t.options:t;if(e&&(s.render=e,s.staticRenderFns=n,s._compiled=!0),o&&(s.functional=!0),i&&(s._scopeId="data-v-"+i),u?(a=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(u)},s._ssrRegister=a):r&&(a=c?function(){r.call(this,this.$root.$options.shadowRoot)}:r),a)if(s.functional){s._injectStyles=a;var l=s.render;s.render=function(t,e){return a.call(e),l(t,e)}}else{var p=s.beforeCreate;s.beforeCreate=p?[].concat(p,a):[a]}return{exports:t,options:s}}var O=_(w,o,[],!1,null,"56fd8264",null);O.options.__file="src/menubar/index.vue";var x=O.exports,j=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"menubaritem",style:t.style,on:{mousedown:t.mousedown,mouseenter:t.mouseenter,mouseleave:t.mouseleave}},[n("div",{style:{paddingTop:t.paddingTop}}),t._v("\n "+t._s(t.label)+"\n "),n("x-menu",{ref:"menu"},[t._t("default")],2)],1)};j._withStripped=!0;var M=function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"fixed"},[e("div",{ref:"wrapper",staticStyle:{position:"absolute"}},[e("transition",{attrs:{name:this.fade}},[e("div",{directives:[{name:"show",rawName:"v-show",value:this.isOpen,expression:"isOpen"}],ref:"menu",staticClass:"menu",style:this.style,on:{mousedown:function(t){t.stopPropagation(),t.preventDefault()},mouseup:function(t){t.stopPropagation()}}},[this._t("default")],2)])],1)])};M._withStripped=!0;var P=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 o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),S=function(){return(S=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},k=function(t,e,n,o){var r,i=arguments.length,u=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,n,o);else for(var c=t.length-1;c>=0;c--)(r=t[c])&&(u=(i<3?r(u):i>3?r(e,n,u):r(e,n))||u);return i>3&&u&&Object.defineProperty(e,n,u),u},C=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.isOpen=!1,e.fade="none",e.submenuDirection="right",e}return P(e,t),e.prototype.open=function(t,e,n){void 0===n&&(n="right"),this.setPosition(t,e,n),this.isOpen=!0},e.prototype.close=function(t,e){void 0===e&&(e=!1),this.isOpen&&(this.fade=t&&this.menuStyle.animation?"fade":"none",this.isOpen=!1,t||(this.menuElement().style.display="none"),this.$emit(u.type,new u(e))),e&&this.parentMenuitem&&this.parentMenuitem.parentMenu.close(t,!0)},e.prototype.setPosition=function(t,e,n){var o,r,i,u=this;t=Math.floor(t),e=Math.floor(e),o=[this.menuElement(),this.wrapperElement()],r=function(o){var r=o[0],i=o[1],c=r.getBoundingClientRect();r.style.maxHeight=window.innerHeight-8+"px",i.style.left=("right"==n?t:t-c.width+1)+"px",i.style.top=e+"px",(c=r.getBoundingClientRect()).bottom>window.innerHeight&&(i.style.top=window.innerHeight-c.height+"px"),u.submenuDirection=n,c.right>window.innerWidth&&(u.submenuDirection="left",i.style.left=t-c.width-(u.parentMenuitem?u.parentMenuitem.$el.clientWidth:0)+"px"),c.left<0&&(u.submenuDirection="right",i.style.left=t+(u.parentMenuitem?u.parentMenuitem.$el.clientWidth:0)+"px")},i=o.map(function(t){var e=t.style,n=e.display,o=e.visibility;return t.style.display="block",t.style.visibility="visible",{display:n,visibility:o}}),r(o),o.forEach(function(t,e){var n=i[e],o=n.display,r=n.visibility;t.style.display=o,t.style.visibility=r})},e.prototype.menuElement=function(){return this.$refs.menu},e.prototype.wrapperElement=function(){return this.$refs.wrapper},Object.defineProperty(e.prototype,"style",{get:function(){return S({},this.menuStyle.menu,{padding:"4px 0"})},enumerable:!0,configurable:!0}),e.prototype.mounted=function(){document.body.appendChild(this.$el)},e.prototype.beforeDestroy=function(){this.$el&&this.$el.parentNode&&this.$el.parentNode.removeChild(this.$el)},k([Object(r.Prop)()],e.prototype,"parentMenuitem",void 0),k([Object(r.Inject)(l)],e.prototype,"menuStyle",void 0),e=k([Object(r.Component)({provide:function(){var t;return(t={})["@hscmap/vue-menu/parentMenu"]=this,t}})],e)}(r.Vue);var $=C,R=(n(14),_($,M,[],!1,null,"7fd2e88a",null));R.options.__file="src/menu/index.vue";var E=R.exports,T=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function u(t){try{a(o.next(t))}catch(t){i(t)}}function c(t){try{a(o.throw(t))}catch(t){i(t)}}function a(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(u,c)}a((o=o.apply(t,e||[])).next())})},A=function(t,e){var n,o,r,i,u={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,o=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(r=(r=u.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){u.label=i[1];break}if(6===i[0]&&u.label<r[1]){u.label=r[1],r=i;break}if(r&&u.label<r[2]){u.label=r[2],u.ops.push(i);break}r[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},I=new(function(){function t(){this.q=[],this.open=!0}return t.prototype.lock=function(t){return T(this,void 0,void 0,function(){return A(this,function(e){switch(e.label){case 0:return this.q.push(t),[4,this.challenge()];case 1:return e.sent(),[2]}})})},t.prototype.challenge=function(){return T(this,void 0,void 0,function(){return A(this,function(t){switch(t.label){case 0:if(!this.open)return[3,4];this.open=!1,t.label=1;case 1:return this.q.length>0?[4,this.q.shift()()]:[3,3];case 2:return t.sent(),[3,1];case 3:this.open=!0,t.label=4;case 4:return[2]}})})},t}()),D=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 o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),L=function(t,e,n,o){var r,i=arguments.length,u=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,n,o);else for(var c=t.length-1;c>=0;c--)(r=t[c])&&(u=(i<3?r(u):i>3?r(e,n,u):r(e,n))||u);return i>3&&u&&Object.defineProperty(e,n,u),u},U=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function u(t){try{a(o.next(t))}catch(t){i(t)}}function c(t){try{a(o.throw(t))}catch(t){i(t)}}function a(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(u,c)}a((o=o.apply(t,e||[])).next())})},B=function(t,e){var n,o,r,i,u={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,o=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(r=(r=u.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){u.label=i[1];break}if(6===i[0]&&u.label<r[1]){u.label=r[1],r=i;break}if(r&&u.label<r[2]){u.label=r[2],u.ops.push(i);break}r[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},N=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.hover=!1,e.isOpen=!1,e}return D(e,t),e.prototype.mounted=function(){var t=this;this.menu().$on(u.type,function(e){t.isOpen=!1,e.fromChild&&t.menubar.deactivate()}),this.menubar.$on(c.type,function(e){if(t!=e.menubaritem){var n=t.menu();n&&n.close(!1)}}),this.menubar.$on(a.type,function(e){var n=t.menu();n&&n.close(!0)})},e.prototype.onMenuiatemFired=function(){var t=this;setTimeout(function(){t.hover=!1},200)},Object.defineProperty(e.prototype,"style",{get:function(){return this.active?this.menuStyle.active:{}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"paddingTop",{get:function(){return this.menubar.paddingTop+"px"},enumerable:!0,configurable:!0}),e.prototype.menu=function(){return this.$refs.menu},e.prototype.activate=function(){var t=this.$el.getBoundingClientRect();this.menu().open(t.left,t.bottom),this.menubar.$emit(c.type,new c(this)),this.isOpen=!0},e.prototype.mousedown=function(){var t=this;I.lock(function(){return U(t,void 0,void 0,function(){return B(this,function(t){return this.activate(),[2]})})})},e.prototype.mouseenter=function(){var t=this;I.lock(function(){return U(t,void 0,void 0,function(){return B(this,function(t){return this.hover=!0,this.menubar.active&&this.activate(),[2]})})})},e.prototype.mouseleave=function(){var t=this;I.lock(function(){return U(t,void 0,void 0,function(){return B(this,function(t){return this.hover=!1,[2]})})})},Object.defineProperty(e.prototype,"active",{get:function(){return this.hover||this.isOpen},enumerable:!0,configurable:!0}),L([Object(r.Prop)({type:String,required:!0})],e.prototype,"label",void 0),L([Object(r.Inject)("@hscmap/vue-menu/menubar")],e.prototype,"menubar",void 0),L([Object(r.Inject)(l)],e.prototype,"menuStyle",void 0),e=L([Object(r.Component)({components:{XMenu:E},provide:function(){var t;return(t={})["@hscmap/vue-menu/menubaritem"]=this,t}})],e)}(r.Vue),q=(n(16),_(N,j,[],!1,null,"72252ca1",null));q.options.__file="src/menubaritem/index.vue";var H=q.exports,F=function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticStyle:{display:"inline-block"},on:{contextmenu:this.openMenu}},[this._t("default"),this._v(" "),e("x-menu",{ref:"menu",style:this.menuStyle},[this._t("contextmenu")],2)],2)};F._withStripped=!0;var V=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 o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),X=function(t,e,n,o){var r,i=arguments.length,u=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,n,o);else for(var c=t.length-1;c>=0;c--)(r=t[c])&&(u=(i<3?r(u):i>3?r(e,n,u):r(e,n))||u);return i>3&&u&&Object.defineProperty(e,n,u),u},G=[];var W=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return V(e,t),Object.defineProperty(e.prototype,"menuStyle",{get:function(){return null==this.menuZIndex?{}:{zIndex:String(this.menuZIndex)}},enumerable:!0,configurable:!0}),e.prototype.menu=function(){return this.$refs.menu},e.prototype.beforeDestroy=function(){this.clearCancellers()},e.prototype.openMenu=function(t){var e=this;if(t.preventDefault(),function(){for(;G.length>0;)G.pop().close()}(),G.push(this),this.clearCancellers(),this.menu().isOpen)return this.close();this.cancelMouseup=s(document,"mouseup",function(n){e.cancelMouseup=void 0,n.timeStamp-t.timeStamp>=500?e.close():e.cancelMousedown=s(document,"mousedown",function(t){e.cancelMousedown=void 0,function(t){return 2==t.button||t.ctrlKey}(t)||e.close()})});var n=this.position(t);this.menu().open(n.x,n.y,n.direction)},e.prototype.close=function(){this.clearCancellers();var t=this.menu();t&&t.close(!0)},e.prototype.clearCancellers=function(){this.cancelMouseup&&this.cancelMouseup(),this.cancelMousedown&&this.cancelMousedown()},e.prototype.mounted=function(){var t=this;this.$watch(function(){return t.menu().isOpen},function(e){t.$emit(e?"open":"close")})},X([Object(r.Prop)({type:Function})],e.prototype,"position",void 0),X([Object(r.Prop)({type:Number})],e.prototype,"menuZIndex",void 0),e=X([Object(r.Component)({components:{XMenu:E},provide:function(){var t;return(t={})["@hscmap/vue-menu/menubaritem"]=void 0,t}})],e)}(r.Vue);var J=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 o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),K=function(t,e,n,o){var r,i=arguments.length,u=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,n,o);else for(var c=t.length-1;c>=0;c--)(r=t[c])&&(u=(i<3?r(u):i>3?r(e,n,u):r(e,n))||u);return i>3&&u&&Object.defineProperty(e,n,u),u};function Z(t){return{x:t.clientX,y:t.clientY,direction:"right"}}var z=_(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return J(e,t),K([Object(r.Prop)({type:Function,default:Z})],e.prototype,"position",void 0),e=K([r.Component],e)}(W),F,[],!1,null,null,null);z.options.__file="src/contextmenu.vue";var Y=z.exports,Q=function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticStyle:{display:"inline-block"}},[e("div",{on:{mousedown:this.openMenu}},[this._t("default")],2),this._v(" "),e("x-menu",{ref:"menu",style:this.menuStyle},[this._t("contextmenu")],2)],1)};Q._withStripped=!0;var tt=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 o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),et=function(t,e,n,o){var r,i=arguments.length,u=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,n,o);else for(var c=t.length-1;c>=0;c--)(r=t[c])&&(u=(i<3?r(u):i>3?r(e,n,u):r(e,n))||u);return i>3&&u&&Object.defineProperty(e,n,u),u};function nt(t){var e=t.currentTarget.children.item(0).getBoundingClientRect();return{x:e.left,y:e.bottom,direction:"right"}}var ot=_(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return tt(e,t),et([Object(r.Prop)({type:Function,default:nt})],e.prototype,"position",void 0),e=et([r.Component],e)}(W),Q,[],!1,null,null,null);ot.options.__file="src/buttonmenu.vue";var rt=ot.exports,it=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[t.keybind?n("x-keybinder",{attrs:{source:t.keybind,enabled:!t.disabled},on:{keybindmatch:t.fire}}):t._e(),t._v(" "),n("div",{staticClass:"menuitem",style:t.style,on:{mouseenter:function(e){return e.stopPropagation(),t.mouseenter(e)},mouseleave:t.mouseleave,mouseup:t.mouseup,mousedown:function(t){t.stopPropagation(),t.preventDefault()}}},[n("div",{staticStyle:{padding:"0 0.3em"},style:{visibility:t.showCheckmark?"visible":"hidden"}},[t._v("✓")]),t._v(" "),n("div",{staticClass:"label"},[t.$slots.body?t._t("body"):n("div",{domProps:{innerHTML:t._s(t.label)}})],2),t._v(" "),n("div",{staticStyle:{"padding-left":"1em"}},[t.$slots.default?n("span",[t._v("▸")]):t._e(),t._v(" "),n("span",{domProps:{innerHTML:t._s(t.keybindHTML)}})]),t._v(" "),t.$slots.default?n("div",[n("x-menu",{ref:"childMenu",attrs:{parentMenuitem:this}},[t._t("default")],2)],1):t._e()])],1)};it._withStripped=!0;var ut=n(1),ct=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 o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),at=function(t,e,n,o){var r,i=arguments.length,u=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,n,o);else for(var c=t.length-1;c>=0;c--)(r=t[c])&&(u=(i<3?r(u):i>3?r(e,n,u):r(e,n))||u);return i>3&&u&&Object.defineProperty(e,n,u),u},st=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return ct(e,t),e.prototype.created=function(){var t=this;this.off=ut.on(this.source,function(e){t.enabled&&t.$emit("keybindmatch")})},e.prototype.updated=function(){console.warn("Changing keybind dynamically is not supported.")},e.prototype.beforeDestroy=function(){this.off()},e.prototype.render=function(t){},at([Object(r.Prop)({required:!0,type:String})],e.prototype,"source",void 0),at([Object(r.Prop)({type:Boolean,default:!0})],e.prototype,"enabled",void 0),e=at([r.Component],e)}(r.Vue),lt=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 o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),pt=function(){return(pt=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},ft=function(t,e,n,o){var r,i=arguments.length,u=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,n,o);else for(var c=t.length-1;c>=0;c--)(r=t[c])&&(u=(i<3?r(u):i>3?r(e,n,u):r(e,n))||u);return i>3&&u&&Object.defineProperty(e,n,u),u},dt=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function u(t){try{a(o.next(t))}catch(t){i(t)}}function c(t){try{a(o.throw(t))}catch(t){i(t)}}function a(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(u,c)}a((o=o.apply(t,e||[])).next())})},ht=function(t,e){var n,o,r,i,u={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,o=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(r=(r=u.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){u.label=i[1];break}if(6===i[0]&&u.label<r[1]){u.label=r[1],r=i;break}if(r&&u.label<r[2]){u.label=r[2],u.ops.push(i);break}r[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},vt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.hover=!1,e}return lt(e,t),e.prototype.created=function(){void 0!==this.vModel&&(mt(["radio","checkbox"].indexOf(this.type)>=0,'prop :type must be one of "radio" or "checkbox"'),"checkbox"==this.type?mt(Array.isArray(this.vModel)||"boolean"==typeof this.vModel,"v-model must be an array or boolean"):"radio"==this.type&&mt(void 0!==this.value,"v-model must be set"))},Object.defineProperty(e.prototype,"keybindHTML",{get:function(){return this.keybind&&ut.html(this.keybind)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"style",{get:function(){var t=this.menuStyle,e=t.active,n=t.disabled;return pt({},this.active?e:{},this.disabled?n:{})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showCheckmark",{get:function(){return"radio"==this.type?this.vModel==this.value:"checkbox"==this.type&&void 0!==this.vModel?Array.isArray(this.vModel)?this.vModel.indexOf(this.value)>=0:this.vModel:this.checked},enumerable:!0,configurable:!0}),e.prototype.mounted=function(){var t=this;this.parentMenu.$on(i.type,function(e){e.menuitem!=t&&t.deactivate()}),this.parentMenu.$on(u.type,function(e){t.hover=!1;var n=t.childMenu();n&&n.close(!0)})},Object.defineProperty(e.prototype,"active",{get:function(){var t=this.childMenu();return this.hover||t&&t.isOpen},enumerable:!0,configurable:!0}),e.prototype.activate=function(){this.parentMenu.$emit(i.type,new i(this));var t=this.childMenu();if(t){var e=this.$el.getBoundingClientRect(),n=this.parentMenu.submenuDirection;t.open(e[n],e.top-4,n)}},e.prototype.deactivate=function(){var t=this.childMenu();t&&t.close(!1)},e.prototype.fire=function(){if(this.$emit("click"),"radio"==this.type)this.$emit("input",this.value);else if("checkbox"==this.type&&void 0!==this.vModel)if(Array.isArray(this.vModel)){var t=this.vModel.indexOf(this.value),e=this.vModel.slice();t>=0?e.splice(t,1):e.push(this.value),this.$emit("input",e)}else this.$emit("input",!this.vModel);this.menubaritem&&this.menubaritem.onMenuiatemFired()},e.prototype.flash=function(){return dt(this,void 0,void 0,function(){var t,e;return ht(this,function(n){switch(n.label){case 0:if(!this.menuStyle.animation)return[3,5];t=50,e=0,n.label=1;case 1:return e<3?(this.hover=!1,[4,yt(t)]):[3,5];case 2:return n.sent(),this.hover=!0,[4,yt(t)];case 3:n.sent(),n.label=4;case 4:return++e,[3,1];case 5:return this.hover=!1,[2]}})})},e.prototype.childMenu=function(){var t=this.$refs.childMenu;return t||void 0},e.prototype.mouseenter=function(t){var e=this;this.disabled||I.lock(function(){return dt(e,void 0,void 0,function(){return ht(this,function(t){return this.parentMenu.isOpen&&(this.hover=!0,this.activate()),[2]})})})},e.prototype.mouseleave=function(t){var e=this;I.lock(function(){return dt(e,void 0,void 0,function(){return ht(this,function(t){return this.parentMenu.isOpen&&(this.hover=!1),[2]})})})},e.prototype.mouseup=function(t){var e=this;this.hover&&I.lock(function(){return dt(e,void 0,void 0,function(){var e=this;return ht(this,function(n){return this.parentMenu.isOpen&&!this.$slots.default&&I.lock(function(){return dt(e,void 0,void 0,function(){return ht(this,function(e){switch(e.label){case 0:return this.sync?[3,2]:[4,this.flash()];case 1:e.sent(),e.label=2;case 2:return this.fire(),t.shiftKey||this.parentMenu.close(!0,!0),[2]}})})}),[2]})})})},ft([Object(r.Inject)("@hscmap/vue-menu/parentMenu")],e.prototype,"parentMenu",void 0),ft([Object(r.Inject)(l)],e.prototype,"menuStyle",void 0),ft([Object(r.Inject)("@hscmap/vue-menu/menubaritem")],e.prototype,"menubaritem",void 0),ft([Object(r.Prop)({type:String,default:""})],e.prototype,"label",void 0),ft([Object(r.Prop)({type:Boolean,default:!1})],e.prototype,"checked",void 0),ft([Object(r.Prop)({type:Boolean,default:!1})],e.prototype,"disabled",void 0),ft([Object(r.Prop)({type:String})],e.prototype,"keybind",void 0),ft([Object(r.Prop)({default:!1})],e.prototype,"sync",void 0),ft([Object(r.Prop)({default:"checkbox"})],e.prototype,"type",void 0),ft([Object(r.Prop)()],e.prototype,"vModel",void 0),ft([Object(r.Prop)()],e.prototype,"value",void 0),e=ft([Object(r.Component)({components:{XMenu:E,XKeybinder:st},model:{prop:"vModel"}})],e)}(r.Vue);function yt(t){return new Promise(function(e){return setTimeout(e,t)})}function mt(t,e){if(!t)throw new Error(e)}var bt=vt,gt=(n(18),_(bt,it,[],!1,null,"717f89e4",null));gt.options.__file="src/menuitem/index.vue";var wt=gt.exports,_t=function(){var t=this.$createElement;return(this._self._c||t)("div",{staticClass:"separator",style:this.menuStyle.separator})};_t._withStripped=!0;var Ot={inject:{menuStyle:l}},xt=(n(20),_(Ot,_t,[],!1,null,"469f5cdc",null));xt.options.__file="src/separator.vue";var jt=xt.exports;function Mt(t,e){void 0===e&&(e={prefix:"hsc-menu"});var n=e.prefix;t.component(n+"-bar",x),t.component(""+n,E),t.component(n+"-bar-item",H),t.component(n+"-context-menu",Y),t.component(n+"-button-menu",rt),t.component(n+"-item",wt),t.component(n+"-separator",jt),t.component(n+"-style-black",h),t.component(n+"-style-white",v),t.component(n+"-style-metal",y)}n.d(e,"install",function(){return Mt}),n.d(e,"Menubar",function(){return x}),n.d(e,"Menu",function(){return E}),n.d(e,"Menubaritem",function(){return H}),n.d(e,"Contextmenu",function(){return Y}),n.d(e,"Buttonmenu",function(){return rt}),n.d(e,"Menuitem",function(){return wt}),n.d(e,"Separator",function(){return jt}),n.d(e,"MenubarType",function(){return g}),n.d(e,"MenuType",function(){return C}),n.d(e,"MenuitemType",function(){return vt}),n.d(e,"StyleFactory",function(){return p}),n.d(e,"StyleBlack",function(){return h}),n.d(e,"StyleWhite",function(){return v}),n.d(e,"StyleMetal",function(){return y}),n.d(e,"keyDomBind",function(){return ut.bind})}]));