@useinsider/guido 3.9.1-beta.c408b35 → 3.9.1-beta.c521c3a

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.
@@ -10,17 +10,17 @@ import { en as h } from "../config/i18n/en/index.js";
10
10
  import { ToasterTypeOptions as L } from "../enums/toaster.js";
11
11
  import { useStripoApi as $ } from "../services/stripoApi.js";
12
12
  import G from "../static/styles/customEditorStyle.css.js";
13
- import { useEditorStore as E } from "../stores/editor.js";
13
+ import { useEditorStore as C } from "../stores/editor.js";
14
14
  import { dynamicContentToMergeTags as J } from "../utils/genericUtil.js";
15
15
  import N from "../package.json.js";
16
- const ce = (C, l) => {
17
- const { features: c, template: w, isFeatureEnabled: u } = R(), { handleError: m, showToaster: b } = H(), { getToken: k, getCustomFonts: T, getSyncModulesStatus: B } = $(), { handleEvent: F } = q(), { getStripoBlocksConfig: v } = U(), V = async (s, r = [], i = !1) => {
16
+ const ce = (E, l) => {
17
+ const { features: c, template: w, isFeatureEnabled: u } = R(), { handleError: m, showToaster: b } = H(), { getToken: T, getCustomFonts: k, getSyncModulesStatus: B } = $(), { handleEvent: F } = q(), { getStripoBlocksConfig: v } = U(), V = async (s, r = [], i = !1) => {
18
18
  var g, S, y;
19
- const e = E(), { html: p, css: a } = s, { baseBlocks: o, extensions: d } = await v(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0, A = ((S = c.value) == null ? void 0 : S.modulesDisabled) ?? !1, M = ((y = w.value) == null ? void 0 : y.forceRecreate) ?? !1;
19
+ const e = C(), { html: p, css: a } = s, { baseBlocks: t, extensions: d } = await v(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0, A = ((S = c.value) == null ? void 0 : S.modulesDisabled) ?? !1, M = ((y = w.value) == null ? void 0 : y.forceRecreate) ?? !1;
20
20
  await window.UIEditor.initEditor(
21
21
  document.querySelector("#guido-editor"),
22
22
  {
23
- metadata: C,
23
+ metadata: E,
24
24
  html: p,
25
25
  css: a,
26
26
  forceRecreate: M,
@@ -42,13 +42,12 @@ const ce = (C, l) => {
42
42
  messageSettingsEnabled: !0,
43
43
  displayGmailAnnotations: !0,
44
44
  displayHiddenPreheader: !1,
45
- keepModuleStylesEnabled: !0,
46
45
  displayTitle: !1,
47
46
  displayUTM: !1,
48
47
  selectElementAfterDrop: !0,
49
48
  sameFontSizeForOutlook: !0,
50
49
  allowedScriptSourceDomains: "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com",
51
- ...o ? { baseBlocks: o } : {},
50
+ ...t ? { baseBlocks: t } : {},
52
51
  editorFonts: {
53
52
  showDefaultStandardFonts: !0,
54
53
  showDefaultNotStandardFonts: !0,
@@ -62,32 +61,32 @@ const ce = (C, l) => {
62
61
  )
63
62
  }
64
63
  ],
65
- async onTokenRefreshRequest(t) {
64
+ async onTokenRefreshRequest(o) {
66
65
  try {
67
- const n = await k();
68
- t(n);
66
+ const n = await T();
67
+ o(n);
69
68
  } catch (n) {
70
69
  m(n, "Failed to refresh token");
71
70
  }
72
71
  },
73
72
  onTemplateLoaded() {
74
73
  try {
75
- const { importCss: t } = x(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: P } = I(), { injectFullStory: D } = O();
76
- t(), n(), D(), P(), l.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
74
+ const { importCss: o } = x(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: P } = I(), { injectFullStory: D } = O();
75
+ o(), n(), D(), P(), l.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
77
76
  e.hasChanges = !1;
78
77
  }, 1e3);
79
- } catch (t) {
80
- m(t, "Failed to load custom interface appearance");
78
+ } catch (o) {
79
+ m(o, "Failed to load custom interface appearance");
81
80
  }
82
81
  },
83
- onCodeEditorVisibilityChanged(t) {
84
- e.isCodeEditorOpen = t;
82
+ onCodeEditorVisibilityChanged(o) {
83
+ e.isCodeEditorOpen = o;
85
84
  },
86
- onEditorVisualModeChanged(t) {
87
- e.editorVisualMode = t.toLowerCase();
85
+ onEditorVisualModeChanged(o) {
86
+ e.editorVisualMode = o.toLowerCase();
88
87
  },
89
- onVersionHistoryVisibilityChanged(t) {
90
- e.isVersionHistoryOpen = t;
88
+ onVersionHistoryVisibilityChanged(o) {
89
+ e.isVersionHistoryOpen = o;
91
90
  },
92
91
  onDataChanged() {
93
92
  e.hasChanges = !0;
@@ -108,19 +107,19 @@ const ce = (C, l) => {
108
107
  Promise.resolve(s()).then(r, i);
109
108
  return;
110
109
  }
111
- const e = N.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");
112
- o.id = "UiEditorScript", o.type = "module", o.src = a, o.onload = () => {
110
+ const e = N.guido, a = `https://email-static.useinsider.com/guido/${(d = e == null ? void 0 : e.stripo) == null ? void 0 : d.version}/UIEditor.js`, t = document.createElement("script");
111
+ t.id = "UiEditorScript", t.type = "module", t.src = a, t.onload = () => {
113
112
  Promise.resolve(s()).then(r, i);
114
- }, o.onerror = () => {
113
+ }, t.onerror = () => {
115
114
  i(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
116
- }, document.body.appendChild(o);
115
+ }, document.body.appendChild(t);
117
116
  });
118
117
  return { initPlugin: async (s) => {
119
- const r = E();
118
+ const r = C();
120
119
  try {
121
120
  await _(async () => {
122
121
  const [i, e] = await Promise.all([
123
- T(),
122
+ k(),
124
123
  B()
125
124
  ]);
126
125
  r.syncModulesEnabled = e, await V(s, i, e);
@@ -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,4 +1,4 @@
1
- const u = [
1
+ const l = [
2
2
  {
3
3
  key: "locale",
4
4
  getValue: (e) => e.language,
@@ -7,27 +7,28 @@ const u = [
7
7
  {
8
8
  key: "currency",
9
9
  getValue: (e) => e.currencySettings.value,
10
- getAvailableOptions: (e) => e.currencyList.map((n) => n.text)
10
+ getAvailableOptions: (e) => e.currencyList.map((n) => n.text),
11
+ canBeEmpty: !0
11
12
  }
12
- ], s = "newsletter.recommendation-fill-required-fields";
13
- function l(e, n, o = u) {
14
- return o.filter((t) => {
15
- var a;
13
+ ], o = "newsletter.recommendation-fill-required-fields";
14
+ function c(e, n, i = l) {
15
+ return i.filter((t) => {
16
+ var u;
16
17
  if (t.condition && !t.condition(e))
17
18
  return !1;
18
- const i = t.getValue(e);
19
- if (!i)
20
- return !0;
21
- const r = (a = t.getAvailableOptions) == null ? void 0 : a.call(t, n);
22
- return r !== void 0 && !r.includes(i);
19
+ const r = (u = t.getAvailableOptions) == null ? void 0 : u.call(t, n);
20
+ if (t.canBeEmpty && (r == null ? void 0 : r.length) === 0)
21
+ return !1;
22
+ const a = t.getValue(e);
23
+ return a ? r !== void 0 && !r.includes(a) : !0;
23
24
  }).map((t) => t.key);
24
25
  }
25
- function c(e, n) {
26
- return l(e, n).length === 0;
26
+ function s(e, n) {
27
+ return c(e, n).length === 0;
27
28
  }
28
29
  export {
29
- u as REQUIRED_RECOMMENDATION_FIELDS,
30
- s as RecommendationRequiredFieldsKey,
31
- l as getInvalidFields,
32
- c as isConfigValid
30
+ l as REQUIRED_RECOMMENDATION_FIELDS,
31
+ o as RecommendationRequiredFieldsKey,
32
+ c as getInvalidFields,
33
+ s as isConfigValid
33
34
  };
@@ -10,6 +10,7 @@ export interface ExtensionStoreSlice {
10
10
  }
11
11
  export interface RequiredField {
12
12
  key: string;
13
+ canBeEmpty?: boolean;
13
14
  getValue: (config: PerBlockConfigs) => string;
14
15
  getAvailableOptions?: (store: ExtensionStoreSlice) => string[];
15
16
  condition?: (config: PerBlockConfigs) => boolean;
@@ -1,85 +1,84 @@
1
- import { productPairs as L } from "../extensions/Blocks/Items/enums/productEnums.js";
2
- function q(w) {
3
- const y = w.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), T = new DOMParser().parseFromString(y, "text/html"), C = L.PAIRS_FOR_EXTENSION;
4
- Object.entries(C).forEach(([r, f]) => {
5
- T.querySelectorAll(".ins-product-td").forEach((o) => {
6
- const A = o.getAttribute("data-number") || "1", b = o.getAttribute("data-type") || "CART_ITEMS";
7
- o.querySelectorAll(`[product-attr="${r}"]`).forEach((e) => {
8
- var k, F, I;
9
- const $ = e.getAttribute("data-type") || b, d = e.getAttribute("data-number") || A, u = f[$];
10
- if (u)
1
+ import { productPairs as q } from "../extensions/Blocks/Items/enums/productEnums.js";
2
+ import { DefaultConfigValues as N } from "../extensions/Blocks/Items/enums/settingsEnums.js";
3
+ function W(M) {
4
+ const S = M.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), g = new DOMParser().parseFromString(S, "text/html"), m = q.PAIRS_FOR_EXTENSION;
5
+ Object.entries(m).forEach(([r, f]) => {
6
+ g.querySelectorAll(".ins-product-td").forEach((c) => {
7
+ const A = c.getAttribute("data-number") || "1", C = c.getAttribute("data-type") || "CART_ITEMS";
8
+ c.querySelectorAll(`[product-attr="${r}"]`).forEach((e) => {
9
+ var F, I, w;
10
+ const $ = e.getAttribute("data-type") || C, u = e.getAttribute("data-number") || A, d = f[$];
11
+ if (d)
11
12
  switch (r) {
12
13
  case "imageSrc": {
13
14
  let t = null, i = null;
14
15
  if (e.tagName === "IMG" ? (t = e, i = t.closest("a")) : (t = e.querySelector("img"), i = e.querySelector("a") || e.closest("a")), !t)
15
16
  break;
16
- const a = u.DEFAULT, s = u.ATTR;
17
+ const a = d.DEFAULT, s = d.ATTR;
17
18
  if (a && t.src) {
18
- const c = t.src;
19
+ const o = t.src;
19
20
  a.some((h) => {
20
- const l = h.split("/").pop() || "", g = c.split("/").pop() || "";
21
- return c.includes(h) || c.includes(l) || g === l;
22
- }) && (t.src = `{{${s}_${d}}}`);
21
+ const l = h.split("/").pop() || "", b = o.split("/").pop() || "";
22
+ return o.includes(h) || o.includes(l) || b === l;
23
+ }) && (t.src = `{{${s}_${u}}}`);
23
24
  }
24
- const n = (F = (k = C.name) == null ? void 0 : k[$]) == null ? void 0 : F.ATTR;
25
- if (n && t.setAttribute("alt", `{{${n}_${d}}}`), i) {
26
- const c = (I = C.itemLink) == null ? void 0 : I[$];
27
- if (c) {
28
- const E = c.HREF, h = c.DEFAULT_HREF || "#!", l = i.href;
29
- (l === "#" || l === "" || l.endsWith("#!") || l.endsWith(h) || l === `${window.location.href}${h}` || !l || l === window.location.href) && (i.href = `{{${E}_${d}}}`);
25
+ const n = (I = (F = m.name) == null ? void 0 : F[$]) == null ? void 0 : I.ATTR;
26
+ if (n && t.setAttribute("alt", `{{${n}_${u}}}`), i) {
27
+ const o = (w = m.itemLink) == null ? void 0 : w[$];
28
+ if (o) {
29
+ const E = o.HREF, h = o.DEFAULT_HREF || "#!", l = i.href;
30
+ (l === "#" || l === "" || l.endsWith("#!") || l.endsWith(h) || l === `${window.location.href}${h}` || !l || l === window.location.href) && (i.href = `{{${E}_${u}}}`);
30
31
  }
31
32
  }
32
33
  break;
33
34
  }
34
35
  case "name": {
35
- const t = u, i = t.ATTR, a = t.DEFAULT_HREF || "#!", s = t.HREF;
36
- e.textContent && (e.textContent = `{{${i}_${d}}}`);
36
+ const t = d, i = t.ATTR, a = t.DEFAULT_HREF || "#!", s = t.HREF;
37
+ e.textContent && (e.textContent = `{{${i}_${u}}}`);
37
38
  const n = e.closest("a") || (e.tagName === "A" ? e : null);
38
39
  if (n && s) {
39
- const c = n.href, E = `${window.location.href}${a}`;
40
- (c === E || c.endsWith(a)) && (n.href = `{{${s}_${d}}}`);
40
+ const o = n.href, E = `${window.location.href}${a}`;
41
+ (o === E || o.endsWith(a)) && (n.href = `{{${s}_${u}}}`);
41
42
  }
42
43
  break;
43
44
  }
44
45
  case "price":
45
46
  case "originalPrice": {
46
- const t = u, i = e.getAttribute("data-formated"), a = e.getAttribute("data-single_price"), s = i === "true", n = a === "true", c = e.getAttribute("data-curency") || "before";
47
+ const t = d, i = e.getAttribute("data-formated"), a = e.getAttribute("data-single_price"), s = i === "true", n = a === "true", o = e.getAttribute("data-curency") || "before";
47
48
  let E;
48
49
  n ? E = s ? t.SINGLE_PRICE_FORMATTED : t.SINGLE_PRICE : E = s ? t.PRICE_FORMATTED : t.PRICE;
49
50
  const h = t.CURRENCY;
50
- let l = `{{${E}_${d}}}`;
51
- if (h) {
52
- const g = `{{${h}_${d}}}`;
53
- l = c === "after" ? `${l} ${g}` : `${g} ${l}`;
54
- }
55
- e.textContent = l;
51
+ let l = `{{${E}_${u}}}`;
52
+ const b = (e.getAttribute("data-currency_symbol") || "").trim(), x = b !== "" && b !== N.productPriceCurrencySymbolControlValue;
53
+ let T = "";
54
+ x ? T = b : h && (T = `{{${h}_${u}}}`), T && (l = o === "after" ? `${l} ${T}` : `${T} ${l}`), e.textContent = l;
56
55
  break;
57
56
  }
58
57
  case "quantity": {
59
- const t = u, i = t.ATTR, a = t.DEFAULT;
60
- e.textContent && e.textContent.trim() === a && (e.textContent = `{{${i}_${d}}}`);
58
+ const t = d, i = t.ATTR, a = t.DEFAULT;
59
+ e.textContent && e.textContent.trim() === a && (e.textContent = `{{${i}_${u}}}`);
61
60
  break;
62
61
  }
63
62
  case "button": {
64
- const t = u, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e.tagName === "A" ? e : e.querySelector("a");
63
+ const t = d, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e.tagName === "A" ? e : e.querySelector("a");
65
64
  if (s) {
66
- const n = s.href || "", c = `${window.location.href}${a}`;
67
- (n === "" || n === "#" || n === c || n.endsWith(a) || n.endsWith("#!") || n === window.location.href) && (s.href = `{{${i}_${d}}}`);
65
+ const n = s.href || "", o = `${window.location.href}${a}`;
66
+ (n === "" || n === "#" || n === o || n.endsWith(a) || n.endsWith("#!") || n === window.location.href) && (s.href = `{{${i}_${u}}}`);
68
67
  }
69
68
  break;
70
69
  }
71
70
  case "itemLink": {
72
- const t = u, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e;
71
+ const t = d, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e;
73
72
  if (s.href) {
74
- const n = s.href, c = `${window.location.href}${a}`;
75
- (n === c || n.endsWith(a)) && (s.href = `{{${i}_${d}}}`);
73
+ const n = s.href, o = `${window.location.href}${a}`;
74
+ (n === o || n.endsWith(a)) && (s.href = `{{${i}_${u}}}`);
76
75
  }
77
76
  break;
78
77
  }
79
78
  default: {
80
- if ("ATTR" in u) {
81
- const t = u.ATTR;
82
- e.textContent && (e.textContent = `{{${t}_${d}}}`);
79
+ if ("ATTR" in d) {
80
+ const t = d.ATTR;
81
+ e.textContent && (e.textContent = `{{${t}_${u}}}`);
83
82
  }
84
83
  break;
85
84
  }
@@ -87,48 +86,48 @@ function q(w) {
87
86
  });
88
87
  });
89
88
  });
90
- const S = y.match(/<!DOCTYPE[^>]*>/i), M = S ? `${S[0]}
91
- ` : "", P = T.querySelectorAll(".ins-product-td"), H = [];
92
- P.forEach((r) => {
93
- const f = r.getAttribute("data-type") || "CART_ITEMS", p = r.getAttribute("data-number") || "1", o = r.getAttribute("data-nodup"), A = r.outerHTML;
94
- H.push({
89
+ const H = S.match(/<!DOCTYPE[^>]*>/i), P = H ? `${H[0]}
90
+ ` : "", D = g.querySelectorAll(".ins-product-td"), k = [];
91
+ D.forEach((r) => {
92
+ const f = r.getAttribute("data-type") || "CART_ITEMS", p = r.getAttribute("data-number") || "1", c = r.getAttribute("data-nodup"), A = r.outerHTML;
93
+ k.push({
95
94
  element: r,
96
95
  outerHtml: A,
97
96
  type: f,
98
97
  number: p,
99
- nodup: o || void 0
98
+ nodup: c || void 0
100
99
  });
101
100
  });
102
- let _ = M + T.documentElement.outerHTML;
103
- H.reverse().forEach(({ outerHtml: r, type: f, number: p }) => {
104
- let o = "";
101
+ let _ = P + g.documentElement.outerHTML;
102
+ k.reverse().forEach(({ outerHtml: r, type: f, number: p }) => {
103
+ let c = "";
105
104
  switch (f) {
106
105
  case "CART_ITEMS":
107
- o = "ins_apr_total_product_kind";
106
+ c = "ins_apr_total_product_kind";
108
107
  break;
109
108
  case "BROWSED_ITEMS":
110
- o = "browsed_item_total_product_kind";
109
+ c = "browsed_item_total_product_kind";
111
110
  break;
112
111
  case "PURCHASED_ITEMS":
113
- o = "purchased_item_total_product_kind";
112
+ c = "purchased_item_total_product_kind";
114
113
  break;
115
114
  }
116
- if (o) {
117
- const b = parseInt(p) - 1, $ = `${`{% if ${o} > ${b} %}`}${r}{% endif %}`;
115
+ if (c) {
116
+ const C = parseInt(p) - 1, $ = `${`{% if ${c} > ${C} %}`}${r}{% endif %}`;
118
117
  _ = _.replace(r, $);
119
118
  }
120
119
  });
121
- const D = T.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), R = [];
122
- return D.forEach((r) => {
120
+ const L = g.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), y = [];
121
+ return L.forEach((r) => {
123
122
  const f = r.getAttribute("data-number"), p = r.getAttribute("data-type");
124
123
  if (!f || p !== "CART_ITEMS")
125
124
  return;
126
- const o = r.closest(".product-original-price-class");
127
- if (o) {
128
- const A = o.outerHTML;
129
- R.some((m) => m.tdOuterHtml === A) || R.push({ tdOuterHtml: A, number: f });
125
+ const c = r.closest(".product-original-price-class");
126
+ if (c) {
127
+ const A = c.outerHTML;
128
+ y.some((R) => R.tdOuterHtml === A) || y.push({ tdOuterHtml: A, number: f });
130
129
  }
131
- }), R.reverse().forEach(({ tdOuterHtml: r, number: f }) => {
130
+ }), y.reverse().forEach(({ tdOuterHtml: r, number: f }) => {
132
131
  const p = `{% if ins_apr_price_${f} != ins_apr_originalprice_${f} %}`;
133
132
  if (!_.includes(p) && !r.includes("{% if")) {
134
133
  const A = `${p}${r}{% endif %}`;
@@ -137,5 +136,5 @@ function q(w) {
137
136
  }), _.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
138
137
  }
139
138
  export {
140
- q as pairProductVariables
139
+ W as pairProductVariables
141
140
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.9.1-beta.c408b35",
3
+ "version": "3.9.1-beta.c521c3a",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",