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