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