react-new-window
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -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}function makeEmptyFunction(e){return function(){return e}}var emptyFunction=function(){};emptyFunction.thatReturns=makeEmptyFunction,emptyFunction.thatReturnsFalse=makeEmptyFunction(!1),emptyFunction.thatReturnsTrue=makeEmptyFunction(!0),emptyFunction.thatReturnsNull=makeEmptyFunction(null),emptyFunction.thatReturnsThis=function(){return this},emptyFunction.thatReturnsArgument=function(e){return e};var emptyFunction_1=emptyFunction;function invariant(e,t,n,o,r,i,c,s){if(!e){var a;if(void 0===t)a=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var p=[n,o,r,i,c,s],u=0;(a=new Error(t.replace(/%s/g,function(){return p[u++]}))).name="Invariant Violation"}throw a.framesToPop=1,a}}var invariant_1=invariant,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,factoryWithThrowingShims=function(){function e(e,t,n,o,r,i){i!==ReactPropTypesSecret_1&&invariant_1(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function 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_1,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}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,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:screen.width,l=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight: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(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 createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}function makeEmptyFunction(e){return function(){return e}}var emptyFunction=function(){};emptyFunction.thatReturns=makeEmptyFunction,emptyFunction.thatReturnsFalse=makeEmptyFunction(!1),emptyFunction.thatReturnsTrue=makeEmptyFunction(!0),emptyFunction.thatReturnsNull=makeEmptyFunction(null),emptyFunction.thatReturnsThis=function(){return this},emptyFunction.thatReturnsArgument=function(e){return e};var emptyFunction_1=emptyFunction;function invariant(e,t,n,o,r,i,c,s){if(!e){var a;if(void 0===t)a=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var p=[n,o,r,i,c,s],u=0;(a=new Error(t.replace(/%s/g,function(){return p[u++]}))).name="Invariant Violation"}throw a.framesToPop=1,a}}var invariant_1=invariant,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,factoryWithThrowingShims=function(){function e(e,t,n,o,r,i){i!==ReactPropTypesSecret_1&&invariant_1(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function 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_1,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,p=void 0!==window.screenTop?window.screenTop:screen.top,u=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,l=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight: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(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; | ||
//# sourceMappingURL=react-new-window.js.map |
{ | ||
"name": "react-new-window", | ||
"description": "🔲 Pop a new window React using window.open", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "react", |
@@ -40,2 +40,5 @@ /** | ||
this.released = false | ||
this.state = { | ||
mounted: false | ||
}; | ||
} | ||
@@ -47,9 +50,15 @@ | ||
render() { | ||
if (!this.state.mounted) return null; | ||
return ReactDOM.createPortal(this.props.children, this.container) | ||
} | ||
componentDidMount() { | ||
this.openChild(); | ||
this.setState({mounted: true}); | ||
} | ||
/** | ||
* Create the new window when NewWindow component mount. | ||
*/ | ||
componentDidMount() { | ||
openChild() { | ||
const { url, title, name, features, onBlock, center } = this.props | ||
@@ -56,0 +65,0 @@ |
@@ -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";function n(e){return function(){return e}}e=e&&e.hasOwnProperty("default")?e.default:e,t=t&&t.hasOwnProperty("default")?t.default:t;var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e};var o=r;var i=function(e,t,n,r,o,i,c,a){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[n,r,o,i,c,a],l=0;(s=new Error(t.replace(/%s/g,function(){return u[l++]}))).name="Invariant Violation"}throw s.framesToPop=1,s}},c=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=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 r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}})()&&Object.assign;var u,l="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",d=(function(e){e.exports=function(){function e(e,t,n,r,o,c){c!==l&&i(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function 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=o,n.PropTypes=n,n}()}(u={exports:{}},u.exports),u.exports),p=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},f=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),h=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},w=function(n){function r(e){p(this,r);var t=h(this,(r.__proto__||Object.getPrototypeOf(r)).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)}(r,e.PureComponent),f(r,[{key:"render",value:function(){return t.createPortal(this.props.children,this.container)}},{key:"componentDidMount",value:function(){var e,t=this,n=this.props,r=n.url,o=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 u=void 0!==window.screenLeft?window.screenLeft:screen.left,l=void 0!==window.screenTop?window.screenTop:screen.top,d=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,p=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;c.left=d/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(r,i,(e=c,Object.keys(e).reduce(function(t,n){var r=e[n];return"boolean"==typeof r?t.push(n+"="+(r?"yes":"no")):t.push(n+"="+r),t},[]).join(","))),this.windowCheckerInterval=setInterval(function(){t.window&&!t.window.closed||t.release()},50),this.window?(this.window.document.title=o,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 r=void 0;try{r=t.cssRules}catch(e){console.error(e)}if(r){var o=e.createElement("style");Array.from(t.cssRules).forEach(function(t){var n=t.cssText,r=t.type,i=n;[3,5].includes(r)&&(i=n.split("url(").map(function(e){return"/"===e[1]?""+e.slice(0,1)+window.location.origin+e.slice(1):e}).join("url(")),o.appendChild(e.createTextNode(i))}),n.head.appendChild(o)}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)}}}]),r}();return w.defaultProps={url:"",name:"",title:"",features:{width:"600px",height:"640px"},onBlock:null,onUnload:null,center:"parent",copyStyles:!0},w.propTypes={children:d.node,url:d.string,name:d.string,title:d.string,features:d.object,onUnload:d.func,onBlock:d.func,center:d.oneOf(["parent","screen"]),copyStyles:d.bool},w}); | ||
!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";function n(e){return function(){return e}}e=e&&e.hasOwnProperty("default")?e.default:e,t=t&&t.hasOwnProperty("default")?t.default:t;var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e};var o=r;var i=function(e,t,n,r,o,i,c,a){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[n,r,o,i,c,a],l=0;(s=new Error(t.replace(/%s/g,function(){return u[l++]}))).name="Invariant Violation"}throw s.framesToPop=1,s}},c=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=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 r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}})()&&Object.assign;var u,l="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",d=(function(e){e.exports=function(){function e(e,t,n,r,o,c){c!==l&&i(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function 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=o,n.PropTypes=n,n}()}(u={exports:{}},u.exports),u.exports),p=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},f=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),h=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},w=function(n){function r(e){p(this,r);var t=h(this,(r.__proto__||Object.getPrototypeOf(r)).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)}(r,e.PureComponent),f(r,[{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,r=n.url,o=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 u=void 0!==window.screenLeft?window.screenLeft:screen.left,l=void 0!==window.screenTop?window.screenTop:screen.top,d=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,p=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;c.left=d/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(r,i,(e=c,Object.keys(e).reduce(function(t,n){var r=e[n];return"boolean"==typeof r?t.push(n+"="+(r?"yes":"no")):t.push(n+"="+r),t},[]).join(","))),this.windowCheckerInterval=setInterval(function(){t.window&&!t.window.closed||t.release()},50),this.window?(this.window.document.title=o,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 r=void 0;try{r=t.cssRules}catch(e){console.error(e)}if(r){var o=e.createElement("style");Array.from(t.cssRules).forEach(function(t){var n=t.cssText,r=t.type,i=n;[3,5].includes(r)&&(i=n.split("url(").map(function(e){return"/"===e[1]?""+e.slice(0,1)+window.location.origin+e.slice(1):e}).join("url(")),o.appendChild(e.createTextNode(i))}),n.head.appendChild(o)}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)}}}]),r}();return w.defaultProps={url:"",name:"",title:"",features:{width:"600px",height:"640px"},onBlock:null,onUnload:null,center:"parent",copyStyles:!0},w.propTypes={children:d.node,url:d.string,name:d.string,title:d.string,features:d.object,onUnload:d.func,onBlock:d.func,center:d.oneOf(["parent","screen"]),copyStyles:d.bool},w}); | ||
//# 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
69910
341
0