@useinsider/guido 3.15.0-beta.360c5d6 → 3.15.0-beta.e9014b0

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,23 +1,37 @@
1
- import { productPairs as I } from "../extensions/Blocks/Items/enums/productEnums.js";
1
+ import { productPairs as w } from "../extensions/Blocks/Items/enums/productEnums.js";
2
2
  import { DefaultConfigValues as G } from "../extensions/Blocks/Items/enums/settingsEnums.js";
3
3
  import { escapeReplacement as N } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
4
- import { preserveTextStyles as S } from "./preserveTextStyles.js";
5
- import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
6
- const x = {
4
+ import { preserveTextStyles as I } from "./preserveTextStyles.js";
5
+ import { unwrapProductNameLinks as v } from "./unwrapProductNameLink.js";
6
+ const O = {
7
7
  CART_ITEMS: "ins_apr",
8
8
  BROWSED_ITEMS: "browsed_item",
9
9
  PURCHASED_ITEMS: "purchased_item"
10
- }, O = (m) => m.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
11
- function z(m) {
12
- const P = O(m), b = new DOMParser().parseFromString(P, "text/html");
13
- X(b);
14
- const C = I.PAIRS_FOR_EXTENSION;
15
- Object.entries(C).forEach(([r, l]) => {
16
- b.querySelectorAll(".ins-product-td").forEach((u) => {
17
- const p = u.getAttribute("data-number") || "1", T = u.getAttribute("data-type") || "CART_ITEMS";
18
- u.querySelectorAll(`[product-attr="${r}"]`).forEach((t) => {
19
- var w, k, D;
20
- const _ = t.getAttribute("data-type") || T, f = t.getAttribute("data-number") || p, A = l[_];
10
+ }, q = (h) => h.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
11
+ function X(h, g, _) {
12
+ let E = h.indexOf(g);
13
+ if (E === -1)
14
+ return !1;
15
+ for (; E !== -1; ) {
16
+ let b = E;
17
+ for (; b > 0 && /\s/.test(h[b - 1]); )
18
+ b -= 1;
19
+ if (!_.some((P) => h.endsWith(P, b)))
20
+ return !1;
21
+ E = h.indexOf(g, E + g.length);
22
+ }
23
+ return !0;
24
+ }
25
+ function J(h) {
26
+ const g = q(h), _ = new DOMParser().parseFromString(g, "text/html");
27
+ v(_);
28
+ const E = w.PAIRS_FOR_EXTENSION;
29
+ Object.entries(E).forEach(([r, l]) => {
30
+ _.querySelectorAll(".ins-product-td").forEach((f) => {
31
+ const p = f.getAttribute("data-number") || "1", R = f.getAttribute("data-type") || "CART_ITEMS";
32
+ f.querySelectorAll(`[product-attr="${r}"]`).forEach((t) => {
33
+ var k, D, x;
34
+ const S = t.getAttribute("data-type") || R, u = t.getAttribute("data-number") || p, A = l[S];
21
35
  if (A)
22
36
  switch (r) {
23
37
  case "imageSrc": {
@@ -27,53 +41,53 @@ function z(m) {
27
41
  const i = A.DEFAULT, s = A.ATTR;
28
42
  if (i && e.src) {
29
43
  const o = e.src;
30
- i.some(($) => {
31
- const a = $.split("/").pop() || "", g = o.split("/").pop() || "";
32
- return o.includes($) || o.includes(a) || g === a;
33
- }) && (e.src = `{{${s}_${f}}}`);
44
+ i.some((T) => {
45
+ const a = T.split("/").pop() || "", C = o.split("/").pop() || "";
46
+ return o.includes(T) || o.includes(a) || C === a;
47
+ }) && (e.src = `{{${s}_${u}}}`);
34
48
  }
35
- const n = (k = (w = C.name) == null ? void 0 : w[_]) == null ? void 0 : k.ATTR;
36
- if (n && e.setAttribute("alt", `{{${n}_${f}}}`), c) {
37
- const o = (D = C.itemLink) == null ? void 0 : D[_];
49
+ const n = (D = (k = E.name) == null ? void 0 : k[S]) == null ? void 0 : D.ATTR;
50
+ if (n && e.setAttribute("alt", `{{${n}_${u}}}`), c) {
51
+ const o = (x = E.itemLink) == null ? void 0 : x[S];
38
52
  if (o) {
39
- const E = o.HREF, $ = o.DEFAULT_HREF || "#!", a = c.href;
40
- (a === "#" || a === "" || a.endsWith("#!") || a.endsWith($) || a === `${window.location.href}${$}` || !a || a === window.location.href) && (c.href = `{{${E}_${f}}}`);
53
+ const $ = o.HREF, T = o.DEFAULT_HREF || "#!", a = c.href;
54
+ (a === "#" || a === "" || a.endsWith("#!") || a.endsWith(T) || a === `${window.location.href}${T}` || !a || a === window.location.href) && (c.href = `{{${$}_${u}}}`);
41
55
  }
42
56
  }
43
57
  break;
44
58
  }
45
59
  case "name": {
46
60
  const e = A, c = e.ATTR, i = e.DEFAULT_HREF || "#!", s = e.HREF;
47
- t.textContent && (t.innerHTML = S(t, `{{${c}_${f}}}`));
61
+ t.textContent && (t.innerHTML = I(t, `{{${c}_${u}}}`));
48
62
  const n = t.closest("a") || (t.tagName === "A" ? t : null);
49
63
  if (n && s) {
50
- const o = n.href, E = `${window.location.href}${i}`;
51
- (o === E || o.endsWith(i)) && (n.href = `{{${s}_${f}}}`);
64
+ const o = n.href, $ = `${window.location.href}${i}`;
65
+ (o === $ || o.endsWith(i)) && (n.href = `{{${s}_${u}}}`);
52
66
  }
53
67
  break;
54
68
  }
55
69
  case "price":
56
70
  case "originalPrice": {
57
71
  const e = A, c = t.getAttribute("data-formated"), i = t.getAttribute("data-single_price"), s = c === "true", n = i === "true", o = t.getAttribute("data-curency") || "before";
58
- let E;
59
- n ? E = s ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : E = s ? e.PRICE_FORMATTED : e.PRICE;
60
- const $ = e.CURRENCY;
61
- let a = `{{${E}_${f}}}`;
62
- const g = (t.getAttribute("data-currency_symbol") || "").trim(), W = g !== "" && g !== G.productPriceCurrencySymbolControlValue;
63
- let y = "";
64
- W ? y = g : $ && (y = `{{${$}_${f}}}`), y && (a = o === "after" ? `${a} ${y}` : `${y} ${a}`), t.innerHTML = S(t, a);
72
+ let $;
73
+ n ? $ = s ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : $ = s ? e.PRICE_FORMATTED : e.PRICE;
74
+ const T = e.CURRENCY;
75
+ let a = `{{${$}_${u}}}`;
76
+ const C = (t.getAttribute("data-currency_symbol") || "").trim(), W = C !== "" && C !== G.productPriceCurrencySymbolControlValue;
77
+ let H = "";
78
+ W ? H = C : T && (H = `{{${T}_${u}}}`), H && (a = o === "after" ? `${a} ${H}` : `${H} ${a}`), t.innerHTML = I(t, a);
65
79
  break;
66
80
  }
67
81
  case "quantity": {
68
82
  const e = A, c = e.ATTR, i = e.DEFAULT;
69
- t.textContent && t.textContent.trim() === i && (t.innerHTML = S(t, `{{${c}_${f}}}`));
83
+ t.textContent && t.textContent.trim() === i && (t.innerHTML = I(t, `{{${c}_${u}}}`));
70
84
  break;
71
85
  }
72
86
  case "button": {
73
87
  const e = A, c = e.HREF, i = e.DEFAULT_HREF || "#!", s = t.tagName === "A" ? t : t.querySelector("a");
74
88
  if (s) {
75
89
  const n = s.href || "", o = `${window.location.href}${i}`;
76
- (n === "" || n === "#" || n === o || n.endsWith(i) || n.endsWith("#!") || n === window.location.href) && (s.href = `{{${c}_${f}}}`);
90
+ (n === "" || n === "#" || n === o || n.endsWith(i) || n.endsWith("#!") || n === window.location.href) && (s.href = `{{${c}_${u}}}`);
77
91
  }
78
92
  break;
79
93
  }
@@ -81,14 +95,14 @@ function z(m) {
81
95
  const e = A, c = e.HREF, i = e.DEFAULT_HREF || "#!", s = t;
82
96
  if (s.href) {
83
97
  const n = s.href, o = `${window.location.href}${i}`;
84
- (n === o || n.endsWith(i)) && (s.href = `{{${c}_${f}}}`);
98
+ (n === o || n.endsWith(i)) && (s.href = `{{${c}_${u}}}`);
85
99
  }
86
100
  break;
87
101
  }
88
102
  default: {
89
103
  if ("ATTR" in A) {
90
104
  const e = A.ATTR;
91
- t.textContent && (t.innerHTML = S(t, `{{${e}_${f}}}`));
105
+ t.textContent && (t.innerHTML = I(t, `{{${e}_${u}}}`));
92
106
  }
93
107
  break;
94
108
  }
@@ -96,50 +110,53 @@ function z(m) {
96
110
  });
97
111
  });
98
112
  });
99
- const F = P.match(/<!DOCTYPE[^>]*>/i), q = F ? `${F[0]}
100
- ` : "", U = b.querySelectorAll(".ins-product-td"), L = [];
113
+ const b = g.match(/<!DOCTYPE[^>]*>/i), P = b ? `${b[0]}
114
+ ` : "", U = _.querySelectorAll(".ins-product-td"), L = [];
101
115
  U.forEach((r) => {
102
- const l = r.getAttribute("data-type") || "CART_ITEMS", d = r.getAttribute("data-number") || "1", u = r.outerHTML;
116
+ const l = r.getAttribute("data-type") || "CART_ITEMS", d = r.getAttribute("data-number") || "1", f = r.outerHTML;
103
117
  L.push({
104
118
  element: r,
105
- outerHtml: u,
119
+ outerHtml: f,
106
120
  type: l,
107
121
  number: d
108
122
  });
109
123
  });
110
- let h = q + b.documentElement.outerHTML;
124
+ let y = P + _.documentElement.outerHTML;
111
125
  L.reverse().forEach(({ outerHtml: r, type: l, number: d }) => {
112
- const u = x[l], p = u ? `${u}_total_product_kind` : "";
126
+ const f = O[l], p = f ? `${f}_total_product_kind` : "";
113
127
  if (p) {
114
- const R = parseInt(d) - 1, f = `${`{% if ${p} > ${R} %}`}${r}{% endif %}`;
115
- h = h.replace(r, N(f));
128
+ const m = parseInt(d) - 1, u = `${`{% if ${p} > ${m} %}`}${r}{% endif %}`;
129
+ y = y.replace(r, N(u));
116
130
  }
117
131
  });
118
- const V = b.querySelectorAll('[product-attr="originalPrice"][data-type]'), H = [], M = /* @__PURE__ */ new Set();
132
+ const V = _.querySelectorAll('[product-attr="originalPrice"][data-type]'), F = [], M = /* @__PURE__ */ new Set();
119
133
  return V.forEach((r) => {
120
134
  var t;
121
135
  const l = r.getAttribute("data-number"), d = r.getAttribute("data-type");
122
- if (!l || !x[d])
136
+ if (!l || !O[d])
123
137
  return;
124
- const u = r.closest(".product-original-price-class");
125
- if (!u)
138
+ const f = r.closest(".product-original-price-class");
139
+ if (!f)
126
140
  return;
127
- const p = u.outerHTML;
141
+ const p = f.outerHTML;
128
142
  if (((t = r.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup")) === "false") {
129
143
  M.add(p);
130
144
  return;
131
145
  }
132
- H.some((_) => _.tdOuterHtml === p) || H.push({ tdOuterHtml: p, number: l, type: d });
133
- }), H.forEach(({ tdOuterHtml: r, number: l, type: d }) => {
146
+ F.some((S) => S.tdOuterHtml === p) || F.push({ tdOuterHtml: p, number: l, type: d });
147
+ }), F.forEach(({ tdOuterHtml: r, number: l, type: d }) => {
134
148
  if (M.has(r))
135
149
  return;
136
- const u = I.PAIRS_FOR_EXTENSION.price[d].PRICE, p = I.PAIRS_FOR_EXTENSION.originalPrice[d].PRICE, T = `{% if ${u}_${l} != ${p}_${l} %}`, R = h.includes(`${T}${r}`) || h.includes(`${O(T)}${r}`);
137
- r.includes("{% if") || R || (h = h.replaceAll(
150
+ const f = w.PAIRS_FOR_EXTENSION.price[d].PRICE, p = w.PAIRS_FOR_EXTENSION.originalPrice[d].PRICE, R = `{% if ${f}_${l} != ${p}_${l} %}`, m = X(y, r, [
151
+ R,
152
+ q(R)
153
+ ]);
154
+ r.includes("{% if") || m || (y = y.replaceAll(
138
155
  r,
139
- N(`${T}${r}{% endif %}`)
156
+ N(`${R}${r}{% endif %}`)
140
157
  ));
141
- }), h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
158
+ }), y.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
142
159
  }
143
160
  export {
144
- z as pairProductVariables
161
+ J as pairProductVariables
145
162
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.15.0-beta.360c5d6",
3
+ "version": "3.15.0-beta.e9014b0",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",