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