@salla.sa/twilight-components 2.13.53 → 2.13.55

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.
Files changed (129) hide show
  1. package/dist/cjs/{Helper-134c96cd.js → Helper-11c2f7a7.js} +2 -2
  2. package/dist/cjs/Helper-11c2f7a7.js.map +1 -0
  3. package/dist/cjs/{app-globals-8f8d8f50.js → app-globals-db36c588.js} +5 -5
  4. package/dist/cjs/app-globals-db36c588.js.map +1 -0
  5. package/dist/cjs/loader.cjs.js +2 -2
  6. package/dist/cjs/salla-add-product-button_47.cjs.entry.js +1 -1
  7. package/dist/cjs/salla-add-product-button_47.cjs.entry.js.map +1 -1
  8. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  9. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  10. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  11. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  12. package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
  13. package/dist/cjs/salla-products-slider.cjs.entry.js +1 -1
  14. package/dist/cjs/salla-reviews.cjs.entry.js +11 -5
  15. package/dist/cjs/salla-reviews.cjs.entry.js.map +1 -1
  16. package/dist/cjs/twilight.cjs.js +2 -2
  17. package/dist/collection/Helpers/Helper.js +1 -1
  18. package/dist/collection/Helpers/Helper.js.map +1 -1
  19. package/dist/collection/components/salla-reviews/interfaces.js.map +1 -1
  20. package/dist/collection/components/salla-reviews/salla-reviews.js +97 -14
  21. package/dist/collection/components/salla-reviews/salla-reviews.js.map +1 -1
  22. package/dist/components/Helper.js +1 -1
  23. package/dist/components/Helper.js.map +1 -1
  24. package/dist/components/index.js +4 -4
  25. package/dist/components/index.js.map +1 -1
  26. package/dist/components/salla-quick-buy2.js.map +1 -1
  27. package/dist/components/salla-reviews.js +14 -5
  28. package/dist/components/salla-reviews.js.map +1 -1
  29. package/dist/esm/{Helper-6e1f8269.js → Helper-e84a53b2.js} +2 -2
  30. package/dist/esm/Helper-e84a53b2.js.map +1 -0
  31. package/dist/esm/{app-globals-c3c69e17.js → app-globals-29abf3e3.js} +5 -5
  32. package/dist/esm/app-globals-29abf3e3.js.map +1 -0
  33. package/dist/esm/loader.js +2 -2
  34. package/dist/esm/salla-add-product-button_47.entry.js +1 -1
  35. package/dist/esm/salla-add-product-button_47.entry.js.map +1 -1
  36. package/dist/esm/salla-filters-widget.entry.js +1 -1
  37. package/dist/esm/salla-filters.entry.js +1 -1
  38. package/dist/esm/salla-notifications.entry.js +1 -1
  39. package/dist/esm/salla-orders.entry.js +1 -1
  40. package/dist/esm/salla-products-list.entry.js +1 -1
  41. package/dist/esm/salla-products-slider.entry.js +1 -1
  42. package/dist/esm/salla-reviews.entry.js +11 -5
  43. package/dist/esm/salla-reviews.entry.js.map +1 -1
  44. package/dist/esm/twilight.js +2 -2
  45. package/dist/esm-es5/{Helper-6e1f8269.js → Helper-e84a53b2.js} +2 -2
  46. package/dist/esm-es5/Helper-e84a53b2.js.map +1 -0
  47. package/dist/esm-es5/{app-globals-c3c69e17.js → app-globals-29abf3e3.js} +3 -3
  48. package/dist/esm-es5/app-globals-29abf3e3.js.map +1 -0
  49. package/dist/esm-es5/loader.js +1 -1
  50. package/dist/esm-es5/loader.js.map +1 -1
  51. package/dist/esm-es5/salla-add-product-button_47.entry.js +1 -1
  52. package/dist/esm-es5/salla-add-product-button_47.entry.js.map +1 -1
  53. package/dist/esm-es5/salla-filters-widget.entry.js +1 -1
  54. package/dist/esm-es5/salla-filters.entry.js +1 -1
  55. package/dist/esm-es5/salla-notifications.entry.js +1 -1
  56. package/dist/esm-es5/salla-orders.entry.js +1 -1
  57. package/dist/esm-es5/salla-products-list.entry.js +1 -1
  58. package/dist/esm-es5/salla-products-slider.entry.js +1 -1
  59. package/dist/esm-es5/salla-reviews.entry.js +1 -1
  60. package/dist/esm-es5/salla-reviews.entry.js.map +1 -1
  61. package/dist/esm-es5/twilight.js +1 -1
  62. package/dist/esm-es5/twilight.js.map +1 -1
  63. package/dist/twilight/p-06221496.js +25 -0
  64. package/dist/twilight/p-06221496.js.map +1 -0
  65. package/dist/twilight/{p-868c776b.system.entry.js → p-1079c870.system.entry.js} +2 -2
  66. package/dist/twilight/{p-e7d5c03c.entry.js → p-20a47e29.entry.js} +2 -2
  67. package/dist/twilight/p-2866def3.system.entry.js +5 -0
  68. package/dist/twilight/p-2866def3.system.entry.js.map +1 -0
  69. package/dist/twilight/{p-d08d5f11.entry.js → p-508a9dbf.entry.js} +2 -2
  70. package/dist/twilight/p-546db59b.entry.js +5 -0
  71. package/dist/twilight/p-546db59b.entry.js.map +1 -0
  72. package/dist/twilight/{p-b0585915.system.entry.js → p-5be05a17.system.entry.js} +2 -2
  73. package/dist/twilight/{p-b0585915.system.entry.js.map → p-5be05a17.system.entry.js.map} +1 -1
  74. package/dist/twilight/{p-f629ebf3.js → p-5de9ca19.js} +2 -2
  75. package/dist/twilight/p-5de9ca19.js.map +1 -0
  76. package/dist/twilight/{p-49a5b997.entry.js → p-60d513b0.entry.js} +2 -2
  77. package/dist/twilight/{p-38e9e758.system.entry.js → p-69539ba8.system.entry.js} +2 -2
  78. package/dist/twilight/{p-7d3b8a00.entry.js → p-708b7673.entry.js} +2 -2
  79. package/dist/twilight/p-a7b263b2.system.js +25 -0
  80. package/dist/twilight/p-a7b263b2.system.js.map +1 -0
  81. package/dist/twilight/{p-b0c8cac2.entry.js → p-a859e3fc.entry.js} +2 -2
  82. package/dist/twilight/{p-e3444194.system.js → p-af17aa74.system.js} +2 -2
  83. package/dist/twilight/p-af17aa74.system.js.map +1 -0
  84. package/dist/twilight/{p-429870cc.entry.js → p-bc7cb3df.entry.js} +2 -2
  85. package/dist/twilight/{p-429870cc.entry.js.map → p-bc7cb3df.entry.js.map} +1 -1
  86. package/dist/twilight/{p-3e19dd7e.system.entry.js → p-dcb268c2.system.entry.js} +2 -2
  87. package/dist/twilight/{p-5e7ea64b.system.entry.js → p-e56c026b.system.entry.js} +2 -2
  88. package/dist/twilight/{p-09f168ed.system.entry.js → p-eed0af43.system.entry.js} +2 -2
  89. package/dist/twilight/{p-e8c4822f.system.entry.js → p-f493ef81.system.entry.js} +2 -2
  90. package/dist/twilight/p-f51c9acb.system.js +5 -0
  91. package/dist/twilight/{p-64d97ea7.system.js.map → p-f51c9acb.system.js.map} +1 -1
  92. package/dist/twilight/{p-9d552606.entry.js → p-f5e0d239.entry.js} +2 -2
  93. package/dist/twilight/twilight.esm.js +1 -1
  94. package/dist/twilight/twilight.esm.js.map +1 -1
  95. package/dist/twilight/twilight.js +1 -1
  96. package/dist/types/Helpers/Helper.d.ts +1 -1
  97. package/dist/types/components/salla-reviews/interfaces.d.ts +4 -2
  98. package/dist/types/components/salla-reviews/salla-reviews.d.ts +32 -6
  99. package/dist/types/components.d.ts +41 -9
  100. package/package.json +5 -5
  101. package/dist/cjs/Helper-134c96cd.js.map +0 -1
  102. package/dist/cjs/app-globals-8f8d8f50.js.map +0 -1
  103. package/dist/esm/Helper-6e1f8269.js.map +0 -1
  104. package/dist/esm/app-globals-c3c69e17.js.map +0 -1
  105. package/dist/esm-es5/Helper-6e1f8269.js.map +0 -1
  106. package/dist/esm-es5/app-globals-c3c69e17.js.map +0 -1
  107. package/dist/twilight/p-43badfba.js +0 -25
  108. package/dist/twilight/p-43badfba.js.map +0 -1
  109. package/dist/twilight/p-52f673f6.system.js +0 -25
  110. package/dist/twilight/p-52f673f6.system.js.map +0 -1
  111. package/dist/twilight/p-64d97ea7.system.js +0 -5
  112. package/dist/twilight/p-6b99863e.system.entry.js +0 -5
  113. package/dist/twilight/p-6b99863e.system.entry.js.map +0 -1
  114. package/dist/twilight/p-e3444194.system.js.map +0 -1
  115. package/dist/twilight/p-f209fb12.entry.js +0 -5
  116. package/dist/twilight/p-f209fb12.entry.js.map +0 -1
  117. package/dist/twilight/p-f629ebf3.js.map +0 -1
  118. /package/dist/twilight/{p-868c776b.system.entry.js.map → p-1079c870.system.entry.js.map} +0 -0
  119. /package/dist/twilight/{p-e7d5c03c.entry.js.map → p-20a47e29.entry.js.map} +0 -0
  120. /package/dist/twilight/{p-d08d5f11.entry.js.map → p-508a9dbf.entry.js.map} +0 -0
  121. /package/dist/twilight/{p-49a5b997.entry.js.map → p-60d513b0.entry.js.map} +0 -0
  122. /package/dist/twilight/{p-38e9e758.system.entry.js.map → p-69539ba8.system.entry.js.map} +0 -0
  123. /package/dist/twilight/{p-7d3b8a00.entry.js.map → p-708b7673.entry.js.map} +0 -0
  124. /package/dist/twilight/{p-b0c8cac2.entry.js.map → p-a859e3fc.entry.js.map} +0 -0
  125. /package/dist/twilight/{p-3e19dd7e.system.entry.js.map → p-dcb268c2.system.entry.js.map} +0 -0
  126. /package/dist/twilight/{p-5e7ea64b.system.entry.js.map → p-e56c026b.system.entry.js.map} +0 -0
  127. /package/dist/twilight/{p-09f168ed.system.entry.js.map → p-eed0af43.system.entry.js.map} +0 -0
  128. /package/dist/twilight/{p-e8c4822f.system.entry.js.map → p-f493ef81.system.entry.js.map} +0 -0
  129. /package/dist/twilight/{p-9d552606.entry.js.map → p-f5e0d239.entry.js.map} +0 -0
@@ -22,9 +22,12 @@ const SallaReviews$1 = /*@__PURE__*/ proxyCustomElement(class SallaReviews exten
22
22
  this.__registerHost();
23
23
  this.displayAllURL = null;
24
24
  this.displayAllLink = undefined;
25
- this.source = "store";
25
+ this.source = undefined;
26
26
  this.sourceValue = undefined;
27
27
  this.limit = 5;
28
+ this.type = "store";
29
+ this.sort = "latest";
30
+ this.hideCustomerInfo = false;
28
31
  this.reviews = [];
29
32
  this.isRTL = undefined;
30
33
  this.showReviews = false;
@@ -46,9 +49,12 @@ const SallaReviews$1 = /*@__PURE__*/ proxyCustomElement(class SallaReviews exten
46
49
  }
47
50
  const isJsonEncoded = ['products', 'categories'].includes(this.source);
48
51
  const params = {
49
- per_page: this.limit,
50
- type: this.source,
52
+ limit: this.limit,
53
+ source: this.source,
51
54
  items: isJsonEncoded ? JSON.parse(this.sourceValue) : this.sourceValue,
55
+ sort: this.sort,
56
+ type: this.type,
57
+ hide_customer_info: this.hideCustomerInfo
52
58
  };
53
59
  return salla.api.request('reviews', { params }, 'get');
54
60
  }
@@ -65,14 +71,17 @@ const SallaReviews$1 = /*@__PURE__*/ proxyCustomElement(class SallaReviews exten
65
71
  });
66
72
  }
67
73
  render() {
68
- return (h("div", { class: "s-reviews-container" }, h("div", { class: "s-reviews-header-wrapper" }, h("h1", { class: "s-reviews-header" }, this.testimonialText), !!this.displayAllLink ? (h("a", { href: this.displayAllURL, class: "s-reviews-display-all" }, this.displayAllLinkText, h("span", { class: "s-reviews-display-all-icon", innerHTML: IconArrowLeft }))) : null), h("salla-slider", { centered: true, "slides-per-view": 1, type: "testimonials", class: "s-reviews-testimonials-slider", "controls-outer": true, "auto-play": true, id: `testimonials-${this.source}-slider` }, h("div", { slot: "items" }, this.reviews.map((item, index) => (h("div", { key: index, class: "s-reviews-swiper-slide" }, h("div", { class: "s-reviews-testimonial" }, h("div", { class: "s-reviews-testimonial__inner" }, h("div", { class: "s-reviews-testimonial__avatar" }, h("img", { src: 'images/s-empty.png', "data-src": item.avatar, alt: item.name ? item.name : 'testimonial-' + index, class: "lazy" })), h("div", { class: "s-reviews-testimonial__text" }, h("p", null, item.text), h("div", { class: "s-reviews-testimonial__name_wrapper" }, h("div", { class: "s-reviews-testimonial__info" }, item.name && h("h2", null, `${item.name}`)), h("div", { class: "s-reviews-testimonial__rating" }, h("salla-rating-stars", { size: "small", value: item.rating })))), h("span", { class: "s-reviews-testimonial__icon", innerHTML: IconQuoteOpen }))))))))));
74
+ return (h("div", { class: "s-reviews-container" }, h("div", { class: "s-reviews-header-wrapper" }, h("h1", { class: "s-reviews-header" }, this.testimonialText), !!this.displayAllLink ? (h("a", { href: this.displayAllURL, class: "s-reviews-display-all" }, this.displayAllLinkText, h("span", { class: "s-reviews-display-all-icon", innerHTML: IconArrowLeft }))) : null), h("salla-slider", { centered: true, "slides-per-view": 1, type: "testimonials", class: "s-reviews-testimonials-slider", "controls-outer": true, "auto-play": true, id: `testimonials-${this.source}-slider` }, h("div", { slot: "items" }, this.reviews.map((item, index) => (h("div", { key: index, class: "s-reviews-swiper-slide" }, h("div", { class: "s-reviews-testimonial" }, h("div", { class: "s-reviews-testimonial__inner" }, h("div", { class: "s-reviews-testimonial__avatar" }, h("img", { src: 'images/s-empty.png', "data-src": item.avatar, alt: item.name ? item.name : 'testimonial-' + index, class: "lazy" })), h("div", { class: "s-reviews-testimonial__text" }, h("p", null, item.content), h("div", { class: "s-reviews-testimonial__name_wrapper" }, h("div", { class: "s-reviews-testimonial__info" }, item.name && h("h2", null, `${item.name}`)), h("div", { class: "s-reviews-testimonial__rating" }, h("salla-rating-stars", { size: "small", value: item.stars })))), h("span", { class: "s-reviews-testimonial__icon", innerHTML: IconQuoteOpen }))))))))));
69
75
  }
70
76
  static get style() { return sallaReviewsCss; }
71
77
  }, [0, "salla-reviews", {
72
78
  "displayAllLink": [516, "display-all-link"],
73
79
  "source": [513],
74
- "sourceValue": [520, "source-value"],
80
+ "sourceValue": [513, "source-value"],
75
81
  "limit": [514],
82
+ "type": [1],
83
+ "sort": [1],
84
+ "hideCustomerInfo": [4, "hide-customer-info"],
76
85
  "reviews": [32],
77
86
  "isRTL": [32],
78
87
  "showReviews": [32],
@@ -1 +1 @@
1
- {"file":"salla-reviews.js","mappings":";;;;;;;;;;;;;;;;AAAA,MAAM,eAAe,GAAG,EAAE;;MCYbA,cAAY;EACvB;;;IAkEQ,kBAAa,GAAG,IAAI,CAAA;;kBA7Bc,OAAO;;iBAoBhB,CAAC;mBAGA,EAAE;;uBAEJ,KAAK;2BACF,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,0BAA0B,CAAC;8BACvC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC;IA/D7E,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1B,KAAK,CAAC,OAAO,CAAC;MACZ,IAAI,CAAC,aAAa,GAAG,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AK,EAAC,qCAAqC,IAC9C,WAAK,KAAK,EAAC,6BAA6B,IACrC,IAAI,CAAC,IAAI,IAAI,cAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAM,CACnC,EACN,WAAK,KAAK,EAAC,+BAA+B,IAExC,0BAAoB,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,MAAM,GAAuB,CACtE,CACF,CACF,EAEN,YAAM,KAAK,EAAC,6BAA6B,EAAC,SAAS,EAAE,aAAa,GAAI,CAClE,CACF,CACF,CACP,CAAC,CACE,CACO,CACX,EACN;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SallaReviews"],"sources":["src/components/salla-reviews/salla-reviews.scss?tag=salla-reviews","src/components/salla-reviews/salla-reviews.tsx"],"sourcesContent":["","import { Component, Prop, State, h } from '@stencil/core';\nimport IconArrowLeft from '../../assets/svg/arrow-left.svg'\nimport IconQuoteOpen from '../../assets/svg/quote-open.svg'\n\nimport {Source, Review} from \"./interfaces\"\nimport Helper from '../../Helpers/Helper';\n\n\n@Component({\n tag: 'salla-reviews',\n styleUrl: 'salla-reviews.scss',\n})\nexport class SallaReviews {\n constructor(){\n this.source = this.source;\n salla.onReady(() => {\n this.displayAllURL = salla.url.get('testimonials')\n this.isRTL = salla.config.get('theme.is_rtl', true)\n })\n\n salla.lang.onLoaded(() => { \n this.testimonialText = salla.lang.get('blocks.home.testimonials')\n this.displayAllLinkText = salla.lang.get('blocks.home.display_all')\n })\n }\n\n /**\n * Controls the visibility of a link to the reviews page.\n * \n * When set to `true`, a link will be displayed allowing users to navigate to the full reviews section.\n * \n * @type {boolean}\n */\n @Prop({ reflect: true }) displayAllLink: boolean\n\n /**\n * Specifies the data source for reviews.\n * \n * Valid options include:\n * - 'store': Retrieves reviews for the entire store.\n * - 'all': Retrieves reviews from all sources.\n * - 'categories': Retrieves reviews for specific product categories.\n * - 'products': Retrieves reviews for individual products.\n * - 'json': Retrieves reviews from a custom JSON payload provided in `sourceValue`.\n * \n * When using 'json' as the source, a valid payload must be provided in `sourceValue`.\n * \n * @type {Source}\n * @default \"store\"\n */\n @Prop({ reflect: true }) source: Source = \"store\";\n\n /**\n * Provides data specific to the chosen source.\n * \n * Required when using 'categories', 'products', or 'json' as the source:\n * - 'categories': An array of category IDs.\n * - 'products': An array of product IDs.\n * - 'json': A custom JSON object containing review data.\n * \n * @type {number | string | object | Array<string | number>}\n */\n @Prop({ reflect: true }) sourceValue: number | string | object | Array<string | number>;\n\n /**\n * Defines the maximum number of reviews to retrieve from the API.\n * \n * @type {number}\n * @default 5\n */\n @Prop({ reflect: true }) limit = 5\n\n\n @State() reviews: Array<Review> = [];\n @State() isRTL: boolean\n @State() showReviews: boolean = false;\n @State() testimonialText: string = salla.lang.get('blocks.home.testimonials');\n @State() displayAllLinkText: string = salla.lang.get('blocks.home.display_all');\n\n private displayAllURL = null\n\n fetchReviews() {\n if (this.source === 'json') {\n return Promise.resolve(JSON.parse(this.sourceValue as string));\n }\n const isJsonEncoded = ['products', 'categories'].includes(this.source);\n const params = {\n per_page: this.limit,\n type: this.source,\n items: isJsonEncoded ? JSON.parse(this.sourceValue as string) : this.sourceValue,\n };\n return salla.api.request('reviews', { params }, 'get');\n }\n\n\n componentWillLoad() {\n return (new Promise(resolve => salla.onReady(resolve)))\n .then(() => this.fetchReviews())\n .then((resp) => resp.data || [])\n .then(reviews => {\n if (reviews.length) {\n this.reviews = reviews;\n this.showReviews = true;\n Helper.generateReviewSchema(this.reviews);\n }\n });\n }\n\n render() {\n return (\n <div class=\"s-reviews-container\">\n <div class=\"s-reviews-header-wrapper\">\n <h1 class=\"s-reviews-header\">\n {this.testimonialText}\n </h1>\n {!!this.displayAllLink ? (\n <a href={this.displayAllURL} class=\"s-reviews-display-all\">\n {this.displayAllLinkText}\n <span class=\"s-reviews-display-all-icon\" innerHTML={IconArrowLeft} />\n </a>\n ) : null}\n </div>\n <salla-slider\n centered\n slides-per-view={1}\n type=\"testimonials\"\n class=\"s-reviews-testimonials-slider\"\n controls-outer\n auto-play\n id={`testimonials-${this.source}-slider`}\n >\n <div slot=\"items\">\n {this.reviews.map((item: Review, index) => (\n <div key={index} class=\"s-reviews-swiper-slide\">\n <div class=\"s-reviews-testimonial\">\n <div class=\"s-reviews-testimonial__inner\">\n <div class=\"s-reviews-testimonial__avatar\">\n <img\n src={'images/s-empty.png'}\n data-src={item.avatar}\n alt={item.name ? item.name : 'testimonial-' + index}\n class=\"lazy\"\n />\n </div>\n <div class=\"s-reviews-testimonial__text\">\n <p>{item.text}</p>\n <div class=\"s-reviews-testimonial__name_wrapper\">\n <div class=\"s-reviews-testimonial__info\">\n {item.name && <h2>{`${item.name}`}</h2>}\n </div>\n <div class=\"s-reviews-testimonial__rating\">\n {/* TODO stars is missing */}\n <salla-rating-stars size=\"small\" value={item.rating}></salla-rating-stars>\n </div>\n </div>\n </div>\n\n <span class=\"s-reviews-testimonial__icon\" innerHTML={IconQuoteOpen} />\n </div>\n </div>\n </div>\n ))}\n </div>\n </salla-slider>\n </div>\n );\n }\n\n}\n\n"],"version":3}
1
+ {"file":"salla-reviews.js","mappings":";;;;;;;;;;;;;;;;AAAA,MAAM,eAAe,GAAG,EAAE;;MCYbA,cAAY;EACvB;;;IAkGQ,kBAAa,GAAG,IAAI,CAAA;;;;iBA3CK,CAAC;gBAaP,OAAO;gBAaJ,QAAQ;4BAQF,KAAK;mBAGP,EAAE;;uBAEJ,KAAK;2BACF,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,0BAA0B,CAAC;8BACvC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC;IA/F7E,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1B,KAAK,CAAC,OAAO,CAAC;MACZ,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;MAClD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM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,WAAK,KAAK,EAAC,qCAAqC,IAC9C,WAAK,KAAK,EAAC,6BAA6B,IACrC,IAAI,CAAC,IAAI,IAAI,cAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAM,CACnC,EACN,WAAK,KAAK,EAAC,+BAA+B,IAExC,0BAAoB,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAuB,CACrE,CACF,CACF,EAEN,YAAM,KAAK,EAAC,6BAA6B,EAAC,SAAS,EAAE,aAAa,GAAI,CAClE,CACF,CACF,CACP,CAAC,CACE,CACO,CACX,EACN;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SallaReviews"],"sources":["src/components/salla-reviews/salla-reviews.scss?tag=salla-reviews","src/components/salla-reviews/salla-reviews.tsx"],"sourcesContent":["","import { Component, Prop, State, h } from '@stencil/core';\nimport IconArrowLeft from '../../assets/svg/arrow-left.svg'\nimport IconQuoteOpen from '../../assets/svg/quote-open.svg'\n\nimport {Source, Review, ReviewType, SortingOption} from \"./interfaces\"\nimport Helper from '../../Helpers/Helper';\n\n\n@Component({\n tag: 'salla-reviews',\n styleUrl: 'salla-reviews.scss',\n})\nexport class SallaReviews {\n constructor(){\n this.source = this.source;\n salla.onReady(() => {\n this.displayAllURL = salla.url.get('testimonials')\n this.isRTL = salla.config.get('theme.is_rtl', true)\n })\n\n salla.lang.onLoaded(() => { \n this.testimonialText = salla.lang.get('blocks.home.testimonials')\n this.displayAllLinkText = salla.lang.get('blocks.home.display_all')\n })\n }\n\n /**\n * Controls the visibility of a link to the reviews page.\n * \n * When set to `true`, a link will be displayed allowing users to navigate to the full reviews section.\n * \n * @type {boolean}\n */\n @Prop({ reflect: true }) displayAllLink: boolean\n\n /**\n * Specifies the data source for reviews.\n * \n * Valid options include:\n * - 'categories': Retrieves reviews for specific product categories.\n * - 'products': Retrieves reviews for individual products.\n * - 'json': Retrieves reviews from a custom JSON payload provided in `sourceValue`.\n * \n * When using 'json' as the source, a valid payload must be provided in `sourceValue`.\n * \n * @type {Source}\n * @default \"store\"\n */\n @Prop({ reflect: true }) source?: Source;\n\n /**\n * Provides data specific to the chosen source.\n * \n * Required when using 'categories', 'products', or 'json' as the source:\n * - 'categories': An array of category IDs.\n * - 'products': An array of product IDs.\n * - 'json': A custom JSON object containing review data.\n * \n * @type {string | object | Array<number>}\n */\n @Prop({ reflect: true }) sourceValue?: string | object | Array<number>;\n\n /**\n * Defines the maximum number of reviews to retrieve from the API.\n * \n * @type {number}\n * @default 5\n */\n @Prop({ reflect: true }) limit = 5\n\n\n /**\n * Specifies the type of reviews to fetch.\n * Available options:\n * - \"all\": Fetches reviews from all sources.\n * - \"store\": Fetches reviews specific to the store.\n * - \"products\": Fetches reviews specific to products.\n * \n * @type {ReviewType}\n * @default store\n */\n @Prop() type: ReviewType = \"store\";\n\n\n /**\n * Specifies the sorting criteria for the fetched reviews.\n * Available options:\n * - \"top_rating\": Sorts reviews based on top ratings.\n * - \"random\": Sorts reviews randomly.\n * - \"latest\": Sorts reviews based on the latest ones (default).\n * \n * @type {SortingOption}\n * @default latest\n */\n @Prop() sort: SortingOption = \"latest\";\n\n\n /**\n * Specifies whether to hide customer information in the component.\n * When set to true, customer information will be hidden.\n * Defaults to false, meaning customer information will be displayed.\n */\n @Prop() hideCustomerInfo: boolean = false;\n\n\n @State() reviews: Array<Review> = [];\n @State() isRTL: boolean\n @State() showReviews: boolean = false;\n @State() testimonialText: string = salla.lang.get('blocks.home.testimonials');\n @State() displayAllLinkText: string = salla.lang.get('blocks.home.display_all');\n\n private displayAllURL = null\n\n fetchReviews() {\n if (this.source === 'json') {\n return Promise.resolve(JSON.parse(this.sourceValue as string));\n }\n const isJsonEncoded = ['products', 'categories'].includes(this.source);\n const params = {\n limit: this.limit,\n source: this.source,\n items: isJsonEncoded ? JSON.parse(this.sourceValue as string) : this.sourceValue,\n sort: this.sort,\n type: this.type,\n hide_customer_info: this.hideCustomerInfo\n };\n return salla.api.request('reviews', { params }, 'get');\n }\n\n\n componentWillLoad() {\n return (new Promise(resolve => salla.onReady(resolve)))\n .then(() => this.fetchReviews())\n .then((resp) => resp.data || [])\n .then(reviews => {\n if (reviews.length) {\n this.reviews = reviews;\n this.showReviews = true;\n Helper.generateReviewSchema(this.reviews);\n }\n });\n }\n\n render() {\n return (\n <div class=\"s-reviews-container\">\n <div class=\"s-reviews-header-wrapper\">\n <h1 class=\"s-reviews-header\">\n {this.testimonialText}\n </h1>\n {!!this.displayAllLink ? (\n <a href={this.displayAllURL} class=\"s-reviews-display-all\">\n {this.displayAllLinkText}\n <span class=\"s-reviews-display-all-icon\" innerHTML={IconArrowLeft} />\n </a>\n ) : null}\n </div>\n <salla-slider\n centered\n slides-per-view={1}\n type=\"testimonials\"\n class=\"s-reviews-testimonials-slider\"\n controls-outer\n auto-play\n id={`testimonials-${this.source}-slider`}\n >\n <div slot=\"items\">\n {this.reviews.map((item: Review, index) => (\n <div key={index} class=\"s-reviews-swiper-slide\">\n <div class=\"s-reviews-testimonial\">\n <div class=\"s-reviews-testimonial__inner\">\n <div class=\"s-reviews-testimonial__avatar\">\n <img\n src={'images/s-empty.png'}\n data-src={item.avatar}\n alt={item.name ? item.name : 'testimonial-' + index}\n class=\"lazy\"\n />\n </div>\n <div class=\"s-reviews-testimonial__text\">\n <p>{item.content}</p>\n <div class=\"s-reviews-testimonial__name_wrapper\">\n <div class=\"s-reviews-testimonial__info\">\n {item.name && <h2>{`${item.name}`}</h2>}\n </div>\n <div class=\"s-reviews-testimonial__rating\">\n {/* TODO stars is missing */}\n <salla-rating-stars size=\"small\" value={item.stars}></salla-rating-stars>\n </div>\n </div>\n </div>\n\n <span class=\"s-reviews-testimonial__icon\" innerHTML={IconQuoteOpen} />\n </div>\n </div>\n </div>\n ))}\n </div>\n </salla-slider>\n </div>\n );\n }\n\n}\n\n"],"version":3}
@@ -292,7 +292,7 @@ class Helper {
292
292
  return {
293
293
  "@type": "Review",
294
294
  "author": reviewData.name,
295
- "datePublished": Date.parse(reviewData.created_at.date).toString(),
295
+ "datePublished": reviewData.date * 1000,
296
296
  "description": reviewData.content,
297
297
  "reviewRating": {
298
298
  "@type": "Rating",
@@ -320,4 +320,4 @@ const Helper$1 = new Helper;
320
320
 
321
321
  export { Helper$1 as H };
322
322
 
323
- //# sourceMappingURL=Helper-6e1f8269.js.map
323
+ //# sourceMappingURL=Helper-e84a53b2.js.map
@@ -0,0 +1 @@
1
+ {"file":"Helper-e84a53b2.js","mappings":";;;;;AAMA;AACA,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;AAEjC,MAAM,MAAM;EAGV,oBAAoB,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ;IACxD,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpE,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpE,IAAI,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACnC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC,MAAM,CAAC,IAAI,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;IACjE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC,GAAG,CAAC,IAAI,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;IAC9D,OAAO,IAAI,CAAC;GACb;EAED,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ;IAClD,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,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EAAE,gBAAgB;MACzB,MAAM,EAAE,eAAe;MACvB,aAAa,EAAE,6BAA6B;MAC5C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;KACnE,CAAA;IAED,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC5C,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;GACnC;CACF;AAED,iBAAe,IAAI,MAAM;;;;","names":[],"sources":["src/Helpers/Helper.ts"],"sourcesContent":["import { ProductDetail, ProductResponse } from \"@salla.sa/twilight/types/api/product\";\nimport { Review } from \"../../src/components/salla-reviews/interfaces\";\nimport { Product as SallaProduct } from \"@salla.sa/twilight/types/common\";\nimport { ListItem, ItemList, Product as SchemaProduct, WithContext } from 'schema-dts';\nimport anime from 'animejs';\n\n//TODO::reduce it to 10\nsalla.event.setMaxListeners(100);\n\nclass Helper {\n private debounce_: any;\n\n toggleElementClassIf(element, classes1, classes2, callback) {\n classes1 = Array.isArray(classes1) ? classes1 : classes1.split(' ');\n classes2 = Array.isArray(classes2) ? classes2 : classes2.split(' ');\n let isClasses1 = callback(element);\n element?.classList.remove(...(isClasses1 ? classes2 : classes1));\n element?.classList.add(...(isClasses1 ? classes1 : classes2));\n return this;\n }\n\n toggleClassIf(selector, classes1, classes2, callback) {\n document.querySelectorAll(selector).forEach(element => this.toggleElementClassIf(element, classes1, classes2, callback));\n return this;\n }\n\n isValidEmail(email) {\n const re = /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n return re.test(String(email).toLowerCase());\n }\n\n filterEmojies(text) {\n var characterFilter = /(?:[\\u2700-\\u27bf]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\u0023-\\u0039]\\ufe0f?\\u20e3|\\u3299|\\u3297|\\u303d|\\u3030|\\u24c2|\\ud83c[\\udd70-\\udd71]|\\ud83c[\\udd7e-\\udd7f]|\\ud83c\\udd8e|\\ud83c[\\udd91-\\udd9a]|\\ud83c[\\udde6-\\uddff]|\\ud83c[\\ude01-\\ude02]|\\ud83c\\ude1a|\\ud83c\\ude2f|\\ud83c[\\ude32-\\ude3a]|\\ud83c[\\ude50-\\ude51]|\\u203c|\\u2049|[\\u25aa-\\u25ab]|\\u25b6|\\u25c0|[\\u25fb-\\u25fe]|\\u00a9|\\u00ae|\\u2122|\\u2139|\\ud83c\\udc04|[\\u2600-\\u26FF]|\\u2b05|\\u2b06|\\u2b07|\\u2b1b|\\u2b1c|\\u2b50|\\u2b55|\\u231a|\\u231b|\\u2328|\\u23cf|[\\u23e9-\\u23f3]|[\\u23f8-\\u23fa]|\\ud83c\\udccf|\\u2934|\\u2935|[\\u2190-\\u21ff])/g;\n return text.replace(characterFilter, \"\");\n }\n\n debounce(fn, ...data) {\n if (!this.debounce_) {\n this.debounce_ = salla.helpers.debounce((callback, ...innerData) => callback(...innerData), 500);\n }\n //@ts-ignore\n return this.debounce_(fn, ...data);\n }\n\n getProductsSource(source) {\n return {\n 'brands.single': 'brands',\n 'product.index': 'categories',\n 'product.index.latest': 'latest',\n 'product.index.offers': 'offers',\n 'product.index.search': 'search',\n 'customer.wishlist': 'wishlist',\n 'landing-page': 'landing-page',\n 'product.index.tag': 'tags',\n 'product.index.sales': 'sales',\n 'components.most_sales_products': 'sales',//temporary, delete it after two days from now\n }[source || salla.config.get('page.slug')] || source || 'latest';\n }\n\n getPageTitleForSource(source) {\n\n source = {\n 'brands': 'common.titles.brands',\n // 'categories':'',\n 'latest': 'blocks.home.latest_products',\n 'offers': 'common.titles.discounts',\n // 'search':'',\n // 'landing-page':'',\n // 'tags':'',\n 'sales': 'common.titles.most_sales',\n }[source];\n\n return source ? salla.lang.get(source) : '';\n }\n\n getProductsSourceValue(source, sourceValue) {\n const parsedSource = this.getProductsSource(source);\n\n // Validate if the source value is a valid JSON string\n let parsedSourceValue: any = null;\n if (sourceValue) {\n try {\n parsedSourceValue = JSON.parse(sourceValue);\n } catch (error) {\n console.error('Invalid JSON string in sourceValue:', error);\n }\n }\n\n // Handle different source types\n if (!['search', 'json', 'offers', 'latest', 'sales', 'related'].includes(parsedSource)) {\n\n if (Array.isArray(parsedSourceValue) && parsedSourceValue.length) {\n return parsedSourceValue;\n }\n\n\n if (Array.isArray(parsedSourceValue) && !parsedSourceValue.length) {\n return '';\n }\n\n if (typeof parsedSourceValue === 'number') {\n return [parsedSourceValue];\n }\n\n if (!sourceValue && ['categories', 'tags', 'brands'].includes(source)) {\n return [salla.config.get('page.id')];\n }\n }\n\n // Return sourceValue if it exists and is a valid JSON object/array\n if (parsedSourceValue || sourceValue) {\n return parsedSourceValue || sourceValue;\n }\n\n if (parsedSource === 'search') {\n return new URLSearchParams(window.location.search).get('q') || '';\n }\n\n // Return page id as default value\n return salla.config.get('page.id');\n }\n\n extractFiltersFromUrl(searchParams) {\n let filters = {};\n searchParams.forEach((value, key) => {\n // Handle filters[xxx] format\n const matchesNested = key.match(/^filters\\[(.*?)\\](\\[(.*?)\\])?$/u);\n\n if (matchesNested) {\n const filterName = matchesNested[1];\n const nestedKey = matchesNested[3];\n\n if (nestedKey) {\n // Handle nested object\n filters[filterName] = filters[filterName] || {};\n filters[filterName][nestedKey] = value;\n } else {\n // Handle regular key\n filters[filterName] = value;\n }\n } else {\n // Handle simple key-value pairs\n const matchesSimple = key.match(/^(.*?)$/u);\n\n if (matchesSimple) {\n filters[matchesSimple[1]] = value;\n }\n }\n });\n return filters;\n }\n\n /**\n * We needed this function to help us avoid requesting the products list before salla is ready,\n * was causing a strange issues in live for the bad connections ex: not loading the dom, requesting api without storeIdentefire\n */\n onSallaReadyPromise(callback): Promise<any> {\n return new Promise((resolve) => salla.onReady(() => callback(resolve)));\n }\n\n /**\n * \n * let's make sure to send the request only when salla is ready\n * we will return the data and the resolve callback, to give the component the green light (by resolving the Promise in onSallaReadyPromise) to render only when we have the data\n * we will return the data and the resolve callback, to give the component the green light (by resolving the Promise in onSallaReadyPromise) to render only when we have the data\n */\n fetchProducts(source, source_value, limit): Promise<ProductResponse.lists> {\n return this.onSallaReadyPromise((resolve) => resolve(salla.product.api.fetch({ source: source, source_value: source_value, limit: limit })));\n }\n\n getProductSchemaMarkupScript(product: any): HTMLScriptElement {\n const scriptElement = document.createElement('script');\n scriptElement.type = 'application/ld+json';\n // TODO: This json object MIGHT need mode data or properties.\n const jsonData = {\n \"@context\": \"http://schema.org\",\n \"@type\": \"Product\",\n \"name\": product?.name,\n \"image\": product?.image?.url || product?.thumbnail,\n \"description\": product?.description,\n \"brand\": {\n \"@type\": \"Brand\",\n \"logo\": product?.brand?.logo\n },\n \"offers\": {\n \"@type\": \"Offer\",\n \"price\": product?.price\n }\n };\n scriptElement.text = JSON.stringify(jsonData);\n return scriptElement\n }\n\n createProductSchema(product: SallaProduct | ProductDetail, position: number): ListItem {\n let ProductSchema: SchemaProduct = {\n \"productID\": `${product.id}`,\n \"@type\": 'Product',\n \"name\": product.name,\n \"url\": product.url,\n \"image\": product.image.url || (product.image as string),\n \"description\": product.description || product.subtitle || product.name,\n \"offers\": {\n \"@type\": \"Offer\",\n \"url\": product.url,\n \"priceCurrency\": product.currency,\n \"price\": product.price,\n \"itemCondition\": \"NewCondition\",\n \"availability\": product.is_available ? \"InStock\" : \"OutOfStock\",\n //if there is no product.discount_ends, will set it to be valid until the end of this week\n \"priceValidUntil\": product.discount_ends || (new Date(new Date().setDate(new Date().getDate() + 7)).toISOString().split('T')[0]),\n \"priceSpecification\": {\n \"@type\": \"PriceSpecification\",\n \"price\": product.regular_price,\n \"priceCurrency\": product.currency,\n \"valueAddedTaxIncluded\": product.is_taxable,\n },\n \"seller\": {\n \"@type\": \"Organization\",\n \"name\": salla.config.get('store.name'),\n },\n }\n };\n //@ts-ignore\n if (product.rating?.stars) {\n ProductSchema.aggregateRating = {\n \"@type\": \"AggregateRating\",\n //@ts-ignore\n \"ratingValue\": product.rating.stars,\n \"reviewCount\": product.rating.count,\n };\n }\n\n\n return {\n \"@type\": \"ListItem\",\n \"position\": position,\n \"item\": ProductSchema,\n\n };\n }\n \n generateProductSchema(productList: Array<SallaProduct | ProductDetail>) {\n const schemaId = 'salla-product-schema-script';\n if (document.getElementById(schemaId)) {\n salla.logger.warn(`already added schema-script with id (${schemaId})!`)\n return;\n }\n\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n script.id = schemaId;\n\n\n const schema: WithContext<ItemList> = {\n \"@context\": \"https://schema.org\",\n \"@type\": \"ItemList\",\n \"name\": salla.config.get('page.title'),\n \"itemListElement\": productList.map((product, indxe) => this.createProductSchema(product, indxe + 1)),\n };\n\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n }\n\n /**\n * Format date in the form of `Monday 13 November 2023`\n */\n formatDateFromString(dateString: string, numberCb: Function, lang: string = 'en'): string {\n const dateObject = new Date(dateString);\n\n const errors = {\n en: \"Invalid Date\",\n ar: \"تاريخ غير صالح\"\n }\n\n if (isNaN(dateObject.getTime())) {\n return errors[lang];\n }\n\n const daysOfWeek = {\n en: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],\n ar: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت']\n };\n const months = {\n en: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],\n ar: ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر']\n };\n\n const dayOfWeek = daysOfWeek[lang][dateObject.getDay()];\n const dayOfMonth = numberCb(dateObject.getDate(), lang === 'en');\n const month = months[lang][dateObject.getMonth()];\n const year = numberCb(dateObject.getFullYear(), lang === 'en');\n\n return `${dayOfWeek} ${dayOfMonth} ${month} ${year}`;\n }\n\n /**\n * Copy text into clipboard.\n * @param event \n */\n copyToClipboard(event) {\n // Get the text content from the clicked div\n var textToCopy = event.target.innerText;\n\n // Use the Clipboard API to copy text to the clipboard\n navigator.clipboard.writeText(textToCopy)\n .then(() => {\n console.log('Text copied to clipboard: ' + textToCopy);\n })\n .catch(err => {\n console.error('Unable to copy text to clipboard', err);\n });\n\n }\n\n animateItems(items: NodeListOf<Element>) {\n if (!items) return;\n anime({\n targets: items,\n opacity: [0, 1],\n duration: 1200,\n translateY: [20, 0],\n delay: function (_el, i) {\n return i * 100;\n },\n easing: 'easeOutExpo',\n complete: function (_anim) {\n items.forEach((item: Element) => {\n item.classList.add('animated');\n })\n }\n\n })\n }\n\n createReviewObject(reviewData: Review) {\n return {\n \"@type\": \"Review\",\n \"author\": reviewData.name,\n \"datePublished\": reviewData.date * 1000,\n \"description\": reviewData.content,\n \"reviewRating\": {\n \"@type\": \"Rating\",\n \"bestRating\": \"5\",\n \"ratingValue\": \"5\",\n \"worstRating\": \"1\"\n }\n };\n }\n\n generateReviewSchema(reviews: Array<Review>){\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n\n\n const schema = {\n \"@context\": \"http://schema.org/\",\n \"@type\": \"CollectionPage\",\n \"name\": \"Category Name\", // TODO: check for the correct value here\n \"description\": \"Description of the category\", // TODO: here too\n \"review\": reviews.map((review) => this.createReviewObject(review))\n }\n\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n }\n}\n\nexport default new Helper;\n"],"version":3}