@zonos/elements 1.3.184 → 1.3.185
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/{cart-3d0c0f0b.js → cart-f9df3ac8.js} +3209 -10
- package/dist/cjs/debounce-3eaa4f7e.js +357 -0
- package/dist/cjs/{getBorderRadius-94ef609c.js → getBorderRadius-87f3b69c.js} +1 -1
- package/dist/cjs/getGenericSettingsOverride-c0ca32b9.js +104 -0
- package/dist/cjs/helpers-5bdbb68c.js +100 -0
- package/dist/cjs/{index-2f90486e.js → index-0993f42d.js} +15 -3
- package/dist/cjs/index.cjs.js +19 -8
- package/dist/cjs/{isDarkColor-ec4a4e7d.js → isDarkColor-d0c67c3d.js} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{paypal-9eaa9196.js → paypal-5e73c8f5.js} +3 -3
- package/dist/cjs/zonos-address_11.cjs.entry.js +7917 -0
- package/dist/cjs/zonos-badge.cjs.entry.js +2 -2
- package/dist/cjs/zonos-banner.cjs.entry.js +2 -2
- package/dist/cjs/zonos-button_3.cjs.entry.js +18 -7
- package/dist/cjs/zonos-card.cjs.entry.js +3 -3
- package/dist/cjs/zonos-cart-items_13.cjs.entry.js +113 -21
- package/dist/cjs/zonos-checkout.cjs.entry.js +9 -7
- package/dist/cjs/zonos-collapse.cjs.entry.js +2 -2
- package/dist/cjs/zonos-component.cjs.entry.js +2 -2
- package/dist/cjs/zonos-controller.cjs.entry.js +225 -7
- package/dist/cjs/zonos-country-flag.cjs.entry.js +5 -5
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +10 -10
- package/dist/cjs/zonos-elements.cjs.js +2 -2
- package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +8 -8
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +9 -9
- package/dist/cjs/zonos-hello.cjs.entry.js +7 -358
- package/dist/cjs/zonos-input.cjs.entry.js +3 -3
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +5 -5
- package/dist/cjs/zonos-link.cjs.entry.js +1 -1
- package/dist/cjs/zonos-logo.cjs.entry.js +2 -2
- package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +3 -3
- package/dist/cjs/zonos-stripe-input.cjs.entry.js +31 -12
- package/dist/cjs/zonos-text.cjs.entry.js +2 -2
- package/dist/cjs/zonos-toggle.cjs.entry.js +4 -4
- package/dist/cjs/zonos-tooltip.cjs.entry.js +3 -3
- package/dist/cjs/zonos-v-stack.cjs.entry.js +4 -4
- package/dist/cjs/{zonosStore-3812b318.js → zonosStore-adc42868.js} +2 -1
- package/dist/collection/collection-manifest.json +4 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-address-update-dialog/zonos-address-update-dialog.js +3 -3
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.css +11 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +22 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.css +1 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +162 -17
- package/dist/collection/components/common/zonos-button/zonos-button.js +14 -3
- package/dist/collection/components/common/zonos-checkbox/zonos-checkbox.js +5 -3
- package/dist/collection/components/common/zonos-checkout-progress-tabs/zonos-checkout-progress-tabs.js +2 -2
- package/dist/collection/components/common/zonos-country-select/zonos-country-select.css +0 -6
- package/dist/collection/components/common/zonos-dialog/zonos-dialog.js +2 -2
- package/dist/collection/components/common/zonos-stripe-input/zonos-stripe-input.css +2 -3
- package/dist/collection/components/common/zonos-stripe-input/zonos-stripe-input.js +105 -8
- package/dist/collection/components/common/zonos-stripe-phone-input/assets/ChevronDownIcon.svg +1 -0
- package/dist/collection/components/common/zonos-stripe-phone-input/zonos-stripe-phone-input.css +222 -0
- package/dist/collection/components/common/zonos-stripe-phone-input/zonos-stripe-phone-input.js +481 -0
- package/dist/collection/components/common/zonos-stripe-select/assets/ChevronDownIcon.svg +1 -0
- package/dist/collection/components/common/zonos-stripe-select/assets/RemoveLineIcon.svg +1 -0
- package/dist/collection/components/common/zonos-stripe-select/zonos-stripe-select.css +178 -0
- package/dist/collection/components/common/zonos-stripe-select/zonos-stripe-select.js +455 -0
- package/dist/collection/components/common/zonos-toggle/zonos-toggle.js +2 -2
- package/dist/collection/components/common/zonos-tooltip/zonos-tooltip.js +2 -2
- package/dist/collection/components/common/zonos-v-stack/zonos-v-stack.js +2 -2
- package/dist/collection/components/common/zonos-virtual-scroll/zonos-virtual-scroll.js +2 -2
- 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/zonos-hello-dialog-footer.js +2 -2
- package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +4 -4
- package/dist/collection/components/main/zonos-controller.js +24 -1
- package/dist/collection/components/paypal/zonos-paypal-payment.js +1 -1
- package/dist/collection/components/store/checkout/stripe.js +24 -7
- package/dist/collection/components/store/translationStore/strings.arabic.js +159 -0
- package/dist/collection/components/store/translationStore/strings.base.js +161 -0
- package/dist/collection/components/store/translationStore/strings.chinese.js +159 -0
- package/dist/collection/components/store/translationStore/strings.danish.js +159 -0
- package/dist/collection/components/store/translationStore/strings.dutch.js +159 -0
- package/dist/collection/components/store/translationStore/strings.french.js +159 -0
- package/dist/collection/components/store/translationStore/strings.german.js +159 -0
- package/dist/collection/components/store/translationStore/strings.hebrew.js +159 -0
- package/dist/collection/components/store/translationStore/strings.indonesian.js +159 -0
- package/dist/collection/components/store/translationStore/strings.italian.js +159 -0
- package/dist/collection/components/store/translationStore/strings.japanese.js +159 -0
- package/dist/collection/components/store/translationStore/strings.korean.js +159 -0
- package/dist/collection/components/store/translationStore/strings.norwegian.js +159 -0
- package/dist/collection/components/store/translationStore/strings.polish.js +159 -0
- package/dist/collection/components/store/translationStore/strings.portuguese.js +159 -0
- package/dist/collection/components/store/translationStore/strings.russian.js +159 -0
- package/dist/collection/components/store/translationStore/strings.spanish.js +159 -0
- package/dist/collection/components/store/translationStore/strings.swedish.js +159 -0
- package/dist/collection/components/store/translationStore/strings.turkish.js +159 -0
- package/dist/collection/components/store/translationStore/strings.vietnamese.js +159 -0
- package/dist/collection/components/store/zonosStore.js +1 -0
- package/dist/collection/components/stripe/zonos-address/zonos-address.js +1 -1
- package/dist/collection/components/stripe/zonos-custom-address/zonos-address-suggestions/assets/RemoveIcon.svg +1 -0
- package/dist/collection/components/stripe/zonos-custom-address/zonos-address-suggestions/zonos-address-suggestions.css +86 -0
- package/dist/collection/components/stripe/zonos-custom-address/zonos-address-suggestions/zonos-address-suggestions.js +192 -0
- package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.css +67 -0
- package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +978 -0
- package/dist/collection/components/stripe/zonos-payment/zonos-payment.js +1 -1
- package/dist/collection/components/utils/api/getGenericSettingsOverride.js +10 -0
- package/dist/collection/components/utils/api/getZonosSettings.js +7 -1
- package/dist/collection/components/utils/checkout/form/helpers.js +95 -0
- package/dist/collection/components/utils/checkout/form/isValidZip.js +18 -0
- package/dist/collection/components/utils/iframe/CheckoutAddressService.js +193 -0
- package/dist/collection/components/utils/iframe/IframeHelpers.js +86 -0
- package/dist/collection/components/utils/mergeAddress.js +5 -0
- package/dist/collection/constants/phone-formats.js +658 -0
- package/dist/collection/scripts/_getCartInfoById.js +7 -1
- package/dist/collection/scripts/_zonosBase.js +7 -0
- package/dist/collection/types/CountryFields.js +1 -0
- package/dist/collection/types/checkout/form/CustomAddressErrors.js +1 -0
- package/dist/collection/types/generated/graphql.frontend.types.js +9 -0
- package/dist/collection/types/generated/graphql.internal.types.js +96 -0
- package/dist/collection/types/index.js +0 -1
- package/dist/esm/{cart-3fb04f1f.js → cart-4725a63b.js} +3209 -10
- package/dist/esm/debounce-3cf0793c.js +355 -0
- package/dist/esm/{getBorderRadius-ada3ccad.js → getBorderRadius-a9a48f79.js} +1 -1
- package/dist/esm/getGenericSettingsOverride-0bc3e118.js +99 -0
- package/dist/esm/helpers-2f6955b1.js +97 -0
- package/dist/esm/{index-d82f06f2.js → index-a457c60c.js} +15 -3
- package/dist/esm/index.js +19 -8
- package/dist/esm/{isDarkColor-446fccb7.js → isDarkColor-62cbddb5.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{paypal-1f2e863c.js → paypal-a09943f4.js} +3 -3
- package/dist/esm/zonos-address_11.entry.js +7903 -0
- package/dist/esm/zonos-badge.entry.js +2 -2
- package/dist/esm/zonos-banner.entry.js +2 -2
- package/dist/esm/zonos-button_3.entry.js +18 -7
- package/dist/esm/zonos-card.entry.js +3 -3
- package/dist/esm/zonos-cart-items_13.entry.js +113 -21
- package/dist/esm/zonos-checkout.entry.js +9 -7
- package/dist/esm/zonos-collapse.entry.js +2 -2
- package/dist/esm/zonos-component.entry.js +2 -2
- package/dist/esm/zonos-controller.entry.js +225 -7
- package/dist/esm/zonos-country-flag.entry.js +5 -5
- package/dist/esm/zonos-country-select_4.entry.js +10 -10
- package/dist/esm/zonos-elements.js +3 -3
- package/dist/esm/zonos-empty-state-payment_4.entry.js +8 -8
- package/dist/esm/zonos-hello-dialog.entry.js +9 -9
- package/dist/esm/zonos-hello.entry.js +6 -357
- package/dist/esm/zonos-input.entry.js +3 -3
- package/dist/esm/zonos-language-select_2.entry.js +5 -5
- package/dist/esm/zonos-link.entry.js +1 -1
- package/dist/esm/zonos-logo.entry.js +2 -2
- package/dist/esm/zonos-shipping-rich-radio.entry.js +3 -3
- package/dist/esm/zonos-stripe-input.entry.js +31 -12
- package/dist/esm/zonos-text.entry.js +2 -2
- package/dist/esm/zonos-toggle.entry.js +4 -4
- package/dist/esm/zonos-tooltip.entry.js +3 -3
- package/dist/esm/zonos-v-stack.entry.js +4 -4
- package/dist/esm/{zonosStore-d3c5a0a5.js → zonosStore-1ce34e04.js} +2 -1
- package/dist/esm-es5/cart-4725a63b.js +1 -0
- package/dist/esm-es5/debounce-3cf0793c.js +1 -0
- package/dist/esm-es5/{getBorderRadius-ada3ccad.js → getBorderRadius-a9a48f79.js} +1 -1
- package/dist/esm-es5/getGenericSettingsOverride-0bc3e118.js +1 -0
- package/dist/esm-es5/helpers-2f6955b1.js +1 -0
- package/dist/esm-es5/index-a457c60c.js +2 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{isDarkColor-446fccb7.js → isDarkColor-62cbddb5.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/{paypal-1f2e863c.js → paypal-a09943f4.js} +1 -1
- package/dist/esm-es5/zonos-address_11.entry.js +1 -0
- package/dist/esm-es5/zonos-badge.entry.js +1 -1
- package/dist/esm-es5/zonos-banner.entry.js +1 -1
- package/dist/esm-es5/zonos-button_3.entry.js +1 -1
- package/dist/esm-es5/zonos-card.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_13.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-collapse.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 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-elements.js +1 -1
- package/dist/esm-es5/zonos-empty-state-payment_4.entry.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-input.entry.js +1 -1
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/esm-es5/zonos-link.entry.js +1 -1
- package/dist/esm-es5/zonos-logo.entry.js +1 -1
- package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
- package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
- package/dist/esm-es5/zonos-text.entry.js +1 -1
- package/dist/esm-es5/zonos-toggle.entry.js +1 -1
- package/dist/esm-es5/zonos-tooltip.entry.js +1 -1
- package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
- package/dist/esm-es5/{zonosStore-d3c5a0a5.js → zonosStore-1ce34e04.js} +1 -1
- package/dist/scripts/index.d.ts +3985 -3371
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/checkout/zonos-checkout/zonos-checkout.d.ts +4 -0
- package/dist/types/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.d.ts +28 -1
- package/dist/types/components/common/zonos-button/zonos-button.d.ts +4 -0
- package/dist/types/components/common/zonos-checkbox/zonos-checkbox.d.ts +1 -0
- package/dist/types/components/common/zonos-stripe-input/zonos-stripe-input.d.ts +22 -0
- package/dist/types/components/common/zonos-stripe-phone-input/zonos-stripe-phone-input.d.ts +88 -0
- package/dist/types/components/common/zonos-stripe-select/zonos-stripe-select.d.ts +86 -0
- package/dist/types/components/main/zonos-controller.d.ts +1 -0
- package/dist/types/components/store/checkout/stripe.d.ts +9 -0
- package/dist/types/components/store/translationStore/strings.arabic.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.base.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.chinese.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.danish.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.dutch.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.french.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.german.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.hebrew.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.indonesian.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.italian.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.japanese.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.korean.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.norwegian.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.polish.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.portuguese.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.russian.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.spanish.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.swedish.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.turkish.d.ts +159 -0
- package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +159 -0
- package/dist/types/components/store/zonosStore.d.ts +6 -1
- package/dist/types/components/stripe/zonos-custom-address/zonos-address-suggestions/zonos-address-suggestions.d.ts +38 -0
- package/dist/types/components/stripe/zonos-custom-address/zonos-custom-address.d.ts +150 -0
- package/dist/types/components/utils/api/getGenericSettingsOverride.d.ts +5 -0
- package/dist/types/components/utils/api/getLocaleMessages.d.ts +1 -1
- package/dist/types/components/utils/api/getZonosSettings.d.ts +2 -2
- package/dist/types/components/utils/checkout/form/helpers.d.ts +19 -0
- package/dist/types/components/utils/checkout/form/isValidZip.d.ts +5 -0
- package/dist/types/components/utils/iframe/CheckoutAddressService.d.ts +38 -0
- package/dist/types/components/utils/iframe/IframeHelpers.d.ts +81 -0
- package/dist/types/components/utils/mergeAddress.d.ts +4 -0
- package/dist/types/components/utils/resetToSelectedTab.d.ts +1 -1
- package/dist/types/components.d.ts +472 -4
- package/dist/types/constants/phone-formats.d.ts +5 -0
- package/dist/types/environment.d.ts +1 -1
- package/dist/types/scripts/_zonosBase.d.ts +13 -1
- package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +1 -0
- package/dist/types/types/CountryFields.d.ts +40 -0
- package/dist/types/types/checkout/form/CustomAddressErrors.d.ts +13 -0
- package/dist/types/types/generated/graphql.frontend.types.d.ts +164 -1
- package/dist/types/types/generated/graphql.frontend.types.ts +145 -1
- package/dist/types/types/generated/graphql.internal.types.d.ts +127 -0
- package/dist/types/types/generated/graphql.internal.types.ts +155 -0
- package/dist/types/types/global.d.ts +1 -0
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/types/utils/ZonosSettings.d.ts +17 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-4622cca6.entry.js → p-0104d3ba.entry.js} +1 -1
- package/dist/zonos-elements/{p-7cb87ea7.system.entry.js → p-04303b56.system.entry.js} +1 -1
- package/dist/zonos-elements/p-06f798ee.system.js +1 -0
- package/dist/zonos-elements/{p-739014f8.system.entry.js → p-0fdd7034.system.entry.js} +1 -1
- package/dist/zonos-elements/p-15dd7ea4.system.entry.js +1 -0
- package/dist/zonos-elements/{p-a1cfbd0a.js → p-17299200.js} +1 -1
- package/dist/zonos-elements/{p-58f660d4.system.entry.js → p-1b29bc5f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-fe2c27c4.entry.js → p-1e612c29.entry.js} +1 -1
- package/dist/zonos-elements/{p-98aa88b1.js → p-2097fae5.js} +1 -1
- package/dist/zonos-elements/{p-81084be5.system.entry.js → p-240ee490.system.entry.js} +1 -1
- package/dist/zonos-elements/p-2416aaa1.system.entry.js +1 -0
- package/dist/zonos-elements/{p-cedf08f0.entry.js → p-313ef896.entry.js} +1 -1
- package/dist/zonos-elements/{p-fa65b53d.entry.js → p-314fbfe1.entry.js} +1 -1
- package/dist/zonos-elements/{p-5187ba8f.system.js → p-31e90130.system.js} +1 -1
- package/dist/zonos-elements/{p-4ca666ea.system.entry.js → p-341f40c2.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d49c6a3e.system.entry.js → p-35f33601.system.entry.js} +1 -1
- package/dist/zonos-elements/p-4160bbc2.system.js +1 -0
- package/dist/zonos-elements/p-43633269.system.js +2 -0
- package/dist/zonos-elements/p-443b5db2.entry.js +1 -0
- package/dist/zonos-elements/p-46d3e378.system.entry.js +1 -0
- package/dist/zonos-elements/{p-3d221556.system.entry.js → p-488ad646.system.entry.js} +1 -1
- package/dist/zonos-elements/p-53ffdb91.js +1 -0
- package/dist/zonos-elements/p-56b56caa.system.entry.js +1 -0
- package/dist/zonos-elements/p-5e15616f.entry.js +1 -0
- package/dist/zonos-elements/{p-3eac4b10.entry.js → p-5f896e9a.entry.js} +1 -1
- package/dist/zonos-elements/{p-e8c70c7d.system.entry.js → p-609c32a3.system.entry.js} +1 -1
- package/dist/zonos-elements/p-64ea232c.system.entry.js +1 -0
- package/dist/zonos-elements/{p-f378b4d3.system.entry.js → p-678ccc3f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8048932d.entry.js → p-67b904c2.entry.js} +1 -1
- package/dist/zonos-elements/p-6b40da70.system.js +1 -0
- package/dist/zonos-elements/p-70d4d436.entry.js +1 -0
- package/dist/zonos-elements/{p-64dbc282.entry.js → p-818d6f17.entry.js} +1 -1
- package/dist/zonos-elements/{p-b5b9aa6c.entry.js → p-81ee1683.entry.js} +1 -1
- package/dist/zonos-elements/{p-236f32c8.system.entry.js → p-89fcd305.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-c4fa8524.system.entry.js → p-94a80d93.system.entry.js} +1 -1
- package/dist/zonos-elements/p-961620ae.entry.js +1 -0
- package/dist/zonos-elements/{p-4eff2f8a.system.entry.js → p-98e4a965.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-5bebcfc2.system.js → p-9913c186.system.js} +1 -1
- package/dist/zonos-elements/{p-29e8c9e8.system.entry.js → p-991c85f1.system.entry.js} +1 -1
- package/dist/zonos-elements/p-995761ea.system.entry.js +1 -0
- package/dist/zonos-elements/p-9a6eb099.entry.js +1 -0
- package/dist/zonos-elements/p-9a7a9b1c.entry.js +1 -0
- package/dist/zonos-elements/{p-d367c9ae.system.entry.js → p-9f7b9d66.system.entry.js} +1 -1
- package/dist/zonos-elements/p-a2dab25e.system.entry.js +1 -0
- package/dist/zonos-elements/{p-587568b5.entry.js → p-aaff5dcc.entry.js} +1 -1
- package/dist/zonos-elements/{p-3731e7f5.entry.js → p-abc66a0b.entry.js} +1 -1
- package/dist/zonos-elements/{p-eb294265.entry.js → p-aca3a2bb.entry.js} +1 -1
- package/dist/zonos-elements/p-afa34aff.system.js +1 -0
- package/dist/zonos-elements/{p-69f84611.entry.js → p-b2241919.entry.js} +1 -1
- package/dist/zonos-elements/p-b5edee66.system.js +1 -0
- package/dist/zonos-elements/p-b610f70c.system.js +1 -0
- package/dist/zonos-elements/{p-69255ed2.system.js → p-bbbaea3a.system.js} +1 -1
- package/dist/zonos-elements/p-c137dc82.js +2 -0
- package/dist/zonos-elements/{p-be9e1818.system.entry.js → p-c140a0bd.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-de221545.entry.js → p-cf6ae7dc.entry.js} +1 -1
- package/dist/zonos-elements/{p-90633d63.entry.js → p-d0f4b6c3.entry.js} +1 -1
- package/dist/zonos-elements/{p-112aecac.js → p-de462b9b.js} +2 -2
- package/dist/zonos-elements/{p-107b08c1.entry.js → p-e5d081d8.entry.js} +1 -1
- package/dist/zonos-elements/p-e7b0c156.js +1 -0
- package/dist/zonos-elements/{p-30fdcbee.js → p-e892fb29.js} +1 -1
- package/dist/zonos-elements/p-e90cb997.entry.js +1 -0
- package/dist/zonos-elements/{p-db3f381d.entry.js → p-e91b244c.entry.js} +1 -1
- package/dist/zonos-elements/{p-41dfc828.entry.js → p-e99354d5.entry.js} +1 -1
- package/dist/zonos-elements/p-ea6d87a1.system.js +1 -0
- package/dist/zonos-elements/p-eef5b0cc.js +1 -0
- package/dist/zonos-elements/{p-d0944cc8.system.entry.js → p-f3f27bf2.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-0e63259c.system.entry.js → p-f4cc688e.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-cc6d9f7d.entry.js → p-f7d3e48b.entry.js} +1 -1
- package/dist/zonos-elements/p-fa6de0f3.js +1 -0
- package/dist/zonos-elements/{p-c5c8f803.system.entry.js → p-fd348fd4.system.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/dist/zonos-elements/zonos-elements.js +1 -1
- package/package.json +3 -1
- package/dist/cjs/zonos-address_7.cjs.entry.js +0 -772
- package/dist/esm/zonos-address_7.entry.js +0 -762
- package/dist/esm-es5/cart-3fb04f1f.js +0 -1
- package/dist/esm-es5/index-d82f06f2.js +0 -2
- package/dist/esm-es5/zonos-address_7.entry.js +0 -1
- package/dist/zonos-elements/p-09041efe.entry.js +0 -1
- package/dist/zonos-elements/p-16e4cdb1.entry.js +0 -1
- package/dist/zonos-elements/p-43feb95e.entry.js +0 -1
- package/dist/zonos-elements/p-46f6e5e9.system.js +0 -1
- package/dist/zonos-elements/p-4caffd96.system.js +0 -2
- package/dist/zonos-elements/p-642bf613.system.entry.js +0 -1
- package/dist/zonos-elements/p-6c0c8722.system.entry.js +0 -1
- package/dist/zonos-elements/p-7decb19b.entry.js +0 -1
- package/dist/zonos-elements/p-829f6a40.entry.js +0 -1
- package/dist/zonos-elements/p-8f640b28.entry.js +0 -1
- package/dist/zonos-elements/p-a69dbe14.js +0 -1
- package/dist/zonos-elements/p-ab68ad11.js +0 -2
- package/dist/zonos-elements/p-b1020237.system.js +0 -1
- package/dist/zonos-elements/p-bc0f885e.system.entry.js +0 -1
- package/dist/zonos-elements/p-c6d96a42.system.js +0 -1
- package/dist/zonos-elements/p-ce853f8f.system.entry.js +0 -1
- package/dist/zonos-elements/p-d5d39db4.system.entry.js +0 -1
- package/dist/zonos-elements/p-e4f8114a.system.js +0 -1
- package/dist/zonos-elements/p-e99e75dd.system.entry.js +0 -1
- package/dist/zonos-elements/p-f66a5c7c.system.entry.js +0 -1
- package/dist/zonos-elements/p-febb90e0.entry.js +0 -1
|
@@ -0,0 +1,978 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s)
|
|
4
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { h, Host, } from "@stencil/core";
|
|
14
|
+
import throttle from "lodash/throttle";
|
|
15
|
+
import { cartStore } from "../../store/checkout/cart";
|
|
16
|
+
import { stripeStore } from "../../store/checkout/stripe";
|
|
17
|
+
import { localizationStore } from "../../store/hello/localization";
|
|
18
|
+
import { translate } from "../../store/translationStore";
|
|
19
|
+
import { zonosStore } from "../../store/zonosStore";
|
|
20
|
+
import { trackConversionEvent } from "../../utils/api/trackConversionEvent";
|
|
21
|
+
import { isValidZip } from "../../utils/checkout/form/isValidZip";
|
|
22
|
+
import { isCheckoutMobile } from "../../utils/checkout/isCheckoutMobile";
|
|
23
|
+
import { classes } from "../../utils/classes";
|
|
24
|
+
import { log } from "../../utils/logging/log";
|
|
25
|
+
import { mergeAddress } from "../../utils/mergeAddress";
|
|
26
|
+
/**
|
|
27
|
+
* This component is a wrapper for the stripe address element that would render default style object
|
|
28
|
+
*/
|
|
29
|
+
export class ZonosAddress {
|
|
30
|
+
constructor() {
|
|
31
|
+
/**
|
|
32
|
+
* Whether the suggestion is clicked
|
|
33
|
+
*/
|
|
34
|
+
this.suggestionClicked = false;
|
|
35
|
+
/**
|
|
36
|
+
* Check if the tracking event is sent
|
|
37
|
+
*/
|
|
38
|
+
this.trackingSent = false;
|
|
39
|
+
/**
|
|
40
|
+
* Google autocomplete overlay is conflict with our button, this is to adjust z index of the autocomplete
|
|
41
|
+
*/
|
|
42
|
+
this.isAutoCompleteAdjusted = false;
|
|
43
|
+
// Create a single throttled instance that persists
|
|
44
|
+
this.throttledGetAddressSuggestions = throttle(() => {
|
|
45
|
+
if (zonosStore.checkoutAddressService) {
|
|
46
|
+
zonosStore.checkoutAddressService.getAddressSuggestions({
|
|
47
|
+
country: this.country,
|
|
48
|
+
query: [this.line1, this.state, this.postalCode]
|
|
49
|
+
.filter(Boolean)
|
|
50
|
+
.join(', '),
|
|
51
|
+
type: this.type,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}, 1000);
|
|
55
|
+
// Map the custom address form to stripe address event data
|
|
56
|
+
this.setCustomAddressFormToStripeAddressEventData = () => {
|
|
57
|
+
// If the field is not shown, set it to an empty string
|
|
58
|
+
const cityValue = !this.countryField || this.countryField.cityShow ? this.city : '';
|
|
59
|
+
const stateValue = !this.countryField || this.countryField.stateShow ? this.state : '';
|
|
60
|
+
const postalCodeValue = !this.countryField || this.countryField.zipShow ? this.postalCode : '';
|
|
61
|
+
const transformedAddress = {
|
|
62
|
+
complete: this.getIsComplete(),
|
|
63
|
+
elementMode: this.type,
|
|
64
|
+
elementType: 'address',
|
|
65
|
+
empty: !this.getIsComplete(),
|
|
66
|
+
isNewAddress: true,
|
|
67
|
+
value: {
|
|
68
|
+
address: {
|
|
69
|
+
city: cityValue,
|
|
70
|
+
country: this.country,
|
|
71
|
+
line1: this.line1,
|
|
72
|
+
line2: this.line2,
|
|
73
|
+
postal_code: postalCodeValue,
|
|
74
|
+
state: stateValue,
|
|
75
|
+
},
|
|
76
|
+
firstName: this.firstName,
|
|
77
|
+
lastName: this.lastName,
|
|
78
|
+
name: `${this.firstName} ${this.lastName}`,
|
|
79
|
+
phone: this.phone,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
this.updateAddressEventData({
|
|
83
|
+
event: transformedAddress,
|
|
84
|
+
type: this.type,
|
|
85
|
+
});
|
|
86
|
+
this.addressChange.emit({
|
|
87
|
+
errors: this.getCustomAddressErrors(),
|
|
88
|
+
type: this.type,
|
|
89
|
+
value: transformedAddress,
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
this.getCustomAddressErrors = () => {
|
|
93
|
+
return this.type === 'shipping'
|
|
94
|
+
? stripeStore.customAddressErrors
|
|
95
|
+
: stripeStore.customBillingAddressErrors;
|
|
96
|
+
};
|
|
97
|
+
this.validate = ({ phoneValidateInfo, type, value, valueType, }) => {
|
|
98
|
+
var _a, _b, _c;
|
|
99
|
+
const customErrors = Object.assign({}, this.getCustomAddressErrors());
|
|
100
|
+
switch (valueType) {
|
|
101
|
+
case 'city': {
|
|
102
|
+
const isValid = ((_a = this.countryField) === null || _a === void 0 ? void 0 : _a.cityRequired) && !!(value === null || value === void 0 ? void 0 : value.trim());
|
|
103
|
+
customErrors.city = '';
|
|
104
|
+
if (!isValid) {
|
|
105
|
+
customErrors.city = translate('The field is incomplete');
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case 'state': {
|
|
110
|
+
const isValid = ((_b = this.countryField) === null || _b === void 0 ? void 0 : _b.stateRequired) && !!(value === null || value === void 0 ? void 0 : value.trim());
|
|
111
|
+
customErrors.state = '';
|
|
112
|
+
if (!isValid) {
|
|
113
|
+
customErrors.state = translate('The field is incomplete');
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
case 'postalCode': {
|
|
118
|
+
const isValid = isValidZip({
|
|
119
|
+
countryFields: this.countryField,
|
|
120
|
+
zip: value || '',
|
|
121
|
+
});
|
|
122
|
+
customErrors.postalCode = '';
|
|
123
|
+
if (!isValid) {
|
|
124
|
+
customErrors.postalCode = translate('Your [zipLabel] is invalid', {
|
|
125
|
+
zipLabel: ((_c = this.countryField) === null || _c === void 0 ? void 0 : _c.zipLabel) || 'ZIP',
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case 'firstName': {
|
|
131
|
+
const isValid = !!(value === null || value === void 0 ? void 0 : value.trim());
|
|
132
|
+
customErrors.firstName = '';
|
|
133
|
+
if (!isValid) {
|
|
134
|
+
customErrors.firstName = translate('Please provide your first name.');
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
case 'lastName': {
|
|
139
|
+
const isValid = !!(value === null || value === void 0 ? void 0 : value.trim());
|
|
140
|
+
customErrors.lastName = '';
|
|
141
|
+
if (!isValid) {
|
|
142
|
+
customErrors.lastName = translate('Please provide your last name.');
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
case 'line1': {
|
|
147
|
+
const isValid = !!(value === null || value === void 0 ? void 0 : value.trim());
|
|
148
|
+
customErrors.line1 = '';
|
|
149
|
+
if (!isValid) {
|
|
150
|
+
customErrors.line1 = translate('The field is incomplete');
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case 'phone': {
|
|
155
|
+
// If the phone validate info is not provided, we need to validate the phone number
|
|
156
|
+
if (!phoneValidateInfo) {
|
|
157
|
+
const isValid = !!(value === null || value === void 0 ? void 0 : value.trim());
|
|
158
|
+
customErrors.phone = '';
|
|
159
|
+
if (!isValid) {
|
|
160
|
+
customErrors.phone = translate('Please provide a mobile phone number.');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
customErrors.phone = '';
|
|
165
|
+
// If the phone number is empty, set the error message
|
|
166
|
+
if (phoneValidateInfo.isEmpty) {
|
|
167
|
+
customErrors.phone = translate('Please provide a mobile phone number.');
|
|
168
|
+
}
|
|
169
|
+
else if (phoneValidateInfo.wrongFormat) {
|
|
170
|
+
customErrors.phone = translate('Your mobile phone number is incomplete.');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (type === 'shipping') {
|
|
177
|
+
stripeStore.customAddressErrors = customErrors;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
stripeStore.customBillingAddressErrors = customErrors;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
this.type = undefined;
|
|
184
|
+
this.titleText = undefined;
|
|
185
|
+
this.defaultAddress = [];
|
|
186
|
+
this.stripe = window.Zonos.stripe;
|
|
187
|
+
this.isDirtyAddress = false;
|
|
188
|
+
this.isAddressFilled = false;
|
|
189
|
+
this.isAddressLine1Entered = false;
|
|
190
|
+
this.addressSuggestions = [];
|
|
191
|
+
this.countryField = null;
|
|
192
|
+
this.startGooglePlaceSuggestions = false;
|
|
193
|
+
this.shipToCountries = null;
|
|
194
|
+
this.shippingZones = null;
|
|
195
|
+
this.city = '';
|
|
196
|
+
this.country = '';
|
|
197
|
+
this.firstName = '';
|
|
198
|
+
this.lastName = '';
|
|
199
|
+
this.line1 = '';
|
|
200
|
+
this.line2 = null;
|
|
201
|
+
this.phone = '';
|
|
202
|
+
this.postalCode = '';
|
|
203
|
+
this.state = '';
|
|
204
|
+
this.cityError = '';
|
|
205
|
+
this.stateError = '';
|
|
206
|
+
this.postalCodeError = '';
|
|
207
|
+
this.phoneError = '';
|
|
208
|
+
this.firstNameError = '';
|
|
209
|
+
this.lastNameError = '';
|
|
210
|
+
this.isFirstInitialization = true;
|
|
211
|
+
this.addressService = null;
|
|
212
|
+
this.checkoutSessionId = cartStore.checkoutSessionId;
|
|
213
|
+
}
|
|
214
|
+
getStripeAddressInstance() {
|
|
215
|
+
if (this.type === 'billing') {
|
|
216
|
+
return {
|
|
217
|
+
stripeAddressElement: stripeStore.stripeBillingAddressElement,
|
|
218
|
+
stripeAddressEventData: stripeStore.stripeBillingAddressEventData,
|
|
219
|
+
stripeElements: stripeStore.stripeElementsForBillingAddress,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
stripeAddressElement: stripeStore.stripeAddressElement,
|
|
224
|
+
stripeAddressEventData: stripeStore.stripeAddressEventData,
|
|
225
|
+
stripeElements: stripeStore.stripeElements,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
updateAddressEventData({ event, type, }) {
|
|
229
|
+
switch (type) {
|
|
230
|
+
case 'billing':
|
|
231
|
+
stripeStore.stripeBillingAddressEventData = event;
|
|
232
|
+
break;
|
|
233
|
+
default: {
|
|
234
|
+
stripeStore.stripeAddressEventData = event;
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
isAddressFilledChanged() {
|
|
240
|
+
// Sometimes address elements is loaded with prefilled data before checkout is loaded, need to not send the event if checkout session id is not available, and send the event after checkout is loaded
|
|
241
|
+
if (!cartStore.checkoutSessionId) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
// Only need to track the event if the shipping address is filled
|
|
245
|
+
if (this.isAddressFilled &&
|
|
246
|
+
!this.trackingSent &&
|
|
247
|
+
this.type === 'shipping') {
|
|
248
|
+
this.trackingSent = true;
|
|
249
|
+
const checkoutSessionId = cartStore.checkoutSessionId;
|
|
250
|
+
void trackConversionEvent({
|
|
251
|
+
checkoutSessionId,
|
|
252
|
+
eventName: 'checkout_customerInfoFilled',
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
defaultAddressChanged(newAddress, oldAddress) {
|
|
257
|
+
// check if stringified json of oldAddress is different from newAddress
|
|
258
|
+
const oldAddressString = JSON.stringify(oldAddress);
|
|
259
|
+
const newAddressString = JSON.stringify(newAddress);
|
|
260
|
+
// No need to reset address element if the default address is the same
|
|
261
|
+
if (oldAddressString === newAddressString) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
log('Reset address element when default address property is changed', 'info', {
|
|
265
|
+
defaultAddress: this.defaultAddress,
|
|
266
|
+
});
|
|
267
|
+
// Reset stripe address event data
|
|
268
|
+
if (this.type === 'shipping') {
|
|
269
|
+
stripeStore.stripeAddressEventData = null;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
stripeStore.stripeBillingAddressEventData = null;
|
|
273
|
+
}
|
|
274
|
+
this.initDefaultCustomAddressForm();
|
|
275
|
+
}
|
|
276
|
+
getIsComplete() {
|
|
277
|
+
const { city, firstName, lastName, line1, phone, postalCode, state } = this.getCustomAddressErrors();
|
|
278
|
+
// empty field when first loaded
|
|
279
|
+
if (!this.line1 ||
|
|
280
|
+
!this.postalCode ||
|
|
281
|
+
!this.firstName ||
|
|
282
|
+
!this.lastName ||
|
|
283
|
+
!this.phone) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
// has any errors from any of the fields
|
|
287
|
+
const hasErrors = line1 || postalCode || state || city || firstName || lastName || phone;
|
|
288
|
+
return !hasErrors;
|
|
289
|
+
}
|
|
290
|
+
renderCompanyNameInput() {
|
|
291
|
+
var _a;
|
|
292
|
+
// No need to render company name for billing address
|
|
293
|
+
if (this.type === 'billing') {
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
// No need to render company name if it's not enabled
|
|
297
|
+
if (!((_a = zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.companyNameInputEnabled)) {
|
|
298
|
+
// Clear the company name when it's not enabled
|
|
299
|
+
stripeStore.companyName = '';
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
return (h("zonos-stripe-input", { class: "zonos--company-name-input", inputLabel: translate('Company name (optional)'), inputValue: stripeStore.companyName, onInputChange: (event) => {
|
|
303
|
+
stripeStore.companyName = event.detail;
|
|
304
|
+
} }));
|
|
305
|
+
}
|
|
306
|
+
initCountryField(countryCode) {
|
|
307
|
+
var _a, _b, _c;
|
|
308
|
+
this.countryField =
|
|
309
|
+
((_a = zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.countryFields) && countryCode
|
|
310
|
+
? (_c = (_b = zonosStore.genericSettings) === null || _b === void 0 ? void 0 : _b.countryFields) === null || _c === void 0 ? void 0 : _c[countryCode]
|
|
311
|
+
: null;
|
|
312
|
+
}
|
|
313
|
+
initDefaultCustomAddressForm() {
|
|
314
|
+
log('initDefaultCustomAddressForm', 'info', this.type);
|
|
315
|
+
const stripeAddressEventData = this.getStripeAddressInstance().stripeAddressEventData;
|
|
316
|
+
// Use data from Stripe address element if it's available (This may happen when user has already at shipping selection page but go back to customer page)
|
|
317
|
+
if (stripeAddressEventData) {
|
|
318
|
+
const countryCode = stripeAddressEventData.value.address.country ||
|
|
319
|
+
localizationStore.selectedCountryCode ||
|
|
320
|
+
'US';
|
|
321
|
+
this.setFormValues({
|
|
322
|
+
city: stripeAddressEventData.value.address.city,
|
|
323
|
+
country: countryCode,
|
|
324
|
+
firstName: stripeAddressEventData.value.firstName || '',
|
|
325
|
+
lastName: stripeAddressEventData.value.lastName || '',
|
|
326
|
+
line1: stripeAddressEventData.value.address.line1,
|
|
327
|
+
line2: stripeAddressEventData.value.address.line2 || '',
|
|
328
|
+
phone: stripeAddressEventData.value.phone || '',
|
|
329
|
+
postal_code: stripeAddressEventData.value.address.postal_code,
|
|
330
|
+
state: stripeAddressEventData.value.address.state,
|
|
331
|
+
});
|
|
332
|
+
this.initCountryField(countryCode);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
// Use data from default address if it's available
|
|
336
|
+
const firstDefaultAddress = this.defaultAddress[0];
|
|
337
|
+
if (firstDefaultAddress) {
|
|
338
|
+
const countryCode = firstDefaultAddress.address.country ||
|
|
339
|
+
localizationStore.selectedCountryCode ||
|
|
340
|
+
'US';
|
|
341
|
+
this.setFormValues({
|
|
342
|
+
city: firstDefaultAddress.address.city,
|
|
343
|
+
country: countryCode,
|
|
344
|
+
firstName: firstDefaultAddress.name.split(' ')[0] || '',
|
|
345
|
+
lastName: firstDefaultAddress.name.split(' ')[1] || '',
|
|
346
|
+
line1: firstDefaultAddress.address.line1,
|
|
347
|
+
line2: firstDefaultAddress.address.line2 || '',
|
|
348
|
+
phone: firstDefaultAddress.phone || '',
|
|
349
|
+
postal_code: firstDefaultAddress.address.postal_code,
|
|
350
|
+
state: firstDefaultAddress.address.state,
|
|
351
|
+
});
|
|
352
|
+
this.initCountryField(countryCode);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
const countryCode = localizationStore.selectedCountryCode || 'US';
|
|
356
|
+
// Set default values
|
|
357
|
+
this.setFormValues({
|
|
358
|
+
city: '',
|
|
359
|
+
country: countryCode,
|
|
360
|
+
firstName: '',
|
|
361
|
+
lastName: '',
|
|
362
|
+
line1: '',
|
|
363
|
+
line2: '',
|
|
364
|
+
phone: '',
|
|
365
|
+
postal_code: '',
|
|
366
|
+
state: '',
|
|
367
|
+
});
|
|
368
|
+
this.initCountryField(countryCode);
|
|
369
|
+
// Set the first initialization to false when the address element is initialized
|
|
370
|
+
this.isFirstInitialization = false;
|
|
371
|
+
}
|
|
372
|
+
line1Changed() {
|
|
373
|
+
const stripeAddressEventData = this.getStripeAddressInstance().stripeAddressEventData;
|
|
374
|
+
const isAddressChanged = !stripeAddressEventData ||
|
|
375
|
+
this.line1 !== (stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address.line1);
|
|
376
|
+
// Start requesting google place suggestions when address line 1 is more than 3 characters
|
|
377
|
+
if (isAddressChanged && this.line1.length > 3) {
|
|
378
|
+
// Turn on the suggestion when the address line 1 is changed
|
|
379
|
+
this.startGooglePlaceSuggestions = true;
|
|
380
|
+
this.isAddressLine1Entered = true;
|
|
381
|
+
// Turn off the suggestion when the address suggestion is clicked, but next time the address line 1 is changed, the suggestion will be turned on again
|
|
382
|
+
if (this.suggestionClicked) {
|
|
383
|
+
this.suggestionClicked = false;
|
|
384
|
+
this.startGooglePlaceSuggestions = false;
|
|
385
|
+
}
|
|
386
|
+
if (!this.isDirtyAddress) {
|
|
387
|
+
this.isDirtyAddress = true;
|
|
388
|
+
// stripe element started with just address line 1, so scroll bar is not yet available. Wait for a moment before scrolling
|
|
389
|
+
setTimeout(() => {
|
|
390
|
+
if (!this.isAutoCompleteAdjusted) {
|
|
391
|
+
if (isCheckoutMobile()) {
|
|
392
|
+
this.el.scrollIntoView({ behavior: 'smooth', block: 'end' });
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
// scroll into the end of the page so the address placeholder won't be hidden
|
|
396
|
+
const yOffset = this.type === 'shipping' ? 100 : 600;
|
|
397
|
+
const parentWrapper = this.el.closest('.zonos--group');
|
|
398
|
+
const y = this.el.getBoundingClientRect().top + yOffset;
|
|
399
|
+
parentWrapper === null || parentWrapper === void 0 ? void 0 : parentWrapper.scrollTo({ behavior: 'smooth', top: y });
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}, 600);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
this.setCustomAddressFormToStripeAddressEventData();
|
|
406
|
+
// Start requesting google place suggestions when address line 1 is more than 3 characters (No need to request suggestions on first initialization if address is pre-filled)
|
|
407
|
+
if (this.startGooglePlaceSuggestions &&
|
|
408
|
+
zonosStore.checkoutAddressService &&
|
|
409
|
+
!this.isFirstInitialization) {
|
|
410
|
+
this.throttledGetAddressSuggestions();
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
formFieldsChanged() {
|
|
414
|
+
this.setCustomAddressFormToStripeAddressEventData();
|
|
415
|
+
}
|
|
416
|
+
addressSuggestionSelected({ placeDetails, }) {
|
|
417
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
418
|
+
// Set the trigger to true when the address suggestion is selected so we won't trigger the suggestion again
|
|
419
|
+
this.suggestionClicked = true;
|
|
420
|
+
this.startGooglePlaceSuggestions = false;
|
|
421
|
+
const addressInfo = placeDetails.addressComponents;
|
|
422
|
+
const addressLine1 = mergeAddress({
|
|
423
|
+
addresses: [
|
|
424
|
+
(_a = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.find(address => address.types.includes('street_number'))) === null || _a === void 0 ? void 0 : _a.longText,
|
|
425
|
+
(_b = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.find(address => address.types.includes('route'))) === null || _b === void 0 ? void 0 : _b.longText,
|
|
426
|
+
],
|
|
427
|
+
});
|
|
428
|
+
const subtituteAddressLine1 = mergeAddress({
|
|
429
|
+
addresses: [
|
|
430
|
+
(_c = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.find(address => address.types.includes('premise'))) === null || _c === void 0 ? void 0 : _c.longText,
|
|
431
|
+
((_d = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.find(address => address.types.includes('sublocality_level_2'))) === null || _d === void 0 ? void 0 : _d.longText) ||
|
|
432
|
+
((_e = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.find(address => address.types.includes('sublocality_level_3'))) === null || _e === void 0 ? void 0 : _e.longText) ||
|
|
433
|
+
((_f = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.find(address => address.types.includes('sublocality_level_4'))) === null || _f === void 0 ? void 0 : _f.longText) ||
|
|
434
|
+
((_g = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.find(address => address.types.includes('sublocality_level_5'))) === null || _g === void 0 ? void 0 : _g.longText),
|
|
435
|
+
],
|
|
436
|
+
});
|
|
437
|
+
const addressLine2 = mergeAddress({
|
|
438
|
+
addresses: [
|
|
439
|
+
(_h = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.find(address => address.types.includes('subpremise'))) === null || _h === void 0 ? void 0 : _h.longText,
|
|
440
|
+
(_j = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.find(address => address.types.includes('neighborhood'))) === null || _j === void 0 ? void 0 : _j.longText,
|
|
441
|
+
],
|
|
442
|
+
delimiter: ', ',
|
|
443
|
+
});
|
|
444
|
+
const city = mergeAddress({
|
|
445
|
+
addresses: [
|
|
446
|
+
((_k = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.find(address => address.types.includes('locality'))) === null || _k === void 0 ? void 0 : _k.longText) ||
|
|
447
|
+
((_l = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.find(address => address.types.includes('sublocality_level_1'))) === null || _l === void 0 ? void 0 : _l.longText) ||
|
|
448
|
+
((_m = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.find(address => address.types.includes('administrative_area_level_1'))) === null || _m === void 0 ? void 0 : _m.longText),
|
|
449
|
+
],
|
|
450
|
+
});
|
|
451
|
+
const state = mergeAddress({
|
|
452
|
+
addresses: [
|
|
453
|
+
(_o = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.find(address => address.types.includes('administrative_area_level_1'))) === null || _o === void 0 ? void 0 : _o.shortText,
|
|
454
|
+
],
|
|
455
|
+
});
|
|
456
|
+
const postalCode = mergeAddress({
|
|
457
|
+
addresses: [
|
|
458
|
+
(_p = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.find(address => address.types.includes('postal_code'))) === null || _p === void 0 ? void 0 : _p.longText,
|
|
459
|
+
],
|
|
460
|
+
});
|
|
461
|
+
const country = mergeAddress({
|
|
462
|
+
addresses: [
|
|
463
|
+
(_q = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.find(address => address.types.includes('country'))) === null || _q === void 0 ? void 0 : _q.shortText,
|
|
464
|
+
],
|
|
465
|
+
});
|
|
466
|
+
this.setFormValues({
|
|
467
|
+
city: city,
|
|
468
|
+
country: country,
|
|
469
|
+
line1: addressLine1 || subtituteAddressLine1,
|
|
470
|
+
line2: addressLine2,
|
|
471
|
+
postal_code: postalCode,
|
|
472
|
+
state: state,
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
setFormValues(values) {
|
|
476
|
+
if (values.city !== undefined)
|
|
477
|
+
this.city = values.city;
|
|
478
|
+
if (values.country !== undefined)
|
|
479
|
+
this.country = values.country;
|
|
480
|
+
if (values.firstName !== undefined)
|
|
481
|
+
this.firstName = values.firstName;
|
|
482
|
+
if (values.lastName !== undefined)
|
|
483
|
+
this.lastName = values.lastName;
|
|
484
|
+
if (values.line1 !== undefined)
|
|
485
|
+
this.line1 = values.line1;
|
|
486
|
+
if (values.line2 !== undefined)
|
|
487
|
+
this.line2 = values.line2;
|
|
488
|
+
if (values.phone !== undefined)
|
|
489
|
+
this.phone = values.phone;
|
|
490
|
+
if (values.postal_code !== undefined)
|
|
491
|
+
this.postalCode = values.postal_code;
|
|
492
|
+
if (values.state !== undefined)
|
|
493
|
+
this.state = values.state;
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Initialize the address suggestions
|
|
497
|
+
*/
|
|
498
|
+
initAddressSuggestions() {
|
|
499
|
+
// Only initialize the address suggestions if the address service is not already initialized
|
|
500
|
+
if (!zonosStore.checkoutAddressService ||
|
|
501
|
+
(!!this.onAddressSuggestionsUnsubscribe &&
|
|
502
|
+
!!this.onAddressSelectedUnsubscribe)) {
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
log('on initAddressSuggestions', 'info');
|
|
506
|
+
this.onAddressSuggestionsUnsubscribe =
|
|
507
|
+
zonosStore.checkoutAddressService.onAddressSuggestions(({ suggestions, type }) => {
|
|
508
|
+
// Only update the address suggestions if the type matches the current type
|
|
509
|
+
if (type !== this.type) {
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
this.addressSuggestions = suggestions;
|
|
513
|
+
});
|
|
514
|
+
this.onAddressSelectedUnsubscribe =
|
|
515
|
+
zonosStore.checkoutAddressService.onAddressSelected(data => {
|
|
516
|
+
if (data.type !== this.type) {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
this.addressSuggestions = [];
|
|
520
|
+
this.addressSuggestionSelected(data);
|
|
521
|
+
});
|
|
522
|
+
this.validate({
|
|
523
|
+
type: this.type,
|
|
524
|
+
value: this.firstName,
|
|
525
|
+
valueType: 'firstName',
|
|
526
|
+
});
|
|
527
|
+
this.validate({
|
|
528
|
+
type: this.type,
|
|
529
|
+
value: this.lastName,
|
|
530
|
+
valueType: 'lastName',
|
|
531
|
+
});
|
|
532
|
+
this.validate({
|
|
533
|
+
type: this.type,
|
|
534
|
+
value: this.line1,
|
|
535
|
+
valueType: 'line1',
|
|
536
|
+
});
|
|
537
|
+
this.validate({
|
|
538
|
+
type: this.type,
|
|
539
|
+
value: this.phone,
|
|
540
|
+
valueType: 'phone',
|
|
541
|
+
});
|
|
542
|
+
this.validate({
|
|
543
|
+
type: this.type,
|
|
544
|
+
value: this.postalCode,
|
|
545
|
+
valueType: 'postalCode',
|
|
546
|
+
});
|
|
547
|
+
this.validate({
|
|
548
|
+
type: this.type,
|
|
549
|
+
value: this.state,
|
|
550
|
+
valueType: 'state',
|
|
551
|
+
});
|
|
552
|
+
this.validate({
|
|
553
|
+
type: this.type,
|
|
554
|
+
value: this.city,
|
|
555
|
+
valueType: 'city',
|
|
556
|
+
});
|
|
557
|
+
this.validate({
|
|
558
|
+
type: this.type,
|
|
559
|
+
value: this.phone,
|
|
560
|
+
valueType: 'phone',
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
shouldEnabledCustomAddressChanged() {
|
|
564
|
+
// Only initialize the address suggestions if the address service is not already initialized
|
|
565
|
+
this.initAddressSuggestions();
|
|
566
|
+
this.initDefaultCustomAddressForm();
|
|
567
|
+
}
|
|
568
|
+
shippingZonesChanged() {
|
|
569
|
+
this.shippingZones = localizationStore.shippingZoneCountries;
|
|
570
|
+
this.shipToCountries = Object.values(this.shippingZones || {})
|
|
571
|
+
.map(country => ({
|
|
572
|
+
label: country.displayName,
|
|
573
|
+
value: country.code,
|
|
574
|
+
}))
|
|
575
|
+
.sort((a, b) => {
|
|
576
|
+
return a.label.localeCompare(b.label);
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
renderCustomAddressForm() {
|
|
580
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
581
|
+
const _w = this.getCustomAddressErrors(), { showError } = _w, customAddressErrors = __rest(_w, ["showError"]);
|
|
582
|
+
const stripeAddressEventData = this.getStripeAddressInstance().stripeAddressEventData;
|
|
583
|
+
const countryCode = stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address.country;
|
|
584
|
+
this.countryField =
|
|
585
|
+
((_a = zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.countryFields) && countryCode
|
|
586
|
+
? (_c = (_b = zonosStore.genericSettings) === null || _b === void 0 ? void 0 : _b.countryFields) === null || _c === void 0 ? void 0 : _c[countryCode]
|
|
587
|
+
: null;
|
|
588
|
+
const firstCountry = (_d = this.shipToCountries) === null || _d === void 0 ? void 0 : _d[0];
|
|
589
|
+
const stateOptions = Object.entries(((_e = this.countryField) === null || _e === void 0 ? void 0 : _e.regions) || {})
|
|
590
|
+
.map(([label, region]) => ({
|
|
591
|
+
label,
|
|
592
|
+
value: region.interpayCode,
|
|
593
|
+
}))
|
|
594
|
+
.sort((a, b) => a.label.localeCompare(b.label));
|
|
595
|
+
return (h("div", { "aria-label": `${this.type} address form`, class: "zonos--custom-address-form", role: "form" }, h("zonos-stripe-input", { "aria-required": "true", class: "zonos--custom-address-form-input", error: showError ? customAddressErrors.firstName : undefined, inputLabel: translate('First name'), inputValue: stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.firstName, onInputChange: (event) => {
|
|
596
|
+
this.validate({
|
|
597
|
+
type: this.type,
|
|
598
|
+
value: event.detail,
|
|
599
|
+
valueType: 'firstName',
|
|
600
|
+
});
|
|
601
|
+
/**
|
|
602
|
+
* Order of operations is important here:
|
|
603
|
+
* 1. validate() updates all input error states
|
|
604
|
+
* 2. Setting postalCode triggers @Watch('postalCode')
|
|
605
|
+
* 3. getIsComplete() checks customAddressErrors state
|
|
606
|
+
* Therefore, we must update the value after validation to ensure correct error state
|
|
607
|
+
*/
|
|
608
|
+
this.firstName = event.detail;
|
|
609
|
+
}, required: true }), h("zonos-stripe-input", { "aria-required": "true", class: "zonos--custom-address-form-input", error: showError ? customAddressErrors.lastName : undefined, inputLabel: translate('Last name'), inputValue: stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.lastName, onInputChange: (event) => {
|
|
610
|
+
this.validate({
|
|
611
|
+
type: this.type,
|
|
612
|
+
value: event.detail,
|
|
613
|
+
valueType: 'lastName',
|
|
614
|
+
});
|
|
615
|
+
/**
|
|
616
|
+
* Order of operations is important here:
|
|
617
|
+
* 1. validate() updates all input error states
|
|
618
|
+
* 2. Setting postalCode triggers @Watch('postalCode')
|
|
619
|
+
* 3. getIsComplete() checks customAddressErrors state
|
|
620
|
+
* Therefore, we must update the value after validation to ensure correct error state
|
|
621
|
+
*/
|
|
622
|
+
this.lastName = event.detail;
|
|
623
|
+
}, required: true }), h("zonos-stripe-select", { "aria-required": "true", autoComplete: "shipping country", class: "zonos--custom-address-form-input", name: `${this.type}-country`, onSelectChange: (event) => {
|
|
624
|
+
this.country = event.detail;
|
|
625
|
+
this.city = '';
|
|
626
|
+
this.state = '';
|
|
627
|
+
this.postalCode = '';
|
|
628
|
+
}, options: this.shipToCountries || [], required: true, selectLabel: translate('Country'), selectedValue: (stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address.country) ||
|
|
629
|
+
localizationStore.selectedCountryCode ||
|
|
630
|
+
(firstCountry === null || firstCountry === void 0 ? void 0 : firstCountry.value), title: `${this.type} country` }), h("div", { class: "zonos--custom-address-form-line1-wrapper" }, h("zonos-stripe-input", { "aria-autocomplete": "list", "aria-controls": "autocomplete-search", "aria-required": "true", autoComplete: "shipping address-line1", class: "zonos--custom-address-form-input", error: showError ? customAddressErrors.line1 : undefined, inputLabel: translate('Address line 1'), inputValue: stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address.line1, name: "address-line1", onInputChange: (event) => {
|
|
631
|
+
this.validate({
|
|
632
|
+
type: this.type,
|
|
633
|
+
value: event.detail,
|
|
634
|
+
valueType: 'line1',
|
|
635
|
+
});
|
|
636
|
+
/**
|
|
637
|
+
* Order of operations is important here:
|
|
638
|
+
* 1. validate() updates all input error states
|
|
639
|
+
* 2. Setting postalCode triggers @Watch('postalCode')
|
|
640
|
+
* 3. getIsComplete() checks customAddressErrors state
|
|
641
|
+
* Therefore, we must update the value after validation to ensure correct error state
|
|
642
|
+
*/
|
|
643
|
+
this.line1 = event.detail;
|
|
644
|
+
}, onKeyDown: event => {
|
|
645
|
+
// Clear the address suggestions when the user presses the escape key
|
|
646
|
+
if (event.key === 'Escape') {
|
|
647
|
+
event.preventDefault();
|
|
648
|
+
event.stopPropagation();
|
|
649
|
+
this.addressSuggestions = [];
|
|
650
|
+
}
|
|
651
|
+
}, required: true }), h("zonos-address-suggestions", { onSuggestionSelected: e => {
|
|
652
|
+
var _a;
|
|
653
|
+
const { placeId } = e.detail;
|
|
654
|
+
(_a = zonosStore.checkoutAddressService) === null || _a === void 0 ? void 0 : _a.selectAddress({
|
|
655
|
+
placeId,
|
|
656
|
+
type: this.type,
|
|
657
|
+
});
|
|
658
|
+
}, suggestions: this.addressSuggestions, type: this.type })), h("div", { "aria-label": "Additional address details", class: classes([
|
|
659
|
+
'zonos--custom-address-form-additional-fields',
|
|
660
|
+
countryCode && this.isAddressLine1Entered ? 'show' : '',
|
|
661
|
+
]), role: "group" }, h("zonos-stripe-input", { "aria-required": "false", autoComplete: "shipping address-line2", class: "zonos--custom-address-form-input", inputLabel: translate(((_f = this.countryField) === null || _f === void 0 ? void 0 : _f.address2Label) || 'Address line 2'), inputValue: (stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address.line2) || '', onInputChange: (event) => {
|
|
662
|
+
this.line2 = event.detail;
|
|
663
|
+
} }), ((_g = this.countryField) === null || _g === void 0 ? void 0 : _g.cityShow) && (h("zonos-stripe-input", { "aria-required": ((_h = this.countryField) === null || _h === void 0 ? void 0 : _h.cityRequired) ? 'true' : 'false', autoComplete: "shipping address-level2", class: "zonos--custom-address-form-input", error: showError ? customAddressErrors.city : undefined, inputLabel: translate(((_j = this.countryField) === null || _j === void 0 ? void 0 : _j.cityLabel) || 'City'), inputValue: (stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address.city) || '', name: "locality", onInputChange: (event) => {
|
|
664
|
+
this.validate({
|
|
665
|
+
type: this.type,
|
|
666
|
+
value: event.detail,
|
|
667
|
+
valueType: 'city',
|
|
668
|
+
});
|
|
669
|
+
/**
|
|
670
|
+
* Order of operations is important here:
|
|
671
|
+
* 1. validate() updates all input error states
|
|
672
|
+
* 2. Setting postalCode triggers @Watch('postalCode')
|
|
673
|
+
* 3. getIsComplete() checks customAddressErrors state
|
|
674
|
+
* Therefore, we must update the value after validation to ensure correct error state
|
|
675
|
+
*/
|
|
676
|
+
this.city = event.detail;
|
|
677
|
+
}, required: (_k = this.countryField) === null || _k === void 0 ? void 0 : _k.cityRequired })), h("div", { class: "zonos--custom-address-form-state-zip-wrapper" }, ((_l = this.countryField) === null || _l === void 0 ? void 0 : _l.stateShow) && (h("zonos-stripe-select", { "aria-required": ((_m = this.countryField) === null || _m === void 0 ? void 0 : _m.stateRequired) ? 'true' : 'false', autoComplete: "shipping address-level1", class: "zonos--custom-address-form-input", error: showError ? customAddressErrors.state : undefined, isError: showError && !!customAddressErrors.state, name: `${this.type}-state`, onSelectChange: (event) => {
|
|
678
|
+
this.validate({
|
|
679
|
+
type: this.type,
|
|
680
|
+
value: event.detail,
|
|
681
|
+
valueType: 'state',
|
|
682
|
+
});
|
|
683
|
+
/**
|
|
684
|
+
* Order of operations is important here:
|
|
685
|
+
* 1. validate() updates all input error states
|
|
686
|
+
* 2. Setting postalCode triggers @Watch('postalCode')
|
|
687
|
+
* 3. getIsComplete() checks customAddressErrors state
|
|
688
|
+
* Therefore, we must update the value after validation to ensure correct error state
|
|
689
|
+
*/
|
|
690
|
+
this.state = event.detail;
|
|
691
|
+
}, options: stateOptions, required: (_o = this.countryField) === null || _o === void 0 ? void 0 : _o.stateRequired, selectLabel: translate(((_p = this.countryField) === null || _p === void 0 ? void 0 : _p.stateLabel) || 'State'), selectedValue: stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address.state, title: `${this.type} state` })), ((_q = this.countryField) === null || _q === void 0 ? void 0 : _q.zipShow) && (h("zonos-stripe-input", { "aria-describedby": ((_r = this.countryField) === null || _r === void 0 ? void 0 : _r.zipFormat)
|
|
692
|
+
? `zip-format-${this.type}`
|
|
693
|
+
: undefined, "aria-required": ((_s = this.countryField) === null || _s === void 0 ? void 0 : _s.zipRequired) ? 'true' : 'false', autoComplete: "shipping postal-code", class: "zonos--custom-address-form-input", error: showError ? customAddressErrors.postalCode : undefined, inputLabel: translate(((_t = this.countryField) === null || _t === void 0 ? void 0 : _t.zipLabel) || 'Zip'), inputValue: (stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address.postal_code) || '', onInputChange: (event) => {
|
|
694
|
+
this.validate({
|
|
695
|
+
type: this.type,
|
|
696
|
+
value: event.detail,
|
|
697
|
+
valueType: 'postalCode',
|
|
698
|
+
});
|
|
699
|
+
/**
|
|
700
|
+
* Order of operations is important here:
|
|
701
|
+
* 1. validate() updates all input error states
|
|
702
|
+
* 2. Setting postalCode triggers @Watch('postalCode')
|
|
703
|
+
* 3. getIsComplete() checks customAddressErrors state
|
|
704
|
+
* Therefore, we must update the value after validation to ensure correct error state
|
|
705
|
+
*/
|
|
706
|
+
this.postalCode = event.detail;
|
|
707
|
+
}, required: (_u = this.countryField) === null || _u === void 0 ? void 0 : _u.zipRequired }))), h("zonos-stripe-phone-input", { autoComplete: "shipping tel", class: "zonos--custom-address-form-input", countryCode: stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address.country, countryOptions: (_v = zonosStore.genericSettings) === null || _v === void 0 ? void 0 : _v.countryFields, error: showError ? customAddressErrors.phone : undefined, inputLabel: translate('Phone number'), inputValue: (stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.phone) || '', onInputValueChange: event => {
|
|
708
|
+
const { isEmpty, phoneNumber, valid, wrongFormat } = event.detail;
|
|
709
|
+
// Validate the phone number
|
|
710
|
+
this.validate({
|
|
711
|
+
phoneValidateInfo: {
|
|
712
|
+
isEmpty,
|
|
713
|
+
isValid: valid,
|
|
714
|
+
wrongFormat,
|
|
715
|
+
},
|
|
716
|
+
type: this.type,
|
|
717
|
+
value: phoneNumber,
|
|
718
|
+
valueType: 'phone',
|
|
719
|
+
});
|
|
720
|
+
/**
|
|
721
|
+
* Order of operations is important here:
|
|
722
|
+
* 1. validate() updates all input error states
|
|
723
|
+
* 2. Setting postalCode triggers @Watch('postalCode')
|
|
724
|
+
* 3. getIsComplete() checks customAddressErrors state
|
|
725
|
+
* Therefore, we must update the value after validation to ensure correct error state
|
|
726
|
+
*/
|
|
727
|
+
this.phone = phoneNumber;
|
|
728
|
+
} }))));
|
|
729
|
+
}
|
|
730
|
+
disconnectedCallback() {
|
|
731
|
+
var _a, _b;
|
|
732
|
+
// destroy the stripe element when this component is removed from the DOM, so that we can re-create the new one with previous value
|
|
733
|
+
const stripeElement = this.getStripeAddressInstance().stripeAddressElement;
|
|
734
|
+
stripeElement === null || stripeElement === void 0 ? void 0 : stripeElement.destroy();
|
|
735
|
+
// unsubscribe from address suggestions when this component is removed from the DOM
|
|
736
|
+
(_a = this.onAddressSuggestionsUnsubscribe) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
737
|
+
(_b = this.onAddressSelectedUnsubscribe) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
738
|
+
}
|
|
739
|
+
componentWillLoad() {
|
|
740
|
+
if (zonosStore.checkoutAddressService) {
|
|
741
|
+
this.initDefaultCustomAddressForm();
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
componentDidLoad() {
|
|
745
|
+
const stripeAddressEventData = this.getStripeAddressInstance().stripeAddressEventData;
|
|
746
|
+
this.shipToCountries = Object.values(localizationStore.shippingZoneCountries || {})
|
|
747
|
+
.map(country => ({
|
|
748
|
+
label: country.displayName,
|
|
749
|
+
value: country.code,
|
|
750
|
+
}))
|
|
751
|
+
.sort((a, b) => {
|
|
752
|
+
return a.label.localeCompare(b.label);
|
|
753
|
+
});
|
|
754
|
+
this.isDirtyAddress =
|
|
755
|
+
!!stripeAddressEventData &&
|
|
756
|
+
stripeAddressEventData.value.address.line1.length > 0;
|
|
757
|
+
// @Watch doesn't get trigger on initial load
|
|
758
|
+
this.initAddressSuggestions();
|
|
759
|
+
this.isFirstInitialization = false;
|
|
760
|
+
}
|
|
761
|
+
render() {
|
|
762
|
+
var _a;
|
|
763
|
+
this.shippingZones = localizationStore.shippingZoneCountries;
|
|
764
|
+
this.addressService = zonosStore.checkoutAddressService;
|
|
765
|
+
this.checkoutSessionId = cartStore.checkoutSessionId;
|
|
766
|
+
if ((_a = stripeStore.stripeAddressEventData) === null || _a === void 0 ? void 0 : _a.complete) {
|
|
767
|
+
this.isAddressFilled = true;
|
|
768
|
+
}
|
|
769
|
+
// Only set country if custom address form is enabled
|
|
770
|
+
if (!this.country && localizationStore.selectedCountryCode) {
|
|
771
|
+
this.country = localizationStore.selectedCountryCode;
|
|
772
|
+
}
|
|
773
|
+
// this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
|
|
774
|
+
return (h(Host, { key: '9460547ea10813bdd211ed19c01ece0a8ec07a41', class: classes([
|
|
775
|
+
'zonos--address zonos--elements',
|
|
776
|
+
`zonos--${this.type}-address`,
|
|
777
|
+
]) }, h("zonos-text", { key: '700b00ddfd9eb1ec55370c9a3d7e69dcb6bc9668', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), this.renderCompanyNameInput(), this.renderCustomAddressForm()));
|
|
778
|
+
}
|
|
779
|
+
static get is() { return "zonos-custom-address"; }
|
|
780
|
+
static get encapsulation() { return "scoped"; }
|
|
781
|
+
static get originalStyleUrls() {
|
|
782
|
+
return {
|
|
783
|
+
"$": ["zonos-custom-address.scss"]
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
static get styleUrls() {
|
|
787
|
+
return {
|
|
788
|
+
"$": ["zonos-custom-address.css"]
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
static get properties() {
|
|
792
|
+
return {
|
|
793
|
+
"type": {
|
|
794
|
+
"type": "string",
|
|
795
|
+
"mutable": false,
|
|
796
|
+
"complexType": {
|
|
797
|
+
"original": "'billing' | 'shipping'",
|
|
798
|
+
"resolved": "\"billing\" | \"shipping\"",
|
|
799
|
+
"references": {}
|
|
800
|
+
},
|
|
801
|
+
"required": true,
|
|
802
|
+
"optional": false,
|
|
803
|
+
"docs": {
|
|
804
|
+
"tags": [],
|
|
805
|
+
"text": "The type of address element to render"
|
|
806
|
+
},
|
|
807
|
+
"getter": false,
|
|
808
|
+
"setter": false,
|
|
809
|
+
"attribute": "type",
|
|
810
|
+
"reflect": false
|
|
811
|
+
},
|
|
812
|
+
"titleText": {
|
|
813
|
+
"type": "string",
|
|
814
|
+
"mutable": false,
|
|
815
|
+
"complexType": {
|
|
816
|
+
"original": "string",
|
|
817
|
+
"resolved": "string",
|
|
818
|
+
"references": {}
|
|
819
|
+
},
|
|
820
|
+
"required": true,
|
|
821
|
+
"optional": false,
|
|
822
|
+
"docs": {
|
|
823
|
+
"tags": [],
|
|
824
|
+
"text": "The title text for the address element"
|
|
825
|
+
},
|
|
826
|
+
"getter": false,
|
|
827
|
+
"setter": false,
|
|
828
|
+
"attribute": "title-text",
|
|
829
|
+
"reflect": false
|
|
830
|
+
},
|
|
831
|
+
"defaultAddress": {
|
|
832
|
+
"type": "unknown",
|
|
833
|
+
"mutable": false,
|
|
834
|
+
"complexType": {
|
|
835
|
+
"original": "ContactOption[]",
|
|
836
|
+
"resolved": "ContactOption[]",
|
|
837
|
+
"references": {
|
|
838
|
+
"ContactOption": {
|
|
839
|
+
"location": "import",
|
|
840
|
+
"path": "@stripe/stripe-js",
|
|
841
|
+
"id": "node_modules::ContactOption"
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
},
|
|
845
|
+
"required": false,
|
|
846
|
+
"optional": false,
|
|
847
|
+
"docs": {
|
|
848
|
+
"tags": [],
|
|
849
|
+
"text": "Default address for stripe"
|
|
850
|
+
},
|
|
851
|
+
"getter": false,
|
|
852
|
+
"setter": false,
|
|
853
|
+
"defaultValue": "[]"
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
static get states() {
|
|
858
|
+
return {
|
|
859
|
+
"stripe": {},
|
|
860
|
+
"isDirtyAddress": {},
|
|
861
|
+
"isAddressFilled": {},
|
|
862
|
+
"isAddressLine1Entered": {},
|
|
863
|
+
"addressSuggestions": {},
|
|
864
|
+
"countryField": {},
|
|
865
|
+
"startGooglePlaceSuggestions": {},
|
|
866
|
+
"shipToCountries": {},
|
|
867
|
+
"shippingZones": {},
|
|
868
|
+
"city": {},
|
|
869
|
+
"country": {},
|
|
870
|
+
"firstName": {},
|
|
871
|
+
"lastName": {},
|
|
872
|
+
"line1": {},
|
|
873
|
+
"line2": {},
|
|
874
|
+
"phone": {},
|
|
875
|
+
"postalCode": {},
|
|
876
|
+
"state": {},
|
|
877
|
+
"cityError": {},
|
|
878
|
+
"stateError": {},
|
|
879
|
+
"postalCodeError": {},
|
|
880
|
+
"phoneError": {},
|
|
881
|
+
"firstNameError": {},
|
|
882
|
+
"lastNameError": {},
|
|
883
|
+
"isFirstInitialization": {},
|
|
884
|
+
"addressService": {},
|
|
885
|
+
"checkoutSessionId": {}
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
static get events() {
|
|
889
|
+
return [{
|
|
890
|
+
"method": "invalidCharacters",
|
|
891
|
+
"name": "invalidCharacters",
|
|
892
|
+
"bubbles": true,
|
|
893
|
+
"cancelable": true,
|
|
894
|
+
"composed": true,
|
|
895
|
+
"docs": {
|
|
896
|
+
"tags": [],
|
|
897
|
+
"text": "Event to emit when address is not containing allowed character sets"
|
|
898
|
+
},
|
|
899
|
+
"complexType": {
|
|
900
|
+
"original": "boolean",
|
|
901
|
+
"resolved": "boolean",
|
|
902
|
+
"references": {}
|
|
903
|
+
}
|
|
904
|
+
}, {
|
|
905
|
+
"method": "addressChange",
|
|
906
|
+
"name": "addressChange",
|
|
907
|
+
"bubbles": true,
|
|
908
|
+
"cancelable": true,
|
|
909
|
+
"composed": true,
|
|
910
|
+
"docs": {
|
|
911
|
+
"tags": [],
|
|
912
|
+
"text": "Event to emit when address is changed"
|
|
913
|
+
},
|
|
914
|
+
"complexType": {
|
|
915
|
+
"original": "{\n errors: CustomAddressErrors;\n type: 'billing' | 'shipping';\n value: StripeAddressElementChangeEvent;\n }",
|
|
916
|
+
"resolved": "{ errors: CustomAddressErrors; type: \"billing\" | \"shipping\"; value: StripeAddressElementChangeEvent; }",
|
|
917
|
+
"references": {
|
|
918
|
+
"CustomAddressErrors": {
|
|
919
|
+
"location": "import",
|
|
920
|
+
"path": "src/types/checkout/form/CustomAddressErrors",
|
|
921
|
+
"id": "src/types/checkout/form/CustomAddressErrors.ts::CustomAddressErrors"
|
|
922
|
+
},
|
|
923
|
+
"StripeAddressElementChangeEvent": {
|
|
924
|
+
"location": "import",
|
|
925
|
+
"path": "@stripe/stripe-js",
|
|
926
|
+
"id": "node_modules::StripeAddressElementChangeEvent"
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}];
|
|
931
|
+
}
|
|
932
|
+
static get elementRef() { return "el"; }
|
|
933
|
+
static get watchers() {
|
|
934
|
+
return [{
|
|
935
|
+
"propName": "checkoutSessionId",
|
|
936
|
+
"methodName": "isAddressFilledChanged"
|
|
937
|
+
}, {
|
|
938
|
+
"propName": "isAddressFilled",
|
|
939
|
+
"methodName": "isAddressFilledChanged"
|
|
940
|
+
}, {
|
|
941
|
+
"propName": "defaultAddress",
|
|
942
|
+
"methodName": "defaultAddressChanged"
|
|
943
|
+
}, {
|
|
944
|
+
"propName": "line1",
|
|
945
|
+
"methodName": "line1Changed"
|
|
946
|
+
}, {
|
|
947
|
+
"propName": "city",
|
|
948
|
+
"methodName": "formFieldsChanged"
|
|
949
|
+
}, {
|
|
950
|
+
"propName": "country",
|
|
951
|
+
"methodName": "formFieldsChanged"
|
|
952
|
+
}, {
|
|
953
|
+
"propName": "firstName",
|
|
954
|
+
"methodName": "formFieldsChanged"
|
|
955
|
+
}, {
|
|
956
|
+
"propName": "lastName",
|
|
957
|
+
"methodName": "formFieldsChanged"
|
|
958
|
+
}, {
|
|
959
|
+
"propName": "line2",
|
|
960
|
+
"methodName": "formFieldsChanged"
|
|
961
|
+
}, {
|
|
962
|
+
"propName": "phone",
|
|
963
|
+
"methodName": "formFieldsChanged"
|
|
964
|
+
}, {
|
|
965
|
+
"propName": "postalCode",
|
|
966
|
+
"methodName": "formFieldsChanged"
|
|
967
|
+
}, {
|
|
968
|
+
"propName": "state",
|
|
969
|
+
"methodName": "formFieldsChanged"
|
|
970
|
+
}, {
|
|
971
|
+
"propName": "addressService",
|
|
972
|
+
"methodName": "shouldEnabledCustomAddressChanged"
|
|
973
|
+
}, {
|
|
974
|
+
"propName": "shippingZones",
|
|
975
|
+
"methodName": "shippingZonesChanged"
|
|
976
|
+
}];
|
|
977
|
+
}
|
|
978
|
+
}
|