react-pdf-levelup 1.0.11 → 1.0.13
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.cjs +141 -0
- package/dist/index.d.cts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +140 -0
- package/package.json +4 -1
package/dist/index.cjs
CHANGED
|
@@ -78,6 +78,7 @@ __export(index_exports, {
|
|
|
78
78
|
Left: () => Left,
|
|
79
79
|
Mark: () => Mark,
|
|
80
80
|
P: () => P,
|
|
81
|
+
QRCode: () => QRCode_default,
|
|
81
82
|
Right: () => Right,
|
|
82
83
|
Row: () => Row,
|
|
83
84
|
Small: () => Small,
|
|
@@ -578,6 +579,145 @@ var Header = ({ children, style, fixed = false }) => {
|
|
|
578
579
|
var Footer = ({ children, style, fixed = false }) => {
|
|
579
580
|
return /* @__PURE__ */ import_react7.default.createElement(import_renderer7.View, { style: [styles7.footer, style], fixed }, typeof children === "string" ? /* @__PURE__ */ import_react7.default.createElement(import_renderer7.Text, null, children) : children);
|
|
580
581
|
};
|
|
582
|
+
|
|
583
|
+
// src/components/PDF/core/QRCode.tsx
|
|
584
|
+
var import_react8 = __toESM(require("react"), 1);
|
|
585
|
+
var import_react9 = require("react");
|
|
586
|
+
var import_renderer8 = require("@react-pdf/renderer");
|
|
587
|
+
var import_qr_code_styling = __toESM(require("qr-code-styling"), 1);
|
|
588
|
+
var styles8 = import_renderer8.StyleSheet.create({
|
|
589
|
+
qrContainer: {
|
|
590
|
+
position: "relative",
|
|
591
|
+
alignItems: "center",
|
|
592
|
+
justifyContent: "center"
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
var QRCode = ({
|
|
596
|
+
value,
|
|
597
|
+
size = 150,
|
|
598
|
+
dotsColor = "#000000",
|
|
599
|
+
dotsGradient,
|
|
600
|
+
backgroundColor = "#ffffff",
|
|
601
|
+
dotsType = "square",
|
|
602
|
+
cornersType = "square",
|
|
603
|
+
cornersSquareColor,
|
|
604
|
+
cornersDotColor,
|
|
605
|
+
logo,
|
|
606
|
+
logoSize = 30,
|
|
607
|
+
logoBackgroundColor,
|
|
608
|
+
logoMargin = 5,
|
|
609
|
+
errorCorrectionLevel = "M",
|
|
610
|
+
margin = 10,
|
|
611
|
+
style
|
|
612
|
+
}) => {
|
|
613
|
+
const [qrDataURL, setQrDataURL] = (0, import_react9.useState)("");
|
|
614
|
+
const qrCodeRef = (0, import_react9.useRef)(null);
|
|
615
|
+
(0, import_react9.useEffect)(() => {
|
|
616
|
+
if (typeof window !== "undefined" && !qrCodeRef.current) {
|
|
617
|
+
qrCodeRef.current = new import_qr_code_styling.default({
|
|
618
|
+
width: 300,
|
|
619
|
+
height: 300,
|
|
620
|
+
type: "canvas",
|
|
621
|
+
data: "Initial",
|
|
622
|
+
dotsOptions: {
|
|
623
|
+
type: "square",
|
|
624
|
+
color: "#000000"
|
|
625
|
+
},
|
|
626
|
+
cornersSquareOptions: {
|
|
627
|
+
type: "square"
|
|
628
|
+
},
|
|
629
|
+
cornersDotOptions: {
|
|
630
|
+
type: "square"
|
|
631
|
+
},
|
|
632
|
+
backgroundOptions: {
|
|
633
|
+
color: "#ffffff"
|
|
634
|
+
},
|
|
635
|
+
imageOptions: {
|
|
636
|
+
crossOrigin: "anonymous",
|
|
637
|
+
margin: 5
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
const generateQRCode = async () => {
|
|
642
|
+
if (typeof window === "undefined" || !qrCodeRef.current) return;
|
|
643
|
+
try {
|
|
644
|
+
const options = {
|
|
645
|
+
width: size,
|
|
646
|
+
height: size,
|
|
647
|
+
data: value,
|
|
648
|
+
margin,
|
|
649
|
+
qrOptions: {
|
|
650
|
+
errorCorrectionLevel
|
|
651
|
+
},
|
|
652
|
+
dotsOptions: {
|
|
653
|
+
type: dotsType,
|
|
654
|
+
color: dotsColor
|
|
655
|
+
},
|
|
656
|
+
cornersSquareOptions: {
|
|
657
|
+
type: cornersType,
|
|
658
|
+
color: cornersSquareColor || dotsColor
|
|
659
|
+
},
|
|
660
|
+
cornersDotOptions: {
|
|
661
|
+
type: cornersType,
|
|
662
|
+
color: cornersDotColor || dotsColor
|
|
663
|
+
},
|
|
664
|
+
backgroundOptions: {
|
|
665
|
+
color: backgroundColor
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
if (dotsGradient && dotsGradient.length === 2) {
|
|
669
|
+
options.dotsOptions.gradient = {
|
|
670
|
+
type: "linear",
|
|
671
|
+
colorStops: [
|
|
672
|
+
{ offset: 0, color: dotsGradient[0] },
|
|
673
|
+
{ offset: 1, color: dotsGradient[1] }
|
|
674
|
+
]
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
if (logo) {
|
|
678
|
+
options.image = logo;
|
|
679
|
+
options.imageOptions = {
|
|
680
|
+
hideBackgroundDots: true,
|
|
681
|
+
imageSize: logoSize / size,
|
|
682
|
+
crossOrigin: "anonymous",
|
|
683
|
+
margin: logoMargin
|
|
684
|
+
};
|
|
685
|
+
if (logoBackgroundColor) {
|
|
686
|
+
options.imageOptions.margin = logoMargin;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
qrCodeRef.current.update(options);
|
|
690
|
+
const dataURL = await qrCodeRef.current.getDataUrl();
|
|
691
|
+
setQrDataURL(dataURL);
|
|
692
|
+
} catch (error) {
|
|
693
|
+
console.error("Error generating QR code:", error);
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
generateQRCode();
|
|
697
|
+
}, [
|
|
698
|
+
value,
|
|
699
|
+
size,
|
|
700
|
+
dotsColor,
|
|
701
|
+
dotsGradient,
|
|
702
|
+
backgroundColor,
|
|
703
|
+
dotsType,
|
|
704
|
+
cornersType,
|
|
705
|
+
cornersSquareColor,
|
|
706
|
+
cornersDotColor,
|
|
707
|
+
logo,
|
|
708
|
+
logoSize,
|
|
709
|
+
logoBackgroundColor,
|
|
710
|
+
logoMargin,
|
|
711
|
+
errorCorrectionLevel,
|
|
712
|
+
margin
|
|
713
|
+
]);
|
|
714
|
+
const containerStyle = __spreadValues(__spreadProps(__spreadValues({}, styles8.qrContainer), {
|
|
715
|
+
width: size,
|
|
716
|
+
height: size
|
|
717
|
+
}), style);
|
|
718
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_renderer8.View, { style: containerStyle }, qrDataURL ? /* @__PURE__ */ import_react8.default.createElement(import_renderer8.Image, { src: qrDataURL || "/placeholder.svg", style: { width: size, height: size } }) : null);
|
|
719
|
+
};
|
|
720
|
+
var QRCode_default = QRCode;
|
|
581
721
|
// Annotate the CommonJS export names for ESM import in node:
|
|
582
722
|
0 && (module.exports = {
|
|
583
723
|
A,
|
|
@@ -611,6 +751,7 @@ var Footer = ({ children, style, fixed = false }) => {
|
|
|
611
751
|
Left,
|
|
612
752
|
Mark,
|
|
613
753
|
P,
|
|
754
|
+
QRCode,
|
|
614
755
|
Right,
|
|
615
756
|
Row,
|
|
616
757
|
Small,
|
package/dist/index.d.cts
CHANGED
|
@@ -113,4 +113,24 @@ interface PageElementProps {
|
|
|
113
113
|
declare const Header: React.FC<PageElementProps>;
|
|
114
114
|
declare const Footer: React.FC<PageElementProps>;
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
interface QRCodeProps {
|
|
117
|
+
value: string;
|
|
118
|
+
size?: number;
|
|
119
|
+
dotsColor?: string;
|
|
120
|
+
dotsGradient?: [string, string];
|
|
121
|
+
backgroundColor?: string;
|
|
122
|
+
dotsType?: "square" | "dots" | "rounded" | "classy" | "classy-rounded" | "extra-rounded";
|
|
123
|
+
cornersType?: "square" | "dots" | "rounded" | "extra-rounded";
|
|
124
|
+
cornersSquareColor?: string;
|
|
125
|
+
cornersDotColor?: string;
|
|
126
|
+
logo?: string;
|
|
127
|
+
logoSize?: number;
|
|
128
|
+
logoBackgroundColor?: string;
|
|
129
|
+
logoMargin?: number;
|
|
130
|
+
errorCorrectionLevel?: "L" | "M" | "Q" | "H";
|
|
131
|
+
margin?: number;
|
|
132
|
+
style?: any;
|
|
133
|
+
}
|
|
134
|
+
declare const QRCode: React.FC<QRCodeProps>;
|
|
135
|
+
|
|
136
|
+
export { A, BR, Blockquote, Center, Col1, Col10, Col11, Col12, Col2, Col3, Col4, Col5, Col6, Col7, Col8, Col9, Container, Em, Footer, H1, H2, H3, H4, H5, H6, Header, Img, LayoutPDF, Left, Mark, P, QRCode, Right, Row, Small, Span, Strong, Table, Tbody, Td, Th, Thead, Tr, U };
|
package/dist/index.d.ts
CHANGED
|
@@ -113,4 +113,24 @@ interface PageElementProps {
|
|
|
113
113
|
declare const Header: React.FC<PageElementProps>;
|
|
114
114
|
declare const Footer: React.FC<PageElementProps>;
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
interface QRCodeProps {
|
|
117
|
+
value: string;
|
|
118
|
+
size?: number;
|
|
119
|
+
dotsColor?: string;
|
|
120
|
+
dotsGradient?: [string, string];
|
|
121
|
+
backgroundColor?: string;
|
|
122
|
+
dotsType?: "square" | "dots" | "rounded" | "classy" | "classy-rounded" | "extra-rounded";
|
|
123
|
+
cornersType?: "square" | "dots" | "rounded" | "extra-rounded";
|
|
124
|
+
cornersSquareColor?: string;
|
|
125
|
+
cornersDotColor?: string;
|
|
126
|
+
logo?: string;
|
|
127
|
+
logoSize?: number;
|
|
128
|
+
logoBackgroundColor?: string;
|
|
129
|
+
logoMargin?: number;
|
|
130
|
+
errorCorrectionLevel?: "L" | "M" | "Q" | "H";
|
|
131
|
+
margin?: number;
|
|
132
|
+
style?: any;
|
|
133
|
+
}
|
|
134
|
+
declare const QRCode: React.FC<QRCodeProps>;
|
|
135
|
+
|
|
136
|
+
export { A, BR, Blockquote, Center, Col1, Col10, Col11, Col12, Col2, Col3, Col4, Col5, Col6, Col7, Col8, Col9, Container, Em, Footer, H1, H2, H3, H4, H5, H6, Header, Img, LayoutPDF, Left, Mark, P, QRCode, Right, Row, Small, Span, Strong, Table, Tbody, Td, Th, Thead, Tr, U };
|
package/dist/index.js
CHANGED
|
@@ -503,6 +503,145 @@ var Header = ({ children, style, fixed = false }) => {
|
|
|
503
503
|
var Footer = ({ children, style, fixed = false }) => {
|
|
504
504
|
return /* @__PURE__ */ React7.createElement(View4, { style: [styles7.footer, style], fixed }, typeof children === "string" ? /* @__PURE__ */ React7.createElement(Text4, null, children) : children);
|
|
505
505
|
};
|
|
506
|
+
|
|
507
|
+
// src/components/PDF/core/QRCode.tsx
|
|
508
|
+
import React8 from "react";
|
|
509
|
+
import { useEffect, useState, useRef } from "react";
|
|
510
|
+
import { Image as Image2, StyleSheet as StyleSheet8, View as View5 } from "@react-pdf/renderer";
|
|
511
|
+
import QRCodeStyling from "qr-code-styling";
|
|
512
|
+
var styles8 = StyleSheet8.create({
|
|
513
|
+
qrContainer: {
|
|
514
|
+
position: "relative",
|
|
515
|
+
alignItems: "center",
|
|
516
|
+
justifyContent: "center"
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
var QRCode = ({
|
|
520
|
+
value,
|
|
521
|
+
size = 150,
|
|
522
|
+
dotsColor = "#000000",
|
|
523
|
+
dotsGradient,
|
|
524
|
+
backgroundColor = "#ffffff",
|
|
525
|
+
dotsType = "square",
|
|
526
|
+
cornersType = "square",
|
|
527
|
+
cornersSquareColor,
|
|
528
|
+
cornersDotColor,
|
|
529
|
+
logo,
|
|
530
|
+
logoSize = 30,
|
|
531
|
+
logoBackgroundColor,
|
|
532
|
+
logoMargin = 5,
|
|
533
|
+
errorCorrectionLevel = "M",
|
|
534
|
+
margin = 10,
|
|
535
|
+
style
|
|
536
|
+
}) => {
|
|
537
|
+
const [qrDataURL, setQrDataURL] = useState("");
|
|
538
|
+
const qrCodeRef = useRef(null);
|
|
539
|
+
useEffect(() => {
|
|
540
|
+
if (typeof window !== "undefined" && !qrCodeRef.current) {
|
|
541
|
+
qrCodeRef.current = new QRCodeStyling({
|
|
542
|
+
width: 300,
|
|
543
|
+
height: 300,
|
|
544
|
+
type: "canvas",
|
|
545
|
+
data: "Initial",
|
|
546
|
+
dotsOptions: {
|
|
547
|
+
type: "square",
|
|
548
|
+
color: "#000000"
|
|
549
|
+
},
|
|
550
|
+
cornersSquareOptions: {
|
|
551
|
+
type: "square"
|
|
552
|
+
},
|
|
553
|
+
cornersDotOptions: {
|
|
554
|
+
type: "square"
|
|
555
|
+
},
|
|
556
|
+
backgroundOptions: {
|
|
557
|
+
color: "#ffffff"
|
|
558
|
+
},
|
|
559
|
+
imageOptions: {
|
|
560
|
+
crossOrigin: "anonymous",
|
|
561
|
+
margin: 5
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
const generateQRCode = async () => {
|
|
566
|
+
if (typeof window === "undefined" || !qrCodeRef.current) return;
|
|
567
|
+
try {
|
|
568
|
+
const options = {
|
|
569
|
+
width: size,
|
|
570
|
+
height: size,
|
|
571
|
+
data: value,
|
|
572
|
+
margin,
|
|
573
|
+
qrOptions: {
|
|
574
|
+
errorCorrectionLevel
|
|
575
|
+
},
|
|
576
|
+
dotsOptions: {
|
|
577
|
+
type: dotsType,
|
|
578
|
+
color: dotsColor
|
|
579
|
+
},
|
|
580
|
+
cornersSquareOptions: {
|
|
581
|
+
type: cornersType,
|
|
582
|
+
color: cornersSquareColor || dotsColor
|
|
583
|
+
},
|
|
584
|
+
cornersDotOptions: {
|
|
585
|
+
type: cornersType,
|
|
586
|
+
color: cornersDotColor || dotsColor
|
|
587
|
+
},
|
|
588
|
+
backgroundOptions: {
|
|
589
|
+
color: backgroundColor
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
if (dotsGradient && dotsGradient.length === 2) {
|
|
593
|
+
options.dotsOptions.gradient = {
|
|
594
|
+
type: "linear",
|
|
595
|
+
colorStops: [
|
|
596
|
+
{ offset: 0, color: dotsGradient[0] },
|
|
597
|
+
{ offset: 1, color: dotsGradient[1] }
|
|
598
|
+
]
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
if (logo) {
|
|
602
|
+
options.image = logo;
|
|
603
|
+
options.imageOptions = {
|
|
604
|
+
hideBackgroundDots: true,
|
|
605
|
+
imageSize: logoSize / size,
|
|
606
|
+
crossOrigin: "anonymous",
|
|
607
|
+
margin: logoMargin
|
|
608
|
+
};
|
|
609
|
+
if (logoBackgroundColor) {
|
|
610
|
+
options.imageOptions.margin = logoMargin;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
qrCodeRef.current.update(options);
|
|
614
|
+
const dataURL = await qrCodeRef.current.getDataUrl();
|
|
615
|
+
setQrDataURL(dataURL);
|
|
616
|
+
} catch (error) {
|
|
617
|
+
console.error("Error generating QR code:", error);
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
generateQRCode();
|
|
621
|
+
}, [
|
|
622
|
+
value,
|
|
623
|
+
size,
|
|
624
|
+
dotsColor,
|
|
625
|
+
dotsGradient,
|
|
626
|
+
backgroundColor,
|
|
627
|
+
dotsType,
|
|
628
|
+
cornersType,
|
|
629
|
+
cornersSquareColor,
|
|
630
|
+
cornersDotColor,
|
|
631
|
+
logo,
|
|
632
|
+
logoSize,
|
|
633
|
+
logoBackgroundColor,
|
|
634
|
+
logoMargin,
|
|
635
|
+
errorCorrectionLevel,
|
|
636
|
+
margin
|
|
637
|
+
]);
|
|
638
|
+
const containerStyle = __spreadValues(__spreadProps(__spreadValues({}, styles8.qrContainer), {
|
|
639
|
+
width: size,
|
|
640
|
+
height: size
|
|
641
|
+
}), style);
|
|
642
|
+
return /* @__PURE__ */ React8.createElement(View5, { style: containerStyle }, qrDataURL ? /* @__PURE__ */ React8.createElement(Image2, { src: qrDataURL || "/placeholder.svg", style: { width: size, height: size } }) : null);
|
|
643
|
+
};
|
|
644
|
+
var QRCode_default = QRCode;
|
|
506
645
|
export {
|
|
507
646
|
A,
|
|
508
647
|
BR,
|
|
@@ -535,6 +674,7 @@ export {
|
|
|
535
674
|
Left,
|
|
536
675
|
Mark,
|
|
537
676
|
P,
|
|
677
|
+
QRCode_default as QRCode,
|
|
538
678
|
Right,
|
|
539
679
|
Row,
|
|
540
680
|
Small,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-pdf-levelup",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
"lucide-react": "^0.477.0",
|
|
27
27
|
"next": "14.2.24",
|
|
28
28
|
"next-transpile-modules": "^10.0.1",
|
|
29
|
+
"qr-code-styling": "^1.9.1",
|
|
30
|
+
"qrcode": "^1.5.4",
|
|
29
31
|
"react": "^18",
|
|
30
32
|
"react-dom": "^18",
|
|
31
33
|
"react-pdf": "^9.2.1"
|
|
@@ -33,6 +35,7 @@
|
|
|
33
35
|
"devDependencies": {
|
|
34
36
|
"@react-pdf/types": "^2.9.0",
|
|
35
37
|
"@types/node": "^20",
|
|
38
|
+
"@types/qrcode": "^1.5.5",
|
|
36
39
|
"@types/react": "^18",
|
|
37
40
|
"@types/react-dom": "^18",
|
|
38
41
|
"eslint": "^8",
|