pdf-catalog-generator 3.1.2 → 3.1.3

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.mjs CHANGED
@@ -3,29 +3,6 @@ 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;
29
6
 
30
7
  // src/utils/fieldHelpers.ts
31
8
  function formatFieldName(fieldName) {
@@ -207,12 +184,12 @@ var dynamicFieldStyles = StyleSheet.create({
207
184
  flexShrink: 1
208
185
  }
209
186
  });
210
- function renderDynamicFields(fields, styles9) {
187
+ function renderDynamicFields(fields, styles8) {
211
188
  if (fields.length === 0) return null;
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;
189
+ const containerStyle = styles8?.container || { marginBottom: 8 };
190
+ const rowStyle = styles8?.row || dynamicFieldStyles.detailRow;
191
+ const labelStyle = styles8?.label || dynamicFieldStyles.detailLabel;
192
+ const valueStyle = styles8?.value || dynamicFieldStyles.detailValue;
216
193
  return /* @__PURE__ */ jsx(View, { style: containerStyle, children: fields.map(([key, value]) => /* @__PURE__ */ jsxs(View, { style: rowStyle, children: [
217
194
  /* @__PURE__ */ jsxs(Text, { style: labelStyle, children: [
218
195
  formatFieldName(key),
@@ -256,7 +233,7 @@ function mergeTemplateConfig(config = {}) {
256
233
  ...config
257
234
  };
258
235
  }
259
- var styles2 = StyleSheet.create({
236
+ var styles = StyleSheet.create({
260
237
  productContainer: {
261
238
  flexDirection: "row",
262
239
  flexWrap: "wrap",
@@ -320,27 +297,27 @@ var styles2 = StyleSheet.create({
320
297
  }
321
298
  });
322
299
  var Template1 = ({ products }) => {
323
- return /* @__PURE__ */ jsx(View, { style: styles2.productContainer, children: products.map((product, index) => {
300
+ return /* @__PURE__ */ jsx(View, { style: styles.productContainer, children: products.map((product, index) => {
324
301
  const fields = extractProductFields(product);
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
+ return /* @__PURE__ */ jsxs(View, { style: styles.productSection, children: [
303
+ /* @__PURE__ */ jsx(Image, { style: styles.image, src: fields.imageUrl }),
304
+ /* @__PURE__ */ jsxs(View, { style: styles.productTitleBox, children: [
305
+ /* @__PURE__ */ jsx(Text, { style: styles.productTitle, children: fields.title }),
306
+ renderRating(fields.rating, styles.productRate)
330
307
  ] }),
331
- fields.description && /* @__PURE__ */ jsx(Text, { style: styles2.productDescription, children: fields.description }),
308
+ fields.description && /* @__PURE__ */ jsx(Text, { style: styles.productDescription, children: fields.description }),
332
309
  renderDynamicFields(fields.dynamicFields),
333
310
  renderBuyButton(
334
311
  fields.link,
335
- styles2.buyButton,
312
+ styles.buyButton,
336
313
  "Buy Now",
337
- renderPrice(fields.price, styles2.productPrice)
314
+ renderPrice(fields.price, styles.productPrice)
338
315
  )
339
316
  ] }, index);
340
317
  }) });
341
318
  };
342
319
  var Template1_default = Template1;
343
- var styles3 = StyleSheet.create({
320
+ var styles2 = StyleSheet.create({
344
321
  productContainer: {
345
322
  flexDirection: "row",
346
323
  flexWrap: "wrap",
@@ -417,14 +394,14 @@ var styles3 = StyleSheet.create({
417
394
  }
418
395
  });
419
396
  var Template2 = ({ products }) => {
420
- return /* @__PURE__ */ jsx(View, { style: styles3.productContainer, children: products.map((product, index) => {
397
+ return /* @__PURE__ */ jsx(View, { style: styles2.productContainer, children: products.map((product, index) => {
421
398
  const fields = extractProductFields(product);
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)
399
+ return /* @__PURE__ */ jsxs(View, { style: styles2.productSection, children: [
400
+ /* @__PURE__ */ jsxs(View, { style: styles2.productSectionImage, children: [
401
+ /* @__PURE__ */ jsx(Image, { style: styles2.image, src: fields.imageUrl }),
402
+ renderRating(fields.rating, styles2.productRate)
426
403
  ] }),
427
- /* @__PURE__ */ jsxs(View, { style: styles3.productSectionText, children: [
404
+ /* @__PURE__ */ jsxs(View, { style: styles2.productSectionText, children: [
428
405
  /* @__PURE__ */ jsxs(
429
406
  View,
430
407
  {
@@ -434,20 +411,20 @@ var Template2 = ({ products }) => {
434
411
  justifyContent: "space-between"
435
412
  },
436
413
  children: [
437
- /* @__PURE__ */ jsx(Text, { style: styles3.productTitle, children: fields.title }),
438
- renderPrice(fields.price, styles3.productPrice)
414
+ /* @__PURE__ */ jsx(Text, { style: styles2.productTitle, children: fields.title }),
415
+ renderPrice(fields.price, styles2.productPrice)
439
416
  ]
440
417
  }
441
418
  ),
442
- fields.description && /* @__PURE__ */ jsx(Text, { style: styles3.productDescription, children: fields.description }),
419
+ fields.description && /* @__PURE__ */ jsx(Text, { style: styles2.productDescription, children: fields.description }),
443
420
  renderDynamicFields(fields.dynamicFields),
444
- renderBuyButton(fields.link, styles3.buyButton)
421
+ renderBuyButton(fields.link, styles2.buyButton)
445
422
  ] })
446
423
  ] }, index);
447
424
  }) });
448
425
  };
449
426
  var Template2_default = Template2;
450
- var styles4 = StyleSheet.create({
427
+ var styles3 = StyleSheet.create({
451
428
  productSection: {
452
429
  width: "100%",
453
430
  height: "100vh",
@@ -527,10 +504,10 @@ var compactDynamicFieldStyles = StyleSheet.create({
527
504
  var Template3 = ({ products }) => {
528
505
  return /* @__PURE__ */ jsx(Fragment, { children: products.map((product, index) => {
529
506
  const fields = extractProductFields(product, { maxDynamicFields: 5 });
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 }),
507
+ return /* @__PURE__ */ jsxs(View, { style: styles3.productSection, children: [
508
+ /* @__PURE__ */ jsx(Image, { style: styles3.image, src: fields.imageUrl }),
509
+ /* @__PURE__ */ jsxs(View, { style: styles3.productDetailsBox, children: [
510
+ /* @__PURE__ */ jsx(Text, { style: styles3.productTitle, children: fields.title }),
534
511
  /* @__PURE__ */ jsxs(
535
512
  View,
536
513
  {
@@ -540,25 +517,25 @@ var Template3 = ({ products }) => {
540
517
  justifyContent: "space-between"
541
518
  },
542
519
  children: [
543
- renderPrice(fields.price, styles4.productPrice),
544
- renderRating(fields.rating, styles4.productRate)
520
+ renderPrice(fields.price, styles3.productPrice),
521
+ renderRating(fields.rating, styles3.productRate)
545
522
  ]
546
523
  }
547
524
  ),
548
- fields.description && /* @__PURE__ */ jsx(Text, { style: styles4.productDescription, children: fields.description }),
525
+ fields.description && /* @__PURE__ */ jsx(Text, { style: styles3.productDescription, children: fields.description }),
549
526
  renderDynamicFields(fields.dynamicFields, {
550
527
  row: compactDynamicFieldStyles.detailRow,
551
528
  label: compactDynamicFieldStyles.detailLabel,
552
529
  value: compactDynamicFieldStyles.detailValue
553
530
  }),
554
- renderBuyButton(fields.link, styles4.buyButton)
531
+ renderBuyButton(fields.link, styles3.buyButton)
555
532
  ] }),
556
533
  /* @__PURE__ */ jsx(View, { break: true })
557
534
  ] }, index);
558
535
  }) });
559
536
  };
560
537
  var Template3_default = Template3;
561
- var styles5 = StyleSheet.create({
538
+ var styles4 = StyleSheet.create({
562
539
  page: {
563
540
  width: "100%",
564
541
  height: "100%",
@@ -655,21 +632,21 @@ var Template4 = ({
655
632
  )
656
633
  );
657
634
  const fields = extractProductFields(product);
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 })
635
+ return /* @__PURE__ */ jsxs(View, { style: styles4.page, children: [
636
+ /* @__PURE__ */ jsxs(View, { style: styles4.header, children: [
637
+ /* @__PURE__ */ jsx(Text, { style: styles4.companyName, children: companyName || "" }),
638
+ companyLogo && /* @__PURE__ */ jsx(Image, { style: styles4.brandLogo, src: companyLogo })
662
639
  ] }),
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) })
640
+ /* @__PURE__ */ jsxs(View, { style: styles4.productContainer, children: [
641
+ /* @__PURE__ */ jsx(Image, { style: styles4.productImage, src: fields.imageUrl }),
642
+ allFields.length > 0 && /* @__PURE__ */ jsx(View, { style: styles4.detailsBox, children: renderFieldsInColumns(allFields) })
666
643
  ] }),
667
644
  /* @__PURE__ */ jsx(View, { break: true })
668
645
  ] }, index);
669
646
  }) });
670
647
  };
671
648
  var Template4_default = Template4;
672
- var styles6 = StyleSheet.create({
649
+ var styles5 = StyleSheet.create({
673
650
  page: {
674
651
  width: "100%",
675
652
  height: "100%",
@@ -782,22 +759,22 @@ var Template5 = ({
782
759
  const { imageUrl, title, dynamicFields } = extractProductFields(product);
783
760
  const image2Url = getImage2Url(product);
784
761
  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 })
762
+ return /* @__PURE__ */ jsxs(View, { style: styles5.page, children: [
763
+ /* @__PURE__ */ jsxs(View, { style: styles5.header, children: [
764
+ companyLogo && /* @__PURE__ */ jsx(Image, { style: styles5.logo, src: companyLogo }),
765
+ /* @__PURE__ */ jsx(Text, { style: styles5.companyName, children: companyName })
789
766
  ] }),
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 }) })
767
+ /* @__PURE__ */ jsxs(View, { style: styles5.contentContainer, children: [
768
+ /* @__PURE__ */ jsxs(View, { style: styles5.imageSection, children: [
769
+ /* @__PURE__ */ jsx(View, { style: styles5.imageWrapper, children: /* @__PURE__ */ jsx(Image, { style: styles5.productImage, src: imageUrl }) }),
770
+ /* @__PURE__ */ jsx(View, { style: styles5.imageWrapper, children: /* @__PURE__ */ jsx(Image, { style: styles5.productImage, src: secondImage }) })
794
771
  ] }),
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
772
+ /* @__PURE__ */ jsxs(View, { style: styles5.detailsSection, children: [
773
+ title && /* @__PURE__ */ jsx(Text, { style: styles5.productTitle, children: title }),
774
+ /* @__PURE__ */ jsx(View, { style: styles5.dynamicFieldsContainer, children: renderDynamicFields(dynamicFields, {
775
+ row: styles5.detailRow,
776
+ label: styles5.detailLabel,
777
+ value: styles5.detailValue
801
778
  }) })
802
779
  ] })
803
780
  ] }),
@@ -806,7 +783,7 @@ var Template5 = ({
806
783
  }) });
807
784
  };
808
785
  var Template5_default = Template5;
809
- var styles7 = StyleSheet.create({
786
+ var styles6 = StyleSheet.create({
810
787
  page: {
811
788
  width: "100%",
812
789
  height: "100%",
@@ -947,26 +924,26 @@ var Template6 = ({
947
924
  const { imageUrl, title, dynamicFields } = extractProductFields(product);
948
925
  const image2Url = getImage2Url2(product);
949
926
  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" })
927
+ return /* @__PURE__ */ jsxs(View, { style: styles6.page, children: [
928
+ /* @__PURE__ */ jsxs(View, { style: styles6.leftColumn, children: [
929
+ /* @__PURE__ */ jsx(Image, { style: styles6.imageFull, src: imageUrl }),
930
+ /* @__PURE__ */ jsxs(View, { style: styles6.specsOverlay, children: [
931
+ /* @__PURE__ */ jsxs(View, { style: styles6.specsHeader, children: [
932
+ companyLogo && /* @__PURE__ */ jsx(Image, { style: styles6.miniLogo, src: companyLogo }),
933
+ /* @__PURE__ */ jsx(Text, { style: styles6.designNumber, children: title || "Specifications" })
957
934
  ] }),
958
935
  renderDynamicFields(dynamicFields, {
959
- row: styles7.fieldRow,
960
- label: styles7.fieldLabel,
961
- value: styles7.fieldValue
936
+ row: styles6.fieldRow,
937
+ label: styles6.fieldLabel,
938
+ value: styles6.fieldValue
962
939
  })
963
940
  ] })
964
941
  ] }),
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 })
942
+ /* @__PURE__ */ jsxs(View, { style: styles6.rightColumn, children: [
943
+ /* @__PURE__ */ jsx(View, { style: styles6.rightImageContainer, children: /* @__PURE__ */ jsx(Image, { style: styles6.rightImage, src: secondImage }) }),
944
+ /* @__PURE__ */ jsx(View, { style: styles6.footer, children: /* @__PURE__ */ jsxs(View, { style: styles6.footerContent, children: [
945
+ companyLogo && /* @__PURE__ */ jsx(Image, { style: styles6.footerLogo, src: companyLogo }),
946
+ /* @__PURE__ */ jsx(Text, { style: styles6.footerText, children: companyName })
970
947
  ] }) })
971
948
  ] }),
972
949
  /* @__PURE__ */ jsx(View, { break: true })
@@ -974,7 +951,7 @@ var Template6 = ({
974
951
  }) });
975
952
  };
976
953
  var Template6_default = Template6;
977
- var styles8 = StyleSheet.create({
954
+ var styles7 = StyleSheet.create({
978
955
  page: {
979
956
  flexDirection: "column",
980
957
  backgroundColor: "#FFFFFF"
@@ -1032,45 +1009,38 @@ async function generateProductCatalog(config) {
1032
1009
  TemplateComponent = Template1_default;
1033
1010
  }
1034
1011
  if (template === "template4") {
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
- ] }) });
1012
+ const doc2 = /* @__PURE__ */ jsx(Document, { children: /* @__PURE__ */ jsx(Page, { size: "A4", style: styles7.page, children: /* @__PURE__ */ jsx(
1013
+ Template4_default,
1014
+ {
1015
+ products,
1016
+ companyLogo,
1017
+ companyName
1018
+ }
1019
+ ) }) });
1046
1020
  const blob2 = await pdf(doc2).toBlob();
1047
1021
  const arrayBuffer2 = await blob2.arrayBuffer();
1048
1022
  return new Uint8Array(arrayBuffer2);
1049
1023
  }
1050
1024
  if (template === "template5" || template === "template6") {
1051
1025
  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
- ] }) });
1026
+ const doc2 = /* @__PURE__ */ jsx(Document, { children: /* @__PURE__ */ jsx(Page, { size: "A4", orientation: "landscape", style: styles7.page, children: /* @__PURE__ */ jsx(
1027
+ Template,
1028
+ {
1029
+ products,
1030
+ companyLogo,
1031
+ companyName
1032
+ }
1033
+ ) }) });
1063
1034
  const blob2 = await pdf(doc2).toBlob();
1064
1035
  const arrayBuffer2 = await blob2.arrayBuffer();
1065
1036
  return new Uint8Array(arrayBuffer2);
1066
1037
  }
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 }) })
1038
+ const doc = /* @__PURE__ */ jsx(Document, { children: /* @__PURE__ */ jsxs(Page, { size: "A4", style: styles7.page, children: [
1039
+ /* @__PURE__ */ jsxs(View, { style: styles7.header, children: [
1040
+ companyLogo && /* @__PURE__ */ jsx(View, { style: styles7.logoSection, children: /* @__PURE__ */ jsx(Image, { style: styles7.logo, src: companyLogo }) }),
1041
+ /* @__PURE__ */ jsx(View, { style: styles7.storeNameSection, children: /* @__PURE__ */ jsx(Text, { style: styles7.storeName, children: companyName }) })
1071
1042
  ] }),
1072
- /* @__PURE__ */ jsx(TemplateComponent, { products }),
1073
- /* @__PURE__ */ jsx(PoweredByTeziApp_default, {})
1043
+ /* @__PURE__ */ jsx(TemplateComponent, { products })
1074
1044
  ] }) });
1075
1045
  const blob = await pdf(doc).toBlob();
1076
1046
  const arrayBuffer = await blob.arrayBuffer();