diff --git a/docs/ctxmenu.js b/docs/ctxmenu.js index 8f17ed3..0aeebf9 100644 --- a/docs/ctxmenu.js +++ b/docs/ctxmenu.js @@ -35,7 +35,7 @@ })()({ 1: [function (require, module, exports) { "use strict"; - /*! ctxMenu v1.3.0 | (c) Nikolaj Kappler | https://github.com/nkappler/ctxmenu/blob/master/LICENSE !*/ + /*! ctxMenu v1.4.0 | (c) Nikolaj Kappler | https://github.com/nkappler/ctxmenu/blob/master/LICENSE !*/ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); diff --git a/docs/ctxmenu.min.js b/docs/ctxmenu.min.js index 4370e68..ccbb972 100644 --- a/docs/ctxmenu.min.js +++ b/docs/ctxmenu.min.js @@ -1 +1 @@ -"use strict";(function(){function b(d,e,g){function a(j,i){if(!e[j]){if(!d[j]){var f="function"==typeof require&&require;if(!i&&f)return f(j,!0);if(h)return h(j,!0);var c=new Error("Cannot find module '"+j+"'");throw c.code="MODULE_NOT_FOUND",c}var k=e[j]={exports:{}};d[j][0].call(k.exports,function(b){var c=d[j][1][b];return a(c||b)},k,k.exports,b,d,e,g)}return e[j].exports}for(var h="function"==typeof require&&require,c=0;ca.length)&&(b=a.length);for(var c=0,d=Array(b);c".concat(b.getProp(c.text),""),i=b.getProp(c.element);if(i?f.append(i):f.innerHTML=g?g:h,f.title=b.getProp(c.tooltip)||"",c.style&&f.setAttribute("style",b.getProp(c.style)),!b.itemIsInteractive(c))f.setAttribute("style","font-weight: bold; margin-left: -5px;"+f.getAttribute("style"));else if(!!b.getProp(c.disabled))f.classList.add("disabled"),b.itemIsSubMenu(c)&&f.classList.add("submenu");else if(f.classList.add("interactive"),b.itemIsAction(c))f.addEventListener("click",function(a){c.action(a),d.hide()});else if(b.itemIsAnchor(c)){var j=document.createElement("a");i?j.append(i):j.innerHTML=g?g:h,j.onclick=function(){return d.hide()},j.href=b.getProp(c.href),c.hasOwnProperty("download")&&(j.download=b.getProp(c.download)),c.hasOwnProperty("target")&&(j.target=b.getProp(c.target)),f.childNodes.forEach(function(a){return a.remove()}),f.append(j)}else b.itemIsSubMenu(c)&&(0===b.getProp(c.subMenu).length?f.classList.add("disabled"):(f.classList.add("submenu"),d.debounce(f,function(a){var e=f.querySelector("ul");e||d.openSubMenu(a,b.getProp(c.subMenu),f)})));b.getProp(c.icon)&&(f.classList.add("icon"),f.innerHTML+=""))}e.appendChild(f)}),e.style.position="fixed",e.className="ctxmenu";var f=b.getBounding(e),g={x:0,y:0};if(c instanceof Element){var h=c.getBoundingClientRect();g={x:"r"===this.hdir?h.left+h.width:h.left-f.width,y:h.top+("d"===this.vdir?4:-12)};var i=this.getPosition(f,g);g.x!==i.x&&(this.hdir="r"===this.hdir?"l":"r",g.x="r"===this.hdir?h.left+h.width:h.left-f.width),g.y!==i.y&&(this.vdir="u"===this.vdir?"d":"u",g.y=i.y),g=this.getPosition(f,g)}else g=this.getPosition(f,{x:c.clientX,y:c.clientY});return e.style.left=g.x+"px",e.style.top=g.y+"px",e.addEventListener("contextmenu",function(a){a.stopPropagation(),a.preventDefault()}),e.addEventListener("click",function(a){var b=a.target instanceof Element&&a.target.parentElement;b&&"interactive"!==b.className&&a.stopPropagation()}),e}},{key:"openSubMenu",value:function(a,b,c){var d,e=null===(d=c.parentElement)||void 0===d?void 0:d.querySelector("li > ul");e&&e.parentElement!==c&&this.hide(e),c.appendChild(this.generateDOM(b,c))}},{key:"getPosition",value:function(a,b){return{x:"r"===this.hdir?b.x+a.width>window.innerWidth?window.innerWidth-a.width:b.x:0>b.x?0:b.x,y:"d"===this.vdir?b.y+a.height>window.innerHeight?window.innerHeight-a.height:b.y:0>b.y?0:b.y}}}],[{key:"getInstance",value:function(){return b.instance||(b.instance=new b),b.instance}},{key:"getBounding",value:function(a){var b=a.cloneNode(!0);b.style.visibility="hidden",document.body.appendChild(b);var c=b.getBoundingClientRect();return document.body.removeChild(b),c}},{key:"getProp",value:function(a){return"function"==typeof a?a():a}},{key:"itemIsInteractive",value:function(a){return this.itemIsAction(a)||this.itemIsAnchor(a)||this.itemIsSubMenu(a)||this.itemIsCustom(a)}},{key:"itemIsAction",value:function(a){return a.hasOwnProperty("action")}},{key:"itemIsAnchor",value:function(a){return a.hasOwnProperty("href")}},{key:"itemIsDivider",value:function(a){return a.hasOwnProperty("isDivider")}},{key:"itemIsSubMenu",value:function(a){return a.hasOwnProperty("subMenu")}},{key:"itemIsCustom",value:function(a){return a.hasOwnProperty("html")||a.hasOwnProperty("element")}},{key:"addStylesToDom",value:function(){var a=function(){var b=Object.entries({".ctxmenu":{maxHeight:"100vh",border:"1px solid #999",padding:"2px 0",boxShadow:"3px 3px 3px #aaa",background:"#fff",margin:"0",fontSize:"15px",fontFamily:"Verdana, sans-serif",zIndex:"9999",overflowY:"auto"},".ctxmenu li":{margin:"1px 0",display:"block",position:"relative",userSelect:"none",webkitUserSelect:"none"},".ctxmenu li span":{display:"block",padding:"2px 20px",cursor:"default"},".ctxmenu li a":{color:"inherit",textDecoration:"none"},".ctxmenu li.icon":{paddingLeft:"15px"},".ctxmenu img.icon":{position:"absolute",width:"18px",left:"10px",top:"2px"},".ctxmenu li.disabled":{color:"#ccc"},".ctxmenu li.divider":{borderBottom:"1px solid #aaa",margin:"5px 0"},".ctxmenu li.interactive:hover":{background:"rgba(0,0,0,0.1)"},".ctxmenu li.submenu::after":{content:"''",position:"absolute",display:"block",top:"0",bottom:"0",right:"0.4em",margin:"auto",borderRight:"1px solid #000",borderTop:"1px solid #000",transform:"rotate(45deg)",width:"0.3rem",height:"0.3rem",marginRight:"0.1rem"},".ctxmenu li.submenu.disabled::after":{borderColor:"#ccc"}}).map(function(a){return"".concat(a[0]," { ").concat(Object.assign(document.createElement("p").style,a[1]).cssText," }")}),c=document.head.insertBefore(document.createElement("style"),document.head.childNodes[0]);b.forEach(function(a){var b;return null===(b=c.sheet)||void 0===b?void 0:b.insertRule(a)}),a=function(){}};"loading"===document.readyState?document.addEventListener("readystatechange",function(){"loading"!==document.readyState&&a()}):a()}}]),b}();c.ctxmenu=m.getInstance()},{}],2:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d=a("./ctxmenu");window.ctxmenu=d.ctxmenu},{"./ctxmenu":1}]},{},[2]); +"use strict";(function(){function b(d,e,g){function a(j,i){if(!e[j]){if(!d[j]){var f="function"==typeof require&&require;if(!i&&f)return f(j,!0);if(h)return h(j,!0);var c=new Error("Cannot find module '"+j+"'");throw c.code="MODULE_NOT_FOUND",c}var k=e[j]={exports:{}};d[j][0].call(k.exports,function(b){var c=d[j][1][b];return a(c||b)},k,k.exports,b,d,e,g)}return e[j].exports}for(var h="function"==typeof require&&require,c=0;ca.length)&&(b=a.length);for(var c=0,d=Array(b);c".concat(b.getProp(c.text),""),i=b.getProp(c.element);if(i?f.append(i):f.innerHTML=g?g:h,f.title=b.getProp(c.tooltip)||"",c.style&&f.setAttribute("style",b.getProp(c.style)),!b.itemIsInteractive(c))f.setAttribute("style","font-weight: bold; margin-left: -5px;"+f.getAttribute("style"));else if(!!b.getProp(c.disabled))f.classList.add("disabled"),b.itemIsSubMenu(c)&&f.classList.add("submenu");else if(f.classList.add("interactive"),b.itemIsAction(c))f.addEventListener("click",function(a){c.action(a),d.hide()});else if(b.itemIsAnchor(c)){var j=document.createElement("a");i?j.append(i):j.innerHTML=g?g:h,j.onclick=function(){return d.hide()},j.href=b.getProp(c.href),c.hasOwnProperty("download")&&(j.download=b.getProp(c.download)),c.hasOwnProperty("target")&&(j.target=b.getProp(c.target)),f.childNodes.forEach(function(a){return a.remove()}),f.append(j)}else b.itemIsSubMenu(c)&&(0===b.getProp(c.subMenu).length?f.classList.add("disabled"):(f.classList.add("submenu"),d.debounce(f,function(a){var e=f.querySelector("ul");e||d.openSubMenu(a,b.getProp(c.subMenu),f)})));b.getProp(c.icon)&&(f.classList.add("icon"),f.innerHTML+=""))}e.appendChild(f)}),e.style.position="fixed",e.className="ctxmenu";var f=b.getBounding(e),g={x:0,y:0};if(c instanceof Element){var h=c.getBoundingClientRect();g={x:"r"===this.hdir?h.left+h.width:h.left-f.width,y:h.top+("d"===this.vdir?4:-12)};var i=this.getPosition(f,g);g.x!==i.x&&(this.hdir="r"===this.hdir?"l":"r",g.x="r"===this.hdir?h.left+h.width:h.left-f.width),g.y!==i.y&&(this.vdir="u"===this.vdir?"d":"u",g.y=i.y),g=this.getPosition(f,g)}else g=this.getPosition(f,{x:c.clientX,y:c.clientY});return e.style.left=g.x+"px",e.style.top=g.y+"px",e.addEventListener("contextmenu",function(a){a.stopPropagation(),a.preventDefault()}),e.addEventListener("click",function(a){var b=a.target instanceof Element&&a.target.parentElement;b&&"interactive"!==b.className&&a.stopPropagation()}),e}},{key:"openSubMenu",value:function(a,b,c){var d,e=null===(d=c.parentElement)||void 0===d?void 0:d.querySelector("li > ul");e&&e.parentElement!==c&&this.hide(e),c.appendChild(this.generateDOM(b,c))}},{key:"getPosition",value:function(a,b){return{x:"r"===this.hdir?b.x+a.width>window.innerWidth?window.innerWidth-a.width:b.x:0>b.x?0:b.x,y:"d"===this.vdir?b.y+a.height>window.innerHeight?window.innerHeight-a.height:b.y:0>b.y?0:b.y}}}],[{key:"getInstance",value:function(){return b.instance||(b.instance=new b),b.instance}},{key:"getBounding",value:function(a){var b=a.cloneNode(!0);b.style.visibility="hidden",document.body.appendChild(b);var c=b.getBoundingClientRect();return document.body.removeChild(b),c}},{key:"getProp",value:function(a){return"function"==typeof a?a():a}},{key:"itemIsInteractive",value:function(a){return this.itemIsAction(a)||this.itemIsAnchor(a)||this.itemIsSubMenu(a)||this.itemIsCustom(a)}},{key:"itemIsAction",value:function(a){return a.hasOwnProperty("action")}},{key:"itemIsAnchor",value:function(a){return a.hasOwnProperty("href")}},{key:"itemIsDivider",value:function(a){return a.hasOwnProperty("isDivider")}},{key:"itemIsSubMenu",value:function(a){return a.hasOwnProperty("subMenu")}},{key:"itemIsCustom",value:function(a){return a.hasOwnProperty("html")||a.hasOwnProperty("element")}},{key:"addStylesToDom",value:function(){var a=function(){var b=Object.entries({".ctxmenu":{maxHeight:"100vh",border:"1px solid #999",padding:"2px 0",boxShadow:"3px 3px 3px #aaa",background:"#fff",margin:"0",fontSize:"15px",fontFamily:"Verdana, sans-serif",zIndex:"9999",overflowY:"auto"},".ctxmenu li":{margin:"1px 0",display:"block",position:"relative",userSelect:"none",webkitUserSelect:"none"},".ctxmenu li span":{display:"block",padding:"2px 20px",cursor:"default"},".ctxmenu li a":{color:"inherit",textDecoration:"none"},".ctxmenu li.icon":{paddingLeft:"15px"},".ctxmenu img.icon":{position:"absolute",width:"18px",left:"10px",top:"2px"},".ctxmenu li.disabled":{color:"#ccc"},".ctxmenu li.divider":{borderBottom:"1px solid #aaa",margin:"5px 0"},".ctxmenu li.interactive:hover":{background:"rgba(0,0,0,0.1)"},".ctxmenu li.submenu::after":{content:"''",position:"absolute",display:"block",top:"0",bottom:"0",right:"0.4em",margin:"auto",borderRight:"1px solid #000",borderTop:"1px solid #000",transform:"rotate(45deg)",width:"0.3rem",height:"0.3rem",marginRight:"0.1rem"},".ctxmenu li.submenu.disabled::after":{borderColor:"#ccc"}}).map(function(a){return"".concat(a[0]," { ").concat(Object.assign(document.createElement("p").style,a[1]).cssText," }")}),c=document.head.insertBefore(document.createElement("style"),document.head.childNodes[0]);b.forEach(function(a){var b;return null===(b=c.sheet)||void 0===b?void 0:b.insertRule(a)}),a=function(){}};"loading"===document.readyState?document.addEventListener("readystatechange",function(){"loading"!==document.readyState&&a()}):a()}}]),b}();c.ctxmenu=m.getInstance()},{}],2:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d=a("./ctxmenu");window.ctxmenu=d.ctxmenu},{"./ctxmenu":1}]},{},[2]); diff --git a/index.d.ts b/index.d.ts index 6efc677..0b284f3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,5 +1,5 @@ declare module "ctxmenu" { - /*! ctxMenu v1.3.0 | (c) Nikolaj Kappler | https://github.com/nkappler/ctxmenu/blob/master/LICENSE !*/ + /*! ctxMenu v1.4.0 | (c) Nikolaj Kappler | https://github.com/nkappler/ctxmenu/blob/master/LICENSE !*/ export type ValueOrFunction = T | (() => T); /** This is a Divider Menu Item */ export interface CTXMDivider { diff --git a/index.js b/index.js index 497af70..4c8dd17 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ "use strict"; -/*! ctxMenu v1.3.0 | (c) Nikolaj Kappler | https://github.com/nkappler/ctxmenu/blob/master/LICENSE !*/ +/*! ctxMenu v1.4.0 | (c) Nikolaj Kappler | https://github.com/nkappler/ctxmenu/blob/master/LICENSE !*/ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } diff --git a/package-lock.json b/package-lock.json index 589aac5..2b5ab86 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ctxmenu", - "version": "1.3.0", + "version": "1.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index cb92547..bca3bd2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ctxmenu", - "version": "1.3.0", + "version": "1.4.0", "description": "", "main": "index.js", "types": "index.d.ts", diff --git a/src/ctxmenu.ts b/src/ctxmenu.ts index 4a0837b..bdff551 100644 --- a/src/ctxmenu.ts +++ b/src/ctxmenu.ts @@ -1,4 +1,4 @@ -/*! ctxMenu v1.3.0 | (c) Nikolaj Kappler | https://github.com/nkappler/ctxmenu/blob/master/LICENSE !*/ +/*! ctxMenu v1.4.0 | (c) Nikolaj Kappler | https://github.com/nkappler/ctxmenu/blob/master/LICENSE !*/ export type ValueOrFunction = T | (() => T); diff --git a/standalone/ctxmenu.d.ts b/standalone/ctxmenu.d.ts index 31dbf31..60fe0fd 100644 --- a/standalone/ctxmenu.d.ts +++ b/standalone/ctxmenu.d.ts @@ -1,5 +1,5 @@ declare module "ctxmenu" { - /*! ctxMenu v1.3.0 | (c) Nikolaj Kappler | https://github.com/nkappler/ctxmenu/blob/master/LICENSE !*/ + /*! ctxMenu v1.4.0 | (c) Nikolaj Kappler | https://github.com/nkappler/ctxmenu/blob/master/LICENSE !*/ export type ValueOrFunction = T | (() => T); /** This is a Divider Menu Item */ export interface CTXMDivider { diff --git a/standalone/ctxmenu.js b/standalone/ctxmenu.js index 96eb2de..28fe5c5 100644 --- a/standalone/ctxmenu.js +++ b/standalone/ctxmenu.js @@ -1,6 +1,6 @@ (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;ia.length)&&(b=a.length);for(var c=0,d=Array(b);c".concat(b.getProp(c.text),""),i=b.getProp(c.element);if(i?f.append(i):f.innerHTML=g?g:h,f.title=b.getProp(c.tooltip)||"",c.style&&f.setAttribute("style",b.getProp(c.style)),!b.itemIsInteractive(c))f.setAttribute("style","font-weight: bold; margin-left: -5px;"+f.getAttribute("style"));else if(!!b.getProp(c.disabled))f.classList.add("disabled"),b.itemIsSubMenu(c)&&f.classList.add("submenu");else if(f.classList.add("interactive"),b.itemIsAction(c))f.addEventListener("click",function(a){c.action(a),d.hide()});else if(b.itemIsAnchor(c)){var j=document.createElement("a");i?j.append(i):j.innerHTML=g?g:h,j.onclick=function(){return d.hide()},j.href=b.getProp(c.href),c.hasOwnProperty("download")&&(j.download=b.getProp(c.download)),c.hasOwnProperty("target")&&(j.target=b.getProp(c.target)),f.childNodes.forEach(function(a){return a.remove()}),f.append(j)}else b.itemIsSubMenu(c)&&(0===b.getProp(c.subMenu).length?f.classList.add("disabled"):(f.classList.add("submenu"),d.debounce(f,function(a){var e=f.querySelector("ul");e||d.openSubMenu(a,b.getProp(c.subMenu),f)})));b.getProp(c.icon)&&(f.classList.add("icon"),f.innerHTML+=""))}e.appendChild(f)}),e.style.position="fixed",e.className="ctxmenu";var f=b.getBounding(e),g={x:0,y:0};if(c instanceof Element){var h=c.getBoundingClientRect();g={x:"r"===this.hdir?h.left+h.width:h.left-f.width,y:h.top+("d"===this.vdir?4:-12)};var i=this.getPosition(f,g);g.x!==i.x&&(this.hdir="r"===this.hdir?"l":"r",g.x="r"===this.hdir?h.left+h.width:h.left-f.width),g.y!==i.y&&(this.vdir="u"===this.vdir?"d":"u",g.y=i.y),g=this.getPosition(f,g)}else g=this.getPosition(f,{x:c.clientX,y:c.clientY});return e.style.left=g.x+"px",e.style.top=g.y+"px",e.addEventListener("contextmenu",function(a){a.stopPropagation(),a.preventDefault()}),e.addEventListener("click",function(a){var b=a.target instanceof Element&&a.target.parentElement;b&&"interactive"!==b.className&&a.stopPropagation()}),e}},{key:"openSubMenu",value:function(a,b,c){var d,e=null===(d=c.parentElement)||void 0===d?void 0:d.querySelector("li > ul");e&&e.parentElement!==c&&this.hide(e),c.appendChild(this.generateDOM(b,c))}},{key:"getPosition",value:function(a,b){return{x:"r"===this.hdir?b.x+a.width>window.innerWidth?window.innerWidth-a.width:b.x:0>b.x?0:b.x,y:"d"===this.vdir?b.y+a.height>window.innerHeight?window.innerHeight-a.height:b.y:0>b.y?0:b.y}}}],[{key:"getInstance",value:function(){return b.instance||(b.instance=new b),b.instance}},{key:"getBounding",value:function(a){var b=a.cloneNode(!0);b.style.visibility="hidden",document.body.appendChild(b);var c=b.getBoundingClientRect();return document.body.removeChild(b),c}},{key:"getProp",value:function(a){return"function"==typeof a?a():a}},{key:"itemIsInteractive",value:function(a){return this.itemIsAction(a)||this.itemIsAnchor(a)||this.itemIsSubMenu(a)||this.itemIsCustom(a)}},{key:"itemIsAction",value:function(a){return a.hasOwnProperty("action")}},{key:"itemIsAnchor",value:function(a){return a.hasOwnProperty("href")}},{key:"itemIsDivider",value:function(a){return a.hasOwnProperty("isDivider")}},{key:"itemIsSubMenu",value:function(a){return a.hasOwnProperty("subMenu")}},{key:"itemIsCustom",value:function(a){return a.hasOwnProperty("html")||a.hasOwnProperty("element")}},{key:"addStylesToDom",value:function(){var a=function(){var b=Object.entries({".ctxmenu":{maxHeight:"100vh",border:"1px solid #999",padding:"2px 0",boxShadow:"3px 3px 3px #aaa",background:"#fff",margin:"0",fontSize:"15px",fontFamily:"Verdana, sans-serif",zIndex:"9999",overflowY:"auto"},".ctxmenu li":{margin:"1px 0",display:"block",position:"relative",userSelect:"none",webkitUserSelect:"none"},".ctxmenu li span":{display:"block",padding:"2px 20px",cursor:"default"},".ctxmenu li a":{color:"inherit",textDecoration:"none"},".ctxmenu li.icon":{paddingLeft:"15px"},".ctxmenu img.icon":{position:"absolute",width:"18px",left:"10px",top:"2px"},".ctxmenu li.disabled":{color:"#ccc"},".ctxmenu li.divider":{borderBottom:"1px solid #aaa",margin:"5px 0"},".ctxmenu li.interactive:hover":{background:"rgba(0,0,0,0.1)"},".ctxmenu li.submenu::after":{content:"''",position:"absolute",display:"block",top:"0",bottom:"0",right:"0.4em",margin:"auto",borderRight:"1px solid #000",borderTop:"1px solid #000",transform:"rotate(45deg)",width:"0.3rem",height:"0.3rem",marginRight:"0.1rem"},".ctxmenu li.submenu.disabled::after":{borderColor:"#ccc"}}).map(function(a){return"".concat(a[0]," { ").concat(Object.assign(document.createElement("p").style,a[1]).cssText," }")}),c=document.head.insertBefore(document.createElement("style"),document.head.childNodes[0]);b.forEach(function(a){var b;return null===(b=c.sheet)||void 0===b?void 0:b.insertRule(a)}),a=function(){}};"loading"===document.readyState?document.addEventListener("readystatechange",function(){"loading"!==document.readyState&&a()}):a()}}]),b}();c.ctxmenu=m.getInstance()},{}],2:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d=a("./ctxmenu");window.ctxmenu=d.ctxmenu},{"./ctxmenu":1}]},{},[2]); +"use strict";(function(){function b(d,e,g){function a(j,i){if(!e[j]){if(!d[j]){var f="function"==typeof require&&require;if(!i&&f)return f(j,!0);if(h)return h(j,!0);var c=new Error("Cannot find module '"+j+"'");throw c.code="MODULE_NOT_FOUND",c}var k=e[j]={exports:{}};d[j][0].call(k.exports,function(b){var c=d[j][1][b];return a(c||b)},k,k.exports,b,d,e,g)}return e[j].exports}for(var h="function"==typeof require&&require,c=0;ca.length)&&(b=a.length);for(var c=0,d=Array(b);c".concat(b.getProp(c.text),""),i=b.getProp(c.element);if(i?f.append(i):f.innerHTML=g?g:h,f.title=b.getProp(c.tooltip)||"",c.style&&f.setAttribute("style",b.getProp(c.style)),!b.itemIsInteractive(c))f.setAttribute("style","font-weight: bold; margin-left: -5px;"+f.getAttribute("style"));else if(!!b.getProp(c.disabled))f.classList.add("disabled"),b.itemIsSubMenu(c)&&f.classList.add("submenu");else if(f.classList.add("interactive"),b.itemIsAction(c))f.addEventListener("click",function(a){c.action(a),d.hide()});else if(b.itemIsAnchor(c)){var j=document.createElement("a");i?j.append(i):j.innerHTML=g?g:h,j.onclick=function(){return d.hide()},j.href=b.getProp(c.href),c.hasOwnProperty("download")&&(j.download=b.getProp(c.download)),c.hasOwnProperty("target")&&(j.target=b.getProp(c.target)),f.childNodes.forEach(function(a){return a.remove()}),f.append(j)}else b.itemIsSubMenu(c)&&(0===b.getProp(c.subMenu).length?f.classList.add("disabled"):(f.classList.add("submenu"),d.debounce(f,function(a){var e=f.querySelector("ul");e||d.openSubMenu(a,b.getProp(c.subMenu),f)})));b.getProp(c.icon)&&(f.classList.add("icon"),f.innerHTML+=""))}e.appendChild(f)}),e.style.position="fixed",e.className="ctxmenu";var f=b.getBounding(e),g={x:0,y:0};if(c instanceof Element){var h=c.getBoundingClientRect();g={x:"r"===this.hdir?h.left+h.width:h.left-f.width,y:h.top+("d"===this.vdir?4:-12)};var i=this.getPosition(f,g);g.x!==i.x&&(this.hdir="r"===this.hdir?"l":"r",g.x="r"===this.hdir?h.left+h.width:h.left-f.width),g.y!==i.y&&(this.vdir="u"===this.vdir?"d":"u",g.y=i.y),g=this.getPosition(f,g)}else g=this.getPosition(f,{x:c.clientX,y:c.clientY});return e.style.left=g.x+"px",e.style.top=g.y+"px",e.addEventListener("contextmenu",function(a){a.stopPropagation(),a.preventDefault()}),e.addEventListener("click",function(a){var b=a.target instanceof Element&&a.target.parentElement;b&&"interactive"!==b.className&&a.stopPropagation()}),e}},{key:"openSubMenu",value:function(a,b,c){var d,e=null===(d=c.parentElement)||void 0===d?void 0:d.querySelector("li > ul");e&&e.parentElement!==c&&this.hide(e),c.appendChild(this.generateDOM(b,c))}},{key:"getPosition",value:function(a,b){return{x:"r"===this.hdir?b.x+a.width>window.innerWidth?window.innerWidth-a.width:b.x:0>b.x?0:b.x,y:"d"===this.vdir?b.y+a.height>window.innerHeight?window.innerHeight-a.height:b.y:0>b.y?0:b.y}}}],[{key:"getInstance",value:function(){return b.instance||(b.instance=new b),b.instance}},{key:"getBounding",value:function(a){var b=a.cloneNode(!0);b.style.visibility="hidden",document.body.appendChild(b);var c=b.getBoundingClientRect();return document.body.removeChild(b),c}},{key:"getProp",value:function(a){return"function"==typeof a?a():a}},{key:"itemIsInteractive",value:function(a){return this.itemIsAction(a)||this.itemIsAnchor(a)||this.itemIsSubMenu(a)||this.itemIsCustom(a)}},{key:"itemIsAction",value:function(a){return a.hasOwnProperty("action")}},{key:"itemIsAnchor",value:function(a){return a.hasOwnProperty("href")}},{key:"itemIsDivider",value:function(a){return a.hasOwnProperty("isDivider")}},{key:"itemIsSubMenu",value:function(a){return a.hasOwnProperty("subMenu")}},{key:"itemIsCustom",value:function(a){return a.hasOwnProperty("html")||a.hasOwnProperty("element")}},{key:"addStylesToDom",value:function(){var a=function(){var b=Object.entries({".ctxmenu":{maxHeight:"100vh",border:"1px solid #999",padding:"2px 0",boxShadow:"3px 3px 3px #aaa",background:"#fff",margin:"0",fontSize:"15px",fontFamily:"Verdana, sans-serif",zIndex:"9999",overflowY:"auto"},".ctxmenu li":{margin:"1px 0",display:"block",position:"relative",userSelect:"none",webkitUserSelect:"none"},".ctxmenu li span":{display:"block",padding:"2px 20px",cursor:"default"},".ctxmenu li a":{color:"inherit",textDecoration:"none"},".ctxmenu li.icon":{paddingLeft:"15px"},".ctxmenu img.icon":{position:"absolute",width:"18px",left:"10px",top:"2px"},".ctxmenu li.disabled":{color:"#ccc"},".ctxmenu li.divider":{borderBottom:"1px solid #aaa",margin:"5px 0"},".ctxmenu li.interactive:hover":{background:"rgba(0,0,0,0.1)"},".ctxmenu li.submenu::after":{content:"''",position:"absolute",display:"block",top:"0",bottom:"0",right:"0.4em",margin:"auto",borderRight:"1px solid #000",borderTop:"1px solid #000",transform:"rotate(45deg)",width:"0.3rem",height:"0.3rem",marginRight:"0.1rem"},".ctxmenu li.submenu.disabled::after":{borderColor:"#ccc"}}).map(function(a){return"".concat(a[0]," { ").concat(Object.assign(document.createElement("p").style,a[1]).cssText," }")}),c=document.head.insertBefore(document.createElement("style"),document.head.childNodes[0]);b.forEach(function(a){var b;return null===(b=c.sheet)||void 0===b?void 0:b.insertRule(a)}),a=function(){}};"loading"===document.readyState?document.addEventListener("readystatechange",function(){"loading"!==document.readyState&&a()}):a()}}]),b}();c.ctxmenu=m.getInstance()},{}],2:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d=a("./ctxmenu");window.ctxmenu=d.ctxmenu},{"./ctxmenu":1}]},{},[2]);