@useinsider/guido 3.7.2-beta.0ef1511 → 3.7.2-beta.1489585

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