react-pdf-levelup 2.0.32 → 3.0.34
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 +237 -47
- package/dist/index.cjs +954 -0
- package/dist/{index.d.mts → index.d.cts} +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +237 -252
- package/license +17 -0
- package/package.json +8 -2
- package/dist/index.mjs +0 -792
package/dist/index.js
CHANGED
|
@@ -1,166 +1,172 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/components/core/index.tsx
|
|
31
|
-
var index_exports = {};
|
|
32
|
-
__export(index_exports, {
|
|
33
|
-
A: () => A,
|
|
34
|
-
BR: () => BR,
|
|
35
|
-
Blockquote: () => Blockquote,
|
|
36
|
-
Center: () => Center,
|
|
37
|
-
Col1: () => Col1,
|
|
38
|
-
Col10: () => Col10,
|
|
39
|
-
Col11: () => Col11,
|
|
40
|
-
Col12: () => Col12,
|
|
41
|
-
Col2: () => Col2,
|
|
42
|
-
Col3: () => Col3,
|
|
43
|
-
Col4: () => Col4,
|
|
44
|
-
Col5: () => Col5,
|
|
45
|
-
Col6: () => Col6,
|
|
46
|
-
Col7: () => Col7,
|
|
47
|
-
Col8: () => Col8,
|
|
48
|
-
Col9: () => Col9,
|
|
49
|
-
Container: () => Container,
|
|
50
|
-
Em: () => Em,
|
|
51
|
-
Font: () => import_renderer11.Font,
|
|
52
|
-
Footer: () => Footer,
|
|
53
|
-
H1: () => H1,
|
|
54
|
-
H2: () => H2,
|
|
55
|
-
H3: () => H3,
|
|
56
|
-
H4: () => H4,
|
|
57
|
-
H5: () => H5,
|
|
58
|
-
H6: () => H6,
|
|
59
|
-
Header: () => Header,
|
|
60
|
-
Img: () => Img_default,
|
|
61
|
-
LI: () => LI,
|
|
62
|
-
LayoutPDF: () => LayoutPDF_default,
|
|
63
|
-
Left: () => Left,
|
|
64
|
-
Mark: () => Mark,
|
|
65
|
-
OL: () => OL,
|
|
66
|
-
P: () => P,
|
|
67
|
-
QR: () => QR_default,
|
|
68
|
-
Right: () => Right,
|
|
69
|
-
Row: () => Row,
|
|
70
|
-
Small: () => Small,
|
|
71
|
-
Span: () => Span,
|
|
72
|
-
Strong: () => Strong,
|
|
73
|
-
StyleSheet: () => import_renderer11.StyleSheet,
|
|
74
|
-
Table: () => Table,
|
|
75
|
-
Tbody: () => Tbody,
|
|
76
|
-
Td: () => Td,
|
|
77
|
-
Text: () => import_renderer11.Text,
|
|
78
|
-
Th: () => Th,
|
|
79
|
-
Thead: () => Thead,
|
|
80
|
-
Tr: () => Tr,
|
|
81
|
-
U: () => U,
|
|
82
|
-
UL: () => UL,
|
|
83
|
-
View: () => import_renderer11.View,
|
|
84
|
-
decodeBase64Pdf: () => decodeBase64Pdf_default,
|
|
85
|
-
generatePDF: () => generatePDF_default
|
|
86
|
-
});
|
|
87
|
-
module.exports = __toCommonJS(index_exports);
|
|
88
|
-
|
|
89
1
|
// src/components/core/LayoutPDF.tsx
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
var styles =
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Page, Document, StyleSheet, Text, View } from "@react-pdf/renderer";
|
|
4
|
+
var styles = StyleSheet.create({
|
|
93
5
|
page: {
|
|
94
6
|
backgroundColor: "white",
|
|
95
7
|
padding: 30,
|
|
96
8
|
fontFamily: "Helvetica",
|
|
97
|
-
fontSize:
|
|
98
|
-
lineHeight: 1.5
|
|
9
|
+
fontSize: 14
|
|
99
10
|
},
|
|
100
|
-
|
|
11
|
+
footer: {
|
|
101
12
|
position: "absolute",
|
|
102
|
-
fontSize: 10,
|
|
103
|
-
top: 792 - 14,
|
|
104
13
|
left: 0,
|
|
105
14
|
right: 0,
|
|
106
|
-
textAlign: "center"
|
|
107
|
-
color: "grey"
|
|
15
|
+
textAlign: "center"
|
|
108
16
|
}
|
|
109
17
|
});
|
|
110
18
|
var LayoutPDF = ({
|
|
111
19
|
children,
|
|
112
20
|
size = "A4",
|
|
113
|
-
orientation = "
|
|
21
|
+
orientation = "vertical",
|
|
114
22
|
backgroundColor = "white",
|
|
115
|
-
showPageNumbers = true,
|
|
116
23
|
padding = 30,
|
|
117
|
-
|
|
24
|
+
margen = "normal",
|
|
25
|
+
style = {},
|
|
26
|
+
footer,
|
|
27
|
+
lines = footer ? 2 : 1
|
|
118
28
|
}) => {
|
|
29
|
+
const LINE_HEIGHT = 20;
|
|
30
|
+
const FOOTER_PADDING = 10;
|
|
31
|
+
const footerHeight = lines * LINE_HEIGHT + FOOTER_PADDING;
|
|
32
|
+
const getMargins = (margen2, pageSize) => {
|
|
33
|
+
const normalizedSize = pageSize.toUpperCase();
|
|
34
|
+
switch (margen2) {
|
|
35
|
+
case "apa":
|
|
36
|
+
if (normalizedSize === "LETTER" || normalizedSize === "LEGAL") {
|
|
37
|
+
return {
|
|
38
|
+
paddingTop: 72,
|
|
39
|
+
paddingRight: 72,
|
|
40
|
+
paddingBottom: 72,
|
|
41
|
+
paddingLeft: 72
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
paddingTop: 72,
|
|
46
|
+
paddingRight: 72,
|
|
47
|
+
paddingBottom: 72,
|
|
48
|
+
paddingLeft: 72
|
|
49
|
+
};
|
|
50
|
+
case "estrecho":
|
|
51
|
+
return {
|
|
52
|
+
paddingTop: 36,
|
|
53
|
+
paddingRight: 36,
|
|
54
|
+
paddingBottom: 36,
|
|
55
|
+
paddingLeft: 36
|
|
56
|
+
};
|
|
57
|
+
case "ancho":
|
|
58
|
+
return {
|
|
59
|
+
paddingTop: 108,
|
|
60
|
+
paddingRight: 108,
|
|
61
|
+
paddingBottom: 108,
|
|
62
|
+
paddingLeft: 108
|
|
63
|
+
};
|
|
64
|
+
case "normal":
|
|
65
|
+
default:
|
|
66
|
+
return {
|
|
67
|
+
paddingTop: padding,
|
|
68
|
+
paddingRight: padding,
|
|
69
|
+
paddingBottom: padding,
|
|
70
|
+
paddingLeft: padding
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
119
74
|
let safeSize = size;
|
|
120
75
|
let safeOrientation = orientation;
|
|
121
76
|
let safeBackgroundColor = backgroundColor;
|
|
122
|
-
let
|
|
77
|
+
let safeLines = Math.max(1, Math.min(lines, 10));
|
|
78
|
+
let safeMargen = margen;
|
|
123
79
|
try {
|
|
124
|
-
const validSizes = ["
|
|
80
|
+
const validSizes = ["A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "LETTER", "LEGAL", "TABLOID"];
|
|
125
81
|
if (typeof size === "string" && !validSizes.includes(size.toUpperCase())) {
|
|
126
|
-
console.warn(`
|
|
82
|
+
console.warn(`Invalid page size: ${size}. Using A4 as default.`);
|
|
127
83
|
safeSize = "A4";
|
|
128
84
|
}
|
|
129
|
-
if (orientation !== "
|
|
130
|
-
console.warn(`
|
|
131
|
-
safeOrientation = "
|
|
85
|
+
if (orientation !== "vertical" && orientation !== "horizontal") {
|
|
86
|
+
console.warn(`Invalid orientation: ${orientation}. Using vertical as default.`);
|
|
87
|
+
safeOrientation = "vertical";
|
|
132
88
|
}
|
|
133
89
|
if (typeof backgroundColor !== "string") {
|
|
134
|
-
console.warn(`
|
|
90
|
+
console.warn(`Invalid background color: ${backgroundColor}. Using white as default.`);
|
|
135
91
|
safeBackgroundColor = "white";
|
|
136
92
|
}
|
|
137
|
-
|
|
138
|
-
|
|
93
|
+
const validMargins = ["apa", "normal", "estrecho", "ancho"];
|
|
94
|
+
if (!validMargins.includes(margen)) {
|
|
95
|
+
console.warn(`Invalid margin type: ${margen}. Using normal as default.`);
|
|
96
|
+
safeMargen = "normal";
|
|
97
|
+
}
|
|
98
|
+
if (typeof lines !== "number" || lines < 1) {
|
|
99
|
+
console.warn(`Invalid lines value: ${lines}. Using 1 as default.`);
|
|
100
|
+
safeLines = 1;
|
|
139
101
|
}
|
|
140
102
|
} catch (e) {
|
|
141
|
-
console.warn("Error
|
|
103
|
+
console.warn("Error processing props in LayoutPDF:", e);
|
|
142
104
|
}
|
|
105
|
+
const transformOrientation = (orientation2) => {
|
|
106
|
+
switch (orientation2) {
|
|
107
|
+
case "vertical":
|
|
108
|
+
return "portrait";
|
|
109
|
+
case "horizontal":
|
|
110
|
+
return "landscape";
|
|
111
|
+
default:
|
|
112
|
+
console.warn(`Unrecognized orientation: ${orientation2}. Using portrait as default.`);
|
|
113
|
+
return "portrait";
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const getFooterPosition = (pageSize, orientation2, footerHeight2) => {
|
|
117
|
+
const pageDimensions = {
|
|
118
|
+
A0: { width: 841, height: 1189 },
|
|
119
|
+
A1: { width: 594, height: 841 },
|
|
120
|
+
A2: { width: 420, height: 594 },
|
|
121
|
+
A3: { width: 297, height: 420 },
|
|
122
|
+
A4: { width: 210, height: 297 },
|
|
123
|
+
A5: { width: 148, height: 210 },
|
|
124
|
+
A6: { width: 105, height: 148 },
|
|
125
|
+
A7: { width: 74, height: 105 },
|
|
126
|
+
A8: { width: 52, height: 74 },
|
|
127
|
+
A9: { width: 37, height: 52 },
|
|
128
|
+
LETTER: { width: 216, height: 279 },
|
|
129
|
+
LEGAL: { width: 216, height: 356 },
|
|
130
|
+
TABLOID: { width: 279, height: 432 }
|
|
131
|
+
};
|
|
132
|
+
const mmToPoints = 2.834645669;
|
|
133
|
+
const dimensions = pageDimensions[pageSize.toUpperCase()];
|
|
134
|
+
if (!dimensions) {
|
|
135
|
+
return orientation2 === "landscape" ? 595 - footerHeight2 - 10 : 842 - footerHeight2 - 10;
|
|
136
|
+
}
|
|
137
|
+
const heightInPoints = dimensions.height * mmToPoints;
|
|
138
|
+
const widthInPoints = dimensions.width * mmToPoints;
|
|
139
|
+
return orientation2 === "landscape" ? widthInPoints - footerHeight2 - 10 : heightInPoints - footerHeight2 - 10;
|
|
140
|
+
};
|
|
141
|
+
const pdfOrientation = transformOrientation(safeOrientation);
|
|
142
|
+
const margins = getMargins(safeMargen, safeSize);
|
|
143
|
+
const footerTop = getFooterPosition(safeSize, pdfOrientation, footerHeight);
|
|
143
144
|
const pageStyle = {
|
|
144
145
|
...styles.page,
|
|
145
146
|
backgroundColor: safeBackgroundColor,
|
|
146
|
-
|
|
147
|
+
...margins,
|
|
148
|
+
paddingBottom: margins.paddingBottom + footerHeight,
|
|
147
149
|
...style
|
|
148
150
|
};
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
const footerStyle = {
|
|
152
|
+
...styles.footer,
|
|
153
|
+
top: footerTop,
|
|
154
|
+
height: footerHeight,
|
|
155
|
+
display: "flex",
|
|
156
|
+
flexDirection: "column",
|
|
157
|
+
justifyContent: "center",
|
|
158
|
+
alignItems: "center",
|
|
159
|
+
fontSize: 10,
|
|
160
|
+
color: "grey"
|
|
161
|
+
};
|
|
162
|
+
return /* @__PURE__ */ React.createElement(Document, null, /* @__PURE__ */ React.createElement(Page, { size: safeSize, orientation: pdfOrientation, style: pageStyle, wrap: true }, /* @__PURE__ */ React.createElement(View, { style: { paddingBottom: footerHeight } }, children), /* @__PURE__ */ React.createElement(View, { style: footerStyle, fixed: true }, footer, /* @__PURE__ */ React.createElement(Text, { style: { fontSize: footerStyle.fontSize }, render: ({ pageNumber, totalPages }) => `${pageNumber} / ${totalPages}` }))));
|
|
157
163
|
};
|
|
158
164
|
var LayoutPDF_default = LayoutPDF;
|
|
159
165
|
|
|
160
166
|
// src/components/core/Img.tsx
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
var styles2 =
|
|
167
|
+
import React2 from "react";
|
|
168
|
+
import { Image as Image2, StyleSheet as StyleSheet2 } from "@react-pdf/renderer";
|
|
169
|
+
var styles2 = StyleSheet2.create({
|
|
164
170
|
image: {
|
|
165
171
|
width: "100%",
|
|
166
172
|
height: "auto",
|
|
@@ -168,14 +174,14 @@ var styles2 = import_renderer2.StyleSheet.create({
|
|
|
168
174
|
}
|
|
169
175
|
});
|
|
170
176
|
var Img = ({ src, style }) => {
|
|
171
|
-
return /* @__PURE__ */
|
|
177
|
+
return /* @__PURE__ */ React2.createElement(Image2, { src, style: [styles2.image, style] });
|
|
172
178
|
};
|
|
173
179
|
var Img_default = Img;
|
|
174
180
|
|
|
175
181
|
// src/components/core/Position.tsx
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
var styles3 =
|
|
182
|
+
import React3 from "react";
|
|
183
|
+
import { View as View2, StyleSheet as StyleSheet3 } from "@react-pdf/renderer";
|
|
184
|
+
var styles3 = StyleSheet3.create({
|
|
179
185
|
left: {
|
|
180
186
|
textAlign: "left"
|
|
181
187
|
},
|
|
@@ -187,23 +193,23 @@ var styles3 = import_renderer3.StyleSheet.create({
|
|
|
187
193
|
}
|
|
188
194
|
});
|
|
189
195
|
var Left = ({ children, style }) => {
|
|
190
|
-
return /* @__PURE__ */
|
|
196
|
+
return /* @__PURE__ */ React3.createElement(View2, { style: [styles3.left, style] }, children);
|
|
191
197
|
};
|
|
192
198
|
var Right = ({ children, style }) => {
|
|
193
|
-
return /* @__PURE__ */
|
|
199
|
+
return /* @__PURE__ */ React3.createElement(View2, { style: [styles3.right, style] }, children);
|
|
194
200
|
};
|
|
195
201
|
var Center = ({ children, style }) => {
|
|
196
|
-
return /* @__PURE__ */
|
|
202
|
+
return /* @__PURE__ */ React3.createElement(View2, { style: [styles3.center, style] }, children);
|
|
197
203
|
};
|
|
198
204
|
|
|
199
205
|
// src/components/core/Etiquetas.tsx
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
var styles4 =
|
|
206
|
+
import React4 from "react";
|
|
207
|
+
import { Text as Text2, StyleSheet as StyleSheet4, Link, View as View3 } from "@react-pdf/renderer";
|
|
208
|
+
var styles4 = StyleSheet4.create({
|
|
203
209
|
p: {
|
|
204
210
|
fontSize: 12,
|
|
205
|
-
marginBottom:
|
|
206
|
-
lineHeight: 1.
|
|
211
|
+
marginBottom: 5,
|
|
212
|
+
lineHeight: 1.2
|
|
207
213
|
},
|
|
208
214
|
h1: {
|
|
209
215
|
fontSize: 24,
|
|
@@ -266,61 +272,74 @@ var styles4 = import_renderer4.StyleSheet.create({
|
|
|
266
272
|
height: 1,
|
|
267
273
|
marginTop: 7,
|
|
268
274
|
marginBottom: 7
|
|
275
|
+
},
|
|
276
|
+
header: {
|
|
277
|
+
position: "absolute",
|
|
278
|
+
top: 20,
|
|
279
|
+
left: 0,
|
|
280
|
+
right: 0,
|
|
281
|
+
textAlign: "center",
|
|
282
|
+
fontSize: 10,
|
|
283
|
+
color: "#666",
|
|
284
|
+
paddingHorizontal: 40
|
|
269
285
|
}
|
|
270
286
|
});
|
|
271
287
|
var P = ({ children, style }) => {
|
|
272
|
-
return /* @__PURE__ */
|
|
288
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.p, style] }, children);
|
|
273
289
|
};
|
|
274
290
|
var H1 = ({ children, style }) => {
|
|
275
|
-
return /* @__PURE__ */
|
|
291
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h1, style] }, children);
|
|
276
292
|
};
|
|
277
293
|
var H2 = ({ children, style }) => {
|
|
278
|
-
return /* @__PURE__ */
|
|
294
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h2, style] }, children);
|
|
279
295
|
};
|
|
280
296
|
var H3 = ({ children, style }) => {
|
|
281
|
-
return /* @__PURE__ */
|
|
297
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h3, style] }, children);
|
|
282
298
|
};
|
|
283
299
|
var H4 = ({ children, style }) => {
|
|
284
|
-
return /* @__PURE__ */
|
|
300
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h4, style] }, children);
|
|
285
301
|
};
|
|
286
302
|
var H5 = ({ children, style }) => {
|
|
287
|
-
return /* @__PURE__ */
|
|
303
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h5, style] }, children);
|
|
288
304
|
};
|
|
289
305
|
var H6 = ({ children, style }) => {
|
|
290
|
-
return /* @__PURE__ */
|
|
306
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h6, style] }, children);
|
|
291
307
|
};
|
|
292
308
|
var Strong = ({ children, style }) => {
|
|
293
|
-
return /* @__PURE__ */
|
|
309
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.strong, style] }, children);
|
|
294
310
|
};
|
|
295
311
|
var Em = ({ children, style }) => {
|
|
296
|
-
return /* @__PURE__ */
|
|
312
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.em, style] }, children);
|
|
297
313
|
};
|
|
298
314
|
var U = ({ children, style }) => {
|
|
299
|
-
return /* @__PURE__ */
|
|
315
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.u, style] }, children);
|
|
300
316
|
};
|
|
301
317
|
var Small = ({ children, style }) => {
|
|
302
|
-
return /* @__PURE__ */
|
|
318
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.small, style] }, children);
|
|
303
319
|
};
|
|
304
320
|
var Blockquote = ({ children, style }) => {
|
|
305
|
-
return /* @__PURE__ */
|
|
321
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.blockquote, style] }, children);
|
|
306
322
|
};
|
|
307
323
|
var Mark = ({ children, style }) => {
|
|
308
|
-
return /* @__PURE__ */
|
|
324
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.mark, style] }, children);
|
|
309
325
|
};
|
|
310
326
|
var A = ({ children, style, href }) => {
|
|
311
|
-
return /* @__PURE__ */
|
|
327
|
+
return /* @__PURE__ */ React4.createElement(Link, { src: href, style: [styles4.A, style] }, children);
|
|
312
328
|
};
|
|
313
329
|
var BR = ({ style }) => {
|
|
314
|
-
return /* @__PURE__ */
|
|
330
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.br, style] }, "\n");
|
|
315
331
|
};
|
|
316
332
|
var Span = ({ children, style }) => {
|
|
317
|
-
return /* @__PURE__ */
|
|
333
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [style] }, children);
|
|
334
|
+
};
|
|
335
|
+
var Header = ({ children, style, fixed = false }) => {
|
|
336
|
+
return /* @__PURE__ */ React4.createElement(View3, { style: [styles4.header, style], fixed }, typeof children === "string" ? /* @__PURE__ */ React4.createElement(Text2, null, children) : children);
|
|
318
337
|
};
|
|
319
338
|
|
|
320
339
|
// src/components/core/Tablet.tsx
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
var styles5 =
|
|
340
|
+
import React5 from "react";
|
|
341
|
+
import { View as View4, Text as Text3, StyleSheet as StyleSheet5 } from "@react-pdf/renderer";
|
|
342
|
+
var styles5 = StyleSheet5.create({
|
|
324
343
|
table: {
|
|
325
344
|
width: "100%",
|
|
326
345
|
borderWidth: 1,
|
|
@@ -351,13 +370,13 @@ var styles5 = import_renderer5.StyleSheet.create({
|
|
|
351
370
|
backgroundColor: "#eeeeee"
|
|
352
371
|
}
|
|
353
372
|
});
|
|
354
|
-
var Table = ({ children, style }) => /* @__PURE__ */
|
|
355
|
-
var Thead = ({ children, style }) => /* @__PURE__ */
|
|
373
|
+
var Table = ({ children, style }) => /* @__PURE__ */ React5.createElement(View4, { style: [styles5.table, style] }, children);
|
|
374
|
+
var Thead = ({ children, style }) => /* @__PURE__ */ React5.createElement(View4, { style: [styles5.thead, style] }, children);
|
|
356
375
|
var Tbody = ({ children, style }) => {
|
|
357
|
-
const rows =
|
|
376
|
+
const rows = React5.Children.toArray(children);
|
|
358
377
|
const count = rows.length;
|
|
359
|
-
return /* @__PURE__ */
|
|
360
|
-
(row, idx) =>
|
|
378
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, rows.map(
|
|
379
|
+
(row, idx) => React5.cloneElement(row, {
|
|
361
380
|
isLastRow: idx === count - 1,
|
|
362
381
|
isOdd: idx % 2 === 1
|
|
363
382
|
})
|
|
@@ -369,12 +388,12 @@ var Tr = ({
|
|
|
369
388
|
isLastRow = false,
|
|
370
389
|
isOdd = false
|
|
371
390
|
}) => {
|
|
372
|
-
const elements =
|
|
391
|
+
const elements = React5.Children.toArray(children);
|
|
373
392
|
const count = elements.length;
|
|
374
|
-
return /* @__PURE__ */
|
|
393
|
+
return /* @__PURE__ */ React5.createElement(View4, { style: [styles5.tr, style] }, elements.map((child, idx) => {
|
|
375
394
|
const isLast = idx === count - 1;
|
|
376
395
|
const width = `${(100 / count).toFixed(2)}%`;
|
|
377
|
-
return
|
|
396
|
+
return React5.cloneElement(child, { width, isLast, isLastRow, isOdd });
|
|
378
397
|
}));
|
|
379
398
|
};
|
|
380
399
|
var Th = ({
|
|
@@ -393,7 +412,7 @@ var Th = ({
|
|
|
393
412
|
borderColor: "#000",
|
|
394
413
|
...height !== void 0 && { height }
|
|
395
414
|
};
|
|
396
|
-
return /* @__PURE__ */
|
|
415
|
+
return /* @__PURE__ */ React5.createElement(View4, { style: [styles5.textBold, { width: baseWidth }, borders, style] }, /* @__PURE__ */ React5.createElement(Text3, null, children));
|
|
397
416
|
};
|
|
398
417
|
var Td = ({
|
|
399
418
|
children,
|
|
@@ -412,19 +431,19 @@ var Td = ({
|
|
|
412
431
|
borderColor: "#000",
|
|
413
432
|
...height !== void 0 && { height }
|
|
414
433
|
};
|
|
415
|
-
return /* @__PURE__ */
|
|
434
|
+
return /* @__PURE__ */ React5.createElement(View4, { style: [
|
|
416
435
|
styles5.text,
|
|
417
436
|
isOdd && styles5.zebraOdd,
|
|
418
437
|
{ width: baseWidth },
|
|
419
438
|
borders,
|
|
420
439
|
style
|
|
421
|
-
] }, /* @__PURE__ */
|
|
440
|
+
] }, /* @__PURE__ */ React5.createElement(Text3, null, children));
|
|
422
441
|
};
|
|
423
442
|
|
|
424
443
|
// src/components/core/Grid.tsx
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
var styles6 =
|
|
444
|
+
import React6 from "react";
|
|
445
|
+
import { View as View5, StyleSheet as StyleSheet6 } from "@react-pdf/renderer";
|
|
446
|
+
var styles6 = StyleSheet6.create({
|
|
428
447
|
container: {
|
|
429
448
|
width: "100%",
|
|
430
449
|
paddingHorizontal: 20
|
|
@@ -451,87 +470,55 @@ var styles6 = import_renderer6.StyleSheet.create({
|
|
|
451
470
|
col12: { width: "100%" }
|
|
452
471
|
});
|
|
453
472
|
var Container = ({ children, style }) => {
|
|
454
|
-
return /* @__PURE__ */
|
|
473
|
+
return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.container, style] }, children);
|
|
455
474
|
};
|
|
456
475
|
var Row = ({ children, style }) => {
|
|
457
|
-
return /* @__PURE__ */
|
|
476
|
+
return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.row, style] }, children);
|
|
458
477
|
};
|
|
459
478
|
var Col1 = ({ children, style }) => {
|
|
460
|
-
return /* @__PURE__ */
|
|
479
|
+
return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col1, style] }, children);
|
|
461
480
|
};
|
|
462
481
|
var Col2 = ({ children, style }) => {
|
|
463
|
-
return /* @__PURE__ */
|
|
482
|
+
return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col2, style] }, children);
|
|
464
483
|
};
|
|
465
484
|
var Col3 = ({ children, style }) => {
|
|
466
|
-
return /* @__PURE__ */
|
|
485
|
+
return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col3, style] }, children);
|
|
467
486
|
};
|
|
468
487
|
var Col4 = ({ children, style }) => {
|
|
469
|
-
return /* @__PURE__ */
|
|
488
|
+
return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col4, style] }, children);
|
|
470
489
|
};
|
|
471
490
|
var Col5 = ({ children, style }) => {
|
|
472
|
-
return /* @__PURE__ */
|
|
491
|
+
return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col5, style] }, children);
|
|
473
492
|
};
|
|
474
493
|
var Col6 = ({ children, style }) => {
|
|
475
|
-
return /* @__PURE__ */
|
|
494
|
+
return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col6, style] }, children);
|
|
476
495
|
};
|
|
477
496
|
var Col7 = ({ children, style }) => {
|
|
478
|
-
return /* @__PURE__ */
|
|
497
|
+
return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col7, style] }, children);
|
|
479
498
|
};
|
|
480
499
|
var Col8 = ({ children, style }) => {
|
|
481
|
-
return /* @__PURE__ */
|
|
500
|
+
return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col8, style] }, children);
|
|
482
501
|
};
|
|
483
502
|
var Col9 = ({ children, style }) => {
|
|
484
|
-
return /* @__PURE__ */
|
|
503
|
+
return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col9, style] }, children);
|
|
485
504
|
};
|
|
486
505
|
var Col10 = ({ children, style }) => {
|
|
487
|
-
return /* @__PURE__ */
|
|
506
|
+
return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col10, style] }, children);
|
|
488
507
|
};
|
|
489
508
|
var Col11 = ({ children, style }) => {
|
|
490
|
-
return /* @__PURE__ */
|
|
509
|
+
return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col11, style] }, children);
|
|
491
510
|
};
|
|
492
511
|
var Col12 = ({ children, style }) => {
|
|
493
|
-
return /* @__PURE__ */
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
// src/components/core/PageElements.tsx
|
|
497
|
-
var import_react7 = __toESM(require("react"));
|
|
498
|
-
var import_renderer7 = require("@react-pdf/renderer");
|
|
499
|
-
var styles7 = import_renderer7.StyleSheet.create({
|
|
500
|
-
header: {
|
|
501
|
-
position: "absolute",
|
|
502
|
-
top: 20,
|
|
503
|
-
left: 0,
|
|
504
|
-
right: 0,
|
|
505
|
-
textAlign: "center",
|
|
506
|
-
fontSize: 10,
|
|
507
|
-
color: "#666",
|
|
508
|
-
paddingHorizontal: 40
|
|
509
|
-
},
|
|
510
|
-
footer: {
|
|
511
|
-
position: "absolute",
|
|
512
|
-
bottom: 20,
|
|
513
|
-
left: 0,
|
|
514
|
-
right: 0,
|
|
515
|
-
textAlign: "center",
|
|
516
|
-
fontSize: 10,
|
|
517
|
-
color: "#666",
|
|
518
|
-
paddingHorizontal: 40
|
|
519
|
-
}
|
|
520
|
-
});
|
|
521
|
-
var Header = ({ children, style, fixed = false }) => {
|
|
522
|
-
return /* @__PURE__ */ import_react7.default.createElement(import_renderer7.View, { style: [styles7.header, style], fixed }, typeof children === "string" ? /* @__PURE__ */ import_react7.default.createElement(import_renderer7.Text, null, children) : children);
|
|
523
|
-
};
|
|
524
|
-
var Footer = ({ children, style, fixed = false }) => {
|
|
525
|
-
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);
|
|
512
|
+
return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col12, style] }, children);
|
|
526
513
|
};
|
|
527
514
|
|
|
528
515
|
// src/components/core/QR.tsx
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
516
|
+
import React7 from "react";
|
|
517
|
+
import { Image as Image3, StyleSheet as StyleSheet7, View as View6 } from "@react-pdf/renderer";
|
|
518
|
+
import { useEffect, useState } from "react";
|
|
532
519
|
|
|
533
520
|
// src/components/core/QRGenerator.tsx
|
|
534
|
-
|
|
521
|
+
import QRCode from "qrcode";
|
|
535
522
|
var generateQRAsBase64 = async ({
|
|
536
523
|
value,
|
|
537
524
|
size = 150,
|
|
@@ -552,7 +539,7 @@ var generateQRAsBase64 = async ({
|
|
|
552
539
|
},
|
|
553
540
|
width: size
|
|
554
541
|
};
|
|
555
|
-
const qrDataUrl =
|
|
542
|
+
const qrDataUrl = QRCode.toDataURL(value, options);
|
|
556
543
|
return qrDataUrl;
|
|
557
544
|
} catch (error) {
|
|
558
545
|
console.error("Error generando QR:", error);
|
|
@@ -608,7 +595,7 @@ var addLogoToQR = async (qrDataUrl, logoUrl, logoWidth, logoHeight) => {
|
|
|
608
595
|
};
|
|
609
596
|
|
|
610
597
|
// src/components/core/QR.tsx
|
|
611
|
-
var
|
|
598
|
+
var styles7 = StyleSheet7.create({
|
|
612
599
|
qrContainer: {
|
|
613
600
|
display: "flex",
|
|
614
601
|
alignItems: "center",
|
|
@@ -634,8 +621,8 @@ var QR = ({
|
|
|
634
621
|
logoHeight = 30,
|
|
635
622
|
errorCorrectionLevel = "M"
|
|
636
623
|
}) => {
|
|
637
|
-
const [qrDataUrl, setQrDataUrl] =
|
|
638
|
-
|
|
624
|
+
const [qrDataUrl, setQrDataUrl] = useState("");
|
|
625
|
+
useEffect(() => {
|
|
639
626
|
const generateQR = async () => {
|
|
640
627
|
try {
|
|
641
628
|
const baseQrDataUrl = await generateQRAsBase64({
|
|
@@ -667,14 +654,14 @@ var QR = ({
|
|
|
667
654
|
const fallbackUrl = `https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(
|
|
668
655
|
value
|
|
669
656
|
)}&size=${size}x${size}`;
|
|
670
|
-
return /* @__PURE__ */
|
|
657
|
+
return /* @__PURE__ */ React7.createElement(View6, { style: [styles7.qrContainer, style] }, /* @__PURE__ */ React7.createElement(Image3, { src: qrDataUrl || fallbackUrl, style: { width: size, height: size } }));
|
|
671
658
|
};
|
|
672
659
|
var QR_default = QR;
|
|
673
660
|
|
|
674
661
|
// src/components/core/Lista.tsx
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
var
|
|
662
|
+
import React8 from "react";
|
|
663
|
+
import { View as View7, Text as Text4, StyleSheet as StyleSheet8 } from "@react-pdf/renderer";
|
|
664
|
+
var styles8 = StyleSheet8.create({
|
|
678
665
|
ul: {
|
|
679
666
|
marginBottom: 10,
|
|
680
667
|
paddingLeft: 15
|
|
@@ -734,9 +721,9 @@ var toRoman = (num) => {
|
|
|
734
721
|
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];
|
|
735
722
|
};
|
|
736
723
|
var UL = ({ children, style, type = "disc" }) => {
|
|
737
|
-
const childrenWithBullets =
|
|
738
|
-
if (
|
|
739
|
-
return
|
|
724
|
+
const childrenWithBullets = React8.Children.map(children, (child, index) => {
|
|
725
|
+
if (React8.isValidElement(child)) {
|
|
726
|
+
return React8.cloneElement(child, {
|
|
740
727
|
bulletType: type,
|
|
741
728
|
isOrdered: false,
|
|
742
729
|
index: index + 1
|
|
@@ -744,12 +731,12 @@ var UL = ({ children, style, type = "disc" }) => {
|
|
|
744
731
|
}
|
|
745
732
|
return child;
|
|
746
733
|
});
|
|
747
|
-
return /* @__PURE__ */
|
|
734
|
+
return /* @__PURE__ */ React8.createElement(View7, { style: [styles8.ul, style] }, childrenWithBullets);
|
|
748
735
|
};
|
|
749
736
|
var OL = ({ children, style, type = "decimal", start = 1 }) => {
|
|
750
|
-
const childrenWithNumbers =
|
|
751
|
-
if (
|
|
752
|
-
return
|
|
737
|
+
const childrenWithNumbers = React8.Children.map(children, (child, index) => {
|
|
738
|
+
if (React8.isValidElement(child)) {
|
|
739
|
+
return React8.cloneElement(child, {
|
|
753
740
|
bulletType: type,
|
|
754
741
|
isOrdered: true,
|
|
755
742
|
index: index + 1,
|
|
@@ -758,7 +745,7 @@ var OL = ({ children, style, type = "decimal", start = 1 }) => {
|
|
|
758
745
|
}
|
|
759
746
|
return child;
|
|
760
747
|
});
|
|
761
|
-
return /* @__PURE__ */
|
|
748
|
+
return /* @__PURE__ */ React8.createElement(View7, { style: [styles8.ol, style] }, childrenWithNumbers);
|
|
762
749
|
};
|
|
763
750
|
var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1, start = 1, value }) => {
|
|
764
751
|
let marker;
|
|
@@ -768,11 +755,11 @@ var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1,
|
|
|
768
755
|
} else {
|
|
769
756
|
marker = getBulletPoint(bulletType);
|
|
770
757
|
}
|
|
771
|
-
return /* @__PURE__ */
|
|
758
|
+
return /* @__PURE__ */ React8.createElement(View7, { style: [styles8.li, style] }, /* @__PURE__ */ React8.createElement(Text4, { style: styles8.bulletPoint }, marker), /* @__PURE__ */ React8.createElement(View7, { style: styles8.itemContent }, typeof children === "string" ? /* @__PURE__ */ React8.createElement(Text4, null, children) : children));
|
|
772
759
|
};
|
|
773
760
|
|
|
774
761
|
// src/components/core/index.tsx
|
|
775
|
-
|
|
762
|
+
import { View as View8, Text as Text5, StyleSheet as StyleSheet9, Font } from "@react-pdf/renderer";
|
|
776
763
|
|
|
777
764
|
// src/functions/decodeBase64Pdf.ts
|
|
778
765
|
var decodeBase64Pdf = (base64, fileName) => {
|
|
@@ -802,15 +789,15 @@ var decodeBase64Pdf = (base64, fileName) => {
|
|
|
802
789
|
var decodeBase64Pdf_default = decodeBase64Pdf;
|
|
803
790
|
|
|
804
791
|
// src/functions/generatePDF.ts
|
|
805
|
-
|
|
806
|
-
|
|
792
|
+
import { renderToStream } from "@react-pdf/renderer";
|
|
793
|
+
import { createElement } from "react";
|
|
807
794
|
var generatePDF = async ({ template: Template, data }) => {
|
|
808
795
|
try {
|
|
809
796
|
if (!Template) {
|
|
810
797
|
throw new Error("Template not provided");
|
|
811
798
|
}
|
|
812
|
-
const MyDocument =
|
|
813
|
-
const stream = await
|
|
799
|
+
const MyDocument = createElement(Template, { data });
|
|
800
|
+
const stream = await renderToStream(MyDocument);
|
|
814
801
|
const base64String = await new Promise((resolve, reject) => {
|
|
815
802
|
const chunks = [];
|
|
816
803
|
stream.on("data", (chunk) => chunks.push(chunk));
|
|
@@ -823,8 +810,7 @@ var generatePDF = async ({ template: Template, data }) => {
|
|
|
823
810
|
}
|
|
824
811
|
};
|
|
825
812
|
var generatePDF_default = generatePDF;
|
|
826
|
-
|
|
827
|
-
0 && (module.exports = {
|
|
813
|
+
export {
|
|
828
814
|
A,
|
|
829
815
|
BR,
|
|
830
816
|
Blockquote,
|
|
@@ -844,7 +830,6 @@ var generatePDF_default = generatePDF;
|
|
|
844
830
|
Container,
|
|
845
831
|
Em,
|
|
846
832
|
Font,
|
|
847
|
-
Footer,
|
|
848
833
|
H1,
|
|
849
834
|
H2,
|
|
850
835
|
H3,
|
|
@@ -852,30 +837,30 @@ var generatePDF_default = generatePDF;
|
|
|
852
837
|
H5,
|
|
853
838
|
H6,
|
|
854
839
|
Header,
|
|
855
|
-
Img,
|
|
840
|
+
Img_default as Img,
|
|
856
841
|
LI,
|
|
857
|
-
LayoutPDF,
|
|
842
|
+
LayoutPDF_default as LayoutPDF,
|
|
858
843
|
Left,
|
|
859
844
|
Mark,
|
|
860
845
|
OL,
|
|
861
846
|
P,
|
|
862
|
-
QR,
|
|
847
|
+
QR_default as QR,
|
|
863
848
|
Right,
|
|
864
849
|
Row,
|
|
865
850
|
Small,
|
|
866
851
|
Span,
|
|
867
852
|
Strong,
|
|
868
|
-
StyleSheet,
|
|
853
|
+
StyleSheet9 as StyleSheet,
|
|
869
854
|
Table,
|
|
870
855
|
Tbody,
|
|
871
856
|
Td,
|
|
872
|
-
Text,
|
|
857
|
+
Text5 as Text,
|
|
873
858
|
Th,
|
|
874
859
|
Thead,
|
|
875
860
|
Tr,
|
|
876
861
|
U,
|
|
877
862
|
UL,
|
|
878
|
-
View,
|
|
879
|
-
decodeBase64Pdf,
|
|
880
|
-
generatePDF
|
|
881
|
-
}
|
|
863
|
+
View8 as View,
|
|
864
|
+
decodeBase64Pdf_default as decodeBase64Pdf,
|
|
865
|
+
generatePDF_default as generatePDF
|
|
866
|
+
};
|