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

react-new-window

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-new-window - npm Package Compare versions

Comparing version 0.1.3 to 0.2.1

17

es/react-new-window.js

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

import React from"react";import ReactDOM from"react-dom";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var classCallCheck=_classCallCheck;function _defineProperties(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}var createClass=_createClass;function unwrapExports(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var _typeof_1=createCommonjsModule(function(e){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(o){return"function"==typeof Symbol&&"symbol"===t(Symbol.iterator)?e.exports=n=function(e){return t(e)}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":t(e)},n(o)}e.exports=n});function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var assertThisInitialized=_assertThisInitialized;function _possibleConstructorReturn(e,t){return!t||"object"!==_typeof_1(t)&&"function"!=typeof t?assertThisInitialized(e):t}var possibleConstructorReturn=_possibleConstructorReturn,getPrototypeOf=createCommonjsModule(function(e){function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},t(n)}e.exports=t}),setPrototypeOf=createCommonjsModule(function(e){function t(n,o){return e.exports=t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t(n,o)}e.exports=t});function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&setPrototypeOf(e,t)}var inherits=_inherits;function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var defineProperty=_defineProperty,reactIs_production_min=createCommonjsModule(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&Symbol.for,o=n?Symbol.for("react.element"):60103,r=n?Symbol.for("react.portal"):60106,i=n?Symbol.for("react.fragment"):60107,c=n?Symbol.for("react.strict_mode"):60108,s=n?Symbol.for("react.profiler"):60114,a=n?Symbol.for("react.provider"):60109,p=n?Symbol.for("react.context"):60110,u=n?Symbol.for("react.async_mode"):60111,l=n?Symbol.for("react.concurrent_mode"):60111,d=n?Symbol.for("react.forward_ref"):60112,_=n?Symbol.for("react.suspense"):60113,m=n?Symbol.for("react.memo"):60115,f=n?Symbol.for("react.lazy"):60116;function y(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case o:switch(e=e.type){case u:case l:case i:case s:case c:case _:return e;default:switch(e=e&&e.$$typeof){case p:case d:case a:return e;default:return t}}case f:case m:case r:return t}}}function h(e){return y(e)===l}t.typeOf=y,t.AsyncMode=u,t.ConcurrentMode=l,t.ContextConsumer=p,t.ContextProvider=a,t.Element=o,t.ForwardRef=d,t.Fragment=i,t.Lazy=f,t.Memo=m,t.Portal=r,t.Profiler=s,t.StrictMode=c,t.Suspense=_,t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===l||e===s||e===c||e===_||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===m||e.$$typeof===a||e.$$typeof===p||e.$$typeof===d)},t.isAsyncMode=function(e){return h(e)||y(e)===u},t.isConcurrentMode=h,t.isContextConsumer=function(e){return y(e)===p},t.isContextProvider=function(e){return y(e)===a},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===o},t.isForwardRef=function(e){return y(e)===d},t.isFragment=function(e){return y(e)===i},t.isLazy=function(e){return y(e)===f},t.isMemo=function(e){return y(e)===m},t.isPortal=function(e){return y(e)===r},t.isProfiler=function(e){return y(e)===s},t.isStrictMode=function(e){return y(e)===c},t.isSuspense=function(e){return y(e)===_}});unwrapExports(reactIs_production_min);var reactIs_production_min_1=reactIs_production_min.typeOf,reactIs_production_min_2=reactIs_production_min.AsyncMode,reactIs_production_min_3=reactIs_production_min.ConcurrentMode,reactIs_production_min_4=reactIs_production_min.ContextConsumer,reactIs_production_min_5=reactIs_production_min.ContextProvider,reactIs_production_min_6=reactIs_production_min.Element,reactIs_production_min_7=reactIs_production_min.ForwardRef,reactIs_production_min_8=reactIs_production_min.Fragment,reactIs_production_min_9=reactIs_production_min.Lazy,reactIs_production_min_10=reactIs_production_min.Memo,reactIs_production_min_11=reactIs_production_min.Portal,reactIs_production_min_12=reactIs_production_min.Profiler,reactIs_production_min_13=reactIs_production_min.StrictMode,reactIs_production_min_14=reactIs_production_min.Suspense,reactIs_production_min_15=reactIs_production_min.isValidElementType,reactIs_production_min_16=reactIs_production_min.isAsyncMode,reactIs_production_min_17=reactIs_production_min.isConcurrentMode,reactIs_production_min_18=reactIs_production_min.isContextConsumer,reactIs_production_min_19=reactIs_production_min.isContextProvider,reactIs_production_min_20=reactIs_production_min.isElement,reactIs_production_min_21=reactIs_production_min.isForwardRef,reactIs_production_min_22=reactIs_production_min.isFragment,reactIs_production_min_23=reactIs_production_min.isLazy,reactIs_production_min_24=reactIs_production_min.isMemo,reactIs_production_min_25=reactIs_production_min.isPortal,reactIs_production_min_26=reactIs_production_min.isProfiler,reactIs_production_min_27=reactIs_production_min.isStrictMode,reactIs_production_min_28=reactIs_production_min.isSuspense,reactIs_development=createCommonjsModule(function(e,t){});unwrapExports(reactIs_development);var reactIs_development_1=reactIs_development.typeOf,reactIs_development_2=reactIs_development.AsyncMode,reactIs_development_3=reactIs_development.ConcurrentMode,reactIs_development_4=reactIs_development.ContextConsumer,reactIs_development_5=reactIs_development.ContextProvider,reactIs_development_6=reactIs_development.Element,reactIs_development_7=reactIs_development.ForwardRef,reactIs_development_8=reactIs_development.Fragment,reactIs_development_9=reactIs_development.Lazy,reactIs_development_10=reactIs_development.Memo,reactIs_development_11=reactIs_development.Portal,reactIs_development_12=reactIs_development.Profiler,reactIs_development_13=reactIs_development.StrictMode,reactIs_development_14=reactIs_development.Suspense,reactIs_development_15=reactIs_development.isValidElementType,reactIs_development_16=reactIs_development.isAsyncMode,reactIs_development_17=reactIs_development.isConcurrentMode,reactIs_development_18=reactIs_development.isContextConsumer,reactIs_development_19=reactIs_development.isContextProvider,reactIs_development_20=reactIs_development.isElement,reactIs_development_21=reactIs_development.isForwardRef,reactIs_development_22=reactIs_development.isFragment,reactIs_development_23=reactIs_development.isLazy,reactIs_development_24=reactIs_development.isMemo,reactIs_development_25=reactIs_development.isPortal,reactIs_development_26=reactIs_development.isProfiler,reactIs_development_27=reactIs_development.isStrictMode,reactIs_development_28=reactIs_development.isSuspense,reactIs=createCommonjsModule(function(e){e.exports=reactIs_production_min}),getOwnPropertySymbols=Object.getOwnPropertySymbols,hasOwnProperty=Object.prototype.hasOwnProperty,propIsEnumerable=Object.prototype.propertyIsEnumerable;function toObject(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function shouldUseNative(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(e){o[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}}var objectAssign=shouldUseNative()?Object.assign:function(e,t){for(var n,o,r=toObject(e),i=1;i<arguments.length;i++){for(var c in n=Object(arguments[i]))hasOwnProperty.call(n,c)&&(r[c]=n[c]);if(getOwnPropertySymbols){o=getOwnPropertySymbols(n);for(var s=0;s<o.length;s++)propIsEnumerable.call(n,o[s])&&(r[o[s]]=n[o[s]])}}return r},ReactPropTypesSecret="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",ReactPropTypesSecret_1=ReactPropTypesSecret,has$1=Function.call.bind(Object.prototype.hasOwnProperty);function emptyFunction(){}function emptyFunctionWithReset(){}emptyFunctionWithReset.resetWarningCache=emptyFunction;var factoryWithThrowingShims=function(){function e(e,t,n,o,r,i){if(i!==ReactPropTypesSecret_1){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:emptyFunctionWithReset,resetWarningCache:emptyFunction};return n.PropTypes=n,n},propTypes=createCommonjsModule(function(e){e.exports=factoryWithThrowingShims()}),NewWindow=function(e){function t(e){var n;return classCallCheck(this,t),(n=possibleConstructorReturn(this,getPrototypeOf(t).call(this,e))).container=null,n.window=null,n.windowCheckerInterval=null,n.released=!1,n.state={mounted:!1},n}return inherits(t,e),createClass(t,[{key:"render",value:function(){return this.state.mounted?ReactDOM.createPortal(this.props.children,this.container):null}},{key:"componentDidMount",value:function(){this.openChild(),this.setState({mounted:!0})}},{key:"openChild",value:function(){var e=this,t=this.props,n=t.url,o=t.title,r=t.name,i=t.features,c=t.onBlock,s=t.onOpen,a=t.center;if("string"!=typeof a||void 0!==i.width&&void 0!==i.height){if("parent"===a)i.left=window.top.outerWidth/2+window.top.screenX-i.width/2,i.top=window.top.outerHeight/2+window.top.screenY-i.height/2;else if("screen"===a){var p=void 0!==window.screenLeft?window.screenLeft:window.screen.left,u=void 0!==window.screenTop?window.screenTop:window.screen.top,l=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:window.screen.width,d=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:window.screen.height;i.left=l/2-i.width/2+p,i.top=d/2-i.height/2+u}}else console.warn("width and height window features must be present when a center prop is provided");this.window=window.open(n,r,toWindowFeatures(i)),this.container=this.window.document.createElement("div"),this.windowCheckerInterval=setInterval(function(){e.window&&!e.window.closed||e.release()},50),this.window?(this.window.document.title=o,this.window.document.body.appendChild(this.container),this.props.copyStyles&&setTimeout(function(){return copyStyles(document,e.window.document)},0),"function"==typeof s&&s(this.window),this.window.addEventListener("beforeunload",function(){return e.release()})):"function"==typeof c?c(null):console.warn("A new window could not be opened. Maybe it was blocked.")}},{key:"componentWillUnmount",value:function(){this.window&&this.window.close()}},{key:"release",value:function(){if(!this.released){this.released=!0,clearInterval(this.windowCheckerInterval);var e=this.props.onUnload;"function"==typeof e&&e(null)}}}]),t}(React.PureComponent);function copyStyles(e,t){var n=t.createDocumentFragment();Array.from(e.styleSheets).forEach(function(e){var o;try{o=e.cssRules}catch(e){console.error(e)}if(o){var r=[];Array.from(e.cssRules).forEach(function(e){var t=e.type;if(t!==CSSRule.UNKNOWN_RULE){var n="";n=t===CSSRule.KEYFRAMES_RULE?getKeyFrameText(e):[CSSRule.IMPORT_RULE,CSSRule.FONT_FACE_RULE].includes(t)?fixUrlForRule(e):e.cssText,r.push(n)}});var i=t.createElement("style");i.textContent=r.join("\n"),n.appendChild(i)}else if(e.href){var c=t.createElement("link");c.rel="stylesheet",c.href=e.href,n.appendChild(c)}}),t.head.appendChild(n)}function getKeyFrameText(e){var t=["@keyframes",e.name,"{"];return Array.from(e.cssRules).forEach(function(e){t.push(e.keyText,"{",e.style.cssText,"}")}),t.push("}"),t.join(" ")}function fixUrlForRule(e){return e.cssText.split("url(").map(function(e){return"/"===e[1]?"".concat(e.slice(0,1)).concat(window.location.origin).concat(e.slice(1)):e}).join("url(")}function toWindowFeatures(e){return Object.keys(e).reduce(function(t,n){var o=e[n];return"boolean"==typeof o?t.push("".concat(n,"=").concat(o?"yes":"no")):t.push("".concat(n,"=").concat(o)),t},[]).join(",")}defineProperty(NewWindow,"defaultProps",{url:"",name:"",title:"",features:{width:"600px",height:"640px"},onBlock:null,onOpen:null,onUnload:null,center:"parent",copyStyles:!0}),NewWindow.propTypes={children:propTypes.node,url:propTypes.string,name:propTypes.string,title:propTypes.string,features:propTypes.object,onUnload:propTypes.func,onBlock:propTypes.func,onOpen:propTypes.func,center:propTypes.oneOf(["parent","screen"]),copyStyles:propTypes.bool};export default NewWindow;
import e from"react";import t from"react-dom";function n(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function o(e,t){return o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},o(e,t)}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}var s={exports:{}},u={};
/** @license React v16.8.6
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(u,"__esModule",{value:!0});var a="function"==typeof Symbol&&Symbol.for,l=a?Symbol.for("react.element"):60103,f=a?Symbol.for("react.portal"):60106,d=a?Symbol.for("react.fragment"):60107,p=a?Symbol.for("react.strict_mode"):60108,y=a?Symbol.for("react.profiler"):60114,h=a?Symbol.for("react.provider"):60109,w=a?Symbol.for("react.context"):60110,m=a?Symbol.for("react.async_mode"):60111,b=a?Symbol.for("react.concurrent_mode"):60111,v=a?Symbol.for("react.forward_ref"):60112,O=a?Symbol.for("react.suspense"):60113,S=a?Symbol.for("react.memo"):60115,g=a?Symbol.for("react.lazy"):60116;function j(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case l:switch(e=e.type){case m:case b:case d:case y:case p:case O:return e;default:switch(e=e&&e.$$typeof){case w:case v:case h:return e;default:return t}}case g:case S:case f:return t}}}function E(e){return j(e)===b}u.typeOf=j,u.AsyncMode=m,u.ConcurrentMode=b,u.ContextConsumer=w,u.ContextProvider=h,u.Element=l,u.ForwardRef=v,u.Fragment=d,u.Lazy=g,u.Memo=S,u.Portal=f,u.Profiler=y,u.StrictMode=p,u.Suspense=O,u.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===d||e===b||e===y||e===p||e===O||"object"==typeof e&&null!==e&&(e.$$typeof===g||e.$$typeof===S||e.$$typeof===h||e.$$typeof===w||e.$$typeof===v)},u.isAsyncMode=function(e){return E(e)||j(e)===m},u.isConcurrentMode=E,u.isContextConsumer=function(e){return j(e)===w},u.isContextProvider=function(e){return j(e)===h},u.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===l},u.isForwardRef=function(e){return j(e)===v},u.isFragment=function(e){return j(e)===d},u.isLazy=function(e){return j(e)===g},u.isMemo=function(e){return j(e)===S},u.isPortal=function(e){return j(e)===f},u.isProfiler=function(e){return j(e)===y},u.isStrictMode=function(e){return j(e)===p},u.isSuspense=function(e){return j(e)===O};
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;!function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;var o=Object.getOwnPropertyNames(t).map((function(e){return t[e]}));if("0123456789"!==o.join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()||Object.assign;Function.call.bind(Object.prototype.hasOwnProperty);function C(){}function P(){}P.resetWarningCache=C;s.exports=function(){function e(e,t,n,o,r,i){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==i){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:P,resetWarningCache:C};return n.PropTypes=n,n}();var _=s.exports;function R(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=c(e);if(t){var r=c(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return i(this,n)}}var k,T,x,$=function(r){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(a,e.PureComponent);var i,c,s,u=R(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=u.call(this,e)).container=null,t.window=null,t.windowCheckerInterval=null,t.released=!1,t.state={mounted:!1},t}return i=a,(c=[{key:"render",value:function(){return this.state.mounted?t.createPortal(this.props.children,this.container):null}},{key:"componentDidMount",value:function(){this.openChild(),this.setState({mounted:!0})}},{key:"openChild",value:function(){var e,t=this,n=this.props,o=n.url,r=n.title,i=n.name,c=n.features,s=n.onBlock,u=n.onOpen,a=n.center;if("string"!=typeof a||void 0!==c.width&&void 0!==c.height){if("parent"===a)c.left=window.top.outerWidth/2+window.top.screenX-c.width/2,c.top=window.top.outerHeight/2+window.top.screenY-c.height/2;else if("screen"===a){var l=void 0!==window.screenLeft?window.screenLeft:window.screen.left,f=void 0!==window.screenTop?window.screenTop:window.screen.top,d=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:window.screen.width,p=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:window.screen.height;c.left=d/2-c.width/2+l,c.top=p/2-c.height/2+f}}else console.warn("width and height window features must be present when a center prop is provided");if(this.window=window.open(o,i,(e=c,Object.keys(e).reduce((function(t,n){var o=e[n];return"boolean"==typeof o?t.push("".concat(n,"=").concat(o?"yes":"no")):t.push("".concat(n,"=").concat(o)),t}),[]).join(","))),this.container=this.window.document.createElement("div"),this.windowCheckerInterval=setInterval((function(){t.window&&!t.window.closed||t.release()}),50),this.window){if(this.window.document.title=r,this.container=this.window.document.getElementById("new-window-container"),null===this.container)this.container=this.window.document.createElement("div"),this.container.setAttribute("id","new-window-container"),this.window.document.body.appendChild(this.container);else{var y=this.window.document.getElementById("new-window-container-static");this.window.document.body.removeChild(y)}this.props.copyStyles&&setTimeout((function(){return e=document,n=t.window.document,o=n.createDocumentFragment(),Array.from(e.styleSheets).forEach((function(e){var t;try{t=e.cssRules}catch(e){console.error(e)}if(t){var r=[];Array.from(e.cssRules).forEach((function(e){var t=e.type;if(t!==CSSRule.UNKNOWN_RULE){var n="";n=t===CSSRule.KEYFRAMES_RULE?function(e){var t=["@keyframes",e.name,"{"];return Array.from(e.cssRules).forEach((function(e){t.push(e.keyText,"{",e.style.cssText,"}")})),t.push("}"),t.join(" ")}(e):[CSSRule.IMPORT_RULE,CSSRule.FONT_FACE_RULE].includes(t)?function(e){return e.cssText.split("url(").map((function(e){return"/"===e[1]?"".concat(e.slice(0,1)).concat(window.location.origin).concat(e.slice(1)):e})).join("url(")}(e):e.cssText,r.push(n)}}));var i=n.createElement("style");i.textContent=r.join("\n"),o.appendChild(i)}else if(e.href){var c=n.createElement("link");c.rel="stylesheet",c.href=e.href,o.appendChild(c)}})),void n.head.appendChild(o);var e,n,o}),0),"function"==typeof u&&u(this.window),this.window.addEventListener("beforeunload",(function(){return t.release()}))}else"function"==typeof s?s(null):console.warn("A new window could not be opened. Maybe it was blocked.")}},{key:"componentWillUnmount",value:function(){if(this.window)if(this.props.closeOnUnmount)this.window.close();else if(this.props.children){var e=this.container.cloneNode(!0);e.setAttribute("id","new-window-container-static"),this.window.document.body.appendChild(e)}}},{key:"release",value:function(){if(!this.released){this.released=!0,clearInterval(this.windowCheckerInterval);var e=this.props.onUnload;"function"==typeof e&&e(null)}}}])&&n(i.prototype,c),s&&n(i,s),a}();x={url:"",name:"",title:"",features:{width:"600px",height:"640px"},onBlock:null,onOpen:null,onUnload:null,center:"parent",copyStyles:!0,closeOnUnmount:!0},(T="defaultProps")in(k=$)?Object.defineProperty(k,T,{value:x,enumerable:!0,configurable:!0,writable:!0}):k[T]=x,$.propTypes={children:_.node,url:_.string,name:_.string,title:_.string,features:_.object,onUnload:_.func,onBlock:_.func,onOpen:_.func,center:_.oneOf(["parent","screen"]),copyStyles:_.bool,closeOnUnmount:_.bool};export{$ as default};
//# sourceMappingURL=react-new-window.js.map

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

"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=_interopDefault(require("react")),ReactDOM=_interopDefault(require("react-dom"));function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var classCallCheck=_classCallCheck;function _defineProperties(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}var createClass=_createClass;function unwrapExports(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var _typeof_1=createCommonjsModule(function(e){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(o){return"function"==typeof Symbol&&"symbol"===t(Symbol.iterator)?e.exports=n=function(e){return t(e)}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":t(e)},n(o)}e.exports=n});function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var assertThisInitialized=_assertThisInitialized;function _possibleConstructorReturn(e,t){return!t||"object"!==_typeof_1(t)&&"function"!=typeof t?assertThisInitialized(e):t}var possibleConstructorReturn=_possibleConstructorReturn,getPrototypeOf=createCommonjsModule(function(e){function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},t(n)}e.exports=t}),setPrototypeOf=createCommonjsModule(function(e){function t(n,o){return e.exports=t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t(n,o)}e.exports=t});function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&setPrototypeOf(e,t)}var inherits=_inherits;function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var defineProperty=_defineProperty,reactIs_production_min=createCommonjsModule(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&Symbol.for,o=n?Symbol.for("react.element"):60103,r=n?Symbol.for("react.portal"):60106,i=n?Symbol.for("react.fragment"):60107,c=n?Symbol.for("react.strict_mode"):60108,s=n?Symbol.for("react.profiler"):60114,a=n?Symbol.for("react.provider"):60109,p=n?Symbol.for("react.context"):60110,u=n?Symbol.for("react.async_mode"):60111,l=n?Symbol.for("react.concurrent_mode"):60111,d=n?Symbol.for("react.forward_ref"):60112,_=n?Symbol.for("react.suspense"):60113,m=n?Symbol.for("react.memo"):60115,f=n?Symbol.for("react.lazy"):60116;function y(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case o:switch(e=e.type){case u:case l:case i:case s:case c:case _:return e;default:switch(e=e&&e.$$typeof){case p:case d:case a:return e;default:return t}}case f:case m:case r:return t}}}function h(e){return y(e)===l}t.typeOf=y,t.AsyncMode=u,t.ConcurrentMode=l,t.ContextConsumer=p,t.ContextProvider=a,t.Element=o,t.ForwardRef=d,t.Fragment=i,t.Lazy=f,t.Memo=m,t.Portal=r,t.Profiler=s,t.StrictMode=c,t.Suspense=_,t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===l||e===s||e===c||e===_||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===m||e.$$typeof===a||e.$$typeof===p||e.$$typeof===d)},t.isAsyncMode=function(e){return h(e)||y(e)===u},t.isConcurrentMode=h,t.isContextConsumer=function(e){return y(e)===p},t.isContextProvider=function(e){return y(e)===a},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===o},t.isForwardRef=function(e){return y(e)===d},t.isFragment=function(e){return y(e)===i},t.isLazy=function(e){return y(e)===f},t.isMemo=function(e){return y(e)===m},t.isPortal=function(e){return y(e)===r},t.isProfiler=function(e){return y(e)===s},t.isStrictMode=function(e){return y(e)===c},t.isSuspense=function(e){return y(e)===_}});unwrapExports(reactIs_production_min);var reactIs_production_min_1=reactIs_production_min.typeOf,reactIs_production_min_2=reactIs_production_min.AsyncMode,reactIs_production_min_3=reactIs_production_min.ConcurrentMode,reactIs_production_min_4=reactIs_production_min.ContextConsumer,reactIs_production_min_5=reactIs_production_min.ContextProvider,reactIs_production_min_6=reactIs_production_min.Element,reactIs_production_min_7=reactIs_production_min.ForwardRef,reactIs_production_min_8=reactIs_production_min.Fragment,reactIs_production_min_9=reactIs_production_min.Lazy,reactIs_production_min_10=reactIs_production_min.Memo,reactIs_production_min_11=reactIs_production_min.Portal,reactIs_production_min_12=reactIs_production_min.Profiler,reactIs_production_min_13=reactIs_production_min.StrictMode,reactIs_production_min_14=reactIs_production_min.Suspense,reactIs_production_min_15=reactIs_production_min.isValidElementType,reactIs_production_min_16=reactIs_production_min.isAsyncMode,reactIs_production_min_17=reactIs_production_min.isConcurrentMode,reactIs_production_min_18=reactIs_production_min.isContextConsumer,reactIs_production_min_19=reactIs_production_min.isContextProvider,reactIs_production_min_20=reactIs_production_min.isElement,reactIs_production_min_21=reactIs_production_min.isForwardRef,reactIs_production_min_22=reactIs_production_min.isFragment,reactIs_production_min_23=reactIs_production_min.isLazy,reactIs_production_min_24=reactIs_production_min.isMemo,reactIs_production_min_25=reactIs_production_min.isPortal,reactIs_production_min_26=reactIs_production_min.isProfiler,reactIs_production_min_27=reactIs_production_min.isStrictMode,reactIs_production_min_28=reactIs_production_min.isSuspense,reactIs_development=createCommonjsModule(function(e,t){});unwrapExports(reactIs_development);var reactIs_development_1=reactIs_development.typeOf,reactIs_development_2=reactIs_development.AsyncMode,reactIs_development_3=reactIs_development.ConcurrentMode,reactIs_development_4=reactIs_development.ContextConsumer,reactIs_development_5=reactIs_development.ContextProvider,reactIs_development_6=reactIs_development.Element,reactIs_development_7=reactIs_development.ForwardRef,reactIs_development_8=reactIs_development.Fragment,reactIs_development_9=reactIs_development.Lazy,reactIs_development_10=reactIs_development.Memo,reactIs_development_11=reactIs_development.Portal,reactIs_development_12=reactIs_development.Profiler,reactIs_development_13=reactIs_development.StrictMode,reactIs_development_14=reactIs_development.Suspense,reactIs_development_15=reactIs_development.isValidElementType,reactIs_development_16=reactIs_development.isAsyncMode,reactIs_development_17=reactIs_development.isConcurrentMode,reactIs_development_18=reactIs_development.isContextConsumer,reactIs_development_19=reactIs_development.isContextProvider,reactIs_development_20=reactIs_development.isElement,reactIs_development_21=reactIs_development.isForwardRef,reactIs_development_22=reactIs_development.isFragment,reactIs_development_23=reactIs_development.isLazy,reactIs_development_24=reactIs_development.isMemo,reactIs_development_25=reactIs_development.isPortal,reactIs_development_26=reactIs_development.isProfiler,reactIs_development_27=reactIs_development.isStrictMode,reactIs_development_28=reactIs_development.isSuspense,reactIs=createCommonjsModule(function(e){e.exports=reactIs_production_min}),getOwnPropertySymbols=Object.getOwnPropertySymbols,hasOwnProperty=Object.prototype.hasOwnProperty,propIsEnumerable=Object.prototype.propertyIsEnumerable;function toObject(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function shouldUseNative(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(e){o[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}}var objectAssign=shouldUseNative()?Object.assign:function(e,t){for(var n,o,r=toObject(e),i=1;i<arguments.length;i++){for(var c in n=Object(arguments[i]))hasOwnProperty.call(n,c)&&(r[c]=n[c]);if(getOwnPropertySymbols){o=getOwnPropertySymbols(n);for(var s=0;s<o.length;s++)propIsEnumerable.call(n,o[s])&&(r[o[s]]=n[o[s]])}}return r},ReactPropTypesSecret="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",ReactPropTypesSecret_1=ReactPropTypesSecret,has$1=Function.call.bind(Object.prototype.hasOwnProperty);function emptyFunction(){}function emptyFunctionWithReset(){}emptyFunctionWithReset.resetWarningCache=emptyFunction;var factoryWithThrowingShims=function(){function e(e,t,n,o,r,i){if(i!==ReactPropTypesSecret_1){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:emptyFunctionWithReset,resetWarningCache:emptyFunction};return n.PropTypes=n,n},propTypes=createCommonjsModule(function(e){e.exports=factoryWithThrowingShims()}),NewWindow=function(e){function t(e){var n;return classCallCheck(this,t),(n=possibleConstructorReturn(this,getPrototypeOf(t).call(this,e))).container=null,n.window=null,n.windowCheckerInterval=null,n.released=!1,n.state={mounted:!1},n}return inherits(t,e),createClass(t,[{key:"render",value:function(){return this.state.mounted?ReactDOM.createPortal(this.props.children,this.container):null}},{key:"componentDidMount",value:function(){this.openChild(),this.setState({mounted:!0})}},{key:"openChild",value:function(){var e=this,t=this.props,n=t.url,o=t.title,r=t.name,i=t.features,c=t.onBlock,s=t.onOpen,a=t.center;if("string"!=typeof a||void 0!==i.width&&void 0!==i.height){if("parent"===a)i.left=window.top.outerWidth/2+window.top.screenX-i.width/2,i.top=window.top.outerHeight/2+window.top.screenY-i.height/2;else if("screen"===a){var p=void 0!==window.screenLeft?window.screenLeft:window.screen.left,u=void 0!==window.screenTop?window.screenTop:window.screen.top,l=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:window.screen.width,d=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:window.screen.height;i.left=l/2-i.width/2+p,i.top=d/2-i.height/2+u}}else console.warn("width and height window features must be present when a center prop is provided");this.window=window.open(n,r,toWindowFeatures(i)),this.container=this.window.document.createElement("div"),this.windowCheckerInterval=setInterval(function(){e.window&&!e.window.closed||e.release()},50),this.window?(this.window.document.title=o,this.window.document.body.appendChild(this.container),this.props.copyStyles&&setTimeout(function(){return copyStyles(document,e.window.document)},0),"function"==typeof s&&s(this.window),this.window.addEventListener("beforeunload",function(){return e.release()})):"function"==typeof c?c(null):console.warn("A new window could not be opened. Maybe it was blocked.")}},{key:"componentWillUnmount",value:function(){this.window&&this.window.close()}},{key:"release",value:function(){if(!this.released){this.released=!0,clearInterval(this.windowCheckerInterval);var e=this.props.onUnload;"function"==typeof e&&e(null)}}}]),t}(React.PureComponent);function copyStyles(e,t){var n=t.createDocumentFragment();Array.from(e.styleSheets).forEach(function(e){var o;try{o=e.cssRules}catch(e){console.error(e)}if(o){var r=[];Array.from(e.cssRules).forEach(function(e){var t=e.type;if(t!==CSSRule.UNKNOWN_RULE){var n="";n=t===CSSRule.KEYFRAMES_RULE?getKeyFrameText(e):[CSSRule.IMPORT_RULE,CSSRule.FONT_FACE_RULE].includes(t)?fixUrlForRule(e):e.cssText,r.push(n)}});var i=t.createElement("style");i.textContent=r.join("\n"),n.appendChild(i)}else if(e.href){var c=t.createElement("link");c.rel="stylesheet",c.href=e.href,n.appendChild(c)}}),t.head.appendChild(n)}function getKeyFrameText(e){var t=["@keyframes",e.name,"{"];return Array.from(e.cssRules).forEach(function(e){t.push(e.keyText,"{",e.style.cssText,"}")}),t.push("}"),t.join(" ")}function fixUrlForRule(e){return e.cssText.split("url(").map(function(e){return"/"===e[1]?"".concat(e.slice(0,1)).concat(window.location.origin).concat(e.slice(1)):e}).join("url(")}function toWindowFeatures(e){return Object.keys(e).reduce(function(t,n){var o=e[n];return"boolean"==typeof o?t.push("".concat(n,"=").concat(o?"yes":"no")):t.push("".concat(n,"=").concat(o)),t},[]).join(",")}defineProperty(NewWindow,"defaultProps",{url:"",name:"",title:"",features:{width:"600px",height:"640px"},onBlock:null,onOpen:null,onUnload:null,center:"parent",copyStyles:!0}),NewWindow.propTypes={children:propTypes.node,url:propTypes.string,name:propTypes.string,title:propTypes.string,features:propTypes.object,onUnload:propTypes.func,onBlock:propTypes.func,onOpen:propTypes.func,center:propTypes.oneOf(["parent","screen"]),copyStyles:propTypes.bool},module.exports=NewWindow;
"use strict";var e=require("react"),t=require("react-dom");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(e),r=n(t);function i(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function c(e,t){return c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},c(e,t)}function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function s(e,t){if(t&&("object"===u(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}var l={exports:{}},f={};
/** @license React v16.8.6
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(f,"__esModule",{value:!0});var d="function"==typeof Symbol&&Symbol.for,p=d?Symbol.for("react.element"):60103,y=d?Symbol.for("react.portal"):60106,h=d?Symbol.for("react.fragment"):60107,w=d?Symbol.for("react.strict_mode"):60108,m=d?Symbol.for("react.profiler"):60114,b=d?Symbol.for("react.provider"):60109,v=d?Symbol.for("react.context"):60110,O=d?Symbol.for("react.async_mode"):60111,S=d?Symbol.for("react.concurrent_mode"):60111,g=d?Symbol.for("react.forward_ref"):60112,j=d?Symbol.for("react.suspense"):60113,E=d?Symbol.for("react.memo"):60115,C=d?Symbol.for("react.lazy"):60116;function P(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case p:switch(e=e.type){case O:case S:case h:case m:case w:case j:return e;default:switch(e=e&&e.$$typeof){case v:case g:case b:return e;default:return t}}case C:case E:case y:return t}}}function _(e){return P(e)===S}f.typeOf=P,f.AsyncMode=O,f.ConcurrentMode=S,f.ContextConsumer=v,f.ContextProvider=b,f.Element=p,f.ForwardRef=g,f.Fragment=h,f.Lazy=C,f.Memo=E,f.Portal=y,f.Profiler=m,f.StrictMode=w,f.Suspense=j,f.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===h||e===S||e===m||e===w||e===j||"object"==typeof e&&null!==e&&(e.$$typeof===C||e.$$typeof===E||e.$$typeof===b||e.$$typeof===v||e.$$typeof===g)},f.isAsyncMode=function(e){return _(e)||P(e)===O},f.isConcurrentMode=_,f.isContextConsumer=function(e){return P(e)===v},f.isContextProvider=function(e){return P(e)===b},f.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===p},f.isForwardRef=function(e){return P(e)===g},f.isFragment=function(e){return P(e)===h},f.isLazy=function(e){return P(e)===C},f.isMemo=function(e){return P(e)===E},f.isPortal=function(e){return P(e)===y},f.isProfiler=function(e){return P(e)===m},f.isStrictMode=function(e){return P(e)===w},f.isSuspense=function(e){return P(e)===j};
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;!function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;var o=Object.getOwnPropertyNames(t).map((function(e){return t[e]}));if("0123456789"!==o.join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()||Object.assign;Function.call.bind(Object.prototype.hasOwnProperty);function R(){}function k(){}k.resetWarningCache=R;l.exports=function(){function e(e,t,n,o,r,i){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==i){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:k,resetWarningCache:R};return n.PropTypes=n,n}();var T=l.exports;function x(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=a(e);if(t){var r=a(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return s(this,n)}}var $,U,I,M=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(a,o["default"].PureComponent);var t,n,u,s=x(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=s.call(this,e)).container=null,t.window=null,t.windowCheckerInterval=null,t.released=!1,t.state={mounted:!1},t}return t=a,(n=[{key:"render",value:function(){return this.state.mounted?r.default.createPortal(this.props.children,this.container):null}},{key:"componentDidMount",value:function(){this.openChild(),this.setState({mounted:!0})}},{key:"openChild",value:function(){var e,t=this,n=this.props,o=n.url,r=n.title,i=n.name,c=n.features,u=n.onBlock,s=n.onOpen,a=n.center;if("string"!=typeof a||void 0!==c.width&&void 0!==c.height){if("parent"===a)c.left=window.top.outerWidth/2+window.top.screenX-c.width/2,c.top=window.top.outerHeight/2+window.top.screenY-c.height/2;else if("screen"===a){var l=void 0!==window.screenLeft?window.screenLeft:window.screen.left,f=void 0!==window.screenTop?window.screenTop:window.screen.top,d=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:window.screen.width,p=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:window.screen.height;c.left=d/2-c.width/2+l,c.top=p/2-c.height/2+f}}else console.warn("width and height window features must be present when a center prop is provided");if(this.window=window.open(o,i,(e=c,Object.keys(e).reduce((function(t,n){var o=e[n];return"boolean"==typeof o?t.push("".concat(n,"=").concat(o?"yes":"no")):t.push("".concat(n,"=").concat(o)),t}),[]).join(","))),this.container=this.window.document.createElement("div"),this.windowCheckerInterval=setInterval((function(){t.window&&!t.window.closed||t.release()}),50),this.window){if(this.window.document.title=r,this.container=this.window.document.getElementById("new-window-container"),null===this.container)this.container=this.window.document.createElement("div"),this.container.setAttribute("id","new-window-container"),this.window.document.body.appendChild(this.container);else{var y=this.window.document.getElementById("new-window-container-static");this.window.document.body.removeChild(y)}this.props.copyStyles&&setTimeout((function(){return e=document,n=t.window.document,o=n.createDocumentFragment(),Array.from(e.styleSheets).forEach((function(e){var t;try{t=e.cssRules}catch(e){console.error(e)}if(t){var r=[];Array.from(e.cssRules).forEach((function(e){var t=e.type;if(t!==CSSRule.UNKNOWN_RULE){var n="";n=t===CSSRule.KEYFRAMES_RULE?function(e){var t=["@keyframes",e.name,"{"];return Array.from(e.cssRules).forEach((function(e){t.push(e.keyText,"{",e.style.cssText,"}")})),t.push("}"),t.join(" ")}(e):[CSSRule.IMPORT_RULE,CSSRule.FONT_FACE_RULE].includes(t)?function(e){return e.cssText.split("url(").map((function(e){return"/"===e[1]?"".concat(e.slice(0,1)).concat(window.location.origin).concat(e.slice(1)):e})).join("url(")}(e):e.cssText,r.push(n)}}));var i=n.createElement("style");i.textContent=r.join("\n"),o.appendChild(i)}else if(e.href){var c=n.createElement("link");c.rel="stylesheet",c.href=e.href,o.appendChild(c)}})),void n.head.appendChild(o);var e,n,o}),0),"function"==typeof s&&s(this.window),this.window.addEventListener("beforeunload",(function(){return t.release()}))}else"function"==typeof u?u(null):console.warn("A new window could not be opened. Maybe it was blocked.")}},{key:"componentWillUnmount",value:function(){if(this.window)if(this.props.closeOnUnmount)this.window.close();else if(this.props.children){var e=this.container.cloneNode(!0);e.setAttribute("id","new-window-container-static"),this.window.document.body.appendChild(e)}}},{key:"release",value:function(){if(!this.released){this.released=!0,clearInterval(this.windowCheckerInterval);var e=this.props.onUnload;"function"==typeof e&&e(null)}}}])&&i(t.prototype,n),u&&i(t,u),a}();I={url:"",name:"",title:"",features:{width:"600px",height:"640px"},onBlock:null,onOpen:null,onUnload:null,center:"parent",copyStyles:!0,closeOnUnmount:!0},(U="defaultProps")in($=M)?Object.defineProperty($,U,{value:I,enumerable:!0,configurable:!0,writable:!0}):$[U]=I,M.propTypes={children:T.node,url:T.string,name:T.string,title:T.string,features:T.object,onUnload:T.func,onBlock:T.func,onOpen:T.func,center:T.oneOf(["parent","screen"]),copyStyles:T.bool,closeOnUnmount:T.bool},module.exports=M;
//# sourceMappingURL=react-new-window.js.map

63

package.json
{
"name": "react-new-window",
"description": "Pop a new window in React, using window.open API",
"version": "0.1.3",
"version": "0.2.1",
"keywords": [

@@ -16,3 +16,3 @@ "react",

"author": "Rubens Mariuzzo <rubens@mariuzzo.com>",
"license": "SEE LICENSE IN ./LICENSE",
"license": "MIT",
"files": [

@@ -29,38 +29,37 @@ "lib",

"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@storybook/addon-actions": "^5.0.11",
"@storybook/addon-links": "^5.0.11",
"@storybook/react": "^5.0.11",
"babel-eslint": "^10.0.1",
"cross-env": "^5.2.0",
"eslint": "^4.19.1",
"eslint-plugin-prettier": "^2.7.0",
"eslint-plugin-react": "^7.13.0",
"husky": "^2.3.0",
"jest": "^22.4.4",
"prettier": "^1.17.1",
"pretty-quick": "^1.11.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-test-renderer": "^16.8.6",
"@babel/core": "^7.15.8",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-transform-runtime": "^7.15.8",
"@babel/preset-env": "^7.15.8",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.0.6",
"@rollup/plugin-replace": "^3.0.0",
"@storybook/addon-actions": "^6.3.12",
"@storybook/addon-links": "^6.3.12",
"@storybook/react": "^6.3.12",
"babel-eslint": "^10.1.0",
"cross-env": "^7.0.3",
"eslint": "^8.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.26.1",
"husky": "^7.0.4",
"jest": "^27.3.1",
"prettier": "^2.4.1",
"pretty-quick": "^3.1.1",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-test-renderer": "^17.0.2",
"rimraf": "^3.0.2",
"rollup": "^0.57.1",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-filesize": "^1.4.2",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-uglify": "^3.0.0",
"uglify-es": "^3.3.10"
"rollup": "^2.58.1",
"rollup-plugin-filesize": "^9.1.1",
"rollup-plugin-terser": "^7.0.2"
},
"peerDependencies": {
"react": "^16.0.0",
"react-dom": "^16.0.0"
"react": "^16.0.0 || ^17.0.0",
"react-dom": "^16.0.0 || ^17.0.0"
},
"scripts": {
"build": "cross-env NODE_ENV=production rollup -c",
"clean": "rimraf 'es' 'lib' 'umd'",
"clean": "rimraf 'es' 'lib' 'umd' 'docs'",
"build-storybook": "cross-env NODE_ENV=test build-storybook -o docs",

@@ -67,0 +66,0 @@ "lint": "eslint ./src",

[![React New Window - Pop new windows in React, using window.open API.](.github/banner.svg)](#features)
> Inspired by [David Gilbertson's article](https://hackernoon.com/using-a-react-16-portal-to-do-something-cool-2a2d627b0202).
> Inspired by [David Gilbertson's article](https://medium.com/hackernoon/using-a-react-16-portal-to-do-something-cool-2a2d627b0202).

@@ -9,3 +9,3 @@ </div>

- **Only 2.68KB** (gzipped!).
- **Only 4.05KB** (gzipped!).
- **Support the full `window.open` api**.

@@ -49,4 +49,6 @@ - **Built for React 16** (uses `ReactDOM.createPortal`).

| `onBlock` | `Function` | `undefined` | A function to be triggered when the new window could not be opened. |
| `onOpen` | `Function` | `undefined` | A function to be triggered when window open by library. |
| `center` | `String` | `parent` | Indicate how to center the new window. Valid values are: `parent` or `screen`. `parent` will center the new window according to its _parent_ window. `screen` will center the new window according to the _screen_. |
| `copyStyles` | `Boolean` | `true` | If specified, copy styles from parent window's document. |
| `closeOnUnmount` | `Boolean` | `true` | If specified, close the new window on unmount. |

@@ -53,0 +55,0 @@ ## Tests

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):e.ReactNewWindow=t(e.React,e.ReactDOM)}(this,function(e,t){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,t=t&&t.hasOwnProperty("default")?t.default:t;var n=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function o(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var r=function(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function c(e,t){return e(t={exports:{}},t.exports),t.exports}var s=c(function(e){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(o){return"function"==typeof Symbol&&"symbol"===t(Symbol.iterator)?e.exports=n=function(e){return t(e)}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":t(e)},n(o)}e.exports=n});var u=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e};var a=function(e,t){return!t||"object"!==s(t)&&"function"!=typeof t?u(e):t},l=c(function(e){function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},t(n)}e.exports=t}),f=c(function(e){function t(n,o){return e.exports=t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t(n,o)}e.exports=t});var p=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&f(e,t)};var d=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},y=c(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&Symbol.for,o=n?Symbol.for("react.element"):60103,r=n?Symbol.for("react.portal"):60106,i=n?Symbol.for("react.fragment"):60107,c=n?Symbol.for("react.strict_mode"):60108,s=n?Symbol.for("react.profiler"):60114,u=n?Symbol.for("react.provider"):60109,a=n?Symbol.for("react.context"):60110,l=n?Symbol.for("react.async_mode"):60111,f=n?Symbol.for("react.concurrent_mode"):60111,p=n?Symbol.for("react.forward_ref"):60112,d=n?Symbol.for("react.suspense"):60113,y=n?Symbol.for("react.memo"):60115,m=n?Symbol.for("react.lazy"):60116;function w(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case o:switch(e=e.type){case l:case f:case i:case s:case c:case d:return e;default:switch(e=e&&e.$$typeof){case a:case p:case u:return e;default:return t}}case m:case y:case r:return t}}}function h(e){return w(e)===f}t.typeOf=w,t.AsyncMode=l,t.ConcurrentMode=f,t.ContextConsumer=a,t.ContextProvider=u,t.Element=o,t.ForwardRef=p,t.Fragment=i,t.Lazy=m,t.Memo=y,t.Portal=r,t.Profiler=s,t.StrictMode=c,t.Suspense=d,t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===f||e===s||e===c||e===d||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===y||e.$$typeof===u||e.$$typeof===a||e.$$typeof===p)},t.isAsyncMode=function(e){return h(e)||w(e)===l},t.isConcurrentMode=h,t.isContextConsumer=function(e){return w(e)===a},t.isContextProvider=function(e){return w(e)===u},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===o},t.isForwardRef=function(e){return w(e)===p},t.isFragment=function(e){return w(e)===i},t.isLazy=function(e){return w(e)===m},t.isMemo=function(e){return w(e)===y},t.isPortal=function(e){return w(e)===r},t.isProfiler=function(e){return w(e)===s},t.isStrictMode=function(e){return w(e)===c},t.isSuspense=function(e){return w(e)===d}});i(y);y.typeOf,y.AsyncMode,y.ConcurrentMode,y.ContextConsumer,y.ContextProvider,y.Element,y.ForwardRef,y.Fragment,y.Lazy,y.Memo,y.Portal,y.Profiler,y.StrictMode,y.Suspense,y.isValidElementType,y.isAsyncMode,y.isConcurrentMode,y.isContextConsumer,y.isContextProvider,y.isElement,y.isForwardRef,y.isFragment,y.isLazy,y.isMemo,y.isPortal,y.isProfiler,y.isStrictMode,y.isSuspense;var m=c(function(e,t){});i(m);m.typeOf,m.AsyncMode,m.ConcurrentMode,m.ContextConsumer,m.ContextProvider,m.Element,m.ForwardRef,m.Fragment,m.Lazy,m.Memo,m.Portal,m.Profiler,m.StrictMode,m.Suspense,m.isValidElementType,m.isAsyncMode,m.isConcurrentMode,m.isContextConsumer,m.isContextProvider,m.isElement,m.isForwardRef,m.isFragment,m.isLazy,m.isMemo,m.isPortal,m.isProfiler,m.isStrictMode,m.isSuspense,c(function(e){e.exports=y});var w=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;(function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(e){o[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}})()&&Object.assign;var v="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";Function.call.bind(Object.prototype.hasOwnProperty);function S(){}function O(){}O.resetWarningCache=S;var C=c(function(e){e.exports=function(){function e(e,t,n,o,r,i){if(i!==v){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:O,resetWarningCache:S};return n.PropTypes=n,n}()}),g=function(e){function o(e){var t;return n(this,o),(t=a(this,l(o).call(this,e))).container=null,t.window=null,t.windowCheckerInterval=null,t.released=!1,t.state={mounted:!1},t}return p(o,e),r(o,[{key:"render",value:function(){return this.state.mounted?t.createPortal(this.props.children,this.container):null}},{key:"componentDidMount",value:function(){this.openChild(),this.setState({mounted:!0})}},{key:"openChild",value:function(){var e,t=this,n=this.props,o=n.url,r=n.title,i=n.name,c=n.features,s=n.onBlock,u=n.onOpen,a=n.center;if("string"!=typeof a||void 0!==c.width&&void 0!==c.height){if("parent"===a)c.left=window.top.outerWidth/2+window.top.screenX-c.width/2,c.top=window.top.outerHeight/2+window.top.screenY-c.height/2;else if("screen"===a){var l=void 0!==window.screenLeft?window.screenLeft:window.screen.left,f=void 0!==window.screenTop?window.screenTop:window.screen.top,p=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:window.screen.width,d=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:window.screen.height;c.left=p/2-c.width/2+l,c.top=d/2-c.height/2+f}}else console.warn("width and height window features must be present when a center prop is provided");this.window=window.open(o,i,(e=c,Object.keys(e).reduce(function(t,n){var o=e[n];return"boolean"==typeof o?t.push("".concat(n,"=").concat(o?"yes":"no")):t.push("".concat(n,"=").concat(o)),t},[]).join(","))),this.container=this.window.document.createElement("div"),this.windowCheckerInterval=setInterval(function(){t.window&&!t.window.closed||t.release()},50),this.window?(this.window.document.title=r,this.window.document.body.appendChild(this.container),this.props.copyStyles&&setTimeout(function(){return e=document,n=t.window.document,o=n.createDocumentFragment(),Array.from(e.styleSheets).forEach(function(e){var t;try{t=e.cssRules}catch(e){console.error(e)}if(t){var r=[];Array.from(e.cssRules).forEach(function(e){var t=e.type;if(t!==CSSRule.UNKNOWN_RULE){var n="";n=t===CSSRule.KEYFRAMES_RULE?function(e){var t=["@keyframes",e.name,"{"];return Array.from(e.cssRules).forEach(function(e){t.push(e.keyText,"{",e.style.cssText,"}")}),t.push("}"),t.join(" ")}(e):[CSSRule.IMPORT_RULE,CSSRule.FONT_FACE_RULE].includes(t)?function(e){return e.cssText.split("url(").map(function(e){return"/"===e[1]?"".concat(e.slice(0,1)).concat(window.location.origin).concat(e.slice(1)):e}).join("url(")}(e):e.cssText,r.push(n)}});var i=n.createElement("style");i.textContent=r.join("\n"),o.appendChild(i)}else if(e.href){var c=n.createElement("link");c.rel="stylesheet",c.href=e.href,o.appendChild(c)}}),void n.head.appendChild(o);var e,n,o},0),"function"==typeof u&&u(this.window),this.window.addEventListener("beforeunload",function(){return t.release()})):"function"==typeof s?s(null):console.warn("A new window could not be opened. Maybe it was blocked.")}},{key:"componentWillUnmount",value:function(){this.window&&this.window.close()}},{key:"release",value:function(){if(!this.released){this.released=!0,clearInterval(this.windowCheckerInterval);var e=this.props.onUnload;"function"==typeof e&&e(null)}}}]),o}(e.PureComponent);return d(g,"defaultProps",{url:"",name:"",title:"",features:{width:"600px",height:"640px"},onBlock:null,onOpen:null,onUnload:null,center:"parent",copyStyles:!0}),g.propTypes={children:C.node,url:C.string,name:C.string,title:C.string,features:C.object,onUnload:C.func,onBlock:C.func,onOpen:C.func,center:C.oneOf(["parent","screen"]),copyStyles:C.bool},g});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).ReactNewWindow=t(e.React,e.ReactDOM)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(e),r=n(t);function i(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function c(e,t){return c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},c(e,t)}function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function s(e,t){if(t&&("object"===u(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}var l={exports:{}},f={};
/** @license React v16.8.6
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(f,"__esModule",{value:!0});var d="function"==typeof Symbol&&Symbol.for,p=d?Symbol.for("react.element"):60103,y=d?Symbol.for("react.portal"):60106,h=d?Symbol.for("react.fragment"):60107,w=d?Symbol.for("react.strict_mode"):60108,m=d?Symbol.for("react.profiler"):60114,b=d?Symbol.for("react.provider"):60109,v=d?Symbol.for("react.context"):60110,O=d?Symbol.for("react.async_mode"):60111,g=d?Symbol.for("react.concurrent_mode"):60111,S=d?Symbol.for("react.forward_ref"):60112,j=d?Symbol.for("react.suspense"):60113,E=d?Symbol.for("react.memo"):60115,C=d?Symbol.for("react.lazy"):60116;function P(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case p:switch(e=e.type){case O:case g:case h:case m:case w:case j:return e;default:switch(e=e&&e.$$typeof){case v:case S:case b:return e;default:return t}}case C:case E:case y:return t}}}function R(e){return P(e)===g}f.typeOf=P,f.AsyncMode=O,f.ConcurrentMode=g,f.ContextConsumer=v,f.ContextProvider=b,f.Element=p,f.ForwardRef=S,f.Fragment=h,f.Lazy=C,f.Memo=E,f.Portal=y,f.Profiler=m,f.StrictMode=w,f.Suspense=j,f.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===h||e===g||e===m||e===w||e===j||"object"==typeof e&&null!==e&&(e.$$typeof===C||e.$$typeof===E||e.$$typeof===b||e.$$typeof===v||e.$$typeof===S)},f.isAsyncMode=function(e){return R(e)||P(e)===O},f.isConcurrentMode=R,f.isContextConsumer=function(e){return P(e)===v},f.isContextProvider=function(e){return P(e)===b},f.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===p},f.isForwardRef=function(e){return P(e)===S},f.isFragment=function(e){return P(e)===h},f.isLazy=function(e){return P(e)===C},f.isMemo=function(e){return P(e)===E},f.isPortal=function(e){return P(e)===y},f.isProfiler=function(e){return P(e)===m},f.isStrictMode=function(e){return P(e)===w},f.isSuspense=function(e){return P(e)===j};
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;!function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;var o=Object.getOwnPropertyNames(t).map((function(e){return t[e]}));if("0123456789"!==o.join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()||Object.assign;Function.call.bind(Object.prototype.hasOwnProperty);function _(){}function T(){}T.resetWarningCache=_;l.exports=function(){function e(e,t,n,o,r,i){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==i){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:T,resetWarningCache:_};return n.PropTypes=n,n}();var k=l.exports;function x(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=a(e);if(t){var r=a(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return s(this,n)}}var $,M,U,I=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(s,e);var t,n,o,u=x(s);function s(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),(t=u.call(this,e)).container=null,t.window=null,t.windowCheckerInterval=null,t.released=!1,t.state={mounted:!1},t}return t=s,(n=[{key:"render",value:function(){return this.state.mounted?r.default.createPortal(this.props.children,this.container):null}},{key:"componentDidMount",value:function(){this.openChild(),this.setState({mounted:!0})}},{key:"openChild",value:function(){var e,t=this,n=this.props,o=n.url,r=n.title,i=n.name,c=n.features,u=n.onBlock,s=n.onOpen,a=n.center;if("string"!=typeof a||void 0!==c.width&&void 0!==c.height){if("parent"===a)c.left=window.top.outerWidth/2+window.top.screenX-c.width/2,c.top=window.top.outerHeight/2+window.top.screenY-c.height/2;else if("screen"===a){var l=void 0!==window.screenLeft?window.screenLeft:window.screen.left,f=void 0!==window.screenTop?window.screenTop:window.screen.top,d=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:window.screen.width,p=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:window.screen.height;c.left=d/2-c.width/2+l,c.top=p/2-c.height/2+f}}else console.warn("width and height window features must be present when a center prop is provided");if(this.window=window.open(o,i,(e=c,Object.keys(e).reduce((function(t,n){var o=e[n];return"boolean"==typeof o?t.push("".concat(n,"=").concat(o?"yes":"no")):t.push("".concat(n,"=").concat(o)),t}),[]).join(","))),this.container=this.window.document.createElement("div"),this.windowCheckerInterval=setInterval((function(){t.window&&!t.window.closed||t.release()}),50),this.window){if(this.window.document.title=r,this.container=this.window.document.getElementById("new-window-container"),null===this.container)this.container=this.window.document.createElement("div"),this.container.setAttribute("id","new-window-container"),this.window.document.body.appendChild(this.container);else{var y=this.window.document.getElementById("new-window-container-static");this.window.document.body.removeChild(y)}this.props.copyStyles&&setTimeout((function(){return e=document,n=t.window.document,o=n.createDocumentFragment(),Array.from(e.styleSheets).forEach((function(e){var t;try{t=e.cssRules}catch(e){console.error(e)}if(t){var r=[];Array.from(e.cssRules).forEach((function(e){var t=e.type;if(t!==CSSRule.UNKNOWN_RULE){var n="";n=t===CSSRule.KEYFRAMES_RULE?function(e){var t=["@keyframes",e.name,"{"];return Array.from(e.cssRules).forEach((function(e){t.push(e.keyText,"{",e.style.cssText,"}")})),t.push("}"),t.join(" ")}(e):[CSSRule.IMPORT_RULE,CSSRule.FONT_FACE_RULE].includes(t)?function(e){return e.cssText.split("url(").map((function(e){return"/"===e[1]?"".concat(e.slice(0,1)).concat(window.location.origin).concat(e.slice(1)):e})).join("url(")}(e):e.cssText,r.push(n)}}));var i=n.createElement("style");i.textContent=r.join("\n"),o.appendChild(i)}else if(e.href){var c=n.createElement("link");c.rel="stylesheet",c.href=e.href,o.appendChild(c)}})),void n.head.appendChild(o);var e,n,o}),0),"function"==typeof s&&s(this.window),this.window.addEventListener("beforeunload",(function(){return t.release()}))}else"function"==typeof u?u(null):console.warn("A new window could not be opened. Maybe it was blocked.")}},{key:"componentWillUnmount",value:function(){if(this.window)if(this.props.closeOnUnmount)this.window.close();else if(this.props.children){var e=this.container.cloneNode(!0);e.setAttribute("id","new-window-container-static"),this.window.document.body.appendChild(e)}}},{key:"release",value:function(){if(!this.released){this.released=!0,clearInterval(this.windowCheckerInterval);var e=this.props.onUnload;"function"==typeof e&&e(null)}}}])&&i(t.prototype,n),o&&i(t,o),s}(o.default.PureComponent);return U={url:"",name:"",title:"",features:{width:"600px",height:"640px"},onBlock:null,onOpen:null,onUnload:null,center:"parent",copyStyles:!0,closeOnUnmount:!0},(M="defaultProps")in($=I)?Object.defineProperty($,M,{value:U,enumerable:!0,configurable:!0,writable:!0}):$[M]=U,I.propTypes={children:k.node,url:k.string,name:k.string,title:k.string,features:k.object,onUnload:k.func,onBlock:k.func,onOpen:k.func,center:k.oneOf(["parent","screen"]),copyStyles:k.bool,closeOnUnmount:k.bool},I}));
//# sourceMappingURL=react-new-window.js.map

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