@firefox-devtools/react-contextmenu
Version:
Context Menu implemented in React
2 lines • 21 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 s={228(e){"use strict";var t=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,n=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={},s=0;s<10;s++)t["_"+String.fromCharCode(s)]=s;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).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]))s.call(o,u)&&(l[u]=o[u]);if(t){r=t(o);for(var d=0;d<r.length;d++)n.call(o,r[d])&&(l[r[d]]=o[r[d]])}}return l}},694(e,t,s){"use strict";var n=s(925);function i(){}function o(){}o.resetWarningCache=i,e.exports=function(){function e(e,t,s,i,o,r){if(r!==n){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 s={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 s.PropTypes=s,s}},556(e,t,s){e.exports=s(694)()},925(e){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},442(t){"use strict";t.exports=e},3(e){"use strict";e.exports=t},942(e,t){var s;!function(){"use strict";var n={}.hasOwnProperty;function i(){for(var e="",t=0;t<arguments.length;t++){var s=arguments[t];s&&(e=r(e,o(s)))}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 s in e)n.call(e,s)&&e[s]&&(t=r(t,s));return t}function r(e,t){return t?e?e+" "+t:e+t:e}e.exports?(i.default=i,e.exports=i):void 0===(s=function(){return i}.apply(t,[]))||(e.exports=s)}()}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={exports:{}};return s[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 s in t)i.o(t,s)&&!i.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},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:()=>j,MenuItem:()=>k,SubMenu:()=>L,connectMenu:()=>D,hideMenu:()=>T,showMenu:()=>E});var e=i(442),t=i.n(e),s=i(3),n=i.n(s),r=i(556),l=i.n(r),a=i(942),u=i.n(a),d=i(228),h=i.n(d);function c(e,...t){return"function"==typeof e&&e(...t)}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,s=window){let n;"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(e={},t){w(C,h()({},e,{type:C}),t)}function T(e={},t){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 s=Math.random().toString(36).substring(7);return this.callbacks[s]={show:e,hide:t},s};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 s=arguments[t];for(var n in s)({}).hasOwnProperty.call(s,n)&&(e[n]=s[n])}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:s,className:n,disabled:i,divider:o,selected:r,role:l}=this.props,a=u()(n,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:s)}}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:s}=this.state,n=[];let i=0,o={};const r=(e,s)=>{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[s]=!0),n.push(e)))};if(t().Children.forEach(this.props.children,r),i===n.length)return;const l=function(t){let s=t;do{e?--s:++s,s<0?s=n.length-1:s>=n.length&&(s=0)}while(s!==t&&o[s]);return s===t?null:s}(s?s.index:-1);null!==l&&this.setState({selectedItem:{index:l,type:n[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=(e,s={value:-1})=>t().Children.map(e,(e=>{let n=s;const i={};if(!t().isValidElement(e))return e;if([k,this.getSubMenuType()].indexOf(e.type)<0)return i.children=this.renderChildren(e.props.children,n),t().cloneElement(e,i);let o=null;return e.props.divider||(o=++n.value),i.onMouseLeave=this.onChildMouseLeave.bind(this),e.type===this.getSubMenuType()&&(i.forceOpen=this.state.forceSubMenuOpen&&this.state.selectedItem&&this.state.selectedItem.index===o,i.forceClose=this.handleForceClose,i.parentKeyNavigationHandler=this.handleKeyNavigation),!e.props.divider&&this.state.selectedItem&&this.state.selectedItem.index===o?(i.selected=!0,i.ref=e=>{this.seletedItemRef=e},t().cloneElement(e,i)):(i.onMouseMove=()=>this.onChildMouseMove(e,o),t().cloneElement(e,i))}))}function H(){return H=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)({}).hasOwnProperty.call(s,n)&&(e[n]=s[n])}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,onClick:l().func,data:l().object,preventCloseOnClick:l().bool};static defaultProps={disabled:!1,hoverDelay:500,attributes:{},className:"",rtl:!1,selected:!1,onMouseMove:()=>null,onMouseOut:()=>null,forceOpen:!1,forceClose:()=>null,parentKeyNavigationHandler:()=>null,onClick:()=>null,data:{},preventCloseOnClick:!1};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,s=this.subMenu.getBoundingClientRect(),n={};return s.bottom>t?n.bottom=0:n.top=0,s.right<e?n.left="100%":n.right="100%",n};getRTLMenuPosition=()=>{const{innerHeight:e}=window,t=this.subMenu.getBoundingClientRect(),s={};return t.bottom>e?s.bottom=0:s.top=0,t.left<0?s.left="100%":s.right="100%",s};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:s,disabled:n,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",s.listClassName),style:{position:"relative"}},a={className:u()(b,s.className,{[u()(v,s.disabledClassName)]:n,[u()("react-contextmenu-item--active",s.visibleClassName)]:r,[u()(g,s.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({},s,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:s}=this.state,{top:n,left:i}=this.props.rtl?this.getRTLMenuPosition(t,s):this.getMenuPosition(t,s);e((()=>{this.menu&&this.state.isVisible&&(this.menu.style.top=`${n}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:s}=e.detail.position;this.setState({isVisible:!0,x:t,y:s}),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})},n().flushSync?n().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=(e=0,t=0)=>{let s={top:t,left:e};if(!this.menu)return s;const{innerWidth:n,innerHeight:i}=window,o=this.menu.getBoundingClientRect();return t+o.height>i&&(s.top-=o.height),e+o.width>n&&(s.left-=o.width),s.top<0&&(s.top=o.height<i?(i-o.height)/2:0),s.left<0&&(s.left=o.width<n?(n-o.width)/2:0),s};getRTLMenuPosition=(e=0,t=0)=>{let s={top:t,left:e};if(!this.menu)return s;const{innerWidth:n,innerHeight:i}=window,o=this.menu.getBoundingClientRect();return s.left=e-o.width,t+o.height>i&&(s.top-=o.height),s.left<0&&(s.left+=o.width),s.top<0&&(s.top=o.height<i?(i-o.height)/2:0),s.left+o.width>n&&(s.left=o.width<n?(n-o.width)/2:0),s};menuRef=e=>{this.menu=e};render(){const{children:e,className:s,style:n}=this.props,{isVisible:i}=this.state,o=h()({},n,{position:"fixed",opacity:0,pointerEvents:"none"}),r=u()(m,s,{[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 j 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,s=e.clientY||e.touches&&e.touches[0].pageY;this.props.posX&&(t-=this.props.posX),this.props.posY&&(s-=this.props.posY),T();let n=c(this.props.collect,this.props),i={position:{x:t,y:s},target:this.elem,id:this.props.id};n&&"function"==typeof n.then?n.then((t=>{i.data=h()({},t,{target:e.target}),E(i)})):(i.data=h()({},n,{target:e.target}),E(i))};elemRef=e=>{this.elem=e};render(){const{renderTag:e,attributes:s,children:n,triggerOnLeftClick:i}=this.props,o={...s,className:u()("react-contextmenu-wrapper",s.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,n)}}function N(){return N=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)({}).hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},N.apply(null,arguments)}const P=[...Object.keys(j.propTypes),"children"];function D(s){return function(n){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!==s)return;const{data:t}=e.detail,n={};for(const e in t)P.includes(e)||(n[e]=t[e]);this.setState({trigger:n})};handleHide=()=>{this.setState({trigger:null})};render(){return t().createElement(n,N({},this.props,{id:s,trigger:this.state.trigger}))}}}}})(),o})()));