react-pdf-levelup 2.0.28 → 2.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +881 -0
- package/dist/{index.d.mts → index.d.cts} +7 -21
- package/dist/index.d.ts +7 -21
- package/dist/index.js +231 -339
- package/package.json +4 -2
- package/dist/index.mjs +0 -811
package/dist/index.js
CHANGED
|
@@ -1,95 +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
|
-
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 } from "@react-pdf/renderer";
|
|
4
|
+
var styles = StyleSheet.create({
|
|
93
5
|
page: {
|
|
94
6
|
backgroundColor: "white",
|
|
95
7
|
padding: 30,
|
|
@@ -146,8 +58,8 @@ var LayoutPDF = ({
|
|
|
146
58
|
padding,
|
|
147
59
|
...style
|
|
148
60
|
};
|
|
149
|
-
return /* @__PURE__ */
|
|
150
|
-
|
|
61
|
+
return /* @__PURE__ */ React.createElement(Document, null, /* @__PURE__ */ React.createElement(Page, { size: safeSize, orientation: safeOrientation, style: pageStyle }, children, safeShowPageNumbers && /* @__PURE__ */ React.createElement(
|
|
62
|
+
Text,
|
|
151
63
|
{
|
|
152
64
|
style: styles.pageNumber,
|
|
153
65
|
render: ({ pageNumber, totalPages }) => `${pageNumber} / ${totalPages}`,
|
|
@@ -158,9 +70,9 @@ var LayoutPDF = ({
|
|
|
158
70
|
var LayoutPDF_default = LayoutPDF;
|
|
159
71
|
|
|
160
72
|
// src/components/core/Img.tsx
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
var styles2 =
|
|
73
|
+
import React2 from "react";
|
|
74
|
+
import { Image as Image2, StyleSheet as StyleSheet2 } from "@react-pdf/renderer";
|
|
75
|
+
var styles2 = StyleSheet2.create({
|
|
164
76
|
image: {
|
|
165
77
|
width: "100%",
|
|
166
78
|
height: "auto",
|
|
@@ -168,14 +80,14 @@ var styles2 = import_renderer2.StyleSheet.create({
|
|
|
168
80
|
}
|
|
169
81
|
});
|
|
170
82
|
var Img = ({ src, style }) => {
|
|
171
|
-
return /* @__PURE__ */
|
|
83
|
+
return /* @__PURE__ */ React2.createElement(Image2, { src, style: [styles2.image, style] });
|
|
172
84
|
};
|
|
173
85
|
var Img_default = Img;
|
|
174
86
|
|
|
175
87
|
// src/components/core/Position.tsx
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
var styles3 =
|
|
88
|
+
import React3 from "react";
|
|
89
|
+
import { View, StyleSheet as StyleSheet3 } from "@react-pdf/renderer";
|
|
90
|
+
var styles3 = StyleSheet3.create({
|
|
179
91
|
left: {
|
|
180
92
|
textAlign: "left"
|
|
181
93
|
},
|
|
@@ -187,19 +99,19 @@ var styles3 = import_renderer3.StyleSheet.create({
|
|
|
187
99
|
}
|
|
188
100
|
});
|
|
189
101
|
var Left = ({ children, style }) => {
|
|
190
|
-
return /* @__PURE__ */
|
|
102
|
+
return /* @__PURE__ */ React3.createElement(View, { style: [styles3.left, style] }, children);
|
|
191
103
|
};
|
|
192
104
|
var Right = ({ children, style }) => {
|
|
193
|
-
return /* @__PURE__ */
|
|
105
|
+
return /* @__PURE__ */ React3.createElement(View, { style: [styles3.right, style] }, children);
|
|
194
106
|
};
|
|
195
107
|
var Center = ({ children, style }) => {
|
|
196
|
-
return /* @__PURE__ */
|
|
108
|
+
return /* @__PURE__ */ React3.createElement(View, { style: [styles3.center, style] }, children);
|
|
197
109
|
};
|
|
198
110
|
|
|
199
111
|
// src/components/core/Etiquetas.tsx
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
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({
|
|
203
115
|
p: {
|
|
204
116
|
fontSize: 12,
|
|
205
117
|
marginBottom: 14,
|
|
@@ -269,58 +181,58 @@ var styles4 = import_renderer4.StyleSheet.create({
|
|
|
269
181
|
}
|
|
270
182
|
});
|
|
271
183
|
var P = ({ children, style }) => {
|
|
272
|
-
return /* @__PURE__ */
|
|
184
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.p, style] }, children);
|
|
273
185
|
};
|
|
274
186
|
var H1 = ({ children, style }) => {
|
|
275
|
-
return /* @__PURE__ */
|
|
187
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h1, style] }, children);
|
|
276
188
|
};
|
|
277
189
|
var H2 = ({ children, style }) => {
|
|
278
|
-
return /* @__PURE__ */
|
|
190
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h2, style] }, children);
|
|
279
191
|
};
|
|
280
192
|
var H3 = ({ children, style }) => {
|
|
281
|
-
return /* @__PURE__ */
|
|
193
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h3, style] }, children);
|
|
282
194
|
};
|
|
283
195
|
var H4 = ({ children, style }) => {
|
|
284
|
-
return /* @__PURE__ */
|
|
196
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h4, style] }, children);
|
|
285
197
|
};
|
|
286
198
|
var H5 = ({ children, style }) => {
|
|
287
|
-
return /* @__PURE__ */
|
|
199
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h5, style] }, children);
|
|
288
200
|
};
|
|
289
201
|
var H6 = ({ children, style }) => {
|
|
290
|
-
return /* @__PURE__ */
|
|
202
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h6, style] }, children);
|
|
291
203
|
};
|
|
292
204
|
var Strong = ({ children, style }) => {
|
|
293
|
-
return /* @__PURE__ */
|
|
205
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.strong, style] }, children);
|
|
294
206
|
};
|
|
295
207
|
var Em = ({ children, style }) => {
|
|
296
|
-
return /* @__PURE__ */
|
|
208
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.em, style] }, children);
|
|
297
209
|
};
|
|
298
210
|
var U = ({ children, style }) => {
|
|
299
|
-
return /* @__PURE__ */
|
|
211
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.u, style] }, children);
|
|
300
212
|
};
|
|
301
213
|
var Small = ({ children, style }) => {
|
|
302
|
-
return /* @__PURE__ */
|
|
214
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.small, style] }, children);
|
|
303
215
|
};
|
|
304
216
|
var Blockquote = ({ children, style }) => {
|
|
305
|
-
return /* @__PURE__ */
|
|
217
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.blockquote, style] }, children);
|
|
306
218
|
};
|
|
307
219
|
var Mark = ({ children, style }) => {
|
|
308
|
-
return /* @__PURE__ */
|
|
220
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.mark, style] }, children);
|
|
309
221
|
};
|
|
310
222
|
var A = ({ children, style, href }) => {
|
|
311
|
-
return /* @__PURE__ */
|
|
223
|
+
return /* @__PURE__ */ React4.createElement(Link, { src: href, style: [styles4.A, style] }, children);
|
|
312
224
|
};
|
|
313
225
|
var BR = ({ style }) => {
|
|
314
|
-
return /* @__PURE__ */
|
|
226
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.br, style] }, "\n");
|
|
315
227
|
};
|
|
316
228
|
var Span = ({ children, style }) => {
|
|
317
|
-
return /* @__PURE__ */
|
|
229
|
+
return /* @__PURE__ */ React4.createElement(Text2, { style: [style] }, children);
|
|
318
230
|
};
|
|
319
231
|
|
|
320
232
|
// src/components/core/Tablet.tsx
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
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({
|
|
324
236
|
table: {
|
|
325
237
|
width: "100%",
|
|
326
238
|
borderWidth: 1,
|
|
@@ -351,13 +263,13 @@ var styles5 = import_renderer5.StyleSheet.create({
|
|
|
351
263
|
backgroundColor: "#eeeeee"
|
|
352
264
|
}
|
|
353
265
|
});
|
|
354
|
-
var Table = ({ children, style }) => /* @__PURE__ */
|
|
355
|
-
var Thead = ({ children, style }) => /* @__PURE__ */
|
|
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);
|
|
356
268
|
var Tbody = ({ children, style }) => {
|
|
357
|
-
const rows =
|
|
269
|
+
const rows = React5.Children.toArray(children);
|
|
358
270
|
const count = rows.length;
|
|
359
|
-
return /* @__PURE__ */
|
|
360
|
-
(row, idx) =>
|
|
271
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, rows.map(
|
|
272
|
+
(row, idx) => React5.cloneElement(row, {
|
|
361
273
|
isLastRow: idx === count - 1,
|
|
362
274
|
isOdd: idx % 2 === 1
|
|
363
275
|
})
|
|
@@ -369,12 +281,12 @@ var Tr = ({
|
|
|
369
281
|
isLastRow = false,
|
|
370
282
|
isOdd = false
|
|
371
283
|
}) => {
|
|
372
|
-
const elements =
|
|
284
|
+
const elements = React5.Children.toArray(children);
|
|
373
285
|
const count = elements.length;
|
|
374
|
-
return /* @__PURE__ */
|
|
286
|
+
return /* @__PURE__ */ React5.createElement(View2, { style: [styles5.tr, style] }, elements.map((child, idx) => {
|
|
375
287
|
const isLast = idx === count - 1;
|
|
376
288
|
const width = `${(100 / count).toFixed(2)}%`;
|
|
377
|
-
return
|
|
289
|
+
return React5.cloneElement(child, { width, isLast, isLastRow, isOdd });
|
|
378
290
|
}));
|
|
379
291
|
};
|
|
380
292
|
var Th = ({
|
|
@@ -393,7 +305,7 @@ var Th = ({
|
|
|
393
305
|
borderColor: "#000",
|
|
394
306
|
...height !== void 0 && { height }
|
|
395
307
|
};
|
|
396
|
-
return /* @__PURE__ */
|
|
308
|
+
return /* @__PURE__ */ React5.createElement(View2, { style: [styles5.textBold, { width: baseWidth }, borders, style] }, /* @__PURE__ */ React5.createElement(Text3, null, children));
|
|
397
309
|
};
|
|
398
310
|
var Td = ({
|
|
399
311
|
children,
|
|
@@ -412,19 +324,19 @@ var Td = ({
|
|
|
412
324
|
borderColor: "#000",
|
|
413
325
|
...height !== void 0 && { height }
|
|
414
326
|
};
|
|
415
|
-
return /* @__PURE__ */
|
|
327
|
+
return /* @__PURE__ */ React5.createElement(View2, { style: [
|
|
416
328
|
styles5.text,
|
|
417
329
|
isOdd && styles5.zebraOdd,
|
|
418
330
|
{ width: baseWidth },
|
|
419
331
|
borders,
|
|
420
332
|
style
|
|
421
|
-
] }, /* @__PURE__ */
|
|
333
|
+
] }, /* @__PURE__ */ React5.createElement(Text3, null, children));
|
|
422
334
|
};
|
|
423
335
|
|
|
424
336
|
// src/components/core/Grid.tsx
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
var styles6 =
|
|
337
|
+
import React6 from "react";
|
|
338
|
+
import { View as View3, StyleSheet as StyleSheet6 } from "@react-pdf/renderer";
|
|
339
|
+
var styles6 = StyleSheet6.create({
|
|
428
340
|
container: {
|
|
429
341
|
width: "100%",
|
|
430
342
|
paddingHorizontal: 20
|
|
@@ -451,52 +363,52 @@ var styles6 = import_renderer6.StyleSheet.create({
|
|
|
451
363
|
col12: { width: "100%" }
|
|
452
364
|
});
|
|
453
365
|
var Container = ({ children, style }) => {
|
|
454
|
-
return /* @__PURE__ */
|
|
366
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.container, style] }, children);
|
|
455
367
|
};
|
|
456
368
|
var Row = ({ children, style }) => {
|
|
457
|
-
return /* @__PURE__ */
|
|
369
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.row, style] }, children);
|
|
458
370
|
};
|
|
459
371
|
var Col1 = ({ children, style }) => {
|
|
460
|
-
return /* @__PURE__ */
|
|
372
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col1, style] }, children);
|
|
461
373
|
};
|
|
462
374
|
var Col2 = ({ children, style }) => {
|
|
463
|
-
return /* @__PURE__ */
|
|
375
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col2, style] }, children);
|
|
464
376
|
};
|
|
465
377
|
var Col3 = ({ children, style }) => {
|
|
466
|
-
return /* @__PURE__ */
|
|
378
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col3, style] }, children);
|
|
467
379
|
};
|
|
468
380
|
var Col4 = ({ children, style }) => {
|
|
469
|
-
return /* @__PURE__ */
|
|
381
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col4, style] }, children);
|
|
470
382
|
};
|
|
471
383
|
var Col5 = ({ children, style }) => {
|
|
472
|
-
return /* @__PURE__ */
|
|
384
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col5, style] }, children);
|
|
473
385
|
};
|
|
474
386
|
var Col6 = ({ children, style }) => {
|
|
475
|
-
return /* @__PURE__ */
|
|
387
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col6, style] }, children);
|
|
476
388
|
};
|
|
477
389
|
var Col7 = ({ children, style }) => {
|
|
478
|
-
return /* @__PURE__ */
|
|
390
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col7, style] }, children);
|
|
479
391
|
};
|
|
480
392
|
var Col8 = ({ children, style }) => {
|
|
481
|
-
return /* @__PURE__ */
|
|
393
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col8, style] }, children);
|
|
482
394
|
};
|
|
483
395
|
var Col9 = ({ children, style }) => {
|
|
484
|
-
return /* @__PURE__ */
|
|
396
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col9, style] }, children);
|
|
485
397
|
};
|
|
486
398
|
var Col10 = ({ children, style }) => {
|
|
487
|
-
return /* @__PURE__ */
|
|
399
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col10, style] }, children);
|
|
488
400
|
};
|
|
489
401
|
var Col11 = ({ children, style }) => {
|
|
490
|
-
return /* @__PURE__ */
|
|
402
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col11, style] }, children);
|
|
491
403
|
};
|
|
492
404
|
var Col12 = ({ children, style }) => {
|
|
493
|
-
return /* @__PURE__ */
|
|
405
|
+
return /* @__PURE__ */ React6.createElement(View3, { style: [styles6.col, styles6.col12, style] }, children);
|
|
494
406
|
};
|
|
495
407
|
|
|
496
408
|
// src/components/core/PageElements.tsx
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
var styles7 =
|
|
409
|
+
import React7 from "react";
|
|
410
|
+
import { Text as Text4, View as View4, StyleSheet as StyleSheet7 } from "@react-pdf/renderer";
|
|
411
|
+
var styles7 = StyleSheet7.create({
|
|
500
412
|
header: {
|
|
501
413
|
position: "absolute",
|
|
502
414
|
top: 20,
|
|
@@ -519,181 +431,162 @@ var styles7 = import_renderer7.StyleSheet.create({
|
|
|
519
431
|
}
|
|
520
432
|
});
|
|
521
433
|
var Header = ({ children, style, fixed = false }) => {
|
|
522
|
-
return /* @__PURE__ */
|
|
434
|
+
return /* @__PURE__ */ React7.createElement(View4, { style: [styles7.header, style], fixed }, typeof children === "string" ? /* @__PURE__ */ React7.createElement(Text4, null, children) : children);
|
|
523
435
|
};
|
|
524
436
|
var Footer = ({ children, style, fixed = false }) => {
|
|
525
|
-
return /* @__PURE__ */
|
|
437
|
+
return /* @__PURE__ */ React7.createElement(View4, { style: [styles7.footer, style], fixed }, typeof children === "string" ? /* @__PURE__ */ React7.createElement(Text4, null, children) : children);
|
|
526
438
|
};
|
|
527
439
|
|
|
528
440
|
// src/components/core/QR.tsx
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
logoHeight,
|
|
441
|
+
import React8 from "react";
|
|
442
|
+
import { Image as Image3, StyleSheet as StyleSheet8, View as View5 } from "@react-pdf/renderer";
|
|
443
|
+
import { useEffect, useState } from "react";
|
|
444
|
+
|
|
445
|
+
// src/components/core/QRGenerator.tsx
|
|
446
|
+
import QRCode from "qrcode";
|
|
447
|
+
var generateQRAsBase64 = async ({
|
|
448
|
+
value,
|
|
449
|
+
size = 150,
|
|
450
|
+
colorDark = "#000000",
|
|
451
|
+
colorLight = "#ffffff",
|
|
541
452
|
margin = 0,
|
|
542
|
-
errorCorrectionLevel = "
|
|
453
|
+
errorCorrectionLevel = "M"
|
|
454
|
+
}) => {
|
|
455
|
+
try {
|
|
456
|
+
const options = {
|
|
457
|
+
errorCorrectionLevel,
|
|
458
|
+
type: "image/png",
|
|
459
|
+
quality: 0.92,
|
|
460
|
+
margin,
|
|
461
|
+
color: {
|
|
462
|
+
dark: colorDark,
|
|
463
|
+
light: colorLight
|
|
464
|
+
},
|
|
465
|
+
width: size
|
|
466
|
+
};
|
|
467
|
+
const qrDataUrl = QRCode.toDataURL(value, options);
|
|
468
|
+
return qrDataUrl;
|
|
469
|
+
} catch (error) {
|
|
470
|
+
console.error("Error generando QR:", error);
|
|
471
|
+
return "";
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
var addLogoToQR = async (qrDataUrl, logoUrl, logoWidth, logoHeight) => {
|
|
475
|
+
return new Promise((resolve) => {
|
|
476
|
+
if (!qrDataUrl || !logoUrl) {
|
|
477
|
+
resolve(qrDataUrl);
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
try {
|
|
481
|
+
const canvas = document.createElement("canvas");
|
|
482
|
+
const ctx = canvas.getContext("2d");
|
|
483
|
+
if (!ctx) {
|
|
484
|
+
resolve(qrDataUrl);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
const qrImage = new Image();
|
|
488
|
+
qrImage.crossOrigin = "anonymous";
|
|
489
|
+
qrImage.onload = () => {
|
|
490
|
+
canvas.width = qrImage.width;
|
|
491
|
+
canvas.height = qrImage.height;
|
|
492
|
+
ctx.drawImage(qrImage, 0, 0, canvas.width, canvas.height);
|
|
493
|
+
const logoImage = new Image();
|
|
494
|
+
logoImage.crossOrigin = "anonymous";
|
|
495
|
+
logoImage.onload = () => {
|
|
496
|
+
const x = (canvas.width - logoWidth) / 2;
|
|
497
|
+
const y = (canvas.height - logoHeight) / 2;
|
|
498
|
+
ctx.fillStyle = "#FFFFFF";
|
|
499
|
+
ctx.fillRect(x - 5, y - 5, logoWidth + 10, logoHeight + 10);
|
|
500
|
+
ctx.drawImage(logoImage, x, y, logoWidth, logoHeight);
|
|
501
|
+
const finalQrDataUrl = canvas.toDataURL("image/png");
|
|
502
|
+
resolve(finalQrDataUrl);
|
|
503
|
+
};
|
|
504
|
+
logoImage.onerror = () => {
|
|
505
|
+
console.error("Error cargando el logo");
|
|
506
|
+
resolve(qrDataUrl);
|
|
507
|
+
};
|
|
508
|
+
logoImage.src = logoUrl;
|
|
509
|
+
};
|
|
510
|
+
qrImage.onerror = () => {
|
|
511
|
+
console.error("Error cargando el QR");
|
|
512
|
+
resolve("");
|
|
513
|
+
};
|
|
514
|
+
qrImage.src = qrDataUrl;
|
|
515
|
+
} catch (error) {
|
|
516
|
+
console.error("Error procesando el QR con logo:", error);
|
|
517
|
+
resolve(qrDataUrl);
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
// src/components/core/QR.tsx
|
|
523
|
+
var styles8 = StyleSheet8.create({
|
|
524
|
+
qrContainer: {
|
|
525
|
+
display: "flex",
|
|
526
|
+
alignItems: "center",
|
|
527
|
+
justifyContent: "center",
|
|
528
|
+
margin: 10
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
var errorLevelMap = {
|
|
532
|
+
0: "L",
|
|
533
|
+
1: "M",
|
|
534
|
+
2: "Q",
|
|
535
|
+
3: "H"
|
|
536
|
+
};
|
|
537
|
+
var QR = ({
|
|
538
|
+
value,
|
|
539
|
+
size = 150,
|
|
543
540
|
style,
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
moveText = 0,
|
|
552
|
-
textColor = colorData,
|
|
553
|
-
fontSize = 12,
|
|
554
|
-
fontFamily = "Helvetica",
|
|
555
|
-
textBackgroundColor = colorDataBG,
|
|
556
|
-
textPadding = 1,
|
|
557
|
-
textBold = true
|
|
541
|
+
colorDark = "#000000",
|
|
542
|
+
colorLight = "#ffffff",
|
|
543
|
+
margin = 0,
|
|
544
|
+
logo = "",
|
|
545
|
+
logoWidth = 30,
|
|
546
|
+
logoHeight = 30,
|
|
547
|
+
errorCorrectionLevel = "M"
|
|
558
548
|
}) => {
|
|
559
|
-
const [
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
(0, import_react9.useEffect)(() => {
|
|
563
|
-
const generateQRCode = async () => {
|
|
549
|
+
const [qrDataUrl, setQrDataUrl] = useState("");
|
|
550
|
+
useEffect(() => {
|
|
551
|
+
const generateQR = async () => {
|
|
564
552
|
try {
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
type: dotType
|
|
573
|
-
},
|
|
574
|
-
cornersSquareOptions: {
|
|
575
|
-
color: cornerSquareColor || colorData,
|
|
576
|
-
type: cornerSquareType
|
|
577
|
-
},
|
|
578
|
-
cornersDotOptions: {
|
|
579
|
-
color: cornerDotColor || colorData,
|
|
580
|
-
type: cornerDotType
|
|
581
|
-
},
|
|
582
|
-
backgroundOptions: {
|
|
583
|
-
color: colorDataBG
|
|
584
|
-
},
|
|
585
|
-
qrOptions: {
|
|
586
|
-
errorCorrectionLevel
|
|
587
|
-
},
|
|
588
|
-
margin
|
|
553
|
+
const baseQrDataUrl = await generateQRAsBase64({
|
|
554
|
+
value,
|
|
555
|
+
size,
|
|
556
|
+
colorDark,
|
|
557
|
+
colorLight,
|
|
558
|
+
margin,
|
|
559
|
+
errorCorrectionLevel: typeof errorCorrectionLevel === "number" ? errorLevelMap[errorCorrectionLevel] || "M" : errorCorrectionLevel
|
|
589
560
|
});
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
setTimeout(() => {
|
|
597
|
-
try {
|
|
598
|
-
const qrCanvas = container.querySelector("canvas");
|
|
599
|
-
if (qrCanvas) {
|
|
600
|
-
const canvas = document.createElement("canvas");
|
|
601
|
-
canvas.width = size;
|
|
602
|
-
canvas.height = size;
|
|
603
|
-
const ctx = canvas.getContext("2d");
|
|
604
|
-
if (ctx) {
|
|
605
|
-
ctx.drawImage(qrCanvas, 0, 0);
|
|
606
|
-
const dataURL = canvas.toDataURL("image/png");
|
|
607
|
-
setQrDataURL(dataURL);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
document.body.removeChild(container);
|
|
611
|
-
} catch (error) {
|
|
612
|
-
console.error("Error capturing QR code:", error);
|
|
613
|
-
}
|
|
614
|
-
}, 100);
|
|
561
|
+
if (logo && logoWidth && logoHeight) {
|
|
562
|
+
const qrWithLogo = await addLogoToQR(baseQrDataUrl, logo, logoWidth, logoHeight);
|
|
563
|
+
setQrDataUrl(qrWithLogo);
|
|
564
|
+
} else {
|
|
565
|
+
setQrDataUrl(baseQrDataUrl);
|
|
566
|
+
}
|
|
615
567
|
} catch (error) {
|
|
616
|
-
console.error("Error
|
|
568
|
+
console.error("Error generando QR:", error);
|
|
569
|
+
const fallbackUrl2 = `https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(
|
|
570
|
+
value
|
|
571
|
+
)}&size=${size}x${size}&color=${encodeURIComponent(colorDark.replace("#", ""))}&bgcolor=${encodeURIComponent(
|
|
572
|
+
colorLight.replace("#", "")
|
|
573
|
+
)}`;
|
|
574
|
+
setQrDataUrl(fallbackUrl2);
|
|
617
575
|
}
|
|
618
576
|
};
|
|
619
|
-
|
|
620
|
-
}, [
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
margin,
|
|
626
|
-
errorCorrectionLevel,
|
|
627
|
-
dotType,
|
|
628
|
-
cornerSquareType,
|
|
629
|
-
cornerDotType,
|
|
630
|
-
cornerSquareColor,
|
|
631
|
-
cornerDotColor,
|
|
632
|
-
logoBG
|
|
633
|
-
]);
|
|
634
|
-
if (!qrDataURL) return null;
|
|
635
|
-
const centerPosition = size / 2;
|
|
636
|
-
const logoContainerSize = Math.max(actualLogoWidth, actualLogoHeight) + 10;
|
|
637
|
-
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(
|
|
638
|
-
import_renderer8.View,
|
|
639
|
-
{
|
|
640
|
-
style: {
|
|
641
|
-
position: "absolute",
|
|
642
|
-
width: logoContainerSize,
|
|
643
|
-
height: logoContainerSize,
|
|
644
|
-
backgroundColor: logoBG || colorDataBG,
|
|
645
|
-
left: centerPosition - logoContainerSize / 2,
|
|
646
|
-
top: centerPosition - logoContainerSize / 2,
|
|
647
|
-
borderRadius: 100,
|
|
648
|
-
border: `5px solid ${colorData}`,
|
|
649
|
-
padding: 0
|
|
650
|
-
}
|
|
651
|
-
},
|
|
652
|
-
/* @__PURE__ */ import_react8.default.createElement(
|
|
653
|
-
import_renderer8.Image,
|
|
654
|
-
{
|
|
655
|
-
src: logo || "/placeholder.svg",
|
|
656
|
-
style: {
|
|
657
|
-
objectFit: "contain",
|
|
658
|
-
width: actualLogoWidth,
|
|
659
|
-
height: actualLogoHeight || actualLogoWidth
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
)
|
|
663
|
-
), !logo && logoText && /* @__PURE__ */ import_react8.default.createElement(
|
|
664
|
-
import_renderer8.View,
|
|
665
|
-
{
|
|
666
|
-
style: {
|
|
667
|
-
position: "absolute",
|
|
668
|
-
backgroundColor: textBackgroundColor,
|
|
669
|
-
padding: textPadding,
|
|
670
|
-
borderRadius: 4,
|
|
671
|
-
left: moveText + centerPosition - 20,
|
|
672
|
-
// Approximate center
|
|
673
|
-
top: centerPosition - 10
|
|
674
|
-
// Approximate center
|
|
675
|
-
}
|
|
676
|
-
},
|
|
677
|
-
/* @__PURE__ */ import_react8.default.createElement(
|
|
678
|
-
import_renderer8.Text,
|
|
679
|
-
{
|
|
680
|
-
style: {
|
|
681
|
-
color: textColor,
|
|
682
|
-
fontSize,
|
|
683
|
-
fontFamily,
|
|
684
|
-
fontWeight: textBold ? "bold" : "normal"
|
|
685
|
-
}
|
|
686
|
-
},
|
|
687
|
-
logoText
|
|
688
|
-
)
|
|
689
|
-
));
|
|
577
|
+
generateQR();
|
|
578
|
+
}, [value, size, colorDark, colorLight, margin, logo, logoWidth, logoHeight, errorCorrectionLevel]);
|
|
579
|
+
const fallbackUrl = `https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(
|
|
580
|
+
value
|
|
581
|
+
)}&size=${size}x${size}`;
|
|
582
|
+
return /* @__PURE__ */ React8.createElement(View5, { style: [styles8.qrContainer, style] }, /* @__PURE__ */ React8.createElement(Image3, { src: qrDataUrl || fallbackUrl, style: { width: size, height: size } }));
|
|
690
583
|
};
|
|
691
584
|
var QR_default = QR;
|
|
692
585
|
|
|
693
586
|
// src/components/core/Lista.tsx
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
var
|
|
587
|
+
import React9 from "react";
|
|
588
|
+
import { View as View6, Text as Text5, StyleSheet as StyleSheet9 } from "@react-pdf/renderer";
|
|
589
|
+
var styles9 = StyleSheet9.create({
|
|
697
590
|
ul: {
|
|
698
591
|
marginBottom: 10,
|
|
699
592
|
paddingLeft: 15
|
|
@@ -753,9 +646,9 @@ var toRoman = (num) => {
|
|
|
753
646
|
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];
|
|
754
647
|
};
|
|
755
648
|
var UL = ({ children, style, type = "disc" }) => {
|
|
756
|
-
const childrenWithBullets =
|
|
757
|
-
if (
|
|
758
|
-
return
|
|
649
|
+
const childrenWithBullets = React9.Children.map(children, (child, index) => {
|
|
650
|
+
if (React9.isValidElement(child)) {
|
|
651
|
+
return React9.cloneElement(child, {
|
|
759
652
|
bulletType: type,
|
|
760
653
|
isOrdered: false,
|
|
761
654
|
index: index + 1
|
|
@@ -763,12 +656,12 @@ var UL = ({ children, style, type = "disc" }) => {
|
|
|
763
656
|
}
|
|
764
657
|
return child;
|
|
765
658
|
});
|
|
766
|
-
return /* @__PURE__ */
|
|
659
|
+
return /* @__PURE__ */ React9.createElement(View6, { style: [styles9.ul, style] }, childrenWithBullets);
|
|
767
660
|
};
|
|
768
661
|
var OL = ({ children, style, type = "decimal", start = 1 }) => {
|
|
769
|
-
const childrenWithNumbers =
|
|
770
|
-
if (
|
|
771
|
-
return
|
|
662
|
+
const childrenWithNumbers = React9.Children.map(children, (child, index) => {
|
|
663
|
+
if (React9.isValidElement(child)) {
|
|
664
|
+
return React9.cloneElement(child, {
|
|
772
665
|
bulletType: type,
|
|
773
666
|
isOrdered: true,
|
|
774
667
|
index: index + 1,
|
|
@@ -777,7 +670,7 @@ var OL = ({ children, style, type = "decimal", start = 1 }) => {
|
|
|
777
670
|
}
|
|
778
671
|
return child;
|
|
779
672
|
});
|
|
780
|
-
return /* @__PURE__ */
|
|
673
|
+
return /* @__PURE__ */ React9.createElement(View6, { style: [styles9.ol, style] }, childrenWithNumbers);
|
|
781
674
|
};
|
|
782
675
|
var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1, start = 1, value }) => {
|
|
783
676
|
let marker;
|
|
@@ -787,11 +680,11 @@ var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1,
|
|
|
787
680
|
} else {
|
|
788
681
|
marker = getBulletPoint(bulletType);
|
|
789
682
|
}
|
|
790
|
-
return /* @__PURE__ */
|
|
683
|
+
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));
|
|
791
684
|
};
|
|
792
685
|
|
|
793
686
|
// src/components/core/index.tsx
|
|
794
|
-
|
|
687
|
+
import { View as View7, Text as Text6, StyleSheet as StyleSheet10, Font } from "@react-pdf/renderer";
|
|
795
688
|
|
|
796
689
|
// src/functions/decodeBase64Pdf.ts
|
|
797
690
|
var decodeBase64Pdf = (base64, fileName) => {
|
|
@@ -821,15 +714,15 @@ var decodeBase64Pdf = (base64, fileName) => {
|
|
|
821
714
|
var decodeBase64Pdf_default = decodeBase64Pdf;
|
|
822
715
|
|
|
823
716
|
// src/functions/generatePDF.ts
|
|
824
|
-
|
|
825
|
-
|
|
717
|
+
import { renderToStream } from "@react-pdf/renderer";
|
|
718
|
+
import { createElement } from "react";
|
|
826
719
|
var generatePDF = async ({ template: Template, data }) => {
|
|
827
720
|
try {
|
|
828
721
|
if (!Template) {
|
|
829
722
|
throw new Error("Template not provided");
|
|
830
723
|
}
|
|
831
|
-
const MyDocument =
|
|
832
|
-
const stream = await
|
|
724
|
+
const MyDocument = createElement(Template, { data });
|
|
725
|
+
const stream = await renderToStream(MyDocument);
|
|
833
726
|
const base64String = await new Promise((resolve, reject) => {
|
|
834
727
|
const chunks = [];
|
|
835
728
|
stream.on("data", (chunk) => chunks.push(chunk));
|
|
@@ -842,8 +735,7 @@ var generatePDF = async ({ template: Template, data }) => {
|
|
|
842
735
|
}
|
|
843
736
|
};
|
|
844
737
|
var generatePDF_default = generatePDF;
|
|
845
|
-
|
|
846
|
-
0 && (module.exports = {
|
|
738
|
+
export {
|
|
847
739
|
A,
|
|
848
740
|
BR,
|
|
849
741
|
Blockquote,
|
|
@@ -871,30 +763,30 @@ var generatePDF_default = generatePDF;
|
|
|
871
763
|
H5,
|
|
872
764
|
H6,
|
|
873
765
|
Header,
|
|
874
|
-
Img,
|
|
766
|
+
Img_default as Img,
|
|
875
767
|
LI,
|
|
876
|
-
LayoutPDF,
|
|
768
|
+
LayoutPDF_default as LayoutPDF,
|
|
877
769
|
Left,
|
|
878
770
|
Mark,
|
|
879
771
|
OL,
|
|
880
772
|
P,
|
|
881
|
-
QR,
|
|
773
|
+
QR_default as QR,
|
|
882
774
|
Right,
|
|
883
775
|
Row,
|
|
884
776
|
Small,
|
|
885
777
|
Span,
|
|
886
778
|
Strong,
|
|
887
|
-
StyleSheet,
|
|
779
|
+
StyleSheet10 as StyleSheet,
|
|
888
780
|
Table,
|
|
889
781
|
Tbody,
|
|
890
782
|
Td,
|
|
891
|
-
Text,
|
|
783
|
+
Text6 as Text,
|
|
892
784
|
Th,
|
|
893
785
|
Thead,
|
|
894
786
|
Tr,
|
|
895
787
|
U,
|
|
896
788
|
UL,
|
|
897
|
-
View,
|
|
898
|
-
decodeBase64Pdf,
|
|
899
|
-
generatePDF
|
|
900
|
-
}
|
|
789
|
+
View7 as View,
|
|
790
|
+
decodeBase64Pdf_default as decodeBase64Pdf,
|
|
791
|
+
generatePDF_default as generatePDF
|
|
792
|
+
};
|