@zonos/elements 1.3.5-alpha.0 → 1.3.6
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/ILanguage-d247b45b.js +26 -0
- package/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/{cart-f038cf46.js → cart-b8bbf22d.js} +71 -22
- package/dist/cjs/{getBorderRadius-cd7ef574.js → getBorderRadius-b252096d.js} +8 -4
- package/dist/cjs/index.cjs.js +0 -21
- package/dist/cjs/isCheckoutMobile-f491ca7c.js +8 -0
- package/dist/cjs/{isDarkColor-5eda1323.js → isDarkColor-168002d6.js} +1 -1
- package/dist/cjs/loader.cjs.js +5 -3
- package/dist/cjs/{localization-d43e1540.js → localization-2c9f5765.js} +366 -1
- package/dist/cjs/{submitGtag-42f29b3a.js → submitGtag-792fe45d.js} +2 -8
- package/dist/cjs/zonos-address_4.cjs.entry.js +289 -0
- package/dist/cjs/zonos-badge_2.cjs.entry.js +57 -0
- package/dist/cjs/zonos-banner.cjs.entry.js +4 -9
- package/dist/cjs/zonos-button_3.cjs.entry.js +161 -0
- package/dist/cjs/zonos-card_2.cjs.entry.js +26 -14
- package/dist/cjs/{zonos-cart-items_10.cjs.entry.js → zonos-cart-items_9.cjs.entry.js} +84 -92
- package/dist/cjs/zonos-checkout.cjs.entry.js +23 -26
- package/dist/cjs/zonos-component.cjs.entry.js +2 -2
- package/dist/cjs/zonos-controller.cjs.entry.js +7 -7
- package/dist/cjs/zonos-country-flag.cjs.entry.js +40 -0
- package/dist/cjs/{zonos-country-flag_4.cjs.entry.js → zonos-country-select_3.cjs.entry.js} +29 -55
- package/dist/cjs/zonos-elements.cjs.js +6 -4
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +13 -8
- package/dist/cjs/zonos-hello.cjs.entry.js +3 -3
- package/dist/cjs/zonos-logo.cjs.entry.js +32 -0
- package/dist/cjs/zonos-notification.cjs.entry.js +5 -6
- package/dist/cjs/zonos-payment.cjs.entry.js +7 -7
- package/dist/cjs/zonos-select-dialog-header_2.cjs.entry.js +45 -0
- package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +4 -4
- package/dist/cjs/zonos-text.cjs.entry.js +4 -6
- package/dist/cjs/{zonosStore-b88b5671.js → zonosStore-5d94dabb.js} +1 -1
- package/dist/collection/collection-manifest.json +6 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-cart-subtotal/zonos-cart-subtotal.js +1 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +5 -5
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/assets/chevronDownIcon.svg +1 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/assets/globe.svg +3 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/assets/zonosIcon.svg +5 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/zonos-checkout-footer.css +126 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/zonos-checkout-footer.js +60 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-payment/zonos-checkout-payment.css +5 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-payment/zonos-checkout-payment.js +2 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.css +18 -23
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +11 -15
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.css +14 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +13 -5
- package/dist/collection/components/checkout/zonos-checkout/zonos-review/zonos-review.css +7 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-review/zonos-review.js +3 -3
- package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.css +5 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +2 -2
- package/dist/collection/components/common/zonos-badge/zonos-badge.js +7 -26
- package/dist/collection/components/common/zonos-banner/zonos-banner.js +2 -25
- package/dist/collection/components/common/zonos-button/zonos-button.css +20 -2
- package/dist/collection/components/common/zonos-button/zonos-button.js +19 -34
- package/dist/collection/components/common/zonos-card/zonos-card.js +2 -20
- package/dist/collection/components/common/zonos-checkbox/zonos-checkbox.css +82 -0
- package/dist/collection/components/common/zonos-checkbox/zonos-checkbox.js +218 -0
- package/dist/collection/components/common/zonos-collapse/zonos-collapse.js +2 -2
- package/dist/collection/components/common/zonos-country-flag/zonos-country-flag.js +1 -20
- package/dist/collection/components/common/zonos-country-select/assets/greenCheckDuotone.svg +4 -0
- package/dist/collection/components/common/zonos-country-select/zonos-country-select.css +11 -10
- package/dist/collection/components/common/zonos-country-select/zonos-country-select.js +7 -11
- package/dist/collection/components/common/zonos-custom-message/zonos-custom-message.js +2 -2
- package/dist/collection/components/common/zonos-dialog/zonos-dialog.js +3 -3
- package/dist/collection/components/common/zonos-icon/zonos-icon.js +4 -4
- package/dist/collection/components/common/zonos-language-select/assets/greenCheckDuotone.svg +4 -0
- package/dist/collection/components/common/zonos-language-select/zonos-language-select.css +61 -0
- package/dist/collection/components/common/zonos-language-select/zonos-language-select.js +58 -0
- package/dist/collection/components/common/zonos-logo/zonos-logo.js +2 -21
- package/dist/collection/components/common/zonos-notification/zonos-notification.js +3 -26
- package/dist/collection/components/common/zonos-select-dialog-header/assets/removeIcon.svg +1 -0
- package/dist/collection/components/common/zonos-select-dialog-header/zonos-select-dialog-header.css +45 -0
- package/dist/collection/components/common/zonos-select-dialog-header/zonos-select-dialog-header.js +68 -0
- package/dist/collection/components/common/zonos-shipping-rich-radio/zonos-shipping-rich-radio.js +1 -1
- package/dist/collection/components/common/zonos-spinner/zonos-spinner.css +41 -35
- package/dist/collection/components/common/zonos-spinner/zonos-spinner.js +4 -4
- package/dist/collection/components/common/zonos-text/zonos-text.js +4 -24
- package/dist/collection/components/common/zonos-tooltip/zonos-tooltip.css +55 -0
- package/dist/collection/components/common/zonos-tooltip/zonos-tooltip.js +72 -0
- package/dist/collection/components/common/zonos-v-stack/zonos-v-stack.js +2 -21
- package/dist/collection/components/component-template/zonos-component/zonos-component.js +1 -1
- package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/assets/globe.svg +3 -0
- package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/zonos-hello-dialog-footer.css +10 -0
- package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/zonos-hello-dialog-footer.js +27 -5
- package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.css +16 -2
- package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +11 -5
- package/dist/collection/components/main/zonos-controller.js +1 -1
- package/dist/collection/components/store/checkout/cart.js +3 -1
- package/dist/collection/components/store/checkout/stripe.js +36 -10
- package/dist/collection/components/store/hello/localization.js +5 -1
- package/dist/collection/components/store/translationStore/strings.arabic.js +18 -0
- package/dist/collection/components/store/translationStore/strings.base.js +18 -0
- package/dist/collection/components/store/translationStore/strings.chinese.js +18 -0
- package/dist/collection/components/store/translationStore/strings.danish.js +18 -0
- package/dist/collection/components/store/translationStore/strings.dutch.js +18 -0
- package/dist/collection/components/store/translationStore/strings.french.js +18 -0
- package/dist/collection/components/store/translationStore/strings.german.js +18 -0
- package/dist/collection/components/store/translationStore/strings.hebrew.js +18 -0
- package/dist/collection/components/store/translationStore/strings.indonesian.js +18 -0
- package/dist/collection/components/store/translationStore/strings.italian.js +18 -0
- package/dist/collection/components/store/translationStore/strings.japanese.js +18 -0
- package/dist/collection/components/store/translationStore/strings.korean.js +18 -0
- package/dist/collection/components/store/translationStore/strings.norwegian.js +18 -0
- package/dist/collection/components/store/translationStore/strings.polish.js +18 -0
- package/dist/collection/components/store/translationStore/strings.portuguese.js +18 -0
- package/dist/collection/components/store/translationStore/strings.russian.js +18 -0
- package/dist/collection/components/store/translationStore/strings.spanish.js +18 -0
- package/dist/collection/components/store/translationStore/strings.swedish.js +18 -0
- package/dist/collection/components/store/translationStore/strings.turkish.js +18 -0
- package/dist/collection/components/store/translationStore/strings.vietnamese.js +18 -0
- package/dist/collection/components/stripe/zonos-address/zonos-address.js +81 -21
- package/dist/collection/components/stripe/zonos-link-authentication/zonos-link-authentication.js +1 -1
- package/dist/collection/components/stripe/zonos-payment/zonos-payment.js +1 -1
- package/dist/collection/components/utils/api/prepCalculateLandedCost.js +19 -1
- package/dist/collection/components/utils/api/triggerBuildLandedCost.js +11 -5
- package/dist/collection/components/utils/getBorderRadius.js +7 -3
- package/dist/collection/types/ILanguage.js +22 -0
- package/dist/collection/types/generated/graphql.customer.types.js +13 -0
- package/dist/collection/types/index.js +0 -1
- package/dist/collection/types/styles/Color.js +9 -0
- package/dist/components/ILanguage.js +24 -0
- package/dist/components/getBorderRadius.js +7 -3
- package/dist/components/index.js +0 -1
- package/dist/components/isCheckoutMobile.js +6 -0
- package/dist/components/isDarkColor.js +1 -1
- package/dist/components/localization.js +365 -1
- package/dist/components/{cart.js → stripe.js} +280 -229
- package/dist/components/submitGtag.js +1 -1
- package/dist/components/zonos-address2.js +83 -23
- package/dist/components/zonos-badge2.js +8 -10
- package/dist/components/zonos-banner2.js +3 -9
- package/dist/components/zonos-button2.js +20 -18
- package/dist/components/zonos-card2.js +3 -5
- package/dist/components/zonos-cart-items2.js +1 -1
- package/dist/components/zonos-cart-subtotal2.js +14 -8
- package/dist/components/zonos-checkbox.d.ts +11 -0
- package/dist/components/zonos-checkbox.js +6 -0
- package/dist/components/zonos-checkbox2.js +87 -0
- package/dist/components/zonos-checkout-finish2.js +3 -3
- package/dist/components/zonos-checkout-footer.d.ts +11 -0
- package/dist/components/zonos-checkout-footer.js +6 -0
- package/dist/components/zonos-checkout-footer2.js +109 -0
- package/dist/components/zonos-checkout-payment2.js +4 -4
- package/dist/components/zonos-checkout.js +83 -62
- package/dist/components/zonos-collapse2.js +3 -3
- package/dist/components/zonos-component.js +1 -1
- package/dist/components/zonos-controller.js +4 -4
- package/dist/components/zonos-country-flag2.js +3 -5
- package/dist/components/zonos-country-select2.js +26 -19
- package/dist/components/zonos-custom-message2.js +3 -3
- package/dist/components/zonos-customer-info2.js +31 -11
- package/dist/components/zonos-dialog2.js +4 -4
- package/dist/components/zonos-hello-dialog-footer2.js +23 -10
- package/dist/components/zonos-hello-dialog2.js +41 -23
- package/dist/components/zonos-hello.js +31 -19
- package/dist/components/zonos-icon2.js +4 -4
- package/dist/components/zonos-language-select.d.ts +11 -0
- package/dist/components/zonos-language-select.js +6 -0
- package/dist/components/zonos-language-select2.js +87 -0
- package/dist/components/zonos-link-authentication2.js +2 -2
- package/dist/components/zonos-logo.js +44 -1
- package/dist/components/zonos-notification2.js +4 -6
- package/dist/components/zonos-payment2.js +2 -2
- package/dist/components/zonos-review2.js +7 -11
- package/dist/components/zonos-select-dialog-header.d.ts +11 -0
- package/dist/components/zonos-select-dialog-header.js +6 -0
- package/dist/components/zonos-select-dialog-header2.js +71 -0
- package/dist/components/zonos-shipping-rich-radio2.js +2 -2
- package/dist/components/zonos-shipping2.js +4 -4
- package/dist/components/zonos-spinner2.js +4 -4
- package/dist/components/zonos-text2.js +4 -7
- package/dist/components/zonos-tooltip.d.ts +11 -0
- package/dist/components/zonos-tooltip.js +6 -0
- package/dist/components/zonos-tooltip2.js +48 -0
- package/dist/components/zonos-v-stack2.js +4 -6
- package/dist/components/zonosStore.js +1 -1
- package/dist/esm/ILanguage-97790bee.js +24 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/{cart-ba9b0d4c.js → cart-bc3bb22e.js} +72 -21
- package/dist/esm/getBorderRadius-e9736f7e.js +20 -0
- package/dist/esm/index.js +1 -6
- package/dist/esm/isCheckoutMobile-8846dccb.js +6 -0
- package/dist/esm/{isDarkColor-8696cb70.js → isDarkColor-e982fa09.js} +1 -1
- package/dist/esm/loader.js +6 -4
- package/dist/esm/{localization-5d83fde2.js → localization-d8f6453b.js} +366 -2
- package/dist/esm/{submitGtag-a7d07aec.js → submitGtag-bebe2cb0.js} +3 -8
- package/dist/esm/zonos-address_4.entry.js +282 -0
- package/dist/esm/zonos-badge_2.entry.js +52 -0
- package/dist/esm/zonos-banner.entry.js +4 -9
- package/dist/esm/zonos-button_3.entry.js +155 -0
- package/dist/esm/zonos-card_2.entry.js +26 -14
- package/dist/esm/{zonos-cart-items_10.entry.js → zonos-cart-items_9.entry.js} +82 -89
- package/dist/esm/zonos-checkout.entry.js +20 -23
- package/dist/esm/zonos-component.entry.js +2 -2
- package/dist/esm/zonos-controller.entry.js +7 -7
- package/dist/esm/zonos-country-flag.entry.js +36 -0
- package/dist/esm/{zonos-country-flag_4.entry.js → zonos-country-select_3.entry.js} +30 -55
- package/dist/esm/zonos-elements.js +7 -5
- package/dist/esm/zonos-hello-dialog.entry.js +13 -8
- package/dist/esm/zonos-hello.entry.js +3 -3
- package/dist/esm/zonos-logo.entry.js +28 -0
- package/dist/esm/zonos-notification.entry.js +5 -6
- package/dist/esm/zonos-payment.entry.js +7 -7
- package/dist/esm/zonos-select-dialog-header_2.entry.js +40 -0
- package/dist/esm/zonos-shipping-rich-radio.entry.js +4 -4
- package/dist/esm/zonos-text.entry.js +4 -6
- package/dist/esm/{zonosStore-e59617f8.js → zonosStore-e6c7be3a.js} +1 -1
- package/dist/esm-es5/ILanguage-97790bee.js +1 -0
- package/dist/esm-es5/app-globals-0f993ce5.js +1 -0
- package/dist/esm-es5/cart-bc3bb22e.js +1 -0
- package/dist/esm-es5/getBorderRadius-e9736f7e.js +1 -0
- package/dist/esm-es5/index.js +0 -1
- package/dist/esm-es5/isCheckoutMobile-8846dccb.js +1 -0
- package/dist/esm-es5/{isDarkColor-8696cb70.js → isDarkColor-e982fa09.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/localization-d8f6453b.js +1 -0
- package/dist/esm-es5/submitGtag-bebe2cb0.js +1 -0
- package/dist/esm-es5/zonos-address_4.entry.js +1 -0
- package/dist/esm-es5/zonos-badge_2.entry.js +1 -0
- package/dist/esm-es5/zonos-banner.entry.js +1 -1
- package/dist/esm-es5/zonos-button_3.entry.js +1 -0
- package/dist/esm-es5/zonos-card_2.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_9.entry.js +1 -0
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-component.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -0
- package/dist/esm-es5/zonos-country-select_3.entry.js +1 -0
- package/dist/esm-es5/zonos-elements.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-logo.entry.js +1 -0
- package/dist/esm-es5/zonos-notification.entry.js +1 -1
- package/dist/esm-es5/zonos-payment.entry.js +1 -1
- package/dist/esm-es5/zonos-select-dialog-header_2.entry.js +1 -0
- package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
- package/dist/esm-es5/zonos-text.entry.js +1 -1
- package/dist/esm-es5/{zonosStore-e59617f8.js → zonosStore-e6c7be3a.js} +1 -1
- package/dist/scripts/insertTranslations.js +1 -0
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/scripts/zonosBase.js +1 -1
- package/dist/types/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.d.ts +2 -1
- package/dist/types/components/checkout/zonos-checkout/zonos-checkout-footer/zonos-checkout-footer.d.ts +7 -0
- package/dist/types/components/common/zonos-badge/zonos-badge.d.ts +1 -5
- package/dist/types/components/common/zonos-banner/zonos-banner.d.ts +0 -4
- package/dist/types/components/common/zonos-button/zonos-button.d.ts +1 -5
- package/dist/types/components/common/zonos-card/zonos-card.d.ts +0 -4
- package/dist/types/components/common/zonos-checkbox/zonos-checkbox.d.ts +42 -0
- package/dist/types/components/common/zonos-country-flag/zonos-country-flag.d.ts +0 -4
- package/dist/types/components/common/zonos-country-select/zonos-country-select.d.ts +1 -1
- package/dist/types/components/common/zonos-icon/zonos-icon.d.ts +1 -1
- package/dist/types/components/common/zonos-language-select/zonos-language-select.d.ts +9 -0
- package/dist/types/components/common/zonos-logo/zonos-logo.d.ts +0 -4
- package/dist/types/components/common/zonos-notification/zonos-notification.d.ts +0 -4
- package/dist/types/components/common/zonos-select-dialog-header/zonos-select-dialog-header.d.ts +12 -0
- package/dist/types/components/common/zonos-spinner/zonos-spinner.d.ts +1 -1
- package/dist/types/components/common/zonos-text/zonos-text.d.ts +1 -5
- package/dist/types/components/common/zonos-tooltip/zonos-tooltip.d.ts +12 -0
- package/dist/types/components/common/zonos-v-stack/zonos-v-stack.d.ts +0 -4
- package/dist/types/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/zonos-hello-dialog-footer.d.ts +5 -0
- package/dist/types/components/hello/zonos-hello-dialog/zonos-hello-dialog.d.ts +2 -0
- package/dist/types/components/store/checkout/stripe.d.ts +9 -0
- package/dist/types/components/store/hello/localization.d.ts +2 -1
- package/dist/types/components/store/translationStore/strings.arabic.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.base.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.chinese.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.danish.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.dutch.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.french.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.german.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.hebrew.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.indonesian.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.italian.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.japanese.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.korean.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.norwegian.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.polish.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.portuguese.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.russian.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.spanish.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.swedish.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.turkish.d.ts +18 -0
- package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +18 -0
- package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +7 -0
- package/dist/types/components/utils/api/getLocaleMessages.d.ts +1 -1
- package/dist/types/components/utils/api/triggerBuildLandedCost.d.ts +18 -2
- package/dist/types/components/utils/changeDeepProperty.d.ts +1 -1
- package/dist/types/components/utils/changeDeepPropertyAtIndex.d.ts +1 -1
- package/dist/types/components/utils/checkout/isCheckoutMobile.d.ts +1 -1
- package/dist/types/components/utils/getBorderRadius.d.ts +1 -1
- package/dist/types/components.d.ts +242 -116
- package/dist/types/types/ILanguage.d.ts +81 -0
- package/dist/types/types/checkout/CheckoutConfig.d.ts +3 -3
- package/dist/types/types/checkout/api/CalculateLandedCostRequest.d.ts +13 -0
- package/dist/types/types/generated/graphql.customer.types.d.ts +16 -4
- package/dist/types/types/generated/graphql.customer.types.ts +21 -4
- package/dist/types/types/generated/graphql.frontend.types.d.ts +6 -6
- package/dist/types/types/generated/graphql.frontend.types.ts +14 -4
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/types/styles/Color.d.ts +2 -0
- package/dist/zonos-elements/index.esm.js +0 -1
- package/dist/zonos-elements/{p-eb96f893.system.entry.js → p-00d63df1.system.entry.js} +1 -1
- package/dist/zonos-elements/p-04f63cea.entry.js +1 -0
- package/dist/zonos-elements/{p-7cae86a0.system.entry.js → p-06652d87.system.entry.js} +1 -1
- package/dist/zonos-elements/p-066c5893.system.js +1 -0
- package/dist/zonos-elements/p-0c7480a5.entry.js +1 -0
- package/dist/zonos-elements/p-16ad90ca.js +1 -0
- package/dist/zonos-elements/p-16b74c31.system.js +1 -0
- package/dist/zonos-elements/{p-0024f8c2.js → p-17550a10.js} +1 -1
- package/dist/zonos-elements/p-1d16a6fb.js +1 -0
- package/dist/zonos-elements/p-1ea68e3b.entry.js +1 -0
- package/dist/zonos-elements/{p-28d7b75d.entry.js → p-1ed530cc.entry.js} +1 -1
- package/dist/zonos-elements/p-289c8b1a.system.entry.js +1 -0
- package/dist/zonos-elements/{p-8970e202.system.entry.js → p-2a00c270.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-be23cc91.system.entry.js → p-32bca9c8.system.entry.js} +1 -1
- package/dist/zonos-elements/p-37f53a79.entry.js +1 -0
- package/dist/zonos-elements/p-394cf1cf.js +1 -0
- package/dist/zonos-elements/p-3ef27745.js +1 -0
- package/dist/zonos-elements/{p-7beaee33.system.entry.js → p-458fd100.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-e8da4463.js → p-47fac33f.js} +1 -1
- package/dist/zonos-elements/p-49a764e9.system.entry.js +1 -0
- package/dist/zonos-elements/p-4fafb2a5.system.entry.js +1 -0
- package/dist/zonos-elements/p-4fb71a93.js +1 -0
- package/dist/zonos-elements/{p-dc09ca69.system.js → p-50287643.system.js} +1 -1
- package/dist/zonos-elements/p-50ea2036.system.js +1 -0
- package/dist/zonos-elements/p-5276c61b.system.entry.js +1 -0
- package/dist/zonos-elements/p-56ba5cbf.system.js +1 -0
- package/dist/zonos-elements/{p-5a0264e8.system.entry.js → p-5a113c3d.system.entry.js} +1 -1
- package/dist/zonos-elements/p-6308b347.entry.js +1 -0
- package/dist/zonos-elements/p-63d1b1fe.entry.js +1 -0
- package/dist/zonos-elements/p-7347ee7c.system.entry.js +1 -0
- package/dist/zonos-elements/p-7a6144b1.entry.js +1 -0
- package/dist/zonos-elements/p-7dd8e8ba.system.entry.js +1 -0
- package/dist/zonos-elements/p-81a54668.js +1 -0
- package/dist/zonos-elements/p-8c26a080.system.js +1 -0
- package/dist/zonos-elements/p-96aabe02.entry.js +1 -0
- package/dist/zonos-elements/p-9cbbf261.system.entry.js +1 -0
- package/dist/zonos-elements/p-a33745e9.entry.js +1 -0
- package/dist/zonos-elements/{p-5d91e45c.entry.js → p-a4de3fb2.entry.js} +1 -1
- package/dist/zonos-elements/p-a682fd38.system.entry.js +1 -0
- package/dist/zonos-elements/p-abe7524f.system.js +1 -0
- package/dist/zonos-elements/p-aed0098c.system.js +1 -0
- package/dist/zonos-elements/{p-73174d0c.system.entry.js → p-b81a0577.system.entry.js} +1 -1
- package/dist/zonos-elements/p-ba1a111a.system.entry.js +1 -0
- package/dist/zonos-elements/p-ba43275e.entry.js +1 -0
- package/dist/zonos-elements/p-bd6a2095.entry.js +1 -0
- package/dist/zonos-elements/{p-f82e000f.system.entry.js → p-c4321084.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-824ebf9d.entry.js → p-cdf114a2.entry.js} +1 -1
- package/dist/zonos-elements/p-d5ae3cbb.system.entry.js +1 -0
- package/dist/zonos-elements/p-d5d7c8f5.entry.js +1 -0
- package/dist/zonos-elements/p-dd7729fd.system.entry.js +1 -0
- package/dist/zonos-elements/p-de339fb6.entry.js +1 -0
- package/dist/zonos-elements/p-e1255160.js +1 -0
- package/dist/zonos-elements/p-e8a9bc56.entry.js +1 -0
- package/dist/zonos-elements/{p-7f68c103.system.js → p-e99d79d9.system.js} +1 -1
- package/dist/zonos-elements/p-ec25f180.entry.js +1 -0
- package/dist/zonos-elements/p-f49dfd06.system.js +1 -0
- package/dist/zonos-elements/{p-1165b6e5.entry.js → p-f6f5f644.entry.js} +1 -1
- package/dist/zonos-elements/p-fcc4f140.system.js +1 -0
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/dist/zonos-elements/zonos-elements.js +1 -1
- package/package.json +17 -18
- package/dist/cjs/zonos-address_2.cjs.entry.js +0 -141
- package/dist/cjs/zonos-badge.cjs.entry.js +0 -38
- package/dist/cjs/zonos-button_2.cjs.entry.js +0 -130
- package/dist/cjs/zonos-icon.cjs.entry.js +0 -35
- package/dist/collection/components/common/zonos-country-select/assets/arrowLeftBlue.svg +0 -1
- package/dist/components/zonos-logo2.js +0 -48
- package/dist/esm/getBorderRadius-9e4cb3b1.js +0 -16
- package/dist/esm/zonos-address_2.entry.js +0 -136
- package/dist/esm/zonos-badge.entry.js +0 -34
- package/dist/esm/zonos-button_2.entry.js +0 -125
- package/dist/esm/zonos-icon.entry.js +0 -31
- package/dist/esm-es5/cart-ba9b0d4c.js +0 -1
- package/dist/esm-es5/getBorderRadius-9e4cb3b1.js +0 -1
- package/dist/esm-es5/localization-5d83fde2.js +0 -1
- package/dist/esm-es5/submitGtag-a7d07aec.js +0 -1
- package/dist/esm-es5/zonos-address_2.entry.js +0 -1
- package/dist/esm-es5/zonos-badge.entry.js +0 -1
- package/dist/esm-es5/zonos-button_2.entry.js +0 -1
- package/dist/esm-es5/zonos-cart-items_10.entry.js +0 -1
- package/dist/esm-es5/zonos-country-flag_4.entry.js +0 -1
- package/dist/esm-es5/zonos-icon.entry.js +0 -1
- package/dist/zonos-elements/p-027abb50.entry.js +0 -1
- package/dist/zonos-elements/p-12c19be6.system.entry.js +0 -1
- package/dist/zonos-elements/p-12ecf765.system.js +0 -1
- package/dist/zonos-elements/p-1c00ffea.system.entry.js +0 -1
- package/dist/zonos-elements/p-21793192.entry.js +0 -1
- package/dist/zonos-elements/p-245997d9.js +0 -1
- package/dist/zonos-elements/p-26edde4d.system.entry.js +0 -1
- package/dist/zonos-elements/p-39d12bf0.entry.js +0 -1
- package/dist/zonos-elements/p-3d965e88.entry.js +0 -1
- package/dist/zonos-elements/p-410045c5.system.entry.js +0 -1
- package/dist/zonos-elements/p-59343e23.system.js +0 -1
- package/dist/zonos-elements/p-7748735d.entry.js +0 -1
- package/dist/zonos-elements/p-839f6cd9.entry.js +0 -1
- package/dist/zonos-elements/p-83bb8727.system.entry.js +0 -1
- package/dist/zonos-elements/p-8ebc0b64.js +0 -1
- package/dist/zonos-elements/p-9f3cad08.entry.js +0 -1
- package/dist/zonos-elements/p-a6f2e282.system.js +0 -1
- package/dist/zonos-elements/p-afed9236.entry.js +0 -1
- package/dist/zonos-elements/p-b035f9e5.system.js +0 -1
- package/dist/zonos-elements/p-b1ffb37b.entry.js +0 -1
- package/dist/zonos-elements/p-b87fa3a1.js +0 -1
- package/dist/zonos-elements/p-bd02a65c.entry.js +0 -1
- package/dist/zonos-elements/p-be4bc6bc.entry.js +0 -1
- package/dist/zonos-elements/p-bea31a7b.system.entry.js +0 -1
- package/dist/zonos-elements/p-c3d75f4f.system.js +0 -1
- package/dist/zonos-elements/p-da2387d2.system.entry.js +0 -1
- package/dist/zonos-elements/p-dcf1e1b4.system.entry.js +0 -1
- package/dist/zonos-elements/p-ee8b44c0.system.js +0 -1
- package/dist/zonos-elements/p-efd1544b.system.entry.js +0 -1
- package/dist/zonos-elements/p-f2733cc7.js +0 -1
- package/dist/zonos-elements/p-f342e7c7.entry.js +0 -1
- package/dist/zonos-elements/p-fdb9568e.entry.js +0 -1
- /package/dist/cjs/{index-3ead02fe.js → index-72767498.js} +0 -0
- /package/dist/esm/{index-81a199ef.js → index-b5be4dc3.js} +0 -0
- /package/dist/esm-es5/{index-81a199ef.js → index-b5be4dc3.js} +0 -0
- /package/dist/zonos-elements/{p-4d8545e1.js → p-58127116.js} +0 -0
- /package/dist/zonos-elements/{p-4d39efb6.system.js → p-d1ab0823.system.js} +0 -0
|
@@ -1,16 +1,243 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { c as createStore, z as zonosStore } from './zonosStore.js';
|
|
2
|
+
import { b as log, l as logError, t as translate, a as localizationStore, h as handleFetch } from './localization.js';
|
|
3
3
|
import { i as isDarkColor } from './isDarkColor.js';
|
|
4
4
|
import { g as getBorderRadius } from './getBorderRadius.js';
|
|
5
5
|
|
|
6
|
+
const formatDate = ({ date, formatOptions = { day: 'numeric', weekday: 'long', year: 'numeric' }, }) => {
|
|
7
|
+
// format date to Thursday 3, 2023
|
|
8
|
+
return new Intl.DateTimeFormat('en-US', formatOptions).format(date);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const getDaysDifference = (targetDate) => {
|
|
12
|
+
const currentDate = new Date();
|
|
13
|
+
const timeDifference = targetDate.getTime() - currentDate.getTime();
|
|
14
|
+
const daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24)); // Convert milliseconds to days
|
|
15
|
+
return daysDifference;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const { onChange: onChange$1, reset: reset$1, state: cartStore, } = createStore(() => ({
|
|
19
|
+
checkoutSessionId: sessionStorage.getItem('zonos--checkout-session-id') || null,
|
|
20
|
+
currency: 'USD',
|
|
21
|
+
dutiesTaxFees: 0,
|
|
22
|
+
error: null,
|
|
23
|
+
exchangeRate: null,
|
|
24
|
+
isSelectedShippingAboveDeminimis: false,
|
|
25
|
+
isSelectedShippingGuarantee: false,
|
|
26
|
+
items: [],
|
|
27
|
+
landedCostData: null,
|
|
28
|
+
selectedLandedCost: null,
|
|
29
|
+
selectedShippingOption: null,
|
|
30
|
+
selectedShippingOptionExpectedDate: '',
|
|
31
|
+
selectedShippingOptionTransitTime: '',
|
|
32
|
+
shipping: 0,
|
|
33
|
+
shippingData: null,
|
|
34
|
+
step: 'customer-info',
|
|
35
|
+
subtotal: 0,
|
|
36
|
+
total: 0,
|
|
37
|
+
}));
|
|
38
|
+
/**
|
|
39
|
+
* Format shipping transit info to be displayed on UI
|
|
40
|
+
* @returns
|
|
41
|
+
* - expectedDate: Thursday, Aug 12
|
|
42
|
+
* - maxTransit: 5
|
|
43
|
+
* - minTransit: 3
|
|
44
|
+
*/
|
|
45
|
+
const cartStoreGetShippingTransitInfo = (item) => {
|
|
46
|
+
const minTransit = item.minTransitAt
|
|
47
|
+
? getDaysDifference(new Date(item.minTransitAt))
|
|
48
|
+
: '';
|
|
49
|
+
const maxTransit = item.maxTransitAt
|
|
50
|
+
? getDaysDifference(new Date(item.maxTransitAt))
|
|
51
|
+
: '';
|
|
52
|
+
const expectedDate = item.minTransitAt
|
|
53
|
+
? formatDate({
|
|
54
|
+
date: new Date(item.minTransitAt),
|
|
55
|
+
})
|
|
56
|
+
: '';
|
|
57
|
+
return {
|
|
58
|
+
expectedDate,
|
|
59
|
+
maxTransit,
|
|
60
|
+
minTransit,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const cartStoreReset = () => {
|
|
64
|
+
sessionStorage.removeItem('zonos--checkout-session-id');
|
|
65
|
+
// reset cart store
|
|
66
|
+
reset$1();
|
|
67
|
+
};
|
|
68
|
+
const cartStoreUpdateToErrorState = ({ messages, title, }) => {
|
|
69
|
+
cartStoreReset();
|
|
70
|
+
stripeStoreReset();
|
|
71
|
+
cartStore.step = 'error';
|
|
72
|
+
cartStore.error = {
|
|
73
|
+
messages,
|
|
74
|
+
title,
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
const cartStoreApplySubtotals = (subtotals) => {
|
|
78
|
+
// update exchange rate so we can use it to display cart items
|
|
79
|
+
cartStore.exchangeRate = subtotals.exchangeRate;
|
|
80
|
+
cartStore.dutiesTaxFees = subtotals.landedCostTotal;
|
|
81
|
+
cartStore.subtotal = subtotals.items;
|
|
82
|
+
cartStore.total = subtotals.total;
|
|
83
|
+
cartStore.currency = subtotals.presentmentCurrencyCode;
|
|
84
|
+
};
|
|
85
|
+
const cartStoreReCalculateTotal = async ({ currency, itemsAmount, landedCostId, }) => {
|
|
86
|
+
if (landedCostId && cartStore.selectedLandedCost) {
|
|
87
|
+
// update cart total right away if we have landed cost id to avoid order total flickering
|
|
88
|
+
const subtotals = cartStore.selectedLandedCost.subtotals;
|
|
89
|
+
cartStoreApplySubtotals(subtotals);
|
|
90
|
+
log('Exchange rate updated for cart items (landed cost subtotal)', 'info', cartStore.exchangeRate);
|
|
91
|
+
}
|
|
92
|
+
// update checkout session
|
|
93
|
+
if (!cartStore.checkoutSessionId) {
|
|
94
|
+
logError('Could not update cart total without checkout session id');
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
const { json } = await stripeStoreUpdateCheckoutSession({
|
|
98
|
+
currency,
|
|
99
|
+
id: cartStore.checkoutSessionId,
|
|
100
|
+
itemsAmount,
|
|
101
|
+
landedCostId,
|
|
102
|
+
presentmentCountryCode: localizationStore.selectedCountryCode,
|
|
103
|
+
});
|
|
104
|
+
if (!json) {
|
|
105
|
+
// do nothing if we can't get checkout session
|
|
106
|
+
logError('Error occurs when updating checkout session');
|
|
107
|
+
cartStoreUpdateToErrorState({
|
|
108
|
+
messages: [
|
|
109
|
+
translate("There's been an error updating your checkout session. Please reload and try again or contact support if the error persists"),
|
|
110
|
+
],
|
|
111
|
+
title: translate('Error updating Checkout'),
|
|
112
|
+
});
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
if (!landedCostId) {
|
|
116
|
+
// This is when first open the checkout modal and we just want to get info from the old cart session.
|
|
117
|
+
// use subtotals from checkout session to update cart total
|
|
118
|
+
cartStoreApplySubtotals(json.checkoutSessionUpdate.subtotals);
|
|
119
|
+
log('Exchange rate updated for cart items (checkout session update)', 'info', cartStore.exchangeRate);
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
};
|
|
123
|
+
const cartStoreUpdateSelectedShippingOption = async (selectedShippingOption) => {
|
|
124
|
+
var _a, _b, _c, _d, _e;
|
|
125
|
+
cartStore.selectedShippingOption = selectedShippingOption;
|
|
126
|
+
// update shipping transit info
|
|
127
|
+
const { expectedDate, maxTransit, minTransit } = cartStoreGetShippingTransitInfo(cartStore.selectedShippingOption);
|
|
128
|
+
cartStore.selectedShippingOptionExpectedDate = expectedDate;
|
|
129
|
+
cartStore.selectedShippingOptionTransitTime =
|
|
130
|
+
minTransit && maxTransit
|
|
131
|
+
? `${minTransit}-${maxTransit}`
|
|
132
|
+
: `${minTransit || maxTransit}`;
|
|
133
|
+
const selectedLandedCost = (_a = cartStore.landedCostData) === null || _a === void 0 ? void 0 : _a.find(checkoutSessionPresentment => {
|
|
134
|
+
var _a, _b, _c;
|
|
135
|
+
return ((_b = (_a = checkoutSessionPresentment.landedCost) === null || _a === void 0 ? void 0 : _a.shipmentRating) === null || _b === void 0 ? void 0 : _b.id) ===
|
|
136
|
+
((_c = cartStore.selectedShippingOption) === null || _c === void 0 ? void 0 : _c.id);
|
|
137
|
+
});
|
|
138
|
+
// save selected landed cost for later use
|
|
139
|
+
cartStore.selectedLandedCost = selectedLandedCost || null;
|
|
140
|
+
if (!selectedLandedCost) {
|
|
141
|
+
// do nothing if we can't find landed cost for selected shipping option
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
// update shipping value and dutiesTaxFees on selectedShippingOption change
|
|
145
|
+
cartStore.shipping = selectedLandedCost.subtotals.shipping;
|
|
146
|
+
// update deminimis status
|
|
147
|
+
const isGuarantee = ((_b = selectedLandedCost === null || selectedLandedCost === void 0 ? void 0 : selectedLandedCost.landedCost) === null || _b === void 0 ? void 0 : _b.landedCostGuaranteeCode) === 'ZONOS';
|
|
148
|
+
// one item in deminimis with type of duty and tax has threshold value is "ABOVE"
|
|
149
|
+
const isAboveDeminimis = !!((_d = (_c = selectedLandedCost === null || selectedLandedCost === void 0 ? void 0 : selectedLandedCost.landedCost) === null || _c === void 0 ? void 0 : _c.deMinimis) === null || _d === void 0 ? void 0 : _d.find(item => ['DUTY', 'TAX'].includes(item.type) && item.threshold === 'ABOVE'));
|
|
150
|
+
cartStore.isSelectedShippingAboveDeminimis = isAboveDeminimis;
|
|
151
|
+
cartStore.isSelectedShippingGuarantee = isGuarantee;
|
|
152
|
+
// update session with selected landed cost
|
|
153
|
+
const updateCalulateStatus = await cartStoreReCalculateTotal({
|
|
154
|
+
landedCostId: (_e = selectedLandedCost.landedCost) === null || _e === void 0 ? void 0 : _e.id,
|
|
155
|
+
});
|
|
156
|
+
return updateCalulateStatus;
|
|
157
|
+
};
|
|
158
|
+
onChange$1('checkoutSessionId', () => {
|
|
159
|
+
if (!cartStore.checkoutSessionId) {
|
|
160
|
+
sessionStorage.removeItem('zonos--checkout-session-id');
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
sessionStorage.setItem('zonos--checkout-session-id', cartStore.checkoutSessionId);
|
|
164
|
+
});
|
|
165
|
+
const cartStoreUpdateItems = async (items) => {
|
|
166
|
+
var _a;
|
|
167
|
+
cartStore.items = items;
|
|
168
|
+
const currency = (_a = items.find(Boolean)) === null || _a === void 0 ? void 0 : _a.currencyCode;
|
|
169
|
+
const total = items.reduce((amt, item) => {
|
|
170
|
+
return amt + item.amount * item.quantity;
|
|
171
|
+
}, 0);
|
|
172
|
+
if (!currency || !total) {
|
|
173
|
+
// do nothing if we can't get currency or total
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
cartStore.currency = currency;
|
|
177
|
+
// set loading state here because this is first load checkout session when we already have checkout session id stored
|
|
178
|
+
stripeStore.isFetchingSession = true;
|
|
179
|
+
await cartStoreReCalculateTotal({
|
|
180
|
+
currency: currency,
|
|
181
|
+
itemsAmount: total,
|
|
182
|
+
});
|
|
183
|
+
stripeStore.isFetchingSession = false;
|
|
184
|
+
};
|
|
185
|
+
const cartStoreResetSelectedShippingOption = () => {
|
|
186
|
+
cartStore.selectedShippingOption = null;
|
|
187
|
+
cartStore.isSelectedShippingAboveDeminimis = false;
|
|
188
|
+
cartStore.isSelectedShippingGuarantee = false;
|
|
189
|
+
cartStore.selectedShippingOptionExpectedDate = '';
|
|
190
|
+
cartStore.selectedShippingOptionTransitTime = '';
|
|
191
|
+
cartStore.shipping = 0;
|
|
192
|
+
};
|
|
193
|
+
const cartStoreNextStep = () => {
|
|
194
|
+
if (cartStore.step === 'customer-info') {
|
|
195
|
+
cartStore.step = 'shipping';
|
|
196
|
+
}
|
|
197
|
+
else if (cartStore.step === 'shipping') {
|
|
198
|
+
cartStore.step = 'payment';
|
|
199
|
+
}
|
|
200
|
+
else if (cartStore.step === 'payment') {
|
|
201
|
+
cartStore.step = 'finish';
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
const cartStorePreviousStep = () => {
|
|
205
|
+
if (cartStore.step === 'payment') {
|
|
206
|
+
cartStore.step = 'shipping';
|
|
207
|
+
}
|
|
208
|
+
else if (cartStore.step === 'shipping') {
|
|
209
|
+
cartStore.step = 'customer-info';
|
|
210
|
+
// reset selected shipping option
|
|
211
|
+
cartStoreResetSelectedShippingOption();
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
6
215
|
const prepCalculateLandedCost = () => {
|
|
7
216
|
// maybe we don't need email now for prefetch the landed cost
|
|
8
217
|
const stripeLinkData = stripeStore.stripeLinkEventData;
|
|
9
218
|
const stripeAddressData = stripeStore.stripeAddressEventData;
|
|
10
|
-
|
|
219
|
+
const stripeBillingAddressData = stripeStore.stripeShippingSameAsBilling
|
|
220
|
+
? stripeStore.stripeAddressEventData
|
|
221
|
+
: stripeStore.stripeBillingAddressEventData;
|
|
222
|
+
if (!(stripeAddressData === null || stripeAddressData === void 0 ? void 0 : stripeAddressData.complete) || !(stripeBillingAddressData === null || stripeBillingAddressData === void 0 ? void 0 : stripeBillingAddressData.complete)) {
|
|
11
223
|
throw new Error('Missing stripe address data');
|
|
12
224
|
}
|
|
13
225
|
return {
|
|
226
|
+
billingAddress: {
|
|
227
|
+
addressLine1: stripeBillingAddressData.value.address.line1,
|
|
228
|
+
addressLine2: stripeBillingAddressData.value.address.line2 || '',
|
|
229
|
+
city: stripeBillingAddressData.value.address.city,
|
|
230
|
+
country: stripeBillingAddressData.value.address.country,
|
|
231
|
+
postalCode: stripeBillingAddressData.value.address.postal_code,
|
|
232
|
+
state: stripeBillingAddressData.value.address.state,
|
|
233
|
+
},
|
|
234
|
+
billingContact: {
|
|
235
|
+
// firstName and lastName should be valid now since stripe only mark
|
|
236
|
+
// the address as complete when both fields are filled.
|
|
237
|
+
firstName: stripeBillingAddressData.value.firstName || '',
|
|
238
|
+
lastName: stripeBillingAddressData.value.lastName || '',
|
|
239
|
+
phone: stripeBillingAddressData.value.phone || '',
|
|
240
|
+
},
|
|
14
241
|
checkoutSessionId: cartStore.checkoutSessionId || '',
|
|
15
242
|
contact: {
|
|
16
243
|
email: (stripeLinkData === null || stripeLinkData === void 0 ? void 0 : stripeLinkData.value.email) || '',
|
|
@@ -33,11 +260,17 @@ const prepCalculateLandedCost = () => {
|
|
|
33
260
|
};
|
|
34
261
|
|
|
35
262
|
const triggerBuildLandedCost = async (buildLandedCost) => {
|
|
36
|
-
var _a;
|
|
263
|
+
var _a, _b, _c, _d;
|
|
37
264
|
const data = prepCalculateLandedCost();
|
|
38
|
-
const landedCost = await buildLandedCost(
|
|
39
|
-
|
|
40
|
-
|
|
265
|
+
const landedCost = await buildLandedCost({
|
|
266
|
+
billingAddress: data.billingAddress,
|
|
267
|
+
billingContact: data.billingContact,
|
|
268
|
+
checkoutSessionId: data.checkoutSessionId,
|
|
269
|
+
contact: data.contact,
|
|
270
|
+
shippingAddress: data.shippingAddress,
|
|
271
|
+
});
|
|
272
|
+
if (!landedCost || ((_a = landedCost.errors) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
273
|
+
throw new Error(`Failed to build landed cost: ${((_c = (_b = landedCost === null || landedCost === void 0 ? void 0 : landedCost.errors) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.message) || 'Unknown error'}`);
|
|
41
274
|
}
|
|
42
275
|
// Validate the landed cost object to make sure the returned value from buildLandedCost has a valid schema
|
|
43
276
|
const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/validate-landed-cost`, {
|
|
@@ -48,7 +281,7 @@ const triggerBuildLandedCost = async (buildLandedCost) => {
|
|
|
48
281
|
method: 'POST',
|
|
49
282
|
});
|
|
50
283
|
if (!json || errors.length) {
|
|
51
|
-
throw new Error(`Invalid landed cost object: ${((
|
|
284
|
+
throw new Error(`Invalid landed cost object: ${((_d = errors.find(Boolean)) === null || _d === void 0 ? void 0 : _d.message) || 'Unknown error'}`);
|
|
52
285
|
}
|
|
53
286
|
return landedCost;
|
|
54
287
|
};
|
|
@@ -112,7 +345,7 @@ const defaultVariable = ({ borderStyle, theme, }) => {
|
|
|
112
345
|
}
|
|
113
346
|
};
|
|
114
347
|
|
|
115
|
-
const { onChange
|
|
348
|
+
const { onChange, reset, state: stripeStore, } = createStore(() => ({
|
|
116
349
|
clientSecret: sessionStorage.getItem('zonos--client-secret') || null,
|
|
117
350
|
fetchingLandedCostAbordController: null,
|
|
118
351
|
isFetchingLandedCost: false,
|
|
@@ -122,16 +355,21 @@ const { onChange: onChange$1, reset: reset$1, state: stripeStore, } = createStor
|
|
|
122
355
|
stripeAddressEventData: null,
|
|
123
356
|
stripeAddressUsedWhenFetchingLC: null,
|
|
124
357
|
stripeBillingAddressElement: null,
|
|
358
|
+
stripeBillingAddressEventData: null,
|
|
359
|
+
stripeBillingAddressUsedWhenFetchingLC: null,
|
|
125
360
|
stripeElements: null,
|
|
361
|
+
stripeElementsForBillingAddress: null,
|
|
126
362
|
stripeElementsOptions: null,
|
|
127
363
|
stripeLinkElement: null,
|
|
128
364
|
stripeLinkEventData: null,
|
|
129
365
|
stripeLinkUsedWhenFetchingLC: null,
|
|
130
366
|
stripePaymentElement: null,
|
|
131
367
|
stripePaymentEventData: null,
|
|
368
|
+
stripeShippingSameAsBilling: true,
|
|
132
369
|
}));
|
|
133
|
-
const getStripeOptions = ({ clientSecret, overrideBorderRaidus, overridePrimaryColor, overrideTheme, }) => {
|
|
370
|
+
const getStripeOptions = ({ clientSecret, overrideBorderRaidus, overridePrimaryColor, overrideSecondaryColor, overrideTheme, }) => {
|
|
134
371
|
const primaryColor = overridePrimaryColor || zonosStore.appearance.colorPrimary;
|
|
372
|
+
const secondaryColor = overrideSecondaryColor || zonosStore.appearance.colorSecondary;
|
|
135
373
|
const themeBasedColor = primaryColor && isDarkColor(primaryColor) ? 'night' : 'flat';
|
|
136
374
|
// if overrideTheme is provided, use it. Otherwise, use theme based on primary color
|
|
137
375
|
const theme = overrideTheme === 'DARK' ? 'night' : 'flat';
|
|
@@ -141,17 +379,19 @@ const getStripeOptions = ({ clientSecret, overrideBorderRaidus, overridePrimaryC
|
|
|
141
379
|
rules: Object.assign({}, addressRuleStyle({ theme: 'LIGHT' })),
|
|
142
380
|
// get contrast theme color base on primary color
|
|
143
381
|
theme: overrideTheme ? theme : themeBasedColor,
|
|
144
|
-
variables: Object.assign({}, defaultVariable({
|
|
382
|
+
variables: Object.assign(Object.assign({}, defaultVariable({
|
|
145
383
|
borderStyle: overrideBorderRaidus,
|
|
146
384
|
theme: 'LIGHT',
|
|
147
|
-
})),
|
|
385
|
+
})), {
|
|
386
|
+
// use the button background color for input glow color
|
|
387
|
+
colorPrimary: secondaryColor }),
|
|
148
388
|
},
|
|
149
389
|
clientSecret,
|
|
150
390
|
locale: localizationStore.selectedLocale,
|
|
151
391
|
};
|
|
152
392
|
};
|
|
153
393
|
const initStripeElements = async (props) => {
|
|
154
|
-
var _a;
|
|
394
|
+
var _a, _b;
|
|
155
395
|
const clientSecret = stripeStore.clientSecret;
|
|
156
396
|
if (!stripeStore.stripe) {
|
|
157
397
|
log('Skip. Stripe is not initialized');
|
|
@@ -162,22 +402,30 @@ const initStripeElements = async (props) => {
|
|
|
162
402
|
clientSecret,
|
|
163
403
|
overrideBorderRaidus: props === null || props === void 0 ? void 0 : props.overrideBorderRaidus,
|
|
164
404
|
overridePrimaryColor: props === null || props === void 0 ? void 0 : props.overridePrimaryColor,
|
|
405
|
+
overrideSecondaryColor: props === null || props === void 0 ? void 0 : props.overrideSecondaryColor,
|
|
165
406
|
overrideTheme: props === null || props === void 0 ? void 0 : props.overrideTheme,
|
|
166
407
|
});
|
|
167
408
|
// compare with the previous options to see if we need to update
|
|
168
409
|
const isSameOptions = JSON.stringify(stripeOptions) ===
|
|
169
410
|
JSON.stringify(stripeStore.stripeElementsOptions);
|
|
170
|
-
if (!stripeStore.stripeElements
|
|
411
|
+
if (!stripeStore.stripeElements ||
|
|
412
|
+
!stripeStore.stripeElementsForBillingAddress) {
|
|
171
413
|
// init stripe elements if it doesn't exist
|
|
172
414
|
stripeStore.stripeElements = (_a = stripeStore.stripe) === null || _a === void 0 ? void 0 : _a.elements(stripeOptions);
|
|
173
415
|
// save stripe elements options for later comparison
|
|
174
416
|
stripeStore.stripeElementsOptions = stripeOptions;
|
|
175
417
|
log('Stripe elements initialized');
|
|
418
|
+
// init stripe elements for billing address
|
|
419
|
+
stripeStore.stripeElementsForBillingAddress =
|
|
420
|
+
(_b = stripeStore.stripe) === null || _b === void 0 ? void 0 : _b.elements(stripeOptions);
|
|
421
|
+
log('Stripe elements for billing address initialized');
|
|
176
422
|
return;
|
|
177
423
|
}
|
|
178
424
|
if (!isSameOptions) {
|
|
179
425
|
// update elements with new option if it already exists
|
|
180
426
|
stripeStore.stripeElements.update(stripeOptions);
|
|
427
|
+
// update elements for stripe billing address
|
|
428
|
+
stripeStore.stripeElementsForBillingAddress.update(stripeOptions);
|
|
181
429
|
// save stripe elements options for later comparison
|
|
182
430
|
stripeStore.stripeElementsOptions = stripeOptions;
|
|
183
431
|
}
|
|
@@ -188,7 +436,7 @@ const stripeStoreReset = () => {
|
|
|
188
436
|
// clean clientSecret so that we can start the new one.
|
|
189
437
|
sessionStorage.removeItem('zonos--client-secret');
|
|
190
438
|
// cleanup stripe elements
|
|
191
|
-
reset
|
|
439
|
+
reset();
|
|
192
440
|
// set stripe back to window.Zonos.stripe
|
|
193
441
|
stripeStore.stripe = window.Zonos.stripe;
|
|
194
442
|
};
|
|
@@ -197,7 +445,7 @@ const stripeStoreReset = () => {
|
|
|
197
445
|
* Purpose is to resend the request if the info used when fetching landed cost is different from the current info
|
|
198
446
|
*/
|
|
199
447
|
const isPrefetchInfoOutdated = () => {
|
|
200
|
-
var _a, _b, _c, _d;
|
|
448
|
+
var _a, _b, _c, _d, _e, _f;
|
|
201
449
|
const hasAbortController = stripeStore.fetchingLandedCostAbordController;
|
|
202
450
|
if (!hasAbortController) {
|
|
203
451
|
// if there is no abort controller, this is a new request
|
|
@@ -207,26 +455,36 @@ const isPrefetchInfoOutdated = () => {
|
|
|
207
455
|
JSON.stringify((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.value);
|
|
208
456
|
const isAddressDataDirty = JSON.stringify((_c = stripeStore.stripeAddressUsedWhenFetchingLC) === null || _c === void 0 ? void 0 : _c.value) !==
|
|
209
457
|
JSON.stringify((_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value);
|
|
210
|
-
|
|
458
|
+
const isBillingAddressDataDirty = !stripeStore.stripeShippingSameAsBilling &&
|
|
459
|
+
JSON.stringify((_e = stripeStore.stripeBillingAddressEventData) === null || _e === void 0 ? void 0 : _e.value) !==
|
|
460
|
+
JSON.stringify((_f = stripeStore.stripeBillingAddressUsedWhenFetchingLC) === null || _f === void 0 ? void 0 : _f.value);
|
|
461
|
+
return isLinkDataDirty || isAddressDataDirty || isBillingAddressDataDirty;
|
|
211
462
|
};
|
|
212
463
|
const stripeStorePrefetchLandedCost = async () => {
|
|
213
|
-
var _a, _b, _c, _d;
|
|
464
|
+
var _a, _b, _c, _d, _e, _f;
|
|
214
465
|
const stripeAddressReady = !!((_a = stripeStore.stripeAddressEventData) === null || _a === void 0 ? void 0 : _a.complete);
|
|
215
466
|
const stripeLinkReady = !!((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.complete);
|
|
467
|
+
const stripeBillingAddressReady = stripeStore.stripeShippingSameAsBilling
|
|
468
|
+
? !!((_c = stripeStore.stripeLinkEventData) === null || _c === void 0 ? void 0 : _c.complete)
|
|
469
|
+
: !!((_d = stripeStore.stripeBillingAddressEventData) === null || _d === void 0 ? void 0 : _d.complete);
|
|
216
470
|
const shouldRefetch = isPrefetchInfoOutdated();
|
|
217
471
|
if (shouldRefetch) {
|
|
218
472
|
// if the info used when fetching landed cost is different from the current info, abort the previous request
|
|
219
|
-
(
|
|
473
|
+
(_e = stripeStore.fetchingLandedCostAbordController) === null || _e === void 0 ? void 0 : _e.abort();
|
|
220
474
|
stripeStore.fetchingLandedCostAbordController = null;
|
|
221
475
|
}
|
|
222
476
|
// only fetch if we are not fetching or we need to refetch
|
|
223
477
|
if (stripeAddressReady &&
|
|
224
478
|
stripeLinkReady &&
|
|
479
|
+
stripeBillingAddressReady &&
|
|
225
480
|
(shouldRefetch || !stripeStore.isFetchingLandedCost)) {
|
|
226
481
|
stripeStore.isFetchingLandedCost = true;
|
|
227
482
|
if (stripeStore.stripeAddressEventData) {
|
|
228
483
|
stripeStore.stripeAddressUsedWhenFetchingLC = Object.assign({}, stripeStore.stripeAddressEventData);
|
|
229
484
|
}
|
|
485
|
+
if (stripeStore.stripeBillingAddressEventData) {
|
|
486
|
+
stripeStore.stripeBillingAddressUsedWhenFetchingLC = Object.assign({}, stripeStore.stripeBillingAddressEventData);
|
|
487
|
+
}
|
|
230
488
|
if (stripeStore.stripeLinkEventData) {
|
|
231
489
|
stripeStore.stripeLinkUsedWhenFetchingLC = Object.assign({}, stripeStore.stripeLinkEventData);
|
|
232
490
|
}
|
|
@@ -242,7 +500,7 @@ const stripeStorePrefetchLandedCost = async () => {
|
|
|
242
500
|
cartStore.shippingData =
|
|
243
501
|
(shipmentRatingCalculateWorkflow === null || shipmentRatingCalculateWorkflow === void 0 ? void 0 : shipmentRatingCalculateWorkflow.filter(Boolean)) || null;
|
|
244
502
|
// apply new subtotal and total, this is mainly to show items in the presentment currency
|
|
245
|
-
const firstLandedCostData = (
|
|
503
|
+
const firstLandedCostData = (_f = cartStore.landedCostData) === null || _f === void 0 ? void 0 : _f.find(Boolean);
|
|
246
504
|
const subtotals = !!firstLandedCostData
|
|
247
505
|
? firstLandedCostData.subtotals
|
|
248
506
|
: null;
|
|
@@ -411,7 +669,7 @@ const stripeStoreUpdateCheckoutSession = async ({ currency, id, itemsAmount, lan
|
|
|
411
669
|
}
|
|
412
670
|
return { errors: [], json };
|
|
413
671
|
};
|
|
414
|
-
onChange
|
|
672
|
+
onChange('clientSecret', clientSecret => {
|
|
415
673
|
// update stripe elements when client secret changes
|
|
416
674
|
if (clientSecret && stripeStore.stripe) {
|
|
417
675
|
sessionStorage.setItem('zonos--client-secret', clientSecret);
|
|
@@ -421,211 +679,4 @@ onChange$1('clientSecret', clientSecret => {
|
|
|
421
679
|
}
|
|
422
680
|
});
|
|
423
681
|
|
|
424
|
-
|
|
425
|
-
// format date to Thursday 3, 2023
|
|
426
|
-
return new Intl.DateTimeFormat('en-US', formatOptions).format(date);
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
const getDaysDifference = (targetDate) => {
|
|
430
|
-
const currentDate = new Date();
|
|
431
|
-
const timeDifference = targetDate.getTime() - currentDate.getTime();
|
|
432
|
-
const daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24)); // Convert milliseconds to days
|
|
433
|
-
return daysDifference;
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
const { onChange, reset, state: cartStore, } = createStore(() => ({
|
|
437
|
-
checkoutSessionId: sessionStorage.getItem('zonos--checkout-session-id') || null,
|
|
438
|
-
currency: 'USD',
|
|
439
|
-
dutiesTaxFees: 0,
|
|
440
|
-
error: null,
|
|
441
|
-
exchangeRate: null,
|
|
442
|
-
isSelectedShippingAboveDeminimis: false,
|
|
443
|
-
isSelectedShippingGuarantee: false,
|
|
444
|
-
items: [],
|
|
445
|
-
landedCostData: null,
|
|
446
|
-
selectedLandedCost: null,
|
|
447
|
-
selectedShippingOption: null,
|
|
448
|
-
selectedShippingOptionExpectedDate: '',
|
|
449
|
-
selectedShippingOptionTransitTime: '',
|
|
450
|
-
shipping: 0,
|
|
451
|
-
shippingData: null,
|
|
452
|
-
step: 'customer-info',
|
|
453
|
-
subtotal: 0,
|
|
454
|
-
total: 0,
|
|
455
|
-
}));
|
|
456
|
-
/**
|
|
457
|
-
* Format shipping transit info to be displayed on UI
|
|
458
|
-
* @returns
|
|
459
|
-
* - expectedDate: Thursday, Aug 12
|
|
460
|
-
* - maxTransit: 5
|
|
461
|
-
* - minTransit: 3
|
|
462
|
-
*/
|
|
463
|
-
const cartStoreGetShippingTransitInfo = (item) => {
|
|
464
|
-
const minTransit = item.minTransitAt
|
|
465
|
-
? getDaysDifference(new Date(item.minTransitAt))
|
|
466
|
-
: '';
|
|
467
|
-
const maxTransit = item.maxTransitAt
|
|
468
|
-
? getDaysDifference(new Date(item.maxTransitAt))
|
|
469
|
-
: '';
|
|
470
|
-
const expectedDate = item.minTransitAt
|
|
471
|
-
? formatDate({
|
|
472
|
-
date: new Date(item.minTransitAt),
|
|
473
|
-
})
|
|
474
|
-
: '';
|
|
475
|
-
return {
|
|
476
|
-
expectedDate,
|
|
477
|
-
maxTransit,
|
|
478
|
-
minTransit,
|
|
479
|
-
};
|
|
480
|
-
};
|
|
481
|
-
const cartStoreReset = () => {
|
|
482
|
-
sessionStorage.removeItem('zonos--checkout-session-id');
|
|
483
|
-
// reset cart store
|
|
484
|
-
reset();
|
|
485
|
-
};
|
|
486
|
-
const cartStoreUpdateToErrorState = ({ messages, title, }) => {
|
|
487
|
-
cartStore.step = 'error';
|
|
488
|
-
cartStore.error = {
|
|
489
|
-
messages,
|
|
490
|
-
title,
|
|
491
|
-
};
|
|
492
|
-
};
|
|
493
|
-
const cartStoreApplySubtotals = (subtotals) => {
|
|
494
|
-
// update exchange rate so we can use it to display cart items
|
|
495
|
-
cartStore.exchangeRate = subtotals.exchangeRate;
|
|
496
|
-
cartStore.dutiesTaxFees = subtotals.landedCostTotal;
|
|
497
|
-
cartStore.subtotal = subtotals.items;
|
|
498
|
-
cartStore.total = subtotals.total;
|
|
499
|
-
cartStore.currency = subtotals.presentmentCurrencyCode;
|
|
500
|
-
};
|
|
501
|
-
const cartStoreReCalculateTotal = async ({ currency, itemsAmount, landedCostId, }) => {
|
|
502
|
-
if (landedCostId && cartStore.selectedLandedCost) {
|
|
503
|
-
// update cart total right away if we have landed cost id to avoid order total flickering
|
|
504
|
-
const subtotals = cartStore.selectedLandedCost.subtotals;
|
|
505
|
-
cartStoreApplySubtotals(subtotals);
|
|
506
|
-
log('Exchange rate updated for cart items (landed cost subtotal)', 'info', cartStore.exchangeRate);
|
|
507
|
-
}
|
|
508
|
-
// update checkout session
|
|
509
|
-
if (!cartStore.checkoutSessionId) {
|
|
510
|
-
logError('Could not update cart total without checkout session id');
|
|
511
|
-
return false;
|
|
512
|
-
}
|
|
513
|
-
const { json } = await stripeStoreUpdateCheckoutSession({
|
|
514
|
-
currency,
|
|
515
|
-
id: cartStore.checkoutSessionId,
|
|
516
|
-
itemsAmount,
|
|
517
|
-
landedCostId,
|
|
518
|
-
presentmentCountryCode: localizationStore.selectedCountryCode,
|
|
519
|
-
});
|
|
520
|
-
if (!json) {
|
|
521
|
-
// do nothing if we can't get checkout session
|
|
522
|
-
logError('Error occurs when updating checkout session');
|
|
523
|
-
cartStoreUpdateToErrorState({
|
|
524
|
-
messages: [
|
|
525
|
-
translate("There's been an error updating your checkout session. Please reload and try again or contact support if the error persists"),
|
|
526
|
-
],
|
|
527
|
-
title: translate('Error updating Checkout'),
|
|
528
|
-
});
|
|
529
|
-
return false;
|
|
530
|
-
}
|
|
531
|
-
if (!landedCostId) {
|
|
532
|
-
// This is when first open the checkout modal and we just want to get info from the old cart session.
|
|
533
|
-
// use subtotals from checkout session to update cart total
|
|
534
|
-
cartStoreApplySubtotals(json.checkoutSessionUpdate.subtotals);
|
|
535
|
-
log('Exchange rate updated for cart items (checkout session update)', 'info', cartStore.exchangeRate);
|
|
536
|
-
}
|
|
537
|
-
return true;
|
|
538
|
-
};
|
|
539
|
-
const cartStoreUpdateSelectedShippingOption = async (selectedShippingOption) => {
|
|
540
|
-
var _a, _b, _c, _d, _e;
|
|
541
|
-
cartStore.selectedShippingOption = selectedShippingOption;
|
|
542
|
-
// update shipping transit info
|
|
543
|
-
const { expectedDate, maxTransit, minTransit } = cartStoreGetShippingTransitInfo(cartStore.selectedShippingOption);
|
|
544
|
-
cartStore.selectedShippingOptionExpectedDate = expectedDate;
|
|
545
|
-
cartStore.selectedShippingOptionTransitTime =
|
|
546
|
-
minTransit && maxTransit
|
|
547
|
-
? `${minTransit}-${maxTransit}`
|
|
548
|
-
: `${minTransit || maxTransit}`;
|
|
549
|
-
const selectedLandedCost = (_a = cartStore.landedCostData) === null || _a === void 0 ? void 0 : _a.find(checkoutSessionPresentment => {
|
|
550
|
-
var _a, _b, _c;
|
|
551
|
-
return ((_b = (_a = checkoutSessionPresentment.landedCost) === null || _a === void 0 ? void 0 : _a.shipmentRating) === null || _b === void 0 ? void 0 : _b.id) ===
|
|
552
|
-
((_c = cartStore.selectedShippingOption) === null || _c === void 0 ? void 0 : _c.id);
|
|
553
|
-
});
|
|
554
|
-
// save selected landed cost for later use
|
|
555
|
-
cartStore.selectedLandedCost = selectedLandedCost || null;
|
|
556
|
-
if (!selectedLandedCost) {
|
|
557
|
-
// do nothing if we can't find landed cost for selected shipping option
|
|
558
|
-
return false;
|
|
559
|
-
}
|
|
560
|
-
// update shipping value and dutiesTaxFees on selectedShippingOption change
|
|
561
|
-
cartStore.shipping = selectedLandedCost.subtotals.shipping;
|
|
562
|
-
// update deminimis status
|
|
563
|
-
const isGuarantee = ((_b = selectedLandedCost === null || selectedLandedCost === void 0 ? void 0 : selectedLandedCost.landedCost) === null || _b === void 0 ? void 0 : _b.landedCostGuaranteeCode) === 'ZONOS';
|
|
564
|
-
// one item in deminimis with type of duty and tax has threshold value is "ABOVE"
|
|
565
|
-
const isAboveDeminimis = !!((_d = (_c = selectedLandedCost === null || selectedLandedCost === void 0 ? void 0 : selectedLandedCost.landedCost) === null || _c === void 0 ? void 0 : _c.deMinimis) === null || _d === void 0 ? void 0 : _d.find(item => ['DUTY', 'TAX'].includes(item.type) && item.threshold === 'ABOVE'));
|
|
566
|
-
cartStore.isSelectedShippingAboveDeminimis = isAboveDeminimis;
|
|
567
|
-
cartStore.isSelectedShippingGuarantee = isGuarantee;
|
|
568
|
-
// update session with selected landed cost
|
|
569
|
-
const updateCalulateStatus = await cartStoreReCalculateTotal({
|
|
570
|
-
landedCostId: (_e = selectedLandedCost.landedCost) === null || _e === void 0 ? void 0 : _e.id,
|
|
571
|
-
});
|
|
572
|
-
return updateCalulateStatus;
|
|
573
|
-
};
|
|
574
|
-
onChange('checkoutSessionId', () => {
|
|
575
|
-
if (!cartStore.checkoutSessionId) {
|
|
576
|
-
sessionStorage.removeItem('zonos--checkout-session-id');
|
|
577
|
-
return;
|
|
578
|
-
}
|
|
579
|
-
sessionStorage.setItem('zonos--checkout-session-id', cartStore.checkoutSessionId);
|
|
580
|
-
});
|
|
581
|
-
const cartStoreUpdateItems = async (items) => {
|
|
582
|
-
var _a;
|
|
583
|
-
cartStore.items = items;
|
|
584
|
-
const currency = (_a = items.find(Boolean)) === null || _a === void 0 ? void 0 : _a.currencyCode;
|
|
585
|
-
const total = items.reduce((amt, item) => {
|
|
586
|
-
return amt + item.amount * item.quantity;
|
|
587
|
-
}, 0);
|
|
588
|
-
if (!currency || !total) {
|
|
589
|
-
// do nothing if we can't get currency or total
|
|
590
|
-
return;
|
|
591
|
-
}
|
|
592
|
-
cartStore.currency = currency;
|
|
593
|
-
// set loading state here because this is first load checkout session when we already have checkout session id stored
|
|
594
|
-
stripeStore.isFetchingSession = true;
|
|
595
|
-
await cartStoreReCalculateTotal({
|
|
596
|
-
currency: currency,
|
|
597
|
-
itemsAmount: total,
|
|
598
|
-
});
|
|
599
|
-
stripeStore.isFetchingSession = false;
|
|
600
|
-
};
|
|
601
|
-
const cartStoreResetSelectedShippingOption = () => {
|
|
602
|
-
cartStore.selectedShippingOption = null;
|
|
603
|
-
cartStore.isSelectedShippingAboveDeminimis = false;
|
|
604
|
-
cartStore.isSelectedShippingGuarantee = false;
|
|
605
|
-
cartStore.selectedShippingOptionExpectedDate = '';
|
|
606
|
-
cartStore.selectedShippingOptionTransitTime = '';
|
|
607
|
-
cartStore.shipping = 0;
|
|
608
|
-
};
|
|
609
|
-
const cartStoreNextStep = () => {
|
|
610
|
-
if (cartStore.step === 'customer-info') {
|
|
611
|
-
cartStore.step = 'shipping';
|
|
612
|
-
}
|
|
613
|
-
else if (cartStore.step === 'shipping') {
|
|
614
|
-
cartStore.step = 'payment';
|
|
615
|
-
}
|
|
616
|
-
else if (cartStore.step === 'payment') {
|
|
617
|
-
cartStore.step = 'finish';
|
|
618
|
-
}
|
|
619
|
-
};
|
|
620
|
-
const cartStorePreviousStep = () => {
|
|
621
|
-
if (cartStore.step === 'payment') {
|
|
622
|
-
cartStore.step = 'shipping';
|
|
623
|
-
}
|
|
624
|
-
else if (cartStore.step === 'shipping') {
|
|
625
|
-
cartStore.step = 'customer-info';
|
|
626
|
-
// reset selected shipping option
|
|
627
|
-
cartStoreResetSelectedShippingOption();
|
|
628
|
-
}
|
|
629
|
-
};
|
|
630
|
-
|
|
631
|
-
export { cartStoreApplySubtotals as a, cartStoreGetShippingTransitInfo as b, cartStore as c, cartStoreNextStep as d, cartStorePreviousStep as e, cartStoreReCalculateTotal as f, cartStoreReset as g, cartStoreUpdateItems as h, cartStoreUpdateSelectedShippingOption as i, cartStoreUpdateToErrorState as j, stripeStorePrefetchLandedCost as k, initStripeElements as l, stripeStoreInitCheckoutSession as m, stripeStoreConfirmPayment as n, stripeStoreReset as o, stripeStoreRetrievePayment as p, stripeStore as s };
|
|
682
|
+
export { stripeStorePrefetchLandedCost as a, cartStoreUpdateItems as b, cartStore as c, cartStoreReset as d, stripeStoreInitCheckoutSession as e, cartStoreUpdateToErrorState as f, cartStoreNextStep as g, stripeStoreConfirmPayment as h, initStripeElements as i, stripeStoreReset as j, cartStorePreviousStep as k, stripeStoreRetrievePayment as l, cartStoreUpdateSelectedShippingOption as m, cartStoreGetShippingTransitInfo as n, stripeStore as s };
|