react-to-print
Advanced tools
Comparing version 1.0.12 to 1.0.13
@@ -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=require("react-dom"),propTypes=_interopDefault(require("prop-types")),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 r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),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},toConsumableArray=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},ReactToPrint=function(e){function t(){classCallCheck(this,t);var e=possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.handlePrint=function(){var t=e.props,r=t.content,n=t.copyStyles,o=(t.onBeforePrint,t.onAfterPrint),a=window.open("","Print","status=no, toolbar=no, scrollbars=yes","false");o&&(a.onbeforeunload=o);var i=r(),c=reactDom.findDOMNode(i),u=[].concat(toConsumableArray(c.getElementsByTagName("img")));e.imageTotal=u.length,e.imageLoaded=0;var l=function(){e.imageLoaded++,e.imageLoaded===e.imageTotal&&e.triggerPrint(a)};if([].concat(toConsumableArray(u)).forEach(function(e){e.setAttribute("src",e.src),e.onload=l,e.onerror=l}),!1!==n){var s=document.querySelectorAll('style, link[rel="stylesheet"]');[].concat(toConsumableArray(s)).forEach(function(e){var t=a.document.createElement(e.tagName);e.textContent?t.textContent=e.textContent:e.innerText&&(t.innerText=e.innerText);[].concat(toConsumableArray(e.attributes)).forEach(function(e){var r=e.nodeValue;"href"===e.nodeName&&!1===/^https?:\/\//.test(e.nodeValue)&&(r=document.location.protocol+"//"+document.location.host+r),t.setAttribute(e.nodeName,r)}),a.document.head.appendChild(t)})}if(document.body.className){document.body.className.split(" ").map(function(e){return a.document.body.classList.add(e)})}var f=a.document.createElement("style");f.appendChild(a.document.createTextNode("@page { size: auto; margin: 0mm; } @media print { body { -webkit-print-color-adjust: exact; } }")),a.document.head.appendChild(f),a.document.body.innerHTML=c.outerHTML,0===e.imageTotal&&e.triggerPrint(a)},e.imageTotal=0,e.imageLoaded=0,e}return inherits(t,e),createClass(t,[{key:"triggerPrint",value:function(e){var t=this;setTimeout(function(){t.props.onBeforePrint&&t.props.onBeforePrint(),e.print(),e.close()},500)}},{key:"render",value:function(){var e=this;return React.cloneElement(this.props.trigger(),{ref:function(t){return e.triggerRef=t},onClick:this.handlePrint})}}]),t}(React.Component);ReactToPrint.defaultProps={copyStyles:!0},module.exports=ReactToPrint; | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=_interopDefault(require("react")),reactDom=require("react-dom"),propTypes=_interopDefault(require("prop-types")),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 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}}(),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},toConsumableArray=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)},ReactToPrint=function(e){function t(){var e,n,r,o;classCallCheck(this,t);for(var a=arguments.length,i=Array(a),l=0;l<a;l++)i[l]=arguments[l];return n=r=possibleConstructorReturn(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(i))),r.handlePrint=function(){var e=r.props,t=e.content,n=e.copyStyles,o=(e.onBeforePrint,e.onAfterPrint),a=window.open("","Print","status=no, toolbar=no, scrollbars=yes","false");o&&(a.onbeforeunload=o);var i=t(),l=reactDom.findDOMNode(i),c=[].concat(toConsumableArray(l.getElementsByTagName("img"))),u=document.querySelectorAll('link[rel="stylesheet"]');r.imageTotal=c.length,r.imageLoaded=0,r.linkTotal=u.length,r.linkLoaded=0;var s=function(e){"image"===e?r.imageLoaded++:"link"===e&&r.linkLoaded++,r.imageLoaded===r.imageTotal&&r.linkLoaded===r.linkTotal&&r.triggerPrint(a)};if([].concat(toConsumableArray(c)).forEach(function(e){e.setAttribute("src",e.src),e.onload=s.bind(null,"image"),e.onerror=s.bind(null,"image")}),!1!==n){var d=document.querySelectorAll('style, link[rel="stylesheet"]');[].concat(toConsumableArray(d)).forEach(function(e){var t=a.document.createElement(e.tagName);e.textContent?t.textContent=e.textContent:e.innerText&&(t.innerText=e.innerText);[].concat(toConsumableArray(e.attributes)).forEach(function(e){var n=e.nodeValue;"href"===e.nodeName&&!1===/^https?:\/\//.test(e.nodeValue)&&(n=document.location.protocol+"//"+document.location.host+n),t.setAttribute(e.nodeName,n)}),"LINK"===e.tagName&&(t.onload=s.bind(null,"link"),t.onerror=s.bind(null,"link")),a.document.head.appendChild(t)})}if(document.body.className){document.body.className.split(" ").map(function(e){return a.document.body.classList.add(e)})}var f=a.document.createElement("style");f.appendChild(a.document.createTextNode("@page { size: auto; margin: 0mm; } @media print { body { -webkit-print-color-adjust: exact; } }")),a.document.head.appendChild(f),a.document.body.innerHTML=l.outerHTML,0!==r.imageTotal&&!1!==n||r.triggerPrint(a)},o=n,possibleConstructorReturn(r,o)}return inherits(t,e),createClass(t,[{key:"triggerPrint",value:function(e){var t=this;setTimeout(function(){t.props.onBeforePrint&&t.props.onBeforePrint(),e.print(),e.close()},500)}},{key:"render",value:function(){var e=this;return React.cloneElement(this.props.trigger(),{ref:function(t){return e.triggerRef=t},onClick:this.handlePrint})}}]),t}(React.Component);ReactToPrint.defaultProps={copyStyles:!0},module.exports=ReactToPrint; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "react-to-print", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "Print React components in the browser", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
15778
16