@useinsider/guido 3.15.0-beta.afdb685 → 3.15.0-beta.bc7091e

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 (32) hide show
  1. package/dist/composables/useAllowlist.js +48 -30
  2. package/dist/composables/useHtmlCompiler.js +19 -16
  3. package/dist/composables/useHtmlValidator.js +50 -50
  4. package/dist/composables/useStripo.js +29 -30
  5. package/dist/config/compiler/htmlCompilerRules.js +34 -7
  6. package/dist/config/compiler/recommendationCompilerRules.js +30 -30
  7. package/dist/config/i18n/en/labels.json.js +7 -3
  8. package/dist/config/migrator/itemsBlockMigrator.js +1 -1
  9. package/dist/config/migrator/recommendation/compositionMapper.js +26 -23
  10. package/dist/config/migrator/recommendation/htmlBuilder.js +156 -155
  11. package/dist/enums/recommendation.js +17 -17
  12. package/dist/extensions/Blocks/Items/enums/productEnums.js +45 -45
  13. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +18 -15
  14. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +363 -322
  15. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +8 -8
  16. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +271 -231
  17. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +16 -16
  18. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +16 -16
  19. package/dist/extensions/Blocks/Recommendation/templates/utils.js +120 -120
  20. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +55 -54
  21. package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +89 -0
  22. package/dist/extensions/Blocks/common-control.js +42 -35
  23. package/dist/src/composables/useHtmlValidator.d.ts +3 -2
  24. package/dist/src/config/migrator/recommendation/types.d.ts +1 -0
  25. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  26. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +6 -0
  27. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +27 -5
  28. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +4 -2
  29. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +12 -11
  30. package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +47 -0
  31. package/dist/src/extensions/Blocks/common-control.d.ts +3 -1
  32. package/package.json +1 -1
@@ -1,16 +1,16 @@
1
1
  import { useRecommendation as N } from "../../composables/useRecommendation.js";
2
- import { DUMMY_IMAGE_MAPPINGS as h, REGEX as d, VerticalOrientation as $, CSS as n, ATTRIBUTES as p, CONDITIONS as A, HTML as g } from "../../enums/recommendation.js";
2
+ import { DUMMY_IMAGE_MAPPINGS as C, REGEX as d, VerticalOrientation as $, CSS as n, ATTRIBUTES as p, CONDITIONS as A, HTML as g } from "../../enums/recommendation.js";
3
3
  import { prepareRecommendationBlocks as O } from "./utils/recommendationCompilerUtils.js";
4
- const H = [
4
+ const P = "https://s3-eu-west-1.amazonaws.com/", D = (t) => t.replace("https://", P), U = [
5
5
  {
6
6
  id: "replace-images-with-variable-names",
7
7
  description: "Replacing dummy images with variable names in recommendation module",
8
8
  type: "custom",
9
9
  processor: (t) => {
10
10
  let e = t;
11
- return Object.entries(h).forEach(([, r]) => {
12
- Object.entries(r).forEach(([o, i]) => {
13
- e = e.replaceAll(i, `{{${o}}}`);
11
+ return Object.entries(C).forEach(([, i]) => {
12
+ Object.entries(i).forEach(([o, r]) => {
13
+ e = e.replaceAll(D(r), `{{${o}}}`).replaceAll(r, `{{${o}}}`);
14
14
  });
15
15
  }), e;
16
16
  },
@@ -42,13 +42,13 @@ const H = [
42
42
  description: "Adding recommendation unresponsive css",
43
43
  type: "custom",
44
44
  processor: (t) => {
45
- const { calculateCardWidth: e, getRecommendationCampaignData: r } = N();
45
+ const { calculateCardWidth: e, getRecommendationCampaignData: i } = N();
46
46
  let o = t;
47
- const i = o.match(d.ID);
48
- if (i) {
47
+ const r = o.match(d.ID);
48
+ if (r) {
49
49
  const s = [];
50
- if (i.forEach((c) => {
51
- const m = /recommendation-id="(.*?)"/i.exec(c), E = m ? m[1].trim() : "", u = r(E);
50
+ if (r.forEach((c) => {
51
+ const m = /recommendation-id="(.*?)"/i.exec(c), E = m ? m[1].trim() : "", u = i(E);
52
52
  u.textTrimming && u.orientation === $ && s.push(e(u));
53
53
  }), s.length) {
54
54
  const c = `width:${Math.min(...s)}px!important;`;
@@ -72,25 +72,25 @@ const H = [
72
72
  type: "custom",
73
73
  processor: (t) => {
74
74
  let e = t;
75
- const r = e.match(d.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: o } = N();
76
- return r !== null && r.forEach((i) => {
77
- const s = i.match(d.CUSTOM_FIELD);
75
+ const i = e.match(d.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: o } = N();
76
+ return i !== null && i.forEach((r) => {
77
+ const s = r.match(d.CUSTOM_FIELD);
78
78
  if (!s)
79
79
  return;
80
- const [c] = s, m = c.match(d.CUSTOM_FIELD_INDEXES_PART), E = c.match(d.CUSTOM_FIELD_NAME_PART), u = i.match(d.ATTRIBUTE_PARAGRAPH_START_TAG);
80
+ const [c] = s, m = c.match(d.CUSTOM_FIELD_INDEXES_PART), E = c.match(d.CUSTOM_FIELD_NAME_PART), u = r.match(d.ATTRIBUTE_PARAGRAPH_START_TAG);
81
81
  if (!m || !E || !u)
82
82
  return;
83
- const [T] = m, [I] = E, [_] = u, b = I.substring(1, I.length - 2), S = _.match(d.COMPOSITION) !== null;
83
+ const [b] = m, [I] = E, [T] = u, _ = I.substring(1, I.length - 2), S = T.match(d.COMPOSITION) !== null;
84
84
  let a = c;
85
85
  if (S) {
86
- const y = T.substring(2, T.length - 3), l = o(y);
87
- b === p.OMNIBUS_PRICE && (l.priceBeforeTextValue && (a = `${l.priceBeforeTextValue}${a}`), l.priceAfterTextValue && (a = `${a}${l.priceAfterTextValue}`)), b === p.OMNIBUS_DISCOUNT && (l.discountBeforeTextValue && (a = `${l.discountBeforeTextValue}${a}`), l.discountAfterTextValue && (a = `${a}${l.discountAfterTextValue}`));
86
+ const f = b.substring(2, b.length - 3), l = o(f);
87
+ _ === p.OMNIBUS_PRICE && (l.priceBeforeTextValue && (a = `${l.priceBeforeTextValue}${a}`), l.priceAfterTextValue && (a = `${a}${l.priceAfterTextValue}`)), _ === p.OMNIBUS_DISCOUNT && (l.discountBeforeTextValue && (a = `${l.discountBeforeTextValue}${a}`), l.discountAfterTextValue && (a = `${a}${l.discountAfterTextValue}`));
88
88
  }
89
- const R = T.substring(2);
90
- let f = "";
91
- b in A.IF && (f = A.IF[b].replaceAll(`{${p.DISCOUNT}}`, `${R}${p.DISCOUNT}`).replaceAll(`{${p.OMNIBUS_DISCOUNT}}`, `${R}${p.OMNIBUS_DISCOUNT}`).replaceAll(`{${p.OMNIBUS_PRICE}}`, `${R}${p.OMNIBUS_PRICE}`));
92
- const M = `${_}${a}${g.PARAGRAPH_END_TAG}`, C = `${f}${S ? M : i}${A.ELSE}${_}${g.PARAGRAPH_END_TAG}${A.END_IF}`;
93
- e = e.replace(i, C);
89
+ const R = b.substring(2);
90
+ let y = "";
91
+ _ in A.IF && (y = A.IF[_].replaceAll(`{${p.DISCOUNT}}`, `${R}${p.DISCOUNT}`).replaceAll(`{${p.OMNIBUS_DISCOUNT}}`, `${R}${p.OMNIBUS_DISCOUNT}`).replaceAll(`{${p.OMNIBUS_PRICE}}`, `${R}${p.OMNIBUS_PRICE}`));
92
+ const h = `${T}${a}${g.PARAGRAPH_END_TAG}`, M = `${y}${S ? h : r}${A.ELSE}${T}${g.PARAGRAPH_END_TAG}${A.END_IF}`;
93
+ e = e.replace(r, M);
94
94
  }), e;
95
95
  },
96
96
  priority: 53
@@ -114,7 +114,7 @@ const H = [
114
114
  const e = /\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|data-same-price|product-attr|composition)="[^"]*"/g;
115
115
  return t.replace(
116
116
  /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
117
- (r, o) => `<!--REC_START-->${o.replace(e, "")}<!--REC_END-->`
117
+ (i, o) => `<!--REC_START-->${o.replace(e, "")}<!--REC_END-->`
118
118
  );
119
119
  },
120
120
  priority: 55
@@ -146,9 +146,9 @@ const H = [
146
146
  ""
147
147
  ), e = e.replace(
148
148
  /@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
149
- (r, o) => {
150
- const i = o.match(/[^{}]+\{[^{}]*\}/g) || [], s = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
151
- return i.every((m) => s.test(m)) ? "" : r;
149
+ (i, o) => {
150
+ const r = o.match(/[^{}]+\{[^{}]*\}/g) || [], s = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
151
+ return r.every((m) => s.test(m)) ? "" : i;
152
152
  }
153
153
  )), e;
154
154
  },
@@ -167,7 +167,7 @@ const H = [
167
167
  /<a\b[^>]*\bes-button\b[^>]*>/g,
168
168
  (e) => e.replace(
169
169
  /([;"]color:)([^;"]+)/g,
170
- (r, o, i) => i.includes("!important") ? r : `${o}${i} !important`
170
+ (i, o, r) => r.includes("!important") ? i : `${o}${r} !important`
171
171
  )
172
172
  ),
173
173
  priority: 58
@@ -184,8 +184,8 @@ const H = [
184
184
  description: "Collapse whitespace inside recommendation blocks and strip boundary markers",
185
185
  type: "custom",
186
186
  processor: (t) => {
187
- const e = (r) => r.replace(/>\s+</g, "><").replace(/<[^>]+>/g, (o) => o.replace(/\s+/g, " "));
188
- return t.replace(/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, (r, o) => e(o)).replaceAll("<!--REC_START-->", "").replaceAll("<!--REC_END-->", "");
187
+ const e = (i) => i.replace(/>\s+</g, "><").replace(/<[^>]+>/g, (o) => o.replace(/\s+/g, " "));
188
+ return t.replace(/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, (i, o) => e(o)).replaceAll("<!--REC_START-->", "").replaceAll("<!--REC_END-->", "");
189
189
  },
190
190
  priority: 99
191
191
  },
@@ -208,5 +208,5 @@ const H = [
208
208
  }
209
209
  ];
210
210
  export {
211
- H as recommendationCompilerRules
211
+ U as recommendationCompilerRules
212
212
  };
@@ -1,4 +1,4 @@
1
- const e = "Items", o = {
1
+ const e = "Items", o = "Default", t = "Custom", s = {
2
2
  "Global Styles & Layout": "Global Styles and Layout",
3
3
  "Structures & Modules": "Structures and Modules",
4
4
  "Recommendation Block": "Recommendation",
@@ -7,9 +7,13 @@ const e = "Items", o = {
7
7
  "This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.": "This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.",
8
8
  "Pixel Tracking Opt-in": "Pixel Tracking Opt-in",
9
9
  "OPT-IN SELECTION": "OPT-IN SELECTION",
10
- "UNSUBSCRIBE GROUPS": "UNSUBSCRIBE GROUPS"
10
+ "UNSUBSCRIBE GROUPS": "UNSUBSCRIBE GROUPS",
11
+ Default: o,
12
+ Custom: t
11
13
  };
12
14
  export {
15
+ t as Custom,
16
+ o as Default,
13
17
  e as Items,
14
- o as default
18
+ s as default
15
19
  };
@@ -381,7 +381,7 @@ class H {
381
381
  * Supports all block types by detecting prefix and using appropriate type:
382
382
  *
383
383
  * Examples:
384
- * - {{ins_apr_img_1}} → https://s3.../img_1.jpeg (CART_ITEMS)
384
+ * - {{ins_apr_img_1}} → https://web-image.useinsider.com/.../img_1.jpeg (CART_ITEMS)
385
385
  * - {{browsed_item_name_2}} → 'Set of Sprite Yoga Straps' (BROWSED_ITEMS)
386
386
  * - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
387
387
  */
@@ -1,4 +1,4 @@
1
- import { DEFAULT_COMPOSITION as d, DEFAULT_VISIBILITY as I } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
1
+ import { DEFAULT_COMPOSITION as p, DEFAULT_VISIBILITY as I } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
2
2
  import { ATTR_CUSTOM_PREFIX as l, ATTR_PRODUCT_BUTTON as k, ATTR_PRODUCT_OMNIBUS_DISCOUNT as A, ATTR_PRODUCT_OMNIBUS_PRICE as x, ATTR_PRODUCT_OLD_PRICE as f, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_NAME as h, ATTR_PRODUCT_IMAGE as y } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
3
3
  import { mapTextTheme as E, mapButtonTheme as O, mapImageTheme as b } from "./themeMapper.js";
4
4
  const C = "__title__", a = "product_attribute.";
@@ -23,19 +23,22 @@ function N(r) {
23
23
  return { key: k, kind: "button" };
24
24
  default:
25
25
  if (r.variableType === "p_attribute" || t.startsWith("p_attribute_")) {
26
- const s = r.value ?? "", o = s.startsWith(a) ? s.slice(a.length) : s;
27
- return o ? {
28
- key: `${l}${o}`,
26
+ const o = r.value ?? "", s = o.startsWith(a) ? o.slice(a.length) : o;
27
+ if (!s)
28
+ return null;
29
+ const e = o || `${a}${s}`;
30
+ return {
31
+ key: `${l}${e}`,
29
32
  kind: "custom",
30
- customAttrName: o,
31
- customAttrValue: s || `${a}${o}`
32
- } : null;
33
+ customAttrName: s,
34
+ customAttrValue: e
35
+ };
33
36
  }
34
37
  return null;
35
38
  }
36
39
  }
37
- function p(r) {
38
- const t = d.indexOf(r);
40
+ function _(r) {
41
+ const t = p.indexOf(r);
39
42
  return t === -1 ? Number.POSITIVE_INFINITY : t;
40
43
  }
41
44
  function S(r) {
@@ -48,8 +51,8 @@ function S(r) {
48
51
  anyTextTrimming: !1
49
52
  };
50
53
  if (!r || r.length === 0)
51
- return t.composition = [...d], t;
52
- const s = [];
54
+ return t.composition = [...p], t;
55
+ const o = [];
53
56
  r.forEach((e, i) => {
54
57
  const n = N(e);
55
58
  if (n) {
@@ -57,7 +60,7 @@ function S(r) {
57
60
  t.titleVariable = e;
58
61
  return;
59
62
  }
60
- s.push({
63
+ o.push({
61
64
  key: n.key,
62
65
  kind: n.kind,
63
66
  hidden: e.hidden === !0,
@@ -68,30 +71,30 @@ function S(r) {
68
71
  originalIndex: i
69
72
  });
70
73
  }
71
- }), s.sort((e, i) => {
74
+ }), o.sort((e, i) => {
72
75
  if (e.positionIdx !== i.positionIdx)
73
76
  return e.positionIdx - i.positionIdx;
74
- const n = p(e.key), u = p(i.key);
77
+ const n = _(e.key), u = _(i.key);
75
78
  return n !== u ? n - u : e.originalIndex - i.originalIndex;
76
79
  });
77
- const o = {};
78
- return s.forEach((e) => {
79
- const { key: i, kind: n, hidden: u, legacy: m, customAttrName: c, customAttrValue: T } = e;
80
- switch (t.composition.push(i), t.visibility[i] = !u, n === "custom" && c && T && (t.customAttributes.includes(c) || t.customAttributes.push(c), t.customAttrValues[i] = T), n) {
80
+ const s = {};
81
+ return o.forEach((e) => {
82
+ const { key: i, kind: n, hidden: u, legacy: c, customAttrName: d, customAttrValue: m } = e;
83
+ switch (t.composition.push(i), t.visibility[i] = !u, n === "custom" && d && m && (t.customAttributes.includes(m) || t.customAttributes.push(m), t.customAttrValues[i] = m), n) {
81
84
  case "image":
82
- o[i] = b(m.theme);
85
+ s[i] = b(c.theme);
83
86
  break;
84
87
  case "button":
85
- o[i] = O(m.theme);
88
+ s[i] = O(c.theme);
86
89
  break;
87
90
  case "text":
88
91
  case "custom": {
89
- const _ = E(m.theme);
90
- o[i] = _, _.textTrimming && (t.anyTextTrimming = !0);
92
+ const T = E(c.theme);
93
+ s[i] = T, T.textTrimming && (t.anyTextTrimming = !0);
91
94
  break;
92
95
  }
93
96
  }
94
- }), t.perElementStyles = o, t;
97
+ }), t.perElementStyles = s, t;
95
98
  }
96
99
  export {
97
100
  S as mapComposition