authscape 1.0.154 → 1.0.158
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 +27 -22
- package/package.json +1 -1
- package/src/components/EditableDatagrid.js +2 -4
- package/src/components/pageToPDF.js +26 -18
package/index.js
CHANGED
|
@@ -201,7 +201,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
201
201
|
Object.defineProperty(exports, "__esModule", {
|
|
202
202
|
value: true
|
|
203
203
|
});
|
|
204
|
-
exports
|
|
204
|
+
exports.EditableDatagrid = void 0;
|
|
205
205
|
var _react = _interopRequireWildcard(require("react"));
|
|
206
206
|
var _xDataGrid = require("@mui/x-data-grid");
|
|
207
207
|
var _material = require("@mui/material");
|
|
@@ -331,8 +331,7 @@ var EditableDatagrid = function EditableDatagrid(_ref) {
|
|
|
331
331
|
}
|
|
332
332
|
}));
|
|
333
333
|
};
|
|
334
|
-
|
|
335
|
-
exports["default"] = _default;
|
|
334
|
+
exports.EditableDatagrid = EditableDatagrid;
|
|
336
335
|
"use strict";
|
|
337
336
|
|
|
338
337
|
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); }
|
|
@@ -1141,28 +1140,34 @@ var PageToPDF = function PageToPDF(_ref) {
|
|
|
1141
1140
|
elementById = _ref.elementById,
|
|
1142
1141
|
_ref$scale = _ref.scale,
|
|
1143
1142
|
scale = _ref$scale === void 0 ? 2 : _ref$scale,
|
|
1143
|
+
_ref$onHideElements = _ref.onHideElements,
|
|
1144
|
+
onHideElements = _ref$onHideElements === void 0 ? null : _ref$onHideElements,
|
|
1144
1145
|
_ref$fileName = _ref.fileName,
|
|
1145
1146
|
fileName = _ref$fileName === void 0 ? "download" : _ref$fileName;
|
|
1146
1147
|
var printElement = function printElement() {
|
|
1147
|
-
|
|
1148
|
-
(
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1148
|
+
onHideElements(true);
|
|
1149
|
+
setTimeout(function () {
|
|
1150
|
+
var input = document.getElementById(elementById);
|
|
1151
|
+
(0, _html2canvas["default"])(input, {
|
|
1152
|
+
backgroundColor: null,
|
|
1153
|
+
scale: scale
|
|
1154
|
+
}).then(function (canvas) {
|
|
1155
|
+
var imgData = canvas.toDataURL("image/png", 1.0);
|
|
1156
|
+
var pdf = new _jspdf.jsPDF();
|
|
1157
|
+
var pdfWidth = pdf.internal.pageSize.getWidth();
|
|
1158
|
+
var pdfHeight = pdf.internal.pageSize.getHeight();
|
|
1159
|
+
var imgWidth = canvas.width;
|
|
1160
|
+
var imgHeight = canvas.height;
|
|
1161
|
+
var scaleFactor = Math.min(pdfWidth / imgWidth, pdfHeight / imgHeight);
|
|
1162
|
+
var scaledWidth = imgWidth * scaleFactor;
|
|
1163
|
+
var scaledHeight = imgHeight * scaleFactor;
|
|
1164
|
+
var x = (pdfWidth - scaledWidth) / 2;
|
|
1165
|
+
var y = 0; // Set y coordinate to 0 to align to the top
|
|
1166
|
+
pdf.addImage(imgData, "PNG", x, y, scaledWidth, scaledHeight);
|
|
1167
|
+
pdf.save(fileName + ".pdf");
|
|
1168
|
+
});
|
|
1169
|
+
}, 2000);
|
|
1170
|
+
onHideElements(false);
|
|
1166
1171
|
};
|
|
1167
1172
|
return /*#__PURE__*/_react["default"].createElement(_Box["default"], null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
1168
1173
|
startIcon: startIcon,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import React, {useEffect, useState} from 'react';
|
|
|
2
2
|
import { DataGrid, GridActionsCellItem } from "@mui/x-data-grid";
|
|
3
3
|
import { Box } from '@mui/material';
|
|
4
4
|
|
|
5
|
-
const EditableDatagrid = ({loadedUser, url, columns, isCellEditable = null, onCellEdited = null, sx = {}, height="50vh", pageSize = 50, rowsPerPage = [25, 50, 100], rowHeight = 70}) => {
|
|
5
|
+
export const EditableDatagrid = ({loadedUser, url, columns, isCellEditable = null, onCellEdited = null, sx = {}, height="50vh", pageSize = 50, rowsPerPage = [25, 50, 100], rowHeight = 70}) => {
|
|
6
6
|
|
|
7
7
|
const [rows, setRows] = useState([]);
|
|
8
8
|
const [totalRows, setTotalRows] = useState(0);
|
|
@@ -69,6 +69,4 @@ const EditableDatagrid = ({loadedUser, url, columns, isCellEditable = null, onCe
|
|
|
69
69
|
</Box>
|
|
70
70
|
)
|
|
71
71
|
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export default EditableDatagrid;
|
|
72
|
+
}
|
|
@@ -5,27 +5,35 @@ import { jsPDF } from "jspdf";
|
|
|
5
5
|
import Button from "@mui/material/Button";
|
|
6
6
|
import DownloadRoundedIcon from '@mui/icons-material/DownloadRounded';
|
|
7
7
|
|
|
8
|
-
export const PageToPDF = ({buttonText = "Download", startIcon = <DownloadRoundedIcon/>, variant = "contained", elementById, scale = 2, fileName = "download"}) => {
|
|
8
|
+
export const PageToPDF = ({buttonText = "Download", startIcon = <DownloadRoundedIcon/>, variant = "contained", elementById, scale = 2, onHideElements = null, fileName = "download"}) => {
|
|
9
9
|
|
|
10
10
|
const printElement = () => {
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
onHideElements(true);
|
|
13
|
+
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
|
|
16
|
+
const input = document.getElementById(elementById);
|
|
17
|
+
html2canvas(input, {backgroundColor: null, scale: scale})
|
|
18
|
+
.then((canvas) => {
|
|
19
|
+
const imgData = canvas.toDataURL("image/png", 1.0);
|
|
20
|
+
const pdf = new jsPDF();
|
|
21
|
+
const pdfWidth = pdf.internal.pageSize.getWidth();
|
|
22
|
+
const pdfHeight = pdf.internal.pageSize.getHeight();
|
|
23
|
+
const imgWidth = canvas.width;
|
|
24
|
+
const imgHeight = canvas.height;
|
|
25
|
+
const scaleFactor = Math.min(pdfWidth / imgWidth, pdfHeight / imgHeight);
|
|
26
|
+
const scaledWidth = imgWidth * scaleFactor;
|
|
27
|
+
const scaledHeight = imgHeight * scaleFactor;
|
|
28
|
+
const x = (pdfWidth - scaledWidth) / 2;
|
|
29
|
+
const y = 0; // Set y coordinate to 0 to align to the top
|
|
30
|
+
pdf.addImage(imgData, "PNG", x, y, scaledWidth, scaledHeight);
|
|
31
|
+
pdf.save(fileName + ".pdf");
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
}, 2000);
|
|
35
|
+
|
|
36
|
+
onHideElements(false);
|
|
29
37
|
}
|
|
30
38
|
|
|
31
39
|
|