react-pdf-levelup 3.1.59 → 3.1.63
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 +4 -1132
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +59 -11
- package/dist/index.d.ts +59 -11
- package/dist/index.js +4 -1040
- package/dist/index.js.map +1 -0
- package/package.json +14 -15
- package/README.md +0 -244
- package/license +0 -17
package/dist/index.cjs
CHANGED
|
@@ -1,1132 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
Div: () => Div,
|
|
51
|
-
Em: () => Em,
|
|
52
|
-
Font: () => import_renderer12.Font,
|
|
53
|
-
H1: () => H1,
|
|
54
|
-
H2: () => H2,
|
|
55
|
-
H3: () => H3,
|
|
56
|
-
H4: () => H4,
|
|
57
|
-
H5: () => H5,
|
|
58
|
-
H6: () => H6,
|
|
59
|
-
HR: () => HR,
|
|
60
|
-
Header: () => Header,
|
|
61
|
-
Img: () => Img_default,
|
|
62
|
-
ImgBg: () => ImgBg_default,
|
|
63
|
-
LI: () => LI,
|
|
64
|
-
LayoutPDF: () => LayoutPDF_default,
|
|
65
|
-
Left: () => Left,
|
|
66
|
-
Mark: () => Mark,
|
|
67
|
-
OL: () => OL,
|
|
68
|
-
P: () => P,
|
|
69
|
-
QR: () => QR_default,
|
|
70
|
-
Right: () => Right,
|
|
71
|
-
Row: () => Row,
|
|
72
|
-
Small: () => Small,
|
|
73
|
-
Span: () => Span,
|
|
74
|
-
Strong: () => Strong,
|
|
75
|
-
StyleSheet: () => import_renderer12.StyleSheet,
|
|
76
|
-
Table: () => Table,
|
|
77
|
-
Tbody: () => Tbody,
|
|
78
|
-
Td: () => Td,
|
|
79
|
-
Text: () => import_renderer12.Text,
|
|
80
|
-
Th: () => Th,
|
|
81
|
-
Thead: () => Thead,
|
|
82
|
-
Tr: () => Tr,
|
|
83
|
-
U: () => U,
|
|
84
|
-
UL: () => UL,
|
|
85
|
-
View: () => import_renderer12.View,
|
|
86
|
-
decodeBase64Pdf: () => decodeBase64Pdf_default,
|
|
87
|
-
generatePDF: () => generatePDF_default,
|
|
88
|
-
renderToStream: () => import_renderer10.renderToStream
|
|
89
|
-
});
|
|
90
|
-
module.exports = __toCommonJS(index_exports);
|
|
91
|
-
|
|
92
|
-
// src/components/core/LayoutPDF.tsx
|
|
93
|
-
var import_react = __toESM(require("react"), 1);
|
|
94
|
-
var import_renderer = require("@react-pdf/renderer");
|
|
95
|
-
var styles = import_renderer.StyleSheet.create({
|
|
96
|
-
page: {
|
|
97
|
-
backgroundColor: "white",
|
|
98
|
-
padding: 30,
|
|
99
|
-
fontFamily: "Helvetica",
|
|
100
|
-
fontSize: 14
|
|
101
|
-
},
|
|
102
|
-
footer: {
|
|
103
|
-
position: "absolute",
|
|
104
|
-
left: 0,
|
|
105
|
-
right: 0,
|
|
106
|
-
textAlign: "center"
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
var LayoutPDF = ({
|
|
110
|
-
children,
|
|
111
|
-
size = "A4",
|
|
112
|
-
orientation = "vertical",
|
|
113
|
-
backgroundColor = "white",
|
|
114
|
-
padding = 30,
|
|
115
|
-
margen = "normal",
|
|
116
|
-
style = {},
|
|
117
|
-
pagination = true,
|
|
118
|
-
footer,
|
|
119
|
-
lines = footer ? 2 : 1,
|
|
120
|
-
rule = false
|
|
121
|
-
}) => {
|
|
122
|
-
const LINE_HEIGHT = 20;
|
|
123
|
-
const FOOTER_PADDING = 10;
|
|
124
|
-
const footerHeight = lines * LINE_HEIGHT + FOOTER_PADDING;
|
|
125
|
-
const getMargins = (margen2, pageSize) => {
|
|
126
|
-
const normalizedSize = pageSize.toUpperCase();
|
|
127
|
-
switch (margen2) {
|
|
128
|
-
case "apa":
|
|
129
|
-
if (normalizedSize === "LETTER" || normalizedSize === "LEGAL") {
|
|
130
|
-
return {
|
|
131
|
-
paddingTop: 72,
|
|
132
|
-
paddingRight: 72,
|
|
133
|
-
paddingBottom: 72,
|
|
134
|
-
paddingLeft: 72
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
return {
|
|
138
|
-
paddingTop: 72,
|
|
139
|
-
paddingRight: 72,
|
|
140
|
-
paddingBottom: 72,
|
|
141
|
-
paddingLeft: 72
|
|
142
|
-
};
|
|
143
|
-
case "estrecho":
|
|
144
|
-
return {
|
|
145
|
-
paddingTop: 36,
|
|
146
|
-
paddingRight: 36,
|
|
147
|
-
paddingBottom: 36,
|
|
148
|
-
paddingLeft: 36
|
|
149
|
-
};
|
|
150
|
-
case "ancho":
|
|
151
|
-
return {
|
|
152
|
-
paddingTop: 108,
|
|
153
|
-
paddingRight: 108,
|
|
154
|
-
paddingBottom: 108,
|
|
155
|
-
paddingLeft: 108
|
|
156
|
-
};
|
|
157
|
-
case "normal":
|
|
158
|
-
default:
|
|
159
|
-
return {
|
|
160
|
-
paddingTop: padding,
|
|
161
|
-
paddingRight: padding,
|
|
162
|
-
paddingBottom: padding,
|
|
163
|
-
paddingLeft: padding
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
let safeSize = size;
|
|
168
|
-
let safeOrientation = orientation;
|
|
169
|
-
let safeBackgroundColor = backgroundColor;
|
|
170
|
-
let safeLines = Math.max(1, Math.min(lines, 10));
|
|
171
|
-
let safeMargen = margen;
|
|
172
|
-
try {
|
|
173
|
-
const validSizes = ["A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "LETTER", "LEGAL", "TABLOID"];
|
|
174
|
-
if (typeof size === "string" && !validSizes.includes(size.toUpperCase())) {
|
|
175
|
-
console.warn(`Invalid page size: ${size}. Using A4 as default.`);
|
|
176
|
-
safeSize = "A4";
|
|
177
|
-
}
|
|
178
|
-
if (orientation !== "vertical" && orientation !== "horizontal") {
|
|
179
|
-
console.warn(`Invalid orientation: ${orientation}. Using vertical as default.`);
|
|
180
|
-
safeOrientation = "vertical";
|
|
181
|
-
}
|
|
182
|
-
if (typeof backgroundColor !== "string") {
|
|
183
|
-
console.warn(`Invalid background color: ${backgroundColor}. Using white as default.`);
|
|
184
|
-
safeBackgroundColor = "white";
|
|
185
|
-
}
|
|
186
|
-
const validMargins = ["apa", "normal", "estrecho", "ancho"];
|
|
187
|
-
if (!validMargins.includes(margen)) {
|
|
188
|
-
console.warn(`Invalid margin type: ${margen}. Using normal as default.`);
|
|
189
|
-
safeMargen = "normal";
|
|
190
|
-
}
|
|
191
|
-
if (typeof lines !== "number" || lines < 1) {
|
|
192
|
-
console.warn(`Invalid lines value: ${lines}. Using 1 as default.`);
|
|
193
|
-
safeLines = 1;
|
|
194
|
-
}
|
|
195
|
-
} catch (e) {
|
|
196
|
-
console.warn("Error processing props in LayoutPDF:", e);
|
|
197
|
-
}
|
|
198
|
-
const transformOrientation = (orientation2) => {
|
|
199
|
-
switch (orientation2) {
|
|
200
|
-
case "vertical":
|
|
201
|
-
case "portrait":
|
|
202
|
-
case "v":
|
|
203
|
-
return "portrait";
|
|
204
|
-
case "horizontal":
|
|
205
|
-
case "landscape":
|
|
206
|
-
case "h":
|
|
207
|
-
return "landscape";
|
|
208
|
-
default:
|
|
209
|
-
console.warn(`Unrecognized orientation: ${orientation2}. Using portrait as default.`);
|
|
210
|
-
return "portrait";
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
const getFooterPosition = (pageSize, orientation2, footerHeight2) => {
|
|
214
|
-
const pageDimensions = {
|
|
215
|
-
A0: { width: 841, height: 1189 },
|
|
216
|
-
A1: { width: 594, height: 841 },
|
|
217
|
-
A2: { width: 420, height: 594 },
|
|
218
|
-
A3: { width: 297, height: 420 },
|
|
219
|
-
A4: { width: 210, height: 297 },
|
|
220
|
-
A5: { width: 148, height: 210 },
|
|
221
|
-
A6: { width: 105, height: 148 },
|
|
222
|
-
A7: { width: 74, height: 105 },
|
|
223
|
-
A8: { width: 52, height: 74 },
|
|
224
|
-
A9: { width: 37, height: 52 },
|
|
225
|
-
LETTER: { width: 216, height: 279 },
|
|
226
|
-
LEGAL: { width: 216, height: 356 },
|
|
227
|
-
TABLOID: { width: 279, height: 432 }
|
|
228
|
-
};
|
|
229
|
-
const mmToPoints = 2.834645669;
|
|
230
|
-
const dimensions = pageDimensions[pageSize.toUpperCase()];
|
|
231
|
-
if (!dimensions) {
|
|
232
|
-
return orientation2 === "landscape" ? 595 - footerHeight2 - 10 : 842 - footerHeight2 - 10;
|
|
233
|
-
}
|
|
234
|
-
const heightInPoints = dimensions.height * mmToPoints;
|
|
235
|
-
const widthInPoints = dimensions.width * mmToPoints;
|
|
236
|
-
return orientation2 === "landscape" ? widthInPoints - footerHeight2 - 10 : heightInPoints - footerHeight2 - 10;
|
|
237
|
-
};
|
|
238
|
-
const pdfOrientation = transformOrientation(safeOrientation);
|
|
239
|
-
const margins = getMargins(safeMargen, safeSize);
|
|
240
|
-
const footerTop = getFooterPosition(safeSize, pdfOrientation, footerHeight);
|
|
241
|
-
const renderGrid = () => {
|
|
242
|
-
if (!rule) return null;
|
|
243
|
-
const cmToPoints = 28.3465;
|
|
244
|
-
const pageDimensions = {
|
|
245
|
-
A0: { width: 841 * 2.834645669, height: 1189 * 2.834645669 },
|
|
246
|
-
A1: { width: 594 * 2.834645669, height: 841 * 2.834645669 },
|
|
247
|
-
A2: { width: 420 * 2.834645669, height: 594 * 2.834645669 },
|
|
248
|
-
A3: { width: 297 * 2.834645669, height: 420 * 2.834645669 },
|
|
249
|
-
A4: { width: 210 * 2.834645669, height: 297 * 2.834645669 },
|
|
250
|
-
A5: { width: 148 * 2.834645669, height: 210 * 2.834645669 },
|
|
251
|
-
A6: { width: 105 * 2.834645669, height: 148 * 2.834645669 },
|
|
252
|
-
A7: { width: 74 * 2.834645669, height: 105 * 2.834645669 },
|
|
253
|
-
A8: { width: 52 * 2.834645669, height: 74 * 2.834645669 },
|
|
254
|
-
A9: { width: 37 * 2.834645669, height: 52 * 2.834645669 },
|
|
255
|
-
LETTER: { width: 216 * 2.834645669, height: 279 * 2.834645669 },
|
|
256
|
-
LEGAL: { width: 216 * 2.834645669, height: 356 * 2.834645669 },
|
|
257
|
-
TABLOID: { width: 279 * 2.834645669, height: 432 * 2.834645669 }
|
|
258
|
-
};
|
|
259
|
-
const dimensions = pageDimensions[safeSize.toUpperCase()] || pageDimensions.A4;
|
|
260
|
-
const pageWidth = pdfOrientation === "landscape" ? dimensions.height : dimensions.width;
|
|
261
|
-
const pageHeight = pdfOrientation === "landscape" ? dimensions.width : dimensions.height;
|
|
262
|
-
const horizontalLines = [];
|
|
263
|
-
const verticalLines = [];
|
|
264
|
-
for (let i = 0; i <= Math.ceil(pageHeight / cmToPoints); i++) {
|
|
265
|
-
horizontalLines.push(
|
|
266
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
267
|
-
import_renderer.View,
|
|
268
|
-
{
|
|
269
|
-
key: `h-${i}`,
|
|
270
|
-
style: {
|
|
271
|
-
position: "absolute",
|
|
272
|
-
top: i * cmToPoints,
|
|
273
|
-
left: 0,
|
|
274
|
-
right: 0,
|
|
275
|
-
height: i % 5 === 0 ? 1 : 0.5,
|
|
276
|
-
backgroundColor: i % 5 === 0 ? "rgba(255, 0, 0, 0.8)" : "rgba(100, 100, 100, 0.5)"
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
)
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
for (let i = 0; i <= Math.ceil(pageWidth / cmToPoints); i++) {
|
|
283
|
-
verticalLines.push(
|
|
284
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
285
|
-
import_renderer.View,
|
|
286
|
-
{
|
|
287
|
-
key: `v-${i}`,
|
|
288
|
-
style: {
|
|
289
|
-
position: "absolute",
|
|
290
|
-
left: i * cmToPoints,
|
|
291
|
-
top: 0,
|
|
292
|
-
bottom: 0,
|
|
293
|
-
width: i % 5 === 0 ? 1 : 0.5,
|
|
294
|
-
backgroundColor: i % 5 === 0 ? "rgba(255, 0, 0, 0.8)" : "rgba(100, 100, 100, 0.5)"
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
)
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
return /* @__PURE__ */ import_react.default.createElement(import_renderer.View, { style: { position: "absolute", top: 0, left: 0, right: 0, bottom: 0 }, fixed: true }, horizontalLines, verticalLines);
|
|
301
|
-
};
|
|
302
|
-
const pageStyle = {
|
|
303
|
-
...styles.page,
|
|
304
|
-
backgroundColor: safeBackgroundColor,
|
|
305
|
-
...margins,
|
|
306
|
-
paddingBottom: margins.paddingBottom + footerHeight,
|
|
307
|
-
...style
|
|
308
|
-
};
|
|
309
|
-
const footerStyle = {
|
|
310
|
-
...styles.footer,
|
|
311
|
-
top: footerTop,
|
|
312
|
-
height: footerHeight,
|
|
313
|
-
display: "flex",
|
|
314
|
-
flexDirection: "column",
|
|
315
|
-
justifyContent: "center",
|
|
316
|
-
alignItems: "center",
|
|
317
|
-
fontSize: 10,
|
|
318
|
-
color: "grey"
|
|
319
|
-
};
|
|
320
|
-
return /* @__PURE__ */ import_react.default.createElement(import_renderer.Document, null, /* @__PURE__ */ import_react.default.createElement(import_renderer.Page, { size: safeSize, orientation: pdfOrientation, style: pageStyle, wrap: true }, renderGrid(), /* @__PURE__ */ import_react.default.createElement(import_renderer.View, { style: { paddingBottom: footerHeight } }, children), pagination ? /* @__PURE__ */ import_react.default.createElement(import_renderer.View, { style: footerStyle, fixed: true }, footer, /* @__PURE__ */ import_react.default.createElement(import_renderer.Text, { style: { fontSize: footerStyle.fontSize }, render: ({ pageNumber, totalPages }) => `${pageNumber} / ${totalPages}` })) : null));
|
|
321
|
-
};
|
|
322
|
-
var LayoutPDF_default = LayoutPDF;
|
|
323
|
-
|
|
324
|
-
// src/components/core/Img.tsx
|
|
325
|
-
var import_react2 = __toESM(require("react"), 1);
|
|
326
|
-
var import_renderer2 = require("@react-pdf/renderer");
|
|
327
|
-
var styles2 = import_renderer2.StyleSheet.create({
|
|
328
|
-
image: {
|
|
329
|
-
width: "100%",
|
|
330
|
-
height: "auto",
|
|
331
|
-
marginBottom: 14
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
var Img = ({ src, style }) => {
|
|
335
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_renderer2.Image, { src, style: [styles2.image, style] });
|
|
336
|
-
};
|
|
337
|
-
var Img_default = Img;
|
|
338
|
-
|
|
339
|
-
// src/components/core/Position.tsx
|
|
340
|
-
var import_react3 = __toESM(require("react"), 1);
|
|
341
|
-
var import_renderer3 = require("@react-pdf/renderer");
|
|
342
|
-
var styles3 = import_renderer3.StyleSheet.create({
|
|
343
|
-
left: {
|
|
344
|
-
textAlign: "left"
|
|
345
|
-
},
|
|
346
|
-
right: {
|
|
347
|
-
textAlign: "right"
|
|
348
|
-
},
|
|
349
|
-
center: {
|
|
350
|
-
textAlign: "center"
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
var Left = ({ children, style }) => {
|
|
354
|
-
return /* @__PURE__ */ import_react3.default.createElement(import_renderer3.View, { style: [styles3.left, style] }, children);
|
|
355
|
-
};
|
|
356
|
-
var Right = ({ children, style }) => {
|
|
357
|
-
return /* @__PURE__ */ import_react3.default.createElement(import_renderer3.View, { style: [styles3.right, style] }, children);
|
|
358
|
-
};
|
|
359
|
-
var Center = ({ children, style }) => {
|
|
360
|
-
return /* @__PURE__ */ import_react3.default.createElement(import_renderer3.View, { style: [styles3.center, style] }, children);
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
// src/components/core/Etiquetas.tsx
|
|
364
|
-
var import_react4 = __toESM(require("react"), 1);
|
|
365
|
-
var import_renderer4 = require("@react-pdf/renderer");
|
|
366
|
-
var styles4 = import_renderer4.StyleSheet.create({
|
|
367
|
-
p: {
|
|
368
|
-
fontSize: 12,
|
|
369
|
-
marginBottom: 5,
|
|
370
|
-
lineHeight: 1.2
|
|
371
|
-
},
|
|
372
|
-
h1: {
|
|
373
|
-
fontSize: 24,
|
|
374
|
-
fontWeight: "bold",
|
|
375
|
-
marginBottom: 12
|
|
376
|
-
},
|
|
377
|
-
h2: {
|
|
378
|
-
fontSize: 20,
|
|
379
|
-
fontWeight: "bold",
|
|
380
|
-
marginBottom: 10
|
|
381
|
-
},
|
|
382
|
-
h3: {
|
|
383
|
-
fontSize: 18,
|
|
384
|
-
fontWeight: "bold",
|
|
385
|
-
marginBottom: 8
|
|
386
|
-
},
|
|
387
|
-
h4: {
|
|
388
|
-
fontSize: 16,
|
|
389
|
-
fontWeight: "bold",
|
|
390
|
-
marginBottom: 6
|
|
391
|
-
},
|
|
392
|
-
h5: {
|
|
393
|
-
fontSize: 14,
|
|
394
|
-
fontWeight: "bold",
|
|
395
|
-
marginBottom: 4
|
|
396
|
-
},
|
|
397
|
-
h6: {
|
|
398
|
-
fontSize: 12,
|
|
399
|
-
fontWeight: "bold",
|
|
400
|
-
marginBottom: 0
|
|
401
|
-
},
|
|
402
|
-
strong: {
|
|
403
|
-
fontWeight: "bold"
|
|
404
|
-
},
|
|
405
|
-
em: {
|
|
406
|
-
fontStyle: "italic"
|
|
407
|
-
},
|
|
408
|
-
u: {
|
|
409
|
-
textDecoration: "underline"
|
|
410
|
-
},
|
|
411
|
-
small: {
|
|
412
|
-
fontSize: 10
|
|
413
|
-
},
|
|
414
|
-
blockquote: {
|
|
415
|
-
marginLeft: 20,
|
|
416
|
-
marginRight: 20,
|
|
417
|
-
fontStyle: "italic",
|
|
418
|
-
borderLeft: "4px solid #ccc",
|
|
419
|
-
paddingLeft: 10
|
|
420
|
-
},
|
|
421
|
-
mark: {
|
|
422
|
-
backgroundColor: "yellow"
|
|
423
|
-
},
|
|
424
|
-
A: {
|
|
425
|
-
color: "#3d65fd",
|
|
426
|
-
textDecoration: "none"
|
|
427
|
-
},
|
|
428
|
-
br: {
|
|
429
|
-
width: "100%",
|
|
430
|
-
height: 1,
|
|
431
|
-
marginTop: 7,
|
|
432
|
-
marginBottom: 7
|
|
433
|
-
},
|
|
434
|
-
header: {
|
|
435
|
-
position: "absolute",
|
|
436
|
-
top: 20,
|
|
437
|
-
left: 0,
|
|
438
|
-
right: 0,
|
|
439
|
-
textAlign: "center",
|
|
440
|
-
fontSize: 10,
|
|
441
|
-
color: "#666",
|
|
442
|
-
paddingHorizontal: 40
|
|
443
|
-
},
|
|
444
|
-
hr: {
|
|
445
|
-
width: "100%",
|
|
446
|
-
borderTop: "1px solid #000",
|
|
447
|
-
marginTop: 8,
|
|
448
|
-
marginBottom: 8
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
var P = ({ children, style }) => {
|
|
452
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [styles4.p, style] }, children);
|
|
453
|
-
};
|
|
454
|
-
var H1 = ({ children, style }) => {
|
|
455
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [styles4.h1, style] }, children);
|
|
456
|
-
};
|
|
457
|
-
var H2 = ({ children, style }) => {
|
|
458
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [styles4.h2, style] }, children);
|
|
459
|
-
};
|
|
460
|
-
var H3 = ({ children, style }) => {
|
|
461
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [styles4.h3, style] }, children);
|
|
462
|
-
};
|
|
463
|
-
var H4 = ({ children, style }) => {
|
|
464
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [styles4.h4, style] }, children);
|
|
465
|
-
};
|
|
466
|
-
var H5 = ({ children, style }) => {
|
|
467
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [styles4.h5, style] }, children);
|
|
468
|
-
};
|
|
469
|
-
var H6 = ({ children, style }) => {
|
|
470
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [styles4.h6, style] }, children);
|
|
471
|
-
};
|
|
472
|
-
var Strong = ({ children, style }) => {
|
|
473
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [styles4.strong, style] }, children);
|
|
474
|
-
};
|
|
475
|
-
var Em = ({ children, style }) => {
|
|
476
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [styles4.em, style] }, children);
|
|
477
|
-
};
|
|
478
|
-
var U = ({ children, style }) => {
|
|
479
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [styles4.u, style] }, children);
|
|
480
|
-
};
|
|
481
|
-
var Small = ({ children, style }) => {
|
|
482
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [styles4.small, style] }, children);
|
|
483
|
-
};
|
|
484
|
-
var Blockquote = ({ children, style }) => {
|
|
485
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [styles4.blockquote, style] }, children);
|
|
486
|
-
};
|
|
487
|
-
var Mark = ({ children, style }) => {
|
|
488
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [styles4.mark, style] }, children);
|
|
489
|
-
};
|
|
490
|
-
var A = ({ children, style, href }) => {
|
|
491
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Link, { src: href, style: [styles4.A, style] }, children);
|
|
492
|
-
};
|
|
493
|
-
var BR = ({ style }) => {
|
|
494
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [styles4.br, style] }, "\n");
|
|
495
|
-
};
|
|
496
|
-
var HR = ({ style }) => {
|
|
497
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.View, { style: [styles4.hr, style] });
|
|
498
|
-
};
|
|
499
|
-
var Span = ({ children, style }) => {
|
|
500
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, { style: [style] }, children);
|
|
501
|
-
};
|
|
502
|
-
var Header = ({ children, style, fixed = false }) => {
|
|
503
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.View, { style: [styles4.header, style], fixed }, typeof children === "string" ? /* @__PURE__ */ import_react4.default.createElement(import_renderer4.Text, null, children) : children);
|
|
504
|
-
};
|
|
505
|
-
var Div = ({ children, style }) => {
|
|
506
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_renderer4.View, { style }, children);
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
// src/components/core/Tablet.tsx
|
|
510
|
-
var import_react5 = __toESM(require("react"), 1);
|
|
511
|
-
var import_renderer5 = require("@react-pdf/renderer");
|
|
512
|
-
var TableContext = (0, import_react5.createContext)({
|
|
513
|
-
cellHeight: 22,
|
|
514
|
-
textAlign: "left"
|
|
515
|
-
});
|
|
516
|
-
var styles5 = import_renderer5.StyleSheet.create({
|
|
517
|
-
table: {
|
|
518
|
-
width: "100%",
|
|
519
|
-
borderWidth: 1,
|
|
520
|
-
borderColor: "#000",
|
|
521
|
-
marginBottom: 20
|
|
522
|
-
},
|
|
523
|
-
thead: {
|
|
524
|
-
backgroundColor: "#ccc"
|
|
525
|
-
},
|
|
526
|
-
tr: {
|
|
527
|
-
flexDirection: "row"
|
|
528
|
-
},
|
|
529
|
-
textBold: {
|
|
530
|
-
fontSize: 10,
|
|
531
|
-
fontFamily: "Helvetica",
|
|
532
|
-
fontWeight: "bold",
|
|
533
|
-
paddingLeft: 8,
|
|
534
|
-
paddingRight: 8,
|
|
535
|
-
justifyContent: "center"
|
|
536
|
-
},
|
|
537
|
-
text: {
|
|
538
|
-
fontSize: 10,
|
|
539
|
-
fontFamily: "Helvetica",
|
|
540
|
-
paddingLeft: 8,
|
|
541
|
-
paddingRight: 8,
|
|
542
|
-
justifyContent: "center"
|
|
543
|
-
},
|
|
544
|
-
zebraOdd: {
|
|
545
|
-
backgroundColor: "#eeeeee"
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
var Table = ({ children, style, cellHeight = 22 }) => /* @__PURE__ */ import_react5.default.createElement(TableContext.Provider, { value: { cellHeight, textAlign: "left" } }, /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.table, style] }, children));
|
|
549
|
-
var Thead = ({
|
|
550
|
-
children,
|
|
551
|
-
style,
|
|
552
|
-
textAlign = "left"
|
|
553
|
-
}) => {
|
|
554
|
-
const { cellHeight } = (0, import_react5.useContext)(TableContext);
|
|
555
|
-
return /* @__PURE__ */ import_react5.default.createElement(TableContext.Provider, { value: { cellHeight, textAlign } }, /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.thead, style] }, children));
|
|
556
|
-
};
|
|
557
|
-
var Tbody = ({ children, style }) => {
|
|
558
|
-
const rows = import_react5.default.Children.toArray(children);
|
|
559
|
-
const count = rows.length;
|
|
560
|
-
return /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, rows.map(
|
|
561
|
-
(row, idx) => import_react5.default.cloneElement(row, {
|
|
562
|
-
isLastRow: idx === count - 1,
|
|
563
|
-
isOdd: idx % 2 === 1
|
|
564
|
-
})
|
|
565
|
-
));
|
|
566
|
-
};
|
|
567
|
-
var Tr = ({
|
|
568
|
-
children,
|
|
569
|
-
style,
|
|
570
|
-
isLastRow = false,
|
|
571
|
-
isOdd = false
|
|
572
|
-
}) => {
|
|
573
|
-
const elements = import_react5.default.Children.toArray(
|
|
574
|
-
children
|
|
575
|
-
);
|
|
576
|
-
const count = elements.length;
|
|
577
|
-
return /* @__PURE__ */ import_react5.default.createElement(import_renderer5.View, { style: [styles5.tr, style] }, elements.map((child, idx) => {
|
|
578
|
-
const isLast = idx === count - 1;
|
|
579
|
-
const width = `${(100 / count).toFixed(2)}%`;
|
|
580
|
-
return import_react5.default.cloneElement(child, { width, isLast, isLastRow, isOdd });
|
|
581
|
-
}));
|
|
582
|
-
};
|
|
583
|
-
var Th = ({
|
|
584
|
-
children,
|
|
585
|
-
style,
|
|
586
|
-
width,
|
|
587
|
-
height,
|
|
588
|
-
colSpan,
|
|
589
|
-
isLast = false,
|
|
590
|
-
isLastRow = false,
|
|
591
|
-
textAlign: propTextAlign
|
|
592
|
-
}) => {
|
|
593
|
-
const { cellHeight, textAlign: contextTextAlign } = (0, import_react5.useContext)(TableContext);
|
|
594
|
-
const finalTextAlign = propTextAlign || contextTextAlign || "left";
|
|
595
|
-
const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
|
|
596
|
-
const cellHeightValue = height !== void 0 ? height : cellHeight;
|
|
597
|
-
const borders = {
|
|
598
|
-
borderRightWidth: isLast ? 0 : 1,
|
|
599
|
-
borderBottomWidth: isLastRow ? 0 : 1,
|
|
600
|
-
borderColor: "#000",
|
|
601
|
-
minHeight: cellHeightValue
|
|
602
|
-
};
|
|
603
|
-
return /* @__PURE__ */ import_react5.default.createElement(
|
|
604
|
-
import_renderer5.View,
|
|
605
|
-
{
|
|
606
|
-
style: [
|
|
607
|
-
styles5.textBold,
|
|
608
|
-
{
|
|
609
|
-
width: baseWidth
|
|
610
|
-
},
|
|
611
|
-
borders,
|
|
612
|
-
style
|
|
613
|
-
]
|
|
614
|
-
},
|
|
615
|
-
/* @__PURE__ */ import_react5.default.createElement(import_renderer5.Text, { style: { textAlign: finalTextAlign } }, children)
|
|
616
|
-
);
|
|
617
|
-
};
|
|
618
|
-
var Td = ({
|
|
619
|
-
children,
|
|
620
|
-
style,
|
|
621
|
-
width,
|
|
622
|
-
height,
|
|
623
|
-
colSpan,
|
|
624
|
-
isLast = false,
|
|
625
|
-
isLastRow = false,
|
|
626
|
-
isOdd = false,
|
|
627
|
-
textAlign: propTextAlign
|
|
628
|
-
}) => {
|
|
629
|
-
const { cellHeight, textAlign: contextTextAlign } = (0, import_react5.useContext)(TableContext);
|
|
630
|
-
const finalTextAlign = propTextAlign || contextTextAlign || "left";
|
|
631
|
-
const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
|
|
632
|
-
const cellHeightValue = height !== void 0 ? height : cellHeight;
|
|
633
|
-
const borders = {
|
|
634
|
-
borderRightWidth: isLast ? 0 : 1,
|
|
635
|
-
borderBottomWidth: isLastRow ? 0 : 1,
|
|
636
|
-
borderColor: "#000",
|
|
637
|
-
minHeight: cellHeightValue
|
|
638
|
-
};
|
|
639
|
-
return /* @__PURE__ */ import_react5.default.createElement(
|
|
640
|
-
import_renderer5.View,
|
|
641
|
-
{
|
|
642
|
-
style: [
|
|
643
|
-
styles5.text,
|
|
644
|
-
isOdd && styles5.zebraOdd,
|
|
645
|
-
{
|
|
646
|
-
width: baseWidth
|
|
647
|
-
},
|
|
648
|
-
borders,
|
|
649
|
-
style
|
|
650
|
-
]
|
|
651
|
-
},
|
|
652
|
-
/* @__PURE__ */ import_react5.default.createElement(import_renderer5.Text, { style: { textAlign: finalTextAlign } }, children)
|
|
653
|
-
);
|
|
654
|
-
};
|
|
655
|
-
|
|
656
|
-
// src/components/core/Grid.tsx
|
|
657
|
-
var import_react6 = __toESM(require("react"), 1);
|
|
658
|
-
var import_renderer6 = require("@react-pdf/renderer");
|
|
659
|
-
var styles6 = import_renderer6.StyleSheet.create({
|
|
660
|
-
container: {
|
|
661
|
-
width: "100%",
|
|
662
|
-
paddingHorizontal: 20
|
|
663
|
-
},
|
|
664
|
-
row: {
|
|
665
|
-
flexDirection: "row",
|
|
666
|
-
flexWrap: "wrap",
|
|
667
|
-
marginHorizontal: -5
|
|
668
|
-
},
|
|
669
|
-
col: {
|
|
670
|
-
paddingHorizontal: 5
|
|
671
|
-
},
|
|
672
|
-
col1: { width: "8.33%" },
|
|
673
|
-
col2: { width: "16.66%" },
|
|
674
|
-
col3: { width: "25%" },
|
|
675
|
-
col4: { width: "33.33%" },
|
|
676
|
-
col5: { width: "41.66%" },
|
|
677
|
-
col6: { width: "50%" },
|
|
678
|
-
col7: { width: "58.33%" },
|
|
679
|
-
col8: { width: "66.66%" },
|
|
680
|
-
col9: { width: "75%" },
|
|
681
|
-
col10: { width: "83.33%" },
|
|
682
|
-
col11: { width: "91.66%" },
|
|
683
|
-
col12: { width: "100%" }
|
|
684
|
-
});
|
|
685
|
-
var Container = ({ children, style }) => {
|
|
686
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_renderer6.View, { style: [styles6.container, style] }, children);
|
|
687
|
-
};
|
|
688
|
-
var Row = ({ children, style }) => {
|
|
689
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_renderer6.View, { style: [styles6.row, style] }, children);
|
|
690
|
-
};
|
|
691
|
-
var Col1 = ({ children, style }) => {
|
|
692
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_renderer6.View, { style: [styles6.col, styles6.col1, style] }, children);
|
|
693
|
-
};
|
|
694
|
-
var Col2 = ({ children, style }) => {
|
|
695
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_renderer6.View, { style: [styles6.col, styles6.col2, style] }, children);
|
|
696
|
-
};
|
|
697
|
-
var Col3 = ({ children, style }) => {
|
|
698
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_renderer6.View, { style: [styles6.col, styles6.col3, style] }, children);
|
|
699
|
-
};
|
|
700
|
-
var Col4 = ({ children, style }) => {
|
|
701
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_renderer6.View, { style: [styles6.col, styles6.col4, style] }, children);
|
|
702
|
-
};
|
|
703
|
-
var Col5 = ({ children, style }) => {
|
|
704
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_renderer6.View, { style: [styles6.col, styles6.col5, style] }, children);
|
|
705
|
-
};
|
|
706
|
-
var Col6 = ({ children, style }) => {
|
|
707
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_renderer6.View, { style: [styles6.col, styles6.col6, style] }, children);
|
|
708
|
-
};
|
|
709
|
-
var Col7 = ({ children, style }) => {
|
|
710
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_renderer6.View, { style: [styles6.col, styles6.col7, style] }, children);
|
|
711
|
-
};
|
|
712
|
-
var Col8 = ({ children, style }) => {
|
|
713
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_renderer6.View, { style: [styles6.col, styles6.col8, style] }, children);
|
|
714
|
-
};
|
|
715
|
-
var Col9 = ({ children, style }) => {
|
|
716
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_renderer6.View, { style: [styles6.col, styles6.col9, style] }, children);
|
|
717
|
-
};
|
|
718
|
-
var Col10 = ({ children, style }) => {
|
|
719
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_renderer6.View, { style: [styles6.col, styles6.col10, style] }, children);
|
|
720
|
-
};
|
|
721
|
-
var Col11 = ({ children, style }) => {
|
|
722
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_renderer6.View, { style: [styles6.col, styles6.col11, style] }, children);
|
|
723
|
-
};
|
|
724
|
-
var Col12 = ({ children, style }) => {
|
|
725
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_renderer6.View, { style: [styles6.col, styles6.col12, style] }, children);
|
|
726
|
-
};
|
|
727
|
-
|
|
728
|
-
// src/components/core/QR.tsx
|
|
729
|
-
var import_react7 = __toESM(require("react"), 1);
|
|
730
|
-
var import_renderer7 = require("@react-pdf/renderer");
|
|
731
|
-
var import_react8 = require("react");
|
|
732
|
-
|
|
733
|
-
// src/components/core/QRGenerator.tsx
|
|
734
|
-
var import_qrcode = __toESM(require("qrcode"), 1);
|
|
735
|
-
var generateQRAsBase64 = async ({
|
|
736
|
-
value,
|
|
737
|
-
size = 150,
|
|
738
|
-
colorDark = "#000000",
|
|
739
|
-
colorLight = "#ffffff",
|
|
740
|
-
margin = 0,
|
|
741
|
-
errorCorrectionLevel = "M"
|
|
742
|
-
}) => {
|
|
743
|
-
try {
|
|
744
|
-
const options = {
|
|
745
|
-
errorCorrectionLevel,
|
|
746
|
-
type: "image/png",
|
|
747
|
-
quality: 0.92,
|
|
748
|
-
margin,
|
|
749
|
-
color: {
|
|
750
|
-
dark: colorDark,
|
|
751
|
-
light: colorLight
|
|
752
|
-
},
|
|
753
|
-
width: size
|
|
754
|
-
};
|
|
755
|
-
const qrDataUrl = import_qrcode.default.toDataURL(value, options);
|
|
756
|
-
return qrDataUrl;
|
|
757
|
-
} catch (error) {
|
|
758
|
-
console.error("Error generando QR:", error);
|
|
759
|
-
return "";
|
|
760
|
-
}
|
|
761
|
-
};
|
|
762
|
-
var addLogoToQR = async (qrDataUrl, logoUrl, logoWidth, logoHeight) => {
|
|
763
|
-
return new Promise((resolve) => {
|
|
764
|
-
if (!qrDataUrl || !logoUrl) {
|
|
765
|
-
resolve(qrDataUrl);
|
|
766
|
-
return;
|
|
767
|
-
}
|
|
768
|
-
try {
|
|
769
|
-
const canvas = document.createElement("canvas");
|
|
770
|
-
const ctx = canvas.getContext("2d");
|
|
771
|
-
if (!ctx) {
|
|
772
|
-
resolve(qrDataUrl);
|
|
773
|
-
return;
|
|
774
|
-
}
|
|
775
|
-
const qrImage = new Image();
|
|
776
|
-
qrImage.crossOrigin = "anonymous";
|
|
777
|
-
qrImage.onload = () => {
|
|
778
|
-
canvas.width = qrImage.width;
|
|
779
|
-
canvas.height = qrImage.height;
|
|
780
|
-
ctx.drawImage(qrImage, 0, 0, canvas.width, canvas.height);
|
|
781
|
-
const logoImage = new Image();
|
|
782
|
-
logoImage.crossOrigin = "anonymous";
|
|
783
|
-
logoImage.onload = () => {
|
|
784
|
-
const x = (canvas.width - logoWidth) / 2;
|
|
785
|
-
const y = (canvas.height - logoHeight) / 2;
|
|
786
|
-
ctx.fillStyle = "#FFFFFF";
|
|
787
|
-
ctx.fillRect(x - 5, y - 5, logoWidth + 10, logoHeight + 10);
|
|
788
|
-
ctx.drawImage(logoImage, x, y, logoWidth, logoHeight);
|
|
789
|
-
const finalQrDataUrl = canvas.toDataURL("image/png");
|
|
790
|
-
resolve(finalQrDataUrl);
|
|
791
|
-
};
|
|
792
|
-
logoImage.onerror = () => {
|
|
793
|
-
console.error("Error cargando el logo");
|
|
794
|
-
resolve(qrDataUrl);
|
|
795
|
-
};
|
|
796
|
-
logoImage.src = logoUrl;
|
|
797
|
-
};
|
|
798
|
-
qrImage.onerror = () => {
|
|
799
|
-
console.error("Error cargando el QR");
|
|
800
|
-
resolve("");
|
|
801
|
-
};
|
|
802
|
-
qrImage.src = qrDataUrl;
|
|
803
|
-
} catch (error) {
|
|
804
|
-
console.error("Error procesando el QR con logo:", error);
|
|
805
|
-
resolve(qrDataUrl);
|
|
806
|
-
}
|
|
807
|
-
});
|
|
808
|
-
};
|
|
809
|
-
|
|
810
|
-
// src/components/core/QR.tsx
|
|
811
|
-
var styles7 = import_renderer7.StyleSheet.create({
|
|
812
|
-
qrContainer: {
|
|
813
|
-
display: "flex",
|
|
814
|
-
alignItems: "center",
|
|
815
|
-
justifyContent: "center",
|
|
816
|
-
margin: 10
|
|
817
|
-
}
|
|
818
|
-
});
|
|
819
|
-
var errorLevelMap = {
|
|
820
|
-
0: "L",
|
|
821
|
-
1: "M",
|
|
822
|
-
2: "Q",
|
|
823
|
-
3: "H"
|
|
824
|
-
};
|
|
825
|
-
var QR = ({
|
|
826
|
-
value,
|
|
827
|
-
size = 150,
|
|
828
|
-
style,
|
|
829
|
-
colorDark = "#000000",
|
|
830
|
-
colorLight = "#ffffff",
|
|
831
|
-
margin = 0,
|
|
832
|
-
logo = "",
|
|
833
|
-
logoWidth = 30,
|
|
834
|
-
logoHeight = 30,
|
|
835
|
-
errorCorrectionLevel = logo ? "H" : "M"
|
|
836
|
-
}) => {
|
|
837
|
-
const [qrDataUrl, setQrDataUrl] = (0, import_react8.useState)("");
|
|
838
|
-
(0, import_react8.useEffect)(() => {
|
|
839
|
-
const generateQR = async () => {
|
|
840
|
-
try {
|
|
841
|
-
const baseQrDataUrl = await generateQRAsBase64({
|
|
842
|
-
value,
|
|
843
|
-
size,
|
|
844
|
-
colorDark,
|
|
845
|
-
colorLight,
|
|
846
|
-
margin,
|
|
847
|
-
errorCorrectionLevel: typeof errorCorrectionLevel === "number" ? errorLevelMap[errorCorrectionLevel] || "M" : errorCorrectionLevel
|
|
848
|
-
});
|
|
849
|
-
if (logo && logoWidth && logoHeight) {
|
|
850
|
-
const qrWithLogo = await addLogoToQR(baseQrDataUrl, logo, logoWidth, logoHeight);
|
|
851
|
-
setQrDataUrl(qrWithLogo);
|
|
852
|
-
} else {
|
|
853
|
-
setQrDataUrl(baseQrDataUrl);
|
|
854
|
-
}
|
|
855
|
-
} catch (error) {
|
|
856
|
-
console.error("Error generando QR:", error);
|
|
857
|
-
const fallbackUrl2 = `https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(
|
|
858
|
-
value
|
|
859
|
-
)}&size=${size}x${size}&color=${encodeURIComponent(colorDark.replace("#", ""))}&bgcolor=${encodeURIComponent(
|
|
860
|
-
colorLight.replace("#", "")
|
|
861
|
-
)}`;
|
|
862
|
-
setQrDataUrl(fallbackUrl2);
|
|
863
|
-
}
|
|
864
|
-
};
|
|
865
|
-
generateQR();
|
|
866
|
-
}, [value, size, colorDark, colorLight, margin, logo, logoWidth, logoHeight, errorCorrectionLevel]);
|
|
867
|
-
const fallbackUrl = `https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(
|
|
868
|
-
value
|
|
869
|
-
)}&size=${size}x${size}`;
|
|
870
|
-
return /* @__PURE__ */ import_react7.default.createElement(import_renderer7.View, { style: [styles7.qrContainer, style] }, /* @__PURE__ */ import_react7.default.createElement(import_renderer7.Image, { src: qrDataUrl || fallbackUrl, style: { width: size, height: size } }));
|
|
871
|
-
};
|
|
872
|
-
var QR_default = QR;
|
|
873
|
-
|
|
874
|
-
// src/components/core/Lista.tsx
|
|
875
|
-
var import_react9 = __toESM(require("react"), 1);
|
|
876
|
-
var import_renderer8 = require("@react-pdf/renderer");
|
|
877
|
-
var styles8 = import_renderer8.StyleSheet.create({
|
|
878
|
-
ul: {
|
|
879
|
-
marginBottom: 10,
|
|
880
|
-
paddingLeft: 15
|
|
881
|
-
},
|
|
882
|
-
ol: {
|
|
883
|
-
marginBottom: 10,
|
|
884
|
-
paddingLeft: 15
|
|
885
|
-
},
|
|
886
|
-
li: {
|
|
887
|
-
marginBottom: 5,
|
|
888
|
-
flexDirection: "row"
|
|
889
|
-
},
|
|
890
|
-
bulletPoint: {
|
|
891
|
-
width: 15,
|
|
892
|
-
marginRight: 5,
|
|
893
|
-
fontSize: 12
|
|
894
|
-
},
|
|
895
|
-
itemContent: {
|
|
896
|
-
flex: 1
|
|
897
|
-
}
|
|
898
|
-
});
|
|
899
|
-
var getBulletPoint = (type = "disc") => {
|
|
900
|
-
switch (type) {
|
|
901
|
-
case "circle":
|
|
902
|
-
return "\u25CB";
|
|
903
|
-
case "square":
|
|
904
|
-
return "\u25A0";
|
|
905
|
-
case "disc":
|
|
906
|
-
default:
|
|
907
|
-
return "\u2022";
|
|
908
|
-
}
|
|
909
|
-
};
|
|
910
|
-
var getOrderedMarker = (index, type = "decimal", start = 1) => {
|
|
911
|
-
const actualIndex = start + index - 1;
|
|
912
|
-
switch (type) {
|
|
913
|
-
case "lower-alpha":
|
|
914
|
-
return String.fromCharCode(97 + actualIndex % 26) + ".";
|
|
915
|
-
case "upper-alpha":
|
|
916
|
-
return String.fromCharCode(65 + actualIndex % 26) + ".";
|
|
917
|
-
case "lower-roman":
|
|
918
|
-
return toRoman(actualIndex).toLowerCase() + ".";
|
|
919
|
-
case "upper-roman":
|
|
920
|
-
return toRoman(actualIndex) + ".";
|
|
921
|
-
case "decimal":
|
|
922
|
-
default:
|
|
923
|
-
return actualIndex + ".";
|
|
924
|
-
}
|
|
925
|
-
};
|
|
926
|
-
var toRoman = (num) => {
|
|
927
|
-
if (num <= 0 || num > 3999) return String(num);
|
|
928
|
-
const romanNumerals = [
|
|
929
|
-
["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"],
|
|
930
|
-
["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"],
|
|
931
|
-
["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"],
|
|
932
|
-
["", "M", "MM", "MMM"]
|
|
933
|
-
];
|
|
934
|
-
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];
|
|
935
|
-
};
|
|
936
|
-
var UL = ({ children, style, type = "disc" }) => {
|
|
937
|
-
const childrenWithBullets = import_react9.default.Children.map(children, (child, index) => {
|
|
938
|
-
if (import_react9.default.isValidElement(child)) {
|
|
939
|
-
return import_react9.default.cloneElement(child, {
|
|
940
|
-
bulletType: type,
|
|
941
|
-
isOrdered: false,
|
|
942
|
-
index: index + 1
|
|
943
|
-
});
|
|
944
|
-
}
|
|
945
|
-
return child;
|
|
946
|
-
});
|
|
947
|
-
return /* @__PURE__ */ import_react9.default.createElement(import_renderer8.View, { style: [styles8.ul, style] }, childrenWithBullets);
|
|
948
|
-
};
|
|
949
|
-
var OL = ({ children, style, type = "decimal", start = 1 }) => {
|
|
950
|
-
const childrenWithNumbers = import_react9.default.Children.map(children, (child, index) => {
|
|
951
|
-
if (import_react9.default.isValidElement(child)) {
|
|
952
|
-
return import_react9.default.cloneElement(child, {
|
|
953
|
-
bulletType: type,
|
|
954
|
-
isOrdered: true,
|
|
955
|
-
index: index + 1,
|
|
956
|
-
start
|
|
957
|
-
});
|
|
958
|
-
}
|
|
959
|
-
return child;
|
|
960
|
-
});
|
|
961
|
-
return /* @__PURE__ */ import_react9.default.createElement(import_renderer8.View, { style: [styles8.ol, style] }, childrenWithNumbers);
|
|
962
|
-
};
|
|
963
|
-
var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1, start = 1, value }) => {
|
|
964
|
-
let marker;
|
|
965
|
-
if (isOrdered) {
|
|
966
|
-
const actualIndex = value !== void 0 ? Number(value) : index;
|
|
967
|
-
marker = getOrderedMarker(actualIndex, bulletType, start);
|
|
968
|
-
} else {
|
|
969
|
-
marker = getBulletPoint(bulletType);
|
|
970
|
-
}
|
|
971
|
-
return /* @__PURE__ */ import_react9.default.createElement(import_renderer8.View, { style: [styles8.li, style] }, /* @__PURE__ */ import_react9.default.createElement(import_renderer8.Text, { style: styles8.bulletPoint }, marker), /* @__PURE__ */ import_react9.default.createElement(import_renderer8.View, { style: styles8.itemContent }, typeof children === "string" ? /* @__PURE__ */ import_react9.default.createElement(import_renderer8.Text, null, children) : children));
|
|
972
|
-
};
|
|
973
|
-
|
|
974
|
-
// src/components/core/index.tsx
|
|
975
|
-
var import_renderer12 = require("@react-pdf/renderer");
|
|
976
|
-
|
|
977
|
-
// src/functions/decodeBase64Pdf.ts
|
|
978
|
-
var decodeBase64Pdf = (base64, fileName) => {
|
|
979
|
-
const byteCharacters = atob(base64);
|
|
980
|
-
const byteNumbers = new Array(byteCharacters.length);
|
|
981
|
-
for (let i = 0; i < byteCharacters.length; i++) {
|
|
982
|
-
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
|
983
|
-
}
|
|
984
|
-
const byteArray = new Uint8Array(byteNumbers);
|
|
985
|
-
const blob = new Blob([byteArray], { type: "application/pdf" });
|
|
986
|
-
const blobUrl = URL.createObjectURL(blob);
|
|
987
|
-
if (document === void 0) {
|
|
988
|
-
console.error("document is undefined, only works in browser context");
|
|
989
|
-
return;
|
|
990
|
-
}
|
|
991
|
-
const link = document.createElement("a");
|
|
992
|
-
link.href = blobUrl;
|
|
993
|
-
link.download = fileName;
|
|
994
|
-
document.body.appendChild(link);
|
|
995
|
-
link.click();
|
|
996
|
-
document.body.removeChild(link);
|
|
997
|
-
window.open(blobUrl, "_blank");
|
|
998
|
-
setTimeout(() => {
|
|
999
|
-
URL.revokeObjectURL(blobUrl);
|
|
1000
|
-
}, 100);
|
|
1001
|
-
};
|
|
1002
|
-
var decodeBase64Pdf_default = decodeBase64Pdf;
|
|
1003
|
-
|
|
1004
|
-
// src/functions/generatePDF.ts
|
|
1005
|
-
var import_renderer9 = require("@react-pdf/renderer");
|
|
1006
|
-
var import_react10 = require("react");
|
|
1007
|
-
var generatePDF = async ({ template: Template, data }) => {
|
|
1008
|
-
try {
|
|
1009
|
-
if (!Template) {
|
|
1010
|
-
throw new Error("Template not provided");
|
|
1011
|
-
}
|
|
1012
|
-
const MyDocument = (0, import_react10.createElement)(Template, { data });
|
|
1013
|
-
const stream = await (0, import_renderer9.renderToStream)(MyDocument);
|
|
1014
|
-
const base64String = await new Promise((resolve, reject) => {
|
|
1015
|
-
const chunks = [];
|
|
1016
|
-
stream.on("data", (chunk) => chunks.push(chunk));
|
|
1017
|
-
stream.on("end", () => resolve(Buffer.concat(chunks).toString("base64")));
|
|
1018
|
-
stream.on("error", (error) => reject(error));
|
|
1019
|
-
});
|
|
1020
|
-
return base64String;
|
|
1021
|
-
} catch (error) {
|
|
1022
|
-
throw new Error("Error generating PDF: " + (error instanceof Error ? error.message : "Unknown error"));
|
|
1023
|
-
}
|
|
1024
|
-
};
|
|
1025
|
-
var generatePDF_default = generatePDF;
|
|
1026
|
-
|
|
1027
|
-
// src/functions/index.ts
|
|
1028
|
-
var import_renderer10 = require("@react-pdf/renderer");
|
|
1029
|
-
|
|
1030
|
-
// src/components/core/ImgBg.tsx
|
|
1031
|
-
var import_react11 = __toESM(require("react"), 1);
|
|
1032
|
-
var import_renderer11 = require("@react-pdf/renderer");
|
|
1033
|
-
var styles9 = import_renderer11.StyleSheet.create({
|
|
1034
|
-
container: {
|
|
1035
|
-
position: "relative",
|
|
1036
|
-
width: "100%",
|
|
1037
|
-
height: "100%"
|
|
1038
|
-
},
|
|
1039
|
-
background: {
|
|
1040
|
-
position: "absolute",
|
|
1041
|
-
top: 0,
|
|
1042
|
-
left: 0,
|
|
1043
|
-
right: 0,
|
|
1044
|
-
bottom: 0
|
|
1045
|
-
},
|
|
1046
|
-
content: {
|
|
1047
|
-
position: "relative"
|
|
1048
|
-
}
|
|
1049
|
-
});
|
|
1050
|
-
var ImgBg = ({
|
|
1051
|
-
src,
|
|
1052
|
-
width = "100%",
|
|
1053
|
-
height = "100%",
|
|
1054
|
-
opacity = 0.2,
|
|
1055
|
-
children,
|
|
1056
|
-
style,
|
|
1057
|
-
fixed = false,
|
|
1058
|
-
objectFit = "cover",
|
|
1059
|
-
objectPosition = "center"
|
|
1060
|
-
}) => {
|
|
1061
|
-
return /* @__PURE__ */ import_react11.default.createElement(import_renderer11.View, { style: [styles9.container, style] }, /* @__PURE__ */ import_react11.default.createElement(
|
|
1062
|
-
import_renderer11.Image,
|
|
1063
|
-
{
|
|
1064
|
-
src,
|
|
1065
|
-
style: [
|
|
1066
|
-
styles9.background,
|
|
1067
|
-
{ width, height, opacity, objectFit, objectPosition }
|
|
1068
|
-
],
|
|
1069
|
-
fixed
|
|
1070
|
-
}
|
|
1071
|
-
), /* @__PURE__ */ import_react11.default.createElement(import_renderer11.View, { style: styles9.content }, children));
|
|
1072
|
-
};
|
|
1073
|
-
var ImgBg_default = ImgBg;
|
|
1074
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
1075
|
-
0 && (module.exports = {
|
|
1076
|
-
A,
|
|
1077
|
-
BR,
|
|
1078
|
-
Blockquote,
|
|
1079
|
-
Center,
|
|
1080
|
-
Col1,
|
|
1081
|
-
Col10,
|
|
1082
|
-
Col11,
|
|
1083
|
-
Col12,
|
|
1084
|
-
Col2,
|
|
1085
|
-
Col3,
|
|
1086
|
-
Col4,
|
|
1087
|
-
Col5,
|
|
1088
|
-
Col6,
|
|
1089
|
-
Col7,
|
|
1090
|
-
Col8,
|
|
1091
|
-
Col9,
|
|
1092
|
-
Container,
|
|
1093
|
-
Div,
|
|
1094
|
-
Em,
|
|
1095
|
-
Font,
|
|
1096
|
-
H1,
|
|
1097
|
-
H2,
|
|
1098
|
-
H3,
|
|
1099
|
-
H4,
|
|
1100
|
-
H5,
|
|
1101
|
-
H6,
|
|
1102
|
-
HR,
|
|
1103
|
-
Header,
|
|
1104
|
-
Img,
|
|
1105
|
-
ImgBg,
|
|
1106
|
-
LI,
|
|
1107
|
-
LayoutPDF,
|
|
1108
|
-
Left,
|
|
1109
|
-
Mark,
|
|
1110
|
-
OL,
|
|
1111
|
-
P,
|
|
1112
|
-
QR,
|
|
1113
|
-
Right,
|
|
1114
|
-
Row,
|
|
1115
|
-
Small,
|
|
1116
|
-
Span,
|
|
1117
|
-
Strong,
|
|
1118
|
-
StyleSheet,
|
|
1119
|
-
Table,
|
|
1120
|
-
Tbody,
|
|
1121
|
-
Td,
|
|
1122
|
-
Text,
|
|
1123
|
-
Th,
|
|
1124
|
-
Thead,
|
|
1125
|
-
Tr,
|
|
1126
|
-
U,
|
|
1127
|
-
UL,
|
|
1128
|
-
View,
|
|
1129
|
-
decodeBase64Pdf,
|
|
1130
|
-
generatePDF,
|
|
1131
|
-
renderToStream
|
|
1132
|
-
});
|
|
1
|
+
'use strict';var renderer=require('@react-pdf/renderer'),O=require('react'),jsxRuntime=require('react/jsx-runtime'),Et=require('qrcode');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var O__default=/*#__PURE__*/_interopDefault(O);var Et__default=/*#__PURE__*/_interopDefault(Et);var ft=(e,t)=>{let o=atob(e),r=new Array(o.length);for(let d=0;d<o.length;d++)r[d]=o.charCodeAt(d);let a=new Uint8Array(r),i=new Blob([a],{type:"application/pdf"}),n=URL.createObjectURL(i);if(document===void 0){console.error("document is undefined, only works in browser context");return}let s=document.createElement("a");s.href=n,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),window.open(n,"_blank"),setTimeout(()=>{URL.revokeObjectURL(n);},100);},J=ft;var wt=async({template:e,data:t})=>{try{if(!e)throw new Error("Template not provided");let o=O.createElement(e,{data:t}),r=await renderer.renderToStream(o);return await new Promise((i,n)=>{let s=[];r.on("data",d=>s.push(d)),r.on("end",()=>i(Buffer.concat(s).toString("base64"))),r.on("error",d=>n(d));})}catch(o){throw new Error("Error generating PDF: "+(o instanceof Error?o.message:"Unknown error"))}},_=wt;var ie=renderer.StyleSheet.create({page:{backgroundColor:"white",padding:30,fontFamily:"Helvetica",fontSize:14},footer:{position:"absolute",left:0,right:0,textAlign:"center"}}),Pt=({children:e,size:t="A4",orientation:o="vertical",backgroundColor:r="white",padding:a=30,margen:i="normal",style:n={},pagination:s=true,footer:d,lines:l=d?2:1,rule:c=false})=>{let u=l*20+10,P=(y,F)=>{let T=F.toUpperCase();switch(y){case "apa":return T==="LETTER"||T==="LEGAL"?{paddingTop:72,paddingRight:72,paddingBottom:72,paddingLeft:72}:{paddingTop:72,paddingRight:72,paddingBottom:72,paddingLeft:72};case "estrecho":return {paddingTop:36,paddingRight:36,paddingBottom:36,paddingLeft:36};case "ancho":return {paddingTop:108,paddingRight:108,paddingBottom:108,paddingLeft:108};default:return {paddingTop:a,paddingRight:a,paddingBottom:a,paddingLeft:a}}},R=t,I=o,S=r,B=Math.max(1,Math.min(l,10)),U=i;try{typeof t=="string"&&!["A0","A1","A2","A3","A4","A5","A6","A7","A8","A9","LETTER","LEGAL","TABLOID"].includes(t.toUpperCase())&&(console.warn(`Invalid page size: ${t}. Using A4 as default.`),R="A4"),o!=="vertical"&&o!=="horizontal"&&(console.warn(`Invalid orientation: ${o}. Using vertical as default.`),I="vertical"),typeof r!="string"&&(console.warn(`Invalid background color: ${r}. Using white as default.`),S="white"),["apa","normal","estrecho","ancho"].includes(i)||(console.warn(`Invalid margin type: ${i}. Using normal as default.`),U="normal"),(typeof l!="number"||l<1)&&(console.warn(`Invalid lines value: ${l}. Using 1 as default.`),B=1);}catch(y){console.warn("Error processing props in LayoutPDF:",y);}let v=y=>{switch(y){case "vertical":case "portrait":case "v":return "portrait";case "horizontal":case "landscape":case "h":return "landscape";default:return console.warn(`Unrecognized orientation: ${y}. Using portrait as default.`),"portrait"}},gt=(y,F,T)=>{let G={A0:{width:841,height:1189},A1:{width:594,height:841},A2:{width:420,height:594},A3:{width:297,height:420},A4:{width:210,height:297},A5:{width:148,height:210},A6:{width:105,height:148},A7:{width:74,height:105},A8:{width:52,height:74},A9:{width:37,height:52},LETTER:{width:216,height:279},LEGAL:{width:216,height:356},TABLOID:{width:279,height:432}},q=2.834645669,A=G[y.toUpperCase()];if(!A)return F==="landscape"?595-T-10:842-T-10;let z=A.height*q,C=A.width*q;return F==="landscape"?C-T-10:z-T-10},N=v(I),ne=P(U,R),mt=gt(R,N,u),pt=()=>{if(!c)return null;let y=28.3465,F={A0:{width:841*2.834645669,height:1189*2.834645669},A1:{width:594*2.834645669,height:841*2.834645669},A2:{width:420*2.834645669,height:594*2.834645669},A3:{width:297*2.834645669,height:420*2.834645669},A4:{width:210*2.834645669,height:297*2.834645669},A5:{width:148*2.834645669,height:210*2.834645669},A6:{width:105*2.834645669,height:148*2.834645669},A7:{width:74*2.834645669,height:105*2.834645669},A8:{width:52*2.834645669,height:74*2.834645669},A9:{width:37*2.834645669,height:52*2.834645669},LETTER:{width:216*2.834645669,height:279*2.834645669},LEGAL:{width:216*2.834645669,height:356*2.834645669},TABLOID:{width:279*2.834645669,height:432*2.834645669}},T=F[R.toUpperCase()]||F.A4,G=N==="landscape"?T.height:T.width,q=N==="landscape"?T.width:T.height,A=[],z=[];for(let C=0;C<=Math.ceil(q/y);C++)A.push(jsxRuntime.jsx(renderer.View,{style:{position:"absolute",top:C*y,left:0,right:0,height:C%5===0?1:.5,backgroundColor:C%5===0?"rgba(255, 0, 0, 0.8)":"rgba(100, 100, 100, 0.5)"}},`h-${C}`));for(let C=0;C<=Math.ceil(G/y);C++)z.push(jsxRuntime.jsx(renderer.View,{style:{position:"absolute",left:C*y,top:0,bottom:0,width:C%5===0?1:.5,backgroundColor:C%5===0?"rgba(255, 0, 0, 0.8)":"rgba(100, 100, 100, 0.5)"}},`v-${C}`));return jsxRuntime.jsxs(renderer.View,{style:{position:"absolute",top:0,left:0,right:0,bottom:0},fixed:true,children:[A,z]})},ht={...ie.page,backgroundColor:S,...ne,paddingBottom:ne.paddingBottom+u,...n},ae={...ie.footer,top:mt,height:u,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",fontSize:10,color:"grey"};return jsxRuntime.jsx(renderer.Document,{children:jsxRuntime.jsxs(renderer.Page,{size:R,orientation:N,style:ht,wrap:true,children:[pt(),jsxRuntime.jsx(renderer.View,{style:{paddingBottom:u},children:e}),s?jsxRuntime.jsxs(renderer.View,{style:ae,fixed:true,children:[d,jsxRuntime.jsx(renderer.Text,{style:{fontSize:ae.fontSize},render:({pageNumber:y,totalPages:F})=>`${y} / ${F}`})]}):null]})})},se=Pt;var Lt=renderer.StyleSheet.create({image:{width:"100%",height:"auto",marginBottom:14}}),St=({src:e,style:t})=>jsxRuntime.jsx(renderer.Image,{src:e,style:[Lt.image,t]}),le=St;var Y=renderer.StyleSheet.create({left:{textAlign:"left"},right:{textAlign:"right"},center:{textAlign:"center"}}),ce=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[Y.left,t],children:e}),de=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[Y.right,t],children:e}),ge=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[Y.center,t],children:e});var f=renderer.StyleSheet.create({p:{fontSize:12,marginBottom:5,lineHeight:1.2},h1:{fontSize:24,fontWeight:"bold",marginBottom:12},h2:{fontSize:20,fontWeight:"bold",marginBottom:10},h3:{fontSize:18,fontWeight:"bold",marginBottom:8},h4:{fontSize:16,fontWeight:"bold",marginBottom:6},h5:{fontSize:14,fontWeight:"bold",marginBottom:4},h6:{fontSize:12,fontWeight:"bold",marginBottom:0},strong:{fontWeight:"bold"},em:{fontStyle:"italic"},u:{textDecoration:"underline"},small:{fontSize:10},blockquote:{marginLeft:20,marginRight:20,fontStyle:"italic",borderLeft:"4px solid #ccc",paddingLeft:10},mark:{backgroundColor:"yellow"},A:{color:"#3d65fd",textDecoration:"none"},br:{width:"100%",height:1,marginTop:7,marginBottom:7},header:{position:"absolute",top:20,left:0,right:0,textAlign:"center",fontSize:10,color:"#666",paddingHorizontal:40},hr:{width:"100%",borderTop:"1px solid #000",marginTop:8,marginBottom:8}}),me=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.p,t],children:e}),pe=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h1,t],children:e}),he=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h2,t],children:e}),fe=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h3,t],children:e}),ue=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h4,t],children:e}),ye=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h5,t],children:e}),we=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h6,t],children:e}),Ce=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.strong,t],children:e}),Re=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.em,t],children:e}),be=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.u,t],children:e}),xe=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.small,t],children:e}),Pe=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.blockquote,t],children:e}),Te=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.mark,t],children:e}),Fe=({children:e,style:t,href:o})=>jsxRuntime.jsx(renderer.Link,{src:o,style:[f.A,t],children:e}),Le=({style:e})=>jsxRuntime.jsx(renderer.Text,{style:[f.br,e],children:`
|
|
2
|
+
`}),Se=({style:e})=>jsxRuntime.jsx(renderer.View,{style:[f.hr,e]}),Ae=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[t],children:e}),Ve=({children:e,style:t,fixed:o=false})=>jsxRuntime.jsx(renderer.View,{style:[f.header,t],fixed:o,children:typeof e=="string"?jsxRuntime.jsx(renderer.Text,{children:e}):e}),Oe=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:t,children:e});var E=O.createContext({cellHeight:22,textAlign:"left"}),V=renderer.StyleSheet.create({table:{width:"100%",borderWidth:1,borderColor:"#000",marginBottom:20},thead:{backgroundColor:"#ccc"},tr:{flexDirection:"row"},textBold:{fontSize:10,fontFamily:"Helvetica",fontWeight:"bold",paddingLeft:8,paddingRight:8,justifyContent:"center"},text:{fontSize:10,fontFamily:"Helvetica",paddingLeft:8,paddingRight:8,justifyContent:"center"},zebraOdd:{backgroundColor:"#eeeeee"}}),Be=({children:e,style:t,cellHeight:o=22})=>jsxRuntime.jsx(E.Provider,{value:{cellHeight:o,textAlign:"left"},children:jsxRuntime.jsx(renderer.View,{style:[V.table,t],children:e})}),ve=({children:e,style:t,textAlign:o="left"})=>{let{cellHeight:r}=O.useContext(E);return jsxRuntime.jsx(E.Provider,{value:{cellHeight:r,textAlign:o},children:jsxRuntime.jsx(renderer.View,{style:[V.thead,t],children:e})})},ke=({children:e,style:t})=>{let o=O__default.default.Children.toArray(e),r=o.length;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:o.map((a,i)=>O__default.default.cloneElement(a,{isLastRow:i===r-1,isOdd:i%2===1}))})},De=({children:e,style:t,isLastRow:o=false,isOdd:r=false})=>{let a=O__default.default.Children.toArray(e),i=a.length;return jsxRuntime.jsx(renderer.View,{style:[V.tr,t],children:a.map((n,s)=>{let d=s===i-1,l=`${(100/i).toFixed(2)}%`;return O__default.default.cloneElement(n,{width:l,isLast:d,isLastRow:o,isOdd:r})})})},Ee=({children:e,style:t,width:o,height:r,colSpan:a,isLast:i=false,isLastRow:n=false,textAlign:s})=>{let{cellHeight:d,textAlign:l}=O.useContext(E),c=s||l||"left",g=typeof o=="string"&&a?`${(parseFloat(o)*a).toFixed(2)}%`:o,u={borderRightWidth:i?0:1,borderBottomWidth:n?0:1,borderColor:"#000",minHeight:r!==void 0?r:d};return jsxRuntime.jsx(renderer.View,{style:[V.textBold,{width:g},u,t],children:jsxRuntime.jsx(renderer.Text,{style:{textAlign:c},children:e})})},He=({children:e,style:t,width:o,height:r,colSpan:a,isLast:i=false,isLastRow:n=false,isOdd:s=false,textAlign:d})=>{let{cellHeight:l,textAlign:c}=O.useContext(E),g=d||c||"left",p=typeof o=="string"&&a?`${(parseFloat(o)*a).toFixed(2)}%`:o,P={borderRightWidth:i?0:1,borderBottomWidth:n?0:1,borderColor:"#000",minHeight:r!==void 0?r:l};return jsxRuntime.jsx(renderer.View,{style:[V.text,s&&V.zebraOdd,{width:p},P,t],children:jsxRuntime.jsx(renderer.Text,{style:{textAlign:g},children:e})})};var m=renderer.StyleSheet.create({container:{width:"100%",paddingHorizontal:20},row:{flexDirection:"row",flexWrap:"wrap",marginHorizontal:-5},col:{paddingHorizontal:5},col1:{width:"8.33%"},col2:{width:"16.66%"},col3:{width:"25%"},col4:{width:"33.33%"},col5:{width:"41.66%"},col6:{width:"50%"},col7:{width:"58.33%"},col8:{width:"66.66%"},col9:{width:"75%"},col10:{width:"83.33%"},col11:{width:"91.66%"},col12:{width:"100%"}}),Qe=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.container,t],children:e}),Me=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.row,t],children:e}),Ue=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col1,t],children:e}),Ne=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col2,t],children:e}),qe=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col3,t],children:e}),ze=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col4,t],children:e}),$e=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col5,t],children:e}),We=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col6,t],children:e}),Xe=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col7,t],children:e}),Ge=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col8,t],children:e}),Je=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col9,t],children:e}),_e=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col10,t],children:e}),je=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col11,t],children:e}),Ke=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col12,t],children:e});var W=async({value:e,size:t=150,colorDark:o="#000000",colorLight:r="#ffffff",margin:a=0,errorCorrectionLevel:i="M"})=>{try{let n={errorCorrectionLevel:i,type:"image/png",quality:.92,margin:a,color:{dark:o,light:r},width:t};return Et__default.default.toDataURL(e,n)}catch(n){return console.error("Error generando QR:",n),""}},Ye=async(e,t,o,r)=>new Promise(async a=>{if(!e||!t){a(e);return}try{let i=typeof window<"u"&&typeof window.document<"u",n,s,d;if(i)n=document.createElement("canvas"),s=n.getContext("2d"),d=window.Image;else try{let{createCanvas:c,Image:g}=await import('canvas');n=c(100,100),s=n.getContext("2d"),d=g;}catch(c){console.error("Canvas not available in Node environment for addLogoToQR",c),a(e);return}if(!s){a(e);return}let l=new d;i&&(l.crossOrigin="anonymous"),l.onload=()=>{n.width=l.width,n.height=l.height,s.drawImage(l,0,0,n.width,n.height);let c=new d;i&&(c.crossOrigin="anonymous"),c.onload=()=>{let g=(n.width-o)/2,p=(n.height-r)/2;s.fillStyle="#FFFFFF",s.fillRect(g-5,p-5,o+10,r+10),s.drawImage(c,g,p,o,r);let u=n.toDataURL("image/png");a(u);},c.onerror=g=>{console.error("Error cargando el logo:",g),a(e);},c.src=t;},l.onerror=c=>{console.error("Error cargando el QR:",c),a("");},l.src=e;}catch(i){console.error("Error procesando el QR con logo:",i),a(e);}});var qt=renderer.StyleSheet.create({qrContainer:{display:"flex",alignItems:"center",justifyContent:"center",margin:10}}),zt={0:"L",1:"M",2:"Q",3:"H"},$t=({value:e,size:t=150,style:o,colorDark:r="#000000",colorLight:a="#ffffff",margin:i=0,logo:n="",logoWidth:s=30,logoHeight:d=30,errorCorrectionLevel:l=n?"H":"M"})=>{let[c,g]=O.useState("");O.useEffect(()=>{(async()=>{try{let P=await W({value:e,size:t,colorDark:r,colorLight:a,margin:i,errorCorrectionLevel:typeof l=="number"?zt[l]||"M":l});if(n&&s&&d){let R=await Ye(P,n,s,d);g(R);}else g(P);}catch(P){console.error("Error generando QR:",P);let R=`https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(e)}&size=${t}x${t}&color=${encodeURIComponent(r.replace("#",""))}&bgcolor=${encodeURIComponent(a.replace("#",""))}`;g(R);}})();},[e,t,r,a,i,n,s,d,l]);let p=`https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(e)}&size=${t}x${t}`;return jsxRuntime.jsx(renderer.View,{style:[qt.qrContainer,o],children:jsxRuntime.jsx(renderer.Image,{src:c||p,style:{width:t,height:t}})})},et=$t;var oe=async e=>{try{let t=typeof window<"u"&&typeof window.document<"u",o,r={};if(t)try{let c=await import('qr-code-styling');o=c.default||c;}catch(c){throw console.error("Failed to load qr-code-styling in browser",c),c}else {let c="jsdom",g="canvas",p="qr-code-styling/lib/qr-code-styling.common.js";try{let[u,P,R]=await Promise.all([import(c),import(g),import(p)]),{JSDOM:I}=u,S=P.default||P,{QRCodeStyling:B}=R;o=B,r={jsdom:I,nodeCanvas:S};}catch(u){throw console.error("Failed to load Node dependencies for QR generation",u),u}}let a=typeof e.width=="number"&&isFinite(e.width)?Math.round(e.width):300,i=typeof e.height=="number"&&isFinite(e.height)?Math.round(e.height):300,n=!!e.image,s={width:a,height:i,data:e.value,image:e.image,dotsOptions:e.dotsOptions,backgroundOptions:{color:e.backgroundOptions?.color||"#ffffff",...e.backgroundOptions},imageOptions:{crossOrigin:"anonymous",margin:typeof e.imageOptions?.margin=="number"&&isFinite(e.imageOptions.margin)?e.imageOptions.margin:0,saveAsBlob:!0,imageSize:typeof e.imageOptions?.imageSize=="number"&&isFinite(e.imageOptions.imageSize)?Math.max(0,Math.min(1,e.imageOptions.imageSize)):.4},cornersSquareOptions:e.cornersSquareOptions,cornersDotOptions:e.cornersDotOptions},l=await new o({type:"png",...r,...s}).getRawData("png");if(!l)throw new Error("Failed to generate raw data from qr-code-styling");if(t){if(l instanceof Blob)return new Promise((c,g)=>{let p=new FileReader;p.onloadend=()=>{typeof p.result=="string"?c(p.result):g(new Error("Failed to convert blob to base64"));},p.onerror=g,p.readAsDataURL(l);});console.warn("Unexpected rawData type in browser:",l);}if(typeof Buffer<"u"&&Buffer.isBuffer(l))return `data:image/png;base64,${l.toString("base64")}`;throw new Error(`Unexpected raw data type: ${typeof l}`)}catch(t){return console.error("Error generating QR V2, falling back to V1:",t),W({value:e.value,size:e.width,colorDark:e.fallbackColorDark||e.dotsOptions?.color,colorLight:e.fallbackColorLight||e.backgroundOptions?.color,margin:e.fallbackMargin||0,errorCorrectionLevel:e.fallbackErrorCorrectionLevel||"M"})}};var jt=renderer.StyleSheet.create({qrContainer:{display:"flex",alignItems:"center",justifyContent:"center"}}),Kt=({value:e,size:t=300,style:o,image:r,dotsOptions:a,backgroundOptions:i,imageOptions:n,cornersSquareOptions:s,cornersDotOptions:d,colorDark:l,colorLight:c,margin:g,errorCorrectionLevel:p})=>{let[u,P]=O.useState("");return O.useEffect(()=>{let R=true;return (async()=>{let S=a||(l?{color:l}:void 0),B=i||(c?{color:c}:void 0),U={...n,margin:n?.margin!==void 0?n.margin:g};try{let v=await oe({value:e,width:t,height:t,image:r,dotsOptions:S,backgroundOptions:B,imageOptions:U,cornersSquareOptions:s,cornersDotOptions:d,fallbackColorDark:l,fallbackColorLight:c,fallbackMargin:g,fallbackErrorCorrectionLevel:p});R&&P(v);}catch(v){console.error("QRV2 Generation Error:",v);}})(),()=>{R=false;}},[e,t,r,JSON.stringify(a),JSON.stringify(i),JSON.stringify(n),JSON.stringify(s),JSON.stringify(d),l,c,g,p]),jsxRuntime.jsx(renderer.View,{style:[jt.qrContainer,o],children:jsxRuntime.jsx(renderer.Image,{style:{width:t,height:t},src:oe({value:e,width:t,height:t,image:r,dotsOptions:a||(l?{color:l}:void 0),backgroundOptions:i||(c?{color:c}:void 0),imageOptions:{...n,margin:n?.margin!==void 0?n.margin:g},cornersSquareOptions:s,cornersDotOptions:d,fallbackColorDark:l,fallbackColorLight:c,fallbackMargin:g,fallbackErrorCorrectionLevel:p})})})},ot=Kt;var Q=renderer.StyleSheet.create({ul:{marginBottom:10,paddingLeft:15},ol:{marginBottom:10,paddingLeft:15},li:{marginBottom:5,flexDirection:"row"},bulletPoint:{width:15,marginRight:5,fontSize:12},itemContent:{flex:1}}),Zt=(e="disc")=>{switch(e){case "circle":return "\u25CB";case "square":return "\u25A0";default:return "\u2022"}},eo=(e,t="decimal",o=1)=>{let r=o+e-1;switch(t){case "lower-alpha":return String.fromCharCode(97+r%26)+".";case "upper-alpha":return String.fromCharCode(65+r%26)+".";case "lower-roman":return nt(r).toLowerCase()+".";case "upper-roman":return nt(r)+".";default:return r+"."}},nt=e=>{if(e<=0||e>3999)return String(e);let t=[["","I","II","III","IV","V","VI","VII","VIII","IX"],["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"],["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"],["","M","MM","MMM"]];return t[3][Math.floor(e/1e3)]+t[2][Math.floor(e%1e3/100)]+t[1][Math.floor(e%100/10)]+t[0][e%10]},at=({children:e,style:t,type:o="disc"})=>{let r=O__default.default.Children.map(e,(a,i)=>O__default.default.isValidElement(a)?O__default.default.cloneElement(a,{bulletType:o,isOrdered:false,index:i+1}):a);return jsxRuntime.jsx(renderer.View,{style:[Q.ul,t],children:r})},it=({children:e,style:t,type:o="decimal",start:r=1})=>{let a=O__default.default.Children.map(e,(i,n)=>O__default.default.isValidElement(i)?O__default.default.cloneElement(i,{bulletType:o,isOrdered:true,index:n+1,start:r}):i);return jsxRuntime.jsx(renderer.View,{style:[Q.ol,t],children:a})},st=({children:e,style:t,bulletType:o="disc",isOrdered:r=false,index:a=1,start:i=1,value:n})=>{let s;if(r){let d=n!==void 0?Number(n):a;s=eo(d,o,i);}else s=Zt(o);return jsxRuntime.jsxs(renderer.View,{style:[Q.li,t],children:[jsxRuntime.jsx(renderer.Text,{style:Q.bulletPoint,children:s}),jsxRuntime.jsx(renderer.View,{style:Q.itemContent,children:typeof e=="string"?jsxRuntime.jsx(renderer.Text,{children:e}):e})]})};var re=renderer.StyleSheet.create({container:{position:"relative",width:"100%",height:"100%"},background:{position:"absolute",top:0,left:0,right:0,bottom:0},content:{position:"relative"}}),no=({src:e,width:t="100%",height:o="100%",opacity:r=.2,children:a,style:i,fixed:n=false,objectFit:s="cover",objectPosition:d="center"})=>jsxRuntime.jsxs(renderer.View,{style:[re.container,i],children:[jsxRuntime.jsx(renderer.Image,{src:e,style:[re.background,{width:t,height:o,opacity:r,objectFit:s,objectPosition:d}],fixed:n}),jsxRuntime.jsx(renderer.View,{style:re.content,children:a})]}),dt=no;
|
|
3
|
+
Object.defineProperty(exports,"Font",{enumerable:true,get:function(){return renderer.Font}});Object.defineProperty(exports,"StyleSheet",{enumerable:true,get:function(){return renderer.StyleSheet}});Object.defineProperty(exports,"Text",{enumerable:true,get:function(){return renderer.Text}});Object.defineProperty(exports,"View",{enumerable:true,get:function(){return renderer.View}});Object.defineProperty(exports,"renderToStream",{enumerable:true,get:function(){return renderer.renderToStream}});exports.A=Fe;exports.BR=Le;exports.Blockquote=Pe;exports.Center=ge;exports.Col1=Ue;exports.Col10=_e;exports.Col11=je;exports.Col12=Ke;exports.Col2=Ne;exports.Col3=qe;exports.Col4=ze;exports.Col5=$e;exports.Col6=We;exports.Col7=Xe;exports.Col8=Ge;exports.Col9=Je;exports.Container=Qe;exports.Div=Oe;exports.Em=Re;exports.H1=pe;exports.H2=he;exports.H3=fe;exports.H4=ue;exports.H5=ye;exports.H6=we;exports.HR=Se;exports.Header=Ve;exports.Img=le;exports.ImgBg=dt;exports.LI=st;exports.LayoutPDF=se;exports.Left=ce;exports.Mark=Te;exports.OL=it;exports.P=me;exports.QR=et;exports.QRV2=ot;exports.Right=de;exports.Row=Me;exports.Small=xe;exports.Span=Ae;exports.Strong=Ce;exports.Table=Be;exports.Tbody=ke;exports.Td=He;exports.Th=Ee;exports.Thead=ve;exports.Tr=De;exports.U=be;exports.UL=at;exports.decodeBase64Pdf=J;exports.generatePDF=_;//# sourceMappingURL=index.cjs.map
|
|
4
|
+
//# sourceMappingURL=index.cjs.map
|