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