@firefox-devtools/react-contextmenu
Version:
Context Menu implemented in React
2 lines • 21.7 kB
JavaScript
/*! For license information please see react-contextmenu.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):"object"==typeof exports?exports.ReactContextMenu=t(require("react"),require("react-dom")):e.ReactContextMenu=t(e.React,e.ReactDOM)}(self,((e,t)=>(()=>{var n={3:e=>{"use strict";e.exports=t},228:e=>{"use strict";var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var s={};return"abcdefghijklmnopqrst".split("").forEach((function(e){s[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},s)).join("")}catch(e){return!1}}()?Object.assign:function(e,i){for(var o,r,l=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),a=1;a<arguments.length;a++){for(var u in o=Object(arguments[a]))n.call(o,u)&&(l[u]=o[u]);if(t){r=t(o);for(var d=0;d<r.length;d++)s.call(o,r[d])&&(l[r[d]]=o[r[d]])}}return l}},442:t=>{"use strict";t.exports=e},556:(e,t,n)=>{e.exports=n(694)()},694:(e,t,n)=>{"use strict";var s=n(925);function i(){}function o(){}o.resetWarningCache=i,e.exports=function(){function e(e,t,n,i,o,r){if(r!==s){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:i};return n.PropTypes=n,n}},925:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},942:(e,t)=>{var n;!function(){"use strict";var s={}.hasOwnProperty;function i(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=r(e,o(n)))}return e}function o(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return i.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var n in e)s.call(e,n)&&e[n]&&(t=r(t,n));return t}function r(e,t){return t?e?e+" "+t:e+t:e}e.exports?(i.default=i,e.exports=i):void 0===(n=function(){return i}.apply(t,[]))||(e.exports=n)}()}},s={};function i(e){var t=s[e];if(void 0!==t)return t.exports;var o=s[e]={exports:{}};return n[e](o,o.exports,i),o.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{"use strict";i.r(o),i.d(o,{ContextMenu:()=>R,ContextMenuTrigger:()=>N,MenuItem:()=>k,SubMenu:()=>L,connectMenu:()=>D,hideMenu:()=>T,showMenu:()=>E});var e=i(442),t=i.n(e),n=i(3),s=i.n(n),r=i(556),l=i.n(r),a=i(942),u=i.n(a),d=i(228),h=i.n(d);function c(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];return"function"==typeof e&&e(...n)}function p(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const m="react-contextmenu",f="react-contextmenu--visible",b="react-contextmenu-item",v="react-contextmenu-item--disabled",g="react-contextmenu-item--selected",y={},M=Boolean("undefined"!=typeof window&&window.document&&window.document.createElement),C="REACT_CONTEXTMENU_SHOW",O="REACT_CONTEXTMENU_HIDE";function w(e,t){let n,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window;"function"==typeof window.CustomEvent?n=new window.CustomEvent(e,{detail:t}):(n=document.createEvent("CustomEvent"),n.initCustomEvent(e,!1,!0,t)),s&&(s.dispatchEvent(n),h()(y,t))}function E(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;w(C,h()({},e,{type:C}),t)}function T(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;w(O,h()({},e,{type:O}),t)}const x=new class{constructor(){this.callbacks={},M&&(window.addEventListener(C,this.handleShowEvent),window.addEventListener(O,this.handleHideEvent))}handleShowEvent=e=>{for(const t in this.callbacks)p(this.callbacks,t)&&this.callbacks[t].show(e)};handleHideEvent=e=>{for(const t in this.callbacks)p(this.callbacks,t)&&this.callbacks[t].hide(e)};register=(e,t)=>{const n=Math.random().toString(36).substring(7);return this.callbacks[n]={show:e,hide:t},n};unregister=e=>{e&&this.callbacks[e]&&delete this.callbacks[e]}};function S(){return S=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)({}).hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},S.apply(null,arguments)}class k extends e.Component{static propTypes=(()=>({attributes:l().object,children:l().node,className:l().string,data:l().object,disabled:l().bool,divider:l().bool,onClick:l().func,onMouseLeave:l().func,onMouseMove:l().func,preventClose:l().bool,selected:l().bool,role:l().string}))();static defaultProps={attributes:{},children:null,className:"",data:{},disabled:!1,divider:!1,onClick:()=>null,onMouseMove:()=>null,onMouseLeave:()=>null,preventClose:!1,selected:!1,role:"menuitem"};handleClick=e=>{0!==e.button&&1!==e.button&&e.preventDefault(),this.props.disabled||this.props.divider||(c(this.props.onClick,e,h()({},this.props.data,y.data),y.target),this.props.preventClose||T())};render(){const{attributes:e,children:n,className:s,disabled:i,divider:o,selected:r,role:l}=this.props,a=u()(s,b,e.className,{[u()(v,e.disabledClassName)]:i,[u()("react-contextmenu-item--divider",e.dividerClassName)]:o,[u()(g,e.selectedClassName)]:r});return t().createElement("div",S({},e,{className:a,role:l,tabIndex:"-1","aria-disabled":i?"true":"false","aria-orientation":o?"horizontal":null,ref:e=>{this.ref=e},onMouseMove:this.props.onMouseMove,onMouseLeave:this.props.onMouseLeave,onTouchEnd:this.handleClick,onClick:this.handleClick}),o?null:n)}}class I extends e.Component{static propTypes=(()=>({children:l().node.isRequired}))();constructor(e){super(e),this.seletedItemRef=null,this.state={selectedItem:null,forceSubMenuOpen:!1}}handleKeyNavigation=e=>{if(!1!==this.state.isVisible)switch(e.key){case"ArrowLeft":case"Left":case"Escape":case"Esc":e.preventDefault(),this.hideMenu(e);break;case"ArrowUp":case"Up":e.preventDefault(),this.selectChildren(!0);break;case"ArrowDown":case"Down":e.preventDefault(),this.selectChildren(!1);break;case"ArrowRight":case"Right":this.tryToOpenSubMenu(e);break;case"Enter":e.preventDefault(),this.tryToOpenSubMenu(e);{const t=this.seletedItemRef&&this.seletedItemRef.props&&this.seletedItemRef.props.disabled;this.seletedItemRef&&this.seletedItemRef.ref instanceof HTMLElement&&!t?this.seletedItemRef.ref.click():this.hideMenu(e)}}};handleForceClose=()=>{this.setState({forceSubMenuOpen:!1})};tryToOpenSubMenu=e=>{this.state.selectedItem&&this.state.selectedItem.type===this.getSubMenuType()&&(e.preventDefault(),this.setState({forceSubMenuOpen:!0}))};selectChildren=e=>{const{selectedItem:n}=this.state,s=[];let i=0,o={};const r=(e,n)=>{e&&([k,this.getSubMenuType()].indexOf(e.type)<0&&e.props.children instanceof Object?t().Children.forEach(e.props.children,r):e.props.divider||(e.props.disabled&&(++i,o[n]=!0),s.push(e)))};if(t().Children.forEach(this.props.children,r),i===s.length)return;const l=function(t){let n=t;do{e?--n:++n,n<0?n=s.length-1:n>=s.length&&(n=0)}while(n!==t&&o[n]);return n===t?null:n}(n?n.index:-1);null!==l&&this.setState({selectedItem:{index:l,type:s[l].type},forceSubMenuOpen:!1})};onChildMouseMove=(e,t)=>{null!==this.state.selectedItem&&this.state.selectedItem.index===t||this.setState({selectedItem:{index:t,type:e.type},forceSubMenuOpen:!1})};onChildMouseLeave=()=>{this.setState({selectedItem:null,forceSubMenuOpen:!1})};renderChildren=(()=>{var e=this;return function(n){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{value:-1};return t().Children.map(n,(n=>{let i=s;const o={};if(!t().isValidElement(n))return n;if([k,e.getSubMenuType()].indexOf(n.type)<0)return o.children=e.renderChildren(n.props.children,i),t().cloneElement(n,o);let r=null;return n.props.divider||(r=++i.value),o.onMouseLeave=e.onChildMouseLeave.bind(e),n.type===e.getSubMenuType()&&(o.forceOpen=e.state.forceSubMenuOpen&&e.state.selectedItem&&e.state.selectedItem.index===r,o.forceClose=e.handleForceClose,o.parentKeyNavigationHandler=e.handleKeyNavigation),!n.props.divider&&e.state.selectedItem&&e.state.selectedItem.index===r?(o.selected=!0,o.ref=t=>{e.seletedItemRef=t},t().cloneElement(n,o)):(o.onMouseMove=()=>e.onChildMouseMove(n,r),t().cloneElement(n,o))}))}})()}function H(){return H=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)({}).hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},H.apply(null,arguments)}class L extends I{static propTypes=(()=>({children:l().node.isRequired,attributes:l().object,title:l().node.isRequired,className:l().string,disabled:l().bool,hoverDelay:l().number,rtl:l().bool,selected:l().bool,onMouseMove:l().func,onMouseOut:l().func,forceOpen:l().bool,forceClose:l().func,parentKeyNavigationHandler:l().func}))();static defaultProps={disabled:!1,hoverDelay:500,attributes:{},className:"",rtl:!1,selected:!1,onMouseMove:()=>null,onMouseOut:()=>null,forceOpen:!1,forceClose:()=>null,parentKeyNavigationHandler:()=>null};constructor(e){super(e),this.state=h()({},this.state,{visible:!1})}componentDidMount(){this.listenId=x.register((()=>{}),this.hideSubMenu)}getSubMenuType(){return L}shouldComponentUpdate(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}componentDidUpdate(){if(this.isVisibilityChange)if(this.props.forceOpen||this.state.visible)(window.requestAnimationFrame||setTimeout)((()=>{if(!this.subMenu)return;const e=this.props.rtl?this.getRTLMenuPosition():this.getMenuPosition();this.subMenu.style.removeProperty("top"),this.subMenu.style.removeProperty("bottom"),this.subMenu.style.removeProperty("left"),this.subMenu.style.removeProperty("right"),p(e,"top")&&(this.subMenu.style.top=e.top),p(e,"left")&&(this.subMenu.style.left=e.left),p(e,"bottom")&&(this.subMenu.style.bottom=e.bottom),p(e,"right")&&(this.subMenu.style.right=e.right),this.subMenu.classList.add(f),this.registerHandlers(),this.setState({selectedItem:null})}));else{const e=()=>{this.subMenu&&(this.subMenu.removeEventListener("transitionend",e),this.subMenu.style.removeProperty("bottom"),this.subMenu.style.removeProperty("right"),this.subMenu.style.top=0,this.subMenu.style.left="100%",this.unregisterHandlers())};this.subMenu.addEventListener("transitionend",e),this.subMenu.classList.remove(f)}}componentWillUnmount(){this.listenId&&x.unregister(this.listenId),this.opentimer&&clearTimeout(this.opentimer),this.closetimer&&clearTimeout(this.closetimer),this.unregisterHandlers(!0)}getMenuPosition=()=>{const{innerWidth:e,innerHeight:t}=window,n=this.subMenu.getBoundingClientRect(),s={};return n.bottom>t?s.bottom=0:s.top=0,n.right<e?s.left="100%":s.right="100%",s};getRTLMenuPosition=()=>{const{innerHeight:e}=window,t=this.subMenu.getBoundingClientRect(),n={};return t.bottom>e?n.bottom=0:n.top=0,t.left<0?n.left="100%":n.right="100%",n};hideMenu=e=>{e.preventDefault(),this.hideSubMenu(e)};hideSubMenu=e=>{e.detail&&e.detail.id&&this.menu&&e.detail.id!==this.menu.id||(this.props.forceOpen&&this.props.forceClose(),this.setState({visible:!1,selectedItem:null}),this.unregisterHandlers())};handleClick=e=>{e.preventDefault(),this.props.disabled||(c(this.props.onClick,e,h()({},this.props.data,y.data),y.target),this.props.onClick&&!this.props.preventCloseOnClick&&T())};handleMouseEnter=()=>{this.closetimer&&clearTimeout(this.closetimer),this.props.disabled||this.state.visible||(this.opentimer=setTimeout((()=>this.setState({visible:!0,selectedItem:null})),this.props.hoverDelay))};handleMouseLeave=()=>{this.opentimer&&clearTimeout(this.opentimer),this.state.visible&&(this.closetimer=setTimeout((()=>this.setState({visible:!1,selectedItem:null})),this.props.hoverDelay))};menuRef=e=>{this.menu=e};subMenuRef=e=>{this.subMenu=e};registerHandlers=()=>{document.removeEventListener("keydown",this.props.parentKeyNavigationHandler),document.addEventListener("keydown",this.handleKeyNavigation)};unregisterHandlers=e=>{document.removeEventListener("keydown",this.handleKeyNavigation),e||document.addEventListener("keydown",this.props.parentKeyNavigationHandler)};render(){const{children:e,attributes:n,disabled:s,title:i,selected:o}=this.props,{visible:r}=this.state,l={ref:this.menuRef,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,className:u()(b,"react-contextmenu-submenu",n.listClassName),style:{position:"relative"}},a={className:u()(b,n.className,{[u()(v,n.disabledClassName)]:s,[u()("react-contextmenu-item--active",n.visibleClassName)]:r,[u()(g,n.selectedClassName)]:o}),onMouseMove:this.props.onMouseMove,onMouseOut:this.props.onMouseOut,onClick:this.handleClick},d={ref:this.subMenuRef,style:{position:"absolute",transition:"opacity 1ms",top:0,left:"100%"},className:u()(m,this.props.className)};return t().createElement("nav",H({},l,{role:"menuitem",tabIndex:"-1","aria-haspopup":"true"}),t().createElement("div",H({},n,a),i),t().createElement("nav",H({},d,{role:"menu",tabIndex:"-1"}),this.renderChildren(e)))}}class R extends I{static propTypes=(()=>({id:l().string.isRequired,children:l().node.isRequired,data:l().object,className:l().string,hideOnLeave:l().bool,rtl:l().bool,onHide:l().func,onMouseLeave:l().func,onShow:l().func,preventHideOnContextMenu:l().bool,preventHideOnResize:l().bool,preventHideOnScroll:l().bool,style:l().object}))();static defaultProps={className:"",data:{},hideOnLeave:!1,rtl:!1,onHide:()=>null,onMouseLeave:()=>null,onShow:()=>null,preventHideOnContextMenu:!1,preventHideOnResize:!1,preventHideOnScroll:!1,style:{}};constructor(e){super(e),this.state=h()({},this.state,{x:0,y:0,isVisible:!1})}getSubMenuType(){return L}componentDidMount(){this.listenId=x.register(this.handleShow,this.handleHide)}componentDidUpdate(){const e=window.requestAnimationFrame||setTimeout;this.state.isVisible?e((()=>{const{x:t,y:n}=this.state,{top:s,left:i}=this.props.rtl?this.getRTLMenuPosition(t,n):this.getMenuPosition(t,n);e((()=>{this.menu&&this.state.isVisible&&(this.menu.style.top=`${s}px`,this.menu.style.left=`${i}px`,this.menu.style.opacity=1,this.menu.style.pointerEvents="auto")}))})):e((()=>{this.menu&&(this.menu.style.opacity=0,this.menu.style.pointerEvents="none")}))}componentWillUnmount(){this.listenId&&x.unregister(this.listenId),this.unregisterHandlers()}registerHandlers=()=>{document.addEventListener("mousedown",this.handleOutsideClick),document.addEventListener("touchstart",this.handleOutsideClick),this.props.preventHideOnScroll||document.addEventListener("scroll",this.handleHide),this.props.preventHideOnContextMenu||document.addEventListener("contextmenu",this.handleHide),document.addEventListener("keydown",this.handleKeyNavigation),this.props.preventHideOnResize||window.addEventListener("resize",this.handleHide)};unregisterHandlers=()=>{document.removeEventListener("mousedown",this.handleOutsideClick),document.removeEventListener("touchstart",this.handleOutsideClick),document.removeEventListener("scroll",this.handleHide),document.removeEventListener("contextmenu",this.handleHide),document.removeEventListener("keydown",this.handleKeyNavigation),window.removeEventListener("resize",this.handleHide)};handleShow=e=>{if(e.detail.id!==this.props.id||this.state.isVisible)return;const{x:t,y:n}=e.detail.position;this.setState({isVisible:!0,x:t,y:n}),this.registerHandlers(),c(this.props.onShow,e)};handleHide=e=>{var t;!this.state.isVisible||e.detail&&e.detail.id&&e.detail.id!==this.props.id||(this.unregisterHandlers(),t=()=>{this.setState({isVisible:!1,selectedItem:null,forceSubMenuOpen:!1})},s().flushSync?s().flushSync(t):t(),c(this.props.onHide,e))};handleOutsideClick=e=>{this.menu.contains(e.target)||T()};handleMouseLeave=e=>{e.preventDefault(),c(this.props.onMouseLeave,e,h()({},this.props.data,y.data),y.target),this.props.hideOnLeave&&T()};handleContextMenu=e=>{e.preventDefault(),this.handleHide(e)};hideMenu=e=>{"Escape"!==e.key&&"Esc"!==e.key&&"Enter"!==e.key||T()};getMenuPosition=(()=>{var e=this;return function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s={top:n,left:t};if(!e.menu)return s;const{innerWidth:i,innerHeight:o}=window,r=e.menu.getBoundingClientRect();return n+r.height>o&&(s.top-=r.height),t+r.width>i&&(s.left-=r.width),s.top<0&&(s.top=r.height<o?(o-r.height)/2:0),s.left<0&&(s.left=r.width<i?(i-r.width)/2:0),s}})();getRTLMenuPosition=(()=>{var e=this;return function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s={top:n,left:t};if(!e.menu)return s;const{innerWidth:i,innerHeight:o}=window,r=e.menu.getBoundingClientRect();return s.left=t-r.width,n+r.height>o&&(s.top-=r.height),s.left<0&&(s.left+=r.width),s.top<0&&(s.top=r.height<o?(o-r.height)/2:0),s.left+r.width>i&&(s.left=r.width<i?(i-r.width)/2:0),s}})();menuRef=e=>{this.menu=e};render(){const{children:e,className:n,style:s}=this.props,{isVisible:i}=this.state,o=h()({},s,{position:"fixed",opacity:0,pointerEvents:"none"}),r=u()(m,n,{[f]:i});return t().createElement("nav",{role:"menu",tabIndex:"-1",ref:this.menuRef,style:o,className:r,onContextMenu:this.handleContextMenu,onMouseLeave:this.handleMouseLeave},this.renderChildren(e))}}class N extends e.Component{static propTypes=(()=>({id:l().string.isRequired,children:l().node.isRequired,attributes:l().object,collect:l().func,disable:l().bool,holdToDisplay:l().number,posX:l().number,posY:l().number,renderTag:l().elementType,triggerOnLeftClick:l().bool,disableIfShiftIsPressed:l().bool}))();static defaultProps={attributes:{},collect:()=>null,disable:!1,holdToDisplay:1e3,renderTag:"div",posX:0,posY:0,triggerOnLeftClick:!1,disableIfShiftIsPressed:!1};touchHandled=!1;handleMouseDown=e=>{this.props.holdToDisplay>=0&&0===e.button&&(e.persist(),e.stopPropagation(),this.mouseDownTimeoutId=setTimeout((()=>this.handleContextClick(e)),this.props.holdToDisplay)),c(this.props.attributes.onMouseDown,e)};handleMouseUp=e=>{0===e.button&&clearTimeout(this.mouseDownTimeoutId),c(this.props.attributes.onMouseUp,e)};handleMouseOut=e=>{0===e.button&&clearTimeout(this.mouseDownTimeoutId),c(this.props.attributes.onMouseOut,e)};handleTouchstart=e=>{this.touchHandled=!1,this.props.holdToDisplay>=0&&(e.persist(),e.stopPropagation(),this.touchstartTimeoutId=setTimeout((()=>{this.handleContextClick(e),this.touchHandled=!0}),this.props.holdToDisplay)),c(this.props.attributes.onTouchStart,e)};handleTouchEnd=e=>{this.touchHandled&&e.preventDefault(),clearTimeout(this.touchstartTimeoutId),c(this.props.attributes.onTouchEnd,e)};handleContextMenu=e=>{this.handleContextClick(e),c(this.props.attributes.onContextMenu,e)};handleMouseClick=e=>{this.handleContextClick(e),c(this.props.attributes.onClick,e)};handleContextClick=e=>{if(this.props.disable)return;if(this.props.disableIfShiftIsPressed&&e.shiftKey)return;e.preventDefault(),e.stopPropagation();let t=e.clientX||e.touches&&e.touches[0].pageX,n=e.clientY||e.touches&&e.touches[0].pageY;this.props.posX&&(t-=this.props.posX),this.props.posY&&(n-=this.props.posY),T();let s=c(this.props.collect,this.props),i={position:{x:t,y:n},target:this.elem,id:this.props.id};s&&"function"==typeof s.then?s.then((t=>{i.data=h()({},t,{target:e.target}),E(i)})):(i.data=h()({},s,{target:e.target}),E(i))};elemRef=e=>{this.elem=e};render(){const{renderTag:e,attributes:n,children:s,triggerOnLeftClick:i}=this.props,o={...n,className:u()("react-contextmenu-wrapper",n.className),onContextMenu:this.handleContextMenu,onClick:i?this.handleMouseClick:null,onMouseDown:this.handleMouseDown,onMouseUp:this.handleMouseUp,onTouchStart:this.handleTouchstart,onTouchEnd:this.handleTouchEnd,onMouseOut:this.handleMouseOut,ref:this.elemRef};return t().createElement(e,o,s)}}function P(){return P=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)({}).hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},P.apply(null,arguments)}const j=[...Object.keys(N.propTypes),"children"];function D(n){return function(s){return class extends e.Component{constructor(e){super(e),this.state={trigger:null}}componentDidMount(){this.listenId=x.register(this.handleShow,this.handleHide)}componentWillUnmount(){this.listenId&&x.unregister(this.listenId)}handleShow=e=>{if(e.detail.id!==n)return;const{data:t}=e.detail,s={};for(const e in t)j.includes(e)||(s[e]=t[e]);this.setState({trigger:s})};handleHide=()=>{this.setState({trigger:null})};render(){return t().createElement(s,P({},this.props,{id:n,trigger:this.state.trigger}))}}}}})(),o})()));