@react-pdf-levelup/client 1.1.15
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/README.md +89 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://genarogg.github.io/media/react-pdf-levelup/logo-de-react-pdf-levelup.png" alt="react-pdf-levelup logo" width="160" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# `@react-pdf-levelup/qr`
|
|
6
|
+
|
|
7
|
+
> Paquete de componentes y utilidades para generar códigos QR estilizados dentro de plantillas PDF (React + `@react-pdf/renderer`) y en el frontend.
|
|
8
|
+
|
|
9
|
+
## Instalación
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @react-pdf-levelup/qr
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Componentes principales
|
|
16
|
+
|
|
17
|
+
- `QR`: componente para insertar un código QR en una plantilla PDF.
|
|
18
|
+
- `QRStyle`: utilidades/constructores para generar estilos personalizados de QR (colores, forma de puntos, máscaras, etc.).
|
|
19
|
+
|
|
20
|
+
## Uso en plantillas PDF (ejemplo mínimo)
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import React from 'react';
|
|
24
|
+
import { Document, Page } from '@react-pdf/renderer';
|
|
25
|
+
import { QR } from '@react-pdf-levelup/qr';
|
|
26
|
+
|
|
27
|
+
const MyPdfTemplate = ({ data }) => (
|
|
28
|
+
<Document>
|
|
29
|
+
<Page size="A4">
|
|
30
|
+
{/* QR simple */}
|
|
31
|
+
<QR value={data.url} size={120} />
|
|
32
|
+
</Page>
|
|
33
|
+
</Document>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
export default MyPdfTemplate;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Props comunes de `QR` (ejemplos):
|
|
40
|
+
- `value` (string): contenido del QR (URL, texto).
|
|
41
|
+
- `size` (number): tamaño en px.
|
|
42
|
+
- `style` (object): estilo generado por `QRStyle` o un objeto inline con colores y forma.
|
|
43
|
+
|
|
44
|
+
## Personalizar apariencia con `QRStyle` (ejemplos)
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { QRStyle } from '@react-pdf-levelup/qr';
|
|
48
|
+
|
|
49
|
+
// Genera un objeto estilo reutilizable
|
|
50
|
+
const style = QRStyle({
|
|
51
|
+
dotColor: '#0b74de',
|
|
52
|
+
backgroundColor: '#ffffff',
|
|
53
|
+
eyeColor: '#0b74de',
|
|
54
|
+
eyeRadius: 4,
|
|
55
|
+
dotShape: 'rounded'
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Usarlo en el componente QR
|
|
59
|
+
// <QR value="https://example.com" size={140} style={style} />
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Ejemplo avanzado (preview + export)
|
|
63
|
+
|
|
64
|
+
Frontend (vista previa y generación):
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import React from 'react';
|
|
68
|
+
import { QRGenerator, QRstyleGenerator } from '@react-pdf-levelup/qr';
|
|
69
|
+
|
|
70
|
+
function Preview() {
|
|
71
|
+
const qrValue = 'https://react-pdf-levelup.nimbux.cloud';
|
|
72
|
+
const previewStyle = QRstyleGenerator({ dotColor: '#222', eyeColor: '#ff6b6b' });
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div>
|
|
76
|
+
<h3>Previsualización QR</h3>
|
|
77
|
+
<QRGenerator value={qrValue} size={180} style={previewStyle} />
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default Preview;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Notes
|
|
86
|
+
- Asegúrate de compilar el paquete (`dist/`) antes de publicar.
|
|
87
|
+
- `QRStyle`/`QRGenerator` APIs pueden variar según la versión; revisa los archivos fuente `frontend/src/components/core/qr` si necesitas adaptar propiedades concretas.
|
|
88
|
+
|
|
89
|
+
Si quieres, puedo actualizar README con la API exacta detectada en `frontend/src/components/core/qr` y añadir ejemplos concretos basados en las props reales.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';require('@react-pdf/renderer'),require('react');var m=(c,s)=>{let r=atob(c),n=new Array(r.length);for(let t=0;t<r.length;t++)n[t]=r.charCodeAt(t);let d=new Uint8Array(n),i=new Blob([d],{type:"application/pdf"}),o=URL.createObjectURL(i);if(document===void 0){console.error("document is undefined, only works in browser context");return}let e=document.createElement("a");e.href=o,e.download=s,document.body.appendChild(e),e.click(),document.body.removeChild(e),window.open(o,"_blank"),setTimeout(()=>{URL.revokeObjectURL(o);},100);},a=m;exports.decodeBase64Pdf=a;//# sourceMappingURL=index.cjs.map
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../frontend/src/functions/decodeBase64Pdf.ts"],"names":["decodeBase64Pdf","base64","fileName","byteCharacters","byteNumbers","i","byteArray","blob","blobUrl","link","decodeBase64Pdf_default"],"mappings":"6DAAA,IAAMA,CAAAA,CAAkB,CAACC,CAAAA,CAAgBC,CAAAA,GAAqB,CAC5D,IAAMC,CAAAA,CAAiB,IAAA,CAAKF,CAAM,CAAA,CAC5BG,CAAAA,CAAc,IAAI,MAAMD,CAAAA,CAAe,MAAM,CAAA,CACnD,IAAA,IAASE,CAAAA,CAAI,CAAA,CAAGA,EAAIF,CAAAA,CAAe,MAAA,CAAQE,CAAAA,EAAAA,CACzCD,CAAAA,CAAYC,CAAC,CAAA,CAAIF,EAAe,UAAA,CAAWE,CAAC,CAAA,CAE9C,IAAMC,CAAAA,CAAY,IAAI,WAAWF,CAAW,CAAA,CACtCG,CAAAA,CAAO,IAAI,IAAA,CAAK,CAACD,CAAS,CAAA,CAAG,CAAE,IAAA,CAAM,iBAAkB,CAAC,CAAA,CACxDE,CAAAA,CAAU,GAAA,CAAI,eAAA,CAAgBD,CAAI,CAAA,CAGxC,GAAI,QAAA,GAAa,MAAA,CAAW,CAC1B,OAAA,CAAQ,KAAA,CAAM,sDAAsD,CAAA,CACpE,MACF,CAGA,IAAME,CAAAA,CAAO,QAAA,CAAS,aAAA,CAAc,GAAG,CAAA,CACvCA,CAAAA,CAAK,KAAOD,CAAAA,CACZC,CAAAA,CAAK,QAAA,CAAWP,CAAAA,CAChB,QAAA,CAAS,IAAA,CAAK,WAAA,CAAYO,CAAI,CAAA,CAC9BA,CAAAA,CAAK,KAAA,EAAM,CACX,QAAA,CAAS,IAAA,CAAK,YAAYA,CAAI,CAAA,CAG9B,MAAA,CAAO,IAAA,CAAKD,CAAAA,CAAS,QAAQ,EAG7B,UAAA,CAAW,IAAM,CACf,GAAA,CAAI,eAAA,CAAgBA,CAAO,EAC7B,CAAA,CAAG,GAAG,EACR,CAAA,CAEOE,CAAAA,CAAQV","file":"index.cjs","sourcesContent":["const decodeBase64Pdf = (base64: string, fileName: string) => {\r\n const byteCharacters = atob(base64);\r\n const byteNumbers = new Array(byteCharacters.length);\r\n for (let i = 0; i < byteCharacters.length; i++) {\r\n byteNumbers[i] = byteCharacters.charCodeAt(i);\r\n }\r\n const byteArray = new Uint8Array(byteNumbers);\r\n const blob = new Blob([byteArray], { type: 'application/pdf' });\r\n const blobUrl = URL.createObjectURL(blob);\r\n\r\n\r\n if (document === undefined) {\r\n console.error(\"document is undefined, only works in browser context\");\r\n return;\r\n }\r\n\r\n // Crear un enlace para descargar el archivo\r\n const link = document.createElement('a');\r\n link.href = blobUrl;\r\n link.download = fileName;\r\n document.body.appendChild(link);\r\n link.click();\r\n document.body.removeChild(link);\r\n\r\n // Abrir el PDF en una nueva pestaña\r\n window.open(blobUrl, '_blank');\r\n\r\n // Revocar el objeto URL después de un tiempo\r\n setTimeout(() => {\r\n URL.revokeObjectURL(blobUrl);\r\n }, 100);\r\n};\r\n\r\nexport default decodeBase64Pdf;"]}
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import'@react-pdf/renderer';import'react';var m=(c,s)=>{let r=atob(c),n=new Array(r.length);for(let t=0;t<r.length;t++)n[t]=r.charCodeAt(t);let d=new Uint8Array(n),i=new Blob([d],{type:"application/pdf"}),o=URL.createObjectURL(i);if(document===void 0){console.error("document is undefined, only works in browser context");return}let e=document.createElement("a");e.href=o,e.download=s,document.body.appendChild(e),e.click(),document.body.removeChild(e),window.open(o,"_blank"),setTimeout(()=>{URL.revokeObjectURL(o);},100);},a=m;export{a as decodeBase64Pdf};//# sourceMappingURL=index.js.map
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../frontend/src/functions/decodeBase64Pdf.ts"],"names":["decodeBase64Pdf","base64","fileName","byteCharacters","byteNumbers","i","byteArray","blob","blobUrl","link","decodeBase64Pdf_default"],"mappings":"0CAAA,IAAMA,CAAAA,CAAkB,CAACC,CAAAA,CAAgBC,CAAAA,GAAqB,CAC5D,IAAMC,CAAAA,CAAiB,IAAA,CAAKF,CAAM,CAAA,CAC5BG,CAAAA,CAAc,IAAI,MAAMD,CAAAA,CAAe,MAAM,CAAA,CACnD,IAAA,IAASE,CAAAA,CAAI,CAAA,CAAGA,EAAIF,CAAAA,CAAe,MAAA,CAAQE,CAAAA,EAAAA,CACzCD,CAAAA,CAAYC,CAAC,CAAA,CAAIF,EAAe,UAAA,CAAWE,CAAC,CAAA,CAE9C,IAAMC,CAAAA,CAAY,IAAI,WAAWF,CAAW,CAAA,CACtCG,CAAAA,CAAO,IAAI,IAAA,CAAK,CAACD,CAAS,CAAA,CAAG,CAAE,IAAA,CAAM,iBAAkB,CAAC,CAAA,CACxDE,CAAAA,CAAU,GAAA,CAAI,eAAA,CAAgBD,CAAI,CAAA,CAGxC,GAAI,QAAA,GAAa,MAAA,CAAW,CAC1B,OAAA,CAAQ,KAAA,CAAM,sDAAsD,CAAA,CACpE,MACF,CAGA,IAAME,CAAAA,CAAO,QAAA,CAAS,aAAA,CAAc,GAAG,CAAA,CACvCA,CAAAA,CAAK,KAAOD,CAAAA,CACZC,CAAAA,CAAK,QAAA,CAAWP,CAAAA,CAChB,QAAA,CAAS,IAAA,CAAK,WAAA,CAAYO,CAAI,CAAA,CAC9BA,CAAAA,CAAK,KAAA,EAAM,CACX,QAAA,CAAS,IAAA,CAAK,YAAYA,CAAI,CAAA,CAG9B,MAAA,CAAO,IAAA,CAAKD,CAAAA,CAAS,QAAQ,EAG7B,UAAA,CAAW,IAAM,CACf,GAAA,CAAI,eAAA,CAAgBA,CAAO,EAC7B,CAAA,CAAG,GAAG,EACR,CAAA,CAEOE,CAAAA,CAAQV","file":"index.js","sourcesContent":["const decodeBase64Pdf = (base64: string, fileName: string) => {\r\n const byteCharacters = atob(base64);\r\n const byteNumbers = new Array(byteCharacters.length);\r\n for (let i = 0; i < byteCharacters.length; i++) {\r\n byteNumbers[i] = byteCharacters.charCodeAt(i);\r\n }\r\n const byteArray = new Uint8Array(byteNumbers);\r\n const blob = new Blob([byteArray], { type: 'application/pdf' });\r\n const blobUrl = URL.createObjectURL(blob);\r\n\r\n\r\n if (document === undefined) {\r\n console.error(\"document is undefined, only works in browser context\");\r\n return;\r\n }\r\n\r\n // Crear un enlace para descargar el archivo\r\n const link = document.createElement('a');\r\n link.href = blobUrl;\r\n link.download = fileName;\r\n document.body.appendChild(link);\r\n link.click();\r\n document.body.removeChild(link);\r\n\r\n // Abrir el PDF en una nueva pestaña\r\n window.open(blobUrl, '_blank');\r\n\r\n // Revocar el objeto URL después de un tiempo\r\n setTimeout(() => {\r\n URL.revokeObjectURL(blobUrl);\r\n }, 100);\r\n};\r\n\r\nexport default decodeBase64Pdf;"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-pdf-levelup/client",
|
|
3
|
+
"version": "1.1.15",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"private": false,
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"publicar": "npm run build:lib && node ../scripts/index.js",
|
|
17
|
+
"build:lib": "tsup --config tsup.config.ts",
|
|
18
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@react-pdf/renderer": "^4.3.2",
|
|
22
|
+
"react": ">=18 <=19",
|
|
23
|
+
"react-dom": ">=18 <=19"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"jsdom": "^27.4.0",
|
|
27
|
+
"qr-code-styling": "^1.9.2",
|
|
28
|
+
"qrcode": "^1.5.4",
|
|
29
|
+
"canvas": "^3.2.0"
|
|
30
|
+
}
|
|
31
|
+
}
|