!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactContextMenu=t(require("react")):e.ReactContextMenu=t(e.React)}("undefined"!=typeof self?self:this,function(e){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,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="",t(t.s=11)}([function(t,n){t.exports=e},function(e,t,n){"use strict";function o(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window,o=void 0;"function"==typeof window.CustomEvent?o=new window.CustomEvent(e,{detail:t}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!0,t)),n&&(n.dispatchEvent(o),u()(s.e,t))}function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];o(l,u()({},e,{type:l}),t)}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];o(c,u()({},e,{type:c}),t)}n.d(t,"b",function(){return l}),n.d(t,"a",function(){return c}),t.d=r,t.c=i;var a=n(4),u=n.n(a),s=n(2),l="REACT_CONTEXTMENU_SHOW",c="REACT_CONTEXTMENU_HIDE"},function(e,t,n){"use strict";function o(e){for(var t=arguments.length,n=Array(t>1?t-1:0),o=1;o=o.length&&(n=0)}()}while(n!==e&&i[n]);return n===e?null:n}(s);null!==l&&e.setState({selectedItem:o[l],forceSubMenuOpen:!1})}},this.onChildMouseMove=function(t){e.state.selectedItem!==t&&e.setState({selectedItem:t,forceSubMenuOpen:!1})},this.onChildMouseLeave=function(){e.setState({selectedItem:null,forceSubMenuOpen:!1})},this.renderChildren=function(t){return u.a.Children.map(t,function(t){var n={};return u.a.isValidElement(t)?[c.a,e.getSubMenuType()].indexOf(t.type)<0?(n.children=e.renderChildren(t.props.children),u.a.cloneElement(t,n)):(n.onMouseLeave=e.onChildMouseLeave.bind(e),t.type===e.getSubMenuType()&&(n.forceOpen=e.state.forceSubMenuOpen&&e.state.selectedItem===t,n.forceClose=e.handleForceClose,n.parentKeyNavigationHandler=e.handleKeyNavigation),t.props.divider||e.state.selectedItem!==t?(n.onMouseMove=function(){return e.onChildMouseMove(t)},u.a.cloneElement(t,n)):(n.selected=!0,n.ref=function(t){e.seletedItemRef=t},u.a.cloneElement(t,n))):t})}};t.a=p},function(e,t,n){"use strict";function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=n(0),s=n.n(u),l=n(3),c=n.n(l),p=n(5),d=n.n(p),f=n(4),h=n.n(f),b=n(1),m=n(2),v=Object.assign||function(e){for(var t=1;to?i.bottom=0:i.top=0,r.rightt?r.bottom=0:r.top=0,o.left<0?r.left="100%":r.right="100%",r},n.hideSubMenu=function(e){e.detail&&e.detail.id&&n.menu&&e.detail.id!==n.menu.id||(n.props.forceOpen&&n.props.forceClose(),n.setState({visible:!1,selectedItem:null}),n.unregisterHandlers())},n.handleClick=function(e){e.preventDefault(),n.props.disabled||(Object(v.a)(n.props.onClick,e,h()({},n.props.data,v.e.data),v.e.target),n.props.onClick&&!n.props.preventCloseOnClick&&Object(b.c)())},n.handleMouseEnter=function(){n.closetimer&&clearTimeout(n.closetimer),n.props.disabled||n.state.visible||(n.opentimer=setTimeout(function(){return n.setState({visible:!0,selectedItem:null})},n.props.hoverDelay))},n.handleMouseLeave=function(){n.opentimer&&clearTimeout(n.opentimer),n.state.visible&&(n.closetimer=setTimeout(function(){return n.setState({visible:!1,selectedItem:null})},n.props.hoverDelay))},n.menuRef=function(e){n.menu=e},n.subMenuRef=function(e){n.subMenu=e},n.registerHandlers=function(){document.removeEventListener("keydown",n.props.parentKeyNavigationHandler),document.addEventListener("keydown",n.handleKeyNavigation)},n.unregisterHandlers=function(e){document.removeEventListener("keydown",n.handleKeyNavigation),e||document.addEventListener("keydown",n.props.parentKeyNavigationHandler)},n.state=h()({},n.state,{visible:!1}),n}return a(t,e),O(t,[{key:"componentDidMount",value:function(){this.listenId=y.a.register(function(){},this.hideSubMenu)}},{key:"getSubMenuType",value:function(){return t}},{key:"shouldComponentUpdate",value:function(e,t){return this.isVisibilityChange=!(this.state.visible===t.visible&&this.props.forceOpen===e.forceOpen||this.state.visible&&e.forceOpen||this.props.forceOpen&&t.visible),!0}},{key:"componentDidUpdate",value:function(){var e=this;if(this.isVisibilityChange)if(this.props.forceOpen||this.state.visible){var t=window.requestAnimationFrame||setTimeout;t(function(){var t=e.props.rtl?e.getRTLMenuPosition():e.getMenuPosition();e.subMenu.style.removeProperty("top"),e.subMenu.style.removeProperty("bottom"),e.subMenu.style.removeProperty("left"),e.subMenu.style.removeProperty("right"),Object(v.d)(t,"top")&&(e.subMenu.style.top=t.top),Object(v.d)(t,"left")&&(e.subMenu.style.left=t.left),Object(v.d)(t,"bottom")&&(e.subMenu.style.bottom=t.bottom),Object(v.d)(t,"right")&&(e.subMenu.style.right=t.right),e.subMenu.classList.add(v.c.menuVisible),e.registerHandlers(),e.setState({selectedItem:null})})}else{var n=function t(){e.subMenu.removeEventListener("transitionend",t),e.subMenu.style.removeProperty("bottom"),e.subMenu.style.removeProperty("right"),e.subMenu.style.top=0,e.subMenu.style.left="100%",e.unregisterHandlers()};this.subMenu.addEventListener("transitionend",n),this.subMenu.classList.remove(v.c.menuVisible)}}},{key:"componentWillUnmount",value:function(){this.listenId&&y.a.unregister(this.listenId),this.opentimer&&clearTimeout(this.opentimer),this.closetimer&&clearTimeout(this.closetimer),this.unregisterHandlers(!0)}},{key:"render",value:function(){var e,t=this.props,n=t.children,r=t.attributes,i=t.disabled,a=t.title,u=t.selected,l=this.state.visible,c={ref:this.menuRef,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,className:d()(v.c.menuItem,v.c.subMenu,r.listClassName),style:{position:"relative"}},p={className:d()(v.c.menuItem,r.className,(e={},o(e,d()(v.c.menuItemDisabled,r.disabledClassName),i),o(e,d()(v.c.menuItemActive,r.visibleClassName),l),o(e,d()(v.c.menuItemSelected,r.selectedClassName),u),e)),onMouseMove:this.props.onMouseMove,onMouseOut:this.props.onMouseOut,onClick:this.handleClick},f={ref:this.subMenuRef,style:{position:"absolute",transition:"opacity 1ms",top:0,left:"100%"},className:d()(v.c.menu,this.props.className)};return s.a.createElement("nav",g({},c,{role:"menuitem",tabIndex:"-1","aria-haspopup":"true"}),s.a.createElement("div",g({},r,p),a),s.a.createElement("nav",g({},f,{role:"menu",tabIndex:"-1"}),this.renderChildren(n)))}}]),t}(m.a);w.propTypes={children:c.a.node.isRequired,attributes:c.a.object,title:c.a.node.isRequired,className:c.a.string,disabled:c.a.bool,hoverDelay:c.a.number,rtl:c.a.bool,selected:c.a.bool,onMouseMove:c.a.func,onMouseOut:c.a.func,forceOpen:c.a.bool,forceClose:c.a.func,parentKeyNavigationHandler:c.a.func},w.defaultProps={disabled:!1,hoverDelay:500,attributes:{},className:"",rtl:!1,selected:!1,onMouseMove:function(){return null},onMouseOut:function(){return null},forceOpen:!1,forceClose:function(){return null},parentKeyNavigationHandler:function(){return null}},t.a=w},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n(0),u=n.n(a),s=n(3),l=n.n(s),c=n(5),p=n.n(c),d=n(4),f=n.n(d),h=n(1),b=n(2),m=function(){function e(e,t){for(var n=0;n=0&&0===e.button&&(e.persist(),e.stopPropagation(),i.mouseDownTimeoutId=setTimeout(function(){return i.handleContextClick(e)},i.props.holdToDisplay)),Object(b.a)(i.props.attributes.onMouseDown,e)},i.handleMouseUp=function(e){0===e.button&&clearTimeout(i.mouseDownTimeoutId),Object(b.a)(i.props.attributes.onMouseUp,e)},i.handleMouseOut=function(e){0===e.button&&clearTimeout(i.mouseDownTimeoutId),Object(b.a)(i.props.attributes.onMouseOut,e)},i.handleTouchstart=function(e){i.touchHandled=!1,i.props.holdToDisplay>=0&&(e.persist(),e.stopPropagation(),i.touchstartTimeoutId=setTimeout(function(){i.handleContextClick(e),i.touchHandled=!0},i.props.holdToDisplay)),Object(b.a)(i.props.attributes.onTouchStart,e)},i.handleTouchEnd=function(e){i.touchHandled&&e.preventDefault(),clearTimeout(i.touchstartTimeoutId),Object(b.a)(i.props.attributes.onTouchEnd,e)},i.handleContextMenu=function(e){e.button===i.props.mouseButton&&i.handleContextClick(e),Object(b.a)(i.props.attributes.onContextMenu,e)},i.handleMouseClick=function(e){e.button===i.props.mouseButton&&i.handleContextClick(e),Object(b.a)(i.props.attributes.onClick,e)},i.handleContextClick=function(e){if(!(i.props.disable||i.props.disableIfShiftIsPressed&&e.shiftKey)){e.preventDefault(),e.stopPropagation();var t=e.clientX||e.touches&&e.touches[0].pageX,n=e.clientY||e.touches&&e.touches[0].pageY;i.props.posX&&(t-=i.props.posX),i.props.posY&&(n-=i.props.posY),Object(h.c)();var o=Object(b.a)(i.props.collect,i.props),r={position:{x:t,y:n},target:i.elem,id:i.props.id};o&&"function"==typeof o.then?o.then(function(t){r.data=f()({},t,{target:e.target}),Object(h.d)(r)}):(r.data=f()({},o,{target:e.target}),Object(h.d)(r))}},i.elemRef=function(e){i.elem=e},a=n,r(i,a)}return i(t,e),m(t,[{key:"render",value:function(){var e=this.props,t=e.renderTag,n=e.attributes,o=e.children,r=f()({},n,{className:p()(b.c.menuWrapper,n.className),onContextMenu:this.handleContextMenu,onClick:this.handleMouseClick,onMouseDown:this.handleMouseDown,onMouseUp:this.handleMouseUp,onTouchStart:this.handleTouchstart,onTouchEnd:this.handleTouchEnd,onMouseOut:this.handleMouseOut,ref:this.elemRef});return u.a.createElement(t,r,o)}}]),t}(a.Component);v.propTypes={id:l.a.string.isRequired,children:l.a.node.isRequired,attributes:l.a.object,collect:l.a.func,disable:l.a.bool,holdToDisplay:l.a.number,posX:l.a.number,posY:l.a.number,renderTag:l.a.oneOfType([l.a.node,l.a.func]),mouseButton:l.a.number,disableIfShiftIsPressed:l.a.bool},v.defaultProps={attributes:{},collect:function(){return null},disable:!1,holdToDisplay:1e3,renderTag:"div",posX:0,posY:0,mouseButton:2,disableIfShiftIsPressed:!1},t.a=v},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(12);n.d(t,"ContextMenu",function(){return o.a});var r=n(10);n.d(t,"ContextMenuTrigger",function(){return r.a});var i=n(8);n.d(t,"MenuItem",function(){return i.a});var a=n(9);n.d(t,"SubMenu",function(){return a.a});var u=n(15);n.d(t,"connectMenu",function(){return u.a});var s=n(1);n.d(t,"hideMenu",function(){return s.c}),n.d(t,"showMenu",function(){return s.d})},function(e,t,n){"use strict";function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=n(0),s=n.n(u),l=n(3),c=n.n(l),p=n(5),d=n.n(p),f=n(4),h=n.n(f),b=n(6),m=n(7),v=n(9),y=n(1),g=n(2),O=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o={top:t,left:e};if(!n.menu)return o;var r=window,i=r.innerWidth,a=r.innerHeight,u=n.menu.getBoundingClientRect();return t+u.height>a&&(o.top-=u.height),e+u.width>i&&(o.left-=u.width),o.top<0&&(o.top=u.height0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o={top:t,left:e};if(!n.menu)return o;var r=window,i=r.innerWidth,a=r.innerHeight,u=n.menu.getBoundingClientRect();return o.left=e-u.width,t+u.height>a&&(o.top-=u.height),o.left<0&&(o.left+=u.width),o.top<0&&(o.top=u.heighti&&(o.left=u.width