@salla.sa/twilight-components 2.14.349 → 2.14.351

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 (162) hide show
  1. package/dist/cjs/{Helper-B5NunIdR.js → Helper-DHRnzcFm.js} +14 -0
  2. package/dist/cjs/{filepond-DFhbfTkt.js → filepond-DmgB2usw.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-poster-Dj4Zm459.js → filepond-plugin-file-poster-Qz9yBcC6.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-size-DsH6GzKJ.js → filepond-plugin-file-validate-size-BpxufYGC.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-file-validate-type-DfaEudMs.js → filepond-plugin-file-validate-type-DPpMnDuU.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-edit-gz-CV83v.js → filepond-plugin-image-edit-DSig_Hnr.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-exif-orientation-DfkLjcpx.js → filepond-plugin-image-exif-orientation-BdyyWkN_.js} +1 -1
  8. package/dist/cjs/{filepond-plugin-image-preview-BxaEwNCI.js → filepond-plugin-image-preview-ClN5AjHL.js} +1 -1
  9. package/dist/cjs/{index-C9ymZIiv.js → index-ByiRU---.js} +1 -1
  10. package/dist/cjs/{index-DcTksD2K.js → index-wroCOFea.js} +2 -2
  11. package/dist/cjs/loader.cjs.js +2 -2
  12. package/dist/cjs/salla-accordion_62.cjs.entry.js +83 -52
  13. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  14. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  15. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-cart-item-offers.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  20. package/dist/cjs/salla-filters-widget.cjs.entry.js +2 -2
  21. package/dist/cjs/salla-filters.cjs.entry.js +2 -2
  22. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-notifications.cjs.entry.js +2 -2
  29. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-orders.cjs.entry.js +2 -2
  36. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-review-card.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-reviews-page.cjs.entry.js +2 -2
  40. package/dist/cjs/salla-reviews.cjs.entry.js +2 -2
  41. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  46. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  47. package/dist/cjs/twilight.cjs.js +2 -2
  48. package/dist/cjs/{vanilla-picker-BYDLZw1n.js → vanilla-picker-Dud2hHSp.js} +1 -1
  49. package/dist/collection/Helpers/Helper.js +14 -0
  50. package/dist/collection/components/salla-product-options/salla-product-options.js +44 -10
  51. package/dist/collection/components/salla-products-list/salla-products-list.js +9 -22
  52. package/dist/collection/components/salla-products-slider/salla-products-slider.js +9 -7
  53. package/dist/collection/components/salla-slider/salla-slider.js +15 -7
  54. package/dist/components/Helper.js +14 -0
  55. package/dist/components/index.js +2 -2
  56. package/dist/components/salla-product-options2.js +44 -10
  57. package/dist/components/salla-products-list2.js +7 -20
  58. package/dist/components/salla-products-slider2.js +7 -5
  59. package/dist/components/salla-slider2.js +15 -7
  60. package/dist/esm/{Helper-Bt5Zv9cl.js → Helper-B5RLi6Xo.js} +14 -0
  61. package/dist/esm/{filepond-DQR2YBu7.js → filepond-BcVCWOQQ.js} +1 -1
  62. package/dist/esm/{filepond-plugin-file-poster-XvYa1rlk.js → filepond-plugin-file-poster-B6OLqzjJ.js} +1 -1
  63. package/dist/esm/{filepond-plugin-file-validate-size-BRBnctOE.js → filepond-plugin-file-validate-size-BCifsMdp.js} +1 -1
  64. package/dist/esm/{filepond-plugin-file-validate-type-BuD6F1gi.js → filepond-plugin-file-validate-type-BzRNZ2wk.js} +1 -1
  65. package/dist/esm/{filepond-plugin-image-edit-BJ8YnBRL.js → filepond-plugin-image-edit-Dvu8RWud.js} +1 -1
  66. package/dist/esm/{filepond-plugin-image-exif-orientation-BGad_AoX.js → filepond-plugin-image-exif-orientation-DtlS_Id7.js} +1 -1
  67. package/dist/esm/{filepond-plugin-image-preview-Cb6UzPfa.js → filepond-plugin-image-preview-DRaZsLxF.js} +1 -1
  68. package/dist/esm/{index-DIfeuyTs.js → index-BT5aIJiI.js} +1 -1
  69. package/dist/esm/{index-Bhszo8cU.js → index-D8IUoDXw.js} +2 -2
  70. package/dist/esm/loader.js +3 -3
  71. package/dist/esm/salla-accordion_62.entry.js +83 -52
  72. package/dist/esm/salla-advertisement.entry.js +1 -1
  73. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  74. package/dist/esm/salla-apps-icons.entry.js +1 -1
  75. package/dist/esm/salla-cart-item-offers.entry.js +1 -1
  76. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  77. package/dist/esm/salla-contacts.entry.js +1 -1
  78. package/dist/esm/salla-custom-fields.entry.js +1 -1
  79. package/dist/esm/salla-filters-widget.entry.js +2 -2
  80. package/dist/esm/salla-filters.entry.js +2 -2
  81. package/dist/esm/salla-hook.entry.js +1 -1
  82. package/dist/esm/salla-installment.entry.js +1 -1
  83. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  84. package/dist/esm/salla-loyalty-program.entry.js +1 -1
  85. package/dist/esm/salla-metadata.entry.js +1 -1
  86. package/dist/esm/salla-notification-item.entry.js +1 -1
  87. package/dist/esm/salla-notifications.entry.js +2 -2
  88. package/dist/esm/salla-offer.entry.js +1 -1
  89. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  90. package/dist/esm/salla-order-details-options.entry.js +1 -1
  91. package/dist/esm/salla-order-details.entry.js +1 -1
  92. package/dist/esm/salla-order-summary.entry.js +1 -1
  93. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  94. package/dist/esm/salla-orders.entry.js +2 -2
  95. package/dist/esm/salla-payments.entry.js +1 -1
  96. package/dist/esm/salla-price-range.entry.js +1 -1
  97. package/dist/esm/salla-review-card.entry.js +1 -1
  98. package/dist/esm/salla-reviews-page.entry.js +2 -2
  99. package/dist/esm/salla-reviews.entry.js +2 -2
  100. package/dist/esm/salla-social.entry.js +1 -1
  101. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  102. package/dist/esm/salla-tooltip.entry.js +1 -1
  103. package/dist/esm/salla-trust-badges.entry.js +1 -1
  104. package/dist/esm/salla-verify.entry.js +1 -1
  105. package/dist/esm/salla-wallet.entry.js +1 -1
  106. package/dist/esm/twilight.js +3 -3
  107. package/dist/esm/{vanilla-picker-C4Kwbr5L.js → vanilla-picker-BPR2c_5J.js} +1 -1
  108. package/dist/twilight/{p-0daa34c4.entry.js → p-0fb07494.entry.js} +1 -1
  109. package/dist/twilight/{p-5bb9ace5.entry.js → p-1d6ae0cd.entry.js} +1 -1
  110. package/dist/twilight/{p-a25fe3c1.entry.js → p-234d4270.entry.js} +1 -1
  111. package/dist/twilight/{p-f4bf39fb.entry.js → p-2986242d.entry.js} +1 -1
  112. package/dist/twilight/p-319d0ee6.entry.js +4 -0
  113. package/dist/twilight/{p-112e9574.entry.js → p-403fc5a0.entry.js} +1 -1
  114. package/dist/twilight/{p-574bd55f.entry.js → p-44c225e2.entry.js} +1 -1
  115. package/dist/twilight/{p-64c18854.entry.js → p-46095c81.entry.js} +1 -1
  116. package/dist/twilight/{p-66c5dcd3.entry.js → p-4a269d95.entry.js} +1 -1
  117. package/dist/twilight/{p-a6f250b8.entry.js → p-53bbd4e8.entry.js} +1 -1
  118. package/dist/twilight/{p-7a706d50.entry.js → p-5a27fc24.entry.js} +1 -1
  119. package/dist/twilight/{p-a5df8334.entry.js → p-5e83dab1.entry.js} +1 -1
  120. package/dist/twilight/{p-b0abcc89.entry.js → p-6961de25.entry.js} +1 -1
  121. package/dist/twilight/{p-ed0f40e2.entry.js → p-88aa8e1c.entry.js} +1 -1
  122. package/dist/twilight/{p-ae93ed50.entry.js → p-8af29c6e.entry.js} +1 -1
  123. package/dist/twilight/{p-de290cc2.entry.js → p-8d0e34f8.entry.js} +1 -1
  124. package/dist/twilight/{p-cc43a1bd.entry.js → p-97d6ac02.entry.js} +1 -1
  125. package/dist/twilight/{p-6222b0fa.entry.js → p-993dff37.entry.js} +1 -1
  126. package/dist/twilight/{p-004be2ff.entry.js → p-9a6195f6.entry.js} +1 -1
  127. package/dist/twilight/{p-129e02c2.entry.js → p-9ab1a8dd.entry.js} +1 -1
  128. package/dist/twilight/{p-af8daa75.entry.js → p-9dc0d7cb.entry.js} +1 -1
  129. package/dist/twilight/{p-DAM1DKLB.js → p-B1PME38e.js} +1 -1
  130. package/dist/twilight/{p-ByJhdNbq.js → p-BjevMNf5.js} +1 -1
  131. package/dist/twilight/{p-B-MyfVCv.js → p-CLCMzFCR.js} +1 -1
  132. package/dist/twilight/{p-Bhszo8cU.js → p-D8IUoDXw.js} +1 -1
  133. package/dist/twilight/{p-NTgp-Syt.js → p-DMvcLQlj.js} +1 -1
  134. package/dist/twilight/{p-CmuTtBET.js → p-DNuuIRPk.js} +1 -1
  135. package/dist/twilight/p-DgNC8L6e.js +4 -0
  136. package/dist/twilight/{p-CuNS5C_o.js → p-DhPpUonS.js} +1 -1
  137. package/dist/twilight/{p-BVmy-j16.js → p-R8UuPKQS.js} +1 -1
  138. package/dist/twilight/{p-BvldZUSR.js → p-VHxFG8vR.js} +1 -1
  139. package/dist/twilight/{p-9f541d63.entry.js → p-a0fb9e8d.entry.js} +1 -1
  140. package/dist/twilight/{p-48617181.entry.js → p-a50658ad.entry.js} +1 -1
  141. package/dist/twilight/{p-b8a203c1.entry.js → p-af71190f.entry.js} +1 -1
  142. package/dist/twilight/{p-f3d3e11e.entry.js → p-b4bb7b69.entry.js} +1 -1
  143. package/dist/twilight/{p-25f64b3e.entry.js → p-c5dc7685.entry.js} +1 -1
  144. package/dist/twilight/{p-1bfef164.entry.js → p-c8f83a29.entry.js} +1 -1
  145. package/dist/twilight/{p-55c9e7fe.entry.js → p-cef109da.entry.js} +1 -1
  146. package/dist/twilight/{p-60747f3b.entry.js → p-d8c30c7b.entry.js} +1 -1
  147. package/dist/twilight/{p-cadbe7b6.entry.js → p-de74f566.entry.js} +1 -1
  148. package/dist/twilight/{p-cc6238be.entry.js → p-eb109f9d.entry.js} +1 -1
  149. package/dist/twilight/{p-48df4495.entry.js → p-ef9334ed.entry.js} +1 -1
  150. package/dist/twilight/{p-46fb77ce.entry.js → p-faa4c75d.entry.js} +1 -1
  151. package/dist/twilight/{p-911bbc7d.entry.js → p-fad69d7b.entry.js} +1 -1
  152. package/dist/twilight/{p-307b5fa0.entry.js → p-ffcfb224.entry.js} +1 -1
  153. package/dist/twilight/{p-Cy9bcLMa.js → p-mIk_7HE4.js} +1 -1
  154. package/dist/twilight/twilight.esm.js +1 -1
  155. package/dist/types/Helpers/Helper.d.ts +2 -0
  156. package/dist/types/components/salla-products-list/salla-products-list.d.ts +1 -1
  157. package/dist/types/components/salla-products-slider/salla-products-slider.d.ts +1 -1
  158. package/dist/types/components/salla-slider/salla-slider.d.ts +4 -1
  159. package/dist/types/components.d.ts +4 -4
  160. package/package.json +5 -5
  161. package/dist/twilight/p-4fc33cee.entry.js +0 -4
  162. package/dist/twilight/p-Dljb4XCt.js +0 -4
@@ -558,19 +558,53 @@ const SallaProductOptions = /*@__PURE__*/ proxyCustomElement(class SallaProductO
558
558
  }, []);
559
559
  }
560
560
  componentDidLoad() {
561
- if (this.optionsData?.length === 0 && !this.optionsData.some(option => option.type === DisplayType.DONATION)) {
561
+ if (!this.optionsData?.length) {
562
562
  return;
563
563
  }
564
- const selectedDonationOption = this.optionsData.find(option => option.type === DisplayType.DONATION)?.details.find(detail => detail.is_selected);
565
- if (!selectedDonationOption) {
566
- return;
564
+ // Handle donation options
565
+ const selectedDonationOption = this.optionsData.find(option => option.type === DisplayType.DONATION)?.details?.find(detail => detail.is_selected);
566
+ if (selectedDonationOption) {
567
+ setTimeout(() => {
568
+ salla.event.emit('product-options::donation-changed', {
569
+ id: this.productId,
570
+ price: selectedDonationOption.additional_price
571
+ });
572
+ }, 1000);
573
+ }
574
+ // Handle pre-selected options on product page
575
+ // Call salla.product.getPrice() directly to avoid triggering form validation which causes unwanted scroll
576
+ if (!salla.url.is_page("cart")) {
577
+ const pricingOptionTypes = [
578
+ DisplayType.SINGLE_OPTION,
579
+ DisplayType.MULTIPLE_OPTIONS,
580
+ DisplayType.COLOR,
581
+ DisplayType.THUMBNAIL,
582
+ DisplayType.DONATION,
583
+ DisplayType.DIGITAL_CARD_VALUE,
584
+ DisplayType.COUNTRY
585
+ ];
586
+ const hasPreSelectedPricingOption = this.optionsData.some(option => pricingOptionTypes.includes(option.type) &&
587
+ option.details?.some(detail => detail.is_selected));
588
+ if (hasPreSelectedPricingOption) {
589
+ // Use requestAnimationFrame to ensure DOM is fully painted before accessing form
590
+ requestAnimationFrame(() => {
591
+ try {
592
+ const form = this.host.closest('form');
593
+ if (!form)
594
+ return;
595
+ // Validate form belongs to this product to avoid conflicts on complex pages
596
+ const formData = new FormData(form);
597
+ const formProductId = formData.get('id') || formData.get('product_id');
598
+ if (formProductId && String(formProductId) !== String(this.productId))
599
+ return;
600
+ salla.product.getPrice(formData);
601
+ }
602
+ catch (e) {
603
+ salla.log('Error updating price for pre-selected options:', e);
604
+ }
605
+ });
606
+ }
567
607
  }
568
- setTimeout(() => {
569
- salla.event.emit('product-options::donation-changed', {
570
- id: this.productId,
571
- price: selectedDonationOption.additional_price
572
- });
573
- }, 1000);
574
608
  }
575
609
  /**
576
610
  * Enable user-initiated validation mode so invalid fields will scroll into view
@@ -203,19 +203,6 @@ const SallaProductsList = /*@__PURE__*/ proxyCustomElement(class SallaProductsLi
203
203
  //as a request they don't want to let the user to open the product details
204
204
  //todo:: find a better way to handle this request
205
205
  this.getSource() === 'landing-page' && (product.url = '');
206
- try {
207
- // Add source query param to product URL for tracking in Product Viewed event
208
- if (this.source && product.url && !product.url.includes('s-product-source=')) {
209
- const [urlWithoutFragment, fragment] = product.url.split('#');
210
- const separator = urlWithoutFragment.includes('?') ? '&' : '?';
211
- const pageSlug = salla.config?.get('page.slug') || 'unknown';
212
- const sourceValue = `${pageSlug}.${this.source}`;
213
- product.url = `${urlWithoutFragment}${separator}s-product-source=${sourceValue}${fragment ? '#' + fragment : ''}`;
214
- }
215
- }
216
- catch (error) {
217
- Salla.log('Error with source');
218
- }
219
206
  const customComponentTag = this.hasCustomComponent ? this.productCardComponent : 'salla-product-card';
220
207
  const productCard = document.createElement(customComponentTag);
221
208
  productCard.product = product;
@@ -223,15 +210,15 @@ const SallaProductsList = /*@__PURE__*/ proxyCustomElement(class SallaProductsLi
223
210
  this.applyHorizontalCardStyles(productCard);
224
211
  // Attach click event listener to save the current products snapshot
225
212
  productCard.addEventListener('click', (event) => {
226
- if (!this.hasInfiniteScroll) {
227
- return;
228
- }
229
213
  const target = event.target;
230
214
  // Check if the clicked element is an anchor or inside an anchor
231
215
  const anchor = target.closest('a');
232
216
  if (anchor) {
233
- this.takeStateSnapshot();
234
- sessionStorage.setItem(this.lastViewedProductKey, product.id);
217
+ Helper.saveProductSource(this.getSource());
218
+ if (this.hasInfiniteScroll) {
219
+ this.takeStateSnapshot();
220
+ sessionStorage.setItem(this.lastViewedProductKey, product.id);
221
+ }
235
222
  }
236
223
  });
237
224
  return productCard;
@@ -561,7 +548,7 @@ const SallaProductsList = /*@__PURE__*/ proxyCustomElement(class SallaProductsLi
561
548
  }
562
549
  getInitialData() {
563
550
  this.loading();
564
- return salla.product.api.fetch({ source: this.getSource(), source_value: this.getSourceValue(), limit: this.limit }).then(async (response) => {
551
+ return salla.product.api.fetch({ source: Helper.getApiSource(this.getSource()), source_value: this.getSourceValue(), limit: this.limit }).then(async (response) => {
565
552
  if (!response.data.length) {
566
553
  this.showPlaceholder = true;
567
554
  this.placeholderLoader && this.placeholderLoader.remove();
@@ -587,7 +574,7 @@ const SallaProductsList = /*@__PURE__*/ proxyCustomElement(class SallaProductsLi
587
574
  .then(() => {
588
575
  this.hasCustomComponent = !!customElements.get(this.productCardComponent);
589
576
  this.sourceValueIsValid = !!(this.getSourceValue() || this.isSourceWithoutValue());
590
- this.hasInfiniteScroll = !['json', 'selected', 'related', 'landing-page'].includes(this.getSource()) && !this.limit;
577
+ this.hasInfiniteScroll = !['json', 'selected', 'related', 'landing-page', 'recently'].includes(this.getSource()) && !this.limit;
591
578
  let searchParams = new URLSearchParams(window.location.search);
592
579
  try {
593
580
  this.sortBy = this.sortBy || searchParams.get('sort') || searchParams.get('by');
@@ -57,7 +57,7 @@ const SallaProductsSlider = /*@__PURE__*/ proxyCustomElement(class SallaProducts
57
57
  this.isReady = false;
58
58
  return;
59
59
  }
60
- return salla.product.api.fetch({ source: this.getSource(), source_value: this.getSourceValue(), limit: this.limit })
60
+ return salla.product.api.fetch({ source: Helper.getApiSource(this.getSource()), source_value: this.getSourceValue(), limit: this.limit })
61
61
  .then(response => Helper.injectExtraFieldsToResponse(response))
62
62
  .then(response => {
63
63
  this.productsData = response.data;
@@ -87,18 +87,20 @@ const SallaProductsSlider = /*@__PURE__*/ proxyCustomElement(class SallaProducts
87
87
  getItemHTML(product) {
88
88
  //as a request they don't want to let the user to open the product details
89
89
  //todo:: find a better way to handle this request
90
- this.getSource() === 'landing-page' && (product.url = '');
90
+ const isLandingPage = this.getSource() === 'landing-page';
91
+ isLandingPage && (product.url = '');
92
+ const handleClick = isLandingPage ? undefined : () => Helper.saveProductSource(this.getSource());
91
93
  if (this.hasCustomComponent && this.productCardComponent.toLowerCase() == 'custom-salla-product-card') {
92
- return h("div", { class: "s-products-slider-card" }, h("custom-salla-product-card", { product: product, source: this.getSource(), "source-value": this.getSourceValue() }));
94
+ return h("div", { class: "s-products-slider-card", onClick: handleClick }, h("custom-salla-product-card", { product: product, source: this.getSource(), "source-value": this.getSourceValue() }));
93
95
  }
94
96
  if (this.hasCustomComponent) {
95
97
  const customElem = document.createElement(this.productCardComponent);
96
98
  customElem.setAttribute('product', JSON.stringify(product));
97
99
  customElem.setAttribute('source', this.getSource());
98
100
  customElem.setAttribute('source-value', this.getSourceValue());
99
- return h("div", { class: "s-products-slider-card", innerHTML: customElem.outerHTML });
101
+ return h("div", { class: "s-products-slider-card", onClick: handleClick, innerHTML: customElem.outerHTML });
100
102
  }
101
- return h("div", { class: "s-products-slider-card" }, h("salla-product-card", { "show-quantity": this.getSource() == 'landing-page', "hide-add-btn": this.getSource() == 'landing-page', "shadow-on-hover": true, product: product }));
103
+ return h("div", { class: "s-products-slider-card", onClick: handleClick }, h("salla-product-card", { "show-quantity": isLandingPage, "hide-add-btn": isLandingPage, "shadow-on-hover": true, product: product }));
102
104
  }
103
105
  canRender() {
104
106
  return this.sourceValueIsValid && this.isReady;
@@ -9887,7 +9887,9 @@ const SallaSlider = /*@__PURE__*/ proxyCustomElement(class SallaSlider extends H
9887
9887
  this.currentIndex = undefined;
9888
9888
  this.isEnd = false;
9889
9889
  this.isBeginning = true;
9890
- this.windowWidth = window.innerWidth;
9890
+ /** Use matchMedia instead of window.innerWidth to avoid forced reflow (Lighthouse recommended) */
9891
+ this.isDesktopViewport = typeof window !== 'undefined' ? window.matchMedia('(min-width: 768px)').matches : true;
9892
+ this.viewportMediaQuery = null;
9891
9893
  this.hasThumbSlot = false;
9892
9894
  this.pre_defined_config = {
9893
9895
  carousel: {
@@ -9931,6 +9933,9 @@ const SallaSlider = /*@__PURE__*/ proxyCustomElement(class SallaSlider extends H
9931
9933
  spaceBetween: 30
9932
9934
  }
9933
9935
  };
9936
+ this.onViewportChange = (e) => {
9937
+ this.isDesktopViewport = e.matches;
9938
+ };
9934
9939
  this.direction = this.direction || document.documentElement.dir;
9935
9940
  }
9936
9941
  // Methods
@@ -10227,11 +10232,11 @@ const SallaSlider = /*@__PURE__*/ proxyCustomElement(class SallaSlider extends H
10227
10232
  return pre_defined_config;
10228
10233
  }
10229
10234
  getThumbsDirection() {
10230
- const { verticalThumbs, windowWidth, direction } = this;
10231
- if (verticalThumbs && windowWidth < 768 && direction === 'rtl') {
10235
+ const { verticalThumbs, isDesktopViewport, direction } = this;
10236
+ if (verticalThumbs && !isDesktopViewport && direction === 'rtl') {
10232
10237
  return 'rtl';
10233
10238
  }
10234
- if (verticalThumbs && windowWidth > 768 && direction === 'rtl') {
10239
+ if (verticalThumbs && isDesktopViewport && direction === 'rtl') {
10235
10240
  return 'ltr';
10236
10241
  }
10237
10242
  return direction;
@@ -10286,7 +10291,7 @@ const SallaSlider = /*@__PURE__*/ proxyCustomElement(class SallaSlider extends H
10286
10291
  classes += this.verticalThumbs ? ' s-slider-vertical ' : ' s-slider-horizontal ';
10287
10292
  classes += this.arrowsCentered ? ' s-slider-v-centered ' : '';
10288
10293
  classes += this.gridThumbs ? ' s-slider-with-grid-thumbs ' : '';
10289
- return (h(Host, { key: '0b3f597ee3e0b5bfddfdcc9e3167edc93273defe', class: 's-slider-wrapper ' + classes }, this.blockTitle || this.showControls ?
10294
+ return (h(Host, { key: '44f6baf2ec3a6421cd8d8ce6779c6ce781cecc7f', class: 's-slider-wrapper ' + classes }, this.blockTitle || this.showControls ?
10290
10295
  h("div", { class: "s-slider-block__title" }, this.blockTitle ?
10291
10296
  h("div", { class: "s-slider-block__title-right" }, h("h2", null, this.blockTitle), this.blockSubtitle ? h("p", { innerHTML: this.blockSubtitle }) : '')
10292
10297
  : '', h("div", { class: "s-slider-block__title-left" }, this.displayAllUrl ?
@@ -10294,7 +10299,7 @@ const SallaSlider = /*@__PURE__*/ proxyCustomElement(class SallaSlider extends H
10294
10299
  : '', this.showControls ?
10295
10300
  h("div", { class: "s-slider-block__title-nav", dir: "rtl" }, h("button", { "aria-label": "Previous Slide", class: "s-slider-prev s-slider-nav-arrow" }, h("span", { class: "s-slider-button-icon", innerHTML: this.direction == 'rtl' ? KeyBoardArrowRightIcon : KeyBoardArrowLeftIcon })), h("button", { "aria-label": "Next Slide", class: "s-slider-next s-slider-nav-arrow" }, h("span", { class: "s-slider-button-icon", innerHTML: this.direction == 'rtl' ? KeyBoardArrowLeftIcon : KeyBoardArrowRightIcon })))
10296
10301
  : ''))
10297
- : '', h("div", { key: 'b4439c52238fef56cb59af6a568759dbe4ff7b3b', class: "swiper s-slider-container", ref: el => this.sliderContainer = el, dir: this.vertical ? "ltr" : this.direction }, h("slot", { key: '9f527368279faa132cd8f451d231da84d37736b4' }), h("div", { key: '1a25a9068037cd732c5d0dcba32fbf630b812acd', class: "swiper-wrapper s-slider-swiper-wrapper", ref: el => this.sliderWrapper = el }, h("slot", { key: '777e3773d840abaf0fc55cdcdf50b504696fdd5c', name: 'items' })), this.pagination ? h("div", { class: "swiper-pagination" }) : ''), this.type == 'thumbs' && this.hasThumbSlot ? h("div", { class: "s-slider-thumbs" }, h("div", { class: "swiper s-slider-thumbs-container", dir: this.getThumbsDirection(), ref: el => this.thumbsSliderContainer = el }, h("div", { class: { "s-slider-swiper-wrapper swiper-wrapper": true, "s-slider-grid-thumbs": this.gridThumbs }, ref: el => this.thumbsSliderWrapper = el }, h("slot", { name: "thumbs" })), this.showThumbsControls ?
10302
+ : '', h("div", { key: '384d3224e9e2f9ad08d71093ee4c6f907232c07e', class: "swiper s-slider-container", ref: el => this.sliderContainer = el, dir: this.vertical ? "ltr" : this.direction }, h("slot", { key: '578756df5b652d9b7e86d3f0424e4ec886b7a75f' }), h("div", { key: '7966a00ec720374a3dac1533d72fdfeb31db8105', class: "swiper-wrapper s-slider-swiper-wrapper", ref: el => this.sliderWrapper = el }, h("slot", { key: '39f9656cabb053dc4878ae1f2bd94a6efc19f975', name: 'items' })), this.pagination ? h("div", { class: "swiper-pagination" }) : ''), this.type == 'thumbs' && this.hasThumbSlot ? h("div", { class: "s-slider-thumbs" }, h("div", { class: "swiper s-slider-thumbs-container", dir: this.getThumbsDirection(), ref: el => this.thumbsSliderContainer = el }, h("div", { class: { "s-slider-swiper-wrapper swiper-wrapper": true, "s-slider-grid-thumbs": this.gridThumbs }, ref: el => this.thumbsSliderWrapper = el }, h("slot", { name: "thumbs" })), this.showThumbsControls ?
10298
10303
  h("div", { class: "s-slider-thumbs-nav", dir: "rtl" }, h("button", { "aria-label": "Previous Slide", class: "s-slider-thumbs-prev s-slider-nav-arrow" }, h("span", { class: "s-slider-button-icon", innerHTML: this.direction == 'rtl' ? KeyBoardArrowRightIcon : KeyBoardArrowLeftIcon })), h("button", { "aria-label": "Next Slide", class: "s-slider-thumbs-next s-slider-nav-arrow" }, h("span", { class: "s-slider-button-icon", innerHTML: this.direction == 'rtl' ? KeyBoardArrowLeftIcon : KeyBoardArrowRightIcon })))
10299
10304
  : null))
10300
10305
  : null));
@@ -10368,8 +10373,11 @@ const SallaSlider = /*@__PURE__*/ proxyCustomElement(class SallaSlider extends H
10368
10373
  this.flattenSlotToElements(this.thumbsSliderWrapper, 'div[slot="thumbs"]');
10369
10374
  }
10370
10375
  this.initSlider();
10376
+ this.viewportMediaQuery = window.matchMedia('(min-width: 768px)');
10377
+ this.viewportMediaQuery.addEventListener('change', this.onViewportChange);
10371
10378
  }
10372
10379
  disconnectedCallback() {
10380
+ this.viewportMediaQuery?.removeEventListener('change', this.onViewportChange);
10373
10381
  this.lazyObserver?.disconnect();
10374
10382
  this.lazyImageObserver?.disconnect();
10375
10383
  }
@@ -10401,7 +10409,7 @@ const SallaSlider = /*@__PURE__*/ proxyCustomElement(class SallaSlider extends H
10401
10409
  "isEnd": [32],
10402
10410
  "isBeginning": [32],
10403
10411
  "displayAllTitle": [32],
10404
- "windowWidth": [32],
10412
+ "isDesktopViewport": [32],
10405
10413
  "sliderInstance": [64],
10406
10414
  "slideTo": [64],
10407
10415
  "slideNext": [64],
@@ -51,6 +51,10 @@ class Helper {
51
51
  'components.most_sales_products': 'sales', //temporary, delete it after two days from now
52
52
  }[source || salla.config.get('page.slug')] || source || 'latest';
53
53
  }
54
+ getApiSource(source) {
55
+ const apiSourceMap = { 'recently': 'selected' };
56
+ return apiSourceMap[source] || source;
57
+ }
54
58
  getPageTitleForSource(source) {
55
59
  source = {
56
60
  'brands': 'common.titles.brands',
@@ -177,6 +181,16 @@ class Helper {
177
181
  productsIncludes() {
178
182
  return this.includes?.filter(field => field != 'metadata');
179
183
  }
184
+ saveProductSource(source) {
185
+ if (!source)
186
+ return;
187
+ try {
188
+ sessionStorage.setItem('s-viewed-source', source);
189
+ }
190
+ catch (error) {
191
+ salla.logger.warn('Error saving product source to session storage');
192
+ }
193
+ }
180
194
  parseJson(includes) {
181
195
  if (typeof includes !== 'string') {
182
196
  return includes;
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { d as getDefaultExportFromCjs } from './index-Bhszo8cU.js';
4
+ import { d as getDefaultExportFromCjs } from './index-D8IUoDXw.js';
5
5
 
6
6
  function _mergeNamespaces(n, m) {
7
7
  m.forEach(function (e) {
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { d as getDefaultExportFromCjs } from './index-Bhszo8cU.js';
4
+ import { d as getDefaultExportFromCjs } from './index-D8IUoDXw.js';
5
5
 
6
6
  function _mergeNamespaces(n, m) {
7
7
  m.forEach(function (e) {
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { d as getDefaultExportFromCjs } from './index-Bhszo8cU.js';
4
+ import { d as getDefaultExportFromCjs } from './index-D8IUoDXw.js';
5
5
 
6
6
  function _mergeNamespaces(n, m) {
7
7
  m.forEach(function (e) {
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { d as getDefaultExportFromCjs } from './index-Bhszo8cU.js';
4
+ import { d as getDefaultExportFromCjs } from './index-D8IUoDXw.js';
5
5
 
6
6
  function _mergeNamespaces(n, m) {
7
7
  m.forEach(function (e) {
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { d as getDefaultExportFromCjs } from './index-Bhszo8cU.js';
4
+ import { d as getDefaultExportFromCjs } from './index-D8IUoDXw.js';
5
5
 
6
6
  function _mergeNamespaces(n, m) {
7
7
  m.forEach(function (e) {
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { d as getDefaultExportFromCjs } from './index-Bhszo8cU.js';
4
+ import { d as getDefaultExportFromCjs } from './index-D8IUoDXw.js';
5
5
 
6
6
  function _mergeNamespaces(n, m) {
7
7
  m.forEach(function (e) {
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { d as getDefaultExportFromCjs } from './index-Bhszo8cU.js';
4
+ import { d as getDefaultExportFromCjs } from './index-D8IUoDXw.js';
5
5
 
6
6
  function _mergeNamespaces(n, m) {
7
7
  m.forEach(function (e) {
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { d as getDefaultExportFromCjs } from './index-Bhszo8cU.js';
4
+ import { d as getDefaultExportFromCjs } from './index-D8IUoDXw.js';
5
5
 
6
6
  function _mergeNamespaces(n, m) {
7
7
  m.forEach(function (e) {