@useinsider/guido 3.8.2 → 3.9.0-beta.1549171

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 (64) hide show
  1. package/dist/@types/config/schemas.js +70 -66
  2. package/dist/composables/usePreviewMode.js +15 -14
  3. package/dist/composables/useRecommendationPreview.js +111 -0
  4. package/dist/config/compiler/recommendationCompilerRules.js +1 -1
  5. package/dist/config/compiler/utils/recommendationCompilerUtils.js +88 -80
  6. package/dist/config/migrator/itemsBlockMigrator.js +168 -122
  7. package/dist/config/migrator/recommendation/htmlBuilder.js +53 -52
  8. package/dist/config/migrator/recommendation/settingsMapper.js +38 -33
  9. package/dist/enums/html-validator.js +6 -5
  10. package/dist/extensions/Blocks/Items/block.js +48 -29
  11. package/dist/extensions/Blocks/Items/controls/name/trimming.js +17 -18
  12. package/dist/extensions/Blocks/Items/controls/settingsControl.js +47 -47
  13. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +13 -9
  14. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +26 -14
  15. package/dist/extensions/Blocks/Items/template.js +229 -223
  16. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +62 -45
  17. package/dist/extensions/Blocks/Recommendation/block.js +64 -42
  18. package/dist/extensions/Blocks/Recommendation/canvasPreview.css.js +16 -0
  19. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +41 -32
  20. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +461 -363
  21. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +99 -87
  22. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +133 -0
  23. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +162 -160
  24. package/dist/extensions/Blocks/Recommendation/extension.js +30 -29
  25. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +21 -7
  26. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +64 -4
  27. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +3 -1
  28. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +130 -96
  29. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +43 -54
  30. package/dist/extensions/Blocks/Recommendation/templates/index.js +17 -14
  31. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +86 -80
  32. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +31 -40
  33. package/dist/extensions/Blocks/Recommendation/templates/utils.js +155 -102
  34. package/dist/extensions/Blocks/controlFactories.js +76 -57
  35. package/dist/src/@types/config/schemas.d.ts +16 -0
  36. package/dist/src/composables/useConfig.d.ts +4 -0
  37. package/dist/src/composables/useRecommendationPreview.d.ts +10 -0
  38. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
  39. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +1 -1
  40. package/dist/src/extensions/Blocks/Items/block.d.ts +8 -0
  41. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +3 -3
  42. package/dist/src/extensions/Blocks/Items/template.d.ts +7 -0
  43. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -1
  44. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
  45. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +29 -3
  46. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
  47. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +3 -1
  48. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +59 -0
  49. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +1 -1
  50. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +1 -1
  51. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +1 -1
  52. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +1 -1
  53. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +1 -1
  54. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  55. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +13 -1
  56. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  57. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
  58. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +10 -1
  59. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  60. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +51 -1
  61. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +15 -0
  62. package/dist/src/extensions/Blocks/controlFactories.d.ts +10 -1
  63. package/dist/src/stores/config.d.ts +36 -0
  64. package/package.json +1 -1
@@ -3,171 +3,179 @@ 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 h(r, n, e, o, c = "") {
7
- const i = `{{${c}${r}_${n}_${e}}}`, t = `{{${c}${r}_${n}_currency}}`;
8
- return o === "before" ? `${t} ${i}` : `${i} ${t}`;
6
+ function b(e, n, t, o, c = "") {
7
+ const i = `{{${c}${e}_${n}_${t}}}`, r = `{{${c}${e}_${n}_currency}}`;
8
+ return o === "before" ? `${r} ${i}` : `${i} ${r}`;
9
9
  }
10
- function f(r) {
11
- let n = r;
10
+ function m(e) {
11
+ let n = e;
12
12
  for (; n.children.length === 1; )
13
13
  [n] = n.children;
14
14
  return n;
15
15
  }
16
- function A(r, n, e, o, c, i) {
16
+ function h(e, n, t, o, c, i) {
17
17
  switch (n) {
18
18
  case "productImage": {
19
- const t = r.querySelector("img");
20
- t && (t.setAttribute("src", `{{${i}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${i}${e}_${o}_name}}`));
21
- const s = r.querySelector("a");
22
- s && (s.setAttribute("href", `{{${i}${e}_${o}_url}}`), s.classList.add(q));
19
+ const r = e.querySelector("img");
20
+ r && (r.setAttribute("src", `{{${i}${t}_${o}_image_url}}`), r.setAttribute("alt", `{{${i}${t}_${o}_name}}`));
21
+ const s = e.querySelector("a");
22
+ s && (s.setAttribute("href", `{{${i}${t}_${o}_url}}`), s.classList.add(q));
23
23
  break;
24
24
  }
25
25
  case "productName": {
26
- const t = r.querySelector("p");
27
- t && (f(t).textContent = `{{${i}${e}_${o}_name}}`);
26
+ const r = e.querySelector("p");
27
+ r && (m(r).textContent = `{{${i}${t}_${o}_name}}`);
28
28
  break;
29
29
  }
30
30
  case "productPrice": {
31
- const t = r.querySelector("p");
32
- t && (f(t).textContent = h(
33
- e,
31
+ const r = e.querySelector(".product-price p") ?? e.querySelector("p");
32
+ r && (m(r).textContent = b(
33
+ t,
34
34
  o,
35
35
  "price",
36
36
  c,
37
37
  i
38
38
  ));
39
+ const s = e.querySelector(".product-old-price p");
40
+ s && (m(s).textContent = b(
41
+ t,
42
+ o,
43
+ "original_price",
44
+ c,
45
+ i
46
+ ));
39
47
  break;
40
48
  }
41
49
  case "productOldPrice": {
42
- const t = r.querySelector("p");
43
- t && (f(t).textContent = h(
44
- e,
50
+ const r = e.querySelector("p");
51
+ r && (m(r).textContent = b(
52
+ t,
45
53
  o,
46
54
  "original_price",
47
55
  c,
48
56
  i
49
- ), t.setAttribute("product-attr", "discount"));
57
+ ));
50
58
  break;
51
59
  }
52
60
  case "productButton": {
53
- const t = r.querySelector("a");
54
- t && t.setAttribute("href", `{{${i}${e}_${o}_url}}`);
61
+ const r = e.querySelector("a");
62
+ r && r.setAttribute("href", `{{${i}${t}_${o}_url}}`);
55
63
  break;
56
64
  }
57
65
  case "productOmnibusPrice": {
58
- const t = r.querySelector(".omnibus-price-value");
59
- if (t) {
60
- t.textContent = `{{${i}${e}_${o}_omnibus_price}}`;
61
- const s = t.closest("p");
66
+ const r = e.querySelector(".omnibus-price-value");
67
+ if (r) {
68
+ r.textContent = `{{${i}${t}_${o}_omnibus_price}}`;
69
+ const s = r.closest("p");
62
70
  s && (s.setAttribute("product-attr", "omnibus_price"), s.setAttribute("composition", "true"));
63
71
  }
64
72
  break;
65
73
  }
66
74
  case "productOmnibusDiscount": {
67
- const t = r.querySelector(".omnibus-discount-value");
68
- if (t) {
69
- t.textContent = `{{${i}${e}_${o}_omnibus_discount}}`;
70
- const s = t.closest("p");
75
+ const r = e.querySelector(".omnibus-discount-value");
76
+ if (r) {
77
+ r.textContent = `{{${i}${t}_${o}_omnibus_discount}}`;
78
+ const s = r.closest("p");
71
79
  s && (s.setAttribute("product-attr", "omnibus_discount"), s.setAttribute("composition", "true"));
72
80
  }
73
81
  break;
74
82
  }
75
83
  default: {
76
- const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
77
- if (t) {
78
- const s = t.getAttribute("product-attr"), a = t.querySelector("p");
79
- a && (f(a).textContent = `{{${i}${e}_${o}_${s}}}`);
84
+ const r = e.getAttribute("product-attr") ? e : e.querySelector("[product-attr]");
85
+ if (r) {
86
+ const s = r.getAttribute("product-attr"), a = r.querySelector("p");
87
+ a && (m(a).textContent = `{{${i}${t}_${o}_${s}}}`);
80
88
  }
81
89
  break;
82
90
  }
83
91
  }
84
92
  }
85
- function E(r, n, e, o) {
86
- r.querySelectorAll(".recommendation-product-row").forEach((i, t) => {
93
+ function E(e, n, t, o) {
94
+ e.querySelectorAll(".recommendation-product-row").forEach((i, r) => {
87
95
  i.querySelectorAll("[data-attribute-type]").forEach((a) => {
88
96
  const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
89
97
  p.length > 0 ? p.forEach((l) => {
90
- A(l, u, n, t, e, o);
91
- }) : A(a, u, n, t, e, o);
98
+ h(l, u, n, r, t, o);
99
+ }) : h(a, u, n, r, t, o);
92
100
  });
93
101
  });
94
102
  }
95
- function R(r, n, e, o) {
96
- const c = r.querySelectorAll(".recommendation-product-row");
103
+ function P(e, n, t, o) {
104
+ const c = e.querySelectorAll(".recommendation-product-row");
97
105
  if (!c.length)
98
106
  return;
99
- const [i] = c, t = i.querySelector("[data-attribute-type]"), s = t ? t.querySelectorAll(".attribute-cell").length : 1;
107
+ const [i] = c, r = i.querySelector("[data-attribute-type]"), s = r ? r.querySelectorAll(".attribute-cell").length : 1;
100
108
  c.forEach((a, u) => {
101
109
  a.querySelectorAll("[data-attribute-type]").forEach((l) => {
102
- const m = l.getAttribute("data-attribute-type") || "";
103
- l.querySelectorAll(".attribute-cell").forEach((y, $) => {
110
+ const d = l.getAttribute("data-attribute-type") || "";
111
+ l.querySelectorAll(".attribute-cell").forEach((A, $) => {
104
112
  const S = u * s + $;
105
- A(y, m, n, S, e, o);
113
+ h(A, d, n, S, t, o);
106
114
  });
107
115
  });
108
116
  });
109
117
  }
110
- function P(r, n, e, o) {
111
- r.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
112
- R(i, n, e, o);
118
+ function R(e, n, t, o) {
119
+ e.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
120
+ P(i, n, t, o);
113
121
  });
114
122
  }
115
- function T(r, n, e) {
116
- const o = r.getAttribute("data-layout") || "grid", c = r.getAttribute("currency-alignment") || "after";
117
- o === "list" ? E(r, n, c, e) : P(r, n, c, e);
123
+ function O(e, n, t) {
124
+ const o = e.getAttribute("data-layout") || "grid", c = e.getAttribute("currency-alignment") || "after";
125
+ o === "list" ? E(e, n, c, t) : R(e, n, c, t);
118
126
  }
119
- function b(r, n, e) {
120
- const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), c = r.match(o);
121
- return c ? parseInt(c[1]) : e;
127
+ function y(e, n, t) {
128
+ const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), c = e.match(o);
129
+ return c ? parseInt(c[1]) : t;
122
130
  }
123
- function v(r, n) {
124
- let e = r.parentElement;
125
- for (; e && e !== n; ) {
126
- if (e.tagName === "TD") {
127
- const o = e.getAttribute("width");
131
+ function T(e, n) {
132
+ let t = e.parentElement;
133
+ for (; t && t !== n; ) {
134
+ if (t.tagName === "TD") {
135
+ const o = t.getAttribute("width");
128
136
  if (o && o.endsWith("%") && parseFloat(o) < 100)
129
- return e;
137
+ return t;
130
138
  }
131
- e = e.parentElement;
139
+ t = t.parentElement;
132
140
  }
133
141
  return null;
134
142
  }
135
- function O(r) {
136
- const n = r.getAttribute("style") || "", e = b(n, "width", 600), o = b(n, "padding", 0) * 2, c = Math.max(0, e - o);
137
- c !== 0 && r.querySelectorAll("img.adapt-img").forEach((i) => {
143
+ function v(e) {
144
+ const n = e.getAttribute("style") || "", t = y(n, "width", 600), o = y(n, "padding", 0) * 2, c = Math.max(0, t - o);
145
+ c !== 0 && e.querySelectorAll("img.adapt-img").forEach((i) => {
138
146
  if (i.hasAttribute("width"))
139
147
  return;
140
- const t = v(i, r);
141
- if (!t)
148
+ const r = T(i, e);
149
+ if (!r)
142
150
  return;
143
- const s = t.getAttribute("width"), a = parseFloat(s), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(c * a / 100), l = Math.max(1, p - u);
151
+ const s = r.getAttribute("width"), a = parseFloat(s), u = y(r.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(c * a / 100), l = Math.max(1, p - u);
144
152
  i.setAttribute("width", String(l));
145
- const m = i.getAttribute("style") || "";
146
- if (!/\bwidth\s*:\s*\d/i.test(m)) {
147
- const d = m && !m.trim().endsWith(";") ? "; " : "";
148
- i.setAttribute("style", `${m}${d}width: ${l}px`);
153
+ const d = i.getAttribute("style") || "";
154
+ if (!/\bwidth\s*:\s*\d/i.test(d)) {
155
+ const f = d && !d.trim().endsWith(";") ? "; " : "";
156
+ i.setAttribute("style", `${d}${f}width: ${l}px`);
149
157
  }
150
158
  });
151
159
  }
152
- function W(r, n) {
153
- const e = r.match(/<!DOCTYPE[^>]*>/i);
154
- return (e ? `${e[0]}
160
+ function W(e, n) {
161
+ const t = e.match(/<!DOCTYPE[^>]*>/i);
162
+ return (t ? `${t[0]}
155
163
  ` : "") + n.documentElement.outerHTML;
156
164
  }
157
- function F(r) {
158
- const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
165
+ function F(e) {
166
+ const n = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), t = new DOMParser().parseFromString(n, "text/html"), o = t.querySelectorAll(".recommendation-block-v2");
159
167
  if (!o.length)
160
- return r;
168
+ return e;
161
169
  const { buildCampaignUrl: c } = g(), i = C();
162
170
  i.recommendationCampaignUrls = {};
163
- const { isFeatureEnabled: t } = _(), s = t("liquidSyntax") ? "reco_" : "";
171
+ const { isFeatureEnabled: r } = _(), s = r("liquidSyntax") ? "reco_" : "";
164
172
  return o.forEach((u) => {
165
- var l, m;
173
+ var l, d;
166
174
  const p = u.getAttribute("recommendation-id");
167
- p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (m = u.parentNode) == null || m.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((d) => d.remove()), c(p), w(u) || T(u, p, s), O(u));
168
- }), W(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
175
+ p && ((l = u.parentNode) == null || l.insertBefore(t.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(t.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((f) => f.remove()), c(p), w(u) || O(u, p, s), v(u));
176
+ }), W(n, t).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
169
177
  }
170
178
  export {
171
- h as formatPriceVariable,
179
+ b as formatPriceVariable,
172
180
  F as prepareRecommendationBlocks
173
181
  };