@zonos/elements 1.2.1 → 1.2.3
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-7b70853c.js → cart-55512e32.js} +12 -2
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/{localization-387a8a65.js → localization-d7fe7290.js} +40 -13
- package/dist/cjs/{submitGtag-bf6e7c5e.js → submitGtag-d65003f9.js} +1 -1
- package/dist/cjs/zonos-address_2.cjs.entry.js +7 -2
- package/dist/cjs/zonos-cart-items_10.cjs.entry.js +6 -7
- package/dist/cjs/zonos-checkout.cjs.entry.js +8 -4
- package/dist/cjs/zonos-controller.cjs.entry.js +49 -3
- package/dist/cjs/zonos-country-flag_4.cjs.entry.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +15 -7
- package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
- package/dist/cjs/zonos-payment.cjs.entry.js +2 -2
- package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +1 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.css +2 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +4 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +3 -5
- package/dist/collection/components/common/zonos-shipping-rich-radio/zonos-shipping-rich-radio.css +1 -0
- package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +15 -7
- package/dist/collection/components/main/zonos-controller.js +46 -0
- package/dist/collection/components/store/checkout/stripe.js +11 -1
- package/dist/collection/components/store/hello/localization.js +31 -9
- package/dist/collection/components/stripe/zonos-address/zonos-address.js +5 -0
- package/dist/collection/components/utils/api/getExchangeRate.js +9 -4
- package/dist/collection/components/utils/checkout/initCheckout.js +1 -1
- package/dist/collection/environment.js +22 -13
- package/dist/collection/scripts/zonos.js +84 -3
- package/dist/collection/utils/generateVercelDeployUrl.js +3 -2
- package/dist/components/cart.js +11 -1
- package/dist/components/localization.js +40 -13
- package/dist/components/zonos-address2.js +5 -0
- package/dist/components/zonos-checkout.js +5 -1
- package/dist/components/zonos-controller.js +47 -1
- package/dist/components/zonos-hello-dialog2.js +15 -7
- package/dist/components/zonos-shipping-rich-radio2.js +1 -1
- package/dist/components/zonos-shipping2.js +4 -5
- package/dist/esm/{cart-07091d2a.js → cart-17650017.js} +12 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/{localization-b3c2a9a9.js → localization-f3828793.js} +40 -13
- package/dist/esm/{submitGtag-c0b655ad.js → submitGtag-a901ece5.js} +1 -1
- package/dist/esm/zonos-address_2.entry.js +7 -2
- package/dist/esm/zonos-cart-items_10.entry.js +6 -7
- package/dist/esm/zonos-checkout.entry.js +8 -4
- package/dist/esm/zonos-controller.entry.js +49 -3
- package/dist/esm/zonos-country-flag_4.entry.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +15 -7
- package/dist/esm/zonos-hello.entry.js +1 -1
- package/dist/esm/zonos-payment.entry.js +2 -2
- package/dist/esm/zonos-shipping-rich-radio.entry.js +1 -1
- package/dist/esm-es5/cart-17650017.js +1 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{localization-b3c2a9a9.js → localization-f3828793.js} +1 -1
- package/dist/esm-es5/{submitGtag-c0b655ad.js → submitGtag-a901ece5.js} +1 -1
- package/dist/esm-es5/zonos-address_2.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_10.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag_4.entry.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-payment.entry.js +1 -1
- package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
- package/dist/scripts/loadZonos.js +86 -5
- package/dist/scripts/zonos.js +86 -5
- package/dist/types/components/main/zonos-controller.d.ts +1 -0
- package/dist/types/components/store/checkout/stripe.d.ts +2 -1
- package/dist/types/components/store/hello/localization.d.ts +2 -0
- package/dist/types/components/utils/api/getExchangeRate.d.ts +9 -3
- package/dist/types/components/utils/changeDeepProperty.d.ts +1 -1
- package/dist/types/components/utils/changeDeepPropertyAtIndex.d.ts +1 -1
- package/dist/types/components/utils/checkout/initCheckout.d.ts +1 -1
- package/dist/types/environment.d.ts +6 -1
- package/dist/types/scripts/zonos.d.ts +3 -0
- package/dist/types/types/generated/graphql.customer.types.d.ts +1 -0
- package/dist/types/types/generated/graphql.customer.types.ts +1 -0
- package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-0ed3bb9f.system.entry.js +1 -0
- package/dist/zonos-elements/{p-42ba069d.system.js → p-164fae93.system.js} +1 -1
- package/dist/zonos-elements/{p-9b86e655.system.entry.js → p-224125da.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9dc9cbc8.entry.js → p-28681677.entry.js} +1 -1
- package/dist/zonos-elements/p-3a56c240.entry.js +1 -0
- package/dist/zonos-elements/p-3f3fbcea.entry.js +1 -0
- package/dist/zonos-elements/{p-bb36a9f8.js → p-770c959e.js} +1 -1
- package/dist/zonos-elements/p-8378d94e.js +1 -0
- package/dist/zonos-elements/{p-37db3842.system.entry.js → p-84b00605.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-f23749e4.system.js → p-8aabbb9b.system.js} +1 -1
- package/dist/zonos-elements/p-8b415737.system.entry.js +1 -0
- package/dist/zonos-elements/{p-98105ede.entry.js → p-9202375f.entry.js} +1 -1
- package/dist/zonos-elements/p-a1fa50fb.entry.js +1 -0
- package/dist/zonos-elements/{p-a20b97e9.system.entry.js → p-aca66238.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-87f324c5.entry.js → p-bc2c42f5.entry.js} +1 -1
- package/dist/zonos-elements/{p-c28157ec.system.entry.js → p-c8ad044e.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-343071d5.entry.js → p-cc070c1c.entry.js} +1 -1
- package/dist/zonos-elements/{p-4524a84f.system.entry.js → p-cc1c785c.system.entry.js} +1 -1
- package/dist/zonos-elements/p-cd71e41e.entry.js +1 -0
- package/dist/zonos-elements/{p-0f7233fd.system.entry.js → p-cf97cc68.system.entry.js} +1 -1
- package/dist/zonos-elements/p-d6b8563b.system.entry.js +1 -0
- package/dist/zonos-elements/{p-96a3c767.entry.js → p-e5908de2.entry.js} +1 -1
- package/dist/zonos-elements/p-f6add79c.system.js +1 -0
- package/dist/zonos-elements/{p-6df1eaee.js → p-f7875c40.js} +1 -1
- package/dist/zonos-elements/p-f8491335.system.js +1 -1
- package/dist/zonos-elements/{p-b64bbf38.system.js → p-f95ac9ec.system.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +3 -3
- package/dist/esm-es5/cart-07091d2a.js +0 -1
- package/dist/zonos-elements/p-0a788f68.entry.js +0 -1
- package/dist/zonos-elements/p-23b0b4a2.system.entry.js +0 -1
- package/dist/zonos-elements/p-2c20c082.entry.js +0 -1
- package/dist/zonos-elements/p-30fd29fb.js +0 -1
- package/dist/zonos-elements/p-37fc9f6b.entry.js +0 -1
- package/dist/zonos-elements/p-79f9e330.system.js +0 -1
- package/dist/zonos-elements/p-914ce305.system.entry.js +0 -1
- package/dist/zonos-elements/p-9adf546f.system.entry.js +0 -1
- package/dist/zonos-elements/p-d43749bd.entry.js +0 -1
|
@@ -141,8 +141,43 @@ const zonosLoadStripe = async (...args) => {
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
var _a;
|
|
144
|
-
|
|
145
|
-
const
|
|
144
|
+
// 3 hours
|
|
145
|
+
const EXPIRED_QA_TIME = 3 * 60 * 60 * 1000;
|
|
146
|
+
// validate the time format (yyyymmddhhmmss) in the qa params if exceeds 1 hour, don't use qa
|
|
147
|
+
const isZonosQa = (() => {
|
|
148
|
+
const zonosQaTime = window.location.search.match(/\?.*(&*)zonosQa=(\d+)/);
|
|
149
|
+
if (!zonosQaTime) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
const [, , zonosQaTimeExtracted] = zonosQaTime;
|
|
153
|
+
if (!zonosQaTimeExtracted) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
const zonosQaTimeValue = parseInt(zonosQaTimeExtracted, 10);
|
|
157
|
+
const now = new Date();
|
|
158
|
+
const nowTime = now.getTime();
|
|
159
|
+
const isValid = nowTime - zonosQaTimeValue < EXPIRED_QA_TIME;
|
|
160
|
+
if (isValid) {
|
|
161
|
+
// Zonos class is not available in here yet, so we use console.warn instead of log util
|
|
162
|
+
// eslint-disable-next-line no-console
|
|
163
|
+
console.warn(`[ZONOS-WARNING] USING DEBUG DOMAIN, THIS IS ONLY FOR ZONOS DEVELOPER TO DEBUG, PLEASE REMOVE zonosQa=xxx OUT OF URL IF YOU DON'T KNOW WHAT YOU'RE DOING`);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
// Zonos class is not available in here yet, so we use console.warn instead of log util
|
|
167
|
+
// eslint-disable-next-line no-console
|
|
168
|
+
console.warn(`[ZONOS-WARNING] QA DOMAIN IS EXPIRED, USING PRODUCTION DOMAIN NOW`);
|
|
169
|
+
// remove the zonosQa param from url
|
|
170
|
+
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
171
|
+
urlSearchParams.delete('zonosQa');
|
|
172
|
+
const newUrl = `${window.location.pathname}?${urlSearchParams.toString()}`;
|
|
173
|
+
window.history.replaceState({}, '', newUrl);
|
|
174
|
+
}
|
|
175
|
+
return isValid;
|
|
176
|
+
})();
|
|
177
|
+
const ZONOS_URL = isZonosQa
|
|
178
|
+
? 'https://debug.js.zonos.com'
|
|
179
|
+
: "https://v1.2.3.js.zonos.com";
|
|
180
|
+
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.2.3";
|
|
146
181
|
const INTER_FONT_URL = 'https://rsms.me';
|
|
147
182
|
const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
|
|
148
183
|
class Zonos {
|
|
@@ -153,7 +188,8 @@ Zonos.doneInit = false;
|
|
|
153
188
|
Zonos.debug = !!window.location.search.match(/\?.*(&*)zonosDebug=1/);
|
|
154
189
|
Zonos.isBigCommerce = false;
|
|
155
190
|
Zonos.internationalHideSelector = '';
|
|
156
|
-
Zonos.version = `v${"1.2.
|
|
191
|
+
Zonos.version = `v${"1.2.3"}`;
|
|
192
|
+
Zonos.getCurrentTimestamp = () => new Date().getTime();
|
|
157
193
|
Zonos.init = async ({ appearance, checkoutSettings, currencyConverter, helloSettings, zonosApiKey, }) => {
|
|
158
194
|
if (Zonos.doneInit) {
|
|
159
195
|
// do nothing if zonos is already initializeds
|
|
@@ -165,7 +201,6 @@ Zonos.init = async ({ appearance, checkoutSettings, currencyConverter, helloSett
|
|
|
165
201
|
return;
|
|
166
202
|
}
|
|
167
203
|
_a.zonosApiKey = zonosApiKey;
|
|
168
|
-
// eslint-disable-next-line no-console
|
|
169
204
|
log('init zonos');
|
|
170
205
|
// inject zonos cdn
|
|
171
206
|
Zonos.injectZonosCdn();
|
|
@@ -195,10 +230,56 @@ Zonos.showNotification = (notification) => {
|
|
|
195
230
|
const zonosController = document.querySelector('zonos-controller');
|
|
196
231
|
void (zonosController === null || zonosController === void 0 ? void 0 : zonosController.showNotification(notification));
|
|
197
232
|
};
|
|
233
|
+
Zonos.disablePlaceOrderButtons = ({ autoEnable = true, disable, placeOrderButtonSelector, }) => {
|
|
234
|
+
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
235
|
+
if (placeOrderButtonSelector) {
|
|
236
|
+
const placeOrderButton = document.querySelectorAll(placeOrderButtonSelector);
|
|
237
|
+
const disableEvent = (e) => {
|
|
238
|
+
const target = e.target;
|
|
239
|
+
// prevent default and propagation when the item has disabled attribute
|
|
240
|
+
if (target.getAttribute('disabled')) {
|
|
241
|
+
e.preventDefault();
|
|
242
|
+
e.stopPropagation();
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
placeOrderButton.forEach(button => {
|
|
246
|
+
if (disable) {
|
|
247
|
+
button.setAttribute('disabled', 'true');
|
|
248
|
+
// prevent the selector to perform default action when it's disabled
|
|
249
|
+
button.addEventListener('click', disableEvent);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
button.removeAttribute('disabled');
|
|
253
|
+
// clean up the event listener
|
|
254
|
+
button.removeEventListener('click', disableEvent);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
// only auto enable if autoEnable is true and we are setting button disable
|
|
258
|
+
if (autoEnable && disable) {
|
|
259
|
+
setTimeout(() => {
|
|
260
|
+
// release it if zonos is not initialized after 5 seconds (this is to prevent the place order button from being disabled forever due to api)
|
|
261
|
+
placeOrderButton.forEach(button => {
|
|
262
|
+
button.removeAttribute('disabled');
|
|
263
|
+
// clean up the event listener if exists
|
|
264
|
+
button.removeEventListener('click', disableEvent);
|
|
265
|
+
});
|
|
266
|
+
}, 5000);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
};
|
|
198
270
|
Zonos.injectController = ({ config, zonosApiKey, }) => {
|
|
271
|
+
var _b;
|
|
199
272
|
if (document.querySelector('zonos-controller')) {
|
|
200
273
|
return;
|
|
201
274
|
}
|
|
275
|
+
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
276
|
+
if ((_b = config.checkoutSettings) === null || _b === void 0 ? void 0 : _b.placeOrderButtonSelector) {
|
|
277
|
+
const placeOrderButtonSelector = config.checkoutSettings.placeOrderButtonSelector;
|
|
278
|
+
_a.disablePlaceOrderButtons({
|
|
279
|
+
disable: true,
|
|
280
|
+
placeOrderButtonSelector,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
202
283
|
const zonosController = document.createElement('zonos-controller');
|
|
203
284
|
zonosController.config = config;
|
|
204
285
|
zonosController.zonosApiKey = zonosApiKey;
|
|
@@ -306,7 +387,7 @@ Zonos.injectStylesheet = ({ fallBackDomain, stylesheetDomain, theRestUrl, }) =>
|
|
|
306
387
|
};
|
|
307
388
|
Zonos.injectZonosCss = () => {
|
|
308
389
|
const findStyleLink = () => {
|
|
309
|
-
return !!document.querySelector(`link[rel="stylesheet"][href
|
|
390
|
+
return !!document.querySelector(`link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]`);
|
|
310
391
|
};
|
|
311
392
|
if (findStyleLink()) {
|
|
312
393
|
// eslint-disable-next-line no-console
|
package/dist/scripts/zonos.js
CHANGED
|
@@ -141,8 +141,43 @@ const zonosLoadStripe = async (...args) => {
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
var _a;
|
|
144
|
-
|
|
145
|
-
const
|
|
144
|
+
// 3 hours
|
|
145
|
+
const EXPIRED_QA_TIME = 3 * 60 * 60 * 1000;
|
|
146
|
+
// validate the time format (yyyymmddhhmmss) in the qa params if exceeds 1 hour, don't use qa
|
|
147
|
+
const isZonosQa = (() => {
|
|
148
|
+
const zonosQaTime = window.location.search.match(/\?.*(&*)zonosQa=(\d+)/);
|
|
149
|
+
if (!zonosQaTime) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
const [, , zonosQaTimeExtracted] = zonosQaTime;
|
|
153
|
+
if (!zonosQaTimeExtracted) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
const zonosQaTimeValue = parseInt(zonosQaTimeExtracted, 10);
|
|
157
|
+
const now = new Date();
|
|
158
|
+
const nowTime = now.getTime();
|
|
159
|
+
const isValid = nowTime - zonosQaTimeValue < EXPIRED_QA_TIME;
|
|
160
|
+
if (isValid) {
|
|
161
|
+
// Zonos class is not available in here yet, so we use console.warn instead of log util
|
|
162
|
+
// eslint-disable-next-line no-console
|
|
163
|
+
console.warn(`[ZONOS-WARNING] USING DEBUG DOMAIN, THIS IS ONLY FOR ZONOS DEVELOPER TO DEBUG, PLEASE REMOVE zonosQa=xxx OUT OF URL IF YOU DON'T KNOW WHAT YOU'RE DOING`);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
// Zonos class is not available in here yet, so we use console.warn instead of log util
|
|
167
|
+
// eslint-disable-next-line no-console
|
|
168
|
+
console.warn(`[ZONOS-WARNING] QA DOMAIN IS EXPIRED, USING PRODUCTION DOMAIN NOW`);
|
|
169
|
+
// remove the zonosQa param from url
|
|
170
|
+
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
171
|
+
urlSearchParams.delete('zonosQa');
|
|
172
|
+
const newUrl = `${window.location.pathname}?${urlSearchParams.toString()}`;
|
|
173
|
+
window.history.replaceState({}, '', newUrl);
|
|
174
|
+
}
|
|
175
|
+
return isValid;
|
|
176
|
+
})();
|
|
177
|
+
const ZONOS_URL = isZonosQa
|
|
178
|
+
? 'https://debug.js.zonos.com'
|
|
179
|
+
: "https://v1.2.3.js.zonos.com";
|
|
180
|
+
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.2.3";
|
|
146
181
|
const INTER_FONT_URL = 'https://rsms.me';
|
|
147
182
|
const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
|
|
148
183
|
class Zonos {
|
|
@@ -153,7 +188,8 @@ Zonos.doneInit = false;
|
|
|
153
188
|
Zonos.debug = !!window.location.search.match(/\?.*(&*)zonosDebug=1/);
|
|
154
189
|
Zonos.isBigCommerce = false;
|
|
155
190
|
Zonos.internationalHideSelector = '';
|
|
156
|
-
Zonos.version = `v${"1.2.
|
|
191
|
+
Zonos.version = `v${"1.2.3"}`;
|
|
192
|
+
Zonos.getCurrentTimestamp = () => new Date().getTime();
|
|
157
193
|
Zonos.init = async ({ appearance, checkoutSettings, currencyConverter, helloSettings, zonosApiKey, }) => {
|
|
158
194
|
if (Zonos.doneInit) {
|
|
159
195
|
// do nothing if zonos is already initializeds
|
|
@@ -165,7 +201,6 @@ Zonos.init = async ({ appearance, checkoutSettings, currencyConverter, helloSett
|
|
|
165
201
|
return;
|
|
166
202
|
}
|
|
167
203
|
_a.zonosApiKey = zonosApiKey;
|
|
168
|
-
// eslint-disable-next-line no-console
|
|
169
204
|
log('init zonos');
|
|
170
205
|
// inject zonos cdn
|
|
171
206
|
Zonos.injectZonosCdn();
|
|
@@ -195,10 +230,56 @@ Zonos.showNotification = (notification) => {
|
|
|
195
230
|
const zonosController = document.querySelector('zonos-controller');
|
|
196
231
|
void (zonosController === null || zonosController === void 0 ? void 0 : zonosController.showNotification(notification));
|
|
197
232
|
};
|
|
233
|
+
Zonos.disablePlaceOrderButtons = ({ autoEnable = true, disable, placeOrderButtonSelector, }) => {
|
|
234
|
+
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
235
|
+
if (placeOrderButtonSelector) {
|
|
236
|
+
const placeOrderButton = document.querySelectorAll(placeOrderButtonSelector);
|
|
237
|
+
const disableEvent = (e) => {
|
|
238
|
+
const target = e.target;
|
|
239
|
+
// prevent default and propagation when the item has disabled attribute
|
|
240
|
+
if (target.getAttribute('disabled')) {
|
|
241
|
+
e.preventDefault();
|
|
242
|
+
e.stopPropagation();
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
placeOrderButton.forEach(button => {
|
|
246
|
+
if (disable) {
|
|
247
|
+
button.setAttribute('disabled', 'true');
|
|
248
|
+
// prevent the selector to perform default action when it's disabled
|
|
249
|
+
button.addEventListener('click', disableEvent);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
button.removeAttribute('disabled');
|
|
253
|
+
// clean up the event listener
|
|
254
|
+
button.removeEventListener('click', disableEvent);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
// only auto enable if autoEnable is true and we are setting button disable
|
|
258
|
+
if (autoEnable && disable) {
|
|
259
|
+
setTimeout(() => {
|
|
260
|
+
// release it if zonos is not initialized after 5 seconds (this is to prevent the place order button from being disabled forever due to api)
|
|
261
|
+
placeOrderButton.forEach(button => {
|
|
262
|
+
button.removeAttribute('disabled');
|
|
263
|
+
// clean up the event listener if exists
|
|
264
|
+
button.removeEventListener('click', disableEvent);
|
|
265
|
+
});
|
|
266
|
+
}, 5000);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
};
|
|
198
270
|
Zonos.injectController = ({ config, zonosApiKey, }) => {
|
|
271
|
+
var _b;
|
|
199
272
|
if (document.querySelector('zonos-controller')) {
|
|
200
273
|
return;
|
|
201
274
|
}
|
|
275
|
+
// if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
|
|
276
|
+
if ((_b = config.checkoutSettings) === null || _b === void 0 ? void 0 : _b.placeOrderButtonSelector) {
|
|
277
|
+
const placeOrderButtonSelector = config.checkoutSettings.placeOrderButtonSelector;
|
|
278
|
+
_a.disablePlaceOrderButtons({
|
|
279
|
+
disable: true,
|
|
280
|
+
placeOrderButtonSelector,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
202
283
|
const zonosController = document.createElement('zonos-controller');
|
|
203
284
|
zonosController.config = config;
|
|
204
285
|
zonosController.zonosApiKey = zonosApiKey;
|
|
@@ -306,7 +387,7 @@ Zonos.injectStylesheet = ({ fallBackDomain, stylesheetDomain, theRestUrl, }) =>
|
|
|
306
387
|
};
|
|
307
388
|
Zonos.injectZonosCss = () => {
|
|
308
389
|
const findStyleLink = () => {
|
|
309
|
-
return !!document.querySelector(`link[rel="stylesheet"][href
|
|
390
|
+
return !!document.querySelector(`link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]`);
|
|
310
391
|
};
|
|
311
392
|
if (findStyleLink()) {
|
|
312
393
|
// eslint-disable-next-line no-console
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PaymentIntent, Stripe, StripeAddressElement, StripeAddressElementChangeEvent, StripeElements, StripeLinkAuthenticationElement, StripeLinkAuthenticationElementChangeEvent, StripePaymentElement, StripePaymentElementChangeEvent } from '@stripe/stripe-js';
|
|
1
|
+
import type { PaymentIntent, Stripe, StripeAddressElement, StripeAddressElementChangeEvent, StripeElements, StripeElementsOptions, StripeLinkAuthenticationElement, StripeLinkAuthenticationElementChangeEvent, StripePaymentElement, StripePaymentElementChangeEvent } from '@stripe/stripe-js';
|
|
2
2
|
import type { CheckoutSessionUpdateMutation, CountryCode, ElementsUiStyle, ElementsUiTheme } from "../../../types/generated/graphql.customer.types";
|
|
3
3
|
export type ContactOption = {
|
|
4
4
|
address: {
|
|
@@ -22,6 +22,7 @@ type StripeStore = {
|
|
|
22
22
|
stripeAddressEventData: StripeAddressElementChangeEvent | null;
|
|
23
23
|
stripeAddressUsedWhenFetchingLC: StripeAddressElementChangeEvent | null;
|
|
24
24
|
stripeElements: StripeElements | null;
|
|
25
|
+
stripeElementsOptions: StripeElementsOptions | null;
|
|
25
26
|
stripeLinkElement: StripeLinkAuthenticationElement | null;
|
|
26
27
|
stripeLinkEventData: StripeLinkAuthenticationElementChangeEvent | null;
|
|
27
28
|
stripeLinkUsedWhenFetchingLC: StripeLinkAuthenticationElementChangeEvent | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { type CountryLandedCost } from "../../utils/api/getCountryLandedCost";
|
|
2
3
|
import { type TargetFormat } from "../../utils/api/getExchangeRate";
|
|
3
4
|
import type { CountryCode } from "../../../types/index";
|
|
@@ -12,6 +13,7 @@ type LocalizationStore = {
|
|
|
12
13
|
countryLandedCost: CountryLandedCost | null;
|
|
13
14
|
customMessages: ILocaleMessageForUse[];
|
|
14
15
|
exchangeRate: ExchangeRateForUse | null;
|
|
16
|
+
exchangeRateTimeout?: NodeJS.Timeout;
|
|
15
17
|
isShippableCountry: boolean;
|
|
16
18
|
localizationLoaded: boolean;
|
|
17
19
|
selectedCountryCode: CountryCode | null;
|
|
@@ -12,6 +12,12 @@ export declare const getExchangeRate: ({ country, isGuaranteed, sourceCurrency,
|
|
|
12
12
|
sourceCurrency: string;
|
|
13
13
|
targetCurrency: string;
|
|
14
14
|
}) => Promise<{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} |
|
|
15
|
+
exchangeRate: null;
|
|
16
|
+
maxAge: null;
|
|
17
|
+
} | {
|
|
18
|
+
exchangeRate: {
|
|
19
|
+
rate: number;
|
|
20
|
+
targetFormat: TargetFormat;
|
|
21
|
+
};
|
|
22
|
+
maxAge: number;
|
|
23
|
+
}>;
|
|
@@ -37,7 +37,7 @@ import type { IDeepKeyof, IDeepPropertyType } from "../../types/index";
|
|
|
37
37
|
},
|
|
38
38
|
};
|
|
39
39
|
*/
|
|
40
|
-
export declare const changeDeepProperty: <T extends Record<string, unknown>, P extends IDeepKeyof<T, Depth>, Depth extends 0 | 8 | 1 | 2 |
|
|
40
|
+
export declare const changeDeepProperty: <T extends Record<string, unknown>, P extends IDeepKeyof<T, Depth>, Depth extends 0 | 8 | 1 | 2 | 6 | 5 | 3 | 4 | 7 | 9 = 4>({ obj, propertyPath, value, }: {
|
|
41
41
|
obj: T;
|
|
42
42
|
propertyPath: P;
|
|
43
43
|
value: IDeepPropertyType<T, P, Depth>;
|
|
@@ -60,7 +60,7 @@ import type { IDeepKeyofAtIndex, IDeepPropertyTypeAtIndex } from "../../types/in
|
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
62
|
*/
|
|
63
|
-
export declare const changeDeepPropertyAtIndex: <T extends object, P extends IDeepKeyofAtIndex<T, Depth>, Depth extends 0 | 8 | 1 | 2 |
|
|
63
|
+
export declare const changeDeepPropertyAtIndex: <T extends object, P extends IDeepKeyofAtIndex<T, Depth>, Depth extends 0 | 8 | 1 | 2 | 6 | 5 | 3 | 4 | 7 | 9 = 4>({ index, obj, propertyPath, value, }: {
|
|
64
64
|
index: number;
|
|
65
65
|
obj: T;
|
|
66
66
|
propertyPath: P;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { CheckoutConfig } from "../../../types/checkout/CheckoutConfig";
|
|
2
|
-
export declare const initCheckout: (config: Partial<CheckoutConfig>) =>
|
|
2
|
+
export declare const initCheckout: (config: Partial<CheckoutConfig>) => void;
|
|
@@ -45,9 +45,14 @@ export declare const env: {
|
|
|
45
45
|
NEXT_PUBLIC_ZONOS_UNPKG_CDN_URL: string;
|
|
46
46
|
};
|
|
47
47
|
type Keys = keyof typeof env;
|
|
48
|
+
type Props = {
|
|
49
|
+
override?: {
|
|
50
|
+
[key in Keys]: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
48
53
|
/**
|
|
49
54
|
* Env object that has all of native env variable used in code to replace them with
|
|
50
55
|
* actual values from .env
|
|
51
56
|
*/
|
|
52
|
-
export declare const getReplaceEnv: () => Record<`process.env.${Keys}`, string>;
|
|
57
|
+
export declare const getReplaceEnv: (props?: Props) => Record<`process.env.${Keys}`, string>;
|
|
53
58
|
export {};
|
|
@@ -27,6 +27,7 @@ export interface Zonos {
|
|
|
27
27
|
version: string;
|
|
28
28
|
zonosApiKey: string;
|
|
29
29
|
displayCurrency: () => void;
|
|
30
|
+
getCurrentTimestamp: () => number;
|
|
30
31
|
init: (params: LoadZonosParams) => Promise<void>;
|
|
31
32
|
showNotification: (props: NotificationInit) => void;
|
|
32
33
|
}
|
|
@@ -38,9 +39,11 @@ export declare abstract class Zonos {
|
|
|
38
39
|
static isBigCommerce: boolean;
|
|
39
40
|
static internationalHideSelector: string;
|
|
40
41
|
static version: string;
|
|
42
|
+
static getCurrentTimestamp: () => number;
|
|
41
43
|
static init: ({ appearance, checkoutSettings, currencyConverter, helloSettings, zonosApiKey, }: LoadZonosParams) => Promise<void>;
|
|
42
44
|
static displayCurrency: () => void;
|
|
43
45
|
static showNotification: (notification: NotificationInit) => void;
|
|
46
|
+
private static disablePlaceOrderButtons;
|
|
44
47
|
private static injectController;
|
|
45
48
|
private static injectScript;
|
|
46
49
|
private static injectZonosCdn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg color="var(--amino-red-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--amino-red-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>
|
|
1
|
+
<svg color="var(--amino-red-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--amino-red-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{c as cartStore,a as cartStoreApplySubtotals,b as cartStoreGetShippingTransitInfo,d as cartStoreNextStep,e as cartStorePreviousStep,f as cartStoreReCalculateTotal,g as cartStoreReset,h as cartStoreUpdateItems,i as cartStoreUpdateSelectedShippingOption,j as cartStoreUpdateToErrorState}from"./p-
|
|
1
|
+
export{c as cartStore,a as cartStoreApplySubtotals,b as cartStoreGetShippingTransitInfo,d as cartStoreNextStep,e as cartStorePreviousStep,f as cartStoreReCalculateTotal,g as cartStoreReset,h as cartStoreUpdateItems,i as cartStoreUpdateSelectedShippingOption,j as cartStoreUpdateToErrorState}from"./p-8378d94e.js";import"./p-08695f4e.js";import"./p-dc8d7000.js";import"./p-770c959e.js";import"./p-bf070bf6.js";import"./p-0e0b46a5.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(t,e,n,o){function r(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,i){function s(t){try{u(o.next(t))}catch(t){i(t)}}function c(t){try{u(o["throw"](t))}catch(t){i(t)}}function u(t){t.done?n(t.value):r(t.value).then(s,c)}u((o=o.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,r,i,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(t){return function(e){return u([t,e])}}function u(c){if(o)throw new TypeError("Generator is already executing.");while(s&&(s=0,c[0]&&(n=0)),n)try{if(o=1,r&&(i=c[0]&2?r["return"]:c[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;if(r=0,i)c=[c[0]&2,i.value];switch(c[0]){case 0:case 1:i=c;break;case 4:n.label++;return{value:c[1],done:false};case 5:n.label++;r=c[1];c=[0];continue;case 7:c=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){n.label=c[1];break}if(c[0]===6&&n.label<i[1]){n.label=i[1];i=c;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(c);break}if(i[2])n.ops.pop();n.trys.pop();continue}c=e.call(t,n)}catch(t){c=[6,t];r=0}finally{o=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}};System.register(["./p-68d06767.system.js","./p-f6add79c.system.js","./p-164fae93.system.js","./p-6dcd752e.system.js","./p-85ab35c9.system.js","./p-8c867835.system.js"],(function(t){"use strict";var e,n,o,r,i,s,c,u,a,l,f,d,h;return{setters:[function(t){e=t.r;n=t.c;o=t.h;r=t.H},function(t){i=t.s},function(t){s=t.h;c=t.b;u=t.i;a=t.l;l=t.c;f=t.d},function(t){d=t.z;h=t.d},function(){},function(){}],execute:function(){var v=this;var p=function(){return __awaiter(v,void 0,void 0,(function(){var t,e,n,o;return __generator(this,(function(r){switch(r.label){case 0:t="".concat("https://v1.route.js.zonos.com","/api/zonos-setting");return[4,s(t)];case 1:e=r.sent(),n=e.errors,o=e.json;if(n.length){c("Error occurs when getting zonos settings. If this is not an unauthorized error, it will use user setting or default setting");return[2,{errors:n,json:null}]}return[2,{errors:[],json:o}]}}))}))};var y=function(){var t=document.querySelector("zonos-checkout");if(!t){var e=document.createElement("zonos-checkout");document.body.appendChild(e)}};var m=function(t){if(!t.placeOrderButtonSelector){return}if(!u(t.placeOrderButtonSelector)){c('Selector checkoutButtonAnchor "'.concat(t.placeOrderButtonSelector,'" is not a valid selector'));return}y()};var g=function(t){var e=document.querySelector("zonos-hello");if(!e&&t){var n=document.createElement("zonos-hello");t.appendChild(n)}};var b=function(t){return __awaiter(v,void 0,void 0,(function(){var e,n;return __generator(this,(function(o){e=t.anchorElementSelector;if(!e||!u(e)){c('Selector anchorElementSelector "'.concat(t.anchorElementSelector,'" is not a valid selector.'));return[2]}n=document.querySelector(e);a("Hello init complete");g(n);return[2]}))}))};var _=":host{font-family:Inter;display:block}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{visibility:hidden;opacity:0;height:0}";var w=t("zonos_controller",function(){function t(t){e(this,t);this.stripeInitEvent=n(this,"stripeInitEvent",7);this.disablePlaceOrderButtons=function(t){var e=t.disable;var n=d.checkoutSettings.placeOrderButtonSelector;if(!n){return}var o=function(t){var e=t.target;if(e.getAttribute("disabled")){t.preventDefault();t.stopPropagation()}};var r=document.querySelectorAll(n);r.forEach((function(t){if(e){t.setAttribute("disabled","true");t.addEventListener("click",o)}else{t.removeAttribute("disabled");t.removeEventListener("click",o)}}));if(e){setTimeout((function(){r.forEach((function(t){t.removeAttribute("disabled");t.removeEventListener("click",o)}))}),5e3)}};this.config=undefined;this.zonosApiKey=undefined}t.prototype.initCheckoutElement=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){if(!t){a("Stripe is not loaded yet - cannot init checkout element","warn");return[2]}i.stripe=t;void m(d.checkoutSettings);a("init checkout element");this.disablePlaceOrderButtons({disable:false});return[2]}))}))};t.prototype.initZonosNotification=function(){var t=document.querySelector("zonos-notification");if(t){return}var e=document.createElement("zonos-notification");document.body.appendChild(e)};t.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(e){d.zonosApiKey=this.zonosApiKey;(function(){return __awaiter(t,void 0,void 0,(function(){var t,e,n,o,r,i;return __generator(this,(function(s){switch(s.label){case 0:return[4,p()];case 1:n=s.sent(),o=n.errors,r=n.json;if(((t=o[0])===null||t===void 0?void 0:t.type.toString())==="403"){a("Failed to load zonos settings. This domain may not have access","warn");return[2]}this.disablePlaceOrderButtons({disable:true});this.initZonosNotification();h({overrideSettings:this.config,zonosSettings:r});if(d.helloSettings){void b(d.helloSettings)}return[4,l()];case 2:s.sent();i=((e=r===null||r===void 0?void 0:r.checkoutSettings)===null||e===void 0?void 0:e.externalServiceTokens.find((function(t){return t.type==="STRIPE_PUBLISHABLE_TOKEN"})))||null;if(!i||!this.stripeInitEvent){a("Checkout failed to load -- missing publishable key","warn");return[2]}if(d.checkoutSettings.subscriptionStatus==="INACTIVE"){a('=== Checkout subscription is "INACTIVE" - Cancel initializing for Checkout ===',"warn");a("zonos controller loaded");return[2]}if(d.checkoutSettings.visibilityStatus==="DISABLED"){a("=== Checkout is disabled by store owner ===","warn");a("zonos controller loaded");return[2]}this.stripeInitEvent.emit({publishableKey:i.token});a("zonos controller loaded");return[2]}}))}))})();return[2]}))}))};t.prototype.showNotification=function(t){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(n){e=document.querySelector("zonos-notification");if(!e){a("Failed to show notification - zonos-notification not found","warn");return[2]}void e.showNotification(t);return[2]}))}))};t.prototype.overrideConfig=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){h({overrideSettings:t,zonosSettings:null});return[2]}))}))};t.prototype.overrideCountry=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){void f(t);return[2]}))}))};t.prototype.render=function(){return o(r,{class:"zonos--elements"})};return t}());w.style=_}}}));
|