authscape 1.0.130 → 1.0.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +39 -0
- package/package.json +3 -1
- package/src/components/pageToPDF.js +31 -0
package/index.js
CHANGED
|
@@ -717,6 +717,45 @@ var FileUploader = function FileUploader(_ref) {
|
|
|
717
717
|
exports.FileUploader = FileUploader;
|
|
718
718
|
"use strict";
|
|
719
719
|
|
|
720
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
721
|
+
Object.defineProperty(exports, "__esModule", {
|
|
722
|
+
value: true
|
|
723
|
+
});
|
|
724
|
+
exports.PageToPDF = void 0;
|
|
725
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
726
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
727
|
+
var _html2canvas = _interopRequireDefault(require("html2canvas"));
|
|
728
|
+
var _jspdf = require("jspdf");
|
|
729
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
730
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
731
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
732
|
+
var PageToPDF = function PageToPDF(_ref) {
|
|
733
|
+
var _ref$buttonText = _ref.buttonText,
|
|
734
|
+
buttonText = _ref$buttonText === void 0 ? "Download" : _ref$buttonText,
|
|
735
|
+
_ref$variant = _ref.variant,
|
|
736
|
+
variant = _ref$variant === void 0 ? "contained" : _ref$variant,
|
|
737
|
+
elementById = _ref.elementById,
|
|
738
|
+
_ref$fileName = _ref.fileName,
|
|
739
|
+
fileName = _ref$fileName === void 0 ? "download.pdf" : _ref$fileName;
|
|
740
|
+
var printElement = function printElement() {
|
|
741
|
+
var input = document.getElementById(elementById);
|
|
742
|
+
(0, _html2canvas["default"])(input).then(function (canvas) {
|
|
743
|
+
var imgData = canvas.toDataURL('image/png');
|
|
744
|
+
var pdf = new _jspdf.jsPDF();
|
|
745
|
+
pdf.addImage(imgData, 'JPEG', 0, 0);
|
|
746
|
+
pdf.save(fileName);
|
|
747
|
+
});
|
|
748
|
+
};
|
|
749
|
+
return /*#__PURE__*/_react["default"].createElement(_Box["default"], null, /*#__PURE__*/_react["default"].createElement(Button, {
|
|
750
|
+
variant: variant,
|
|
751
|
+
onClick: function onClick() {
|
|
752
|
+
printElement();
|
|
753
|
+
}
|
|
754
|
+
}, buttonText));
|
|
755
|
+
};
|
|
756
|
+
exports.PageToPDF = PageToPDF;
|
|
757
|
+
"use strict";
|
|
758
|
+
|
|
720
759
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
721
760
|
Object.defineProperty(exports, "__esModule", {
|
|
722
761
|
value: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "authscape",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.133",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
"@stripe/stripe-js": "^1.32.0",
|
|
33
33
|
"axios": "^0.27.2",
|
|
34
34
|
"eslint-config-next": "^13.3.2",
|
|
35
|
+
"html2canvas": "^1.4.1",
|
|
35
36
|
"js-file-download": "^0.4.12",
|
|
37
|
+
"jspdf": "^2.5.1",
|
|
36
38
|
"next": "^13.3.2",
|
|
37
39
|
"nookies": "^2.5.2",
|
|
38
40
|
"query-string": "^7.1.1",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, {useEffect, useState} from 'react';
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import html2canvas from 'html2canvas';
|
|
4
|
+
import { jsPDF } from "jspdf";
|
|
5
|
+
|
|
6
|
+
export const PageToPDF = ({buttonText = "Download", variant = "contained", elementById, fileName = "download.pdf"}) => {
|
|
7
|
+
|
|
8
|
+
const printElement = () => {
|
|
9
|
+
|
|
10
|
+
const input = document.getElementById(elementById);
|
|
11
|
+
html2canvas(input)
|
|
12
|
+
.then((canvas) => {
|
|
13
|
+
const imgData = canvas.toDataURL('image/png');
|
|
14
|
+
const pdf = new jsPDF();
|
|
15
|
+
pdf.addImage(imgData, 'JPEG', 0, 0);
|
|
16
|
+
pdf.save(fileName);
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Box>
|
|
22
|
+
<Button variant={variant} onClick={() => {
|
|
23
|
+
|
|
24
|
+
printElement();
|
|
25
|
+
|
|
26
|
+
}}>{buttonText}</Button>
|
|
27
|
+
</Box>
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
};
|