Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-to-print

Package Overview
Dependencies
Maintainers
1
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-to-print - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

lib/index.js.map

2

lib/index.js

@@ -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 &lt;style> and &lt;link type="stylesheet" /> from <head> inside the parent window into the print window. (default: true)
|**`copyStyles`**|boolean|Copies all &lt;style> and &lt;link type="stylesheet" /> from <head> inside the parent window into the print window. (default: true)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc