pdf-catalog-generator 3.0.0 → 3.1.0

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
@@ -129,7 +129,12 @@ var KNOWN_FIELD_NAMES_LOWER = [
129
129
  "link",
130
130
  "url",
131
131
  "producturl",
132
- "href"
132
+ "href",
133
+ "image2",
134
+ "imageurl2",
135
+ "img2",
136
+ "photo2",
137
+ "picture2"
133
138
  ];
134
139
  function extractProductFields(product, options = {}) {
135
140
  const { maxDynamicFields, excludeFields = [] } = options;
@@ -179,12 +184,12 @@ var dynamicFieldStyles = StyleSheet.create({
179
184
  flexShrink: 1
180
185
  }
181
186
  });
182
- function renderDynamicFields(fields, styles6) {
187
+ function renderDynamicFields(fields, styles8) {
183
188
  if (fields.length === 0) return null;
184
- const containerStyle = styles6?.container || { marginBottom: 8 };
185
- const rowStyle = styles6?.row || dynamicFieldStyles.detailRow;
186
- const labelStyle = styles6?.label || dynamicFieldStyles.detailLabel;
187
- const valueStyle = styles6?.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;
188
193
  return /* @__PURE__ */ jsx(View, { style: containerStyle, children: fields.map(([key, value]) => /* @__PURE__ */ jsxs(View, { style: rowStyle, children: [
189
194
  /* @__PURE__ */ jsxs(Text, { style: labelStyle, children: [
190
195
  formatFieldName(key),
@@ -642,6 +647,311 @@ var Template4 = ({
642
647
  };
643
648
  var Template4_default = Template4;
644
649
  var styles5 = StyleSheet.create({
650
+ page: {
651
+ width: "100%",
652
+ height: "100%",
653
+ position: "relative",
654
+ backgroundColor: "#FFFFFF",
655
+ flexDirection: "column"
656
+ },
657
+ header: {
658
+ height: 80,
659
+ display: "flex",
660
+ flexDirection: "row",
661
+ alignItems: "center",
662
+ paddingHorizontal: 30,
663
+ paddingTop: 20,
664
+ paddingBottom: 10,
665
+ borderBottomWidth: 1,
666
+ borderBottomColor: "#E0E0E0",
667
+ marginBottom: 10
668
+ },
669
+ logo: {
670
+ height: 50,
671
+ marginRight: 20,
672
+ objectFit: "contain"
673
+ },
674
+ companyName: {
675
+ fontSize: 24,
676
+ fontWeight: "bold",
677
+ color: "#333333",
678
+ letterSpacing: 1
679
+ },
680
+ contentContainer: {
681
+ flex: 1,
682
+ flexDirection: "row",
683
+ paddingHorizontal: 30,
684
+ paddingBottom: 30,
685
+ gap: 20
686
+ },
687
+ imageSection: {
688
+ flex: 2,
689
+ flexDirection: "row",
690
+ gap: 15
691
+ },
692
+ imageWrapper: {
693
+ flex: 1,
694
+ height: "100%",
695
+ backgroundColor: "#F9F9F9",
696
+ borderRadius: 4,
697
+ overflow: "hidden"
698
+ },
699
+ productImage: {
700
+ width: "100%",
701
+ height: "100%",
702
+ objectFit: "cover"
703
+ },
704
+ detailsSection: {
705
+ flex: 1,
706
+ backgroundColor: "#F5F5F5",
707
+ padding: 20,
708
+ borderRadius: 8,
709
+ justifyContent: "center"
710
+ },
711
+ productTitle: {
712
+ fontSize: 18,
713
+ fontWeight: "bold",
714
+ color: "#222222",
715
+ marginBottom: 15,
716
+ borderBottomWidth: 2,
717
+ borderBottomColor: "#333333",
718
+ paddingBottom: 5
719
+ },
720
+ dynamicFieldsContainer: {
721
+ gap: 8
722
+ },
723
+ detailRow: {
724
+ flexDirection: "row",
725
+ marginBottom: 6,
726
+ borderBottomWidth: 1,
727
+ borderBottomColor: "#E0E0E0",
728
+ paddingBottom: 4
729
+ },
730
+ detailLabel: {
731
+ fontSize: 10,
732
+ fontWeight: "bold",
733
+ color: "#555555",
734
+ width: "40%"
735
+ },
736
+ detailValue: {
737
+ fontSize: 10,
738
+ color: "#333333",
739
+ flex: 1,
740
+ flexWrap: "wrap"
741
+ }
742
+ });
743
+ function getImage2Url(product) {
744
+ const image2Fields = ["image2", "imageurl2", "img2", "photo2", "picture2"];
745
+ for (const field of image2Fields) {
746
+ const value = product[field];
747
+ if (value && typeof value === "string" && value.trim() !== "") {
748
+ return value;
749
+ }
750
+ }
751
+ return null;
752
+ }
753
+ var Template5 = ({
754
+ products,
755
+ companyLogo,
756
+ companyName
757
+ }) => {
758
+ return /* @__PURE__ */ jsx(Fragment, { children: products.map((product, index) => {
759
+ const { imageUrl, title, dynamicFields } = extractProductFields(product);
760
+ const image2Url = getImage2Url(product);
761
+ const secondImage = image2Url || imageUrl;
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 })
766
+ ] }),
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 }) })
771
+ ] }),
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
778
+ }) })
779
+ ] })
780
+ ] }),
781
+ /* @__PURE__ */ jsx(View, { break: true })
782
+ ] }, index);
783
+ }) });
784
+ };
785
+ var Template5_default = Template5;
786
+ var styles6 = StyleSheet.create({
787
+ page: {
788
+ width: "100%",
789
+ height: "100%",
790
+ flexDirection: "row",
791
+ backgroundColor: "#FFFFFF"
792
+ },
793
+ leftColumn: {
794
+ width: "50%",
795
+ height: "100%",
796
+ position: "relative",
797
+ borderRightWidth: 1,
798
+ borderRightColor: "#E0E0E0"
799
+ },
800
+ rightColumn: {
801
+ width: "50%",
802
+ height: "100%",
803
+ display: "flex",
804
+ flexDirection: "column",
805
+ position: "relative"
806
+ },
807
+ imageFull: {
808
+ width: "100%",
809
+ height: "100%",
810
+ objectFit: "cover"
811
+ },
812
+ rightImageContainer: {
813
+ flex: 1,
814
+ width: "100%",
815
+ position: "relative",
816
+ justifyContent: "center",
817
+ alignItems: "center",
818
+ padding: 20
819
+ },
820
+ rightImage: {
821
+ width: "100%",
822
+ height: "100%",
823
+ objectFit: "contain"
824
+ },
825
+ specsOverlay: {
826
+ position: "absolute",
827
+ bottom: 40,
828
+ // Lifted slightly from absolute bottom
829
+ right: 0,
830
+ backgroundColor: "#FFFFFF",
831
+ padding: 15,
832
+ width: "65%",
833
+ // Takes up a good chunk of the corner
834
+ borderTopLeftRadius: 4,
835
+ borderBottomLeftRadius: 4,
836
+ shadowColor: "#000",
837
+ shadowOpacity: 0.2,
838
+ shadowRadius: 3,
839
+ borderWidth: 1,
840
+ borderColor: "#EEEEEE"
841
+ },
842
+ specsHeader: {
843
+ flexDirection: "row",
844
+ alignItems: "center",
845
+ marginBottom: 10,
846
+ borderBottomWidth: 1,
847
+ borderBottomColor: "#333",
848
+ paddingBottom: 5
849
+ },
850
+ miniLogo: {
851
+ width: 20,
852
+ height: 20,
853
+ objectFit: "contain",
854
+ marginRight: 8
855
+ },
856
+ designNumber: {
857
+ fontSize: 12,
858
+ fontWeight: "bold",
859
+ color: "#000"
860
+ },
861
+ footer: {
862
+ height: 100,
863
+ backgroundColor: "#1A1A1A",
864
+ flexDirection: "row",
865
+ alignItems: "center",
866
+ justifyContent: "flex-end",
867
+ paddingHorizontal: 30,
868
+ width: "100%"
869
+ },
870
+ footerContent: {
871
+ flexDirection: "row",
872
+ alignItems: "center"
873
+ },
874
+ footerLogo: {
875
+ width: 40,
876
+ height: 40,
877
+ objectFit: "contain",
878
+ marginRight: 15,
879
+ backgroundColor: "#FFF",
880
+ // White background for logo visibility
881
+ padding: 2,
882
+ borderRadius: 2
883
+ },
884
+ footerText: {
885
+ color: "#FFFFFF",
886
+ fontSize: 14,
887
+ fontWeight: "bold",
888
+ letterSpacing: 1,
889
+ textTransform: "uppercase"
890
+ },
891
+ // Custom styles for dynamic fields in the overlay
892
+ fieldRow: {
893
+ flexDirection: "row",
894
+ marginBottom: 4
895
+ },
896
+ fieldLabel: {
897
+ fontSize: 9,
898
+ fontWeight: "bold",
899
+ color: "#333",
900
+ width: "40%"
901
+ },
902
+ fieldValue: {
903
+ fontSize: 9,
904
+ color: "#555",
905
+ flex: 1
906
+ }
907
+ });
908
+ function getImage2Url2(product) {
909
+ const image2Fields = ["image2", "imageurl2", "img2", "photo2", "picture2"];
910
+ for (const field of image2Fields) {
911
+ const value = product[field];
912
+ if (value && typeof value === "string" && value.trim() !== "") {
913
+ return value;
914
+ }
915
+ }
916
+ return null;
917
+ }
918
+ var Template6 = ({
919
+ products,
920
+ companyLogo,
921
+ companyName
922
+ }) => {
923
+ return /* @__PURE__ */ jsx(Fragment, { children: products.map((product, index) => {
924
+ const { imageUrl, title, dynamicFields } = extractProductFields(product);
925
+ const image2Url = getImage2Url2(product);
926
+ const secondImage = image2Url || imageUrl;
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" })
934
+ ] }),
935
+ renderDynamicFields(dynamicFields, {
936
+ row: styles6.fieldRow,
937
+ label: styles6.fieldLabel,
938
+ value: styles6.fieldValue
939
+ })
940
+ ] })
941
+ ] }),
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 })
947
+ ] }) })
948
+ ] }),
949
+ /* @__PURE__ */ jsx(View, { break: true })
950
+ ] }, index);
951
+ }) });
952
+ };
953
+ var Template6_default = Template6;
954
+ var styles7 = StyleSheet.create({
645
955
  page: {
646
956
  flexDirection: "column",
647
957
  backgroundColor: "#FFFFFF"
@@ -709,11 +1019,17 @@ async function generateProductCatalog(config) {
709
1019
  case "template4":
710
1020
  TemplateComponent = Template4_default;
711
1021
  break;
1022
+ case "template5":
1023
+ TemplateComponent = Template5_default;
1024
+ break;
1025
+ case "template6":
1026
+ TemplateComponent = Template6_default;
1027
+ break;
712
1028
  default:
713
1029
  TemplateComponent = Template1_default;
714
1030
  }
715
1031
  if (template === "template4") {
716
- const doc2 = /* @__PURE__ */ jsx(Document, { children: /* @__PURE__ */ jsx(Page, { size: "A4", style: styles5.page, children: /* @__PURE__ */ jsx(
1032
+ const doc2 = /* @__PURE__ */ jsx(Document, { children: /* @__PURE__ */ jsx(Page, { size: "A4", style: styles7.page, children: /* @__PURE__ */ jsx(
717
1033
  Template4_default,
718
1034
  {
719
1035
  products,
@@ -725,10 +1041,24 @@ async function generateProductCatalog(config) {
725
1041
  const arrayBuffer2 = await blob2.arrayBuffer();
726
1042
  return new Uint8Array(arrayBuffer2);
727
1043
  }
728
- const doc = /* @__PURE__ */ jsx(Document, { children: /* @__PURE__ */ jsxs(Page, { size: "A4", style: styles5.page, children: [
729
- /* @__PURE__ */ jsxs(View, { style: styles5.header, children: [
730
- companyLogo && /* @__PURE__ */ jsx(View, { style: styles5.logoSection, children: /* @__PURE__ */ jsx(Image, { style: styles5.logo, src: normalizeImageSource(companyLogo) }) }),
731
- /* @__PURE__ */ jsx(View, { style: styles5.storeNameSection, children: /* @__PURE__ */ jsx(Text, { style: styles5.storeName, children: companyName }) }),
1044
+ if (template === "template5" || template === "template6") {
1045
+ const Template = template === "template5" ? Template5_default : Template6_default;
1046
+ const doc2 = /* @__PURE__ */ jsx(Document, { children: /* @__PURE__ */ jsx(Page, { size: "A4", orientation: "landscape", style: styles7.page, children: /* @__PURE__ */ jsx(
1047
+ Template,
1048
+ {
1049
+ products,
1050
+ companyLogo: companyLogo ? normalizeImageSource(companyLogo) : void 0,
1051
+ companyName
1052
+ }
1053
+ ) }) });
1054
+ const blob2 = await pdf(doc2).toBlob();
1055
+ const arrayBuffer2 = await blob2.arrayBuffer();
1056
+ return new Uint8Array(arrayBuffer2);
1057
+ }
1058
+ const doc = /* @__PURE__ */ jsx(Document, { children: /* @__PURE__ */ jsxs(Page, { size: "A4", style: styles7.page, children: [
1059
+ /* @__PURE__ */ jsxs(View, { style: styles7.header, children: [
1060
+ companyLogo && /* @__PURE__ */ jsx(View, { style: styles7.logoSection, children: /* @__PURE__ */ jsx(Image, { style: styles7.logo, src: normalizeImageSource(companyLogo) }) }),
1061
+ /* @__PURE__ */ jsx(View, { style: styles7.storeNameSection, children: /* @__PURE__ */ jsx(Text, { style: styles7.storeName, children: companyName }) }),
732
1062
  /* @__PURE__ */ jsx(View, { break: true })
733
1063
  ] }),
734
1064
  /* @__PURE__ */ jsx(TemplateComponent, { products })
@@ -775,6 +1105,6 @@ function parseJSON(data) {
775
1105
  return data;
776
1106
  }
777
1107
 
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 };
1108
+ 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
1109
  //# sourceMappingURL=index.mjs.map
780
1110
  //# sourceMappingURL=index.mjs.map