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

react-to-print

Package Overview
Dependencies
Maintainers
2
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 2.2.0 to 2.2.1

4

CHANGELOG.md
# CHANGELOG
## 2.2.1 (July 22nd, 2019)
- FIX [149](https://github.com/gregnb/react-to-print/pull/149): Print window would not open if `onBeforePrint` was not given. Thanks [aviklai](https://github.com/aviklai)
## 2.2.0 (July 19th, 2019)

@@ -4,0 +8,0 @@

2

lib/index.js

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define("lib",["react","react-dom"],e):"object"==typeof exports?exports.lib=e(require("react"),require("react-dom")):t.lib=e(t.react,t["react-dom"])}("undefined"!=typeof self?self:this,function(t,e){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(1),o=n(2),i=n(3),a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.startPrint=function(t,e){setTimeout(function(){t.contentWindow.focus(),t.contentWindow.print(),e&&e()},500)},e.triggerPrint=function(t){var n=e.props,r=n.onBeforePrint,o=n.onAfterPrint;if(r){var i=r();i&&"function"==typeof i.then?i.then(function(){e.startPrint(t,o)}):e.startPrint(t,o)}},e.handlePrint=function(){var t=e.props,n=t.bodyClass,r=void 0===n?"":n,o=t.content,a=t.copyStyles,u=void 0===a||a,c=t.pageStyle,l=o();if(void 0!==l){var f=document.createElement("iframe");f.style.position="absolute",f.style.top="-1000px",f.style.left="-1000px",f.id="printWindow";var s=i.findDOMNode(l),d=document.querySelectorAll("link[rel='stylesheet']");e.linkTotal=d.length||0,e.linksLoaded=[],e.linksErrored=[];var p=function(t,n){n?e.linksLoaded.push(t):(console.error('"react-to-print" was unable to load a link. It may be invalid. "react-to-print" will continue attempting to print the page. The link the errored was:',t),e.linksErrored.push(t)),e.linksLoaded.length+e.linksErrored.length===e.linkTotal&&e.triggerPrint(f)};f.onload=function(){window.navigator&&window.navigator.userAgent.indexOf("Trident/7.0")>-1&&(f.onload=null);var t=f.contentDocument||f.contentWindow.document,n=s.querySelectorAll("canvas");t.open(),t.write(s.outerHTML),t.close();var o=void 0===c?"@page { size: auto; margin: 0mm; } @media print { body { -webkit-print-color-adjust: exact; } }":c,i=t.createElement("style");i.appendChild(t.createTextNode(o)),t.head.appendChild(i),r.length&&t.body.classList.add(r);for(var a=t.querySelectorAll("canvas"),l=0,d=a.length;l<d;++l){(h=a[l]).getContext("2d").drawImage(n[l],0,0)}if(!1!==u){var y=document.querySelectorAll("style, link[rel='stylesheet']");for(l=0,d=y.length;l<d;++l){var h;if("STYLE"===(h=y[l]).tagName){var b=t.createElement(h.tagName),v=h.sheet;if(v){for(var m="",g=0;g<v.cssRules.length;g++)"string"==typeof v.cssRules[g].cssText&&(m+=v.cssRules[g].cssText+"\r\n");b.setAttribute("id","react-to-print-"+l),b.appendChild(t.createTextNode(m)),t.head.appendChild(b)}}else if(h.hasAttribute("href")&&h.getAttribute("href")){b=t.createElement(h.tagName),g=0;for(var _=h.attributes.length;g<_;++g){var w=h.attributes[g];b.setAttribute(w.nodeName,w.nodeValue)}b.onload=p.bind(null,b,!0),b.onerror=p.bind(null,b,!1),t.head.appendChild(b)}else console.warn('"react-to-print" encountered a <link> tag with an empty "href" attribute. In addition to being invalid HTML, this can cause problems in many browsers, and so the <link> was not loaded. The <link> is:',h),p(h,!0)}}0!==e.linkTotal&&!1!==u||e.triggerPrint(f)},document.getElementById("printWindow")&&document.body.removeChild(document.getElementById("printWindow")),document.body.appendChild(f)}else console.error('Refs are not available for stateless components. For "react-to-print" to work only Class based components can be printed')},e.setRef=function(t){e.triggerRef=t},e}return r.__extends(e,t),e.prototype.render=function(){var t=this.props.trigger;return o.cloneElement(t(),{onClick:this.handlePrint,ref:this.setRef})},e}(o.Component);e.default=a},function(t,e,n){"use strict";n.r(e),n.d(e,"__extends",function(){return o}),n.d(e,"__assign",function(){return i}),n.d(e,"__rest",function(){return a}),n.d(e,"__decorate",function(){return u}),n.d(e,"__param",function(){return c}),n.d(e,"__metadata",function(){return l}),n.d(e,"__awaiter",function(){return f}),n.d(e,"__generator",function(){return s}),n.d(e,"__exportStar",function(){return d}),n.d(e,"__values",function(){return p}),n.d(e,"__read",function(){return y}),n.d(e,"__spread",function(){return h}),n.d(e,"__await",function(){return b}),n.d(e,"__asyncGenerator",function(){return v}),n.d(e,"__asyncDelegator",function(){return m}),n.d(e,"__asyncValues",function(){return g}),n.d(e,"__makeTemplateObject",function(){return _}),n.d(e,"__importStar",function(){return w}),n.d(e,"__importDefault",function(){return x});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define("lib",["react","react-dom"],e):"object"==typeof exports?exports.lib=e(require("react"),require("react-dom")):t.lib=e(t.react,t["react-dom"])}("undefined"!=typeof self?self:this,function(t,e){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(1),o=n(2),i=n(3),a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.startPrint=function(t,e){setTimeout(function(){t.contentWindow.focus(),t.contentWindow.print(),e&&e()},500)},e.triggerPrint=function(t){var n=e.props,r=n.onBeforePrint,o=n.onAfterPrint;if(r){var i=r();i&&"function"==typeof i.then?i.then(function(){e.startPrint(t,o)}):e.startPrint(t,o)}else e.startPrint(t,o)},e.handlePrint=function(){var t=e.props,n=t.bodyClass,r=void 0===n?"":n,o=t.content,a=t.copyStyles,u=void 0===a||a,c=t.pageStyle,l=o();if(void 0!==l){var f=document.createElement("iframe");f.style.position="absolute",f.style.top="-1000px",f.style.left="-1000px",f.id="printWindow";var s=i.findDOMNode(l),d=document.querySelectorAll("link[rel='stylesheet']");e.linkTotal=d.length||0,e.linksLoaded=[],e.linksErrored=[];var p=function(t,n){n?e.linksLoaded.push(t):(console.error('"react-to-print" was unable to load a link. It may be invalid. "react-to-print" will continue attempting to print the page. The link the errored was:',t),e.linksErrored.push(t)),e.linksLoaded.length+e.linksErrored.length===e.linkTotal&&e.triggerPrint(f)};f.onload=function(){window.navigator&&window.navigator.userAgent.indexOf("Trident/7.0")>-1&&(f.onload=null);var t=f.contentDocument||f.contentWindow.document,n=s.querySelectorAll("canvas");t.open(),t.write(s.outerHTML),t.close();var o=void 0===c?"@page { size: auto; margin: 0mm; } @media print { body { -webkit-print-color-adjust: exact; } }":c,i=t.createElement("style");i.appendChild(t.createTextNode(o)),t.head.appendChild(i),r.length&&t.body.classList.add(r);for(var a=t.querySelectorAll("canvas"),l=0,d=a.length;l<d;++l){(h=a[l]).getContext("2d").drawImage(n[l],0,0)}if(!1!==u){var y=document.querySelectorAll("style, link[rel='stylesheet']");for(l=0,d=y.length;l<d;++l){var h;if("STYLE"===(h=y[l]).tagName){var b=t.createElement(h.tagName),v=h.sheet;if(v){for(var m="",g=0;g<v.cssRules.length;g++)"string"==typeof v.cssRules[g].cssText&&(m+=v.cssRules[g].cssText+"\r\n");b.setAttribute("id","react-to-print-"+l),b.appendChild(t.createTextNode(m)),t.head.appendChild(b)}}else if(h.hasAttribute("href")&&h.getAttribute("href")){b=t.createElement(h.tagName),g=0;for(var _=h.attributes.length;g<_;++g){var w=h.attributes[g];b.setAttribute(w.nodeName,w.nodeValue)}b.onload=p.bind(null,b,!0),b.onerror=p.bind(null,b,!1),t.head.appendChild(b)}else console.warn('"react-to-print" encountered a <link> tag with an empty "href" attribute. In addition to being invalid HTML, this can cause problems in many browsers, and so the <link> was not loaded. The <link> is:',h),p(h,!0)}}0!==e.linkTotal&&!1!==u||e.triggerPrint(f)},document.getElementById("printWindow")&&document.body.removeChild(document.getElementById("printWindow")),document.body.appendChild(f)}else console.error('Refs are not available for stateless components. For "react-to-print" to work only Class based components can be printed')},e.setRef=function(t){e.triggerRef=t},e}return r.__extends(e,t),e.prototype.render=function(){var t=this.props.trigger;return o.cloneElement(t(),{onClick:this.handlePrint,ref:this.setRef})},e}(o.Component);e.default=a},function(t,e,n){"use strict";n.r(e),n.d(e,"__extends",function(){return o}),n.d(e,"__assign",function(){return i}),n.d(e,"__rest",function(){return a}),n.d(e,"__decorate",function(){return u}),n.d(e,"__param",function(){return c}),n.d(e,"__metadata",function(){return l}),n.d(e,"__awaiter",function(){return f}),n.d(e,"__generator",function(){return s}),n.d(e,"__exportStar",function(){return d}),n.d(e,"__values",function(){return p}),n.d(e,"__read",function(){return y}),n.d(e,"__spread",function(){return h}),n.d(e,"__await",function(){return b}),n.d(e,"__asyncGenerator",function(){return v}),n.d(e,"__asyncDelegator",function(){return m}),n.d(e,"__asyncValues",function(){return g}),n.d(e,"__makeTemplateObject",function(){return _}),n.d(e,"__importStar",function(){return w}),n.d(e,"__importDefault",function(){return x});
/*! *****************************************************************************

@@ -3,0 +3,0 @@ Copyright (c) Microsoft Corporation. All rights reserved.

{
"name": "react-to-print",
"version": "2.2.0",
"version": "2.2.1",
"description": "Print React components in the browser",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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