react-popout
Advanced tools
Comparing version 3.0.2 to 3.0.3
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"),require("react-dom"));else if("function"==typeof define&&define.amd)define(["react","react-dom"],t);else{var n="object"==typeof exports?t(require("react"),require("react-dom")):t(e.React,e.ReactDOM);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}("undefined"!=typeof self?self:this,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(e){if(f===setTimeout)return setTimeout(e,0);if((f===n||!f)&&setTimeout)return f=setTimeout,setTimeout(e,0);try{return f(e,0)}catch(t){try{return f.call(null,e,0)}catch(t){return f.call(this,e,0)}}}function i(e){if(l===clearTimeout)return clearTimeout(e);if((l===r||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(e);try{return l(e)}catch(t){try{return l.call(null,e)}catch(t){return l.call(this,e)}}}function a(){m&&d&&(m=!1,d.length?y=d.concat(y):h=-1,y.length&&u())}function u(){if(!m){var e=o(a);m=!0;for(var t=y.length;t;){for(d=y,y=[];++h<t;)d&&d[h].run();h=-1,t=y.length}d=null,m=!1,i(e)}}function c(e,t){this.fun=e,this.array=t}function s(){}var f,l,p=e.exports={};!function(){try{f="function"==typeof setTimeout?setTimeout:n}catch(e){f=n}try{l="function"==typeof clearTimeout?clearTimeout:r}catch(e){l=r}}();var d,y=[],m=!1,h=-1;p.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];y.push(new c(e,t)),1!==y.length||m||o(u)},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,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";(function(t){"production"===t.env.NODE_ENV?e.exports=n(10):e.exports=n(11)}).call(t,n(0))},function(e,t){e.exports=Function.call.bind(Object.prototype.hasOwnProperty)},function(e,t,n){e.exports=n(5)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(6),s=r(c),f=n(7),l=n(9),p=r(l),d={toolbar:"no",location:"no",directories:"no",status:"no",menubar:"no",scrollbars:"yes",resizable:"yes",width:500,height:400,top:function(e,t){return(t.innerHeight-e.height)/2+t.screenY},left:function(e,t){return(t.innerWidth-e.width)/2+t.screenX}},y=function(e){function t(e){o(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.mainWindowClosed=n.mainWindowClosed.bind(n),n.popoutWindowUnloading=n.popoutWindowUnloading.bind(n),n.popoutWindowLoaded=n.popoutWindowLoaded.bind(n),n.state={openedWindowComponent:null,popoutWindow:null,container:null},n}return a(t,e),u(t,[{key:"createOptions",value:function(e){var t=this,n=Object.assign({},d,this.props.options);return Object.keys(n).map(function(r){return r+"="+("function"==typeof n[r]?n[r].call(t,n,e):n[r])}).join(",")}},{key:"componentDidMount",value:function(){var e=this.props.window||window;e&&(this.openPopoutWindow(e),e.addEventListener("unload",this.mainWindowClosed))}},{key:"componentWillReceiveProps",value:function(e){e.title!==this.props.title&&this.state.popoutWindow&&(this.state.popoutWindow.document.title=e.title)}},{key:"componentDidUpdate",value:function(){this.renderToContainer(this.state.container,this.state.popoutWindow,this.props.children)}},{key:"componentWillUnmount",value:function(){this.mainWindowClosed()}},{key:"popoutWindowLoaded",value:function(e){if(!this.state.container){e=this.state.popoutWindow||e,e.document.title=this.props.title;var t=e.document.createElement("div");t.id=this.props.containerId,t.className=this.props.containerClassName,e.document.body.appendChild(t),this.setState({container:t}),this.renderToContainer(t,e,this.props.children)}}},{key:"openPopoutWindow",value:function(e){var t=e.open(this.props.url,this.props.name||this.props.title,this.createOptions(e));if(!t)return void this.props.onError();this.setState({popoutWindow:t}),t.addEventListener("load",this.popoutWindowLoaded),t.addEventListener("unload",this.popoutWindowUnloading),"about:blank"===this.props.url?"complete"===t.document.readyState&&this.popoutWindowLoaded(t):this.checkForPopoutWindowClosure(t)}},{key:"closeWindow",value:function(){this.mainWindowClosed()}},{key:"checkForPopoutWindowClosure",value:function(e){var t=this;this.interval=setInterval(function(){e.closed&&(clearInterval(t.interval),t.props.onClosing&&t.props.onClosing())},500)}},{key:"mainWindowClosed",value:function(){this.state.popoutWindow&&this.state.popoutWindow.close(),(this.props.window||window).removeEventListener("unload",this.mainWindowClosed)}},{key:"popoutWindowUnloading",value:function(){this.state.container&&(clearInterval(this.interval),this.root.unmount(this.state.container),this.props.onClosing&&this.props.onClosing())}},{key:"renderToContainer",value:function(e,t,n){if(e){var r=n;"function"==typeof n&&(r=n(t)),this.root||(this.root=(0,f.createRoot)(e)),this.root.render(r)}}},{key:"render",value:function(){return null}}]),t}(s.default.Component);y.defaultProps={url:"about:blank",containerId:"popout-content-container",containerClassName:"",onError:function(){}},y.propTypes={title:p.default.string.isRequired,url:p.default.string,onClosing:p.default.func,options:p.default.object,window:p.default.object,containerId:p.default.string,containerClassName:p.default.string,children:p.default.oneOfType([p.default.element,p.default.func]),onError:p.default.func},t.default=y},function(t,n){t.exports=e},function(e,t,n){"use strict";(function(e){var r=n(8);if("production"===e.env.NODE_ENV)t.createRoot=r.createRoot,t.hydrateRoot=r.hydrateRoot;else{var o=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;t.createRoot=function(e,t){o.usingClientEntryPoint=!0;try{return r.createRoot(e,t)}finally{o.usingClientEntryPoint=!1}},t.hydrateRoot=function(e,t,n){o.usingClientEntryPoint=!0;try{return r.hydrateRoot(e,t,n)}finally{o.usingClientEntryPoint=!1}}}}).call(t,n(0))},function(e,n){e.exports=t},function(e,t,n){(function(t){if("production"!==t.env.NODE_ENV){var r=n(2);e.exports=n(12)(r.isElement,!0)}else e.exports=n(15)()}).call(t,n(0))},function(e,t,n){"use strict";function r(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case a:switch(e=e.type){case d:case y:case c:case f:case s:case h:return e;default:switch(e=e&&e.$$typeof){case p:case m:case w:case b:case l:return e;default:return t}}case u:return t}}}function o(e){return r(e)===y}/** @license React v16.13.1 | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"),require("react-dom"));else if("function"==typeof define&&define.amd)define(["react","react-dom"],t);else{var n="object"==typeof exports?t(require("react"),require("react-dom")):t(e.React,e.ReactDOM);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}("undefined"!=typeof self?self:this,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(e){if(f===setTimeout)return setTimeout(e,0);if((f===n||!f)&&setTimeout)return f=setTimeout,setTimeout(e,0);try{return f(e,0)}catch(t){try{return f.call(null,e,0)}catch(t){return f.call(this,e,0)}}}function i(e){if(l===clearTimeout)return clearTimeout(e);if((l===r||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(e);try{return l(e)}catch(t){try{return l.call(null,e)}catch(t){return l.call(this,e)}}}function a(){m&&d&&(m=!1,d.length?y=d.concat(y):h=-1,y.length&&u())}function u(){if(!m){var e=o(a);m=!0;for(var t=y.length;t;){for(d=y,y=[];++h<t;)d&&d[h].run();h=-1,t=y.length}d=null,m=!1,i(e)}}function c(e,t){this.fun=e,this.array=t}function s(){}var f,l,p=e.exports={};!function(){try{f="function"==typeof setTimeout?setTimeout:n}catch(e){f=n}try{l="function"==typeof clearTimeout?clearTimeout:r}catch(e){l=r}}();var d,y=[],m=!1,h=-1;p.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];y.push(new c(e,t)),1!==y.length||m||o(u)},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,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";(function(t){"production"===t.env.NODE_ENV?e.exports=n(10):e.exports=n(11)}).call(t,n(0))},function(e,t){e.exports=Function.call.bind(Object.prototype.hasOwnProperty)},function(e,t,n){e.exports=n(5)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(6),s=r(c),f=n(7),l=n(9),p=r(l),d={toolbar:"no",location:"no",directories:"no",status:"no",menubar:"no",scrollbars:"yes",resizable:"yes",width:500,height:400,top:function(e,t){return(t.innerHeight-e.height)/2+t.screenY},left:function(e,t){return(t.innerWidth-e.width)/2+t.screenX}},y=function(e){function t(e){o(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.mainWindowClosed=n.mainWindowClosed.bind(n),n.popoutWindowUnloading=n.popoutWindowUnloading.bind(n),n.popoutWindowLoaded=n.popoutWindowLoaded.bind(n),n.state={openedWindowComponent:null,popoutWindow:null,container:null},n}return a(t,e),u(t,[{key:"createOptions",value:function(e){var t=this,n=Object.assign({},d,this.props.options);return Object.keys(n).map(function(r){return r+"="+("function"==typeof n[r]?n[r].call(t,n,e):n[r])}).join(",")}},{key:"componentDidMount",value:function(){var e=this.props.window||window;e&&(this.openPopoutWindow(e),e.addEventListener("unload",this.mainWindowClosed))}},{key:"componentWillReceiveProps",value:function(e){e.title!==this.props.title&&this.state.popoutWindow&&(this.state.popoutWindow.document.title=e.title)}},{key:"componentDidUpdate",value:function(){this.renderToContainer(this.state.container,this.state.popoutWindow,this.props.children)}},{key:"componentWillUnmount",value:function(){this.mainWindowClosed()}},{key:"popoutWindowLoaded",value:function(e){if(!this.state.container){e=this.state.popoutWindow||e,e.document.title=this.props.title;var t=e.document.createElement("div");t.id=this.props.containerId,t.className=this.props.containerClassName,e.document.body.appendChild(t),this.setState({container:t}),this.renderToContainer(t,e,this.props.children)}}},{key:"openPopoutWindow",value:function(e){var t=e.open(this.props.url,this.props.name||this.props.title,this.createOptions(e));if(!t)return void this.props.onError();this.setState({popoutWindow:t}),t.addEventListener("load",this.popoutWindowLoaded),t.addEventListener("unload",this.popoutWindowUnloading),"about:blank"===this.props.url?"complete"===t.document.readyState&&this.popoutWindowLoaded(t):this.checkForPopoutWindowClosure(t)}},{key:"closeWindow",value:function(){this.mainWindowClosed()}},{key:"checkForPopoutWindowClosure",value:function(e){var t=this;this.interval=setInterval(function(){e.closed&&(clearInterval(t.interval),t.props.onClosing&&t.props.onClosing(e))},500)}},{key:"mainWindowClosed",value:function(){this.state.popoutWindow&&this.state.popoutWindow.close(),(this.props.window||window).removeEventListener("unload",this.mainWindowClosed)}},{key:"popoutWindowUnloading",value:function(){this.state.container&&(clearInterval(this.interval),this.root.unmount(this.state.container),this.props.onClosing&&this.props.onClosing())}},{key:"renderToContainer",value:function(e,t,n){if(e){var r=n;"function"==typeof n&&(r=n(t)),this.root||(this.root=(0,f.createRoot)(e)),this.root.render(r)}}},{key:"render",value:function(){return null}}]),t}(s.default.Component);y.defaultProps={url:"about:blank",containerId:"popout-content-container",containerClassName:"",onError:function(){}},y.propTypes={title:p.default.string.isRequired,url:p.default.string,onClosing:p.default.func,options:p.default.object,window:p.default.object,containerId:p.default.string,containerClassName:p.default.string,children:p.default.oneOfType([p.default.element,p.default.func]),onError:p.default.func},t.default=y},function(t,n){t.exports=e},function(e,t,n){"use strict";(function(e){var r=n(8);if("production"===e.env.NODE_ENV)t.createRoot=r.createRoot,t.hydrateRoot=r.hydrateRoot;else{var o=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;t.createRoot=function(e,t){o.usingClientEntryPoint=!0;try{return r.createRoot(e,t)}finally{o.usingClientEntryPoint=!1}},t.hydrateRoot=function(e,t,n){o.usingClientEntryPoint=!0;try{return r.hydrateRoot(e,t,n)}finally{o.usingClientEntryPoint=!1}}}}).call(t,n(0))},function(e,n){e.exports=t},function(e,t,n){(function(t){if("production"!==t.env.NODE_ENV){var r=n(2);e.exports=n(12)(r.isElement,!0)}else e.exports=n(15)()}).call(t,n(0))},function(e,t,n){"use strict";function r(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case a:switch(e=e.type){case d:case y:case c:case f:case s:case h:return e;default:switch(e=e&&e.$$typeof){case p:case m:case w:case b:case l:return e;default:return t}}case u:return t}}}function o(e){return r(e)===y}/** @license React v16.13.1 | ||
* react-is.production.min.js | ||
@@ -3,0 +3,0 @@ * |
@@ -0,0 +0,0 @@ { |
@@ -160,3 +160,3 @@ import React from 'react'; | ||
clearInterval(this.interval); | ||
this.props.onClosing && this.props.onClosing(); | ||
this.props.onClosing && this.props.onClosing(popoutWindow); | ||
} | ||
@@ -163,0 +163,0 @@ }, 500); |
{ | ||
"name": "react-popout", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "Wraps window.open in a react component, allowing the contents to be part of your react render tree", | ||
@@ -5,0 +5,0 @@ "main": "dist/react-popout.min.js", |
@@ -0,0 +0,0 @@ # react-popout |
@@ -0,0 +0,0 @@ describe('', () => { |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
Sorry, the diff of this file is not supported yet
28
249000