@salla.sa/twilight-components 2.14.449 → 2.14.451
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{filepond-f9KbKIYn.js → filepond-CFAfS398.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-BSdUMAjs.js → filepond-plugin-file-poster-CGV3AN8S.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-YLL5nfmo.js → filepond-plugin-file-validate-size-5lxojxa3.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-DnRb2szA.js → filepond-plugin-file-validate-type-DU3FUIcL.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-BDCQgpe-.js → filepond-plugin-image-edit-DYML2Igz.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-CDJWoL6I.js → filepond-plugin-image-exif-orientation-PyHdAMQE.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-1OlWyiTm.js → filepond-plugin-image-preview-B723diKP.js} +1 -1
- package/dist/cjs/{functions-BZosuGw4.js → functions-CCmv-cGP.js} +1 -1
- package/dist/cjs/{index-Dj3X-WjA.js → index-CL8sn0_c.js} +1 -1
- package/dist/cjs/{index-C7gO-zm5.js → index-lbHgh2oF.js} +6 -6
- package/dist/cjs/index.esm-DOwgk2YK.js +2444 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
- package/dist/cjs/salla-add-product-button_5.cjs.entry.js +1 -1
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-alert_2.cjs.entry.js +21 -17
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-badge.cjs.entry.js +1 -1
- package/dist/cjs/salla-booking-field_7.cjs.entry.js +10 -10
- package/dist/cjs/salla-bullet-delivery_2.cjs.entry.js +4611 -24
- package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-cashback-banner.cjs.entry.js +1 -1
- package/dist/cjs/salla-comment-form_8.cjs.entry.js +1 -1
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
- package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
- package/dist/cjs/salla-count-down.cjs.entry.js +1 -1
- package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
- package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
- package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters.cjs.entry.js +1 -1
- package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
- package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
- package/dist/cjs/salla-hook.cjs.entry.js +1 -1
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
- package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-banner.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty-hero_2.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty-panel.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-points-banner.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-reward.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
- package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-map.cjs.entry.js +1 -1
- package/dist/cjs/salla-menu.cjs.entry.js +1 -1
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +1 -1
- package/dist/cjs/salla-payments.cjs.entry.js +1 -1
- package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
- package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-card-embed.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-card_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
- package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
- package/dist/cjs/salla-progress-bar.cjs.entry.js +1 -1
- package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-reward-action_4.cjs.entry.js +3 -3
- package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
- package/dist/cjs/salla-search.cjs.entry.js +1 -1
- package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
- package/dist/cjs/salla-slider.cjs.entry.js +1 -1
- package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
- package/dist/cjs/salla-social.cjs.entry.js +1 -1
- package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/{tracked-promise-CMALwoa6.js → tracked-promise-BEZGH5zy.js} +1 -1
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/cjs/{vanilla-picker-BEliYBNM.js → vanilla-picker-DEoSMlkf.js} +1 -1
- package/dist/collection/assets/svg/location-tag.svg +10 -0
- package/dist/collection/components/salla-bottom-alert/salla-bottom-alert.js +20 -16
- package/dist/collection/components/salla-bullet-delivery/api-service.js +6 -0
- package/dist/collection/components/salla-bullet-delivery/helpers.js +3 -1
- package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.css +128 -0
- package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.js +195 -20
- package/dist/components/index.esm.js +2424 -0
- package/dist/components/index.js +2 -2
- package/dist/components/salla-bottom-alert.js +20 -16
- package/dist/components/salla-bullet-delivery.js +4644 -51
- package/dist/esm/{filepond-CDpPHT7z.js → filepond-CCUaTwJO.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-BOtfCgt6.js → filepond-plugin-file-poster-C3FfmUV2.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size--uO_3T9g.js → filepond-plugin-file-validate-size-27nMbGKo.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-DnJbL2zb.js → filepond-plugin-file-validate-type-RRO4qH5n.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-CjUUwl1o.js → filepond-plugin-image-edit-wY6LYrlF.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-DkjfYMVD.js → filepond-plugin-image-exif-orientation-OrAkjCVu.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-3LlHu8_B.js → filepond-plugin-image-preview-COtDiNmq.js} +1 -1
- package/dist/esm/{functions-BQD6jHG4.js → functions-BBStjquJ.js} +1 -1
- package/dist/esm/{index-CFtXUFT2.js → index-BAOl7AJU.js} +6 -6
- package/dist/esm/{index-B5mrC7UX.js → index-BgFU58I4.js} +1 -1
- package/dist/esm/index.esm-BkPzCq-C.js +2424 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/salla-accordion-body_2.entry.js +1 -1
- package/dist/esm/salla-accordion_6.entry.js +1 -1
- package/dist/esm/salla-add-product-button_5.entry.js +1 -1
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-alert_2.entry.js +21 -17
- package/dist/esm/salla-app-install-alert.entry.js +1 -1
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-badge.entry.js +1 -1
- package/dist/esm/salla-booking-field_7.entry.js +10 -10
- package/dist/esm/salla-bullet-delivery_2.entry.js +4646 -59
- package/dist/esm/salla-cart-coupons.entry.js +1 -1
- package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
- package/dist/esm/salla-cashback-banner.entry.js +1 -1
- package/dist/esm/salla-comment-form_8.entry.js +1 -1
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +1 -1
- package/dist/esm/salla-cookies-bar.entry.js +1 -1
- package/dist/esm/salla-count-down.entry.js +1 -1
- package/dist/esm/salla-custom-fields.entry.js +1 -1
- package/dist/esm/salla-delivery-promise.entry.js +1 -1
- package/dist/esm/salla-edit-order-button.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +1 -1
- package/dist/esm/salla-filters.entry.js +1 -1
- package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
- package/dist/esm/salla-gifting.entry.js +1 -1
- package/dist/esm/salla-hook.entry.js +1 -1
- package/dist/esm/salla-infinite-scroll.entry.js +1 -1
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-list-tile.entry.js +1 -1
- package/dist/esm/salla-localization-modal.entry.js +1 -1
- package/dist/esm/salla-login-modal.entry.js +1 -1
- package/dist/esm/salla-loyalty-banner.entry.js +2 -2
- package/dist/esm/salla-loyalty-hero_2.entry.js +2 -2
- package/dist/esm/salla-loyalty-panel.entry.js +3 -3
- package/dist/esm/salla-loyalty-points-banner.entry.js +1 -1
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty-program.entry.js +3 -3
- package/dist/esm/salla-loyalty-reward.entry.js +2 -2
- package/dist/esm/salla-loyalty.entry.js +1 -1
- package/dist/esm/salla-maintenance-alert.entry.js +1 -1
- package/dist/esm/salla-map.entry.js +1 -1
- package/dist/esm/salla-menu.entry.js +1 -1
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-next-order-coupon.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +1 -1
- package/dist/esm/salla-notifications.entry.js +1 -1
- package/dist/esm/salla-offer-modal.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-order-details-options.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +1 -1
- package/dist/esm/salla-order-edit-item.entry.js +1 -1
- package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
- package/dist/esm/salla-order-edit.entry.js +1 -1
- package/dist/esm/salla-order-summary.entry.js +1 -1
- package/dist/esm/salla-order-totals-card.entry.js +1 -1
- package/dist/esm/salla-orders.entry.js +1 -1
- package/dist/esm/salla-payments.entry.js +1 -1
- package/dist/esm/salla-placeholder.entry.js +1 -1
- package/dist/esm/salla-price-range.entry.js +1 -1
- package/dist/esm/salla-product-card-embed.entry.js +1 -1
- package/dist/esm/salla-product-card_2.entry.js +1 -1
- package/dist/esm/salla-product-size-guide.entry.js +1 -1
- package/dist/esm/salla-products-list.entry.js +1 -1
- package/dist/esm/salla-progress-bar.entry.js +1 -1
- package/dist/esm/salla-quick-order.entry.js +1 -1
- package/dist/esm/salla-rating-modal.entry.js +1 -1
- package/dist/esm/salla-reward-action_4.entry.js +3 -3
- package/dist/esm/salla-scopes.entry.js +1 -1
- package/dist/esm/salla-search.entry.js +1 -1
- package/dist/esm/salla-skeleton.entry.js +1 -1
- package/dist/esm/salla-slider.entry.js +1 -1
- package/dist/esm/salla-social-share.entry.js +1 -1
- package/dist/esm/salla-social.entry.js +1 -1
- package/dist/esm/salla-tab-content_3.entry.js +1 -1
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-tooltip.entry.js +1 -1
- package/dist/esm/salla-trust-badges.entry.js +1 -1
- package/dist/esm/salla-user-menu.entry.js +1 -1
- package/dist/esm/salla-user-profile.entry.js +1 -1
- package/dist/esm/salla-user-settings.entry.js +1 -1
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/{tracked-promise-7zOvv3M6.js → tracked-promise-CPfI_VcX.js} +1 -1
- package/dist/esm/twilight.js +3 -3
- package/dist/esm/{vanilla-picker-yptjYbav.js → vanilla-picker-D6ctFQpu.js} +1 -1
- package/dist/twilight/{p-DZLwjHmr.js → p--sGcI7SX.js} +1 -1
- package/dist/twilight/{p-c6ed7a7f.entry.js → p-01359d46.entry.js} +1 -1
- package/dist/twilight/{p-a22f93c7.entry.js → p-02668306.entry.js} +1 -1
- package/dist/twilight/{p-a709602c.entry.js → p-02e4b3f7.entry.js} +1 -1
- package/dist/twilight/{p-187ddba3.entry.js → p-059a362b.entry.js} +1 -1
- package/dist/twilight/{p-564d8c45.entry.js → p-082ac280.entry.js} +1 -1
- package/dist/twilight/{p-effe5301.entry.js → p-091ef563.entry.js} +1 -1
- package/dist/twilight/p-0bb2ae4a.entry.js +4 -0
- package/dist/twilight/{p-a4de6d64.entry.js → p-0c2af75c.entry.js} +1 -1
- package/dist/twilight/{p-c24749d7.entry.js → p-1090cced.entry.js} +1 -1
- package/dist/twilight/{p-6ccdae0e.entry.js → p-14319930.entry.js} +1 -1
- package/dist/twilight/{p-f31595be.entry.js → p-1b028d1e.entry.js} +1 -1
- package/dist/twilight/{p-c987e5c4.entry.js → p-1c8f540e.entry.js} +1 -1
- package/dist/twilight/{p-52dada7c.entry.js → p-1f98bb26.entry.js} +1 -1
- package/dist/twilight/{p-210b5cd5.entry.js → p-20d5f87f.entry.js} +1 -1
- package/dist/twilight/{p-f92040a1.entry.js → p-224d3c26.entry.js} +1 -1
- package/dist/twilight/{p-8b578d2c.entry.js → p-26ef7b3c.entry.js} +1 -1
- package/dist/twilight/{p-7d3b048e.entry.js → p-2879b9ac.entry.js} +1 -1
- package/dist/twilight/{p-764f3053.entry.js → p-2b706f7e.entry.js} +1 -1
- package/dist/twilight/{p-26a0fdd4.entry.js → p-3400cfe4.entry.js} +1 -1
- package/dist/twilight/{p-fbdf7bc2.entry.js → p-34bea7ca.entry.js} +1 -1
- package/dist/twilight/{p-c2fa334e.entry.js → p-37ad673f.entry.js} +1 -1
- package/dist/twilight/{p-10f3641c.entry.js → p-3829e7fb.entry.js} +1 -1
- package/dist/twilight/{p-b5bf31c8.entry.js → p-436ff3dd.entry.js} +1 -1
- package/dist/twilight/{p-a5f6b737.entry.js → p-4b061d3d.entry.js} +1 -1
- package/dist/twilight/{p-536d29ce.entry.js → p-4c67cd2d.entry.js} +1 -1
- package/dist/twilight/{p-237ae017.entry.js → p-4f9a39de.entry.js} +1 -1
- package/dist/twilight/{p-5e30b0bd.entry.js → p-5165a1aa.entry.js} +1 -1
- package/dist/twilight/{p-54d8c2ca.entry.js → p-53c543c6.entry.js} +1 -1
- package/dist/twilight/{p-dad1b803.entry.js → p-56c33728.entry.js} +1 -1
- package/dist/twilight/{p-76bbabcb.entry.js → p-5851ae3f.entry.js} +1 -1
- package/dist/twilight/{p-b96744fc.entry.js → p-58d38f43.entry.js} +1 -1
- package/dist/twilight/{p-e89bfadd.entry.js → p-5cd566f6.entry.js} +1 -1
- package/dist/twilight/{p-b3123f77.entry.js → p-5ce3a659.entry.js} +1 -1
- package/dist/twilight/{p-a832d2f6.entry.js → p-6446fca2.entry.js} +1 -1
- package/dist/twilight/{p-97b47164.entry.js → p-66026d3b.entry.js} +1 -1
- package/dist/twilight/{p-58face3f.entry.js → p-66fc6ca0.entry.js} +1 -1
- package/dist/twilight/{p-cc06234d.entry.js → p-69824501.entry.js} +1 -1
- package/dist/twilight/{p-3c328960.entry.js → p-6bd2e89b.entry.js} +1 -1
- package/dist/twilight/{p-ca38de68.entry.js → p-6e60ba3f.entry.js} +1 -1
- package/dist/twilight/{p-b4108a9a.entry.js → p-72770a46.entry.js} +1 -1
- package/dist/twilight/{p-bcbb8488.entry.js → p-76dbef2b.entry.js} +1 -1
- package/dist/twilight/{p-d8cb14bd.entry.js → p-77020583.entry.js} +1 -1
- package/dist/twilight/{p-d8d6f688.entry.js → p-7a80b4d6.entry.js} +1 -1
- package/dist/twilight/{p-967fbc9c.entry.js → p-80ac1d80.entry.js} +1 -1
- package/dist/twilight/{p-2174a8e6.entry.js → p-87593f7e.entry.js} +1 -1
- package/dist/twilight/{p-0f7f0c9a.entry.js → p-8ab015d1.entry.js} +1 -1
- package/dist/twilight/{p-e1b2f1cd.entry.js → p-8bbe9a50.entry.js} +1 -1
- package/dist/twilight/{p-947aea47.entry.js → p-8bd255f1.entry.js} +1 -1
- package/dist/twilight/{p-fe8417b0.entry.js → p-8c06c63a.entry.js} +1 -1
- package/dist/twilight/{p-c4f9029a.entry.js → p-9b9851cc.entry.js} +1 -1
- package/dist/twilight/{p-b5184ea5.entry.js → p-9f09fd9c.entry.js} +1 -1
- package/dist/twilight/{p-99fa8ba6.entry.js → p-9f7d63e8.entry.js} +1 -1
- package/dist/twilight/{p-c0491160.entry.js → p-9fff0a8c.entry.js} +1 -1
- package/dist/twilight/{p-CFtXUFT2.js → p-BAOl7AJU.js} +1 -1
- package/dist/twilight/{p-4HuZkmYv.js → p-BjvOwYKG.js} +1 -1
- package/dist/twilight/p-BkPzCq-C.js +4 -0
- package/dist/twilight/{p-DRqWSUhZ.js → p-C2ha2a9w.js} +1 -1
- package/dist/twilight/{p-DVY4bWKx.js → p-COOk2-xF.js} +2 -2
- package/dist/twilight/{p-Cz2LJSD1.js → p-CiN9P6Vs.js} +1 -1
- package/dist/twilight/p-CjFUdilz.js +4 -0
- package/dist/twilight/{p-BmPGKoL7.js → p-DAZuaKqm.js} +1 -1
- package/dist/twilight/{p-CUBlD0Kt.js → p-DrBLhfjt.js} +1 -1
- package/dist/twilight/{p-59337a84.entry.js → p-a07f60cc.entry.js} +1 -1
- package/dist/twilight/{p-00c80ce0.entry.js → p-a16e2ac6.entry.js} +1 -1
- package/dist/twilight/{p-3a067383.entry.js → p-a2a8fe83.entry.js} +1 -1
- package/dist/twilight/{p-af8f9d9d.entry.js → p-a3868737.entry.js} +1 -1
- package/dist/twilight/{p-3c479c07.entry.js → p-a64f0aff.entry.js} +1 -1
- package/dist/twilight/p-a83d78fb.entry.js +1019 -0
- package/dist/twilight/{p-a19b9fcd.entry.js → p-ac57e992.entry.js} +1 -1
- package/dist/twilight/{p-d4db02e7.entry.js → p-ac9bf5bf.entry.js} +1 -1
- package/dist/twilight/{p-2bb0e5c5.entry.js → p-acf12c83.entry.js} +1 -1
- package/dist/twilight/{p-400ecb0a.entry.js → p-afd1364b.entry.js} +1 -1
- package/dist/twilight/{p-a2b9f075.entry.js → p-b0a99b96.entry.js} +1 -1
- package/dist/twilight/{p-31d281ab.entry.js → p-b2069f14.entry.js} +1 -1
- package/dist/twilight/{p-7fcbc3ef.entry.js → p-b42c7823.entry.js} +1 -1
- package/dist/twilight/{p-dfd0bf16.entry.js → p-b6661dd0.entry.js} +1 -1
- package/dist/twilight/{p-469c8350.entry.js → p-b929dda0.entry.js} +1 -1
- package/dist/twilight/{p-bf4257bb.entry.js → p-b9385507.entry.js} +1 -1
- package/dist/twilight/{p-bf76d88f.entry.js → p-bb4205bf.entry.js} +1 -1
- package/dist/twilight/{p-2b3e3ca7.entry.js → p-bec9d32a.entry.js} +1 -1
- package/dist/twilight/{p-03aed385.entry.js → p-c69e79ac.entry.js} +1 -1
- package/dist/twilight/{p-d69b9a02.entry.js → p-c82f5b3f.entry.js} +1 -1
- package/dist/twilight/{p-10adfec3.entry.js → p-caaff989.entry.js} +1 -1
- package/dist/twilight/{p-121ca1bf.entry.js → p-d18cb38a.entry.js} +1 -1
- package/dist/twilight/{p-61269cd6.entry.js → p-d1cabb89.entry.js} +1 -1
- package/dist/twilight/{p-c79ac487.entry.js → p-db744497.entry.js} +1 -1
- package/dist/twilight/{p-b04933fd.entry.js → p-e0bf3d3e.entry.js} +1 -1
- package/dist/twilight/{p-eabd1eef.entry.js → p-e632fbe1.entry.js} +1 -1
- package/dist/twilight/{p-3db06266.entry.js → p-e6f50fda.entry.js} +1 -1
- package/dist/twilight/{p-eb2e5d15.entry.js → p-e725ca51.entry.js} +1 -1
- package/dist/twilight/{p-fab8d485.entry.js → p-ea1f6f62.entry.js} +1 -1
- package/dist/twilight/{p-fc49d9c6.entry.js → p-eb9802ec.entry.js} +1 -1
- package/dist/twilight/{p-6ba1c14e.entry.js → p-eeb759a2.entry.js} +1 -1
- package/dist/twilight/{p-5e1b51dd.entry.js → p-f13ab7c3.entry.js} +1 -1
- package/dist/twilight/{p-918178f5.entry.js → p-f9a6bd74.entry.js} +1 -1
- package/dist/twilight/{p-B9HPqa9u.js → p-fngctMOB.js} +1 -1
- package/dist/twilight/{p-CxOW9p-m.js → p-nNw4abgW.js} +1 -1
- package/dist/twilight/{p-CsCwHOvQ.js → p-saXA_VGx.js} +2 -2
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-bullet-delivery/api-service.d.ts +1 -0
- package/dist/types/components/salla-bullet-delivery/helpers.d.ts +3 -0
- package/dist/types/components/salla-bullet-delivery/interfaces.d.ts +3 -0
- package/dist/types/components/salla-bullet-delivery/salla-bullet-delivery.d.ts +23 -1
- package/package.json +8 -5
- package/dist/twilight/p-2a3b2509.entry.js +0 -4
- package/dist/twilight/p-Dw1i2i3R.js +0 -4
- package/dist/twilight/p-b57b8cae.entry.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as a,c as e,h as s,H as r}from"./p-CFtXUFT2.js";import{c as l,b as t,f as o}from"./p-Dw1i2i3R.js";import{S as c}from"./p-CXRKXFgT.js";import{S as d}from"./p-cgSL_BIo.js";import{S as i}from"./p-BZp0rKEO.js";import{S as n}from"./p-8Tsmrwno.js";import{T as y}from"./p-DRqWSUhZ.js";const p=class{constructor(s){a(this,s),this.actionClick=e(this,"actionClick"),this.isShopNow=a=>!!(salla.config.get("store.features")||[]).includes("loyalty-system-v2")&&"free_product"===a.key?.toLowerCase(),this.handleClick=a=>{salla.config.isGuest()?l((()=>salla.event.dispatch("login::open"))):this.actionClick.emit(a)}}render(){return s("div",{key:"95d6e753d49c7cb69e6f5e25ef6ccf3f916f4022",class:"s-loyalty-program-rewards-modal-action"},this.isShopNow(this.prize)?s("a",{href:this.prize.prize_url||salla.url.get(""),class:{"s-loyalty-program-rewards-action-base":!0,"s-loyalty-program-rewards-action-on":!0}},salla.lang.get("pages.loyalty_program.shop_now")):s("button",{onClick:this.handleClick,class:{"s-loyalty-program-rewards-action-base":!0,"s-loyalty-program-rewards-action-on":!0}},salla.lang.get("pages.loyalty_program.redeem_reward")))}};p.style="";const f=class{constructor(s){a(this,s),this.areaClick=e(this,"areaClick"),this.actionClick=e(this,"actionClick")}render(){return s(r,{key:"900a20618e1b3ce82778aa99715baf61689f3eee",class:"s-loyalty-program-reward-host"},s("div",{key:"95b326008c2799ee7d38b48bc57e0860a9386184",class:"s-loyalty-program-reward-container"},s("div",{key:"d846dc36fa4494ed9ac6152a982f18598936969f",onClick:a=>this.areaClick.emit(a),role:"button"},s("div",{key:"b8d23796827e4b07f6c271c50fa0e4aeb59f82fc",class:"s-loyalty-program-reward-img"},s("img",{key:"04a52401941d8a731e8d310397b1ad735bfe44db",alt:"",src:this.prize.image||salla.url.cdn("images/s-empty.png"),class:"s-loyalty-program-rewards-img"})),s("div",{key:"64fa967c98d615d7b16859c9d14b60e0c53fc5aa",class:"s-loyalty-program-reward-content"},s("div",{key:"bb8c34ce8f3bcec9599c87b56bea6abd793187df",class:"s-loyalty-program-reward-points"},s("salla-badge",{key:"f7d0a396cf754d1e8f9e8fddee53a7d545311148",size:"xs"},s("span",{key:"36f4e1ed873f1a231e2d5e51a2a8cc36bdcedfee",innerHTML:c}),s("span",{key:"638b3ecefbfcb424869987ab33478e67d9b5d9b8",class:"s-loyalty-program-rewards-points"},this.prize.cost_points," ",salla.lang.get("pages.loyalty_program.points")))),s("div",{key:"6f8386fccf201836d76a86e7fe5e6d3461bb5540",class:"s-loyalty-program-reward-title"},s("span",{key:"6d6692c44d6bac35da40108514471a3c56884d81"},this.prize.group_title)),s("div",{key:"6ad9ad90728ac7f882ff8db9cfadb5a6e12f3e25",class:"s-loyalty-program-reward-name"},s("div",{key:"ef4344c7cb67785a4cd66d36e303e40a610a5375",class:"s-loyalty-program-rewards-name",id:`prize-${this.prize.id}`},this.prize.name,this.prize.description?`: ${this.prize.description}`:"")))),s("div",{key:"5eee5a4f8b10cd790ce41e4a99d94f86bd26dd3b",class:"p-4"},s("slot",{key:"359d50033cdd3cce41901401bf0b75ba9c5aea1f",name:"action"},s("button",{key:"ea7aa1c5cd50937a27cef7580e508a1e3f8f852d",onClick:a=>this.actionClick.emit(a.detail),class:"s-loyalty-program-rewards-action-base s-loyalty-program-rewards-action-on"},salla.lang.get("pages.loyalty_program.show_reward"))))))}};f.style="";var m=function(a,e,s,r){var l,t=arguments.length,o=t<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(a,e,s,r);else for(var c=a.length-1;c>=0;c--)(l=a[c])&&(o=(t<3?l(o):t>3?l(e,s,o):l(e,s))||o);return t>3&&o&&Object.defineProperty(e,s,o),o};const g=(...a)=>a.map((a=>"s-loyalty-program-"+a)).join(" "),b=class{constructor(s){a(this,s),this.actionClick=e(this,"actionClick"),this.refreshKey=Date.now()}handlePrizeChange(){this.refreshKey=Date.now()}componentWillLoad(){"idle"===this.category.status&&this.category(),"idle"===this.brand.status&&this.brand()}getTermsAndConditions(){const a=Number((this.prize.order_minimum_amount||"0").split(".")[0])||0,e=Number((this.prize.coupon_maximum_amount||"0").split(".")[0])||0,s=[];return a&&s.push([salla.lang.get("pages.loyalty_program.order_minimum_amount"),`${a} ${salla.lang.get(`currency.${(salla.config.get("user.currency_code")||"").toLowerCase()}`)}`]),e&&s.push([salla.lang.get("pages.loyalty_program.coupon_maximum_amount"),`${e} ${salla.lang.get(`currency.${(salla.config.get("user.currency_code")||"").toLowerCase()}`)}`]),s}findItems(a){return a?.length?this.brand.data.concat(this.category.data).filter((e=>a.includes(e.id_))):[]}getIncludedItems(a,e){return a?.length?a:e?.length?this.findItems(e):[]}getProductIds(a){return a||[]}getItemsMarkers(a){return"both"===a?this.getItemsMarkers("included")+this.getItemsMarkers("excluded"):[this.prize[`${a}_product_ids`]?.length||0,this.prize[`${a}_brand_ids`]?.length||0,this.prize[`${a}_category_ids`]?.length||0].map(Boolean).map(Number).join("")}getItemsMarkersText(){if("FREE_SHIPPING"===this.prize.key)return salla.lang.get("pages.loyalty_program.redeem_for_free_shipping");switch(this.getItemsMarkers("included")){case"001":default:return salla.lang.get("pages.loyalty_program.redeem_on_specific_products");case"010":return salla.lang.get("pages.loyalty_program.redeem_on_specific_brands");case"100":return salla.lang.get("pages.loyalty_program.redeem_on_specific_categories");case"000":return salla.lang.get("pages.loyalty_program.redeem_on_all_products")}}getCategoriesJsx(a,e){return a.length?s("div",{class:g("reward-details-categories-wrapper")},s("div",{class:g("reward-details-categories")},s("h2",{class:g("reward-details-categories-heading")},e),s("ul",{class:g("reward-details-categories-list")},a.map((a=>s("li",null,s("a",{href:a.urls?.customer||a.url||a.lingual_urls?.[0],class:g("reward-details-categories-item")},s("span",{innerHTML:d}),s("span",{class:g("reward-details-categories-item-content")},a.name)))))))):""}getBrandsJsx(a,e){return a.length?s("div",{class:g("reward-details-items-brands","slider-arrows-edges")},s("div",null,s("h2",null,e),s("salla-slider",{id:`brands-${a.map((({id:a})=>a)).join("-")}`,"slider-config":'{"loop":false,"slidesPerView":"auto","spaceBetween":10}'},s("div",{slot:"items"},a.map((a=>s("a",{href:salla.url.get(t(a)),class:g("reward-brand-item")},s("img",{src:a.logo||salla.url.cdn("images/s-empty.png"),alt:""})))))))):""}getProductsJsx(a,e){return a?.length?s("div",{class:"s-loyalty-program-reward-details-items-products s-loyalty-program-slider-arrows-edges"},s("h2",null,e),s("salla-products-slider",{source:"selected",sourceValue:JSON.stringify(a),"slider-config":'{"loop":false,"slidesPerView":"auto","freeMode":true,"spaceBetween":0,"breakpoints":{"768":{"slidesPerView":3,"freeMode":false,"speed":300}}}'})):""}render(){const a=this.getTermsAndConditions();return s("div",{key:"280d646eff094c16596ca31ee57f4bd104958f8c",class:"s-loyalty-program-reward-modal"},s("div",{key:"a39d376f170684f754c4357dc64d02b5ffbb1ed2",class:"s-loyalty-program-points-modal-header"},s("h1",{key:"654e061c8852461a5248248ed2d95ef02a8a4711",class:"s-loyalty-program-points-modal-info"},salla.url.is_page("cart")?s("button",{class:"s-loyalty-program-back-btn",onClick:()=>l((()=>salla.event.dispatch("modal::open","loyalty-rewards-modal")))},s("span",{class:{"sicon-arrow-right":"rtl"===document.documentElement.getAttribute("dir"),"sicon-arrow-left":"ltr"===document.documentElement.getAttribute("dir")}})):"",this.prize.name)),s("div",{key:"8dce07ce81b0d6879efc0cba88523b6d3daf42bb",class:"s-loyalty-program-modal-scrollable-content"},s("div",{key:"f288d7483911af0bbc17a824ee4397ad0b3ef367",class:"s-loyalty-program-reward-details-header"},s("div",{key:"87686174a3a8c17558d0a97180cb4756a1edbefe",class:"s-loyalty-program-aspect-container"},s("img",{key:"31461e1503c50715f160e75cf7ffad59939fb93c",src:this.prize.image,alt:this.prize.name})),s("salla-badge",{key:"ed1fc08260885fa865279a9d2fc6af35c01e2bdc",size:"sm",bg:"light"},s("span",{key:"26eec953f9c5f3fa5aa118828faec50a4477e013",innerHTML:c}),s("span",{key:"db3bf908be0f28534e121da9e692d801d2ee6cf9",class:"s-loyalty-program-points-badge-points"},o(this.prize.cost_points)))),a.length?s("div",{class:"s-loyalty-program-terms-and-conditions"},s("h1",{class:"s-loyalty-program-terms-and-conditions-heading"},salla.lang.get("pages.loyalty_program.terms_and_conditions")),s("ul",{class:"s-loyalty-program-terms-and-conditions-list"},a.map((([a,e])=>s("li",{class:"s-loyalty-program-terms-and-conditions-item"},s("span",{class:"s-loyalty-program-terms-and-conditions-content"},a),s("span",{class:"s-loyalty-program-terms-and-conditions-content"},e)))))):"",s("div",{key:"bfdc4d22117ae86f3bb2140546b4b5a8ecd35f8e",class:"s-loyalty-program-reward-info-message"},s("h1",{key:"f03b30c0372fd83e4fa7815bbd76d307c6fbe3c1",class:"s-loyalty-program-reward-info-message-heading"},salla.lang.get("pages.loyalty_program.how_to_benefit_from_this_reward")),s("p",{key:"245acd0b8438230ff5d503e5819abb581f0ba14a",class:"s-loyalty-program-reward-info-message-content"},this.getItemsMarkersText())),"FREE_SHIPPING"===this.prize.key||"000000"===this.getItemsMarkers("both")?"":s("div",{class:"s-loyalty-program-reward-details"},s("salla-tabs",{key:this.refreshKey},"000"===this.getItemsMarkers("included")?"":[s("salla-tab-header",{slot:"header",name:"included",style:{display:"000"===this.getItemsMarkers("excluded")?"none":"block"}},s("span",{class:"s-loyalty-program-reward-details-tab-icon",innerHTML:i}),s("span",null,salla.lang.get("pages.loyalty_program.included"))),s("salla-tab-content",{slot:"content",name:"included"},s("div",{class:"s-loyalty-program-reward-details-items-wrapper"},this.getCategoriesJsx(this.getIncludedItems(this.prize.categories,this.prize.included_category_ids),salla.lang.get("pages.loyalty_program.included_categories")),this.getBrandsJsx(this.getIncludedItems(this.prize.brands,this.prize.included_brand_ids),salla.lang.get("pages.loyalty_program.included_brands")),this.getProductsJsx(this.getProductIds(this.prize.included_product_ids),salla.lang.get("pages.loyalty_program.included_products"))))],"000"===this.getItemsMarkers("excluded")?"":[s("salla-tab-header",{slot:"header",name:"excluded",style:{display:"000"===this.getItemsMarkers("included")?"none":"block"}},s("span",{class:"s-loyalty-program-reward-details-tab-icon",innerHTML:n}),s("span",null,salla.lang.get("pages.loyalty_program.excluded"))),s("salla-tab-content",{slot:"content",name:"excluded"},s("div",{class:"s-loyalty-program-reward-details-items-wrapper"},this.getCategoriesJsx(this.getIncludedItems(this.prize.excludedCategories,this.prize.excluded_category_ids),salla.lang.get("pages.loyalty_program.excluded_categories")),this.getBrandsJsx(this.getIncludedItems(this.prize.excludedBrands,this.prize.excluded_brand_ids),salla.lang.get("pages.loyalty_program.excluded_brands")),this.getProductsJsx(this.getProductIds(this.prize.excluded_product_ids),salla.lang.get("pages.loyalty_program.excluded_products"))))]))),s("salla-reward-action",{key:"e129546afde7da7fe66e250ce4de67d4523727be",onActionClick:a=>this.actionClick.emit(a.detail),prize:this.prize}))}static get watchers(){return{prize:["handlePrizeChange"]}}};m([y((async()=>(await salla.product.api.categories()).data),{initialData:[]})],b.prototype,"category",void 0),m([y((async()=>(await salla.api.request("/brands")).data),{initialData:[]})],b.prototype,"brand",void 0),b.style="";const h=class{constructor(e){a(this,e),this.productId=null}reset(a=0){setTimeout((()=>{l()}),a)}getApiErrorMessage(a){return a?.response?.data?.error?.message||a?.response?.data?.message||("string"==typeof a?a:null)||salla.lang.get("common.errors.error_occurred")}async handleConfirm(){try{await this.exchange(this.prize.id,null,this.productId),this.reset(300)}catch(a){salla.notify.error(this.getApiErrorMessage(a))}}handleCancel(){this.reset(0)}render(){return s(r,{key:"ceecba37884a11443b52b76dad69bd164b52b788"},s("div",{key:"598f185363b917969b9de0fb6a536884d6578c95",class:"s-loyalty-program-exchange-heading"},s("div",{key:"a2aa6b15d97533a973f7f2fb6a2cf517c147367d",class:"s-loyalty-program-circle-base s-loyalty-program-circle-size-xl s-loyalty-program-circle-variant-fill"},s("span",{key:"9745001d514643add62fe9a64df7fc2c0a694513",innerHTML:c})),s("h2",{key:"4819327aacc1307c0f75014d9faef50f55115289"},salla.lang.get("pages.loyalty_program.redeem_reward")),s("p",{key:"b39c99abcefb0f3baf609cd21049b083a115cdef"},salla.lang.get("pages.loyalty_program.redeem_confirmation")," ",s("span",{key:"50852d87c9686f66beddc7b0a0a3062f0ced1a61"},"(",this.prize.cost_points," ",salla.lang.get("pages.loyalty_program.point"),")")," ",salla.lang.get("pages.loyalty_program.for")," ",s("span",{key:"5a4baa0f02859ced6fdcf7ce77c31bf9b27c45e6"},"(",this.prize.name,")"))),s("div",{key:"b1f1067bd0f3a84231ac017f4b66a71277a5d209",class:"s-loyalty-program-exchange-btns"},s("button",{key:"7d4ce6c08fcac58290b364a0df55f8acb715d362",class:"s-loyalty-program-rewards-action-base s-loyalty-program-rewards-action-confirm",onClick:()=>this.handleConfirm()},s("span",{key:"ef1deb96c4bbb2843ae088b539848c15aacdb244",style:{opacity:"pending"!==this.exchange.status?"1":"0"}},salla.lang.get("common.elements.confirm")),s("span",{key:"0f949386c85d7544f7098e2bdc8c7ce4390c4383",class:"s-loyalty-program-exchange-loading",style:{opacity:"pending"===this.exchange.status?"1":"0"}},s("salla-loading",{key:"9cdfbfdc7ebfb2e1874f1956560dc464e4aa2a9f",color:"primary",size:24}))),s("button",{key:"79a2e8b44be5eb4b3ec5f1a285a8f4eba5324814",class:"s-loyalty-program-rewards-action-base s-loyalty-program-rewards-action-cancel",onClick:()=>this.handleCancel()},salla.lang.get("common.elements.cancel"))))}};(function(a,e,s,r){var l,t=arguments.length,o=t<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(a,e,s,r);else for(var c=a.length-1;c>=0;c--)(l=a[c])&&(o=(t<3?l(o):t>3?l(e,s,o):l(e,s))||o);t>3&&o&&Object.defineProperty(e,s,o)})([y((async(...a)=>await salla.loyalty.exchange(...a)))],h.prototype,"exchange",void 0),h.style="";export{p as salla_reward_action,f as salla_reward_card,b as salla_reward_details,h as salla_reward_exchange}
|
|
4
|
+
import{r as a,c as e,h as s,H as r}from"./p-BAOl7AJU.js";import{c as l,b as t,f as o}from"./p-CjFUdilz.js";import{S as c}from"./p-CXRKXFgT.js";import{S as d}from"./p-cgSL_BIo.js";import{S as i}from"./p-BZp0rKEO.js";import{S as n}from"./p-8Tsmrwno.js";import{T as y}from"./p-C2ha2a9w.js";const p=class{constructor(s){a(this,s),this.actionClick=e(this,"actionClick"),this.isShopNow=a=>!!(salla.config.get("store.features")||[]).includes("loyalty-system-v2")&&"free_product"===a.key?.toLowerCase(),this.handleClick=a=>{salla.config.isGuest()?l((()=>salla.event.dispatch("login::open"))):this.actionClick.emit(a)}}render(){return s("div",{key:"95d6e753d49c7cb69e6f5e25ef6ccf3f916f4022",class:"s-loyalty-program-rewards-modal-action"},this.isShopNow(this.prize)?s("a",{href:this.prize.prize_url||salla.url.get(""),class:{"s-loyalty-program-rewards-action-base":!0,"s-loyalty-program-rewards-action-on":!0}},salla.lang.get("pages.loyalty_program.shop_now")):s("button",{onClick:this.handleClick,class:{"s-loyalty-program-rewards-action-base":!0,"s-loyalty-program-rewards-action-on":!0}},salla.lang.get("pages.loyalty_program.redeem_reward")))}};p.style="";const f=class{constructor(s){a(this,s),this.areaClick=e(this,"areaClick"),this.actionClick=e(this,"actionClick")}render(){return s(r,{key:"900a20618e1b3ce82778aa99715baf61689f3eee",class:"s-loyalty-program-reward-host"},s("div",{key:"95b326008c2799ee7d38b48bc57e0860a9386184",class:"s-loyalty-program-reward-container"},s("div",{key:"d846dc36fa4494ed9ac6152a982f18598936969f",onClick:a=>this.areaClick.emit(a),role:"button"},s("div",{key:"b8d23796827e4b07f6c271c50fa0e4aeb59f82fc",class:"s-loyalty-program-reward-img"},s("img",{key:"04a52401941d8a731e8d310397b1ad735bfe44db",alt:"",src:this.prize.image||salla.url.cdn("images/s-empty.png"),class:"s-loyalty-program-rewards-img"})),s("div",{key:"64fa967c98d615d7b16859c9d14b60e0c53fc5aa",class:"s-loyalty-program-reward-content"},s("div",{key:"bb8c34ce8f3bcec9599c87b56bea6abd793187df",class:"s-loyalty-program-reward-points"},s("salla-badge",{key:"f7d0a396cf754d1e8f9e8fddee53a7d545311148",size:"xs"},s("span",{key:"36f4e1ed873f1a231e2d5e51a2a8cc36bdcedfee",innerHTML:c}),s("span",{key:"638b3ecefbfcb424869987ab33478e67d9b5d9b8",class:"s-loyalty-program-rewards-points"},this.prize.cost_points," ",salla.lang.get("pages.loyalty_program.points")))),s("div",{key:"6f8386fccf201836d76a86e7fe5e6d3461bb5540",class:"s-loyalty-program-reward-title"},s("span",{key:"6d6692c44d6bac35da40108514471a3c56884d81"},this.prize.group_title)),s("div",{key:"6ad9ad90728ac7f882ff8db9cfadb5a6e12f3e25",class:"s-loyalty-program-reward-name"},s("div",{key:"ef4344c7cb67785a4cd66d36e303e40a610a5375",class:"s-loyalty-program-rewards-name",id:`prize-${this.prize.id}`},this.prize.name,this.prize.description?`: ${this.prize.description}`:"")))),s("div",{key:"5eee5a4f8b10cd790ce41e4a99d94f86bd26dd3b",class:"p-4"},s("slot",{key:"359d50033cdd3cce41901401bf0b75ba9c5aea1f",name:"action"},s("button",{key:"ea7aa1c5cd50937a27cef7580e508a1e3f8f852d",onClick:a=>this.actionClick.emit(a.detail),class:"s-loyalty-program-rewards-action-base s-loyalty-program-rewards-action-on"},salla.lang.get("pages.loyalty_program.show_reward"))))))}};f.style="";var m=function(a,e,s,r){var l,t=arguments.length,o=t<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(a,e,s,r);else for(var c=a.length-1;c>=0;c--)(l=a[c])&&(o=(t<3?l(o):t>3?l(e,s,o):l(e,s))||o);return t>3&&o&&Object.defineProperty(e,s,o),o};const g=(...a)=>a.map((a=>"s-loyalty-program-"+a)).join(" "),b=class{constructor(s){a(this,s),this.actionClick=e(this,"actionClick"),this.refreshKey=Date.now()}handlePrizeChange(){this.refreshKey=Date.now()}componentWillLoad(){"idle"===this.category.status&&this.category(),"idle"===this.brand.status&&this.brand()}getTermsAndConditions(){const a=Number((this.prize.order_minimum_amount||"0").split(".")[0])||0,e=Number((this.prize.coupon_maximum_amount||"0").split(".")[0])||0,s=[];return a&&s.push([salla.lang.get("pages.loyalty_program.order_minimum_amount"),`${a} ${salla.lang.get(`currency.${(salla.config.get("user.currency_code")||"").toLowerCase()}`)}`]),e&&s.push([salla.lang.get("pages.loyalty_program.coupon_maximum_amount"),`${e} ${salla.lang.get(`currency.${(salla.config.get("user.currency_code")||"").toLowerCase()}`)}`]),s}findItems(a){return a?.length?this.brand.data.concat(this.category.data).filter((e=>a.includes(e.id_))):[]}getIncludedItems(a,e){return a?.length?a:e?.length?this.findItems(e):[]}getProductIds(a){return a||[]}getItemsMarkers(a){return"both"===a?this.getItemsMarkers("included")+this.getItemsMarkers("excluded"):[this.prize[`${a}_product_ids`]?.length||0,this.prize[`${a}_brand_ids`]?.length||0,this.prize[`${a}_category_ids`]?.length||0].map(Boolean).map(Number).join("")}getItemsMarkersText(){if("FREE_SHIPPING"===this.prize.key)return salla.lang.get("pages.loyalty_program.redeem_for_free_shipping");switch(this.getItemsMarkers("included")){case"001":default:return salla.lang.get("pages.loyalty_program.redeem_on_specific_products");case"010":return salla.lang.get("pages.loyalty_program.redeem_on_specific_brands");case"100":return salla.lang.get("pages.loyalty_program.redeem_on_specific_categories");case"000":return salla.lang.get("pages.loyalty_program.redeem_on_all_products")}}getCategoriesJsx(a,e){return a.length?s("div",{class:g("reward-details-categories-wrapper")},s("div",{class:g("reward-details-categories")},s("h2",{class:g("reward-details-categories-heading")},e),s("ul",{class:g("reward-details-categories-list")},a.map((a=>s("li",null,s("a",{href:a.urls?.customer||a.url||a.lingual_urls?.[0],class:g("reward-details-categories-item")},s("span",{innerHTML:d}),s("span",{class:g("reward-details-categories-item-content")},a.name)))))))):""}getBrandsJsx(a,e){return a.length?s("div",{class:g("reward-details-items-brands","slider-arrows-edges")},s("div",null,s("h2",null,e),s("salla-slider",{id:`brands-${a.map((({id:a})=>a)).join("-")}`,"slider-config":'{"loop":false,"slidesPerView":"auto","spaceBetween":10}'},s("div",{slot:"items"},a.map((a=>s("a",{href:salla.url.get(t(a)),class:g("reward-brand-item")},s("img",{src:a.logo||salla.url.cdn("images/s-empty.png"),alt:""})))))))):""}getProductsJsx(a,e){return a?.length?s("div",{class:"s-loyalty-program-reward-details-items-products s-loyalty-program-slider-arrows-edges"},s("h2",null,e),s("salla-products-slider",{source:"selected",sourceValue:JSON.stringify(a),"slider-config":'{"loop":false,"slidesPerView":"auto","freeMode":true,"spaceBetween":0,"breakpoints":{"768":{"slidesPerView":3,"freeMode":false,"speed":300}}}'})):""}render(){const a=this.getTermsAndConditions();return s("div",{key:"280d646eff094c16596ca31ee57f4bd104958f8c",class:"s-loyalty-program-reward-modal"},s("div",{key:"a39d376f170684f754c4357dc64d02b5ffbb1ed2",class:"s-loyalty-program-points-modal-header"},s("h1",{key:"654e061c8852461a5248248ed2d95ef02a8a4711",class:"s-loyalty-program-points-modal-info"},salla.url.is_page("cart")?s("button",{class:"s-loyalty-program-back-btn",onClick:()=>l((()=>salla.event.dispatch("modal::open","loyalty-rewards-modal")))},s("span",{class:{"sicon-arrow-right":"rtl"===document.documentElement.getAttribute("dir"),"sicon-arrow-left":"ltr"===document.documentElement.getAttribute("dir")}})):"",this.prize.name)),s("div",{key:"8dce07ce81b0d6879efc0cba88523b6d3daf42bb",class:"s-loyalty-program-modal-scrollable-content"},s("div",{key:"f288d7483911af0bbc17a824ee4397ad0b3ef367",class:"s-loyalty-program-reward-details-header"},s("div",{key:"87686174a3a8c17558d0a97180cb4756a1edbefe",class:"s-loyalty-program-aspect-container"},s("img",{key:"31461e1503c50715f160e75cf7ffad59939fb93c",src:this.prize.image,alt:this.prize.name})),s("salla-badge",{key:"ed1fc08260885fa865279a9d2fc6af35c01e2bdc",size:"sm",bg:"light"},s("span",{key:"26eec953f9c5f3fa5aa118828faec50a4477e013",innerHTML:c}),s("span",{key:"db3bf908be0f28534e121da9e692d801d2ee6cf9",class:"s-loyalty-program-points-badge-points"},o(this.prize.cost_points)))),a.length?s("div",{class:"s-loyalty-program-terms-and-conditions"},s("h1",{class:"s-loyalty-program-terms-and-conditions-heading"},salla.lang.get("pages.loyalty_program.terms_and_conditions")),s("ul",{class:"s-loyalty-program-terms-and-conditions-list"},a.map((([a,e])=>s("li",{class:"s-loyalty-program-terms-and-conditions-item"},s("span",{class:"s-loyalty-program-terms-and-conditions-content"},a),s("span",{class:"s-loyalty-program-terms-and-conditions-content"},e)))))):"",s("div",{key:"bfdc4d22117ae86f3bb2140546b4b5a8ecd35f8e",class:"s-loyalty-program-reward-info-message"},s("h1",{key:"f03b30c0372fd83e4fa7815bbd76d307c6fbe3c1",class:"s-loyalty-program-reward-info-message-heading"},salla.lang.get("pages.loyalty_program.how_to_benefit_from_this_reward")),s("p",{key:"245acd0b8438230ff5d503e5819abb581f0ba14a",class:"s-loyalty-program-reward-info-message-content"},this.getItemsMarkersText())),"FREE_SHIPPING"===this.prize.key||"000000"===this.getItemsMarkers("both")?"":s("div",{class:"s-loyalty-program-reward-details"},s("salla-tabs",{key:this.refreshKey},"000"===this.getItemsMarkers("included")?"":[s("salla-tab-header",{slot:"header",name:"included",style:{display:"000"===this.getItemsMarkers("excluded")?"none":"block"}},s("span",{class:"s-loyalty-program-reward-details-tab-icon",innerHTML:i}),s("span",null,salla.lang.get("pages.loyalty_program.included"))),s("salla-tab-content",{slot:"content",name:"included"},s("div",{class:"s-loyalty-program-reward-details-items-wrapper"},this.getCategoriesJsx(this.getIncludedItems(this.prize.categories,this.prize.included_category_ids),salla.lang.get("pages.loyalty_program.included_categories")),this.getBrandsJsx(this.getIncludedItems(this.prize.brands,this.prize.included_brand_ids),salla.lang.get("pages.loyalty_program.included_brands")),this.getProductsJsx(this.getProductIds(this.prize.included_product_ids),salla.lang.get("pages.loyalty_program.included_products"))))],"000"===this.getItemsMarkers("excluded")?"":[s("salla-tab-header",{slot:"header",name:"excluded",style:{display:"000"===this.getItemsMarkers("included")?"none":"block"}},s("span",{class:"s-loyalty-program-reward-details-tab-icon",innerHTML:n}),s("span",null,salla.lang.get("pages.loyalty_program.excluded"))),s("salla-tab-content",{slot:"content",name:"excluded"},s("div",{class:"s-loyalty-program-reward-details-items-wrapper"},this.getCategoriesJsx(this.getIncludedItems(this.prize.excludedCategories,this.prize.excluded_category_ids),salla.lang.get("pages.loyalty_program.excluded_categories")),this.getBrandsJsx(this.getIncludedItems(this.prize.excludedBrands,this.prize.excluded_brand_ids),salla.lang.get("pages.loyalty_program.excluded_brands")),this.getProductsJsx(this.getProductIds(this.prize.excluded_product_ids),salla.lang.get("pages.loyalty_program.excluded_products"))))]))),s("salla-reward-action",{key:"e129546afde7da7fe66e250ce4de67d4523727be",onActionClick:a=>this.actionClick.emit(a.detail),prize:this.prize}))}static get watchers(){return{prize:["handlePrizeChange"]}}};m([y((async()=>(await salla.product.api.categories()).data),{initialData:[]})],b.prototype,"category",void 0),m([y((async()=>(await salla.api.request("/brands")).data),{initialData:[]})],b.prototype,"brand",void 0),b.style="";const h=class{constructor(e){a(this,e),this.productId=null}reset(a=0){setTimeout((()=>{l()}),a)}getApiErrorMessage(a){return a?.response?.data?.error?.message||a?.response?.data?.message||("string"==typeof a?a:null)||salla.lang.get("common.errors.error_occurred")}async handleConfirm(){try{await this.exchange(this.prize.id,null,this.productId),this.reset(300)}catch(a){salla.notify.error(this.getApiErrorMessage(a))}}handleCancel(){this.reset(0)}render(){return s(r,{key:"ceecba37884a11443b52b76dad69bd164b52b788"},s("div",{key:"598f185363b917969b9de0fb6a536884d6578c95",class:"s-loyalty-program-exchange-heading"},s("div",{key:"a2aa6b15d97533a973f7f2fb6a2cf517c147367d",class:"s-loyalty-program-circle-base s-loyalty-program-circle-size-xl s-loyalty-program-circle-variant-fill"},s("span",{key:"9745001d514643add62fe9a64df7fc2c0a694513",innerHTML:c})),s("h2",{key:"4819327aacc1307c0f75014d9faef50f55115289"},salla.lang.get("pages.loyalty_program.redeem_reward")),s("p",{key:"b39c99abcefb0f3baf609cd21049b083a115cdef"},salla.lang.get("pages.loyalty_program.redeem_confirmation")," ",s("span",{key:"50852d87c9686f66beddc7b0a0a3062f0ced1a61"},"(",this.prize.cost_points," ",salla.lang.get("pages.loyalty_program.point"),")")," ",salla.lang.get("pages.loyalty_program.for")," ",s("span",{key:"5a4baa0f02859ced6fdcf7ce77c31bf9b27c45e6"},"(",this.prize.name,")"))),s("div",{key:"b1f1067bd0f3a84231ac017f4b66a71277a5d209",class:"s-loyalty-program-exchange-btns"},s("button",{key:"7d4ce6c08fcac58290b364a0df55f8acb715d362",class:"s-loyalty-program-rewards-action-base s-loyalty-program-rewards-action-confirm",onClick:()=>this.handleConfirm()},s("span",{key:"ef1deb96c4bbb2843ae088b539848c15aacdb244",style:{opacity:"pending"!==this.exchange.status?"1":"0"}},salla.lang.get("common.elements.confirm")),s("span",{key:"0f949386c85d7544f7098e2bdc8c7ce4390c4383",class:"s-loyalty-program-exchange-loading",style:{opacity:"pending"===this.exchange.status?"1":"0"}},s("salla-loading",{key:"9cdfbfdc7ebfb2e1874f1956560dc464e4aa2a9f",color:"primary",size:24}))),s("button",{key:"79a2e8b44be5eb4b3ec5f1a285a8f4eba5324814",class:"s-loyalty-program-rewards-action-base s-loyalty-program-rewards-action-cancel",onClick:()=>this.handleCancel()},salla.lang.get("common.elements.cancel"))))}};(function(a,e,s,r){var l,t=arguments.length,o=t<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(a,e,s,r);else for(var c=a.length-1;c>=0;c--)(l=a[c])&&(o=(t<3?l(o):t>3?l(e,s,o):l(e,s))||o);t>3&&o&&Object.defineProperty(e,s,o)})([y((async(...a)=>await salla.loyalty.exchange(...a)))],h.prototype,"exchange",void 0),h.style="";export{p as salla_reward_action,f as salla_reward_card,b as salla_reward_details,h as salla_reward_exchange}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,c as s,h as i,H as e,a}from"./p-CFtXUFT2.js";import{a as r}from"./p-CgtvEd63.js";import{S as o}from"./p-DiKTtDW5.js";import{H as h}from"./p-CHf8XdiS.js";const l=class{constructor(i){t(this,i),this.productsFetched=s(this,"productsFetched"),this.autoload=!1,this.productCardComponent="custom-salla-product-card",this.page=1,this.placeholderText=salla.lang.get("pages.categories.no_products"),this.endOfText=salla.lang.get("common.elements.end_of_content"),this.failedLoadMore=salla.lang.get("common.elements.failed_to_load_more"),this.currentPage=salla.config.get("page"),this.filtersSnapshot=[],this.lastViewedProductKey="lastViewedProductId",this.filtersKey="filters",this.infiniteScrollStateKey="infiniteScrollState",this.prevCategoryIdKey="prevCategoryId",this.isProcessing=!1,this.scrollTimeout=null,this.boundScrollToLastViewedProduct=()=>this.scrollToLastViewedProduct(),this.boundHandleScroll=()=>this.handleScroll(),this.specialPagesWithoutIds={"product.index.latest":"latest","product.index.offers":"offers","product.index.search":"search","product.index.sales":"sales"},this.includes=h.parseJson(this.includes||this.host.getAttribute("includes")),Array.isArray(this.includes)||(this.includes=null),h.setIncludes(this.includes),salla.lang.onLoaded((()=>{this.placeholderText=salla.lang.get("pages.categories.no_products"),this.endOfText=salla.lang.get("common.elements.end_of_content"),this.failedLoadMore=salla.lang.get("common.elements.failed_to_load_more"),this.currentPage=salla.config.get("page")}))}connectedCallback(){"scrollRestoration"in history&&(history.scrollRestoration="manual"),window.addEventListener("DOMContentLoaded",this.boundScrollToLastViewedProduct),salla.event.on("salla-filters::changed",(t=>this.setFilters(t)))}disconnectedCallback(){window.removeEventListener("DOMContentLoaded",this.boundScrollToLastViewedProduct),window.removeEventListener("scroll",this.boundHandleScroll)}async setFilters(t){if(t&&JSON.stringify(t)!==JSON.stringify(this.parsedFilters))return window.scrollTo({top:0,behavior:"smooth"}),this.parsedFilters=JSON.parse(JSON.stringify(t)),this.filtersSnapshot=this.parsedFilters,"product.index"==this.currentPage?.slug&&this.parsedFilters&&this.parsedFilters.category_id&&(this.currentCategoryIdFilter=[this.parsedFilters.category_id]),this.reload()}async reload(){!this.autoload&&this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="none"),this.hasInfiniteScroll&&salla.infiniteScroll.destroy(this.infiniteScroll),await this.buildNextPageUrl(),this.wrapper.innerHTML="",this.hasInfiniteScroll?this.init():this.getInitialData(),this.showPlaceholder&&(this.showPlaceholder=!1,this.placeholderLoader=document.createElement("div"),this.placeholderLoader.classList.add("s-products-list-loading-wrapper"),this.placeholderLoader.style.display="inherit",this.placeholderLoader.innerHTML='<span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader"></span>',this.host.insertAdjacentElement("afterend",this.placeholderLoader))}isFilterable(){return salla.config.get("store.settings.product.filters")&&this.filtersResults}isSourceWithoutValue(){return["offers","latest","sales","wishlist","top-rated","reorder"].includes(this.getSource())}animateItems(){r({targets:"salla-products-list salla-product-card",opacity:[0,1],duration:1200,translateY:[20,0],delay:function(t,s){return 100*s}})}async initBaseNextPageUrl(t){this.nextPage=salla.url.api(`products?source=${t}`),this.includes?.length&&(this.nextPage+=`&includes[]=${this.includes.join("&includes[]=")}`),this.limit&&(this.nextPage+=`&per_page=${this.limit>32?32:this.limit}`),this.sortBy&&(this.nextPage+=`&sort=${this.sortBy}`),"preview"===salla.config.get("theme.mode")&&(this.nextPage+="&use_username_url=1"),this.nextPage+="&filterable=1";for(const[t,s]of Object.entries(this.parsedFilters||{}))if(["string","number"].includes(typeof s))this.nextPage+=`&filters[${encodeURIComponent(t)}]=${encodeURIComponent(s)}`;else if(Array.isArray(s))s.forEach((s=>this.nextPage+=`&filters[${encodeURIComponent(t)}][]=${encodeURIComponent(s)}`));else if("object"==typeof s)for(const[i,e]of Object.entries(s))this.nextPage+=`&filters[${encodeURIComponent(t)}][${encodeURIComponent(i)}]=${encodeURIComponent(e)}`;this.nextPage=await this.applyBeforeBuildListUrl(this.nextPage)}async buildNextPageUrl(){let t=this.getSource();if("json"===t)return;const s=sessionStorage.getItem(this.infiniteScrollStateKey);if(s){const{nextPage:t}=JSON.parse(s);if(!t)return}if(await this.initBaseNextPageUrl(t),!this.isSourceWithoutValue())if(["search","related","landing-page"].includes(t))this.nextPage+=`&source_value=${this.getSourceValue()}`;else try{this.nextPage+=`&source_value[]=${this.getSourceValue().join("&source_value[]=")}`}catch(s){salla.logger.warn(`source-value prop should be array of ids ex source-value="[1,2,3]" for the source [${t}]`),this.sourceValueIsValid=!1}}loading(t=!0,s=!1){if(t){let t=s&&!this.autoload?this.btnLoader:this.loader;t&&(t.style.display="inherit")}else this.autoload||this.btnLoader&&(this.btnLoader.style.display="none"),this.loader&&(this.loader.style.display="none")}getItemHTML(t){"landing-page"===this.getSource()&&(t.url="");const s=document.createElement(this.hasCustomComponent?this.productCardComponent:"salla-product-card");return s.product=t,this.compactCards&&(s.compact=!0,s.toggleAttribute("compact",!0)),this.applyLandingPageStyles(s),this.applyHorizontalCardStyles(s),s.addEventListener("click",(s=>{s.target.closest("a")&&(h.saveProductSource(this.getSource()),this.hasInfiniteScroll&&(this.takeStateSnapshot(),sessionStorage.setItem(this.lastViewedProductKey,t.id)))})),s}applyLandingPageStyles(t){"landing-page"!==this.getSource()||this.hasCustomComponent||(t.toggleAttribute("hide-add-btn",!0),t.classList.add("s-product-card-fit-height"))}applyHorizontalCardStyles(t){this.horizontalCards&&(t.toggleAttribute("horizontal",!0),this.hasCustomComponent||t.toggleAttribute("shadow-on-hover",!0))}waitForResizing(t){let s=null;return new Promise((i=>{const e=new ResizeObserver((()=>{clearTimeout(s),s=setTimeout((()=>{e.disconnect(),i(null)}),160)}));e.observe(t)}))}waitForLayoutStable(t){let s=null;return new Promise((i=>{const e=new MutationObserver((()=>{clearTimeout(s),s=setTimeout((()=>{e.disconnect(),i(null)}),160)}));e.observe(t,{childList:!0,subtree:!0,attributes:!0})}))}async waitForStableLayout(t){return await Promise.allSettled([this.waitForResizing(t),this.waitForLayoutStable(t)])}scrollToLastViewedProduct(){const t=sessionStorage.getItem(this.lastViewedProductKey);t&&!salla.url.is_page("product.single")&&this.isElementLoaded(`[id*="${t}"]`).then((()=>{const s=this.wrapper?.querySelector(`[id*="${t}"]`);if(!s)return;const i=()=>{const t=()=>{s.scrollIntoView({block:"start",behavior:"instant"});const t=matchMedia("(max-width: 1024px)").matches?"header .inner":"ul.main-menu",i=window?.header_is_sticky?document.querySelector(t)?.getBoundingClientRect()?.height??56:0,e=parseInt(getComputedStyle(this.wrapper).rowGap)??16;scrollBy({top:-1*(i+e),behavior:"instant"})};requestAnimationFrame(t),s.querySelectorAll("img.lazy").forEach((s=>{const i=s,e=()=>{requestAnimationFrame(t),i.onload=i.onerror=null};i.onload=e,i.onerror=e})),this.removeScrollRestorationSession()};this.waitForStableLayout(this.host).then((()=>requestAnimationFrame(i)))}))}isElementLoaded(t){return new Promise((s=>{const i=setInterval((()=>{if(document.querySelector(t))return clearInterval(i),s(document.querySelector(t))}),50)}))}takeStateSnapshot(){const t=[];for(let s=0;s<this.wrapper.children.length;s++){const i=this.wrapper.children?.[s];t.push(i.product)}const s={pageIndex:Math.max((this.infiniteScroll?.pageIndex??1)-1,1),nextPage:this.nextPage,currentPageData:t};if(this.isFilterable()){const t=sessionStorage.getItem(this.filtersKey);sessionStorage.setItem(this.filtersKey,t||JSON.stringify(this.filtersSnapshot))}sessionStorage.setItem(this.infiniteScrollStateKey,JSON.stringify(s));let i=salla.config.get("page.id");const e=Object.keys(this.specialPagesWithoutIds).find((t=>salla.url.is_page(t)));e?i=this.specialPagesWithoutIds[e]:null!==i&&(i=String(i)),sessionStorage.setItem(this.prevCategoryIdKey,i)}removeScrollRestorationSession(){this.isFilterable()||sessionStorage.removeItem(this.filtersKey),sessionStorage.removeItem(this.infiniteScrollStateKey),sessionStorage.removeItem(this.lastViewedProductKey),sessionStorage.removeItem(this.prevCategoryIdKey)}loadStoredScrollState(){const t=sessionStorage.getItem(this.infiniteScrollStateKey),s=sessionStorage.getItem(this.filtersKey),i=sessionStorage.getItem(this.prevCategoryIdKey),e=this.specialPagesWithoutIds[salla.config.get("page.slug")]||null,a=salla.config.get("page.id"),r=salla.url.is_page("index"),o=salla.url.is_page("product.single"),h=e?i!==e:i!==String(a);if(i&&h&&!r&&!o||r&&!this.hasInfiniteScroll)return this.removeScrollRestorationSession(),this.switchToNormalBehavior=!0,!1;if(o)return this.switchToNormalBehavior=!0,!1;if(t)try{const{pageIndex:i,nextPage:e,currentPageData:a}=JSON.parse(t);if("undefined"!==s){const t=JSON.parse(s);salla.event.emit("filters::fetched",{filters:t})}this.page=i,this.nextPage=e;for(let t=0;t<a.length;t++)this.wrapper.append(this.getItemHTML(a?.[t]));return!0}catch(t){console.error("Failed to load stored scroll state:",t),this.removeScrollRestorationSession()}return!1}getSource(){return h.getProductsSource(this.source)}isAuxiliaryProductsListSource(){return["json","selected","related","landing-page","recently"].includes(this.getSource())}getSourceValue(){return this.currentCategoryIdFilter?this.currentCategoryIdFilter:h.getProductsSourceValue(this.source,this.sourceValue)}logFetchError(t,s,i,e,a){try{const r=a&&"object"==typeof a?a:null,o=this.getSourceValue();salla.analytics?.log("salla::products.list.fetch.error",{errorPhase:t,source:this.getSource(),sourceValue:"string"==typeof o&&o.length>200?`${o.slice(0,200)}…`:Array.isArray(o)?{length:o.length}:o,pageIndex:this.infiniteScroll?.pageIndex,fetchPath:i,httpStatus:e?.status,httpStatusText:e?.statusText,responseUrl:e?.url,...r&&{dataCount:Array.isArray(r.data)?r.data.length:void 0,responseKeys:Object.keys(r).slice(0,15),filtersCount:Array.isArray(r.filters)?r.filters.length:void 0},errorMessage:s instanceof Error?s.message:String(s),..."processing"===t&&s instanceof Error&&s.stack?{errorStack:s.stack.slice(0,500)}:{}})}catch{}}appendDataLayer(t){"object"==typeof dataLayer&&Array.isArray(dataLayer)&&dataLayer.push({event:"impressions",ecommerce:{currencyCode:salla.config.currency().code,impressions:t.map(((t,s)=>({id:t.id,name:t.name,price:t.price,brand:t.brand?.name||"",quantity:t.quantity,categories:[{name:t.category?.name||salla.config.get("page.title"),id:salla.config.get("page.id")}],category:t.category?.name||salla.config.get("page.title"),position:s+1})))}})}initiateInfiniteScroll(){if(!this.hasInfiniteScroll)return;const t=this.autoload&&this.includes&&this.includes.length>0;this.infiniteScroll=salla.infiniteScroll.initiate(this.wrapper,this.wrapper,{path:()=>this.nextPage,history:!1,nextPage:this.nextPage,scrollThreshold:!t&&!!this.autoload&&100,loadOnScroll:!t&&this.autoload},!0),this.infiniteScroll.pageIndex=this.page,this.infiniteScroll?.on("request",(()=>{this.loading(!0,!this.autoload)})),t&&window.addEventListener("scroll",this.boundHandleScroll),this.infiniteScroll?.on("load",(async(t,s,i)=>{if(!this.isProcessing){this.isProcessing=!0;try{if(!t.data?.length&&2===this.infiniteScroll.pageIndex)return this.showPlaceholder=!0,salla.infiniteScroll.destroy(this.infiniteScroll),this.loading(!1),void(this.placeholderLoader&&this.placeholderLoader.remove());this.includes&&await this.injectAndProcessData(t);const s=await this.handleResponse(t);this.infiniteScroll.appendItems(s),2===this.infiniteScroll.pageIndex&&(!this.autoload&&this.nextPage&&(this.loadMoreWrapper.style.display="block"),this.animateItems())}catch(e){console.error("Error during load:",e),this.logFetchError("processing",e,"string"==typeof s?s:void 0,i,t)}finally{this.isProcessing=!1}}})),this.infiniteScroll?.on("error",((t,s,i)=>{const e=i;this.status.querySelector(".s-infinite-scroll-error").classList.remove("s-hidden"),this.placeholderLoader&&this.placeholderLoader.remove(),this.loading(!1),this.isProcessing=!1,this.logFetchError("fetch",t,s,e)})),salla.onReady((()=>{sessionStorage.getItem(this.infiniteScrollStateKey)||this.manualLoadNextPage()}))}handleScroll(){this.isProcessing||this.scrollTimeout||(this.scrollTimeout=setTimeout((()=>{this.scrollTimeout=null,requestAnimationFrame((()=>{const t=this.wrapper.getBoundingClientRect(),s=window.innerHeight;t.bottom-s<=200&&!this.isProcessing&&this.nextPage&&this.manualLoadNextPage()}))}),200))}manualLoadNextPage(){this.nextPage&&this.infiniteScroll.loadNextPage()}async applyBeforeBuildListUrl(t){try{const s={component:this,url:t};return await salla.hooks.call("salla-products-list","beforeBuildListUrl",s),s.url}catch(s){return salla.logger.warn("beforeBuildListUrl hook failed",s?.message),t}}async resolveNextPageFromCursor(t){return t.cursor?t.cursor.next?await this.applyBeforeBuildListUrl(t.cursor.next):t.cursor.next:this.nextPage}async injectAndProcessData(t){try{await h.injectExtraFieldsToResponse(t)}catch(t){console.error("Error injecting data:",t)}}getInitialData(){return this.loading(),salla.api.withoutNotifier((()=>salla.product.api.fetch({source:h.getApiSource(this.getSource()),source_value:this.getSourceValue(),limit:this.limit}).then((async t=>t.data.length?(await h.injectExtraFieldsToResponse(t),this.firstPageResponse?void(await this.handleResponse(t)).forEach((t=>this.wrapper.append(t))):(this.firstPageResponse=t,void(this.nextPage=await this.resolveNextPageFromCursor(t)))):(this.showPlaceholder=!0,this.placeholderLoader&&this.placeholderLoader.remove(),void this.loading(!1))))))}async loadMore(){this.infiniteScroll?.loadNextPage()}componentWillLoad(){return salla.onReady().then((async()=>{this.hasCustomComponent=!!customElements.get(this.productCardComponent),this.sourceValueIsValid=!(!this.getSourceValue()&&!this.isSourceWithoutValue()),this.hasInfiniteScroll=!this.isAuxiliaryProductsListSource()&&!this.limit;let t=new URLSearchParams(window.location.search);try{this.sortBy=this.sortBy||t.get("sort")||t.get("by"),this.parsedFilters=h.extractFiltersFromUrl(t),this.parsedFilters&&this.parsedFilters.category_id&&(this.currentCategoryIdFilter=[this.parsedFilters.category_id])}catch(t){salla.logger.warn("failed to get filters from url",t.message)}if(await this.buildNextPageUrl(),this.isReady=!0,!sessionStorage.getItem(this.infiniteScrollStateKey))if(this.sourceValueIsValid){if(!this.hasInfiniteScroll){if("json"===this.getSource())return this.getSourceValue().length?void setTimeout((()=>{this.getSourceValue().map((t=>this.wrapper.append(this.getItemHTML(t))))})):void(this.showPlaceholder=!0);if("selected"!==this.getSource()||this.getSourceValue().length)return this.getInitialData();this.showPlaceholder=!0}}else salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`)}))}async componentDidLoad(){this.hasInfiniteScroll&&this.init(),await Salla.hooks.registerComponent("salla-products-list",this),this.loadStoredScrollState()?(this.autoload?!this.nextPage&&this.loading(!1):this.nextPage?this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="block"):(this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="none"),this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden")),this.scrollToLastViewedProduct()):!this.firstPageResponse&&this.switchToNormalBehavior?this.getInitialData().then((async()=>{this.firstPageResponse?((await this.handleResponse(this.firstPageResponse,!1)).forEach((t=>{this.wrapper.append(t)})),setTimeout((()=>{if(!this.autoload&&this.nextPage&&1==this.infiniteScroll.pageIndex){const t=this.host.querySelector(".s-infinite-scroll-wrapper");t&&(t.style.display="block")}}))):console.error("No response received after getInitialData.")})).catch((t=>{console.error("Error during initial data fetch:",t)})):this.firstPageResponse&&(await this.handleResponse(this.firstPageResponse,!1)).forEach((t=>this.wrapper.append(t)))}canRender(){return this.sourceValueIsValid&&this.isReady}render(){return this.canRender()?this.showPlaceholder?i("div",{class:"s-products-list-placeholder"},i("span",{innerHTML:o}),i("p",null,this.placeholderText)):i(e,{class:"s-products-list"},i("div",{class:{"s-products-list-wrapper":!0,"s-products-list-horizontal-cards":this.horizontalCards&&!this.filtersResults,"s-products-list-vertical-cards":!this.horizontalCards&&!this.rowCards&&!this.filtersResults,"s-products-list-row-cards":this.rowCards,"s-products-list-compact-cards":this.compactCards,"s-products-list-filters-results":this.filtersResults},ref:t=>this.wrapper=t}),i("div",{class:"s-infinite-scroll-status",ref:t=>this.status=t},i("p",{class:"s-infinite-scroll-last infinite-scroll-last s-hidden"},this.endOfText),i("p",{class:"s-infinite-scroll-error infinite-scroll-error s-hidden"},this.failedLoadMore)),this.autoload&&i("div",{class:"s-products-list-loading-wrapper",style:{display:"none"},ref:t=>this.loader=t},i("span",{class:"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader"})),this.hasInfiniteScroll&&this.nextPage&&!this.autoload?i("div",{class:"s-infinite-scroll-wrapper",style:{display:"none"},ref:t=>this.loadMoreWrapper=t},i("button",{onClick:()=>this.loadMore(),class:"s-infinite-scroll-btn s-button-btn s-button-primary"},i("span",{class:"s-button-text s-infinite-scroll-btn-text"},this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")),i("span",{class:"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader",ref:t=>this.btnLoader=t,style:{display:"none"}}))):""):""}init(){this.initiateInfiniteScroll(),this.loading()}async handleResponse(t,s=!0){if(!t)return[];let i=this.getSource();if(1===t.cursor?.current){if(!this.isAuxiliaryProductsListSource()){let s=h.getPageTitleForSource(i);try{if("search"===this.getSource())s=salla.lang.get("common.elements.search_about",{word:this.getSourceValue()});else if(!s){let i=this.parsedFilters.category_id||this.getSourceValue()[0];s=t.filters?.find((t=>"category_id"===t.key))?.values?.find((t=>t.key===i))?.value??"",this.filtersSnapshot=t.filters}s+=(s?" - ":"")+salla.lang.choice("blocks.header.products_count",t.data?.length),15===t.data.length&&(s=s.replace(t.data.length,salla.lang.get("common.elements.more_than")+" "+t.data.length)),t.title=s}catch(t){salla.logger.error("Error::falid to handle response",t)}}h.generateProductSchema(t.data)}this.appendDataLayer(t.data),t.nextPage=this.nextPage,t.source=this.getSource(),t.sourceValue=this.getSourceValue(),salla.event.emit("salla-products-list::products.fetched",t),this.productsFetched.emit(t),t.filters&&this.isFilterable()?(this.filtersResults=!0,this.filtersSnapshot=JSON.parse(JSON.stringify(t.filters)),salla.event.emit("filters::fetched",{filters:t.filters})):this.isFilterable()&&salla.event.emit("filters::hidden"),s&&(this.nextPage=await this.resolveNextPageFromCursor(t)),this.loading(!1),this.placeholderLoader&&this.placeholderLoader.remove(),this.hasInfiniteScroll&&!this.nextPage&&(this.infiniteScroll.option({scrollThreshold:!1,loadOnScroll:!1}),this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden"));const e=[];for(let s=0;s<t.data.length;s++)e.push(this.getItemHTML(t.data?.[s]));return e}get host(){return a(this)}};l.style="";export{l as salla_products_list}
|
|
4
|
+
import{r as t,c as s,h as i,H as e,a}from"./p-BAOl7AJU.js";import{a as r}from"./p-CgtvEd63.js";import{S as o}from"./p-DiKTtDW5.js";import{H as h}from"./p-CHf8XdiS.js";const l=class{constructor(i){t(this,i),this.productsFetched=s(this,"productsFetched"),this.autoload=!1,this.productCardComponent="custom-salla-product-card",this.page=1,this.placeholderText=salla.lang.get("pages.categories.no_products"),this.endOfText=salla.lang.get("common.elements.end_of_content"),this.failedLoadMore=salla.lang.get("common.elements.failed_to_load_more"),this.currentPage=salla.config.get("page"),this.filtersSnapshot=[],this.lastViewedProductKey="lastViewedProductId",this.filtersKey="filters",this.infiniteScrollStateKey="infiniteScrollState",this.prevCategoryIdKey="prevCategoryId",this.isProcessing=!1,this.scrollTimeout=null,this.boundScrollToLastViewedProduct=()=>this.scrollToLastViewedProduct(),this.boundHandleScroll=()=>this.handleScroll(),this.specialPagesWithoutIds={"product.index.latest":"latest","product.index.offers":"offers","product.index.search":"search","product.index.sales":"sales"},this.includes=h.parseJson(this.includes||this.host.getAttribute("includes")),Array.isArray(this.includes)||(this.includes=null),h.setIncludes(this.includes),salla.lang.onLoaded((()=>{this.placeholderText=salla.lang.get("pages.categories.no_products"),this.endOfText=salla.lang.get("common.elements.end_of_content"),this.failedLoadMore=salla.lang.get("common.elements.failed_to_load_more"),this.currentPage=salla.config.get("page")}))}connectedCallback(){"scrollRestoration"in history&&(history.scrollRestoration="manual"),window.addEventListener("DOMContentLoaded",this.boundScrollToLastViewedProduct),salla.event.on("salla-filters::changed",(t=>this.setFilters(t)))}disconnectedCallback(){window.removeEventListener("DOMContentLoaded",this.boundScrollToLastViewedProduct),window.removeEventListener("scroll",this.boundHandleScroll)}async setFilters(t){if(t&&JSON.stringify(t)!==JSON.stringify(this.parsedFilters))return window.scrollTo({top:0,behavior:"smooth"}),this.parsedFilters=JSON.parse(JSON.stringify(t)),this.filtersSnapshot=this.parsedFilters,"product.index"==this.currentPage?.slug&&this.parsedFilters&&this.parsedFilters.category_id&&(this.currentCategoryIdFilter=[this.parsedFilters.category_id]),this.reload()}async reload(){!this.autoload&&this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="none"),this.hasInfiniteScroll&&salla.infiniteScroll.destroy(this.infiniteScroll),await this.buildNextPageUrl(),this.wrapper.innerHTML="",this.hasInfiniteScroll?this.init():this.getInitialData(),this.showPlaceholder&&(this.showPlaceholder=!1,this.placeholderLoader=document.createElement("div"),this.placeholderLoader.classList.add("s-products-list-loading-wrapper"),this.placeholderLoader.style.display="inherit",this.placeholderLoader.innerHTML='<span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader"></span>',this.host.insertAdjacentElement("afterend",this.placeholderLoader))}isFilterable(){return salla.config.get("store.settings.product.filters")&&this.filtersResults}isSourceWithoutValue(){return["offers","latest","sales","wishlist","top-rated","reorder"].includes(this.getSource())}animateItems(){r({targets:"salla-products-list salla-product-card",opacity:[0,1],duration:1200,translateY:[20,0],delay:function(t,s){return 100*s}})}async initBaseNextPageUrl(t){this.nextPage=salla.url.api(`products?source=${t}`),this.includes?.length&&(this.nextPage+=`&includes[]=${this.includes.join("&includes[]=")}`),this.limit&&(this.nextPage+=`&per_page=${this.limit>32?32:this.limit}`),this.sortBy&&(this.nextPage+=`&sort=${this.sortBy}`),"preview"===salla.config.get("theme.mode")&&(this.nextPage+="&use_username_url=1"),this.nextPage+="&filterable=1";for(const[t,s]of Object.entries(this.parsedFilters||{}))if(["string","number"].includes(typeof s))this.nextPage+=`&filters[${encodeURIComponent(t)}]=${encodeURIComponent(s)}`;else if(Array.isArray(s))s.forEach((s=>this.nextPage+=`&filters[${encodeURIComponent(t)}][]=${encodeURIComponent(s)}`));else if("object"==typeof s)for(const[i,e]of Object.entries(s))this.nextPage+=`&filters[${encodeURIComponent(t)}][${encodeURIComponent(i)}]=${encodeURIComponent(e)}`;this.nextPage=await this.applyBeforeBuildListUrl(this.nextPage)}async buildNextPageUrl(){let t=this.getSource();if("json"===t)return;const s=sessionStorage.getItem(this.infiniteScrollStateKey);if(s){const{nextPage:t}=JSON.parse(s);if(!t)return}if(await this.initBaseNextPageUrl(t),!this.isSourceWithoutValue())if(["search","related","landing-page"].includes(t))this.nextPage+=`&source_value=${this.getSourceValue()}`;else try{this.nextPage+=`&source_value[]=${this.getSourceValue().join("&source_value[]=")}`}catch(s){salla.logger.warn(`source-value prop should be array of ids ex source-value="[1,2,3]" for the source [${t}]`),this.sourceValueIsValid=!1}}loading(t=!0,s=!1){if(t){let t=s&&!this.autoload?this.btnLoader:this.loader;t&&(t.style.display="inherit")}else this.autoload||this.btnLoader&&(this.btnLoader.style.display="none"),this.loader&&(this.loader.style.display="none")}getItemHTML(t){"landing-page"===this.getSource()&&(t.url="");const s=document.createElement(this.hasCustomComponent?this.productCardComponent:"salla-product-card");return s.product=t,this.compactCards&&(s.compact=!0,s.toggleAttribute("compact",!0)),this.applyLandingPageStyles(s),this.applyHorizontalCardStyles(s),s.addEventListener("click",(s=>{s.target.closest("a")&&(h.saveProductSource(this.getSource()),this.hasInfiniteScroll&&(this.takeStateSnapshot(),sessionStorage.setItem(this.lastViewedProductKey,t.id)))})),s}applyLandingPageStyles(t){"landing-page"!==this.getSource()||this.hasCustomComponent||(t.toggleAttribute("hide-add-btn",!0),t.classList.add("s-product-card-fit-height"))}applyHorizontalCardStyles(t){this.horizontalCards&&(t.toggleAttribute("horizontal",!0),this.hasCustomComponent||t.toggleAttribute("shadow-on-hover",!0))}waitForResizing(t){let s=null;return new Promise((i=>{const e=new ResizeObserver((()=>{clearTimeout(s),s=setTimeout((()=>{e.disconnect(),i(null)}),160)}));e.observe(t)}))}waitForLayoutStable(t){let s=null;return new Promise((i=>{const e=new MutationObserver((()=>{clearTimeout(s),s=setTimeout((()=>{e.disconnect(),i(null)}),160)}));e.observe(t,{childList:!0,subtree:!0,attributes:!0})}))}async waitForStableLayout(t){return await Promise.allSettled([this.waitForResizing(t),this.waitForLayoutStable(t)])}scrollToLastViewedProduct(){const t=sessionStorage.getItem(this.lastViewedProductKey);t&&!salla.url.is_page("product.single")&&this.isElementLoaded(`[id*="${t}"]`).then((()=>{const s=this.wrapper?.querySelector(`[id*="${t}"]`);if(!s)return;const i=()=>{const t=()=>{s.scrollIntoView({block:"start",behavior:"instant"});const t=matchMedia("(max-width: 1024px)").matches?"header .inner":"ul.main-menu",i=window?.header_is_sticky?document.querySelector(t)?.getBoundingClientRect()?.height??56:0,e=parseInt(getComputedStyle(this.wrapper).rowGap)??16;scrollBy({top:-1*(i+e),behavior:"instant"})};requestAnimationFrame(t),s.querySelectorAll("img.lazy").forEach((s=>{const i=s,e=()=>{requestAnimationFrame(t),i.onload=i.onerror=null};i.onload=e,i.onerror=e})),this.removeScrollRestorationSession()};this.waitForStableLayout(this.host).then((()=>requestAnimationFrame(i)))}))}isElementLoaded(t){return new Promise((s=>{const i=setInterval((()=>{if(document.querySelector(t))return clearInterval(i),s(document.querySelector(t))}),50)}))}takeStateSnapshot(){const t=[];for(let s=0;s<this.wrapper.children.length;s++){const i=this.wrapper.children?.[s];t.push(i.product)}const s={pageIndex:Math.max((this.infiniteScroll?.pageIndex??1)-1,1),nextPage:this.nextPage,currentPageData:t};if(this.isFilterable()){const t=sessionStorage.getItem(this.filtersKey);sessionStorage.setItem(this.filtersKey,t||JSON.stringify(this.filtersSnapshot))}sessionStorage.setItem(this.infiniteScrollStateKey,JSON.stringify(s));let i=salla.config.get("page.id");const e=Object.keys(this.specialPagesWithoutIds).find((t=>salla.url.is_page(t)));e?i=this.specialPagesWithoutIds[e]:null!==i&&(i=String(i)),sessionStorage.setItem(this.prevCategoryIdKey,i)}removeScrollRestorationSession(){this.isFilterable()||sessionStorage.removeItem(this.filtersKey),sessionStorage.removeItem(this.infiniteScrollStateKey),sessionStorage.removeItem(this.lastViewedProductKey),sessionStorage.removeItem(this.prevCategoryIdKey)}loadStoredScrollState(){const t=sessionStorage.getItem(this.infiniteScrollStateKey),s=sessionStorage.getItem(this.filtersKey),i=sessionStorage.getItem(this.prevCategoryIdKey),e=this.specialPagesWithoutIds[salla.config.get("page.slug")]||null,a=salla.config.get("page.id"),r=salla.url.is_page("index"),o=salla.url.is_page("product.single"),h=e?i!==e:i!==String(a);if(i&&h&&!r&&!o||r&&!this.hasInfiniteScroll)return this.removeScrollRestorationSession(),this.switchToNormalBehavior=!0,!1;if(o)return this.switchToNormalBehavior=!0,!1;if(t)try{const{pageIndex:i,nextPage:e,currentPageData:a}=JSON.parse(t);if("undefined"!==s){const t=JSON.parse(s);salla.event.emit("filters::fetched",{filters:t})}this.page=i,this.nextPage=e;for(let t=0;t<a.length;t++)this.wrapper.append(this.getItemHTML(a?.[t]));return!0}catch(t){console.error("Failed to load stored scroll state:",t),this.removeScrollRestorationSession()}return!1}getSource(){return h.getProductsSource(this.source)}isAuxiliaryProductsListSource(){return["json","selected","related","landing-page","recently"].includes(this.getSource())}getSourceValue(){return this.currentCategoryIdFilter?this.currentCategoryIdFilter:h.getProductsSourceValue(this.source,this.sourceValue)}logFetchError(t,s,i,e,a){try{const r=a&&"object"==typeof a?a:null,o=this.getSourceValue();salla.analytics?.log("salla::products.list.fetch.error",{errorPhase:t,source:this.getSource(),sourceValue:"string"==typeof o&&o.length>200?`${o.slice(0,200)}…`:Array.isArray(o)?{length:o.length}:o,pageIndex:this.infiniteScroll?.pageIndex,fetchPath:i,httpStatus:e?.status,httpStatusText:e?.statusText,responseUrl:e?.url,...r&&{dataCount:Array.isArray(r.data)?r.data.length:void 0,responseKeys:Object.keys(r).slice(0,15),filtersCount:Array.isArray(r.filters)?r.filters.length:void 0},errorMessage:s instanceof Error?s.message:String(s),..."processing"===t&&s instanceof Error&&s.stack?{errorStack:s.stack.slice(0,500)}:{}})}catch{}}appendDataLayer(t){"object"==typeof dataLayer&&Array.isArray(dataLayer)&&dataLayer.push({event:"impressions",ecommerce:{currencyCode:salla.config.currency().code,impressions:t.map(((t,s)=>({id:t.id,name:t.name,price:t.price,brand:t.brand?.name||"",quantity:t.quantity,categories:[{name:t.category?.name||salla.config.get("page.title"),id:salla.config.get("page.id")}],category:t.category?.name||salla.config.get("page.title"),position:s+1})))}})}initiateInfiniteScroll(){if(!this.hasInfiniteScroll)return;const t=this.autoload&&this.includes&&this.includes.length>0;this.infiniteScroll=salla.infiniteScroll.initiate(this.wrapper,this.wrapper,{path:()=>this.nextPage,history:!1,nextPage:this.nextPage,scrollThreshold:!t&&!!this.autoload&&100,loadOnScroll:!t&&this.autoload},!0),this.infiniteScroll.pageIndex=this.page,this.infiniteScroll?.on("request",(()=>{this.loading(!0,!this.autoload)})),t&&window.addEventListener("scroll",this.boundHandleScroll),this.infiniteScroll?.on("load",(async(t,s,i)=>{if(!this.isProcessing){this.isProcessing=!0;try{if(!t.data?.length&&2===this.infiniteScroll.pageIndex)return this.showPlaceholder=!0,salla.infiniteScroll.destroy(this.infiniteScroll),this.loading(!1),void(this.placeholderLoader&&this.placeholderLoader.remove());this.includes&&await this.injectAndProcessData(t);const s=await this.handleResponse(t);this.infiniteScroll.appendItems(s),2===this.infiniteScroll.pageIndex&&(!this.autoload&&this.nextPage&&(this.loadMoreWrapper.style.display="block"),this.animateItems())}catch(e){console.error("Error during load:",e),this.logFetchError("processing",e,"string"==typeof s?s:void 0,i,t)}finally{this.isProcessing=!1}}})),this.infiniteScroll?.on("error",((t,s,i)=>{const e=i;this.status.querySelector(".s-infinite-scroll-error").classList.remove("s-hidden"),this.placeholderLoader&&this.placeholderLoader.remove(),this.loading(!1),this.isProcessing=!1,this.logFetchError("fetch",t,s,e)})),salla.onReady((()=>{sessionStorage.getItem(this.infiniteScrollStateKey)||this.manualLoadNextPage()}))}handleScroll(){this.isProcessing||this.scrollTimeout||(this.scrollTimeout=setTimeout((()=>{this.scrollTimeout=null,requestAnimationFrame((()=>{const t=this.wrapper.getBoundingClientRect(),s=window.innerHeight;t.bottom-s<=200&&!this.isProcessing&&this.nextPage&&this.manualLoadNextPage()}))}),200))}manualLoadNextPage(){this.nextPage&&this.infiniteScroll.loadNextPage()}async applyBeforeBuildListUrl(t){try{const s={component:this,url:t};return await salla.hooks.call("salla-products-list","beforeBuildListUrl",s),s.url}catch(s){return salla.logger.warn("beforeBuildListUrl hook failed",s?.message),t}}async resolveNextPageFromCursor(t){return t.cursor?t.cursor.next?await this.applyBeforeBuildListUrl(t.cursor.next):t.cursor.next:this.nextPage}async injectAndProcessData(t){try{await h.injectExtraFieldsToResponse(t)}catch(t){console.error("Error injecting data:",t)}}getInitialData(){return this.loading(),salla.api.withoutNotifier((()=>salla.product.api.fetch({source:h.getApiSource(this.getSource()),source_value:this.getSourceValue(),limit:this.limit}).then((async t=>t.data.length?(await h.injectExtraFieldsToResponse(t),this.firstPageResponse?void(await this.handleResponse(t)).forEach((t=>this.wrapper.append(t))):(this.firstPageResponse=t,void(this.nextPage=await this.resolveNextPageFromCursor(t)))):(this.showPlaceholder=!0,this.placeholderLoader&&this.placeholderLoader.remove(),void this.loading(!1))))))}async loadMore(){this.infiniteScroll?.loadNextPage()}componentWillLoad(){return salla.onReady().then((async()=>{this.hasCustomComponent=!!customElements.get(this.productCardComponent),this.sourceValueIsValid=!(!this.getSourceValue()&&!this.isSourceWithoutValue()),this.hasInfiniteScroll=!this.isAuxiliaryProductsListSource()&&!this.limit;let t=new URLSearchParams(window.location.search);try{this.sortBy=this.sortBy||t.get("sort")||t.get("by"),this.parsedFilters=h.extractFiltersFromUrl(t),this.parsedFilters&&this.parsedFilters.category_id&&(this.currentCategoryIdFilter=[this.parsedFilters.category_id])}catch(t){salla.logger.warn("failed to get filters from url",t.message)}if(await this.buildNextPageUrl(),this.isReady=!0,!sessionStorage.getItem(this.infiniteScrollStateKey))if(this.sourceValueIsValid){if(!this.hasInfiniteScroll){if("json"===this.getSource())return this.getSourceValue().length?void setTimeout((()=>{this.getSourceValue().map((t=>this.wrapper.append(this.getItemHTML(t))))})):void(this.showPlaceholder=!0);if("selected"!==this.getSource()||this.getSourceValue().length)return this.getInitialData();this.showPlaceholder=!0}}else salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`)}))}async componentDidLoad(){this.hasInfiniteScroll&&this.init(),await Salla.hooks.registerComponent("salla-products-list",this),this.loadStoredScrollState()?(this.autoload?!this.nextPage&&this.loading(!1):this.nextPage?this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="block"):(this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="none"),this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden")),this.scrollToLastViewedProduct()):!this.firstPageResponse&&this.switchToNormalBehavior?this.getInitialData().then((async()=>{this.firstPageResponse?((await this.handleResponse(this.firstPageResponse,!1)).forEach((t=>{this.wrapper.append(t)})),setTimeout((()=>{if(!this.autoload&&this.nextPage&&1==this.infiniteScroll.pageIndex){const t=this.host.querySelector(".s-infinite-scroll-wrapper");t&&(t.style.display="block")}}))):console.error("No response received after getInitialData.")})).catch((t=>{console.error("Error during initial data fetch:",t)})):this.firstPageResponse&&(await this.handleResponse(this.firstPageResponse,!1)).forEach((t=>this.wrapper.append(t)))}canRender(){return this.sourceValueIsValid&&this.isReady}render(){return this.canRender()?this.showPlaceholder?i("div",{class:"s-products-list-placeholder"},i("span",{innerHTML:o}),i("p",null,this.placeholderText)):i(e,{class:"s-products-list"},i("div",{class:{"s-products-list-wrapper":!0,"s-products-list-horizontal-cards":this.horizontalCards&&!this.filtersResults,"s-products-list-vertical-cards":!this.horizontalCards&&!this.rowCards&&!this.filtersResults,"s-products-list-row-cards":this.rowCards,"s-products-list-compact-cards":this.compactCards,"s-products-list-filters-results":this.filtersResults},ref:t=>this.wrapper=t}),i("div",{class:"s-infinite-scroll-status",ref:t=>this.status=t},i("p",{class:"s-infinite-scroll-last infinite-scroll-last s-hidden"},this.endOfText),i("p",{class:"s-infinite-scroll-error infinite-scroll-error s-hidden"},this.failedLoadMore)),this.autoload&&i("div",{class:"s-products-list-loading-wrapper",style:{display:"none"},ref:t=>this.loader=t},i("span",{class:"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader"})),this.hasInfiniteScroll&&this.nextPage&&!this.autoload?i("div",{class:"s-infinite-scroll-wrapper",style:{display:"none"},ref:t=>this.loadMoreWrapper=t},i("button",{onClick:()=>this.loadMore(),class:"s-infinite-scroll-btn s-button-btn s-button-primary"},i("span",{class:"s-button-text s-infinite-scroll-btn-text"},this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")),i("span",{class:"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader",ref:t=>this.btnLoader=t,style:{display:"none"}}))):""):""}init(){this.initiateInfiniteScroll(),this.loading()}async handleResponse(t,s=!0){if(!t)return[];let i=this.getSource();if(1===t.cursor?.current){if(!this.isAuxiliaryProductsListSource()){let s=h.getPageTitleForSource(i);try{if("search"===this.getSource())s=salla.lang.get("common.elements.search_about",{word:this.getSourceValue()});else if(!s){let i=this.parsedFilters.category_id||this.getSourceValue()[0];s=t.filters?.find((t=>"category_id"===t.key))?.values?.find((t=>t.key===i))?.value??"",this.filtersSnapshot=t.filters}s+=(s?" - ":"")+salla.lang.choice("blocks.header.products_count",t.data?.length),15===t.data.length&&(s=s.replace(t.data.length,salla.lang.get("common.elements.more_than")+" "+t.data.length)),t.title=s}catch(t){salla.logger.error("Error::falid to handle response",t)}}h.generateProductSchema(t.data)}this.appendDataLayer(t.data),t.nextPage=this.nextPage,t.source=this.getSource(),t.sourceValue=this.getSourceValue(),salla.event.emit("salla-products-list::products.fetched",t),this.productsFetched.emit(t),t.filters&&this.isFilterable()?(this.filtersResults=!0,this.filtersSnapshot=JSON.parse(JSON.stringify(t.filters)),salla.event.emit("filters::fetched",{filters:t.filters})):this.isFilterable()&&salla.event.emit("filters::hidden"),s&&(this.nextPage=await this.resolveNextPageFromCursor(t)),this.loading(!1),this.placeholderLoader&&this.placeholderLoader.remove(),this.hasInfiniteScroll&&!this.nextPage&&(this.infiniteScroll.option({scrollThreshold:!1,loadOnScroll:!1}),this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden"));const e=[];for(let s=0;s<t.data.length;s++)e.push(this.getItemHTML(t.data?.[s]));return e}get host(){return a(this)}};l.style="";export{l as salla_products_list}
|