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