@useinsider/guido 3.8.0-beta.4a5664c → 3.8.0-beta.84f6c0a

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 (36) hide show
  1. package/dist/config/compiler/utils/recommendationCompilerUtils.js +19 -25
  2. package/dist/extensions/Blocks/Recommendation/block.js +1 -4
  3. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +11 -10
  4. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +135 -152
  5. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +24 -26
  6. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +30 -39
  7. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +28 -34
  8. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +285 -333
  9. package/dist/extensions/Blocks/Recommendation/extension.js +6 -5
  10. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +3 -2
  11. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +142 -173
  12. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +56 -30
  13. package/dist/extensions/Blocks/Recommendation/templates/index.js +29 -8
  14. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +132 -105
  15. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +44 -23
  16. package/dist/extensions/Blocks/Recommendation/templates/utils.js +112 -64
  17. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +219 -0
  18. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +24 -19
  19. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +30 -22
  20. package/dist/extensions/Blocks/controlFactories.js +159 -133
  21. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +1 -1
  22. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  23. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +2 -0
  24. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +1 -1
  25. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +2 -1
  26. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +20 -47
  27. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  28. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
  29. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -2
  30. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +165 -11
  31. package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +78 -0
  32. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +15 -0
  33. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +29 -9
  34. package/dist/src/extensions/Blocks/controlFactories.d.ts +11 -1
  35. package/package.json +1 -1
  36. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
@@ -1,18 +1,18 @@
1
- import { useConfig as g } from "../../../composables/useConfig.js";
2
- import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
1
+ import { useConfig as _ } from "../../../composables/useConfig.js";
2
+ import { useRecommendation as g } from "../../../composables/useRecommendation.js";
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
- function y(r, n, e, o, i = "") {
5
+ function h(r, n, e, o, i = "") {
6
6
  const c = `{{${i}${r}_${n}_${e}}}`, t = `{{${i}${r}_${n}_currency}}`;
7
7
  return o === "before" ? `${t} ${c}` : `${c} ${t}`;
8
8
  }
9
- function A(r) {
9
+ function b(r) {
10
10
  let n = r;
11
11
  for (; n.children.length === 1; )
12
12
  [n] = n.children;
13
13
  return n;
14
14
  }
15
- function f(r, n, e, o, i, c) {
15
+ function A(r, n, e, o, i, c) {
16
16
  switch (n) {
17
17
  case "productImage": {
18
18
  const t = r.querySelector("img");
@@ -23,15 +23,12 @@ function f(r, n, e, o, i, c) {
23
23
  }
24
24
  case "productName": {
25
25
  const t = r.querySelector("p");
26
- if (t) {
27
- const s = t.querySelector("strong") || t;
28
- s.textContent = `{{${c}${e}_${o}_name}}`;
29
- }
26
+ t && (b(t).textContent = `{{${c}${e}_${o}_name}}`);
30
27
  break;
31
28
  }
32
29
  case "productPrice": {
33
30
  const t = r.querySelector("p");
34
- t && (A(t).textContent = y(
31
+ t && (b(t).textContent = h(
35
32
  e,
36
33
  o,
37
34
  "price",
@@ -42,7 +39,7 @@ function f(r, n, e, o, i, c) {
42
39
  }
43
40
  case "productOldPrice": {
44
41
  const t = r.querySelector("p");
45
- t && (A(t).textContent = y(
42
+ t && (b(t).textContent = h(
46
43
  e,
47
44
  o,
48
45
  "original_price",
@@ -78,10 +75,7 @@ function f(r, n, e, o, i, c) {
78
75
  const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
79
76
  if (t) {
80
77
  const s = t.getAttribute("product-attr"), a = t.querySelector("p");
81
- if (a) {
82
- const u = a.querySelector("strong") || a;
83
- u.textContent = `{{${c}${e}_${o}_${s}}}`;
84
- }
78
+ a && (b(a).textContent = `{{${c}${e}_${o}_${s}}}`);
85
79
  }
86
80
  break;
87
81
  }
@@ -92,8 +86,8 @@ function w(r, n, e, o) {
92
86
  c.querySelectorAll("[data-attribute-type]").forEach((a) => {
93
87
  const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
94
88
  p.length > 0 ? p.forEach((l) => {
95
- f(l, u, n, t, e, o);
96
- }) : f(a, u, n, t, e, o);
89
+ A(l, u, n, t, e, o);
90
+ }) : A(a, u, n, t, e, o);
97
91
  });
98
92
  });
99
93
  }
@@ -105,9 +99,9 @@ function E(r, n, e, o) {
105
99
  i.forEach((a, u) => {
106
100
  a.querySelectorAll("[data-attribute-type]").forEach((l) => {
107
101
  const d = l.getAttribute("data-attribute-type") || "";
108
- l.querySelectorAll(".attribute-cell").forEach((h, $) => {
102
+ l.querySelectorAll(".attribute-cell").forEach((y, $) => {
109
103
  const S = u * s + $;
110
- f(h, d, n, S, e, o);
104
+ A(y, d, n, S, e, o);
111
105
  });
112
106
  });
113
107
  });
@@ -121,7 +115,7 @@ function P(r, n, e) {
121
115
  const o = r.getAttribute("data-layout") || "grid", i = r.getAttribute("currency-alignment") || "after";
122
116
  o === "list" ? w(r, n, i, e) : R(r, n, i, e);
123
117
  }
124
- function b(r, n, e) {
118
+ function f(r, n, e) {
125
119
  const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), i = r.match(o);
126
120
  return i ? parseInt(i[1]) : e;
127
121
  }
@@ -138,14 +132,14 @@ function T(r, n) {
138
132
  return null;
139
133
  }
140
134
  function v(r) {
141
- const n = r.getAttribute("style") || "", e = b(n, "width", 600), o = b(n, "padding", 0) * 2, i = Math.max(0, e - o);
135
+ const n = r.getAttribute("style") || "", e = f(n, "width", 600), o = f(n, "padding", 0) * 2, i = Math.max(0, e - o);
142
136
  i !== 0 && r.querySelectorAll("img.adapt-img").forEach((c) => {
143
137
  if (c.hasAttribute("width"))
144
138
  return;
145
139
  const t = T(c, r);
146
140
  if (!t)
147
141
  return;
148
- const s = t.getAttribute("width"), a = parseFloat(s), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(i * a / 100), l = Math.max(1, p - u);
142
+ const s = t.getAttribute("width"), a = parseFloat(s), u = f(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(i * a / 100), l = Math.max(1, p - u);
149
143
  c.setAttribute("width", String(l));
150
144
  const d = c.getAttribute("style") || "";
151
145
  if (!/\bwidth\s*:\s*\d/i.test(d)) {
@@ -163,9 +157,9 @@ function N(r) {
163
157
  const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
164
158
  if (!o.length)
165
159
  return r;
166
- const { buildCampaignUrl: i } = _(), c = C();
160
+ const { buildCampaignUrl: i } = g(), c = C();
167
161
  c.recommendationCampaignUrls = {};
168
- const { isFeatureEnabled: t } = g(), s = t("liquidSyntax") ? "reco_" : "";
162
+ const { isFeatureEnabled: t } = _(), s = t("liquidSyntax") ? "reco_" : "";
169
163
  return o.forEach((u) => {
170
164
  var l, d;
171
165
  const p = u.getAttribute("recommendation-id");
@@ -173,6 +167,6 @@ function N(r) {
173
167
  }), O(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
174
168
  }
175
169
  export {
176
- y as formatPriceVariable,
170
+ h as formatPriceVariable,
177
171
  N as prepareRecommendationBlocks
178
172
  };
@@ -48,11 +48,8 @@ class H extends D {
48
48
  allowInnerBlocksDND() {
49
49
  return !1;
50
50
  }
51
- // A saved module carries its config in the esd-config blob, restored on
52
- // re-drop by migrateFromDataAttributes; per-element styles ride the
53
- // preserved inner HTML. (onCreated early-returns for re-drops, never clobbers.)
54
51
  canBeSavedAsModule() {
55
- return !0;
52
+ return !1;
56
53
  }
57
54
  /**
58
55
  * Returns the template HTML for a new recommendation block.
@@ -1,11 +1,11 @@
1
- const T = ".recommendation-block-v2", c = ".ins-recommendation-product-container", o = ".ins-recommendation-desktop-container", n = ".ins-recommendation-mobile-container", t = ".ins-recommendation-mobile-row", r = "reco-v3-button", _ = {
1
+ const T = ".recommendation-block-v2", c = ".ins-recommendation-product-container", t = ".ins-recommendation-desktop-container", o = ".ins-recommendation-mobile-container", n = ".ins-recommendation-mobile-row", r = "reco-v3-button", _ = {
2
2
  CURRENCY: "currency",
3
3
  SYMBOL: "currency-symbol",
4
4
  ALIGNMENT: "currency-alignment",
5
5
  THOUSAND_SEPARATOR: "currency-thousand-separator",
6
6
  DECIMAL_SEPARATOR: "currency-decimal-separator",
7
7
  DECIMAL_COUNT: "currency-decimal-count"
8
- }, R = "productImage", e = "productName", O = "productPrice", s = "productOldPrice", i = "productOmnibusPrice", C = "productOmnibusDiscount", E = "productButton", A = "customAttr:", u = "data-custom-attributes", m = "product-attr", a = /* @__PURE__ */ new Set([
8
+ }, R = "productImage", e = "productName", O = "productPrice", s = "productOldPrice", E = "productOmnibusPrice", i = "productOmnibusDiscount", C = "productButton", A = "customAttr:", u = "data-custom-attributes", a = "product-attr", m = "product_attribute.", U = /* @__PURE__ */ new Set([
9
9
  "name",
10
10
  // productName
11
11
  "price",
@@ -24,20 +24,21 @@ const T = ".recommendation-block-v2", c = ".ins-recommendation-product-container
24
24
  export {
25
25
  A as ATTR_CUSTOM_PREFIX,
26
26
  u as ATTR_DATA_CUSTOM_ATTRIBUTES,
27
- m as ATTR_PRODUCT_ATTR,
28
- E as ATTR_PRODUCT_BUTTON,
27
+ a as ATTR_PRODUCT_ATTR,
28
+ C as ATTR_PRODUCT_BUTTON,
29
29
  R as ATTR_PRODUCT_IMAGE,
30
30
  e as ATTR_PRODUCT_NAME,
31
31
  s as ATTR_PRODUCT_OLD_PRICE,
32
- C as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
33
- i as ATTR_PRODUCT_OMNIBUS_PRICE,
32
+ i as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
33
+ E as ATTR_PRODUCT_OMNIBUS_PRICE,
34
34
  O as ATTR_PRODUCT_PRICE,
35
35
  T as BLOCK_ROOT_SELECTOR,
36
- a as BUILT_IN_DEFAULT_ATTRIBUTES,
36
+ U as BUILT_IN_DEFAULT_ATTRIBUTES,
37
37
  c as CONTAINER_SELECTOR,
38
38
  r as CSS_CLASS_RECO_BUTTON,
39
39
  _ as CURRENCY_ATTR,
40
- o as DESKTOP_CONTAINER_SELECTOR,
41
- n as MOBILE_CONTAINER_SELECTOR,
42
- t as MOBILE_ROW_SELECTOR
40
+ t as DESKTOP_CONTAINER_SELECTOR,
41
+ o as MOBILE_CONTAINER_SELECTOR,
42
+ n as MOBILE_ROW_SELECTOR,
43
+ m as PRODUCT_ATTRIBUTE_PREFIX
43
44
  };