react-pdf-levelup 2.0.25 → 2.0.28
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/dist/index.js +23 -46
- package/dist/index.mjs +10 -33
- package/package.json +1 -4
package/dist/index.js
CHANGED
|
@@ -527,31 +527,9 @@ var Footer = ({ children, style, fixed = false }) => {
|
|
|
527
527
|
|
|
528
528
|
// src/components/core/QR.tsx
|
|
529
529
|
var import_react8 = __toESM(require("react"));
|
|
530
|
+
var import_react9 = require("react");
|
|
530
531
|
var import_renderer8 = require("@react-pdf/renderer");
|
|
531
532
|
var import_qr_code_styling = __toESM(require("qr-code-styling"));
|
|
532
|
-
if (typeof window === "undefined" && typeof process !== "undefined") {
|
|
533
|
-
try {
|
|
534
|
-
import("jsdom").then((jsdom) => {
|
|
535
|
-
const { JSDOM } = jsdom;
|
|
536
|
-
import("canvas").then((canvas) => {
|
|
537
|
-
const { Canvas, Image: CanvasImage } = canvas;
|
|
538
|
-
const { window: domWindow } = new JSDOM("<!DOCTYPE html><html><body></body></html>");
|
|
539
|
-
global.window = domWindow;
|
|
540
|
-
global.document = domWindow.document;
|
|
541
|
-
global.HTMLElement = domWindow.HTMLElement;
|
|
542
|
-
global.HTMLCanvasElement = Canvas;
|
|
543
|
-
global.CanvasRenderingContext2D = Canvas;
|
|
544
|
-
global.Image = CanvasImage;
|
|
545
|
-
}).catch((err) => {
|
|
546
|
-
console.error("Error loading canvas:", err);
|
|
547
|
-
});
|
|
548
|
-
}).catch((err) => {
|
|
549
|
-
console.error("Error loading jsdom:", err);
|
|
550
|
-
});
|
|
551
|
-
} catch (error) {
|
|
552
|
-
console.error("Error setting up Node.js environment:", error);
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
533
|
var QR = ({
|
|
556
534
|
url,
|
|
557
535
|
size = 200,
|
|
@@ -578,13 +556,10 @@ var QR = ({
|
|
|
578
556
|
textPadding = 1,
|
|
579
557
|
textBold = true
|
|
580
558
|
}) => {
|
|
581
|
-
const [qrDataURL, setQrDataURL] = (0,
|
|
559
|
+
const [qrDataURL, setQrDataURL] = (0, import_react9.useState)(null);
|
|
582
560
|
const actualLogoWidth = logoWidth || Math.floor(size * 0.2);
|
|
583
561
|
const actualLogoHeight = logoHeight || actualLogoWidth;
|
|
584
|
-
(0,
|
|
585
|
-
if (typeof window === "undefined") {
|
|
586
|
-
return;
|
|
587
|
-
}
|
|
562
|
+
(0, import_react9.useEffect)(() => {
|
|
588
563
|
const generateQRCode = async () => {
|
|
589
564
|
try {
|
|
590
565
|
const qrCode = new import_qr_code_styling.default({
|
|
@@ -634,11 +609,11 @@ var QR = ({
|
|
|
634
609
|
}
|
|
635
610
|
document.body.removeChild(container);
|
|
636
611
|
} catch (error) {
|
|
637
|
-
console.error("Error
|
|
612
|
+
console.error("Error capturing QR code:", error);
|
|
638
613
|
}
|
|
639
614
|
}, 100);
|
|
640
615
|
} catch (error) {
|
|
641
|
-
console.error("Error
|
|
616
|
+
console.error("Error generating QR code:", error);
|
|
642
617
|
}
|
|
643
618
|
};
|
|
644
619
|
generateQRCode();
|
|
@@ -659,14 +634,14 @@ var QR = ({
|
|
|
659
634
|
if (!qrDataURL) return null;
|
|
660
635
|
const centerPosition = size / 2;
|
|
661
636
|
const logoContainerSize = Math.max(actualLogoWidth, actualLogoHeight) + 10;
|
|
662
|
-
return /* @__PURE__ */ import_react8.default.createElement(import_renderer8.View, { style: { width: size, height: size, position: "relative", ...style } }, /* @__PURE__ */ import_react8.default.createElement(import_renderer8.Image, { src: qrDataURL, style: { width: size, height: size } }), logo && /* @__PURE__ */ import_react8.default.createElement(
|
|
637
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_renderer8.View, { style: { width: size, height: size, position: "relative", ...style } }, /* @__PURE__ */ import_react8.default.createElement(import_renderer8.Image, { src: qrDataURL || "/placeholder.svg", style: { width: size, height: size } }), logo && /* @__PURE__ */ import_react8.default.createElement(
|
|
663
638
|
import_renderer8.View,
|
|
664
639
|
{
|
|
665
640
|
style: {
|
|
666
641
|
position: "absolute",
|
|
667
642
|
width: logoContainerSize,
|
|
668
643
|
height: logoContainerSize,
|
|
669
|
-
backgroundColor: logoBG,
|
|
644
|
+
backgroundColor: logoBG || colorDataBG,
|
|
670
645
|
left: centerPosition - logoContainerSize / 2,
|
|
671
646
|
top: centerPosition - logoContainerSize / 2,
|
|
672
647
|
borderRadius: 100,
|
|
@@ -677,11 +652,11 @@ var QR = ({
|
|
|
677
652
|
/* @__PURE__ */ import_react8.default.createElement(
|
|
678
653
|
import_renderer8.Image,
|
|
679
654
|
{
|
|
680
|
-
src: logo,
|
|
655
|
+
src: logo || "/placeholder.svg",
|
|
681
656
|
style: {
|
|
682
657
|
objectFit: "contain",
|
|
683
658
|
width: actualLogoWidth,
|
|
684
|
-
height: actualLogoHeight
|
|
659
|
+
height: actualLogoHeight || actualLogoWidth
|
|
685
660
|
}
|
|
686
661
|
}
|
|
687
662
|
)
|
|
@@ -694,7 +669,9 @@ var QR = ({
|
|
|
694
669
|
padding: textPadding,
|
|
695
670
|
borderRadius: 4,
|
|
696
671
|
left: moveText + centerPosition - 20,
|
|
672
|
+
// Approximate center
|
|
697
673
|
top: centerPosition - 10
|
|
674
|
+
// Approximate center
|
|
698
675
|
}
|
|
699
676
|
},
|
|
700
677
|
/* @__PURE__ */ import_react8.default.createElement(
|
|
@@ -714,7 +691,7 @@ var QR = ({
|
|
|
714
691
|
var QR_default = QR;
|
|
715
692
|
|
|
716
693
|
// src/components/core/Lista.tsx
|
|
717
|
-
var
|
|
694
|
+
var import_react10 = __toESM(require("react"));
|
|
718
695
|
var import_renderer9 = require("@react-pdf/renderer");
|
|
719
696
|
var styles8 = import_renderer9.StyleSheet.create({
|
|
720
697
|
ul: {
|
|
@@ -776,9 +753,9 @@ var toRoman = (num) => {
|
|
|
776
753
|
return romanNumerals[3][Math.floor(num / 1e3)] + romanNumerals[2][Math.floor(num % 1e3 / 100)] + romanNumerals[1][Math.floor(num % 100 / 10)] + romanNumerals[0][num % 10];
|
|
777
754
|
};
|
|
778
755
|
var UL = ({ children, style, type = "disc" }) => {
|
|
779
|
-
const childrenWithBullets =
|
|
780
|
-
if (
|
|
781
|
-
return
|
|
756
|
+
const childrenWithBullets = import_react10.default.Children.map(children, (child, index) => {
|
|
757
|
+
if (import_react10.default.isValidElement(child)) {
|
|
758
|
+
return import_react10.default.cloneElement(child, {
|
|
782
759
|
bulletType: type,
|
|
783
760
|
isOrdered: false,
|
|
784
761
|
index: index + 1
|
|
@@ -786,12 +763,12 @@ var UL = ({ children, style, type = "disc" }) => {
|
|
|
786
763
|
}
|
|
787
764
|
return child;
|
|
788
765
|
});
|
|
789
|
-
return /* @__PURE__ */
|
|
766
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_renderer9.View, { style: [styles8.ul, style] }, childrenWithBullets);
|
|
790
767
|
};
|
|
791
768
|
var OL = ({ children, style, type = "decimal", start = 1 }) => {
|
|
792
|
-
const childrenWithNumbers =
|
|
793
|
-
if (
|
|
794
|
-
return
|
|
769
|
+
const childrenWithNumbers = import_react10.default.Children.map(children, (child, index) => {
|
|
770
|
+
if (import_react10.default.isValidElement(child)) {
|
|
771
|
+
return import_react10.default.cloneElement(child, {
|
|
795
772
|
bulletType: type,
|
|
796
773
|
isOrdered: true,
|
|
797
774
|
index: index + 1,
|
|
@@ -800,7 +777,7 @@ var OL = ({ children, style, type = "decimal", start = 1 }) => {
|
|
|
800
777
|
}
|
|
801
778
|
return child;
|
|
802
779
|
});
|
|
803
|
-
return /* @__PURE__ */
|
|
780
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_renderer9.View, { style: [styles8.ol, style] }, childrenWithNumbers);
|
|
804
781
|
};
|
|
805
782
|
var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1, start = 1, value }) => {
|
|
806
783
|
let marker;
|
|
@@ -810,7 +787,7 @@ var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1,
|
|
|
810
787
|
} else {
|
|
811
788
|
marker = getBulletPoint(bulletType);
|
|
812
789
|
}
|
|
813
|
-
return /* @__PURE__ */
|
|
790
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_renderer9.View, { style: [styles8.li, style] }, /* @__PURE__ */ import_react10.default.createElement(import_renderer9.Text, { style: styles8.bulletPoint }, marker), /* @__PURE__ */ import_react10.default.createElement(import_renderer9.View, { style: styles8.itemContent }, typeof children === "string" ? /* @__PURE__ */ import_react10.default.createElement(import_renderer9.Text, null, children) : children));
|
|
814
791
|
};
|
|
815
792
|
|
|
816
793
|
// src/components/core/index.tsx
|
|
@@ -845,13 +822,13 @@ var decodeBase64Pdf_default = decodeBase64Pdf;
|
|
|
845
822
|
|
|
846
823
|
// src/functions/generatePDF.ts
|
|
847
824
|
var import_renderer10 = require("@react-pdf/renderer");
|
|
848
|
-
var
|
|
825
|
+
var import_react11 = require("react");
|
|
849
826
|
var generatePDF = async ({ template: Template, data }) => {
|
|
850
827
|
try {
|
|
851
828
|
if (!Template) {
|
|
852
829
|
throw new Error("Template not provided");
|
|
853
830
|
}
|
|
854
|
-
const MyDocument = (0,
|
|
831
|
+
const MyDocument = (0, import_react11.createElement)(Template, { data });
|
|
855
832
|
const stream = await (0, import_renderer10.renderToStream)(MyDocument);
|
|
856
833
|
const base64String = await new Promise((resolve, reject) => {
|
|
857
834
|
const chunks = [];
|
package/dist/index.mjs
CHANGED
|
@@ -438,32 +438,10 @@ var Footer = ({ children, style, fixed = false }) => {
|
|
|
438
438
|
};
|
|
439
439
|
|
|
440
440
|
// src/components/core/QR.tsx
|
|
441
|
-
import React8
|
|
441
|
+
import React8 from "react";
|
|
442
|
+
import { useEffect, useState } from "react";
|
|
442
443
|
import { Image as Image2, View as View5, Text as Text5 } from "@react-pdf/renderer";
|
|
443
444
|
import QRCodeStyling from "qr-code-styling";
|
|
444
|
-
if (typeof window === "undefined" && typeof process !== "undefined") {
|
|
445
|
-
try {
|
|
446
|
-
import("jsdom").then((jsdom) => {
|
|
447
|
-
const { JSDOM } = jsdom;
|
|
448
|
-
import("canvas").then((canvas) => {
|
|
449
|
-
const { Canvas, Image: CanvasImage } = canvas;
|
|
450
|
-
const { window: domWindow } = new JSDOM("<!DOCTYPE html><html><body></body></html>");
|
|
451
|
-
global.window = domWindow;
|
|
452
|
-
global.document = domWindow.document;
|
|
453
|
-
global.HTMLElement = domWindow.HTMLElement;
|
|
454
|
-
global.HTMLCanvasElement = Canvas;
|
|
455
|
-
global.CanvasRenderingContext2D = Canvas;
|
|
456
|
-
global.Image = CanvasImage;
|
|
457
|
-
}).catch((err) => {
|
|
458
|
-
console.error("Error loading canvas:", err);
|
|
459
|
-
});
|
|
460
|
-
}).catch((err) => {
|
|
461
|
-
console.error("Error loading jsdom:", err);
|
|
462
|
-
});
|
|
463
|
-
} catch (error) {
|
|
464
|
-
console.error("Error setting up Node.js environment:", error);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
445
|
var QR = ({
|
|
468
446
|
url,
|
|
469
447
|
size = 200,
|
|
@@ -494,9 +472,6 @@ var QR = ({
|
|
|
494
472
|
const actualLogoWidth = logoWidth || Math.floor(size * 0.2);
|
|
495
473
|
const actualLogoHeight = logoHeight || actualLogoWidth;
|
|
496
474
|
useEffect(() => {
|
|
497
|
-
if (typeof window === "undefined") {
|
|
498
|
-
return;
|
|
499
|
-
}
|
|
500
475
|
const generateQRCode = async () => {
|
|
501
476
|
try {
|
|
502
477
|
const qrCode = new QRCodeStyling({
|
|
@@ -546,11 +521,11 @@ var QR = ({
|
|
|
546
521
|
}
|
|
547
522
|
document.body.removeChild(container);
|
|
548
523
|
} catch (error) {
|
|
549
|
-
console.error("Error
|
|
524
|
+
console.error("Error capturing QR code:", error);
|
|
550
525
|
}
|
|
551
526
|
}, 100);
|
|
552
527
|
} catch (error) {
|
|
553
|
-
console.error("Error
|
|
528
|
+
console.error("Error generating QR code:", error);
|
|
554
529
|
}
|
|
555
530
|
};
|
|
556
531
|
generateQRCode();
|
|
@@ -571,14 +546,14 @@ var QR = ({
|
|
|
571
546
|
if (!qrDataURL) return null;
|
|
572
547
|
const centerPosition = size / 2;
|
|
573
548
|
const logoContainerSize = Math.max(actualLogoWidth, actualLogoHeight) + 10;
|
|
574
|
-
return /* @__PURE__ */ React8.createElement(View5, { style: { width: size, height: size, position: "relative", ...style } }, /* @__PURE__ */ React8.createElement(Image2, { src: qrDataURL, style: { width: size, height: size } }), logo && /* @__PURE__ */ React8.createElement(
|
|
549
|
+
return /* @__PURE__ */ React8.createElement(View5, { style: { width: size, height: size, position: "relative", ...style } }, /* @__PURE__ */ React8.createElement(Image2, { src: qrDataURL || "/placeholder.svg", style: { width: size, height: size } }), logo && /* @__PURE__ */ React8.createElement(
|
|
575
550
|
View5,
|
|
576
551
|
{
|
|
577
552
|
style: {
|
|
578
553
|
position: "absolute",
|
|
579
554
|
width: logoContainerSize,
|
|
580
555
|
height: logoContainerSize,
|
|
581
|
-
backgroundColor: logoBG,
|
|
556
|
+
backgroundColor: logoBG || colorDataBG,
|
|
582
557
|
left: centerPosition - logoContainerSize / 2,
|
|
583
558
|
top: centerPosition - logoContainerSize / 2,
|
|
584
559
|
borderRadius: 100,
|
|
@@ -589,11 +564,11 @@ var QR = ({
|
|
|
589
564
|
/* @__PURE__ */ React8.createElement(
|
|
590
565
|
Image2,
|
|
591
566
|
{
|
|
592
|
-
src: logo,
|
|
567
|
+
src: logo || "/placeholder.svg",
|
|
593
568
|
style: {
|
|
594
569
|
objectFit: "contain",
|
|
595
570
|
width: actualLogoWidth,
|
|
596
|
-
height: actualLogoHeight
|
|
571
|
+
height: actualLogoHeight || actualLogoWidth
|
|
597
572
|
}
|
|
598
573
|
}
|
|
599
574
|
)
|
|
@@ -606,7 +581,9 @@ var QR = ({
|
|
|
606
581
|
padding: textPadding,
|
|
607
582
|
borderRadius: 4,
|
|
608
583
|
left: moveText + centerPosition - 20,
|
|
584
|
+
// Approximate center
|
|
609
585
|
top: centerPosition - 10
|
|
586
|
+
// Approximate center
|
|
610
587
|
}
|
|
611
588
|
},
|
|
612
589
|
/* @__PURE__ */ React8.createElement(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-pdf-levelup",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.28",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -27,9 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@babel/standalone": "^7.23.10",
|
|
29
29
|
"@monaco-editor/react": "^4.7.0",
|
|
30
|
-
"canvas": "^3.1.0",
|
|
31
30
|
"i": "^0.3.7",
|
|
32
|
-
"jsdom": "^26.1.0",
|
|
33
31
|
"lucide-react": "^0.485.0",
|
|
34
32
|
"npm": "^11.3.0",
|
|
35
33
|
"react-router-dom": "^7.4.1",
|
|
@@ -39,7 +37,6 @@
|
|
|
39
37
|
"devDependencies": {
|
|
40
38
|
"@eslint/js": "^9.21.0",
|
|
41
39
|
"@react-pdf/types": "^2.9.0",
|
|
42
|
-
"@types/jsdom": "^21.1.7",
|
|
43
40
|
"@types/react": "^18.2.56",
|
|
44
41
|
"@types/react-dom": "^18.2.19",
|
|
45
42
|
"@vitejs/plugin-react": "^4.3.4",
|