@useinsider/guido 3.9.0-beta.fcaa08b → 3.9.0

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,44 +1,44 @@
1
- import { useConfig as C } from "../../../composables/useConfig.js";
1
+ import { useConfig as _ } from "../../../composables/useConfig.js";
2
2
  import { useRecommendation as g } from "../../../composables/useRecommendation.js";
3
3
  import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
- import { useRecommendationExtensionStore as E } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
4
+ import { useRecommendationExtensionStore as C } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
5
  import { isIgnoredRecommendationBlock as w } from "./recommendationIgnoreUtils.js";
6
- function b(t, n, e, o, c = "") {
7
- const i = `{{${c}${t}_${n}_${e}}}`, r = `{{${c}${t}_${n}_currency}}`;
6
+ function b(e, n, t, o, c = "") {
7
+ const i = `{{${c}${e}_${n}_${t}}}`, r = `{{${c}${e}_${n}_currency}}`;
8
8
  return o === "before" ? `${r} ${i}` : `${i} ${r}`;
9
9
  }
10
- function m(t) {
11
- let n = t;
10
+ function m(e) {
11
+ let n = e;
12
12
  for (; n.children.length === 1; )
13
13
  [n] = n.children;
14
14
  return n;
15
15
  }
16
- function y(t, n, e, o, c, i) {
16
+ function h(e, n, t, o, c, i) {
17
17
  switch (n) {
18
18
  case "productImage": {
19
- const r = t.querySelector("img");
20
- r && (r.setAttribute("src", `{{${i}${e}_${o}_image_url}}`), r.setAttribute("alt", `{{${i}${e}_${o}_name}}`));
21
- const s = t.querySelector("a");
22
- s && (s.setAttribute("href", `{{${i}${e}_${o}_url}}`), s.classList.add(q));
19
+ const r = e.querySelector("img");
20
+ r && (r.setAttribute("src", `{{${i}${t}_${o}_image_url}}`), r.setAttribute("alt", `{{${i}${t}_${o}_name}}`));
21
+ const s = e.querySelector("a");
22
+ s && (s.setAttribute("href", `{{${i}${t}_${o}_url}}`), s.classList.add(q));
23
23
  break;
24
24
  }
25
25
  case "productName": {
26
- const r = t.querySelector("p");
27
- r && (m(r).textContent = `{{${i}${e}_${o}_name}}`);
26
+ const r = e.querySelector("p");
27
+ r && (m(r).textContent = `{{${i}${t}_${o}_name}}`);
28
28
  break;
29
29
  }
30
30
  case "productPrice": {
31
- const r = t.querySelector(".product-price p") ?? t.querySelector("p");
31
+ const r = e.querySelector(".product-price p") ?? e.querySelector("p");
32
32
  r && (m(r).textContent = b(
33
- e,
33
+ t,
34
34
  o,
35
35
  "price",
36
36
  c,
37
37
  i
38
38
  ));
39
- const s = t.querySelector(".product-old-price p");
39
+ const s = e.querySelector(".product-old-price p");
40
40
  s && (m(s).textContent = b(
41
- e,
41
+ t,
42
42
  o,
43
43
  "original_price",
44
44
  c,
@@ -47,9 +47,9 @@ function y(t, n, e, o, c, i) {
47
47
  break;
48
48
  }
49
49
  case "productOldPrice": {
50
- const r = t.querySelector("p");
50
+ const r = e.querySelector("p");
51
51
  r && (m(r).textContent = b(
52
- e,
52
+ t,
53
53
  o,
54
54
  "original_price",
55
55
  c,
@@ -58,117 +58,97 @@ function y(t, n, e, o, c, i) {
58
58
  break;
59
59
  }
60
60
  case "productButton": {
61
- const r = t.querySelector("a");
62
- r && r.setAttribute("href", `{{${i}${e}_${o}_url}}`);
61
+ const r = e.querySelector("a");
62
+ r && r.setAttribute("href", `{{${i}${t}_${o}_url}}`);
63
63
  break;
64
64
  }
65
65
  case "productOmnibusPrice": {
66
- const r = t.querySelector(".omnibus-price-value");
66
+ const r = e.querySelector(".omnibus-price-value");
67
67
  if (r) {
68
- r.textContent = `{{${i}${e}_${o}_omnibus_price}}`;
68
+ r.textContent = `{{${i}${t}_${o}_omnibus_price}}`;
69
69
  const s = r.closest("p");
70
70
  s && (s.setAttribute("product-attr", "omnibus_price"), s.setAttribute("composition", "true"));
71
71
  }
72
72
  break;
73
73
  }
74
74
  case "productOmnibusDiscount": {
75
- const r = t.querySelector(".omnibus-discount-value");
75
+ const r = e.querySelector(".omnibus-discount-value");
76
76
  if (r) {
77
- r.textContent = `{{${i}${e}_${o}_omnibus_discount}}`;
77
+ r.textContent = `{{${i}${t}_${o}_omnibus_discount}}`;
78
78
  const s = r.closest("p");
79
79
  s && (s.setAttribute("product-attr", "omnibus_discount"), s.setAttribute("composition", "true"));
80
80
  }
81
81
  break;
82
82
  }
83
83
  default: {
84
- const r = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
84
+ const r = e.getAttribute("product-attr") ? e : e.querySelector("[product-attr]");
85
85
  if (r) {
86
86
  const s = r.getAttribute("product-attr"), a = r.querySelector("p");
87
- a && (m(a).textContent = `{{${i}${e}_${o}_${s}}}`);
87
+ a && (m(a).textContent = `{{${i}${t}_${o}_${s}}}`);
88
88
  }
89
89
  break;
90
90
  }
91
91
  }
92
92
  }
93
- const R = "name";
94
- function S(t, n, e, o) {
95
- const c = `${o}${n}_${e}_${R}`;
96
- return {
97
- open: t.createComment(`{% if ${c} and ${c} != "" %}`),
98
- close: t.createComment("{% endif %}")
99
- };
100
- }
101
- function P(t, n, e, o) {
102
- if (!t.innerHTML.includes("{{"))
103
- return;
104
- const { open: c, close: i } = S(t.ownerDocument, n, e, o);
105
- t.insertBefore(c, t.firstChild), t.appendChild(i);
106
- }
107
- function T(t, n, e, o) {
108
- if (!t.innerHTML.includes("{{"))
109
- return;
110
- const { open: c, close: i } = S(t.ownerDocument, n, e, o), r = t.parentNode;
111
- r.insertBefore(c, t), r.insertBefore(i, t.nextSibling);
112
- }
113
- function L(t, n, e, o) {
114
- t.querySelectorAll(".recommendation-product-row").forEach((i, r) => {
93
+ function E(e, n, t, o) {
94
+ e.querySelectorAll(".recommendation-product-row").forEach((i, r) => {
115
95
  i.querySelectorAll("[data-attribute-type]").forEach((a) => {
116
96
  const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
117
97
  p.length > 0 ? p.forEach((l) => {
118
- y(l, u, n, r, e, o);
119
- }) : y(a, u, n, r, e, o);
120
- }), T(i, n, r, o);
98
+ h(l, u, n, r, t, o);
99
+ }) : h(a, u, n, r, t, o);
100
+ });
121
101
  });
122
102
  }
123
- function O(t, n, e, o) {
124
- const c = t.querySelectorAll(".recommendation-product-row");
103
+ function P(e, n, t, o) {
104
+ const c = e.querySelectorAll(".recommendation-product-row");
125
105
  if (!c.length)
126
106
  return;
127
107
  const [i] = c, r = i.querySelector("[data-attribute-type]"), s = r ? r.querySelectorAll(".attribute-cell").length : 1;
128
108
  c.forEach((a, u) => {
129
109
  a.querySelectorAll("[data-attribute-type]").forEach((l) => {
130
110
  const d = l.getAttribute("data-attribute-type") || "";
131
- l.querySelectorAll(".attribute-cell").forEach(($, _) => {
132
- const A = u * s + _;
133
- y($, d, n, A, e, o), P($, n, A, o);
111
+ l.querySelectorAll(".attribute-cell").forEach((A, $) => {
112
+ const S = u * s + $;
113
+ h(A, d, n, S, t, o);
134
114
  });
135
115
  });
136
116
  });
137
117
  }
138
- function v(t, n, e, o) {
139
- t.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
140
- O(i, n, e, o);
118
+ function R(e, n, t, o) {
119
+ e.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
120
+ P(i, n, t, o);
141
121
  });
142
122
  }
143
- function B(t, n, e) {
144
- const o = t.getAttribute("data-layout") || "grid", c = t.getAttribute("currency-alignment") || "after";
145
- o === "list" ? L(t, n, c, e) : v(t, n, c, e);
123
+ function O(e, n, t) {
124
+ const o = e.getAttribute("data-layout") || "grid", c = e.getAttribute("currency-alignment") || "after";
125
+ o === "list" ? E(e, n, c, t) : R(e, n, c, t);
146
126
  }
147
- function h(t, n, e) {
148
- const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), c = t.match(o);
149
- return c ? parseInt(c[1]) : e;
127
+ function y(e, n, t) {
128
+ const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), c = e.match(o);
129
+ return c ? parseInt(c[1]) : t;
150
130
  }
151
- function D(t, n) {
152
- let e = t.parentElement;
153
- for (; e && e !== n; ) {
154
- if (e.tagName === "TD") {
155
- const o = e.getAttribute("width");
131
+ function T(e, n) {
132
+ let t = e.parentElement;
133
+ for (; t && t !== n; ) {
134
+ if (t.tagName === "TD") {
135
+ const o = t.getAttribute("width");
156
136
  if (o && o.endsWith("%") && parseFloat(o) < 100)
157
- return e;
137
+ return t;
158
138
  }
159
- e = e.parentElement;
139
+ t = t.parentElement;
160
140
  }
161
141
  return null;
162
142
  }
163
- function M(t) {
164
- const n = t.getAttribute("style") || "", e = h(n, "width", 600), o = h(n, "padding", 0) * 2, c = Math.max(0, e - o);
165
- c !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
143
+ function v(e) {
144
+ const n = e.getAttribute("style") || "", t = y(n, "width", 600), o = y(n, "padding", 0) * 2, c = Math.max(0, t - o);
145
+ c !== 0 && e.querySelectorAll("img.adapt-img").forEach((i) => {
166
146
  if (i.hasAttribute("width"))
167
147
  return;
168
- const r = D(i, t);
148
+ const r = T(i, e);
169
149
  if (!r)
170
150
  return;
171
- const s = r.getAttribute("width"), a = parseFloat(s), u = h(r.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(c * a / 100), l = Math.max(1, p - u);
151
+ const s = r.getAttribute("width"), a = parseFloat(s), u = y(r.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(c * a / 100), l = Math.max(1, p - u);
172
152
  i.setAttribute("width", String(l));
173
153
  const d = i.getAttribute("style") || "";
174
154
  if (!/\bwidth\s*:\s*\d/i.test(d)) {
@@ -177,25 +157,25 @@ function M(t) {
177
157
  }
178
158
  });
179
159
  }
180
- function N(t, n) {
181
- const e = t.match(/<!DOCTYPE[^>]*>/i);
182
- return (e ? `${e[0]}
160
+ function W(e, n) {
161
+ const t = e.match(/<!DOCTYPE[^>]*>/i);
162
+ return (t ? `${t[0]}
183
163
  ` : "") + n.documentElement.outerHTML;
184
164
  }
185
- function k(t) {
186
- const n = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
165
+ function F(e) {
166
+ const n = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), t = new DOMParser().parseFromString(n, "text/html"), o = t.querySelectorAll(".recommendation-block-v2");
187
167
  if (!o.length)
188
- return t;
189
- const { buildCampaignUrl: c } = g(), i = E();
168
+ return e;
169
+ const { buildCampaignUrl: c } = g(), i = C();
190
170
  i.recommendationCampaignUrls = {};
191
- const { isFeatureEnabled: r } = C(), s = r("liquidSyntax") ? "reco_" : "";
171
+ const { isFeatureEnabled: r } = _(), s = r("liquidSyntax") ? "reco_" : "";
192
172
  return o.forEach((u) => {
193
173
  var l, d;
194
174
  const p = u.getAttribute("recommendation-id");
195
- p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((f) => f.remove()), c(p), w(u) || B(u, p, s), M(u));
196
- }), N(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
175
+ p && ((l = u.parentNode) == null || l.insertBefore(t.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(t.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((f) => f.remove()), c(p), w(u) || O(u, p, s), v(u));
176
+ }), W(n, t).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
197
177
  }
198
178
  export {
199
179
  b as formatPriceVariable,
200
- k as prepareRecommendationBlocks
180
+ F as prepareRecommendationBlocks
201
181
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.9.0-beta.fcaa08b",
3
+ "version": "3.9.0",
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",