@salla.sa/twilight-components 2.14.393 → 2.14.394
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-D7RVR_w_.js → filepond-C_gLbAbF.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-DTuZK2ot.js → filepond-plugin-file-poster-DXWo2FUU.js} +2 -2
- package/dist/cjs/{filepond-plugin-file-validate-size-DHc6pF_j.js → filepond-plugin-file-validate-size-fBXMP7ez.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-DnkcvJVc.js → filepond-plugin-file-validate-type-DEo7juC7.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-vrZ1s7kw.js → filepond-plugin-image-edit-4j4e1VEp.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-Bn5JSzQK.js → filepond-plugin-image-exif-orientation-DWqiXxv1.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-8qWUFe9n.js → filepond-plugin-image-preview-emT_teia.js} +1 -1
- package/dist/cjs/{index-C5VeFDQ0.js → index-B03mYCWz.js} +547 -780
- package/dist/cjs/{index-CwD81m7i.js → index-Y-2uyQDK.js} +1 -1
- package/dist/cjs/loader.cjs.js +3 -4
- package/dist/cjs/salla-accordion-body_2.cjs.entry.js +5 -5
- package/dist/cjs/salla-accordion_6.cjs.entry.js +15 -19
- package/dist/cjs/salla-add-product-button_4.cjs.entry.js +10 -12
- package/dist/cjs/salla-advertisement.cjs.entry.js +3 -3
- package/dist/cjs/salla-alert_2.cjs.entry.js +5 -5
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +3 -3
- package/dist/cjs/salla-apps-icons.cjs.entry.js +3 -3
- package/dist/cjs/salla-booking-field_7.cjs.entry.js +23 -25
- package/dist/cjs/salla-bullet-delivery.cjs.entry.js +3 -3
- package/dist/cjs/salla-cart-coupons.cjs.entry.js +3 -3
- package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +5 -5
- package/dist/cjs/salla-comment-form_8.cjs.entry.js +17 -17
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +3 -3
- package/dist/cjs/salla-contacts.cjs.entry.js +3 -3
- package/dist/cjs/salla-cookies-bar.cjs.entry.js +3 -3
- package/dist/cjs/salla-count-down.cjs.entry.js +3 -3
- package/dist/cjs/salla-custom-fields.cjs.entry.js +3 -3
- package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +3 -3
- package/dist/cjs/salla-filters.cjs.entry.js +3 -3
- package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
- package/dist/cjs/salla-gifting.cjs.entry.js +3 -3
- package/dist/cjs/salla-hook.cjs.entry.js +2 -5
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +3 -3
- package/dist/cjs/salla-installment.cjs.entry.js +3 -3
- package/dist/cjs/salla-list-tile.cjs.entry.js +3 -3
- package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-login-modal.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty.cjs.entry.js +3 -3
- package/dist/cjs/salla-maintenance-alert.cjs.entry.js +3 -3
- package/dist/cjs/salla-map.cjs.entry.js +3 -3
- package/dist/cjs/salla-menu.cjs.entry.js +3 -3
- package/dist/cjs/salla-metadata.cjs.entry.js +3 -3
- package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +5 -5
- package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +6 -8
- package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +4 -6
- package/dist/cjs/salla-notification-item.cjs.entry.js +3 -3
- package/dist/cjs/salla-notifications.cjs.entry.js +3 -3
- package/dist/cjs/salla-offer-modal.cjs.entry.js +3 -3
- package/dist/cjs/salla-offer.cjs.entry.js +3 -3
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +3 -3
- package/dist/cjs/salla-order-details-options.cjs.entry.js +3 -3
- package/dist/cjs/salla-order-details.cjs.entry.js +4 -6
- package/dist/cjs/salla-order-edit-item.cjs.entry.js +3 -3
- package/dist/cjs/salla-order-edit.cjs.entry.js +3 -3
- package/dist/cjs/salla-order-summary.cjs.entry.js +3 -3
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +4 -6
- package/dist/cjs/salla-orders.cjs.entry.js +3 -3
- package/dist/cjs/salla-payments.cjs.entry.js +3 -3
- package/dist/cjs/salla-placeholder.cjs.entry.js +3 -3
- package/dist/cjs/salla-price-range.cjs.entry.js +3 -3
- package/dist/cjs/salla-product-card.cjs.entry.js +3 -3
- package/dist/cjs/salla-product-size-guide.cjs.entry.js +3 -3
- package/dist/cjs/salla-products-list.cjs.entry.js +3 -3
- package/dist/cjs/salla-products-slider.cjs.entry.js +3 -3
- package/dist/cjs/salla-progress-bar.cjs.entry.js +3 -3
- package/dist/cjs/salla-quick-order.cjs.entry.js +3 -3
- package/dist/cjs/salla-rating-modal.cjs.entry.js +3 -3
- package/dist/cjs/salla-scopes.cjs.entry.js +3 -3
- package/dist/cjs/salla-search.cjs.entry.js +4 -6
- package/dist/cjs/salla-skeleton.cjs.entry.js +3 -3
- package/dist/cjs/salla-slider.cjs.entry.js +3 -3
- package/dist/cjs/salla-social-share.cjs.entry.js +3 -3
- package/dist/cjs/salla-social.cjs.entry.js +3 -3
- package/dist/cjs/salla-tab-content_3.cjs.entry.js +7 -7
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +3 -3
- package/dist/cjs/salla-tooltip.cjs.entry.js +3 -3
- package/dist/cjs/salla-trust-badges.cjs.entry.js +3 -3
- package/dist/cjs/salla-user-menu.cjs.entry.js +3 -3
- package/dist/cjs/salla-user-profile.cjs.entry.js +3 -3
- package/dist/cjs/salla-user-settings.cjs.entry.js +3 -3
- package/dist/cjs/salla-verify.cjs.entry.js +3 -3
- package/dist/cjs/salla-wallet.cjs.entry.js +3 -3
- package/dist/cjs/twilight.cjs.js +4 -5
- package/dist/cjs/{vanilla-picker-yKERbLpx.js → vanilla-picker-CKZvBtHS.js} +1 -1
- package/dist/collection/collection-manifest.json +2 -3
- package/dist/collection/components/salla-accordion/salla-accordion-head.js +2 -2
- package/dist/collection/components/salla-accordion/salla-accordion.js +4 -4
- package/dist/collection/components/salla-add-product-button/salla-add-product-button.js +19 -19
- package/dist/collection/components/salla-alert/salla-alert.js +5 -5
- package/dist/collection/components/salla-apps-icons/salla-apps-icons.js +6 -6
- package/dist/collection/components/salla-booking-field/salla-booking-field.js +4 -4
- package/dist/collection/components/salla-bottom-alert/salla-bottom-alert.js +9 -9
- package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.js +3 -6
- package/dist/collection/components/salla-button/salla-button.js +11 -11
- package/dist/collection/components/salla-cart-coupons/salla-cart-coupons.js +1 -2
- package/dist/collection/components/salla-cart-item-offers/salla-cart-item-offers.js +8 -8
- package/dist/collection/components/salla-cart-summary/salla-cart-summary.js +2 -2
- package/dist/collection/components/salla-color-picker/salla-color-picker.js +14 -20
- package/dist/collection/components/salla-comment-form/salla-comment-form.js +6 -6
- package/dist/collection/components/salla-comments/salla-comment-item.js +3 -2
- package/dist/collection/components/salla-comments/salla-comments.js +17 -18
- package/dist/collection/components/salla-contacts/salla-contacts.js +10 -10
- package/dist/collection/components/salla-count-down/salla-count-down.js +34 -34
- package/dist/collection/components/salla-custom-fields/salla-custom-fields.js +7 -9
- package/dist/collection/components/salla-datetime-picker/salla-datetime-picker.js +65 -69
- package/dist/collection/components/salla-drawer/salla-drawer.js +11 -11
- package/dist/collection/components/salla-file-upload/salla-file-upload.js +84 -85
- package/dist/collection/components/salla-filters/salla-filters.js +2 -2
- package/dist/collection/components/salla-filters-widget/salla-filters-widget.js +5 -4
- package/dist/collection/components/salla-gifting/salla-gifting.js +11 -11
- package/dist/collection/components/salla-hook/salla-hook.js +2 -2
- package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.js +6 -6
- package/dist/collection/components/salla-installment/salla-installment.js +5 -5
- package/dist/collection/components/salla-list-tile/salla-list-tile.js +2 -2
- package/dist/collection/components/salla-loading/salla-loading.js +4 -4
- package/dist/collection/components/salla-localization-modal/salla-localization-modal.js +5 -5
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +14 -14
- package/dist/collection/components/salla-loyalty/salla-loyalty-prize-item.js +3 -4
- package/dist/collection/components/salla-loyalty/salla-loyalty.js +12 -13
- package/dist/collection/components/salla-map/salla-map.js +14 -14
- package/dist/collection/components/salla-menu/salla-menu.js +9 -10
- package/dist/collection/components/salla-metadata/salla-metadata.js +3 -3
- package/dist/collection/components/salla-modal/salla-modal.js +11 -11
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-cart.js +2 -2
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-details.js +2 -2
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-options-modal.js +2 -4
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-slider.js +7 -8
- package/dist/collection/components/salla-multiple-bundle-product/salla-multiple-bundle-product.js +2 -2
- package/dist/collection/components/salla-notifications/salla-notification-item.js +2 -2
- package/dist/collection/components/salla-notifications/salla-notifications.js +3 -3
- package/dist/collection/components/salla-offer/salla-offer.js +1 -1
- package/dist/collection/components/salla-order-details/salla-order-details-multiple-bundle-product.js +5 -5
- package/dist/collection/components/salla-order-details/salla-order-details-options.js +5 -6
- package/dist/collection/components/salla-order-details/salla-order-details.js +3 -4
- package/dist/collection/components/salla-order-edit/salla-order-edit-item.js +4 -4
- package/dist/collection/components/salla-order-edit/salla-order-edit.js +4 -4
- package/dist/collection/components/salla-order-summary/salla-order-summary.js +2 -2
- package/dist/collection/components/salla-order-totals-card/salla-order-totals-card.js +3 -4
- package/dist/collection/components/salla-orders/salla-orders.js +4 -4
- package/dist/collection/components/salla-payments/salla-payments.js +1 -0
- package/dist/collection/components/salla-placeholder/salla-placeholder.js +3 -3
- package/dist/collection/components/salla-price-range/salla-price-range.js +8 -8
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +6 -6
- package/dist/collection/components/salla-product-card/salla-product-card.js +18 -18
- package/dist/collection/components/salla-product-options/salla-product-options.js +13 -15
- package/dist/collection/components/salla-products-list/salla-products-list.js +21 -20
- package/dist/collection/components/salla-products-slider/salla-products-slider.js +23 -22
- package/dist/collection/components/salla-progress-bar/salla-progress-bar.js +20 -21
- package/dist/collection/components/salla-quantity-input/salla-quantity-input.js +2 -2
- package/dist/collection/components/salla-quick-buy/salla-quick-buy.js +17 -16
- package/dist/collection/components/salla-quick-order/salla-quick-order.js +11 -11
- package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +2 -2
- package/dist/collection/components/salla-rating-stars/salla-rating-stars.js +8 -8
- package/dist/collection/components/salla-review-card/salla-review-card.js +3 -3
- package/dist/collection/components/salla-reviews/salla-reviews.js +13 -16
- package/dist/collection/components/salla-reviews-summary/salla-reviews-summary.js +2 -2
- package/dist/collection/components/salla-scopes/salla-scopes.js +2 -2
- package/dist/collection/components/salla-search/salla-search.js +6 -6
- package/dist/collection/components/salla-skeleton/salla-skeleton.js +3 -3
- package/dist/collection/components/salla-slider/salla-slider.js +25 -25
- package/dist/collection/components/salla-social-share/salla-social-share.js +3 -3
- package/dist/collection/components/salla-tabs/salla-tab-content.js +2 -2
- package/dist/collection/components/salla-tabs/salla-tab-header.js +5 -5
- package/dist/collection/components/salla-tabs/salla-tabs.js +2 -2
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +8 -9
- package/dist/collection/components/salla-tooltip/salla-tooltip.js +5 -5
- package/dist/collection/components/salla-trust-badges/salla-trust-badges.js +1 -1
- package/dist/collection/components/salla-user-menu/salla-user-menu.js +5 -5
- package/dist/collection/components/salla-user-profile/salla-user-profile.js +1 -1
- package/dist/collection/components/salla-verify/salla-verify.js +4 -4
- package/dist/components/Helper.js +432 -1
- package/dist/components/_commonjsHelpers.js +7 -1
- package/dist/components/anime.es.js +1310 -1
- package/dist/components/arrow-left.js +8 -1
- package/dist/components/axios.js +4240 -2
- package/dist/components/bell-ring.js +8 -1
- package/dist/components/camera.js +8 -1
- package/dist/components/cancel.js +8 -1
- package/dist/components/cart.js +8 -1
- package/dist/components/check-circle2.js +15 -1
- package/dist/components/check.js +8 -1
- package/dist/components/facebook.js +10 -1
- package/dist/components/filepond-plugin-file-poster.js +662 -2
- package/dist/components/filepond-plugin-file-validate-size.js +204 -2
- package/dist/components/filepond-plugin-file-validate-type.js +262 -2
- package/dist/components/filepond-plugin-image-edit.js +487 -2
- package/dist/components/filepond-plugin-image-exif-orientation.js +214 -2
- package/dist/components/filepond-plugin-image-preview.js +2237 -2
- package/dist/components/filepond.js +11286 -2
- package/dist/components/gift.js +8 -1
- package/dist/components/image.js +8 -1
- package/dist/components/index.d.ts +0 -2
- package/dist/components/index.js +8220 -1
- package/dist/components/index2.js +1709 -1
- package/dist/components/index3.js +2550 -1
- package/dist/components/interfaces.js +12 -1
- package/dist/components/isObject.js +292 -1
- package/dist/components/keyboard_arrow_down.js +8 -1
- package/dist/components/keyboard_arrow_right.js +15 -1
- package/dist/components/location.js +11 -1
- package/dist/components/mail.js +8 -1
- package/dist/components/minus.js +15 -1
- package/dist/components/salla-accordion-body.js +6 -1
- package/dist/components/salla-accordion-body2.js +30 -1
- package/dist/components/salla-accordion-head.js +6 -1
- package/dist/components/salla-accordion-head2.js +63 -1
- package/dist/components/salla-accordion.js +6 -1
- package/dist/components/salla-accordion2.js +68 -1
- package/dist/components/salla-add-product-button.js +6 -1
- package/dist/components/salla-add-product-button2.js +306 -1
- package/dist/components/salla-advertisement.js +155 -1
- package/dist/components/salla-alert.js +59 -1
- package/dist/components/salla-app-install-alert.js +91 -1
- package/dist/components/salla-apps-icons.js +63 -1
- package/dist/components/salla-booking-field.js +6 -1
- package/dist/components/salla-booking-field2.js +221 -1
- package/dist/components/salla-bottom-alert.js +214 -1
- package/dist/components/salla-breadcrumb.js +226 -1
- package/dist/components/salla-bullet-delivery.js +2114 -1
- package/dist/components/salla-button.js +6 -1
- package/dist/components/salla-button2.js +174 -1
- package/dist/components/salla-cart-coupons.js +284 -1
- package/dist/components/salla-cart-item-offers.js +143 -1
- package/dist/components/salla-cart-summary.js +136 -1
- package/dist/components/salla-color-picker.js +6 -1
- package/dist/components/salla-color-picker2.js +260 -1
- package/dist/components/salla-comment-form.js +6 -1
- package/dist/components/salla-comment-form2.js +64 -1
- package/dist/components/salla-comment-item.js +6 -1
- package/dist/components/salla-comment-item2.js +217 -1
- package/dist/components/salla-comments.js +395 -1
- package/dist/components/salla-conditional-fields.js +6 -1
- package/dist/components/salla-conditional-fields2.js +137 -1
- package/dist/components/salla-conditional-offer.js +194 -1
- package/dist/components/salla-contacts.js +125 -1
- package/dist/components/salla-cookies-bar.js +107 -1
- package/dist/components/salla-count-down.js +6 -1
- package/dist/components/salla-count-down2.js +271 -1
- package/dist/components/salla-custom-fields.js +175 -1
- package/dist/components/salla-datetime-picker.js +6 -1
- package/dist/components/salla-datetime-picker2.js +342 -1
- package/dist/components/salla-delivery-promise.js +263 -1
- package/dist/components/salla-drawer.js +6 -1
- package/dist/components/salla-drawer2.js +214 -1
- package/dist/components/salla-file-upload.js +6 -1
- package/dist/components/salla-file-upload2.js +583 -1
- package/dist/components/salla-filters-widget.js +6 -1
- package/dist/components/salla-filters-widget2.js +245 -1
- package/dist/components/salla-filters.js +253 -1
- package/dist/components/salla-fulfillment-methods.js +61 -1
- package/dist/components/salla-gifting.js +732 -1
- package/dist/components/salla-hook.js +47 -1
- package/dist/components/salla-infinite-scroll.js +112 -1
- package/dist/components/salla-installment.js +306 -1
- package/dist/components/salla-list-tile.js +6 -1
- package/dist/components/salla-list-tile2.js +47 -1
- package/dist/components/salla-loading.js +6 -1
- package/dist/components/salla-loading2.js +51 -1
- package/dist/components/salla-localization-modal.js +296 -1
- package/dist/components/salla-login-modal.js +6 -1
- package/dist/components/salla-login-modal2.js +359 -1
- package/dist/components/salla-loyalty-prize-item.js +39 -1
- package/dist/components/salla-loyalty-program.js +115 -1
- package/dist/components/salla-loyalty.js +304 -1
- package/dist/components/salla-maintenance-alert.js +57 -1
- package/dist/components/salla-map.js +6 -1
- package/dist/components/salla-map2.js +766 -1
- package/dist/components/salla-menu.js +165 -1
- package/dist/components/salla-metadata.js +97 -1
- package/dist/components/salla-modal.js +6 -1
- package/dist/components/salla-modal2.js +215 -1
- package/dist/components/salla-multiple-bundle-product-cart.js +6 -1
- package/dist/components/salla-multiple-bundle-product-cart2.js +151 -1
- package/dist/components/salla-multiple-bundle-product-details.js +6 -1
- package/dist/components/salla-multiple-bundle-product-details2.js +296 -1
- package/dist/components/salla-multiple-bundle-product-options-modal.js +6 -1
- package/dist/components/salla-multiple-bundle-product-options-modal2.js +598 -1
- package/dist/components/salla-multiple-bundle-product-slider.js +6 -1
- package/dist/components/salla-multiple-bundle-product-slider2.js +136 -1
- package/dist/components/salla-multiple-bundle-product.js +207 -1
- package/dist/components/salla-notification-item.js +6 -1
- package/dist/components/salla-notification-item2.js +32 -1
- package/dist/components/salla-notifications.js +190 -1
- package/dist/components/salla-offer-modal.js +328 -1
- package/dist/components/salla-offer.js +478 -1
- package/dist/components/salla-order-details-multiple-bundle-product.js +6 -1
- package/dist/components/salla-order-details-multiple-bundle-product2.js +122 -1
- package/dist/components/salla-order-details-options.js +6 -1
- package/dist/components/salla-order-details-options2.js +140 -1
- package/dist/components/salla-order-details.js +122 -1
- package/dist/components/salla-order-edit-item.js +6 -1
- package/dist/components/salla-order-edit-item2.js +181 -1
- package/dist/components/salla-order-edit.js +288 -1
- package/dist/components/salla-order-summary.js +132 -1
- package/dist/components/salla-order-totals-card.js +87 -1
- package/dist/components/salla-orders.js +271 -1
- package/dist/components/salla-payments.js +76 -1
- package/dist/components/salla-placeholder.js +6 -1
- package/dist/components/salla-placeholder2.js +66 -1
- package/dist/components/salla-price-range.js +6 -1
- package/dist/components/salla-price-range2.js +204 -1
- package/dist/components/salla-product-availability.js +6 -1
- package/dist/components/salla-product-availability2.js +206 -1
- package/dist/components/salla-product-card.js +6 -1
- package/dist/components/salla-product-card2.js +241 -1
- package/dist/components/salla-product-options.js +6 -1
- package/dist/components/salla-product-options2.js +962 -1
- package/dist/components/salla-product-size-guide.js +130 -1
- package/dist/components/salla-products-list.js +6 -1
- package/dist/components/salla-products-list2.js +812 -1
- package/dist/components/salla-products-slider.js +6 -1
- package/dist/components/salla-products-slider2.js +215 -1
- package/dist/components/salla-progress-bar.js +6 -1
- package/dist/components/salla-progress-bar2.js +94 -1
- package/dist/components/salla-quantity-input.js +6 -1
- package/dist/components/salla-quantity-input2.js +127 -1
- package/dist/components/salla-quick-buy.js +6 -1
- package/dist/components/salla-quick-buy2.js +1181 -1
- package/dist/components/salla-quick-order.js +299 -1
- package/dist/components/salla-rating-modal.js +530 -1
- package/dist/components/salla-rating-stars.js +6 -1
- package/dist/components/salla-rating-stars2.js +162 -1
- package/dist/components/salla-review-card.js +6 -1
- package/dist/components/salla-review-card2.js +198 -1
- package/dist/components/salla-reviews-page.js +726 -1
- package/dist/components/salla-reviews-summary.js +6 -1
- package/dist/components/salla-reviews-summary2.js +132 -1
- package/dist/components/salla-reviews.js +143 -1
- package/dist/components/salla-scopes.js +249 -1
- package/dist/components/salla-search.js +213 -1
- package/dist/components/salla-skeleton.js +6 -1
- package/dist/components/salla-skeleton2.js +50 -1
- package/dist/components/salla-slider.js +6 -1
- package/dist/components/salla-slider2.js +10489 -1
- package/dist/components/salla-social-share.js +194 -1
- package/dist/components/salla-social.js +89 -1
- package/dist/components/salla-tab-content.js +6 -1
- package/dist/components/salla-tab-content2.js +55 -1
- package/dist/components/salla-tab-header.js +6 -1
- package/dist/components/salla-tab-header2.js +85 -1
- package/dist/components/salla-tabs.js +6 -1
- package/dist/components/salla-tabs2.js +75 -1
- package/dist/components/salla-tel-input.js +6 -1
- package/dist/components/salla-tel-input2.js +168 -1
- package/dist/components/salla-tiered-offer.js +366 -1
- package/dist/components/salla-tooltip.js +6 -1
- package/dist/components/salla-tooltip2.js +57 -1
- package/dist/components/salla-trust-badges.js +90 -1
- package/dist/components/salla-user-menu.js +344 -1
- package/dist/components/salla-user-profile.js +203 -1
- package/dist/components/salla-user-settings.js +139 -1
- package/dist/components/salla-verify.js +303 -1
- package/dist/components/salla-wallet.js +114 -1
- package/dist/components/search.js +8 -1
- package/dist/components/shopping-bag.js +8 -1
- package/dist/components/special-discount.js +8 -1
- package/dist/components/star.js +8 -1
- package/dist/components/star2.js +8 -1
- package/dist/components/vanilla-picker.js +1034 -2
- package/dist/components/whatsapp2.js +8 -1
- package/dist/esm/{filepond-DlGaLh8N.js → filepond-Be7JObSq.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-BTVFYcQx.js → filepond-plugin-file-poster-DF0NWKCQ.js} +2 -2
- package/dist/esm/{filepond-plugin-file-validate-size-DGryLmWv.js → filepond-plugin-file-validate-size-DJFlJHtE.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-DxKfCD0V.js → filepond-plugin-file-validate-type-DykpLW1Z.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-2W7pu9hn.js → filepond-plugin-image-edit-CyIHxrnW.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-OQu-IvPH.js → filepond-plugin-image-exif-orientation-DbCOAhSu.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-DEW_tSNR.js → filepond-plugin-image-preview-CGRGZcft.js} +1 -1
- package/dist/esm/{index-DYB20YqN.js → index-Cz6cYzxG.js} +547 -780
- package/dist/esm/{index-BDqMkCqE.js → index-_kPnZdm0.js} +1 -1
- package/dist/esm/loader.js +3 -4
- package/dist/esm/salla-accordion-body_2.entry.js +5 -5
- package/dist/esm/salla-accordion_6.entry.js +15 -19
- package/dist/esm/salla-add-product-button_4.entry.js +10 -12
- package/dist/esm/salla-advertisement.entry.js +3 -3
- package/dist/esm/salla-alert_2.entry.js +5 -5
- package/dist/esm/salla-app-install-alert.entry.js +3 -3
- package/dist/esm/salla-apps-icons.entry.js +3 -3
- package/dist/esm/salla-booking-field_7.entry.js +23 -25
- package/dist/esm/salla-bullet-delivery.entry.js +3 -3
- package/dist/esm/salla-cart-coupons.entry.js +3 -3
- package/dist/esm/salla-cart-item-offers_2.entry.js +5 -5
- package/dist/esm/salla-comment-form_8.entry.js +17 -17
- package/dist/esm/salla-conditional-offer.entry.js +3 -3
- package/dist/esm/salla-contacts.entry.js +3 -3
- package/dist/esm/salla-cookies-bar.entry.js +3 -3
- package/dist/esm/salla-count-down.entry.js +3 -3
- package/dist/esm/salla-custom-fields.entry.js +3 -3
- package/dist/esm/salla-delivery-promise.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +3 -3
- package/dist/esm/salla-filters.entry.js +3 -3
- package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
- package/dist/esm/salla-gifting.entry.js +3 -3
- package/dist/esm/salla-hook.entry.js +2 -5
- package/dist/esm/salla-infinite-scroll.entry.js +3 -3
- package/dist/esm/salla-installment.entry.js +3 -3
- package/dist/esm/salla-list-tile.entry.js +3 -3
- package/dist/esm/salla-localization-modal.entry.js +1 -1
- package/dist/esm/salla-login-modal.entry.js +3 -3
- package/dist/esm/salla-loyalty-prize-item.entry.js +3 -3
- package/dist/esm/salla-loyalty-program.entry.js +3 -3
- package/dist/esm/salla-loyalty.entry.js +3 -3
- package/dist/esm/salla-maintenance-alert.entry.js +3 -3
- package/dist/esm/salla-map.entry.js +3 -3
- package/dist/esm/salla-menu.entry.js +3 -3
- package/dist/esm/salla-metadata.entry.js +3 -3
- package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +5 -5
- package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +6 -8
- package/dist/esm/salla-multiple-bundle-product.entry.js +4 -6
- package/dist/esm/salla-notification-item.entry.js +3 -3
- package/dist/esm/salla-notifications.entry.js +3 -3
- package/dist/esm/salla-offer-modal.entry.js +3 -3
- package/dist/esm/salla-offer.entry.js +3 -3
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +3 -3
- package/dist/esm/salla-order-details-options.entry.js +3 -3
- package/dist/esm/salla-order-details.entry.js +4 -6
- package/dist/esm/salla-order-edit-item.entry.js +3 -3
- package/dist/esm/salla-order-edit.entry.js +3 -3
- package/dist/esm/salla-order-summary.entry.js +3 -3
- package/dist/esm/salla-order-totals-card.entry.js +4 -6
- package/dist/esm/salla-orders.entry.js +3 -3
- package/dist/esm/salla-payments.entry.js +3 -3
- package/dist/esm/salla-placeholder.entry.js +3 -3
- package/dist/esm/salla-price-range.entry.js +3 -3
- package/dist/esm/salla-product-card.entry.js +3 -3
- package/dist/esm/salla-product-size-guide.entry.js +3 -3
- package/dist/esm/salla-products-list.entry.js +3 -3
- package/dist/esm/salla-products-slider.entry.js +3 -3
- package/dist/esm/salla-progress-bar.entry.js +3 -3
- package/dist/esm/salla-quick-order.entry.js +3 -3
- package/dist/esm/salla-rating-modal.entry.js +3 -3
- package/dist/esm/salla-scopes.entry.js +3 -3
- package/dist/esm/salla-search.entry.js +4 -6
- package/dist/esm/salla-skeleton.entry.js +3 -3
- package/dist/esm/salla-slider.entry.js +3 -3
- package/dist/esm/salla-social-share.entry.js +3 -3
- package/dist/esm/salla-social.entry.js +3 -3
- package/dist/esm/salla-tab-content_3.entry.js +7 -7
- package/dist/esm/salla-tiered-offer.entry.js +3 -3
- package/dist/esm/salla-tooltip.entry.js +3 -3
- package/dist/esm/salla-trust-badges.entry.js +3 -3
- package/dist/esm/salla-user-menu.entry.js +3 -3
- package/dist/esm/salla-user-profile.entry.js +3 -3
- package/dist/esm/salla-user-settings.entry.js +3 -3
- package/dist/esm/salla-verify.entry.js +3 -3
- package/dist/esm/salla-wallet.entry.js +3 -3
- package/dist/esm/twilight.js +4 -5
- package/dist/esm/{vanilla-picker-Dt9vZPZF.js → vanilla-picker-C_YV5LtA.js} +1 -1
- package/dist/twilight/{p-33779828.entry.js → p-0200cddd.entry.js} +1 -1
- package/dist/twilight/p-04dc0b71.entry.js +4 -0
- package/dist/twilight/{p-105b1dab.entry.js → p-0bac200e.entry.js} +1 -1
- package/dist/twilight/{p-ccfe5308.entry.js → p-0ef99df1.entry.js} +1 -1
- package/dist/twilight/{p-647b6d76.entry.js → p-1087f0dd.entry.js} +1 -1
- package/dist/twilight/{p-1875537e.entry.js → p-17dd8b68.entry.js} +1 -1
- package/dist/twilight/{p-aa7c5de0.entry.js → p-25a9bf1b.entry.js} +1 -1
- package/dist/twilight/{p-34b670fc.entry.js → p-2602927d.entry.js} +1 -1
- package/dist/twilight/p-268695ff.entry.js +4 -0
- package/dist/twilight/{p-aaa0c743.entry.js → p-34920aac.entry.js} +1 -1
- package/dist/twilight/{p-817b8ba5.entry.js → p-3656b48d.entry.js} +1 -1
- package/dist/twilight/{p-4932857d.entry.js → p-3857beb4.entry.js} +1 -1
- package/dist/twilight/{p-af3c74f4.entry.js → p-39c601e3.entry.js} +1 -1
- package/dist/twilight/{p-b598c0f7.entry.js → p-3c810881.entry.js} +1 -1
- package/dist/twilight/{p-d371d450.entry.js → p-3cf5c61f.entry.js} +1 -1
- package/dist/twilight/{p-3ccc532d.entry.js → p-413a7236.entry.js} +1 -1
- package/dist/twilight/{p-f176d41d.entry.js → p-42778349.entry.js} +1 -1
- package/dist/twilight/{p-b17d055d.entry.js → p-45e4f6f4.entry.js} +1 -1
- package/dist/twilight/{p-2abaa633.entry.js → p-4680956b.entry.js} +1 -1
- package/dist/twilight/{p-96a20515.entry.js → p-468b999f.entry.js} +1 -1
- package/dist/twilight/{p-df6853b5.entry.js → p-46d1823f.entry.js} +1 -1
- package/dist/twilight/{p-c87951a2.entry.js → p-49db497f.entry.js} +1 -1
- package/dist/twilight/{p-18bb0181.entry.js → p-4b033276.entry.js} +1 -1
- package/dist/twilight/{p-296d2dd0.entry.js → p-4f7bc9c3.entry.js} +1 -1
- package/dist/twilight/{p-4fa4547a.entry.js → p-543ee624.entry.js} +1 -1
- package/dist/twilight/{p-2fe01e44.entry.js → p-5957f774.entry.js} +1 -1
- package/dist/twilight/{p-96e78428.entry.js → p-5a4f0b99.entry.js} +1 -1
- package/dist/twilight/{p-87c0ca91.entry.js → p-5a8c0fd2.entry.js} +1 -1
- package/dist/twilight/{p-e28c0773.entry.js → p-5ab7a295.entry.js} +1 -1
- package/dist/twilight/{p-542d3277.entry.js → p-5e496aaa.entry.js} +1 -1
- package/dist/twilight/{p-c3ffb88a.entry.js → p-5f440956.entry.js} +1 -1
- package/dist/twilight/{p-94dbc1e9.entry.js → p-60fafcd9.entry.js} +1 -1
- package/dist/twilight/{p-1ef2602d.entry.js → p-708f02db.entry.js} +1 -1
- package/dist/twilight/{p-b64f3155.entry.js → p-7829ea8a.entry.js} +1 -1
- package/dist/twilight/{p-7093a427.entry.js → p-7d3e592a.entry.js} +1 -1
- package/dist/twilight/{p-96d03a28.entry.js → p-81876026.entry.js} +1 -1
- package/dist/twilight/{p-d9f5a8cd.entry.js → p-8306ef5e.entry.js} +1 -1
- package/dist/twilight/{p-d4a242f8.entry.js → p-8403cd93.entry.js} +1 -1
- package/dist/twilight/{p-7abddca8.entry.js → p-8474c4f6.entry.js} +1 -1
- package/dist/twilight/p-8552160a.entry.js +4 -0
- package/dist/twilight/p-8c9b0e2a.entry.js +4 -0
- package/dist/twilight/{p-2881bb33.entry.js → p-8f2dfc57.entry.js} +1 -1
- package/dist/twilight/{p-c091e2dc.entry.js → p-94b1a2ae.entry.js} +1 -1
- package/dist/twilight/{p-ede67a08.entry.js → p-95dad1af.entry.js} +1 -1
- package/dist/twilight/{p-eac718cd.entry.js → p-964b7db9.entry.js} +1 -1
- package/dist/twilight/{p-e3b8e0e1.entry.js → p-99735748.entry.js} +1 -1
- package/dist/twilight/{p-X6Yi3bYP.js → p-BZKDQg1s.js} +1 -1
- package/dist/twilight/{p-Cw3UBzjl.js → p-B_sN7OnY.js} +1 -1
- package/dist/twilight/{p-8r0S6BcZ.js → p-Bpi0aG1F.js} +1 -1
- package/dist/twilight/{p-BkClxrC4.js → p-CP8rFQ5n.js} +1 -1
- package/dist/twilight/{p-bNzv71Xl.js → p-CfmIbM8B.js} +1 -1
- package/dist/twilight/{p-bScl0xMh.js → p-CpO1SrBd.js} +1 -1
- package/dist/twilight/p-Cz6cYzxG.js +5 -0
- package/dist/twilight/p-Do4hSOGo.js +9 -0
- package/dist/twilight/{p-Ck4zxCil.js → p-JJmlh-ji.js} +1 -1
- package/dist/twilight/{p-dd2bd5dc.entry.js → p-a4aedcfe.entry.js} +1 -1
- package/dist/twilight/{p-06fa7327.entry.js → p-b0d01f9f.entry.js} +1 -1
- package/dist/twilight/p-b8404cfb.entry.js +4 -0
- package/dist/twilight/{p-108d8c8b.entry.js → p-b8e3e180.entry.js} +1 -1
- package/dist/twilight/{p-ad07f67a.entry.js → p-bd687cd0.entry.js} +1 -1
- package/dist/twilight/{p-44fa7521.entry.js → p-c0037fac.entry.js} +1 -1
- package/dist/twilight/{p-293c6cf3.entry.js → p-c121f8e4.entry.js} +1 -1
- package/dist/twilight/{p-a01f1992.entry.js → p-c29907df.entry.js} +1 -1
- package/dist/twilight/p-c39675ef.entry.js +4 -0
- package/dist/twilight/{p-bff4c7b3.entry.js → p-cb7a985e.entry.js} +1 -1
- package/dist/twilight/p-cbe620c4.entry.js +4 -0
- package/dist/twilight/{p-6f36541a.entry.js → p-d2fd79b4.entry.js} +1 -1
- package/dist/twilight/{p-d337c399.entry.js → p-d6cf0ffd.entry.js} +1 -1
- package/dist/twilight/{p-748df7e6.entry.js → p-d8f60f2f.entry.js} +1 -1
- package/dist/twilight/p-d99610f9.entry.js +4 -0
- package/dist/twilight/{p-e6bbf50d.entry.js → p-dc897bdd.entry.js} +1 -1
- package/dist/twilight/{p-f7999a6d.entry.js → p-dca46236.entry.js} +1 -1
- package/dist/twilight/{p-e94f217b.entry.js → p-e48853c9.entry.js} +1 -1
- package/dist/twilight/{p-09d39785.entry.js → p-e4fdb206.entry.js} +1 -1
- package/dist/twilight/p-ed913ae7.entry.js +4 -0
- package/dist/twilight/p-f067fcd6.entry.js +4 -0
- package/dist/twilight/{p-57ff1f25.entry.js → p-f2cd6975.entry.js} +1 -1
- package/dist/twilight/{p-ad041ab5.entry.js → p-f2ffbfbb.entry.js} +1 -1
- package/dist/twilight/{p-f5d15e71.entry.js → p-f3166e60.entry.js} +1 -1
- package/dist/twilight/{p-59ae82bd.entry.js → p-f8fcc8f4.entry.js} +1 -1
- package/dist/twilight/{p-c1fd45b1.entry.js → p-f9e52fd9.entry.js} +1 -1
- package/dist/twilight/p-fcddbfc3.entry.js +4 -0
- package/dist/twilight/{p-41c733c2.entry.js → p-fe7ac9bb.entry.js} +1 -1
- package/dist/twilight/{p-0add06f9.entry.js → p-ff14dca3.entry.js} +1 -1
- package/dist/twilight/{p-BZnoSB1s.js → p-mlFGjxcj.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components.d.ts +177 -763
- package/dist/types/stencil-public-runtime.d.ts +11 -169
- package/package.json +5 -5
- package/dist/cjs/app-globals-oehrC7QI.js +0 -39
- package/dist/esm/app-globals-BFryt7-C.js +0 -37
- package/dist/twilight/p-1daeed6e.entry.js +0 -4
- package/dist/twilight/p-2ddb3fce.entry.js +0 -4
- package/dist/twilight/p-34968e31.entry.js +0 -4
- package/dist/twilight/p-665189b4.entry.js +0 -4
- package/dist/twilight/p-776c9d33.entry.js +0 -4
- package/dist/twilight/p-7b8313ef.entry.js +0 -4
- package/dist/twilight/p-7bd0ede5.entry.js +0 -4
- package/dist/twilight/p-8e8d9d7d.entry.js +0 -4
- package/dist/twilight/p-D1vqXXNX.js +0 -9
- package/dist/twilight/p-DYB20YqN.js +0 -5
- package/dist/twilight/p-Vl6qpttb.js +0 -4
- package/dist/twilight/p-af60e72a.entry.js +0 -4
- package/dist/twilight/p-e679884a.entry.js +0 -4
- package/dist/twilight/p-efab88c5.entry.js +0 -4
|
@@ -1,4 +1,815 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{transformTag as t,proxyCustomElement as s,HTMLElement as i,createEvent as e,h as o,Host as a}from"@stencil/core/internal/client";import{a as r}from"./anime.es.js";import{S as l}from"./shopping-bag.js";import{H as h}from"./Helper.js";const n=s(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.productsFetched=e(this,"productsFetched",7),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),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}})}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)}`}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(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,o=salla.config.get("page.id"),a=salla.url.is_page("index"),r=salla.url.is_page("product.single"),l=e?i!==e:i!==String(o);if(i&&l&&!a&&!r||a&&!this.hasInfiniteScroll)return this.removeScrollRestorationSession(),this.switchToNormalBehavior=!0,!1;if(r)return this.switchToNormalBehavior=!0,!1;if(t)try{const{pageIndex:i,nextPage:e,currentPageData:o}=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<o.length;t++)this.wrapper.append(this.getItemHTML(o?.[t]));return!0}catch(t){console.error("Failed to load stored scroll state:",t),this.removeScrollRestorationSession()}return!1}getSource(){return h.getProductsSource(this.source)}getSourceValue(){return this.currentCategoryIdFilter?this.currentCategoryIdFilter:h.getProductsSourceValue(this.source,this.sourceValue)}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=>{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=this.handleResponse(t);this.infiniteScroll.appendItems(s),2===this.infiniteScroll.pageIndex&&(!this.autoload&&this.nextPage&&(this.loadMoreWrapper.style.display="block"),this.animateItems())}catch(t){console.error("Error during load:",t)}finally{this.isProcessing=!1}}})),this.infiniteScroll?.on("error",(()=>{console.log("Error occurred during request"),this.status.querySelector(".s-infinite-scroll-error").classList.remove("s-hidden"),this.placeholderLoader&&this.placeholderLoader.remove(),this.loading(!1),this.isProcessing=!1})),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 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 this.handleResponse(t).forEach((t=>this.wrapper.append(t))):(this.firstPageResponse=t,void(this.nextPage=t.cursor?t.cursor.next:this.nextPage))):(this.showPlaceholder=!0,this.placeholderLoader&&this.placeholderLoader.remove(),void this.loading(!1))))))}async loadMore(){this.infiniteScroll?.loadNextPage()}componentWillLoad(){return salla.onReady().then((()=>{this.hasCustomComponent=!!customElements.get(this.productCardComponent),this.sourceValueIsValid=!(!this.getSourceValue()&&!this.isSourceWithoutValue()),this.hasInfiniteScroll=!["json","selected","related","landing-page","recently"].includes(this.getSource())&&!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(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((()=>{this.firstPageResponse?(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&&this.handleResponse(this.firstPageResponse,!1).forEach((t=>this.wrapper.append(t)))}canRender(){return this.sourceValueIsValid&&this.isReady}render(){return this.canRender()?this.showPlaceholder?o("div",{class:"s-products-list-placeholder"},o("span",{innerHTML:l}),o("p",null,this.placeholderText)):o(a,{class:"s-products-list"},o("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}),o("div",{class:"s-infinite-scroll-status",ref:t=>this.status=t},o("p",{class:"s-infinite-scroll-last infinite-scroll-last s-hidden"},this.endOfText),o("p",{class:"s-infinite-scroll-error infinite-scroll-error s-hidden"},this.failedLoadMore)),this.autoload&&o("div",{class:"s-products-list-loading-wrapper",style:{display:"none"},ref:t=>this.loader=t},o("span",{class:"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader"})),this.hasInfiniteScroll&&this.nextPage&&!this.autoload?o("div",{class:"s-infinite-scroll-wrapper",style:{display:"none"},ref:t=>this.loadMoreWrapper=t},o("button",{onClick:()=>this.loadMore(),class:"s-infinite-scroll-btn s-button-btn s-button-primary"},o("span",{class:"s-button-text s-infinite-scroll-btn-text"},this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")),o("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()}handleResponse(t,s=!0){if(!t)return[];let i=this.getSource(),e="";if(1===t.cursor?.current){e=h.getPageTitleForSource(i);try{if("search"===this.getSource())e=salla.lang.get("common.elements.search_about",{word:this.getSourceValue()});else if(!e){let s=this.parsedFilters.category_id||this.getSourceValue()[0];e=t.filters?.find((t=>"category_id"===t.key))?.values?.find((t=>t.key===s))?.value??"",this.filtersSnapshot=t.filters}e+=(e?" - ":"")+salla.lang.choice("blocks.header.products_count",t.data?.length),15===t.data.length&&(e=e.replace(t.data.length,salla.lang.get("common.elements.more_than")+" "+t.data.length)),t.title=e}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=t.cursor?t.cursor.next:this.nextPage),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 o=[];for(let s=0;s<t.data.length;s++)o.push(this.getItemHTML(t.data?.[s]));return o}get host(){return this}static get style(){return""}},[0,"salla-products-list",{source:[1537],sourceValue:[1032,"source-value"],limit:[1026],sortBy:[1025,"sort-by"],filtersResults:[1540,"filters-results"],horizontalCards:[516,"horizontal-cards"],rowCards:[516,"row-cards"],compactCards:[516,"compact-cards"],autoload:[1028],loadMoreText:[1,"load-more-text"],productCardComponent:[1,"product-card-component"],includes:[1040],page:[32],nextPage:[32],hasInfiniteScroll:[32],hasCustomComponent:[32],sourceValueIsValid:[32],placeholderText:[32],endOfText:[32],failedLoadMore:[32],currentPage:[32],currentCategoryIdFilter:[32],isReady:[32],showPlaceholder:[32],switchToNormalBehavior:[32],parsedFilters:[32],filtersSnapshot:[32],setFilters:[64],reload:[64]}]);function c(){"undefined"!=typeof customElements&&["salla-products-list"].forEach((s=>{"salla-products-list"===s&&(customElements.get(t(s))||customElements.define(t(s),n))}))}c();export{n as S,c as d}
|
|
4
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
5
|
+
import { a as anime } from './anime.es.js';
|
|
6
|
+
import { S as ShoppingBag } from './shopping-bag.js';
|
|
7
|
+
import { H as Helper } from './Helper.js';
|
|
8
|
+
|
|
9
|
+
const sallaProductsListCss = "";
|
|
10
|
+
|
|
11
|
+
const SallaProductsList = /*@__PURE__*/ proxyCustomElement(class SallaProductsList extends HTMLElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this.__registerHost();
|
|
15
|
+
this.productsFetched = createEvent(this, "productsFetched", 7);
|
|
16
|
+
/**
|
|
17
|
+
* Autoload next page when scroll
|
|
18
|
+
*/
|
|
19
|
+
this.autoload = false;
|
|
20
|
+
/**
|
|
21
|
+
* Custom Card Component for the Salla Products List.
|
|
22
|
+
*
|
|
23
|
+
* This component allows you to customize the appearance of individual product cards within a Salla Products List.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* <salla-products-list product-card-component="my-custom-card-style1" ...
|
|
27
|
+
* <salla-products-list product-card-component="my-custom-card-style2" ...
|
|
28
|
+
*/
|
|
29
|
+
this.productCardComponent = 'custom-salla-product-card';
|
|
30
|
+
// State
|
|
31
|
+
this.page = 1;
|
|
32
|
+
this.placeholderText = salla.lang.get('pages.categories.no_products');
|
|
33
|
+
this.endOfText = salla.lang.get('common.elements.end_of_content');
|
|
34
|
+
this.failedLoadMore = salla.lang.get('common.elements.failed_to_load_more');
|
|
35
|
+
this.currentPage = salla.config.get('page');
|
|
36
|
+
this.filtersSnapshot = [];
|
|
37
|
+
this.lastViewedProductKey = "lastViewedProductId";
|
|
38
|
+
this.filtersKey = "filters";
|
|
39
|
+
this.infiniteScrollStateKey = "infiniteScrollState";
|
|
40
|
+
this.prevCategoryIdKey = "prevCategoryId";
|
|
41
|
+
this.isProcessing = false; // Tracks if we are processing data
|
|
42
|
+
this.scrollTimeout = null;
|
|
43
|
+
this.boundScrollToLastViewedProduct = () => this.scrollToLastViewedProduct();
|
|
44
|
+
this.boundHandleScroll = () => this.handleScroll();
|
|
45
|
+
this.specialPagesWithoutIds = {
|
|
46
|
+
'product.index.latest': 'latest',
|
|
47
|
+
'product.index.offers': 'offers',
|
|
48
|
+
'product.index.search': 'search',
|
|
49
|
+
'product.index.sales': 'sales'
|
|
50
|
+
};
|
|
51
|
+
//TODO:: check why `this.includes` not working!!
|
|
52
|
+
this.includes = Helper.parseJson(this.includes || this.host.getAttribute('includes'));
|
|
53
|
+
if (!Array.isArray(this.includes)) {
|
|
54
|
+
this.includes = null;
|
|
55
|
+
}
|
|
56
|
+
Helper.setIncludes(this.includes);
|
|
57
|
+
salla.lang.onLoaded(() => {
|
|
58
|
+
this.placeholderText = salla.lang.get('pages.categories.no_products');
|
|
59
|
+
this.endOfText = salla.lang.get('common.elements.end_of_content');
|
|
60
|
+
this.failedLoadMore = salla.lang.get('common.elements.failed_to_load_more');
|
|
61
|
+
this.currentPage = salla.config.get('page');
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
connectedCallback() {
|
|
65
|
+
//Override browser scroll restoration default behaviour
|
|
66
|
+
if ("scrollRestoration" in history)
|
|
67
|
+
history.scrollRestoration = "manual";
|
|
68
|
+
// required for scroll restoration case when the component loads before DOM content is completed (slow internet bandwidth /low device specs)
|
|
69
|
+
window.addEventListener('DOMContentLoaded', this.boundScrollToLastViewedProduct);
|
|
70
|
+
salla.event.on('salla-filters::changed', filters => this.setFilters(filters));
|
|
71
|
+
}
|
|
72
|
+
disconnectedCallback() {
|
|
73
|
+
window.removeEventListener('DOMContentLoaded', this.boundScrollToLastViewedProduct);
|
|
74
|
+
window.removeEventListener('scroll', this.boundHandleScroll);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Set parsed filters data from URI
|
|
78
|
+
* @param filters
|
|
79
|
+
*/
|
|
80
|
+
async setFilters(filters) {
|
|
81
|
+
if (!filters || JSON.stringify(filters) === JSON.stringify(this.parsedFilters)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
85
|
+
// Create a deep copy of the filters object to avoid mutating the original object
|
|
86
|
+
this.parsedFilters = JSON.parse(JSON.stringify(filters));
|
|
87
|
+
this.filtersSnapshot = this.parsedFilters;
|
|
88
|
+
if (this.currentPage?.slug == "product.index" && this.parsedFilters && this.parsedFilters.category_id) {
|
|
89
|
+
this.currentCategoryIdFilter = [this.parsedFilters.category_id];
|
|
90
|
+
}
|
|
91
|
+
return this.reload();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Reload the list of products (entire content of the component).
|
|
95
|
+
*/
|
|
96
|
+
async reload() {
|
|
97
|
+
!this.autoload && this.loadMoreWrapper && (this.loadMoreWrapper.style.display = 'none');
|
|
98
|
+
this.hasInfiniteScroll && salla.infiniteScroll.destroy(this.infiniteScroll);
|
|
99
|
+
this.buildNextPageUrl();
|
|
100
|
+
// TODO: this is problematic in testing, for the time being it's been resolved like this
|
|
101
|
+
this.wrapper.innerHTML = '';
|
|
102
|
+
if (this.hasInfiniteScroll) {
|
|
103
|
+
this.init();
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
this.getInitialData();
|
|
107
|
+
}
|
|
108
|
+
// Special case for the placeholder loader
|
|
109
|
+
if (this.showPlaceholder) {
|
|
110
|
+
this.showPlaceholder = false;
|
|
111
|
+
this.placeholderLoader = document.createElement('div');
|
|
112
|
+
this.placeholderLoader.classList.add('s-products-list-loading-wrapper');
|
|
113
|
+
this.placeholderLoader.style.display = 'inherit';
|
|
114
|
+
this.placeholderLoader.innerHTML = `<span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader"></span>`;
|
|
115
|
+
this.host.insertAdjacentElement('afterend', this.placeholderLoader);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
isFilterable() {
|
|
119
|
+
return salla.config.get('store.settings.product.filters') && this.filtersResults;
|
|
120
|
+
}
|
|
121
|
+
isSourceWithoutValue() {
|
|
122
|
+
return ['offers', 'latest', 'sales', 'wishlist', 'top-rated', 'reorder'].includes(this.getSource());
|
|
123
|
+
}
|
|
124
|
+
animateItems() {
|
|
125
|
+
anime({
|
|
126
|
+
targets: 'salla-products-list salla-product-card',
|
|
127
|
+
opacity: [0, 1],
|
|
128
|
+
duration: 1200,
|
|
129
|
+
translateY: [20, 0],
|
|
130
|
+
delay: function (_el, i) {
|
|
131
|
+
return i * 100;
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
initBaseNextPageUrl(source) {
|
|
136
|
+
this.nextPage = salla.url.api(`products?source=${source}`);
|
|
137
|
+
if (this.includes?.length) {
|
|
138
|
+
this.nextPage += `&includes[]=${this.includes.join('&includes[]=')}`;
|
|
139
|
+
}
|
|
140
|
+
if (this.limit) {
|
|
141
|
+
this.nextPage += `&per_page=${this.limit > 32 ? 32 : this.limit}`;
|
|
142
|
+
}
|
|
143
|
+
if (this.sortBy) {
|
|
144
|
+
this.nextPage += `&sort=${this.sortBy}`;
|
|
145
|
+
}
|
|
146
|
+
if (salla.config.get('theme.mode') === 'preview') {
|
|
147
|
+
this.nextPage += `&use_username_url=1`;
|
|
148
|
+
}
|
|
149
|
+
this.nextPage += '&filterable=1';
|
|
150
|
+
for (const [key, value] of Object.entries(this.parsedFilters || {})) {
|
|
151
|
+
if (["string", "number"].includes(typeof value)) {
|
|
152
|
+
// @ts-ignore
|
|
153
|
+
this.nextPage += `&filters[${encodeURIComponent(key)}]=${encodeURIComponent(value)}`;
|
|
154
|
+
}
|
|
155
|
+
else if (Array.isArray(value)) {
|
|
156
|
+
value.forEach(item => this.nextPage += `&filters[${encodeURIComponent(key)}][]=${encodeURIComponent(item)}`);
|
|
157
|
+
}
|
|
158
|
+
else if (typeof value === 'object') {
|
|
159
|
+
for (const [k, v] of Object.entries(value)) {
|
|
160
|
+
this.nextPage += `&filters[${encodeURIComponent(key)}][${encodeURIComponent(k)}]=${encodeURIComponent(v)}`;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
buildNextPageUrl() {
|
|
166
|
+
let source = this.getSource();
|
|
167
|
+
if (source === 'json') {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const snapshot = sessionStorage.getItem(this.infiniteScrollStateKey);
|
|
171
|
+
if (snapshot) {
|
|
172
|
+
const { nextPage } = JSON.parse(snapshot);
|
|
173
|
+
if (!nextPage) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
this.initBaseNextPageUrl(source);
|
|
178
|
+
if (this.isSourceWithoutValue()) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (['search', 'related', 'landing-page'].includes(source)) {
|
|
182
|
+
this.nextPage += `&source_value=${this.getSourceValue()}`;
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
this.nextPage += `&source_value[]=${this.getSourceValue().join('&source_value[]=')}`;
|
|
187
|
+
}
|
|
188
|
+
catch (e) {
|
|
189
|
+
salla.logger.warn(`source-value prop should be array of ids ex source-value="[1,2,3]" for the source [${source}]`);
|
|
190
|
+
this.sourceValueIsValid = false;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
loading(isLoading = true, isBtn = false) {
|
|
194
|
+
if (!isLoading) {
|
|
195
|
+
if (!this.autoload) {
|
|
196
|
+
this.btnLoader && (this.btnLoader.style.display = 'none');
|
|
197
|
+
}
|
|
198
|
+
this.loader && (this.loader.style.display = 'none');
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
let currentLoader = isBtn && !this.autoload ? this.btnLoader : this.loader;
|
|
202
|
+
currentLoader && (currentLoader.style.display = 'inherit');
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
getItemHTML(product) {
|
|
206
|
+
//as a request they don't want to let the user to open the product details
|
|
207
|
+
//todo:: find a better way to handle this request
|
|
208
|
+
this.getSource() === 'landing-page' && (product.url = '');
|
|
209
|
+
const customComponentTag = this.hasCustomComponent ? this.productCardComponent : 'salla-product-card';
|
|
210
|
+
const productCard = document.createElement(customComponentTag);
|
|
211
|
+
productCard.product = product;
|
|
212
|
+
// Apply compact layout if requested - set both property and attribute for compatibility
|
|
213
|
+
if (this.compactCards) {
|
|
214
|
+
productCard.compact = true;
|
|
215
|
+
productCard.toggleAttribute('compact', true);
|
|
216
|
+
}
|
|
217
|
+
this.applyLandingPageStyles(productCard);
|
|
218
|
+
this.applyHorizontalCardStyles(productCard);
|
|
219
|
+
// Attach click event listener to save the current products snapshot
|
|
220
|
+
productCard.addEventListener('click', (event) => {
|
|
221
|
+
const target = event.target;
|
|
222
|
+
// Check if the clicked element is an anchor or inside an anchor
|
|
223
|
+
const anchor = target.closest('a');
|
|
224
|
+
if (anchor) {
|
|
225
|
+
Helper.saveProductSource(this.getSource());
|
|
226
|
+
if (this.hasInfiniteScroll) {
|
|
227
|
+
this.takeStateSnapshot();
|
|
228
|
+
sessionStorage.setItem(this.lastViewedProductKey, product.id);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
return productCard;
|
|
233
|
+
}
|
|
234
|
+
applyLandingPageStyles(productCard) {
|
|
235
|
+
if (this.getSource() === 'landing-page' && !this.hasCustomComponent) {
|
|
236
|
+
productCard.toggleAttribute('hide-add-btn', true);
|
|
237
|
+
productCard.classList.add('s-product-card-fit-height');
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
applyHorizontalCardStyles(productCard) {
|
|
241
|
+
if (!this.horizontalCards) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
productCard.toggleAttribute('horizontal', true);
|
|
245
|
+
if (!this.hasCustomComponent) {
|
|
246
|
+
productCard.toggleAttribute('shadow-on-hover', true);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
waitForResizing(element) {
|
|
250
|
+
let timeout = null;
|
|
251
|
+
return new Promise((resolve) => {
|
|
252
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
253
|
+
clearTimeout(timeout);
|
|
254
|
+
timeout = setTimeout(() => {
|
|
255
|
+
resizeObserver.disconnect();
|
|
256
|
+
resolve(null);
|
|
257
|
+
}, 160); // Adjust delay as needed for your layout
|
|
258
|
+
});
|
|
259
|
+
resizeObserver.observe(element); // Watch the body or a specific container
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
waitForLayoutStable(element) {
|
|
263
|
+
let timeout = null;
|
|
264
|
+
return new Promise((resolve) => {
|
|
265
|
+
const observer = new MutationObserver(() => {
|
|
266
|
+
clearTimeout(timeout);
|
|
267
|
+
timeout = setTimeout(() => {
|
|
268
|
+
observer.disconnect();
|
|
269
|
+
resolve(null);
|
|
270
|
+
}, 160); // Adjust delay as needed for your layout
|
|
271
|
+
});
|
|
272
|
+
// Observe changes to the entire body, including child nodes and attributes.
|
|
273
|
+
observer.observe(element, {
|
|
274
|
+
childList: true,
|
|
275
|
+
subtree: true,
|
|
276
|
+
attributes: true,
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
async waitForStableLayout(element) {
|
|
281
|
+
// Wait for DOM mutations and layout shifts to stabilize
|
|
282
|
+
return await Promise.allSettled([
|
|
283
|
+
this.waitForResizing(element),
|
|
284
|
+
this.waitForLayoutStable(element)
|
|
285
|
+
]);
|
|
286
|
+
}
|
|
287
|
+
scrollToLastViewedProduct() {
|
|
288
|
+
const lastViewedProductId = sessionStorage.getItem(this.lastViewedProductKey);
|
|
289
|
+
if (!lastViewedProductId || salla.url.is_page('product.single'))
|
|
290
|
+
return;
|
|
291
|
+
this.isElementLoaded(`[id*="${lastViewedProductId}"]`)
|
|
292
|
+
.then(() => {
|
|
293
|
+
const productCard = this.wrapper?.querySelector(`[id*="${lastViewedProductId}"]`);
|
|
294
|
+
if (!productCard)
|
|
295
|
+
return;
|
|
296
|
+
const scrollToPosition = () => {
|
|
297
|
+
const scrollToProductCard = () => {
|
|
298
|
+
// calculations is located here for last second changes in the ui (ie. sticky header height)
|
|
299
|
+
productCard.scrollIntoView({ block: 'start', behavior: 'instant' });
|
|
300
|
+
const headerSelector = matchMedia('(max-width: 1024px)').matches ? "header .inner" : "ul.main-menu";
|
|
301
|
+
const headerHeight = window?.header_is_sticky ? (document.querySelector(headerSelector)?.getBoundingClientRect()?.height ?? 56) : 0;
|
|
302
|
+
const cardsListRowGap = parseInt(getComputedStyle(this.wrapper).rowGap) ?? 16;
|
|
303
|
+
const productCardOffset = headerHeight + cardsListRowGap;
|
|
304
|
+
scrollBy({ top: productCardOffset * -1, behavior: 'instant' });
|
|
305
|
+
};
|
|
306
|
+
//start scrolling to the product card position
|
|
307
|
+
requestAnimationFrame(scrollToProductCard);
|
|
308
|
+
const productImages = productCard.querySelectorAll('img.lazy');
|
|
309
|
+
productImages.forEach((image) => {
|
|
310
|
+
const productImage = image;
|
|
311
|
+
const handleImageEvent = () => {
|
|
312
|
+
requestAnimationFrame(scrollToProductCard);
|
|
313
|
+
productImage.onload = productImage.onerror = null;
|
|
314
|
+
};
|
|
315
|
+
productImage.onload = handleImageEvent;
|
|
316
|
+
productImage.onerror = handleImageEvent;
|
|
317
|
+
});
|
|
318
|
+
// remove snapshot of product cards items in session storage after scroll restoration completiion
|
|
319
|
+
this.removeScrollRestorationSession();
|
|
320
|
+
return void 0;
|
|
321
|
+
};
|
|
322
|
+
this.waitForStableLayout(this.host).then(() => requestAnimationFrame(scrollToPosition));
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
isElementLoaded(selector) {
|
|
326
|
+
return new Promise((resolve => {
|
|
327
|
+
const interval = setInterval(() => {
|
|
328
|
+
if (document.querySelector(selector)) {
|
|
329
|
+
clearInterval(interval);
|
|
330
|
+
return resolve(document.querySelector(selector));
|
|
331
|
+
}
|
|
332
|
+
}, 50);
|
|
333
|
+
}));
|
|
334
|
+
}
|
|
335
|
+
;
|
|
336
|
+
takeStateSnapshot() {
|
|
337
|
+
const currentPageData = [];
|
|
338
|
+
// Classic for-loop for performance
|
|
339
|
+
for (let i = 0; i < this.wrapper.children.length; i++) {
|
|
340
|
+
const child = this.wrapper.children?.[i];
|
|
341
|
+
currentPageData.push(child.product);
|
|
342
|
+
}
|
|
343
|
+
const scrollState = {
|
|
344
|
+
pageIndex: Math.max((this.infiniteScroll?.pageIndex ?? 1) - 1, 1),
|
|
345
|
+
nextPage: this.nextPage,
|
|
346
|
+
currentPageData
|
|
347
|
+
};
|
|
348
|
+
if (this.isFilterable()) {
|
|
349
|
+
const existingFilters = sessionStorage.getItem(this.filtersKey);
|
|
350
|
+
sessionStorage.setItem(this.filtersKey, existingFilters || JSON.stringify(this.filtersSnapshot));
|
|
351
|
+
}
|
|
352
|
+
sessionStorage.setItem(this.infiniteScrollStateKey, JSON.stringify(scrollState));
|
|
353
|
+
// Determine and store the correct prevCategoryId
|
|
354
|
+
let prevCategoryId = salla.config.get('page.id'); // Number or null
|
|
355
|
+
const currentPage = Object.keys(this.specialPagesWithoutIds).find(page => salla.url.is_page(page));
|
|
356
|
+
if (currentPage) {
|
|
357
|
+
prevCategoryId = this.specialPagesWithoutIds[currentPage];
|
|
358
|
+
}
|
|
359
|
+
else if (prevCategoryId !== null) {
|
|
360
|
+
prevCategoryId = String(prevCategoryId); // Ensure it's stored as a string
|
|
361
|
+
}
|
|
362
|
+
sessionStorage.setItem(this.prevCategoryIdKey, prevCategoryId);
|
|
363
|
+
}
|
|
364
|
+
removeScrollRestorationSession() {
|
|
365
|
+
if (!this.isFilterable()) {
|
|
366
|
+
sessionStorage.removeItem(this.filtersKey);
|
|
367
|
+
}
|
|
368
|
+
sessionStorage.removeItem(this.infiniteScrollStateKey);
|
|
369
|
+
sessionStorage.removeItem(this.lastViewedProductKey);
|
|
370
|
+
sessionStorage.removeItem(this.prevCategoryIdKey);
|
|
371
|
+
}
|
|
372
|
+
loadStoredScrollState() {
|
|
373
|
+
const storedState = sessionStorage.getItem(this.infiniteScrollStateKey);
|
|
374
|
+
const filetrsState = sessionStorage.getItem(this.filtersKey);
|
|
375
|
+
/*
|
|
376
|
+
* Remove the scroll restoration session under the following conditions:
|
|
377
|
+
* 1. The user has navigated to a different category page:
|
|
378
|
+
* - If the previously stored category ID is different from the current one.
|
|
379
|
+
* - This includes "latest", "offers", "sales" and "search" pages.
|
|
380
|
+
*
|
|
381
|
+
* 2. The user is on the homepage, but infinite scroll is disabled.
|
|
382
|
+
*
|
|
383
|
+
* 3. The user is on a product page.
|
|
384
|
+
*/
|
|
385
|
+
const prevCategory = sessionStorage.getItem(this.prevCategoryIdKey); // Get previously stored category
|
|
386
|
+
const currentPageSlug = this.specialPagesWithoutIds[salla.config.get('page.slug')] || null;
|
|
387
|
+
const currentPageId = salla.config.get('page.id'); // Number or null
|
|
388
|
+
const isHomepage = salla.url.is_page('index');
|
|
389
|
+
const isProductPage = salla.url.is_page('product.single');
|
|
390
|
+
const isDifferentCategory = currentPageSlug
|
|
391
|
+
? prevCategory !== currentPageSlug // Compare slugs for special pages
|
|
392
|
+
: prevCategory !== String(currentPageId); // Compare IDs otherwise
|
|
393
|
+
if ((prevCategory && isDifferentCategory && !isHomepage && !isProductPage)
|
|
394
|
+
||
|
|
395
|
+
(isHomepage && !this.hasInfiniteScroll)) {
|
|
396
|
+
this.removeScrollRestorationSession();
|
|
397
|
+
this.switchToNormalBehavior = true;
|
|
398
|
+
return false;
|
|
399
|
+
}
|
|
400
|
+
// Keep the snapshot in product page that contains salla-products-list but without scroll restoration
|
|
401
|
+
if (isProductPage) {
|
|
402
|
+
this.switchToNormalBehavior = true;
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
if (storedState) {
|
|
406
|
+
try {
|
|
407
|
+
const { pageIndex, nextPage, currentPageData } = JSON.parse(storedState);
|
|
408
|
+
if (filetrsState !== 'undefined') {
|
|
409
|
+
const filters = JSON.parse(filetrsState);
|
|
410
|
+
salla.event.emit('filters::fetched', { filters });
|
|
411
|
+
}
|
|
412
|
+
this.page = pageIndex;
|
|
413
|
+
this.nextPage = nextPage;
|
|
414
|
+
// more performant on larger set of data
|
|
415
|
+
for (let i = 0; i < currentPageData.length; i++) {
|
|
416
|
+
this.wrapper.append(this.getItemHTML(currentPageData?.[i]));
|
|
417
|
+
}
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
catch (error) {
|
|
421
|
+
console.error('Failed to load stored scroll state:', error);
|
|
422
|
+
this.removeScrollRestorationSession();
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
getSource() {
|
|
428
|
+
return Helper.getProductsSource(this.source);
|
|
429
|
+
}
|
|
430
|
+
getSourceValue() {
|
|
431
|
+
return this.currentCategoryIdFilter ? this.currentCategoryIdFilter : Helper.getProductsSourceValue(this.source, this.sourceValue);
|
|
432
|
+
}
|
|
433
|
+
appendDataLayer(data) {
|
|
434
|
+
if (typeof dataLayer !== 'object' || !Array.isArray(dataLayer)) {
|
|
435
|
+
//todo:: check if we should define it here
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
dataLayer.push({
|
|
439
|
+
"event": "impressions",
|
|
440
|
+
"ecommerce": {
|
|
441
|
+
"currencyCode": salla.config.currency().code,
|
|
442
|
+
// "event_id":"", // todo
|
|
443
|
+
"impressions": data.map((product, index) => {
|
|
444
|
+
return {
|
|
445
|
+
"id": product.id,
|
|
446
|
+
"name": product.name,
|
|
447
|
+
"price": product.price,
|
|
448
|
+
"brand": product.brand?.name || '',
|
|
449
|
+
"quantity": product.quantity,
|
|
450
|
+
// "variant": "",
|
|
451
|
+
"categories": [
|
|
452
|
+
{
|
|
453
|
+
"name": product.category?.name || salla.config.get('page.title'),
|
|
454
|
+
"id": salla.config.get('page.id')
|
|
455
|
+
}
|
|
456
|
+
],
|
|
457
|
+
"category": product.category?.name || salla.config.get('page.title'),
|
|
458
|
+
'position': index + 1
|
|
459
|
+
};
|
|
460
|
+
})
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
initiateInfiniteScroll() {
|
|
465
|
+
if (!this.hasInfiniteScroll) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
const shouldApplyManualLoad = this.autoload && this.includes && this.includes.length > 0;
|
|
469
|
+
this.infiniteScroll = salla.infiniteScroll.initiate(this.wrapper, this.wrapper, {
|
|
470
|
+
path: () => this.nextPage,
|
|
471
|
+
history: false,
|
|
472
|
+
nextPage: this.nextPage,
|
|
473
|
+
scrollThreshold: shouldApplyManualLoad ? false : this.autoload ? 100 : false,
|
|
474
|
+
loadOnScroll: shouldApplyManualLoad ? false : this.autoload
|
|
475
|
+
}, true);
|
|
476
|
+
this.infiniteScroll.pageIndex = this.page;
|
|
477
|
+
this.infiniteScroll?.on('request', () => {
|
|
478
|
+
this.loading(true, this.autoload ? false : true);
|
|
479
|
+
});
|
|
480
|
+
// Manual scroll listener
|
|
481
|
+
shouldApplyManualLoad && window.addEventListener('scroll', this.boundHandleScroll);
|
|
482
|
+
this.infiniteScroll?.on('load', async (response) => {
|
|
483
|
+
if (this.isProcessing)
|
|
484
|
+
return;
|
|
485
|
+
this.isProcessing = true;
|
|
486
|
+
try {
|
|
487
|
+
if (!response.data?.length && this.infiniteScroll.pageIndex === 2) {
|
|
488
|
+
this.showPlaceholder = true;
|
|
489
|
+
salla.infiniteScroll.destroy(this.infiniteScroll);
|
|
490
|
+
this.loading(false);
|
|
491
|
+
this.placeholderLoader && this.placeholderLoader.remove();
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
if (this.includes) {
|
|
495
|
+
await this.injectAndProcessData(response);
|
|
496
|
+
}
|
|
497
|
+
const items = this.handleResponse(response);
|
|
498
|
+
this.infiniteScroll.appendItems(items);
|
|
499
|
+
if (this.infiniteScroll.pageIndex === 2) {
|
|
500
|
+
if (!this.autoload && this.nextPage) {
|
|
501
|
+
this.loadMoreWrapper.style.display = 'block';
|
|
502
|
+
}
|
|
503
|
+
this.animateItems();
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
catch (error) {
|
|
507
|
+
console.error('Error during load:', error);
|
|
508
|
+
}
|
|
509
|
+
finally {
|
|
510
|
+
this.isProcessing = false;
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
this.infiniteScroll?.on('error', () => {
|
|
514
|
+
console.log('Error occurred during request');
|
|
515
|
+
this.status.querySelector('.s-infinite-scroll-error').classList.remove('s-hidden');
|
|
516
|
+
this.placeholderLoader && this.placeholderLoader.remove();
|
|
517
|
+
this.loading(false);
|
|
518
|
+
this.isProcessing = false;
|
|
519
|
+
});
|
|
520
|
+
salla.onReady(() => {
|
|
521
|
+
const snapshot = sessionStorage.getItem(this.infiniteScrollStateKey);
|
|
522
|
+
if (!snapshot) {
|
|
523
|
+
this.manualLoadNextPage();
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
handleScroll() {
|
|
528
|
+
if (this.isProcessing)
|
|
529
|
+
return;
|
|
530
|
+
if (this.scrollTimeout)
|
|
531
|
+
return;
|
|
532
|
+
this.scrollTimeout = setTimeout(() => {
|
|
533
|
+
this.scrollTimeout = null;
|
|
534
|
+
// Defer layout reads to next frame to avoid forced reflow (Lighthouse/PageSpeed)
|
|
535
|
+
requestAnimationFrame(() => {
|
|
536
|
+
const wrapperRect = this.wrapper.getBoundingClientRect();
|
|
537
|
+
const windowHeight = window.innerHeight;
|
|
538
|
+
const distanceToBottom = wrapperRect.bottom - windowHeight;
|
|
539
|
+
// Trigger only when the wrapper bottom is within 200px of the viewport bottom
|
|
540
|
+
if (distanceToBottom <= 200 && !this.isProcessing && this.nextPage) {
|
|
541
|
+
// Reached near the bottom of the wrapper, loading next page...
|
|
542
|
+
this.manualLoadNextPage();
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
}, 200);
|
|
546
|
+
}
|
|
547
|
+
manualLoadNextPage() {
|
|
548
|
+
if (this.nextPage) {
|
|
549
|
+
this.infiniteScroll.loadNextPage();
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
async injectAndProcessData(response) {
|
|
553
|
+
try {
|
|
554
|
+
await Helper.injectExtraFieldsToResponse(response);
|
|
555
|
+
}
|
|
556
|
+
catch (error) {
|
|
557
|
+
console.error('Error injecting data:', error);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
getInitialData() {
|
|
561
|
+
this.loading();
|
|
562
|
+
return salla.api.withoutNotifier(() => salla.product.api.fetch({
|
|
563
|
+
source: Helper.getApiSource(this.getSource()),
|
|
564
|
+
source_value: this.getSourceValue(),
|
|
565
|
+
limit: this.limit
|
|
566
|
+
}).then(async (response) => {
|
|
567
|
+
if (!response.data.length) {
|
|
568
|
+
this.showPlaceholder = true;
|
|
569
|
+
this.placeholderLoader && this.placeholderLoader.remove();
|
|
570
|
+
this.loading(false);
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
await Helper.injectExtraFieldsToResponse(response);
|
|
574
|
+
//this.firstPageResponse will be null only in the first page, after that it will be assinged,
|
|
575
|
+
//for the first page we need to inject the dom after the load, see @method componentDidLoad
|
|
576
|
+
if (!this.firstPageResponse) {
|
|
577
|
+
this.firstPageResponse = response;
|
|
578
|
+
this.nextPage = response.cursor ? response.cursor.next : this.nextPage;
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
this.handleResponse(response).forEach(card => this.wrapper.append(card));
|
|
582
|
+
}));
|
|
583
|
+
}
|
|
584
|
+
async loadMore() {
|
|
585
|
+
this.infiniteScroll?.loadNextPage();
|
|
586
|
+
}
|
|
587
|
+
componentWillLoad() {
|
|
588
|
+
return salla.onReady()
|
|
589
|
+
.then(() => {
|
|
590
|
+
this.hasCustomComponent = !!customElements.get(this.productCardComponent);
|
|
591
|
+
this.sourceValueIsValid = !!(this.getSourceValue() || this.isSourceWithoutValue());
|
|
592
|
+
this.hasInfiniteScroll = !['json', 'selected', 'related', 'landing-page', 'recently'].includes(this.getSource()) && !this.limit;
|
|
593
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
594
|
+
try {
|
|
595
|
+
this.sortBy = this.sortBy || searchParams.get('sort') || searchParams.get('by');
|
|
596
|
+
this.parsedFilters = Helper.extractFiltersFromUrl(searchParams);
|
|
597
|
+
if (this.parsedFilters && this.parsedFilters.category_id) {
|
|
598
|
+
this.currentCategoryIdFilter = [this.parsedFilters.category_id];
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
catch (e) {
|
|
602
|
+
salla.logger.warn('failed to get filters from url', e.message);
|
|
603
|
+
}
|
|
604
|
+
this.buildNextPageUrl();
|
|
605
|
+
this.isReady = true;
|
|
606
|
+
const snapshot = sessionStorage.getItem(this.infiniteScrollStateKey);
|
|
607
|
+
if (!!snapshot) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
if (!this.sourceValueIsValid) {
|
|
611
|
+
salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`);
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
if (this.hasInfiniteScroll) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
// Handle json source
|
|
618
|
+
if (this.getSource() === 'json') {
|
|
619
|
+
if (!this.getSourceValue().length) {
|
|
620
|
+
this.showPlaceholder = true;
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
//todo:: avoid using timeout, just assigne the data to the this.firstPageResponse and it should work fine, because it will be rendered in componentDidLoad
|
|
624
|
+
setTimeout(() => {
|
|
625
|
+
let productsList = this.getSourceValue();
|
|
626
|
+
productsList.map(product => this.wrapper.append(this.getItemHTML(product)));
|
|
627
|
+
});
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
// Handle selected source
|
|
631
|
+
if (this.getSource() === 'selected' && !this.getSourceValue().length) {
|
|
632
|
+
this.showPlaceholder = true;
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
return this.getInitialData();
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
async componentDidLoad() {
|
|
639
|
+
this.hasInfiniteScroll && this.init();
|
|
640
|
+
await Salla.hooks.registerComponent('salla-products-list', this);
|
|
641
|
+
if (this.loadStoredScrollState()) {
|
|
642
|
+
if (this.autoload) {
|
|
643
|
+
!this.nextPage && this.loading(false);
|
|
644
|
+
}
|
|
645
|
+
else if (!this.nextPage) {
|
|
646
|
+
this.loadMoreWrapper && (this.loadMoreWrapper.style.display = 'none');
|
|
647
|
+
this.status.querySelector('.s-infinite-scroll-last').classList.remove('s-hidden');
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
this.loadMoreWrapper && (this.loadMoreWrapper.style.display = 'block');
|
|
651
|
+
}
|
|
652
|
+
this.scrollToLastViewedProduct();
|
|
653
|
+
}
|
|
654
|
+
else if (!this.firstPageResponse && this.switchToNormalBehavior) {
|
|
655
|
+
this.getInitialData()
|
|
656
|
+
.then(() => {
|
|
657
|
+
if (this.firstPageResponse) {
|
|
658
|
+
this.handleResponse(this.firstPageResponse, false).forEach(card => {
|
|
659
|
+
this.wrapper.append(card);
|
|
660
|
+
});
|
|
661
|
+
setTimeout(() => {
|
|
662
|
+
if (!this.autoload && this.nextPage && this.infiniteScroll.pageIndex == 1) {
|
|
663
|
+
const loadMoreWrapper = this.host.querySelector('.s-infinite-scroll-wrapper');
|
|
664
|
+
loadMoreWrapper && (loadMoreWrapper.style.display = 'block');
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
else {
|
|
669
|
+
console.error("No response received after getInitialData.");
|
|
670
|
+
}
|
|
671
|
+
})
|
|
672
|
+
.catch(error => {
|
|
673
|
+
console.error("Error during initial data fetch:", error);
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
else {
|
|
677
|
+
this.firstPageResponse && this.handleResponse(this.firstPageResponse, false).forEach(card => this.wrapper.append(card));
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
canRender() {
|
|
681
|
+
return this.sourceValueIsValid && this.isReady;
|
|
682
|
+
}
|
|
683
|
+
render() {
|
|
684
|
+
if (!this.canRender()) {
|
|
685
|
+
return '';
|
|
686
|
+
}
|
|
687
|
+
if (this.showPlaceholder) {
|
|
688
|
+
return h("div", { class: "s-products-list-placeholder" }, h("span", { innerHTML: ShoppingBag }), h("p", null, this.placeholderText));
|
|
689
|
+
}
|
|
690
|
+
return (h(Host, { class: "s-products-list" }, h("div", { class: {
|
|
691
|
+
"s-products-list-wrapper": true,
|
|
692
|
+
's-products-list-horizontal-cards': this.horizontalCards && !this.filtersResults,
|
|
693
|
+
's-products-list-vertical-cards': !this.horizontalCards && !this.rowCards && !this.filtersResults,
|
|
694
|
+
's-products-list-row-cards': this.rowCards,
|
|
695
|
+
's-products-list-compact-cards': this.compactCards,
|
|
696
|
+
's-products-list-filters-results': this.filtersResults,
|
|
697
|
+
}, 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" } })))) : ""));
|
|
698
|
+
}
|
|
699
|
+
init() {
|
|
700
|
+
this.initiateInfiniteScroll();
|
|
701
|
+
this.loading();
|
|
702
|
+
}
|
|
703
|
+
handleResponse(response, shouldBuildNextPage = true) {
|
|
704
|
+
//todo:: check why it reach here undfined one time🤔
|
|
705
|
+
if (!response) {
|
|
706
|
+
return [];
|
|
707
|
+
}
|
|
708
|
+
let source = this.getSource();
|
|
709
|
+
let title = '';
|
|
710
|
+
//help the developer to know the current page title
|
|
711
|
+
if (response.cursor?.current === 1) {
|
|
712
|
+
title = Helper.getPageTitleForSource(source);
|
|
713
|
+
try {
|
|
714
|
+
if (this.getSource() === 'search') {
|
|
715
|
+
title = salla.lang.get('common.elements.search_about', { 'word': this.getSourceValue() });
|
|
716
|
+
}
|
|
717
|
+
else if (!title) {
|
|
718
|
+
let catId = this.parsedFilters.category_id || this.getSourceValue()[0];
|
|
719
|
+
// get the first filter that its key is category_id, then get the value when filter.value.*.key==catId
|
|
720
|
+
title = response.filters?.find(filter => filter.key === 'category_id')?.values?.find(cat => cat.key === catId)?.value ?? '';
|
|
721
|
+
this.filtersSnapshot = response.filters;
|
|
722
|
+
}
|
|
723
|
+
title += (title ? ' - ' : '') + salla.lang.choice('blocks.header.products_count', response.data?.length);
|
|
724
|
+
if (response.data.length === 15) {
|
|
725
|
+
title = title.replace(response.data.length, salla.lang.get('common.elements.more_than') + ' ' + response.data.length);
|
|
726
|
+
}
|
|
727
|
+
response.title = title;
|
|
728
|
+
}
|
|
729
|
+
catch (e) {
|
|
730
|
+
salla.logger.error('Error::falid to handle response', e);
|
|
731
|
+
}
|
|
732
|
+
//inject the SEO schema
|
|
733
|
+
//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
|
|
734
|
+
Helper.generateProductSchema(response.data);
|
|
735
|
+
}
|
|
736
|
+
this.appendDataLayer(response.data);
|
|
737
|
+
response.nextPage = this.nextPage;
|
|
738
|
+
response.source = this.getSource();
|
|
739
|
+
response.sourceValue = this.getSourceValue();
|
|
740
|
+
salla.event.emit('salla-products-list::products.fetched', response);
|
|
741
|
+
this.productsFetched.emit(response);
|
|
742
|
+
//💡 when source is related, cursor will not be existed
|
|
743
|
+
if (response.filters && this.isFilterable()) {
|
|
744
|
+
this.filtersResults = true;
|
|
745
|
+
this.filtersSnapshot = JSON.parse(JSON.stringify(response.filters));
|
|
746
|
+
salla.event.emit('filters::fetched', { filters: response.filters });
|
|
747
|
+
}
|
|
748
|
+
else if (this.isFilterable()) {
|
|
749
|
+
salla.event.emit('filters::hidden');
|
|
750
|
+
}
|
|
751
|
+
//because: this.nextPage is state we don't need to touch it after the build, to avoid the re-rendering
|
|
752
|
+
if (shouldBuildNextPage) {
|
|
753
|
+
this.nextPage = response.cursor ? response.cursor.next : this.nextPage;
|
|
754
|
+
}
|
|
755
|
+
this.loading(false);
|
|
756
|
+
this.placeholderLoader && this.placeholderLoader.remove();
|
|
757
|
+
if (this.hasInfiniteScroll && !this.nextPage) {
|
|
758
|
+
this.infiniteScroll.option({ scrollThreshold: false, loadOnScroll: false });
|
|
759
|
+
this.status.querySelector('.s-infinite-scroll-last').classList.remove('s-hidden');
|
|
760
|
+
}
|
|
761
|
+
const productCardsView = [];
|
|
762
|
+
for (let i = 0; i < response.data.length; i++) {
|
|
763
|
+
productCardsView.push(this.getItemHTML(response.data?.[i]));
|
|
764
|
+
}
|
|
765
|
+
return productCardsView;
|
|
766
|
+
}
|
|
767
|
+
get host() { return this; }
|
|
768
|
+
static get style() { return sallaProductsListCss; }
|
|
769
|
+
}, [0, "salla-products-list", {
|
|
770
|
+
"source": [1537],
|
|
771
|
+
"sourceValue": [1032, "source-value"],
|
|
772
|
+
"limit": [1026],
|
|
773
|
+
"sortBy": [1025, "sort-by"],
|
|
774
|
+
"filtersResults": [1540, "filters-results"],
|
|
775
|
+
"horizontalCards": [516, "horizontal-cards"],
|
|
776
|
+
"rowCards": [516, "row-cards"],
|
|
777
|
+
"compactCards": [516, "compact-cards"],
|
|
778
|
+
"autoload": [1028],
|
|
779
|
+
"loadMoreText": [1, "load-more-text"],
|
|
780
|
+
"productCardComponent": [1, "product-card-component"],
|
|
781
|
+
"includes": [1040],
|
|
782
|
+
"page": [32],
|
|
783
|
+
"nextPage": [32],
|
|
784
|
+
"hasInfiniteScroll": [32],
|
|
785
|
+
"hasCustomComponent": [32],
|
|
786
|
+
"sourceValueIsValid": [32],
|
|
787
|
+
"placeholderText": [32],
|
|
788
|
+
"endOfText": [32],
|
|
789
|
+
"failedLoadMore": [32],
|
|
790
|
+
"currentPage": [32],
|
|
791
|
+
"currentCategoryIdFilter": [32],
|
|
792
|
+
"isReady": [32],
|
|
793
|
+
"showPlaceholder": [32],
|
|
794
|
+
"switchToNormalBehavior": [32],
|
|
795
|
+
"parsedFilters": [32],
|
|
796
|
+
"filtersSnapshot": [32],
|
|
797
|
+
"setFilters": [64],
|
|
798
|
+
"reload": [64]
|
|
799
|
+
}]);
|
|
800
|
+
function defineCustomElement() {
|
|
801
|
+
if (typeof customElements === "undefined") {
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
const components = ["salla-products-list"];
|
|
805
|
+
components.forEach(tagName => { switch (tagName) {
|
|
806
|
+
case "salla-products-list":
|
|
807
|
+
if (!customElements.get(tagName)) {
|
|
808
|
+
customElements.define(tagName, SallaProductsList);
|
|
809
|
+
}
|
|
810
|
+
break;
|
|
811
|
+
} });
|
|
812
|
+
}
|
|
813
|
+
defineCustomElement();
|
|
814
|
+
|
|
815
|
+
export { SallaProductsList as S, defineCustomElement as d };
|