@useinsider/guido 3.7.0-beta.bd7cb8f → 3.7.0-beta.d579d2a

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