@useinsider/guido 3.5.0-beta.17c0032 → 3.5.0-beta.6656912

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