@useinsider/guido 3.5.1 → 3.6.0-beta.0e98cf4

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.
@@ -5,16 +5,16 @@ import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommend
5
5
  import { useConfigStore as x } from "../stores/config.js";
6
6
  const w = () => ({
7
7
  calculateCardWidth: ({
8
- mobileLeftPadding: s,
9
- mobileRightPadding: a,
10
- cardsInRow: c,
8
+ mobileLeftPadding: o,
9
+ mobileRightPadding: s,
10
+ cardsInRow: a,
11
11
  unresponsive: n
12
12
  }) => {
13
- const r = n ? c : 1, e = s + a + (r - 1) * b;
13
+ const r = n ? a : 1, e = o + s + (r - 1) * b;
14
14
  return (R - e) / r;
15
15
  },
16
- getRecommendationCampaignData: (s) => {
17
- const a = m(), c = Number(s), n = a.blockStates[c];
16
+ getRecommendationCampaignData: (o) => {
17
+ const s = m(), a = Number(o), n = s.blockStates[a];
18
18
  if (!n)
19
19
  return {
20
20
  textTrimming: !1,
@@ -42,37 +42,33 @@ const w = () => ({
42
42
  discountAfterTextValue: ""
43
43
  };
44
44
  },
45
- buildCampaignUrl: (s, a) => {
45
+ buildCampaignUrl: (o, s) => {
46
46
  var l;
47
- const c = m(), n = x(), r = Number(s);
47
+ const a = m(), n = x(), r = Number(o);
48
48
  let e;
49
- if (a)
50
- e = a;
49
+ if (s)
50
+ e = s;
51
51
  else {
52
- const i = c.blockStates[r];
53
- if (!i)
52
+ const c = a.blockStates[r];
53
+ if (!c)
54
54
  return "";
55
- const { recommendationConfigs: o } = i;
55
+ const { recommendationConfigs: i } = c;
56
56
  e = {
57
- strategy: o.strategy,
58
- language: o.language,
59
- currencyCode: o.currencySettings.value,
60
- size: o.size,
61
- productIds: o.productIds,
62
- filters: o.filters,
63
- shuffleProducts: o.shuffleProducts
57
+ strategy: i.strategy,
58
+ language: i.language,
59
+ currencyCode: i.currencySettings.value,
60
+ size: i.size,
61
+ productIds: i.productIds,
62
+ filters: i.filters,
63
+ shuffleProducts: i.shuffleProducts
64
64
  };
65
65
  }
66
- const f = ((l = I().find((i) => i.key === e.strategy)) == null ? void 0 : l.path) || "", t = new URLSearchParams();
67
- if (t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", n.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", n.variationId), e.strategy === "manualMerchandising") {
68
- const i = parseInt(e.size) || 6;
69
- t.set("productId", e.productIds.slice(0, i).join(","));
70
- } else e.strategy === "similarViewed" && t.set("productId", "{itemId}");
71
- e.strategy === "userBased" && t.set("userId", "{user_id}");
72
- const g = e.filters.filter((i) => i.isValid), d = h(g);
66
+ const f = ((l = I().find((c) => c.key === e.strategy)) == null ? void 0 : l.path) || "", t = new URLSearchParams();
67
+ t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", n.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", n.variationId), e.strategy === "manualMerchandising" ? t.set("productId", e.productIds.join(",")) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
68
+ const g = e.filters.filter((c) => c.isValid), d = h(g);
73
69
  d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true");
74
70
  const p = decodeURIComponent(t.toString()), u = `${C.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
75
- return c.recommendationCampaignUrls[s] = u, u;
71
+ return a.recommendationCampaignUrls[o] = u, u;
76
72
  }
77
73
  });
78
74
  export {
@@ -9,12 +9,12 @@ import { localePatch as H } from "../config/i18n/index.js";
9
9
  import { useStripoApi as O } from "../services/stripoApi.js";
10
10
  import j from "../static/styles/customEditorStyle.css.js";
11
11
  import { useEditorStore as E } from "../stores/editor.js";
12
- import { dynamicContentToMergeTags as L } from "../utils/genericUtil.js";
13
- import $ from "../package.json.js";
12
+ import { dynamicContentToMergeTags as z } from "../utils/genericUtil.js";
13
+ import L from "../package.json.js";
14
14
  const se = (C, l) => {
15
- const { features: c, template: h, isFeatureEnabled: u } = P(), { handleError: m } = x(), { getToken: w, getCustomFonts: b, getSyncModulesStatus: k } = O(), { handleEvent: B } = q(), { getStripoBlocksConfig: T } = I(), V = async (i, r = [], s = !1) => {
15
+ const { features: c, template: h, isFeatureEnabled: u } = P(), { handleError: m } = x(), { getToken: w, getCustomFonts: b, getSyncModulesStatus: k } = O(), { handleEvent: F } = q(), { getStripoBlocksConfig: B } = I(), T = async (i, r = [], s = !1) => {
16
16
  var g, S, y;
17
- const e = E(), { html: p, css: a } = i, { baseBlocks: o, extensions: d } = await T(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0, F = ((S = c.value) == null ? void 0 : S.modulesDisabled) ?? !1, v = ((y = h.value) == null ? void 0 : y.forceRecreate) ?? !1;
17
+ const e = E(), { html: p, css: a } = i, { baseBlocks: o, extensions: d } = await B(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0, _ = ((S = c.value) == null ? void 0 : S.modulesDisabled) ?? !1, v = ((y = h.value) == null ? void 0 : y.forceRecreate) ?? !1;
18
18
  window.UIEditor.initEditor(
19
19
  document.querySelector("#guido-editor"),
20
20
  {
@@ -35,7 +35,7 @@ const se = (C, l) => {
35
35
  conditionsEnabled: f,
36
36
  customConditionsEnabled: f,
37
37
  enableXSSSecurity: !0,
38
- modulesDisabled: F,
38
+ modulesDisabled: _,
39
39
  syncModulesEnabled: s,
40
40
  messageSettingsEnabled: !0,
41
41
  displayGmailAnnotations: !0,
@@ -43,6 +43,7 @@ const se = (C, l) => {
43
43
  displayTitle: !1,
44
44
  displayUTM: !1,
45
45
  selectElementAfterDrop: !0,
46
+ sameFontSizeForOutlook: !0,
46
47
  allowedScriptSourceDomains: "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com",
47
48
  ...o ? { baseBlocks: o } : {},
48
49
  editorFonts: {
@@ -52,7 +53,7 @@ const se = (C, l) => {
52
53
  },
53
54
  mergeTags: [
54
55
  {
55
- entries: L(
56
+ entries: z(
56
57
  l.preselectedDynamicContentList,
57
58
  u("liquidSyntax")
58
59
  )
@@ -88,7 +89,7 @@ const se = (C, l) => {
88
89
  onDataChanged() {
89
90
  e.hasChanges = !0;
90
91
  },
91
- onEvent: B,
92
+ onEvent: F,
92
93
  ignoreClickOutsideSelectors: [
93
94
  "#guido-dynamic-content-modal",
94
95
  ".in-on-board-wrapper",
@@ -98,13 +99,13 @@ const se = (C, l) => {
98
99
  localePatch: H
99
100
  }
100
101
  );
101
- }, _ = (i) => new Promise((r, s) => {
102
+ }, V = (i) => new Promise((r, s) => {
102
103
  var d;
103
104
  if (document.getElementById("UiEditorScript")) {
104
105
  i(), r();
105
106
  return;
106
107
  }
107
- const e = $.guido, a = `https://email-static.useinsider.com/guido/${(d = e == null ? void 0 : e.stripo) == null ? void 0 : d.version}/UIEditor.js`, o = document.createElement("script");
108
+ const e = L.guido, a = `https://email-static.useinsider.com/guido/${(d = e == null ? void 0 : e.stripo) == null ? void 0 : d.version}/UIEditor.js`, o = document.createElement("script");
108
109
  o.id = "UiEditorScript", o.type = "module", o.src = a, o.onload = () => {
109
110
  i(), r();
110
111
  }, o.onerror = () => {
@@ -112,12 +113,12 @@ const se = (C, l) => {
112
113
  }, document.body.appendChild(o);
113
114
  });
114
115
  return { initPlugin: async (i) => {
115
- await _(async () => {
116
+ await V(async () => {
116
117
  const r = E(), [s, e] = await Promise.all([
117
118
  b(),
118
119
  k()
119
120
  ]);
120
- r.syncModulesEnabled = e, await V(i, s, e);
121
+ r.syncModulesEnabled = e, await T(i, s, e);
121
122
  });
122
123
  } };
123
124
  };
@@ -1,127 +1,133 @@
1
- import { useConfig as S } from "../../../composables/useConfig.js";
2
- import { useRecommendation as g } from "../../../composables/useRecommendation.js";
3
- import { CSS_CLASS_RECO_BUTTON as _ } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
- import { useRecommendationExtensionStore as q } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
- function y(r, c, e, o, s = "") {
6
- const n = `{{${s}${r}_${c}_${e}}}`, t = `{{${s}${r}_${c}_currency}}`;
7
- return o === "before" ? `${t} ${n}` : `${n} ${t}`;
1
+ import { useConfig as g } from "../../../composables/useConfig.js";
2
+ import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
3
+ import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
+ import { useRecommendationExtensionStore as C } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ function y(r, n, e, o, i = "") {
6
+ const c = `{{${i}${r}_${n}_${e}}}`, t = `{{${i}${r}_${n}_currency}}`;
7
+ return o === "before" ? `${t} ${c}` : `${c} ${t}`;
8
8
  }
9
- function f(r, c, e, o, s, n) {
10
- switch (c) {
9
+ function A(r) {
10
+ let n = r;
11
+ for (; n.children.length === 1; )
12
+ [n] = n.children;
13
+ return n;
14
+ }
15
+ function f(r, n, e, o, i, c) {
16
+ switch (n) {
11
17
  case "productImage": {
12
18
  const t = r.querySelector("img");
13
- t && (t.setAttribute("src", `{{${n}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${e}_${o}_name}}`));
14
- const i = r.querySelector("a");
15
- i && (i.setAttribute("href", `{{${n}${e}_${o}_url}}`), i.classList.add(_));
19
+ t && (t.setAttribute("src", `{{${c}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${c}${e}_${o}_name}}`));
20
+ const s = r.querySelector("a");
21
+ s && (s.setAttribute("href", `{{${c}${e}_${o}_url}}`), s.classList.add(q));
16
22
  break;
17
23
  }
18
24
  case "productName": {
19
25
  const t = r.querySelector("p");
20
26
  if (t) {
21
- const i = t.querySelector("strong") || t;
22
- i.textContent = `{{${n}${e}_${o}_name}}`;
27
+ const s = t.querySelector("strong") || t;
28
+ s.textContent = `{{${c}${e}_${o}_name}}`;
23
29
  }
24
30
  break;
25
31
  }
26
32
  case "productPrice": {
27
33
  const t = r.querySelector("p");
28
- if (t) {
29
- const i = t.querySelector("strong") || t;
30
- i.textContent = y(e, o, "price", s, n);
31
- }
34
+ t && (A(t).textContent = y(
35
+ e,
36
+ o,
37
+ "price",
38
+ i,
39
+ c
40
+ ));
32
41
  break;
33
42
  }
34
43
  case "productOldPrice": {
35
44
  const t = r.querySelector("p");
36
- if (t) {
37
- const i = t.querySelector("strong") || t;
38
- i.textContent = y(
39
- e,
40
- o,
41
- "original_price",
42
- s,
43
- n
44
- ), t.setAttribute("product-attr", "discount");
45
- }
45
+ t && (A(t).textContent = y(
46
+ e,
47
+ o,
48
+ "original_price",
49
+ i,
50
+ c
51
+ ), t.setAttribute("product-attr", "discount"));
46
52
  break;
47
53
  }
48
54
  case "productButton": {
49
55
  const t = r.querySelector("a");
50
- t && t.setAttribute("href", `{{${n}${e}_${o}_url}}`);
56
+ t && t.setAttribute("href", `{{${c}${e}_${o}_url}}`);
51
57
  break;
52
58
  }
53
59
  case "productOmnibusPrice": {
54
60
  const t = r.querySelector(".omnibus-price-value");
55
61
  if (t) {
56
- t.textContent = `{{${n}${e}_${o}_omnibus_price}}`;
57
- const i = t.closest("p");
58
- i && (i.setAttribute("product-attr", "omnibus_price"), i.setAttribute("composition", "true"));
62
+ t.textContent = `{{${c}${e}_${o}_omnibus_price}}`;
63
+ const s = t.closest("p");
64
+ s && (s.setAttribute("product-attr", "omnibus_price"), s.setAttribute("composition", "true"));
59
65
  }
60
66
  break;
61
67
  }
62
68
  case "productOmnibusDiscount": {
63
69
  const t = r.querySelector(".omnibus-discount-value");
64
70
  if (t) {
65
- t.textContent = `{{${n}${e}_${o}_omnibus_discount}}`;
66
- const i = t.closest("p");
67
- i && (i.setAttribute("product-attr", "omnibus_discount"), i.setAttribute("composition", "true"));
71
+ t.textContent = `{{${c}${e}_${o}_omnibus_discount}}`;
72
+ const s = t.closest("p");
73
+ s && (s.setAttribute("product-attr", "omnibus_discount"), s.setAttribute("composition", "true"));
68
74
  }
69
75
  break;
70
76
  }
71
77
  default: {
72
78
  const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
73
79
  if (t) {
74
- const i = t.getAttribute("product-attr"), a = t.querySelector("p");
80
+ const s = t.getAttribute("product-attr"), a = t.querySelector("p");
75
81
  if (a) {
76
82
  const u = a.querySelector("strong") || a;
77
- u.textContent = `{{${n}${e}_${o}_${i}}}`;
83
+ u.textContent = `{{${c}${e}_${o}_${s}}}`;
78
84
  }
79
85
  }
80
86
  break;
81
87
  }
82
88
  }
83
89
  }
84
- function C(r, c, e, o) {
85
- r.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
86
- n.querySelectorAll("[data-attribute-type]").forEach((a) => {
90
+ function w(r, n, e, o) {
91
+ r.querySelectorAll(".recommendation-product-row").forEach((c, t) => {
92
+ c.querySelectorAll("[data-attribute-type]").forEach((a) => {
87
93
  const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
88
94
  p.length > 0 ? p.forEach((l) => {
89
- f(l, u, c, t, e, o);
90
- }) : f(a, u, c, t, e, o);
95
+ f(l, u, n, t, e, o);
96
+ }) : f(a, u, n, t, e, o);
91
97
  });
92
98
  });
93
99
  }
94
- function E(r, c, e, o) {
95
- const s = r.querySelectorAll(".recommendation-product-row");
96
- if (!s.length)
100
+ function E(r, n, e, o) {
101
+ const i = r.querySelectorAll(".recommendation-product-row");
102
+ if (!i.length)
97
103
  return;
98
- const [n] = s, t = n.querySelector("[data-attribute-type]"), i = t ? t.querySelectorAll(".attribute-cell").length : 1;
99
- s.forEach((a, u) => {
104
+ const [c] = i, t = c.querySelector("[data-attribute-type]"), s = t ? t.querySelectorAll(".attribute-cell").length : 1;
105
+ i.forEach((a, u) => {
100
106
  a.querySelectorAll("[data-attribute-type]").forEach((l) => {
101
107
  const d = l.getAttribute("data-attribute-type") || "";
102
- l.querySelectorAll(".attribute-cell").forEach((A, h) => {
103
- const $ = u * i + h;
104
- f(A, d, c, $, e, o);
108
+ l.querySelectorAll(".attribute-cell").forEach((h, $) => {
109
+ const S = u * s + $;
110
+ f(h, d, n, S, e, o);
105
111
  });
106
112
  });
107
113
  });
108
114
  }
109
- function w(r, c, e, o) {
110
- r.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
111
- E(n, c, e, o);
115
+ function R(r, n, e, o) {
116
+ r.querySelectorAll(".ins-recommendation-product-container").forEach((c) => {
117
+ E(c, n, e, o);
112
118
  });
113
119
  }
114
- function R(r, c, e) {
115
- const o = r.getAttribute("data-layout") || "grid", s = r.getAttribute("currency-alignment") || "after";
116
- o === "list" ? C(r, c, s, e) : w(r, c, s, e);
120
+ function P(r, n, e) {
121
+ const o = r.getAttribute("data-layout") || "grid", i = r.getAttribute("currency-alignment") || "after";
122
+ o === "list" ? w(r, n, i, e) : R(r, n, i, e);
117
123
  }
118
- function b(r, c, e) {
119
- const o = new RegExp(`${c}\\s*:\\s*(\\d+)\\s*px`, "i"), s = r.match(o);
120
- return s ? parseInt(s[1]) : e;
124
+ function b(r, n, e) {
125
+ const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), i = r.match(o);
126
+ return i ? parseInt(i[1]) : e;
121
127
  }
122
- function P(r, c) {
128
+ function T(r, n) {
123
129
  let e = r.parentElement;
124
- for (; e && e !== c; ) {
130
+ for (; e && e !== n; ) {
125
131
  if (e.tagName === "TD") {
126
132
  const o = e.getAttribute("width");
127
133
  if (o && o.endsWith("%") && parseFloat(o) < 100)
@@ -131,40 +137,40 @@ function P(r, c) {
131
137
  }
132
138
  return null;
133
139
  }
134
- function T(r) {
135
- const c = r.getAttribute("style") || "", e = b(c, "width", 600), o = b(c, "padding", 0) * 2, s = Math.max(0, e - o);
136
- s !== 0 && r.querySelectorAll("img.adapt-img").forEach((n) => {
137
- if (n.hasAttribute("width"))
140
+ 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);
142
+ i !== 0 && r.querySelectorAll("img.adapt-img").forEach((c) => {
143
+ if (c.hasAttribute("width"))
138
144
  return;
139
- const t = P(n, r);
145
+ const t = T(c, r);
140
146
  if (!t)
141
147
  return;
142
- const i = t.getAttribute("width"), a = parseFloat(i), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(s * a / 100), l = Math.max(1, p - u);
143
- n.setAttribute("width", String(l));
144
- const d = n.getAttribute("style") || "";
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);
149
+ c.setAttribute("width", String(l));
150
+ const d = c.getAttribute("style") || "";
145
151
  if (!/\bwidth\s*:\s*\d/i.test(d)) {
146
152
  const m = d && !d.trim().endsWith(";") ? "; " : "";
147
- n.setAttribute("style", `${d}${m}width: ${l}px`);
153
+ c.setAttribute("style", `${d}${m}width: ${l}px`);
148
154
  }
149
155
  });
150
156
  }
151
- function v(r, c) {
157
+ function O(r, n) {
152
158
  const e = r.match(/<!DOCTYPE[^>]*>/i);
153
159
  return (e ? `${e[0]}
154
- ` : "") + c.documentElement.outerHTML;
160
+ ` : "") + n.documentElement.outerHTML;
155
161
  }
156
162
  function N(r) {
157
- const c = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(c, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
163
+ const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
158
164
  if (!o.length)
159
165
  return r;
160
- const { buildCampaignUrl: s } = g(), n = q();
161
- n.recommendationCampaignUrls = {};
162
- const { isFeatureEnabled: t } = S(), i = t("liquidSyntax") ? "reco_" : "";
166
+ const { buildCampaignUrl: i } = _(), c = C();
167
+ c.recommendationCampaignUrls = {};
168
+ const { isFeatureEnabled: t } = g(), s = t("liquidSyntax") ? "reco_" : "";
163
169
  return o.forEach((u) => {
164
170
  var l, d;
165
171
  const p = u.getAttribute("recommendation-id");
166
- p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), s(p), R(u, p, i), T(u));
167
- }), v(c, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
172
+ p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), i(p), P(u, p, s), v(u));
173
+ }), O(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
168
174
  }
169
175
  export {
170
176
  y as formatPriceVariable,