@salla.sa/twilight-components 2.14.353 → 2.14.354

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 (311) hide show
  1. package/dist/cjs/bell-ring-BfKPinNo.js +13 -0
  2. package/dist/cjs/{interfaces-CX9-6aLf.js → camera-DytepEoK.js} +0 -11
  3. package/dist/cjs/cancel-De6vslRA.js +13 -0
  4. package/dist/cjs/cart-s-x1Fshk.js +13 -0
  5. package/dist/cjs/check-circle2-BDvlT4_n.js +13 -0
  6. package/dist/cjs/{check-CLRvuniI.js → check-x3w3-gpj.js} +2 -2
  7. package/dist/cjs/{filepond-7SxqaoXb.js → filepond-CuKErtOy.js} +1 -1
  8. package/dist/cjs/{filepond-plugin-file-poster-DwIv84hN.js → filepond-plugin-file-poster-d-8BSuST.js} +1 -1
  9. package/dist/cjs/{filepond-plugin-file-validate-size-NUNnIo4Q.js → filepond-plugin-file-validate-size-zgI_JcqY.js} +1 -1
  10. package/dist/cjs/{filepond-plugin-file-validate-type-CXI-hfww.js → filepond-plugin-file-validate-type-Cy8IgG2P.js} +1 -1
  11. package/dist/cjs/{filepond-plugin-image-edit-fBeBGIBb.js → filepond-plugin-image-edit-9ZAUzCvh.js} +1 -1
  12. package/dist/cjs/{filepond-plugin-image-exif-orientation-BmLTdQ6d.js → filepond-plugin-image-exif-orientation-DzNe_tY2.js} +1 -1
  13. package/dist/cjs/{filepond-plugin-image-preview-CssKRM6n.js → filepond-plugin-image-preview-Cfna6xTB.js} +1 -1
  14. package/dist/{esm/gift-C0JNGIpa.js → cjs/gift-CJ-3Yw_x.js} +4 -2
  15. package/dist/cjs/image-BoZ6Hums.js +13 -0
  16. package/dist/cjs/{index-B5soIVRX.js → index-Ce40E8tZ.js} +136 -12
  17. package/dist/cjs/{index-B9TEdQDE.js → index-ff-xJfhj.js} +1 -1
  18. package/dist/cjs/interfaces-CRqrf5RX.js +15 -0
  19. package/dist/cjs/keyboard_arrow_down-DHJ3FFZq.js +13 -0
  20. package/dist/cjs/keyboard_arrow_right-BayM_Il2.js +21 -0
  21. package/dist/cjs/loader.cjs.js +2 -2
  22. package/dist/cjs/minus-CCryh1qf.js +21 -0
  23. package/dist/cjs/salla-accordion-body_3.cjs.entry.js +775 -0
  24. package/dist/cjs/salla-accordion_6.cjs.entry.js +768 -0
  25. package/dist/cjs/salla-add-product-button_4.cjs.entry.js +2389 -0
  26. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-alert_2.cjs.entry.js +194 -0
  28. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-booking-field_7.cjs.entry.js +1565 -0
  31. package/dist/cjs/{salla-cart-item-offers.cjs.entry.js → salla-cart-item-offers_2.cjs.entry.js} +104 -5
  32. package/dist/cjs/salla-comment-form_8.cjs.entry.js +1661 -0
  33. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-contacts.cjs.entry.js +3 -3
  35. package/dist/cjs/salla-count-down_2.cjs.entry.js +302 -0
  36. package/dist/cjs/salla-custom-fields.cjs.entry.js +4 -3
  37. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-gifting.cjs.entry.js +488 -0
  40. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +91 -0
  42. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-list-tile.cjs.entry.js +34 -0
  44. package/dist/cjs/salla-localization-modal.cjs.entry.js +137 -0
  45. package/dist/cjs/salla-login-modal.cjs.entry.js +320 -0
  46. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  47. package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
  48. package/dist/cjs/salla-loyalty.cjs.entry.js +211 -0
  49. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +40 -0
  50. package/dist/cjs/salla-menu.cjs.entry.js +139 -0
  51. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +220 -0
  53. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +598 -0
  54. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +69 -0
  55. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-offer-modal.cjs.entry.js +206 -0
  58. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  59. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  60. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  61. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-order-summary.cjs.entry.js +3 -3
  63. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  64. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  66. package/dist/cjs/salla-placeholder.cjs.entry.js +51 -0
  67. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-product-size-guide.cjs.entry.js +66 -0
  69. package/dist/cjs/salla-products-list.cjs.entry.js +762 -0
  70. package/dist/cjs/salla-products-slider.cjs.entry.js +115 -0
  71. package/dist/cjs/salla-progress-bar.cjs.entry.js +73 -0
  72. package/dist/cjs/salla-quick-order.cjs.entry.js +239 -0
  73. package/dist/cjs/salla-rating-modal.cjs.entry.js +453 -0
  74. package/dist/cjs/salla-scopes.cjs.entry.js +180 -0
  75. package/dist/cjs/salla-search.cjs.entry.js +153 -0
  76. package/dist/cjs/salla-skeleton.cjs.entry.js +36 -0
  77. package/dist/cjs/salla-slider.cjs.entry.js +10389 -0
  78. package/dist/cjs/salla-social-share.cjs.entry.js +165 -0
  79. package/dist/cjs/salla-social.cjs.entry.js +3 -3
  80. package/dist/cjs/salla-tab-content_3.cjs.entry.js +157 -0
  81. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  82. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  83. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  84. package/dist/cjs/salla-user-menu.cjs.entry.js +275 -0
  85. package/dist/cjs/salla-user-profile.cjs.entry.js +145 -0
  86. package/dist/cjs/salla-user-settings.cjs.entry.js +88 -0
  87. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  88. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  89. package/dist/cjs/search-c7Aa7lM9.js +13 -0
  90. package/dist/cjs/{special-discount-OVG_9Kf9.js → special-discount-DC2oXurL.js} +0 -8
  91. package/dist/cjs/star-DGcH7Yso.js +13 -0
  92. package/dist/cjs/star2-R146a27p.js +13 -0
  93. package/dist/cjs/twilight.cjs.js +2 -2
  94. package/dist/cjs/{vanilla-picker-C6fk8_TR.js → vanilla-picker-zQsXQIff.js} +1 -1
  95. package/dist/cjs/{whatsapp2-D7Sbg8Ey.js → whatsapp2-BdMd5Gx1.js} +2 -2
  96. package/dist/collection/collection-manifest.json +55 -1
  97. package/dist/collection/components/salla-product-options/salla-product-options.js +36 -3
  98. package/dist/components/index.js +2 -2
  99. package/dist/components/salla-product-options2.js +19 -2
  100. package/dist/esm/bell-ring-D3mWkc-3.js +11 -0
  101. package/dist/esm/{interfaces-CBT_Nxny.js → camera-C6jIkM-X.js} +1 -12
  102. package/dist/esm/cancel-BsLF_HK7.js +11 -0
  103. package/dist/esm/cart-DY4LZmNP.js +11 -0
  104. package/dist/esm/{check-uTyAzPSy.js → check-BsXh13x8.js} +2 -2
  105. package/dist/esm/check-circle2-BV4kqbdL.js +11 -0
  106. package/dist/esm/{filepond-Cuqyleyy.js → filepond-DEzyRrdH.js} +1 -1
  107. package/dist/esm/{filepond-plugin-file-poster-C6Wara8q.js → filepond-plugin-file-poster-DyLcCcHM.js} +1 -1
  108. package/dist/esm/{filepond-plugin-file-validate-size-D-M3KSxo.js → filepond-plugin-file-validate-size-Cxp5Yzea.js} +1 -1
  109. package/dist/esm/{filepond-plugin-file-validate-type-DzAl1VI8.js → filepond-plugin-file-validate-type-D2qNOQP4.js} +1 -1
  110. package/dist/esm/{filepond-plugin-image-edit-flutfc9I.js → filepond-plugin-image-edit-DndTlA7m.js} +1 -1
  111. package/dist/esm/{filepond-plugin-image-exif-orientation-B2UkG6iE.js → filepond-plugin-image-exif-orientation-CiT1CQoK.js} +1 -1
  112. package/dist/esm/{filepond-plugin-image-preview-B4u8N2nE.js → filepond-plugin-image-preview-DBG7keFZ.js} +1 -1
  113. package/dist/{cjs/gift-BPDUPIY_.js → esm/gift-BChI23pG.js} +2 -4
  114. package/dist/esm/image-C-tzSDxw.js +11 -0
  115. package/dist/esm/{index-6mr785rH.js → index-B74h9G6a.js} +137 -13
  116. package/dist/esm/{index-xWIb6INF.js → index-BLw7mdtM.js} +1 -1
  117. package/dist/esm/interfaces-OF8QcbMM.js +15 -0
  118. package/dist/esm/keyboard_arrow_down-DCZbpt2a.js +11 -0
  119. package/dist/esm/keyboard_arrow_right-Vqpj4CWE.js +18 -0
  120. package/dist/esm/loader.js +3 -3
  121. package/dist/esm/minus-DfeagqF1.js +18 -0
  122. package/dist/esm/salla-accordion-body_3.entry.js +771 -0
  123. package/dist/esm/salla-accordion_6.entry.js +761 -0
  124. package/dist/esm/salla-add-product-button_4.entry.js +2384 -0
  125. package/dist/esm/salla-advertisement.entry.js +1 -1
  126. package/dist/esm/salla-alert_2.entry.js +191 -0
  127. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  128. package/dist/esm/salla-apps-icons.entry.js +1 -1
  129. package/dist/esm/salla-booking-field_7.entry.js +1539 -0
  130. package/dist/esm/{salla-cart-item-offers.entry.js → salla-cart-item-offers_2.entry.js} +104 -6
  131. package/dist/esm/salla-comment-form_8.entry.js +1652 -0
  132. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  133. package/dist/esm/salla-contacts.entry.js +3 -3
  134. package/dist/esm/salla-count-down_2.entry.js +299 -0
  135. package/dist/esm/salla-custom-fields.entry.js +3 -2
  136. package/dist/esm/salla-filters-widget.entry.js +1 -1
  137. package/dist/esm/salla-filters.entry.js +1 -1
  138. package/dist/esm/salla-gifting.entry.js +486 -0
  139. package/dist/esm/salla-hook.entry.js +1 -1
  140. package/dist/esm/salla-infinite-scroll.entry.js +89 -0
  141. package/dist/esm/salla-installment.entry.js +1 -1
  142. package/dist/esm/salla-list-tile.entry.js +32 -0
  143. package/dist/esm/salla-localization-modal.entry.js +135 -0
  144. package/dist/esm/salla-login-modal.entry.js +318 -0
  145. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  146. package/dist/esm/salla-loyalty-program.entry.js +3 -3
  147. package/dist/esm/salla-loyalty.entry.js +209 -0
  148. package/dist/esm/salla-maintenance-alert.entry.js +38 -0
  149. package/dist/esm/salla-menu.entry.js +137 -0
  150. package/dist/esm/salla-metadata.entry.js +1 -1
  151. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +217 -0
  152. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +595 -0
  153. package/dist/esm/salla-multiple-bundle-product.entry.js +67 -0
  154. package/dist/esm/salla-notification-item.entry.js +1 -1
  155. package/dist/esm/salla-notifications.entry.js +1 -1
  156. package/dist/esm/salla-offer-modal.entry.js +204 -0
  157. package/dist/esm/salla-offer.entry.js +1 -1
  158. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  159. package/dist/esm/salla-order-details-options.entry.js +1 -1
  160. package/dist/esm/salla-order-details.entry.js +1 -1
  161. package/dist/esm/salla-order-summary.entry.js +3 -3
  162. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  163. package/dist/esm/salla-orders.entry.js +1 -1
  164. package/dist/esm/salla-payments.entry.js +1 -1
  165. package/dist/esm/salla-placeholder.entry.js +49 -0
  166. package/dist/esm/salla-price-range.entry.js +1 -1
  167. package/dist/esm/salla-product-size-guide.entry.js +64 -0
  168. package/dist/esm/salla-products-list.entry.js +760 -0
  169. package/dist/esm/salla-products-slider.entry.js +113 -0
  170. package/dist/esm/salla-progress-bar.entry.js +71 -0
  171. package/dist/esm/salla-quick-order.entry.js +237 -0
  172. package/dist/esm/salla-rating-modal.entry.js +451 -0
  173. package/dist/esm/salla-scopes.entry.js +178 -0
  174. package/dist/esm/salla-search.entry.js +151 -0
  175. package/dist/esm/salla-skeleton.entry.js +34 -0
  176. package/dist/esm/salla-slider.entry.js +10387 -0
  177. package/dist/esm/salla-social-share.entry.js +163 -0
  178. package/dist/esm/salla-social.entry.js +2 -2
  179. package/dist/esm/salla-tab-content_3.entry.js +153 -0
  180. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  181. package/dist/esm/salla-tooltip.entry.js +1 -1
  182. package/dist/esm/salla-trust-badges.entry.js +1 -1
  183. package/dist/esm/salla-user-menu.entry.js +273 -0
  184. package/dist/esm/salla-user-profile.entry.js +143 -0
  185. package/dist/esm/salla-user-settings.entry.js +86 -0
  186. package/dist/esm/salla-verify.entry.js +1 -1
  187. package/dist/esm/salla-wallet.entry.js +1 -1
  188. package/dist/esm/search-BscTeWDc.js +11 -0
  189. package/dist/esm/{special-discount-yRO-ZESF.js → special-discount-Ctkfc4K-.js} +1 -8
  190. package/dist/esm/star-ZT7ehBBk.js +11 -0
  191. package/dist/esm/star2-D4oPi1Ov.js +11 -0
  192. package/dist/esm/twilight.js +3 -3
  193. package/dist/esm/{vanilla-picker-B4PKRAhm.js → vanilla-picker-CtwkXTap.js} +1 -1
  194. package/dist/esm/{whatsapp2-DWksgowB.js → whatsapp2-CgR-T_ZS.js} +2 -2
  195. package/dist/twilight/{p-2a26c1d6.entry.js → p-0134b4fd.entry.js} +1 -1
  196. package/dist/twilight/{p-d4aaeef4.entry.js → p-01daaaa6.entry.js} +1 -1
  197. package/dist/twilight/p-07da7390.entry.js +4 -0
  198. package/dist/twilight/{p-81702ecb.entry.js → p-08badc32.entry.js} +1 -1
  199. package/dist/twilight/{p-4bc98557.entry.js → p-0aa5a12a.entry.js} +1 -1
  200. package/dist/twilight/{p-6f576591.entry.js → p-10dcd981.entry.js} +1 -1
  201. package/dist/twilight/{p-5067322a.entry.js → p-212a0710.entry.js} +1 -1
  202. package/dist/twilight/p-229275db.entry.js +4 -0
  203. package/dist/twilight/{p-dde21f4b.entry.js → p-232185ec.entry.js} +1 -1
  204. package/dist/twilight/{p-12e49031.entry.js → p-2a927eac.entry.js} +1 -1
  205. package/dist/twilight/p-2d880232.entry.js +4 -0
  206. package/dist/twilight/p-2de9df64.entry.js +4 -0
  207. package/dist/twilight/p-309a0ba4.entry.js +4 -0
  208. package/dist/twilight/{p-e909d28b.entry.js → p-32732ca7.entry.js} +1 -1
  209. package/dist/twilight/{p-19e07b9e.entry.js → p-32ca34ec.entry.js} +1 -1
  210. package/dist/twilight/{p-9946fa76.entry.js → p-33093880.entry.js} +1 -1
  211. package/dist/twilight/p-3cffa4c9.entry.js +4 -0
  212. package/dist/twilight/p-3d0bb451.entry.js +4 -0
  213. package/dist/twilight/p-3e0d814c.entry.js +4 -0
  214. package/dist/twilight/p-4036d5dc.entry.js +4 -0
  215. package/dist/twilight/p-40fe4b01.entry.js +4 -0
  216. package/dist/twilight/p-47ac0ca5.entry.js +4 -0
  217. package/dist/twilight/{p-5bf05092.entry.js → p-4cd9da44.entry.js} +1 -1
  218. package/dist/twilight/p-5c9281d3.entry.js +4 -0
  219. package/dist/twilight/p-5d044466.entry.js +4 -0
  220. package/dist/twilight/p-5d21334a.entry.js +4 -0
  221. package/dist/twilight/{p-c096e336.entry.js → p-654429df.entry.js} +1 -1
  222. package/dist/twilight/p-6b8453be.entry.js +4 -0
  223. package/dist/twilight/p-6be7bbb0.entry.js +4 -0
  224. package/dist/twilight/{p-4253fc44.entry.js → p-6c8f5c94.entry.js} +1 -1
  225. package/dist/twilight/{p-6f5d02c6.entry.js → p-6fa02770.entry.js} +1 -1
  226. package/dist/twilight/p-7040ea33.entry.js +4 -0
  227. package/dist/twilight/p-8c189d76.entry.js +4 -0
  228. package/dist/twilight/p-8f1f052c.entry.js +4 -0
  229. package/dist/twilight/{p-ac6fc286.entry.js → p-9051a540.entry.js} +1 -1
  230. package/dist/twilight/p-9f1c561f.entry.js +4 -0
  231. package/dist/twilight/{p-B2SkkGH8.js → p-B69XOH6h.js} +1 -1
  232. package/dist/twilight/{p-6mr785rH.js → p-B74h9G6a.js} +2 -2
  233. package/dist/twilight/{p-C0JNGIpa.js → p-BChI23pG.js} +1 -1
  234. package/dist/twilight/{p-C_h1JDCU.js → p-BCxm-ISm.js} +1 -1
  235. package/dist/twilight/{p-Bp_xKTyn.js → p-BPqZ249Z.js} +1 -1
  236. package/dist/twilight/p-BV4kqbdL.js +4 -0
  237. package/dist/twilight/p-BsLF_HK7.js +4 -0
  238. package/dist/twilight/{p-uTyAzPSy.js → p-BsXh13x8.js} +1 -1
  239. package/dist/twilight/p-BscTeWDc.js +4 -0
  240. package/dist/twilight/p-C-tzSDxw.js +4 -0
  241. package/dist/twilight/p-C6jIkM-X.js +4 -0
  242. package/dist/twilight/p-CO-PeZ27.js +4 -0
  243. package/dist/twilight/{p-ChfiVIJv.js → p-CQq81yb5.js} +1 -1
  244. package/dist/twilight/{p-DWksgowB.js → p-CgR-T_ZS.js} +1 -1
  245. package/dist/twilight/p-Ctkfc4K-.js +4 -0
  246. package/dist/twilight/p-D3mWkc-3.js +4 -0
  247. package/dist/twilight/p-D4oPi1Ov.js +4 -0
  248. package/dist/twilight/p-DCZbpt2a.js +4 -0
  249. package/dist/twilight/p-DY4LZmNP.js +4 -0
  250. package/dist/twilight/p-DfeagqF1.js +4 -0
  251. package/dist/twilight/{p-Cuxsz9f-.js → p-DpsbV3x1.js} +1 -1
  252. package/dist/twilight/p-OF8QcbMM.js +4 -0
  253. package/dist/twilight/p-Vqpj4CWE.js +4 -0
  254. package/dist/twilight/p-ZT7ehBBk.js +4 -0
  255. package/dist/twilight/{p-tFBCbVoG.js → p-_-aXm0Wb.js} +1 -1
  256. package/dist/twilight/p-a100bd38.entry.js +4 -0
  257. package/dist/twilight/{p-0c87ef6c.entry.js → p-a2756650.entry.js} +1 -1
  258. package/dist/twilight/{p-8b018d82.entry.js → p-aab45a16.entry.js} +1 -1
  259. package/dist/twilight/p-aae761ff.entry.js +4 -0
  260. package/dist/twilight/p-afd61e47.entry.js +4 -0
  261. package/dist/twilight/p-b1fc6dfc.entry.js +4 -0
  262. package/dist/twilight/p-b206a0a1.entry.js +4 -0
  263. package/dist/twilight/p-b2332516.entry.js +4 -0
  264. package/dist/twilight/{p-18ebec2c.entry.js → p-b588ef46.entry.js} +1 -1
  265. package/dist/twilight/p-b71fc1b5.entry.js +4 -0
  266. package/dist/twilight/{p-zHj-W7EE.js → p-bVqtOl1F.js} +1 -1
  267. package/dist/twilight/{p-300624bb.entry.js → p-bf65b263.entry.js} +1 -1
  268. package/dist/twilight/{p-33ea3141.entry.js → p-c56a47b0.entry.js} +1 -1
  269. package/dist/twilight/p-c73189e3.entry.js +4 -0
  270. package/dist/twilight/p-d1203242.entry.js +4 -0
  271. package/dist/twilight/p-d4edfed4.entry.js +4 -0
  272. package/dist/twilight/{p-6472200c.entry.js → p-d86ce978.entry.js} +1 -1
  273. package/dist/twilight/{p-fa585081.entry.js → p-d9e7973d.entry.js} +1 -1
  274. package/dist/twilight/p-e3e33238.entry.js +4 -0
  275. package/dist/twilight/p-e6bb7362.entry.js +4 -0
  276. package/dist/twilight/{p-28900b2e.entry.js → p-e7813c80.entry.js} +1 -1
  277. package/dist/twilight/p-ec2fd37e.entry.js +4 -0
  278. package/dist/twilight/{p-b60db6c8.entry.js → p-ec77c523.entry.js} +1 -1
  279. package/dist/twilight/{p-8c7b7712.entry.js → p-efc18ce6.entry.js} +1 -1
  280. package/dist/twilight/p-f4039c40.entry.js +4 -0
  281. package/dist/twilight/p-f47b130c.entry.js +4 -0
  282. package/dist/twilight/{p-7e39343d.entry.js → p-f57ca123.entry.js} +1 -1
  283. package/dist/twilight/{p-2d209f96.entry.js → p-f5ad6572.entry.js} +1 -1
  284. package/dist/twilight/p-fc65084f.entry.js +4 -0
  285. package/dist/twilight/p-fd81a311.entry.js +4 -0
  286. package/dist/twilight/{p-16b8d78c.entry.js → p-fe983809.entry.js} +1 -1
  287. package/dist/twilight/{p-BijadG7g.js → p-i5J7XGS6.js} +1 -1
  288. package/dist/twilight/{p-DnELO4MH.js → p-shFpk0H3.js} +1 -1
  289. package/dist/twilight/twilight.esm.js +1 -1
  290. package/dist/types/components/salla-product-options/salla-product-options.d.ts +8 -1
  291. package/dist/types/components.d.ts +4 -0
  292. package/package.json +5 -5
  293. package/dist/cjs/salla-accordion_62.cjs.entry.js +0 -22470
  294. package/dist/cjs/salla-review-card.cjs.entry.js +0 -183
  295. package/dist/cjs/salla-reviews-page.cjs.entry.js +0 -695
  296. package/dist/cjs/salla-reviews.cjs.entry.js +0 -106
  297. package/dist/esm/salla-accordion_62.entry.js +0 -22389
  298. package/dist/esm/salla-review-card.entry.js +0 -181
  299. package/dist/esm/salla-reviews-page.entry.js +0 -693
  300. package/dist/esm/salla-reviews.entry.js +0 -104
  301. package/dist/twilight/p-67830f2a.entry.js +0 -4
  302. package/dist/twilight/p-751dddd4.entry.js +0 -4
  303. package/dist/twilight/p-9b22a7eb.entry.js +0 -4
  304. package/dist/twilight/p-CBT_Nxny.js +0 -4
  305. package/dist/twilight/p-Dz7o69vX.js +0 -4
  306. package/dist/twilight/p-a515a8cc.entry.js +0 -4
  307. package/dist/twilight/p-c4821f8b.entry.js +0 -4
  308. package/dist/twilight/p-de807340.entry.js +0 -4
  309. package/dist/twilight/p-yRO-ZESF.js +0 -4
  310. package/dist/cjs/{twitter-pOrUNjXi.js → facebook-DbXua6B9.js} +2 -2
  311. package/dist/esm/{twitter-Dz7o69vX.js → facebook-CO-PeZ27.js} +2 -2
@@ -0,0 +1,760 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import { r as registerInstance, c as createEvent, h, H as Host, a as getElement } from './index-B74h9G6a.js';
5
+ import { a as anime } from './anime.es-CgtvEd63.js';
6
+ import { S as ShoppingBag } from './shopping-bag-DiKTtDW5.js';
7
+ import { H as Helper } from './Helper-B5RLi6Xo.js';
8
+
9
+ const sallaProductsListCss = "";
10
+
11
+ const SallaProductsList = class {
12
+ constructor(hostRef) {
13
+ registerInstance(this, hostRef);
14
+ this.productsFetched = createEvent(this, "productsFetched");
15
+ /**
16
+ * Autoload next page when scroll
17
+ */
18
+ this.autoload = false;
19
+ /**
20
+ * Custom Card Component for the Salla Products List.
21
+ *
22
+ * This component allows you to customize the appearance of individual product cards within a Salla Products List.
23
+ *
24
+ * @example
25
+ * <salla-products-list product-card-component="my-custom-card-style1" ...
26
+ * <salla-products-list product-card-component="my-custom-card-style2" ...
27
+ */
28
+ this.productCardComponent = 'custom-salla-product-card';
29
+ // State
30
+ this.page = 1;
31
+ this.placeholderText = salla.lang.get('pages.categories.no_products');
32
+ this.endOfText = salla.lang.get('common.elements.end_of_content');
33
+ this.failedLoadMore = salla.lang.get('common.elements.failed_to_load_more');
34
+ this.currentPage = salla.config.get('page');
35
+ this.filtersSnapshot = [];
36
+ this.lastViewedProductKey = "lastViewedProductId";
37
+ this.filtersKey = "filters";
38
+ this.infiniteScrollStateKey = "infiniteScrollState";
39
+ this.prevCategoryIdKey = "prevCategoryId";
40
+ this.isProcessing = false; // Tracks if we are processing data
41
+ this.scrollTimeout = null;
42
+ this.boundScrollToLastViewedProduct = () => this.scrollToLastViewedProduct();
43
+ this.boundHandleScroll = () => this.handleScroll();
44
+ this.specialPagesWithoutIds = {
45
+ 'product.index.latest': 'latest',
46
+ 'product.index.offers': 'offers',
47
+ 'product.index.search': 'search',
48
+ 'product.index.sales': 'sales'
49
+ };
50
+ //TODO:: check why `this.includes` not working!!
51
+ this.includes = Helper.parseJson(this.includes || this.host.getAttribute('includes'));
52
+ if (!Array.isArray(this.includes)) {
53
+ this.includes = null;
54
+ }
55
+ Helper.setIncludes(this.includes);
56
+ salla.lang.onLoaded(() => {
57
+ this.placeholderText = salla.lang.get('pages.categories.no_products');
58
+ this.endOfText = salla.lang.get('common.elements.end_of_content');
59
+ this.failedLoadMore = salla.lang.get('common.elements.failed_to_load_more');
60
+ this.currentPage = salla.config.get('page');
61
+ });
62
+ }
63
+ connectedCallback() {
64
+ //Override browser scroll restoration default behaviour
65
+ if ("scrollRestoration" in history)
66
+ history.scrollRestoration = "manual";
67
+ // required for scroll restoration case when the component loads before DOM content is completed (slow internet bandwidth /low device specs)
68
+ window.addEventListener('DOMContentLoaded', this.boundScrollToLastViewedProduct);
69
+ salla.event.on('salla-filters::changed', filters => this.setFilters(filters));
70
+ }
71
+ disconnectedCallback() {
72
+ window.removeEventListener('DOMContentLoaded', this.boundScrollToLastViewedProduct);
73
+ window.removeEventListener('scroll', this.boundHandleScroll);
74
+ }
75
+ /**
76
+ * Set parsed filters data from URI
77
+ * @param filters
78
+ */
79
+ async setFilters(filters) {
80
+ if (!filters || JSON.stringify(filters) === JSON.stringify(this.parsedFilters)) {
81
+ return;
82
+ }
83
+ window.scrollTo({ top: 0, behavior: 'smooth' });
84
+ // Create a deep copy of the filters object to avoid mutating the original object
85
+ this.parsedFilters = JSON.parse(JSON.stringify(filters));
86
+ this.filtersSnapshot = this.parsedFilters;
87
+ if (this.currentPage?.slug == "product.index" && this.parsedFilters && this.parsedFilters.category_id) {
88
+ this.currentCategoryIdFilter = [this.parsedFilters.category_id];
89
+ }
90
+ return this.reload();
91
+ }
92
+ /**
93
+ * Reload the list of products (entire content of the component).
94
+ */
95
+ async reload() {
96
+ !this.autoload && this.loadMoreWrapper && (this.loadMoreWrapper.style.display = 'none');
97
+ this.hasInfiniteScroll && salla.infiniteScroll.destroy(this.infiniteScroll);
98
+ this.buildNextPageUrl();
99
+ // TODO: this is problematic in testing, for the time being it's been resolved like this
100
+ this.wrapper.innerHTML = '';
101
+ if (this.hasInfiniteScroll) {
102
+ this.init();
103
+ }
104
+ else {
105
+ this.getInitialData();
106
+ }
107
+ // Special case for the placeholder loader
108
+ if (this.showPlaceholder) {
109
+ this.showPlaceholder = false;
110
+ this.placeholderLoader = document.createElement('div');
111
+ this.placeholderLoader.classList.add('s-products-list-loading-wrapper');
112
+ this.placeholderLoader.style.display = 'inherit';
113
+ this.placeholderLoader.innerHTML = `<span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader"></span>`;
114
+ this.host.insertAdjacentElement('afterend', this.placeholderLoader);
115
+ }
116
+ }
117
+ isFilterable() {
118
+ return salla.config.get('store.settings.product.filters') && this.filtersResults;
119
+ }
120
+ isSourceWithoutValue() {
121
+ return ['offers', 'latest', 'sales', 'wishlist', 'top-rated', 'reorder'].includes(this.getSource());
122
+ }
123
+ animateItems() {
124
+ anime({
125
+ targets: 'salla-products-list salla-product-card',
126
+ opacity: [0, 1],
127
+ duration: 1200,
128
+ translateY: [20, 0],
129
+ delay: function (_el, i) {
130
+ return i * 100;
131
+ },
132
+ });
133
+ }
134
+ initBaseNextPageUrl(source) {
135
+ this.nextPage = salla.url.api(`products?source=${source}`);
136
+ if (this.includes?.length) {
137
+ this.nextPage += `&includes[]=${this.includes.join('&includes[]=')}`;
138
+ }
139
+ if (this.limit) {
140
+ this.nextPage += `&per_page=${this.limit > 32 ? 32 : this.limit}`;
141
+ }
142
+ if (this.sortBy) {
143
+ this.nextPage += `&sort=${this.sortBy}`;
144
+ }
145
+ if (salla.config.get('theme.mode') === 'preview') {
146
+ this.nextPage += `&use_username_url=1`;
147
+ }
148
+ this.nextPage += '&filterable=1';
149
+ for (const [key, value] of Object.entries(this.parsedFilters || {})) {
150
+ if (["string", "number"].includes(typeof value)) {
151
+ // @ts-ignore
152
+ this.nextPage += `&filters[${encodeURIComponent(key)}]=${encodeURIComponent(value)}`;
153
+ }
154
+ else if (Array.isArray(value)) {
155
+ value.forEach(item => this.nextPage += `&filters[${encodeURIComponent(key)}][]=${encodeURIComponent(item)}`);
156
+ }
157
+ else if (typeof value === 'object') {
158
+ for (const [k, v] of Object.entries(value)) {
159
+ this.nextPage += `&filters[${encodeURIComponent(key)}][${encodeURIComponent(k)}]=${encodeURIComponent(v)}`;
160
+ }
161
+ }
162
+ }
163
+ }
164
+ buildNextPageUrl() {
165
+ let source = this.getSource();
166
+ if (source === 'json') {
167
+ return;
168
+ }
169
+ const snapshot = sessionStorage.getItem(this.infiniteScrollStateKey);
170
+ if (snapshot) {
171
+ const { nextPage } = JSON.parse(snapshot);
172
+ if (!nextPage) {
173
+ return;
174
+ }
175
+ }
176
+ this.initBaseNextPageUrl(source);
177
+ if (this.isSourceWithoutValue()) {
178
+ return;
179
+ }
180
+ if (['search', 'related', 'landing-page'].includes(source)) {
181
+ this.nextPage += `&source_value=${this.getSourceValue()}`;
182
+ return;
183
+ }
184
+ try {
185
+ this.nextPage += `&source_value[]=${this.getSourceValue().join('&source_value[]=')}`;
186
+ }
187
+ catch (e) {
188
+ salla.logger.warn(`source-value prop should be array of ids ex source-value="[1,2,3]" for the source [${source}]`);
189
+ this.sourceValueIsValid = false;
190
+ }
191
+ }
192
+ loading(isLoading = true, isBtn = false) {
193
+ if (!isLoading) {
194
+ if (!this.autoload) {
195
+ this.btnLoader && (this.btnLoader.style.display = 'none');
196
+ }
197
+ this.loader && (this.loader.style.display = 'none');
198
+ }
199
+ else {
200
+ let currentLoader = isBtn && !this.autoload ? this.btnLoader : this.loader;
201
+ currentLoader && (currentLoader.style.display = 'inherit');
202
+ }
203
+ }
204
+ getItemHTML(product) {
205
+ //as a request they don't want to let the user to open the product details
206
+ //todo:: find a better way to handle this request
207
+ this.getSource() === 'landing-page' && (product.url = '');
208
+ const customComponentTag = this.hasCustomComponent ? this.productCardComponent : 'salla-product-card';
209
+ const productCard = document.createElement(customComponentTag);
210
+ productCard.product = product;
211
+ this.applyLandingPageStyles(productCard);
212
+ this.applyHorizontalCardStyles(productCard);
213
+ // Attach click event listener to save the current products snapshot
214
+ productCard.addEventListener('click', (event) => {
215
+ const target = event.target;
216
+ // Check if the clicked element is an anchor or inside an anchor
217
+ const anchor = target.closest('a');
218
+ if (anchor) {
219
+ Helper.saveProductSource(this.getSource());
220
+ if (this.hasInfiniteScroll) {
221
+ this.takeStateSnapshot();
222
+ sessionStorage.setItem(this.lastViewedProductKey, product.id);
223
+ }
224
+ }
225
+ });
226
+ return productCard;
227
+ }
228
+ applyLandingPageStyles(productCard) {
229
+ if (this.getSource() === 'landing-page' && !this.hasCustomComponent) {
230
+ productCard.toggleAttribute('hide-add-btn', true);
231
+ productCard.classList.add('s-product-card-fit-height');
232
+ }
233
+ }
234
+ applyHorizontalCardStyles(productCard) {
235
+ if (!this.horizontalCards) {
236
+ return;
237
+ }
238
+ productCard.setAttribute('horizontal', true);
239
+ if (!this.hasCustomComponent) {
240
+ productCard.setAttribute('shadow-on-hover', true);
241
+ }
242
+ }
243
+ waitForResizing(element) {
244
+ let timeout = null;
245
+ return new Promise((resolve) => {
246
+ const resizeObserver = new ResizeObserver(() => {
247
+ clearTimeout(timeout);
248
+ timeout = setTimeout(() => {
249
+ resizeObserver.disconnect();
250
+ resolve(null);
251
+ }, 160); // Adjust delay as needed for your layout
252
+ });
253
+ resizeObserver.observe(element); // Watch the body or a specific container
254
+ });
255
+ }
256
+ waitForLayoutStable(element) {
257
+ let timeout = null;
258
+ return new Promise((resolve) => {
259
+ const observer = new MutationObserver(() => {
260
+ clearTimeout(timeout);
261
+ timeout = setTimeout(() => {
262
+ observer.disconnect();
263
+ resolve(null);
264
+ }, 160); // Adjust delay as needed for your layout
265
+ });
266
+ // Observe changes to the entire body, including child nodes and attributes.
267
+ observer.observe(element, {
268
+ childList: true,
269
+ subtree: true,
270
+ attributes: true,
271
+ });
272
+ });
273
+ }
274
+ async waitForStableLayout(element) {
275
+ // Wait for DOM mutations and layout shifts to stabilize
276
+ return await Promise.allSettled([
277
+ this.waitForResizing(element),
278
+ this.waitForLayoutStable(element)
279
+ ]);
280
+ }
281
+ scrollToLastViewedProduct() {
282
+ const lastViewedProductId = sessionStorage.getItem(this.lastViewedProductKey);
283
+ if (!lastViewedProductId || salla.url.is_page('product.single'))
284
+ return;
285
+ this.isElementLoaded(`[id*="${lastViewedProductId}"]`)
286
+ .then(() => {
287
+ const productCard = this.wrapper?.querySelector(`[id*="${lastViewedProductId}"]`);
288
+ if (!productCard)
289
+ return;
290
+ const scrollToPosition = () => {
291
+ const scrollToProductCard = () => {
292
+ // calculations is located here for last second changes in the ui (ie. sticky header height)
293
+ productCard.scrollIntoView({ block: 'start', behavior: 'instant' });
294
+ const headerSelector = matchMedia('(max-width: 1024px)').matches ? "header .inner" : "ul.main-menu";
295
+ const headerHeight = window?.header_is_sticky ? (document.querySelector(headerSelector)?.getBoundingClientRect()?.height ?? 56) : 0;
296
+ const cardsListRowGap = parseInt(getComputedStyle(this.wrapper).rowGap) ?? 16;
297
+ const productCardOffset = headerHeight + cardsListRowGap;
298
+ scrollBy({ top: productCardOffset * -1, behavior: 'instant' });
299
+ };
300
+ //start scrolling to the product card position
301
+ requestAnimationFrame(scrollToProductCard);
302
+ const productImages = productCard.querySelectorAll('img.lazy');
303
+ productImages.forEach((image) => {
304
+ const productImage = image;
305
+ const handleImageEvent = () => {
306
+ requestAnimationFrame(scrollToProductCard);
307
+ productImage.onload = productImage.onerror = null;
308
+ };
309
+ productImage.onload = handleImageEvent;
310
+ productImage.onerror = handleImageEvent;
311
+ });
312
+ // remove snapshot of product cards items in session storage after scroll restoration completiion
313
+ this.removeScrollRestorationSession();
314
+ return void 0;
315
+ };
316
+ this.waitForStableLayout(this.host).then(() => requestAnimationFrame(scrollToPosition));
317
+ });
318
+ }
319
+ isElementLoaded(selector) {
320
+ return new Promise((resolve => {
321
+ const interval = setInterval(() => {
322
+ if (document.querySelector(selector)) {
323
+ clearInterval(interval);
324
+ return resolve(document.querySelector(selector));
325
+ }
326
+ }, 50);
327
+ }));
328
+ }
329
+ ;
330
+ takeStateSnapshot() {
331
+ const currentPageData = [];
332
+ // Classic for-loop for performance
333
+ for (let i = 0; i < this.wrapper.children.length; i++) {
334
+ const child = this.wrapper.children?.[i];
335
+ currentPageData.push(child.product);
336
+ }
337
+ const scrollState = {
338
+ pageIndex: Math.max((this.infiniteScroll?.pageIndex ?? 1) - 1, 1),
339
+ nextPage: this.nextPage,
340
+ currentPageData
341
+ };
342
+ if (this.isFilterable()) {
343
+ const existingFilters = sessionStorage.getItem(this.filtersKey);
344
+ sessionStorage.setItem(this.filtersKey, existingFilters || JSON.stringify(this.filtersSnapshot));
345
+ }
346
+ sessionStorage.setItem(this.infiniteScrollStateKey, JSON.stringify(scrollState));
347
+ // Determine and store the correct prevCategoryId
348
+ let prevCategoryId = salla.config.get('page.id'); // Number or null
349
+ const currentPage = Object.keys(this.specialPagesWithoutIds).find(page => salla.url.is_page(page));
350
+ if (currentPage) {
351
+ prevCategoryId = this.specialPagesWithoutIds[currentPage];
352
+ }
353
+ else if (prevCategoryId !== null) {
354
+ prevCategoryId = String(prevCategoryId); // Ensure it's stored as a string
355
+ }
356
+ sessionStorage.setItem(this.prevCategoryIdKey, prevCategoryId);
357
+ }
358
+ removeScrollRestorationSession() {
359
+ if (!this.isFilterable()) {
360
+ sessionStorage.removeItem(this.filtersKey);
361
+ }
362
+ sessionStorage.removeItem(this.infiniteScrollStateKey);
363
+ sessionStorage.removeItem(this.lastViewedProductKey);
364
+ sessionStorage.removeItem(this.prevCategoryIdKey);
365
+ }
366
+ loadStoredScrollState() {
367
+ const storedState = sessionStorage.getItem(this.infiniteScrollStateKey);
368
+ const filetrsState = sessionStorage.getItem(this.filtersKey);
369
+ /*
370
+ * Remove the scroll restoration session under the following conditions:
371
+ * 1. The user has navigated to a different category page:
372
+ * - If the previously stored category ID is different from the current one.
373
+ * - This includes "latest", "offers", "sales" and "search" pages.
374
+ *
375
+ * 2. The user is on the homepage, but infinite scroll is disabled.
376
+ *
377
+ * 3. The user is on a product page.
378
+ */
379
+ const prevCategory = sessionStorage.getItem(this.prevCategoryIdKey); // Get previously stored category
380
+ const currentPageSlug = this.specialPagesWithoutIds[salla.config.get('page.slug')] || null;
381
+ const currentPageId = salla.config.get('page.id'); // Number or null
382
+ const isHomepage = salla.url.is_page('index');
383
+ const isProductPage = salla.url.is_page('product.single');
384
+ const isDifferentCategory = currentPageSlug
385
+ ? prevCategory !== currentPageSlug // Compare slugs for special pages
386
+ : prevCategory !== String(currentPageId); // Compare IDs otherwise
387
+ if ((prevCategory && isDifferentCategory && !isHomepage && !isProductPage)
388
+ ||
389
+ (isHomepage && !this.hasInfiniteScroll)) {
390
+ this.removeScrollRestorationSession();
391
+ this.switchToNormalBehavior = true;
392
+ return false;
393
+ }
394
+ // Keep the snapshot in product page that contains salla-products-list but without scroll restoration
395
+ if (isProductPage) {
396
+ this.switchToNormalBehavior = true;
397
+ return false;
398
+ }
399
+ if (storedState) {
400
+ try {
401
+ const { pageIndex, nextPage, currentPageData } = JSON.parse(storedState);
402
+ if (filetrsState !== 'undefined') {
403
+ const filters = JSON.parse(filetrsState);
404
+ salla.event.emit('filters::fetched', { filters });
405
+ }
406
+ this.page = pageIndex;
407
+ this.nextPage = nextPage;
408
+ // more performant on larger set of data
409
+ for (let i = 0; i < currentPageData.length; i++) {
410
+ this.wrapper.append(this.getItemHTML(currentPageData?.[i]));
411
+ }
412
+ return true;
413
+ }
414
+ catch (error) {
415
+ console.error('Failed to load stored scroll state:', error);
416
+ this.removeScrollRestorationSession();
417
+ }
418
+ }
419
+ return false;
420
+ }
421
+ getSource() {
422
+ return Helper.getProductsSource(this.source);
423
+ }
424
+ getSourceValue() {
425
+ return this.currentCategoryIdFilter ? this.currentCategoryIdFilter : Helper.getProductsSourceValue(this.source, this.sourceValue);
426
+ }
427
+ appendDataLayer(data) {
428
+ if (typeof dataLayer !== 'object' || !Array.isArray(dataLayer)) {
429
+ //todo:: check if we should define it here
430
+ return;
431
+ }
432
+ dataLayer.push({
433
+ "event": "impressions",
434
+ "ecommerce": {
435
+ "currencyCode": salla.config.currency().code,
436
+ // "event_id":"", // todo
437
+ "impressions": data.map((product, index) => {
438
+ return {
439
+ "id": product.id,
440
+ "name": product.name,
441
+ "price": product.price,
442
+ "brand": product.brand?.name || '',
443
+ "quantity": product.quantity,
444
+ // "variant": "",
445
+ "categories": [
446
+ {
447
+ "name": product.category?.name || salla.config.get('page.title'),
448
+ "id": salla.config.get('page.id')
449
+ }
450
+ ],
451
+ "category": product.category?.name || salla.config.get('page.title'),
452
+ 'position': index + 1
453
+ };
454
+ })
455
+ }
456
+ });
457
+ }
458
+ initiateInfiniteScroll() {
459
+ if (!this.hasInfiniteScroll) {
460
+ return;
461
+ }
462
+ const shouldApplyManualLoad = this.autoload && this.includes && this.includes.length > 0;
463
+ this.infiniteScroll = salla.infiniteScroll.initiate(this.wrapper, this.wrapper, {
464
+ path: () => this.nextPage,
465
+ history: false,
466
+ nextPage: this.nextPage,
467
+ scrollThreshold: shouldApplyManualLoad ? false : this.autoload ? 100 : false,
468
+ loadOnScroll: shouldApplyManualLoad ? false : this.autoload
469
+ }, true);
470
+ this.infiniteScroll.pageIndex = this.page;
471
+ this.infiniteScroll?.on('request', () => {
472
+ this.loading(true, this.autoload ? false : true);
473
+ });
474
+ // Manual scroll listener
475
+ shouldApplyManualLoad && window.addEventListener('scroll', this.boundHandleScroll);
476
+ this.infiniteScroll?.on('load', async (response) => {
477
+ if (this.isProcessing)
478
+ return;
479
+ this.isProcessing = true;
480
+ try {
481
+ if (!response.data?.length && this.infiniteScroll.pageIndex === 2) {
482
+ this.showPlaceholder = true;
483
+ salla.infiniteScroll.destroy(this.infiniteScroll);
484
+ this.loading(false);
485
+ this.placeholderLoader && this.placeholderLoader.remove();
486
+ return;
487
+ }
488
+ if (this.includes) {
489
+ await this.injectAndProcessData(response);
490
+ }
491
+ const items = this.handleResponse(response);
492
+ this.infiniteScroll.appendItems(items);
493
+ if (this.infiniteScroll.pageIndex === 2) {
494
+ if (!this.autoload && this.nextPage) {
495
+ this.loadMoreWrapper.style.display = 'block';
496
+ }
497
+ this.animateItems();
498
+ }
499
+ }
500
+ catch (error) {
501
+ console.error('Error during load:', error);
502
+ }
503
+ finally {
504
+ this.isProcessing = false;
505
+ }
506
+ });
507
+ this.infiniteScroll?.on('error', () => {
508
+ console.log('Error occurred during request');
509
+ this.status.querySelector('.s-infinite-scroll-error').classList.remove('s-hidden');
510
+ this.placeholderLoader && this.placeholderLoader.remove();
511
+ this.loading(false);
512
+ this.isProcessing = false;
513
+ });
514
+ salla.onReady(() => {
515
+ const snapshot = sessionStorage.getItem(this.infiniteScrollStateKey);
516
+ if (!snapshot) {
517
+ this.manualLoadNextPage();
518
+ }
519
+ });
520
+ }
521
+ handleScroll() {
522
+ if (this.isProcessing)
523
+ return;
524
+ if (this.scrollTimeout)
525
+ return;
526
+ this.scrollTimeout = setTimeout(() => {
527
+ this.scrollTimeout = null;
528
+ // Defer layout reads to next frame to avoid forced reflow (Lighthouse/PageSpeed)
529
+ requestAnimationFrame(() => {
530
+ const wrapperRect = this.wrapper.getBoundingClientRect();
531
+ const windowHeight = window.innerHeight;
532
+ const distanceToBottom = wrapperRect.bottom - windowHeight;
533
+ // Trigger only when the wrapper bottom is within 200px of the viewport bottom
534
+ if (distanceToBottom <= 200 && !this.isProcessing && this.nextPage) {
535
+ // Reached near the bottom of the wrapper, loading next page...
536
+ this.manualLoadNextPage();
537
+ }
538
+ });
539
+ }, 200);
540
+ }
541
+ manualLoadNextPage() {
542
+ if (this.nextPage) {
543
+ this.infiniteScroll.loadNextPage();
544
+ }
545
+ }
546
+ async injectAndProcessData(response) {
547
+ try {
548
+ await Helper.injectExtraFieldsToResponse(response);
549
+ }
550
+ catch (error) {
551
+ console.error('Error injecting data:', error);
552
+ }
553
+ }
554
+ getInitialData() {
555
+ this.loading();
556
+ return salla.product.api.fetch({ source: Helper.getApiSource(this.getSource()), source_value: this.getSourceValue(), limit: this.limit }).then(async (response) => {
557
+ if (!response.data.length) {
558
+ this.showPlaceholder = true;
559
+ this.placeholderLoader && this.placeholderLoader.remove();
560
+ this.loading(false);
561
+ return;
562
+ }
563
+ await Helper.injectExtraFieldsToResponse(response);
564
+ //this.firstPageResponse will be null only in the first page, after that it will be assinged,
565
+ //for the first page we need to inject the dom after the load, see @method componentDidLoad
566
+ if (!this.firstPageResponse) {
567
+ this.firstPageResponse = response;
568
+ this.nextPage = response.cursor ? response.cursor.next : this.nextPage;
569
+ return;
570
+ }
571
+ this.handleResponse(response).forEach(card => this.wrapper.append(card));
572
+ });
573
+ }
574
+ async loadMore() {
575
+ this.infiniteScroll?.loadNextPage();
576
+ }
577
+ componentWillLoad() {
578
+ return salla.onReady()
579
+ .then(() => {
580
+ this.hasCustomComponent = !!customElements.get(this.productCardComponent);
581
+ this.sourceValueIsValid = !!(this.getSourceValue() || this.isSourceWithoutValue());
582
+ this.hasInfiniteScroll = !['json', 'selected', 'related', 'landing-page', 'recently'].includes(this.getSource()) && !this.limit;
583
+ let searchParams = new URLSearchParams(window.location.search);
584
+ try {
585
+ this.sortBy = this.sortBy || searchParams.get('sort') || searchParams.get('by');
586
+ this.parsedFilters = Helper.extractFiltersFromUrl(searchParams);
587
+ if (this.parsedFilters && this.parsedFilters.category_id) {
588
+ this.currentCategoryIdFilter = [this.parsedFilters.category_id];
589
+ }
590
+ }
591
+ catch (e) {
592
+ salla.logger.warn('failed to get filters from url', e.message);
593
+ }
594
+ this.buildNextPageUrl();
595
+ this.isReady = true;
596
+ const snapshot = sessionStorage.getItem(this.infiniteScrollStateKey);
597
+ if (!!snapshot) {
598
+ return;
599
+ }
600
+ if (!this.sourceValueIsValid) {
601
+ salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`);
602
+ return;
603
+ }
604
+ if (this.hasInfiniteScroll) {
605
+ return;
606
+ }
607
+ // Handle json source
608
+ if (this.getSource() === 'json') {
609
+ if (!this.getSourceValue().length) {
610
+ this.showPlaceholder = true;
611
+ return;
612
+ }
613
+ //todo:: avoid using timeout, just assigne the data to the this.firstPageResponse and it should work fine, because it will be rendered in componentDidLoad
614
+ setTimeout(() => {
615
+ let productsList = this.getSourceValue();
616
+ productsList.map(product => this.wrapper.append(this.getItemHTML(product)));
617
+ });
618
+ return;
619
+ }
620
+ // Handle selected source
621
+ if (this.getSource() === 'selected' && !this.getSourceValue().length) {
622
+ this.showPlaceholder = true;
623
+ return;
624
+ }
625
+ return this.getInitialData();
626
+ });
627
+ }
628
+ async componentDidLoad() {
629
+ this.hasInfiniteScroll && this.init();
630
+ await Salla.hooks.registerComponent('salla-products-list', this);
631
+ if (this.loadStoredScrollState()) {
632
+ if (this.autoload) {
633
+ !this.nextPage && this.loading(false);
634
+ }
635
+ else if (!this.nextPage) {
636
+ this.loadMoreWrapper && (this.loadMoreWrapper.style.display = 'none');
637
+ this.status.querySelector('.s-infinite-scroll-last').classList.remove('s-hidden');
638
+ }
639
+ else {
640
+ this.loadMoreWrapper && (this.loadMoreWrapper.style.display = 'block');
641
+ }
642
+ this.scrollToLastViewedProduct();
643
+ }
644
+ else if (!this.firstPageResponse && this.switchToNormalBehavior) {
645
+ this.getInitialData()
646
+ .then(() => {
647
+ if (this.firstPageResponse) {
648
+ this.handleResponse(this.firstPageResponse, false).forEach(card => {
649
+ this.wrapper.append(card);
650
+ });
651
+ setTimeout(() => {
652
+ if (!this.autoload && this.nextPage && this.infiniteScroll.pageIndex == 1) {
653
+ const loadMoreWrapper = this.host.querySelector('.s-infinite-scroll-wrapper');
654
+ loadMoreWrapper && (loadMoreWrapper.style.display = 'block');
655
+ }
656
+ });
657
+ }
658
+ else {
659
+ console.error("No response received after getInitialData.");
660
+ }
661
+ })
662
+ .catch(error => {
663
+ console.error("Error during initial data fetch:", error);
664
+ });
665
+ }
666
+ else {
667
+ this.firstPageResponse && this.handleResponse(this.firstPageResponse, false).forEach(card => this.wrapper.append(card));
668
+ }
669
+ }
670
+ canRender() {
671
+ return this.sourceValueIsValid && this.isReady;
672
+ }
673
+ render() {
674
+ if (!this.canRender()) {
675
+ return '';
676
+ }
677
+ if (this.showPlaceholder) {
678
+ return h("div", { class: "s-products-list-placeholder" }, h("span", { innerHTML: ShoppingBag }), h("p", null, this.placeholderText));
679
+ }
680
+ return (h(Host, { class: "s-products-list" }, h("div", { class: {
681
+ "s-products-list-wrapper": true,
682
+ 's-products-list-horizontal-cards': this.horizontalCards && !this.filtersResults,
683
+ 's-products-list-vertical-cards': !this.horizontalCards && !this.rowCards && !this.filtersResults,
684
+ 's-products-list-row-cards': this.rowCards,
685
+ 's-products-list-filters-results': this.filtersResults,
686
+ }, ref: wrapper => this.wrapper = wrapper }), h("div", { class: "s-infinite-scroll-status", ref: status => this.status = status }, h("p", { class: "s-infinite-scroll-last infinite-scroll-last s-hidden" }, this.endOfText), h("p", { class: "s-infinite-scroll-error infinite-scroll-error s-hidden" }, this.failedLoadMore)), this.autoload && h("div", { class: "s-products-list-loading-wrapper", style: { "display": "none" }, ref: loader => this.loader = loader }, h("span", { class: "s-button-loader s-button-loader-center s-infinite-scroll-btn-loader" })), this.hasInfiniteScroll && this.nextPage && !this.autoload ? (h("div", { class: "s-infinite-scroll-wrapper", style: { "display": "none" }, ref: loadMoreWrapper => this.loadMoreWrapper = loadMoreWrapper }, h("button", { onClick: () => this.loadMore(), class: "s-infinite-scroll-btn s-button-btn s-button-primary" }, h("span", { class: "s-button-text s-infinite-scroll-btn-text" }, this.loadMoreText ? this.loadMoreText : salla.lang.get('common.elements.load_more')), h("span", { class: "s-button-loader s-button-loader-center s-infinite-scroll-btn-loader", ref: btnLoader => this.btnLoader = btnLoader, style: { "display": "none" } })))) : ""));
687
+ }
688
+ init() {
689
+ this.initiateInfiniteScroll();
690
+ this.loading();
691
+ }
692
+ handleResponse(response, shouldBuildNextPage = true) {
693
+ //todo:: check why it reach here undfined one time🤔
694
+ if (!response) {
695
+ return [];
696
+ }
697
+ let source = this.getSource();
698
+ let title = '';
699
+ //help the developer to know the current page title
700
+ if (response.cursor?.current === 1) {
701
+ title = Helper.getPageTitleForSource(source);
702
+ try {
703
+ if (this.getSource() === 'search') {
704
+ title = salla.lang.get('common.elements.search_about', { 'word': this.getSourceValue() });
705
+ }
706
+ else if (!title) {
707
+ let catId = this.parsedFilters.category_id || this.getSourceValue()[0];
708
+ // get the first filter that its key is category_id, then get the value when filter.value.*.key==catId
709
+ title = response.filters?.find(filter => filter.key === 'category_id')?.values?.find(cat => cat.key === catId)?.value ?? '';
710
+ this.filtersSnapshot = response.filters;
711
+ }
712
+ title += (title ? ' - ' : '') + salla.lang.choice('blocks.header.products_count', response.data?.length);
713
+ if (response.data.length === 15) {
714
+ title = title.replace(response.data.length, salla.lang.get('common.elements.more_than') + ' ' + response.data.length);
715
+ }
716
+ response.title = title;
717
+ }
718
+ catch (e) {
719
+ salla.logger.error('Error::falid to handle response', e);
720
+ }
721
+ //inject the SEO schema
722
+ //handleResponse works only on the infinite-scroll and infinite scroll works only on the categories pages and main latest-page ..etc, so no need to add condition
723
+ Helper.generateProductSchema(response.data);
724
+ }
725
+ this.appendDataLayer(response.data);
726
+ response.nextPage = this.nextPage;
727
+ response.source = this.getSource();
728
+ response.sourceValue = this.getSourceValue();
729
+ salla.event.emit('salla-products-list::products.fetched', response);
730
+ this.productsFetched.emit(response);
731
+ //💡 when source is related, cursor will not be existed
732
+ if (response.filters && this.isFilterable()) {
733
+ this.filtersResults = true;
734
+ this.filtersSnapshot = JSON.parse(JSON.stringify(response.filters));
735
+ salla.event.emit('filters::fetched', { filters: response.filters });
736
+ }
737
+ else if (this.isFilterable()) {
738
+ salla.event.emit('filters::hidden');
739
+ }
740
+ //because: this.nextPage is state we don't need to touch it after the build, to avoid the re-rendering
741
+ if (shouldBuildNextPage) {
742
+ this.nextPage = response.cursor ? response.cursor.next : this.nextPage;
743
+ }
744
+ this.loading(false);
745
+ this.placeholderLoader && this.placeholderLoader.remove();
746
+ if (this.hasInfiniteScroll && !this.nextPage) {
747
+ this.infiniteScroll.option({ scrollThreshold: false, loadOnScroll: false });
748
+ this.status.querySelector('.s-infinite-scroll-last').classList.remove('s-hidden');
749
+ }
750
+ const productCardsView = [];
751
+ for (let i = 0; i < response.data.length; i++) {
752
+ productCardsView.push(this.getItemHTML(response.data?.[i]));
753
+ }
754
+ return productCardsView;
755
+ }
756
+ get host() { return getElement(this); }
757
+ };
758
+ SallaProductsList.style = sallaProductsListCss;
759
+
760
+ export { SallaProductsList as salla_products_list };