@zonos/elements 1.3.7-alpha.0 → 1.3.7
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-ecc80eb0.js → cart-eee85bda.js} +145 -100
- package/dist/cjs/formatStringWithLinks-52341fc7.js +17 -0
- package/dist/cjs/{getBorderRadius-834c321d.js → getBorderRadius-d8f18958.js} +1 -1
- package/dist/cjs/{isDarkColor-924e6a7a.js → isDarkColor-57860b44.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/submitGtag-a2e1f652.js +55 -0
- package/dist/cjs/zonos-address_4.cjs.entry.js +21 -16
- 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 +8 -8
- package/dist/cjs/zonos-cart-items_9.cjs.entry.js +35 -33
- package/dist/cjs/zonos-checkout.cjs.entry.js +159 -23
- package/dist/cjs/zonos-component.cjs.entry.js +1 -1
- package/dist/cjs/zonos-controller.cjs.entry.js +28 -9
- package/dist/cjs/zonos-country-flag.cjs.entry.js +4 -4
- package/dist/cjs/zonos-country-select_3.cjs.entry.js +18 -10
- package/dist/cjs/zonos-elements.cjs.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +9 -7
- package/dist/cjs/zonos-hello.cjs.entry.js +25 -11
- 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 +6 -7
- 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-49d4c92a.js → zonosStore-138c5555.js} +5 -3
- 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 +19 -10
- 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 +41 -20
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.css +3 -0
- 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 +13 -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 +52 -13
- 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 -2
- package/dist/collection/components/store/checkout/cart.js +2 -2
- package/dist/collection/components/store/checkout/stripe.js +26 -4
- package/dist/collection/components/store/hello/localization.js +7 -6
- package/dist/collection/components/store/zonosStore.js +5 -3
- package/dist/collection/components/stripe/zonos-address/zonos-address.js +1 -1
- package/dist/collection/components/stripe/zonos-link-authentication/zonos-link-authentication.js +3 -3
- package/dist/collection/components/stripe/zonos-payment/zonos-payment.js +3 -3
- package/dist/collection/components/utils/api/getLocaleMessages.js +2 -2
- 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 -3
- 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 +19 -14
- package/dist/collection/components/utils/logging/logError.js +2 -2
- 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 -34
- package/dist/collection/styles/stripe/addressRuleStyle.js +4 -0
- package/dist/collection/types/generated/graphql.customer.types.js +1 -4
- package/dist/collection/types/generated/graphql.frontend.types.js +3 -0
- package/dist/components/stripe.js +140 -98
- package/dist/components/trackConversionEvent.js +24 -0
- package/dist/components/zonos-address2.js +1 -1
- 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 +1 -6
- package/dist/components/zonos-checkbox2.js +3 -3
- package/dist/components/zonos-checkout-finish2.js +32 -12
- package/dist/components/zonos-checkout-payment2.js +1 -1
- package/dist/components/zonos-checkout.js +158 -20
- package/dist/components/zonos-collapse2.js +13 -6
- package/dist/components/zonos-component.js +1 -1
- package/dist/components/zonos-controller.js +25 -6
- 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 +3 -1
- package/dist/components/zonos-dialog2.js +3 -3
- package/dist/components/zonos-hello-dialog-footer2.js +2 -2
- package/dist/components/zonos-hello-dialog2.js +6 -5
- package/dist/components/zonos-hello.js +24 -9
- package/dist/components/zonos-language-select2.js +3 -3
- package/dist/components/zonos-link-authentication2.js +3 -4
- 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 +3 -4
- package/dist/components/zonos-review2.js +1 -6
- 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 -2
- package/dist/components/zonos-tooltip2.js +2 -2
- package/dist/components/zonos-v-stack2.js +2 -2
- package/dist/components/zonosStore.js +5 -3
- package/dist/esm/{cart-2a0a6871.js → cart-e261efc1.js} +143 -101
- package/dist/esm/formatStringWithLinks-9e819405.js +15 -0
- package/dist/esm/{getBorderRadius-0c7dfcf0.js → getBorderRadius-19787feb.js} +1 -1
- package/dist/esm/{isDarkColor-d0a57fd2.js → isDarkColor-2344e7a5.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/submitGtag-dfc6f1dc.js +51 -0
- package/dist/esm/zonos-address_4.entry.js +21 -16
- 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 -8
- package/dist/esm/zonos-cart-items_9.entry.js +35 -33
- package/dist/esm/zonos-checkout.entry.js +159 -23
- 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 -4
- package/dist/esm/zonos-country-select_3.entry.js +19 -11
- package/dist/esm/zonos-elements.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +9 -7
- package/dist/esm/zonos-hello.entry.js +25 -11
- 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 +6 -7
- 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-dec6bd7e.js → zonosStore-00bce01b.js} +5 -3
- package/dist/esm-es5/{cart-2a0a6871.js → cart-e261efc1.js} +1 -1
- package/dist/esm-es5/formatStringWithLinks-9e819405.js +1 -0
- package/dist/esm-es5/{getBorderRadius-0c7dfcf0.js → getBorderRadius-19787feb.js} +1 -1
- package/dist/esm-es5/{isDarkColor-d0a57fd2.js → isDarkColor-2344e7a5.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/submitGtag-dfc6f1dc.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-dec6bd7e.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 +22 -1
- package/dist/types/components/store/hello/localization.d.ts +2 -3
- package/dist/types/components/store/zonosStore.d.ts +1 -0
- 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/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/checkout/CheckoutConfig.d.ts +1 -1
- package/dist/types/types/generated/graphql.customer.types.d.ts +8 -53
- package/dist/types/types/generated/graphql.customer.types.ts +18 -62
- package/dist/types/types/generated/graphql.frontend.types.d.ts +8 -0
- package/dist/types/types/generated/graphql.frontend.types.ts +18 -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-dfd3edcf.entry.js → p-0c91720b.entry.js} +1 -1
- package/dist/zonos-elements/p-1119dddf.system.entry.js +1 -0
- package/dist/zonos-elements/p-127b480c.entry.js +1 -0
- package/dist/zonos-elements/{p-e855966f.system.entry.js → p-143dc0d9.system.entry.js} +1 -1
- package/dist/zonos-elements/p-14c3ef38.entry.js +1 -0
- package/dist/zonos-elements/{p-55970b10.system.entry.js → p-14d27ce1.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-7d1d862f.system.entry.js → p-165d469e.system.entry.js} +1 -1
- package/dist/zonos-elements/p-17e87be1.entry.js +1 -0
- package/dist/zonos-elements/{p-a95c034c.entry.js → p-1e0dd491.entry.js} +1 -1
- package/dist/zonos-elements/{p-34efed1d.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-79b910bf.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-1f85a98c.system.entry.js → p-389599d3.system.entry.js} +1 -1
- package/dist/zonos-elements/p-3a1e685f.entry.js +1 -0
- package/dist/zonos-elements/{p-a219689f.entry.js → p-3b23e462.entry.js} +1 -1
- package/dist/zonos-elements/{p-591eb6dd.system.js → p-49f6a985.system.js} +1 -1
- package/dist/zonos-elements/p-4fb77a38.system.entry.js +1 -0
- package/dist/zonos-elements/{p-5b44abc8.system.js → p-5496951a.system.js} +1 -1
- package/dist/zonos-elements/{p-06652d87.system.entry.js → p-58e2f6a1.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-cc63a29f.system.entry.js → p-5c176b23.system.entry.js} +1 -1
- package/dist/zonos-elements/p-5d9a000a.system.entry.js +1 -0
- package/dist/zonos-elements/p-5f4ba44c.entry.js +1 -0
- package/dist/zonos-elements/{p-88a55076.system.entry.js → p-61e5cf29.system.entry.js} +1 -1
- package/dist/zonos-elements/p-69e2c59e.entry.js +1 -0
- package/dist/zonos-elements/p-745cd869.system.entry.js +1 -0
- package/dist/zonos-elements/p-78ba2928.system.js +1 -0
- package/dist/zonos-elements/{p-67737613.system.entry.js → p-799d8a17.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-375c472a.system.entry.js → p-79b24786.system.entry.js} +1 -1
- package/dist/zonos-elements/p-7b87b82f.js +1 -0
- package/dist/zonos-elements/{p-e2770968.system.entry.js → p-7c45ce37.system.entry.js} +1 -1
- package/dist/zonos-elements/p-7f4f45b3.entry.js +1 -0
- package/dist/zonos-elements/{p-2d2e1831.entry.js → p-857cfe35.entry.js} +1 -1
- package/dist/zonos-elements/{p-ec4d08b3.system.js → p-91797d4e.system.js} +1 -1
- package/dist/zonos-elements/{p-34c03be2.js → p-95e0fc06.js} +1 -1
- package/dist/zonos-elements/p-9e6b489d.system.entry.js +1 -0
- package/dist/zonos-elements/p-9f4e02a1.entry.js +1 -0
- package/dist/zonos-elements/{p-afe40057.entry.js → p-a3cc0f84.entry.js} +1 -1
- package/dist/zonos-elements/p-a87561b8.js +1 -0
- package/dist/zonos-elements/{p-e161a08c.entry.js → p-ac0a7b8f.entry.js} +1 -1
- package/dist/zonos-elements/{p-549c181b.system.js → p-b4725505.system.js} +1 -1
- package/dist/zonos-elements/p-c060d475.js +1 -0
- package/dist/zonos-elements/p-c2e58ee1.system.entry.js +1 -0
- package/dist/zonos-elements/{p-9878a770.js → p-da767f8b.js} +1 -1
- package/dist/zonos-elements/p-dd9e8589.entry.js +1 -0
- package/dist/zonos-elements/p-f11a3d9e.entry.js +1 -0
- package/dist/zonos-elements/{p-8aeb4679.system.entry.js → p-f6eaef7b.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-c7098c3b.entry.js → p-f7c36fcc.entry.js} +1 -1
- 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/submitGtag-907e71d3.js +0 -21
- package/dist/collection/scripts/extractZonosQaUrl.js +0 -26
- package/dist/esm/submitGtag-a38aed23.js +0 -19
- package/dist/esm-es5/submitGtag-a38aed23.js +0 -1
- package/dist/types/scripts/extractZonosQaUrl.d.ts +0 -11
- package/dist/zonos-elements/p-0057e374.entry.js +0 -1
- package/dist/zonos-elements/p-0c72fb79.system.entry.js +0 -1
- package/dist/zonos-elements/p-290c3670.entry.js +0 -1
- package/dist/zonos-elements/p-2f1e1cbb.system.entry.js +0 -1
- package/dist/zonos-elements/p-33080cde.system.entry.js +0 -1
- package/dist/zonos-elements/p-561e44d6.entry.js +0 -1
- package/dist/zonos-elements/p-5c4dc123.js +0 -1
- package/dist/zonos-elements/p-656c836b.entry.js +0 -1
- package/dist/zonos-elements/p-8d645a00.entry.js +0 -1
- package/dist/zonos-elements/p-a3d72a33.entry.js +0 -1
- package/dist/zonos-elements/p-a93c594f.entry.js +0 -1
- package/dist/zonos-elements/p-b10ff468.entry.js +0 -1
- package/dist/zonos-elements/p-b6992dc2.system.entry.js +0 -1
- package/dist/zonos-elements/p-bce46c41.js +0 -1
- package/dist/zonos-elements/p-c56d4a44.entry.js +0 -1
- package/dist/zonos-elements/p-cbb1e700.system.js +0 -1
- package/dist/zonos-elements/p-cd8bd5e9.system.entry.js +0 -1
- package/dist/zonos-elements/p-d36faf87.system.entry.js +0 -1
- package/dist/zonos-elements/p-e2c6ad57.entry.js +0 -1
- package/dist/zonos-elements/p-ea93943a.system.entry.js +0 -1
- package/dist/zonos-elements/p-f455e08c.js +0 -1
|
@@ -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,21 @@ 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
|
-
|
|
29
|
-
console.warn(message, ...additionalInfo);
|
|
35
|
+
zConsole.warn(message, ...additionalInfo);
|
|
30
36
|
break;
|
|
31
37
|
case 'info':
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
zConsole.info(message, ...additionalInfo);
|
|
39
|
+
break;
|
|
40
|
+
case 'error':
|
|
41
|
+
zConsole.error(message, ...additionalInfo);
|
|
34
42
|
break;
|
|
35
43
|
default:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
console.trace();
|
|
40
|
-
// eslint-disable-next-line no-console
|
|
41
|
-
console.groupEnd();
|
|
44
|
+
zConsole.groupCollapsed(message, ...additionalInfo);
|
|
45
|
+
zConsole.trace();
|
|
46
|
+
zConsole.groupEnd();
|
|
42
47
|
break;
|
|
43
48
|
}
|
|
44
49
|
};
|
|
@@ -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
|
+
};
|
|
@@ -1,39 +1,22 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
import { log } from "../components/utils/logging/log";
|
|
3
3
|
import { logError } from "../components/utils/logging/logError";
|
|
4
|
-
import {
|
|
4
|
+
import { checkIfLoadVersionDomain } from "./checkIfLoadVersionDomain";
|
|
5
5
|
import { zonosLoadStripe } from "./loadStripe";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line no-console
|
|
14
|
-
console.warn(`[ZONOS-WARNING] using '${fullUrl}' for loading script`);
|
|
15
|
-
// request to the url and check if the request has an error
|
|
16
|
-
void fetch(fullUrl)
|
|
17
|
-
.then(() => {
|
|
18
|
-
// cleanup checkout session to avoid using the prod session in preview domain
|
|
19
|
-
window.sessionStorage.removeItem('zonos--checkout-session-id');
|
|
20
|
-
window.sessionStorage.removeItem('zonos--client-secret');
|
|
21
|
-
})
|
|
22
|
-
.catch(() => {
|
|
23
|
-
// eslint-disable-next-line no-console
|
|
24
|
-
alert(`[ZONOS-WARNING] '${fullUrl}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);
|
|
25
|
-
// remove the zonosQaUrl param from url
|
|
26
|
-
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
27
|
-
urlSearchParams.delete('zonosQaUrl');
|
|
28
|
-
const { pathname } = window.location;
|
|
29
|
-
const newUrl = `${pathname}?${urlSearchParams.toString()}`;
|
|
30
|
-
window.history.replaceState({}, '', newUrl);
|
|
31
|
-
window.location.reload();
|
|
32
|
-
return null;
|
|
6
|
+
/**
|
|
7
|
+
* Get the load version and url based on the loadScriptSrc, if the domain that used to load `zonos.js` is in white listed domains, use currentLoadScriptUrl as the load url instead, if zonosQaUrl exists, it would also fall under the white listed domain
|
|
8
|
+
*/
|
|
9
|
+
const zonosLoadUrl = (() => {
|
|
10
|
+
const scriptExist = document.querySelector(`script[src*="/zonos.js"]`);
|
|
11
|
+
const { currentLoadScriptUrl, isWhiteListed } = checkIfLoadVersionDomain({
|
|
12
|
+
loadScriptSrc: scriptExist === null || scriptExist === void 0 ? void 0 : scriptExist.src,
|
|
33
13
|
});
|
|
34
|
-
|
|
14
|
+
if (isWhiteListed) {
|
|
15
|
+
return currentLoadScriptUrl;
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
35
18
|
})();
|
|
36
|
-
const ZONOS_URL =
|
|
19
|
+
const ZONOS_URL = zonosLoadUrl || process.env.NEXT_PUBLIC_ZONOS_CDN_URL;
|
|
37
20
|
const UNPKG_ZONOS_URL = process.env.NEXT_PUBLIC_ZONOS_UNPKG_CDN_URL;
|
|
38
21
|
const INTER_FONT_URL = 'https://rsms.me';
|
|
39
22
|
const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
|
|
@@ -46,7 +29,7 @@ Zonos.doneInit = false;
|
|
|
46
29
|
Zonos.debug = !!window.location.search.match(/\?.*(&*)zonosDebug=1/);
|
|
47
30
|
Zonos.isBigCommerce = false;
|
|
48
31
|
Zonos.internationalHideSelector = '';
|
|
49
|
-
Zonos.zonosQaUrl =
|
|
32
|
+
Zonos.zonosQaUrl = null;
|
|
50
33
|
Zonos.version = `v${process.env.NEXT_PUBLIC_ZONOS_PACKAGE_VERSION}`;
|
|
51
34
|
Zonos.modeAlerted = false;
|
|
52
35
|
Zonos.getCurrentTimestamp = () => new Date().getTime();
|
|
@@ -90,6 +73,13 @@ Zonos.displayCurrency = () => {
|
|
|
90
73
|
void zonosHello.displayCurrency();
|
|
91
74
|
}
|
|
92
75
|
};
|
|
76
|
+
// Called openHelloDialog because the main use case is to simply open the dialog
|
|
77
|
+
Zonos.openHelloDialog = (value) => {
|
|
78
|
+
const zonosHello = document.querySelector('zonos-hello');
|
|
79
|
+
if (zonosHello) {
|
|
80
|
+
void zonosHello.openHelloDialog(value !== null && value !== void 0 ? value : true);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
93
83
|
Zonos.showNotification = (notification) => {
|
|
94
84
|
var _b;
|
|
95
85
|
void ((_b = _a.zonosController) === null || _b === void 0 ? void 0 : _b.showNotification(notification));
|
|
@@ -190,7 +180,6 @@ Zonos.injectSentryScript = () => {
|
|
|
190
180
|
return !!script;
|
|
191
181
|
};
|
|
192
182
|
if (findScript()) {
|
|
193
|
-
// eslint-disable-next-line no-console
|
|
194
183
|
log('Sentry script already exists in the document', 'warn');
|
|
195
184
|
return;
|
|
196
185
|
}
|
|
@@ -223,7 +212,6 @@ Zonos.injectScript = ({ fallBackDomain, isModule, scriptDomain, theRestUrl, }) =
|
|
|
223
212
|
return !!script;
|
|
224
213
|
};
|
|
225
214
|
if (findScript()) {
|
|
226
|
-
// eslint-disable-next-line no-console
|
|
227
215
|
log(`Zonos script "${fullScriptUrl}" already exists in the document`, 'warn');
|
|
228
216
|
return;
|
|
229
217
|
}
|
|
@@ -273,7 +261,6 @@ Zonos.injectZonosCdn = () => {
|
|
|
273
261
|
scriptDomain: ZONOS_URL,
|
|
274
262
|
theRestUrl: 'dist/zonos-elements/zonos-elements.js',
|
|
275
263
|
});
|
|
276
|
-
// eslint-disable-next-line no-console
|
|
277
264
|
log('Zonos cdn script injected!');
|
|
278
265
|
};
|
|
279
266
|
Zonos.injectStylesheet = ({ fallBackDomain, stylesheetDomain, theRestUrl, }) => {
|
|
@@ -3,6 +3,7 @@ export const addressRuleStyle = ({ theme, }) => {
|
|
|
3
3
|
default:
|
|
4
4
|
return {
|
|
5
5
|
'.Input': {
|
|
6
|
+
boxShadow: 'none',
|
|
6
7
|
// need to reset everything and the paddingTop to default, otherwise the paddingTop will not be updated.
|
|
7
8
|
padding: '0',
|
|
8
9
|
paddingBottom: '8px',
|
|
@@ -11,6 +12,9 @@ export const addressRuleStyle = ({ theme, }) => {
|
|
|
11
12
|
// any value here will be add up to the default paddingTop (20px).
|
|
12
13
|
paddingTop: '6px',
|
|
13
14
|
},
|
|
15
|
+
'.Input:focus': {
|
|
16
|
+
boxShadow: 'none',
|
|
17
|
+
},
|
|
14
18
|
};
|
|
15
19
|
}
|
|
16
20
|
};
|
|
@@ -1014,6 +1014,7 @@ export const emailTemplateStatus = {
|
|
|
1014
1014
|
};
|
|
1015
1015
|
export const emailTemplateType = {
|
|
1016
1016
|
AbandonedCart: 'ABANDONED_CART',
|
|
1017
|
+
CatalogExport: 'CATALOG_EXPORT',
|
|
1017
1018
|
OrderCanceled: 'ORDER_CANCELED',
|
|
1018
1019
|
OrderConfirmation: 'ORDER_CONFIRMATION',
|
|
1019
1020
|
OrderReceipt: 'ORDER_RECEIPT',
|
|
@@ -1209,10 +1210,6 @@ export const invoiceLanguageCode = {
|
|
|
1209
1210
|
ZhHk: 'ZH_HK',
|
|
1210
1211
|
ZhTw: 'ZH_TW',
|
|
1211
1212
|
};
|
|
1212
|
-
export const invoiceLineRecordBehaviorCode = {
|
|
1213
|
-
Finalize: 'FINALIZE',
|
|
1214
|
-
Pending: 'PENDING',
|
|
1215
|
-
};
|
|
1216
1213
|
export const invoiceLineRecordStatusCode = {
|
|
1217
1214
|
Failed: 'FAILED',
|
|
1218
1215
|
Pending: 'PENDING',
|
|
@@ -474,6 +474,9 @@ export function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
474
474
|
cleanupTestZonosElementSetting(variables, requestHeaders) {
|
|
475
475
|
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'cleanupTestZonosElementSetting', 'mutation');
|
|
476
476
|
},
|
|
477
|
+
insertConversionEvent(variables, requestHeaders) {
|
|
478
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'insertConversionEvent', 'mutation');
|
|
479
|
+
},
|
|
477
480
|
zonosElementsSetting(variables, requestHeaders) {
|
|
478
481
|
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'zonosElementsSetting', 'query');
|
|
479
482
|
},
|
|
@@ -3546,7 +3546,7 @@ const handleFetch = async (url, _opts) => {
|
|
|
3546
3546
|
const modifiedUrl = new URL(url);
|
|
3547
3547
|
modifiedUrl.searchParams.set('zToken', encodeString(window.location.hostname));
|
|
3548
3548
|
// headers content type
|
|
3549
|
-
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);
|
|
3549
|
+
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);
|
|
3550
3550
|
const options = Object.assign(Object.assign({}, opts), { body: method === 'GET' ? undefined : body, headers,
|
|
3551
3551
|
method });
|
|
3552
3552
|
return handleRequest(modifiedUrl.toString(), options);
|
|
@@ -3567,9 +3567,58 @@ const getCountries = async () => {
|
|
|
3567
3567
|
}
|
|
3568
3568
|
};
|
|
3569
3569
|
|
|
3570
|
+
const log = (message, type, ...additionalInfo) => {
|
|
3571
|
+
var _a, _b;
|
|
3572
|
+
const isDebug = !!((_a = window.Zonos) === null || _a === void 0 ? void 0 : _a.debug) ||
|
|
3573
|
+
!!window.location.search.match(/\?.*(&*)zonosDebug=1/);
|
|
3574
|
+
// if debug is false, do not log
|
|
3575
|
+
if (!isDebug) {
|
|
3576
|
+
// log errors to the console if the type is error
|
|
3577
|
+
if (type === 'error') {
|
|
3578
|
+
// eslint-disable-next-line no-console
|
|
3579
|
+
console.error(message, ...additionalInfo);
|
|
3580
|
+
}
|
|
3581
|
+
return;
|
|
3582
|
+
}
|
|
3583
|
+
let loggingIframe = document.querySelector('iframe#zonos---debug-logging-iframe');
|
|
3584
|
+
if (!loggingIframe) {
|
|
3585
|
+
// add a hidden iframe
|
|
3586
|
+
loggingIframe = document.createElement('iframe');
|
|
3587
|
+
loggingIframe.id = 'zonos---debug-logging-iframe';
|
|
3588
|
+
loggingIframe.style.display = 'none';
|
|
3589
|
+
loggingIframe.style.opacity = '0';
|
|
3590
|
+
loggingIframe.style.position = 'absolute';
|
|
3591
|
+
loggingIframe.style.top = '-9999px';
|
|
3592
|
+
loggingIframe.style.left = '-9999px';
|
|
3593
|
+
loggingIframe.style.width = '1px';
|
|
3594
|
+
loggingIframe.style.height = '1px';
|
|
3595
|
+
loggingIframe.style.border = 'none';
|
|
3596
|
+
loggingIframe.style.overflow = 'hidden';
|
|
3597
|
+
loggingIframe.style.visibility = 'hidden';
|
|
3598
|
+
document.body.appendChild(loggingIframe);
|
|
3599
|
+
}
|
|
3600
|
+
// use the logging iframe's console to log just in case the console is disabled (overriden) by the site owner
|
|
3601
|
+
const zConsole = ((_b = loggingIframe.contentWindow) === null || _b === void 0 ? void 0 : _b.window.console) || window.console;
|
|
3602
|
+
switch (type) {
|
|
3603
|
+
case 'warn':
|
|
3604
|
+
zConsole.warn(message, ...additionalInfo);
|
|
3605
|
+
break;
|
|
3606
|
+
case 'info':
|
|
3607
|
+
zConsole.info(message, ...additionalInfo);
|
|
3608
|
+
break;
|
|
3609
|
+
case 'error':
|
|
3610
|
+
zConsole.error(message, ...additionalInfo);
|
|
3611
|
+
break;
|
|
3612
|
+
default:
|
|
3613
|
+
zConsole.groupCollapsed(message, ...additionalInfo);
|
|
3614
|
+
zConsole.trace();
|
|
3615
|
+
zConsole.groupEnd();
|
|
3616
|
+
break;
|
|
3617
|
+
}
|
|
3618
|
+
};
|
|
3619
|
+
|
|
3570
3620
|
const logError = (message, ...rest) => {
|
|
3571
|
-
|
|
3572
|
-
console.error(message, ...rest);
|
|
3621
|
+
log(message, 'error', ...rest);
|
|
3573
3622
|
};
|
|
3574
3623
|
|
|
3575
3624
|
const getCountryLandedCost = async (countryCode) => {
|
|
@@ -3612,8 +3661,7 @@ const getLocaleMessages = async ({ countryCode, localeTo, storeId, }) => {
|
|
|
3612
3661
|
const url = `${"https://v1.route.js.zonos.com"}/api/zonos-elements/locale-messages?countryCode=${countryCode}&storeId=${storeId}&localeTo=${localeTo}`;
|
|
3613
3662
|
const { errors, json } = await handleFetch(url);
|
|
3614
3663
|
if (errors.length || !json) {
|
|
3615
|
-
|
|
3616
|
-
console.error('Error fetching exchange rate', (_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message);
|
|
3664
|
+
logError('Error fetching exchange rate', (_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message);
|
|
3617
3665
|
return [];
|
|
3618
3666
|
}
|
|
3619
3667
|
return json.locale_countryCodesPage;
|
|
@@ -3731,76 +3779,32 @@ const isValidSelector = (selector) => {
|
|
|
3731
3779
|
return true;
|
|
3732
3780
|
};
|
|
3733
3781
|
|
|
3734
|
-
const log = (message, type, ...additionalInfo) => {
|
|
3735
|
-
var _a;
|
|
3736
|
-
// if type is error and debug is false, do not log
|
|
3737
|
-
if (!window.Zonos.debug) {
|
|
3738
|
-
return;
|
|
3739
|
-
}
|
|
3740
|
-
let loggingIframe = document.querySelector('iframe#zonos---debug-logging-iframe');
|
|
3741
|
-
if (!loggingIframe) {
|
|
3742
|
-
// add a hidden iframe
|
|
3743
|
-
loggingIframe = document.createElement('iframe');
|
|
3744
|
-
loggingIframe.id = 'zonos---debug-logging-iframe';
|
|
3745
|
-
loggingIframe.style.display = 'none';
|
|
3746
|
-
loggingIframe.style.opacity = '0';
|
|
3747
|
-
loggingIframe.style.position = 'absolute';
|
|
3748
|
-
loggingIframe.style.top = '-9999px';
|
|
3749
|
-
loggingIframe.style.left = '-9999px';
|
|
3750
|
-
loggingIframe.style.width = '1px';
|
|
3751
|
-
loggingIframe.style.height = '1px';
|
|
3752
|
-
loggingIframe.style.border = 'none';
|
|
3753
|
-
loggingIframe.style.overflow = 'hidden';
|
|
3754
|
-
loggingIframe.style.visibility = 'hidden';
|
|
3755
|
-
document.body.appendChild(loggingIframe);
|
|
3756
|
-
}
|
|
3757
|
-
// use the logging iframe's console to log just in case the console is disabled (overriden) by the site owner
|
|
3758
|
-
const console = ((_a = loggingIframe.contentWindow) === null || _a === void 0 ? void 0 : _a.window.console) || window.console;
|
|
3759
|
-
switch (type) {
|
|
3760
|
-
case 'warn':
|
|
3761
|
-
// eslint-disable-next-line no-console
|
|
3762
|
-
console.warn(message, ...additionalInfo);
|
|
3763
|
-
break;
|
|
3764
|
-
case 'info':
|
|
3765
|
-
// eslint-disable-next-line no-console
|
|
3766
|
-
console.info(message, ...additionalInfo);
|
|
3767
|
-
break;
|
|
3768
|
-
default:
|
|
3769
|
-
// eslint-disable-next-line no-console
|
|
3770
|
-
console.groupCollapsed(message, ...additionalInfo);
|
|
3771
|
-
// eslint-disable-next-line no-console
|
|
3772
|
-
console.trace();
|
|
3773
|
-
// eslint-disable-next-line no-console
|
|
3774
|
-
console.groupEnd();
|
|
3775
|
-
break;
|
|
3776
|
-
}
|
|
3777
|
-
};
|
|
3778
|
-
|
|
3779
3782
|
const getCurrencyElements = (selector) => {
|
|
3780
3783
|
const currencySelector = selector || '.money';
|
|
3781
3784
|
if (!isValidSelector(currencySelector)) {
|
|
3782
|
-
// eslint-disable-next-line no-console
|
|
3783
3785
|
logError(`Currency element selector "${currencySelector}" is not valid.`);
|
|
3784
3786
|
return null;
|
|
3785
3787
|
}
|
|
3786
3788
|
const currencyElements = document.querySelectorAll(currencySelector);
|
|
3787
3789
|
if (!currencyElements.length) {
|
|
3788
|
-
// eslint-disable-next-line no-console
|
|
3789
3790
|
log(`No currency elements found with selector "${currencySelector}"`, 'warn');
|
|
3790
3791
|
return null;
|
|
3791
3792
|
}
|
|
3792
|
-
return
|
|
3793
|
+
// return array of currency elements instead of a NodeList
|
|
3794
|
+
return Array.from(currencyElements);
|
|
3793
3795
|
};
|
|
3794
3796
|
|
|
3795
3797
|
const getInitialElementAmount = (element) => {
|
|
3796
3798
|
var _a;
|
|
3797
3799
|
const domesticValue = element.getAttribute('data-domestic');
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3800
|
+
const intlValue = element.getAttribute('data-zintl');
|
|
3801
|
+
// Only keep numbers, decimal, and hyphens
|
|
3802
|
+
const cleanedText = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.replace(/[^\d.-]/g, '');
|
|
3803
|
+
if (!cleanedText) {
|
|
3804
|
+
return null;
|
|
3805
|
+
}
|
|
3806
|
+
// If the element has no data-domestic attribute, or the text content is different from the data-zintl attribute, set the data-domestic attribute
|
|
3807
|
+
if (!domesticValue || element.textContent !== intlValue) {
|
|
3804
3808
|
// Store the original value on the element once, and international on every new conversion
|
|
3805
3809
|
element.setAttribute('data-domestic', cleanedText);
|
|
3806
3810
|
return parseFloat(cleanedText);
|
|
@@ -3808,9 +3812,32 @@ const getInitialElementAmount = (element) => {
|
|
|
3808
3812
|
return parseFloat(domesticValue);
|
|
3809
3813
|
};
|
|
3810
3814
|
|
|
3815
|
+
const convertCurrency = (element) => {
|
|
3816
|
+
var _a;
|
|
3817
|
+
const amount = getInitialElementAmount(element);
|
|
3818
|
+
if (!amount || isNaN(amount)) {
|
|
3819
|
+
return;
|
|
3820
|
+
}
|
|
3821
|
+
const currentIntlValue = element.getAttribute('data-zintl');
|
|
3822
|
+
const currentCountryValue = element.getAttribute('data-zcountry-code');
|
|
3823
|
+
// do nothing if the target currency is the same
|
|
3824
|
+
const isExchangeRateReady = localizationStore.targetCurrency ===
|
|
3825
|
+
((_a = localizationStore.exchangeRate) === null || _a === void 0 ? void 0 : _a.targetFormat.currencyCode);
|
|
3826
|
+
// if the current value on the element is different from the current intl value, update the data-zintl attribute
|
|
3827
|
+
if (isExchangeRateReady &&
|
|
3828
|
+
(element.textContent !== currentIntlValue ||
|
|
3829
|
+
currentCountryValue !== localizationStore.selectedCountryCode)) {
|
|
3830
|
+
const observedFormattedValue = currencyConvertAndFormat(amount);
|
|
3831
|
+
element.textContent = observedFormattedValue;
|
|
3832
|
+
// save the new value to the data-zintl attribute
|
|
3833
|
+
element.setAttribute('data-zintl', observedFormattedValue);
|
|
3834
|
+
element.setAttribute('data-zcountry-code', localizationStore.selectedCountryCode || '');
|
|
3835
|
+
}
|
|
3836
|
+
};
|
|
3811
3837
|
const defaultCurrencyConverter = () => {
|
|
3812
3838
|
const { currencyElementSelector } = zonosStore.helloSettings;
|
|
3813
3839
|
const currencyElements = getCurrencyElements(currencyElementSelector);
|
|
3840
|
+
// do nothing if none of the currency elements are found
|
|
3814
3841
|
if (!(currencyElements === null || currencyElements === void 0 ? void 0 : currencyElements.length)) {
|
|
3815
3842
|
return;
|
|
3816
3843
|
}
|
|
@@ -3819,33 +3846,8 @@ const defaultCurrencyConverter = () => {
|
|
|
3819
3846
|
return;
|
|
3820
3847
|
}
|
|
3821
3848
|
currencyElements.forEach((element) => {
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
return;
|
|
3825
|
-
}
|
|
3826
|
-
element.setAttribute('data-zintl', currencyConvert(amount).toString());
|
|
3827
|
-
// Check if an observer is already attached to the element
|
|
3828
|
-
let observer = element._mutationObserver;
|
|
3829
|
-
if (!observer) {
|
|
3830
|
-
observer = new MutationObserver(() => {
|
|
3831
|
-
const observedFormattedValue = currencyConvertAndFormat(amount);
|
|
3832
|
-
element.textContent = observedFormattedValue;
|
|
3833
|
-
});
|
|
3834
|
-
observer.observe(element, {
|
|
3835
|
-
characterData: true,
|
|
3836
|
-
childList: true,
|
|
3837
|
-
});
|
|
3838
|
-
element._mutationObserver = observer;
|
|
3839
|
-
}
|
|
3840
|
-
// Temporarily disconnect the observer to prevent an infinite loop
|
|
3841
|
-
observer.disconnect();
|
|
3842
|
-
const formattedValue = currencyConvertAndFormat(amount);
|
|
3843
|
-
element.textContent = formattedValue;
|
|
3844
|
-
// Reconnect the observer after the update is complete
|
|
3845
|
-
observer.observe(element, {
|
|
3846
|
-
characterData: true,
|
|
3847
|
-
childList: true,
|
|
3848
|
-
});
|
|
3849
|
+
// convert the currency and save the formatted value to the data-zintl attribute
|
|
3850
|
+
convertCurrency(element);
|
|
3849
3851
|
});
|
|
3850
3852
|
};
|
|
3851
3853
|
|
|
@@ -3927,11 +3929,9 @@ const getNewLocalization = async () => {
|
|
|
3927
3929
|
!selectedCountryCode) {
|
|
3928
3930
|
return;
|
|
3929
3931
|
}
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
startExchangeRateTimeout({ isGuaranteed, maxAge });
|
|
3934
|
-
}
|
|
3932
|
+
const isGuaranteed = zonosStore.checkoutSettings.visibilityStatus === 'ENABLED';
|
|
3933
|
+
const { maxAge } = await triggerGetExchangeRate(isGuaranteed);
|
|
3934
|
+
startExchangeRateTimeout({ isGuaranteed, maxAge });
|
|
3935
3935
|
localizationStore.countryLandedCost = await getCountryLandedCost(localizationStore.selectedCountryCode);
|
|
3936
3936
|
};
|
|
3937
3937
|
const getCustomMessages = async () => {
|
|
@@ -3958,7 +3958,8 @@ const getOverrideLocale = () => {
|
|
|
3958
3958
|
const zonosLocale = currentUrl.searchParams.get('zonosLocale');
|
|
3959
3959
|
return zonosLocale;
|
|
3960
3960
|
};
|
|
3961
|
-
const localizationStoreUpdateSelectedCountryCode =
|
|
3961
|
+
const localizationStoreUpdateSelectedCountryCode = (newSelectedCountryCode) => {
|
|
3962
|
+
var _a;
|
|
3962
3963
|
log('update selected country code');
|
|
3963
3964
|
localizationStore.selectedCountryCode = newSelectedCountryCode;
|
|
3964
3965
|
const { selectedCountryCode, shippingZoneCountries } = localizationStore;
|
|
@@ -3982,6 +3983,8 @@ const localizationStoreUpdateSelectedCountryCode = async (newSelectedCountryCode
|
|
|
3982
3983
|
window.sessionStorage.setItem('zonos--country', selectedCountryCode);
|
|
3983
3984
|
// Update the URL query param with the new country code
|
|
3984
3985
|
setZCountryUrlParam(selectedCountryCode);
|
|
3986
|
+
(_a = document
|
|
3987
|
+
.querySelector('zonos-hello')) === null || _a === void 0 ? void 0 : _a.setAttribute('z-country', selectedCountryCode);
|
|
3985
3988
|
};
|
|
3986
3989
|
const initLocalizationStore = async () => {
|
|
3987
3990
|
// all countries from countries.json, shipping zone and localization
|
|
@@ -4129,14 +4132,14 @@ const cartStoreReCalculateTotal = async ({ currency, itemsAmount, landedCostId,
|
|
|
4129
4132
|
logError('Could not update cart total without checkout session id');
|
|
4130
4133
|
return false;
|
|
4131
4134
|
}
|
|
4132
|
-
const { json } = await stripeStoreUpdateCheckoutSession({
|
|
4135
|
+
const { errors, json } = await stripeStoreUpdateCheckoutSession({
|
|
4133
4136
|
currency,
|
|
4134
4137
|
id: cartStore.checkoutSessionId,
|
|
4135
4138
|
itemsAmount,
|
|
4136
4139
|
landedCostId,
|
|
4137
4140
|
presentmentCountryCode: localizationStore.selectedCountryCode,
|
|
4138
4141
|
});
|
|
4139
|
-
if (!json) {
|
|
4142
|
+
if (errors.length > 0 || !json) {
|
|
4140
4143
|
// do nothing if we can't get checkout session
|
|
4141
4144
|
logError('Error occurs when updating checkout session');
|
|
4142
4145
|
cartStoreUpdateToErrorState({
|
|
@@ -4346,11 +4349,26 @@ const calculateLandedCost = async (abortController) => {
|
|
|
4346
4349
|
return json;
|
|
4347
4350
|
};
|
|
4348
4351
|
|
|
4352
|
+
const jsonParse = (_data) => {
|
|
4353
|
+
if (typeof _data === 'string') {
|
|
4354
|
+
try {
|
|
4355
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
4356
|
+
const json = JSON.parse(_data);
|
|
4357
|
+
return json;
|
|
4358
|
+
}
|
|
4359
|
+
catch (_error) {
|
|
4360
|
+
return null;
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
return null;
|
|
4364
|
+
};
|
|
4365
|
+
|
|
4349
4366
|
const addressRuleStyle = ({ theme, }) => {
|
|
4350
4367
|
switch (theme) {
|
|
4351
4368
|
default:
|
|
4352
4369
|
return {
|
|
4353
4370
|
'.Input': {
|
|
4371
|
+
boxShadow: 'none',
|
|
4354
4372
|
// need to reset everything and the paddingTop to default, otherwise the paddingTop will not be updated.
|
|
4355
4373
|
padding: '0',
|
|
4356
4374
|
paddingBottom: '8px',
|
|
@@ -4359,6 +4377,9 @@ const addressRuleStyle = ({ theme, }) => {
|
|
|
4359
4377
|
// any value here will be add up to the default paddingTop (20px).
|
|
4360
4378
|
paddingTop: '6px',
|
|
4361
4379
|
},
|
|
4380
|
+
'.Input:focus': {
|
|
4381
|
+
boxShadow: 'none',
|
|
4382
|
+
},
|
|
4362
4383
|
};
|
|
4363
4384
|
}
|
|
4364
4385
|
};
|
|
@@ -4425,6 +4446,17 @@ const getStripeOptions = ({ clientSecret, overrideBorderRaidus, overridePrimaryC
|
|
|
4425
4446
|
locale: localizationStore.selectedLocale,
|
|
4426
4447
|
};
|
|
4427
4448
|
};
|
|
4449
|
+
const stripeStoreCleanupDomesticShippingSession = () => {
|
|
4450
|
+
window.sessionStorage.removeItem('zonos--bigcommerce-domestic-checkout-shipping');
|
|
4451
|
+
};
|
|
4452
|
+
// Save shipping address to session storage
|
|
4453
|
+
const stripeStoreSaveDomesticShippingSession = (props) => {
|
|
4454
|
+
window.sessionStorage.setItem('zonos--bigcommerce-domestic-checkout-shipping', JSON.stringify(props));
|
|
4455
|
+
};
|
|
4456
|
+
const stripeStoreGetDomesticShippingSession = () => {
|
|
4457
|
+
const session = window.sessionStorage.getItem('zonos--bigcommerce-domestic-checkout-shipping');
|
|
4458
|
+
return jsonParse(session);
|
|
4459
|
+
};
|
|
4428
4460
|
const initStripeElements = async (props) => {
|
|
4429
4461
|
var _a, _b;
|
|
4430
4462
|
const clientSecret = stripeStore.clientSecret;
|
|
@@ -4526,12 +4558,18 @@ const stripeStorePrefetchLandedCost = async () => {
|
|
|
4526
4558
|
try {
|
|
4527
4559
|
const abortController = new AbortController();
|
|
4528
4560
|
stripeStore.fetchingLandedCostAbordController = abortController;
|
|
4529
|
-
const { checkoutSessionWorkflow, shipmentRatingCalculateWorkflow } = await calculateLandedCost(abortController);
|
|
4561
|
+
const { checkoutSessionWorkflow, landedCostCalculateWorkflow, shipmentRatingCalculateWorkflow, } = await calculateLandedCost(abortController);
|
|
4530
4562
|
// reset abort controller after we are done
|
|
4531
4563
|
stripeStore.fetchingLandedCostAbordController = null;
|
|
4532
4564
|
// update cart store with landed cost info
|
|
4533
4565
|
cartStore.landedCostData =
|
|
4534
|
-
(checkoutSessionWorkflow === null || checkoutSessionWorkflow === void 0 ? void 0 : checkoutSessionWorkflow.
|
|
4566
|
+
(checkoutSessionWorkflow === null || checkoutSessionWorkflow === void 0 ? void 0 : checkoutSessionWorkflow.map(checkoutSession => {
|
|
4567
|
+
const foundLandedCost = landedCostCalculateWorkflow === null || landedCostCalculateWorkflow === void 0 ? void 0 : landedCostCalculateWorkflow.find(item => { var _a; return (item === null || item === void 0 ? void 0 : item.id) === ((_a = checkoutSession.landedCost) === null || _a === void 0 ? void 0 : _a.id); });
|
|
4568
|
+
if (!foundLandedCost) {
|
|
4569
|
+
return null;
|
|
4570
|
+
}
|
|
4571
|
+
return Object.assign(Object.assign({}, checkoutSession), { landedCost: foundLandedCost });
|
|
4572
|
+
}).filter(Boolean)) || null;
|
|
4535
4573
|
cartStore.shippingData =
|
|
4536
4574
|
(shipmentRatingCalculateWorkflow === null || shipmentRatingCalculateWorkflow === void 0 ? void 0 : shipmentRatingCalculateWorkflow.filter(Boolean)) || null;
|
|
4537
4575
|
// apply new subtotal and total, this is mainly to show items in the presentment currency
|
|
@@ -4616,7 +4654,11 @@ const stripeStoreRetrievePayment = async ({ clientSecret: _clientSecret, storybo
|
|
|
4616
4654
|
const { paymentIntent } = await stripeStore.stripe.retrievePaymentIntent(clientSecret);
|
|
4617
4655
|
const status = paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status;
|
|
4618
4656
|
const { isError, messages } = getStripeMessageBasedOnStatus(status);
|
|
4619
|
-
return {
|
|
4657
|
+
return {
|
|
4658
|
+
error: isError,
|
|
4659
|
+
messages,
|
|
4660
|
+
paymentMethod: paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.payment_method,
|
|
4661
|
+
};
|
|
4620
4662
|
};
|
|
4621
4663
|
const stripeStoreConfirmPayment = async () => {
|
|
4622
4664
|
var _a, _b, _c;
|
|
@@ -4717,4 +4759,4 @@ onChange('clientSecret', clientSecret => {
|
|
|
4717
4759
|
}
|
|
4718
4760
|
});
|
|
4719
4761
|
|
|
4720
|
-
export {
|
|
4762
|
+
export { initLocalizationStore as A, getZCountryUrlParam as B, setZCountryUrlParam as C, currencyDisplay as D, currencyConvertAndFormat as E, currencyConvert as F, currencyFormat as G, stripeStorePrefetchLandedCost as a, localizationStore as b, cartStore as c, log as d, stripeStoreGetDomesticShippingSession as e, localizationStoreUpdateSelectedCountryCode as f, stripeStoreCleanupDomesticShippingSession as g, stripeStoreSaveDomesticShippingSession as h, initStripeElements as i, cartStoreUpdateItems as j, cartStoreReset as k, logError as l, stripeStoreInitCheckoutSession as m, cartStoreUpdateToErrorState as n, cartStoreNextStep as o, stripeStoreConfirmPayment as p, stripeStoreReset as q, cartStorePreviousStep as r, stripeStore as s, translate as t, handleFetch as u, stripeStoreRetrievePayment as v, localizationStoreUpdateSelectedLocale as w, cartStoreUpdateSelectedShippingOption as x, cartStoreGetShippingTransitInfo as y, isValidSelector as z };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { u as handleFetch, b as localizationStore } from './stripe.js';
|
|
2
|
+
import { z as zonosStore } from './zonosStore.js';
|
|
3
|
+
|
|
4
|
+
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 = `${"https://v1.route.js.zonos.com"}/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
|
+
};
|
|
23
|
+
|
|
24
|
+
export { trackConversionEvent as t };
|