@saleae/react-contexify
Advanced tools
Comparing version 4.1.1 to 4.1.2
@@ -12,3 +12,3 @@ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("prop-types"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","prop-types","react-dom"],t):"object"==typeof exports?exports.ReactContexify=t(require("react"),require("prop-types"),require("react-dom")):e.ReactContexify=t(e.react,e["prop-types"],e["react-dom"])}(window,function(e,t,n){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(t,n){t.exports=e},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.styles={menu:"react-contexify",submenu:"react-contexify react-contexify__submenu",submenuArrow:"react-contexify__submenu-arrow",separator:"react-contexify__separator",item:"react-contexify__item",itemDisabled:"react-contexify__item--disabled",itemContent:"react-contexify__item__content",itemIcon:"react-contexify__item__icon",theme:"react-contexify__theme--",animationWillEnter:"react-contexify__will-enter--",animationWillLeave:"react-contexify__will-leave--"},t.theme={light:"light",dark:"dark"},t.animation={fade:"fade",flip:"flip",pop:"pop",zoom:"zoom"}},function(e,n){e.exports=t},function(e,t,n){var o; | ||
*/ | ||
!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e=[],t=0;t<arguments.length;t++){var o=arguments[t];if(o){var i=typeof o;if("string"===i||"number"===i)e.push(o);else if(Array.isArray(o)&&o.length){var s=r.apply(null,o);s&&e.push(s)}else if("object"===i)for(var a in o)n.call(o,a)&&o[a]&&e.push(a)}}return e.join(" ")}e.exports?(r.default=r,e.exports=r):void 0===(o=function(){return r}.apply(t,[]))||(e.exports=o)}()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HIDE_ALL=0,t.DISPLAY_MENU=function(e){return"DISPLAY_"+e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o={eventList:new Map,on:function(e,t){var n=this;return this.eventList.has(e)||this.eventList.set(e,new Set),this.eventList.get(e).add(t),function(){return n.eventList.get(e).delete(t)}},emit:function(e){for(var t=this,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];return this.eventList.has(e)?(this.eventList.get(e).forEach(function(e){return e.call.apply(e,[t].concat(n))}),!0):(console.warn("<"+e+"> Event is not registered. Did you forgot to bind the event ?"),!1)}};t.eventManager=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(0);t.cloneItem=function(e,t){return o.Children.map(o.Children.toArray(e).filter(function(e){return Boolean(e)}),function(e){return o.cloneElement(e,t)})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(8);t.Menu=o.Menu;var r=n(11);t.Item=r.Item;var i=n(12);t.Separator=i.Separator;var s=n(13);t.IconFont=s.IconFont;var a=n(14);t.Submenu=a.Submenu;var u=n(15);t.MenuProvider=u.MenuProvider;var l=n(16);t.contextMenu=l.contextMenu;var c=n(1);t.theme=c.theme,t.animation=c.animation},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=s(n(0)),l=a(n(2)),c=a(n(3)),d=n(6),f=n(9),p=n(4),h=n(1),v=n(5),y={ENTER:13,ESC:27,ARROW_UP:38,ARROW_DOWN:40,ARROW_LEFT:37,ARROW_RIGHT:39},m=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={x:0,y:0,visible:!1,nativeEvent:{},propsFromTrigger:{},onShown:null,onHidden:null},t.unsub=[],t.bindWindowEvent=function(){window.addEventListener("resize",t.hide),window.addEventListener("contextmenu",t.hide),window.addEventListener("mousedown",t.hide),window.addEventListener("click",t.hide),window.addEventListener("scroll",t.hide),window.addEventListener("keydown",t.handleKeyboard)},t.unBindWindowEvent=function(){window.removeEventListener("resize",t.hide),window.removeEventListener("contextmenu",t.hide),window.removeEventListener("mousedown",t.hide),window.removeEventListener("click",t.hide),window.removeEventListener("scroll",t.hide),window.removeEventListener("keydown",t.handleKeyboard)},t.onMouseEnter=function(){return window.removeEventListener("mousedown",t.hide)},t.onMouseLeave=function(){return window.addEventListener("mousedown",t.hide)},t.hide=function(e){var n=e;(void 0===n||2!==n.button&&!0!==n.ctrlKey||"contextmenu"===n.type)&&(t.unBindWindowEvent(),t.setState({visible:!1}))},t.handleKeyboard=function(e){e.keyCode!==y.ENTER&&e.keyCode!==y.ESC||(t.unBindWindowEvent(),t.setState({visible:!1}))},t.setRef=function(e){t.menuRef=e},t.show=function(e,n){e.stopPropagation(),v.eventManager.emit(p.HIDE_ALL);var o=t.getMousePosition(e),r=o.x,i=o.y;t.setState({visible:!0,x:r,y:i,nativeEvent:e,propsFromTrigger:n},t.setMenuPosition)},t}return r(t,e),t.prototype.componentDidMount=function(){this.unsub.push(v.eventManager.on(p.DISPLAY_MENU(this.props.id),this.show)),this.unsub.push(v.eventManager.on(p.HIDE_ALL,this.hide))},t.prototype.componentWillUnmount=function(){this.unsub.forEach(function(e){return e()}),this.unBindWindowEvent()},t.prototype.componentDidUpdate=function(e,t){this.state.visible!==t.visible&&(this.state.visible&&this.props.onShown?this.props.onShown():!this.state.visible&&this.props.onHidden&&this.props.onHidden())},t.prototype.setMenuPosition=function(){var e=window.innerWidth,t=window.innerHeight,n=this.menuRef,o=n.offsetWidth,r=n.offsetHeight,i=this.state,s=i.x,a=i.y;s+o>e&&(s-=s+o-e),a+r>t&&(a-=a+r-t),this.setState({x:s,y:a},this.bindWindowEvent)},t.prototype.getMousePosition=function(e){var t={x:e.clientX,y:e.clientY};return"touchend"===e.type&&(!t.x||!t.y)&&e.changedTouches&&e.changedTouches.length>0&&(t.x=e.changedTouches[0].clientX,t.y=e.changedTouches[0].clientY),(!t.x||t.x<0)&&(t.x=0),(!t.y||t.y<0)&&(t.y=0),t},t.prototype.render=function(){var e,t=this.props,n=t.theme,o=t.animation,r=t.style,s=t.className,a=t.children,l=this.state,p=l.visible,v=l.nativeEvent,y=l.propsFromTrigger,m=l.x,_=l.y,b=c.default(h.styles.menu,s,((e={})[h.styles.theme+n]=n,e[h.styles.animationWillEnter+o]=o,e)),g=i({},r,{left:m,top:_+1,opacity:1});return u.default.createElement(f.Portal,null,p&&u.default.createElement("div",{className:b,style:g,ref:this.setRef,onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave},u.default.createElement("div",null,d.cloneItem(a,{nativeEvent:v,propsFromTrigger:y}))))},t.propTypes={id:l.default.oneOfType([l.default.string,l.default.number]).isRequired,children:l.default.node.isRequired,theme:l.default.string,animation:l.default.string,className:l.default.string,style:l.default.object},t}(u.Component);t.Menu=m},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),s=n(10),a=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={canRender:!1},t.container={},t}return r(t,e),t.prototype.componentDidMount=function(){this.container=document.createElement("div"),document.body.appendChild(this.container),this.setState({canRender:!0})},t.prototype.componentWillUnmount=function(){document.body.removeChild(this.container)},t.prototype.render=function(){return this.state.canRender&&s.createPortal(this.props.children,this.container)},t}(i.PureComponent);t.Portal=a},function(e,t){e.exports=n},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=s(n(0)),l=a(n(2)),c=a(n(3)),d=n(1),f=function(){},p=function(e){function t(t){var n=e.call(this,t)||this;n.handleClick=function(e){n.stayOpenOnClick&&e.stopPropagation(),n.isDisabled||n.props.onClick({event:n.props.nativeEvent,props:i({},n.props.propsFromTrigger,n.props.data)})};var o=n.props,r=o.disabled,s=o.nativeEvent,a=o.propsFromTrigger,u=o.data,l=o.closeOnClick;return n.isDisabled="function"==typeof r?r({event:s,props:i({},a,u)}):r,n.stayOpenOnClick=n.isDisabled||!("function"==typeof l?l({event:s,props:i({},a,u)}):l),n}return r(t,e),t.prototype.render=function(){var e,t=this.props,n=t.className,o=t.style,r=t.children,i=c.default(d.styles.item,n,((e={})[""+d.styles.itemDisabled]=this.isDisabled,e));return u.default.createElement("div",{className:i,style:o,onClick:this.handleClick,role:"presentation"},u.default.createElement("div",{className:d.styles.itemContent},r))},t.propTypes={children:l.default.node.isRequired,data:l.default.object,disabled:l.default.oneOfType([l.default.func,l.default.bool]),onClick:l.default.func,nativeEvent:l.default.object,propsFromTrigger:l.default.object,className:l.default.string,style:l.default.object,closeOnClick:l.default.bool},t.defaultProps={disabled:!1,onClick:f,closeOnClick:!0},t}(u.Component);t.Item=p},function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var r=o(n(0)),i=n(1);t.Separator=function(){return r.default.createElement("div",{className:i.styles.separator})}},function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var r=o(n(0)),i=o(n(2)),s=o(n(3)),a=n(1),u=function(e){var t=e.className,n=e.style,o=e.children;return r.default.createElement("i",{className:s.default(a.styles.itemIcon,t),style:n},o||"")};t.IconFont=u,u.propTypes={children:i.default.node,className:i.default.string,style:i.default.object}},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=s(n(0)),l=a(n(2)),c=a(n(3)),d=n(6),f=n(1),p=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={left:"100%",top:0,bottom:"initial"},t.setRef=function(e){t.menu=e},t}return r(t,e),t.prototype.componentDidMount=function(){var e=window.innerWidth,t=window.innerHeight,n=this.menu.getBoundingClientRect(),o={};n.right<e?(o.left="100%",o.right=void 0):(o.right="100%",o.left=void 0),n.bottom>t?(o.bottom=0,o.top="initial"):(o.bottom="initial",o.top=0),this.setState(o)},t.prototype.handleClick=function(e){e.stopPropagation()},t.prototype.render=function(){var e,t=this.props,n=t.arrow,o=t.disabled,r=t.className,s=t.style,a=t.label,l=t.nativeEvent,p=t.children,h=t.propsFromTrigger,v=c.default(f.styles.item,r,((e={})[""+f.styles.itemDisabled]="function"==typeof o?o({event:l,props:i({},h)}):o,e)),y=i({},s,this.state);return u.default.createElement("div",{className:v,role:"presentation"},u.default.createElement("div",{className:f.styles.itemContent,onClick:this.handleClick},a,u.default.createElement("span",{className:f.styles.submenuArrow},n)),u.default.createElement("div",{className:f.styles.submenu,ref:this.setRef,style:y},d.cloneItem(p,{propsFromTrigger:h,nativeEvent:l})))},t.propTypes={label:l.default.node.isRequired,children:l.default.node.isRequired,nativeEvent:l.default.object,arrow:l.default.node,disabled:l.default.oneOfType([l.default.func,l.default.bool]),className:l.default.string,style:l.default.object},t.defaultProps={arrow:"▶",disabled:!1,nativeEvent:{}},t}(u.Component);t.Submenu=p},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},s=this&&this.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&(n[o[r]]=e[o[r]])}return n},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=n(0),l=a(n(2)),c=n(4),d=n(5),f=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.childrenRefs=[],t.handleEvent=function(e){e.preventDefault(),e.stopPropagation(),d.eventManager.emit(c.DISPLAY_MENU(t.props.id),e.nativeEvent,i({ref:1===t.childrenRefs.length?t.childrenRefs[0]:t.childrenRefs},t.props.data))},t.setChildRef=function(e){return null===e||t.childrenRefs.push(e)},t}return r(t,e),t.prototype.getChildren=function(){var e=this,t=this.props,n=(t.id,t.component,t.event,t.children),o=(t.className,t.style,t.storeRef),r=(t.data,s(t,["id","component","event","children","className","style","storeRef","data"]));return this.childrenRefs=[],u.Children.map(n,function(t){return u.isValidElement(t)?u.cloneElement(t,i({},r,o?{ref:e.setChildRef}:{})):t})},t.prototype.render=function(){var e,t=this.props,n=t.component,o=t.render,r=t.event,s=t.className,a=t.style,l=((e={})[r]=this.handleEvent,e.className=s,e.style=a,e);return"function"==typeof o?o(i({},l,{children:this.getChildren()})):u.createElement(n,l,this.getChildren())},t.propTypes={id:l.default.oneOfType([l.default.string,l.default.number]).isRequired,children:l.default.node.isRequired,component:l.default.oneOfType([l.default.node,l.default.func]),render:l.default.func,event:l.default.string,className:l.default.string,style:l.default.object,storeRef:l.default.bool,data:l.default.object},t.defaultProps={component:"div",event:"onContextMenu",storeRef:!0},t}(u.Component);t.MenuProvider=f},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(5),r=n(4),i={show:function(e){var t=e.id,n=e.event,i=e.props;o.eventManager.emit(r.DISPLAY_MENU(t),n.nativeEvent||n,i)},hideAll:function(){o.eventManager.emit(r.HIDE_ALL)}};t.contextMenu=i}])}); | ||
!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e=[],t=0;t<arguments.length;t++){var o=arguments[t];if(o){var i=typeof o;if("string"===i||"number"===i)e.push(o);else if(Array.isArray(o)&&o.length){var s=r.apply(null,o);s&&e.push(s)}else if("object"===i)for(var a in o)n.call(o,a)&&o[a]&&e.push(a)}}return e.join(" ")}e.exports?(r.default=r,e.exports=r):void 0===(o=function(){return r}.apply(t,[]))||(e.exports=o)}()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HIDE_ALL=0,t.DISPLAY_MENU=function(e){return"DISPLAY_"+e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o={eventList:new Map,on:function(e,t){var n=this;return this.eventList.has(e)||this.eventList.set(e,new Set),this.eventList.get(e).add(t),function(){return n.eventList.get(e).delete(t)}},emit:function(e){for(var t=this,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];return this.eventList.has(e)?(this.eventList.get(e).forEach(function(e){return e.call.apply(e,[t].concat(n))}),!0):(console.warn("<"+e+"> Event is not registered. Did you forgot to bind the event ?"),!1)}};t.eventManager=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(0);t.cloneItem=function(e,t){return o.Children.map(o.Children.toArray(e).filter(function(e){return Boolean(e)}),function(e){return o.cloneElement(e,t)})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(8);t.Menu=o.Menu;var r=n(11);t.Item=r.Item;var i=n(12);t.Separator=i.Separator;var s=n(13);t.IconFont=s.IconFont;var a=n(14);t.Submenu=a.Submenu;var u=n(15);t.MenuProvider=u.MenuProvider;var l=n(16);t.contextMenu=l.contextMenu;var c=n(1);t.theme=c.theme,t.animation=c.animation},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=s(n(0)),l=a(n(2)),c=a(n(3)),d=n(6),f=n(9),p=n(4),h=n(1),v=n(5),y={ENTER:13,ESC:27,ARROW_UP:38,ARROW_DOWN:40,ARROW_LEFT:37,ARROW_RIGHT:39},m=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={x:0,y:0,visible:!1,nativeEvent:{},propsFromTrigger:{},onShown:null,onHidden:null},t.unsub=[],t.bindWindowEvent=function(){window.addEventListener("resize",t.hide),window.addEventListener("contextmenu",t.hide),window.addEventListener("mousedown",t.hide),window.addEventListener("click",t.hide),window.addEventListener("scroll",t.hide),window.addEventListener("keydown",t.handleKeyboard)},t.unBindWindowEvent=function(){window.removeEventListener("resize",t.hide),window.removeEventListener("contextmenu",t.hide),window.removeEventListener("mousedown",t.hide),window.removeEventListener("click",t.hide),window.removeEventListener("scroll",t.hide),window.removeEventListener("keydown",t.handleKeyboard)},t.onMouseEnter=function(){return window.removeEventListener("mousedown",t.hide)},t.onMouseLeave=function(){return window.addEventListener("mousedown",t.hide)},t.hide=function(e){var n=e;(void 0===n||2!==n.button&&!0!==n.ctrlKey||"contextmenu"===n.type)&&(e&&"click"===e.type&&n.target===t.menuRef||(t.unBindWindowEvent(),t.setState({visible:!1})))},t.handleKeyboard=function(e){e.keyCode!==y.ENTER&&e.keyCode!==y.ESC||(t.unBindWindowEvent(),t.setState({visible:!1}))},t.setRef=function(e){t.menuRef=e},t.show=function(e,n){e.stopPropagation(),v.eventManager.emit(p.HIDE_ALL);var o=t.getMousePosition(e),r=o.x,i=o.y;t.setState({visible:!0,x:r,y:i,nativeEvent:e,propsFromTrigger:n},t.setMenuPosition)},t}return r(t,e),t.prototype.componentDidMount=function(){this.unsub.push(v.eventManager.on(p.DISPLAY_MENU(this.props.id),this.show)),this.unsub.push(v.eventManager.on(p.HIDE_ALL,this.hide))},t.prototype.componentWillUnmount=function(){this.unsub.forEach(function(e){return e()}),this.unBindWindowEvent()},t.prototype.componentDidUpdate=function(e,t){this.state.visible!==t.visible&&(this.state.visible&&this.props.onShown?this.props.onShown():!this.state.visible&&this.props.onHidden&&this.props.onHidden())},t.prototype.setMenuPosition=function(){var e=window.innerWidth,t=window.innerHeight,n=this.menuRef,o=n.offsetWidth,r=n.offsetHeight,i=this.state,s=i.x,a=i.y;s+o>e&&(s-=s+o-e),a+r>t&&(a-=a+r-t),this.setState({x:s,y:a},this.bindWindowEvent)},t.prototype.getMousePosition=function(e){var t={x:e.clientX,y:e.clientY};return"touchend"===e.type&&(!t.x||!t.y)&&e.changedTouches&&e.changedTouches.length>0&&(t.x=e.changedTouches[0].clientX,t.y=e.changedTouches[0].clientY),(!t.x||t.x<0)&&(t.x=0),(!t.y||t.y<0)&&(t.y=0),t},t.prototype.render=function(){var e,t=this.props,n=t.theme,o=t.animation,r=t.style,s=t.className,a=t.children,l=this.state,p=l.visible,v=l.nativeEvent,y=l.propsFromTrigger,m=l.x,_=l.y,b=c.default(h.styles.menu,s,((e={})[h.styles.theme+n]=n,e[h.styles.animationWillEnter+o]=o,e)),g=i({},r,{left:m,top:_+1,opacity:1});return u.default.createElement(f.Portal,null,p&&u.default.createElement("div",{className:b,style:g,ref:this.setRef,onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave},u.default.createElement("div",null,d.cloneItem(a,{nativeEvent:v,propsFromTrigger:y}))))},t.propTypes={id:l.default.oneOfType([l.default.string,l.default.number]).isRequired,children:l.default.node.isRequired,theme:l.default.string,animation:l.default.string,className:l.default.string,style:l.default.object},t}(u.Component);t.Menu=m},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),s=n(10),a=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={canRender:!1},t.container={},t}return r(t,e),t.prototype.componentDidMount=function(){this.container=document.createElement("div"),document.body.appendChild(this.container),this.setState({canRender:!0})},t.prototype.componentWillUnmount=function(){document.body.removeChild(this.container)},t.prototype.render=function(){return this.state.canRender&&s.createPortal(this.props.children,this.container)},t}(i.PureComponent);t.Portal=a},function(e,t){e.exports=n},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=s(n(0)),l=a(n(2)),c=a(n(3)),d=n(1),f=function(){},p=function(e){function t(t){var n=e.call(this,t)||this;n.handleClick=function(e){n.stayOpenOnClick&&e.stopPropagation(),n.isDisabled||n.props.onClick({event:n.props.nativeEvent,props:i({},n.props.propsFromTrigger,n.props.data)})};var o=n.props,r=o.disabled,s=o.nativeEvent,a=o.propsFromTrigger,u=o.data,l=o.closeOnClick;return n.isDisabled="function"==typeof r?r({event:s,props:i({},a,u)}):r,n.stayOpenOnClick=n.isDisabled||!("function"==typeof l?l({event:s,props:i({},a,u)}):l),n}return r(t,e),t.prototype.render=function(){var e,t=this.props,n=t.className,o=t.style,r=t.children,i=c.default(d.styles.item,n,((e={})[""+d.styles.itemDisabled]=this.isDisabled,e));return u.default.createElement("div",{className:i,style:o,onClick:this.handleClick,role:"presentation"},u.default.createElement("div",{className:d.styles.itemContent},r))},t.propTypes={children:l.default.node.isRequired,data:l.default.object,disabled:l.default.oneOfType([l.default.func,l.default.bool]),onClick:l.default.func,nativeEvent:l.default.object,propsFromTrigger:l.default.object,className:l.default.string,style:l.default.object,closeOnClick:l.default.bool},t.defaultProps={disabled:!1,onClick:f,closeOnClick:!0},t}(u.Component);t.Item=p},function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var r=o(n(0)),i=n(1);t.Separator=function(){return r.default.createElement("div",{className:i.styles.separator})}},function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var r=o(n(0)),i=o(n(2)),s=o(n(3)),a=n(1),u=function(e){var t=e.className,n=e.style,o=e.children;return r.default.createElement("i",{className:s.default(a.styles.itemIcon,t),style:n},o||"")};t.IconFont=u,u.propTypes={children:i.default.node,className:i.default.string,style:i.default.object}},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=s(n(0)),l=a(n(2)),c=a(n(3)),d=n(6),f=n(1),p=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={left:"100%",top:0,bottom:"initial"},t.setRef=function(e){t.menu=e},t}return r(t,e),t.prototype.componentDidMount=function(){var e=window.innerWidth,t=window.innerHeight,n=this.menu.getBoundingClientRect(),o={};n.right<e?(o.left="100%",o.right=void 0):(o.right="100%",o.left=void 0),n.bottom>t?(o.bottom=0,o.top="initial"):(o.bottom="initial",o.top=0),this.setState(o)},t.prototype.handleClick=function(e){e.stopPropagation()},t.prototype.render=function(){var e,t=this.props,n=t.arrow,o=t.disabled,r=t.className,s=t.style,a=t.label,l=t.nativeEvent,p=t.children,h=t.propsFromTrigger,v=c.default(f.styles.item,r,((e={})[""+f.styles.itemDisabled]="function"==typeof o?o({event:l,props:i({},h)}):o,e)),y=i({},s,this.state);return u.default.createElement("div",{className:v,role:"presentation"},u.default.createElement("div",{className:f.styles.itemContent,onClick:this.handleClick},a,u.default.createElement("span",{className:f.styles.submenuArrow},n)),u.default.createElement("div",{className:f.styles.submenu,ref:this.setRef,style:y},d.cloneItem(p,{propsFromTrigger:h,nativeEvent:l})))},t.propTypes={label:l.default.node.isRequired,children:l.default.node.isRequired,nativeEvent:l.default.object,arrow:l.default.node,disabled:l.default.oneOfType([l.default.func,l.default.bool]),className:l.default.string,style:l.default.object},t.defaultProps={arrow:"▶",disabled:!1,nativeEvent:{}},t}(u.Component);t.Submenu=p},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},s=this&&this.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&(n[o[r]]=e[o[r]])}return n},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=n(0),l=a(n(2)),c=n(4),d=n(5),f=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.childrenRefs=[],t.handleEvent=function(e){e.preventDefault(),e.stopPropagation(),d.eventManager.emit(c.DISPLAY_MENU(t.props.id),e.nativeEvent,i({ref:1===t.childrenRefs.length?t.childrenRefs[0]:t.childrenRefs},t.props.data))},t.setChildRef=function(e){return null===e||t.childrenRefs.push(e)},t}return r(t,e),t.prototype.getChildren=function(){var e=this,t=this.props,n=(t.id,t.component,t.event,t.children),o=(t.className,t.style,t.storeRef),r=(t.data,s(t,["id","component","event","children","className","style","storeRef","data"]));return this.childrenRefs=[],u.Children.map(n,function(t){return u.isValidElement(t)?u.cloneElement(t,i({},r,o?{ref:e.setChildRef}:{})):t})},t.prototype.render=function(){var e,t=this.props,n=t.component,o=t.render,r=t.event,s=t.className,a=t.style,l=((e={})[r]=this.handleEvent,e.className=s,e.style=a,e);return"function"==typeof o?o(i({},l,{children:this.getChildren()})):u.createElement(n,l,this.getChildren())},t.propTypes={id:l.default.oneOfType([l.default.string,l.default.number]).isRequired,children:l.default.node.isRequired,component:l.default.oneOfType([l.default.node,l.default.func]),render:l.default.func,event:l.default.string,className:l.default.string,style:l.default.object,storeRef:l.default.bool,data:l.default.object},t.defaultProps={component:"div",event:"onContextMenu",storeRef:!0},t}(u.Component);t.MenuProvider=f},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(5),r=n(4),i={show:function(e){var t=e.id,n=e.event,i=e.props;o.eventManager.emit(r.DISPLAY_MENU(t),n.nativeEvent||n,i)},hideAll:function(){o.eventManager.emit(r.HIDE_ALL)}};t.contextMenu=i}])}); | ||
//# sourceMappingURL=ReactContexify.js.map |
@@ -95,2 +95,6 @@ "use strict"; | ||
} | ||
if (event && event.type === 'click' && e.target === _this.menuRef) { | ||
// Ignore clicks directly on the menu element itself (e.g. if it has padding) | ||
return; | ||
} | ||
_this.unBindWindowEvent(); | ||
@@ -97,0 +101,0 @@ _this.setState({ visible: false }); |
{ | ||
"name": "@saleae/react-contexify", | ||
"version": "4.1.1", | ||
"version": "4.1.2", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "typings": "./lib/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
528445
2542