@useinsider/guido 3.9.1 → 3.10.0-beta.06d1f41

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 (37) hide show
  1. package/dist/composables/useCortexBlueprintBridge.js +36 -32
  2. package/dist/composables/useCustomInterfaceAppearance.js +16 -18
  3. package/dist/composables/useEmailTemplateApplier.js +17 -15
  4. package/dist/composables/useExport.js +18 -18
  5. package/dist/composables/useHtmlValidator.js +90 -90
  6. package/dist/composables/useStripo.js +53 -51
  7. package/dist/composables/useStripoNotifications.js +26 -0
  8. package/dist/composables/useToaster.js +11 -11
  9. package/dist/composables/useVersionHistoryApi.js +2 -2
  10. package/dist/composables/validators/useLiquidValidator.js +1 -1
  11. package/dist/composables/validators/useUnsubscribeBlockValidator.js +10 -10
  12. package/dist/config/compiler/htmlCompilerRules.js +30 -7
  13. package/dist/config/compiler/utils/recommendationCompilerUtils.js +137 -119
  14. package/dist/enums/defaults.js +7 -4
  15. package/dist/enums/toaster.js +2 -2
  16. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +1 -1
  17. package/dist/extensions/Blocks/Recommendation/useRecommendationBlockWarning.js +7 -7
  18. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +75 -69
  19. package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +18 -17
  20. package/dist/services/blankTemplate.js +34 -0
  21. package/dist/services/stripoApi.js +13 -18
  22. package/dist/services/templateLibraryApi.js +8 -7
  23. package/dist/src/composables/useCortexBlueprintBridge.d.ts +5 -2
  24. package/dist/src/composables/useEmailTemplateApplier.d.ts +8 -3
  25. package/dist/src/composables/useStripoNotifications.d.ts +10 -0
  26. package/dist/src/enums/defaults.d.ts +3 -0
  27. package/dist/src/enums/toaster.d.ts +2 -2
  28. package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +6 -0
  29. package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +1 -0
  30. package/dist/src/services/blankTemplate.d.ts +11 -0
  31. package/dist/src/stores/toaster.d.ts +2 -3
  32. package/dist/stores/toaster.js +10 -10
  33. package/dist/utils/pairProductVariables.js +64 -65
  34. package/package.json +2 -2
  35. package/dist/static/styles/components/notification.css.js +0 -74
  36. package/dist/static/templates/empty/index.html.js +0 -74
  37. package/dist/static/templates/empty/style.css.js +0 -779
@@ -1,189 +1,207 @@
1
- import { useConfig as q } from "../../../composables/useConfig.js";
2
- import { useRecommendation as C } from "../../../composables/useRecommendation.js";
3
- import { CSS_CLASS_RECO_BUTTON as E } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
1
+ import { useConfig as C } from "../../../composables/useConfig.js";
2
+ import { useRecommendation as E } from "../../../composables/useRecommendation.js";
3
+ import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
4
  import { useRecommendationExtensionStore as w } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
5
  import { isIgnoredRecommendationBlock as P } from "./recommendationIgnoreUtils.js";
6
- function f(t, o, e, n, s = "") {
7
- const i = `{{${s}${t}_${o}_${e}}}`, r = `{{${s}${t}_${o}_currency}}`;
8
- return n === "before" ? `${r} ${i}` : `${i} ${r}`;
9
- }
10
- function m(t) {
11
- let o = t;
12
- for (; o.children.length === 1; )
13
- [o] = o.children;
14
- return o;
15
- }
16
- function h(t, o, e, n, s, i) {
17
- switch (o) {
6
+ function R(t, r, e, o, s = "") {
7
+ const i = `{{${s}${t}_${r}_${e}}}`, n = `{{${s}${t}_${r}_currency}}`;
8
+ return o === "before" ? `${n} ${i}` : `${i} ${n}`;
9
+ }
10
+ function y(t) {
11
+ let r = t;
12
+ for (; r.children.length === 1; )
13
+ [r] = r.children;
14
+ return r;
15
+ }
16
+ function A(t, r, e, o, s, i) {
17
+ switch (r) {
18
18
  case "productImage": {
19
- const r = t.querySelector("img");
20
- r && (r.setAttribute("src", `{{${i}${e}_${n}_image_url}}`), r.setAttribute("alt", `{{${i}${e}_${n}_name}}`));
19
+ const n = t.querySelector("img");
20
+ n && (n.setAttribute("src", `{{${i}${e}_${o}_image_url}}`), n.setAttribute("alt", `{{${i}${e}_${o}_name}}`));
21
21
  const c = t.querySelector("a");
22
- c && (c.setAttribute("href", `{{${i}${e}_${n}_url}}`), c.classList.add(E));
22
+ c && (c.setAttribute("href", `{{${i}${e}_${o}_url}}`), c.classList.add(q));
23
23
  break;
24
24
  }
25
25
  case "productName": {
26
- const r = t.querySelector("p");
27
- r && (m(r).textContent = `{{${i}${e}_${n}_name}}`);
28
- break;
29
- }
30
- case "productPrice": {
31
- const r = t.querySelector(".product-price p") ?? t.querySelector("p");
32
- r && (m(r).textContent = f(
33
- e,
34
- n,
35
- "price",
36
- s,
37
- i
38
- ));
39
- const c = t.querySelector(".product-old-price p");
40
- c && (m(c).textContent = f(
41
- e,
42
- n,
43
- "original_price",
44
- s,
45
- i
46
- ));
26
+ const n = t.querySelector("p");
27
+ n && (y(n).textContent = `{{${i}${e}_${o}_name}}`);
47
28
  break;
48
29
  }
30
+ // Inline mode ("Move to next line" OFF) merges BOTH prices into one row
31
+ // anchored on whichever attribute comes first in the composition, so
32
+ // substitute by cell content, not by the row's anchor (SD-145161).
33
+ case "productPrice":
49
34
  case "productOldPrice": {
50
- const r = t.querySelector("p");
51
- r && (m(r).textContent = f(
52
- e,
53
- n,
54
- "original_price",
55
- s,
56
- i
57
- ));
35
+ const n = (l, d) => {
36
+ l && (y(l).textContent = R(
37
+ e,
38
+ o,
39
+ d,
40
+ s,
41
+ i
42
+ ));
43
+ }, c = t.querySelector(".product-price p"), a = t.querySelector(".product-old-price p"), u = !c && !a ? t.querySelector("p") : null;
44
+ n(c ?? (r === "productPrice" ? u : null), "price"), n(a ?? (r === "productOldPrice" ? u : null), "original_price");
58
45
  break;
59
46
  }
60
47
  case "productButton": {
61
- const r = t.querySelector("a");
62
- r && r.setAttribute("href", `{{${i}${e}_${n}_url}}`);
48
+ const n = t.querySelector("a");
49
+ n && n.setAttribute("href", `{{${i}${e}_${o}_url}}`);
63
50
  break;
64
51
  }
65
52
  case "productOmnibusPrice": {
66
- const r = t.querySelector(".omnibus-price-value");
67
- if (r) {
68
- r.textContent = `{{${i}${e}_${n}_omnibus_price}}`;
69
- const c = r.closest("p");
53
+ const n = t.querySelector(".omnibus-price-value");
54
+ if (n) {
55
+ n.textContent = `{{${i}${e}_${o}_omnibus_price}}`;
56
+ const c = n.closest("p");
70
57
  c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
71
58
  }
72
59
  break;
73
60
  }
74
61
  case "productOmnibusDiscount": {
75
- const r = t.querySelector(".omnibus-discount-value");
76
- if (r) {
77
- r.textContent = `{{${i}${e}_${n}_omnibus_discount}}`;
78
- const c = r.closest("p");
62
+ const n = t.querySelector(".omnibus-discount-value");
63
+ if (n) {
64
+ n.textContent = `{{${i}${e}_${o}_omnibus_discount}}`;
65
+ const c = n.closest("p");
79
66
  c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
80
67
  }
81
68
  break;
82
69
  }
83
70
  default: {
84
- const r = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
85
- if (r) {
86
- const c = r.getAttribute("product-attr"), l = r.querySelector("p");
87
- l && (m(l).textContent = `{{${i}${e}_${n}_${c}}}`);
71
+ const n = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
72
+ if (n) {
73
+ const c = n.getAttribute("product-attr"), a = n.querySelector("p");
74
+ a && (y(a).textContent = `{{${i}${e}_${o}_${c}}}`);
88
75
  }
89
76
  break;
90
77
  }
91
78
  }
92
79
  }
93
- function R(t, o, e, n) {
94
- t.querySelectorAll(".recommendation-product-row").forEach((i, r) => {
95
- i.querySelectorAll("[data-attribute-type]").forEach((l) => {
96
- const u = l.getAttribute("data-attribute-type") || "", p = l.querySelectorAll(".attribute-cell");
97
- p.length > 0 ? p.forEach((a) => {
98
- h(a, u, o, r, e, n);
99
- }) : h(l, u, o, r, e, n);
100
- });
80
+ const B = "name";
81
+ function S(t, r, e, o) {
82
+ const s = `${o}${r}_${e}_${B}`;
83
+ return {
84
+ open: t.createComment(`{% if ${s} and ${s} != "" %}`),
85
+ close: t.createComment("{% endif %}")
86
+ };
87
+ }
88
+ function L(t, r, e) {
89
+ return S(t, r, 0, e);
90
+ }
91
+ function N(t, r, e, o) {
92
+ if (!t.innerHTML.includes("{{"))
93
+ return;
94
+ const { open: s, close: i } = S(t.ownerDocument, r, e, o);
95
+ t.insertBefore(s, t.firstChild), t.appendChild(i);
96
+ }
97
+ function T(t, r, e, o) {
98
+ var n, c;
99
+ if (!t.innerHTML.includes("{{"))
100
+ return;
101
+ const { open: s, close: i } = S(t.ownerDocument, r, e, o);
102
+ (n = t.parentNode) == null || n.insertBefore(s, t), (c = t.parentNode) == null || c.insertBefore(i, t.nextSibling);
103
+ }
104
+ function v(t, r, e, o) {
105
+ t.querySelectorAll(".recommendation-product-row").forEach((i, n) => {
106
+ i.querySelectorAll("[data-attribute-type]").forEach((a) => {
107
+ const u = a.getAttribute("data-attribute-type") || "", l = a.querySelectorAll(".attribute-cell");
108
+ l.length > 0 ? l.forEach((d) => {
109
+ A(d, u, r, n, e, o);
110
+ }) : A(a, u, r, n, e, o);
111
+ }), T(i, r, n, o);
101
112
  });
102
113
  }
103
- function W(t, o, e, n) {
114
+ function O(t, r, e, o) {
104
115
  const s = t.querySelectorAll(".recommendation-product-row");
105
116
  if (!s.length)
106
117
  return;
107
- const [i] = s, r = i.querySelector("[data-attribute-type]"), c = r ? r.querySelectorAll(".attribute-cell").length : 1;
108
- s.forEach((l, u) => {
109
- l.querySelectorAll("[data-attribute-type]").forEach((a) => {
110
- const d = a.getAttribute("data-attribute-type") || "";
111
- a.querySelectorAll(".attribute-cell").forEach((S, _) => {
112
- const g = u * c + _;
113
- h(S, d, o, g, e, n);
118
+ const [i] = s, n = i.querySelector("[data-attribute-type]"), c = n ? n.querySelectorAll(".attribute-cell").length : 1;
119
+ s.forEach((a, u) => {
120
+ a.querySelectorAll("[data-attribute-type]").forEach((d) => {
121
+ const p = d.getAttribute("data-attribute-type") || "";
122
+ d.querySelectorAll(".attribute-cell").forEach((m, f) => {
123
+ const h = u * c + f;
124
+ A(m, p, r, h, e, o), N(m, r, h, o);
114
125
  });
115
126
  });
116
127
  });
117
128
  }
118
- function v(t, o, e, n) {
129
+ function W(t, r, e, o) {
119
130
  t.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
120
- W(i, o, e, n);
131
+ O(i, r, e, o);
121
132
  });
122
133
  }
123
- function O(t, o, e) {
124
- const n = t.getAttribute("data-layout") || "grid", s = t.getAttribute("currency-alignment") || "after";
125
- n === "list" ? R(t, o, s, e) : v(t, o, s, e);
134
+ function D(t, r, e) {
135
+ const o = t.getAttribute("data-layout") || "grid", s = t.getAttribute("currency-alignment") || "after";
136
+ o === "list" ? v(t, r, s, e) : W(t, r, s, e);
126
137
  }
127
- function b(t, o, e) {
128
- const n = new RegExp(`${o}\\s*:\\s*(\\d+)\\s*px`, "i"), s = t.match(n);
138
+ function $(t, r, e) {
139
+ const o = new RegExp(`${r}\\s*:\\s*(\\d+)\\s*px`, "i"), s = t.match(o);
129
140
  return s ? parseInt(s[1]) : e;
130
141
  }
131
- function A(t) {
132
- const o = t.trim();
133
- return o.endsWith("%") ? parseFloat(o) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(o) && parseInt(o) > 0;
142
+ function _(t) {
143
+ const r = t.trim();
144
+ return r.endsWith("%") ? parseFloat(r) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(r) && parseInt(r) > 0;
134
145
  }
135
- function $(t) {
136
- const o = t.getAttribute("width");
137
- if (o && A(o))
138
- return o.trim();
146
+ function g(t) {
147
+ const r = t.getAttribute("width");
148
+ if (r && _(r))
149
+ return r.trim();
139
150
  const e = (t.getAttribute("style") || "").match(/(?:^|[;\s])width\s*:\s*(\d+(?:\.\d+)?(?:px|%))/i);
140
- return e && A(e[1]) ? e[1] : null;
151
+ return e && _(e[1]) ? e[1] : null;
141
152
  }
142
- function T(t, o) {
153
+ function M(t, r) {
143
154
  let e = t.parentElement;
144
- for (; e && e !== o; ) {
145
- if (e.tagName === "TD" && $(e))
155
+ for (; e && e !== r; ) {
156
+ if (e.tagName === "TD" && g(e))
146
157
  return e;
147
158
  e = e.parentElement;
148
159
  }
149
160
  return null;
150
161
  }
151
- function M(t) {
152
- const o = t.getAttribute("style") || "", e = b(o, "width", 600), n = b(o, "padding", 0) * 2, s = Math.max(0, e - n);
162
+ function G(t) {
163
+ const r = t.getAttribute("style") || "", e = $(r, "width", 600), o = $(r, "padding", 0) * 2, s = Math.max(0, e - o);
153
164
  s !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
154
165
  if (i.hasAttribute("width"))
155
166
  return;
156
- const r = T(i, t);
157
- if (!r)
167
+ const n = M(i, t);
168
+ if (!n)
158
169
  return;
159
- const c = $(r), l = b(r.getAttribute("style") || "", "padding", 0) * 2, u = c.endsWith("%") ? Math.floor(s * parseFloat(c) / 100) : parseInt(c), p = Math.max(1, u - l);
160
- i.setAttribute("width", String(p));
161
- const a = i.getAttribute("style") || "";
162
- if (!/\bwidth\s*:\s*\d/i.test(a)) {
163
- const d = a && !a.trim().endsWith(";") ? "; " : "";
164
- i.setAttribute("style", `${a}${d}width: ${p}px`);
170
+ const c = g(n), a = $(n.getAttribute("style") || "", "padding", 0) * 2, u = c.endsWith("%") ? Math.floor(s * parseFloat(c) / 100) : parseInt(c), l = Math.max(1, u - a);
171
+ i.setAttribute("width", String(l));
172
+ const d = i.getAttribute("style") || "";
173
+ if (!/\bwidth\s*:\s*\d/i.test(d)) {
174
+ const p = d && !d.trim().endsWith(";") ? "; " : "";
175
+ i.setAttribute("style", `${d}${p}width: ${l}px`);
165
176
  }
166
177
  });
167
178
  }
168
- function B(t, o) {
179
+ function H(t, r) {
169
180
  const e = t.match(/<!DOCTYPE[^>]*>/i);
170
181
  return (e ? `${e[0]}
171
- ` : "") + o.documentElement.outerHTML;
182
+ ` : "") + r.documentElement.outerHTML;
172
183
  }
173
- function G(t) {
174
- const o = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(o, "text/html"), n = e.querySelectorAll(".recommendation-block-v2");
175
- if (!n.length)
184
+ function Y(t) {
185
+ const r = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(r, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
186
+ if (!o.length)
176
187
  return t;
177
- const { buildCampaignUrl: s } = C(), i = w();
188
+ const { buildCampaignUrl: s } = E(), i = w();
178
189
  i.recommendationCampaignUrls = {};
179
- const { isFeatureEnabled: r } = q(), c = r("liquidSyntax") ? "reco_" : "";
180
- return n.forEach((u) => {
181
- var a, d;
182
- const p = u.getAttribute("recommendation-id");
183
- p && ((a = u.parentNode) == null || a.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((y) => y.remove()), s(p), P(u) || O(u, p, c), M(u));
184
- }), B(o, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
190
+ const { isFeatureEnabled: n } = C(), c = n("liquidSyntax") ? "reco_" : "";
191
+ return o.forEach((u) => {
192
+ var d, p, b, m;
193
+ const l = u.getAttribute("recommendation-id");
194
+ if (l) {
195
+ if ((d = u.parentNode) == null || d.insertBefore(e.createComment("REC_START"), u), (p = u.parentNode) == null || p.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((f) => f.remove()), s(l), !P(u)) {
196
+ D(u, l, c);
197
+ const { open: f, close: h } = L(e, l, c);
198
+ (b = u.parentNode) == null || b.insertBefore(f, u), (m = u.parentNode) == null || m.insertBefore(h, u.nextSibling);
199
+ }
200
+ G(u);
201
+ }
202
+ }), H(r, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
185
203
  }
186
204
  export {
187
- f as formatPriceVariable,
188
- G as prepareRecommendationBlocks
205
+ R as formatPriceVariable,
206
+ Y as prepareRecommendationBlocks
189
207
  };
@@ -1,12 +1,15 @@
1
1
  const e = {
2
2
  transactional: 2
3
- }, o = 2, t = 13, s = {
3
+ }, s = 2, a = 13, t = "https://email-static.useinsider.com", o = `${t}/templates/campaign/default.html`, l = `${t}/templates/campaign/default.css`, E = {
4
4
  SAVED_MODULES: "savedModules",
5
5
  DEFAULT_MODULES: "defaultModules"
6
6
  };
7
7
  export {
8
- o as EditorType,
9
- t as MAX_DEFAULT_TEMPLATE_ID,
10
- s as ModuleFolderDefaults,
8
+ l as BLANK_TEMPLATE_CSS_URL,
9
+ o as BLANK_TEMPLATE_HTML_URL,
10
+ t as EMAIL_STATIC_BASE_URL,
11
+ s as EditorType,
12
+ a as MAX_DEFAULT_TEMPLATE_ID,
13
+ E as ModuleFolderDefaults,
11
14
  e as TemplateTypes
12
15
  };
@@ -1,4 +1,4 @@
1
- var c = /* @__PURE__ */ ((r) => (r.Success = "success", r.Warning = "warning", r.Alert = "alert", r.Dark = "dark", r))(c || {});
1
+ var n = /* @__PURE__ */ ((r) => (r.Success = "success", r.Warning = "warning", r.Error = "error", r.Info = "information", r))(n || {});
2
2
  export {
3
- c as ToasterTypeOptions
3
+ n as ToasterTypeOptions
4
4
  };
@@ -53,7 +53,7 @@ class P extends E {
53
53
  if (!m)
54
54
  return;
55
55
  const g = m.getInnerHTML().trim() || "", C = m.getInnerText().trim() || "", _ = this._removeCurrencySymbol(C, o), S = this._buildPriceContent(_, n, l), b = g.replace(C, f(S));
56
- i.modifyHtml(m).setInnerHtml(b);
56
+ i.modifyHtml(m).setInnerHtml(b).setAttribute("data-currency_symbol", n);
57
57
  }), i.apply(new B(
58
58
  `Updated currency symbol to ${n || "removed"}`
59
59
  ));
@@ -1,16 +1,16 @@
1
- import { useToaster as r } from "../../../composables/useToaster.js";
1
+ import { useToaster as n } from "../../../composables/useToaster.js";
2
2
  import { useTranslations as s } from "../../../composables/useTranslations.js";
3
- import { ToasterTypeOptions as n } from "../../../enums/toaster.js";
3
+ import { ToasterTypeOptions as r } from "../../../enums/toaster.js";
4
4
  import { countLiveRecommendationBlocks as i } from "./utils/recommendationBlockCount.js";
5
- const a = "newsletter.multiple-reco-blocks-warning", f = () => {
6
- const { showToaster: o } = r(), t = s();
5
+ const c = "newsletter.multiple-reco-blocks-warning", u = () => {
6
+ const { showToaster: o } = n(), t = s();
7
7
  return { warnIfMultipleBlocks: (e) => {
8
8
  i(e) > 1 && o({
9
- type: n.Dark,
10
- message: t(a)
9
+ type: r.Info,
10
+ message: t(c)
11
11
  });
12
12
  } };
13
13
  };
14
14
  export {
15
- f as useRecommendationBlockWarning
15
+ u as useRecommendationBlockWarning
16
16
  };