@salla.sa/twilight-components 2.14.427 → 2.14.429
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-CnPKR-6x.js → filepond--V9rRgVA.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-D0g6EUyA.js → filepond-plugin-file-poster-DzvswSJb.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-DXUJ6UPq.js → filepond-plugin-file-validate-size-C5wUWXz6.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-NgEbyq_W.js → filepond-plugin-file-validate-type-HA2w2_fC.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-DU4QWlEV.js → filepond-plugin-image-edit-CXrhd-IB.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-xYuPxwvc.js → filepond-plugin-image-exif-orientation-BJnamgw6.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-CY_efZwj.js → filepond-plugin-image-preview-CmdkZJij.js} +1 -1
- package/dist/cjs/{functions-CTufnsoC.js → functions-DPnm948J.js} +1 -1
- package/dist/cjs/{index-BEj17I33.js → index-D3xsx646.js} +6 -6
- package/dist/cjs/{index-Z8F5J-RV.js → index-DRfjMaC1.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 +3 -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-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-badge.cjs.entry.js +1 -1
- package/dist/cjs/salla-booking-field_7.cjs.entry.js +17 -17
- package/dist/cjs/{salla-bullet-delivery.cjs.entry.js → salla-bullet-delivery_2.cjs.entry.js} +635 -140
- package/dist/cjs/salla-cart-coupons.cjs.entry.js +2 -2
- package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +2 -2
- package/dist/cjs/salla-comment-form_8.cjs.entry.js +8 -8
- 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 +2 -2
- package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
- package/dist/cjs/salla-delivery-promise.cjs.entry.js +43 -17
- package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +3 -3
- package/dist/cjs/salla-filters.cjs.entry.js +2 -2
- package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +2 -2
- package/dist/cjs/salla-gifting.cjs.entry.js +3 -3
- package/dist/cjs/salla-hook.cjs.entry.js +2 -2
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-list-tile.cjs.entry.js +2 -2
- package/dist/cjs/salla-localization-modal.cjs.entry.js +2 -2
- package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-banner.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty-hero_2.cjs.entry.js +8 -8
- package/dist/cjs/salla-loyalty-panel.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-reward.cjs.entry.js +4 -4
- package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
- package/dist/cjs/salla-maintenance-alert.cjs.entry.js +2 -2
- package/dist/cjs/salla-map.cjs.entry.js +4 -4
- 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 +4 -4
- package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +6 -6
- package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +2 -2
- package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +2 -2
- package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer-modal.cjs.entry.js +2 -2
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +2 -2
- package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +2 -2
- package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-summary.cjs.entry.js +2 -2
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +1 -1
- package/dist/cjs/salla-payments.cjs.entry.js +3 -3
- package/dist/cjs/salla-placeholder.cjs.entry.js +2 -2
- package/dist/cjs/salla-price-range.cjs.entry.js +3 -3
- package/dist/cjs/salla-product-card_2.cjs.entry.js +6 -6
- package/dist/cjs/salla-product-size-guide.cjs.entry.js +3 -3
- package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
- package/dist/cjs/salla-progress-bar.cjs.entry.js +1 -1
- package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-reward-action_4.cjs.entry.js +11 -11
- package/dist/cjs/salla-scopes.cjs.entry.js +2 -2
- package/dist/cjs/salla-search.cjs.entry.js +6 -6
- package/dist/cjs/salla-skeleton.cjs.entry.js +2 -2
- package/dist/cjs/salla-slider.cjs.entry.js +1 -1
- package/dist/cjs/salla-social-share.cjs.entry.js +2 -2
- package/dist/cjs/salla-social.cjs.entry.js +2 -2
- package/dist/cjs/salla-tab-content_3.cjs.entry.js +4 -4
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-tooltip.cjs.entry.js +2 -2
- 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 +2 -2
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/{tracked-promise-C_10lCIK.js → tracked-promise-CFp5Besf.js} +1 -1
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/cjs/{vanilla-picker-D9nRSUSv.js → vanilla-picker-Jk2F9CAy.js} +1 -1
- package/dist/collection/collection-manifest.json +7 -0
- package/dist/collection/components/salla-bullet-delivery/api-service.js +80 -13
- package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.css +5 -0
- package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.js +344 -120
- package/dist/collection/components/salla-cart-coupons/salla-cart-coupons.js +1 -1
- package/dist/collection/components/salla-cart-summary/salla-cart-summary.js +1 -1
- package/dist/collection/components/salla-color-picker/salla-color-picker.js +1 -1
- package/dist/collection/components/salla-comment-form/salla-comment-form.js +1 -1
- package/dist/collection/components/salla-comments/salla-comment-item.js +3 -3
- package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.js +1 -1
- package/dist/collection/components/salla-count-down/salla-count-down.js +1 -1
- package/dist/collection/components/salla-datetime-picker/salla-datetime-picker.js +1 -1
- package/dist/collection/components/salla-delivery-promise/delivery-promise-api.js +4 -5
- package/dist/collection/components/salla-delivery-promise/salla-delivery-promise.js +40 -12
- package/dist/collection/components/salla-file-upload/salla-file-upload.js +2 -2
- package/dist/collection/components/salla-filters/salla-filters.js +1 -1
- package/dist/collection/components/salla-filters-widget/salla-filters-widget.js +2 -2
- package/dist/collection/components/salla-fulfillment-methods/salla-fulfillment-methods.js +1 -1
- package/dist/collection/components/salla-gifting/salla-gifting.js +2 -2
- package/dist/collection/components/salla-hook/salla-hook.js +1 -1
- package/dist/collection/components/salla-list-tile/salla-list-tile.js +1 -1
- package/dist/collection/components/salla-loading/salla-loading.js +1 -1
- package/dist/collection/components/salla-localization-modal/salla-localization-modal.js +1 -1
- package/dist/collection/components/salla-loyalty/salla-loyalty-prize-item.js +1 -1
- package/dist/collection/components/salla-loyalty-program/salla-loyalty-hero.js +3 -3
- package/dist/collection/components/salla-loyalty-program/salla-loyalty-point.js +3 -3
- package/dist/collection/components/salla-loyalty-program/salla-loyalty-reward.js +2 -2
- package/dist/collection/components/salla-loyalty-program/salla-reward-action.js +1 -1
- package/dist/collection/components/salla-loyalty-program/salla-reward-card.js +1 -1
- package/dist/collection/components/salla-loyalty-program/salla-reward-details.js +3 -3
- package/dist/collection/components/salla-loyalty-program/salla-reward-exchange.js +3 -3
- package/dist/collection/components/salla-maintenance-alert/salla-maintenance-alert.js +1 -1
- package/dist/collection/components/salla-map/salla-map.js +3 -3
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-cart.js +1 -1
- 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 +4 -4
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-slider.js +1 -1
- package/dist/collection/components/salla-multiple-bundle-product/salla-multiple-bundle-product.js +1 -1
- package/dist/collection/components/salla-notifications/salla-notification-item.js +1 -1
- package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +1 -1
- package/dist/collection/components/salla-order-details/salla-order-details.js +1 -1
- package/dist/collection/components/salla-order-edit/salla-order-edit-product-card.js +1 -1
- package/dist/collection/components/salla-order-summary/salla-order-summary.js +1 -1
- package/dist/collection/components/salla-payments/salla-payments.js +2 -2
- package/dist/collection/components/salla-placeholder/salla-placeholder.js +1 -1
- package/dist/collection/components/salla-price-range/salla-price-range.js +2 -2
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +1 -1
- package/dist/collection/components/salla-product-card/salla-product-card.js +5 -5
- package/dist/collection/components/salla-product-size-guide/salla-product-size-guide.js +2 -2
- package/dist/collection/components/salla-quantity-input/salla-quantity-input.js +1 -1
- package/dist/collection/components/salla-quick-buy/salla-quick-buy.js +1 -1
- package/dist/collection/components/salla-review-card/salla-review-card.js +1 -1
- package/dist/collection/components/salla-reviews/salla-reviews.js +1 -1
- package/dist/collection/components/salla-reviews-page/salla-reviews-page.js +1 -1
- package/dist/collection/components/salla-scopes/salla-scopes.js +1 -1
- package/dist/collection/components/salla-search/salla-search.js +5 -5
- package/dist/collection/components/salla-searchable-dropdown/interfaces.js +1 -0
- package/dist/collection/components/salla-searchable-dropdown/salla-searchable-dropdown.js +566 -0
- package/dist/collection/components/salla-skeleton/salla-skeleton.js +1 -1
- package/dist/collection/components/salla-social/salla-social.js +1 -1
- package/dist/collection/components/salla-social-share/salla-social-share.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tab-content.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tab-header.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tabs.js +1 -1
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +1 -1
- package/dist/collection/components/salla-tooltip/salla-tooltip.js +1 -1
- package/dist/collection/components/salla-user-settings/salla-user-settings.js +1 -1
- package/dist/components/index.js +2 -2
- package/dist/components/salla-bullet-delivery.js +445 -148
- package/dist/components/salla-cart-coupons.js +1 -1
- package/dist/components/salla-cart-summary.js +1 -1
- package/dist/components/salla-color-picker2.js +1 -1
- package/dist/components/salla-comment-form2.js +1 -1
- package/dist/components/salla-comment-item2.js +3 -3
- package/dist/components/salla-conditional-fields2.js +1 -1
- package/dist/components/salla-count-down2.js +1 -1
- package/dist/components/salla-datetime-picker2.js +1 -1
- package/dist/components/salla-delivery-promise.js +42 -16
- package/dist/components/salla-file-upload2.js +2 -2
- package/dist/components/salla-filters-widget2.js +2 -2
- package/dist/components/salla-filters.js +1 -1
- package/dist/components/salla-fulfillment-methods.js +1 -1
- package/dist/components/salla-gifting.js +2 -2
- package/dist/components/salla-hook.js +1 -1
- package/dist/components/salla-list-tile2.js +1 -1
- package/dist/components/salla-loading2.js +1 -1
- package/dist/components/salla-localization-modal.js +1 -1
- package/dist/components/salla-loyalty-hero2.js +3 -3
- package/dist/components/salla-loyalty-point2.js +3 -3
- package/dist/components/salla-loyalty-prize-item.js +1 -1
- package/dist/components/salla-loyalty-reward.js +2 -2
- package/dist/components/salla-maintenance-alert.js +1 -1
- package/dist/components/salla-map2.js +3 -3
- package/dist/components/salla-multiple-bundle-product-cart2.js +1 -1
- package/dist/components/salla-multiple-bundle-product-details2.js +2 -2
- package/dist/components/salla-multiple-bundle-product-options-modal2.js +4 -4
- package/dist/components/salla-multiple-bundle-product-slider2.js +1 -1
- package/dist/components/salla-multiple-bundle-product.js +1 -1
- package/dist/components/salla-notification-item2.js +1 -1
- package/dist/components/salla-offer-modal.js +1 -1
- package/dist/components/salla-order-details.js +1 -1
- package/dist/components/salla-order-edit-product-card.js +1 -1
- package/dist/components/salla-order-summary.js +1 -1
- package/dist/components/salla-payments.js +2 -2
- package/dist/components/salla-placeholder2.js +1 -1
- package/dist/components/salla-price-range2.js +2 -2
- package/dist/components/salla-product-availability2.js +1 -1
- package/dist/components/salla-product-card2.js +5 -5
- package/dist/components/salla-product-size-guide.js +2 -2
- package/dist/components/salla-quantity-input2.js +1 -1
- package/dist/components/salla-quick-buy2.js +1 -1
- package/dist/components/salla-review-card2.js +1 -1
- package/dist/components/salla-reviews-page.js +1 -1
- package/dist/components/salla-reviews.js +1 -1
- package/dist/components/salla-reward-action2.js +1 -1
- package/dist/components/salla-reward-card2.js +1 -1
- package/dist/components/salla-reward-details2.js +3 -3
- package/dist/components/salla-reward-exchange2.js +3 -3
- package/dist/components/salla-scopes.js +1 -1
- package/dist/components/salla-search.js +5 -5
- package/dist/components/salla-searchable-dropdown.d.ts +11 -0
- package/dist/components/salla-searchable-dropdown.js +9 -0
- package/dist/components/salla-searchable-dropdown2.js +255 -0
- package/dist/components/salla-skeleton2.js +1 -1
- package/dist/components/salla-social-share.js +1 -1
- package/dist/components/salla-social.js +1 -1
- package/dist/components/salla-tab-content2.js +1 -1
- package/dist/components/salla-tab-header2.js +1 -1
- package/dist/components/salla-tabs2.js +1 -1
- package/dist/components/salla-tel-input2.js +1 -1
- package/dist/components/salla-tooltip2.js +1 -1
- package/dist/components/salla-user-settings.js +1 -1
- package/dist/esm/{filepond-BRnZDx-B.js → filepond-fJKURtC4.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-D5fDjFO7.js → filepond-plugin-file-poster-Ll-3yUwR.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-CFvpeu0k.js → filepond-plugin-file-validate-size-2D44oWIJ.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-BhjoaDUg.js → filepond-plugin-file-validate-type-08Jawn6d.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-Cenn_Vlr.js → filepond-plugin-image-edit-DmEVMjMi.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-DC9TWqJo.js → filepond-plugin-image-exif-orientation-DJo_07yV.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-Bj9DJRFj.js → filepond-plugin-image-preview-Nd-PQAho.js} +1 -1
- package/dist/esm/{functions-DyAwfRCL.js → functions-GnOlk8am.js} +1 -1
- package/dist/esm/{index-COFXO9XT.js → index-Ba0YDJC7.js} +1 -1
- package/dist/esm/{index-2RfKl9ZG.js → index-DR8BHH7X.js} +6 -6
- 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 +3 -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-apps-icons.entry.js +1 -1
- package/dist/esm/salla-badge.entry.js +1 -1
- package/dist/esm/salla-booking-field_7.entry.js +17 -17
- package/dist/esm/{salla-bullet-delivery.entry.js → salla-bullet-delivery_2.entry.js} +635 -141
- package/dist/esm/salla-cart-coupons.entry.js +2 -2
- package/dist/esm/salla-cart-item-offers_2.entry.js +2 -2
- package/dist/esm/salla-comment-form_8.entry.js +8 -8
- 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 +2 -2
- package/dist/esm/salla-custom-fields.entry.js +1 -1
- package/dist/esm/salla-delivery-promise.entry.js +43 -17
- package/dist/esm/salla-edit-order-button.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +3 -3
- package/dist/esm/salla-filters.entry.js +2 -2
- package/dist/esm/salla-fulfillment-methods.entry.js +2 -2
- package/dist/esm/salla-gifting.entry.js +3 -3
- package/dist/esm/salla-hook.entry.js +2 -2
- package/dist/esm/salla-infinite-scroll.entry.js +1 -1
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-list-tile.entry.js +2 -2
- package/dist/esm/salla-localization-modal.entry.js +2 -2
- package/dist/esm/salla-login-modal.entry.js +1 -1
- package/dist/esm/salla-loyalty-banner.entry.js +2 -2
- package/dist/esm/salla-loyalty-hero_2.entry.js +8 -8
- package/dist/esm/salla-loyalty-panel.entry.js +3 -3
- package/dist/esm/salla-loyalty-prize-item.entry.js +2 -2
- package/dist/esm/salla-loyalty-program.entry.js +3 -3
- package/dist/esm/salla-loyalty-reward.entry.js +4 -4
- package/dist/esm/salla-loyalty.entry.js +1 -1
- package/dist/esm/salla-maintenance-alert.entry.js +2 -2
- package/dist/esm/salla-map.entry.js +4 -4
- 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 +4 -4
- package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +6 -6
- package/dist/esm/salla-multiple-bundle-product.entry.js +2 -2
- package/dist/esm/salla-next-order-coupon.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +2 -2
- package/dist/esm/salla-notifications.entry.js +1 -1
- package/dist/esm/salla-offer-modal.entry.js +2 -2
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-order-details-options.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +2 -2
- package/dist/esm/salla-order-edit-item.entry.js +1 -1
- package/dist/esm/salla-order-edit-product-card.entry.js +2 -2
- package/dist/esm/salla-order-edit.entry.js +1 -1
- package/dist/esm/salla-order-summary.entry.js +2 -2
- package/dist/esm/salla-order-totals-card.entry.js +1 -1
- package/dist/esm/salla-orders.entry.js +1 -1
- package/dist/esm/salla-payments.entry.js +3 -3
- package/dist/esm/salla-placeholder.entry.js +2 -2
- package/dist/esm/salla-price-range.entry.js +3 -3
- package/dist/esm/salla-product-card_2.entry.js +6 -6
- package/dist/esm/salla-product-size-guide.entry.js +3 -3
- package/dist/esm/salla-products-list.entry.js +1 -1
- package/dist/esm/salla-progress-bar.entry.js +1 -1
- package/dist/esm/salla-quick-order.entry.js +1 -1
- package/dist/esm/salla-rating-modal.entry.js +1 -1
- package/dist/esm/salla-reward-action_4.entry.js +11 -11
- package/dist/esm/salla-scopes.entry.js +2 -2
- package/dist/esm/salla-search.entry.js +6 -6
- package/dist/esm/salla-skeleton.entry.js +2 -2
- package/dist/esm/salla-slider.entry.js +1 -1
- package/dist/esm/salla-social-share.entry.js +2 -2
- package/dist/esm/salla-social.entry.js +2 -2
- package/dist/esm/salla-tab-content_3.entry.js +4 -4
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-tooltip.entry.js +2 -2
- 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 +2 -2
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/{tracked-promise-DjHV13KA.js → tracked-promise-BTkBmrok.js} +1 -1
- package/dist/esm/twilight.js +3 -3
- package/dist/esm/{vanilla-picker-BoRNi1fj.js → vanilla-picker-f4lmttLY.js} +1 -1
- package/dist/twilight/p-031f8d35.entry.js +4 -0
- package/dist/twilight/{p-ddb5f8e3.entry.js → p-08c6172b.entry.js} +1 -1
- package/dist/twilight/p-097e2ba0.entry.js +4 -0
- package/dist/twilight/p-0ccf332d.entry.js +4 -0
- package/dist/twilight/{p-3d7a49d9.entry.js → p-103dc47c.entry.js} +1 -1
- package/dist/twilight/{p-c4b74217.entry.js → p-1208793a.entry.js} +1 -1
- package/dist/twilight/{p-15258fe3.entry.js → p-154e782d.entry.js} +1 -1
- package/dist/twilight/{p-b64d9557.entry.js → p-19bb31a5.entry.js} +1 -1
- package/dist/twilight/{p-022144ee.entry.js → p-1c8726e2.entry.js} +1 -1
- package/dist/twilight/{p-adf96b4c.entry.js → p-1e7d16a3.entry.js} +1 -1
- package/dist/twilight/{p-b4273ea4.entry.js → p-2d705236.entry.js} +1 -1
- package/dist/twilight/{p-7106682a.entry.js → p-2e8588ca.entry.js} +1 -1
- package/dist/twilight/{p-fb1b997d.entry.js → p-30256e5f.entry.js} +1 -1
- package/dist/twilight/p-308cfcab.entry.js +4 -0
- package/dist/twilight/{p-f1859466.entry.js → p-38a8f05e.entry.js} +1 -1
- package/dist/twilight/{p-a4f96a76.entry.js → p-3910e00f.entry.js} +1 -1
- package/dist/twilight/{p-ece0e68f.entry.js → p-3a2fdd6f.entry.js} +1 -1
- package/dist/twilight/p-3cc1582f.entry.js +4 -0
- package/dist/twilight/p-3ec34eae.entry.js +4 -0
- package/dist/twilight/{p-916187fb.entry.js → p-400257fd.entry.js} +1 -1
- package/dist/twilight/{p-a72161e7.entry.js → p-42cc9b33.entry.js} +1 -1
- package/dist/twilight/{p-7f07d192.entry.js → p-4482e672.entry.js} +1 -1
- package/dist/twilight/{p-aac173b7.entry.js → p-44b289bb.entry.js} +1 -1
- package/dist/twilight/{p-d2b90374.entry.js → p-4da58baf.entry.js} +1 -1
- package/dist/twilight/{p-390e50ee.entry.js → p-4f873363.entry.js} +1 -1
- package/dist/twilight/{p-1cc094d9.entry.js → p-5999d681.entry.js} +1 -1
- package/dist/twilight/{p-a96ae5ac.entry.js → p-59f47a08.entry.js} +1 -1
- package/dist/twilight/{p-9d20db0f.entry.js → p-5c347cd5.entry.js} +1 -1
- package/dist/twilight/{p-184fbcdf.entry.js → p-5ebbec76.entry.js} +1 -1
- package/dist/twilight/{p-56070211.entry.js → p-5ecf2b26.entry.js} +1 -1
- package/dist/twilight/{p-ce0ecd6d.entry.js → p-612c5b08.entry.js} +1 -1
- package/dist/twilight/{p-3eb30788.entry.js → p-624503ee.entry.js} +1 -1
- package/dist/twilight/{p-597273c9.entry.js → p-6339390a.entry.js} +1 -1
- package/dist/twilight/p-64376e97.entry.js +4 -0
- package/dist/twilight/{p-b75f02c5.entry.js → p-65839961.entry.js} +1 -1
- package/dist/twilight/{p-416bfa3c.entry.js → p-6c58235e.entry.js} +1 -1
- package/dist/twilight/{p-f5b4faf1.entry.js → p-6e26c815.entry.js} +1 -1
- package/dist/twilight/p-6f3da0b7.entry.js +4 -0
- package/dist/twilight/{p-63b807d8.entry.js → p-72b1e6ed.entry.js} +1 -1
- package/dist/twilight/{p-d198466f.entry.js → p-745329af.entry.js} +1 -1
- package/dist/twilight/{p-68981b47.entry.js → p-74eb04ec.entry.js} +1 -1
- package/dist/twilight/{p-be9b05ed.entry.js → p-78ce73ba.entry.js} +1 -1
- package/dist/twilight/{p-a4ee0f48.entry.js → p-7edaa78b.entry.js} +1 -1
- package/dist/twilight/{p-6fa8dc48.entry.js → p-807db423.entry.js} +1 -1
- package/dist/twilight/{p-5f4491df.entry.js → p-824dd42e.entry.js} +1 -1
- package/dist/twilight/{p-15f7a80c.entry.js → p-835c43e6.entry.js} +1 -1
- package/dist/twilight/{p-fdd9c784.entry.js → p-83c1d4b2.entry.js} +1 -1
- package/dist/twilight/{p-82b0696f.entry.js → p-8709e981.entry.js} +1 -1
- package/dist/twilight/{p-31a1aa8c.entry.js → p-8bfca6eb.entry.js} +1 -1
- package/dist/twilight/{p-26659429.entry.js → p-8fad5c91.entry.js} +1 -1
- package/dist/twilight/{p-abb0fe8a.entry.js → p-96d644b8.entry.js} +1 -1
- package/dist/twilight/{p-c57f29fb.entry.js → p-99d0fd61.entry.js} +1 -1
- package/dist/twilight/{p-9c6c3383.entry.js → p-9bde5e3c.entry.js} +1 -1
- package/dist/twilight/{p-25d69769.entry.js → p-9f320350.entry.js} +1 -1
- package/dist/twilight/{p-BRZ-xY4O.js → p-Bc2RLvfZ.js} +1 -1
- package/dist/twilight/{p-DIgIfJIX.js → p-CdbTKQNp.js} +1 -1
- package/dist/twilight/{p-BQHT0o4-.js → p-CiAXtUPQ.js} +1 -1
- package/dist/twilight/{p-gzETizzN.js → p-CmDT48y4.js} +1 -1
- package/dist/twilight/{p-f2zyoe62.js → p-D0FlIX_Z.js} +1 -1
- package/dist/twilight/{p-2RfKl9ZG.js → p-DR8BHH7X.js} +1 -1
- package/dist/twilight/{p-NH4fFDqc.js → p-Dqb1Ri2Y.js} +1 -1
- package/dist/twilight/{p-hMPmvZ4N.js → p-Dtp3srRX.js} +1 -1
- package/dist/twilight/{p-BWhaHax9.js → p-NohMjDY2.js} +1 -1
- package/dist/twilight/{p-5517f377.entry.js → p-a9cbd414.entry.js} +1 -1
- package/dist/twilight/{p-f758d06b.entry.js → p-b20265f2.entry.js} +1 -1
- package/dist/twilight/{p-826b7e39.entry.js → p-b59b7153.entry.js} +1 -1
- package/dist/twilight/{p-cd392e48.entry.js → p-bc47e256.entry.js} +1 -1
- package/dist/twilight/{p-c395af37.entry.js → p-bc76d253.entry.js} +1 -1
- package/dist/twilight/{p-f6afdeea.entry.js → p-bcf201a8.entry.js} +1 -1
- package/dist/twilight/{p-4a41c81f.entry.js → p-beb17e29.entry.js} +1 -1
- package/dist/twilight/{p-5dbfbde6.entry.js → p-c00d4e23.entry.js} +1 -1
- package/dist/twilight/p-c137e672.entry.js +4 -0
- package/dist/twilight/{p-49a31434.entry.js → p-c47e85e9.entry.js} +1 -1
- package/dist/twilight/{p-9e20aea5.entry.js → p-c4960804.entry.js} +1 -1
- package/dist/twilight/{p-0c50e6d1.entry.js → p-c52aac33.entry.js} +1 -1
- package/dist/twilight/{p-58e57008.entry.js → p-c707f55b.entry.js} +1 -1
- package/dist/twilight/p-cb8a1223.entry.js +4 -0
- package/dist/twilight/{p-0f17896f.entry.js → p-ccfe690a.entry.js} +1 -1
- package/dist/twilight/{p-B-Ntbq8B.js → p-cvulr5dQ.js} +1 -1
- package/dist/twilight/{p-674370d9.entry.js → p-d01e76f4.entry.js} +1 -1
- package/dist/twilight/{p-ea3e4838.entry.js → p-d567481d.entry.js} +1 -1
- package/dist/twilight/{p-d0a034ad.entry.js → p-d617d844.entry.js} +1 -1
- package/dist/twilight/{p-b59ea7ea.entry.js → p-df173474.entry.js} +1 -1
- package/dist/twilight/{p-85f0187e.entry.js → p-e0244c37.entry.js} +1 -1
- package/dist/twilight/{p-3c82be41.entry.js → p-e0750731.entry.js} +1 -1
- package/dist/twilight/{p-a44b9668.entry.js → p-e0af89bc.entry.js} +1 -1
- package/dist/twilight/{p-f95df964.entry.js → p-ed6007e1.entry.js} +1 -1
- package/dist/twilight/{p-6591111e.entry.js → p-ed8951c5.entry.js} +1 -1
- package/dist/twilight/p-f245d317.entry.js +4 -0
- package/dist/twilight/{p-f2cb9377.entry.js → p-f2b204a4.entry.js} +1 -1
- package/dist/twilight/{p-8fc96e64.entry.js → p-f579e8ef.entry.js} +1 -1
- package/dist/twilight/{p-ffa981ec.entry.js → p-fca971a6.entry.js} +1 -1
- package/dist/twilight/{p-3aa1e961.entry.js → p-ff75f1c4.entry.js} +1 -1
- package/dist/twilight/{p-8Cy2-80S.js → p-hkzTCOEy.js} +1 -1
- package/dist/twilight/{p-Ctl2lOrt.js → p-kg7IhfAv.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-bullet-delivery/api-service.d.ts +6 -5
- package/dist/types/components/salla-bullet-delivery/salla-bullet-delivery.d.ts +38 -6
- package/dist/types/components/salla-delivery-promise/delivery-promise-api.d.ts +1 -1
- package/dist/types/components/salla-delivery-promise/salla-delivery-promise.d.ts +2 -0
- package/dist/types/components/salla-searchable-dropdown/interfaces.d.ts +5 -0
- package/dist/types/components/salla-searchable-dropdown/salla-searchable-dropdown.d.ts +47 -0
- package/dist/types/components.d.ts +135 -0
- package/package.json +5 -5
- package/dist/twilight/p-5be4ae85.entry.js +0 -4
- package/dist/twilight/p-5c2dcdb0.entry.js +0 -4
- package/dist/twilight/p-637724e7.entry.js +0 -4
- package/dist/twilight/p-68f163aa.entry.js +0 -4
- package/dist/twilight/p-6bf87309.entry.js +0 -4
- package/dist/twilight/p-873eed59.entry.js +0 -4
- package/dist/twilight/p-879f08a4.entry.js +0 -4
- package/dist/twilight/p-ae6aabba.entry.js +0 -4
- package/dist/twilight/p-d0520b44.entry.js +0 -4
- package/dist/twilight/p-dd0be0da.entry.js +0 -4
- package/dist/twilight/p-ec899dc9.entry.js +0 -4
package/dist/cjs/{salla-bullet-delivery.cjs.entry.js → salla-bullet-delivery_2.cjs.entry.js}
RENAMED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
|
-
var index = require('./index-
|
|
7
|
-
var search = require('./search-c7Aa7lM9.js');
|
|
8
|
-
var location = require('./location-DIyESLuI.js');
|
|
6
|
+
var index = require('./index-D3xsx646.js');
|
|
9
7
|
var keyboard_arrow_right = require('./keyboard_arrow_right-BayM_Il2.js');
|
|
8
|
+
var location = require('./location-DIyESLuI.js');
|
|
9
|
+
var search = require('./search-c7Aa7lM9.js');
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* API Service for salla-bullet-delivery component
|
|
@@ -26,6 +26,19 @@ async function withApiErrorHandling(fn, fallback, logLabel) {
|
|
|
26
26
|
return fallback;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
const apiCache = new Map();
|
|
30
|
+
const CACHE_TTL = 5 * 60 * 1000;
|
|
31
|
+
function getCached(key) {
|
|
32
|
+
const entry = apiCache.get(key);
|
|
33
|
+
if (!entry || Date.now() - entry.timestamp > CACHE_TTL) {
|
|
34
|
+
apiCache.delete(key);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return entry.data;
|
|
38
|
+
}
|
|
39
|
+
function setCache(key, data) {
|
|
40
|
+
apiCache.set(key, { data, timestamp: Date.now() });
|
|
41
|
+
}
|
|
29
42
|
/** Uses country code from API (e.g. 'SA'). */
|
|
30
43
|
const isSaudiArabia = (countryCode) => String(countryCode).toUpperCase() === 'SA';
|
|
31
44
|
/**
|
|
@@ -37,53 +50,94 @@ const bulletDeliveryAPI = {
|
|
|
37
50
|
* Get available countries from Salla shipping API
|
|
38
51
|
* @param forBranch - when true, use for_branch=1 (e.g. for pickup/branches tab)
|
|
39
52
|
*/
|
|
40
|
-
async getCountries(forBranch = false) {
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
async getCountries(forBranch = false, query) {
|
|
54
|
+
const cacheKey = !query?.trim() ? `countries_${forBranch ? 1 : 0}` : null;
|
|
55
|
+
if (cacheKey) {
|
|
56
|
+
const cached = getCached(cacheKey);
|
|
57
|
+
if (cached)
|
|
58
|
+
return cached;
|
|
59
|
+
}
|
|
60
|
+
const result = await withApiErrorHandling(async () => {
|
|
61
|
+
const params = { for_branch: forBranch ? 1 : 0 };
|
|
62
|
+
if (forBranch) {
|
|
63
|
+
params.for_allocation = 1;
|
|
64
|
+
}
|
|
65
|
+
if (query?.trim())
|
|
66
|
+
params.query = query.trim();
|
|
67
|
+
const data = (await salla.api.request("shipping/countries", { params }))?.data ?? [];
|
|
43
68
|
return data.map((c) => ({ id: c.id, code: c.code, name: c.name, has_regions: isSaudiArabia(c.code) }));
|
|
44
69
|
}, [], 'Error getting countries');
|
|
70
|
+
if (cacheKey && result.length > 0)
|
|
71
|
+
setCache(cacheKey, result);
|
|
72
|
+
return result;
|
|
45
73
|
},
|
|
46
74
|
/**
|
|
47
75
|
* Get regions for a country from Salla shipping API
|
|
48
76
|
* Endpoint: GET /shipping/countries/<COUNTRY_ID>/region
|
|
49
77
|
*/
|
|
50
|
-
async getRegions(countryId) {
|
|
78
|
+
async getRegions(countryId, query) {
|
|
51
79
|
if (!validId(countryId)) {
|
|
52
80
|
console.warn(`${API_LOG_PREFIX}: getRegions called without valid country_id`);
|
|
53
81
|
return [];
|
|
54
82
|
}
|
|
55
|
-
|
|
56
|
-
|
|
83
|
+
const cacheKey = !query?.trim() ? `regions_${countryId}` : null;
|
|
84
|
+
if (cacheKey) {
|
|
85
|
+
const cached = getCached(cacheKey);
|
|
86
|
+
if (cached)
|
|
87
|
+
return cached;
|
|
88
|
+
}
|
|
89
|
+
const result = await withApiErrorHandling(async () => {
|
|
90
|
+
const params = {};
|
|
91
|
+
if (query?.trim())
|
|
92
|
+
params.query = query.trim();
|
|
93
|
+
const data = (await salla.api.request(`shipping/countries/${countryId}/regions`, { params }))?.data ?? [];
|
|
57
94
|
return data.map((r) => ({ id: r.id, name: r.name, code: r.code, country_id: Number(countryId) }));
|
|
58
95
|
}, [], 'Error fetching regions');
|
|
96
|
+
if (cacheKey && result.length > 0)
|
|
97
|
+
setCache(cacheKey, result);
|
|
98
|
+
return result;
|
|
59
99
|
},
|
|
60
100
|
/**
|
|
61
101
|
* Get cities from Salla shipping API
|
|
62
102
|
* @param regionId - Optional; when provided (e.g. for SA), cities are filtered by region
|
|
63
103
|
*/
|
|
64
|
-
async getCities(countryId, regionId) {
|
|
104
|
+
async getCities(countryId, regionId, query) {
|
|
65
105
|
if (!validId(countryId)) {
|
|
66
106
|
console.warn(`${API_LOG_PREFIX}: getCities called without valid country_id`);
|
|
67
107
|
return [];
|
|
68
108
|
}
|
|
69
|
-
|
|
109
|
+
const cacheKey = !query?.trim() ? `cities_${countryId}_${regionId || 'all'}` : null;
|
|
110
|
+
if (cacheKey) {
|
|
111
|
+
const cached = getCached(cacheKey);
|
|
112
|
+
if (cached)
|
|
113
|
+
return cached;
|
|
114
|
+
}
|
|
115
|
+
const result = await withApiErrorHandling(async () => {
|
|
70
116
|
const params = { for_branch: 0, country_id: countryId };
|
|
71
117
|
if (regionId)
|
|
72
118
|
params.region_id = regionId;
|
|
119
|
+
if (query?.trim())
|
|
120
|
+
params.query = query.trim();
|
|
73
121
|
const data = (await salla.api.request("shipping/cities", { params }))?.data ?? [];
|
|
74
122
|
return data.map((c) => ({ id: c.id, name: c.name, country_id: countryId, ...(c.region_id != null && { region_id: c.region_id }) }));
|
|
75
123
|
}, [], 'Error fetching cities');
|
|
124
|
+
if (cacheKey && result.length > 0)
|
|
125
|
+
setCache(cacheKey, result);
|
|
126
|
+
return result;
|
|
76
127
|
},
|
|
77
128
|
/**
|
|
78
129
|
* Get districts from Salla shipping API
|
|
79
130
|
*/
|
|
80
|
-
async getDistricts(cityId) {
|
|
131
|
+
async getDistricts(cityId, query) {
|
|
81
132
|
if (!validId(cityId)) {
|
|
82
133
|
console.warn(`${API_LOG_PREFIX}: getDistricts called without valid city_id`);
|
|
83
134
|
return [];
|
|
84
135
|
}
|
|
85
136
|
return withApiErrorHandling(async () => {
|
|
86
|
-
const
|
|
137
|
+
const params = { for_branch: 0, city_id: cityId };
|
|
138
|
+
if (query?.trim())
|
|
139
|
+
params.query = query.trim();
|
|
140
|
+
const raw = (await salla.api.request("shipping/districts", { params }))?.data;
|
|
87
141
|
const list = Array.isArray(raw) ? raw : (Array.isArray(raw?.districts) ? raw.districts : []);
|
|
88
142
|
return list.map((d) => ({ id: d.id, name: d.name, name_en: d.name_en, city_id: cityId }));
|
|
89
143
|
}, [], 'Error fetching districts');
|
|
@@ -95,7 +149,14 @@ const bulletDeliveryAPI = {
|
|
|
95
149
|
}, [], 'Error fetching user addresses');
|
|
96
150
|
},
|
|
97
151
|
async getBranches({ query, lat, lng, country_id, per_page = 20 } = {}) {
|
|
98
|
-
|
|
152
|
+
const hasSearchParams = query?.trim()?.length >= 2 || lat || lng;
|
|
153
|
+
const cacheKey = !hasSearchParams && country_id ? `branches_${country_id}` : null;
|
|
154
|
+
if (cacheKey) {
|
|
155
|
+
const cached = getCached(cacheKey);
|
|
156
|
+
if (cached)
|
|
157
|
+
return cached;
|
|
158
|
+
}
|
|
159
|
+
const result = await withApiErrorHandling(async () => {
|
|
99
160
|
const params = { per_page };
|
|
100
161
|
if (query?.trim().length >= 2)
|
|
101
162
|
params.query = query;
|
|
@@ -108,6 +169,9 @@ const bulletDeliveryAPI = {
|
|
|
108
169
|
const res = await salla.api.request("branches", { params });
|
|
109
170
|
return (Array.isArray(res?.data) ? res.data : []);
|
|
110
171
|
}, [], 'Error fetching branches');
|
|
172
|
+
if (cacheKey && result.length > 0)
|
|
173
|
+
setCache(cacheKey, result);
|
|
174
|
+
return result;
|
|
111
175
|
},
|
|
112
176
|
async saveAddressLocation(payload) {
|
|
113
177
|
return withApiErrorHandling(async () => {
|
|
@@ -119,7 +183,7 @@ const bulletDeliveryAPI = {
|
|
|
119
183
|
},
|
|
120
184
|
async setDeliveryScope(scopeId) {
|
|
121
185
|
return withApiErrorHandling(async () => {
|
|
122
|
-
await salla.scope.change({ id: scopeId });
|
|
186
|
+
await salla.api.withoutNotifier(() => salla.scope.change({ id: scopeId }));
|
|
123
187
|
salla.storage.set("scope", { ...(salla.storage.get("scope") || {}), id: scopeId });
|
|
124
188
|
return true;
|
|
125
189
|
}, false, 'Error setting delivery scope');
|
|
@@ -127,7 +191,7 @@ const bulletDeliveryAPI = {
|
|
|
127
191
|
async allocateScope(payload) {
|
|
128
192
|
const errMsg = (d) => d?.error?.message ?? d?.message ?? 'Failed to allocate scope';
|
|
129
193
|
try {
|
|
130
|
-
const response = await salla.api.request("scopes/allocation", payload, 'post');
|
|
194
|
+
const response = await salla.api.withoutNotifier(() => salla.api.request("scopes/allocation", payload, 'post'));
|
|
131
195
|
// SDK resolves with { data } and throws on non-2xx; any resolved value is success
|
|
132
196
|
const data = response?.data ?? response;
|
|
133
197
|
return { success: true, data: data };
|
|
@@ -139,6 +203,9 @@ const bulletDeliveryAPI = {
|
|
|
139
203
|
}
|
|
140
204
|
},
|
|
141
205
|
};
|
|
206
|
+
function clearApiCache() {
|
|
207
|
+
apiCache.clear();
|
|
208
|
+
}
|
|
142
209
|
|
|
143
210
|
/**
|
|
144
211
|
* Helper functions for salla-bullet-delivery component
|
|
@@ -246,16 +313,10 @@ const GEO_ERROR_MESSAGES = {
|
|
|
246
313
|
};
|
|
247
314
|
const getGeolocationErrorMessage = (errorCode) => GEO_ERROR_MESSAGES[errorCode] ?? 'An error occurred while detecting location';
|
|
248
315
|
|
|
249
|
-
var
|
|
250
|
-
<path
|
|
251
|
-
d="M1.14453 5.83032L1.14453 9.16486C1.14453 11.0511 1.14453 11.9943 1.73032 12.5803C2.3161 13.1663 3.25891 13.1663 5.14453 13.1663L9.14453 13.1663C11.0301 13.1663 11.9729 13.1663 12.5587 12.5803C13.1445 11.9943 13.1445 11.0511 13.1445 9.16486V5.83032"
|
|
252
|
-
stroke="currentcolor" stroke-linecap="round" />
|
|
253
|
-
<path
|
|
254
|
-
d="M9.14453 10.1619C8.68846 10.5667 7.9624 10.8285 7.14453 10.8285C6.32666 10.8285 5.60059 10.5667 5.14453 10.1619"
|
|
255
|
-
stroke="currentcolor" stroke-linecap="round" />
|
|
316
|
+
var GetDirections = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
256
317
|
<path
|
|
257
|
-
d="
|
|
258
|
-
stroke="
|
|
318
|
+
d="M7.94798 3.19336C11.1309 2.1083 12.7223 1.56578 13.5783 2.42174C14.4342 3.27771 13.8917 4.86914 12.8066 8.05201L12.0678 10.2195C11.2344 12.6639 10.8178 13.8861 10.131 13.9872C9.94631 14.0144 9.75517 13.9981 9.57248 13.9394C8.89297 13.7212 8.53377 12.4326 7.81538 9.8553C7.65604 9.28364 7.57637 8.99781 7.39494 8.7795C7.34228 8.71614 7.28386 8.65772 7.2205 8.60506C7.00219 8.42363 6.71636 8.34396 6.1447 8.18462C3.56741 7.46623 2.27876 7.10703 2.0606 6.42752C2.00195 6.24483 1.98558 6.05369 2.01277 5.86903C2.11392 5.18221 3.33613 4.76556 5.78054 3.93225L7.94798 3.19336Z"
|
|
319
|
+
stroke="#555555" stroke-width="1.2" />
|
|
259
320
|
</svg>
|
|
260
321
|
`;
|
|
261
322
|
|
|
@@ -309,17 +370,30 @@ var MiniMap = `<svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns
|
|
|
309
370
|
</svg>
|
|
310
371
|
`;
|
|
311
372
|
|
|
312
|
-
var
|
|
373
|
+
var Store = `<svg width="15" height="14" viewBox="0 0 15 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
313
374
|
<path
|
|
314
|
-
d="
|
|
315
|
-
stroke="
|
|
375
|
+
d="M1.14453 5.83032L1.14453 9.16486C1.14453 11.0511 1.14453 11.9943 1.73032 12.5803C2.3161 13.1663 3.25891 13.1663 5.14453 13.1663L9.14453 13.1663C11.0301 13.1663 11.9729 13.1663 12.5587 12.5803C13.1445 11.9943 13.1445 11.0511 13.1445 9.16486V5.83032"
|
|
376
|
+
stroke="currentcolor" stroke-linecap="round" />
|
|
377
|
+
<path
|
|
378
|
+
d="M9.14453 10.1619C8.68846 10.5667 7.9624 10.8285 7.14453 10.8285C6.32666 10.8285 5.60059 10.5667 5.14453 10.1619"
|
|
379
|
+
stroke="currentcolor" stroke-linecap="round" />
|
|
380
|
+
<path
|
|
381
|
+
d="M5.90256 4.44533C5.71455 5.12426 5.03086 6.29542 3.73185 6.46516C2.58488 6.61502 1.71497 6.11437 1.49277 5.90504C1.24779 5.7353 0.689441 5.19216 0.552703 4.85269C0.415966 4.51322 0.575492 3.77771 0.689441 3.47785L1.14495 2.15892C1.25615 1.82765 1.51646 1.04411 1.78334 0.779094C2.05022 0.514073 2.59054 0.502543 2.81294 0.502543L7.48329 0.502543C8.68543 0.519525 11.3139 0.491824 11.8335 0.502545C12.3532 0.513266 12.6654 0.948828 12.7565 1.13553C13.5318 3.01341 13.8333 4.08889 13.8333 4.54717C13.7321 5.03605 13.3133 5.95787 11.8335 6.36332C10.2956 6.7847 9.42363 5.96509 9.15007 5.65043M5.27015 5.65044C5.48665 5.91635 6.16578 6.45158 7.15029 6.46516C8.1348 6.47873 8.98485 5.79188 9.28681 5.44676C9.37227 5.34492 9.55687 5.04279 9.7483 4.44533"
|
|
382
|
+
stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" />
|
|
316
383
|
</svg>
|
|
317
384
|
`;
|
|
318
385
|
|
|
319
|
-
const sallaBulletDeliveryCss = "@supports (interpolate-size: allow-keywords) and (block-size: calc-size(auto, size)) {\n .s-bullet-delivery .s-bullet-delivery-modal .s-modal-body, .s-bullet-delivery-inner {\n @apply [interpolate-size:allow-keywords];\n }\n .s-bullet-delivery .s-bullet-delivery-modal .s-modal-body {\n @apply [overflow:clip] [transition:block-size_500ms_ease];\n }\n .s-bullet-delivery-inner {\n @apply [overflow:clip] [transition:block-size_500ms_ease];\n block-size: calc-size(auto, size);\n }\n}\n\n@keyframes s-bullet-delivery-fade-in {\n from {\n opacity: 0;\n transform: translateY(6px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}";
|
|
386
|
+
const sallaBulletDeliveryCss = "@supports (interpolate-size: allow-keywords) and (block-size: calc-size(auto, size)) {\n .s-bullet-delivery .s-bullet-delivery-modal .s-modal-body, .s-bullet-delivery-inner {\n @apply [interpolate-size:allow-keywords];\n }\n .s-bullet-delivery .s-bullet-delivery-modal .s-modal-body {\n @apply [overflow:clip] [transition:block-size_500ms_ease];\n }\n .s-bullet-delivery-inner {\n @apply [overflow:clip] [transition:block-size_500ms_ease];\n block-size: calc-size(auto, size);\n }\n}\n\n/* Allow searchable dropdown popover to paint outside the modal body */\n.s-bullet-delivery .s-bullet-delivery-modal .s-modal-body:has(.s-searchable-dropdown--open) {\n overflow: visible !important;\n}\n\n@keyframes s-bullet-delivery-fade-in {\n from {\n opacity: 0;\n transform: translateY(6px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}";
|
|
320
387
|
|
|
321
388
|
const BRANCH_SEARCH_DEBOUNCE_MS = 1000;
|
|
322
389
|
const GEOLOCATION_TIMEOUT = 10000;
|
|
390
|
+
const DEBUG_KEY = 'salla-bullet-delivery-debug';
|
|
391
|
+
const OVERRIDE_IP_KEY = 'salla-bullet-delivery-override-ip';
|
|
392
|
+
function log(message, data) {
|
|
393
|
+
if (localStorage.getItem(DEBUG_KEY)) {
|
|
394
|
+
data !== undefined ? console.log(message, data) : console.log(message);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
323
397
|
const SallaBulletDelivery = class {
|
|
324
398
|
constructor(hostRef) {
|
|
325
399
|
index.registerInstance(this, hostRef);
|
|
@@ -332,6 +406,11 @@ const SallaBulletDelivery = class {
|
|
|
332
406
|
this.pendingCartSubmitPromise = null;
|
|
333
407
|
this.cartSubmitConfirmationPending = false;
|
|
334
408
|
this.branchSearchDebounceTimer = null;
|
|
409
|
+
this.countrySearchTimer = null;
|
|
410
|
+
this.regionSearchTimer = null;
|
|
411
|
+
this.citySearchTimer = null;
|
|
412
|
+
this.districtSearchTimer = null;
|
|
413
|
+
this.citySearchCounter = 0;
|
|
335
414
|
this.componentReady = false;
|
|
336
415
|
this.pendingOpen = false;
|
|
337
416
|
this.tabChanging = false;
|
|
@@ -358,7 +437,6 @@ const SallaBulletDelivery = class {
|
|
|
358
437
|
/** True after saved addresses have been loaded (lazy: only when address tab is shown). */
|
|
359
438
|
this.savedAddressesLoaded = false;
|
|
360
439
|
// Core state
|
|
361
|
-
this.loading = true;
|
|
362
440
|
this.activeTab = "address";
|
|
363
441
|
this.isLoggedIn = false;
|
|
364
442
|
this.viewMode = "main";
|
|
@@ -384,6 +462,7 @@ const SallaBulletDelivery = class {
|
|
|
384
462
|
this.selectedBranch = null;
|
|
385
463
|
this.branchSearchQuery = "";
|
|
386
464
|
// Loading states
|
|
465
|
+
this.loadingCountries = false;
|
|
387
466
|
this.loadingCities = false;
|
|
388
467
|
this.loadingDistricts = false;
|
|
389
468
|
this.loadingBranches = false;
|
|
@@ -392,11 +471,95 @@ const SallaBulletDelivery = class {
|
|
|
392
471
|
this.savingAddress = false;
|
|
393
472
|
this.loadingSavedAddresses = false;
|
|
394
473
|
this.showCartWillBeClearedBanner = false;
|
|
474
|
+
// Searchable dropdown state
|
|
475
|
+
this.countrySearchQuery = '';
|
|
476
|
+
this.regionSearchQuery = '';
|
|
477
|
+
this.citySearchQuery = '';
|
|
478
|
+
this.districtSearchQuery = '';
|
|
479
|
+
this.searchingCountries = false;
|
|
480
|
+
this.searchingRegions = false;
|
|
481
|
+
this.searchingCities = false;
|
|
482
|
+
this.searchingDistricts = false;
|
|
483
|
+
this.displayedCountries = [];
|
|
484
|
+
this.displayedRegions = [];
|
|
485
|
+
this.displayedCities = [];
|
|
486
|
+
this.displayedDistricts = [];
|
|
395
487
|
/** Shown when scopes/allocation returns 422 (address outside delivery coverage). Only on delivery tab. */
|
|
396
488
|
this.allocationOutOfCoverageMessage = null;
|
|
397
489
|
this.newAddressForm = {
|
|
398
490
|
...SallaBulletDelivery.INITIAL_ADDRESS_FORM,
|
|
399
491
|
};
|
|
492
|
+
this.handleCountrySearch = (query) => {
|
|
493
|
+
this.countrySearchQuery = query;
|
|
494
|
+
return;
|
|
495
|
+
};
|
|
496
|
+
this.handleRegionSearch = (query) => {
|
|
497
|
+
this.regionSearchQuery = query;
|
|
498
|
+
return;
|
|
499
|
+
};
|
|
500
|
+
this.handleCitySearch = (query) => {
|
|
501
|
+
this.citySearchQuery = query;
|
|
502
|
+
if (this.citySearchTimer)
|
|
503
|
+
clearTimeout(this.citySearchTimer);
|
|
504
|
+
if (!query.trim()) {
|
|
505
|
+
this.displayedCities = this.cities;
|
|
506
|
+
this.searchingCities = false;
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
if (query.trim().length < SallaBulletDelivery.DROPDOWN_SEARCH_MIN_CHARS)
|
|
510
|
+
return;
|
|
511
|
+
const requestId = ++this.citySearchCounter;
|
|
512
|
+
this.citySearchTimer = setTimeout(async () => {
|
|
513
|
+
this.searchingCities = true;
|
|
514
|
+
try {
|
|
515
|
+
const isSA = isSaudiArabia(this.selectedCountry?.code ?? '');
|
|
516
|
+
const regionId = isSA ? this.selectedRegion?.id : undefined;
|
|
517
|
+
const results = await bulletDeliveryAPI.getCities(this.selectedCountry?.id, regionId, query);
|
|
518
|
+
if (requestId === this.citySearchCounter) {
|
|
519
|
+
this.displayedCities = results;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
catch {
|
|
523
|
+
if (requestId === this.citySearchCounter) {
|
|
524
|
+
this.displayedCities = this.cities;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
finally {
|
|
528
|
+
if (requestId === this.citySearchCounter) {
|
|
529
|
+
this.searchingCities = false;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}, SallaBulletDelivery.DROPDOWN_SEARCH_DEBOUNCE_MS);
|
|
533
|
+
};
|
|
534
|
+
this.handleDistrictSearch = (query) => {
|
|
535
|
+
this.districtSearchQuery = query;
|
|
536
|
+
return;
|
|
537
|
+
};
|
|
538
|
+
this.handleCountryDropdownClosed = () => {
|
|
539
|
+
this.countrySearchQuery = '';
|
|
540
|
+
this.displayedCountries = this.countries;
|
|
541
|
+
this.searchingCountries = false;
|
|
542
|
+
};
|
|
543
|
+
this.handleRegionDropdownClosed = () => {
|
|
544
|
+
this.regionSearchQuery = '';
|
|
545
|
+
this.displayedRegions = this.regions;
|
|
546
|
+
this.searchingRegions = false;
|
|
547
|
+
};
|
|
548
|
+
this.handleCityDropdownClosed = () => {
|
|
549
|
+
this.citySearchQuery = '';
|
|
550
|
+
if (this.citySearchTimer) {
|
|
551
|
+
clearTimeout(this.citySearchTimer);
|
|
552
|
+
this.citySearchTimer = null;
|
|
553
|
+
}
|
|
554
|
+
++this.citySearchCounter;
|
|
555
|
+
this.displayedCities = this.cities;
|
|
556
|
+
this.searchingCities = false;
|
|
557
|
+
};
|
|
558
|
+
this.handleDistrictDropdownClosed = () => {
|
|
559
|
+
this.districtSearchQuery = '';
|
|
560
|
+
this.displayedDistricts = this.districts;
|
|
561
|
+
this.searchingDistricts = false;
|
|
562
|
+
};
|
|
400
563
|
/**
|
|
401
564
|
* Submit add-address form: create address via API then switch back to list.
|
|
402
565
|
*/
|
|
@@ -435,10 +598,61 @@ const SallaBulletDelivery = class {
|
|
|
435
598
|
this.savingAddress = false;
|
|
436
599
|
}
|
|
437
600
|
};
|
|
601
|
+
this.handleCountrySelected = (item) => {
|
|
602
|
+
const country = this.countries.find(c => String(c.id) === String(item.id)) || item;
|
|
603
|
+
const isCountrySwitch = this.selectedCountry &&
|
|
604
|
+
country &&
|
|
605
|
+
this.selectedCountry.code !== country.code;
|
|
606
|
+
this.showCartWillBeClearedBanner = !!isCountrySwitch;
|
|
607
|
+
this.countrySearchQuery = '';
|
|
608
|
+
this.displayedCountries = this.countries;
|
|
609
|
+
this.applyCountryChange(country || null);
|
|
610
|
+
};
|
|
611
|
+
this.handleRegionSelected = (item) => {
|
|
612
|
+
const region = this.regions.find(r => String(r.id) === String(item.id)) || item;
|
|
613
|
+
this.selectedRegion = region || null;
|
|
614
|
+
this.regionSearchQuery = '';
|
|
615
|
+
this.displayedRegions = this.regions;
|
|
616
|
+
this.updateNewAddressForm({
|
|
617
|
+
region_id: region?.id,
|
|
618
|
+
city_id: undefined,
|
|
619
|
+
district_id: undefined,
|
|
620
|
+
city: undefined,
|
|
621
|
+
district: undefined,
|
|
622
|
+
});
|
|
623
|
+
if (region && this.selectedCountry) {
|
|
624
|
+
this.loadCities(this.selectedCountry.id, region.id);
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
this.handleCitySelected = (item) => {
|
|
628
|
+
const isSA = isSaudiArabia(this.selectedCountry?.code ?? '');
|
|
629
|
+
const city = this.cities.find(c => String(c.id) === String(item.id)) || item;
|
|
630
|
+
this.selectedCity = city || null;
|
|
631
|
+
this.selectedDistrict = null;
|
|
632
|
+
this.districtName = "";
|
|
633
|
+
this.citySearchQuery = '';
|
|
634
|
+
this.displayedCities = this.cities;
|
|
635
|
+
if (city) {
|
|
636
|
+
this.updateNewAddressForm({ city: city, district: undefined });
|
|
637
|
+
if (isSA) {
|
|
638
|
+
this.loadDistricts(city.id);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
this.handleDistrictSelected = (item) => {
|
|
643
|
+
const district = this.districts.find(d => String(d.id) === String(item.id)) || item;
|
|
644
|
+
this.selectedDistrict = district || null;
|
|
645
|
+
this.districtName = "";
|
|
646
|
+
this.districtSearchQuery = '';
|
|
647
|
+
this.displayedDistricts = this.districts;
|
|
648
|
+
if (district) {
|
|
649
|
+
this.updateNewAddressForm({ district });
|
|
650
|
+
}
|
|
651
|
+
};
|
|
438
652
|
}
|
|
439
|
-
/** Whether to show delivery + pickup tabs. From store.
|
|
653
|
+
/** Whether to show delivery + pickup tabs. From store.shipping.support_pickup */
|
|
440
654
|
get supportsPickup() {
|
|
441
|
-
return
|
|
655
|
+
return Boolean(Salla.config.get("store.shipping.support_pickup"));
|
|
442
656
|
}
|
|
443
657
|
/** The modal opening strategy: 'first_visit' | 'on_cart_click' | 'after_add_to_cart' */
|
|
444
658
|
get openingType() {
|
|
@@ -457,10 +671,9 @@ const SallaBulletDelivery = class {
|
|
|
457
671
|
this.pendingOpen = true;
|
|
458
672
|
return;
|
|
459
673
|
}
|
|
460
|
-
// Reset state
|
|
674
|
+
// Reset state before opening
|
|
461
675
|
this.resetState();
|
|
462
|
-
|
|
463
|
-
// Open modal immediately to show skeleton/loading state
|
|
676
|
+
// Open modal immediately — fields render right away with inline loading
|
|
464
677
|
this.modal.open();
|
|
465
678
|
Salla.event.dispatch("salla::bullet-delivery.modal.opened");
|
|
466
679
|
try {
|
|
@@ -481,11 +694,16 @@ const SallaBulletDelivery = class {
|
|
|
481
694
|
this.activeTab = "address";
|
|
482
695
|
}
|
|
483
696
|
// Load countries always; load saved addresses only when address tab is active (lazy tab data).
|
|
697
|
+
if (this.isLoggedIn && this.activeTab === "address") {
|
|
698
|
+
this.loadingSavedAddresses = true;
|
|
699
|
+
}
|
|
484
700
|
await Promise.all([
|
|
485
701
|
this.loadCountries(hasStoredAddressIds),
|
|
486
702
|
this.isLoggedIn && this.activeTab === "address"
|
|
487
703
|
? this.loadSavedAddresses().then(() => {
|
|
488
704
|
this.savedAddressesLoaded = true;
|
|
705
|
+
}).finally(() => {
|
|
706
|
+
this.loadingSavedAddresses = false;
|
|
489
707
|
})
|
|
490
708
|
: Promise.resolve(),
|
|
491
709
|
]);
|
|
@@ -523,9 +741,6 @@ const SallaBulletDelivery = class {
|
|
|
523
741
|
console.error("SallaBulletDelivery: Error loading data", e);
|
|
524
742
|
}
|
|
525
743
|
finally {
|
|
526
|
-
// Only hide loading after all data is loaded and UI is ready
|
|
527
|
-
this.loading = false;
|
|
528
|
-
this.modal?.stopLoading();
|
|
529
744
|
this.overrideScopeSwitchUI();
|
|
530
745
|
}
|
|
531
746
|
}
|
|
@@ -560,12 +775,13 @@ const SallaBulletDelivery = class {
|
|
|
560
775
|
this.branches = [];
|
|
561
776
|
this.filteredBranches = [];
|
|
562
777
|
this.newAddressForm = { ...SallaBulletDelivery.INITIAL_ADDRESS_FORM };
|
|
563
|
-
// Reset new state variables
|
|
564
778
|
this.showCartWillBeClearedBanner = false;
|
|
565
779
|
this.allocationOutOfCoverageMessage = null;
|
|
566
780
|
this.locationError = "";
|
|
567
781
|
this.savedAddressesLoaded = false;
|
|
568
782
|
this.loadingSavedAddresses = false;
|
|
783
|
+
this.loadingCountries = false;
|
|
784
|
+
this.resetSearchState();
|
|
569
785
|
}
|
|
570
786
|
getIntentStorage() {
|
|
571
787
|
const rememberLastSession = Boolean(Salla.config.get("store.settings.bullet_delivery.settings.remember_last_session"));
|
|
@@ -692,10 +908,14 @@ const SallaBulletDelivery = class {
|
|
|
692
908
|
? bulletDeliveryAPI.getDistricts(Number(cityId))
|
|
693
909
|
: Promise.resolve([]),
|
|
694
910
|
]);
|
|
695
|
-
if (isSA)
|
|
911
|
+
if (isSA) {
|
|
696
912
|
this.regions = regions;
|
|
913
|
+
this.displayedRegions = this.regions;
|
|
914
|
+
}
|
|
697
915
|
this.cities = cities;
|
|
916
|
+
this.displayedCities = this.cities;
|
|
698
917
|
this.districts = districts;
|
|
918
|
+
this.displayedDistricts = this.districts;
|
|
699
919
|
this.loadingCities = false;
|
|
700
920
|
this.loadingRegions = false;
|
|
701
921
|
this.loadingDistricts = false;
|
|
@@ -738,41 +958,117 @@ const SallaBulletDelivery = class {
|
|
|
738
958
|
const storage = this.getShownStorage();
|
|
739
959
|
storage.set(this.sessionShownKey, true);
|
|
740
960
|
}
|
|
961
|
+
getIPLocationConfig() {
|
|
962
|
+
const configPath = "store.shipping.delivery_location";
|
|
963
|
+
const ipAddress = {
|
|
964
|
+
countryId: Salla.config.get(`${configPath}.country_id`),
|
|
965
|
+
regionId: Salla.config.get(`${configPath}.region_id`),
|
|
966
|
+
cityId: Salla.config.get(`${configPath}.city_id`),
|
|
967
|
+
districtId: Salla.config.get(`${configPath}.district_id`),
|
|
968
|
+
};
|
|
969
|
+
return localStorage.getItem(OVERRIDE_IP_KEY) ?
|
|
970
|
+
JSON.parse(localStorage.getItem(OVERRIDE_IP_KEY)) : ipAddress;
|
|
971
|
+
}
|
|
741
972
|
async loadCountries(skipEagerSubFetch = false) {
|
|
973
|
+
this.loadingCountries = true;
|
|
742
974
|
const forBranch = this.activeTab === "branch";
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
if (
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
975
|
+
try {
|
|
976
|
+
this.countries = await bulletDeliveryAPI.getCountries(forBranch);
|
|
977
|
+
this.displayedCountries = this.countries;
|
|
978
|
+
const { countryId: configCountryId, regionId: configRegionId, cityId: configCityId, districtId: configDistrictId } = this.getIPLocationConfig();
|
|
979
|
+
log("getIPLocationConfig", this.getIPLocationConfig());
|
|
980
|
+
const countryToSelect = configCountryId && this.countries.length > 0
|
|
981
|
+
? this.countries.find((c) => String(c.id) === String(configCountryId))
|
|
982
|
+
: null;
|
|
983
|
+
if (countryToSelect) {
|
|
984
|
+
this.selectedCountry = countryToSelect;
|
|
985
|
+
this.updateNewAddressForm({
|
|
986
|
+
country_id: Number(this.selectedCountry.id),
|
|
987
|
+
});
|
|
988
|
+
// Skip eager sub-fetches when stored intent IDs exist — prefillFromSessionStorage
|
|
989
|
+
// will fire regions/cities/districts in parallel using the stored IDs directly.
|
|
990
|
+
if (!skipEagerSubFetch) {
|
|
991
|
+
const hasIPLocationIds = configRegionId != null ||
|
|
992
|
+
configCityId != null ||
|
|
993
|
+
configDistrictId != null;
|
|
994
|
+
if (hasIPLocationIds) {
|
|
995
|
+
await this.prefillFromIPLocation(countryToSelect, {
|
|
996
|
+
regionId: configRegionId,
|
|
997
|
+
cityId: configCityId,
|
|
998
|
+
districtId: configDistrictId,
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
else if (isSaudiArabia(this.selectedCountry.code)) {
|
|
1002
|
+
await this.loadRegions(this.selectedCountry.id);
|
|
1003
|
+
}
|
|
1004
|
+
else {
|
|
1005
|
+
await this.loadCities(this.selectedCountry.id);
|
|
1006
|
+
}
|
|
763
1007
|
}
|
|
764
1008
|
}
|
|
765
1009
|
}
|
|
1010
|
+
finally {
|
|
1011
|
+
this.loadingCountries = false;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
async prefillFromIPLocation(country, ids) {
|
|
1015
|
+
const isSA = isSaudiArabia(country.code);
|
|
1016
|
+
const { regionId, cityId, districtId } = ids;
|
|
1017
|
+
const [regions, cities, districts] = await Promise.all([
|
|
1018
|
+
isSA ? bulletDeliveryAPI.getRegions(country.id) : Promise.resolve([]),
|
|
1019
|
+
bulletDeliveryAPI.getCities(country.id, isSA && regionId != null ? regionId : undefined),
|
|
1020
|
+
cityId != null
|
|
1021
|
+
? bulletDeliveryAPI.getDistricts(Number(cityId))
|
|
1022
|
+
: Promise.resolve([]),
|
|
1023
|
+
]);
|
|
1024
|
+
if (isSA) {
|
|
1025
|
+
this.regions = regions;
|
|
1026
|
+
this.displayedRegions = this.regions;
|
|
1027
|
+
}
|
|
1028
|
+
this.cities = cities;
|
|
1029
|
+
this.displayedCities = this.cities;
|
|
1030
|
+
this.districts = districts;
|
|
1031
|
+
this.displayedDistricts = this.districts;
|
|
1032
|
+
this.loadingRegions = false;
|
|
1033
|
+
this.loadingCities = false;
|
|
1034
|
+
this.loadingDistricts = false;
|
|
1035
|
+
if (isSA && regionId != null) {
|
|
1036
|
+
const region = this.regions.find((r) => String(r.id) === String(regionId));
|
|
1037
|
+
if (region) {
|
|
1038
|
+
this.selectedRegion = region;
|
|
1039
|
+
this.updateNewAddressForm({ region_id: region.id });
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
if (cityId != null && this.cities.length > 0) {
|
|
1043
|
+
const city = this.cities.find((c) => String(c.id) === String(cityId));
|
|
1044
|
+
if (city) {
|
|
1045
|
+
this.selectedCity = city;
|
|
1046
|
+
this.updateNewAddressForm({ city_id: city.id, city });
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
if (districtId != null && this.districts.length > 0) {
|
|
1050
|
+
const district = this.findPrefillDistrict(districtId);
|
|
1051
|
+
if (district) {
|
|
1052
|
+
this.selectedDistrict = district;
|
|
1053
|
+
this.updateNewAddressForm({
|
|
1054
|
+
district_id: district.id,
|
|
1055
|
+
district,
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
766
1059
|
}
|
|
767
1060
|
async loadCities(countryId, regionId) {
|
|
768
1061
|
this.loadingCities = true;
|
|
769
1062
|
this.cities = [];
|
|
1063
|
+
this.displayedCities = [];
|
|
770
1064
|
this.districts = [];
|
|
1065
|
+
this.displayedDistricts = [];
|
|
771
1066
|
this.selectedCity = null;
|
|
772
1067
|
this.selectedDistrict = null;
|
|
773
1068
|
this.districtName = "";
|
|
774
1069
|
try {
|
|
775
1070
|
this.cities = await bulletDeliveryAPI.getCities(countryId, regionId);
|
|
1071
|
+
this.displayedCities = this.cities;
|
|
776
1072
|
}
|
|
777
1073
|
finally {
|
|
778
1074
|
this.loadingCities = false;
|
|
@@ -781,10 +1077,12 @@ const SallaBulletDelivery = class {
|
|
|
781
1077
|
async loadDistricts(cityId) {
|
|
782
1078
|
this.loadingDistricts = true;
|
|
783
1079
|
this.districts = [];
|
|
1080
|
+
this.displayedDistricts = [];
|
|
784
1081
|
this.selectedDistrict = null;
|
|
785
1082
|
this.districtName = "";
|
|
786
1083
|
try {
|
|
787
1084
|
this.districts = await bulletDeliveryAPI.getDistricts(cityId);
|
|
1085
|
+
this.displayedDistricts = this.districts;
|
|
788
1086
|
}
|
|
789
1087
|
finally {
|
|
790
1088
|
this.loadingDistricts = false;
|
|
@@ -865,7 +1163,6 @@ const SallaBulletDelivery = class {
|
|
|
865
1163
|
}
|
|
866
1164
|
async loadSavedAddresses() {
|
|
867
1165
|
this.savedAddresses = await bulletDeliveryAPI.getSavedAddresses();
|
|
868
|
-
// If session address exists (guest intent before login), select it by default
|
|
869
1166
|
const intent = this.getStoredIntent();
|
|
870
1167
|
const hasSessionAddress = hasSessionAddressIntent(intent);
|
|
871
1168
|
if (hasSessionAddress) {
|
|
@@ -873,13 +1170,11 @@ const SallaBulletDelivery = class {
|
|
|
873
1170
|
this.selectedSavedAddress = null;
|
|
874
1171
|
}
|
|
875
1172
|
else {
|
|
876
|
-
// Select default address if available and valid
|
|
877
1173
|
const defaultAddress = this.savedAddresses.find((a) => a.is_default && a.is_in_coverage !== false);
|
|
878
1174
|
if (defaultAddress) {
|
|
879
1175
|
this.selectedSavedAddress = defaultAddress;
|
|
880
1176
|
}
|
|
881
1177
|
else {
|
|
882
|
-
// Select first valid address
|
|
883
1178
|
const validAddress = this.savedAddresses.find((a) => a.is_in_coverage !== false);
|
|
884
1179
|
if (validAddress) {
|
|
885
1180
|
this.selectedSavedAddress = validAddress;
|
|
@@ -891,12 +1186,22 @@ const SallaBulletDelivery = class {
|
|
|
891
1186
|
this.selectedCountry = newCountry;
|
|
892
1187
|
this.selectedRegion = null;
|
|
893
1188
|
this.regions = [];
|
|
1189
|
+
this.displayedRegions = [];
|
|
894
1190
|
this.cities = [];
|
|
1191
|
+
this.displayedCities = [];
|
|
895
1192
|
this.districts = [];
|
|
1193
|
+
this.displayedDistricts = [];
|
|
896
1194
|
this.selectedCity = null;
|
|
897
1195
|
this.selectedDistrict = null;
|
|
898
1196
|
this.districtName = "";
|
|
899
1197
|
this.allocationOutOfCoverageMessage = null;
|
|
1198
|
+
this.regionSearchQuery = '';
|
|
1199
|
+
this.citySearchQuery = '';
|
|
1200
|
+
this.districtSearchQuery = '';
|
|
1201
|
+
this.searchingRegions = false;
|
|
1202
|
+
this.searchingCities = false;
|
|
1203
|
+
this.searchingDistricts = false;
|
|
1204
|
+
this.clearSearchTimers();
|
|
900
1205
|
if (this.selectedCountry) {
|
|
901
1206
|
this.updateNewAddressForm({
|
|
902
1207
|
country_id: Number(this.selectedCountry.id),
|
|
@@ -920,14 +1225,18 @@ const SallaBulletDelivery = class {
|
|
|
920
1225
|
async loadRegions(countryId) {
|
|
921
1226
|
this.loadingRegions = true;
|
|
922
1227
|
this.regions = [];
|
|
1228
|
+
this.displayedRegions = [];
|
|
923
1229
|
this.selectedRegion = null;
|
|
924
1230
|
this.cities = [];
|
|
1231
|
+
this.displayedCities = [];
|
|
925
1232
|
this.districts = [];
|
|
1233
|
+
this.displayedDistricts = [];
|
|
926
1234
|
this.selectedCity = null;
|
|
927
1235
|
this.selectedDistrict = null;
|
|
928
1236
|
this.districtName = "";
|
|
929
1237
|
try {
|
|
930
1238
|
this.regions = await bulletDeliveryAPI.getRegions(countryId);
|
|
1239
|
+
this.displayedRegions = this.regions;
|
|
931
1240
|
}
|
|
932
1241
|
finally {
|
|
933
1242
|
this.loadingRegions = false;
|
|
@@ -1004,6 +1313,29 @@ const SallaBulletDelivery = class {
|
|
|
1004
1313
|
}
|
|
1005
1314
|
}, BRANCH_SEARCH_DEBOUNCE_MS);
|
|
1006
1315
|
}
|
|
1316
|
+
clearSearchTimers() {
|
|
1317
|
+
[this.countrySearchTimer, this.regionSearchTimer, this.citySearchTimer, this.districtSearchTimer]
|
|
1318
|
+
.forEach(t => {
|
|
1319
|
+
if (t)
|
|
1320
|
+
clearTimeout(t);
|
|
1321
|
+
});
|
|
1322
|
+
this.countrySearchTimer = this.regionSearchTimer = this.citySearchTimer = this.districtSearchTimer = null;
|
|
1323
|
+
}
|
|
1324
|
+
resetSearchState() {
|
|
1325
|
+
this.countrySearchQuery = '';
|
|
1326
|
+
this.regionSearchQuery = '';
|
|
1327
|
+
this.citySearchQuery = '';
|
|
1328
|
+
this.districtSearchQuery = '';
|
|
1329
|
+
this.searchingCountries = false;
|
|
1330
|
+
this.searchingRegions = false;
|
|
1331
|
+
this.searchingCities = false;
|
|
1332
|
+
this.searchingDistricts = false;
|
|
1333
|
+
this.displayedCountries = [];
|
|
1334
|
+
this.displayedRegions = [];
|
|
1335
|
+
this.displayedCities = [];
|
|
1336
|
+
this.displayedDistricts = [];
|
|
1337
|
+
this.clearSearchTimers();
|
|
1338
|
+
}
|
|
1007
1339
|
async loadBranchesWithLocation(lat, lng) {
|
|
1008
1340
|
this.loadingBranches = true;
|
|
1009
1341
|
try {
|
|
@@ -1128,14 +1460,26 @@ const SallaBulletDelivery = class {
|
|
|
1128
1460
|
this.activeTab = tab;
|
|
1129
1461
|
this.showCartWillBeClearedBanner = false;
|
|
1130
1462
|
this.allocationOutOfCoverageMessage = null;
|
|
1131
|
-
|
|
1463
|
+
this.resetSearchState();
|
|
1132
1464
|
const forBranch = tab === "branch";
|
|
1133
1465
|
this.countries = await bulletDeliveryAPI.getCountries(forBranch);
|
|
1466
|
+
this.displayedCountries = this.countries;
|
|
1134
1467
|
const previousCountryId = this.selectedCountry?.id;
|
|
1135
1468
|
if (previousCountryId !== undefined && previousCountryId !== null) {
|
|
1136
1469
|
this.selectedCountry =
|
|
1137
1470
|
this.countries.find((c) => c.id === previousCountryId) || null;
|
|
1138
1471
|
}
|
|
1472
|
+
// Fallback to IP-detected country when carry-over fails
|
|
1473
|
+
if (!this.selectedCountry) {
|
|
1474
|
+
const { countryId: configCountryId } = this.getIPLocationConfig();
|
|
1475
|
+
if (configCountryId && this.countries.length > 0) {
|
|
1476
|
+
this.selectedCountry =
|
|
1477
|
+
this.countries.find((c) => String(c.id) === String(configCountryId)) || null;
|
|
1478
|
+
}
|
|
1479
|
+
if (!this.selectedCountry && this.countries.length === 1) {
|
|
1480
|
+
this.selectedCountry = this.countries[0];
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1139
1483
|
// Load appropriate data when switching tabs if country is selected
|
|
1140
1484
|
if (this.selectedCountry) {
|
|
1141
1485
|
if (tab === "branch") {
|
|
@@ -1385,7 +1729,6 @@ const SallaBulletDelivery = class {
|
|
|
1385
1729
|
(this.activeTab === "address"
|
|
1386
1730
|
? Salla.lang.get("pages.checkout.address_out_of_coverage")
|
|
1387
1731
|
: Salla.lang.get("pages.checkout.failed_to_set_pickup"));
|
|
1388
|
-
Salla.notify?.error(errorMessage);
|
|
1389
1732
|
this.allocationOutOfCoverageMessage = errorMessage;
|
|
1390
1733
|
this.confirmBtn?.stop();
|
|
1391
1734
|
this.confirming = false;
|
|
@@ -1430,6 +1773,7 @@ const SallaBulletDelivery = class {
|
|
|
1430
1773
|
this.setStoredIntent(result);
|
|
1431
1774
|
if (allocatedScopeId) {
|
|
1432
1775
|
await bulletDeliveryAPI.setDeliveryScope(allocatedScopeId);
|
|
1776
|
+
clearApiCache();
|
|
1433
1777
|
}
|
|
1434
1778
|
const allocationConfirmedPayload = {
|
|
1435
1779
|
...result,
|
|
@@ -1532,12 +1876,6 @@ const SallaBulletDelivery = class {
|
|
|
1532
1876
|
wrapper.append(info, btn);
|
|
1533
1877
|
return wrapper;
|
|
1534
1878
|
}
|
|
1535
|
-
renderSkeleton() {
|
|
1536
|
-
return (index.h("div", { slot: "loading", class: "s-bullet-delivery-skeleton" }, index.h("div", { class: "s-bullet-delivery-skeleton-header" }, index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-title", height: "28px", width: "68%" }), index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-subtitle", height: "18px", width: "84%" })), index.h("div", { class: {
|
|
1537
|
-
"s-bullet-delivery-skeleton-tabs": true,
|
|
1538
|
-
"s-bullet-delivery-skeleton-tabs--single": !this.supportsPickup,
|
|
1539
|
-
} }, index.h("div", { class: "s-bullet-delivery-skeleton-tab" }, index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-tab-icon", height: "32px", width: "32px" }), index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-tab-label", height: "18px", width: "92px" })), this.supportsPickup && (index.h("div", { class: "s-bullet-delivery-skeleton-tab" }, index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-tab-icon", height: "32px", width: "32px" }), index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-tab-label", height: "18px", width: "84px" })))), index.h("div", { class: "s-bullet-delivery-skeleton-content" }, index.h("div", { class: "s-bullet-delivery-skeleton-field" }, index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-field-label", height: "16px", width: "96px" }), index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-field-control", height: "56px", width: "100%" })), index.h("div", { class: "s-bullet-delivery-skeleton-field" }, index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-field-label", height: "16px", width: "104px" }), index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-field-control", height: "56px", width: "100%" })), index.h("div", { class: "s-bullet-delivery-skeleton-field" }, index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-field-label", height: "16px", width: "88px" }), index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-field-control", height: "56px", width: "100%" }))), index.h("div", { class: "s-bullet-delivery-skeleton-footer" }, index.h("salla-skeleton", { height: "52px", width: "100%" }))));
|
|
1540
|
-
}
|
|
1541
1879
|
renderTabs() {
|
|
1542
1880
|
// Show tabs only when pickup is supported; otherwise delivery-only view with no tabs
|
|
1543
1881
|
if (!this.supportsPickup)
|
|
@@ -1559,56 +1897,22 @@ const SallaBulletDelivery = class {
|
|
|
1559
1897
|
return this.renderAlert(message);
|
|
1560
1898
|
}
|
|
1561
1899
|
renderCountrySelect() {
|
|
1562
|
-
return (index.h("div", { class: "s-bullet-delivery-field" }, index.h("
|
|
1563
|
-
const select = e.target;
|
|
1564
|
-
const countryId = Number.parseInt(select.value);
|
|
1565
|
-
const country = this.countries.find((c) => c.id === countryId);
|
|
1566
|
-
// A "switch" means the user already had a country and picked a different one
|
|
1567
|
-
const isCountrySwitch = this.selectedCountry &&
|
|
1568
|
-
country &&
|
|
1569
|
-
this.selectedCountry.code !== country.code;
|
|
1570
|
-
// Show the info banner whenever a country is changed to a different one
|
|
1571
|
-
this.showCartWillBeClearedBanner = !!isCountrySwitch;
|
|
1572
|
-
this.applyCountryChange(country || null);
|
|
1573
|
-
} }, index.h("option", { value: "", disabled: true, selected: !this.selectedCountry }, Salla.lang.get("pages.checkout.select_country")), this.countries.map((country) => (index.h("option", { key: country.id, value: country.id, selected: this.selectedCountry?.id === country.id }, country.name))))));
|
|
1574
|
-
}
|
|
1575
|
-
renderSelectLoader() {
|
|
1576
|
-
return (index.h("span", { class: "s-bullet-delivery-select-loader", "aria-hidden": "true" }, index.h("salla-skeleton", { height: "16px", width: "16px" })));
|
|
1577
|
-
}
|
|
1578
|
-
renderLoadingLabel(label, htmlFor, isLoading = false, isRequired = true) {
|
|
1579
|
-
return (index.h("label", { class: "s-bullet-delivery-label", htmlFor: htmlFor }, index.h("span", { class: "s-bullet-delivery-label-content" }, index.h("span", null, label, isRequired && index.h("span", { class: "text-red-500" }, " *")), isLoading && this.renderSelectLoader())));
|
|
1900
|
+
return (index.h("div", { class: "s-bullet-delivery-field" }, index.h("salla-searchable-dropdown", { label: Salla.lang.get("blocks.buy_as_gift.receiver_country"), placeholder: Salla.lang.get("pages.checkout.select_country"), items: this.displayedCountries, selectedItem: this.selectedCountry, loading: this.loadingCountries, searching: this.searchingCountries, disabled: this.countries.length <= 1, required: true, inputId: "bullet-delivery-country", searchQuery: this.countrySearchQuery, clientSearch: true, onItemSelected: (e) => this.handleCountrySelected(e.detail), onSearchInput: (e) => this.handleCountrySearch(e.detail), onDropdownClosed: () => this.handleCountryDropdownClosed() })));
|
|
1580
1901
|
}
|
|
1581
1902
|
/** Region select (SA only): shown when SA is selected; city and district disabled until region selected. */
|
|
1582
1903
|
renderRegionSelect() {
|
|
1583
1904
|
const isSA = isSaudiArabia(this.selectedCountry?.code ?? '');
|
|
1584
1905
|
if (!isSA || !this.selectedCountry)
|
|
1585
1906
|
return null;
|
|
1586
|
-
return (index.h("div", { class: "s-bullet-delivery-field" },
|
|
1587
|
-
const select = e.target;
|
|
1588
|
-
const regionId = Number.parseInt(select.value);
|
|
1589
|
-
const region = this.regions.find((r) => r.id === regionId);
|
|
1590
|
-
this.selectedRegion = region || null;
|
|
1591
|
-
this.updateNewAddressForm({
|
|
1592
|
-
region_id: region?.id,
|
|
1593
|
-
city_id: undefined,
|
|
1594
|
-
district_id: undefined,
|
|
1595
|
-
city: undefined,
|
|
1596
|
-
district: undefined,
|
|
1597
|
-
});
|
|
1598
|
-
if (region && this.selectedCountry) {
|
|
1599
|
-
this.loadCities(this.selectedCountry.id, region.id);
|
|
1600
|
-
}
|
|
1601
|
-
} }, index.h("option", { value: "", disabled: true, selected: !this.selectedRegion }, Salla.lang.get("pages.checkout.select_region")), this.regions.map((region) => (index.h("option", { key: region.id, value: region.id, selected: this.selectedRegion?.id === region.id }, region.name))))));
|
|
1907
|
+
return (index.h("div", { class: "s-bullet-delivery-field" }, index.h("salla-searchable-dropdown", { label: Salla.lang.get("pages.checkout.region_field"), placeholder: Salla.lang.get("pages.checkout.select_region"), items: this.displayedRegions, selectedItem: this.selectedRegion, loading: this.loadingRegions, searching: this.searchingRegions, disabled: this.loadingRegions || this.regions.length === 0, required: true, inputId: "bullet-delivery-region", searchQuery: this.regionSearchQuery, clientSearch: true, onItemSelected: (e) => this.handleRegionSelected(e.detail), onSearchInput: (e) => this.handleRegionSearch(e.detail), onDropdownClosed: () => this.handleRegionDropdownClosed() })));
|
|
1602
1908
|
}
|
|
1603
1909
|
renderCityDistrictSelects() {
|
|
1604
|
-
// Guest form: region + district only for SA; other countries get country + city only
|
|
1605
1910
|
const isSA = isSaudiArabia(this.selectedCountry?.code ?? '');
|
|
1606
1911
|
const showDistrict = isSA;
|
|
1607
1912
|
const showDistrictInput = showDistrict &&
|
|
1608
1913
|
this.selectedCity &&
|
|
1609
1914
|
!this.loadingDistricts &&
|
|
1610
1915
|
this.districts.length === 0;
|
|
1611
|
-
// For SA: city disabled until region selected; for non-SA: city disabled until country selected
|
|
1612
1916
|
const cityDisabled = !this.selectedCountry ||
|
|
1613
1917
|
(isSA && !this.selectedRegion) ||
|
|
1614
1918
|
this.loadingCities ||
|
|
@@ -1617,39 +1921,11 @@ const SallaBulletDelivery = class {
|
|
|
1617
1921
|
(isSA && !this.selectedRegion) ||
|
|
1618
1922
|
!this.selectedCity ||
|
|
1619
1923
|
this.loadingDistricts;
|
|
1620
|
-
return (index.h("div", { class: "s-bullet-delivery-field-row" }, index.h("div", { class: "s-bullet-delivery-field" },
|
|
1621
|
-
const select = e.target;
|
|
1622
|
-
const cityId = Number.parseInt(select.value);
|
|
1623
|
-
const city = this.cities.find((c) => c.id === cityId);
|
|
1624
|
-
this.selectedCity = city || null;
|
|
1625
|
-
this.selectedDistrict = null;
|
|
1626
|
-
this.districtName = "";
|
|
1627
|
-
if (city) {
|
|
1628
|
-
this.updateNewAddressForm({ city: city, district: undefined });
|
|
1629
|
-
if (showDistrict) {
|
|
1630
|
-
this.loadDistricts(city.id);
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
} }, index.h("option", { value: "", disabled: true, selected: !this.selectedCity }, Salla.lang.get("pages.checkout.select_city")), this.cities.map((city) => (index.h("option", { key: city.id, value: city.id, selected: this.selectedCity?.id === city.id }, city.name))))), showDistrict && (index.h("div", { class: "s-bullet-delivery-field" }, this.renderLoadingLabel(Salla.lang.get("pages.checkout.district_field"), "bullet-delivery-district", this.loadingDistricts && !showDistrictInput), showDistrictInput ? (index.h("input", { id: "bullet-delivery-district", type: "text", class: "form-input", placeholder: Salla.lang.get("pages.checkout.select_district"), value: this.districtName, disabled: districtDisabled, onInput: (e) => {
|
|
1924
|
+
return (index.h("div", { class: "s-bullet-delivery-field-row" }, index.h("div", { class: "s-bullet-delivery-field" }, index.h("salla-searchable-dropdown", { label: Salla.lang.get("blocks.buy_as_gift.receiver_city"), placeholder: Salla.lang.get("pages.checkout.select_city"), items: this.displayedCities, selectedItem: this.selectedCity, loading: this.loadingCities, searching: this.searchingCities, disabled: cityDisabled, required: true, inputId: "bullet-delivery-city", searchQuery: this.citySearchQuery, onItemSelected: (e) => this.handleCitySelected(e.detail), onSearchInput: (e) => this.handleCitySearch(e.detail), onDropdownClosed: () => this.handleCityDropdownClosed(), dropUp: true })), showDistrict && (index.h("div", { class: "s-bullet-delivery-field" }, showDistrictInput ? (index.h("div", null, index.h("label", { class: "s-bullet-delivery-label", htmlFor: "bullet-delivery-district" }, Salla.lang.get("pages.checkout.district_field"), index.h("span", { class: "text-red-500" }, " *")), index.h("input", { id: "bullet-delivery-district", type: "text", class: "form-input", placeholder: Salla.lang.get("pages.checkout.select_district"), value: this.districtName, disabled: districtDisabled, onInput: (e) => {
|
|
1634
1925
|
const input = e.target;
|
|
1635
1926
|
this.districtName = input.value;
|
|
1636
1927
|
this.updateNewAddressForm({ district: undefined });
|
|
1637
|
-
} })) : (index.h("
|
|
1638
|
-
const select = e.target;
|
|
1639
|
-
const districtId = Number.parseInt(select.value);
|
|
1640
|
-
const district = this.districts.find((d) => d.id === districtId);
|
|
1641
|
-
this.selectedDistrict = district || null;
|
|
1642
|
-
this.districtName = "";
|
|
1643
|
-
if (district) {
|
|
1644
|
-
this.updateNewAddressForm({ district });
|
|
1645
|
-
}
|
|
1646
|
-
} }, index.h("option", { value: "", disabled: true, selected: !this.selectedDistrict }, Salla.lang.get("pages.checkout.select_district")), this.districts.map((district) => {
|
|
1647
|
-
const langCode = Salla.config.get("user.language_code");
|
|
1648
|
-
const label = langCode === "ar"
|
|
1649
|
-
? district.name
|
|
1650
|
-
: (district.name_en ?? district.name);
|
|
1651
|
-
return (index.h("option", { key: district.id, value: district.id, selected: this.selectedDistrict?.id === district.id }, label));
|
|
1652
|
-
})))))));
|
|
1928
|
+
} }))) : (index.h("salla-searchable-dropdown", { label: Salla.lang.get("pages.checkout.district_field"), placeholder: Salla.lang.get("pages.checkout.select_district"), items: this.displayedDistricts, selectedItem: this.selectedDistrict, loading: this.loadingDistricts, searching: this.searchingDistricts, disabled: districtDisabled || this.districts.length === 0, required: true, inputId: "bullet-delivery-district", searchQuery: this.districtSearchQuery, clientSearch: true, onItemSelected: (e) => this.handleDistrictSelected(e.detail), onSearchInput: (e) => this.handleDistrictSearch(e.detail), onDropdownClosed: () => this.handleDistrictDropdownClosed(), dropUp: true }))))));
|
|
1653
1929
|
}
|
|
1654
1930
|
renderSavedAddressesEmptyState() {
|
|
1655
1931
|
return (index.h("div", { class: "s-bullet-delivery-saved-addresses-empty" }, index.h("div", { class: "s-bullet-delivery-saved-addresses-empty-icon", "aria-hidden": "true" }, index.h("svg", { width: "28", height: "28", viewBox: "0 0 28 29", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, index.h("title", null, "No Saved Adresses"), index.h("path", { d: "M20.16 0C21.4613 0 22.6773 0.341333 23.808 1.024C24.9387 1.70667 25.8347 2.61333 26.496 3.744C27.1787 4.91733 27.52 6.18667 27.52 7.552C27.52 9.45067 26.8267 11.232 25.44 12.896C24.4587 14.0907 23.0827 15.2427 21.312 16.352H21.28C20.9387 16.5653 20.5653 16.672 20.16 16.672C19.7547 16.672 19.3813 16.5653 19.04 16.352H19.008C17.2373 15.2213 15.8613 14.0693 14.88 12.896C13.4933 11.232 12.8 9.45067 12.8 7.552C12.8 6.18667 13.1413 4.91733 13.824 3.744C14.4853 2.61333 15.3813 1.70667 16.512 1.024C17.6427 0.341333 18.8587 0 20.16 0ZM11.488 1.984C9.67467 2.368 8.04267 3.14667 6.592 4.32C5.14133 5.49333 4.01067 6.92267 3.2 8.608C2.34667 10.3573 1.92 12.224 1.92 14.208C1.92 14.72 1.952 15.2427 2.016 15.776L2.08 15.744C2.57067 15.488 2.94933 15.3067 3.216 15.2C3.48267 15.0933 3.73867 15.0933 3.984 15.2C4.22933 15.3067 4.4 15.488 4.496 15.744C4.592 16 4.58667 16.256 4.48 16.512C4.37333 16.768 4.19733 16.9493 3.952 17.056C3.70667 17.1627 3.36 17.3227 2.912 17.536L2.656 17.664C2.57067 17.7067 2.48533 17.7387 2.4 17.76C2.89067 19.4667 3.70133 20.9973 4.832 22.352C5.96267 23.7067 7.296 24.7573 8.832 25.504C10.432 26.272 12.1173 26.656 13.888 26.656C15.4667 26.656 16.9813 26.3467 18.432 25.728C19.8187 25.1307 21.0667 24.288 22.176 23.2C21.92 23.0507 21.7653 22.8373 21.712 22.56C21.6587 22.2827 21.7013 22.0267 21.84 21.792C21.9787 21.5573 22.176 21.408 22.432 21.344C22.8373 21.2587 23.2 21.12 23.52 20.928C23.6907 20.8427 23.8613 20.8 24.032 20.8C24.8 19.5413 25.3333 18.176 25.632 16.704C25.6747 16.4267 25.808 16.2133 26.032 16.064C26.256 15.9147 26.496 15.8667 26.752 15.92C27.008 15.9733 27.2107 16.1173 27.36 16.352C27.5093 16.5867 27.552 16.832 27.488 17.088C27.0613 19.2853 26.1973 21.264 24.896 23.024C23.5947 24.784 22.0053 26.1547 20.128 27.136C18.1653 28.16 16.0853 28.672 13.888 28.672C11.3707 28.672 9.03467 28.0107 6.88 26.688C4.78933 25.408 3.12533 23.68 1.888 21.504C0.629333 19.264 0 16.832 0 14.208C0 11.904 0.490667 9.73867 1.472 7.712C2.41067 5.74933 3.728 4.09067 5.424 2.736C7.12 1.38133 9.01333 0.48 11.104 0.032C11.36 -0.032 11.6 0.0106667 11.824 0.16C12.048 0.309333 12.1867 0.522667 12.24 0.8C12.2933 1.07733 12.2453 1.328 12.096 1.552C11.9467 1.776 11.744 1.92 11.488 1.984ZM14.72 7.552C14.72 8.96 15.2533 10.304 16.32 11.584C17.1733 12.5867 18.3893 13.6 19.968 14.624C20.032 14.6453 20.096 14.656 20.16 14.656C20.224 14.656 20.288 14.6453 20.352 14.624C21.9307 13.6213 23.1467 12.608 24 11.584C25.0667 10.304 25.6 8.96 25.6 7.552C25.6 6.57067 25.3547 5.65333 24.864 4.8C24.3733 3.94667 23.7067 3.26933 22.864 2.768C22.0213 2.26667 21.12 2.016 20.16 2.016C19.2 2.016 18.2987 2.26667 17.456 2.768C16.6133 3.26933 15.9467 3.94667 15.456 4.8C14.9653 5.65333 14.72 6.57067 14.72 7.552ZM17.28 7.68C17.28 6.848 17.5627 6.13867 18.128 5.552C18.6933 4.96533 19.3707 4.672 20.16 4.672C20.9493 4.672 21.6267 4.96533 22.192 5.552C22.7573 6.13867 23.04 6.848 23.04 7.68C23.04 8.512 22.7573 9.216 22.192 9.792C21.6267 10.368 20.9493 10.656 20.16 10.656C19.3707 10.656 18.6933 10.368 18.128 9.792C17.5627 9.216 17.28 8.512 17.28 7.68ZM6.752 14.688C7.62667 14.7733 8.53333 15.0293 9.472 15.456C9.70667 15.5627 9.87733 15.744 9.984 16C10.0907 16.256 10.0907 16.512 9.984 16.768C9.87733 17.024 9.70133 17.2 9.456 17.296C9.21067 17.392 8.97067 17.3867 8.736 17.28C7.94667 16.9387 7.22133 16.736 6.56 16.672C6.28267 16.6293 6.064 16.5013 5.904 16.288C5.744 16.0747 5.68 15.8293 5.712 15.552C5.744 15.2747 5.86133 15.0507 6.064 14.88C6.26667 14.7093 6.496 14.6453 6.752 14.688ZM17.6 20.544C18.304 20.864 18.976 21.0987 19.616 21.248C19.872 21.312 20.0693 21.4613 20.208 21.696C20.3467 21.9307 20.3893 22.1813 20.336 22.448C20.2827 22.7147 20.144 22.9227 19.92 23.072C19.696 23.2213 19.4453 23.264 19.168 23.2C18.4213 23.0293 17.632 22.752 16.8 22.368C16.5653 22.2613 16.4 22.08 16.304 21.824C16.208 21.568 16.2133 21.312 16.32 21.056C16.4267 20.8 16.6027 20.624 16.848 20.528C17.0933 20.432 17.344 20.4373 17.6 20.544ZM12.832 17.44C13.0027 17.568 13.248 17.7493 13.568 17.984L14.496 18.688C14.7093 18.8587 14.8373 19.0773 14.88 19.344C14.9227 19.6107 14.8693 19.856 14.72 20.08C14.5707 20.304 14.368 20.4427 14.112 20.496C13.856 20.5493 13.6107 20.5013 13.376 20.352L11.744 19.072C11.5307 18.9227 11.4027 18.7093 11.36 18.432C11.3173 18.1547 11.3707 17.904 11.52 17.68C11.6693 17.456 11.872 17.3227 12.128 17.28C12.384 17.2373 12.6187 17.2907 12.832 17.44ZM20.16 8.672C20.416 8.672 20.64 8.576 20.832 8.384C21.024 8.192 21.12 7.95733 21.12 7.68C21.12 7.40267 21.024 7.16267 20.832 6.96C20.64 6.75733 20.416 6.656 20.16 6.656C19.904 6.656 19.68 6.75733 19.488 6.96C19.296 7.16267 19.2 7.40267 19.2 7.68C19.2 7.95733 19.296 8.192 19.488 8.384C19.68 8.576 19.904 8.672 20.16 8.672Z", fill: "#666666" }))), index.h("p", { class: "s-bullet-delivery-saved-addresses-empty-title" }, Salla.lang.get("pages.checkout.no_saved_addresses")), index.h("p", { class: "s-bullet-delivery-saved-addresses-empty-desc" }, Salla.lang.get("pages.checkout.add_address_simplify_shipping")), index.h("salla-button", { onClick: () => this.handleAddNewAddress(), onKeyUp: () => this.handleAddNewAddress() }, Salla.lang.get("pages.checkout.add_new_address"))));
|
|
@@ -1825,7 +2101,8 @@ const SallaBulletDelivery = class {
|
|
|
1825
2101
|
const submitLabel = this.savingAddress
|
|
1826
2102
|
? Salla.lang.get("pages.checkout.loading")
|
|
1827
2103
|
: Salla.lang.get("pages.checkout.confirm_address");
|
|
1828
|
-
|
|
2104
|
+
const hasAddressesToGoBack = this.savedAddresses.length > 0 || hasSessionAddressIntent(this.getStoredIntent());
|
|
2105
|
+
return (index.h("div", { class: "s-bullet-delivery-add-address" }, index.h("div", { class: "s-bullet-delivery-add-address-header" }, hasAddressesToGoBack ? (index.h("button", { type: "button", class: "s-bullet-delivery-add-address-title", onClick: () => this.handleBackToAddressList(), onKeyDown: (e) => e.key === "Enter" && this.handleBackToAddressList() }, index.h("span", { innerHTML: this.isRTL ? keyboard_arrow_right.ArrowRightIcon : keyboard_arrow_right.ArrowLeftIcon, "aria-hidden": "true" }), index.h("span", { class: "s-bullet-delivery-add-address-title-text" }, title))) : (index.h("span", { class: "s-bullet-delivery-add-address-title" }, index.h("span", { class: "s-bullet-delivery-add-address-title-text" }, title)))), index.h("form", { class: "s-bullet-delivery-add-address-form", onSubmit: (e) => this.handleSubmitAddAddress(e) }, this.renderGuestDeliveryForm(), index.h("div", { class: "s-bullet-delivery-form-actions s-bullet-delivery-form-actions--single" }, index.h("salla-button", { type: "submit", loading: this.savingAddress, disabled: !canSubmit || this.savingAddress, class: "s-bullet-delivery-add-address-submit" }, submitLabel)))));
|
|
1829
2106
|
}
|
|
1830
2107
|
renderFooter() {
|
|
1831
2108
|
const showAddAddressInFooter = this.activeTab === "address" && this.isLoggedIn;
|
|
@@ -1968,9 +2245,9 @@ const SallaBulletDelivery = class {
|
|
|
1968
2245
|
}
|
|
1969
2246
|
}
|
|
1970
2247
|
render() {
|
|
1971
|
-
return (index.h(index.Host, { key: '
|
|
2248
|
+
return (index.h(index.Host, { key: '0daead232faa6590712faef140ab694b3324960e', class: "s-bullet-delivery" }, index.h("salla-modal", { key: '4f318a88c10b524d5f6b71a46cb93535d4b25a82', ref: (modal) => {
|
|
1972
2249
|
this.modal = modal;
|
|
1973
|
-
}, isClosable: !this.isRequired && !this.shouldForceNonClosable(), class: "s-bullet-delivery-modal",
|
|
2250
|
+
}, isClosable: !this.isRequired && !this.shouldForceNonClosable(), class: "s-bullet-delivery-modal", width: "sm" }, index.h("div", { key: '66f3d844ce325e47bfb52f941c038339f3f0cf6c', class: "s-bullet-delivery-inner" }, this.viewMode === "main" && this.renderMainView(), this.viewMode === "add-address" && this.renderAddAddressForm()))));
|
|
1974
2251
|
}
|
|
1975
2252
|
componentDidLoad() {
|
|
1976
2253
|
// Mark component as ready
|
|
@@ -2069,6 +2346,224 @@ SallaBulletDelivery.INITIAL_ADDRESS_FORM = {
|
|
|
2069
2346
|
postal_code: undefined,
|
|
2070
2347
|
description: undefined,
|
|
2071
2348
|
};
|
|
2349
|
+
SallaBulletDelivery.DROPDOWN_SEARCH_DEBOUNCE_MS = 400;
|
|
2350
|
+
SallaBulletDelivery.DROPDOWN_SEARCH_MIN_CHARS = 2;
|
|
2072
2351
|
SallaBulletDelivery.style = sallaBulletDeliveryCss;
|
|
2073
2352
|
|
|
2353
|
+
const SallaSearchableDropdown = class {
|
|
2354
|
+
constructor(hostRef) {
|
|
2355
|
+
index.registerInstance(this, hostRef);
|
|
2356
|
+
this.itemSelected = index.createEvent(this, "itemSelected");
|
|
2357
|
+
this.searchInput = index.createEvent(this, "searchInput");
|
|
2358
|
+
this.dropdownOpened = index.createEvent(this, "dropdownOpened");
|
|
2359
|
+
this.dropdownClosed = index.createEvent(this, "dropdownClosed");
|
|
2360
|
+
this.placeholder = '';
|
|
2361
|
+
this.items = [];
|
|
2362
|
+
this.selectedItem = null;
|
|
2363
|
+
this.loading = false;
|
|
2364
|
+
this.searching = false;
|
|
2365
|
+
this.disabled = false;
|
|
2366
|
+
this.required = false;
|
|
2367
|
+
this.noResultsText = '';
|
|
2368
|
+
this.inputId = '';
|
|
2369
|
+
this.searchQuery = '';
|
|
2370
|
+
this.clientSearch = false;
|
|
2371
|
+
this.dropUp = false;
|
|
2372
|
+
this.isOpen = false;
|
|
2373
|
+
this.focusedIndex = -1;
|
|
2374
|
+
this.clientSearchQuery = '';
|
|
2375
|
+
this.scrollableAncestor = null;
|
|
2376
|
+
this.handleTriggerClick = () => {
|
|
2377
|
+
if (this.isOpen) {
|
|
2378
|
+
this.close();
|
|
2379
|
+
}
|
|
2380
|
+
else {
|
|
2381
|
+
this.open();
|
|
2382
|
+
}
|
|
2383
|
+
};
|
|
2384
|
+
this.handleTriggerKeyDown = (e) => {
|
|
2385
|
+
if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown') {
|
|
2386
|
+
e.preventDefault();
|
|
2387
|
+
if (!this.isOpen)
|
|
2388
|
+
this.open();
|
|
2389
|
+
}
|
|
2390
|
+
else if (e.key === 'Escape') {
|
|
2391
|
+
this.close();
|
|
2392
|
+
}
|
|
2393
|
+
};
|
|
2394
|
+
this.handleSearchInputChange = (e) => {
|
|
2395
|
+
const value = e.target.value;
|
|
2396
|
+
if (this.clientSearch) {
|
|
2397
|
+
this.clientSearchQuery = value;
|
|
2398
|
+
}
|
|
2399
|
+
this.searchInput.emit(value);
|
|
2400
|
+
this.focusedIndex = -1;
|
|
2401
|
+
};
|
|
2402
|
+
this.handleSearchKeyDown = (e) => {
|
|
2403
|
+
const visibleItems = this.filteredItems;
|
|
2404
|
+
const itemCount = visibleItems.length;
|
|
2405
|
+
switch (e.key) {
|
|
2406
|
+
case 'ArrowDown':
|
|
2407
|
+
e.preventDefault();
|
|
2408
|
+
this.focusedIndex = itemCount > 0
|
|
2409
|
+
? (this.focusedIndex + 1) % itemCount
|
|
2410
|
+
: -1;
|
|
2411
|
+
this.scrollFocusedIntoView();
|
|
2412
|
+
break;
|
|
2413
|
+
case 'ArrowUp':
|
|
2414
|
+
e.preventDefault();
|
|
2415
|
+
this.focusedIndex = itemCount > 0
|
|
2416
|
+
? (this.focusedIndex - 1 + itemCount) % itemCount
|
|
2417
|
+
: -1;
|
|
2418
|
+
this.scrollFocusedIntoView();
|
|
2419
|
+
break;
|
|
2420
|
+
case 'Enter':
|
|
2421
|
+
e.preventDefault();
|
|
2422
|
+
if (this.focusedIndex >= 0 && this.focusedIndex < itemCount) {
|
|
2423
|
+
this.selectItem(visibleItems[this.focusedIndex]);
|
|
2424
|
+
}
|
|
2425
|
+
break;
|
|
2426
|
+
case 'Escape':
|
|
2427
|
+
e.preventDefault();
|
|
2428
|
+
this.close();
|
|
2429
|
+
break;
|
|
2430
|
+
}
|
|
2431
|
+
};
|
|
2432
|
+
}
|
|
2433
|
+
connectedCallback() {
|
|
2434
|
+
this.boundHandleClickOutside = this.handleClickOutside.bind(this);
|
|
2435
|
+
document.addEventListener('mousedown', this.boundHandleClickOutside);
|
|
2436
|
+
}
|
|
2437
|
+
disconnectedCallback() {
|
|
2438
|
+
document.removeEventListener('mousedown', this.boundHandleClickOutside);
|
|
2439
|
+
if (this.scrollableAncestor) {
|
|
2440
|
+
this.scrollableAncestor.style.overflow = '';
|
|
2441
|
+
this.scrollableAncestor = null;
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
onItemsChange() {
|
|
2445
|
+
this.focusedIndex = -1;
|
|
2446
|
+
}
|
|
2447
|
+
normalizeArabic(text) {
|
|
2448
|
+
return text.replace(/[أإآا]/g, 'ا');
|
|
2449
|
+
}
|
|
2450
|
+
get filteredItems() {
|
|
2451
|
+
if (!this.clientSearch || !this.clientSearchQuery.trim()) {
|
|
2452
|
+
return this.items;
|
|
2453
|
+
}
|
|
2454
|
+
const query = this.normalizeArabic(this.clientSearchQuery.trim().toLowerCase());
|
|
2455
|
+
return this.items.filter(item => {
|
|
2456
|
+
const normalizedName = this.normalizeArabic(item.name.toLowerCase());
|
|
2457
|
+
const normalizedNameEn = item.name_en ? item.name_en.toLowerCase() : '';
|
|
2458
|
+
return normalizedName.includes(query) || normalizedNameEn.includes(query);
|
|
2459
|
+
});
|
|
2460
|
+
}
|
|
2461
|
+
getDisplayName(item) {
|
|
2462
|
+
const lang = salla?.config?.get('user.language_code');
|
|
2463
|
+
if (lang && lang !== 'ar' && item.name_en?.trim()) {
|
|
2464
|
+
return item.name_en.trim();
|
|
2465
|
+
}
|
|
2466
|
+
return item.name;
|
|
2467
|
+
}
|
|
2468
|
+
handleClickOutside(e) {
|
|
2469
|
+
if (!this.isOpen)
|
|
2470
|
+
return;
|
|
2471
|
+
const target = e.target;
|
|
2472
|
+
if (!this.host.contains(target)) {
|
|
2473
|
+
this.close();
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
findScrollableAncestor() {
|
|
2477
|
+
let el = this.host.parentElement;
|
|
2478
|
+
while (el) {
|
|
2479
|
+
const style = getComputedStyle(el);
|
|
2480
|
+
const overflowY = style.overflowY;
|
|
2481
|
+
if (overflowY === 'auto' || overflowY === 'scroll' || overflowY === 'hidden' || style.overflow === 'clip') {
|
|
2482
|
+
return el;
|
|
2483
|
+
}
|
|
2484
|
+
el = el.parentElement;
|
|
2485
|
+
}
|
|
2486
|
+
return null;
|
|
2487
|
+
}
|
|
2488
|
+
open() {
|
|
2489
|
+
if (this.disabled || this.loading)
|
|
2490
|
+
return;
|
|
2491
|
+
this.isOpen = true;
|
|
2492
|
+
this.focusedIndex = -1;
|
|
2493
|
+
this.scrollableAncestor = this.findScrollableAncestor();
|
|
2494
|
+
if (this.scrollableAncestor) {
|
|
2495
|
+
this.scrollableAncestor.style.overflow = 'visible';
|
|
2496
|
+
}
|
|
2497
|
+
this.dropdownOpened.emit();
|
|
2498
|
+
requestAnimationFrame(() => this.searchInputRef?.focus());
|
|
2499
|
+
}
|
|
2500
|
+
close() {
|
|
2501
|
+
if (!this.isOpen)
|
|
2502
|
+
return;
|
|
2503
|
+
this.isOpen = false;
|
|
2504
|
+
this.focusedIndex = -1;
|
|
2505
|
+
this.clientSearchQuery = '';
|
|
2506
|
+
if (this.scrollableAncestor) {
|
|
2507
|
+
this.scrollableAncestor.style.overflow = '';
|
|
2508
|
+
this.scrollableAncestor = null;
|
|
2509
|
+
}
|
|
2510
|
+
this.dropdownClosed.emit();
|
|
2511
|
+
}
|
|
2512
|
+
scrollFocusedIntoView() {
|
|
2513
|
+
if (this.focusedIndex < 0)
|
|
2514
|
+
return;
|
|
2515
|
+
requestAnimationFrame(() => {
|
|
2516
|
+
const listEl = this.panelRef?.querySelector('.s-searchable-dropdown-list');
|
|
2517
|
+
const focused = listEl?.children[this.focusedIndex];
|
|
2518
|
+
focused?.scrollIntoView({ block: 'nearest' });
|
|
2519
|
+
});
|
|
2520
|
+
}
|
|
2521
|
+
selectItem(item) {
|
|
2522
|
+
this.itemSelected.emit(item);
|
|
2523
|
+
this.close();
|
|
2524
|
+
}
|
|
2525
|
+
render() {
|
|
2526
|
+
const hasSelection = this.selectedItem != null;
|
|
2527
|
+
const listboxId = `${this.inputId}-listbox`;
|
|
2528
|
+
return (index.h(index.Host, { key: '1e413d4391362f274223724ab37f5842a196f936', class: "s-searchable-dropdown" }, index.h("div", { key: 'c1c0b595a458db8918bc7c72b949cd514d764613', class: { 's-searchable-dropdown': true, 's-searchable-dropdown--open': this.isOpen } }, this.label && (index.h("label", { key: '576831e0383f561d5512792cb52d1c6d40156015', class: "s-searchable-dropdown-label", htmlFor: this.inputId }, this.label, this.required && index.h("span", { key: '290e1edb52971f5af6c6555f82ad595e97c9994d', class: "s-searchable-dropdown-required" }, " *"))), index.h("div", { key: 'e3c9aaea5697839e67aab1b91d07cb825ee76c7b', class: {
|
|
2529
|
+
's-searchable-dropdown-trigger': true,
|
|
2530
|
+
's-searchable-dropdown-trigger--disabled': this.disabled || this.loading,
|
|
2531
|
+
's-searchable-dropdown-trigger--open': this.isOpen,
|
|
2532
|
+
}, role: "combobox", "aria-expanded": this.isOpen ? 'true' : 'false', "aria-haspopup": "listbox", "aria-controls": listboxId, "aria-disabled": this.disabled || this.loading ? 'true' : 'false', tabIndex: this.disabled || this.loading ? -1 : 0, onClick: this.handleTriggerClick, onKeyDown: this.handleTriggerKeyDown }, hasSelection ? (index.h("span", { class: "s-searchable-dropdown-trigger-text" }, this.getDisplayName(this.selectedItem))) : (index.h("span", { class: "s-searchable-dropdown-trigger-placeholder" }, this.placeholder)), index.h("i", { key: 'f1e95e38ebffc358a9045f0fd38dd205eb2a14bb', class: {
|
|
2533
|
+
'sicon-keyboard_arrow_down': true,
|
|
2534
|
+
's-searchable-dropdown-trigger-icon': true,
|
|
2535
|
+
's-searchable-dropdown-trigger-icon--open': this.isOpen,
|
|
2536
|
+
}, "aria-hidden": "true" })), this.isOpen && (index.h("div", { key: 'a5c6b4650d8de5467c1d53e67700168a0795ff0b', class: {
|
|
2537
|
+
's-searchable-dropdown-panel': true,
|
|
2538
|
+
's-searchable-dropdown-panel--up': this.dropUp,
|
|
2539
|
+
}, ref: (el) => (this.panelRef = el) }, index.h("div", { key: '5ddf73d6d8cb96881ac6f94ef25a9f58b883a6c0', class: "s-searchable-dropdown-search-wrap" }, index.h("i", { key: 'ec52897c25962c6d1e84986f25bdac2dd8ecdac0', class: "sicon-search s-searchable-dropdown-search-icon", "aria-hidden": "true" }), index.h("input", { key: 'e14dd7a0dae605dd37782cdd8c235e875105fcc9', ref: (el) => (this.searchInputRef = el), id: this.inputId, type: "text", class: "s-searchable-dropdown-search-input", placeholder: this.placeholder, value: this.clientSearch ? this.clientSearchQuery : this.searchQuery, onInput: this.handleSearchInputChange, onKeyDown: this.handleSearchKeyDown, autocomplete: "off", "aria-autocomplete": "list", "aria-expanded": this.isOpen ? 'true' : 'false', "aria-controls": listboxId })), index.h("div", { key: '80daad72643001e400a9ff43444bbad5077ffa2d', id: listboxId, class: "s-searchable-dropdown-list s-scrollbar", role: "listbox" }, this.renderListContent()))))));
|
|
2540
|
+
}
|
|
2541
|
+
renderListContent() {
|
|
2542
|
+
if (this.searching || this.loading) {
|
|
2543
|
+
return (index.h("div", { class: "s-searchable-dropdown-loading" }, index.h("svg", { class: "s-searchable-dropdown-spinner", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, index.h("circle", { cx: "12", cy: "12", r: "10", stroke: "currentColor", "stroke-width": "3", "stroke-linecap": "round", opacity: "0.25" }), index.h("path", { d: "M12 2a10 10 0 0 1 10 10", stroke: "currentColor", "stroke-width": "3", "stroke-linecap": "round" }))));
|
|
2544
|
+
}
|
|
2545
|
+
const visibleItems = this.filteredItems;
|
|
2546
|
+
if (visibleItems.length === 0) {
|
|
2547
|
+
return (index.h("div", { class: "s-searchable-dropdown-empty" }, this.noResultsText || salla?.lang?.get('common.elements.no_options') || 'No results found'));
|
|
2548
|
+
}
|
|
2549
|
+
return visibleItems.map((item, index$1) => {
|
|
2550
|
+
const isSelected = this.selectedItem?.id === item.id;
|
|
2551
|
+
const isFocused = this.focusedIndex === index$1;
|
|
2552
|
+
return (index.h("button", { key: item.id, type: "button", role: "option", class: {
|
|
2553
|
+
's-searchable-dropdown-item': true,
|
|
2554
|
+
's-searchable-dropdown-item--selected': isSelected,
|
|
2555
|
+
's-searchable-dropdown-item--focused': isFocused && !isSelected,
|
|
2556
|
+
}, "aria-selected": isSelected ? 'true' : 'false', onClick: () => this.selectItem(item) }, index.h("span", { class: {
|
|
2557
|
+
's-searchable-dropdown-item-name': true,
|
|
2558
|
+
's-searchable-dropdown-item-name--selected': isSelected,
|
|
2559
|
+
} }, this.getDisplayName(item)), isSelected && (index.h("i", { class: "sicon-check s-searchable-dropdown-item-check", "aria-hidden": "true" }))));
|
|
2560
|
+
});
|
|
2561
|
+
}
|
|
2562
|
+
get host() { return index.getElement(this); }
|
|
2563
|
+
static get watchers() { return {
|
|
2564
|
+
"items": ["onItemsChange"]
|
|
2565
|
+
}; }
|
|
2566
|
+
};
|
|
2567
|
+
|
|
2074
2568
|
exports.salla_bullet_delivery = SallaBulletDelivery;
|
|
2569
|
+
exports.salla_searchable_dropdown = SallaSearchableDropdown;
|