@useinsider/guido 3.7.2-beta.af89512 → 3.7.2-beta.b445a7a
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/composables/useHtmlCompiler.js +6 -8
- package/dist/config/compiler/htmlCompilerRules.js +7 -15
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +19 -25
- package/dist/config/migrator/index.js +7 -8
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +11 -10
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +24 -26
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +30 -39
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +28 -34
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +285 -333
- package/dist/extensions/Blocks/Recommendation/extension.js +6 -5
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +3 -2
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +142 -173
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +56 -30
- package/dist/extensions/Blocks/Recommendation/templates/index.js +29 -8
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +132 -105
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +44 -23
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +112 -64
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +219 -0
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +24 -19
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +30 -22
- package/dist/extensions/Blocks/controlFactories.js +159 -133
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +2 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +20 -47
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +165 -11
- package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +78 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +29 -9
- package/dist/src/extensions/Blocks/controlFactories.d.ts +11 -1
- package/package.json +1 -1
- package/dist/config/migrator/fontTagMigrator.js +0 -7
- package/dist/src/config/migrator/fontTagMigrator.d.ts +0 -8
- package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
- package/dist/src/utils/stripFontTags.d.ts +0 -13
- package/dist/utils/stripFontTags.js +0 -13
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { RecommendationBlockId as c } from "../constants/blockIds.js";
|
|
2
|
+
import { DESKTOP_CONTAINER_SELECTOR as S, ATTR_PRODUCT_NAME as k, ATTR_PRODUCT_PRICE as E, ATTR_PRODUCT_OLD_PRICE as h, ATTR_PRODUCT_OMNIBUS_PRICE as y, ATTR_PRODUCT_OMNIBUS_DISCOUNT as m, ATTR_PRODUCT_BUTTON as P, ATTR_PRODUCT_IMAGE as x, ATTR_PRODUCT_ATTR as v } from "../constants/selectors.js";
|
|
3
|
+
import { CSS_CLASS_TEXT_TRIM as B } from "../controls/shared/textTrimCssRules.js";
|
|
4
|
+
import { toCustomCompositionKey as U } from "../templates/utils.js";
|
|
5
|
+
import { extractWrapperTags as C } from "./preserveTextStyles.js";
|
|
6
|
+
import { hasQuerySelectorAll as A, hasGetAttribute as l, hasGetStyle as R, hasGetComputedStyle as q } from "./tagName.js";
|
|
7
|
+
const s = [
|
|
8
|
+
"font-size",
|
|
9
|
+
"font-family",
|
|
10
|
+
"font-weight",
|
|
11
|
+
"font-style",
|
|
12
|
+
"color",
|
|
13
|
+
"text-align",
|
|
14
|
+
"line-height",
|
|
15
|
+
"text-decoration"
|
|
16
|
+
], N = [
|
|
17
|
+
"background",
|
|
18
|
+
"background-color",
|
|
19
|
+
"border-width",
|
|
20
|
+
"border-color",
|
|
21
|
+
"border-style",
|
|
22
|
+
"border-radius"
|
|
23
|
+
], M = [
|
|
24
|
+
...s,
|
|
25
|
+
"background",
|
|
26
|
+
"background-color",
|
|
27
|
+
// Stripo's Border Radius control writes the radius to the anchor too, not just the
|
|
28
|
+
// border span — capture it so it survives regeneration (symmetric with BUTTON_BORDER_PROPS).
|
|
29
|
+
"border-radius",
|
|
30
|
+
"padding",
|
|
31
|
+
"width",
|
|
32
|
+
"mso-border-alt",
|
|
33
|
+
"mso-padding-alt"
|
|
34
|
+
], D = [
|
|
35
|
+
"display",
|
|
36
|
+
"width",
|
|
37
|
+
"height",
|
|
38
|
+
"max-width",
|
|
39
|
+
"border-radius",
|
|
40
|
+
"margin"
|
|
41
|
+
], b = /* @__PURE__ */ new Set(["transparent", "rgba(0, 0, 0, 0)"]), G = [
|
|
42
|
+
{ attrKey: k, blockId: c.NAME, kind: "text" },
|
|
43
|
+
{ attrKey: E, blockId: c.PRICE, kind: "text" },
|
|
44
|
+
{ attrKey: h, blockId: c.OLD_PRICE, kind: "text" },
|
|
45
|
+
{ attrKey: y, blockId: c.OMNIBUS_PRICE, kind: "text" },
|
|
46
|
+
{ attrKey: m, blockId: c.OMNIBUS_DISCOUNT, kind: "text" },
|
|
47
|
+
{ attrKey: P, blockId: c.BUTTON, kind: "button" },
|
|
48
|
+
{ attrKey: x, blockId: c.IMAGE, kind: "image" }
|
|
49
|
+
];
|
|
50
|
+
function _(t) {
|
|
51
|
+
return t && "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML().trim() : "";
|
|
52
|
+
}
|
|
53
|
+
function L(t) {
|
|
54
|
+
return t && "getInnerText" in t && typeof t.getInnerText == "function" ? t.getInnerText().trim() : "";
|
|
55
|
+
}
|
|
56
|
+
function a(t, e, r) {
|
|
57
|
+
!e || !R(e) || r.forEach((n) => {
|
|
58
|
+
const i = e.getStyle(n);
|
|
59
|
+
i && i !== "inherit" && i !== "initial" && (t[n] = i);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function I(t) {
|
|
63
|
+
return Object.entries(t).map(([e, r]) => `${e}: ${r};`).join(" ");
|
|
64
|
+
}
|
|
65
|
+
function O(t) {
|
|
66
|
+
if (!t || !R(t))
|
|
67
|
+
return;
|
|
68
|
+
const e = t.getStyle("background-color") || t.getStyle("background");
|
|
69
|
+
return e && !b.has(e) ? e : void 0;
|
|
70
|
+
}
|
|
71
|
+
function g(t, e) {
|
|
72
|
+
const r = {};
|
|
73
|
+
return a(r, t, e), I(r);
|
|
74
|
+
}
|
|
75
|
+
function w(t) {
|
|
76
|
+
const e = t.querySelector("p"), r = {};
|
|
77
|
+
a(r, t, s), a(r, e, s), a(r, t.querySelector("strong"), s), a(r, t.querySelector("em"), s), a(r, t.querySelector("s"), s);
|
|
78
|
+
const n = I(r), { openTags: i, closeTags: o } = C(_(e));
|
|
79
|
+
return !n && !i ? null : { pStyle: n || void 0, openTags: i, closeTags: o };
|
|
80
|
+
}
|
|
81
|
+
function K(t) {
|
|
82
|
+
const e = t.querySelector(".es-button-border"), r = t.querySelector("a.es-button") ?? t.querySelector("a"), n = g(e, N), i = g(r, M), o = e && "getAttribute" in e ? e.getAttribute("class") ?? "" : "", u = /\bes-fw\b/.test(o), { openTags: T, closeTags: d } = C(_(r)), p = L(r);
|
|
83
|
+
return !n && !i && !u && !T && !p ? null : {
|
|
84
|
+
buttonBorderStyle: n || void 0,
|
|
85
|
+
buttonAnchorStyle: i || void 0,
|
|
86
|
+
buttonFitToContainer: u || void 0,
|
|
87
|
+
buttonText: p || void 0,
|
|
88
|
+
openTags: T,
|
|
89
|
+
closeTags: d
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function H(t) {
|
|
93
|
+
const e = g(t.querySelector("img"), D);
|
|
94
|
+
return e ? { imgStyle: e } : null;
|
|
95
|
+
}
|
|
96
|
+
function $(t, e) {
|
|
97
|
+
return e === "button" ? K(t) : e === "image" ? H(t) : w(t);
|
|
98
|
+
}
|
|
99
|
+
function f(t, e) {
|
|
100
|
+
if (!t || !("querySelector" in t))
|
|
101
|
+
return;
|
|
102
|
+
const r = t.querySelector(S) ?? t;
|
|
103
|
+
if (G.forEach(({ attrKey: o, blockId: u, kind: T }) => {
|
|
104
|
+
const d = r.querySelector(`[esd-extension-block-id="${u}"]`);
|
|
105
|
+
d && e(d, o, T);
|
|
106
|
+
}), !A(r))
|
|
107
|
+
return;
|
|
108
|
+
const n = /* @__PURE__ */ new Set();
|
|
109
|
+
r.querySelectorAll(
|
|
110
|
+
`[esd-extension-block-id="${c.CUSTOM_ATTRIBUTE}"]`
|
|
111
|
+
).forEach((o) => {
|
|
112
|
+
const u = l(o) ? o.getAttribute(v) : null;
|
|
113
|
+
!u || n.has(u) || (n.add(u), e(o, U(u), "text"));
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function F(t) {
|
|
117
|
+
const e = {};
|
|
118
|
+
return f(t, (r, n, i) => {
|
|
119
|
+
if (!("querySelector" in r))
|
|
120
|
+
return;
|
|
121
|
+
const o = $(r, i);
|
|
122
|
+
o && (e[n] = o);
|
|
123
|
+
}), e;
|
|
124
|
+
}
|
|
125
|
+
function j(t) {
|
|
126
|
+
if (!t || !("querySelector" in t))
|
|
127
|
+
return;
|
|
128
|
+
const e = t.querySelector(S) ?? t, r = e.querySelector(".product-card-segment") ?? e.querySelector(".product-card-wrapper");
|
|
129
|
+
return O(r);
|
|
130
|
+
}
|
|
131
|
+
function X(t) {
|
|
132
|
+
if (!t)
|
|
133
|
+
return;
|
|
134
|
+
const e = l(t) ? t.getAttribute("bgcolor") : null;
|
|
135
|
+
if (e && !b.has(e))
|
|
136
|
+
return e;
|
|
137
|
+
const r = O(t);
|
|
138
|
+
if (r)
|
|
139
|
+
return r;
|
|
140
|
+
const n = q(t) ? t.getComputedStyle("background-color") : void 0;
|
|
141
|
+
return n && !b.has(n) ? n : void 0;
|
|
142
|
+
}
|
|
143
|
+
function z(t) {
|
|
144
|
+
const e = {};
|
|
145
|
+
return f(t, (r, n, i) => {
|
|
146
|
+
if (i !== "text")
|
|
147
|
+
return;
|
|
148
|
+
const o = X(r);
|
|
149
|
+
o && (e[n] = o);
|
|
150
|
+
}), e;
|
|
151
|
+
}
|
|
152
|
+
function Q(t) {
|
|
153
|
+
const e = {};
|
|
154
|
+
return f(t, (r, n, i) => {
|
|
155
|
+
if (i === "image")
|
|
156
|
+
return;
|
|
157
|
+
const o = l(r) ? r.getAttribute("align") : null;
|
|
158
|
+
o && (e[n] = o);
|
|
159
|
+
}), e;
|
|
160
|
+
}
|
|
161
|
+
const V = /^es-[pm]\d+[trbl]?$/;
|
|
162
|
+
function W(t) {
|
|
163
|
+
const e = l(t) ? t.getAttribute("class") : null;
|
|
164
|
+
if (!e)
|
|
165
|
+
return;
|
|
166
|
+
const r = e.split(/\s+/).filter((n) => V.test(n) || n === B);
|
|
167
|
+
return r.length ? r.join(" ") : void 0;
|
|
168
|
+
}
|
|
169
|
+
function Y(t) {
|
|
170
|
+
const e = {};
|
|
171
|
+
return f(t, (r, n, i) => {
|
|
172
|
+
if (i === "image")
|
|
173
|
+
return;
|
|
174
|
+
const o = W(r);
|
|
175
|
+
o && (e[n] = o);
|
|
176
|
+
}), e;
|
|
177
|
+
}
|
|
178
|
+
function J(t) {
|
|
179
|
+
const e = {};
|
|
180
|
+
return f(t, (r, n) => {
|
|
181
|
+
if (n !== y && n !== m || !l(r))
|
|
182
|
+
return;
|
|
183
|
+
const i = r.getAttribute("data-text-before"), o = r.getAttribute("data-text-after");
|
|
184
|
+
(i != null || o != null) && (e[n] = { before: i ?? void 0, after: o ?? void 0 });
|
|
185
|
+
}), e;
|
|
186
|
+
}
|
|
187
|
+
function Z(t) {
|
|
188
|
+
const e = {};
|
|
189
|
+
if (!t || !("querySelector" in t))
|
|
190
|
+
return e;
|
|
191
|
+
const r = t.querySelector(S) ?? t;
|
|
192
|
+
return A(r) && r.querySelectorAll(".recommendation-attribute-row").forEach((n) => {
|
|
193
|
+
if (!l(n))
|
|
194
|
+
return;
|
|
195
|
+
const i = n.getAttribute("data-attribute-type"), o = n.getAttribute("data-visibility");
|
|
196
|
+
i && o != null && (e[i] = o !== "0");
|
|
197
|
+
}), e;
|
|
198
|
+
}
|
|
199
|
+
function ut(t) {
|
|
200
|
+
return {
|
|
201
|
+
styleTemplates: F(t),
|
|
202
|
+
cardBackgroundColor: j(t),
|
|
203
|
+
cellBackgroundColors: z(t),
|
|
204
|
+
cellAlignments: Q(t),
|
|
205
|
+
cellClasses: Y(t),
|
|
206
|
+
omnibusTexts: J(t),
|
|
207
|
+
visibility: Z(t)
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
export {
|
|
211
|
+
F as captureAttributeStyleTemplates,
|
|
212
|
+
j as captureCardBackgroundColor,
|
|
213
|
+
Q as captureCellAlignments,
|
|
214
|
+
z as captureCellBackgroundColors,
|
|
215
|
+
Y as captureCellClasses,
|
|
216
|
+
J as captureOmnibusTexts,
|
|
217
|
+
ut as captureStyles,
|
|
218
|
+
Z as captureVisibility
|
|
219
|
+
};
|
|
@@ -1,27 +1,32 @@
|
|
|
1
|
-
import { escapeHtml as
|
|
2
|
-
function
|
|
3
|
-
return "getInnerHTML" in
|
|
1
|
+
import { escapeHtml as g } from "../../../../utils/htmlEscape.js";
|
|
2
|
+
function u(n) {
|
|
3
|
+
return "getInnerHTML" in n && typeof n.getInnerHTML == "function" ? n.getInnerHTML().trim() : "innerHTML" in n ? n.innerHTML : "";
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
return n;
|
|
9
|
-
const r = T(t);
|
|
10
|
-
if (!r || r.trim() === "" || !/<(strong|em|u|s|b|i)\b/i.test(r))
|
|
11
|
-
return n;
|
|
12
|
-
const e = [], s = [];
|
|
13
|
-
let o = r.trim();
|
|
5
|
+
function T(n) {
|
|
6
|
+
const s = [], t = [];
|
|
7
|
+
let r = n.trim();
|
|
14
8
|
for (; ; ) {
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
9
|
+
const e = r.match(/^<(strong|em|u|s|b|i)(\s[^>]*)?>(.*)$/is);
|
|
10
|
+
if (!e)
|
|
17
11
|
break;
|
|
18
|
-
const [, i, a = "",
|
|
19
|
-
if (!
|
|
12
|
+
const [, i, a = "", o] = e, c = new RegExp(`</${i}>$`, "i");
|
|
13
|
+
if (!c.test(o))
|
|
20
14
|
break;
|
|
21
|
-
|
|
15
|
+
s.push(`<${i}${a}>`), t.unshift(`</${i}>`), r = o.replace(c, "").trim();
|
|
22
16
|
}
|
|
23
|
-
return
|
|
17
|
+
return { openTags: s.join(""), closeTags: t.join("") };
|
|
18
|
+
}
|
|
19
|
+
function p(n, s) {
|
|
20
|
+
const t = g(s);
|
|
21
|
+
if (!n)
|
|
22
|
+
return t;
|
|
23
|
+
const r = u(n);
|
|
24
|
+
if (!r || r.trim() === "")
|
|
25
|
+
return t;
|
|
26
|
+
const { openTags: e, closeTags: i } = T(r);
|
|
27
|
+
return e ? e + t + i : t;
|
|
24
28
|
}
|
|
25
29
|
export {
|
|
26
|
-
|
|
30
|
+
T as extractWrapperTags,
|
|
31
|
+
p as preserveTextStyles
|
|
27
32
|
};
|
|
@@ -1,46 +1,54 @@
|
|
|
1
|
-
function
|
|
1
|
+
function r(t) {
|
|
2
2
|
return typeof t == "object" && t !== null && "tagName" in t && typeof t.tagName == "string";
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function u(t) {
|
|
5
5
|
return typeof t == "object" && t !== null && "getTagName" in t && typeof t.getTagName == "function";
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function n(t) {
|
|
8
8
|
return typeof t == "object" && t !== null && "getStyle" in t && typeof t.getStyle == "function";
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return typeof t == "object" && t !== null && "
|
|
10
|
+
function p(t) {
|
|
11
|
+
return typeof t == "object" && t !== null && "getComputedStyle" in t && typeof t.getComputedStyle == "function";
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return typeof t == "object" && t !== null && "
|
|
13
|
+
function y(t) {
|
|
14
|
+
return typeof t == "object" && t !== null && "getAttribute" in t && typeof t.getAttribute == "function";
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
return
|
|
16
|
+
function o(t) {
|
|
17
|
+
return typeof t == "object" && t !== null && "querySelectorAll" in t && typeof t.querySelectorAll == "function";
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
19
|
+
function l(t) {
|
|
20
|
+
return typeof t == "object" && t !== null && "parent" in t && typeof t.parent == "function";
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return t
|
|
22
|
+
function g(t, e) {
|
|
23
|
+
return !t || !n(t) ? null : t.getStyle(e);
|
|
24
|
+
}
|
|
25
|
+
function s(t) {
|
|
26
|
+
return !t || !l(t) ? null : t.parent() ?? null;
|
|
27
|
+
}
|
|
28
|
+
function a(t, e = "UNKNOWN") {
|
|
29
|
+
return t ? r(t) ? t.tagName.toUpperCase() : u(t) ? t.getTagName().toUpperCase() : e : e;
|
|
24
30
|
}
|
|
25
31
|
const f = /* @__PURE__ */ new Set(["TD", "BLOCK_IMAGE", "BLOCK_BUTTON"]);
|
|
26
32
|
function i(t) {
|
|
27
33
|
return f.has(t.toUpperCase());
|
|
28
34
|
}
|
|
29
35
|
function c(t) {
|
|
30
|
-
const e =
|
|
36
|
+
const e = a(t);
|
|
31
37
|
return i(e);
|
|
32
38
|
}
|
|
33
|
-
function
|
|
39
|
+
function N(t) {
|
|
34
40
|
return c(t) ? "table-cell" : "table-row";
|
|
35
41
|
}
|
|
36
42
|
export {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
N as getTableDisplayValue,
|
|
44
|
+
a as getTagName,
|
|
45
|
+
y as hasGetAttribute,
|
|
46
|
+
p as hasGetComputedStyle,
|
|
47
|
+
n as hasGetStyle,
|
|
48
|
+
l as hasParent,
|
|
49
|
+
o as hasQuerySelectorAll,
|
|
41
50
|
c as isTableCellNode,
|
|
42
51
|
i as isTableCellTag,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
p as safeGetStyle
|
|
52
|
+
s as safeGetParent,
|
|
53
|
+
g as safeGetStyle
|
|
46
54
|
};
|