@zonos/elements 1.3.6 → 1.3.7-alpha.1
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/{localization-2c9f5765.js → cart-89d9fff4.js} +863 -89
- package/dist/cjs/formatStringWithLinks-52341fc7.js +17 -0
- package/dist/cjs/{getBorderRadius-b252096d.js → getBorderRadius-d8f18958.js} +1 -1
- package/dist/cjs/{isDarkColor-168002d6.js → isDarkColor-57860b44.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/submitGtag-24740560.js +55 -0
- package/dist/cjs/zonos-address_4.cjs.entry.js +36 -18
- package/dist/cjs/zonos-badge_2.cjs.entry.js +6 -6
- package/dist/cjs/zonos-banner.cjs.entry.js +1 -1
- package/dist/cjs/zonos-button_3.cjs.entry.js +8 -8
- package/dist/cjs/zonos-card_2.cjs.entry.js +10 -8
- package/dist/cjs/zonos-cart-items_9.cjs.entry.js +66 -56
- package/dist/cjs/zonos-checkout.cjs.entry.js +170 -34
- package/dist/cjs/zonos-component.cjs.entry.js +1 -1
- package/dist/cjs/zonos-controller.cjs.entry.js +51 -32
- package/dist/cjs/zonos-country-flag.cjs.entry.js +5 -3
- package/dist/cjs/zonos-country-select_3.cjs.entry.js +21 -12
- package/dist/cjs/zonos-elements.cjs.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +23 -19
- package/dist/cjs/zonos-hello.cjs.entry.js +51 -34
- package/dist/cjs/zonos-link.cjs.entry.js +24 -0
- package/dist/cjs/zonos-logo.cjs.entry.js +3 -3
- package/dist/cjs/zonos-notification.cjs.entry.js +1 -1
- package/dist/cjs/zonos-payment.cjs.entry.js +5 -6
- package/dist/cjs/zonos-select-dialog-header_2.cjs.entry.js +5 -5
- package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +3 -3
- package/dist/cjs/zonos-text.cjs.entry.js +1 -1
- package/dist/cjs/{zonosStore-5d94dabb.js → zonosStore-138c5555.js} +9 -7
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-cart-subtotal/zonos-cart-subtotal.js +1 -6
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +27 -13
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-payment/zonos-checkout-payment.css +3 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +39 -18
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.css +5 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +2 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-review/zonos-review.js +1 -6
- package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.css +3 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +5 -0
- package/dist/collection/components/common/component-template/zonos-link/zonos-link.css +54 -0
- package/dist/collection/components/common/component-template/zonos-link/zonos-link.js +97 -0
- package/dist/collection/components/common/zonos-badge/zonos-badge.js +3 -3
- package/dist/collection/components/common/zonos-button/zonos-button.css +2 -0
- package/dist/collection/components/common/zonos-button/zonos-button.js +4 -4
- package/dist/collection/components/common/zonos-card/zonos-card.js +2 -2
- package/dist/collection/components/common/zonos-checkbox/zonos-checkbox.js +3 -3
- package/dist/collection/components/common/zonos-collapse/zonos-collapse.js +26 -6
- package/dist/collection/components/common/zonos-country-select/zonos-country-select.js +8 -2
- package/dist/collection/components/common/zonos-custom-message/zonos-custom-message.js +4 -2
- package/dist/collection/components/common/zonos-dialog/zonos-dialog.js +3 -3
- package/dist/collection/components/common/zonos-language-select/zonos-language-select.js +2 -2
- package/dist/collection/components/common/zonos-logo/zonos-logo.js +2 -2
- package/dist/collection/components/common/zonos-select-dialog-header/zonos-select-dialog-header.js +2 -2
- package/dist/collection/components/common/zonos-shipping-rich-radio/zonos-shipping-rich-radio.js +1 -1
- 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/component-template/zonos-component/zonos-component.js +1 -1
- package/dist/collection/components/hello/zonos-hello/zonos-hello.js +50 -11
- 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 +5 -3
- package/dist/collection/components/main/zonos-controller.js +1 -1
- package/dist/collection/components/store/checkout/cart.js +2 -2
- package/dist/collection/components/store/checkout/stripe.js +29 -4
- package/dist/collection/components/store/hello/localization.js +34 -7
- package/dist/collection/components/store/zonosStore.js +9 -7
- package/dist/collection/components/stripe/zonos-address/zonos-address.js +1 -1
- 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/trackConversionEvent.js +22 -0
- package/dist/collection/components/utils/checkout/isShippableCountry.js +15 -0
- package/dist/collection/components/utils/checkout/watchBigcommerceDomesticCheckout.js +111 -0
- package/dist/collection/components/utils/formatStringWithLinks.js +13 -0
- package/dist/collection/components/utils/handleFetch.js +1 -1
- package/dist/collection/components/utils/hello/currencyConversion/defaultCurrencyConverter.js +25 -28
- package/dist/collection/components/utils/hello/currencyConversion/getCurrencyElements.js +2 -1
- package/dist/collection/components/utils/hello/currencyConversion/getInitialElementAmount.js +8 -6
- package/dist/collection/components/utils/hello/initHello.js +23 -3
- package/dist/collection/components/utils/logging/log.js +20 -9
- package/dist/collection/components/utils/logging/logError.js +2 -1
- package/dist/collection/components/utils/logging/sendErrorLog.js +12 -0
- package/dist/collection/scripts/checkIfLoadVersionDomain.js +35 -0
- package/dist/collection/scripts/zonosBase.js +21 -31
- package/dist/collection/styles/stripe/addressRuleStyle.js +4 -0
- package/dist/collection/types/generated/graphql.customer.types.js +7 -4
- package/dist/collection/types/generated/graphql.frontend.types.js +3 -0
- package/dist/components/stripe.js +4097 -7
- package/dist/components/submitGtag.js +1 -1
- package/dist/components/trackConversionEvent.js +24 -0
- package/dist/components/zonos-address2.js +2 -3
- package/dist/components/zonos-badge2.js +3 -3
- package/dist/components/zonos-button2.js +5 -5
- package/dist/components/zonos-card2.js +2 -2
- package/dist/components/zonos-cart-subtotal2.js +2 -8
- package/dist/components/zonos-checkbox2.js +3 -3
- package/dist/components/zonos-checkout-finish2.js +44 -16
- package/dist/components/zonos-checkout-footer2.js +1 -1
- package/dist/components/zonos-checkout-payment2.js +2 -3
- package/dist/components/zonos-checkout.js +157 -19
- package/dist/components/zonos-collapse2.js +26 -6
- package/dist/components/zonos-component.js +1 -1
- package/dist/components/zonos-controller.js +25 -6
- package/dist/components/zonos-country-flag2.js +1 -1
- package/dist/components/zonos-country-select2.js +9 -3
- package/dist/components/zonos-custom-message2.js +18 -3
- package/dist/components/zonos-customer-info2.js +4 -3
- package/dist/components/zonos-dialog2.js +3 -3
- package/dist/components/zonos-hello-dialog-footer2.js +3 -3
- package/dist/components/zonos-hello-dialog2.js +6 -5
- package/dist/components/zonos-hello.js +23 -7
- package/dist/components/zonos-language-select2.js +3 -3
- package/dist/components/zonos-link-authentication2.js +1 -1
- package/dist/components/zonos-link.d.ts +11 -0
- package/dist/components/zonos-link.js +43 -0
- package/dist/components/zonos-logo.js +2 -2
- package/dist/components/zonos-payment2.js +1 -1
- package/dist/components/zonos-review2.js +2 -8
- package/dist/components/zonos-select-dialog-header2.js +2 -2
- package/dist/components/zonos-shipping-rich-radio2.js +1 -1
- package/dist/components/zonos-shipping2.js +7 -3
- package/dist/components/zonos-tooltip2.js +2 -2
- package/dist/components/zonos-v-stack2.js +2 -2
- package/dist/components/zonosStore.js +9 -7
- package/dist/esm/{localization-d8f6453b.js → cart-1bbb7662.js} +846 -90
- package/dist/esm/formatStringWithLinks-9e819405.js +15 -0
- package/dist/esm/{getBorderRadius-e9736f7e.js → getBorderRadius-19787feb.js} +1 -1
- package/dist/esm/{isDarkColor-e982fa09.js → isDarkColor-2344e7a5.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/submitGtag-d3d11f1a.js +51 -0
- package/dist/esm/zonos-address_4.entry.js +33 -15
- package/dist/esm/zonos-badge_2.entry.js +6 -6
- package/dist/esm/zonos-banner.entry.js +1 -1
- package/dist/esm/zonos-button_3.entry.js +8 -8
- package/dist/esm/zonos-card_2.entry.js +8 -6
- package/dist/esm/zonos-cart-items_9.entry.js +47 -37
- package/dist/esm/zonos-checkout.entry.js +158 -22
- package/dist/esm/zonos-component.entry.js +1 -1
- package/dist/esm/zonos-controller.entry.js +28 -9
- package/dist/esm/zonos-country-flag.entry.js +4 -2
- package/dist/esm/zonos-country-select_3.entry.js +19 -10
- package/dist/esm/zonos-elements.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +9 -5
- package/dist/esm/zonos-hello.entry.js +24 -7
- package/dist/esm/zonos-link.entry.js +20 -0
- package/dist/esm/zonos-logo.entry.js +3 -3
- package/dist/esm/zonos-notification.entry.js +1 -1
- package/dist/esm/zonos-payment.entry.js +5 -6
- package/dist/esm/zonos-select-dialog-header_2.entry.js +5 -5
- package/dist/esm/zonos-shipping-rich-radio.entry.js +3 -3
- package/dist/esm/zonos-text.entry.js +1 -1
- package/dist/esm/{zonosStore-e6c7be3a.js → zonosStore-00bce01b.js} +9 -7
- package/dist/esm-es5/cart-1bbb7662.js +1 -0
- package/dist/esm-es5/formatStringWithLinks-9e819405.js +1 -0
- package/dist/esm-es5/{getBorderRadius-e9736f7e.js → getBorderRadius-19787feb.js} +1 -1
- package/dist/esm-es5/{isDarkColor-e982fa09.js → isDarkColor-2344e7a5.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/submitGtag-d3d11f1a.js +1 -0
- package/dist/esm-es5/zonos-address_4.entry.js +1 -1
- package/dist/esm-es5/zonos-badge_2.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_2.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_9.entry.js +1 -1
- 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 -1
- package/dist/esm-es5/zonos-country-select_3.entry.js +1 -1
- 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-link.entry.js +1 -0
- package/dist/esm-es5/zonos-logo.entry.js +1 -1
- 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 -1
- 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-e6c7be3a.js → zonosStore-00bce01b.js} +1 -1
- package/dist/scripts/checkIfLoadVersionDomain.js +1 -0
- package/dist/scripts/loadStripe.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/stripe.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.d.ts +1 -1
- package/dist/types/components/common/component-template/zonos-link/zonos-link.d.ts +19 -0
- package/dist/types/components/common/zonos-collapse/zonos-collapse.d.ts +1 -0
- package/dist/types/components/common/zonos-country-select/zonos-country-select.d.ts +2 -0
- package/dist/types/components/hello/zonos-hello/zonos-hello.d.ts +9 -3
- package/dist/types/components/store/checkout/cart.d.ts +6 -3
- package/dist/types/components/store/checkout/stripe.d.ts +26 -1
- package/dist/types/components/store/hello/localization.d.ts +1 -1
- package/dist/types/components/store/zonosStore.d.ts +2 -1
- package/dist/types/components/utils/api/getLocaleMessages.d.ts +1 -1
- package/dist/types/components/utils/api/trackConversionEvent.d.ts +3 -0
- package/dist/types/components/utils/checkout/isShippableCountry.d.ts +1 -0
- package/dist/types/components/utils/checkout/watchBigcommerceDomesticCheckout.d.ts +20 -0
- package/dist/types/components/utils/formatStringWithLinks.d.ts +1 -0
- package/dist/types/components/utils/hello/currencyConversion/getCurrencyElements.d.ts +1 -1
- package/dist/types/components/utils/hello/currencyConversion/getLanguageCode.d.ts +1 -1
- package/dist/types/components/utils/logging/log.d.ts +1 -1
- package/dist/types/components/utils/logging/sendErrorLog.d.ts +7 -0
- package/dist/types/components.d.ts +53 -3
- package/dist/types/scripts/checkIfLoadVersionDomain.d.ts +13 -0
- package/dist/types/scripts/zonosBase.d.ts +2 -0
- package/dist/types/types/ICountryJson.d.ts +2 -1
- package/dist/types/types/checkout/CheckoutConfig.d.ts +1 -1
- package/dist/types/types/generated/graphql.customer.types.d.ts +23 -53
- package/dist/types/types/generated/graphql.customer.types.ts +42 -62
- package/dist/types/types/generated/graphql.frontend.types.d.ts +9 -1
- package/dist/types/types/generated/graphql.frontend.types.ts +19 -1
- package/dist/zonos-elements/p-0318632a.entry.js +1 -0
- package/dist/zonos-elements/p-066c5893.system.js +1 -1
- package/dist/zonos-elements/p-07966463.entry.js +1 -0
- package/dist/zonos-elements/p-0c0aa552.js +1 -0
- package/dist/zonos-elements/p-127b480c.entry.js +1 -0
- package/dist/zonos-elements/p-135ab559.system.entry.js +1 -0
- package/dist/zonos-elements/{p-b81a0577.system.entry.js → p-143dc0d9.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-32bca9c8.system.entry.js → p-14d27ce1.system.entry.js} +1 -1
- package/dist/zonos-elements/p-15a80c4a.entry.js +1 -0
- package/dist/zonos-elements/p-17e87be1.entry.js +1 -0
- package/dist/zonos-elements/{p-0c7480a5.entry.js → p-1e0dd491.entry.js} +1 -1
- package/dist/zonos-elements/{p-a33745e9.entry.js → p-279d1c5f.entry.js} +1 -1
- package/dist/zonos-elements/p-2d6557ee.system.js +1 -0
- package/dist/zonos-elements/p-314be538.system.entry.js +1 -0
- package/dist/zonos-elements/{p-dd7729fd.system.entry.js → p-328b7f6f.system.entry.js} +1 -1
- package/dist/zonos-elements/p-354603b3.system.entry.js +1 -0
- package/dist/zonos-elements/{p-50287643.system.js → p-49f6a985.system.js} +1 -1
- package/dist/zonos-elements/p-57b65321.system.entry.js +1 -0
- package/dist/zonos-elements/p-58c1ddef.system.js +1 -0
- package/dist/zonos-elements/{p-06652d87.system.entry.js → p-58e2f6a1.system.entry.js} +1 -1
- package/dist/zonos-elements/p-5ee03db0.system.entry.js +1 -0
- package/dist/zonos-elements/{p-5a113c3d.system.entry.js → p-61e5cf29.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-49a764e9.system.entry.js → p-799d8a17.system.entry.js} +1 -1
- package/dist/zonos-elements/p-7a32526c.entry.js +1 -0
- package/dist/zonos-elements/p-7b87b82f.js +1 -0
- package/dist/zonos-elements/{p-9cbbf261.system.entry.js → p-7c45ce37.system.entry.js} +1 -1
- package/dist/zonos-elements/p-84f4f00f.entry.js +1 -0
- package/dist/zonos-elements/{p-e8a9bc56.entry.js → p-857cfe35.entry.js} +1 -1
- package/dist/zonos-elements/p-87e9c42f.entry.js +1 -0
- package/dist/zonos-elements/{p-e99d79d9.system.js → p-91797d4e.system.js} +1 -1
- package/dist/zonos-elements/{p-17550a10.js → p-95e0fc06.js} +1 -1
- package/dist/zonos-elements/{p-7a6144b1.entry.js → p-a3cc0f84.entry.js} +1 -1
- package/dist/zonos-elements/p-a5f12396.entry.js +1 -0
- package/dist/zonos-elements/p-a87561b8.js +1 -0
- package/dist/zonos-elements/{p-ba43275e.entry.js → p-ac0a7b8f.entry.js} +1 -1
- package/dist/zonos-elements/p-ae82a9ae.js +1 -0
- package/dist/zonos-elements/p-b0462325.system.entry.js +1 -0
- package/dist/zonos-elements/p-b2c0ec71.system.entry.js +1 -0
- package/dist/zonos-elements/{p-fcc4f140.system.js → p-b4725505.system.js} +1 -1
- package/dist/zonos-elements/p-bef54fb1.entry.js +1 -0
- package/dist/zonos-elements/p-c0d431f6.system.entry.js +1 -0
- package/dist/zonos-elements/p-d054788b.system.js +1 -0
- package/dist/zonos-elements/p-d407c93a.system.entry.js +1 -0
- package/dist/zonos-elements/p-e55dd932.js +1 -0
- package/dist/zonos-elements/p-ec37439e.entry.js +1 -0
- package/dist/zonos-elements/p-edace42b.entry.js +1 -0
- package/dist/zonos-elements/p-f478c814.system.entry.js +1 -0
- package/dist/zonos-elements/{p-7dd8e8ba.system.entry.js → p-f6eaef7b.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-bd6a2095.entry.js → p-f7c36fcc.entry.js} +1 -1
- package/dist/zonos-elements/p-f862b97f.system.entry.js +1 -0
- package/dist/zonos-elements/p-fd642725.entry.js +1 -0
- package/dist/zonos-elements/p-fdb72530.system.entry.js +1 -0
- package/dist/zonos-elements/{p-a4de3fb2.entry.js → p-ff64ddc5.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/cart-b8bbf22d.js +0 -698
- package/dist/cjs/submitGtag-792fe45d.js +0 -21
- package/dist/collection/scripts/extractZonosQaUrl.js +0 -26
- package/dist/components/localization.js +0 -4016
- package/dist/esm/cart-bc3bb22e.js +0 -682
- package/dist/esm/submitGtag-bebe2cb0.js +0 -19
- package/dist/esm-es5/cart-bc3bb22e.js +0 -1
- package/dist/esm-es5/localization-d8f6453b.js +0 -1
- package/dist/esm-es5/submitGtag-bebe2cb0.js +0 -1
- package/dist/types/scripts/extractZonosQaUrl.d.ts +0 -11
- package/dist/zonos-elements/p-00d63df1.system.entry.js +0 -1
- package/dist/zonos-elements/p-04f63cea.entry.js +0 -1
- package/dist/zonos-elements/p-16b74c31.system.js +0 -1
- package/dist/zonos-elements/p-1d16a6fb.js +0 -1
- package/dist/zonos-elements/p-1ea68e3b.entry.js +0 -1
- package/dist/zonos-elements/p-1ed530cc.entry.js +0 -1
- package/dist/zonos-elements/p-289c8b1a.system.entry.js +0 -1
- package/dist/zonos-elements/p-2a00c270.system.entry.js +0 -1
- package/dist/zonos-elements/p-37f53a79.entry.js +0 -1
- package/dist/zonos-elements/p-394cf1cf.js +0 -1
- package/dist/zonos-elements/p-3ef27745.js +0 -1
- package/dist/zonos-elements/p-458fd100.system.entry.js +0 -1
- package/dist/zonos-elements/p-47fac33f.js +0 -1
- package/dist/zonos-elements/p-4fafb2a5.system.entry.js +0 -1
- package/dist/zonos-elements/p-4fb71a93.js +0 -1
- package/dist/zonos-elements/p-5276c61b.system.entry.js +0 -1
- package/dist/zonos-elements/p-6308b347.entry.js +0 -1
- package/dist/zonos-elements/p-63d1b1fe.entry.js +0 -1
- package/dist/zonos-elements/p-7347ee7c.system.entry.js +0 -1
- package/dist/zonos-elements/p-8c26a080.system.js +0 -1
- package/dist/zonos-elements/p-96aabe02.entry.js +0 -1
- package/dist/zonos-elements/p-a682fd38.system.entry.js +0 -1
- package/dist/zonos-elements/p-ba1a111a.system.entry.js +0 -1
- package/dist/zonos-elements/p-c4321084.system.entry.js +0 -1
- package/dist/zonos-elements/p-cdf114a2.entry.js +0 -1
- package/dist/zonos-elements/p-d5ae3cbb.system.entry.js +0 -1
- package/dist/zonos-elements/p-d5d7c8f5.entry.js +0 -1
- package/dist/zonos-elements/p-de339fb6.entry.js +0 -1
- package/dist/zonos-elements/p-ec25f180.entry.js +0 -1
- package/dist/zonos-elements/p-f49dfd06.system.js +0 -1
- package/dist/zonos-elements/p-f6f5f644.entry.js +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createStore } from "@stencil/store";
|
|
2
|
+
import { cartStore } from "../checkout/cart";
|
|
2
3
|
import { translationStoreUpdateLanguage } from "../translationStore";
|
|
3
4
|
import { zonosStore } from "../zonosStore";
|
|
4
5
|
import { getCountries } from "../../utils/api/getCountries";
|
|
@@ -7,10 +8,12 @@ import { getExchangeRate, } from "../../utils/api/getExchangeRate";
|
|
|
7
8
|
import { getLocaleMessages } from "../../utils/api/getLocaleMessages";
|
|
8
9
|
import { getLocalization } from "../../utils/api/getLocalization";
|
|
9
10
|
import { getShippingZones } from "../../utils/api/getShippingZones";
|
|
11
|
+
import { handleFetch } from "../../utils/handleFetch";
|
|
10
12
|
import { currencyDisplay } from "../../utils/hello/currencyConversion/currencyDisplay";
|
|
11
13
|
import { getCurrencyCode } from "../../utils/hello/currencyConversion/getCurrencyCode";
|
|
12
14
|
import { setZCountryUrlParam } from "../../utils/hello/setZCountryUrlParam";
|
|
13
15
|
import { log } from "../../utils/logging/log";
|
|
16
|
+
import { logError } from "../../utils/logging/logError";
|
|
14
17
|
const { state: localizationStore } = createStore({
|
|
15
18
|
countryLandedCost: null,
|
|
16
19
|
customMessages: [],
|
|
@@ -57,11 +60,9 @@ const getNewLocalization = async () => {
|
|
|
57
60
|
!selectedCountryCode) {
|
|
58
61
|
return;
|
|
59
62
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
startExchangeRateTimeout({ isGuaranteed, maxAge });
|
|
64
|
-
}
|
|
63
|
+
const isGuaranteed = zonosStore.checkoutSettings.visibilityStatus === 'ENABLED';
|
|
64
|
+
const { maxAge } = await triggerGetExchangeRate(isGuaranteed);
|
|
65
|
+
startExchangeRateTimeout({ isGuaranteed, maxAge });
|
|
65
66
|
localizationStore.countryLandedCost = await getCountryLandedCost(localizationStore.selectedCountryCode);
|
|
66
67
|
};
|
|
67
68
|
const getCustomMessages = async () => {
|
|
@@ -88,7 +89,8 @@ const getOverrideLocale = () => {
|
|
|
88
89
|
const zonosLocale = currentUrl.searchParams.get('zonosLocale');
|
|
89
90
|
return zonosLocale;
|
|
90
91
|
};
|
|
91
|
-
const localizationStoreUpdateSelectedCountryCode =
|
|
92
|
+
const localizationStoreUpdateSelectedCountryCode = (newSelectedCountryCode) => {
|
|
93
|
+
var _a;
|
|
92
94
|
log('update selected country code');
|
|
93
95
|
localizationStore.selectedCountryCode = newSelectedCountryCode;
|
|
94
96
|
const { selectedCountryCode, shippingZoneCountries } = localizationStore;
|
|
@@ -112,6 +114,8 @@ const localizationStoreUpdateSelectedCountryCode = async (newSelectedCountryCode
|
|
|
112
114
|
window.sessionStorage.setItem('zonos--country', selectedCountryCode);
|
|
113
115
|
// Update the URL query param with the new country code
|
|
114
116
|
setZCountryUrlParam(selectedCountryCode);
|
|
117
|
+
(_a = document
|
|
118
|
+
.querySelector('zonos-hello')) === null || _a === void 0 ? void 0 : _a.setAttribute('z-country', selectedCountryCode);
|
|
115
119
|
};
|
|
116
120
|
const initLocalizationStore = async () => {
|
|
117
121
|
// all countries from countries.json, shipping zone and localization
|
|
@@ -119,7 +123,7 @@ const initLocalizationStore = async () => {
|
|
|
119
123
|
// Filter countries to only include countries in the shipping zone
|
|
120
124
|
const filteredCountries = shippingZoneCountries === null || shippingZoneCountries === void 0 ? void 0 : shippingZoneCountries.reduce((acc, countryCode) => {
|
|
121
125
|
const countryInfo = allCountries === null || allCountries === void 0 ? void 0 : allCountries[countryCode];
|
|
122
|
-
return countryInfo
|
|
126
|
+
return countryInfo && countryInfo.active
|
|
123
127
|
? Object.assign(Object.assign({}, acc), { [countryCode]: countryInfo }) : acc;
|
|
124
128
|
}, {});
|
|
125
129
|
localizationStore.shippingZoneCountries = filteredCountries || null;
|
|
@@ -140,8 +144,31 @@ const initLocalizationStore = async () => {
|
|
|
140
144
|
localizationStore.localizationLoaded = true;
|
|
141
145
|
void getCustomMessages();
|
|
142
146
|
};
|
|
147
|
+
const updateCheckoutSessionLanguage = async () => {
|
|
148
|
+
if (!cartStore.checkoutSessionId) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
const { errors, json } = await handleFetch(`${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/zonos-elements/update-checkout-session-metadata`, {
|
|
152
|
+
body: {
|
|
153
|
+
id: cartStore.checkoutSessionId,
|
|
154
|
+
metadata: [
|
|
155
|
+
{
|
|
156
|
+
key: 'language',
|
|
157
|
+
value: localizationStore.selectedLocale,
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
method: 'POST',
|
|
162
|
+
});
|
|
163
|
+
if (errors.length || !json) {
|
|
164
|
+
logError('Error occurs when updating checkout session', JSON.stringify(errors, null, 2));
|
|
165
|
+
return { errors, json };
|
|
166
|
+
}
|
|
167
|
+
return { errors: [], json };
|
|
168
|
+
};
|
|
143
169
|
const localizationStoreUpdateSelectedLocale = (newSelectedLocale) => {
|
|
144
170
|
localizationStore.selectedLocale = newSelectedLocale;
|
|
145
171
|
translationStoreUpdateLanguage(newSelectedLocale);
|
|
172
|
+
void updateCheckoutSessionLanguage();
|
|
146
173
|
};
|
|
147
174
|
export { initLocalizationStore, localizationStore, localizationStoreUpdateSelectedCountryCode, localizationStoreUpdateSelectedLocale, };
|
|
@@ -64,6 +64,7 @@ const { reset, state: zonosStore } = createStore(() => ({
|
|
|
64
64
|
restrictionBehavior: 'DISABLED',
|
|
65
65
|
},
|
|
66
66
|
loadedConfig: false,
|
|
67
|
+
organizationId: '',
|
|
67
68
|
organizationName: '',
|
|
68
69
|
sourceCurrency: 'USD',
|
|
69
70
|
storeId: null,
|
|
@@ -76,7 +77,7 @@ let savedZonosSettings = null;
|
|
|
76
77
|
* Init setting from zonos setting
|
|
77
78
|
*/
|
|
78
79
|
const zonosStoreInitSetting = ({ overrideSettings, zonosSettings, }) => {
|
|
79
|
-
var _a, _b, _c;
|
|
80
|
+
var _a, _b, _c, _d;
|
|
80
81
|
reset();
|
|
81
82
|
if (zonosSettings) {
|
|
82
83
|
// save zonos settings to be used later
|
|
@@ -84,16 +85,17 @@ const zonosStoreInitSetting = ({ overrideSettings, zonosSettings, }) => {
|
|
|
84
85
|
}
|
|
85
86
|
zonosStore.appearance = mergeConfig(zonosStore.appearance, (savedZonosSettings === null || savedZonosSettings === void 0 ? void 0 : savedZonosSettings.appearanceSettings) ||
|
|
86
87
|
(zonosSettings === null || zonosSettings === void 0 ? void 0 : zonosSettings.appearanceSettings) ||
|
|
87
|
-
null, overrideSettings.appearance);
|
|
88
|
+
null, overrideSettings === null || overrideSettings === void 0 ? void 0 : overrideSettings.appearance);
|
|
88
89
|
zonosStore.checkoutSettings = mergeConfig(zonosStore.checkoutSettings, (savedZonosSettings === null || savedZonosSettings === void 0 ? void 0 : savedZonosSettings.checkoutSettings) ||
|
|
89
90
|
(zonosSettings === null || zonosSettings === void 0 ? void 0 : zonosSettings.checkoutSettings) ||
|
|
90
|
-
null, overrideSettings.checkoutSettings);
|
|
91
|
-
zonosStore.helloSettings = mergeConfig(zonosStore.helloSettings, (savedZonosSettings === null || savedZonosSettings === void 0 ? void 0 : savedZonosSettings.helloSettings) || (zonosSettings === null || zonosSettings === void 0 ? void 0 : zonosSettings.helloSettings) || null, overrideSettings.helloSettings);
|
|
91
|
+
null, overrideSettings === null || overrideSettings === void 0 ? void 0 : overrideSettings.checkoutSettings);
|
|
92
|
+
zonosStore.helloSettings = mergeConfig(zonosStore.helloSettings, (savedZonosSettings === null || savedZonosSettings === void 0 ? void 0 : savedZonosSettings.helloSettings) || (zonosSettings === null || zonosSettings === void 0 ? void 0 : zonosSettings.helloSettings) || null, overrideSettings === null || overrideSettings === void 0 ? void 0 : overrideSettings.helloSettings);
|
|
92
93
|
// set flag to true to indicate that config is ready
|
|
93
94
|
zonosStore.loadedConfig = true;
|
|
94
|
-
zonosStore.
|
|
95
|
-
zonosStore.
|
|
96
|
-
zonosStore.
|
|
95
|
+
zonosStore.organizationId = ((_a = zonosSettings === null || zonosSettings === void 0 ? void 0 : zonosSettings.organization) === null || _a === void 0 ? void 0 : _a.id) || '';
|
|
96
|
+
zonosStore.organizationName = ((_b = zonosSettings === null || zonosSettings === void 0 ? void 0 : zonosSettings.organization) === null || _b === void 0 ? void 0 : _b.name) || '';
|
|
97
|
+
zonosStore.storeId = ((_d = (_c = zonosSettings === null || zonosSettings === void 0 ? void 0 : zonosSettings.organization) === null || _c === void 0 ? void 0 : _c.references) === null || _d === void 0 ? void 0 : _d.storeId) || null;
|
|
98
|
+
zonosStore.currencyConverter = overrideSettings === null || overrideSettings === void 0 ? void 0 : overrideSettings.currencyConverter;
|
|
97
99
|
};
|
|
98
100
|
const zonosStoreFontFamily = () => {
|
|
99
101
|
const fontFamily = zonosStore.appearance.fontFamily || 'Inter';
|
|
@@ -135,7 +135,7 @@ export class ZonosAddress {
|
|
|
135
135
|
}
|
|
136
136
|
render() {
|
|
137
137
|
// this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
|
|
138
|
-
return (h(Host, { key: '
|
|
138
|
+
return (h(Host, { key: '8d762300d8f599a277806d861d13d2beb6a0a5a6', class: "zonos--address zonos--elements" }, h("zonos-text", { key: 'c355eece2f193cb0595ede434238f062b2c07c7c', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), h("div", { key: '59c3bd68cd67c8d733fd2ca5d9f4b4114c84db4a', class: "zonos--address-component" })));
|
|
139
139
|
}
|
|
140
140
|
static get is() { return "zonos-address"; }
|
|
141
141
|
static get encapsulation() { return "scoped"; }
|
package/dist/collection/components/stripe/zonos-link-authentication/zonos-link-authentication.js
CHANGED
|
@@ -36,7 +36,7 @@ export class ZonosLinkAuthentication {
|
|
|
36
36
|
}
|
|
37
37
|
render() {
|
|
38
38
|
// this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
|
|
39
|
-
return (h(Host, { key: '
|
|
39
|
+
return (h(Host, { key: '62b8e4a5c1902cb2c8fe032d7c43ba68742e8c0a', class: "zonos--link-authentication zonos--elements" }, h("zonos-text", { key: 'b86acc15bfc6eba0c7174c1e229205b34747f57d', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), h("div", { key: 'f0734254d41ff9f221f97143e0df1f28017b9a61', class: "zonos--link-authentication-component" })));
|
|
40
40
|
}
|
|
41
41
|
static get is() { return "zonos-link-authentication"; }
|
|
42
42
|
static get encapsulation() { return "scoped"; }
|
|
@@ -37,7 +37,7 @@ export class ZonosPayment {
|
|
|
37
37
|
}
|
|
38
38
|
render() {
|
|
39
39
|
// this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
|
|
40
|
-
return (h(Host, { key: '
|
|
40
|
+
return (h(Host, { key: 'de560f2de1e48fce2cf11f0fc3e2ef36938e719f', class: "zonos--payment zonos--elements" }, this.titleText && (h("zonos-text", { class: "zonos--title", type: "semiBoldLabel" }, this.titleText)), h("div", { key: 'b6a60c127e67e3d03408d960ad56f712a5677683', class: "zonos--payment-component" })));
|
|
41
41
|
}
|
|
42
42
|
static get is() { return "zonos-payment"; }
|
|
43
43
|
static get encapsulation() { return "scoped"; }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { localizationStore } from "../../store/hello/localization";
|
|
2
|
+
import { zonosStore } from "../../store/zonosStore";
|
|
3
|
+
import { handleFetch } from "../handleFetch";
|
|
4
|
+
export const trackConversionEvent = async (eventName, metadata) => {
|
|
5
|
+
// If a Zonos domain, we don't want analytics to be tracked
|
|
6
|
+
if (window.location.href.includes('zonos.com')) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const url = `${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/zonos-elements/track-conversion-event`;
|
|
10
|
+
const countryCode = localizationStore.selectedCountryCode;
|
|
11
|
+
const organizationId = zonosStore.organizationId;
|
|
12
|
+
const body = {
|
|
13
|
+
countryCode,
|
|
14
|
+
eventName,
|
|
15
|
+
metadata,
|
|
16
|
+
organizationId,
|
|
17
|
+
};
|
|
18
|
+
await handleFetch(url, {
|
|
19
|
+
body,
|
|
20
|
+
method: 'POST',
|
|
21
|
+
});
|
|
22
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { localizationStore } from "../../store/hello/localization";
|
|
2
|
+
import { log } from "../logging/log";
|
|
3
|
+
export const isShippableCountry = (showLog = true) => {
|
|
4
|
+
if (!localizationStore.localizationLoaded) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
// if localization is loaded and the localization is not a shippable country, keep the original click event
|
|
8
|
+
if (!localizationStore.isShippableCountry) {
|
|
9
|
+
if (showLog) {
|
|
10
|
+
log(`Checkout: not shippable country`);
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { stripeStoreCleanupDomesticShippingSession, stripeStoreGetDomesticShippingSession, stripeStoreSaveDomesticShippingSession, } from "../../store/checkout/stripe";
|
|
2
|
+
import { localizationStoreUpdateSelectedCountryCode } from "../../store/hello/localization";
|
|
3
|
+
import { zonosStore } from "../../store/zonosStore";
|
|
4
|
+
import { isShippableCountry } from "./isShippableCountry";
|
|
5
|
+
import { logError } from "../logging/logError";
|
|
6
|
+
import { sendErrorLog } from "../logging/sendErrorLog";
|
|
7
|
+
/**
|
|
8
|
+
* Watch for changes in domestic checkout step, this is to redirect user to home page and open checkout if user enters the ship to country that's in the shipping zone
|
|
9
|
+
* @note Only works on default bigcommerce checkout page
|
|
10
|
+
*/
|
|
11
|
+
export const watchBigcommerceDomesticCheckout = ({ domesticRedirectedBtnSelector, onShippingAddressSessionFound, }) => {
|
|
12
|
+
if (!window.Zonos.isBigCommerce) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const observer = new MutationObserver(async () => {
|
|
16
|
+
const domesticRedirectedButton = document.querySelector(domesticRedirectedBtnSelector);
|
|
17
|
+
const shippingAddressSession = stripeStoreGetDomesticShippingSession();
|
|
18
|
+
// append a hidden button to the body if the shipping address session is found
|
|
19
|
+
if (!domesticRedirectedButton && shippingAddressSession) {
|
|
20
|
+
// create a hidden button to trigger the click event
|
|
21
|
+
const button = document.createElement('button');
|
|
22
|
+
button.style.display = 'none';
|
|
23
|
+
button.id = 'zonos--domestic-redirected-checkout-button';
|
|
24
|
+
document.body.appendChild(button);
|
|
25
|
+
onShippingAddressSessionFound === null || onShippingAddressSessionFound === void 0 ? void 0 : onShippingAddressSessionFound(shippingAddressSession);
|
|
26
|
+
// disconnect the observer after we found the shipping continue button
|
|
27
|
+
observer.disconnect();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const shipToCountryElement = document.querySelector('select[name="shippingAddress.countryCode"]');
|
|
31
|
+
// make sure the continue button is available
|
|
32
|
+
const shippingCountinueBtnEle = document.querySelector('#checkout-shipping-continue');
|
|
33
|
+
if (!shipToCountryElement || !shippingCountinueBtnEle) {
|
|
34
|
+
// do nothing if shipping country and the continue button is not found
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// disconnect the observer after we found the shipping continue button
|
|
38
|
+
observer.disconnect();
|
|
39
|
+
shippingCountinueBtnEle.addEventListener('click', async (e) => {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
const shippingCountry = shipToCountryElement.value;
|
|
42
|
+
if (!shippingCountry) {
|
|
43
|
+
// do nothing if shipping country is not found
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// update the country code in localization store and check if it's shippable
|
|
47
|
+
localizationStoreUpdateSelectedCountryCode(shippingCountry);
|
|
48
|
+
// do nothing if the country is still domestic
|
|
49
|
+
if (!isShippableCountry(false)) {
|
|
50
|
+
// cleanup the domestic shipping session if it's domestic because we will open the intl checkout after redirecting
|
|
51
|
+
stripeStoreCleanupDomesticShippingSession();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// get value of shipping address state
|
|
55
|
+
const shipToFormElement = document.querySelector('form');
|
|
56
|
+
if (!shipToFormElement) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const formData = new FormData(shipToFormElement);
|
|
60
|
+
const shipAddress1Element = document.querySelector('input#addressLine1Input');
|
|
61
|
+
const shippingAddress = {
|
|
62
|
+
address1: (_a = formData.get('shippingAddress.address1')) !== null && _a !== void 0 ? _a :
|
|
63
|
+
// in Canada, the address1 is not included in the form, try to get value from input id instead.
|
|
64
|
+
(shipAddress1Element && shipAddress1Element.value),
|
|
65
|
+
address2: formData.get('shippingAddress.address2'),
|
|
66
|
+
city: formData.get('shippingAddress.city'),
|
|
67
|
+
countryCode: formData.get('shippingAddress.countryCode'),
|
|
68
|
+
firstName: formData.get('shippingAddress.firstName'),
|
|
69
|
+
lastName: formData.get('shippingAddress.lastName'),
|
|
70
|
+
phone: formData.get('shippingAddress.phone'),
|
|
71
|
+
postalCode: formData.get('shippingAddress.postalCode'),
|
|
72
|
+
stateOrProvince: (_b = formData.get('shippingAddress.stateOrProvince')) !== null && _b !== void 0 ? _b : formData.get('shippingAddress.stateOrProvinceCode'),
|
|
73
|
+
};
|
|
74
|
+
if (Object.values(shippingAddress).some(value => value === undefined || value === null)) {
|
|
75
|
+
logError('One or more shipping address field is missing', Object.entries(shippingAddress));
|
|
76
|
+
void sendErrorLog({
|
|
77
|
+
endpoint: 'No endpoint, domestic checkout form missing fields',
|
|
78
|
+
errors: [
|
|
79
|
+
'Bigcommerce: One or more shipping address field is missing in the domestic checkout form',
|
|
80
|
+
JSON.stringify(Object.entries(shippingAddress)),
|
|
81
|
+
],
|
|
82
|
+
metadata: {
|
|
83
|
+
domain: window.location.hostname,
|
|
84
|
+
storeId: zonosStore.storeId,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// save the shipping address to session storage
|
|
90
|
+
stripeStoreSaveDomesticShippingSession({
|
|
91
|
+
address1: shippingAddress.address1,
|
|
92
|
+
address2: shippingAddress.address2,
|
|
93
|
+
city: shippingAddress.city,
|
|
94
|
+
countryCode: shippingAddress.countryCode,
|
|
95
|
+
firstName: shippingAddress.firstName,
|
|
96
|
+
lastName: shippingAddress.lastName,
|
|
97
|
+
phone: shippingAddress.phone,
|
|
98
|
+
postalCode: shippingAddress.postalCode,
|
|
99
|
+
state: shippingAddress.stateOrProvince,
|
|
100
|
+
});
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
e.stopPropagation();
|
|
103
|
+
// redirect to home page, home page then will open the checkout dialog if having domestic shipping session
|
|
104
|
+
window.location.href = '/';
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
observer.observe(document.body, {
|
|
108
|
+
childList: true,
|
|
109
|
+
subtree: true,
|
|
110
|
+
});
|
|
111
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const formatStringWithLinks = (str) => {
|
|
2
|
+
// Match Markdown-style links or standalone URLs not in Markdown format
|
|
3
|
+
const linkRegex = /\[([^\]]+)\]\((https?:\/\/[^\s\)]+)\)|(https?:\/\/[^\s]+)/g;
|
|
4
|
+
const messageWithLinks = str.replace(linkRegex, (_match, text, markdownUrl, url) => {
|
|
5
|
+
if (markdownUrl) {
|
|
6
|
+
return `<zonos-link href="${markdownUrl}" target="_blank" rel="noopener noreferrer">${text}</zonos-link>`;
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
return `<zonos-link href="${url}" target="_blank" rel="noopener noreferrer">${url}</zonos-link>`;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return messageWithLinks;
|
|
13
|
+
};
|
|
@@ -111,7 +111,7 @@ export const handleFetch = async (url, _opts) => {
|
|
|
111
111
|
const modifiedUrl = new URL(url);
|
|
112
112
|
modifiedUrl.searchParams.set('zToken', encodeString(window.location.hostname));
|
|
113
113
|
// headers content type
|
|
114
|
-
const headers = Object.assign({ 'Content-Type': 'application/json', 'Zonos-Is-BigCommerce': window.Zonos.isBigCommerce.toString(), 'Zonos-Referer': window.location.hostname, 'Zonos-Version': window.Zonos.version, credentialtoken: window.Zonos.zonosApiKey }, opts.headers);
|
|
114
|
+
const headers = Object.assign({ 'Content-Type': 'application/json', 'Zonos-Is-BigCommerce': window.Zonos.isBigCommerce.toString(), 'Zonos-Referer': window.location.hostname, 'Zonos-Version': window.Zonos.version, credentialtoken: window.Zonos.zonosApiKey || 'Empty credential token from zonos-elements' }, opts.headers);
|
|
115
115
|
const options = Object.assign(Object.assign({}, opts), { body: method === 'GET' ? undefined : body, headers,
|
|
116
116
|
method });
|
|
117
117
|
return handleRequest(modifiedUrl.toString(), options);
|
package/dist/collection/components/utils/hello/currencyConversion/defaultCurrencyConverter.js
CHANGED
|
@@ -1,13 +1,35 @@
|
|
|
1
1
|
import { localizationStore } from "../../../store/hello/localization";
|
|
2
2
|
import { zonosStore } from "../../../store/zonosStore";
|
|
3
|
-
import { currencyConvert } from "./currencyConvert";
|
|
4
3
|
import { currencyConvertAndFormat } from "./currencyConvertAndFormat";
|
|
5
4
|
import { getCurrencyElements } from "./getCurrencyElements";
|
|
6
5
|
import { getInitialElementAmount } from "./getInitialElementAmount";
|
|
7
6
|
import { logError } from "../../logging/logError";
|
|
7
|
+
const convertCurrency = (element) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const amount = getInitialElementAmount(element);
|
|
10
|
+
if (!amount || isNaN(amount)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const currentIntlValue = element.getAttribute('data-zintl');
|
|
14
|
+
const currentCountryValue = element.getAttribute('data-zcountry-code');
|
|
15
|
+
// do nothing if the target currency is the same
|
|
16
|
+
const isExchangeRateReady = localizationStore.targetCurrency ===
|
|
17
|
+
((_a = localizationStore.exchangeRate) === null || _a === void 0 ? void 0 : _a.targetFormat.currencyCode);
|
|
18
|
+
// if the current value on the element is different from the current intl value, update the data-zintl attribute
|
|
19
|
+
if (isExchangeRateReady &&
|
|
20
|
+
(element.textContent !== currentIntlValue ||
|
|
21
|
+
currentCountryValue !== localizationStore.selectedCountryCode)) {
|
|
22
|
+
const observedFormattedValue = currencyConvertAndFormat(amount);
|
|
23
|
+
element.textContent = observedFormattedValue;
|
|
24
|
+
// save the new value to the data-zintl attribute
|
|
25
|
+
element.setAttribute('data-zintl', observedFormattedValue);
|
|
26
|
+
element.setAttribute('data-zcountry-code', localizationStore.selectedCountryCode || '');
|
|
27
|
+
}
|
|
28
|
+
};
|
|
8
29
|
export const defaultCurrencyConverter = () => {
|
|
9
30
|
const { currencyElementSelector } = zonosStore.helloSettings;
|
|
10
31
|
const currencyElements = getCurrencyElements(currencyElementSelector);
|
|
32
|
+
// do nothing if none of the currency elements are found
|
|
11
33
|
if (!(currencyElements === null || currencyElements === void 0 ? void 0 : currencyElements.length)) {
|
|
12
34
|
return;
|
|
13
35
|
}
|
|
@@ -16,32 +38,7 @@ export const defaultCurrencyConverter = () => {
|
|
|
16
38
|
return;
|
|
17
39
|
}
|
|
18
40
|
currencyElements.forEach((element) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
element.setAttribute('data-zintl', currencyConvert(amount).toString());
|
|
24
|
-
// Check if an observer is already attached to the element
|
|
25
|
-
let observer = element._mutationObserver;
|
|
26
|
-
if (!observer) {
|
|
27
|
-
observer = new MutationObserver(() => {
|
|
28
|
-
const observedFormattedValue = currencyConvertAndFormat(amount);
|
|
29
|
-
element.textContent = observedFormattedValue;
|
|
30
|
-
});
|
|
31
|
-
observer.observe(element, {
|
|
32
|
-
characterData: true,
|
|
33
|
-
childList: true,
|
|
34
|
-
});
|
|
35
|
-
element._mutationObserver = observer;
|
|
36
|
-
}
|
|
37
|
-
// Temporarily disconnect the observer to prevent an infinite loop
|
|
38
|
-
observer.disconnect();
|
|
39
|
-
const formattedValue = currencyConvertAndFormat(amount);
|
|
40
|
-
element.textContent = formattedValue;
|
|
41
|
-
// Reconnect the observer after the update is complete
|
|
42
|
-
observer.observe(element, {
|
|
43
|
-
characterData: true,
|
|
44
|
-
childList: true,
|
|
45
|
-
});
|
|
41
|
+
// convert the currency and save the formatted value to the data-zintl attribute
|
|
42
|
+
convertCurrency(element);
|
|
46
43
|
});
|
|
47
44
|
};
|
|
@@ -14,5 +14,6 @@ export const getCurrencyElements = (selector) => {
|
|
|
14
14
|
log(`No currency elements found with selector "${currencySelector}"`, 'warn');
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
|
-
return
|
|
17
|
+
// return array of currency elements instead of a NodeList
|
|
18
|
+
return Array.from(currencyElements);
|
|
18
19
|
};
|
package/dist/collection/components/utils/hello/currencyConversion/getInitialElementAmount.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export const getInitialElementAmount = (element) => {
|
|
2
2
|
var _a;
|
|
3
3
|
const domesticValue = element.getAttribute('data-domestic');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const intlValue = element.getAttribute('data-zintl');
|
|
5
|
+
// Only keep numbers, decimal, and hyphens
|
|
6
|
+
const cleanedText = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.replace(/[^\d.-]/g, '');
|
|
7
|
+
if (!cleanedText) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
// If the element has no data-domestic attribute, or the text content is different from the data-zintl attribute, set the data-domestic attribute
|
|
11
|
+
if (!domesticValue || element.textContent !== intlValue) {
|
|
10
12
|
// Store the original value on the element once, and international on every new conversion
|
|
11
13
|
element.setAttribute('data-domestic', cleanedText);
|
|
12
14
|
return parseFloat(cleanedText);
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { isValidSelector } from "../isValidSelector";
|
|
2
2
|
import { log } from "../logging/log";
|
|
3
3
|
import { logError } from "../logging/logError";
|
|
4
|
-
const injectHelloComponent = (
|
|
4
|
+
const injectHelloComponent = (anchorElementSelector) => {
|
|
5
|
+
const triggerAnchorElement = document.querySelector(anchorElementSelector);
|
|
5
6
|
// append checkout component if doesn't exist
|
|
6
7
|
const helloElement = document.querySelector('zonos-hello');
|
|
7
8
|
if (!helloElement && triggerAnchorElement) {
|
|
8
9
|
const newHelloElement = document.createElement('zonos-hello');
|
|
9
10
|
triggerAnchorElement.appendChild(newHelloElement);
|
|
11
|
+
return true;
|
|
10
12
|
}
|
|
13
|
+
return false;
|
|
11
14
|
};
|
|
12
15
|
export const initHello = async (helloSettings) => {
|
|
13
16
|
const { anchorElementSelector } = helloSettings;
|
|
@@ -16,7 +19,24 @@ export const initHello = async (helloSettings) => {
|
|
|
16
19
|
logError(`Selector anchorElementSelector "${helloSettings.anchorElementSelector}" is not a valid selector.`);
|
|
17
20
|
return;
|
|
18
21
|
}
|
|
19
|
-
const triggerElement = document.querySelector(anchorElementSelector);
|
|
20
22
|
log('Hello init complete');
|
|
21
|
-
injectHelloComponent(
|
|
23
|
+
const isHelloInjected = injectHelloComponent(anchorElementSelector);
|
|
24
|
+
// keep watching for the anchor element to be added to the DOM, then inject hello component
|
|
25
|
+
if (!isHelloInjected) {
|
|
26
|
+
const observer = new MutationObserver(() => {
|
|
27
|
+
const injected = injectHelloComponent(anchorElementSelector);
|
|
28
|
+
if (injected) {
|
|
29
|
+
// disconnect observer if hello is successfully injected
|
|
30
|
+
observer.disconnect();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
observer.observe(document.body, {
|
|
34
|
+
childList: true,
|
|
35
|
+
subtree: true,
|
|
36
|
+
});
|
|
37
|
+
// kill observer after 5 seconds if the hello still not injected, if the hello still not injected after 10 seconds, it's likely that the selector the user doesn't want to use hello
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
observer.disconnect();
|
|
40
|
+
}, 5000);
|
|
41
|
+
}
|
|
22
42
|
};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
export const log = (message, type, ...additionalInfo) => {
|
|
2
|
-
var _a;
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var _a, _b;
|
|
3
|
+
const isDebug = !((_a = window.Zonos) === null || _a === void 0 ? void 0 : _a.debug) ||
|
|
4
|
+
!window.location.search.match(/\?.*(&*)zonosDebug=1/);
|
|
5
|
+
// if debug is false, do not log
|
|
6
|
+
if (!isDebug) {
|
|
7
|
+
// log errors to the console if the type is error
|
|
8
|
+
if (type === 'error') {
|
|
9
|
+
// eslint-disable-next-line no-console
|
|
10
|
+
console.error(message, ...additionalInfo);
|
|
11
|
+
}
|
|
5
12
|
return;
|
|
6
13
|
}
|
|
7
14
|
let loggingIframe = document.querySelector('iframe#zonos---debug-logging-iframe');
|
|
@@ -22,23 +29,27 @@ export const log = (message, type, ...additionalInfo) => {
|
|
|
22
29
|
document.body.appendChild(loggingIframe);
|
|
23
30
|
}
|
|
24
31
|
// use the logging iframe's console to log just in case the console is disabled (overriden) by the site owner
|
|
25
|
-
const
|
|
32
|
+
const zConsole = ((_b = loggingIframe.contentWindow) === null || _b === void 0 ? void 0 : _b.window.console) || window.console;
|
|
26
33
|
switch (type) {
|
|
27
34
|
case 'warn':
|
|
28
35
|
// eslint-disable-next-line no-console
|
|
29
|
-
|
|
36
|
+
zConsole.warn(message, ...additionalInfo);
|
|
30
37
|
break;
|
|
31
38
|
case 'info':
|
|
32
39
|
// eslint-disable-next-line no-console
|
|
33
|
-
|
|
40
|
+
zConsole.info(message, ...additionalInfo);
|
|
41
|
+
break;
|
|
42
|
+
case 'error':
|
|
43
|
+
// eslint-disable-next-line no-console
|
|
44
|
+
zConsole.error(message, ...additionalInfo);
|
|
34
45
|
break;
|
|
35
46
|
default:
|
|
36
47
|
// eslint-disable-next-line no-console
|
|
37
|
-
|
|
48
|
+
zConsole.groupCollapsed(message, ...additionalInfo);
|
|
38
49
|
// eslint-disable-next-line no-console
|
|
39
|
-
|
|
50
|
+
zConsole.trace();
|
|
40
51
|
// eslint-disable-next-line no-console
|
|
41
|
-
|
|
52
|
+
zConsole.groupEnd();
|
|
42
53
|
break;
|
|
43
54
|
}
|
|
44
55
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { handleFetch } from "../handleFetch";
|
|
2
|
+
export const sendErrorLog = async ({ endpoint, errors, metadata }) => {
|
|
3
|
+
const errorObject = {
|
|
4
|
+
endpoint,
|
|
5
|
+
errors,
|
|
6
|
+
metadata,
|
|
7
|
+
};
|
|
8
|
+
void handleFetch(`${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/zonos-elements/log-error`, {
|
|
9
|
+
body: errorObject,
|
|
10
|
+
method: 'POST',
|
|
11
|
+
});
|
|
12
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the load version and url based on the loadScriptSrc and version
|
|
3
|
+
* @returns
|
|
4
|
+
*/
|
|
5
|
+
export const checkIfLoadVersionDomain = ({ loadScriptSrc }) => {
|
|
6
|
+
if (!loadScriptSrc) {
|
|
7
|
+
return {
|
|
8
|
+
currentLoadScriptUrl: '',
|
|
9
|
+
isForceLoadVersionDomain: false,
|
|
10
|
+
isWhiteListed: false,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const whiteListedDomains = [
|
|
14
|
+
// local domain
|
|
15
|
+
'dev.elements.zonos.com',
|
|
16
|
+
// any domain with prefix , no need to version it
|
|
17
|
+
'.js.zonos.com',
|
|
18
|
+
// vercel git domain
|
|
19
|
+
'zonos-elements-test-git',
|
|
20
|
+
'zonos-elements-git',
|
|
21
|
+
];
|
|
22
|
+
const forceLoadVersionDomain = [
|
|
23
|
+
// force load version for qa domain, this is to test the load version behavior
|
|
24
|
+
'qa.js.zonos.com',
|
|
25
|
+
];
|
|
26
|
+
// get the domain that's used to load the loadZonos.js
|
|
27
|
+
const currentLoadScriptUrl = new URL(loadScriptSrc).origin;
|
|
28
|
+
const isWhiteListed = whiteListedDomains.some(domain =>
|
|
29
|
+
// check if the current domain is in the white listed domains
|
|
30
|
+
currentLoadScriptUrl.includes(domain));
|
|
31
|
+
const isForceLoadVersionDomain = forceLoadVersionDomain.some(domain =>
|
|
32
|
+
// check if the current domain is in the force load version domains list
|
|
33
|
+
currentLoadScriptUrl.includes(domain));
|
|
34
|
+
return { currentLoadScriptUrl, isForceLoadVersionDomain, isWhiteListed };
|
|
35
|
+
};
|