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.3 to 0.0.4

2

dist/react-new-window.esm.js

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

function copyStyles(e,t){Array.from(e.styleSheets).forEach(function(n){if(n.cssRules){var o=e.createElement("style");Array.from(n.cssRules).forEach(function(t){o.appendChild(e.createTextNode(t.cssText))}),t.head.appendChild(o)}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){return t.push(n+"="+e[n]),t},[]).join(",")}import React from"react";import ReactDOM from"react-dom";var 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}return inherits(t,e),createClass(t,[{key:"render",value:function(){return ReactDOM.createPortal(this.props.children,this.container)}},{key:"componentDidMount",value:function(){var e=this.props,t=e.url,n=e.title,o=e.name,i=e.features,r=e.onBlock,c=e.onUnload,l=e.center;if("string"!=typeof l||void 0!==i.width&&void 0!==i.height){if("parent"===l)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"===l){var s=void 0!==window.screenLeft?window.screenLeft:screen.left,a=void 0!==window.screenTop?window.screenTop:screen.top,u=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,d=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;i.left=u/2-i.width/2+s,i.top=d/2-i.height/2+a}}else console.warn("left and top window features must be present when a center prop is provided");this.window=window.open(t,o,toWindowFeatures(i)),this.window?(this.window.document.title=n,this.window.document.body.appendChild(this.container),copyStyles(document,this.window.document),this.window.addEventListener("beforeunload",function(){"function"==typeof c&&c.call(null)})):"function"==typeof r?r.call(null):console.warn("A new window could not be opened. Maybe it was blocked.")}},{key:"componentWillUnmount",value:function(){this.window&&this.window.close()}}]),t}(React.PureComponent);NewWindow.defaultProps={url:"",name:"",title:"",features:{},onBlock:null,onUnload:null,center:"parent"};export default NewWindow;
function copyStyles(e,t){Array.from(e.styleSheets).forEach(function(n){if(n.cssRules){var o=e.createElement("style");Array.from(n.cssRules).forEach(function(t){o.appendChild(e.createTextNode(t.cssText))}),t.head.appendChild(o)}else if(n.href){var r=e.createElement("link");r.rel="stylesheet",r.href=n.href,t.head.appendChild(r)}})}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(",")}import React from"react";import ReactDOM from"react-dom";var 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}return inherits(t,e),createClass(t,[{key:"render",value:function(){return ReactDOM.createPortal(this.props.children,this.container)}},{key:"componentDidMount",value:function(){var e=this,t=this.props,n=t.url,o=t.title,r=t.name,i=t.features,c=t.onBlock,l=t.center;if("string"!=typeof l||void 0!==i.width&&void 0!==i.height){if("parent"===l)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"===l){var s=void 0!==window.screenLeft?window.screenLeft:screen.left,a=void 0!==window.screenTop?window.screenTop:screen.top,d=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,u=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;i.left=d/2-i.width/2+s,i.top=u/2-i.height/2+a}}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&&copyStyles(document,this.window.document),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);NewWindow.defaultProps={url:"",name:"",title:"",features:{},onBlock:null,onUnload:null,center:"parent",copyStyles:!0};export default NewWindow;
//# sourceMappingURL=react-new-window.esm.js.map

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

"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function copyStyles(e,t){Array.from(e.styleSheets).forEach(function(n){if(n.cssRules){var o=e.createElement("style");Array.from(n.cssRules).forEach(function(t){o.appendChild(e.createTextNode(t.cssText))}),t.head.appendChild(o)}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){return t.push(n+"="+e[n]),t},[]).join(",")}var React=_interopDefault(require("react")),ReactDOM=_interopDefault(require("react-dom")),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}return inherits(t,e),createClass(t,[{key:"render",value:function(){return ReactDOM.createPortal(this.props.children,this.container)}},{key:"componentDidMount",value:function(){var e=this.props,t=e.url,n=e.title,o=e.name,i=e.features,r=e.onBlock,c=e.onUnload,l=e.center;if("string"!=typeof l||void 0!==i.width&&void 0!==i.height){if("parent"===l)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"===l){var u=void 0!==window.screenLeft?window.screenLeft:screen.left,s=void 0!==window.screenTop?window.screenTop:screen.top,a=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,d=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;i.left=a/2-i.width/2+u,i.top=d/2-i.height/2+s}}else console.warn("left and top window features must be present when a center prop is provided");this.window=window.open(t,o,toWindowFeatures(i)),this.window?(this.window.document.title=n,this.window.document.body.appendChild(this.container),copyStyles(document,this.window.document),this.window.addEventListener("beforeunload",function(){"function"==typeof c&&c.call(null)})):"function"==typeof r?r.call(null):console.warn("A new window could not be opened. Maybe it was blocked.")}},{key:"componentWillUnmount",value:function(){this.window&&this.window.close()}}]),t}(React.PureComponent);NewWindow.defaultProps={url:"",name:"",title:"",features:{},onBlock:null,onUnload:null,center:"parent"},module.exports=NewWindow;
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function copyStyles(e,t){Array.from(e.styleSheets).forEach(function(n){if(n.cssRules){var o=e.createElement("style");Array.from(n.cssRules).forEach(function(t){o.appendChild(e.createTextNode(t.cssText))}),t.head.appendChild(o)}else if(n.href){var r=e.createElement("link");r.rel="stylesheet",r.href=n.href,t.head.appendChild(r)}})}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(",")}var React=_interopDefault(require("react")),ReactDOM=_interopDefault(require("react-dom")),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}return inherits(t,e),createClass(t,[{key:"render",value:function(){return ReactDOM.createPortal(this.props.children,this.container)}},{key:"componentDidMount",value:function(){var e=this,t=this.props,n=t.url,o=t.title,r=t.name,i=t.features,c=t.onBlock,l=t.center;if("string"!=typeof l||void 0!==i.width&&void 0!==i.height){if("parent"===l)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"===l){var s=void 0!==window.screenLeft?window.screenLeft:screen.left,a=void 0!==window.screenTop?window.screenTop:screen.top,u=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,d=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;i.left=u/2-i.width/2+s,i.top=d/2-i.height/2+a}}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&&copyStyles(document,this.window.document),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);NewWindow.defaultProps={url:"",name:"",title:"",features:{},onBlock:null,onUnload:null,center:"parent",copyStyles:!0},module.exports=NewWindow;
//# sourceMappingURL=react-new-window.js.map

@@ -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=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},o=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}}(),i=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},r=function(r){function c(e){n(this,c);var t=i(this,(c.__proto__||Object.getPrototypeOf(c)).call(this,e));return t.container=document.createElement("div"),t.window=null,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)}(c,e.PureComponent),o(c,[{key:"render",value:function(){return t.createPortal(this.props.children,this.container)}},{key:"componentDidMount",value:function(){var e=this.props,t=e.url,n=e.title,o=e.name,i=e.features,r=e.onBlock,c=e.onUnload,d=e.center;if("string"!=typeof d||void 0!==i.width&&void 0!==i.height){if("parent"===d)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"===d){var u=void 0!==window.screenLeft?window.screenLeft:screen.left,l=void 0!==window.screenTop?window.screenTop:screen.top,a=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,s=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;i.left=a/2-i.width/2+u,i.top=s/2-i.height/2+l}}else console.warn("left and top window features must be present when a center prop is provided");this.window=window.open(t,o,function(e){return Object.keys(e).reduce(function(t,n){return t.push(n+"="+e[n]),t},[]).join(",")}(i)),this.window?(this.window.document.title=n,this.window.document.body.appendChild(this.container),function(e,t){Array.from(e.styleSheets).forEach(function(n){if(n.cssRules){var o=e.createElement("style");Array.from(n.cssRules).forEach(function(t){o.appendChild(e.createTextNode(t.cssText))}),t.head.appendChild(o)}else if(n.href){var i=e.createElement("link");i.rel="stylesheet",i.href=n.href,t.head.appendChild(i)}})}(document,this.window.document),this.window.addEventListener("beforeunload",function(){"function"==typeof c&&c.call(null)})):"function"==typeof r?r.call(null):console.warn("A new window could not be opened. Maybe it was blocked.")}},{key:"componentWillUnmount",value:function(){this.window&&this.window.close()}}]),c}();return r.defaultProps={url:"",name:"",title:"",features:{},onBlock:null,onUnload:null,center:"parent"},r});
!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")},o=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}}(),r=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},i=function(i){function c(e){n(this,c);var t=r(this,(c.__proto__||Object.getPrototypeOf(c)).call(this,e));return t.container=document.createElement("div"),t.window=null,t.windowCheckerInterval=null,t.released=!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)}(c,e.PureComponent),o(c,[{key:"render",value:function(){return t.createPortal(this.props.children,this.container)}},{key:"componentDidMount",value:function(){var e=this,t=this.props,n=t.url,o=t.title,r=t.name,i=t.features,c=t.onBlock,l=t.center;if("string"!=typeof l||void 0!==i.width&&void 0!==i.height){if("parent"===l)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"===l){var d=void 0!==window.screenLeft?window.screenLeft:screen.left,a=void 0!==window.screenTop?window.screenTop:screen.top,u=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,s=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;i.left=u/2-i.width/2+d,i.top=s/2-i.height/2+a}}else console.warn("width and height window features must be present when a center prop is provided");this.window=window.open(n,r,function(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(",")}(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&&function(e,t){Array.from(e.styleSheets).forEach(function(n){if(n.cssRules){var o=e.createElement("style");Array.from(n.cssRules).forEach(function(t){o.appendChild(e.createTextNode(t.cssText))}),t.head.appendChild(o)}else if(n.href){var r=e.createElement("link");r.rel="stylesheet",r.href=n.href,t.head.appendChild(r)}})}(document,this.window.document),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)}}}]),c}();return i.defaultProps={url:"",name:"",title:"",features:{},onBlock:null,onUnload:null,center:"parent",copyStyles:!0},i});
//# sourceMappingURL=react-new-window.umd.js.map
{
"name": "react-new-window",
"description": "🔲 Pop a new window React using window.open",
"version": "0.0.3",
"version": "0.0.4",
"main": "dist/react-new-window.js",

@@ -6,0 +6,0 @@ "module": "dist/react-new-window.esm.js",

@@ -13,3 +13,3 @@ <div align=center>

- **Only 3.3KB** (that's 1.4 gzipped!).
- **Only 3.7KB** (that's 1.6KB gzipped!).
- **Support the full `window.open` api**.

@@ -77,2 +77,3 @@ - **Built for React 16** (uses `ReactDOM.createPortal`).

4. Push new created tag: `git push origin --tags`.
5. Publish: `npm publish`.

@@ -79,0 +80,0 @@ ### Prior work

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