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