@salla.sa/twilight-components 3.0.17 → 3.0.19
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/{Helper-DSYelC4c.js → Helper-DqKJCL8G.js} +1 -1
- package/dist/cjs/{filepond-l9D0Yv7b.js → filepond-Byu0lc8z.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-8SrbLptI.js → filepond-plugin-file-poster-qwx7lYZ-.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-DGD6oJy0.js → filepond-plugin-file-validate-size-C-n0P4TT.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-BIvrhp3w.js → filepond-plugin-file-validate-type-C8VOOXdT.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-4xKikdXG.js → filepond-plugin-image-edit-B9KG763Y.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-C3BvwxQh.js → filepond-plugin-image-exif-orientation-Czt4pYzU.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-CBq_GY0V.js → filepond-plugin-image-preview-BFm1Zl0o.js} +1 -1
- package/dist/cjs/free-shipping-timer-6QBe5BNS.js +156 -0
- package/dist/cjs/helpers-NV7wgP50.js +602 -0
- package/dist/cjs/{index-BAwxpXnB.js → index-CFW798jX.js} +2 -2
- package/dist/cjs/{intlTelInput-xw-HaAEN.js → intlTelInput-CLa2B89b.js} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-accordion_6.cjs.entry.js +2 -2
- package/dist/cjs/salla-add-product-button_5.cjs.entry.js +46 -3
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-applied-filters.cjs.entry.js +2 -2
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-attachment-view_9.cjs.entry.js +11 -11
- package/dist/cjs/salla-badge.cjs.entry.js +1 -1
- package/dist/cjs/salla-basket-gap.cjs.entry.js +1 -1
- package/dist/cjs/salla-bullet-delivery_3.cjs.entry.js +590 -134
- package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-summary-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-cashback-banner.cjs.entry.js +1 -1
- package/dist/cjs/salla-comment-factors.cjs.entry.js +1 -1
- package/dist/cjs/salla-comment-form_9.cjs.entry.js +2 -2
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
- package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
- package/dist/cjs/salla-count-down.cjs.entry.js +1 -1
- package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
- package/dist/cjs/salla-delivery-promise.cjs.entry.js +2 -2
- package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +2 -2
- package/dist/cjs/salla-filters.cjs.entry.js +2 -2
- package/dist/cjs/salla-free-shipping-banner.cjs.entry.js +95 -9
- package/dist/cjs/salla-free-shipping-tag.cjs.entry.js +18 -5
- package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
- package/dist/cjs/salla-gift-card-redeem_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-gifting.cjs.entry.js +13 -6
- package/dist/cjs/salla-hook.cjs.entry.js +1 -1
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +2 -2
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
- package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-login-modal.cjs.entry.js +7 -2
- package/dist/cjs/salla-loyalty-banner_10.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-exchange-product-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-points-banner.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-points-history.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
- package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-map_3.cjs.entry.js +1 -1
- package/dist/cjs/salla-menu.cjs.entry.js +1 -1
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item_2.cjs.entry.js +2 -2
- package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-branch.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-cancel.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-items.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-options-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-payment.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-rewards.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-shipments.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +2 -2
- package/dist/cjs/salla-payments.cjs.entry.js +1 -1
- package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
- package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-card-embed.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
- package/dist/cjs/salla-products-list.cjs.entry.js +13 -5
- package/dist/cjs/salla-products-slider.cjs.entry.js +2 -2
- package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating-modal-v2.cjs.entry.js +7 -4
- package/dist/cjs/salla-rating-modal.cjs.entry.js +2 -2
- package/dist/cjs/salla-review-factors-tags.cjs.entry.js +1 -1
- package/dist/cjs/salla-review-order-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
- package/dist/cjs/salla-search-product-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-search.cjs.entry.js +2 -2
- package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
- package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
- package/dist/cjs/salla-social.cjs.entry.js +1 -1
- package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
- package/dist/cjs/salla-thank-you-header.cjs.entry.js +1 -1
- package/dist/cjs/salla-thank-you-page.cjs.entry.js +1 -1
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/salla-wishlist-actions.cjs.entry.js +1 -1
- package/dist/cjs/salla-wishlist-summary.cjs.entry.js +2 -2
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/cjs/{vanilla-picker-Cm_uNdps.js → vanilla-picker-Vx_7G7bs.js} +1 -1
- package/dist/collection/components/salla-bullet-delivery/api-service.js +156 -25
- package/dist/collection/components/salla-bullet-delivery/helpers.js +143 -15
- package/dist/collection/components/salla-bullet-delivery/icons.js +17 -0
- package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.css +490 -52
- package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.js +489 -106
- package/dist/collection/components/salla-bullet-delivery/selector-tracker.js +106 -0
- package/dist/collection/components/salla-free-shipping-banner/salla-free-shipping-banner.css +18 -4
- package/dist/collection/components/salla-free-shipping-banner/salla-free-shipping-banner.js +94 -11
- package/dist/collection/components/salla-free-shipping-tag/salla-free-shipping-tag.css +6 -0
- package/dist/collection/components/salla-free-shipping-tag/salla-free-shipping-tag.js +18 -2
- package/dist/collection/components/salla-gifting/salla-gifting.css +16 -1
- package/dist/collection/components/salla-gifting/salla-gifting.js +11 -4
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +6 -1
- package/dist/collection/components/salla-products-list/salla-products-list.js +11 -3
- package/dist/collection/components/salla-quick-buy/salla-quick-buy.js +44 -1
- package/dist/collection/components/salla-rating-modal/salla-rating-modal-v2.js +5 -2
- package/dist/collection/shared/free-shipping-timer.js +130 -0
- package/dist/components/free-shipping-timer.js +150 -0
- package/dist/components/helpers.js +299 -40
- package/dist/components/index.js +2 -2
- package/dist/components/salla-bullet-delivery.js +595 -133
- package/dist/components/salla-free-shipping-banner.js +95 -8
- package/dist/components/salla-free-shipping-tag.js +17 -3
- package/dist/components/salla-gifting.js +12 -5
- package/dist/components/salla-login-modal2.js +6 -1
- package/dist/components/salla-products-list2.js +11 -3
- package/dist/components/salla-quick-buy2.js +44 -1
- package/dist/components/salla-rating-modal-v22.js +5 -2
- package/dist/docs.json +25 -5
- package/dist/esm/{Helper-POCi7J93.js → Helper-I0CAizv1.js} +1 -1
- package/dist/esm/{filepond-Ct76xW02.js → filepond-DTUYXV0J.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-C1OkzGRs.js → filepond-plugin-file-poster-DydZjneT.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-gdd-69cO.js → filepond-plugin-file-validate-size-nbsCU2t9.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-BaZ2QTzl.js → filepond-plugin-file-validate-type-Cl5B_DIy.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-CsoNvf0i.js → filepond-plugin-image-edit-bzskFyFR.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-BHDSe3nH.js → filepond-plugin-image-exif-orientation-MBDuxLaX.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-CD_S17z3.js → filepond-plugin-image-preview-N6wzEryW.js} +1 -1
- package/dist/esm/free-shipping-timer-CnTwkF6y.js +150 -0
- package/dist/esm/helpers-Cnh7Qptl.js +568 -0
- package/dist/esm/{index-DmGAR42j.js → index-C9zdeQFI.js} +2 -2
- package/dist/esm/{intlTelInput-D76Q4XFx.js → intlTelInput-B5L9nYtO.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/salla-accordion-body_2.entry.js +1 -1
- package/dist/esm/salla-accordion_6.entry.js +2 -2
- package/dist/esm/salla-add-product-button_5.entry.js +46 -3
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-alert_2.entry.js +1 -1
- package/dist/esm/salla-app-install-alert.entry.js +1 -1
- package/dist/esm/salla-applied-filters.entry.js +2 -2
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-attachment-view_9.entry.js +11 -11
- package/dist/esm/salla-badge.entry.js +1 -1
- package/dist/esm/salla-basket-gap.entry.js +1 -1
- package/dist/esm/salla-bullet-delivery_3.entry.js +590 -134
- package/dist/esm/salla-cart-coupons.entry.js +1 -1
- package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
- package/dist/esm/salla-cart-summary-card.entry.js +1 -1
- package/dist/esm/salla-cashback-banner.entry.js +1 -1
- package/dist/esm/salla-comment-factors.entry.js +1 -1
- package/dist/esm/salla-comment-form_9.entry.js +2 -2
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +1 -1
- package/dist/esm/salla-cookies-bar.entry.js +1 -1
- package/dist/esm/salla-count-down.entry.js +1 -1
- package/dist/esm/salla-custom-fields.entry.js +1 -1
- package/dist/esm/salla-delivery-promise.entry.js +2 -2
- package/dist/esm/salla-edit-order-button.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +2 -2
- package/dist/esm/salla-filters.entry.js +2 -2
- package/dist/esm/salla-free-shipping-banner.entry.js +94 -8
- package/dist/esm/salla-free-shipping-tag.entry.js +17 -4
- package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
- package/dist/esm/salla-gift-card-redeem_2.entry.js +1 -1
- package/dist/esm/salla-gifting.entry.js +13 -6
- package/dist/esm/salla-hook.entry.js +1 -1
- package/dist/esm/salla-infinite-scroll.entry.js +2 -2
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-list-tile.entry.js +1 -1
- package/dist/esm/salla-localization-modal.entry.js +1 -1
- package/dist/esm/salla-login-modal.entry.js +7 -2
- package/dist/esm/salla-loyalty-banner_10.entry.js +1 -1
- package/dist/esm/salla-loyalty-exchange-product-card.entry.js +1 -1
- package/dist/esm/salla-loyalty-points-banner.entry.js +1 -1
- package/dist/esm/salla-loyalty-points-history.entry.js +1 -1
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty.entry.js +1 -1
- package/dist/esm/salla-maintenance-alert.entry.js +1 -1
- package/dist/esm/salla-map_3.entry.js +1 -1
- package/dist/esm/salla-menu.entry.js +1 -1
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-next-order-coupon.entry.js +1 -1
- package/dist/esm/salla-notification-item_2.entry.js +2 -2
- package/dist/esm/salla-offer-modal.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-branch.entry.js +1 -1
- package/dist/esm/salla-order-cancel.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-order-details-options.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +1 -1
- package/dist/esm/salla-order-edit-item.entry.js +1 -1
- package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
- package/dist/esm/salla-order-edit.entry.js +1 -1
- package/dist/esm/salla-order-items.entry.js +1 -1
- package/dist/esm/salla-order-options-modal.entry.js +1 -1
- package/dist/esm/salla-order-payment.entry.js +1 -1
- package/dist/esm/salla-order-rewards.entry.js +1 -1
- package/dist/esm/salla-order-shipments.entry.js +1 -1
- package/dist/esm/salla-order-summary.entry.js +1 -1
- package/dist/esm/salla-order-totals-card.entry.js +1 -1
- package/dist/esm/salla-orders.entry.js +2 -2
- package/dist/esm/salla-payments.entry.js +1 -1
- package/dist/esm/salla-placeholder.entry.js +1 -1
- package/dist/esm/salla-price-range.entry.js +1 -1
- package/dist/esm/salla-product-card-embed.entry.js +1 -1
- package/dist/esm/salla-product-card.entry.js +1 -1
- package/dist/esm/salla-product-size-guide.entry.js +1 -1
- package/dist/esm/salla-products-list.entry.js +13 -5
- package/dist/esm/salla-products-slider.entry.js +2 -2
- package/dist/esm/salla-quick-order.entry.js +1 -1
- package/dist/esm/salla-rating-modal-v2.entry.js +7 -4
- package/dist/esm/salla-rating-modal.entry.js +2 -2
- package/dist/esm/salla-review-factors-tags.entry.js +1 -1
- package/dist/esm/salla-review-order-item.entry.js +1 -1
- package/dist/esm/salla-scopes.entry.js +1 -1
- package/dist/esm/salla-search-product-card.entry.js +1 -1
- package/dist/esm/salla-search.entry.js +2 -2
- package/dist/esm/salla-skeleton.entry.js +1 -1
- package/dist/esm/salla-social-share.entry.js +1 -1
- package/dist/esm/salla-social.entry.js +1 -1
- package/dist/esm/salla-tab-content_3.entry.js +1 -1
- package/dist/esm/salla-thank-you-header.entry.js +1 -1
- package/dist/esm/salla-thank-you-page.entry.js +1 -1
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-trust-badges.entry.js +1 -1
- package/dist/esm/salla-user-menu.entry.js +1 -1
- package/dist/esm/salla-user-profile.entry.js +1 -1
- package/dist/esm/salla-user-settings.entry.js +1 -1
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/salla-wishlist-actions.entry.js +1 -1
- package/dist/esm/salla-wishlist-summary.entry.js +2 -2
- package/dist/esm/twilight.js +3 -3
- package/dist/esm/{vanilla-picker-BlIXJyvJ.js → vanilla-picker-CAeu4f87.js} +1 -1
- package/dist/twilight/{p-84d725d4.entry.js → p-01d5cd61.entry.js} +1 -1
- package/dist/twilight/{p-60f4357f.entry.js → p-0213fde4.entry.js} +1 -1
- package/dist/twilight/{p-8f0af317.entry.js → p-036fbfc0.entry.js} +1 -1
- package/dist/twilight/{p-90d4129f.entry.js → p-0add41ce.entry.js} +1 -1
- package/dist/twilight/{p-fed66bcb.entry.js → p-0b0d4942.entry.js} +1 -1
- package/dist/twilight/{p-86ca22d5.entry.js → p-17bcbf9b.entry.js} +1 -1
- package/dist/twilight/{p-b66df976.entry.js → p-1867f7d4.entry.js} +1 -1
- package/dist/twilight/p-194ff38c.entry.js +4 -0
- package/dist/twilight/{p-4057b692.entry.js → p-20f9c62f.entry.js} +1 -1
- package/dist/twilight/{p-783c6346.entry.js → p-252748d9.entry.js} +1 -1
- package/dist/twilight/{p-3d5e862c.entry.js → p-290ce0bc.entry.js} +1 -1
- package/dist/twilight/{p-d68625f7.entry.js → p-2b930157.entry.js} +1 -1
- package/dist/twilight/{p-184ea04c.entry.js → p-2e4e15c5.entry.js} +1 -1
- package/dist/twilight/p-2e6537a3.entry.js +4 -0
- package/dist/twilight/{p-2a3e2404.entry.js → p-30d64bd1.entry.js} +1 -1
- package/dist/twilight/{p-5d4fadd2.entry.js → p-32495dd2.entry.js} +1 -1
- package/dist/twilight/{p-cd7029fc.entry.js → p-32d9da31.entry.js} +1 -1
- package/dist/twilight/{p-7e854633.entry.js → p-32f100f8.entry.js} +1 -1
- package/dist/twilight/{p-dc3ff1f0.entry.js → p-386b3dcd.entry.js} +1 -1
- package/dist/twilight/{p-e8090773.entry.js → p-3a4e86d1.entry.js} +1 -1
- package/dist/twilight/{p-a0a57259.entry.js → p-3b766a79.entry.js} +1 -1
- package/dist/twilight/{p-a5d2ad5e.entry.js → p-3b7a45ec.entry.js} +1 -1
- package/dist/twilight/{p-33ff7967.entry.js → p-3bb0e184.entry.js} +1 -1
- package/dist/twilight/{p-8b39a9f7.entry.js → p-3cc6ca6c.entry.js} +1 -1
- package/dist/twilight/{p-0a794d6f.entry.js → p-4070f808.entry.js} +1 -1
- package/dist/twilight/{p-d2c1457e.entry.js → p-412fb721.entry.js} +1 -1
- package/dist/twilight/{p-fce39869.entry.js → p-427c13b6.entry.js} +1 -1
- package/dist/twilight/{p-49195cb6.entry.js → p-45e0a5d0.entry.js} +1 -1
- package/dist/twilight/{p-cd866be6.entry.js → p-4d615f9f.entry.js} +1 -1
- package/dist/twilight/{p-4f794057.entry.js → p-4d7fc363.entry.js} +1 -1
- package/dist/twilight/{p-9eb92980.entry.js → p-5009f654.entry.js} +1 -1
- package/dist/twilight/{p-f4411a04.entry.js → p-50853b76.entry.js} +1 -1
- package/dist/twilight/{p-b9695308.entry.js → p-550ad1a6.entry.js} +1 -1
- package/dist/twilight/{p-4839d408.entry.js → p-575014c4.entry.js} +1 -1
- package/dist/twilight/{p-f10b887a.entry.js → p-5aee5e44.entry.js} +1 -1
- package/dist/twilight/{p-622bfb21.entry.js → p-619c709c.entry.js} +1 -1
- package/dist/twilight/{p-74f206cf.entry.js → p-6d572fe0.entry.js} +1 -1
- package/dist/twilight/{p-26fec98c.entry.js → p-6f84c662.entry.js} +1 -1
- package/dist/twilight/{p-4a1aa85f.entry.js → p-703b9253.entry.js} +1 -1
- package/dist/twilight/{p-509ad773.entry.js → p-73dea22d.entry.js} +1 -1
- package/dist/twilight/{p-6c7cae8a.entry.js → p-74285af9.entry.js} +1 -1
- package/dist/twilight/{p-31260fae.entry.js → p-777d28f6.entry.js} +1 -1
- package/dist/twilight/{p-4702959a.entry.js → p-7db6ccfe.entry.js} +1 -1
- package/dist/twilight/{p-e89a1905.entry.js → p-7db8d545.entry.js} +1 -1
- package/dist/twilight/{p-0c6a024f.entry.js → p-7fa4d0b6.entry.js} +1 -1
- package/dist/twilight/{p-2e8f95d0.entry.js → p-825c5b73.entry.js} +1 -1
- package/dist/twilight/{p-e5545546.entry.js → p-8262e669.entry.js} +1 -1
- package/dist/twilight/{p-bab5d057.entry.js → p-86d55a6b.entry.js} +1 -1
- package/dist/twilight/{p-0225f396.entry.js → p-8712f7c7.entry.js} +1 -1
- package/dist/twilight/{p-a53e2c74.entry.js → p-8948b58c.entry.js} +1 -1
- package/dist/twilight/{p-37b68ef3.entry.js → p-8b8cf457.entry.js} +1 -1
- package/dist/twilight/{p-8e8e40bc.entry.js → p-8c2992e7.entry.js} +1 -1
- package/dist/twilight/{p-eb160c2e.entry.js → p-8c548259.entry.js} +1 -1
- package/dist/twilight/{p-5d775867.entry.js → p-8eb3fd92.entry.js} +1 -1
- package/dist/twilight/p-908716fb.entry.js +4 -0
- package/dist/twilight/{p-62ba0971.entry.js → p-90a59027.entry.js} +1 -1
- package/dist/twilight/{p-ae9c0abe.entry.js → p-9683535f.entry.js} +1 -1
- package/dist/twilight/{p-89cff0c8.entry.js → p-982e9124.entry.js} +1 -1
- package/dist/twilight/{p-a17784e6.entry.js → p-995b898f.entry.js} +1 -1
- package/dist/twilight/{p-3a3d4cb7.entry.js → p-99cb3dba.entry.js} +1 -1
- package/dist/twilight/{p-6757344a.entry.js → p-9a0218a6.entry.js} +1 -1
- package/dist/twilight/{p-7d337f25.entry.js → p-9cf31ff4.entry.js} +1 -1
- package/dist/twilight/{p-d495cce0.entry.js → p-9d1a5007.entry.js} +1 -1
- package/dist/twilight/{p-57b93850.entry.js → p-9e429047.entry.js} +1 -1
- package/dist/twilight/{p-40083f25.entry.js → p-9e542951.entry.js} +1 -1
- package/dist/twilight/{p-Dhq3oJAe.js → p-BcT9tEVW.js} +1 -1
- package/dist/twilight/{p-Dza6OBFg.js → p-Bgu5gtOF.js} +1 -1
- package/dist/twilight/p-C9zdeQFI.js +5 -0
- package/dist/twilight/{p-BbZqYBfp.js → p-CSGj1pY-.js} +1 -1
- package/dist/twilight/{p-Nyk6-1lq.js → p-CWWgpQ8Q.js} +1 -1
- package/dist/twilight/{p-BwzmoZpm.js → p-Cfz9xit3.js} +1 -1
- package/dist/twilight/{p-iCJI7qYe.js → p-CmYSalnM.js} +1 -1
- package/dist/twilight/p-CnTwkF6y.js +4 -0
- package/dist/twilight/p-Cnh7Qptl.js +4 -0
- package/dist/twilight/{p-DVWVl151.js → p-Dav_R_d2.js} +1 -1
- package/dist/twilight/{p-B7rn1taO.js → p-JGEddAgs.js} +1 -1
- package/dist/twilight/{p-CAc7tX2K.js → p-RflSBQNB.js} +1 -1
- package/dist/twilight/{p-De2wEjqS.js → p-Xgbueas7.js} +1 -1
- package/dist/twilight/{p-64d49f5d.entry.js → p-a070cce0.entry.js} +1 -1
- package/dist/twilight/p-a0bfedad.entry.js +4 -0
- package/dist/twilight/{p-bf29daf3.entry.js → p-a22d9931.entry.js} +1 -1
- package/dist/twilight/{p-2153c6fd.entry.js → p-a3959219.entry.js} +1 -1
- package/dist/twilight/p-a3ca61af.entry.js +4 -0
- package/dist/twilight/{p-0e1248c4.entry.js → p-a55b5c44.entry.js} +1 -1
- package/dist/twilight/{p-24423a8d.entry.js → p-a5fc8358.entry.js} +1 -1
- package/dist/twilight/{p-66f6d722.entry.js → p-aabcd09f.entry.js} +1 -1
- package/dist/twilight/{p-4c801f91.entry.js → p-ad00021e.entry.js} +1 -1
- package/dist/twilight/{p-fae2a8d0.entry.js → p-ade9a68c.entry.js} +1 -1
- package/dist/twilight/{p-83ccad19.entry.js → p-b5e0065a.entry.js} +1 -1
- package/dist/twilight/{p-2a8d6e7e.entry.js → p-bbb09d92.entry.js} +1 -1
- package/dist/twilight/{p-f034968b.entry.js → p-c2df20f8.entry.js} +1 -1
- package/dist/twilight/{p-b38c38fe.entry.js → p-c4274188.entry.js} +1 -1
- package/dist/twilight/{p-d63ce284.entry.js → p-c5e2c781.entry.js} +1 -1
- package/dist/twilight/{p-07450aed.entry.js → p-c64b2b22.entry.js} +1 -1
- package/dist/twilight/{p-14752d03.entry.js → p-c92cc92f.entry.js} +1 -1
- package/dist/twilight/{p-d6c5bf2a.entry.js → p-cb54adac.entry.js} +1 -1
- package/dist/twilight/{p-7750bace.entry.js → p-ce1e45a3.entry.js} +1 -1
- package/dist/twilight/{p-e4d90663.entry.js → p-d0acd7ff.entry.js} +1 -1
- package/dist/twilight/{p-f9b9af72.entry.js → p-d0f903ac.entry.js} +1 -1
- package/dist/twilight/{p-7df4ee74.entry.js → p-d57b49ff.entry.js} +1 -1
- package/dist/twilight/p-db3efb27.entry.js +4 -0
- package/dist/twilight/{p-e81c4521.entry.js → p-db73d0bf.entry.js} +1 -1
- package/dist/twilight/{p-bfb70998.entry.js → p-e20d5e75.entry.js} +1 -1
- package/dist/twilight/{p-1982520c.entry.js → p-e223beca.entry.js} +1 -1
- package/dist/twilight/{p-20939237.entry.js → p-e37da59f.entry.js} +1 -1
- package/dist/twilight/p-e3991836.entry.js +4 -0
- package/dist/twilight/{p-fe413496.entry.js → p-e455709f.entry.js} +1 -1
- package/dist/twilight/{p-cc2c52bb.entry.js → p-e921b2d1.entry.js} +1 -1
- package/dist/twilight/{p-acd48ae7.entry.js → p-ec356e5a.entry.js} +1 -1
- package/dist/twilight/{p-7a985c8c.entry.js → p-eeefc285.entry.js} +1 -1
- package/dist/twilight/{p-120b4694.entry.js → p-f3b12754.entry.js} +1 -1
- package/dist/twilight/{p-c3c99d9e.entry.js → p-f6279a13.entry.js} +1 -1
- package/dist/twilight/{p-b819de23.entry.js → p-f83efc62.entry.js} +1 -1
- package/dist/twilight/{p-8b43035f.entry.js → p-fa622715.entry.js} +1 -1
- package/dist/twilight/{p-b87ea253.entry.js → p-faf00404.entry.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-bullet-delivery/api-service.d.ts +23 -7
- package/dist/types/components/salla-bullet-delivery/helpers.d.ts +61 -6
- package/dist/types/components/salla-bullet-delivery/icons.d.ts +14 -0
- package/dist/types/components/salla-bullet-delivery/interfaces.d.ts +36 -1
- package/dist/types/components/salla-bullet-delivery/salla-bullet-delivery.d.ts +82 -3
- package/dist/types/components/salla-bullet-delivery/selector-tracker.d.ts +30 -0
- package/dist/types/components/salla-free-shipping-banner/salla-free-shipping-banner.d.ts +19 -5
- package/dist/types/components/salla-free-shipping-tag/salla-free-shipping-tag.d.ts +6 -1
- package/dist/types/components/salla-gifting/salla-gifting.d.ts +1 -0
- package/dist/types/components/salla-quick-buy/salla-quick-buy.d.ts +6 -0
- package/dist/types/components/salla-rating-modal/salla-rating-modal-v2.d.ts +1 -0
- package/dist/types/components.d.ts +11 -25
- package/dist/types/shared/free-shipping-timer.d.ts +36 -0
- package/package.json +5 -5
- package/dist/cjs/free-shipping-DkIKD6ch.js +0 -31
- package/dist/cjs/helpers-8bMfm_mm.js +0 -329
- package/dist/components/free-shipping.js +0 -29
- package/dist/esm/free-shipping-Brg4wsgg.js +0 -29
- package/dist/esm/helpers-DqzaeXrL.js +0 -309
- package/dist/twilight/p-12a8aed8.entry.js +0 -4
- package/dist/twilight/p-4f443e36.entry.js +0 -4
- package/dist/twilight/p-5b81a3d9.entry.js +0 -4
- package/dist/twilight/p-93f26336.entry.js +0 -4
- package/dist/twilight/p-Brg4wsgg.js +0 -4
- package/dist/twilight/p-DmGAR42j.js +0 -5
- package/dist/twilight/p-DqzaeXrL.js +0 -4
- package/dist/twilight/p-c7c868b4.entry.js +0 -4
- package/dist/twilight/p-d5a2ba68.entry.js +0 -4
- package/dist/twilight/p-f8ff074f.entry.js +0 -4
|
@@ -65,6 +65,7 @@ export class SallaRatingModalV2 {
|
|
|
65
65
|
this.stepsCount = 0;
|
|
66
66
|
this.currentIndex = 0;
|
|
67
67
|
this.submitted = [];
|
|
68
|
+
this.isSubmitting = false;
|
|
68
69
|
this.thanksCountdownInterval = null;
|
|
69
70
|
this.MAX_IMAGE_UPLOAD_LIMIT = MAX_IMAGE_UPLOAD_LIMIT;
|
|
70
71
|
this.MAX_VIDEO_UPLOAD_LIMIT = MAX_VIDEO_UPLOAD_LIMIT;
|
|
@@ -577,10 +578,11 @@ export class SallaRatingModalV2 {
|
|
|
577
578
|
this.showActiveStep();
|
|
578
579
|
}
|
|
579
580
|
async submit() {
|
|
580
|
-
if (this.hasUploadsInProgress)
|
|
581
|
+
if (this.hasUploadsInProgress || this.isSubmitting)
|
|
581
582
|
return;
|
|
582
|
-
this.
|
|
583
|
+
this.isSubmitting = true;
|
|
583
584
|
try {
|
|
585
|
+
this.refreshWizardRefs();
|
|
584
586
|
if (!this.submittedBefore()) {
|
|
585
587
|
this.validate();
|
|
586
588
|
}
|
|
@@ -603,6 +605,7 @@ export class SallaRatingModalV2 {
|
|
|
603
605
|
}
|
|
604
606
|
}
|
|
605
607
|
finally {
|
|
608
|
+
this.isSubmitting = false;
|
|
606
609
|
this.nextBtn?.stop();
|
|
607
610
|
salla.config.canLeave = true;
|
|
608
611
|
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
const HOUR = 60 * 60 * 1000;
|
|
5
|
+
const DAY = 24 * HOUR;
|
|
6
|
+
const MAX_TIMEOUT = 2 ** 31 - 1;
|
|
7
|
+
// Used only when storage is not available (private mode, blocked site data).
|
|
8
|
+
let memoryStartedAt = null;
|
|
9
|
+
const DEFAULT_COUNTDOWN_HOURS = 45;
|
|
10
|
+
const DEFAULT_HIDDEN_DAYS = 7;
|
|
11
|
+
const positive = (value, fallback) => {
|
|
12
|
+
const number = Number(value);
|
|
13
|
+
return Number.isFinite(number) && number > 0 ? number : fallback;
|
|
14
|
+
};
|
|
15
|
+
/** The countdown and hidden period, from the store settings with 45 hours and 7 days as the fallback. */
|
|
16
|
+
export function getTimerSettings() {
|
|
17
|
+
const settings = salla.config?.get?.('store.settings.free_shipping_banner');
|
|
18
|
+
return {
|
|
19
|
+
countdownMs: positive(settings?.countdown_hours, DEFAULT_COUNTDOWN_HOURS) * HOUR,
|
|
20
|
+
hiddenMs: positive(settings?.hidden_days, DEFAULT_HIDDEN_DAYS) * DAY,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** The timer exists only for visitors the backend allowed the banner for. */
|
|
24
|
+
export function isTimerEnabled() {
|
|
25
|
+
return !!salla.config?.get?.('store.features')?.includes('free-shipping-banner');
|
|
26
|
+
}
|
|
27
|
+
const storageKey = () => `free-shipping-timer_${salla.config?.get?.('store.id')}`;
|
|
28
|
+
/** When the visitor first saw the banner, or null if they have not yet. */
|
|
29
|
+
export function getStartedAt() {
|
|
30
|
+
try {
|
|
31
|
+
const stored = Number(salla.storage.get(storageKey()));
|
|
32
|
+
if (Number.isFinite(stored) && stored > 0) {
|
|
33
|
+
return stored;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
// fall through to the in-memory value
|
|
38
|
+
}
|
|
39
|
+
return memoryStartedAt;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Records the first time the visitor saw the banner. Does nothing when it is already recorded
|
|
43
|
+
* or when the feature is off.
|
|
44
|
+
*/
|
|
45
|
+
export function startTimerIfNeeded(now = Date.now()) {
|
|
46
|
+
if (!isTimerEnabled()) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const existing = getStartedAt();
|
|
50
|
+
if (existing) {
|
|
51
|
+
return existing;
|
|
52
|
+
}
|
|
53
|
+
memoryStartedAt = now;
|
|
54
|
+
try {
|
|
55
|
+
salla.storage.set(storageKey(), now);
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
// keep the in-memory value
|
|
59
|
+
}
|
|
60
|
+
schedule();
|
|
61
|
+
notify();
|
|
62
|
+
return now;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Where the visitor is in the repeating cycle: `countdown` visible, then `hidden` hidden, again and again.
|
|
66
|
+
* Nothing but the first-seen time is stored, so changed settings apply on the next check.
|
|
67
|
+
*/
|
|
68
|
+
export function computeTimerState(startedAt, now, countdownMs, hiddenMs) {
|
|
69
|
+
const elapsed = Math.max(0, now - startedAt);
|
|
70
|
+
const position = elapsed % (countdownMs + hiddenMs);
|
|
71
|
+
if (position < countdownMs) {
|
|
72
|
+
return { visible: true, remainingMs: countdownMs - position, nextChangeMs: countdownMs - position };
|
|
73
|
+
}
|
|
74
|
+
return { visible: false, remainingMs: 0, nextChangeMs: countdownMs + hiddenMs - position };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The state the banner and tags follow. `null` means there is nothing to follow: the feature is off
|
|
78
|
+
* or the visitor has not seen the banner yet.
|
|
79
|
+
*/
|
|
80
|
+
export function getFreeShippingTimerState(now = Date.now()) {
|
|
81
|
+
if (!isTimerEnabled()) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const startedAt = getStartedAt();
|
|
85
|
+
if (!startedAt) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const { countdownMs, hiddenMs } = getTimerSettings();
|
|
89
|
+
return computeTimerState(startedAt, now, countdownMs, hiddenMs);
|
|
90
|
+
}
|
|
91
|
+
const listeners = new Set();
|
|
92
|
+
let timeout;
|
|
93
|
+
function notify() {
|
|
94
|
+
listeners.forEach((listener) => listener());
|
|
95
|
+
}
|
|
96
|
+
// One timeout for the whole page, set for the next visible/hidden change.
|
|
97
|
+
function schedule() {
|
|
98
|
+
clearTimeout(timeout);
|
|
99
|
+
timeout = undefined;
|
|
100
|
+
if (!listeners.size) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const state = getFreeShippingTimerState();
|
|
104
|
+
if (!state) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
timeout = setTimeout(() => {
|
|
108
|
+
notify();
|
|
109
|
+
schedule();
|
|
110
|
+
}, Math.min(state.nextChangeMs + 50, MAX_TIMEOUT));
|
|
111
|
+
}
|
|
112
|
+
/** Calls back whenever the banner and tags have to show or hide. Returns the unsubscribe function. */
|
|
113
|
+
export function subscribeToFreeShippingTimer(listener) {
|
|
114
|
+
listeners.add(listener);
|
|
115
|
+
schedule();
|
|
116
|
+
return () => {
|
|
117
|
+
listeners.delete(listener);
|
|
118
|
+
if (!listeners.size) {
|
|
119
|
+
clearTimeout(timeout);
|
|
120
|
+
timeout = undefined;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/** Test helper. */
|
|
125
|
+
export function resetFreeShippingTimer() {
|
|
126
|
+
memoryStartedAt = null;
|
|
127
|
+
listeners.clear();
|
|
128
|
+
clearTimeout(timeout);
|
|
129
|
+
timeout = undefined;
|
|
130
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
const cache = new Map();
|
|
5
|
+
async function request(productId) {
|
|
6
|
+
const endpoint = 'products/eligible-for-free-shipping' + (productId ? `/${productId}` : '');
|
|
7
|
+
try {
|
|
8
|
+
// 403 (feature off or plan not supported) and 410 (product gone) mean "not eligible",
|
|
9
|
+
// not a failure worth a toast.
|
|
10
|
+
const response = await salla.api.withoutNotifier(() => salla.api.request(endpoint));
|
|
11
|
+
return response?.data?.eligible === true;
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Whether free shipping applies: to the store when no product is given (banner),
|
|
19
|
+
* or to the product (tag, product page banner). Same calls share one request.
|
|
20
|
+
*/
|
|
21
|
+
function isEligibleForFreeShipping(productId) {
|
|
22
|
+
const key = String(productId ?? '');
|
|
23
|
+
if (!cache.has(key)) {
|
|
24
|
+
cache.set(key, request(productId));
|
|
25
|
+
}
|
|
26
|
+
return cache.get(key);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const HOUR = 60 * 60 * 1000;
|
|
30
|
+
const DAY = 24 * HOUR;
|
|
31
|
+
const MAX_TIMEOUT = 2 ** 31 - 1;
|
|
32
|
+
// Used only when storage is not available (private mode, blocked site data).
|
|
33
|
+
let memoryStartedAt = null;
|
|
34
|
+
const DEFAULT_COUNTDOWN_HOURS = 45;
|
|
35
|
+
const DEFAULT_HIDDEN_DAYS = 7;
|
|
36
|
+
const positive = (value, fallback) => {
|
|
37
|
+
const number = Number(value);
|
|
38
|
+
return Number.isFinite(number) && number > 0 ? number : fallback;
|
|
39
|
+
};
|
|
40
|
+
/** The countdown and hidden period, from the store settings with 45 hours and 7 days as the fallback. */
|
|
41
|
+
function getTimerSettings() {
|
|
42
|
+
const settings = salla.config?.get?.('store.settings.free_shipping_banner');
|
|
43
|
+
return {
|
|
44
|
+
countdownMs: positive(settings?.countdown_hours, DEFAULT_COUNTDOWN_HOURS) * HOUR,
|
|
45
|
+
hiddenMs: positive(settings?.hidden_days, DEFAULT_HIDDEN_DAYS) * DAY,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** The timer exists only for visitors the backend allowed the banner for. */
|
|
49
|
+
function isTimerEnabled() {
|
|
50
|
+
return !!salla.config?.get?.('store.features')?.includes('free-shipping-banner');
|
|
51
|
+
}
|
|
52
|
+
const storageKey = () => `free-shipping-timer_${salla.config?.get?.('store.id')}`;
|
|
53
|
+
/** When the visitor first saw the banner, or null if they have not yet. */
|
|
54
|
+
function getStartedAt() {
|
|
55
|
+
try {
|
|
56
|
+
const stored = Number(salla.storage.get(storageKey()));
|
|
57
|
+
if (Number.isFinite(stored) && stored > 0) {
|
|
58
|
+
return stored;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
// fall through to the in-memory value
|
|
63
|
+
}
|
|
64
|
+
return memoryStartedAt;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Records the first time the visitor saw the banner. Does nothing when it is already recorded
|
|
68
|
+
* or when the feature is off.
|
|
69
|
+
*/
|
|
70
|
+
function startTimerIfNeeded(now = Date.now()) {
|
|
71
|
+
if (!isTimerEnabled()) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const existing = getStartedAt();
|
|
75
|
+
if (existing) {
|
|
76
|
+
return existing;
|
|
77
|
+
}
|
|
78
|
+
memoryStartedAt = now;
|
|
79
|
+
try {
|
|
80
|
+
salla.storage.set(storageKey(), now);
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
// keep the in-memory value
|
|
84
|
+
}
|
|
85
|
+
schedule();
|
|
86
|
+
notify();
|
|
87
|
+
return now;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Where the visitor is in the repeating cycle: `countdown` visible, then `hidden` hidden, again and again.
|
|
91
|
+
* Nothing but the first-seen time is stored, so changed settings apply on the next check.
|
|
92
|
+
*/
|
|
93
|
+
function computeTimerState(startedAt, now, countdownMs, hiddenMs) {
|
|
94
|
+
const elapsed = Math.max(0, now - startedAt);
|
|
95
|
+
const position = elapsed % (countdownMs + hiddenMs);
|
|
96
|
+
if (position < countdownMs) {
|
|
97
|
+
return { visible: true, remainingMs: countdownMs - position, nextChangeMs: countdownMs - position };
|
|
98
|
+
}
|
|
99
|
+
return { visible: false, remainingMs: 0, nextChangeMs: countdownMs + hiddenMs - position };
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The state the banner and tags follow. `null` means there is nothing to follow: the feature is off
|
|
103
|
+
* or the visitor has not seen the banner yet.
|
|
104
|
+
*/
|
|
105
|
+
function getFreeShippingTimerState(now = Date.now()) {
|
|
106
|
+
if (!isTimerEnabled()) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const startedAt = getStartedAt();
|
|
110
|
+
if (!startedAt) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
const { countdownMs, hiddenMs } = getTimerSettings();
|
|
114
|
+
return computeTimerState(startedAt, now, countdownMs, hiddenMs);
|
|
115
|
+
}
|
|
116
|
+
const listeners = new Set();
|
|
117
|
+
let timeout;
|
|
118
|
+
function notify() {
|
|
119
|
+
listeners.forEach((listener) => listener());
|
|
120
|
+
}
|
|
121
|
+
// One timeout for the whole page, set for the next visible/hidden change.
|
|
122
|
+
function schedule() {
|
|
123
|
+
clearTimeout(timeout);
|
|
124
|
+
timeout = undefined;
|
|
125
|
+
if (!listeners.size) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const state = getFreeShippingTimerState();
|
|
129
|
+
if (!state) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
timeout = setTimeout(() => {
|
|
133
|
+
notify();
|
|
134
|
+
schedule();
|
|
135
|
+
}, Math.min(state.nextChangeMs + 50, MAX_TIMEOUT));
|
|
136
|
+
}
|
|
137
|
+
/** Calls back whenever the banner and tags have to show or hide. Returns the unsubscribe function. */
|
|
138
|
+
function subscribeToFreeShippingTimer(listener) {
|
|
139
|
+
listeners.add(listener);
|
|
140
|
+
schedule();
|
|
141
|
+
return () => {
|
|
142
|
+
listeners.delete(listener);
|
|
143
|
+
if (!listeners.size) {
|
|
144
|
+
clearTimeout(timeout);
|
|
145
|
+
timeout = undefined;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export { isTimerEnabled as a, subscribeToFreeShippingTimer as b, getFreeShippingTimerState as g, isEligibleForFreeShipping as i, startTimerIfNeeded as s };
|