pdf-catalog-generator 3.0.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +420 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +419 -80
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,29 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
3
3
|
import * as XLSX from 'xlsx';
|
|
4
4
|
|
|
5
5
|
// src/generator.tsx
|
|
6
|
+
var styles = StyleSheet.create({
|
|
7
|
+
wrapper: {
|
|
8
|
+
position: "absolute",
|
|
9
|
+
bottom: 6,
|
|
10
|
+
right: 10,
|
|
11
|
+
flexDirection: "row",
|
|
12
|
+
alignItems: "center",
|
|
13
|
+
opacity: 0.5
|
|
14
|
+
},
|
|
15
|
+
label: {
|
|
16
|
+
fontSize: 6.5,
|
|
17
|
+
color: "#666666",
|
|
18
|
+
letterSpacing: 0.2
|
|
19
|
+
},
|
|
20
|
+
link: {
|
|
21
|
+
fontSize: 6.5,
|
|
22
|
+
color: "#666666",
|
|
23
|
+
textDecoration: "none",
|
|
24
|
+
letterSpacing: 0.2
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
var PoweredByTeziApp = () => /* @__PURE__ */ jsx(View, { style: styles.wrapper, fixed: true, children: /* @__PURE__ */ jsx(Link, { style: styles.link, src: "https://teziapp.com", children: "Powered by Tezi App" }) });
|
|
28
|
+
var PoweredByTeziApp_default = PoweredByTeziApp;
|
|
6
29
|
|
|
7
30
|
// src/utils/fieldHelpers.ts
|
|
8
31
|
function formatFieldName(fieldName) {
|
|
@@ -129,7 +152,12 @@ var KNOWN_FIELD_NAMES_LOWER = [
|
|
|
129
152
|
"link",
|
|
130
153
|
"url",
|
|
131
154
|
"producturl",
|
|
132
|
-
"href"
|
|
155
|
+
"href",
|
|
156
|
+
"image2",
|
|
157
|
+
"imageurl2",
|
|
158
|
+
"img2",
|
|
159
|
+
"photo2",
|
|
160
|
+
"picture2"
|
|
133
161
|
];
|
|
134
162
|
function extractProductFields(product, options = {}) {
|
|
135
163
|
const { maxDynamicFields, excludeFields = [] } = options;
|
|
@@ -179,12 +207,12 @@ var dynamicFieldStyles = StyleSheet.create({
|
|
|
179
207
|
flexShrink: 1
|
|
180
208
|
}
|
|
181
209
|
});
|
|
182
|
-
function renderDynamicFields(fields,
|
|
210
|
+
function renderDynamicFields(fields, styles9) {
|
|
183
211
|
if (fields.length === 0) return null;
|
|
184
|
-
const containerStyle =
|
|
185
|
-
const rowStyle =
|
|
186
|
-
const labelStyle =
|
|
187
|
-
const valueStyle =
|
|
212
|
+
const containerStyle = styles9?.container || { marginBottom: 8 };
|
|
213
|
+
const rowStyle = styles9?.row || dynamicFieldStyles.detailRow;
|
|
214
|
+
const labelStyle = styles9?.label || dynamicFieldStyles.detailLabel;
|
|
215
|
+
const valueStyle = styles9?.value || dynamicFieldStyles.detailValue;
|
|
188
216
|
return /* @__PURE__ */ jsx(View, { style: containerStyle, children: fields.map(([key, value]) => /* @__PURE__ */ jsxs(View, { style: rowStyle, children: [
|
|
189
217
|
/* @__PURE__ */ jsxs(Text, { style: labelStyle, children: [
|
|
190
218
|
formatFieldName(key),
|
|
@@ -228,7 +256,7 @@ function mergeTemplateConfig(config = {}) {
|
|
|
228
256
|
...config
|
|
229
257
|
};
|
|
230
258
|
}
|
|
231
|
-
var
|
|
259
|
+
var styles2 = StyleSheet.create({
|
|
232
260
|
productContainer: {
|
|
233
261
|
flexDirection: "row",
|
|
234
262
|
flexWrap: "wrap",
|
|
@@ -292,27 +320,27 @@ var styles = StyleSheet.create({
|
|
|
292
320
|
}
|
|
293
321
|
});
|
|
294
322
|
var Template1 = ({ products }) => {
|
|
295
|
-
return /* @__PURE__ */ jsx(View, { style:
|
|
323
|
+
return /* @__PURE__ */ jsx(View, { style: styles2.productContainer, children: products.map((product, index) => {
|
|
296
324
|
const fields = extractProductFields(product);
|
|
297
|
-
return /* @__PURE__ */ jsxs(View, { style:
|
|
298
|
-
/* @__PURE__ */ jsx(Image, { style:
|
|
299
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
300
|
-
/* @__PURE__ */ jsx(Text, { style:
|
|
301
|
-
renderRating(fields.rating,
|
|
325
|
+
return /* @__PURE__ */ jsxs(View, { style: styles2.productSection, children: [
|
|
326
|
+
/* @__PURE__ */ jsx(Image, { style: styles2.image, src: fields.imageUrl }),
|
|
327
|
+
/* @__PURE__ */ jsxs(View, { style: styles2.productTitleBox, children: [
|
|
328
|
+
/* @__PURE__ */ jsx(Text, { style: styles2.productTitle, children: fields.title }),
|
|
329
|
+
renderRating(fields.rating, styles2.productRate)
|
|
302
330
|
] }),
|
|
303
|
-
fields.description && /* @__PURE__ */ jsx(Text, { style:
|
|
331
|
+
fields.description && /* @__PURE__ */ jsx(Text, { style: styles2.productDescription, children: fields.description }),
|
|
304
332
|
renderDynamicFields(fields.dynamicFields),
|
|
305
333
|
renderBuyButton(
|
|
306
334
|
fields.link,
|
|
307
|
-
|
|
335
|
+
styles2.buyButton,
|
|
308
336
|
"Buy Now",
|
|
309
|
-
renderPrice(fields.price,
|
|
337
|
+
renderPrice(fields.price, styles2.productPrice)
|
|
310
338
|
)
|
|
311
339
|
] }, index);
|
|
312
340
|
}) });
|
|
313
341
|
};
|
|
314
342
|
var Template1_default = Template1;
|
|
315
|
-
var
|
|
343
|
+
var styles3 = StyleSheet.create({
|
|
316
344
|
productContainer: {
|
|
317
345
|
flexDirection: "row",
|
|
318
346
|
flexWrap: "wrap",
|
|
@@ -389,14 +417,14 @@ var styles2 = StyleSheet.create({
|
|
|
389
417
|
}
|
|
390
418
|
});
|
|
391
419
|
var Template2 = ({ products }) => {
|
|
392
|
-
return /* @__PURE__ */ jsx(View, { style:
|
|
420
|
+
return /* @__PURE__ */ jsx(View, { style: styles3.productContainer, children: products.map((product, index) => {
|
|
393
421
|
const fields = extractProductFields(product);
|
|
394
|
-
return /* @__PURE__ */ jsxs(View, { style:
|
|
395
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
396
|
-
/* @__PURE__ */ jsx(Image, { style:
|
|
397
|
-
renderRating(fields.rating,
|
|
422
|
+
return /* @__PURE__ */ jsxs(View, { style: styles3.productSection, children: [
|
|
423
|
+
/* @__PURE__ */ jsxs(View, { style: styles3.productSectionImage, children: [
|
|
424
|
+
/* @__PURE__ */ jsx(Image, { style: styles3.image, src: fields.imageUrl }),
|
|
425
|
+
renderRating(fields.rating, styles3.productRate)
|
|
398
426
|
] }),
|
|
399
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
427
|
+
/* @__PURE__ */ jsxs(View, { style: styles3.productSectionText, children: [
|
|
400
428
|
/* @__PURE__ */ jsxs(
|
|
401
429
|
View,
|
|
402
430
|
{
|
|
@@ -406,20 +434,20 @@ var Template2 = ({ products }) => {
|
|
|
406
434
|
justifyContent: "space-between"
|
|
407
435
|
},
|
|
408
436
|
children: [
|
|
409
|
-
/* @__PURE__ */ jsx(Text, { style:
|
|
410
|
-
renderPrice(fields.price,
|
|
437
|
+
/* @__PURE__ */ jsx(Text, { style: styles3.productTitle, children: fields.title }),
|
|
438
|
+
renderPrice(fields.price, styles3.productPrice)
|
|
411
439
|
]
|
|
412
440
|
}
|
|
413
441
|
),
|
|
414
|
-
fields.description && /* @__PURE__ */ jsx(Text, { style:
|
|
442
|
+
fields.description && /* @__PURE__ */ jsx(Text, { style: styles3.productDescription, children: fields.description }),
|
|
415
443
|
renderDynamicFields(fields.dynamicFields),
|
|
416
|
-
renderBuyButton(fields.link,
|
|
444
|
+
renderBuyButton(fields.link, styles3.buyButton)
|
|
417
445
|
] })
|
|
418
446
|
] }, index);
|
|
419
447
|
}) });
|
|
420
448
|
};
|
|
421
449
|
var Template2_default = Template2;
|
|
422
|
-
var
|
|
450
|
+
var styles4 = StyleSheet.create({
|
|
423
451
|
productSection: {
|
|
424
452
|
width: "100%",
|
|
425
453
|
height: "100vh",
|
|
@@ -499,10 +527,10 @@ var compactDynamicFieldStyles = StyleSheet.create({
|
|
|
499
527
|
var Template3 = ({ products }) => {
|
|
500
528
|
return /* @__PURE__ */ jsx(Fragment, { children: products.map((product, index) => {
|
|
501
529
|
const fields = extractProductFields(product, { maxDynamicFields: 5 });
|
|
502
|
-
return /* @__PURE__ */ jsxs(View, { style:
|
|
503
|
-
/* @__PURE__ */ jsx(Image, { style:
|
|
504
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
505
|
-
/* @__PURE__ */ jsx(Text, { style:
|
|
530
|
+
return /* @__PURE__ */ jsxs(View, { style: styles4.productSection, children: [
|
|
531
|
+
/* @__PURE__ */ jsx(Image, { style: styles4.image, src: fields.imageUrl }),
|
|
532
|
+
/* @__PURE__ */ jsxs(View, { style: styles4.productDetailsBox, children: [
|
|
533
|
+
/* @__PURE__ */ jsx(Text, { style: styles4.productTitle, children: fields.title }),
|
|
506
534
|
/* @__PURE__ */ jsxs(
|
|
507
535
|
View,
|
|
508
536
|
{
|
|
@@ -512,25 +540,25 @@ var Template3 = ({ products }) => {
|
|
|
512
540
|
justifyContent: "space-between"
|
|
513
541
|
},
|
|
514
542
|
children: [
|
|
515
|
-
renderPrice(fields.price,
|
|
516
|
-
renderRating(fields.rating,
|
|
543
|
+
renderPrice(fields.price, styles4.productPrice),
|
|
544
|
+
renderRating(fields.rating, styles4.productRate)
|
|
517
545
|
]
|
|
518
546
|
}
|
|
519
547
|
),
|
|
520
|
-
fields.description && /* @__PURE__ */ jsx(Text, { style:
|
|
548
|
+
fields.description && /* @__PURE__ */ jsx(Text, { style: styles4.productDescription, children: fields.description }),
|
|
521
549
|
renderDynamicFields(fields.dynamicFields, {
|
|
522
550
|
row: compactDynamicFieldStyles.detailRow,
|
|
523
551
|
label: compactDynamicFieldStyles.detailLabel,
|
|
524
552
|
value: compactDynamicFieldStyles.detailValue
|
|
525
553
|
}),
|
|
526
|
-
renderBuyButton(fields.link,
|
|
554
|
+
renderBuyButton(fields.link, styles4.buyButton)
|
|
527
555
|
] }),
|
|
528
556
|
/* @__PURE__ */ jsx(View, { break: true })
|
|
529
557
|
] }, index);
|
|
530
558
|
}) });
|
|
531
559
|
};
|
|
532
560
|
var Template3_default = Template3;
|
|
533
|
-
var
|
|
561
|
+
var styles5 = StyleSheet.create({
|
|
534
562
|
page: {
|
|
535
563
|
width: "100%",
|
|
536
564
|
height: "100%",
|
|
@@ -627,21 +655,326 @@ var Template4 = ({
|
|
|
627
655
|
)
|
|
628
656
|
);
|
|
629
657
|
const fields = extractProductFields(product);
|
|
630
|
-
return /* @__PURE__ */ jsxs(View, { style:
|
|
631
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
632
|
-
/* @__PURE__ */ jsx(Text, { style:
|
|
633
|
-
companyLogo && /* @__PURE__ */ jsx(Image, { style:
|
|
658
|
+
return /* @__PURE__ */ jsxs(View, { style: styles5.page, children: [
|
|
659
|
+
/* @__PURE__ */ jsxs(View, { style: styles5.header, children: [
|
|
660
|
+
/* @__PURE__ */ jsx(Text, { style: styles5.companyName, children: companyName || "" }),
|
|
661
|
+
companyLogo && /* @__PURE__ */ jsx(Image, { style: styles5.brandLogo, src: companyLogo })
|
|
634
662
|
] }),
|
|
635
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
636
|
-
/* @__PURE__ */ jsx(Image, { style:
|
|
637
|
-
allFields.length > 0 && /* @__PURE__ */ jsx(View, { style:
|
|
663
|
+
/* @__PURE__ */ jsxs(View, { style: styles5.productContainer, children: [
|
|
664
|
+
/* @__PURE__ */ jsx(Image, { style: styles5.productImage, src: fields.imageUrl }),
|
|
665
|
+
allFields.length > 0 && /* @__PURE__ */ jsx(View, { style: styles5.detailsBox, children: renderFieldsInColumns(allFields) })
|
|
638
666
|
] }),
|
|
639
667
|
/* @__PURE__ */ jsx(View, { break: true })
|
|
640
668
|
] }, index);
|
|
641
669
|
}) });
|
|
642
670
|
};
|
|
643
671
|
var Template4_default = Template4;
|
|
644
|
-
var
|
|
672
|
+
var styles6 = StyleSheet.create({
|
|
673
|
+
page: {
|
|
674
|
+
width: "100%",
|
|
675
|
+
height: "100%",
|
|
676
|
+
position: "relative",
|
|
677
|
+
backgroundColor: "#FFFFFF",
|
|
678
|
+
flexDirection: "column"
|
|
679
|
+
},
|
|
680
|
+
header: {
|
|
681
|
+
height: 80,
|
|
682
|
+
display: "flex",
|
|
683
|
+
flexDirection: "row",
|
|
684
|
+
alignItems: "center",
|
|
685
|
+
paddingHorizontal: 30,
|
|
686
|
+
paddingTop: 20,
|
|
687
|
+
paddingBottom: 10,
|
|
688
|
+
borderBottomWidth: 1,
|
|
689
|
+
borderBottomColor: "#E0E0E0",
|
|
690
|
+
marginBottom: 10
|
|
691
|
+
},
|
|
692
|
+
logo: {
|
|
693
|
+
height: 50,
|
|
694
|
+
marginRight: 20,
|
|
695
|
+
objectFit: "contain"
|
|
696
|
+
},
|
|
697
|
+
companyName: {
|
|
698
|
+
fontSize: 24,
|
|
699
|
+
fontWeight: "bold",
|
|
700
|
+
color: "#333333",
|
|
701
|
+
letterSpacing: 1
|
|
702
|
+
},
|
|
703
|
+
contentContainer: {
|
|
704
|
+
flex: 1,
|
|
705
|
+
flexDirection: "row",
|
|
706
|
+
paddingHorizontal: 30,
|
|
707
|
+
paddingBottom: 30,
|
|
708
|
+
gap: 20
|
|
709
|
+
},
|
|
710
|
+
imageSection: {
|
|
711
|
+
flex: 2,
|
|
712
|
+
flexDirection: "row",
|
|
713
|
+
gap: 15
|
|
714
|
+
},
|
|
715
|
+
imageWrapper: {
|
|
716
|
+
flex: 1,
|
|
717
|
+
height: "100%",
|
|
718
|
+
backgroundColor: "#F9F9F9",
|
|
719
|
+
borderRadius: 4,
|
|
720
|
+
overflow: "hidden"
|
|
721
|
+
},
|
|
722
|
+
productImage: {
|
|
723
|
+
width: "100%",
|
|
724
|
+
height: "100%",
|
|
725
|
+
objectFit: "cover"
|
|
726
|
+
},
|
|
727
|
+
detailsSection: {
|
|
728
|
+
flex: 1,
|
|
729
|
+
backgroundColor: "#F5F5F5",
|
|
730
|
+
padding: 20,
|
|
731
|
+
borderRadius: 8,
|
|
732
|
+
justifyContent: "center"
|
|
733
|
+
},
|
|
734
|
+
productTitle: {
|
|
735
|
+
fontSize: 18,
|
|
736
|
+
fontWeight: "bold",
|
|
737
|
+
color: "#222222",
|
|
738
|
+
marginBottom: 15,
|
|
739
|
+
borderBottomWidth: 2,
|
|
740
|
+
borderBottomColor: "#333333",
|
|
741
|
+
paddingBottom: 5
|
|
742
|
+
},
|
|
743
|
+
dynamicFieldsContainer: {
|
|
744
|
+
gap: 8
|
|
745
|
+
},
|
|
746
|
+
detailRow: {
|
|
747
|
+
flexDirection: "row",
|
|
748
|
+
marginBottom: 6,
|
|
749
|
+
borderBottomWidth: 1,
|
|
750
|
+
borderBottomColor: "#E0E0E0",
|
|
751
|
+
paddingBottom: 4
|
|
752
|
+
},
|
|
753
|
+
detailLabel: {
|
|
754
|
+
fontSize: 10,
|
|
755
|
+
fontWeight: "bold",
|
|
756
|
+
color: "#555555",
|
|
757
|
+
width: "40%"
|
|
758
|
+
},
|
|
759
|
+
detailValue: {
|
|
760
|
+
fontSize: 10,
|
|
761
|
+
color: "#333333",
|
|
762
|
+
flex: 1,
|
|
763
|
+
flexWrap: "wrap"
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
function getImage2Url(product) {
|
|
767
|
+
const image2Fields = ["image2", "imageurl2", "img2", "photo2", "picture2"];
|
|
768
|
+
for (const field of image2Fields) {
|
|
769
|
+
const value = product[field];
|
|
770
|
+
if (value && typeof value === "string" && value.trim() !== "") {
|
|
771
|
+
return value;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
return null;
|
|
775
|
+
}
|
|
776
|
+
var Template5 = ({
|
|
777
|
+
products,
|
|
778
|
+
companyLogo,
|
|
779
|
+
companyName
|
|
780
|
+
}) => {
|
|
781
|
+
return /* @__PURE__ */ jsx(Fragment, { children: products.map((product, index) => {
|
|
782
|
+
const { imageUrl, title, dynamicFields } = extractProductFields(product);
|
|
783
|
+
const image2Url = getImage2Url(product);
|
|
784
|
+
const secondImage = image2Url || imageUrl;
|
|
785
|
+
return /* @__PURE__ */ jsxs(View, { style: styles6.page, children: [
|
|
786
|
+
/* @__PURE__ */ jsxs(View, { style: styles6.header, children: [
|
|
787
|
+
companyLogo && /* @__PURE__ */ jsx(Image, { style: styles6.logo, src: companyLogo }),
|
|
788
|
+
/* @__PURE__ */ jsx(Text, { style: styles6.companyName, children: companyName })
|
|
789
|
+
] }),
|
|
790
|
+
/* @__PURE__ */ jsxs(View, { style: styles6.contentContainer, children: [
|
|
791
|
+
/* @__PURE__ */ jsxs(View, { style: styles6.imageSection, children: [
|
|
792
|
+
/* @__PURE__ */ jsx(View, { style: styles6.imageWrapper, children: /* @__PURE__ */ jsx(Image, { style: styles6.productImage, src: imageUrl }) }),
|
|
793
|
+
/* @__PURE__ */ jsx(View, { style: styles6.imageWrapper, children: /* @__PURE__ */ jsx(Image, { style: styles6.productImage, src: secondImage }) })
|
|
794
|
+
] }),
|
|
795
|
+
/* @__PURE__ */ jsxs(View, { style: styles6.detailsSection, children: [
|
|
796
|
+
title && /* @__PURE__ */ jsx(Text, { style: styles6.productTitle, children: title }),
|
|
797
|
+
/* @__PURE__ */ jsx(View, { style: styles6.dynamicFieldsContainer, children: renderDynamicFields(dynamicFields, {
|
|
798
|
+
row: styles6.detailRow,
|
|
799
|
+
label: styles6.detailLabel,
|
|
800
|
+
value: styles6.detailValue
|
|
801
|
+
}) })
|
|
802
|
+
] })
|
|
803
|
+
] }),
|
|
804
|
+
/* @__PURE__ */ jsx(View, { break: true })
|
|
805
|
+
] }, index);
|
|
806
|
+
}) });
|
|
807
|
+
};
|
|
808
|
+
var Template5_default = Template5;
|
|
809
|
+
var styles7 = StyleSheet.create({
|
|
810
|
+
page: {
|
|
811
|
+
width: "100%",
|
|
812
|
+
height: "100%",
|
|
813
|
+
flexDirection: "row",
|
|
814
|
+
backgroundColor: "#FFFFFF"
|
|
815
|
+
},
|
|
816
|
+
leftColumn: {
|
|
817
|
+
width: "50%",
|
|
818
|
+
height: "100%",
|
|
819
|
+
position: "relative",
|
|
820
|
+
borderRightWidth: 1,
|
|
821
|
+
borderRightColor: "#E0E0E0"
|
|
822
|
+
},
|
|
823
|
+
rightColumn: {
|
|
824
|
+
width: "50%",
|
|
825
|
+
height: "100%",
|
|
826
|
+
display: "flex",
|
|
827
|
+
flexDirection: "column",
|
|
828
|
+
position: "relative"
|
|
829
|
+
},
|
|
830
|
+
imageFull: {
|
|
831
|
+
width: "100%",
|
|
832
|
+
height: "100%",
|
|
833
|
+
objectFit: "cover"
|
|
834
|
+
},
|
|
835
|
+
rightImageContainer: {
|
|
836
|
+
flex: 1,
|
|
837
|
+
width: "100%",
|
|
838
|
+
position: "relative",
|
|
839
|
+
justifyContent: "center",
|
|
840
|
+
alignItems: "center",
|
|
841
|
+
padding: 20
|
|
842
|
+
},
|
|
843
|
+
rightImage: {
|
|
844
|
+
width: "100%",
|
|
845
|
+
height: "100%",
|
|
846
|
+
objectFit: "contain"
|
|
847
|
+
},
|
|
848
|
+
specsOverlay: {
|
|
849
|
+
position: "absolute",
|
|
850
|
+
bottom: 40,
|
|
851
|
+
// Lifted slightly from absolute bottom
|
|
852
|
+
right: 0,
|
|
853
|
+
backgroundColor: "#FFFFFF",
|
|
854
|
+
padding: 15,
|
|
855
|
+
width: "65%",
|
|
856
|
+
// Takes up a good chunk of the corner
|
|
857
|
+
borderTopLeftRadius: 4,
|
|
858
|
+
borderBottomLeftRadius: 4,
|
|
859
|
+
shadowColor: "#000",
|
|
860
|
+
shadowOpacity: 0.2,
|
|
861
|
+
shadowRadius: 3,
|
|
862
|
+
borderWidth: 1,
|
|
863
|
+
borderColor: "#EEEEEE"
|
|
864
|
+
},
|
|
865
|
+
specsHeader: {
|
|
866
|
+
flexDirection: "row",
|
|
867
|
+
alignItems: "center",
|
|
868
|
+
marginBottom: 10,
|
|
869
|
+
borderBottomWidth: 1,
|
|
870
|
+
borderBottomColor: "#333",
|
|
871
|
+
paddingBottom: 5
|
|
872
|
+
},
|
|
873
|
+
miniLogo: {
|
|
874
|
+
width: 20,
|
|
875
|
+
height: 20,
|
|
876
|
+
objectFit: "contain",
|
|
877
|
+
marginRight: 8
|
|
878
|
+
},
|
|
879
|
+
designNumber: {
|
|
880
|
+
fontSize: 12,
|
|
881
|
+
fontWeight: "bold",
|
|
882
|
+
color: "#000"
|
|
883
|
+
},
|
|
884
|
+
footer: {
|
|
885
|
+
height: 100,
|
|
886
|
+
backgroundColor: "#1A1A1A",
|
|
887
|
+
flexDirection: "row",
|
|
888
|
+
alignItems: "center",
|
|
889
|
+
justifyContent: "flex-end",
|
|
890
|
+
paddingHorizontal: 30,
|
|
891
|
+
width: "100%"
|
|
892
|
+
},
|
|
893
|
+
footerContent: {
|
|
894
|
+
flexDirection: "row",
|
|
895
|
+
alignItems: "center"
|
|
896
|
+
},
|
|
897
|
+
footerLogo: {
|
|
898
|
+
width: 40,
|
|
899
|
+
height: 40,
|
|
900
|
+
objectFit: "contain",
|
|
901
|
+
marginRight: 15,
|
|
902
|
+
backgroundColor: "#FFF",
|
|
903
|
+
// White background for logo visibility
|
|
904
|
+
padding: 2,
|
|
905
|
+
borderRadius: 2
|
|
906
|
+
},
|
|
907
|
+
footerText: {
|
|
908
|
+
color: "#FFFFFF",
|
|
909
|
+
fontSize: 14,
|
|
910
|
+
fontWeight: "bold",
|
|
911
|
+
letterSpacing: 1,
|
|
912
|
+
textTransform: "uppercase"
|
|
913
|
+
},
|
|
914
|
+
// Custom styles for dynamic fields in the overlay
|
|
915
|
+
fieldRow: {
|
|
916
|
+
flexDirection: "row",
|
|
917
|
+
marginBottom: 4
|
|
918
|
+
},
|
|
919
|
+
fieldLabel: {
|
|
920
|
+
fontSize: 9,
|
|
921
|
+
fontWeight: "bold",
|
|
922
|
+
color: "#333",
|
|
923
|
+
width: "40%"
|
|
924
|
+
},
|
|
925
|
+
fieldValue: {
|
|
926
|
+
fontSize: 9,
|
|
927
|
+
color: "#555",
|
|
928
|
+
flex: 1
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
function getImage2Url2(product) {
|
|
932
|
+
const image2Fields = ["image2", "imageurl2", "img2", "photo2", "picture2"];
|
|
933
|
+
for (const field of image2Fields) {
|
|
934
|
+
const value = product[field];
|
|
935
|
+
if (value && typeof value === "string" && value.trim() !== "") {
|
|
936
|
+
return value;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
return null;
|
|
940
|
+
}
|
|
941
|
+
var Template6 = ({
|
|
942
|
+
products,
|
|
943
|
+
companyLogo,
|
|
944
|
+
companyName
|
|
945
|
+
}) => {
|
|
946
|
+
return /* @__PURE__ */ jsx(Fragment, { children: products.map((product, index) => {
|
|
947
|
+
const { imageUrl, title, dynamicFields } = extractProductFields(product);
|
|
948
|
+
const image2Url = getImage2Url2(product);
|
|
949
|
+
const secondImage = image2Url || imageUrl;
|
|
950
|
+
return /* @__PURE__ */ jsxs(View, { style: styles7.page, children: [
|
|
951
|
+
/* @__PURE__ */ jsxs(View, { style: styles7.leftColumn, children: [
|
|
952
|
+
/* @__PURE__ */ jsx(Image, { style: styles7.imageFull, src: imageUrl }),
|
|
953
|
+
/* @__PURE__ */ jsxs(View, { style: styles7.specsOverlay, children: [
|
|
954
|
+
/* @__PURE__ */ jsxs(View, { style: styles7.specsHeader, children: [
|
|
955
|
+
companyLogo && /* @__PURE__ */ jsx(Image, { style: styles7.miniLogo, src: companyLogo }),
|
|
956
|
+
/* @__PURE__ */ jsx(Text, { style: styles7.designNumber, children: title || "Specifications" })
|
|
957
|
+
] }),
|
|
958
|
+
renderDynamicFields(dynamicFields, {
|
|
959
|
+
row: styles7.fieldRow,
|
|
960
|
+
label: styles7.fieldLabel,
|
|
961
|
+
value: styles7.fieldValue
|
|
962
|
+
})
|
|
963
|
+
] })
|
|
964
|
+
] }),
|
|
965
|
+
/* @__PURE__ */ jsxs(View, { style: styles7.rightColumn, children: [
|
|
966
|
+
/* @__PURE__ */ jsx(View, { style: styles7.rightImageContainer, children: /* @__PURE__ */ jsx(Image, { style: styles7.rightImage, src: secondImage }) }),
|
|
967
|
+
/* @__PURE__ */ jsx(View, { style: styles7.footer, children: /* @__PURE__ */ jsxs(View, { style: styles7.footerContent, children: [
|
|
968
|
+
companyLogo && /* @__PURE__ */ jsx(Image, { style: styles7.footerLogo, src: companyLogo }),
|
|
969
|
+
/* @__PURE__ */ jsx(Text, { style: styles7.footerText, children: companyName })
|
|
970
|
+
] }) })
|
|
971
|
+
] }),
|
|
972
|
+
/* @__PURE__ */ jsx(View, { break: true })
|
|
973
|
+
] }, index);
|
|
974
|
+
}) });
|
|
975
|
+
};
|
|
976
|
+
var Template6_default = Template6;
|
|
977
|
+
var styles8 = StyleSheet.create({
|
|
645
978
|
page: {
|
|
646
979
|
flexDirection: "column",
|
|
647
980
|
backgroundColor: "#FFFFFF"
|
|
@@ -673,26 +1006,6 @@ Font.registerEmojiSource({
|
|
|
673
1006
|
format: "png",
|
|
674
1007
|
url: "https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/"
|
|
675
1008
|
});
|
|
676
|
-
function normalizeImageSource(imageSource) {
|
|
677
|
-
if (imageSource.startsWith("data:")) {
|
|
678
|
-
return imageSource;
|
|
679
|
-
}
|
|
680
|
-
if (imageSource.startsWith("http://") || imageSource.startsWith("https://")) {
|
|
681
|
-
return imageSource;
|
|
682
|
-
}
|
|
683
|
-
let mimeType = "image/png";
|
|
684
|
-
const base64Start = imageSource.substring(0, 20).toLowerCase();
|
|
685
|
-
if (base64Start.includes("ivborw0kggo") || imageSource.startsWith("iVBORw0KGgo")) {
|
|
686
|
-
mimeType = "image/png";
|
|
687
|
-
} else if (base64Start.includes("/9j/4aaq") || imageSource.startsWith("/9j/4AAQ")) {
|
|
688
|
-
mimeType = "image/jpeg";
|
|
689
|
-
} else if (base64Start.includes("r0lgodlh") || imageSource.startsWith("R0lGODlh")) {
|
|
690
|
-
mimeType = "image/gif";
|
|
691
|
-
} else if (base64Start.includes("uklgr") || imageSource.startsWith("UklGR")) {
|
|
692
|
-
mimeType = "image/webp";
|
|
693
|
-
}
|
|
694
|
-
return `data:${mimeType};base64,${imageSource}`;
|
|
695
|
-
}
|
|
696
1009
|
async function generateProductCatalog(config) {
|
|
697
1010
|
const { products, companyLogo, companyName, template = "template1" } = config;
|
|
698
1011
|
let TemplateComponent;
|
|
@@ -709,29 +1022,55 @@ async function generateProductCatalog(config) {
|
|
|
709
1022
|
case "template4":
|
|
710
1023
|
TemplateComponent = Template4_default;
|
|
711
1024
|
break;
|
|
1025
|
+
case "template5":
|
|
1026
|
+
TemplateComponent = Template5_default;
|
|
1027
|
+
break;
|
|
1028
|
+
case "template6":
|
|
1029
|
+
TemplateComponent = Template6_default;
|
|
1030
|
+
break;
|
|
712
1031
|
default:
|
|
713
1032
|
TemplateComponent = Template1_default;
|
|
714
1033
|
}
|
|
715
1034
|
if (template === "template4") {
|
|
716
|
-
const doc2 = /* @__PURE__ */ jsx(Document, { children: /* @__PURE__ */
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
1035
|
+
const doc2 = /* @__PURE__ */ jsx(Document, { children: /* @__PURE__ */ jsxs(Page, { size: "A4", style: styles8.page, children: [
|
|
1036
|
+
/* @__PURE__ */ jsx(
|
|
1037
|
+
Template4_default,
|
|
1038
|
+
{
|
|
1039
|
+
products,
|
|
1040
|
+
companyLogo,
|
|
1041
|
+
companyName
|
|
1042
|
+
}
|
|
1043
|
+
),
|
|
1044
|
+
/* @__PURE__ */ jsx(PoweredByTeziApp_default, {})
|
|
1045
|
+
] }) });
|
|
724
1046
|
const blob2 = await pdf(doc2).toBlob();
|
|
725
1047
|
const arrayBuffer2 = await blob2.arrayBuffer();
|
|
726
1048
|
return new Uint8Array(arrayBuffer2);
|
|
727
1049
|
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
/* @__PURE__ */ jsx(
|
|
732
|
-
|
|
1050
|
+
if (template === "template5" || template === "template6") {
|
|
1051
|
+
const Template = template === "template5" ? Template5_default : Template6_default;
|
|
1052
|
+
const doc2 = /* @__PURE__ */ jsx(Document, { children: /* @__PURE__ */ jsxs(Page, { size: "A4", orientation: "landscape", style: styles8.page, children: [
|
|
1053
|
+
/* @__PURE__ */ jsx(
|
|
1054
|
+
Template,
|
|
1055
|
+
{
|
|
1056
|
+
products,
|
|
1057
|
+
companyLogo,
|
|
1058
|
+
companyName
|
|
1059
|
+
}
|
|
1060
|
+
),
|
|
1061
|
+
/* @__PURE__ */ jsx(PoweredByTeziApp_default, {})
|
|
1062
|
+
] }) });
|
|
1063
|
+
const blob2 = await pdf(doc2).toBlob();
|
|
1064
|
+
const arrayBuffer2 = await blob2.arrayBuffer();
|
|
1065
|
+
return new Uint8Array(arrayBuffer2);
|
|
1066
|
+
}
|
|
1067
|
+
const doc = /* @__PURE__ */ jsx(Document, { children: /* @__PURE__ */ jsxs(Page, { size: "A4", style: styles8.page, children: [
|
|
1068
|
+
/* @__PURE__ */ jsxs(View, { style: styles8.header, children: [
|
|
1069
|
+
companyLogo && /* @__PURE__ */ jsx(View, { style: styles8.logoSection, children: /* @__PURE__ */ jsx(Image, { style: styles8.logo, src: companyLogo }) }),
|
|
1070
|
+
/* @__PURE__ */ jsx(View, { style: styles8.storeNameSection, children: /* @__PURE__ */ jsx(Text, { style: styles8.storeName, children: companyName }) })
|
|
733
1071
|
] }),
|
|
734
|
-
/* @__PURE__ */ jsx(TemplateComponent, { products })
|
|
1072
|
+
/* @__PURE__ */ jsx(TemplateComponent, { products }),
|
|
1073
|
+
/* @__PURE__ */ jsx(PoweredByTeziApp_default, {})
|
|
735
1074
|
] }) });
|
|
736
1075
|
const blob = await pdf(doc).toBlob();
|
|
737
1076
|
const arrayBuffer = await blob.arrayBuffer();
|
|
@@ -775,6 +1114,6 @@ function parseJSON(data) {
|
|
|
775
1114
|
return data;
|
|
776
1115
|
}
|
|
777
1116
|
|
|
778
|
-
export { DEFAULT_TEMPLATE_CONFIG, KNOWN_FIELD_NAMES_LOWER, Template1_default as Template1, Template2_default as Template2, Template3_default as Template3, Template4_default as Template4, dynamicFieldStyles, extractProductFields, formatFieldName, generateProductCatalog, getDescriptionField, getDisplayFields, getFieldValue, getImageUrl, getLinkField, getPriceField, getRatingField, getTitleField, hasValue, mergeTemplateConfig, parseCSVBuffer, parseCSVFile, parseExcelFile, parseJSON, renderBuyButton, renderDynamicFields, renderPrice, renderRating };
|
|
1117
|
+
export { DEFAULT_TEMPLATE_CONFIG, KNOWN_FIELD_NAMES_LOWER, Template1_default as Template1, Template2_default as Template2, Template3_default as Template3, Template4_default as Template4, Template5_default as Template5, Template6_default as Template6, dynamicFieldStyles, extractProductFields, formatFieldName, generateProductCatalog, getDescriptionField, getDisplayFields, getFieldValue, getImageUrl, getLinkField, getPriceField, getRatingField, getTitleField, hasValue, mergeTemplateConfig, parseCSVBuffer, parseCSVFile, parseExcelFile, parseJSON, renderBuyButton, renderDynamicFields, renderPrice, renderRating };
|
|
779
1118
|
//# sourceMappingURL=index.mjs.map
|
|
780
1119
|
//# sourceMappingURL=index.mjs.map
|