New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.0.12 to 0.1.0

2

es/react-new-window.js

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

import React from"react";import ReactDOM from"react-dom";function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var 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;function 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,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=emptyFunction,n.PropTypes=n,n},propTypes=createCommonjsModule(function(e){e.exports=factoryWithThrowingShims()}),classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},createClass=function(){function e(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)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),inherits=function(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)},possibleConstructorReturn=function(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},NewWindow=function(e){function t(e){classCallCheck(this,t);var n=possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.container=document.createElement("div"),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.center;if("string"!=typeof s||void 0!==i.width&&void 0!==i.height){if("parent"===s)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"===s){var a=void 0!==window.screenLeft?window.screenLeft:screen.left,l=void 0!==window.screenTop?window.screenTop:screen.top,p=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:window.screen.width,u=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:window.screen.height;i.left=p/2-i.width/2+a,i.top=u/2-i.height/2+l}}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.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),this.window.addEventListener("beforeunload",function(){return e.release()})):"function"==typeof c?c.call(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.call(null)}}}]),t}(React.PureComponent);function copyStyles(e,t){Array.from(e.styleSheets).forEach(function(n){var o=void 0;try{o=n.cssRules}catch(e){console.error(e)}if(o){var r=e.createElement("style");Array.from(n.cssRules).forEach(function(t){var n=t.cssText,o=t.type,i=n;[3,5].includes(o)&&(i=n.split("url(").map(function(e){return"/"===e[1]?""+e.slice(0,1)+window.location.origin+e.slice(1):e}).join("url(")),r.appendChild(e.createTextNode(i))}),t.head.appendChild(r)}else if(n.href){var i=e.createElement("link");i.rel="stylesheet",i.href=n.href,t.head.appendChild(i)}})}function toWindowFeatures(e){return Object.keys(e).reduce(function(t,n){var o=e[n];return"boolean"==typeof o?t.push(n+"="+(o?"yes":"no")):t.push(n+"="+o),t},[]).join(",")}NewWindow.defaultProps={url:"",name:"",title:"",features:{width:"600px",height:"640px"},onBlock: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,center:propTypes.oneOf(["parent","screen"]),copyStyles:propTypes.bool};export default NewWindow;
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 o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,o){return t&&_defineProperties(e.prototype,t),o&&_defineProperties(e,o),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 o(n){return"function"==typeof Symbol&&"symbol"===t(Symbol.iterator)?e.exports=o=function(e){return t(e)}:e.exports=o=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":t(e)},o(n)}e.exports=o});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(o){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},t(o)}e.exports=t}),setPrototypeOf=createCommonjsModule(function(e){function t(o,n){return e.exports=t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t(o,n)}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,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var defineProperty=_defineProperty,reactIs_production_min=createCommonjsModule(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var o="function"==typeof Symbol&&Symbol.for,n=o?Symbol.for("react.element"):60103,r=o?Symbol.for("react.portal"):60106,i=o?Symbol.for("react.fragment"):60107,c=o?Symbol.for("react.strict_mode"):60108,s=o?Symbol.for("react.profiler"):60114,a=o?Symbol.for("react.provider"):60109,p=o?Symbol.for("react.context"):60110,u=o?Symbol.for("react.async_mode"):60111,l=o?Symbol.for("react.concurrent_mode"):60111,d=o?Symbol.for("react.forward_ref"):60112,_=o?Symbol.for("react.suspense"):60113,m=o?Symbol.for("react.memo"):60115,f=o?Symbol.for("react.lazy"):60116;function y(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case n: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=n,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===n},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={},o=0;o<10;o++)t["_"+String.fromCharCode(o)]=o;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}var objectAssign=shouldUseNative()?Object.assign:function(e,t){for(var o,n,r=toObject(e),i=1;i<arguments.length;i++){for(var c in o=Object(arguments[i]))hasOwnProperty.call(o,c)&&(r[c]=o[c]);if(getOwnPropertySymbols){n=getOwnPropertySymbols(o);for(var s=0;s<n.length;s++)propIsEnumerable.call(o,n[s])&&(r[n[s]]=o[n[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,o,n,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 o={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 o.PropTypes=o,o},propTypes=createCommonjsModule(function(e){e.exports=factoryWithThrowingShims()}),NewWindow=function(e){function t(e){var o;return classCallCheck(this,t),(o=possibleConstructorReturn(this,getPrototypeOf(t).call(this,e))).container=document.createElement("div"),o.window=null,o.windowCheckerInterval=null,o.released=!1,o.state={mounted:!1},o}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,o=t.url,n=t.title,r=t.name,i=t.features,c=t.onBlock,s=t.center;if("string"!=typeof s||void 0!==i.width&&void 0!==i.height){if("parent"===s)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"===s){var a=void 0!==window.screenLeft?window.screenLeft:screen.left,p=void 0!==window.screenTop?window.screenTop:screen.top,u=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:window.screen.width,l=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:window.screen.height;i.left=u/2-i.width/2+a,i.top=l/2-i.height/2+p}}else console.warn("width and height window features must be present when a center prop is provided");this.window=window.open(o,r,toWindowFeatures(i)),this.windowCheckerInterval=setInterval(function(){e.window&&!e.window.closed||e.release()},50),this.window?(this.window.document.title=n,this.window.document.body.appendChild(this.container),this.props.copyStyles&&setTimeout(function(){return copyStyles(document,e.window.document)},0),this.window.addEventListener("beforeunload",function(){return e.release()})):"function"==typeof c?c.call(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.call(null)}}}]),t}(React.PureComponent);function copyStyles(e,t){Array.from(e.styleSheets).forEach(function(o){var n;try{n=o.cssRules}catch(e){console.error(e)}if(n){var r=e.createElement("style");Array.from(o.cssRules).forEach(function(t){var o=t.cssText,n=t.type,i=o;[3,5].includes(n)&&(i=o.split("url(").map(function(e){return"/"===e[1]?"".concat(e.slice(0,1)).concat(window.location.origin).concat(e.slice(1)):e}).join("url(")),r.appendChild(e.createTextNode(i))}),t.head.appendChild(r)}else if(o.href){var i=e.createElement("link");i.rel="stylesheet",i.href=o.href,t.head.appendChild(i)}})}function toWindowFeatures(e){return Object.keys(e).reduce(function(t,o){var n=e[o];return"boolean"==typeof n?t.push("".concat(o,"=").concat(n?"yes":"no")):t.push("".concat(o,"=").concat(n)),t},[]).join(",")}defineProperty(NewWindow,"defaultProps",{url:"",name:"",title:"",features:{width:"600px",height:"640px"},onBlock: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,center:propTypes.oneOf(["parent","screen"]),copyStyles:propTypes.bool};export default NewWindow;
//# sourceMappingURL=react-new-window.js.map
{
"name": "react-new-window",
"description": "🔲 Pop a new window React using window.open",
"version": "0.0.12",
"description": "🔲 Pop a new window in React, using window.open",
"version": "0.1.0",
"keywords": [

@@ -24,32 +24,29 @@ "react",

"dependencies": {
"prop-types": "^15.6.1"
"prop-types": "^15.7.2"
},
"devDependencies": {
"@storybook/addon-actions": "^3.2.14",
"@storybook/addon-links": "^3.2.14",
"@storybook/react": "^3.2.14",
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.2",
"babel-jest": "^21.2.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-es2015-rollup": "^3.0.0",
"babel-preset-react": "^6.24.1",
"cross-env": "^5.1.1",
"@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.6.0",
"eslint-plugin-react": "^7.7.0",
"jest": "^22.4.2",
"eslint-plugin-prettier": "^2.7.0",
"eslint-plugin-react": "^7.13.0",
"jest": "^22.4.4",
"np": "^2.20.1",
"prettier": "^1.11.1",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-test-renderer": "^16.0.0",
"prettier": "^1.17.1",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-test-renderer": "^16.8.6",
"rollup": "^0.57.1",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-commonjs": "^9.1.0",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-filesize": "^1.4.2",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-uglify": "^3.0.0",

@@ -56,0 +53,0 @@ "uglify-es": "^3.3.10"

@@ -86,9 +86,9 @@ /**

: document.documentElement.clientWidth
? document.documentElement.clientWidth
: window.screen.width
? document.documentElement.clientWidth
: window.screen.width
const height = window.innerHeight
? window.innerHeight
: document.documentElement.clientHeight
? document.documentElement.clientHeight
: window.screen.height
? document.documentElement.clientHeight
: window.screen.height

@@ -95,0 +95,0 @@ features.left = width / 2 - features.width / 2 + screenLeft

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

!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=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=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 i="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";function c(){}var a,s=(function(e){e.exports=function(){function e(e,t,n,o,r,c){if(c!==i){var a=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 a.name="Invariant Violation",a}}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,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=c,n.PropTypes=n,n}()}(a={exports:{}},a.exports),a.exports),l=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},u=function(){function e(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)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),d=function(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},p=function(n){function o(e){l(this,o);var t=d(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,e));return t.container=document.createElement("div"),t.window=null,t.windowCheckerInterval=null,t.released=!1,t.state={mounted:!1},t}return function(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)}(o,e.PureComponent),u(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,a=n.onBlock,s=n.center;if("string"!=typeof s||void 0!==c.width&&void 0!==c.height){if("parent"===s)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"===s){var l=void 0!==window.screenLeft?window.screenLeft:screen.left,u=void 0!==window.screenTop?window.screenTop: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+u}}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(n+"="+(o?"yes":"no")):t.push(n+"="+o),t},[]).join(","))),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,void Array.from(e.styleSheets).forEach(function(t){var o=void 0;try{o=t.cssRules}catch(e){console.error(e)}if(o){var r=e.createElement("style");Array.from(t.cssRules).forEach(function(t){var n=t.cssText,o=t.type,i=n;[3,5].includes(o)&&(i=n.split("url(").map(function(e){return"/"===e[1]?""+e.slice(0,1)+window.location.origin+e.slice(1):e}).join("url(")),r.appendChild(e.createTextNode(i))}),n.head.appendChild(r)}else if(t.href){var i=e.createElement("link");i.rel="stylesheet",i.href=t.href,n.head.appendChild(i)}});var e,n},0),this.window.addEventListener("beforeunload",function(){return t.release()})):"function"==typeof a?a.call(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.call(null)}}}]),o}();return p.defaultProps={url:"",name:"",title:"",features:{width:"600px",height:"640px"},onBlock:null,onUnload:null,center:"parent",copyStyles:!0},p.propTypes={children:s.node,url:s.string,name:s.string,title:s.string,features:s.object,onUnload:s.func,onBlock:s.func,center:s.oneOf(["parent","screen"]),copyStyles:s.bool},p});
!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 a=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e};var u=function(e,t){return!t||"object"!==s(t)&&"function"!=typeof t?a(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,a=n?Symbol.for("react.provider"):60109,u=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 h(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 u:case p:case a:return e;default:return t}}case m:case y:case r:return t}}}function w(e){return h(e)===f}t.typeOf=h,t.AsyncMode=l,t.ConcurrentMode=f,t.ContextConsumer=u,t.ContextProvider=a,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===a||e.$$typeof===u||e.$$typeof===p)},t.isAsyncMode=function(e){return w(e)||h(e)===l},t.isConcurrentMode=w,t.isContextConsumer=function(e){return h(e)===u},t.isContextProvider=function(e){return h(e)===a},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===o},t.isForwardRef=function(e){return h(e)===p},t.isFragment=function(e){return h(e)===i},t.isLazy=function(e){return h(e)===m},t.isMemo=function(e){return h(e)===y},t.isPortal=function(e){return h(e)===r},t.isProfiler=function(e){return h(e)===s},t.isStrictMode=function(e){return h(e)===c},t.isSuspense=function(e){return h(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 h=Object.getOwnPropertySymbols,w=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 g=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}()}),P=function(e){function o(e){var t;return n(this,o),(t=u(this,l(o).call(this,e))).container=document.createElement("div"),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,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 u=void 0!==window.screenLeft?window.screenLeft:screen.left,l=void 0!==window.screenTop?window.screenTop:screen.top,f=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=f/2-c.width/2+u,c.top=p/2-c.height/2+l}}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.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,void Array.from(e.styleSheets).forEach(function(t){var o;try{o=t.cssRules}catch(e){console.error(e)}if(o){var r=e.createElement("style");Array.from(t.cssRules).forEach(function(t){var n=t.cssText,o=t.type,i=n;[3,5].includes(o)&&(i=n.split("url(").map(function(e){return"/"===e[1]?"".concat(e.slice(0,1)).concat(window.location.origin).concat(e.slice(1)):e}).join("url(")),r.appendChild(e.createTextNode(i))}),n.head.appendChild(r)}else if(t.href){var i=e.createElement("link");i.rel="stylesheet",i.href=t.href,n.head.appendChild(i)}});var e,n},0),this.window.addEventListener("beforeunload",function(){return t.release()})):"function"==typeof s?s.call(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.call(null)}}}]),o}(e.PureComponent);return d(P,"defaultProps",{url:"",name:"",title:"",features:{width:"600px",height:"640px"},onBlock:null,onUnload:null,center:"parent",copyStyles:!0}),P.propTypes={children:g.node,url:g.string,name:g.string,title:g.string,features:g.object,onUnload:g.func,onBlock:g.func,center:g.oneOf(["parent","screen"]),copyStyles:g.bool},P});
//# 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

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