vue-cube-contextmenu
Version:
ContextMenu in Vue with accessibility support
2 lines • 11.2 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("Vue")):"function"==typeof define&&define.amd?define("ContextMenu",["Vue"],t):"object"==typeof exports?exports.ContextMenu=t(require("Vue")):e.ContextMenu=t(e.Vue)}(this,function(e){return function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},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="/dist/",t(t.s=12)}([function(e,t,n){"use strict";var o=n(26),i=n.n(o);t.a=new i.a},function(e,t){e.exports=function(){var e=[];return e.toString=function(){for(var e=[],t=0;t<this.length;t++){var n=this[t];n[2]?e.push("@media "+n[2]+"{"+n[1]+"}"):e.push(n[1])}return e.join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var o={},i=0;i<this.length;i++){var r=this[i][0];"number"==typeof r&&(o[r]=!0)}for(i=0;i<t.length;i++){var s=t[i];"number"==typeof s[0]&&o[s[0]]||(n&&!s[2]?s[2]=n:n&&(s[2]="("+s[2]+") and ("+n+")"),e.push(s))}},e}},function(e,t){e.exports=function(e,t,n,o,i){var r,s=e=e||{},a=typeof e.default;"object"!==a&&"function"!==a||(r=e,s=e.default);var u="function"==typeof s?s.options:s;t&&(u.render=t.render,u.staticRenderFns=t.staticRenderFns),o&&(u._scopeId=o);var c;if(i?(c=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),n&&n.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(i)},u._ssrRegister=c):n&&(c=n),c){var d=u.functional,f=d?u.render:u.beforeCreate;d?u.render=function(e,t){return c.call(t),f(e,t)}:u.beforeCreate=f?[].concat(f,c):[c]}return{esModule:r,exports:s,options:u}}},function(e,t,n){function o(e){for(var t=0;t<e.length;t++){var n=e[t],o=d[n.id];if(o){o.refs++;for(var i=0;i<o.parts.length;i++)o.parts[i](n.parts[i]);for(;i<n.parts.length;i++)o.parts.push(r(n.parts[i]));o.parts.length>n.parts.length&&(o.parts.length=n.parts.length)}else{for(var s=[],i=0;i<n.parts.length;i++)s.push(r(n.parts[i]));d[n.id]={id:n.id,refs:1,parts:s}}}}function i(){var e=document.createElement("style");return e.type="text/css",f.appendChild(e),e}function r(e){var t,n,o=document.querySelector("style["+m+'~="'+e.id+'"]');if(o){if(h)return x;o.parentNode.removeChild(o)}if(b){var r=l++;o=p||(p=i()),t=s.bind(null,o,r,!1),n=s.bind(null,o,r,!0)}else o=i(),t=a.bind(null,o),n=function(){o.parentNode.removeChild(o)};return t(e),function(o){if(o){if(o.css===e.css&&o.media===e.media&&o.sourceMap===e.sourceMap)return;t(e=o)}else n()}}function s(e,t,n,o){var i=n?"":o.css;if(e.styleSheet)e.styleSheet.cssText=g(t,i);else{var r=document.createTextNode(i),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(r,s[t]):e.appendChild(r)}}function a(e,t){var n=t.css,o=t.media,i=t.sourceMap;if(o&&e.setAttribute("media",o),v.ssrId&&e.setAttribute(m,t.id),i&&(n+="\n/*# sourceURL="+i.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */"),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var u="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!u)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var c=n(25),d={},f=u&&(document.head||document.getElementsByTagName("head")[0]),p=null,l=0,h=!1,x=function(){},v=null,m="data-vue-ssr-id",b="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());e.exports=function(e,t,n,i){h=n,v=i||{};var r=c(e,t);return o(r),function(t){for(var n=[],i=0;i<r.length;i++){var s=r[i],a=d[s.id];a.refs--,n.push(a)}t?(r=c(e,t),o(r)):r=[];for(var i=0;i<n.length;i++){var a=n[i];if(0===a.refs){for(var u=0;u<a.parts.length;u++)a.parts[u]();delete d[a.id]}}}};var g=function(){var e=[];return function(t,n){return e[t]=n,e.filter(Boolean).join("\n")}}()},function(e,t,n){function o(e){n(24)}var i=n(2)(n(9),n(20),o,"data-v-7f868372",null);e.exports=i.exports},function(e,t,n){function o(e){n(22)}var i=n(2)(n(8),n(18),o,"data-v-1552113f",null);e.exports=i.exports},function(e,t,n){function o(e){n(23)}var i=n(2)(n(10),n(19),o,"data-v-4f853ba9",null);e.exports=i.exports},function(e,t,n){function o(e){n(21)}var i=n(2)(n(11),n(17),o,"data-v-06e685e2",null);e.exports=i.exports},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(0);t.default={props:{id:{type:String,default:"ref"}},data:function(){return{contextMenuStyle:{left:"-500px",top:"-500px"}}},mounted:function(){var e=this;document.addEventListener("click",function(t){e.hide()}),o.a.$on(this.id+"-show-poptip",function(t,n){e.show(t),o.a.$emit(e.id+"-set-attributes",n)}),o.a.$on(this.id+"-hide-poptip",function(t){e.hide()})},methods:{show:function(e){var t=this;e.preventDefault(),this.$nextTick(function(){t.contextMenuStyle=t.getMenuPos(e)})},hide:function(){this.contextMenuStyle={left:"-500px",top:"-500px"}},getMenuPos:function(e){if(this.$refs.contextElem){var t=this.$refs.contextElem.getBoundingClientRect(),n=t.width,o=t.height,i=e.clientX,r=e.clientY,s=document.documentElement.clientWidth,a=document.documentElement.clientHeight,u=i,c=r;return i+n>s&&(u=i-n),a<r+o&&(c=r-o),{left:u+3+"px",top:c+"px"}}}}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(0);t.default={props:{data:{}},data:function(){return{attr:{}}},computed:{id:function(){return this.$parent.id}},mounted:function(){var e=this;o.a.$on(this.id+"-set-attributes",function(t){e.attr=t})},methods:{handleClick:function(e){this.$emit("on-click",e,this.data,this.attr)}}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(0);t.default={props:{id:{type:String,default:"ref"},attributes:{type:Object,default:function(){return{}}}},data:function(){return{}},methods:{contextmenu:function(e){o.a.$emit(this.id+"-show-poptip",e,this.attributes),this.$emit("on-contextmenu")},hide:function(){o.a.$emit(this.id+"-hide-poptip",{})}}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(4),i=n.n(o);n(0);t.default={components:{ContextMenuItem:i.a},props:{title:{type:String,default:""}},data:function(){return{isShow:!1}},computed:{id:function(){return this.$parent.id}}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(5),i=n.n(o),r=n(6),s=n.n(r),a=n(4),u=n.n(a),c=n(7),d=n.n(c),f={ContextMenu:i.a,ContextMenuTrigger:s.a,ContextMenuItem:u.a,ContextSubMenu:d.a},p=function e(t){e.installed||Object.keys(f).forEach(function(e){t.component(e,f[e])})};"undefined"!=typeof window&&window.Vue&&p(window.Vue),t.default={install:p}},function(e,t,n){t=e.exports=n(1)(),t.push([e.i,".context-submenu .context-submenu-icon[data-v-06e685e2]{width:0;height:0;border-left:7px solid #c0c4cc;border-top:7px solid transparent;border-bottom:7px solid transparent;position:absolute;right:10px}.context-submenu .context-submenu-icon-active[data-v-06e685e2]{border-left:7px solid #3f66ff}.context-submenu-content[data-v-06e685e2]{position:absolute;left:227px;top:0;padding-left:6px}.context-submenu-content-wrap[data-v-06e685e2]{padding:8px 0;background-clip:padding-box;background:#fff;box-shadow:0 2px 10px 4px rgba(77,100,169,.1);border-radius:3px;white-space:nowrap}.context-submenu .context-menu-item[data-v-06e685e2]{position:relative;width:200px;height:32px;line-height:32px;padding:0 12px;margin:0 8px;display:flex;align-items:center;justify-content:space-between;transition:background-color .1s ease;color:#606266;cursor:pointer}.context-submenu .context-menu-item-label[data-v-06e685e2]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.context-submenu .context-menu-item[data-v-06e685e2]:hover{background:#ebefff;color:#3f66ff}",""])},function(e,t,n){t=e.exports=n(1)(),t.push([e.i,".m-context-menu[data-v-1552113f]{position:fixed;z-index:100000;padding:8px 0;background-clip:padding-box;background:#fff;box-shadow:0 2px 10px 4px rgba(77,100,169,.1);border-radius:3px;white-space:nowrap}",""])},function(e,t,n){t=e.exports=n(1)(),t.push([e.i,".context-menu-trigger[data-v-4f853ba9]{display:inline-block}",""])},function(e,t,n){t=e.exports=n(1)(),t.push([e.i,".context-menu-item[data-v-7f868372]{position:relative;width:200px;height:32px;line-height:32px;padding:0 12px;margin:0 8px;display:flex;align-items:center;justify-content:space-between;transition:background-color .1s ease;color:#606266;cursor:pointer}.context-menu-item[data-v-7f868372]:hover{background:#ebefff;color:#3f66ff}",""])},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"context-submenu",on:{mouseleave:function(t){e.isShow=!1}}},[n("div",{staticClass:"context-menu-item",on:{mouseenter:function(t){e.isShow=!0}}},[n("span",{staticClass:"context-menu-item-label"},[e._v(e._s(e.title))]),e._v(" "),n("span",{class:"context-submenu-icon context-submenu-icon-"+(e.isShow?"active":"")}),e._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:e.isShow,expression:"isShow"}],staticClass:"context-submenu-content"},[n("div",{staticClass:"context-submenu-content-wrap"},[e._t("default")],2)])])])},staticRenderFns:[]}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",{ref:"contextElem",staticClass:"m-context-menu",style:e.contextMenuStyle},[e._t("default")],2)},staticRenderFns:[]}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",{staticClass:"context-menu-trigger",on:{contextmenu:function(t){return t.stopPropagation(),e.contextmenu(t)},click:e.hide}},[e._t("default")],2)},staticRenderFns:[]}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",{staticClass:"context-menu-item",on:{click:e.handleClick}},[e._t("default")],2)},staticRenderFns:[]}},function(e,t,n){var o=n(13);"string"==typeof o&&(o=[[e.i,o,""]]),o.locals&&(e.exports=o.locals);n(3)("6c159542",o,!0,{})},function(e,t,n){var o=n(14);"string"==typeof o&&(o=[[e.i,o,""]]),o.locals&&(e.exports=o.locals);n(3)("9c4d9ab2",o,!0,{})},function(e,t,n){var o=n(15);"string"==typeof o&&(o=[[e.i,o,""]]),o.locals&&(e.exports=o.locals);n(3)("a3f331d2",o,!0,{})},function(e,t,n){var o=n(16);"string"==typeof o&&(o=[[e.i,o,""]]),o.locals&&(e.exports=o.locals);n(3)("5122d788",o,!0,{})},function(e,t){e.exports=function(e,t){for(var n=[],o={},i=0;i<t.length;i++){var r=t[i],s=r[0],a=r[1],u=r[2],c=r[3],d={id:e+":"+i,css:a,media:u,sourceMap:c};o[s]?o[s].parts.push(d):n.push(o[s]={id:s,parts:[d]})}return n}},function(t,n){t.exports=e}])});
//# sourceMappingURL=vue-cube-contextmenu.min.js.map