react-pdf-levelup 1.0.13 → 1.0.14
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 +35 -101
- package/dist/index.d.cts +4 -9
- package/dist/index.d.ts +4 -9
- package/dist/index.js +36 -102
- package/package.json +1 -2
package/dist/index.cjs
CHANGED
|
@@ -584,138 +584,72 @@ var Footer = ({ children, style, fixed = false }) => {
|
|
|
584
584
|
var import_react8 = __toESM(require("react"), 1);
|
|
585
585
|
var import_react9 = require("react");
|
|
586
586
|
var import_renderer8 = require("@react-pdf/renderer");
|
|
587
|
-
var
|
|
587
|
+
var import_qrcode = __toESM(require("qrcode"), 1);
|
|
588
588
|
var styles8 = import_renderer8.StyleSheet.create({
|
|
589
589
|
qrContainer: {
|
|
590
590
|
position: "relative",
|
|
591
591
|
alignItems: "center",
|
|
592
592
|
justifyContent: "center"
|
|
593
|
+
},
|
|
594
|
+
logo: {
|
|
595
|
+
position: "absolute",
|
|
596
|
+
zIndex: 2
|
|
597
|
+
},
|
|
598
|
+
logoBackground: {
|
|
599
|
+
position: "absolute",
|
|
600
|
+
zIndex: 1
|
|
593
601
|
}
|
|
594
602
|
});
|
|
595
603
|
var QRCode = ({
|
|
596
604
|
value,
|
|
597
605
|
size = 150,
|
|
598
|
-
|
|
599
|
-
dotsGradient,
|
|
606
|
+
color = "#000000",
|
|
600
607
|
backgroundColor = "#ffffff",
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
cornersDotColor,
|
|
608
|
+
errorCorrectionLevel = "M",
|
|
609
|
+
style,
|
|
610
|
+
includeMargin = true,
|
|
605
611
|
logo,
|
|
606
612
|
logoSize = 30,
|
|
607
|
-
logoBackgroundColor,
|
|
608
|
-
logoMargin = 5
|
|
609
|
-
errorCorrectionLevel = "M",
|
|
610
|
-
margin = 10,
|
|
611
|
-
style
|
|
613
|
+
logoBackgroundColor = "#ffffff",
|
|
614
|
+
logoMargin = 5
|
|
612
615
|
}) => {
|
|
613
616
|
const [qrDataURL, setQrDataURL] = (0, import_react9.useState)("");
|
|
614
|
-
const qrCodeRef = (0, import_react9.useRef)(null);
|
|
615
617
|
(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
618
|
const generateQRCode = async () => {
|
|
642
|
-
if (typeof window === "undefined" || !qrCodeRef.current) return;
|
|
643
619
|
try {
|
|
644
620
|
const options = {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
errorCorrectionLevel
|
|
651
|
-
},
|
|
652
|
-
dotsOptions: {
|
|
653
|
-
type: dotsType,
|
|
654
|
-
color: dotsColor
|
|
655
|
-
},
|
|
656
|
-
cornersSquareOptions: {
|
|
657
|
-
type: cornersType,
|
|
658
|
-
color: cornersSquareColor || dotsColor
|
|
621
|
+
errorCorrectionLevel,
|
|
622
|
+
margin: includeMargin ? 4 : 0,
|
|
623
|
+
color: {
|
|
624
|
+
dark: color,
|
|
625
|
+
light: backgroundColor
|
|
659
626
|
},
|
|
660
|
-
|
|
661
|
-
type: cornersType,
|
|
662
|
-
color: cornersDotColor || dotsColor
|
|
663
|
-
},
|
|
664
|
-
backgroundOptions: {
|
|
665
|
-
color: backgroundColor
|
|
666
|
-
}
|
|
627
|
+
width: size
|
|
667
628
|
};
|
|
668
|
-
|
|
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();
|
|
629
|
+
const dataURL = await import_qrcode.default.toDataURL(value, options);
|
|
691
630
|
setQrDataURL(dataURL);
|
|
692
631
|
} catch (error) {
|
|
693
632
|
console.error("Error generating QR code:", error);
|
|
694
633
|
}
|
|
695
634
|
};
|
|
696
635
|
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
|
-
]);
|
|
636
|
+
}, [value, size, color, backgroundColor, errorCorrectionLevel, includeMargin]);
|
|
714
637
|
const containerStyle = __spreadValues(__spreadProps(__spreadValues({}, styles8.qrContainer), {
|
|
715
638
|
width: size,
|
|
716
639
|
height: size
|
|
717
640
|
}), style);
|
|
718
|
-
|
|
641
|
+
const logoContainerSize = logoSize + logoMargin * 2;
|
|
642
|
+
const logoBackgroundStyle = __spreadProps(__spreadValues({}, styles8.logoBackground), {
|
|
643
|
+
width: logoContainerSize,
|
|
644
|
+
height: logoContainerSize,
|
|
645
|
+
backgroundColor: logoBackgroundColor,
|
|
646
|
+
borderRadius: logoContainerSize / 2
|
|
647
|
+
});
|
|
648
|
+
const logoStyle = __spreadProps(__spreadValues({}, styles8.logo), {
|
|
649
|
+
width: logoSize,
|
|
650
|
+
height: logoSize
|
|
651
|
+
});
|
|
652
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_renderer8.View, { style: containerStyle }, qrDataURL ? /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement(import_renderer8.Image, { src: qrDataURL || "/placeholder.svg", style: { width: size, height: size } }), logo && /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement(import_renderer8.View, { style: logoBackgroundStyle }), /* @__PURE__ */ import_react8.default.createElement(import_renderer8.Image, { src: logo || "/placeholder.svg", style: logoStyle }))) : null);
|
|
719
653
|
};
|
|
720
654
|
var QRCode_default = QRCode;
|
|
721
655
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.d.cts
CHANGED
|
@@ -116,20 +116,15 @@ declare const Footer: React.FC<PageElementProps>;
|
|
|
116
116
|
interface QRCodeProps {
|
|
117
117
|
value: string;
|
|
118
118
|
size?: number;
|
|
119
|
-
|
|
120
|
-
dotsGradient?: [string, string];
|
|
119
|
+
color?: string;
|
|
121
120
|
backgroundColor?: string;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
cornersDotColor?: string;
|
|
121
|
+
errorCorrectionLevel?: "L" | "M" | "Q" | "H";
|
|
122
|
+
style?: any;
|
|
123
|
+
includeMargin?: boolean;
|
|
126
124
|
logo?: string;
|
|
127
125
|
logoSize?: number;
|
|
128
126
|
logoBackgroundColor?: string;
|
|
129
127
|
logoMargin?: number;
|
|
130
|
-
errorCorrectionLevel?: "L" | "M" | "Q" | "H";
|
|
131
|
-
margin?: number;
|
|
132
|
-
style?: any;
|
|
133
128
|
}
|
|
134
129
|
declare const QRCode: React.FC<QRCodeProps>;
|
|
135
130
|
|
package/dist/index.d.ts
CHANGED
|
@@ -116,20 +116,15 @@ declare const Footer: React.FC<PageElementProps>;
|
|
|
116
116
|
interface QRCodeProps {
|
|
117
117
|
value: string;
|
|
118
118
|
size?: number;
|
|
119
|
-
|
|
120
|
-
dotsGradient?: [string, string];
|
|
119
|
+
color?: string;
|
|
121
120
|
backgroundColor?: string;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
cornersDotColor?: string;
|
|
121
|
+
errorCorrectionLevel?: "L" | "M" | "Q" | "H";
|
|
122
|
+
style?: any;
|
|
123
|
+
includeMargin?: boolean;
|
|
126
124
|
logo?: string;
|
|
127
125
|
logoSize?: number;
|
|
128
126
|
logoBackgroundColor?: string;
|
|
129
127
|
logoMargin?: number;
|
|
130
|
-
errorCorrectionLevel?: "L" | "M" | "Q" | "H";
|
|
131
|
-
margin?: number;
|
|
132
|
-
style?: any;
|
|
133
128
|
}
|
|
134
129
|
declare const QRCode: React.FC<QRCodeProps>;
|
|
135
130
|
|
package/dist/index.js
CHANGED
|
@@ -506,140 +506,74 @@ var Footer = ({ children, style, fixed = false }) => {
|
|
|
506
506
|
|
|
507
507
|
// src/components/PDF/core/QRCode.tsx
|
|
508
508
|
import React8 from "react";
|
|
509
|
-
import { useEffect, useState
|
|
509
|
+
import { useEffect, useState } from "react";
|
|
510
510
|
import { Image as Image2, StyleSheet as StyleSheet8, View as View5 } from "@react-pdf/renderer";
|
|
511
|
-
import
|
|
511
|
+
import QRCodeLib from "qrcode";
|
|
512
512
|
var styles8 = StyleSheet8.create({
|
|
513
513
|
qrContainer: {
|
|
514
514
|
position: "relative",
|
|
515
515
|
alignItems: "center",
|
|
516
516
|
justifyContent: "center"
|
|
517
|
+
},
|
|
518
|
+
logo: {
|
|
519
|
+
position: "absolute",
|
|
520
|
+
zIndex: 2
|
|
521
|
+
},
|
|
522
|
+
logoBackground: {
|
|
523
|
+
position: "absolute",
|
|
524
|
+
zIndex: 1
|
|
517
525
|
}
|
|
518
526
|
});
|
|
519
527
|
var QRCode = ({
|
|
520
528
|
value,
|
|
521
529
|
size = 150,
|
|
522
|
-
|
|
523
|
-
dotsGradient,
|
|
530
|
+
color = "#000000",
|
|
524
531
|
backgroundColor = "#ffffff",
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
cornersDotColor,
|
|
532
|
+
errorCorrectionLevel = "M",
|
|
533
|
+
style,
|
|
534
|
+
includeMargin = true,
|
|
529
535
|
logo,
|
|
530
536
|
logoSize = 30,
|
|
531
|
-
logoBackgroundColor,
|
|
532
|
-
logoMargin = 5
|
|
533
|
-
errorCorrectionLevel = "M",
|
|
534
|
-
margin = 10,
|
|
535
|
-
style
|
|
537
|
+
logoBackgroundColor = "#ffffff",
|
|
538
|
+
logoMargin = 5
|
|
536
539
|
}) => {
|
|
537
540
|
const [qrDataURL, setQrDataURL] = useState("");
|
|
538
|
-
const qrCodeRef = useRef(null);
|
|
539
541
|
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
542
|
const generateQRCode = async () => {
|
|
566
|
-
if (typeof window === "undefined" || !qrCodeRef.current) return;
|
|
567
543
|
try {
|
|
568
544
|
const options = {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
errorCorrectionLevel
|
|
575
|
-
},
|
|
576
|
-
dotsOptions: {
|
|
577
|
-
type: dotsType,
|
|
578
|
-
color: dotsColor
|
|
579
|
-
},
|
|
580
|
-
cornersSquareOptions: {
|
|
581
|
-
type: cornersType,
|
|
582
|
-
color: cornersSquareColor || dotsColor
|
|
545
|
+
errorCorrectionLevel,
|
|
546
|
+
margin: includeMargin ? 4 : 0,
|
|
547
|
+
color: {
|
|
548
|
+
dark: color,
|
|
549
|
+
light: backgroundColor
|
|
583
550
|
},
|
|
584
|
-
|
|
585
|
-
type: cornersType,
|
|
586
|
-
color: cornersDotColor || dotsColor
|
|
587
|
-
},
|
|
588
|
-
backgroundOptions: {
|
|
589
|
-
color: backgroundColor
|
|
590
|
-
}
|
|
551
|
+
width: size
|
|
591
552
|
};
|
|
592
|
-
|
|
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();
|
|
553
|
+
const dataURL = await QRCodeLib.toDataURL(value, options);
|
|
615
554
|
setQrDataURL(dataURL);
|
|
616
555
|
} catch (error) {
|
|
617
556
|
console.error("Error generating QR code:", error);
|
|
618
557
|
}
|
|
619
558
|
};
|
|
620
559
|
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
|
-
]);
|
|
560
|
+
}, [value, size, color, backgroundColor, errorCorrectionLevel, includeMargin]);
|
|
638
561
|
const containerStyle = __spreadValues(__spreadProps(__spreadValues({}, styles8.qrContainer), {
|
|
639
562
|
width: size,
|
|
640
563
|
height: size
|
|
641
564
|
}), style);
|
|
642
|
-
|
|
565
|
+
const logoContainerSize = logoSize + logoMargin * 2;
|
|
566
|
+
const logoBackgroundStyle = __spreadProps(__spreadValues({}, styles8.logoBackground), {
|
|
567
|
+
width: logoContainerSize,
|
|
568
|
+
height: logoContainerSize,
|
|
569
|
+
backgroundColor: logoBackgroundColor,
|
|
570
|
+
borderRadius: logoContainerSize / 2
|
|
571
|
+
});
|
|
572
|
+
const logoStyle = __spreadProps(__spreadValues({}, styles8.logo), {
|
|
573
|
+
width: logoSize,
|
|
574
|
+
height: logoSize
|
|
575
|
+
});
|
|
576
|
+
return /* @__PURE__ */ React8.createElement(View5, { style: containerStyle }, qrDataURL ? /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(Image2, { src: qrDataURL || "/placeholder.svg", style: { width: size, height: size } }), logo && /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(View5, { style: logoBackgroundStyle }), /* @__PURE__ */ React8.createElement(Image2, { src: logo || "/placeholder.svg", style: logoStyle }))) : null);
|
|
643
577
|
};
|
|
644
578
|
var QRCode_default = QRCode;
|
|
645
579
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-pdf-levelup",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,6 @@
|
|
|
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
29
|
"qrcode": "^1.5.4",
|
|
31
30
|
"react": "^18",
|
|
32
31
|
"react-dom": "^18",
|