@zonos/elements 1.3.87 → 1.3.88

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.
@@ -1,6 +1,7 @@
1
1
  import { getAssetPath, h, Host } from "@stencil/core";
2
2
  import { cartStore } from "../../../store/checkout/cart";
3
3
  import { translate } from "../../../store/translationStore";
4
+ import { cleanHtmlMarkdown } from "../../../utils/cleanHtmlMarkdown";
4
5
  import { currencyFormat } from "../../../utils/hello/currencyConversion/currencyFormat";
5
6
  export class ZonosCartItems {
6
7
  constructor() {
@@ -11,15 +12,14 @@ export class ZonosCartItems {
11
12
  const emptyItemImg = getAssetPath('./assets/empty-item.jpeg');
12
13
  const rate = ((_a = cartStore.exchangeRate) === null || _a === void 0 ? void 0 : _a.rate) || 1;
13
14
  const nonRestrictedItems = cartStore.items.filter(item => !item.isRestricted);
14
- return (h(Host, { key: '7bdf8d1972edb2d11669441b3d8ec6643fca1f4b', class: "zonos--cart-items zonos--elements" }, h("table", { key: '1c2fe6d444ea93e40b981a8935d16192bf61928c', class: "zonos--cart-table" }, h("tbody", { key: '84279bea6821077bf117a7a13ca497155276c622' }, nonRestrictedItems.map(item => {
15
+ return (h(Host, { key: '5bb1ea08c13ffd9521ed1ef3934a0e02bdce3317', class: "zonos--cart-items zonos--elements" }, h("table", { key: '54c1dcf71a22e9fa1108350c272ee5267832f2e3', class: "zonos--cart-table" }, h("tbody", { key: 'f1c426a5cf7db0b4198a25bfb9cb99a2d67908ab' }, nonRestrictedItems.map(item => {
15
16
  const itemImg = item.imageUrl;
16
- // Split the name by <br> tag
17
- const namesWithNewLine = item.name.split(/<br\s*\/*>/);
17
+ const cleanedItemNames = cleanHtmlMarkdown(item.name);
18
18
  return (h("tr", { class: "zonos--cart-item" }, h("td", { class: "zonos--column zonos--cart-item-image" }, itemImg && !this.errorImages.includes(itemImg) ? (h("img", { alt: item.name, onError: () => {
19
19
  this.errorImages = [...this.errorImages, itemImg];
20
20
  }, src: item.imageUrl, style: {
21
21
  'min-width': '40px',
22
- }, width: 40 })) : (h("img", { alt: item.name, src: emptyItemImg, width: 40 }))), h("td", { class: "zonos--column zonos--cart-item-name" }, h("div", null, namesWithNewLine.map(name => (h("zonos-text", { type: "label" }, name)))), h("zonos-text", { textColor: "gray-600", type: "caption" }, translate('Quantity'), ": ", item.quantity)), h("td", { class: "zonos--column zonos--cart-item-price" }, h("zonos-text", { type: "semiBoldLabel", weight: 600 }, currencyFormat({
22
+ }, width: 40 })) : (h("img", { alt: item.name, src: emptyItemImg, width: 40 }))), h("td", { class: "zonos--column zonos--cart-item-name" }, h("div", null, cleanedItemNames.map(name => (h("zonos-text", { type: "label" }, name)))), h("zonos-text", { textColor: "gray-600", type: "caption" }, translate('Quantity'), ": ", item.quantity)), h("td", { class: "zonos--column zonos--cart-item-price" }, h("zonos-text", { type: "semiBoldLabel", weight: 600 }, currencyFormat({
23
23
  amount: item.amount * rate * item.quantity,
24
24
  currency: cartStore.currency,
25
25
  })))));
@@ -93,13 +93,29 @@ export class ZonosCheckoutFinish {
93
93
  };
94
94
  // TODO: This method of pulling orders is temporary. Once we have a working event registry system, we will rely on that to tell us when the order is ready to trigger onOrderSuccess
95
95
  this.getPullOrder = async (attempts = 0) => {
96
+ var _a, _b, _c;
96
97
  const { baseUrl, order } = await this.pullOrder();
97
- if (order) {
98
+ const legacyOrderNumberExist = !!((_c = (_b = (_a = this.order) === null || _a === void 0 ? void 0 : _a.references) === null || _b === void 0 ? void 0 : _b.find(entry => (entry === null || entry === void 0 ? void 0 : entry.key) === 'zonosOrderNumber')) === null || _c === void 0 ? void 0 : _c.value);
99
+ // legacy customers are still using the old order number so we need to wait for legacy order number to attach to dgs order before redirecting
100
+ if ((order && attempts >= 5) || legacyOrderNumberExist) {
101
+ if (!legacyOrderNumberExist) {
102
+ const checkoutSessionId = cartStore.checkoutSessionId;
103
+ void sendErrorLog({
104
+ endpoint: `${baseUrl}/api/zonos-elements/get-order?checkoutSessionId=${checkoutSessionId}&orderId=${order === null || order === void 0 ? void 0 : order.id}`,
105
+ errors: [`Order found but legacy order number doesn’t exist`],
106
+ metadata: {
107
+ checkoutSessionId: cartStore.checkoutSessionId || '',
108
+ domain: window.location.hostname,
109
+ orderId: (order === null || order === void 0 ? void 0 : order.id) || '',
110
+ storeId: zonosStore.storeId,
111
+ },
112
+ });
113
+ }
98
114
  void trackConversionEvent('checkout_orderCompleted');
99
115
  this.order = order;
100
116
  this.handleSuccessBehavior();
101
117
  }
102
- else if (!order && attempts < 5) {
118
+ else if ((!order || !legacyOrderNumberExist) && attempts < 5) {
103
119
  // Wait for 1 second before the next attempt
104
120
  await new Promise(resolve => setTimeout(resolve, 1000));
105
121
  await this.getPullOrder(attempts + 1);
@@ -235,11 +251,11 @@ export class ZonosCheckoutFinish {
235
251
  var _a, _b;
236
252
  const orderId = ((_a = this.order) === null || _a === void 0 ? void 0 : _a.accountOrderNumber) || getGraphQlShortId((_b = this.order) === null || _b === void 0 ? void 0 : _b.id);
237
253
  const isTestMode = getIsTestMode();
238
- return (h(Host, { key: '9939772d4ce4213978ae6b02b4cd5345d15dbdfd', class: "zonos--checkout-finish zonos--elements", style: {
254
+ return (h(Host, { key: '3c6c69c59622b7b2731f9bc6eb1cc8a7f3491572', class: "zonos--checkout-finish zonos--elements", style: {
239
255
  '--border-radius': getBorderRadius({
240
256
  overrideBorderStyle: this.borderRadius,
241
257
  }),
242
- } }, this.isLoading && (h("div", { key: '491d4d0ba3dc487d448606009a30a5ce8d3bb86e', class: "loading-wrapper" }, h("zonos-spinner", { key: '3179aeb472d3e70628d3f1e3e2b76ed3d622145d' }))), !this.isLoading && (h("div", { key: '6044c9d1ac7599d9168f944dcf82028669fd1f37', class: "zonos--finish-details" }, h("div", { key: 'd22ec981a73db08e4871c8babe29f9a09a5bc29d', class: "zonos--group" }, this.notificationType === 'success' ? (h("zonos-icon", { "aria-label": "Order success", content: SuccessIcon, iconColor: 'blue-800', size: 50 })) : (h("zonos-icon", { "aria-label": "Order failed", content: RemoveIcon, iconColor: 'red-800', size: 50 })), h("zonos-text", { key: 'bfef33fd319456253e07c3ef3f81da1b85414df9', class: "zonos--title", type: "semiBoldSubheader" }, this.notificationTitle), orderId && (h("div", { key: 'f056c93644d1f9defa263f59111874f154293b51', class: "zonos--order-number" }, "Order #", orderId)), h("zonos-text", { key: '69d38c4640943a5cfdcef5ea6951ddec9c7b8a84', textColor: "gray-600" }, this.notificationMessages.map(message => (h(Fragment, null, message, h("br", null))))), h("zonos-button", { key: 'fbb2d1cc0baab99a3312f2077c28cb9d51b4eb44', onClick: () => this.closeClickHandler(), size: "md", variant: "primary" }, this.notificationActionText)), isTestMode && cartStore.step === 'finish' && (h("div", { key: '7b63fd838f850ce6a5acf4970fa66657ca05e235', class: "zonos--finish-button-wrapper" }, h("zonos-button", { key: '85035826e36d52ccf8c77aa6ba6e27173fccdaa6', backgroundColor: "gray-0", buttonColor: "gray-1200", onClick: () => this.closeClickHandler(), size: "lg", variant: "outline" }, "New test cart"), h("zonos-button", { key: 'd3848fdbdf1380dce49fcbc2b2903d99ce65247d', onClick: () => this.redirectToUrl(`/orders/all`), size: "lg", variant: "primary" }, "View order in Dashboard")))))));
258
+ } }, this.isLoading && (h("div", { key: '45ce0e608dca725237abc09295656c8b6471d26c', class: "loading-wrapper" }, h("zonos-spinner", { key: 'fd1a193d34ecf41af9bb6eff082c192c6a8d46db' }))), !this.isLoading && (h("div", { key: '64f652a419330967f13b9d01a172fcc52f6dfd5b', class: "zonos--finish-details" }, h("div", { key: '945cb9e55b418de79921c1995604572e6e009459', class: "zonos--group" }, this.notificationType === 'success' ? (h("zonos-icon", { "aria-label": "Order success", content: SuccessIcon, iconColor: 'blue-800', size: 50 })) : (h("zonos-icon", { "aria-label": "Order failed", content: RemoveIcon, iconColor: 'red-800', size: 50 })), h("zonos-text", { key: '241bd7034c5ab5e83e4cedd526a181120a743ad0', class: "zonos--title", type: "semiBoldSubheader" }, this.notificationTitle), orderId && (h("div", { key: '959595c1be3f65aa6cd2e00e4398c5bb4df702b6', class: "zonos--order-number" }, "Order #", orderId)), h("zonos-text", { key: 'a23dce69391c3abf49eb512e715af454c971977e', textColor: "gray-600" }, this.notificationMessages.map(message => (h(Fragment, null, message, h("br", null))))), h("zonos-button", { key: 'ce87734e2d46e8a044bc0ded7a6ed6a4a705685d', onClick: () => this.closeClickHandler(), size: "md", variant: "primary" }, this.notificationActionText)), isTestMode && cartStore.step === 'finish' && (h("div", { key: 'a46cee8819c83fb76a54dbe049ee2452b7fc150a', class: "zonos--finish-button-wrapper" }, h("zonos-button", { key: '514fdff77f5aff9f4b9657a0579ab843833af7b0', backgroundColor: "gray-0", buttonColor: "gray-1200", onClick: () => this.closeClickHandler(), size: "lg", variant: "outline" }, "New test cart"), h("zonos-button", { key: '59630cf7504c1ef9d24854d041b063bbfdc3a1a4', onClick: () => this.redirectToUrl(`/orders/all`), size: "lg", variant: "primary" }, "View order in Dashboard")))))));
243
259
  }
244
260
  static get is() { return "zonos-checkout-finish"; }
245
261
  static get encapsulation() { return "shadow"; }
@@ -0,0 +1,28 @@
1
+ import TurndownService from "turndown";
2
+ const turndownService = new TurndownService();
3
+ /**
4
+ * Converts an HTML string to Markdown format, strips unnecessary Markdown tags,
5
+ * and returns an array of cleaned Markdown text blocks..
6
+ *
7
+ * This utility function is useful for transforming HTML into Markdown and cleaning
8
+ * it by removing extra or unwanted Markdown elements, resulting in an array of
9
+ * plain Markdown text segments.
10
+ *
11
+ * @param {string} htmlString - The input HTML string to be converted and cleaned.
12
+ *
13
+ * @example
14
+ * const htmlInput = "<h1>Hello World</h1><p>This is a paragraph.</p>";
15
+ * const result = cleanHtmlMarkdown(htmlInput);
16
+ * console.log(result); // Outputs cleaned HTML after conversion and processing
17
+ */
18
+ export const cleanHtmlMarkdown = (htmlString) => {
19
+ const mdString = turndownService.turndown(htmlString);
20
+ const sanitizedMdString =
21
+ // remove header tags
22
+ mdString.replace(/^\#+\s+/gm, '').trim();
23
+ if (!sanitizedMdString) {
24
+ return [];
25
+ }
26
+ const mdBlocks = sanitizedMdString.split(/[\n\r]+/gm);
27
+ return mdBlocks;
28
+ };
package/dist/esm/index.js CHANGED
@@ -94,7 +94,7 @@ const getZonosQaUrl = () => {
94
94
  return null;
95
95
  }
96
96
  const qaUrl = extractZonosQaUrl(window.location.href);
97
- const cdnUrl = "https://v1.3.87.js.zonos.com";
97
+ const cdnUrl = "https://v1.3.88.js.zonos.com";
98
98
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
99
99
  if (!qaUrl &&
100
100
  (cdnUrl.includes('test.') ||
@@ -278,10 +278,10 @@ const zonosLoadUrl = (() => {
278
278
  }
279
279
  return null;
280
280
  })();
281
- const ZONOS_URL = "https://v1.3.87.js.zonos.com";
282
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.87";
283
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.87";
284
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.87";
281
+ const ZONOS_URL = "https://v1.3.88.js.zonos.com";
282
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.88";
283
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.88";
284
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.88";
285
285
  const INTER_FONT_URL = 'https://rsms.me';
286
286
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
287
287
  const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
@@ -296,7 +296,7 @@ Zonos.zonosConversionTest = typeof window !== 'undefined' &&
296
296
  !!window.location.search.match(/\?.*(&*)zonosConversionTest/);
297
297
  Zonos._paypalMockResponse = null;
298
298
  Zonos.isBigCommerce = false;
299
- Zonos.releaseDate = "1728918962245";
299
+ Zonos.releaseDate = "1728921230072";
300
300
  Zonos.isLegacyCheckout = false;
301
301
  /**
302
302
  * By default, the package will load from npm
@@ -304,7 +304,7 @@ Zonos.isLegacyCheckout = false;
304
304
  Zonos.isNpm = true;
305
305
  Zonos.zonosQaUrl = null;
306
306
  Zonos.zonosQaUrlApi = null;
307
- Zonos.version = `v${"1.3.87"}`;
307
+ Zonos.version = `v${"1.3.88"}`;
308
308
  Zonos.modeAlerted = false;
309
309
  Zonos.cartData = null;
310
310
  Zonos.paypal = null;