react-to-print
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -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},ReactToPrint=function(e){function t(){var e,r,n,o;classCallCheck(this,t);for(var i=arguments.length,c=Array(i),a=0;a<i;a++)c[a]=arguments[a];return r=n=possibleConstructorReturn(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(c))),n.handlePrint=function(){var e=n.props,t=e.content,r=e.copyStyles,o=t(),i=reactDom.findDOMNode(o).outerHTML,c=window.open("","Print","status=no, toolbar=no, scrollbars=yes","false");if(!1!==r){document.head.querySelectorAll("link, style").forEach(function(e){return c.document.head.appendChild(e.cloneNode(!0))})}var a=document.createElement("style");a.appendChild(document.createTextNode("@page { size: auto; margin: 0mm; }")),c.document.head.appendChild(a),c.document.body.innerHTML=i,c.print(),c.close()},o=r,possibleConstructorReturn(n,o)}return inherits(t,e),createClass(t,[{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.propTypes={copyStyles:PropTypes.bool,trigger:PropTypes.func.isRequired,content:PropTypes.func.isRequired},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 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},ReactToPrint=function(e){function t(){var e,r,n,o;classCallCheck(this,t);for(var a=arguments.length,c=Array(a),i=0;i<a;i++)c[i]=arguments[i];return r=n=possibleConstructorReturn(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(c))),n.handlePrint=function(){var e=n.props,t=e.content,r=e.copyStyles,o=t(),a=reactDom.findDOMNode(o).outerHTML,c=window.open("/","Print","status=no, toolbar=no, scrollbars=yes","false");if(!1!==r){document.head.querySelectorAll("link, style").forEach(function(e){return c.document.head.appendChild(e.cloneNode(!0))})}var i=document.createElement("style");i.appendChild(document.createTextNode("@page { size: auto; margin: 0mm; }")),c.document.head.appendChild(i),c.document.body.innerHTML=a,console.log(a),setTimeout(function(){c.print(),c.close()},2250)},o=r,possibleConstructorReturn(n,o)}return inherits(t,e),createClass(t,[{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.4", | ||
"version": "1.0.5", | ||
"description": "Print React components in the browser", | ||
"main": "lib/index.js", | ||
"main": "lib/index.js", | ||
"files": [ | ||
"lib" | ||
], | ||
"scripts": { | ||
@@ -37,2 +41,4 @@ "build": "rollup -c", | ||
"babel-plugin-transform-class-properties": "^6.24.1", | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.4.13", | ||
"babel-preset-env": "^1.6.1", | ||
@@ -45,2 +51,3 @@ "babel-preset-react": "^6.24.1", | ||
"rollup-plugin-commonjs": "^8.2.6", | ||
"rollup-plugin-replace": "^2.0.0", | ||
"rollup-plugin-uglify": "^2.0.1", | ||
@@ -47,0 +54,0 @@ "webpack": "^3.9.1", |
<div align="center"> | ||
<img src="https://user-images.githubusercontent.com/19170080/33643181-7bdcf3da-da0b-11e7-9463-a627a53ff25f.png" /> | ||
<img src="https://user-images.githubusercontent.com/19170080/33672781-14f1b03e-da79-11e7-95fe-4ce15f170230.png" /> | ||
</div> | ||
@@ -88,2 +88,2 @@ | ||
|**`content`**|function|A callback function that returns a component reference value. The content of this reference value is then used for print | ||
|**`copyStyles`**|boolean|Copies all <style> and <link type="stylesheet" /> from <head> inside the parent window into the print window. (default: true) | ||
|**`copyStyles`**|boolean|Copies all <style> and <link type="stylesheet" /> from <head> inside the parent window into the print window. (default: true) |
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
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
89
9986
18
5
10
1