react-new-window
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -1,2 +0,2 @@ | ||
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.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(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),"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){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,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 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; | ||
//# sourceMappingURL=react-new-window.js.map |
@@ -1,2 +0,2 @@ | ||
"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 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.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(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),"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){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,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";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; | ||
//# sourceMappingURL=react-new-window.js.map |
{ | ||
"name": "react-new-window", | ||
"description": "🔲 Pop a new window in React, using window.open", | ||
"version": "0.1.2", | ||
"description": "Pop a new window in React, using window.open API", | ||
"version": "0.1.3", | ||
"keywords": [ | ||
@@ -16,3 +16,3 @@ "react", | ||
"author": "Rubens Mariuzzo <rubens@mariuzzo.com>", | ||
"license": "MIT", | ||
"license": "SEE LICENSE IN ./LICENSE", | ||
"files": [ | ||
@@ -43,3 +43,2 @@ "lib", | ||
"jest": "^22.4.4", | ||
"np": "^2.20.1", | ||
"prettier": "^1.17.1", | ||
@@ -50,2 +49,3 @@ "pretty-quick": "^1.11.0", | ||
"react-test-renderer": "^16.8.6", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^0.57.1", | ||
@@ -66,8 +66,8 @@ "rollup-plugin-babel": "^4.3.2", | ||
"build": "cross-env NODE_ENV=production rollup -c", | ||
"release": "np", | ||
"prerelease": "npm run lint && npm run build", | ||
"clean": "rimraf 'es' 'lib' 'umd'", | ||
"build-storybook": "cross-env NODE_ENV=test build-storybook -o docs", | ||
"lint": "eslint ./src", | ||
"storybook": "cross-env NODE_ENV=test start-storybook -p 6006", | ||
"build-storybook": "cross-env NODE_ENV=test build-storybook -o docs" | ||
"postversion": "git push origin && git push origin --tags", | ||
"storybook": "cross-env NODE_ENV=test start-storybook -p 6006" | ||
} | ||
} |
@@ -66,3 +66,3 @@ [![React New Window - Pop new windows in React, using window.open API.](.github/banner.svg)](#features) | ||
```sh | ||
npm run release | ||
npm version | ||
``` | ||
@@ -69,0 +69,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";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 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=a(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,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.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),"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(P,"defaultProps",{url:"",name:"",title:"",features:{width:"600px",height:"640px"},onBlock:null,onOpen: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,onOpen:g.func,center:g.oneOf(["parent","screen"]),copyStyles:g.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 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}); | ||
//# 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
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
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
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
206057
217
1
1