@useinsider/guido 3.30.0-beta.411ba02 → 3.30.0-beta.52efeeb
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/migrator/recommendation/extractors.js +180 -72
- package/dist/config/migrator/recommendation/themeMapper.js +33 -21
- package/dist/config/migrator/recommendationMigrator.js +53 -48
- package/dist/package.json.js +6 -6
- package/dist/src/config/migrator/recommendation/extractors.d.ts +15 -1
- package/package.json +1 -1
|
@@ -1,114 +1,222 @@
|
|
|
1
|
-
import { CURRENCY_ATTR as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
1
|
+
import { CURRENCY_ATTR as m, CSS_CLASS_SKIP_COMPILE as _ } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
2
|
+
const h = "You May Also Like!";
|
|
3
|
+
function v(t) {
|
|
4
4
|
var n;
|
|
5
|
-
const r =
|
|
5
|
+
const r = t.querySelector(".ext-recommendation-title");
|
|
6
6
|
if (!r)
|
|
7
|
-
return
|
|
8
|
-
const
|
|
9
|
-
return
|
|
7
|
+
return h;
|
|
8
|
+
const o = (n = r.textContent) == null ? void 0 : n.trim();
|
|
9
|
+
return o && o.length > 0 ? o : h;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
const r =
|
|
11
|
+
function K(t) {
|
|
12
|
+
const r = t.querySelector(".ext-recommendation-title");
|
|
13
13
|
return r ? !/display\s*:\s*none/i.test(r.getAttribute("style") ?? "") : !1;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
var
|
|
17
|
-
const r =
|
|
18
|
-
return !!r && !((
|
|
15
|
+
function $(t) {
|
|
16
|
+
var o;
|
|
17
|
+
const r = t.querySelector(".ext-recommendation-title");
|
|
18
|
+
return !!r && !((o = r == null ? void 0 : r.textContent) != null && o.trim());
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
const r =
|
|
22
|
-
return !r || !
|
|
20
|
+
function V(t) {
|
|
21
|
+
const r = t.querySelector(".ext-product-price"), o = t.querySelector(".ext-product-original-price");
|
|
22
|
+
return !r || !o ? !1 : r.compareDocumentPosition(o) === Node.DOCUMENT_POSITION_PRECEDING;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return /(?:^|;)\s*display\s*:\s*table-cell/i.test(
|
|
24
|
+
function S(t) {
|
|
25
|
+
return /(?:^|;)\s*display\s*:\s*table-cell/i.test(t.getAttribute("style") ?? "");
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
var n,
|
|
29
|
-
const r = (n =
|
|
30
|
-
return !r || !
|
|
27
|
+
function X(t) {
|
|
28
|
+
var n, e;
|
|
29
|
+
const r = (n = t.querySelector(".ext-product-price")) == null ? void 0 : n.closest("tr"), o = (e = t.querySelector(".ext-product-original-price")) == null ? void 0 : e.closest("tr");
|
|
30
|
+
return !r || !o || r === o ? !1 : !S(r) && !S(o);
|
|
31
31
|
}
|
|
32
|
-
const
|
|
32
|
+
const E = /* @__PURE__ */ new Map([
|
|
33
33
|
["p_name", ".ext-product-name p"],
|
|
34
34
|
["p_price", ".ext-product-price p"],
|
|
35
35
|
["p_original_price", ".ext-product-original-price p"]
|
|
36
36
|
]);
|
|
37
|
-
function
|
|
38
|
-
const r = ((
|
|
37
|
+
function A(t) {
|
|
38
|
+
const r = ((t == null ? void 0 : t.getAttribute("style")) ?? "").match(/(?:^|;)\s*color\s*:\s*([^;]+)/i);
|
|
39
39
|
return (r == null ? void 0 : r[1].trim()) || void 0;
|
|
40
40
|
}
|
|
41
|
-
const
|
|
42
|
-
function
|
|
43
|
-
return
|
|
44
|
-
var s,
|
|
45
|
-
const n =
|
|
41
|
+
const L = "ins-trim-text";
|
|
42
|
+
function j(t, r) {
|
|
43
|
+
return t == null ? void 0 : t.map((o) => {
|
|
44
|
+
var s, d;
|
|
45
|
+
const n = E.get(o.variable ?? "");
|
|
46
46
|
if (!n)
|
|
47
|
-
return
|
|
48
|
-
const
|
|
49
|
-
return !
|
|
50
|
-
...
|
|
47
|
+
return o;
|
|
48
|
+
const e = r.querySelector(n), i = (d = (s = o.theme) == null ? void 0 : s.textColor) != null && d.color ? void 0 : A(e), c = o.variable === "p_name" && (e == null ? void 0 : e.classList.contains(L));
|
|
49
|
+
return !i && !c ? o : {
|
|
50
|
+
...o,
|
|
51
51
|
theme: {
|
|
52
|
-
...
|
|
53
|
-
...
|
|
54
|
-
...
|
|
52
|
+
...o.theme,
|
|
53
|
+
...i ? { textColor: { color: i } } : {},
|
|
54
|
+
...c ? { textTrimming: !0 } : {}
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
const R = /^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([\d.,\s%]+\)|[a-z]+)$/i, I = new Set(
|
|
60
|
+
["none", "transparent", "inherit", "initial", "unset", "revert", "currentColor"].map((t) => t.toLowerCase())
|
|
61
|
+
), O = /^(\d+(?:\.\d+)?)(?:px)?$/i, P = /* @__PURE__ */ new Set([
|
|
62
|
+
"none",
|
|
63
|
+
"hidden",
|
|
64
|
+
"dotted",
|
|
65
|
+
"dashed",
|
|
66
|
+
"solid",
|
|
67
|
+
"double",
|
|
68
|
+
"groove",
|
|
69
|
+
"ridge",
|
|
70
|
+
"inset",
|
|
71
|
+
"outset"
|
|
72
|
+
]), w = /\s/, B = /\s*!important\s*$/i, N = ["padding-top", "padding-right", "padding-bottom", "padding-left"];
|
|
73
|
+
function x(t) {
|
|
74
|
+
const r = /* @__PURE__ */ new Map();
|
|
75
|
+
return ((t == null ? void 0 : t.getAttribute("style")) ?? "").split(";").forEach((o, n) => {
|
|
76
|
+
const e = o.indexOf(":");
|
|
77
|
+
if (e < 0)
|
|
78
|
+
return;
|
|
79
|
+
const i = o.slice(0, e).trim().toLowerCase(), c = o.slice(e + 1).replace(B, "").trim();
|
|
80
|
+
i && c && r.set(i, { value: c, position: n });
|
|
81
|
+
}), r;
|
|
82
|
+
}
|
|
83
|
+
function u(t, r) {
|
|
84
|
+
var o;
|
|
85
|
+
return (o = t.get(r)) == null ? void 0 : o.value;
|
|
86
|
+
}
|
|
87
|
+
function l(t) {
|
|
88
|
+
return t && R.test(t) && !I.has(t.toLowerCase()) ? t : void 0;
|
|
89
|
+
}
|
|
90
|
+
function f(t) {
|
|
91
|
+
const r = t == null ? void 0 : t.match(O);
|
|
92
|
+
return (r == null ? void 0 : r[1]) !== void 0 ? Number(r[1]) : void 0;
|
|
93
|
+
}
|
|
94
|
+
function b(t) {
|
|
95
|
+
const r = t == null ? void 0 : t.toLowerCase();
|
|
96
|
+
return r && P.has(r) ? r : void 0;
|
|
97
|
+
}
|
|
98
|
+
function T(t) {
|
|
99
|
+
let r = 0;
|
|
100
|
+
return Array.from(t).reduce((n, e) => (e === "(" ? r += 1 : e === ")" && r > 0 && (r -= 1), r === 0 && w.test(e) ? n.push("") : n[n.length - 1] += e, n), [""]).filter(Boolean);
|
|
101
|
+
}
|
|
102
|
+
function y(t, r) {
|
|
103
|
+
const o = T(t ?? "").map(r);
|
|
104
|
+
if (o.length === 0 || o.length > 4 || o.some((s) => s === void 0))
|
|
105
|
+
return;
|
|
106
|
+
const [n, e = n, i = n, c = e] = o;
|
|
107
|
+
return { top: n, right: e, bottom: i, left: c };
|
|
108
|
+
}
|
|
109
|
+
function D(t) {
|
|
110
|
+
const r = u(t, "padding");
|
|
111
|
+
if (r !== void 0)
|
|
112
|
+
return y(r, f);
|
|
113
|
+
const [o, n, e, i] = N.map((c) => f(u(t, c)));
|
|
114
|
+
if (!(o === void 0 || n === void 0 || e === void 0 || i === void 0))
|
|
115
|
+
return { top: o, right: n, bottom: e, left: i };
|
|
116
|
+
}
|
|
117
|
+
function q(t) {
|
|
118
|
+
return t === void 0 ? void 0 : { top: t, right: t, bottom: t, left: t };
|
|
119
|
+
}
|
|
120
|
+
function k(t) {
|
|
121
|
+
return T(t ?? "").reduce((o, n) => {
|
|
122
|
+
const e = f(n), i = b(n), c = l(n);
|
|
123
|
+
if (o) {
|
|
124
|
+
if (e !== void 0 && o.width === void 0)
|
|
125
|
+
return { ...o, width: e };
|
|
126
|
+
if (i && !o.style)
|
|
127
|
+
return { ...o, style: i };
|
|
128
|
+
if (c && !o.color)
|
|
129
|
+
return { ...o, color: c };
|
|
130
|
+
}
|
|
131
|
+
}, {}) ?? {};
|
|
132
|
+
}
|
|
133
|
+
function p(t, r, o, n) {
|
|
134
|
+
var s, d;
|
|
135
|
+
const e = y(u(t, r), o), i = q(n);
|
|
136
|
+
return (((s = t.get(r)) == null ? void 0 : s.position) ?? -1) > (((d = t.get("border")) == null ? void 0 : d.position) ?? -1) ? e ?? i : i ?? e;
|
|
137
|
+
}
|
|
138
|
+
function M(t) {
|
|
139
|
+
const r = k(u(t, "border")), o = p(t, "border-width", f, r.width);
|
|
140
|
+
if (!o)
|
|
141
|
+
return;
|
|
142
|
+
const n = p(t, "border-style", b, r.style), e = p(t, "border-color", l, r.color);
|
|
143
|
+
return {
|
|
144
|
+
width: o,
|
|
145
|
+
...n ? { style: n } : {},
|
|
146
|
+
...e ? { color: e } : {}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function C(t) {
|
|
150
|
+
return l(u(t, "background")) ?? l(u(t, "background-color"));
|
|
151
|
+
}
|
|
152
|
+
function Y(t, r = {}) {
|
|
153
|
+
var a, g;
|
|
154
|
+
const o = x(t.querySelector(".ext-product-button a.es-button")), n = x(t.querySelector(".ext-product-button .es-button-border")), e = {}, i = (a = r.buttonColor) != null && a.color ? void 0 : C(n) ?? C(o), c = (g = r.textButtonColor) != null && g.color ? void 0 : l(u(o, "color")), s = r.buttonBorder === void 0 ? M(n) : void 0, d = r.buttonInternalPadding === void 0 ? D(o) : void 0;
|
|
155
|
+
return i && (e.buttonColor = { color: i }), c && (e.textButtonColor = { color: c }), s && (e.buttonBorder = s), d && (e.buttonInternalPadding = { desktop: d }), e;
|
|
156
|
+
}
|
|
157
|
+
function H(t, r) {
|
|
158
|
+
return t == null ? void 0 : t.map((o) => {
|
|
159
|
+
if (o.variable !== "p_button")
|
|
160
|
+
return o;
|
|
161
|
+
const n = Y(r, o.theme ?? {});
|
|
162
|
+
return Object.keys(n).length === 0 ? o : { ...o, theme: { ...o.theme, ...n } };
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function W(t) {
|
|
60
166
|
const r = [
|
|
61
|
-
|
|
62
|
-
...Array.from(
|
|
167
|
+
t,
|
|
168
|
+
...Array.from(t.querySelectorAll(".product-card, .ext-recommendation-card"))
|
|
63
169
|
];
|
|
64
|
-
let
|
|
170
|
+
let o = "";
|
|
65
171
|
return r.some((n) => {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
return
|
|
69
|
-
const
|
|
70
|
-
return
|
|
71
|
-
}),
|
|
72
|
-
}
|
|
73
|
-
function
|
|
74
|
-
const r =
|
|
172
|
+
const e = n.getAttribute("bgcolor");
|
|
173
|
+
if (e && e.trim())
|
|
174
|
+
return o = e.trim(), !0;
|
|
175
|
+
const c = (n.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
|
|
176
|
+
return c && c[1] ? (o = c[1].trim(), !0) : !1;
|
|
177
|
+
}), o;
|
|
178
|
+
}
|
|
179
|
+
function z(t) {
|
|
180
|
+
const r = t.getAttribute(m.CURRENCY), o = t.getAttribute(m.SYMBOL);
|
|
75
181
|
return {
|
|
76
182
|
...r ? { value: r } : {},
|
|
77
183
|
// An empty `currency-symbol` is omitted so `mapCurrency` falls back to
|
|
78
184
|
// the currency code as the symbol.
|
|
79
|
-
...
|
|
185
|
+
...o ? { symbol: o } : {},
|
|
80
186
|
alignment: 1,
|
|
81
187
|
decimalCount: "2",
|
|
82
188
|
decimalSeparator: ",",
|
|
83
189
|
thousandSeparator: "."
|
|
84
190
|
};
|
|
85
191
|
}
|
|
86
|
-
const
|
|
87
|
-
function
|
|
88
|
-
const r =
|
|
192
|
+
const F = /^es-p(\d+)([trbl]?)$/, G = { t: "top", r: "right", b: "bottom", l: "left" };
|
|
193
|
+
function J(t) {
|
|
194
|
+
const r = t.querySelector("td.esd-structure.esd-extension-internal-block");
|
|
89
195
|
if (!r)
|
|
90
196
|
return;
|
|
91
|
-
const
|
|
197
|
+
const o = { top: 0, right: 0, bottom: 0, left: 0 };
|
|
92
198
|
return r.classList.forEach((n) => {
|
|
93
|
-
const
|
|
94
|
-
if (!
|
|
199
|
+
const e = n.match(F);
|
|
200
|
+
if (!e)
|
|
95
201
|
return;
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
}),
|
|
202
|
+
const i = Number(e[1]), c = e[2];
|
|
203
|
+
c ? o[G[c]] = i : Object.assign(o, { top: i, right: i, bottom: i, left: i });
|
|
204
|
+
}), o;
|
|
99
205
|
}
|
|
100
|
-
function
|
|
101
|
-
return
|
|
206
|
+
function Q(t) {
|
|
207
|
+
return t.classList.contains(_);
|
|
102
208
|
}
|
|
103
209
|
export {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
210
|
+
W as extractCardBgColor,
|
|
211
|
+
z as extractCurrencyFromBlock,
|
|
212
|
+
J as extractRenderedBlockPadding,
|
|
213
|
+
Y as extractRenderedButtonTheme,
|
|
214
|
+
v as extractTitleText,
|
|
215
|
+
$ as hasEmptyTitle,
|
|
216
|
+
K as hasVisibleTitle,
|
|
217
|
+
V as isOldPriceFirst,
|
|
218
|
+
Q as isPartnerManagedBlock,
|
|
219
|
+
X as isPriceOnNextLine,
|
|
220
|
+
H as withRenderedButtonTheme,
|
|
221
|
+
j as withRenderedTextTheme
|
|
114
222
|
};
|
|
@@ -16,21 +16,21 @@ function P(n) {
|
|
|
16
16
|
const t = n.top ?? n.all ?? 0, o = n.right ?? n.all ?? 0, i = n.bottom ?? n.all ?? 0, l = n.left ?? n.all ?? 0;
|
|
17
17
|
return t === 0 && o === 0 && i === 0 && l === 0 ? null : `${t}px ${o}px ${i}px ${l}px`;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function C(n) {
|
|
20
20
|
if (!n)
|
|
21
21
|
return null;
|
|
22
22
|
const { top: t, right: o, bottom: i, left: l } = n;
|
|
23
23
|
return t === void 0 ? null : t === o && t === i && t === l ? t : null;
|
|
24
24
|
}
|
|
25
25
|
function $(n, t, o, i) {
|
|
26
|
-
const l =
|
|
26
|
+
const l = C(o);
|
|
27
27
|
if (l !== null) {
|
|
28
28
|
r(n, `border-${t}`, i(l));
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
o && (r(n, `border-top-${t}`, o.top !== void 0 ? i(o.top) : null), r(n, `border-right-${t}`, o.right !== void 0 ? i(o.right) : null), r(n, `border-bottom-${t}`, o.bottom !== void 0 ? i(o.bottom) : null), r(n, `border-left-${t}`, o.left !== void 0 ? i(o.left) : null));
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function I(n) {
|
|
34
34
|
if (!n)
|
|
35
35
|
return null;
|
|
36
36
|
const t = x(n.radius ?? n.borderRadius);
|
|
@@ -42,14 +42,14 @@ function D(n) {
|
|
|
42
42
|
}
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function v(n) {
|
|
46
46
|
var t, o;
|
|
47
47
|
return ((t = n.textLineSpacing) == null ? void 0 : t.lineSpacing) ?? ((o = n.textLineSpacing) == null ? void 0 : o["font-lineSpacing"]);
|
|
48
48
|
}
|
|
49
49
|
function N(n) {
|
|
50
|
-
var u, s, a, d, g,
|
|
50
|
+
var u, s, a, d, g, p, b, y;
|
|
51
51
|
const t = [], o = [], i = (u = n == null ? void 0 : n.textAlign) == null ? void 0 : u.align, l = P((s = n == null ? void 0 : n.textPadding) == null ? void 0 : s.desktop), f = (a = n == null ? void 0 : n.textStyle) == null ? void 0 : a["font-weight"], c = (d = n == null ? void 0 : n.textStyle) == null ? void 0 : d["font-style"];
|
|
52
|
-
return r(t, "background-color", (g = n == null ? void 0 : n.textBackgroundColor) == null ? void 0 : g.color), r(t, "padding", l), r(o, "font-family", (
|
|
52
|
+
return r(t, "background-color", (g = n == null ? void 0 : n.textBackgroundColor) == null ? void 0 : g.color), r(t, "padding", l), r(o, "font-family", (p = n == null ? void 0 : n.textStyle) == null ? void 0 : p["font-family"]), r(o, "font-size", (b = n == null ? void 0 : n.textStyle) == null ? void 0 : b["font-size"]), r(o, "font-weight", f), r(o, "font-style", c), r(o, "color", (y = n == null ? void 0 : n.textColor) == null ? void 0 : y.color), r(o, "line-height", v(n ?? {})), r(o, "text-align", i), {
|
|
53
53
|
tdStyle: t.join("; "),
|
|
54
54
|
pStyle: o.join("; "),
|
|
55
55
|
align: i || void 0,
|
|
@@ -59,47 +59,59 @@ function N(n) {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
function E(n) {
|
|
62
|
-
var s, a, d, g,
|
|
62
|
+
var s, a, d, g, p, b, y, k, w, B, j, T;
|
|
63
63
|
const t = [], o = [], i = [];
|
|
64
|
-
r(t, "padding", P((s = n == null ? void 0 : n.buttonExternalPadding) == null ? void 0 : s.desktop)), r(i, "padding", P((a = n == null ? void 0 : n.buttonInternalPadding) == null ? void 0 : a.desktop)), r(i, "font-family", (d = n == null ? void 0 : n.buttonStyle) == null ? void 0 : d["font-family"]), r(i, "font-size", (g = n == null ? void 0 : n.buttonStyle) == null ? void 0 : g["font-size"]), r(i, "font-weight", (
|
|
64
|
+
r(t, "padding", P((s = n == null ? void 0 : n.buttonExternalPadding) == null ? void 0 : s.desktop)), r(i, "padding", P((a = n == null ? void 0 : n.buttonInternalPadding) == null ? void 0 : a.desktop)), r(i, "font-family", (d = n == null ? void 0 : n.buttonStyle) == null ? void 0 : d["font-family"]), r(i, "font-size", (g = n == null ? void 0 : n.buttonStyle) == null ? void 0 : g["font-size"]), r(i, "font-weight", (p = n == null ? void 0 : n.buttonStyle) == null ? void 0 : p["font-weight"]), r(i, "font-style", (b = n == null ? void 0 : n.buttonStyle) == null ? void 0 : b["font-style"]);
|
|
65
65
|
const l = (y = n == null ? void 0 : n.buttonColor) == null ? void 0 : y.color, f = (k = n == null ? void 0 : n.textButtonColor) == null ? void 0 : k.color;
|
|
66
|
-
r(o, "background", l), r(i, "background", l), r(i, "color", f);
|
|
66
|
+
r(o, "background", l), r(i, "background", l), r(i, "color", f), r(i, "mso-border-alt", l ? `10px solid ${l}` : void 0);
|
|
67
67
|
const c = n == null ? void 0 : n.buttonBorder;
|
|
68
68
|
$(o, "width", c == null ? void 0 : c.width, (S) => `${S}px`), $(o, "style", c == null ? void 0 : c.style, (S) => S), $(o, "color", c == null ? void 0 : c.color, (S) => S);
|
|
69
|
-
const u =
|
|
69
|
+
const u = I((n == null ? void 0 : n.buttonBorderRadius) ?? (n == null ? void 0 : n.borderRadius));
|
|
70
70
|
return u && (r(o, "border-radius", u), r(i, "border-radius", u)), ((w = n == null ? void 0 : n.buttonStretch) == null ? void 0 : w.stretched) === !1 ? (r(o, "display", "inline-block"), r(i, "display", "inline-block")) : ((B = n == null ? void 0 : n.buttonStretch) == null ? void 0 : B.stretched) === !0 && (r(o, "display", "block"), r(i, "display", "block")), {
|
|
71
71
|
tdStyle: t.join("; "),
|
|
72
|
-
align: ((
|
|
72
|
+
align: ((j = n == null ? void 0 : n.buttonAlign) == null ? void 0 : j.align) || void 0,
|
|
73
73
|
spanStyle: o.join("; "),
|
|
74
74
|
aStyle: i.join("; "),
|
|
75
|
-
text: (
|
|
75
|
+
text: (T = n == null ? void 0 : n.buttonText) == null ? void 0 : T.text
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function R(n) {
|
|
79
79
|
var t, o;
|
|
80
80
|
return {
|
|
81
81
|
width: x((t = n == null ? void 0 : n.imageSize) == null ? void 0 : t.width),
|
|
82
82
|
height: x((o = n == null ? void 0 : n.imageSize) == null ? void 0 : o.height)
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
const A = /* @__PURE__ */ new Set([5, 10, 15, 20, 25, 30, 35, 40]),
|
|
86
|
-
function
|
|
85
|
+
const A = /* @__PURE__ */ new Set([5, 10, 15, 20, 25, 30, 35, 40]), L = [["t", "top"], ["r", "right"], ["b", "bottom"], ["l", "left"]];
|
|
86
|
+
function _(n) {
|
|
87
87
|
if (!n)
|
|
88
88
|
return;
|
|
89
89
|
const t = [], o = [];
|
|
90
|
-
return
|
|
90
|
+
return L.forEach(([i, l]) => {
|
|
91
91
|
const f = x(n[l] ?? n.all) ?? 0;
|
|
92
92
|
A.has(f) ? t.push(`es-p${f}${i}`) : f > 0 && o.push(`padding-${l}: ${f}px`);
|
|
93
93
|
}), { classes: t.join(" "), style: o.join("; ") };
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function z(n) {
|
|
96
|
+
return n.split(";").map((t) => t.trim()).filter(Boolean);
|
|
97
|
+
}
|
|
98
|
+
function D(n) {
|
|
99
|
+
const t = n.indexOf(":");
|
|
100
|
+
return (t === -1 ? n : n.slice(0, t)).trim().toLowerCase();
|
|
101
|
+
}
|
|
102
|
+
function F(n, t) {
|
|
96
103
|
const o = (n ?? "").trim().replace(/;$/, "").trim(), i = (t ?? "").trim().replace(/;$/, "").trim();
|
|
97
|
-
|
|
104
|
+
if (!o)
|
|
105
|
+
return i;
|
|
106
|
+
if (!i)
|
|
107
|
+
return o;
|
|
108
|
+
const l = new Set(z(i).map(D)), f = z(o), c = f.filter((u) => !l.has(D(u)));
|
|
109
|
+
return c.length === f.length ? `${o}; ${i}` : c.length ? `${c.join("; ")}; ${i}` : i;
|
|
98
110
|
}
|
|
99
111
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
112
|
+
F as appendStyle,
|
|
113
|
+
_ as mapBlockPadding,
|
|
102
114
|
E as mapButtonTheme,
|
|
103
|
-
|
|
115
|
+
R as mapImageTheme,
|
|
104
116
|
N as mapTextTheme
|
|
105
117
|
};
|
|
@@ -1,59 +1,64 @@
|
|
|
1
|
-
import { BlockId as
|
|
2
|
-
import { DEFAULT_NODE_CONFIG as
|
|
3
|
-
import {
|
|
4
|
-
import { useTemplateStore as
|
|
5
|
-
import { mapComposition as
|
|
6
|
-
import { isPriceOnNextLine as
|
|
7
|
-
import { buildBlockHtml as
|
|
8
|
-
import { parseRecommendationId as
|
|
9
|
-
import { mapSettings as
|
|
10
|
-
import { mapBlockPadding as
|
|
11
|
-
const
|
|
12
|
-
function
|
|
13
|
-
var l,
|
|
14
|
-
const t =
|
|
1
|
+
import { BlockId as C } from "../../enums/block.js";
|
|
2
|
+
import { DEFAULT_NODE_CONFIG as b } from "../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
3
|
+
import { ATTR_PRODUCT_BUTTON as f, ATTR_RECOMMENDATION_TITLE as T } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useTemplateStore as x } from "../../stores/template.js";
|
|
5
|
+
import { mapComposition as M } from "./recommendation/compositionMapper.js";
|
|
6
|
+
import { isPriceOnNextLine as B, extractCurrencyFromBlock as S, isOldPriceFirst as E, withRenderedButtonTheme as w, withRenderedTextTheme as L, extractRenderedButtonTheme as O, extractTitleText as P, hasEmptyTitle as A, hasVisibleTitle as H, extractCardBgColor as N, isPartnerManagedBlock as F, extractRenderedBlockPadding as I } from "./recommendation/extractors.js";
|
|
7
|
+
import { buildBlockHtml as _ } from "./recommendation/htmlBuilder.js";
|
|
8
|
+
import { parseRecommendationId as D, parseLegacyConfig as $ } from "./recommendation/parseLegacyConfig.js";
|
|
9
|
+
import { mapSettings as k } from "./recommendation/settingsMapper.js";
|
|
10
|
+
import { mapButtonTheme as U, mapBlockPadding as V } from "./recommendation/themeMapper.js";
|
|
11
|
+
const q = 'td[esd-dev-product-config][class*="ins-recommendation-v3-block-"]:not(.recommendation-block-v2), td.product-block[esd-handler-name*="EmailRecommendationV3"][esd-dev-product-config]:not(.recommendation-block-v2)';
|
|
12
|
+
function G(c, e, m) {
|
|
13
|
+
var l, p, g;
|
|
14
|
+
const t = D(e);
|
|
15
15
|
if (t === null)
|
|
16
16
|
return console.warn(
|
|
17
17
|
"[RecommendationMigrator] Skipping block — missing/invalid `ins-recommendation-v3-campaign-id`"
|
|
18
18
|
), !1;
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
19
|
+
const o = $(e);
|
|
20
|
+
if (!o)
|
|
21
21
|
return console.warn(
|
|
22
22
|
`[RecommendationMigrator] Aborting block id=${t} — \`esd-dev-product-config\` missing or unable to be parsed`
|
|
23
23
|
), !1;
|
|
24
|
-
const
|
|
25
|
-
...
|
|
26
|
-
currencySettings:
|
|
27
|
-
isPriceMovedToNextLine:
|
|
28
|
-
}, a =
|
|
29
|
-
w((l =
|
|
30
|
-
{ oldPriceFirst:
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
const i = m[String(t)] ?? {}, n = {
|
|
25
|
+
...i,
|
|
26
|
+
currencySettings: i.currencySettings ?? S(e),
|
|
27
|
+
isPriceMovedToNextLine: i.isPriceMovedToNextLine ?? B(e)
|
|
28
|
+
}, a = k(n, o, t), r = M(
|
|
29
|
+
w(L((l = o.composition) == null ? void 0 : l.variables, e), e),
|
|
30
|
+
{ oldPriceFirst: E(e) }
|
|
31
|
+
);
|
|
32
|
+
if (r.perElementStyles[f] === void 0) {
|
|
33
|
+
const u = O(e);
|
|
34
|
+
Object.keys(u).length > 0 && (r.perElementStyles[f] = U(u));
|
|
35
|
+
}
|
|
36
|
+
const y = P(e);
|
|
37
|
+
A(e) ? r.visibility[T] = !1 : r.titleVariable || (r.visibility[T] = H(e));
|
|
38
|
+
const v = N(e), h = {
|
|
34
39
|
...a,
|
|
35
40
|
strategyId: "",
|
|
36
|
-
composition:
|
|
37
|
-
visibility:
|
|
38
|
-
previousTitleHtml:
|
|
39
|
-
textTrimming:
|
|
40
|
-
}, s =
|
|
41
|
+
composition: r.composition,
|
|
42
|
+
visibility: r.visibility,
|
|
43
|
+
previousTitleHtml: b.previousTitleHtml,
|
|
44
|
+
textTrimming: r.anyTextTrimming
|
|
45
|
+
}, s = F(e), R = `
|
|
41
46
|
<table>
|
|
42
47
|
<tbody>
|
|
43
48
|
<tr>
|
|
44
49
|
<td class="esd-structure" align="left">
|
|
45
50
|
<table width="100%" cellpadding="0" cellspacing="0">
|
|
46
51
|
<tbody>
|
|
47
|
-
<tr>${
|
|
48
|
-
nodeConfig:
|
|
49
|
-
composition:
|
|
50
|
-
cardBg:
|
|
51
|
-
titleText:
|
|
52
|
+
<tr>${_({
|
|
53
|
+
nodeConfig: h,
|
|
54
|
+
composition: r,
|
|
55
|
+
cardBg: v,
|
|
56
|
+
titleText: y,
|
|
52
57
|
legacyId: e.getAttribute("id") ?? void 0,
|
|
53
58
|
legacyBgColor: e.getAttribute("bgcolor") ?? void 0,
|
|
54
59
|
preserveInnerHtml: s ? e.innerHTML : void 0,
|
|
55
60
|
skipCompile: s,
|
|
56
|
-
blockPadding:
|
|
61
|
+
blockPadding: V(((g = (p = o.theme) == null ? void 0 : p.blockPadding) == null ? void 0 : g.desktop) ?? I(e))
|
|
57
62
|
})}</tr>
|
|
58
63
|
</tbody>
|
|
59
64
|
</table>
|
|
@@ -61,12 +66,12 @@ function $(c, e, m) {
|
|
|
61
66
|
</tr>
|
|
62
67
|
</tbody>
|
|
63
68
|
</table>
|
|
64
|
-
`, d = c.parseFromString(
|
|
69
|
+
`, d = c.parseFromString(R, "text/html").querySelector("td.esd-structure");
|
|
65
70
|
return !d || !e.parentNode ? (console.warn(
|
|
66
71
|
`[RecommendationMigrator] Aborting block id=${t} — failed to construct new HTML element`
|
|
67
72
|
), !1) : (e.parentNode.replaceChild(d, e), !0);
|
|
68
73
|
}
|
|
69
|
-
function
|
|
74
|
+
function oe(c, e = {}) {
|
|
70
75
|
const m = new DOMParser();
|
|
71
76
|
let t;
|
|
72
77
|
try {
|
|
@@ -74,27 +79,27 @@ function X(c, e = {}) {
|
|
|
74
79
|
} catch (n) {
|
|
75
80
|
return console.error("[RecommendationMigrator] Failed to parse template:", n), c;
|
|
76
81
|
}
|
|
77
|
-
const
|
|
82
|
+
const o = Array.from(t.querySelectorAll(q));
|
|
78
83
|
try {
|
|
79
|
-
|
|
84
|
+
x().$patch((a) => {
|
|
80
85
|
a.migrations = {
|
|
81
86
|
...a.migrations,
|
|
82
|
-
[
|
|
87
|
+
[C.Recommendation]: o.length
|
|
83
88
|
};
|
|
84
89
|
});
|
|
85
90
|
} catch {
|
|
86
91
|
}
|
|
87
|
-
if (
|
|
92
|
+
if (o.length === 0)
|
|
88
93
|
return c;
|
|
89
|
-
let
|
|
90
|
-
return
|
|
94
|
+
let i = 0;
|
|
95
|
+
return o.forEach((n) => {
|
|
91
96
|
try {
|
|
92
|
-
|
|
97
|
+
G(m, n, e) && (i += 1);
|
|
93
98
|
} catch (a) {
|
|
94
99
|
console.error("[RecommendationMigrator] Unexpected error migrating block:", a);
|
|
95
100
|
}
|
|
96
|
-
}),
|
|
101
|
+
}), i > 0 && console.info(`[RecommendationMigrator] Migrated ${i} legacy Recommendation block(s)`), t.documentElement.outerHTML;
|
|
97
102
|
}
|
|
98
103
|
export {
|
|
99
|
-
|
|
104
|
+
oe as migrateRecommendation
|
|
100
105
|
};
|
package/dist/package.json.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
version:
|
|
3
|
-
guido:
|
|
1
|
+
const e = "3.30.0-beta.52efeeb", o = { stripo: { version: "2.87.0" } }, s = {
|
|
2
|
+
version: e,
|
|
3
|
+
guido: o
|
|
4
4
|
};
|
|
5
5
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
s as default,
|
|
7
|
+
o as guido,
|
|
8
|
+
e as version
|
|
9
9
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LegacyPaddingViewport, LegacyVariable } from './types';
|
|
1
|
+
import type { LegacyButtonTheme, LegacyPaddingViewport, LegacyVariable } from './types';
|
|
2
2
|
export declare function extractTitleText(block: Element): string;
|
|
3
3
|
/**
|
|
4
4
|
* Fallback for legacy configs that carry no `p_recommendation_title` variable:
|
|
@@ -33,6 +33,20 @@ export declare function isPriceOnNextLine(block: Element): boolean;
|
|
|
33
33
|
* @returns The variables, with `textColor` / `textTrimming` filled from the rendered HTML where the theme lacks them
|
|
34
34
|
*/
|
|
35
35
|
export declare function withRenderedTextTheme(variables: LegacyVariable[] | undefined, block: Element): LegacyVariable[] | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Reads the first legacy product button's inline colors, border and internal padding.
|
|
38
|
+
* @param block - The legacy recommendation block element
|
|
39
|
+
* @param theme - The legacy button theme; keys it already holds are not read
|
|
40
|
+
* @returns Only the keys filled from the rendered button, or an empty object
|
|
41
|
+
*/
|
|
42
|
+
export declare function extractRenderedButtonTheme(block: Element, theme?: LegacyButtonTheme): LegacyButtonTheme;
|
|
43
|
+
/**
|
|
44
|
+
* Legacy keeps the product button's colors, border and internal padding inline on the rendered button.
|
|
45
|
+
* @param variables - The legacy composition variables
|
|
46
|
+
* @param block - The legacy recommendation block element
|
|
47
|
+
* @returns The variables, with the `p_button` theme filled from the rendered button where the theme lacks a value
|
|
48
|
+
*/
|
|
49
|
+
export declare function withRenderedButtonTheme(variables: LegacyVariable[] | undefined, block: Element): LegacyVariable[] | undefined;
|
|
36
50
|
/**
|
|
37
51
|
* Card background lives on either the block (`bgcolor`/`style`) or per-card
|
|
38
52
|
* cells (`.product-card`). Returns empty string when no background is set —
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.30.0-beta.
|
|
3
|
+
"version": "3.30.0-beta.52efeeb",
|
|
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",
|