@useinsider/guido 3.7.2-beta.1489585 → 3.7.2-beta.2220fb0

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 (62) 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 +100 -0
  4. package/dist/config/compiler/recommendationCompilerRules.js +1 -1
  5. package/dist/config/compiler/utils/recommendationCompilerUtils.js +92 -78
  6. package/dist/config/migrator/recommendation/htmlBuilder.js +59 -58
  7. package/dist/config/migrator/recommendation/settingsMapper.js +38 -33
  8. package/dist/extensions/Blocks/Recommendation/block.js +60 -41
  9. package/dist/extensions/Blocks/Recommendation/canvasPreview.css.js +16 -0
  10. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +41 -32
  11. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +10 -11
  12. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +369 -288
  13. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +96 -82
  14. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +39 -30
  15. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +133 -0
  16. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +34 -28
  17. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +338 -288
  18. package/dist/extensions/Blocks/Recommendation/extension.js +30 -30
  19. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +21 -7
  20. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +64 -4
  21. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +2 -3
  22. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +7 -5
  23. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +217 -155
  24. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +31 -56
  25. package/dist/extensions/Blocks/Recommendation/templates/index.js +10 -29
  26. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +135 -145
  27. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +22 -43
  28. package/dist/extensions/Blocks/Recommendation/templates/utils.js +96 -109
  29. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +19 -24
  30. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +22 -30
  31. package/dist/extensions/Blocks/controlFactories.js +133 -159
  32. package/dist/src/@types/config/schemas.d.ts +16 -0
  33. package/dist/src/composables/useConfig.d.ts +4 -0
  34. package/dist/src/composables/useRecommendationPreview.d.ts +10 -0
  35. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
  36. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +1 -1
  37. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
  38. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  39. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -2
  40. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +1 -1
  41. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +29 -3
  42. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
  43. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +3 -1
  44. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +1 -2
  45. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +59 -0
  46. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +47 -20
  47. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  48. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +16 -0
  49. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  50. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
  51. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +13 -0
  52. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  53. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +47 -163
  54. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +15 -0
  55. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -15
  56. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
  57. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +9 -29
  58. package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -11
  59. package/dist/src/stores/config.d.ts +36 -0
  60. package/package.json +1 -1
  61. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +0 -216
  62. package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +0 -78
@@ -1,101 +1,97 @@
1
- import { ATTR_CUSTOM_PREFIX as c, ATTR_PRODUCT_IMAGE as b, ATTR_PRODUCT_NAME as T, ATTR_PRODUCT_OLD_PRICE as g, ATTR_PRODUCT_PRICE as _, ATTR_PRODUCT_OMNIBUS_PRICE as f, ATTR_PRODUCT_OMNIBUS_DISCOUNT as p, ATTR_PRODUCT_BUTTON as m, PRODUCT_ATTRIBUTE_PREFIX as l } from "../constants/selectors.js";
2
- function U(t) {
3
- return t.replace(/_/g, " ").replace(/\b\w/g, (n) => n.toUpperCase());
1
+ import { ATTR_PRODUCT_PRICE as c, ATTR_PRODUCT_OLD_PRICE as a, ATTR_CUSTOM_PREFIX as m, ATTR_PRODUCT_IMAGE as b, ATTR_PRODUCT_NAME as g, ATTR_PRODUCT_OMNIBUS_PRICE as f, ATTR_PRODUCT_OMNIBUS_DISCOUNT as T, ATTR_PRODUCT_BUTTON as _ } from "../constants/selectors.js";
2
+ import { useRecommendationExtensionStore as S } from "../store/recommendation.js";
3
+ import { formatPrice as D } from "../utils/priceFormatter.js";
4
+ function h() {
5
+ const t = S(), { currencySettings: e } = t.recommendationConfigs;
6
+ return {
7
+ code: e.value,
8
+ symbol: e.symbol,
9
+ alignment: e.alignment === "0" ? "before" : "after",
10
+ decimalCount: parseInt(e.decimalCount) || 2,
11
+ decimalSeparator: e.decimalSeparator,
12
+ thousandSeparator: e.thousandSeparator
13
+ };
4
14
  }
5
- function S(t) {
6
- const n = Array.isArray(t) ? t[t.length - 1] : t;
7
- if (typeof n == "string")
8
- return n;
9
- if (typeof n == "number")
10
- return String(n);
15
+ function p(t, e = "price") {
16
+ const r = h(), n = t[e], o = (n == null ? void 0 : n[r.code]) ?? Object.values(n ?? {})[0] ?? 0;
17
+ return D({
18
+ price: o,
19
+ currency: r
20
+ });
11
21
  }
12
- function C(t, n) {
13
- const e = Object.values(n).find((o) => o.attributeName === t);
14
- return (e == null ? void 0 : e.type) === "defaultAttribute";
22
+ function N(t) {
23
+ return p(t, "price") === p(t, "original_price");
15
24
  }
16
- function E(t, n) {
17
- return C(t, n) ? t : `${l}${t}`;
25
+ function I(t) {
26
+ return t.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
18
27
  }
19
- function M(t) {
20
- const n = t.startsWith(l) ? t.substring(l.length) : t;
21
- return `${c}${n}`;
28
+ function v(t) {
29
+ const e = t.indexOf(c), r = t.indexOf(a), n = r !== -1 && (e === -1 || r < e);
30
+ return {
31
+ originalFirst: n,
32
+ anchor: n ? a : c,
33
+ skip: n ? c : a
34
+ };
22
35
  }
23
- const P = Symbol("customCellHtml");
24
- function k(t, n, e = {}) {
25
- const o = t[P];
26
- if (!o)
36
+ function U(t) {
37
+ const e = Array.isArray(t) ? t[t.length - 1] : t;
38
+ if (typeof e == "string")
39
+ return e;
40
+ if (typeof e == "number")
41
+ return String(e);
42
+ }
43
+ function C(t, e) {
44
+ const r = Object.values(e).find((n) => n.attributeName === t);
45
+ return (r == null ? void 0 : r.type) === "defaultAttribute";
46
+ }
47
+ function E(t, e) {
48
+ return C(t, e) ? t : `product_attribute.${t}`;
49
+ }
50
+ const L = Symbol("customCellHtml");
51
+ function B(t, e, r = {}) {
52
+ const n = t[L];
53
+ if (!n)
27
54
  return { ...t };
28
- const s = { ...t };
29
- return n.filter((r) => r.startsWith(c) && !s[r]).forEach((r) => {
30
- const i = r.substring(c.length), a = U(i), y = E(i, e), R = C(i, e);
31
- s[r] = (d, A) => {
55
+ const o = { ...t };
56
+ return e.filter((i) => i.startsWith(m) && !o[i]).forEach((i) => {
57
+ const s = i.substring(m.length), l = I(s), O = E(s, r), R = C(s, r);
58
+ o[i] = (d) => {
32
59
  var u;
33
- const D = R ? d[i] : (u = d.product_attributes) == null ? void 0 : u[i], O = S(D) ?? a;
34
- return o(y, O, A);
60
+ const A = R ? d[s] : (u = d.product_attributes) == null ? void 0 : u[s], P = U(A) ?? l;
61
+ return n(O, P);
35
62
  };
36
- }), s;
63
+ }), o;
37
64
  }
38
- const x = {
65
+ const F = {
39
66
  TITLE: "You May Also Like!"
40
- }, v = [
67
+ }, V = [
41
68
  b,
42
- T,
43
69
  g,
44
- _,
70
+ a,
71
+ c,
45
72
  f,
46
- p,
47
- m
48
- ], F = {
73
+ T,
74
+ _
75
+ ], H = {
49
76
  [b]: !0,
50
- [T]: !0,
51
- [_]: !0,
52
77
  [g]: !0,
78
+ [c]: !0,
79
+ [a]: !0,
53
80
  [f]: !1,
54
- [p]: !1,
55
- [m]: !0
56
- }, I = 10;
57
- function $(t = I) {
58
- return `
81
+ [T]: !1,
82
+ [_]: !0
83
+ }, x = `
59
84
  <tr>
60
- <td class="spacer" style="height: ${t}px;"></td>
85
+ <td class="spacer" style="height: 10px;"></td>
61
86
  </tr>
62
- `;
87
+ `, y = "https://email-static.useinsider.com/stripo/modules/email-recommendation-v3/assets/images/image-placeholder.png";
88
+ function W(t) {
89
+ return !t || typeof t != "string" || t.trim() === "" ? y : t.startsWith("http://") ? t.replace("http://", "https://") : t;
63
90
  }
64
- const L = $();
65
- function w(t, n) {
66
- return n ? n.pStyle ?? "" : t;
67
- }
68
- function W(t, n, e) {
69
- const o = w(n.pStyle, e), s = e ? e.openTags ?? "" : n.openTags, r = e ? e.closeTags ?? "" : n.closeTags;
70
- return `<p contenteditable="false" style="${o}">${s}${t}${r}</p>`;
71
- }
72
- function H(t, n) {
73
- const e = [];
74
- return t && e.push(t), n && e.push(`background-color: ${n};`), e.join(" ");
75
- }
76
- function Y(t) {
77
- return t ? ` style="background-color: ${t};"` : "";
78
- }
79
- function G(t, n = "") {
80
- return {
81
- before: (t == null ? void 0 : t.before) ?? n,
82
- after: (t == null ? void 0 : t.after) ?? ""
83
- };
84
- }
85
- function z(t, n) {
86
- return `${(n == null ? void 0 : n.openTags) ?? ""}${t}${(n == null ? void 0 : n.closeTags) ?? ""}`;
87
- }
88
- function X(t) {
89
- return t != null && t.buttonFitToContainer ? "es-button-border es-fw" : "es-button-border";
90
- }
91
- const j = "display: block; max-width: 100%; height: auto;", V = "border-width: 1px; background: rgb(217, 234, 211); border-color: rgb(106, 168, 79);", K = "color: rgb(56, 118, 29); background: rgb(217, 234, 211); font-family: arial, 'helvetica neue', helvetica, sans-serif; font-size: 16px; font-weight: normal; line-height: 120%; mso-border-alt: 10px solid rgb(217, 234, 211); mso-padding-alt: 0;", h = "https://email-static.useinsider.com/stripo/modules/email-recommendation-v3/assets/images/image-placeholder.png";
92
- function q(t) {
93
- return !t || typeof t != "string" || t.trim() === "" ? h : t.startsWith("http://") ? t.replace("http://", "https://") : t;
94
- }
95
- function B(t) {
91
+ function M(t) {
96
92
  return {
97
93
  name: "Product Name",
98
- image_url: h,
94
+ image_url: y,
99
95
  price: { USD: 18 },
100
96
  original_price: { USD: 20 },
101
97
  discount: { USD: 2 },
@@ -107,19 +103,19 @@ function B(t) {
107
103
  category: []
108
104
  };
109
105
  }
110
- function J(t = 6) {
106
+ function j(t = 6) {
111
107
  return Array.from(
112
108
  { length: t },
113
- (n, e) => B(String(e + 1))
109
+ (e, r) => M(String(r + 1))
114
110
  );
115
111
  }
116
- function Q(t = "grid", n) {
117
- const e = t === "list" ? `
118
- data-layout="list"` : "", o = n ? ` ${n}` : "";
112
+ function z(t = "grid", e) {
113
+ const r = t === "list" ? `
114
+ data-layout="list"` : "", n = e ? ` ${e}` : "";
119
115
  return `
120
116
  <td
121
117
  align="left"
122
- class="${`recommendation-block-v2 esd-block-recommendation-v3-block es-p20${t === "list" ? " es-m-p0 ins-recommendation-list-layout" : ""}${o}`}"${e}>
118
+ class="${`recommendation-block-v2 esd-block-recommendation-v3-block es-p20${t === "list" ? " es-m-p0 ins-recommendation-list-layout" : ""}${n}`}"${r}>
123
119
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
124
120
  <tr>
125
121
  <td align="center">
@@ -151,7 +147,7 @@ function Q(t = "grid", n) {
151
147
  </table>
152
148
  </td>
153
149
  </tr>
154
- ${L}
150
+ ${x}
155
151
  <tr>
156
152
  <td>
157
153
  <table
@@ -190,31 +186,22 @@ function Q(t = "grid", n) {
190
186
  `;
191
187
  }
192
188
  export {
193
- P as CUSTOM_CELL_HTML,
194
- x as DEFAULTS,
195
- K as DEFAULT_BUTTON_ANCHOR_STYLE,
196
- V as DEFAULT_BUTTON_BORDER_STYLE,
197
- v as DEFAULT_CARD_COMPOSITION,
198
- F as DEFAULT_CARD_VISIBILITY,
199
- j as DEFAULT_IMG_STYLE,
200
- I as DEFAULT_ROW_SPACING_PX,
201
- h as PLACEHOLDER_IMAGE,
202
- k as buildElementRenderer,
203
- $ as buildSpacer,
204
- Y as cellBgStyleAttr,
205
- Q as createBlockTemplate,
206
- J as getDefaultProducts,
189
+ L as CUSTOM_CELL_HTML,
190
+ F as DEFAULTS,
191
+ V as DEFAULT_CARD_COMPOSITION,
192
+ H as DEFAULT_CARD_VISIBILITY,
193
+ y as PLACEHOLDER_IMAGE,
194
+ B as buildElementRenderer,
195
+ z as createBlockTemplate,
196
+ p as formatProductPrice,
197
+ h as getCurrentCurrencyConfig,
198
+ j as getDefaultProducts,
207
199
  C as isDefaultAttribute,
208
- z as renderButtonLabel,
209
- W as renderStyledParagraph,
210
- X as resolveButtonBorderClass,
211
- G as resolveOmnibusText,
212
- w as resolvePStyle,
200
+ N as isSamePrice,
201
+ v as resolveInlinePriceOrder,
213
202
  E as resolveProductAttrValue,
214
- H as resolveSegmentBgStyle,
215
- q as sanitizeImageUrl,
216
- L as spacer,
217
- M as toCustomCompositionKey,
218
- U as toDisplayName,
219
- S as toDisplayableAttributeValue
203
+ W as sanitizeImageUrl,
204
+ x as spacer,
205
+ I as toDisplayName,
206
+ U as toDisplayableAttributeValue
220
207
  };
@@ -1,32 +1,27 @@
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 : "";
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 : "";
4
4
  }
5
- function T(n) {
6
- const s = [], t = [];
7
- let r = n.trim();
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();
8
14
  for (; ; ) {
9
- const e = r.match(/^<(strong|em|u|s|b|i)(\s[^>]*)?>(.*)$/is);
10
- if (!e)
15
+ const u = o.match(/^<(strong|em|u|s|b|i)(\s[^>]*)?>(.*)$/is);
16
+ if (!u)
11
17
  break;
12
- const [, i, a = "", o] = e, c = new RegExp(`</${i}>$`, "i");
13
- if (!c.test(o))
18
+ const [, i, a = "", c] = u, g = new RegExp(`</${i}>$`, "i");
19
+ if (!g.test(c))
14
20
  break;
15
- s.push(`<${i}${a}>`), t.unshift(`</${i}>`), r = o.replace(c, "").trim();
21
+ e.push(`<${i}${a}>`), s.unshift(`</${i}>`), o = c.replace(g, "").trim();
16
22
  }
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;
23
+ return e.length > 0 ? e.join("") + n + s.join("") : n;
28
24
  }
29
25
  export {
30
- T as extractWrapperTags,
31
- p as preserveTextStyles
26
+ H as preserveTextStyles
32
27
  };
@@ -1,54 +1,46 @@
1
- function r(t) {
1
+ function a(t) {
2
2
  return typeof t == "object" && t !== null && "tagName" in t && typeof t.tagName == "string";
3
3
  }
4
- function u(t) {
4
+ function n(t) {
5
5
  return typeof t == "object" && t !== null && "getTagName" in t && typeof t.getTagName == "function";
6
6
  }
7
- function n(t) {
7
+ function r(t) {
8
8
  return typeof t == "object" && t !== null && "getStyle" in t && typeof t.getStyle == "function";
9
9
  }
10
- function p(t) {
11
- return typeof t == "object" && t !== null && "getComputedStyle" in t && typeof t.getComputedStyle == "function";
12
- }
13
- function y(t) {
14
- return typeof t == "object" && t !== null && "getAttribute" in t && typeof t.getAttribute == "function";
15
- }
16
- function o(t) {
17
- return typeof t == "object" && t !== null && "querySelectorAll" in t && typeof t.querySelectorAll == "function";
18
- }
19
- function l(t) {
10
+ function u(t) {
20
11
  return typeof t == "object" && t !== null && "parent" in t && typeof t.parent == "function";
21
12
  }
22
- function g(t, e) {
23
- return !t || !n(t) ? null : t.getStyle(e);
13
+ function g(t) {
14
+ return typeof t == "object" && t !== null && "tagName" in t && t.tagName === "TD";
24
15
  }
25
- function s(t) {
26
- return !t || !l(t) ? null : t.parent() ?? null;
16
+ function p(t, e) {
17
+ return !t || !r(t) ? null : t.getStyle(e);
27
18
  }
28
- function a(t, e = "UNKNOWN") {
29
- return t ? r(t) ? t.tagName.toUpperCase() : u(t) ? t.getTagName().toUpperCase() : e : e;
19
+ function N(t) {
20
+ return !t || !u(t) ? null : t.parent() ?? null;
21
+ }
22
+ function l(t, e = "UNKNOWN") {
23
+ return t ? a(t) ? t.tagName.toUpperCase() : n(t) ? t.getTagName().toUpperCase() : e : e;
30
24
  }
31
25
  const f = /* @__PURE__ */ new Set(["TD", "BLOCK_IMAGE", "BLOCK_BUTTON"]);
32
26
  function i(t) {
33
27
  return f.has(t.toUpperCase());
34
28
  }
35
29
  function c(t) {
36
- const e = a(t);
30
+ const e = l(t);
37
31
  return i(e);
38
32
  }
39
- function N(t) {
33
+ function s(t) {
40
34
  return c(t) ? "table-cell" : "table-row";
41
35
  }
42
36
  export {
43
- N as getTableDisplayValue,
44
- a as getTagName,
45
- y as hasGetAttribute,
46
- p as hasGetComputedStyle,
47
- n as hasGetStyle,
48
- l as hasParent,
49
- o as hasQuerySelectorAll,
37
+ s as getTableDisplayValue,
38
+ l as getTagName,
39
+ r as hasGetStyle,
40
+ u as hasParent,
50
41
  c as isTableCellNode,
51
42
  i as isTableCellTag,
52
- s as safeGetParent,
53
- g as safeGetStyle
43
+ g as isTdNode,
44
+ N as safeGetParent,
45
+ p as safeGetStyle
54
46
  };