react-to-print
Advanced tools
Comparing version 2.0.0-beta-1 to 2.0.0-beta-2
@@ -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 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.onAfterPrint,document.createElement("iframe"));o.style.position="absolute",o.style.top="-1000px",o.style.left="-1000px";var a=t(),i=reactDom.findDOMNode(a),l=document.querySelectorAll('link[rel="stylesheet"]');r.linkTotal=l.length,r.linkLoaded=0;var c=function(e){r.linkLoaded++,r.linkLoaded===r.linkTotal&&r.triggerPrint(o.contentWindow)};o.onload=function(){var e=o.contentDocument||o.contentWindow.document;e.open(),e.write(i.outerHTML),e.close();var t=e.createElement("style");if(t.appendChild(e.createTextNode("@page { size: auto; margin: 0mm; } @media print { body { color-adjust: exact !important; -webkit-print-color-adjust: exact; -ms-print-color-adjust: exact; } }")),e.head.appendChild(t),!1!==n){var r=document.querySelectorAll('style, link[rel="stylesheet"]');[].concat(toConsumableArray(r)).forEach(function(t){var n=(o.contentDocument||o.document).createElement(t.tagName);t.textContent?n.textContent=t.textContent:t.innerText&&(n.innerText=t.innerText);[].concat(toConsumableArray(t.attributes)).forEach(function(e){n.setAttribute(e.nodeName,e.nodeValue)}),"LINK"===t.tagName&&(n.onload=c.bind(null,"link"),n.onerror=c.bind(null,"link")),e.head.appendChild(n)})}},document.body.appendChild(o),r.props.debug&&(console.log("** DEBUG MODE **"),console.log(o.document))},o=n,possibleConstructorReturn(r,o)}return inherits(t,e),createClass(t,[{key:"triggerPrint",value:function(e){var t=this;this.props.onBeforePrint&&this.props.onBeforePrint(),setTimeout(function(){t.props.debug||(e.focus(),e.print(),t.props.closeAfterPrint&&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,closeAfterPrint:!0,bodyClass:"",debug:!1},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 i=arguments.length,a=Array(i),l=0;l<i;l++)a[l]=arguments[l];return n=r=possibleConstructorReturn(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(a))),r.handlePrint=function(){var e=r.props,t=e.content,n=e.copyStyles,o=(e.onAfterPrint,document.createElement("iframe"));o.style.position="absolute",o.style.top="-1000px",o.style.left="-1000px";var i=t(),a=reactDom.findDOMNode(i),l=document.querySelectorAll('link[rel="stylesheet"]');r.linkTotal=l.length,r.linkLoaded=0;var c=function(e){r.linkLoaded++,r.linkLoaded===r.linkTotal&&r.triggerPrint(o.contentWindow)};o.onload=function(){var e=o.contentDocument||o.contentWindow.document;e.open(),e.write(a.outerHTML),e.close();var t=e.createElement("style");if(t.appendChild(e.createTextNode("@page { size: auto; margin: 0mm; } @media print { body { -webkit-print-color-adjust: exact; } }")),e.head.appendChild(t),!1!==n){var r=document.querySelectorAll('style, link[rel="stylesheet"]');[].concat(toConsumableArray(r)).forEach(function(t){var n=(o.contentDocument||o.document).createElement(t.tagName);t.textContent?n.textContent=t.textContent:t.innerText&&(n.innerText=t.innerText);[].concat(toConsumableArray(t.attributes)).forEach(function(e){n.setAttribute(e.nodeName,e.nodeValue)}),"LINK"===t.tagName&&(n.onload=c.bind(null,"link"),n.onerror=c.bind(null,"link")),e.head.appendChild(n)})}},document.body.appendChild(o)},o=n,possibleConstructorReturn(r,o)}return inherits(t,e),createClass(t,[{key:"triggerPrint",value:function(e){var t=this;this.props.onBeforePrint&&this.props.onBeforePrint(),setTimeout(function(){e.focus(),e.print(),t.props.closeAfterPrint&&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,closeAfterPrint:!0,bodyClass:""},module.exports=ReactToPrint; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "react-to-print", | ||
"version": "2.0.0-beta-1", | ||
"version": "2.0.0-beta-2", | ||
"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
14045