@useinsider/guido 3.4.1-beta.1fc7f53 → 3.4.1-beta.2120861

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.
package/README.md CHANGED
@@ -8,6 +8,8 @@
8
8
 
9
9
  # @useinsider/guido
10
10
 
11
+ [![Coverus](https://github.com/useinsider/coverus-artifacts/raw/main/badges/github/useinsider/guido/coverage.svg)](http://coverus.internal.dataforce/app/project/github/useinsider/guido)
12
+
11
13
  Guido is a Vue 2 + TypeScript wrapper for the Stripo Email Editor plugin. Easily embed the professional email editor in your Vue applications with a clean, type-safe configuration.
12
14
 
13
15
  ## Installation
@@ -4,21 +4,20 @@ import e from "../static/styles/components/amp-block.css.js";
4
4
  import i from "../static/styles/components/base-input.css.js";
5
5
  import p from "../static/styles/components/button-group.css.js";
6
6
  import n from "../static/styles/components/button.css.js";
7
- import C from "../static/styles/components/combobox.css.js";
8
- import s from "../static/styles/components/counter.css.js";
7
+ import s from "../static/styles/components/combobox.css.js";
8
+ import C from "../static/styles/components/counter.css.js";
9
9
  import f from "../static/styles/components/dropdown-menu.css.js";
10
10
  import a from "../static/styles/components/loader.css.js";
11
11
  import u from "../static/styles/components/narrow-panel.css.js";
12
- import c from "../static/styles/components/notification.css.js";
13
- import d from "../static/styles/components/popup.css.js";
14
- import l from "../static/styles/components/switcher.css.js";
15
- import h from "../static/styles/components/tabs.css.js";
16
- import w from "../static/styles/components/tools.css.js";
17
- import y from "../static/styles/components/version-history.css.js";
18
- import B from "../static/styles/components/wide-panel.css.js";
19
- import b from "../static/styles/variables.css.js";
20
- const A = [
21
- b,
12
+ import c from "../static/styles/components/popup.css.js";
13
+ import d from "../static/styles/components/switcher.css.js";
14
+ import l from "../static/styles/components/tabs.css.js";
15
+ import h from "../static/styles/components/tools.css.js";
16
+ import w from "../static/styles/components/version-history.css.js";
17
+ import y from "../static/styles/components/wide-panel.css.js";
18
+ import B from "../static/styles/variables.css.js";
19
+ const b = [
20
+ B,
22
21
  // Must be on top
23
22
  S,
24
23
  // Must be on top
@@ -27,8 +26,8 @@ const A = [
27
26
  i,
28
27
  p,
29
28
  n,
30
- C,
31
29
  s,
30
+ C,
32
31
  f,
33
32
  a,
34
33
  u,
@@ -37,13 +36,12 @@ const A = [
37
36
  l,
38
37
  h,
39
38
  w,
40
- y,
41
- B
39
+ y
42
40
  ].join(`
43
41
 
44
- `), F = () => ({ importCss: () => {
42
+ `), v = () => ({ importCss: () => {
45
43
  const o = new CSSStyleSheet();
46
- o.replaceSync(A);
44
+ o.replaceSync(b);
47
45
  const r = document.querySelector("ui-editor");
48
46
  if (!r)
49
47
  return;
@@ -51,5 +49,5 @@ const A = [
51
49
  t && (t.adoptedStyleSheets = [o]);
52
50
  } });
53
51
  export {
54
- F as useCustomInterfaceAppearance
52
+ v as useCustomInterfaceAppearance
55
53
  };
@@ -1,27 +1,28 @@
1
- import { useActionsApi as D } from "./useActionsApi.js";
2
- import { useBlocksConfig as I } from "./useBlocksConfig.js";
3
- import { useConfig as P } from "./useConfig.js";
4
- import { useCustomInterfaceAppearance as U } from "./useCustomInterfaceAppearance.js";
5
- import { useFullStoryBridge as R } from "./useFullStoryBridge.js";
6
- import { useStripoEventHandler as q } from "./useStripoEventHandler.js";
7
- import { useToaster as x } from "./useToaster.js";
8
- import { localePatch as H } from "../config/i18n/index.js";
9
- import { useStripoApi as O } from "../services/stripoApi.js";
10
- import j from "../static/styles/customEditorStyle.css.js";
1
+ import { useActionsApi as U } from "./useActionsApi.js";
2
+ import { useBlocksConfig as R } from "./useBlocksConfig.js";
3
+ import { useConfig as q } from "./useConfig.js";
4
+ import { useCustomInterfaceAppearance as x } from "./useCustomInterfaceAppearance.js";
5
+ import { useFullStoryBridge as H } from "./useFullStoryBridge.js";
6
+ import { useStripoEventHandler as N } from "./useStripoEventHandler.js";
7
+ import { useStripoNotifications as O } from "./useStripoNotifications.js";
8
+ import { useToaster as j } from "./useToaster.js";
9
+ import { localePatch as L } from "../config/i18n/index.js";
10
+ import { useStripoApi as $ } from "../services/stripoApi.js";
11
+ import z from "../static/styles/customEditorStyle.css.js";
11
12
  import { useEditorStore as E } from "../stores/editor.js";
12
- import { dynamicContentToMergeTags as L } from "../utils/genericUtil.js";
13
- import $ from "../package.json.js";
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) => {
13
+ import { dynamicContentToMergeTags as G } from "../utils/genericUtil.js";
14
+ import J from "../package.json.js";
15
+ const ct = (C, c) => {
16
+ const { features: l, template: h, isFeatureEnabled: u } = q(), { handleError: m } = j(), { getToken: w, getCustomFonts: b, getSyncModulesStatus: k } = $(), { handleEvent: B } = N(), { getStripoNotifications: T } = O(), { getStripoBlocksConfig: V } = R(), _ = async (i, s = [], r = !1) => {
16
17
  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;
18
+ const t = E(), { html: p, css: a } = i, { baseBlocks: o, extensions: d } = await V(), f = ((g = l.value) == null ? void 0 : g.displayConditions) ?? !0, v = ((S = l.value) == null ? void 0 : S.modulesDisabled) ?? !1, M = ((y = h.value) == null ? void 0 : y.forceRecreate) ?? !1, A = "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com", D = T();
18
19
  window.UIEditor.initEditor(
19
20
  document.querySelector("#guido-editor"),
20
21
  {
21
22
  metadata: C,
22
23
  html: p,
23
24
  css: a,
24
- forceRecreate: v,
25
+ forceRecreate: M,
25
26
  locale: "en",
26
27
  undoButtonSelector: "#guido__undo-button",
27
28
  redoButtonSelector: "#guido__redo-button",
@@ -31,96 +32,97 @@ const se = (C, l) => {
31
32
  customAppearanceMergetags: !u("liquidSyntax"),
32
33
  customAppearanceMergetagsBorderColor: "#f1f3fe",
33
34
  customAppearanceMergetagsBackgroundColor: "#f1f3fe",
34
- customViewStyles: j,
35
+ customViewStyles: z,
35
36
  conditionsEnabled: f,
36
37
  customConditionsEnabled: f,
37
38
  enableXSSSecurity: !0,
38
- modulesDisabled: F,
39
- syncModulesEnabled: s,
39
+ modulesDisabled: v,
40
+ syncModulesEnabled: r,
40
41
  messageSettingsEnabled: !0,
41
42
  displayGmailAnnotations: !0,
42
43
  displayHiddenPreheader: !1,
43
44
  displayTitle: !1,
44
45
  displayUTM: !1,
45
46
  selectElementAfterDrop: !0,
46
- allowedScriptSourceDomains: "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com",
47
+ allowedScriptSourceDomains: A,
47
48
  ...o ? { baseBlocks: o } : {},
48
49
  editorFonts: {
49
50
  showDefaultStandardFonts: !0,
50
51
  showDefaultNotStandardFonts: !0,
51
- customFonts: r
52
+ customFonts: s
52
53
  },
53
54
  mergeTags: [
54
55
  {
55
- entries: L(
56
- l.preselectedDynamicContentList,
56
+ entries: G(
57
+ c.preselectedDynamicContentList,
57
58
  u("liquidSyntax")
58
59
  )
59
60
  }
60
61
  ],
61
- async onTokenRefreshRequest(t) {
62
+ async onTokenRefreshRequest(e) {
62
63
  try {
63
64
  const n = await w();
64
- t(n);
65
+ e(n);
65
66
  } catch (n) {
66
67
  m(n, "Failed to refresh token");
67
68
  }
68
69
  },
69
70
  onTemplateLoaded() {
70
71
  try {
71
- const { importCss: t } = U(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: M } = D(), { injectFullStory: A } = R();
72
- t(), n(), A(), M(), l.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
73
- e.hasChanges = !1;
72
+ const { importCss: e } = x(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: I } = U(), { injectFullStory: P } = H();
73
+ e(), n(), P(), I(), c.onReady(), t.isStripoInitialized = !0, t.loadingStatus = !1, setTimeout(() => {
74
+ t.hasChanges = !1;
74
75
  }, 1e3);
75
- } catch (t) {
76
- m(t, "Failed to load custom interface appearance");
76
+ } catch (e) {
77
+ m(e, "Failed to load custom interface appearance");
77
78
  }
78
79
  },
79
- onCodeEditorVisibilityChanged(t) {
80
- e.isCodeEditorOpen = t;
80
+ onCodeEditorVisibilityChanged(e) {
81
+ t.isCodeEditorOpen = e;
81
82
  },
82
- onEditorVisualModeChanged(t) {
83
- e.editorVisualMode = t.toLowerCase();
83
+ onEditorVisualModeChanged(e) {
84
+ t.editorVisualMode = e.toLowerCase();
84
85
  },
85
- onVersionHistoryVisibilityChanged(t) {
86
- e.isVersionHistoryOpen = t;
86
+ onVersionHistoryVisibilityChanged(e) {
87
+ t.isVersionHistoryOpen = e;
87
88
  },
88
89
  onDataChanged() {
89
- e.hasChanges = !0;
90
+ t.hasChanges = !0;
90
91
  },
91
92
  onEvent: B,
93
+ notifications: D,
92
94
  ignoreClickOutsideSelectors: [
93
95
  "#guido-dynamic-content-modal",
94
96
  ".in-on-board-wrapper",
95
97
  ".in-drawer__container"
96
98
  ],
97
99
  extensions: d,
98
- localePatch: H
100
+ localePatch: L
99
101
  }
100
102
  );
101
- }, _ = (i) => new Promise((r, s) => {
103
+ }, F = (i) => new Promise((s, r) => {
102
104
  var d;
103
105
  if (document.getElementById("UiEditorScript")) {
104
- i(), r();
106
+ i(), s();
105
107
  return;
106
108
  }
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");
109
+ const t = J.guido, a = `https://email-static.useinsider.com/guido/${(d = t == null ? void 0 : t.stripo) == null ? void 0 : d.version}/UIEditor.js`, o = document.createElement("script");
108
110
  o.id = "UiEditorScript", o.type = "module", o.src = a, o.onload = () => {
109
- i(), r();
111
+ i(), s();
110
112
  }, o.onerror = () => {
111
- s(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
113
+ r(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
112
114
  }, document.body.appendChild(o);
113
115
  });
114
116
  return { initPlugin: async (i) => {
115
- await _(async () => {
116
- const r = E(), [s, e] = await Promise.all([
117
+ await F(async () => {
118
+ const s = E(), [r, t] = await Promise.all([
117
119
  b(),
118
120
  k()
119
121
  ]);
120
- r.syncModulesEnabled = e, await V(i, s, e);
122
+ s.syncModulesEnabled = t, await _(i, r, t);
121
123
  });
122
124
  } };
123
125
  };
124
126
  export {
125
- se as useStripo
127
+ ct as useStripo
126
128
  };
@@ -0,0 +1,28 @@
1
+ import { useToaster as d } from "./useToaster.js";
2
+ import { ToasterTypeOptions as c } from "../enums/toaster.js";
3
+ const p = () => {
4
+ const { showToaster: s, hideToaster: u } = d();
5
+ let r = null, l = null;
6
+ const n = (t, o, i, e, f = {}) => {
7
+ if (r === i && l === o)
8
+ return;
9
+ r = i, l = o;
10
+ const a = e != null && e.action ? { text: e.action.label, onClick: e.action.func } : void 0;
11
+ s({ type: t, message: o, actionButton: a, autoHide: f.autoHide });
12
+ };
13
+ return { getStripoNotifications: () => ({
14
+ info: (t, o, i) => n(c.Info, t, o, i),
15
+ success: (t, o, i) => n(c.Success, t, o, i),
16
+ warn: (t, o, i) => n(c.Warning, t, o, i),
17
+ error: (t, o, i) => n(c.Alert, t, o, i),
18
+ // Loader represents an in-progress operation; Stripo dismisses it via hide(id)
19
+ // when the operation finishes, so we disable auto-hide for this variant.
20
+ loader: (t, o, i) => n(c.Info, t, o, i, { autoHide: !1 }),
21
+ hide: (t) => {
22
+ r === t && (u(), r = null, l = null);
23
+ }
24
+ }) };
25
+ };
26
+ export {
27
+ p as useStripoNotifications
28
+ };
@@ -155,6 +155,8 @@ class z {
155
155
  }
156
156
  migrate(t) {
157
157
  try {
158
+ if (!this.containsItemsBlock(t))
159
+ return t;
158
160
  let o = this.removeJinjaConditionals(t);
159
161
  o = this.replaceTemplateVariables(o);
160
162
  const l = this.parser.parseFromString(o, "text/html"), a = l.querySelectorAll(
@@ -178,15 +180,15 @@ class z {
178
180
  originalPriceStyles: e.originalPriceStyles,
179
181
  quantityStyles: e.quantityStyles,
180
182
  nodeConfig: R(e.configBlockAttributes)
181
- }), d = this.parser.parseFromString(
183
+ }), u = this.parser.parseFromString(
182
184
  `<table><tbody><tr>${c}</tr></tbody></table>`,
183
185
  "text/html"
184
186
  ).querySelector("td");
185
- if (d && i.parentNode) {
187
+ if (u && i.parentNode) {
186
188
  const p = R(e.configBlockAttributes);
187
- d.setAttribute("esd-ext-config", JSON.stringify(p));
188
- const u = d.querySelector("esd-config-block");
189
- u && u.remove(), i.parentNode.replaceChild(d, i);
189
+ u.setAttribute("esd-ext-config", JSON.stringify(p));
190
+ const d = u.querySelector("esd-config-block");
191
+ d && d.remove(), i.parentNode.replaceChild(u, i);
190
192
  }
191
193
  }), l.documentElement.outerHTML);
192
194
  } catch (o) {
@@ -201,22 +203,22 @@ class z {
201
203
  */
202
204
  extractConfiguration(t) {
203
205
  var C, D, P;
204
- const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, n = T[o], i = ((P = n == null ? void 0 : n[a]) == null ? void 0 : P.value) || n[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", d = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", p = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", u = this.extractConfigBlockAttributes(t, o, l), S = u["data-card_orientation_control_value"];
206
+ const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, n = T[o], i = ((P = n == null ? void 0 : n[a]) == null ? void 0 : P.value) || n[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", u = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", p = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, o, l), S = d["data-card_orientation_control_value"];
205
207
  let b;
206
208
  S ? b = S === "horizontal" ? "horizontal" : "vertical" : b = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
207
- const y = t.querySelector('a[product-attr="name"]'), I = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, h = (e == null ? void 0 : e.getAttribute("style")) || void 0, A = t.querySelector("p.original-price"), k = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), L = (E == null ? void 0 : E.getAttribute("style")) || void 0;
209
+ const y = t.querySelector('a[product-attr="name"]'), I = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, k = (e == null ? void 0 : e.getAttribute("style")) || void 0, A = t.querySelector("p.original-price"), h = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), L = (E == null ? void 0 : E.getAttribute("style")) || void 0;
208
210
  return {
209
211
  orientation: b,
210
212
  itemsType: o,
211
213
  itemId: i,
212
214
  currencySymbol: c,
213
- currencyLocation: d,
215
+ currencyLocation: u,
214
216
  formattedPrice: p,
215
- configBlockAttributes: u,
217
+ configBlockAttributes: d,
216
218
  nameStyles: I,
217
219
  buttonStyles: m,
218
- priceStyles: h,
219
- originalPriceStyles: k,
220
+ priceStyles: k,
221
+ originalPriceStyles: h,
220
222
  quantityStyles: L
221
223
  };
222
224
  }
@@ -296,6 +298,14 @@ class z {
296
298
  "data-product_button_link": "{{Abandoned Cart Item (1) Url}}"
297
299
  };
298
300
  }
301
+ /**
302
+ * Fast check for the presence of any items block (cart / browsed / purchased)
303
+ * in the raw HTML. Used to gate the migration pipeline so non-items templates
304
+ * are returned untouched.
305
+ */
306
+ containsItemsBlock(t) {
307
+ return t.includes("esd-cart-items-block") || t.includes("esd-browsed-items-block") || t.includes("esd-purchased-items-block");
308
+ }
299
309
  /**
300
310
  * Removes Jinja2 conditional statements from HTML
301
311
  * Handles all items block types:
@@ -337,18 +347,18 @@ class z {
337
347
  const [, i, e, c] = n, _ = x[i];
338
348
  if (!_)
339
349
  return console.warn(`Unknown variable prefix: ${i}`), l;
340
- const d = q[e];
341
- if (!d)
350
+ const u = q[e];
351
+ if (!u)
342
352
  return console.warn(`Unknown variable suffix mapping for: ${e}`), l;
343
- const { pairsKey: p, defaultKey: u, isArray: S } = d, y = o[p][_];
353
+ const { pairsKey: p, defaultKey: d, isArray: S } = u, y = o[p][_];
344
354
  if (!y)
345
355
  return console.warn(`No data found for: ${p}.${_}`), l;
346
356
  if (S) {
347
- const f = parseInt(c) - 1, m = y[u];
348
- return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${p}.${_}.${u}[${f}]`), l);
357
+ const f = parseInt(c) - 1, m = y[d];
358
+ return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${p}.${_}.${d}[${f}]`), l);
349
359
  }
350
- const I = y[u];
351
- return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${p}.${_}.${u}`), l);
360
+ const I = y[d];
361
+ return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${p}.${_}.${d}`), l);
352
362
  });
353
363
  }
354
364
  }
@@ -1,4 +1,4 @@
1
- var c = /* @__PURE__ */ ((r) => (r.Success = "success", r.Warning = "warning", r.Alert = "alert", r))(c || {});
1
+ var n = /* @__PURE__ */ ((r) => (r.Success = "success", r.Warning = "warning", r.Alert = "error", r.Info = "information", r))(n || {});
2
2
  export {
3
- c as ToasterTypeOptions
3
+ n as ToasterTypeOptions
4
4
  };
@@ -1,15 +1,16 @@
1
- import { useConfig as w } from "../composables/useConfig.js";
2
- import { useHttp as b } from "../composables/useHttp.js";
3
- import { useToaster as C } from "../composables/useToaster.js";
1
+ import { useConfig as b } from "../composables/useConfig.js";
2
+ import { useHttp as C } from "../composables/useHttp.js";
3
+ import { useToaster as S } from "../composables/useToaster.js";
4
4
  import { useTranslations as h } from "../composables/useTranslations.js";
5
- import { useLiquidValidator as S } from "../composables/validators/useLiquidValidator.js";
6
- import { EditorType as v } from "../enums/defaults.js";
7
- import { useRecommendationExtensionStore as N } from "../extensions/Blocks/Recommendation/store/recommendation.js";
8
- import { useSaveAsTemplateStore as x } from "../stores/save-as-template.js";
5
+ import { useLiquidValidator as v } from "../composables/validators/useLiquidValidator.js";
6
+ import { EditorType as N } from "../enums/defaults.js";
7
+ import { ToasterTypeOptions as g } from "../enums/toaster.js";
8
+ import { useRecommendationExtensionStore as x } from "../extensions/Blocks/Recommendation/store/recommendation.js";
9
+ import { useSaveAsTemplateStore as A } from "../stores/save-as-template.js";
9
10
  import { base64EncodeWithSpecialChars as r } from "../utils/base64.js";
10
- import { useTemplatePreparation as A } from "../utils/templatePreparation.js";
11
- const $ = () => {
12
- const { get: n, post: m } = b(), { handleError: o, showToaster: l } = C(), { config: c, isFeatureEnabled: p } = w(), { validateLiquidSyntax: g } = S(), u = h();
11
+ import { useTemplatePreparation as E } from "../utils/templatePreparation.js";
12
+ const j = () => {
13
+ const { get: n, post: m } = C(), { handleError: o, showToaster: l } = S(), { config: c, isFeatureEnabled: p } = b(), { validateLiquidSyntax: f } = v(), u = h();
13
14
  return {
14
15
  getCategories: async () => {
15
16
  try {
@@ -39,21 +40,21 @@ const $ = () => {
39
40
  createTemplate: async () => {
40
41
  var e, t, d, y;
41
42
  try {
42
- const { prepareTemplateDetails: i } = A(), s = x(), a = await i();
43
- if (p("liquidSyntax") && !await g(a.compiledHtml))
43
+ const { prepareTemplateDetails: i } = E(), s = A(), a = await i();
44
+ if (p("liquidSyntax") && !await f(a.compiledHtml))
44
45
  return !1;
45
- const f = {
46
+ const T = {
46
47
  name: s.getTemplateName,
47
48
  categories: s.getSelectedCategoryIds,
48
49
  productId: ((t = (e = c.value) == null ? void 0 : e.partner) == null ? void 0 : t.productType) || 0,
49
- editorType: v,
50
+ editorType: N,
50
51
  messageType: ((y = (d = c.value) == null ? void 0 : d.partner) == null ? void 0 : y.messageType) || 0,
51
52
  content: r(a.compiledHtml),
52
53
  css: r(a.css),
53
54
  unsubscriptionPreferencePageStatus: !1,
54
55
  unsubscriptionPreferencePages: [],
55
56
  recommendationCampaignUrls: r(
56
- N().recommendationCampaignUrls
57
+ x().recommendationCampaignUrls
57
58
  ),
58
59
  recommendationConfigs: r({}),
59
60
  isGuido: !0,
@@ -65,22 +66,22 @@ const $ = () => {
65
66
  css: a.css,
66
67
  dynamicContentList: a.dynamicContentList
67
68
  })
68
- }, { data: { type: T } } = await m(
69
+ }, { data: { type: w } } = await m(
69
70
  "/newsletter/template-library/create-template",
70
- f
71
+ T
71
72
  );
72
- return T === "alert" ? (l({
73
+ return w === "alert" ? (l({
73
74
  message: u(
74
75
  "newsletter.template-library-save-alert",
75
76
  { templateName: s.getTemplateName }
76
77
  ),
77
- type: "alert"
78
+ type: g.Alert
78
79
  }), !1) : (l({
79
80
  message: u(
80
81
  "newsletter.template-library-save-success",
81
82
  { templateName: s.getTemplateName }
82
83
  ),
83
- type: "success"
84
+ type: g.Success
84
85
  }), !0);
85
86
  } catch (i) {
86
87
  return o(i, "Failed to create template"), !1;
@@ -89,5 +90,5 @@ const $ = () => {
89
90
  };
90
91
  };
91
92
  export {
92
- $ as useTemplateLibraryApi
93
+ j as useTemplateLibraryApi
93
94
  };
@@ -0,0 +1,4 @@
1
+ import type { StripoNotifications } from '@@/Types/stripo';
2
+ export declare const useStripoNotifications: () => {
3
+ getStripoNotifications: () => StripoNotifications;
4
+ };
@@ -1,5 +1,6 @@
1
1
  export declare enum ToasterTypeOptions {
2
2
  Success = "success",
3
3
  Warning = "warning",
4
- Alert = "alert"
4
+ Alert = "error",
5
+ Info = "information"
5
6
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -11,8 +11,9 @@ export declare const useToasterStore: import("pinia").StoreDefinition<"guidoToas
11
11
  text: string;
12
12
  onClick: () => void;
13
13
  } | undefined;
14
+ autoHide: boolean;
14
15
  } & import("pinia").PiniaCustomStateProperties<ToasterState>) => boolean;
15
16
  }, {
16
- showToaster(this: ToasterState, { type, message, actionButton }: ToasterOptions): void;
17
+ showToaster(this: ToasterState, { type, message, actionButton, autoHide }: ToasterOptions): void;
17
18
  hideToaster(this: ToasterState): void;
18
19
  }>;
File without changes
@@ -1,8 +1,8 @@
1
1
  import "../@types/config/schemas.js";
2
2
  import "../@types/config/defaults.js";
3
- import { parseConfig as n } from "../@types/config/validator.js";
4
- import { defineStore as o } from "pinia";
5
- const s = o("guido-config", {
3
+ import { parseConfig as o } from "../@types/config/validator.js";
4
+ import { defineStore as r } from "pinia";
5
+ const f = r("guido-config", {
6
6
  state: () => ({
7
7
  initialized: !1,
8
8
  config: null
@@ -75,64 +75,65 @@ const s = o("guido-config", {
75
75
  * Get the template ID
76
76
  */
77
77
  templateId: (i) => {
78
- var e;
79
- return ((e = i.config) == null ? void 0 : e.identity.templateId) ?? "";
78
+ var e, t;
79
+ return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.templateId) ?? "";
80
80
  },
81
81
  /**
82
82
  * Get the user ID
83
83
  */
84
84
  userId: (i) => {
85
- var e;
86
- return ((e = i.config) == null ? void 0 : e.identity.userId) ?? "";
85
+ var e, t;
86
+ return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.userId) ?? "";
87
87
  },
88
88
  /**
89
89
  * Get the variation ID
90
90
  */
91
91
  variationId: (i) => {
92
- var e;
93
- return ((e = i.config) == null ? void 0 : e.identity.variationId) ?? "";
92
+ var e, t;
93
+ return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.variationId) ?? "";
94
94
  },
95
95
  /**
96
96
  * Get the partner name
97
97
  */
98
98
  partnerName: (i) => {
99
- var e;
100
- return ((e = i.config) == null ? void 0 : e.partner.name) ?? "";
99
+ var e, t;
100
+ return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.name) ?? "";
101
101
  },
102
102
  /**
103
103
  * Get the product type
104
104
  */
105
105
  productType: (i) => {
106
- var e;
107
- return ((e = i.config) == null ? void 0 : e.partner.productType) ?? 60;
106
+ var e, t;
107
+ return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.productType) ?? 60;
108
108
  },
109
109
  /**
110
110
  * Get the message type
111
111
  */
112
112
  messageType: (i) => {
113
- var e;
114
- return ((e = i.config) == null ? void 0 : e.partner.messageType) ?? 1;
113
+ var e, t;
114
+ return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.messageType) ?? 1;
115
115
  },
116
116
  /**
117
117
  * Get the username
118
118
  */
119
119
  username: (i) => {
120
- var e;
121
- return ((e = i.config) == null ? void 0 : e.partner.username) ?? "Guido User";
120
+ var e, t;
121
+ return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.username) ?? "Guido User";
122
122
  },
123
123
  /**
124
124
  * Check if header should be shown
125
125
  */
126
126
  showHeader: (i) => {
127
- var e;
128
- return ((e = i.config) == null ? void 0 : e.ui.showHeader) ?? !0;
127
+ var e, t;
128
+ return ((t = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : t.showHeader) ?? !0;
129
129
  },
130
130
  /**
131
131
  * Check if a specific feature is enabled
132
132
  */
133
+ // eslint-disable-next-line @stylistic/max-len
133
134
  isFeatureEnabled: (i) => (e) => {
134
- var t;
135
- return ((t = i.config) == null ? void 0 : t.features[e]) ?? !0;
135
+ var t, n;
136
+ return ((n = (t = i.config) == null ? void 0 : t.features) == null ? void 0 : n[e]) ?? !0;
136
137
  }
137
138
  },
138
139
  actions: {
@@ -140,7 +141,7 @@ const s = o("guido-config", {
140
141
  * Initialize the config store with validated configuration
141
142
  */
142
143
  init(i) {
143
- const e = n(i);
144
+ const e = o(i);
144
145
  this.config = e, this.initialized = !0;
145
146
  },
146
147
  /**
@@ -152,5 +153,5 @@ const s = o("guido-config", {
152
153
  }
153
154
  });
154
155
  export {
155
- s as useConfigStore
156
+ f as useConfigStore
156
157
  };
@@ -1,21 +1,22 @@
1
1
  import { ToasterTypeOptions as e } from "../enums/toaster.js";
2
- import { defineStore as i } from "pinia";
3
- const a = () => ({
2
+ import { defineStore as a } from "pinia";
3
+ const u = () => ({
4
4
  status: !1,
5
5
  type: e.Success,
6
6
  text: "",
7
7
  icon: "",
8
8
  withIcon: !0,
9
9
  withoutLeftMargin: !1,
10
- actionButton: void 0
11
- }), n = i("guidoToaster", {
12
- state: () => a(),
10
+ actionButton: void 0,
11
+ autoHide: !0
12
+ }), c = a("guidoToaster", {
13
+ state: () => u(),
13
14
  getters: {
14
- shouldAutoHide: (t) => t.status && !!t.text
15
+ shouldAutoHide: (t) => t.status && !!t.text && t.autoHide
15
16
  },
16
17
  actions: {
17
- showToaster({ type: t = e.Success, message: s, actionButton: o }) {
18
- this.status = !0, this.text = s, this.type = t, this.actionButton = o;
18
+ showToaster({ type: t = e.Success, message: o, actionButton: s, autoHide: i = !0 }) {
19
+ this.status = !0, this.text = o, this.type = t, this.actionButton = s, this.autoHide = i;
19
20
  },
20
21
  hideToaster() {
21
22
  this.status = !1;
@@ -23,5 +24,5 @@ const a = () => ({
23
24
  }
24
25
  });
25
26
  export {
26
- n as useToasterStore
27
+ c as useToasterStore
27
28
  };
@@ -1,79 +1,87 @@
1
- import { useActionsApi as T } from "../composables/useActionsApi.js";
2
- import { useHtmlCompiler as C } from "../composables/useHtmlCompiler.js";
3
- import { DEFAULT_CURRENCY as l, DEFAULT_NODE_CONFIG as a } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
1
+ import { useActionsApi as C } from "../composables/useActionsApi.js";
2
+ import { useHtmlCompiler as T } from "../composables/useHtmlCompiler.js";
3
+ import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as s } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
4
4
  import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { DATA_ATTRIBUTES as y } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
- import { parsePageList as P } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
- import { useDynamicContentStore as D } from "../stores/dynamic-content.js";
8
- import { useUnsubscribeStore as E } from "../stores/unsubscribe.js";
9
- function U(i, r) {
10
- const s = new DOMParser().parseFromString(i, "text/html").querySelectorAll(`[${y.PAGE_LIST}]`), c = [];
11
- return s.forEach((t) => {
12
- const o = t.getAttribute(y.PAGE_LIST);
13
- o && c.push(...P(o));
14
- }), r.filter((t) => c.includes(t));
5
+ import { DATA_ATTRIBUTES as S } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
+ import { parsePageList as D } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
+ import { useDynamicContentStore as P } from "../stores/dynamic-content.js";
8
+ import { useUnsubscribeStore as w } from "../stores/unsubscribe.js";
9
+ function E(i, o) {
10
+ const t = new DOMParser().parseFromString(i, "text/html").querySelectorAll(`[${S.PAGE_LIST}]`), c = [];
11
+ return t.forEach((r) => {
12
+ const a = r.getAttribute(S.PAGE_LIST);
13
+ a && c.push(...D(a));
14
+ }), o.filter((r) => c.includes(r));
15
15
  }
16
- function F(i) {
16
+ async function U(i) {
17
17
  const m = new DOMParser().parseFromString(i, "text/html").querySelectorAll(".recommendation-block-v2");
18
18
  if (m.length === 0)
19
19
  return;
20
- const d = b();
21
- m.forEach((s) => {
22
- var g, f, u, n, S;
23
- const c = s.getAttribute("recommendation-id"), t = c ? Number(c) : NaN;
24
- if (!Number.isFinite(t))
20
+ const l = b();
21
+ m.forEach((t) => {
22
+ var g, f, u, n, y;
23
+ const c = t.getAttribute("recommendation-id"), r = c ? Number(c) : NaN;
24
+ if (!Number.isFinite(r))
25
25
  return;
26
- const o = s.getAttribute("esd-ext-config");
27
- if (!o)
26
+ const a = t.getAttribute("esd-ext-config");
27
+ if (!a)
28
28
  return;
29
29
  let e;
30
30
  try {
31
- e = JSON.parse(o);
31
+ e = JSON.parse(a);
32
32
  } catch {
33
33
  return;
34
34
  }
35
35
  if (!e || typeof e != "object" || Array.isArray(e))
36
36
  return;
37
37
  const p = {
38
- strategy: e.strategy ?? a.strategy,
39
- language: e.language ?? a.language,
40
- size: e.size ?? a.size,
38
+ strategy: e.strategy ?? s.strategy,
39
+ language: e.language ?? s.language,
40
+ size: e.size ?? s.size,
41
41
  // Spread the default arrays so each block gets a fresh reference
42
42
  // instead of sharing the singleton in DEFAULT_NODE_CONFIG.
43
- productIds: e.productIds ?? [...a.productIds],
44
- filters: e.filters ?? [...a.filters],
45
- shuffleProducts: e.shuffleProducts ?? a.shuffleProducts,
46
- currencyCode: ((g = e.currency) == null ? void 0 : g.code) ?? l.code,
47
- currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ?? l.alignment,
48
- currencyDecimalCount: ((u = e.currency) == null ? void 0 : u.decimalCount) ?? l.decimalCount,
49
- currencyDecimalSeparator: ((n = e.currency) == null ? void 0 : n.decimalSeparator) ?? l.decimalSeparator,
50
- currencyThousandSeparator: ((S = e.currency) == null ? void 0 : S.thousandSeparator) ?? l.thousandSeparator
43
+ productIds: e.productIds ?? [...s.productIds],
44
+ filters: e.filters ?? [...s.filters],
45
+ shuffleProducts: e.shuffleProducts ?? s.shuffleProducts,
46
+ currencyCode: ((g = e.currency) == null ? void 0 : g.code) ?? d.code,
47
+ currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ?? d.alignment,
48
+ currencyDecimalCount: ((u = e.currency) == null ? void 0 : u.decimalCount) ?? d.decimalCount,
49
+ currencyDecimalSeparator: ((n = e.currency) == null ? void 0 : n.decimalSeparator) ?? d.decimalSeparator,
50
+ currencyThousandSeparator: ((y = e.currency) == null ? void 0 : y.thousandSeparator) ?? d.thousandSeparator
51
51
  };
52
- d.seedBlockUrlConfig(t, p);
52
+ l.seedBlockUrlConfig(r, p);
53
53
  });
54
+ try {
55
+ await l.fetchRecommendationCreateData();
56
+ } catch (t) {
57
+ console.warn(
58
+ "Recommendation reference data pre-load failed; validator will skip the availability check.",
59
+ t
60
+ );
61
+ }
54
62
  }
55
63
  const _ = () => {
56
- const i = D(), r = E(), { getCompiledEmail: m, getTemplateData: d } = T(), { compileHtml: s } = C();
64
+ const i = P(), o = w(), { getCompiledEmail: m, getTemplateData: l } = C(), { compileHtml: t } = T();
57
65
  return {
58
66
  prepareTemplateDetails: async () => {
59
- const { html: t, ampHtml: o = "", ampErrors: e = [] } = await m({
67
+ const { html: r, ampHtml: a = "", ampErrors: e = [] } = await m({
60
68
  minimize: !0,
61
69
  resetDataSavedFlag: !1
62
- }), { html: p, css: g, syncModulesIds: f = [] } = await d();
63
- r.selectedUnsubscribePages.length && await r.fetchTemplates(), F(p);
64
- const { compiledHtml: u, stats: n, appliedRules: S } = s(t), h = i.getSelectedDynamicContentList, A = b();
70
+ }), { html: p, css: g, syncModulesIds: f = [] } = await l();
71
+ o.selectedUnsubscribePages.length && await o.fetchTemplates(), await U(p);
72
+ const { compiledHtml: u, stats: n, appliedRules: y } = t(r), h = i.getSelectedDynamicContentList, A = b();
65
73
  return console.debug("HTML Compilation Stats:", {
66
74
  originalSize: n.originalSize,
67
75
  compiledSize: n.compiledSize,
68
76
  reduction: `${n.reductionPercentage.toFixed(2)}%`,
69
- appliedRules: S,
77
+ appliedRules: y,
70
78
  executionTime: `${n.executionTime.toFixed(2)}ms`
71
79
  }), {
72
80
  dynamicContentList: h,
73
81
  compiledHtml: u,
74
82
  rawHtml: p,
75
83
  css: g,
76
- ampHtml: o,
84
+ ampHtml: a,
77
85
  ampErrors: e,
78
86
  modules: f.map(Number),
79
87
  recommendation: {
@@ -81,8 +89,8 @@ const _ = () => {
81
89
  configs: {}
82
90
  },
83
91
  unsubscribe: {
84
- status: r.unsubscribePagesStatus,
85
- config: U(u, r.selectedUnsubscribePages)
92
+ status: o.unsubscribePagesStatus,
93
+ config: E(u, o.selectedUnsubscribePages)
86
94
  }
87
95
  };
88
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.4.1-beta.1fc7f53",
3
+ "version": "3.4.1-beta.2120861",
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",
@@ -24,7 +24,7 @@
24
24
  "lint": "NODE_OPTIONS=--max-old-space-size=2048 eslint ./ && bun run type-check",
25
25
  "lint:fix": "NODE_OPTIONS=--max-old-space-size=2048 eslint --fix ./",
26
26
  "type-check": "vue-tsc --noEmit --project tsconfig.config.json && vue-tsc --noEmit --project tsconfig.app.json",
27
- "test": "vitest run",
27
+ "test": "vitest run --coverage",
28
28
  "test:watch": "vitest",
29
29
  "test:visual-update": "npx playwright test --update-snapshots --reporter html",
30
30
  "prepare": "husky",
@@ -35,7 +35,7 @@
35
35
  "license": "ISC",
36
36
  "dependencies": {
37
37
  "@stripoinc/ui-editor-extensions": "3.8.0",
38
- "@useinsider/design-system-vue": "1.1.0-beta.73ec2fa",
38
+ "@useinsider/design-system-vue": "1.2.0",
39
39
  "@vueuse/core": "11.3.0",
40
40
  "lodash-es": "4.17.21",
41
41
  "pinia": "2.3.1",
@@ -61,6 +61,7 @@
61
61
  "@typescript-eslint/parser": "7.18.0",
62
62
  "@useinsider/eslint-config": "1.5.3",
63
63
  "@vitejs/plugin-vue2": "2.3.1",
64
+ "@vitest/coverage-v8": "2.1.9",
64
65
  "eslint": "8.57.1",
65
66
  "eslint-config-airbnb-base": "15.0.0",
66
67
  "eslint-config-airbnb-typescript": "18.0.0",
@@ -1,74 +0,0 @@
1
- const n = `ue-notifications-container {
2
- left: 96px;
3
- margin: 0;
4
- bottom: 32px;
5
- top: unset;
6
- width: unset;
7
- position: fixed;
8
- }
9
-
10
- ue-notifications-container ue-message + ue-message {
11
- margin-bottom: 24px;
12
- }
13
-
14
- ue-notifications-container .alert-message-wrapper {
15
- box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.07);
16
- border: none;
17
- padding: 16px 24px;
18
- }
19
-
20
- ue-notifications-container .alert-message-wrapper.info,
21
- ue-notifications-container .alert-message-wrapper.loader {
22
- background-color: var(--guido-color-background-toaster-info) !important;
23
- color: inherit;
24
- }
25
-
26
- .alert-message-wrapper .alert-message-main {
27
- align-items: center;
28
- }
29
-
30
- ue-notifications-container ue-caption .caption {
31
- color: var(--guido-color-white) !important;
32
- }
33
-
34
- ue-block-thumb-hint {
35
- text-align: left;
36
- }
37
-
38
- ue-notifications-container .alert-message-wrapper .alert-message-main .alert-message-content {
39
- width: calc(100% - 64px);
40
- }
41
-
42
- ue-notifications-container .alert-message-wrapper .alert-message-main .alert-message-text {
43
- font-size: 15px;
44
- font-weight: 600;
45
- }
46
-
47
- ue-notifications-container .alert-message-text,
48
- ue-notifications-container .alert-message-wrapper ue-icon-component.icon,
49
- ue-notifications-container .alert-message-wrapper ue-icon-component.icon-button {
50
- color: var(--guido-color-white);
51
- }
52
-
53
- ue-notifications-container ue-message ue-button.close {
54
- margin: 0 0 0 16px;
55
- }
56
-
57
- ue-notifications-container .alert-message-wrapper.success {
58
- background: var(--guido-color-background-toaster-success);
59
- color: inherit;
60
- }
61
-
62
- ue-notifications-container .alert-message-wrapper.error {
63
- background: var(--guido-color-background-toaster-error);
64
- color: inherit;
65
- }
66
-
67
- ue-notifications-container .alert-message-wrapper.warn {
68
- background: var(--guido-color-background-toaster-warn);
69
- color: inherit;
70
- }
71
- `;
72
- export {
73
- n as default
74
- };