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

react-portal-stateless

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-portal-stateless - npm Package Compare versions

Comparing version 1.0.0 to 1.0.2

2

dist/portal.js

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

!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("React"),require("ReactDOM")):"function"==typeof define&&define.amd?define(["React","ReactDOM"],n):"object"==typeof exports?exports.portal=n(require("React"),require("ReactDOM")):e.portal=n(e.React,e.ReactDOM)}(this,function(e,n){return function(e){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}var t={};return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get: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,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="/Users/vitor/projetos/globocom/react-portal/dist",n(n.s=5)}([function(e,n){function t(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(e){if(l===setTimeout)return setTimeout(e,0);if((l===t||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(n){try{return l.call(null,e,0)}catch(n){return l.call(this,e,0)}}}function i(e){if(f===clearTimeout)return clearTimeout(e);if((f===r||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(n){try{return f.call(null,e)}catch(n){return f.call(this,e)}}}function u(){h&&d&&(h=!1,d.length?y=d.concat(y):v=-1,y.length&&a())}function a(){if(!h){var e=o(u);h=!0;for(var n=y.length;n;){for(d=y,y=[];++v<n;)d&&d[v].run();v=-1,n=y.length}d=null,h=!1,i(e)}}function c(e,n){this.fun=e,this.array=n}function s(){}var l,f,p=e.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:t}catch(e){l=t}try{f="function"==typeof clearTimeout?clearTimeout:r}catch(e){f=r}}();var d,y=[],h=!1,v=-1;p.nextTick=function(e){var n=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)n[t-1]=arguments[t];y.push(new c(e,n)),1!==y.length||h||o(a)},c.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=s,p.addListener=s,p.once=s,p.off=s,p.removeListener=s,p.removeAllListeners=s,p.emit=s,p.prependListener=s,p.prependOnceListener=s,p.listeners=function(e){return[]},p.binding=function(e){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(e){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(e,n,t){"use strict";function r(e){return function(){return e}}var o=function(){};o.thatReturns=r,o.thatReturnsFalse=r(!1),o.thatReturnsTrue=r(!0),o.thatReturnsNull=r(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},function(e,n,t){"use strict";(function(n){function t(e,n,t,o,i,u,a,c){if(r(n),!e){var s;if(void 0===n)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[t,o,i,u,a,c],f=0;s=new Error(n.replace(/%s/g,function(){return l[f++]})),s.name="Invariant Violation"}throw s.framesToPop=1,s}}var r=function(e){};"production"!==n.env.NODE_ENV&&(r=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")}),e.exports=t}).call(n,t(0))},function(e,n,t){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,n,t){"use strict";(function(n){var r=t(1),o=r;if("production"!==n.env.NODE_ENV){var i=function(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;r<n;r++)t[r-1]=arguments[r];var o=0,i="Warning: "+e.replace(/%s/g,function(){return t[o++]});"undefined"!=typeof console&&console.error(i);try{throw new Error(i)}catch(e){}};o=function(e,n){if(void 0===n)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==n.indexOf("Failed Composite propType: ")&&!e){for(var t=arguments.length,r=Array(t>2?t-2:0),o=2;o<t;o++)r[o-2]=arguments[o];i.apply(void 0,[n].concat(r))}}}e.exports=o}).call(n,t(0))},function(e,n,t){e.exports=t(6)},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function i(e,n){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!n||"object"!=typeof n&&"function"!=typeof n?e:n}function u(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function, not "+typeof n);e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),n&&(Object.setPrototypeOf?Object.setPrototypeOf(e,n):e.__proto__=n)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var a=function(){function e(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(n,t,r){return t&&e(n.prototype,t),r&&e(n,r),n}}(),c=t(7),s=r(c),l=t(8),f=r(l),p=t(9),d=r(p),y={ESCAPE:27},h=function(e){function n(e){o(this,n);var t=i(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.closePortal=t.closePortal.bind(t),t.handleOutsideMouseClick=t.handleOutsideMouseClick.bind(t),t.handleKeydown=t.handleKeydown.bind(t),t.portal=null,t.node=null,t}return u(n,e),a(n,[{key:"componentDidMount",value:function(){this.props.closeOnEsc&&document.addEventListener("keydown",this.handleKeydown),this.props.closeOnOutsideClick&&(document.addEventListener("mouseup",this.handleOutsideMouseClick),document.addEventListener("touchstart",this.handleOutsideMouseClick))}},{key:"componentDidUpdate",value:function(e){this.props.isOpen?this.renderPortal():e.isOpen&&this.closePortal()}},{key:"componentWillUnmount",value:function(){this.props.closeOnEsc&&document.removeEventListener("keydown",this.handleKeydown),this.props.closeOnOutsideClick&&(document.removeEventListener("mouseup",this.handleOutsideMouseClick),document.removeEventListener("touchstart",this.handleOutsideMouseClick)),this.closePortal(!0)}},{key:"handleOutsideMouseClick",value:function(e){if(this.props.isOpen){(0,l.findDOMNode)(this.portal).contains(e.target)||e.button&&0!==e.button||(e.stopPropagation(),this.props.onClose())}}},{key:"handleKeydown",value:function(e){e.keyCode===y.ESCAPE&&this.props.isOpen&&this.props.onClose()}},{key:"closePortal",value:function(){this.node&&(f.default.unmountComponentAtNode(this.node),document.body.removeChild(this.node)),this.portal=null,this.node=null}},{key:"renderPortal",value:function(){this.node||(this.node=document.createElement("div"),document.body.appendChild(this.node));var e=this.props.children;"function"==typeof e.type&&(e=s.default.cloneElement(e,{closePortal:this.closePortal})),this.portal=f.default.unstable_renderSubtreeIntoContainer(this,e,this.node,this.props.onUpdate)}},{key:"render",value:function(){return null}}]),n}(s.default.Component);n.default=h,h.propTypes={children:d.default.element.isRequired,closeOnEsc:d.default.bool,closeOnOutsideClick:d.default.bool,isOpen:d.default.bool,onClose:d.default.func,onUpdate:d.default.func},h.defaultProps={onOpen:function(){},onClose:function(){},onUpdate:function(){}}},function(n,t){n.exports=e},function(e,t){e.exports=n},function(e,n,t){(function(n){if("production"!==n.env.NODE_ENV){var r="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,o=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r};e.exports=t(10)(o,!0)}else e.exports=t(12)()}).call(n,t(0))},function(e,n,t){"use strict";(function(n){var r=t(1),o=t(2),i=t(4),u=t(3),a=t(11);e.exports=function(e,t){function c(e){var n=e&&(P&&e[P]||e[k]);if("function"==typeof n)return n}function s(e,n){return e===n?0!==e||1/e==1/n:e!==e&&n!==n}function l(e){this.message=e,this.stack=""}function f(e){function r(r,s,f,p,d,y,h){if(p=p||R,y=y||f,h!==u)if(t)o(!1,"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");else if("production"!==n.env.NODE_ENV&&"undefined"!=typeof console){var v=p+":"+f;!a[v]&&c<3&&(i(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",y,p),a[v]=!0,c++)}return null==s[f]?r?new l(null===s[f]?"The "+d+" `"+y+"` is marked as required in `"+p+"`, but its value is `null`.":"The "+d+" `"+y+"` is marked as required in `"+p+"`, but its value is `undefined`."):null:e(s,f,p,d,y)}if("production"!==n.env.NODE_ENV)var a={},c=0;var s=r.bind(null,!1);return s.isRequired=r.bind(null,!0),s}function p(e){function n(n,t,r,o,i,u){var a=n[t];if(w(a)!==e)return new l("Invalid "+o+" `"+i+"` of type `"+E(a)+"` supplied to `"+r+"`, expected `"+e+"`.");return null}return f(n)}function d(e){function n(n,t,r,o,i){if("function"!=typeof e)return new l("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var a=n[t];if(!Array.isArray(a)){return new l("Invalid "+o+" `"+i+"` of type `"+w(a)+"` supplied to `"+r+"`, expected an array.")}for(var c=0;c<a.length;c++){var s=e(a,c,r,o,i+"["+c+"]",u);if(s instanceof Error)return s}return null}return f(n)}function y(e){function n(n,t,r,o,i){if(!(n[t]instanceof e)){var u=e.name||R;return new l("Invalid "+o+" `"+i+"` of type `"+x(n[t])+"` supplied to `"+r+"`, expected instance of `"+u+"`.")}return null}return f(n)}function h(e){function t(n,t,r,o,i){for(var u=n[t],a=0;a<e.length;a++)if(s(u,e[a]))return null;return new l("Invalid "+o+" `"+i+"` of value `"+u+"` supplied to `"+r+"`, expected one of "+JSON.stringify(e)+".")}return Array.isArray(e)?f(t):("production"!==n.env.NODE_ENV&&i(!1,"Invalid argument supplied to oneOf, expected an instance of array."),r.thatReturnsNull)}function v(e){function n(n,t,r,o,i){if("function"!=typeof e)return new l("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var a=n[t],c=w(a);if("object"!==c)return new l("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+r+"`, expected an object.");for(var s in a)if(a.hasOwnProperty(s)){var f=e(a,s,r,o,i+"."+s,u);if(f instanceof Error)return f}return null}return f(n)}function m(e){function t(n,t,r,o,i){for(var a=0;a<e.length;a++){if(null==(0,e[a])(n,t,r,o,i,u))return null}return new l("Invalid "+o+" `"+i+"` supplied to `"+r+"`.")}if(!Array.isArray(e))return"production"!==n.env.NODE_ENV&&i(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),r.thatReturnsNull;for(var o=0;o<e.length;o++){var a=e[o];if("function"!=typeof a)return i(!1,"Invalid argument supplid to oneOfType. Expected an array of check functions, but received %s at index %s.",T(a),o),r.thatReturnsNull}return f(t)}function b(e){function n(n,t,r,o,i){var a=n[t],c=w(a);if("object"!==c)return new l("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+r+"`, expected `object`.");for(var s in e){var f=e[s];if(f){var p=f(a,s,r,o,i+"."+s,u);if(p)return p}}return null}return f(n)}function O(n){switch(typeof n){case"number":case"string":case"undefined":return!0;case"boolean":return!n;case"object":if(Array.isArray(n))return n.every(O);if(null===n||e(n))return!0;var t=c(n);if(!t)return!1;var r,o=t.call(n);if(t!==n.entries){for(;!(r=o.next()).done;)if(!O(r.value))return!1}else for(;!(r=o.next()).done;){var i=r.value;if(i&&!O(i[1]))return!1}return!0;default:return!1}}function g(e,n){return"symbol"===e||("Symbol"===n["@@toStringTag"]||"function"==typeof Symbol&&n instanceof Symbol)}function w(e){var n=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":g(n,e)?"symbol":n}function E(e){if(void 0===e||null===e)return""+e;var n=w(e);if("object"===n){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return n}function T(e){var n=E(e);switch(n){case"array":case"object":return"an "+n;case"boolean":case"date":case"regexp":return"a "+n;default:return n}}function x(e){return e.constructor&&e.constructor.name?e.constructor.name:R}var P="function"==typeof Symbol&&Symbol.iterator,k="@@iterator",R="<<anonymous>>",_={array:p("array"),bool:p("boolean"),func:p("function"),number:p("number"),object:p("object"),string:p("string"),symbol:p("symbol"),any:function(){return f(r.thatReturnsNull)}(),arrayOf:d,element:function(){function n(n,t,r,o,i){var u=n[t];if(!e(u)){return new l("Invalid "+o+" `"+i+"` of type `"+w(u)+"` supplied to `"+r+"`, expected a single ReactElement.")}return null}return f(n)}(),instanceOf:y,node:function(){function e(e,n,t,r,o){return O(e[n])?null:new l("Invalid "+r+" `"+o+"` supplied to `"+t+"`, expected a ReactNode.")}return f(e)}(),objectOf:v,oneOf:h,oneOfType:m,shape:b};return l.prototype=Error.prototype,_.checkPropTypes=a,_.PropTypes=_,_}}).call(n,t(0))},function(e,n,t){"use strict";(function(n){function r(e,t,r,c,s){if("production"!==n.env.NODE_ENV)for(var l in e)if(e.hasOwnProperty(l)){var f;try{o("function"==typeof e[l],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",c||"React class",r,l),f=e[l](t,l,c,r,null,u)}catch(e){f=e}if(i(!f||f instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",c||"React class",r,l,typeof f),f instanceof Error&&!(f.message in a)){a[f.message]=!0;var p=s?s():"";i(!1,"Failed %s type: %s%s",r,f.message,null!=p?p:"")}}}if("production"!==n.env.NODE_ENV)var o=t(2),i=t(4),u=t(3),a={};e.exports=r}).call(n,t(0))},function(e,n,t){"use strict";var r=t(1),o=t(2),i=t(3);e.exports=function(){function e(e,n,t,r,u,a){a!==i&&o(!1,"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")}function n(){return e}e.isRequired=e;var t={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:n,element:e,instanceOf:n,node:e,objectOf:n,oneOf:n,oneOfType:n,shape:n};return t.checkPropTypes=r,t.PropTypes=t,t}}])});
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("React"),require("ReactDOM")):"function"==typeof define&&define.amd?define(["React","ReactDOM"],n):"object"==typeof exports?exports.portal=n(require("React"),require("ReactDOM")):e.portal=n(e.React,e.ReactDOM)}(this,function(e,n){return function(e){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}var t={};return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get: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,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="/Users/vitor/projetos/globocom/react-portal/dist",n(n.s=5)}([function(e,n){function t(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(e){if(l===setTimeout)return setTimeout(e,0);if((l===t||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(n){try{return l.call(null,e,0)}catch(n){return l.call(this,e,0)}}}function i(e){if(f===clearTimeout)return clearTimeout(e);if((f===r||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(n){try{return f.call(null,e)}catch(n){return f.call(this,e)}}}function u(){h&&d&&(h=!1,d.length?y=d.concat(y):v=-1,y.length&&a())}function a(){if(!h){var e=o(u);h=!0;for(var n=y.length;n;){for(d=y,y=[];++v<n;)d&&d[v].run();v=-1,n=y.length}d=null,h=!1,i(e)}}function s(e,n){this.fun=e,this.array=n}function c(){}var l,f,p=e.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:t}catch(e){l=t}try{f="function"==typeof clearTimeout?clearTimeout:r}catch(e){f=r}}();var d,y=[],h=!1,v=-1;p.nextTick=function(e){var n=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)n[t-1]=arguments[t];y.push(new s(e,n)),1!==y.length||h||o(a)},s.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=c,p.addListener=c,p.once=c,p.off=c,p.removeListener=c,p.removeAllListeners=c,p.emit=c,p.prependListener=c,p.prependOnceListener=c,p.listeners=function(e){return[]},p.binding=function(e){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(e){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(e,n,t){"use strict";function r(e){return function(){return e}}var o=function(){};o.thatReturns=r,o.thatReturnsFalse=r(!1),o.thatReturnsTrue=r(!0),o.thatReturnsNull=r(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},function(e,n,t){"use strict";(function(n){function t(e,n,t,o,i,u,a,s){if(r(n),!e){var c;if(void 0===n)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[t,o,i,u,a,s],f=0;c=new Error(n.replace(/%s/g,function(){return l[f++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}}var r=function(e){};"production"!==n.env.NODE_ENV&&(r=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")}),e.exports=t}).call(n,t(0))},function(e,n,t){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,n,t){"use strict";(function(n){var r=t(1),o=r;if("production"!==n.env.NODE_ENV){var i=function(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;r<n;r++)t[r-1]=arguments[r];var o=0,i="Warning: "+e.replace(/%s/g,function(){return t[o++]});"undefined"!=typeof console&&console.error(i);try{throw new Error(i)}catch(e){}};o=function(e,n){if(void 0===n)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==n.indexOf("Failed Composite propType: ")&&!e){for(var t=arguments.length,r=Array(t>2?t-2:0),o=2;o<t;o++)r[o-2]=arguments[o];i.apply(void 0,[n].concat(r))}}}e.exports=o}).call(n,t(0))},function(e,n,t){e.exports=t(6)},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function i(e,n){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!n||"object"!=typeof n&&"function"!=typeof n?e:n}function u(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function, not "+typeof n);e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),n&&(Object.setPrototypeOf?Object.setPrototypeOf(e,n):e.__proto__=n)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var a=function(){function e(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(n,t,r){return t&&e(n.prototype,t),r&&e(n,r),n}}(),s=t(7),c=r(s),l=t(8),f=r(l),p=t(9),d=r(p),y={ESCAPE:27},h=function(e){function n(e){o(this,n);var t=i(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.closePortal=t.closePortal.bind(t),t.handleOutsideMouseClick=t.handleOutsideMouseClick.bind(t),t.handleKeydown=t.handleKeydown.bind(t),t.portal=null,t.node=null,t}return u(n,e),a(n,[{key:"componentDidMount",value:function(){this.props.closeOnEsc&&document.addEventListener("keydown",this.handleKeydown),this.props.closeOnOutsideClick&&(document.addEventListener("mouseup",this.handleOutsideMouseClick),document.addEventListener("touchstart",this.handleOutsideMouseClick))}},{key:"componentDidUpdate",value:function(e){this.props.isOpen?this.renderPortal():e.isOpen&&this.closePortal()}},{key:"componentWillUnmount",value:function(){this.props.closeOnEsc&&document.removeEventListener("keydown",this.handleKeydown),this.props.closeOnOutsideClick&&(document.removeEventListener("mouseup",this.handleOutsideMouseClick),document.removeEventListener("touchstart",this.handleOutsideMouseClick)),this.closePortal(!0)}},{key:"handleOutsideMouseClick",value:function(e){if(this.props.isOpen){(0,l.findDOMNode)(this.portal).contains(e.target)||e.button&&0!==e.button||(e.stopPropagation(),this.props.onClose())}}},{key:"handleKeydown",value:function(e){e.keyCode===y.ESCAPE&&this.props.isOpen&&this.props.onClose()}},{key:"closePortal",value:function(){this.node&&(f.default.unmountComponentAtNode(this.node),document.body.removeChild(this.node)),this.portal=null,this.node=null}},{key:"renderPortal",value:function(){this.node||(this.node=document.createElement("div"),document.body.appendChild(this.node));var e=this.props.children;"function"==typeof e.type&&(e=c.default.cloneElement(e,{closePortal:this.props.onClose})),this.portal=f.default.unstable_renderSubtreeIntoContainer(this,e,this.node,this.props.onUpdate)}},{key:"render",value:function(){return null}}]),n}(c.default.Component);n.default=h,h.propTypes={children:d.default.element.isRequired,closeOnEsc:d.default.bool,closeOnOutsideClick:d.default.bool,isOpen:d.default.bool,onClose:d.default.func,onUpdate:d.default.func},h.defaultProps={onClose:function(){},onUpdate:function(){}}},function(n,t){n.exports=e},function(e,t){e.exports=n},function(e,n,t){(function(n){if("production"!==n.env.NODE_ENV){var r="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,o=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r};e.exports=t(10)(o,!0)}else e.exports=t(12)()}).call(n,t(0))},function(e,n,t){"use strict";(function(n){var r=t(1),o=t(2),i=t(4),u=t(3),a=t(11);e.exports=function(e,t){function s(e){var n=e&&(P&&e[P]||e[k]);if("function"==typeof n)return n}function c(e,n){return e===n?0!==e||1/e==1/n:e!==e&&n!==n}function l(e){this.message=e,this.stack=""}function f(e){function r(r,c,f,p,d,y,h){if(p=p||R,y=y||f,h!==u)if(t)o(!1,"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");else if("production"!==n.env.NODE_ENV&&"undefined"!=typeof console){var v=p+":"+f;!a[v]&&s<3&&(i(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",y,p),a[v]=!0,s++)}return null==c[f]?r?new l(null===c[f]?"The "+d+" `"+y+"` is marked as required in `"+p+"`, but its value is `null`.":"The "+d+" `"+y+"` is marked as required in `"+p+"`, but its value is `undefined`."):null:e(c,f,p,d,y)}if("production"!==n.env.NODE_ENV)var a={},s=0;var c=r.bind(null,!1);return c.isRequired=r.bind(null,!0),c}function p(e){function n(n,t,r,o,i,u){var a=n[t];if(w(a)!==e)return new l("Invalid "+o+" `"+i+"` of type `"+E(a)+"` supplied to `"+r+"`, expected `"+e+"`.");return null}return f(n)}function d(e){function n(n,t,r,o,i){if("function"!=typeof e)return new l("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var a=n[t];if(!Array.isArray(a)){return new l("Invalid "+o+" `"+i+"` of type `"+w(a)+"` supplied to `"+r+"`, expected an array.")}for(var s=0;s<a.length;s++){var c=e(a,s,r,o,i+"["+s+"]",u);if(c instanceof Error)return c}return null}return f(n)}function y(e){function n(n,t,r,o,i){if(!(n[t]instanceof e)){var u=e.name||R;return new l("Invalid "+o+" `"+i+"` of type `"+x(n[t])+"` supplied to `"+r+"`, expected instance of `"+u+"`.")}return null}return f(n)}function h(e){function t(n,t,r,o,i){for(var u=n[t],a=0;a<e.length;a++)if(c(u,e[a]))return null;return new l("Invalid "+o+" `"+i+"` of value `"+u+"` supplied to `"+r+"`, expected one of "+JSON.stringify(e)+".")}return Array.isArray(e)?f(t):("production"!==n.env.NODE_ENV&&i(!1,"Invalid argument supplied to oneOf, expected an instance of array."),r.thatReturnsNull)}function v(e){function n(n,t,r,o,i){if("function"!=typeof e)return new l("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var a=n[t],s=w(a);if("object"!==s)return new l("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+r+"`, expected an object.");for(var c in a)if(a.hasOwnProperty(c)){var f=e(a,c,r,o,i+"."+c,u);if(f instanceof Error)return f}return null}return f(n)}function m(e){function t(n,t,r,o,i){for(var a=0;a<e.length;a++){if(null==(0,e[a])(n,t,r,o,i,u))return null}return new l("Invalid "+o+" `"+i+"` supplied to `"+r+"`.")}if(!Array.isArray(e))return"production"!==n.env.NODE_ENV&&i(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),r.thatReturnsNull;for(var o=0;o<e.length;o++){var a=e[o];if("function"!=typeof a)return i(!1,"Invalid argument supplid to oneOfType. Expected an array of check functions, but received %s at index %s.",T(a),o),r.thatReturnsNull}return f(t)}function b(e){function n(n,t,r,o,i){var a=n[t],s=w(a);if("object"!==s)return new l("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+r+"`, expected `object`.");for(var c in e){var f=e[c];if(f){var p=f(a,c,r,o,i+"."+c,u);if(p)return p}}return null}return f(n)}function O(n){switch(typeof n){case"number":case"string":case"undefined":return!0;case"boolean":return!n;case"object":if(Array.isArray(n))return n.every(O);if(null===n||e(n))return!0;var t=s(n);if(!t)return!1;var r,o=t.call(n);if(t!==n.entries){for(;!(r=o.next()).done;)if(!O(r.value))return!1}else for(;!(r=o.next()).done;){var i=r.value;if(i&&!O(i[1]))return!1}return!0;default:return!1}}function g(e,n){return"symbol"===e||("Symbol"===n["@@toStringTag"]||"function"==typeof Symbol&&n instanceof Symbol)}function w(e){var n=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":g(n,e)?"symbol":n}function E(e){if(void 0===e||null===e)return""+e;var n=w(e);if("object"===n){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return n}function T(e){var n=E(e);switch(n){case"array":case"object":return"an "+n;case"boolean":case"date":case"regexp":return"a "+n;default:return n}}function x(e){return e.constructor&&e.constructor.name?e.constructor.name:R}var P="function"==typeof Symbol&&Symbol.iterator,k="@@iterator",R="<<anonymous>>",_={array:p("array"),bool:p("boolean"),func:p("function"),number:p("number"),object:p("object"),string:p("string"),symbol:p("symbol"),any:function(){return f(r.thatReturnsNull)}(),arrayOf:d,element:function(){function n(n,t,r,o,i){var u=n[t];if(!e(u)){return new l("Invalid "+o+" `"+i+"` of type `"+w(u)+"` supplied to `"+r+"`, expected a single ReactElement.")}return null}return f(n)}(),instanceOf:y,node:function(){function e(e,n,t,r,o){return O(e[n])?null:new l("Invalid "+r+" `"+o+"` supplied to `"+t+"`, expected a ReactNode.")}return f(e)}(),objectOf:v,oneOf:h,oneOfType:m,shape:b};return l.prototype=Error.prototype,_.checkPropTypes=a,_.PropTypes=_,_}}).call(n,t(0))},function(e,n,t){"use strict";(function(n){function r(e,t,r,s,c){if("production"!==n.env.NODE_ENV)for(var l in e)if(e.hasOwnProperty(l)){var f;try{o("function"==typeof e[l],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",s||"React class",r,l),f=e[l](t,l,s,r,null,u)}catch(e){f=e}if(i(!f||f instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",s||"React class",r,l,typeof f),f instanceof Error&&!(f.message in a)){a[f.message]=!0;var p=c?c():"";i(!1,"Failed %s type: %s%s",r,f.message,null!=p?p:"")}}}if("production"!==n.env.NODE_ENV)var o=t(2),i=t(4),u=t(3),a={};e.exports=r}).call(n,t(0))},function(e,n,t){"use strict";var r=t(1),o=t(2),i=t(3);e.exports=function(){function e(e,n,t,r,u,a){a!==i&&o(!1,"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")}function n(){return e}e.isRequired=e;var t={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:n,element:e,instanceOf:n,node:e,objectOf:n,oneOf:n,oneOfType:n,shape:n};return t.checkPropTypes=r,t.PropTypes=t,t}}])});
//# sourceMappingURL=portal.js.map

@@ -129,3 +129,3 @@ 'use strict';

children = _react2.default.cloneElement(children, {
closePortal: this.closePortal
closePortal: this.props.onClose
});

@@ -159,5 +159,4 @@ }

Portal.defaultProps = {
onOpen: function onOpen() {},
onClose: function onClose() {},
onUpdate: function onUpdate() {}
};
{
"name": "react-portal-stateless",
"version": "1.0.0",
"version": "1.0.2",
"description": "React component for transportation of modals, lightboxes, loading bars... to document.body",

@@ -5,0 +5,0 @@ "main": "lib/portal.js",

@@ -1,7 +0,8 @@

React-portal
React-portal-stateless
============
[![npm version](https://img.shields.io/npm/v/react-portal.svg?style=flat-square)](https://www.npmjs.com/package/react-portal)
[![npm downloads](https://img.shields.io/npm/dm/react-portal.svg?style=flat-square)](https://www.npmjs.com/package/react-portal)
[![Build Status](https://travis-ci.org/tajo/react-portal.svg?branch=master)](https://travis-ci.org/tajo/react-portal)
[![npm version](https://img.shields.io/npm/v/react-portal.svg?style=flat-square)](https://www.npmjs.com/package/react-portal-stateless)
[![npm downloads](https://img.shields.io/npm/dm/react-portal.svg?style=flat-square)](https://www.npmjs.com/package/react-portal-stateless)
This Project is a fork of [React Portal](https://github.com/tajo/react-portal) that implement Stateless version of it.
> Struggling with modals, lightboxes or loading bars in React? React-portal creates a new top-level React tree and injects its child into it. That's necessary for proper styling (especially positioning).

@@ -16,4 +17,3 @@

- transports its child into a new React component and appends it to the **document.body** (creates a new independent React tree)
- can be opened by the prop **isOpened**
- can be opened after a click on an element that you pass through the prop **openByClickOn** (and then it takes care of the open/close state)
- can be opened by the prop **isOpen**
- doesn't leave any mess in DOM after closing

@@ -24,3 +24,2 @@ - provides its child with **this.props.closePortal** callback

- **no dependencies**
- **fully covered by tests**

@@ -52,13 +51,33 @@ ## Demo

export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
isPortalOpen: true
};
}
onClose() {
this.setState({
isPortalOpen: false
});
}
onOpen() {
this.setState({
isPortalOpen: true
});
}
render() {
const button1 = <button>Open portal with pseudo modal</button>;
return (
<Portal closeOnEsc closeOnOutsideClick openByClickOn={button1}>
<PseudoModal>
<h2>Pseudo Modal</h2>
<p>This react component is appended to the document body.</p>
</PseudoModal>
</Portal>
<div>
<button onClick={() => this.onOpen}>Open Portal</button>
<Portal isOpen={this.state.isPortalOpen} closeOnEsc closeOnOutsideClick onClose={() => this.onClose}>
<PseudoModal>
<h2>Pseudo Modal</h2>
<p>This react component is appended to the document body.</p>
</PseudoModal>
</Portal>
</div>
);

@@ -91,15 +110,7 @@ }

### One of these two required
### Optional
#### isOpened : bool
*Renaming to `isOpen` is going to be released soon with the V4.*
#### isOpen : bool
If true, the portal is open. If false, the portal is closed. It's up to you to take care of the closing (aka taking care of the state). Don't use this prop if you want to make your life easier. Use openByClickOn instead!
#### openByClickOn : ReactElement
The second way how to open the portal. This element will be rendered by the portal immediately
with `onClick` handler that triggers portal opening. **How to close the portal then?** The portal provides its ported child with a callback `this.props.closePortal`. Or you can use built-in portal closing methods (closeOnEsc, ... more below). Notice that you don't have to deal with the open/close state (like when using the `isOpened` prop).
### Optional
#### closeOnEsc: bool

@@ -111,8 +122,2 @@ If true, the portal can be closed by the key ESC.

#### onOpen: func(DOMNode)
This callback is called when the portal is opened and rendered (useful for animating the DOMNode).
#### beforeClose: func(DOMNode, removeFromDOM)
This callback is called when the closing event is triggered but it prevents normal removal from the DOM. So, you can do some DOMNode animation first and then call removeFromDOM() that removes the portal from DOM.
#### onClose: func

@@ -148,19 +153,4 @@ This callback is called when the portal closes and after beforeClose.

Sometimes you need to open your portal (e.g. modal) automatically. There is no button to click on. No problem, because the portal has the `isOpened` prop, so you can just set it to `true` or `false`. However, then it's completely up to you to take care about the portal closing (ESC, outside click, no `this.props.closePortal` callback...).
Sometimes you need to open your portal (e.g. modal) automatically. There is no button to click on. No problem, because the portal has the `isOpen` prop, so you can just set it to `true` or `false`.
However, there is a nice trick how to make this happen even without `isOpened`:
```jsx
<Portal ref="myPortal">
<PseudoModal title="My modal">
Modal content
</PseudoModal>
</Portal>
```
```jsx
this.refs.myPortal.openPortal()
// opens the portal, yay!
```
## Contribution

@@ -184,3 +174,3 @@

## Credits
## Credits (Forked from)

@@ -190,1 +180,4 @@ Inspired by the talk [React.js Conf 2015 - Hype!, Ryan Florence](https://www.youtube.com/watch?v=z5e7kWSHWTg)

Vojtech Miksu 2015, [miksu.cz](https://miksu.cz), [@vmiksu](https://twitter.com/vmiksu)
### Credits
Victor Arêas 2017

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