Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@saleae/react-contexify

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@saleae/react-contexify - npm Package Compare versions

Comparing version 4.1.3 to 4.1.4

4

dist/ReactContexify.js

@@ -1,2 +0,2 @@

!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(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(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},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 r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},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 r;
/*!

@@ -12,3 +12,3 @@ Copyright (c) 2017 Jed Watson.

*/
!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},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 o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var i=typeof r;if("string"===i||"number"===i)e.push(r);else if(Array.isArray(r)&&r.length){var s=o.apply(null,r);s&&e.push(s)}else if("object"===i)for(var a in r)n.call(r,a)&&r[a]&&e.push(a)}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},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 r={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=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];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=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);t.cloneItem=function(e,t){return r.Children.map(r.Children.toArray(e).filter(function(e){return Boolean(e)}),function(e){return r.cloneElement(e,t)})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(8);t.Menu=r.Menu;var o=n(11);t.Item=o.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 r,o=this&&this.__extends||(r=function(e,t){return(r=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}r(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,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);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)),f=n(6),d=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.menuRef=u.default.createRef(),t.innerDivRef=u.default.createRef(),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||e.target!==t.menuRef.current&&e.target!==t.innerDivRef.current)&&(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.show=function(e,n){e.stopPropagation(),v.eventManager.emit(p.HIDE_ALL);var r=t.getMousePosition(e),o=r.x,i=r.y;t.setState({visible:!0,x:o,y:i,nativeEvent:e,propsFromTrigger:n},t.setMenuPosition)},t}return o(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(){if(this.menuRef.current){var e=window.innerWidth,t=window.innerHeight,n=this.menuRef.current,r=n.offsetWidth,o=n.offsetHeight,i=this.state,s=i.x,a=i.y;s+r>e&&(s-=s+r-e),a+o>t&&(a-=a+o-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,r=t.animation,o=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+r]=r,e)),g=i({},o,{left:m,top:_+1,opacity:1});return u.default.createElement(d.Portal,null,p&&u.default.createElement("div",{className:b,style:g,ref:this.menuRef,onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave},u.default.createElement("div",{ref:this.innerDivRef},f.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 r,o=this&&this.__extends||(r=function(e,t){return(r=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}r(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 o(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 r,o=this&&this.__extends||(r=function(e,t){return(r=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}r(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,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);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)),f=n(1),d=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 r=n.props,o=r.disabled,s=r.nativeEvent,a=r.propsFromTrigger,u=r.data,l=r.closeOnClick;return n.isDisabled="function"==typeof o?o({event:s,props:i({},a,u)}):o,n.stayOpenOnClick=n.isDisabled||!("function"==typeof l?l({event:s,props:i({},a,u)}):l),n}return o(t,e),t.prototype.render=function(){var e,t=this.props,n=t.className,r=t.style,o=t.children,i=c.default(f.styles.item,n,((e={})[""+f.styles.itemDisabled]=this.isDisabled,e));return u.default.createElement("div",{className:i,style:r,onClick:this.handleClick,role:"presentation"},u.default.createElement("div",{className:f.styles.itemContent},o))},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:d,closeOnClick:!0},t}(u.Component);t.Item=p},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(0)),i=n(1);t.Separator=function(){return o.default.createElement("div",{className:i.styles.separator})}},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(0)),i=r(n(2)),s=r(n(3)),a=n(1),u=function(e){var t=e.className,n=e.style,r=e.children;return o.default.createElement("i",{className:s.default(a.styles.itemIcon,t),style:n},r||"")};t.IconFont=u,u.propTypes={children:i.default.node,className:i.default.string,style:i.default.object}},function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return(r=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}r(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,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);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)),f=n(6),d=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 o(t,e),t.prototype.componentDidMount=function(){var e=window.innerWidth,t=window.innerHeight,n=this.menu.getBoundingClientRect(),r={};n.right<e?(r.left="100%",r.right=void 0):(r.right="100%",r.left=void 0),n.bottom>t?(r.bottom=0,r.top="initial"):(r.bottom="initial",r.top=0),this.setState(r)},t.prototype.handleClick=function(e){e.stopPropagation()},t.prototype.render=function(){var e,t=this.props,n=t.arrow,r=t.disabled,o=t.className,s=t.style,a=t.label,l=t.nativeEvent,p=t.children,h=t.propsFromTrigger,v=c.default(d.styles.item,o,((e={})[""+d.styles.itemDisabled]="function"==typeof r?r({event:l,props:i({},h)}):r,e)),y=i({},s,this.state);return u.default.createElement("div",{className:v,role:"presentation"},u.default.createElement("div",{className:d.styles.itemContent,onClick:this.handleClick},a,u.default.createElement("span",{className:d.styles.submenuArrow},n)),u.default.createElement("div",{className:d.styles.submenu,ref:this.setRef,style:y},f.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 r,o=this&&this.__extends||(r=function(e,t){return(r=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}r(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,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},s=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&(n[r[o]]=e[r[o]])}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),f=n(5),d=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.childrenRefs=[],t.handleEvent=function(e){e.preventDefault(),e.stopPropagation(),f.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 o(t,e),t.prototype.getChildren=function(){var e=this,t=this.props,n=(t.id,t.component,t.event,t.children),r=(t.className,t.style,t.storeRef),o=(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({},o,r?{ref:e.setChildRef}:{})):t})},t.prototype.render=function(){var e,t=this.props,n=t.component,r=t.render,o=t.event,s=t.className,a=t.style,l=((e={})[o]=this.handleEvent,e.className=s,e.style=a,e);return"function"==typeof r?r(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=d},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(5),o=n(4),i={show:function(e){var t=e.id,n=e.event,i=e.props;r.eventManager.emit(o.DISPLAY_MENU(t),n.nativeEvent||n,i)},hideAll:function(){r.eventManager.emit(o.HIDE_ALL)}};t.contextMenu=i}])});
//# sourceMappingURL=ReactContexify.js.map

@@ -1,2 +0,2 @@

import { Component, ReactNode } from 'react';
import React, { Component, ReactNode } from 'react';
import PropTypes from 'prop-types';

@@ -59,3 +59,4 @@ import { TriggerEvent, StyleProps, MenuId } from '../types';

};
menuRef: HTMLDivElement;
menuRef: React.RefObject<HTMLDivElement>;
innerDivRef: React.RefObject<HTMLDivElement>;
unsub: (() => boolean)[];

@@ -71,3 +72,2 @@ componentDidMount(): void;

handleKeyboard: (e: KeyboardEvent) => void;
setRef: (ref: HTMLDivElement) => void;
setMenuPosition(): void;

@@ -74,0 +74,0 @@ getMousePosition(e: TriggerEvent): {

@@ -67,2 +67,4 @@ "use strict";

};
_this.menuRef = react_1.default.createRef();
_this.innerDivRef = react_1.default.createRef();
_this.unsub = [];

@@ -96,3 +98,6 @@ _this.bindWindowEvent = function () {

}
if (event && event.type === 'click' && e.target === _this.menuRef) {
if (event &&
event.type === 'click' &&
(event.target === _this.menuRef.current ||
event.target === _this.innerDivRef.current)) {
// Ignore clicks directly on the menu element itself (e.g. if it has padding)

@@ -110,5 +115,2 @@ return;

};
_this.setRef = function (ref) {
_this.menuRef = ref;
};
_this.show = function (e, props) {

@@ -147,4 +149,6 @@ e.stopPropagation();

Menu.prototype.setMenuPosition = function () {
if (!this.menuRef.current)
return;
var windowWidth = window.innerWidth, windowHeight = window.innerHeight;
var _a = this.menuRef, menuWidth = _a.offsetWidth, menuHeight = _a.offsetHeight;
var _a = this.menuRef.current, menuWidth = _a.offsetWidth, menuHeight = _a.offsetHeight;
var _b = this.state, x = _b.x, y = _b.y;

@@ -190,6 +194,7 @@ if (x + menuWidth > windowWidth) {

var menuStyle = __assign({}, style, { left: x, top: y + 1, opacity: 1 });
return (react_1.default.createElement(Portal_1.Portal, null, visible && (react_1.default.createElement("div", { className: cssClasses, style: menuStyle, ref: this.setRef, onMouseEnter: this.onMouseEnter, onMouseLeave: this.onMouseLeave }, cloneItem_1.cloneItem(children, {
nativeEvent: nativeEvent,
propsFromTrigger: propsFromTrigger
})))));
return (react_1.default.createElement(Portal_1.Portal, null, visible && (react_1.default.createElement("div", { className: cssClasses, style: menuStyle, ref: this.menuRef, onMouseEnter: this.onMouseEnter, onMouseLeave: this.onMouseLeave },
react_1.default.createElement("div", { ref: this.innerDivRef }, cloneItem_1.cloneItem(children, {
nativeEvent: nativeEvent,
propsFromTrigger: propsFromTrigger
}))))));
};

@@ -196,0 +201,0 @@ Menu.propTypes = {

{
"name": "@saleae/react-contexify",
"version": "4.1.3",
"version": "4.1.4",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc