react-pdf-levelup 2.0.13 → 2.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +149 -0
- package/dist/index.d.ts +70 -60
- package/dist/index.js +260 -94
- package/dist/{index.cjs → index.mjs} +173 -177
- package/package.json +6 -5
- package/dist/index.d.cts +0 -139
|
@@ -1,89 +1,7 @@
|
|
|
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
|
-
Footer: () => Footer,
|
|
52
|
-
H1: () => H1,
|
|
53
|
-
H2: () => H2,
|
|
54
|
-
H3: () => H3,
|
|
55
|
-
H4: () => H4,
|
|
56
|
-
H5: () => H5,
|
|
57
|
-
H6: () => H6,
|
|
58
|
-
Header: () => Header,
|
|
59
|
-
Img: () => Img_default,
|
|
60
|
-
LI: () => LI,
|
|
61
|
-
LayoutPDF: () => LayoutPDF_default,
|
|
62
|
-
Left: () => Left,
|
|
63
|
-
Mark: () => Mark,
|
|
64
|
-
OL: () => OL,
|
|
65
|
-
P: () => P,
|
|
66
|
-
QR: () => QR_default,
|
|
67
|
-
Right: () => Right,
|
|
68
|
-
Row: () => Row,
|
|
69
|
-
Small: () => Small,
|
|
70
|
-
Span: () => Span,
|
|
71
|
-
Strong: () => Strong,
|
|
72
|
-
Table: () => Table,
|
|
73
|
-
Tbody: () => Tbody,
|
|
74
|
-
Td: () => Td,
|
|
75
|
-
Th: () => Th,
|
|
76
|
-
Thead: () => Thead,
|
|
77
|
-
Tr: () => Tr,
|
|
78
|
-
U: () => U,
|
|
79
|
-
UL: () => UL
|
|
80
|
-
});
|
|
81
|
-
module.exports = __toCommonJS(index_exports);
|
|
82
|
-
|
|
83
1
|
// src/components/core/LayoutPDF.tsx
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var styles =
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Page, Document, StyleSheet, Text } from "@react-pdf/renderer";
|
|
4
|
+
var styles = StyleSheet.create({
|
|
87
5
|
page: {
|
|
88
6
|
backgroundColor: "white",
|
|
89
7
|
padding: 30,
|
|
@@ -94,7 +12,7 @@ var styles = import_renderer.StyleSheet.create({
|
|
|
94
12
|
pageNumber: {
|
|
95
13
|
position: "absolute",
|
|
96
14
|
fontSize: 10,
|
|
97
|
-
|
|
15
|
+
top: 792 - 14,
|
|
98
16
|
left: 0,
|
|
99
17
|
right: 0,
|
|
100
18
|
textAlign: "center",
|
|
@@ -107,15 +25,41 @@ var LayoutPDF = ({
|
|
|
107
25
|
orientation = "portrait",
|
|
108
26
|
backgroundColor = "white",
|
|
109
27
|
showPageNumbers = true,
|
|
28
|
+
padding = 30,
|
|
110
29
|
style = {}
|
|
111
30
|
}) => {
|
|
31
|
+
let safeSize = size;
|
|
32
|
+
let safeOrientation = orientation;
|
|
33
|
+
let safeBackgroundColor = backgroundColor;
|
|
34
|
+
let safeShowPageNumbers = showPageNumbers;
|
|
35
|
+
try {
|
|
36
|
+
const validSizes = ["A4", "A3", "A5", "LETTER", "LEGAL", "TABLOID"];
|
|
37
|
+
if (typeof size === "string" && !validSizes.includes(size.toUpperCase())) {
|
|
38
|
+
console.warn(`Tama\xF1o de p\xE1gina inv\xE1lido: ${size}. Usando A4 como valor predeterminado.`);
|
|
39
|
+
safeSize = "A4";
|
|
40
|
+
}
|
|
41
|
+
if (orientation !== "portrait" && orientation !== "landscape") {
|
|
42
|
+
console.warn(`Orientaci\xF3n inv\xE1lida: ${orientation}. Usando portrait como valor predeterminado.`);
|
|
43
|
+
safeOrientation = "portrait";
|
|
44
|
+
}
|
|
45
|
+
if (typeof backgroundColor !== "string") {
|
|
46
|
+
console.warn(`Color de fondo inv\xE1lido: ${backgroundColor}. Usando white como valor predeterminado.`);
|
|
47
|
+
safeBackgroundColor = "white";
|
|
48
|
+
}
|
|
49
|
+
if (typeof showPageNumbers !== "boolean") {
|
|
50
|
+
safeShowPageNumbers = Boolean(showPageNumbers);
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.warn("Error procesando props en LayoutPDF:", e);
|
|
54
|
+
}
|
|
112
55
|
const pageStyle = {
|
|
113
56
|
...styles.page,
|
|
114
|
-
backgroundColor,
|
|
57
|
+
backgroundColor: safeBackgroundColor,
|
|
58
|
+
padding,
|
|
115
59
|
...style
|
|
116
60
|
};
|
|
117
|
-
return /* @__PURE__ */
|
|
118
|
-
|
|
61
|
+
return /* @__PURE__ */ React.createElement(Document, null, /* @__PURE__ */ React.createElement(Page, { size: safeSize, orientation: safeOrientation, style: pageStyle }, children, safeShowPageNumbers && /* @__PURE__ */ React.createElement(
|
|
62
|
+
Text,
|
|
119
63
|
{
|
|
120
64
|
style: styles.pageNumber,
|
|
121
65
|
render: ({ pageNumber, totalPages }) => `${pageNumber} / ${totalPages}`,
|
|
@@ -126,9 +70,9 @@ var LayoutPDF = ({
|
|
|
126
70
|
var LayoutPDF_default = LayoutPDF;
|
|
127
71
|
|
|
128
72
|
// src/components/core/Img.tsx
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
var styles2 =
|
|
73
|
+
import React2 from "react";
|
|
74
|
+
import { Image as Image2, StyleSheet as StyleSheet2 } from "@react-pdf/renderer";
|
|
75
|
+
var styles2 = StyleSheet2.create({
|
|
132
76
|
image: {
|
|
133
77
|
width: "100%",
|
|
134
78
|
height: "auto",
|
|
@@ -136,14 +80,14 @@ var styles2 = import_renderer2.StyleSheet.create({
|
|
|
136
80
|
}
|
|
137
81
|
});
|
|
138
82
|
var Img = ({ src, style }) => {
|
|
139
|
-
return /* @__PURE__ */
|
|
83
|
+
return /* @__PURE__ */ React2.createElement(Image2, { src, style: [styles2.image, style] });
|
|
140
84
|
};
|
|
141
85
|
var Img_default = Img;
|
|
142
86
|
|
|
143
87
|
// src/components/core/Position.tsx
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
var styles3 =
|
|
88
|
+
import React3 from "react";
|
|
89
|
+
import { View, StyleSheet as StyleSheet3 } from "@react-pdf/renderer";
|
|
90
|
+
var styles3 = StyleSheet3.create({
|
|
147
91
|
left: {
|
|
148
92
|
textAlign: "left"
|
|
149
93
|
},
|
|
@@ -155,19 +99,19 @@ var styles3 = import_renderer3.StyleSheet.create({
|
|
|
155
99
|
}
|
|
156
100
|
});
|
|
157
101
|
var Left = ({ children, style }) => {
|
|
158
|
-
return /* @__PURE__ */
|
|
102
|
+
return /* @__PURE__ */ React3.createElement(View, { style: [styles3.left, style] }, children);
|
|
159
103
|
};
|
|
160
104
|
var Right = ({ children, style }) => {
|
|
161
|
-
return /* @__PURE__ */
|
|
105
|
+
return /* @__PURE__ */ React3.createElement(View, { style: [styles3.right, style] }, children);
|
|
162
106
|
};
|
|
163
107
|
var Center = ({ children, style }) => {
|
|
164
|
-
return /* @__PURE__ */
|
|
108
|
+
return /* @__PURE__ */ React3.createElement(View, { style: [styles3.center, style] }, children);
|
|
165
109
|
};
|
|
166
110
|
|
|
167
111
|
// src/components/core/Etiquetas.tsx
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
var styles4 =
|
|
112
|
+
import React4 from "react";
|
|
113
|
+
import { Text as Text2, StyleSheet as StyleSheet4, Link } from "@react-pdf/renderer";
|
|
114
|
+
var styles4 = StyleSheet4.create({
|
|
171
115
|
p: {
|
|
172
116
|
fontSize: 12,
|
|
173
117
|
marginBottom: 14,
|
|
@@ -237,58 +181,58 @@ var styles4 = import_renderer4.StyleSheet.create({
|
|
|
237
181
|
}
|
|
238
182
|
});
|
|
239
183
|
var P = ({ children, style }) => {
|
|
240
|
-
return /* @__PURE__ */
|
|
184
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.p, style] }, children);
|
|
241
185
|
};
|
|
242
186
|
var H1 = ({ children, style }) => {
|
|
243
|
-
return /* @__PURE__ */
|
|
187
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h1, style] }, children);
|
|
244
188
|
};
|
|
245
189
|
var H2 = ({ children, style }) => {
|
|
246
|
-
return /* @__PURE__ */
|
|
190
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h2, style] }, children);
|
|
247
191
|
};
|
|
248
192
|
var H3 = ({ children, style }) => {
|
|
249
|
-
return /* @__PURE__ */
|
|
193
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h3, style] }, children);
|
|
250
194
|
};
|
|
251
195
|
var H4 = ({ children, style }) => {
|
|
252
|
-
return /* @__PURE__ */
|
|
196
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h4, style] }, children);
|
|
253
197
|
};
|
|
254
198
|
var H5 = ({ children, style }) => {
|
|
255
|
-
return /* @__PURE__ */
|
|
199
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h5, style] }, children);
|
|
256
200
|
};
|
|
257
201
|
var H6 = ({ children, style }) => {
|
|
258
|
-
return /* @__PURE__ */
|
|
202
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h6, style] }, children);
|
|
259
203
|
};
|
|
260
204
|
var Strong = ({ children, style }) => {
|
|
261
|
-
return /* @__PURE__ */
|
|
205
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.strong, style] }, children);
|
|
262
206
|
};
|
|
263
207
|
var Em = ({ children, style }) => {
|
|
264
|
-
return /* @__PURE__ */
|
|
208
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.em, style] }, children);
|
|
265
209
|
};
|
|
266
210
|
var U = ({ children, style }) => {
|
|
267
|
-
return /* @__PURE__ */
|
|
211
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.u, style] }, children);
|
|
268
212
|
};
|
|
269
213
|
var Small = ({ children, style }) => {
|
|
270
|
-
return /* @__PURE__ */
|
|
214
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.small, style] }, children);
|
|
271
215
|
};
|
|
272
216
|
var Blockquote = ({ children, style }) => {
|
|
273
|
-
return /* @__PURE__ */
|
|
217
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.blockquote, style] }, children);
|
|
274
218
|
};
|
|
275
219
|
var Mark = ({ children, style }) => {
|
|
276
|
-
return /* @__PURE__ */
|
|
220
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.mark, style] }, children);
|
|
277
221
|
};
|
|
278
222
|
var A = ({ children, style, href }) => {
|
|
279
|
-
return /* @__PURE__ */
|
|
223
|
+
return /* @__PURE__ */ React4.createElement(Link, { src: href, style: [styles4.A, style] }, children);
|
|
280
224
|
};
|
|
281
225
|
var BR = ({ style }) => {
|
|
282
|
-
return /* @__PURE__ */
|
|
226
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.br, style] }, "\n");
|
|
283
227
|
};
|
|
284
228
|
var Span = ({ children, style }) => {
|
|
285
|
-
return /* @__PURE__ */
|
|
229
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [style] }, children);
|
|
286
230
|
};
|
|
287
231
|
|
|
288
232
|
// src/components/core/Tablet.tsx
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
var styles5 =
|
|
233
|
+
import React5 from "react";
|
|
234
|
+
import { View as View2, Text as Text3, StyleSheet as StyleSheet5 } from "@react-pdf/renderer";
|
|
235
|
+
var styles5 = StyleSheet5.create({
|
|
292
236
|
table: {
|
|
293
237
|
width: "100%",
|
|
294
238
|
borderWidth: 1,
|
|
@@ -339,16 +283,16 @@ var cellSizeMapping = {
|
|
|
339
283
|
large: styles5.cellLarge
|
|
340
284
|
};
|
|
341
285
|
var Table = ({ children, style }) => {
|
|
342
|
-
return /* @__PURE__ */
|
|
286
|
+
return /* @__PURE__ */ React5.createElement(View2, { style: [styles5.table, style] }, children);
|
|
343
287
|
};
|
|
344
288
|
var Thead = ({ children, style }) => {
|
|
345
|
-
return /* @__PURE__ */
|
|
289
|
+
return /* @__PURE__ */ React5.createElement(View2, { style: [styles5.thead, style] }, children);
|
|
346
290
|
};
|
|
347
291
|
var Tbody = ({ children, style }) => {
|
|
348
|
-
return /* @__PURE__ */
|
|
292
|
+
return /* @__PURE__ */ React5.createElement(View2, { style: [styles5.tbody, style] }, children);
|
|
349
293
|
};
|
|
350
294
|
var Tr = ({ children, style }) => {
|
|
351
|
-
return /* @__PURE__ */
|
|
295
|
+
return /* @__PURE__ */ React5.createElement(View2, { style: [styles5.tr, style] }, children);
|
|
352
296
|
};
|
|
353
297
|
var Th = ({ children, style, cellSize = "medium", width, height, colSpan }) => {
|
|
354
298
|
const spanWidth = colSpan ? `${100 / 3 * colSpan}%` : void 0;
|
|
@@ -357,7 +301,7 @@ var Th = ({ children, style, cellSize = "medium", width, height, colSpan }) => {
|
|
|
357
301
|
width: width || spanWidth || sizeStyle?.width,
|
|
358
302
|
...height !== void 0 && { height }
|
|
359
303
|
};
|
|
360
|
-
return /* @__PURE__ */
|
|
304
|
+
return /* @__PURE__ */ React5.createElement(View2, { style: [styles5.th, customStyle, style] }, /* @__PURE__ */ React5.createElement(Text3, null, children));
|
|
361
305
|
};
|
|
362
306
|
var Td = ({ children, style, cellSize = "medium", width, height, colSpan }) => {
|
|
363
307
|
const spanWidth = colSpan ? `${100 / 3 * colSpan}%` : void 0;
|
|
@@ -366,13 +310,13 @@ var Td = ({ children, style, cellSize = "medium", width, height, colSpan }) => {
|
|
|
366
310
|
width: width || spanWidth || sizeStyle?.width,
|
|
367
311
|
...height !== void 0 && { height }
|
|
368
312
|
};
|
|
369
|
-
return /* @__PURE__ */
|
|
313
|
+
return /* @__PURE__ */ React5.createElement(View2, { style: [styles5.td, customStyle, style] }, /* @__PURE__ */ React5.createElement(Text3, null, children));
|
|
370
314
|
};
|
|
371
315
|
|
|
372
316
|
// src/components/core/Grid.tsx
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
var styles6 =
|
|
317
|
+
import React6 from "react";
|
|
318
|
+
import { View as View3, StyleSheet as StyleSheet6 } from "@react-pdf/renderer";
|
|
319
|
+
var styles6 = StyleSheet6.create({
|
|
376
320
|
container: {
|
|
377
321
|
width: "100%",
|
|
378
322
|
paddingHorizontal: 20
|
|
@@ -399,52 +343,52 @@ var styles6 = import_renderer6.StyleSheet.create({
|
|
|
399
343
|
col12: { width: "100%" }
|
|
400
344
|
});
|
|
401
345
|
var Container = ({ children, style }) => {
|
|
402
|
-
return /* @__PURE__ */
|
|
346
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.container, style] }, children);
|
|
403
347
|
};
|
|
404
348
|
var Row = ({ children, style }) => {
|
|
405
|
-
return /* @__PURE__ */
|
|
349
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.row, style] }, children);
|
|
406
350
|
};
|
|
407
351
|
var Col1 = ({ children, style }) => {
|
|
408
|
-
return /* @__PURE__ */
|
|
352
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col1, style] }, children);
|
|
409
353
|
};
|
|
410
354
|
var Col2 = ({ children, style }) => {
|
|
411
|
-
return /* @__PURE__ */
|
|
355
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col2, style] }, children);
|
|
412
356
|
};
|
|
413
357
|
var Col3 = ({ children, style }) => {
|
|
414
|
-
return /* @__PURE__ */
|
|
358
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col3, style] }, children);
|
|
415
359
|
};
|
|
416
360
|
var Col4 = ({ children, style }) => {
|
|
417
|
-
return /* @__PURE__ */
|
|
361
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col4, style] }, children);
|
|
418
362
|
};
|
|
419
363
|
var Col5 = ({ children, style }) => {
|
|
420
|
-
return /* @__PURE__ */
|
|
364
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col5, style] }, children);
|
|
421
365
|
};
|
|
422
366
|
var Col6 = ({ children, style }) => {
|
|
423
|
-
return /* @__PURE__ */
|
|
367
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col6, style] }, children);
|
|
424
368
|
};
|
|
425
369
|
var Col7 = ({ children, style }) => {
|
|
426
|
-
return /* @__PURE__ */
|
|
370
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col7, style] }, children);
|
|
427
371
|
};
|
|
428
372
|
var Col8 = ({ children, style }) => {
|
|
429
|
-
return /* @__PURE__ */
|
|
373
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col8, style] }, children);
|
|
430
374
|
};
|
|
431
375
|
var Col9 = ({ children, style }) => {
|
|
432
|
-
return /* @__PURE__ */
|
|
376
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col9, style] }, children);
|
|
433
377
|
};
|
|
434
378
|
var Col10 = ({ children, style }) => {
|
|
435
|
-
return /* @__PURE__ */
|
|
379
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col10, style] }, children);
|
|
436
380
|
};
|
|
437
381
|
var Col11 = ({ children, style }) => {
|
|
438
|
-
return /* @__PURE__ */
|
|
382
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col11, style] }, children);
|
|
439
383
|
};
|
|
440
384
|
var Col12 = ({ children, style }) => {
|
|
441
|
-
return /* @__PURE__ */
|
|
385
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col12, style] }, children);
|
|
442
386
|
};
|
|
443
387
|
|
|
444
388
|
// src/components/core/PageElements.tsx
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
var styles7 =
|
|
389
|
+
import React7 from "react";
|
|
390
|
+
import { Text as Text4, View as View4, StyleSheet as StyleSheet7 } from "@react-pdf/renderer";
|
|
391
|
+
var styles7 = StyleSheet7.create({
|
|
448
392
|
header: {
|
|
449
393
|
position: "absolute",
|
|
450
394
|
top: 20,
|
|
@@ -467,19 +411,19 @@ var styles7 = import_renderer7.StyleSheet.create({
|
|
|
467
411
|
}
|
|
468
412
|
});
|
|
469
413
|
var Header = ({ children, style, fixed = false }) => {
|
|
470
|
-
return /* @__PURE__ */
|
|
414
|
+
return /* @__PURE__ */ React7.createElement(View4, { style: [styles7.header, style], fixed }, typeof children === "string" ? /* @__PURE__ */ React7.createElement(Text4, null, children) : children);
|
|
471
415
|
};
|
|
472
416
|
var Footer = ({ children, style, fixed = false }) => {
|
|
473
|
-
return /* @__PURE__ */
|
|
417
|
+
return /* @__PURE__ */ React7.createElement(View4, { style: [styles7.footer, style], fixed }, typeof children === "string" ? /* @__PURE__ */ React7.createElement(Text4, null, children) : children);
|
|
474
418
|
};
|
|
475
419
|
|
|
476
420
|
// src/components/core/QR.tsx
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
421
|
+
import React8 from "react";
|
|
422
|
+
import { Image as Image3, StyleSheet as StyleSheet8, View as View5 } from "@react-pdf/renderer";
|
|
423
|
+
import { useEffect, useState } from "react";
|
|
480
424
|
|
|
481
425
|
// src/components/core/QRGenerator.tsx
|
|
482
|
-
|
|
426
|
+
import QRCode from "qrcode";
|
|
483
427
|
var generateQRAsBase64 = async ({
|
|
484
428
|
value,
|
|
485
429
|
size = 150,
|
|
@@ -500,7 +444,7 @@ var generateQRAsBase64 = async ({
|
|
|
500
444
|
},
|
|
501
445
|
width: size
|
|
502
446
|
};
|
|
503
|
-
const qrDataUrl =
|
|
447
|
+
const qrDataUrl = QRCode.toDataURL(value, options);
|
|
504
448
|
return qrDataUrl;
|
|
505
449
|
} catch (error) {
|
|
506
450
|
console.error("Error generando QR:", error);
|
|
@@ -556,7 +500,7 @@ var addLogoToQR = async (qrDataUrl, logoUrl, logoWidth, logoHeight) => {
|
|
|
556
500
|
};
|
|
557
501
|
|
|
558
502
|
// src/components/core/QR.tsx
|
|
559
|
-
var styles8 =
|
|
503
|
+
var styles8 = StyleSheet8.create({
|
|
560
504
|
qrContainer: {
|
|
561
505
|
display: "flex",
|
|
562
506
|
alignItems: "center",
|
|
@@ -582,8 +526,8 @@ var QR = ({
|
|
|
582
526
|
logoHeight = 30,
|
|
583
527
|
errorCorrectionLevel = "M"
|
|
584
528
|
}) => {
|
|
585
|
-
const [qrDataUrl, setQrDataUrl] =
|
|
586
|
-
|
|
529
|
+
const [qrDataUrl, setQrDataUrl] = useState("");
|
|
530
|
+
useEffect(() => {
|
|
587
531
|
const generateQR = async () => {
|
|
588
532
|
try {
|
|
589
533
|
const baseQrDataUrl = await generateQRAsBase64({
|
|
@@ -615,14 +559,14 @@ var QR = ({
|
|
|
615
559
|
const fallbackUrl = `https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(
|
|
616
560
|
value
|
|
617
561
|
)}&size=${size}x${size}`;
|
|
618
|
-
return /* @__PURE__ */
|
|
562
|
+
return /* @__PURE__ */ React8.createElement(View5, { style: [styles8.qrContainer, style] }, /* @__PURE__ */ React8.createElement(Image3, { src: qrDataUrl || fallbackUrl, style: { width: size, height: size } }));
|
|
619
563
|
};
|
|
620
564
|
var QR_default = QR;
|
|
621
565
|
|
|
622
566
|
// src/components/core/Lista.tsx
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
var styles9 =
|
|
567
|
+
import React9 from "react";
|
|
568
|
+
import { View as View6, Text as Text5, StyleSheet as StyleSheet9 } from "@react-pdf/renderer";
|
|
569
|
+
var styles9 = StyleSheet9.create({
|
|
626
570
|
ul: {
|
|
627
571
|
marginBottom: 10,
|
|
628
572
|
paddingLeft: 15
|
|
@@ -682,9 +626,9 @@ var toRoman = (num) => {
|
|
|
682
626
|
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];
|
|
683
627
|
};
|
|
684
628
|
var UL = ({ children, style, type = "disc" }) => {
|
|
685
|
-
const childrenWithBullets =
|
|
686
|
-
if (
|
|
687
|
-
return
|
|
629
|
+
const childrenWithBullets = React9.Children.map(children, (child, index) => {
|
|
630
|
+
if (React9.isValidElement(child)) {
|
|
631
|
+
return React9.cloneElement(child, {
|
|
688
632
|
bulletType: type,
|
|
689
633
|
isOrdered: false,
|
|
690
634
|
index: index + 1
|
|
@@ -692,12 +636,12 @@ var UL = ({ children, style, type = "disc" }) => {
|
|
|
692
636
|
}
|
|
693
637
|
return child;
|
|
694
638
|
});
|
|
695
|
-
return /* @__PURE__ */
|
|
639
|
+
return /* @__PURE__ */ React9.createElement(View6, { style: [styles9.ul, style] }, childrenWithBullets);
|
|
696
640
|
};
|
|
697
641
|
var OL = ({ children, style, type = "decimal", start = 1 }) => {
|
|
698
|
-
const childrenWithNumbers =
|
|
699
|
-
if (
|
|
700
|
-
return
|
|
642
|
+
const childrenWithNumbers = React9.Children.map(children, (child, index) => {
|
|
643
|
+
if (React9.isValidElement(child)) {
|
|
644
|
+
return React9.cloneElement(child, {
|
|
701
645
|
bulletType: type,
|
|
702
646
|
isOrdered: true,
|
|
703
647
|
index: index + 1,
|
|
@@ -706,7 +650,7 @@ var OL = ({ children, style, type = "decimal", start = 1 }) => {
|
|
|
706
650
|
}
|
|
707
651
|
return child;
|
|
708
652
|
});
|
|
709
|
-
return /* @__PURE__ */
|
|
653
|
+
return /* @__PURE__ */ React9.createElement(View6, { style: [styles9.ol, style] }, childrenWithNumbers);
|
|
710
654
|
};
|
|
711
655
|
var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1, start = 1, value }) => {
|
|
712
656
|
let marker;
|
|
@@ -716,10 +660,58 @@ var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1,
|
|
|
716
660
|
} else {
|
|
717
661
|
marker = getBulletPoint(bulletType);
|
|
718
662
|
}
|
|
719
|
-
return /* @__PURE__ */
|
|
663
|
+
return /* @__PURE__ */ React9.createElement(View6, { style: [styles9.li, style] }, /* @__PURE__ */ React9.createElement(Text5, { style: styles9.bulletPoint }, marker), /* @__PURE__ */ React9.createElement(View6, { style: styles9.itemContent }, typeof children === "string" ? /* @__PURE__ */ React9.createElement(Text5, null, children) : children));
|
|
720
664
|
};
|
|
721
|
-
|
|
722
|
-
|
|
665
|
+
|
|
666
|
+
// src/components/core/index.tsx
|
|
667
|
+
import { View as View7, Text as Text6 } from "@react-pdf/renderer";
|
|
668
|
+
|
|
669
|
+
// src/functions/decodeBase64Pdf.ts
|
|
670
|
+
var decodeBase64Pdf = (base64, fileName) => {
|
|
671
|
+
const byteCharacters = atob(base64);
|
|
672
|
+
const byteNumbers = new Array(byteCharacters.length);
|
|
673
|
+
for (let i = 0; i < byteCharacters.length; i++) {
|
|
674
|
+
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
|
675
|
+
}
|
|
676
|
+
const byteArray = new Uint8Array(byteNumbers);
|
|
677
|
+
const blob = new Blob([byteArray], { type: "application/pdf" });
|
|
678
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
679
|
+
const link = document.createElement("a");
|
|
680
|
+
link.href = blobUrl;
|
|
681
|
+
link.download = fileName;
|
|
682
|
+
document.body.appendChild(link);
|
|
683
|
+
link.click();
|
|
684
|
+
document.body.removeChild(link);
|
|
685
|
+
window.open(blobUrl, "_blank");
|
|
686
|
+
setTimeout(() => {
|
|
687
|
+
URL.revokeObjectURL(blobUrl);
|
|
688
|
+
}, 100);
|
|
689
|
+
};
|
|
690
|
+
var decodeBase64Pdf_default = decodeBase64Pdf;
|
|
691
|
+
|
|
692
|
+
// src/functions/generatePDF.ts
|
|
693
|
+
import { renderToStream } from "@react-pdf/renderer";
|
|
694
|
+
import { createElement } from "react";
|
|
695
|
+
var generatePDF = async ({ template: Template, data }) => {
|
|
696
|
+
try {
|
|
697
|
+
if (!Template) {
|
|
698
|
+
throw new Error("Template not provided");
|
|
699
|
+
}
|
|
700
|
+
const MyDocument = createElement(Template, { data });
|
|
701
|
+
const stream = await renderToStream(MyDocument);
|
|
702
|
+
const base64String = await new Promise((resolve, reject) => {
|
|
703
|
+
const chunks = [];
|
|
704
|
+
stream.on("data", (chunk) => chunks.push(chunk));
|
|
705
|
+
stream.on("end", () => resolve(Buffer.concat(chunks).toString("base64")));
|
|
706
|
+
stream.on("error", (error) => reject(error));
|
|
707
|
+
});
|
|
708
|
+
return base64String;
|
|
709
|
+
} catch (error) {
|
|
710
|
+
throw new Error("Error generating PDF: " + (error instanceof Error ? error.message : "Unknown error"));
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
var generatePDF_default = generatePDF;
|
|
714
|
+
export {
|
|
723
715
|
A,
|
|
724
716
|
BR,
|
|
725
717
|
Blockquote,
|
|
@@ -746,14 +738,14 @@ var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1,
|
|
|
746
738
|
H5,
|
|
747
739
|
H6,
|
|
748
740
|
Header,
|
|
749
|
-
Img,
|
|
741
|
+
Img_default as Img,
|
|
750
742
|
LI,
|
|
751
|
-
LayoutPDF,
|
|
743
|
+
LayoutPDF_default as LayoutPDF,
|
|
752
744
|
Left,
|
|
753
745
|
Mark,
|
|
754
746
|
OL,
|
|
755
747
|
P,
|
|
756
|
-
QR,
|
|
748
|
+
QR_default as QR,
|
|
757
749
|
Right,
|
|
758
750
|
Row,
|
|
759
751
|
Small,
|
|
@@ -762,9 +754,13 @@ var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1,
|
|
|
762
754
|
Table,
|
|
763
755
|
Tbody,
|
|
764
756
|
Td,
|
|
757
|
+
Text6 as Text,
|
|
765
758
|
Th,
|
|
766
759
|
Thead,
|
|
767
760
|
Tr,
|
|
768
761
|
U,
|
|
769
|
-
UL
|
|
770
|
-
|
|
762
|
+
UL,
|
|
763
|
+
View7 as View,
|
|
764
|
+
decodeBase64Pdf_default as decodeBase64Pdf,
|
|
765
|
+
generatePDF_default as generatePDF
|
|
766
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-pdf-levelup",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "2.0.17",
|
|
5
4
|
"main": "dist/index.js",
|
|
6
5
|
"types": "dist/index.d.ts",
|
|
7
6
|
"files": [
|
|
@@ -16,7 +15,8 @@
|
|
|
16
15
|
"update-jsx": "node ./fn/updateTsconfig.js",
|
|
17
16
|
"clean-dist": "rimraf dist",
|
|
18
17
|
"build-lib": "npm run clean-dist && tsup",
|
|
19
|
-
"publicar": "npm run upVersion && npm run update-jsx && npm run build-lib && npm publish"
|
|
18
|
+
"publicar": "npm run upVersion && npm run update-jsx && npm run build-lib && npm publish",
|
|
19
|
+
"demo": "ts-node ./src/functions/generarExample/template.ts"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@babel/standalone": "^7.23.10",
|
|
@@ -27,9 +27,10 @@
|
|
|
27
27
|
"qrcode": "^1.5.4",
|
|
28
28
|
"react": "^18.2.0",
|
|
29
29
|
"react-dom": "^18.2.0",
|
|
30
|
-
"react-pdf-levelup": "^2.0.
|
|
30
|
+
"react-pdf-levelup": "^2.0.14",
|
|
31
31
|
"react-router-dom": "^7.4.1",
|
|
32
|
-
"rimraf": "^6.0.1"
|
|
32
|
+
"rimraf": "^6.0.1",
|
|
33
|
+
"ts-node": "^10.9.2"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@eslint/js": "^9.21.0",
|