@useinsider/guido 3.7.2-beta.3cec1a4 → 3.7.2-beta.a114aa7

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 (33) hide show
  1. package/dist/composables/useHtmlValidator.js +180 -133
  2. package/dist/config/compiler/utils/recommendationCompilerUtils.js +28 -27
  3. package/dist/config/compiler/utils/recommendationIgnoreUtils.js +15 -0
  4. package/dist/config/migrator/recommendation/extractors.js +44 -22
  5. package/dist/config/migrator/recommendation/htmlBuilder.js +175 -169
  6. package/dist/config/migrator/recommendationMigrator.js +30 -31
  7. package/dist/extensions/Blocks/Recommendation/block.js +1 -4
  8. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +21 -15
  9. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +166 -169
  10. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +43 -42
  11. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +44 -33
  12. package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +3 -2
  13. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +59 -49
  14. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +89 -82
  15. package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +7 -6
  16. package/dist/extensions/Blocks/Recommendation/extension.js +6 -5
  17. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +3 -2
  18. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +3 -2
  19. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +13 -12
  20. package/dist/extensions/Blocks/Recommendation/templates/index.js +5 -4
  21. package/dist/src/composables/useHtmlValidator.d.ts +27 -0
  22. package/dist/src/composables/useHtmlValidator.test.d.ts +1 -0
  23. package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +17 -0
  24. package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +1 -0
  25. package/dist/src/config/migrator/recommendation/extractors.d.ts +15 -0
  26. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +8 -0
  27. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  28. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +21 -0
  29. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +7 -0
  30. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +5 -0
  31. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -0
  32. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -0
  33. package/package.json +1 -1
@@ -1,14 +1,14 @@
1
1
  import { BlockId as f } from "../../enums/block.js";
2
- import { useTemplateStore as u } from "../../stores/template.js";
3
- import { mapComposition as b } from "./recommendation/compositionMapper.js";
4
- import { extractTitleText as y, extractCardBgColor as C } from "./recommendation/extractors.js";
5
- import { buildBlockHtml as v } from "./recommendation/htmlBuilder.js";
6
- import { parseRecommendationId as w, parseLegacyConfig as R } from "./recommendation/parseLegacyConfig.js";
7
- import { mapSettings as S } from "./recommendation/settingsMapper.js";
2
+ import { useTemplateStore as b } from "../../stores/template.js";
3
+ import { mapComposition as y } from "./recommendation/compositionMapper.js";
4
+ import { extractCurrencyFromBlock as v, extractTitleText as C, extractCardBgColor as M, isPartnerManagedBlock as S } from "./recommendation/extractors.js";
5
+ import { buildBlockHtml as w } from "./recommendation/htmlBuilder.js";
6
+ import { parseRecommendationId as x, parseLegacyConfig as R } from "./recommendation/parseLegacyConfig.js";
7
+ import { mapSettings as T } from "./recommendation/settingsMapper.js";
8
8
  const h = 'td[esd-dev-product-config][class*="ins-recommendation-v3-block-"]:not(.recommendation-block-v2), td.product-block[esd-handler-name*="EmailRecommendationV3"][esd-dev-product-config]:not(.recommendation-block-v2)';
9
- function x(i, t, c) {
10
- var s;
11
- const o = w(t);
9
+ function B(i, t, a) {
10
+ var d;
11
+ const o = x(t);
12
12
  if (o === null)
13
13
  return console.warn(
14
14
  "[RecommendationMigrator] Skipping block — missing/invalid `ins-recommendation-v3-campaign-id`"
@@ -18,30 +18,29 @@ function x(i, t, c) {
18
18
  return console.warn(
19
19
  `[RecommendationMigrator] Aborting block id=${o} — \`esd-dev-product-config\` missing or unable to be parsed`
20
20
  ), !1;
21
- const n = c[String(o)];
22
- if (!n)
23
- return console.warn(
24
- `[RecommendationMigrator] Aborting block id=${o} — recommendationConfigs entry missing in Guido Config`
25
- ), !1;
26
- const a = S(n, r, o), e = b((s = r.composition) == null ? void 0 : s.variables), d = y(t), l = C(t), g = {
27
- ...a,
21
+ const n = a[String(o)] ?? {
22
+ currencySettings: v(t)
23
+ }, c = T(n, r, o), e = y((d = r.composition) == null ? void 0 : d.variables), l = C(t), g = M(t), p = {
24
+ ...c,
28
25
  composition: e.composition,
29
26
  visibility: e.visibility,
30
27
  textTrimming: e.anyTextTrimming
31
- }, p = `
28
+ }, m = S(t), u = `
32
29
  <table>
33
30
  <tbody>
34
31
  <tr>
35
32
  <td class="esd-structure" align="left">
36
33
  <table width="100%" cellpadding="0" cellspacing="0">
37
34
  <tbody>
38
- <tr>${v({
39
- nodeConfig: g,
35
+ <tr>${w({
36
+ nodeConfig: p,
40
37
  composition: e,
41
- cardBg: l,
42
- titleText: d,
38
+ cardBg: g,
39
+ titleText: l,
43
40
  legacyId: t.getAttribute("id") ?? void 0,
44
- legacyBgColor: t.getAttribute("bgcolor") ?? void 0
41
+ legacyBgColor: t.getAttribute("bgcolor") ?? void 0,
42
+ preserveInnerHtml: m ? t.innerHTML : void 0,
43
+ skipCompile: m
45
44
  })}</tr>
46
45
  </tbody>
47
46
  </table>
@@ -49,15 +48,15 @@ function x(i, t, c) {
49
48
  </tr>
50
49
  </tbody>
51
50
  </table>
52
- `, m = i.parseFromString(p, "text/html").querySelector("td.esd-structure");
53
- return !m || !t.parentNode ? (console.warn(
51
+ `, s = i.parseFromString(u, "text/html").querySelector("td.esd-structure");
52
+ return !s || !t.parentNode ? (console.warn(
54
53
  `[RecommendationMigrator] Aborting block id=${o} — failed to construct new HTML element`
55
- ), !1) : (t.parentNode.replaceChild(m, t), !0);
54
+ ), !1) : (t.parentNode.replaceChild(s, t), !0);
56
55
  }
57
- function I(i, t = {}) {
58
- const c = new DOMParser(), o = c.parseFromString(i, "text/html"), r = Array.from(o.querySelectorAll(h));
56
+ function q(i, t = {}) {
57
+ const a = new DOMParser(), o = a.parseFromString(i, "text/html"), r = Array.from(o.querySelectorAll(h));
59
58
  try {
60
- u().$patch((e) => {
59
+ b().$patch((e) => {
61
60
  e.migrations = {
62
61
  ...e.migrations,
63
62
  [f.Recommendation]: r.length
@@ -68,14 +67,14 @@ function I(i, t = {}) {
68
67
  if (r.length === 0)
69
68
  return i;
70
69
  let n = 0;
71
- return r.forEach((a) => {
70
+ return r.forEach((c) => {
72
71
  try {
73
- x(c, a, t) && (n += 1);
72
+ B(a, c, t) && (n += 1);
74
73
  } catch (e) {
75
74
  console.error("[RecommendationMigrator] Unexpected error migrating block:", e);
76
75
  }
77
76
  }), n > 0 && console.info(`[RecommendationMigrator] Migrated ${n} legacy Recommendation block(s)`), o.documentElement.outerHTML;
78
77
  }
79
78
  export {
80
- I as migrateRecommendation
79
+ q as migrateRecommendation
81
80
  };
@@ -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", n = ".ins-recommendation-product-container", o = ".ins-recommendation-desktop-container", t = ".ins-recommendation-mobile-container", _ = ".ins-recommendation-mobile-row", r = "reco-v3-button", R = "ins-skip-compile", e = {
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
+ }, O = "productImage", s = "productName", E = "productPrice", i = "productOldPrice", A = "productOmnibusPrice", C = "productOmnibusDiscount", u = "productButton", S = "customAttr:", I = "data-custom-attributes", m = "product-attr", c = /* @__PURE__ */ new Set([
9
9
  "name",
10
10
  // productName
11
11
  "price",
@@ -20,24 +20,30 @@ const T = ".recommendation-block-v2", c = ".ins-recommendation-product-container
20
20
  // productOmnibusPrice
21
21
  "omnibus_discount"
22
22
  // productOmnibusDiscount
23
+ ]), a = /* @__PURE__ */ new Set([
24
+ ...c,
25
+ "currency",
26
+ "discount"
23
27
  ]);
24
28
  export {
25
- A as ATTR_CUSTOM_PREFIX,
26
- u as ATTR_DATA_CUSTOM_ATTRIBUTES,
29
+ S as ATTR_CUSTOM_PREFIX,
30
+ I as ATTR_DATA_CUSTOM_ATTRIBUTES,
27
31
  m as ATTR_PRODUCT_ATTR,
28
- E as ATTR_PRODUCT_BUTTON,
29
- R as ATTR_PRODUCT_IMAGE,
30
- e as ATTR_PRODUCT_NAME,
31
- s as ATTR_PRODUCT_OLD_PRICE,
32
+ u as ATTR_PRODUCT_BUTTON,
33
+ O as ATTR_PRODUCT_IMAGE,
34
+ s as ATTR_PRODUCT_NAME,
35
+ i as ATTR_PRODUCT_OLD_PRICE,
32
36
  C as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
33
- i as ATTR_PRODUCT_OMNIBUS_PRICE,
34
- O as ATTR_PRODUCT_PRICE,
37
+ A as ATTR_PRODUCT_OMNIBUS_PRICE,
38
+ E as ATTR_PRODUCT_PRICE,
35
39
  T as BLOCK_ROOT_SELECTOR,
36
- a as BUILT_IN_DEFAULT_ATTRIBUTES,
37
- c as CONTAINER_SELECTOR,
40
+ c as BUILT_IN_DEFAULT_ATTRIBUTES,
41
+ n as CONTAINER_SELECTOR,
38
42
  r as CSS_CLASS_RECO_BUTTON,
39
- _ as CURRENCY_ATTR,
43
+ R as CSS_CLASS_SKIP_COMPILE,
44
+ e as CURRENCY_ATTR,
40
45
  o as DESKTOP_CONTAINER_SELECTOR,
41
- n as MOBILE_CONTAINER_SELECTOR,
42
- t as MOBILE_ROW_SELECTOR
46
+ t as MOBILE_CONTAINER_SELECTOR,
47
+ _ as MOBILE_ROW_SELECTOR,
48
+ a as RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES
43
49
  };