react-pdf-levelup 2.0.20 → 2.0.21
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 +54 -54
- package/dist/index.d.mts +28 -9
- package/dist/index.d.ts +28 -9
- package/dist/index.js +228 -189
- package/dist/index.mjs +234 -195
- package/package.json +10 -8
package/README.md
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
# React + TypeScript + Vite
|
|
2
|
-
|
|
3
|
-
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
-
|
|
5
|
-
Currently, two official plugins are available:
|
|
6
|
-
|
|
7
|
-
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
|
|
8
|
-
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
-
|
|
10
|
-
## Expanding the ESLint configuration
|
|
11
|
-
|
|
12
|
-
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
13
|
-
|
|
14
|
-
```js
|
|
15
|
-
export default tseslint.config({
|
|
16
|
-
extends: [
|
|
17
|
-
// Remove ...tseslint.configs.recommended and replace with this
|
|
18
|
-
...tseslint.configs.recommendedTypeChecked,
|
|
19
|
-
// Alternatively, use this for stricter rules
|
|
20
|
-
...tseslint.configs.strictTypeChecked,
|
|
21
|
-
// Optionally, add this for stylistic rules
|
|
22
|
-
...tseslint.configs.stylisticTypeChecked,
|
|
23
|
-
],
|
|
24
|
-
languageOptions: {
|
|
25
|
-
// other options...
|
|
26
|
-
parserOptions: {
|
|
27
|
-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
28
|
-
tsconfigRootDir: import.meta.dirname,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
})
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
35
|
-
|
|
36
|
-
```js
|
|
37
|
-
// eslint.config.js
|
|
38
|
-
import reactX from 'eslint-plugin-react-x'
|
|
39
|
-
import reactDom from 'eslint-plugin-react-dom'
|
|
40
|
-
|
|
41
|
-
export default tseslint.config({
|
|
42
|
-
plugins: {
|
|
43
|
-
// Add the react-x and react-dom plugins
|
|
44
|
-
'react-x': reactX,
|
|
45
|
-
'react-dom': reactDom,
|
|
46
|
-
},
|
|
47
|
-
rules: {
|
|
48
|
-
// other rules...
|
|
49
|
-
// Enable its recommended typescript rules
|
|
50
|
-
...reactX.configs['recommended-typescript'].rules,
|
|
51
|
-
...reactDom.configs.recommended.rules,
|
|
52
|
-
},
|
|
53
|
-
})
|
|
54
|
-
```
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## Expanding the ESLint configuration
|
|
11
|
+
|
|
12
|
+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
export default tseslint.config({
|
|
16
|
+
extends: [
|
|
17
|
+
// Remove ...tseslint.configs.recommended and replace with this
|
|
18
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
19
|
+
// Alternatively, use this for stricter rules
|
|
20
|
+
...tseslint.configs.strictTypeChecked,
|
|
21
|
+
// Optionally, add this for stylistic rules
|
|
22
|
+
...tseslint.configs.stylisticTypeChecked,
|
|
23
|
+
],
|
|
24
|
+
languageOptions: {
|
|
25
|
+
// other options...
|
|
26
|
+
parserOptions: {
|
|
27
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
28
|
+
tsconfigRootDir: import.meta.dirname,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
// eslint.config.js
|
|
38
|
+
import reactX from 'eslint-plugin-react-x'
|
|
39
|
+
import reactDom from 'eslint-plugin-react-dom'
|
|
40
|
+
|
|
41
|
+
export default tseslint.config({
|
|
42
|
+
plugins: {
|
|
43
|
+
// Add the react-x and react-dom plugins
|
|
44
|
+
'react-x': reactX,
|
|
45
|
+
'react-dom': reactDom,
|
|
46
|
+
},
|
|
47
|
+
rules: {
|
|
48
|
+
// other rules...
|
|
49
|
+
// Enable its recommended typescript rules
|
|
50
|
+
...reactX.configs['recommended-typescript'].rules,
|
|
51
|
+
...reactDom.configs.recommended.rules,
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
```
|
package/dist/index.d.mts
CHANGED
|
@@ -57,15 +57,20 @@ interface TableProps {
|
|
|
57
57
|
interface CellProps {
|
|
58
58
|
children?: React$1.ReactNode;
|
|
59
59
|
style?: any;
|
|
60
|
-
cellSize?: "small" | "medium" | "large";
|
|
61
60
|
width?: string | number;
|
|
62
61
|
height?: string | number;
|
|
63
62
|
colSpan?: number;
|
|
63
|
+
isLast?: boolean;
|
|
64
|
+
isLastRow?: boolean;
|
|
65
|
+
isOdd?: boolean;
|
|
64
66
|
}
|
|
65
67
|
declare const Table: React$1.FC<TableProps>;
|
|
66
68
|
declare const Thead: React$1.FC<TableProps>;
|
|
67
69
|
declare const Tbody: React$1.FC<TableProps>;
|
|
68
|
-
declare const Tr: React$1.FC<TableProps
|
|
70
|
+
declare const Tr: React$1.FC<TableProps & {
|
|
71
|
+
isLastRow?: boolean;
|
|
72
|
+
isOdd?: boolean;
|
|
73
|
+
}>;
|
|
69
74
|
declare const Th: React$1.FC<CellProps>;
|
|
70
75
|
declare const Td: React$1.FC<CellProps>;
|
|
71
76
|
|
|
@@ -104,19 +109,33 @@ interface PageElementProps {
|
|
|
104
109
|
declare const Header: React$1.FC<PageElementProps>;
|
|
105
110
|
declare const Footer: React$1.FC<PageElementProps>;
|
|
106
111
|
|
|
107
|
-
interface
|
|
108
|
-
|
|
112
|
+
interface QRCustomProps {
|
|
113
|
+
url: string;
|
|
109
114
|
size?: number;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
colorLight?: string;
|
|
113
|
-
margin?: number;
|
|
115
|
+
colorData?: string;
|
|
116
|
+
colorDataBG?: string;
|
|
114
117
|
logo?: string;
|
|
115
118
|
logoWidth?: number;
|
|
116
119
|
logoHeight?: number;
|
|
120
|
+
margin?: number;
|
|
117
121
|
errorCorrectionLevel?: "L" | "M" | "Q" | "H";
|
|
122
|
+
style?: any;
|
|
123
|
+
dotType?: "rounded" | "dots" | "classy" | "classy-rounded" | "square" | "extra-rounded";
|
|
124
|
+
cornerSquareType?: "square" | "dot" | "extra-rounded";
|
|
125
|
+
cornerDotType?: "square" | "dot";
|
|
126
|
+
cornerSquareColor?: string;
|
|
127
|
+
cornerDotColor?: string;
|
|
128
|
+
logoBG?: string;
|
|
129
|
+
logoText?: string;
|
|
130
|
+
moveText?: number;
|
|
131
|
+
textColor?: string;
|
|
132
|
+
fontSize?: number;
|
|
133
|
+
fontFamily?: string;
|
|
134
|
+
textBackgroundColor?: string;
|
|
135
|
+
textPadding?: number;
|
|
136
|
+
textBold?: boolean;
|
|
118
137
|
}
|
|
119
|
-
declare const QR: React$1.FC<
|
|
138
|
+
declare const QR: React$1.FC<QRCustomProps>;
|
|
120
139
|
|
|
121
140
|
interface ListProps {
|
|
122
141
|
children: React$1.ReactNode;
|
package/dist/index.d.ts
CHANGED
|
@@ -57,15 +57,20 @@ interface TableProps {
|
|
|
57
57
|
interface CellProps {
|
|
58
58
|
children?: React$1.ReactNode;
|
|
59
59
|
style?: any;
|
|
60
|
-
cellSize?: "small" | "medium" | "large";
|
|
61
60
|
width?: string | number;
|
|
62
61
|
height?: string | number;
|
|
63
62
|
colSpan?: number;
|
|
63
|
+
isLast?: boolean;
|
|
64
|
+
isLastRow?: boolean;
|
|
65
|
+
isOdd?: boolean;
|
|
64
66
|
}
|
|
65
67
|
declare const Table: React$1.FC<TableProps>;
|
|
66
68
|
declare const Thead: React$1.FC<TableProps>;
|
|
67
69
|
declare const Tbody: React$1.FC<TableProps>;
|
|
68
|
-
declare const Tr: React$1.FC<TableProps
|
|
70
|
+
declare const Tr: React$1.FC<TableProps & {
|
|
71
|
+
isLastRow?: boolean;
|
|
72
|
+
isOdd?: boolean;
|
|
73
|
+
}>;
|
|
69
74
|
declare const Th: React$1.FC<CellProps>;
|
|
70
75
|
declare const Td: React$1.FC<CellProps>;
|
|
71
76
|
|
|
@@ -104,19 +109,33 @@ interface PageElementProps {
|
|
|
104
109
|
declare const Header: React$1.FC<PageElementProps>;
|
|
105
110
|
declare const Footer: React$1.FC<PageElementProps>;
|
|
106
111
|
|
|
107
|
-
interface
|
|
108
|
-
|
|
112
|
+
interface QRCustomProps {
|
|
113
|
+
url: string;
|
|
109
114
|
size?: number;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
colorLight?: string;
|
|
113
|
-
margin?: number;
|
|
115
|
+
colorData?: string;
|
|
116
|
+
colorDataBG?: string;
|
|
114
117
|
logo?: string;
|
|
115
118
|
logoWidth?: number;
|
|
116
119
|
logoHeight?: number;
|
|
120
|
+
margin?: number;
|
|
117
121
|
errorCorrectionLevel?: "L" | "M" | "Q" | "H";
|
|
122
|
+
style?: any;
|
|
123
|
+
dotType?: "rounded" | "dots" | "classy" | "classy-rounded" | "square" | "extra-rounded";
|
|
124
|
+
cornerSquareType?: "square" | "dot" | "extra-rounded";
|
|
125
|
+
cornerDotType?: "square" | "dot";
|
|
126
|
+
cornerSquareColor?: string;
|
|
127
|
+
cornerDotColor?: string;
|
|
128
|
+
logoBG?: string;
|
|
129
|
+
logoText?: string;
|
|
130
|
+
moveText?: number;
|
|
131
|
+
textColor?: string;
|
|
132
|
+
fontSize?: number;
|
|
133
|
+
fontFamily?: string;
|
|
134
|
+
textBackgroundColor?: string;
|
|
135
|
+
textPadding?: number;
|
|
136
|
+
textBold?: boolean;
|
|
118
137
|
}
|
|
119
|
-
declare const QR: React$1.FC<
|
|
138
|
+
declare const QR: React$1.FC<QRCustomProps>;
|
|
120
139
|
|
|
121
140
|
interface ListProps {
|
|
122
141
|
children: React$1.ReactNode;
|
package/dist/index.js
CHANGED
|
@@ -325,81 +325,100 @@ var styles5 = import_renderer5.StyleSheet.create({
|
|
|
325
325
|
width: "100%",
|
|
326
326
|
borderWidth: 1,
|
|
327
327
|
borderColor: "#000",
|
|
328
|
-
overflow: "hidden",
|
|
329
328
|
marginBottom: 20
|
|
330
329
|
},
|
|
331
330
|
thead: {
|
|
332
|
-
backgroundColor: "#
|
|
331
|
+
backgroundColor: "#ccc"
|
|
333
332
|
},
|
|
334
|
-
tbody: {},
|
|
335
333
|
tr: {
|
|
336
|
-
flexDirection: "row"
|
|
337
|
-
borderBottomWidth: 1,
|
|
338
|
-
borderColor: "#000"
|
|
334
|
+
flexDirection: "row"
|
|
339
335
|
},
|
|
340
|
-
|
|
341
|
-
paddingTop: 4,
|
|
336
|
+
textBold: {
|
|
342
337
|
fontSize: 10,
|
|
343
338
|
fontFamily: "Helvetica",
|
|
344
339
|
fontWeight: "bold",
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
textAlign: "center"
|
|
340
|
+
textAlign: "center",
|
|
341
|
+
paddingTop: 4
|
|
348
342
|
},
|
|
349
|
-
|
|
350
|
-
paddingTop: 4,
|
|
351
|
-
paddingLeft: 8,
|
|
352
|
-
paddingRight: 8,
|
|
343
|
+
text: {
|
|
353
344
|
fontSize: 10,
|
|
354
345
|
fontFamily: "Helvetica",
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
},
|
|
359
|
-
cellSmall: {
|
|
360
|
-
width: "25%"
|
|
361
|
-
},
|
|
362
|
-
cellMedium: {
|
|
363
|
-
width: "33.33%"
|
|
346
|
+
paddingTop: 4,
|
|
347
|
+
paddingLeft: 8,
|
|
348
|
+
paddingRight: 8
|
|
364
349
|
},
|
|
365
|
-
|
|
366
|
-
|
|
350
|
+
zebraOdd: {
|
|
351
|
+
backgroundColor: "#eeeeee"
|
|
367
352
|
}
|
|
368
353
|
});
|
|
369
|
-
var
|
|
370
|
-
|
|
371
|
-
medium: styles5.cellMedium,
|
|
372
|
-
large: styles5.cellLarge
|
|
373
|
-
};
|
|
374
|
-
var Table = ({ children, style }) => {
|
|
375
|
-
return /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.table, style] }, children);
|
|
376
|
-
};
|
|
377
|
-
var Thead = ({ children, style }) => {
|
|
378
|
-
return /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.thead, style] }, children);
|
|
379
|
-
};
|
|
354
|
+
var Table = ({ children, style }) => /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.table, style] }, children);
|
|
355
|
+
var Thead = ({ children, style }) => /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.thead, style] }, children);
|
|
380
356
|
var Tbody = ({ children, style }) => {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
357
|
+
const rows = import_react5.default.Children.toArray(children);
|
|
358
|
+
const count = rows.length;
|
|
359
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, rows.map(
|
|
360
|
+
(row, idx) => import_react5.default.cloneElement(row, {
|
|
361
|
+
isLastRow: idx === count - 1,
|
|
362
|
+
isOdd: idx % 2 === 1
|
|
363
|
+
})
|
|
364
|
+
));
|
|
365
|
+
};
|
|
366
|
+
var Tr = ({
|
|
367
|
+
children,
|
|
368
|
+
style,
|
|
369
|
+
isLastRow = false,
|
|
370
|
+
isOdd = false
|
|
371
|
+
}) => {
|
|
372
|
+
const elements = import_react5.default.Children.toArray(children);
|
|
373
|
+
const count = elements.length;
|
|
374
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.tr, style] }, elements.map((child, idx) => {
|
|
375
|
+
const isLast = idx === count - 1;
|
|
376
|
+
const width = `${(100 / count).toFixed(2)}%`;
|
|
377
|
+
return import_react5.default.cloneElement(child, { width, isLast, isLastRow, isOdd });
|
|
378
|
+
}));
|
|
379
|
+
};
|
|
380
|
+
var Th = ({
|
|
381
|
+
children,
|
|
382
|
+
style,
|
|
383
|
+
width,
|
|
384
|
+
height,
|
|
385
|
+
colSpan,
|
|
386
|
+
isLast = false,
|
|
387
|
+
isLastRow = false
|
|
388
|
+
}) => {
|
|
389
|
+
const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
|
|
390
|
+
const borders = {
|
|
391
|
+
borderRightWidth: isLast ? 0 : 1,
|
|
392
|
+
borderBottomWidth: isLastRow ? 0 : 1,
|
|
393
|
+
borderColor: "#000",
|
|
391
394
|
...height !== void 0 && { height }
|
|
392
395
|
};
|
|
393
|
-
return /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.
|
|
396
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.textBold, { width: baseWidth }, borders, style] }, /* @__PURE__ */ import_react5.default.createElement(import_renderer5.Text, null, children));
|
|
394
397
|
};
|
|
395
|
-
var Td = ({
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
var Td = ({
|
|
399
|
+
children,
|
|
400
|
+
style,
|
|
401
|
+
width,
|
|
402
|
+
height,
|
|
403
|
+
colSpan,
|
|
404
|
+
isLast = false,
|
|
405
|
+
isLastRow = false,
|
|
406
|
+
isOdd = false
|
|
407
|
+
}) => {
|
|
408
|
+
const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
|
|
409
|
+
const borders = {
|
|
410
|
+
borderRightWidth: isLast ? 0 : 1,
|
|
411
|
+
borderBottomWidth: isLastRow ? 0 : 1,
|
|
412
|
+
borderColor: "#000",
|
|
400
413
|
...height !== void 0 && { height }
|
|
401
414
|
};
|
|
402
|
-
return /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [
|
|
415
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [
|
|
416
|
+
styles5.text,
|
|
417
|
+
isOdd && styles5.zebraOdd,
|
|
418
|
+
{ width: baseWidth },
|
|
419
|
+
borders,
|
|
420
|
+
style
|
|
421
|
+
] }, /* @__PURE__ */ import_react5.default.createElement(import_renderer5.Text, null, children));
|
|
403
422
|
};
|
|
404
423
|
|
|
405
424
|
// src/components/core/Grid.tsx
|
|
@@ -508,154 +527,174 @@ var Footer = ({ children, style, fixed = false }) => {
|
|
|
508
527
|
|
|
509
528
|
// src/components/core/QR.tsx
|
|
510
529
|
var import_react8 = __toESM(require("react"));
|
|
511
|
-
var import_renderer8 = require("@react-pdf/renderer");
|
|
512
530
|
var import_react9 = require("react");
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
var import_qrcode = __toESM(require("qrcode"));
|
|
516
|
-
var generateQRAsBase64 = async ({
|
|
517
|
-
value,
|
|
518
|
-
size = 150,
|
|
519
|
-
colorDark = "#282828",
|
|
520
|
-
colorLight = "#ffffff",
|
|
521
|
-
margin = 0,
|
|
522
|
-
errorCorrectionLevel = "M"
|
|
523
|
-
}) => {
|
|
524
|
-
try {
|
|
525
|
-
const options = {
|
|
526
|
-
errorCorrectionLevel,
|
|
527
|
-
type: "image/png",
|
|
528
|
-
quality: 0.92,
|
|
529
|
-
margin,
|
|
530
|
-
color: {
|
|
531
|
-
dark: colorDark,
|
|
532
|
-
light: colorLight
|
|
533
|
-
},
|
|
534
|
-
width: size
|
|
535
|
-
};
|
|
536
|
-
const qrDataUrl = import_qrcode.default.toDataURL(value, options);
|
|
537
|
-
return qrDataUrl;
|
|
538
|
-
} catch (error) {
|
|
539
|
-
console.error("Error generando QR:", error);
|
|
540
|
-
return "";
|
|
541
|
-
}
|
|
542
|
-
};
|
|
543
|
-
var addLogoToQR = async (qrDataUrl, logoUrl, logoWidth, logoHeight) => {
|
|
544
|
-
return new Promise((resolve) => {
|
|
545
|
-
if (!qrDataUrl || !logoUrl) {
|
|
546
|
-
resolve(qrDataUrl);
|
|
547
|
-
return;
|
|
548
|
-
}
|
|
549
|
-
try {
|
|
550
|
-
const canvas = document.createElement("canvas");
|
|
551
|
-
const ctx = canvas.getContext("2d");
|
|
552
|
-
if (!ctx) {
|
|
553
|
-
resolve(qrDataUrl);
|
|
554
|
-
return;
|
|
555
|
-
}
|
|
556
|
-
const qrImage = new Image();
|
|
557
|
-
qrImage.crossOrigin = "anonymous";
|
|
558
|
-
qrImage.onload = () => {
|
|
559
|
-
canvas.width = qrImage.width;
|
|
560
|
-
canvas.height = qrImage.height;
|
|
561
|
-
ctx.drawImage(qrImage, 0, 0, canvas.width, canvas.height);
|
|
562
|
-
const logoImage = new Image();
|
|
563
|
-
logoImage.crossOrigin = "anonymous";
|
|
564
|
-
logoImage.onload = () => {
|
|
565
|
-
const x = (canvas.width - logoWidth) / 2;
|
|
566
|
-
const y = (canvas.height - logoHeight) / 2;
|
|
567
|
-
ctx.fillStyle = "#FFFFFF";
|
|
568
|
-
ctx.fillRect(x - 5, y - 5, logoWidth + 10, logoHeight + 10);
|
|
569
|
-
ctx.drawImage(logoImage, x, y, logoWidth, logoHeight);
|
|
570
|
-
const finalQrDataUrl = canvas.toDataURL("image/png");
|
|
571
|
-
resolve(finalQrDataUrl);
|
|
572
|
-
};
|
|
573
|
-
logoImage.onerror = () => {
|
|
574
|
-
console.error("Error cargando el logo");
|
|
575
|
-
resolve(qrDataUrl);
|
|
576
|
-
};
|
|
577
|
-
logoImage.src = logoUrl;
|
|
578
|
-
};
|
|
579
|
-
qrImage.onerror = () => {
|
|
580
|
-
console.error("Error cargando el QR");
|
|
581
|
-
resolve("");
|
|
582
|
-
};
|
|
583
|
-
qrImage.src = qrDataUrl;
|
|
584
|
-
} catch (error) {
|
|
585
|
-
console.error("Error procesando el QR con logo:", error);
|
|
586
|
-
resolve(qrDataUrl);
|
|
587
|
-
}
|
|
588
|
-
});
|
|
589
|
-
};
|
|
590
|
-
|
|
591
|
-
// src/components/core/QR.tsx
|
|
592
|
-
var styles8 = import_renderer8.StyleSheet.create({
|
|
593
|
-
qrContainer: {
|
|
594
|
-
display: "flex",
|
|
595
|
-
alignItems: "center",
|
|
596
|
-
justifyContent: "center",
|
|
597
|
-
margin: 10
|
|
598
|
-
}
|
|
599
|
-
});
|
|
600
|
-
var errorLevelMap = {
|
|
601
|
-
0: "L",
|
|
602
|
-
1: "M",
|
|
603
|
-
2: "Q",
|
|
604
|
-
3: "H"
|
|
605
|
-
};
|
|
531
|
+
var import_renderer8 = require("@react-pdf/renderer");
|
|
532
|
+
var import_qr_code_styling = __toESM(require("qr-code-styling"));
|
|
606
533
|
var QR = ({
|
|
607
|
-
|
|
608
|
-
size =
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
margin = 0,
|
|
613
|
-
logo = "",
|
|
534
|
+
url,
|
|
535
|
+
size = 200,
|
|
536
|
+
colorData = "#000000",
|
|
537
|
+
colorDataBG = "#ffffff",
|
|
538
|
+
logo,
|
|
614
539
|
logoWidth = 30,
|
|
615
|
-
logoHeight
|
|
616
|
-
|
|
540
|
+
logoHeight,
|
|
541
|
+
margin = 0,
|
|
542
|
+
errorCorrectionLevel = "H",
|
|
543
|
+
style,
|
|
544
|
+
dotType = "square",
|
|
545
|
+
cornerSquareType = "square",
|
|
546
|
+
cornerDotType = "square",
|
|
547
|
+
cornerSquareColor,
|
|
548
|
+
cornerDotColor,
|
|
549
|
+
logoBG = colorDataBG,
|
|
550
|
+
logoText,
|
|
551
|
+
moveText = 0,
|
|
552
|
+
textColor = colorData,
|
|
553
|
+
fontSize = 12,
|
|
554
|
+
fontFamily = "Helvetica",
|
|
555
|
+
textBackgroundColor = colorDataBG,
|
|
556
|
+
textPadding = 1,
|
|
557
|
+
textBold = true
|
|
617
558
|
}) => {
|
|
618
|
-
const [
|
|
559
|
+
const [qrDataURL, setQrDataURL] = (0, import_react9.useState)(null);
|
|
560
|
+
const actualLogoWidth = logoWidth || Math.floor(size * 0.2);
|
|
561
|
+
const actualLogoHeight = logoHeight || actualLogoWidth;
|
|
619
562
|
(0, import_react9.useEffect)(() => {
|
|
620
|
-
|
|
563
|
+
if (typeof window === "undefined") return;
|
|
564
|
+
const generateQRCode = async () => {
|
|
621
565
|
try {
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
size,
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
566
|
+
const qrCode = new import_qr_code_styling.default({
|
|
567
|
+
width: size,
|
|
568
|
+
height: size,
|
|
569
|
+
type: "canvas",
|
|
570
|
+
data: url,
|
|
571
|
+
dotsOptions: {
|
|
572
|
+
color: colorData,
|
|
573
|
+
type: dotType
|
|
574
|
+
},
|
|
575
|
+
cornersSquareOptions: {
|
|
576
|
+
color: cornerSquareColor || colorData,
|
|
577
|
+
type: cornerSquareType
|
|
578
|
+
},
|
|
579
|
+
cornersDotOptions: {
|
|
580
|
+
color: cornerDotColor || colorData,
|
|
581
|
+
type: cornerDotType
|
|
582
|
+
},
|
|
583
|
+
backgroundOptions: {
|
|
584
|
+
color: colorDataBG
|
|
585
|
+
},
|
|
586
|
+
qrOptions: {
|
|
587
|
+
errorCorrectionLevel
|
|
588
|
+
},
|
|
589
|
+
margin
|
|
629
590
|
});
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
591
|
+
const container = document.createElement("div");
|
|
592
|
+
container.style.position = "absolute";
|
|
593
|
+
container.style.top = "-9999px";
|
|
594
|
+
container.style.left = "-9999px";
|
|
595
|
+
document.body.appendChild(container);
|
|
596
|
+
qrCode.append(container);
|
|
597
|
+
setTimeout(() => {
|
|
598
|
+
try {
|
|
599
|
+
const qrCanvas = container.querySelector("canvas");
|
|
600
|
+
if (qrCanvas) {
|
|
601
|
+
const canvas = document.createElement("canvas");
|
|
602
|
+
canvas.width = size;
|
|
603
|
+
canvas.height = size;
|
|
604
|
+
const ctx = canvas.getContext("2d");
|
|
605
|
+
if (ctx) {
|
|
606
|
+
ctx.drawImage(qrCanvas, 0, 0);
|
|
607
|
+
const dataURL = canvas.toDataURL("image/png");
|
|
608
|
+
setQrDataURL(dataURL);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
document.body.removeChild(container);
|
|
612
|
+
} catch (error) {
|
|
613
|
+
console.error("Error capturing QR code:", error);
|
|
614
|
+
}
|
|
615
|
+
}, 100);
|
|
636
616
|
} catch (error) {
|
|
637
|
-
console.error("Error
|
|
638
|
-
const fallbackUrl2 = `https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(
|
|
639
|
-
value
|
|
640
|
-
)}&size=${size}x${size}&color=${encodeURIComponent(colorDark.replace("#", ""))}&bgcolor=${encodeURIComponent(
|
|
641
|
-
colorLight.replace("#", "")
|
|
642
|
-
)}`;
|
|
643
|
-
setQrDataUrl(fallbackUrl2);
|
|
617
|
+
console.error("Error generating QR code:", error);
|
|
644
618
|
}
|
|
645
619
|
};
|
|
646
|
-
|
|
647
|
-
}, [
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
620
|
+
generateQRCode();
|
|
621
|
+
}, [
|
|
622
|
+
url,
|
|
623
|
+
size,
|
|
624
|
+
colorData,
|
|
625
|
+
colorDataBG,
|
|
626
|
+
margin,
|
|
627
|
+
errorCorrectionLevel,
|
|
628
|
+
dotType,
|
|
629
|
+
cornerSquareType,
|
|
630
|
+
cornerDotType,
|
|
631
|
+
cornerSquareColor,
|
|
632
|
+
cornerDotColor,
|
|
633
|
+
logoBG
|
|
634
|
+
]);
|
|
635
|
+
if (!qrDataURL) return null;
|
|
636
|
+
const centerPosition = size / 2;
|
|
637
|
+
const logoContainerSize = Math.max(actualLogoWidth, actualLogoHeight) + 10;
|
|
638
|
+
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(
|
|
639
|
+
import_renderer8.View,
|
|
640
|
+
{
|
|
641
|
+
style: {
|
|
642
|
+
position: "absolute",
|
|
643
|
+
width: logoContainerSize,
|
|
644
|
+
height: logoContainerSize,
|
|
645
|
+
backgroundColor: logoBG || colorDataBG,
|
|
646
|
+
left: centerPosition - logoContainerSize / 2,
|
|
647
|
+
top: centerPosition - logoContainerSize / 2,
|
|
648
|
+
borderRadius: 100,
|
|
649
|
+
border: `5px solid ${colorData}`,
|
|
650
|
+
padding: 0
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
/* @__PURE__ */ import_react8.default.createElement(
|
|
654
|
+
import_renderer8.Image,
|
|
655
|
+
{
|
|
656
|
+
src: logo || "/placeholder.svg",
|
|
657
|
+
style: {
|
|
658
|
+
objectFit: "contain",
|
|
659
|
+
width: actualLogoWidth,
|
|
660
|
+
height: actualLogoHeight || actualLogoWidth
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
)
|
|
664
|
+
), !logo && logoText && /* @__PURE__ */ import_react8.default.createElement(
|
|
665
|
+
import_renderer8.View,
|
|
666
|
+
{
|
|
667
|
+
style: {
|
|
668
|
+
position: "absolute",
|
|
669
|
+
backgroundColor: textBackgroundColor,
|
|
670
|
+
padding: textPadding,
|
|
671
|
+
borderRadius: 4,
|
|
672
|
+
left: moveText + centerPosition - 20,
|
|
673
|
+
// Approximate center
|
|
674
|
+
top: centerPosition - 10
|
|
675
|
+
// Approximate center
|
|
676
|
+
}
|
|
677
|
+
},
|
|
678
|
+
/* @__PURE__ */ import_react8.default.createElement(
|
|
679
|
+
import_renderer8.Text,
|
|
680
|
+
{
|
|
681
|
+
style: {
|
|
682
|
+
color: textColor,
|
|
683
|
+
fontSize,
|
|
684
|
+
fontFamily,
|
|
685
|
+
fontWeight: textBold ? "bold" : "normal"
|
|
686
|
+
}
|
|
687
|
+
},
|
|
688
|
+
logoText
|
|
689
|
+
)
|
|
690
|
+
));
|
|
652
691
|
};
|
|
653
692
|
var QR_default = QR;
|
|
654
693
|
|
|
655
694
|
// src/components/core/Lista.tsx
|
|
656
695
|
var import_react10 = __toESM(require("react"));
|
|
657
696
|
var import_renderer9 = require("@react-pdf/renderer");
|
|
658
|
-
var
|
|
697
|
+
var styles8 = import_renderer9.StyleSheet.create({
|
|
659
698
|
ul: {
|
|
660
699
|
marginBottom: 10,
|
|
661
700
|
paddingLeft: 15
|
|
@@ -725,7 +764,7 @@ var UL = ({ children, style, type = "disc" }) => {
|
|
|
725
764
|
}
|
|
726
765
|
return child;
|
|
727
766
|
});
|
|
728
|
-
return /* @__PURE__ */ import_react10.default.createElement(import_renderer9.View, { style: [
|
|
767
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_renderer9.View, { style: [styles8.ul, style] }, childrenWithBullets);
|
|
729
768
|
};
|
|
730
769
|
var OL = ({ children, style, type = "decimal", start = 1 }) => {
|
|
731
770
|
const childrenWithNumbers = import_react10.default.Children.map(children, (child, index) => {
|
|
@@ -739,7 +778,7 @@ var OL = ({ children, style, type = "decimal", start = 1 }) => {
|
|
|
739
778
|
}
|
|
740
779
|
return child;
|
|
741
780
|
});
|
|
742
|
-
return /* @__PURE__ */ import_react10.default.createElement(import_renderer9.View, { style: [
|
|
781
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_renderer9.View, { style: [styles8.ol, style] }, childrenWithNumbers);
|
|
743
782
|
};
|
|
744
783
|
var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1, start = 1, value }) => {
|
|
745
784
|
let marker;
|
|
@@ -749,7 +788,7 @@ var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1,
|
|
|
749
788
|
} else {
|
|
750
789
|
marker = getBulletPoint(bulletType);
|
|
751
790
|
}
|
|
752
|
-
return /* @__PURE__ */ import_react10.default.createElement(import_renderer9.View, { style: [
|
|
791
|
+
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));
|
|
753
792
|
};
|
|
754
793
|
|
|
755
794
|
// src/components/core/index.tsx
|
package/dist/index.mjs
CHANGED
|
@@ -71,7 +71,7 @@ var LayoutPDF_default = LayoutPDF;
|
|
|
71
71
|
|
|
72
72
|
// src/components/core/Img.tsx
|
|
73
73
|
import React2 from "react";
|
|
74
|
-
import { Image
|
|
74
|
+
import { Image, StyleSheet as StyleSheet2 } from "@react-pdf/renderer";
|
|
75
75
|
var styles2 = StyleSheet2.create({
|
|
76
76
|
image: {
|
|
77
77
|
width: "100%",
|
|
@@ -80,7 +80,7 @@ var styles2 = StyleSheet2.create({
|
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
var Img = ({ src, style }) => {
|
|
83
|
-
return /* @__PURE__ */ React2.createElement(
|
|
83
|
+
return /* @__PURE__ */ React2.createElement(Image, { src, style: [styles2.image, style] });
|
|
84
84
|
};
|
|
85
85
|
var Img_default = Img;
|
|
86
86
|
|
|
@@ -237,81 +237,100 @@ var styles5 = StyleSheet5.create({
|
|
|
237
237
|
width: "100%",
|
|
238
238
|
borderWidth: 1,
|
|
239
239
|
borderColor: "#000",
|
|
240
|
-
overflow: "hidden",
|
|
241
240
|
marginBottom: 20
|
|
242
241
|
},
|
|
243
242
|
thead: {
|
|
244
|
-
backgroundColor: "#
|
|
243
|
+
backgroundColor: "#ccc"
|
|
245
244
|
},
|
|
246
|
-
tbody: {},
|
|
247
245
|
tr: {
|
|
248
|
-
flexDirection: "row"
|
|
249
|
-
borderBottomWidth: 1,
|
|
250
|
-
borderColor: "#000"
|
|
246
|
+
flexDirection: "row"
|
|
251
247
|
},
|
|
252
|
-
|
|
253
|
-
paddingTop: 4,
|
|
248
|
+
textBold: {
|
|
254
249
|
fontSize: 10,
|
|
255
250
|
fontFamily: "Helvetica",
|
|
256
251
|
fontWeight: "bold",
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
textAlign: "center"
|
|
252
|
+
textAlign: "center",
|
|
253
|
+
paddingTop: 4
|
|
260
254
|
},
|
|
261
|
-
|
|
262
|
-
paddingTop: 4,
|
|
263
|
-
paddingLeft: 8,
|
|
264
|
-
paddingRight: 8,
|
|
255
|
+
text: {
|
|
265
256
|
fontSize: 10,
|
|
266
257
|
fontFamily: "Helvetica",
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
},
|
|
271
|
-
cellSmall: {
|
|
272
|
-
width: "25%"
|
|
273
|
-
},
|
|
274
|
-
cellMedium: {
|
|
275
|
-
width: "33.33%"
|
|
258
|
+
paddingTop: 4,
|
|
259
|
+
paddingLeft: 8,
|
|
260
|
+
paddingRight: 8
|
|
276
261
|
},
|
|
277
|
-
|
|
278
|
-
|
|
262
|
+
zebraOdd: {
|
|
263
|
+
backgroundColor: "#eeeeee"
|
|
279
264
|
}
|
|
280
265
|
});
|
|
281
|
-
var
|
|
282
|
-
|
|
283
|
-
medium: styles5.cellMedium,
|
|
284
|
-
large: styles5.cellLarge
|
|
285
|
-
};
|
|
286
|
-
var Table = ({ children, style }) => {
|
|
287
|
-
return /* @__PURE__ */ React5.createElement(View2, { style: [styles5.table, style] }, children);
|
|
288
|
-
};
|
|
289
|
-
var Thead = ({ children, style }) => {
|
|
290
|
-
return /* @__PURE__ */ React5.createElement(View2, { style: [styles5.thead, style] }, children);
|
|
291
|
-
};
|
|
266
|
+
var Table = ({ children, style }) => /* @__PURE__ */ React5.createElement(View2, { style: [styles5.table, style] }, children);
|
|
267
|
+
var Thead = ({ children, style }) => /* @__PURE__ */ React5.createElement(View2, { style: [styles5.thead, style] }, children);
|
|
292
268
|
var Tbody = ({ children, style }) => {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
269
|
+
const rows = React5.Children.toArray(children);
|
|
270
|
+
const count = rows.length;
|
|
271
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, rows.map(
|
|
272
|
+
(row, idx) => React5.cloneElement(row, {
|
|
273
|
+
isLastRow: idx === count - 1,
|
|
274
|
+
isOdd: idx % 2 === 1
|
|
275
|
+
})
|
|
276
|
+
));
|
|
277
|
+
};
|
|
278
|
+
var Tr = ({
|
|
279
|
+
children,
|
|
280
|
+
style,
|
|
281
|
+
isLastRow = false,
|
|
282
|
+
isOdd = false
|
|
283
|
+
}) => {
|
|
284
|
+
const elements = React5.Children.toArray(children);
|
|
285
|
+
const count = elements.length;
|
|
286
|
+
return /* @__PURE__ */ React5.createElement(View2, { style: [styles5.tr, style] }, elements.map((child, idx) => {
|
|
287
|
+
const isLast = idx === count - 1;
|
|
288
|
+
const width = `${(100 / count).toFixed(2)}%`;
|
|
289
|
+
return React5.cloneElement(child, { width, isLast, isLastRow, isOdd });
|
|
290
|
+
}));
|
|
291
|
+
};
|
|
292
|
+
var Th = ({
|
|
293
|
+
children,
|
|
294
|
+
style,
|
|
295
|
+
width,
|
|
296
|
+
height,
|
|
297
|
+
colSpan,
|
|
298
|
+
isLast = false,
|
|
299
|
+
isLastRow = false
|
|
300
|
+
}) => {
|
|
301
|
+
const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
|
|
302
|
+
const borders = {
|
|
303
|
+
borderRightWidth: isLast ? 0 : 1,
|
|
304
|
+
borderBottomWidth: isLastRow ? 0 : 1,
|
|
305
|
+
borderColor: "#000",
|
|
303
306
|
...height !== void 0 && { height }
|
|
304
307
|
};
|
|
305
|
-
return /* @__PURE__ */ React5.createElement(View2, { style: [styles5.
|
|
308
|
+
return /* @__PURE__ */ React5.createElement(View2, { style: [styles5.textBold, { width: baseWidth }, borders, style] }, /* @__PURE__ */ React5.createElement(Text3, null, children));
|
|
306
309
|
};
|
|
307
|
-
var Td = ({
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
310
|
+
var Td = ({
|
|
311
|
+
children,
|
|
312
|
+
style,
|
|
313
|
+
width,
|
|
314
|
+
height,
|
|
315
|
+
colSpan,
|
|
316
|
+
isLast = false,
|
|
317
|
+
isLastRow = false,
|
|
318
|
+
isOdd = false
|
|
319
|
+
}) => {
|
|
320
|
+
const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
|
|
321
|
+
const borders = {
|
|
322
|
+
borderRightWidth: isLast ? 0 : 1,
|
|
323
|
+
borderBottomWidth: isLastRow ? 0 : 1,
|
|
324
|
+
borderColor: "#000",
|
|
312
325
|
...height !== void 0 && { height }
|
|
313
326
|
};
|
|
314
|
-
return /* @__PURE__ */ React5.createElement(View2, { style: [
|
|
327
|
+
return /* @__PURE__ */ React5.createElement(View2, { style: [
|
|
328
|
+
styles5.text,
|
|
329
|
+
isOdd && styles5.zebraOdd,
|
|
330
|
+
{ width: baseWidth },
|
|
331
|
+
borders,
|
|
332
|
+
style
|
|
333
|
+
] }, /* @__PURE__ */ React5.createElement(Text3, null, children));
|
|
315
334
|
};
|
|
316
335
|
|
|
317
336
|
// src/components/core/Grid.tsx
|
|
@@ -420,154 +439,174 @@ var Footer = ({ children, style, fixed = false }) => {
|
|
|
420
439
|
|
|
421
440
|
// src/components/core/QR.tsx
|
|
422
441
|
import React8 from "react";
|
|
423
|
-
import { Image as Image3, StyleSheet as StyleSheet8, View as View5 } from "@react-pdf/renderer";
|
|
424
442
|
import { useEffect, useState } from "react";
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
import QRCode from "qrcode";
|
|
428
|
-
var generateQRAsBase64 = async ({
|
|
429
|
-
value,
|
|
430
|
-
size = 150,
|
|
431
|
-
colorDark = "#282828",
|
|
432
|
-
colorLight = "#ffffff",
|
|
433
|
-
margin = 0,
|
|
434
|
-
errorCorrectionLevel = "M"
|
|
435
|
-
}) => {
|
|
436
|
-
try {
|
|
437
|
-
const options = {
|
|
438
|
-
errorCorrectionLevel,
|
|
439
|
-
type: "image/png",
|
|
440
|
-
quality: 0.92,
|
|
441
|
-
margin,
|
|
442
|
-
color: {
|
|
443
|
-
dark: colorDark,
|
|
444
|
-
light: colorLight
|
|
445
|
-
},
|
|
446
|
-
width: size
|
|
447
|
-
};
|
|
448
|
-
const qrDataUrl = QRCode.toDataURL(value, options);
|
|
449
|
-
return qrDataUrl;
|
|
450
|
-
} catch (error) {
|
|
451
|
-
console.error("Error generando QR:", error);
|
|
452
|
-
return "";
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
var addLogoToQR = async (qrDataUrl, logoUrl, logoWidth, logoHeight) => {
|
|
456
|
-
return new Promise((resolve) => {
|
|
457
|
-
if (!qrDataUrl || !logoUrl) {
|
|
458
|
-
resolve(qrDataUrl);
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
try {
|
|
462
|
-
const canvas = document.createElement("canvas");
|
|
463
|
-
const ctx = canvas.getContext("2d");
|
|
464
|
-
if (!ctx) {
|
|
465
|
-
resolve(qrDataUrl);
|
|
466
|
-
return;
|
|
467
|
-
}
|
|
468
|
-
const qrImage = new Image();
|
|
469
|
-
qrImage.crossOrigin = "anonymous";
|
|
470
|
-
qrImage.onload = () => {
|
|
471
|
-
canvas.width = qrImage.width;
|
|
472
|
-
canvas.height = qrImage.height;
|
|
473
|
-
ctx.drawImage(qrImage, 0, 0, canvas.width, canvas.height);
|
|
474
|
-
const logoImage = new Image();
|
|
475
|
-
logoImage.crossOrigin = "anonymous";
|
|
476
|
-
logoImage.onload = () => {
|
|
477
|
-
const x = (canvas.width - logoWidth) / 2;
|
|
478
|
-
const y = (canvas.height - logoHeight) / 2;
|
|
479
|
-
ctx.fillStyle = "#FFFFFF";
|
|
480
|
-
ctx.fillRect(x - 5, y - 5, logoWidth + 10, logoHeight + 10);
|
|
481
|
-
ctx.drawImage(logoImage, x, y, logoWidth, logoHeight);
|
|
482
|
-
const finalQrDataUrl = canvas.toDataURL("image/png");
|
|
483
|
-
resolve(finalQrDataUrl);
|
|
484
|
-
};
|
|
485
|
-
logoImage.onerror = () => {
|
|
486
|
-
console.error("Error cargando el logo");
|
|
487
|
-
resolve(qrDataUrl);
|
|
488
|
-
};
|
|
489
|
-
logoImage.src = logoUrl;
|
|
490
|
-
};
|
|
491
|
-
qrImage.onerror = () => {
|
|
492
|
-
console.error("Error cargando el QR");
|
|
493
|
-
resolve("");
|
|
494
|
-
};
|
|
495
|
-
qrImage.src = qrDataUrl;
|
|
496
|
-
} catch (error) {
|
|
497
|
-
console.error("Error procesando el QR con logo:", error);
|
|
498
|
-
resolve(qrDataUrl);
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
};
|
|
502
|
-
|
|
503
|
-
// src/components/core/QR.tsx
|
|
504
|
-
var styles8 = StyleSheet8.create({
|
|
505
|
-
qrContainer: {
|
|
506
|
-
display: "flex",
|
|
507
|
-
alignItems: "center",
|
|
508
|
-
justifyContent: "center",
|
|
509
|
-
margin: 10
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
var errorLevelMap = {
|
|
513
|
-
0: "L",
|
|
514
|
-
1: "M",
|
|
515
|
-
2: "Q",
|
|
516
|
-
3: "H"
|
|
517
|
-
};
|
|
443
|
+
import { Image as Image2, View as View5, Text as Text5 } from "@react-pdf/renderer";
|
|
444
|
+
import QRCodeStyling from "qr-code-styling";
|
|
518
445
|
var QR = ({
|
|
519
|
-
|
|
520
|
-
size =
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
margin = 0,
|
|
525
|
-
logo = "",
|
|
446
|
+
url,
|
|
447
|
+
size = 200,
|
|
448
|
+
colorData = "#000000",
|
|
449
|
+
colorDataBG = "#ffffff",
|
|
450
|
+
logo,
|
|
526
451
|
logoWidth = 30,
|
|
527
|
-
logoHeight
|
|
528
|
-
|
|
452
|
+
logoHeight,
|
|
453
|
+
margin = 0,
|
|
454
|
+
errorCorrectionLevel = "H",
|
|
455
|
+
style,
|
|
456
|
+
dotType = "square",
|
|
457
|
+
cornerSquareType = "square",
|
|
458
|
+
cornerDotType = "square",
|
|
459
|
+
cornerSquareColor,
|
|
460
|
+
cornerDotColor,
|
|
461
|
+
logoBG = colorDataBG,
|
|
462
|
+
logoText,
|
|
463
|
+
moveText = 0,
|
|
464
|
+
textColor = colorData,
|
|
465
|
+
fontSize = 12,
|
|
466
|
+
fontFamily = "Helvetica",
|
|
467
|
+
textBackgroundColor = colorDataBG,
|
|
468
|
+
textPadding = 1,
|
|
469
|
+
textBold = true
|
|
529
470
|
}) => {
|
|
530
|
-
const [
|
|
471
|
+
const [qrDataURL, setQrDataURL] = useState(null);
|
|
472
|
+
const actualLogoWidth = logoWidth || Math.floor(size * 0.2);
|
|
473
|
+
const actualLogoHeight = logoHeight || actualLogoWidth;
|
|
531
474
|
useEffect(() => {
|
|
532
|
-
|
|
475
|
+
if (typeof window === "undefined") return;
|
|
476
|
+
const generateQRCode = async () => {
|
|
533
477
|
try {
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
size,
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
478
|
+
const qrCode = new QRCodeStyling({
|
|
479
|
+
width: size,
|
|
480
|
+
height: size,
|
|
481
|
+
type: "canvas",
|
|
482
|
+
data: url,
|
|
483
|
+
dotsOptions: {
|
|
484
|
+
color: colorData,
|
|
485
|
+
type: dotType
|
|
486
|
+
},
|
|
487
|
+
cornersSquareOptions: {
|
|
488
|
+
color: cornerSquareColor || colorData,
|
|
489
|
+
type: cornerSquareType
|
|
490
|
+
},
|
|
491
|
+
cornersDotOptions: {
|
|
492
|
+
color: cornerDotColor || colorData,
|
|
493
|
+
type: cornerDotType
|
|
494
|
+
},
|
|
495
|
+
backgroundOptions: {
|
|
496
|
+
color: colorDataBG
|
|
497
|
+
},
|
|
498
|
+
qrOptions: {
|
|
499
|
+
errorCorrectionLevel
|
|
500
|
+
},
|
|
501
|
+
margin
|
|
541
502
|
});
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
503
|
+
const container = document.createElement("div");
|
|
504
|
+
container.style.position = "absolute";
|
|
505
|
+
container.style.top = "-9999px";
|
|
506
|
+
container.style.left = "-9999px";
|
|
507
|
+
document.body.appendChild(container);
|
|
508
|
+
qrCode.append(container);
|
|
509
|
+
setTimeout(() => {
|
|
510
|
+
try {
|
|
511
|
+
const qrCanvas = container.querySelector("canvas");
|
|
512
|
+
if (qrCanvas) {
|
|
513
|
+
const canvas = document.createElement("canvas");
|
|
514
|
+
canvas.width = size;
|
|
515
|
+
canvas.height = size;
|
|
516
|
+
const ctx = canvas.getContext("2d");
|
|
517
|
+
if (ctx) {
|
|
518
|
+
ctx.drawImage(qrCanvas, 0, 0);
|
|
519
|
+
const dataURL = canvas.toDataURL("image/png");
|
|
520
|
+
setQrDataURL(dataURL);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
document.body.removeChild(container);
|
|
524
|
+
} catch (error) {
|
|
525
|
+
console.error("Error capturing QR code:", error);
|
|
526
|
+
}
|
|
527
|
+
}, 100);
|
|
548
528
|
} catch (error) {
|
|
549
|
-
console.error("Error
|
|
550
|
-
const fallbackUrl2 = `https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(
|
|
551
|
-
value
|
|
552
|
-
)}&size=${size}x${size}&color=${encodeURIComponent(colorDark.replace("#", ""))}&bgcolor=${encodeURIComponent(
|
|
553
|
-
colorLight.replace("#", "")
|
|
554
|
-
)}`;
|
|
555
|
-
setQrDataUrl(fallbackUrl2);
|
|
529
|
+
console.error("Error generating QR code:", error);
|
|
556
530
|
}
|
|
557
531
|
};
|
|
558
|
-
|
|
559
|
-
}, [
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
532
|
+
generateQRCode();
|
|
533
|
+
}, [
|
|
534
|
+
url,
|
|
535
|
+
size,
|
|
536
|
+
colorData,
|
|
537
|
+
colorDataBG,
|
|
538
|
+
margin,
|
|
539
|
+
errorCorrectionLevel,
|
|
540
|
+
dotType,
|
|
541
|
+
cornerSquareType,
|
|
542
|
+
cornerDotType,
|
|
543
|
+
cornerSquareColor,
|
|
544
|
+
cornerDotColor,
|
|
545
|
+
logoBG
|
|
546
|
+
]);
|
|
547
|
+
if (!qrDataURL) return null;
|
|
548
|
+
const centerPosition = size / 2;
|
|
549
|
+
const logoContainerSize = Math.max(actualLogoWidth, actualLogoHeight) + 10;
|
|
550
|
+
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(
|
|
551
|
+
View5,
|
|
552
|
+
{
|
|
553
|
+
style: {
|
|
554
|
+
position: "absolute",
|
|
555
|
+
width: logoContainerSize,
|
|
556
|
+
height: logoContainerSize,
|
|
557
|
+
backgroundColor: logoBG || colorDataBG,
|
|
558
|
+
left: centerPosition - logoContainerSize / 2,
|
|
559
|
+
top: centerPosition - logoContainerSize / 2,
|
|
560
|
+
borderRadius: 100,
|
|
561
|
+
border: `5px solid ${colorData}`,
|
|
562
|
+
padding: 0
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
/* @__PURE__ */ React8.createElement(
|
|
566
|
+
Image2,
|
|
567
|
+
{
|
|
568
|
+
src: logo || "/placeholder.svg",
|
|
569
|
+
style: {
|
|
570
|
+
objectFit: "contain",
|
|
571
|
+
width: actualLogoWidth,
|
|
572
|
+
height: actualLogoHeight || actualLogoWidth
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
)
|
|
576
|
+
), !logo && logoText && /* @__PURE__ */ React8.createElement(
|
|
577
|
+
View5,
|
|
578
|
+
{
|
|
579
|
+
style: {
|
|
580
|
+
position: "absolute",
|
|
581
|
+
backgroundColor: textBackgroundColor,
|
|
582
|
+
padding: textPadding,
|
|
583
|
+
borderRadius: 4,
|
|
584
|
+
left: moveText + centerPosition - 20,
|
|
585
|
+
// Approximate center
|
|
586
|
+
top: centerPosition - 10
|
|
587
|
+
// Approximate center
|
|
588
|
+
}
|
|
589
|
+
},
|
|
590
|
+
/* @__PURE__ */ React8.createElement(
|
|
591
|
+
Text5,
|
|
592
|
+
{
|
|
593
|
+
style: {
|
|
594
|
+
color: textColor,
|
|
595
|
+
fontSize,
|
|
596
|
+
fontFamily,
|
|
597
|
+
fontWeight: textBold ? "bold" : "normal"
|
|
598
|
+
}
|
|
599
|
+
},
|
|
600
|
+
logoText
|
|
601
|
+
)
|
|
602
|
+
));
|
|
564
603
|
};
|
|
565
604
|
var QR_default = QR;
|
|
566
605
|
|
|
567
606
|
// src/components/core/Lista.tsx
|
|
568
607
|
import React9 from "react";
|
|
569
|
-
import { View as View6, Text as
|
|
570
|
-
var
|
|
608
|
+
import { View as View6, Text as Text6, StyleSheet as StyleSheet8 } from "@react-pdf/renderer";
|
|
609
|
+
var styles8 = StyleSheet8.create({
|
|
571
610
|
ul: {
|
|
572
611
|
marginBottom: 10,
|
|
573
612
|
paddingLeft: 15
|
|
@@ -637,7 +676,7 @@ var UL = ({ children, style, type = "disc" }) => {
|
|
|
637
676
|
}
|
|
638
677
|
return child;
|
|
639
678
|
});
|
|
640
|
-
return /* @__PURE__ */ React9.createElement(View6, { style: [
|
|
679
|
+
return /* @__PURE__ */ React9.createElement(View6, { style: [styles8.ul, style] }, childrenWithBullets);
|
|
641
680
|
};
|
|
642
681
|
var OL = ({ children, style, type = "decimal", start = 1 }) => {
|
|
643
682
|
const childrenWithNumbers = React9.Children.map(children, (child, index) => {
|
|
@@ -651,7 +690,7 @@ var OL = ({ children, style, type = "decimal", start = 1 }) => {
|
|
|
651
690
|
}
|
|
652
691
|
return child;
|
|
653
692
|
});
|
|
654
|
-
return /* @__PURE__ */ React9.createElement(View6, { style: [
|
|
693
|
+
return /* @__PURE__ */ React9.createElement(View6, { style: [styles8.ol, style] }, childrenWithNumbers);
|
|
655
694
|
};
|
|
656
695
|
var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1, start = 1, value }) => {
|
|
657
696
|
let marker;
|
|
@@ -661,11 +700,11 @@ var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1,
|
|
|
661
700
|
} else {
|
|
662
701
|
marker = getBulletPoint(bulletType);
|
|
663
702
|
}
|
|
664
|
-
return /* @__PURE__ */ React9.createElement(View6, { style: [
|
|
703
|
+
return /* @__PURE__ */ React9.createElement(View6, { style: [styles8.li, style] }, /* @__PURE__ */ React9.createElement(Text6, { style: styles8.bulletPoint }, marker), /* @__PURE__ */ React9.createElement(View6, { style: styles8.itemContent }, typeof children === "string" ? /* @__PURE__ */ React9.createElement(Text6, null, children) : children));
|
|
665
704
|
};
|
|
666
705
|
|
|
667
706
|
// src/components/core/index.tsx
|
|
668
|
-
import { View as View7, Text as
|
|
707
|
+
import { View as View7, Text as Text7, StyleSheet as StyleSheet9, Font } from "@react-pdf/renderer";
|
|
669
708
|
|
|
670
709
|
// src/functions/decodeBase64Pdf.ts
|
|
671
710
|
var decodeBase64Pdf = (base64, fileName) => {
|
|
@@ -757,11 +796,11 @@ export {
|
|
|
757
796
|
Small,
|
|
758
797
|
Span,
|
|
759
798
|
Strong,
|
|
760
|
-
|
|
799
|
+
StyleSheet9 as StyleSheet,
|
|
761
800
|
Table,
|
|
762
801
|
Tbody,
|
|
763
802
|
Td,
|
|
764
|
-
|
|
803
|
+
Text7 as Text,
|
|
765
804
|
Th,
|
|
766
805
|
Thead,
|
|
767
806
|
Tr,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-pdf-levelup",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.21",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -18,16 +18,18 @@
|
|
|
18
18
|
"publicar": "npm run upVersion && npm run update-jsx && npm run build-lib && npm publish",
|
|
19
19
|
"demo": "ts-node ./src/useExample/index.ts"
|
|
20
20
|
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@react-pdf/renderer": "^4.3.0",
|
|
23
|
+
"react": "^18",
|
|
24
|
+
"react-dom": "^18",
|
|
25
|
+
"qr-code-styling": "^1.9.2"
|
|
26
|
+
},
|
|
21
27
|
"dependencies": {
|
|
22
28
|
"@babel/standalone": "^7.23.10",
|
|
23
29
|
"@monaco-editor/react": "^4.7.0",
|
|
24
|
-
"
|
|
25
|
-
"easyqrcodejs": "^4.6.2",
|
|
30
|
+
"i": "^0.3.7",
|
|
26
31
|
"lucide-react": "^0.485.0",
|
|
27
|
-
"
|
|
28
|
-
"react": "^18.2.0",
|
|
29
|
-
"react-dom": "^18.2.0",
|
|
30
|
-
"react-pdf-levelup": "^2.0.18",
|
|
32
|
+
"npm": "^11.3.0",
|
|
31
33
|
"react-router-dom": "^7.4.1",
|
|
32
34
|
"rimraf": "^6.0.1",
|
|
33
35
|
"ts-node": "^10.9.2"
|
|
@@ -35,7 +37,6 @@
|
|
|
35
37
|
"devDependencies": {
|
|
36
38
|
"@eslint/js": "^9.21.0",
|
|
37
39
|
"@react-pdf/types": "^2.9.0",
|
|
38
|
-
"@types/qrcode": "^1.5.5",
|
|
39
40
|
"@types/react": "^18.2.56",
|
|
40
41
|
"@types/react-dom": "^18.2.19",
|
|
41
42
|
"@vitejs/plugin-react": "^4.3.4",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"eslint-plugin-react-refresh": "^0.4.19",
|
|
45
46
|
"globals": "^15.15.0",
|
|
46
47
|
"json": "^11.0.0",
|
|
48
|
+
"react-pdf-levelup": "^2.0.18",
|
|
47
49
|
"tsup": "^8.4.0",
|
|
48
50
|
"typescript": "~5.7.2",
|
|
49
51
|
"typescript-eslint": "^8.24.1",
|