@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
|
|
2
|
-
import { useRecommendation as
|
|
3
|
-
import { CSS_CLASS_RECO_BUTTON as
|
|
4
|
-
import { useRecommendationExtensionStore as
|
|
5
|
-
function y(r,
|
|
6
|
-
const c = `{{${
|
|
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
|
|
10
|
-
|
|
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
|
|
15
|
-
|
|
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
|
|
22
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
60
|
-
|
|
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
|
|
69
|
-
|
|
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
|
|
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}_${
|
|
83
|
+
u.textContent = `{{${c}${e}_${o}_${s}}}`;
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
86
|
break;
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
89
|
}
|
|
86
|
-
function
|
|
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,
|
|
92
|
-
}) : f(a, u,
|
|
95
|
+
f(l, u, n, t, e, o);
|
|
96
|
+
}) : f(a, u, n, t, e, o);
|
|
93
97
|
});
|
|
94
98
|
});
|
|
95
99
|
}
|
|
96
|
-
function
|
|
97
|
-
const
|
|
98
|
-
if (!
|
|
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] =
|
|
101
|
-
|
|
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((
|
|
105
|
-
const
|
|
106
|
-
f(
|
|
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
|
|
115
|
+
function R(r, n, e, o) {
|
|
112
116
|
r.querySelectorAll(".ins-recommendation-product-container").forEach((c) => {
|
|
113
|
-
|
|
117
|
+
E(c, n, e, o);
|
|
114
118
|
});
|
|
115
119
|
}
|
|
116
|
-
function
|
|
117
|
-
const o = r.getAttribute("data-layout") || "grid",
|
|
118
|
-
o === "list" ?
|
|
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,
|
|
121
|
-
const o = new RegExp(`${
|
|
122
|
-
return
|
|
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
|
|
128
|
+
function T(r, n) {
|
|
125
129
|
let e = r.parentElement;
|
|
126
|
-
for (; e && e !==
|
|
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
|
|
137
|
-
const
|
|
138
|
-
|
|
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 =
|
|
145
|
+
const t = T(c, r);
|
|
142
146
|
if (!t)
|
|
143
147
|
return;
|
|
144
|
-
const
|
|
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
|
|
157
|
+
function O(r, n) {
|
|
154
158
|
const e = r.match(/<!DOCTYPE[^>]*>/i);
|
|
155
159
|
return (e ? `${e[0]}
|
|
156
|
-
` : "") +
|
|
160
|
+
` : "") + n.documentElement.outerHTML;
|
|
157
161
|
}
|
|
158
162
|
function N(r) {
|
|
159
|
-
const
|
|
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:
|
|
166
|
+
const { buildCampaignUrl: i } = _(), c = C();
|
|
163
167
|
c.recommendationCampaignUrls = {};
|
|
164
|
-
const { isFeatureEnabled: t } =
|
|
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()),
|
|
169
|
-
}),
|
|
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("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
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.
|
|
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",
|