@useinsider/guido 1.0.3-beta.e83334e → 1.0.3-beta.ea69f4a

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
@@ -600,9 +600,6 @@ Create a `.env` file with the following variables: (You can get env variables fr
600
600
  VITE_STRIPO_PLUGIN_ID=your_plugin_id
601
601
  VITE_STRIPO_SECRET_KEY=your_secret_key
602
602
  VITE_STRIPO_ROLE=your_role
603
-
604
- # Playwright Test Configuration (Optional - for local debugging only)
605
- HEADED=false # Set to 'true' to run tests with visible browser
606
603
  ```
607
604
 
608
605
  ### Project Structure
@@ -1,6 +1,6 @@
1
- import { useToaster as g } from "./useToaster.js";
1
+ import { useToaster as w } from "./useToaster.js";
2
2
  const A = () => {
3
- const { handleError: l } = g(), n = (t = {}) => new Promise((e, a) => {
3
+ const { handleError: l } = w(), s = (e = {}) => new Promise((t, a) => {
4
4
  const i = { ...{
5
5
  minimize: !0,
6
6
  utmEntity: {
@@ -20,13 +20,13 @@ const A = () => {
20
20
  forceAmp: !1,
21
21
  resetDataSavedFlag: !1,
22
22
  disableLineHeightsReplace: !0
23
- }, ...t }, m = {
24
- callback: (s, c, p, u, d) => {
25
- s ? a(s) : e({
26
- html: c,
27
- ampHtml: p,
28
- ampErrors: u,
29
- displayConditions: d
23
+ }, ...e }, m = {
24
+ callback: (n, p, c, d, u) => {
25
+ n ? a(n) : t({
26
+ html: p,
27
+ ampHtml: c,
28
+ ampErrors: d,
29
+ displayConditions: u
30
30
  });
31
31
  },
32
32
  ...i
@@ -34,44 +34,53 @@ const A = () => {
34
34
  window.StripoEditorApi.actionsApi.compileEmail(m);
35
35
  });
36
36
  return {
37
- getCompiledEmail: n,
38
- getTemplateData: () => new Promise((t) => {
39
- const e = ({ html: a, css: o, width: i, height: r, utmParams: m, syncModulesIds: s }) => t({
37
+ getCompiledEmail: s,
38
+ getTemplateData: () => new Promise((e) => {
39
+ const t = ({ html: a, css: o, width: i, height: r, utmParams: m, syncModulesIds: n }) => e({
40
40
  html: a,
41
41
  css: o,
42
42
  width: i,
43
43
  height: r,
44
44
  utmParams: m,
45
- syncModulesIds: s
45
+ syncModulesIds: n
46
46
  });
47
- window.StripoEditorApi.actionsApi.getTemplateData(e);
47
+ window.StripoEditorApi.actionsApi.getTemplateData(t);
48
48
  }),
49
- activateCustomViewStyles: (t = !0) => {
50
- window.StripoEditorApi.actionsApi.activateCustomViewStyles(t);
49
+ activateCustomViewStyles: (e = !0) => {
50
+ window.StripoEditorApi.actionsApi.activateCustomViewStyles(e);
51
51
  },
52
- getPreviewData: async (t) => {
52
+ getPreviewData: async (e) => {
53
53
  try {
54
54
  const {
55
- html: e,
55
+ html: t,
56
56
  displayConditions: a,
57
57
  ampHtml: o = "",
58
58
  ampErrors: i = []
59
- } = await n({ minimize: !1, resetDataSavedFlag: !1, ...t });
59
+ } = await s({ minimize: !1, resetDataSavedFlag: !1, ...e });
60
60
  return {
61
- html: e,
61
+ html: t,
62
62
  ampHtml: o,
63
63
  ampErrors: i,
64
64
  displayConditions: a
65
65
  };
66
- } catch (e) {
67
- return l(e, "Error loading preview"), {
66
+ } catch (t) {
67
+ return l(t, "Error loading preview"), {
68
68
  html: "",
69
69
  ampHtml: "",
70
70
  ampErrors: [],
71
71
  displayConditions: []
72
72
  };
73
73
  }
74
- }
74
+ },
75
+ updateTimerInClonedTemplate: () => new Promise((e) => {
76
+ try {
77
+ window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((t, a) => {
78
+ t ? (l(t, "Failed to update timer in cloned template"), e(null)) : e(a || null);
79
+ });
80
+ } catch (t) {
81
+ l(t, "Failed to call updateTimerInClonedTemplate"), e(null);
82
+ }
83
+ })
75
84
  };
76
85
  };
77
86
  export {
@@ -1,25 +1,26 @@
1
- import { useActionsApi as w } from "./useActionsApi.js";
2
- import { useBlocksConfig as b } from "./useBlocksConfig.js";
3
- import { useConfig as k } from "./useConfig.js";
4
- import { useCustomInterfaceAppearance as V } from "./useCustomInterfaceAppearance.js";
5
- import { useStripoEventHandler as _ } from "./useStripoEventHandler.js";
6
- import { useToaster as B } from "./useToaster.js";
7
- import { displayConditions as T } from "../enums/displayConditions.js";
8
- import { useStripoApi as A } from "../services/stripoApi.js";
9
- import F from "../static/styles/customEditorStyle.css.js";
10
- import { useEditorStore as M } from "../stores/editor.js";
11
- import { dynamicContentToMergeTags as U } from "../utils/genericUtil.js";
12
- import v from "../package.json.js";
13
- const J = (c) => {
14
- const { config: u } = k(), { handleError: l } = B(), { getToken: f, getCustomFonts: y } = A(), { handleEvent: S } = _(), { getStripoBlocksConfig: C } = b(), E = async (i, r = []) => {
15
- var m, g;
16
- const t = M(), { html: n, css: p, forceRecreate: a } = i, { baseBlocks: e, extensions: d } = await C();
1
+ import { useActionsApi as V } from "./useActionsApi.js";
2
+ import { useBlocksConfig as _ } from "./useBlocksConfig.js";
3
+ import { useConfig as A } from "./useConfig.js";
4
+ import { useCustomInterfaceAppearance as B } from "./useCustomInterfaceAppearance.js";
5
+ import { useStripoEventHandler as v } from "./useStripoEventHandler.js";
6
+ import { useTimerClone as F } from "./useTimerClone.js";
7
+ import { useToaster as I } from "./useToaster.js";
8
+ import { displayConditions as M } from "../enums/displayConditions.js";
9
+ import { useStripoApi as U } from "../services/stripoApi.js";
10
+ import D from "../static/styles/customEditorStyle.css.js";
11
+ import { useEditorStore as P } from "../stores/editor.js";
12
+ import { dynamicContentToMergeTags as H } from "../utils/genericUtil.js";
13
+ import O from "../package.json.js";
14
+ const Y = (c) => {
15
+ const { config: u } = A(), { handleError: p } = I(), { getToken: m, getCustomFonts: C } = U(), { handleEvent: S } = v(), { getStripoBlocksConfig: E } = _(), w = async (i, r = []) => {
16
+ var g, y;
17
+ const e = P(), { html: s, css: f, forceRecreate: a } = i, { baseBlocks: t, extensions: d } = await E();
17
18
  window.UIEditor.initEditor(
18
19
  document.querySelector("#guido-editor"),
19
20
  {
20
21
  metadata: c,
21
- html: n,
22
- css: p,
22
+ html: s,
23
+ css: f,
23
24
  forceRecreate: a,
24
25
  locale: "en",
25
26
  undoButtonSelector: "#guido__undo-button",
@@ -30,10 +31,10 @@ const J = (c) => {
30
31
  customAppearanceMergetags: !0,
31
32
  customAppearanceMergetagsBorderColor: "#f1f3fe",
32
33
  customAppearanceMergetagsBackgroundColor: "#f1f3fe",
33
- customViewStyles: F,
34
- conditionsEnabled: ((m = u.features) == null ? void 0 : m.displayConditions) ?? !0,
35
- customConditionsEnabled: ((g = u.features) == null ? void 0 : g.displayConditions) ?? !0,
36
- conditionCategories: T,
34
+ customViewStyles: D,
35
+ conditionsEnabled: ((g = u.features) == null ? void 0 : g.displayConditions) ?? !0,
36
+ customConditionsEnabled: ((y = u.features) == null ? void 0 : y.displayConditions) ?? !0,
37
+ conditionCategories: M,
37
38
  enableXSSSecurity: !0,
38
39
  messageSettingsEnabled: !0,
39
40
  displayGmailAnnotations: !0,
@@ -41,7 +42,7 @@ const J = (c) => {
41
42
  displayTitle: !1,
42
43
  displayUTM: !1,
43
44
  selectElementAfterDrop: !0,
44
- ...e ? { baseBlocks: e } : {},
45
+ ...t ? { baseBlocks: t } : {},
45
46
  editorFonts: {
46
47
  showDefaultStandardFonts: !0,
47
48
  showDefaultNotStandardFonts: !0,
@@ -49,38 +50,39 @@ const J = (c) => {
49
50
  },
50
51
  mergeTags: [
51
52
  {
52
- entries: U(c.preselectedDynamicContentList)
53
+ entries: H(c.preselectedDynamicContentList)
53
54
  }
54
55
  ],
55
56
  async onTokenRefreshRequest(o) {
56
57
  try {
57
- const s = await f();
58
- o(s);
59
- } catch (s) {
60
- l(s, "Failed to refresh token");
58
+ const n = await m();
59
+ o(n);
60
+ } catch (n) {
61
+ p(n, "Failed to refresh token");
61
62
  }
62
63
  },
63
64
  onTemplateLoaded() {
65
+ var o, n;
64
66
  try {
65
- const { importCss: o } = V(), { activateCustomViewStyles: s } = w();
66
- o(), s(), c.onReady(), t.isStripoInitialized = !0, t.loadingStatus = !1, setTimeout(() => {
67
- t.hasChanges = !1;
67
+ const { importCss: l } = B(), { activateCustomViewStyles: T, updateTimerInClonedTemplate: b } = V(), { updateTimersOnLoad: k } = F();
68
+ l(), T(), typeof ((n = (o = window.StripoEditorApi) == null ? void 0 : o.actionsApi) == null ? void 0 : n.updateTimerInClonedTemplate) == "function" ? b() : k(m), c.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
69
+ e.hasChanges = !1;
68
70
  }, 1e3);
69
- } catch (o) {
70
- l(o, "Failed to load custom interface appearance");
71
+ } catch (l) {
72
+ p(l, "Failed to load custom interface appearance");
71
73
  }
72
74
  },
73
75
  onCodeEditorVisibilityChanged(o) {
74
- t.isCodeEditorOpen = o;
76
+ e.isCodeEditorOpen = o;
75
77
  },
76
78
  onEditorVisualModeChanged(o) {
77
- t.editorVisualMode = o.toLowerCase();
79
+ e.editorVisualMode = o.toLowerCase();
78
80
  },
79
81
  onVersionHistoryVisibilityChanged(o) {
80
- t.isVersionHistoryOpen = o;
82
+ e.isVersionHistoryOpen = o;
81
83
  },
82
84
  onDataChanged() {
83
- t.hasChanges = !0;
85
+ e.hasChanges = !0;
84
86
  },
85
87
  onEvent: S,
86
88
  ignoreClickOutsideSelectors: [
@@ -91,26 +93,26 @@ const J = (c) => {
91
93
  extensions: d
92
94
  }
93
95
  );
94
- }, h = (i) => new Promise((r, t) => {
96
+ }, h = (i) => new Promise((r, e) => {
95
97
  var d;
96
98
  if (document.getElementById("UiEditorScript")) {
97
99
  i(), r();
98
100
  return;
99
101
  }
100
- const n = v.guido, a = `https://email-static.useinsider.com/guido/${(d = n == null ? void 0 : n.stripo) == null ? void 0 : d.version}/UIEditor.js`, e = document.createElement("script");
101
- e.id = "UiEditorScript", e.type = "module", e.src = a, e.onload = () => {
102
+ const s = O.guido, a = `https://email-static.useinsider.com/guido/${(d = s == null ? void 0 : s.stripo) == null ? void 0 : d.version}/UIEditor.js`, t = document.createElement("script");
103
+ t.id = "UiEditorScript", t.type = "module", t.src = a, t.onload = () => {
102
104
  i(), r();
103
- }, e.onerror = () => {
104
- t(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
105
- }, document.body.appendChild(e);
105
+ }, t.onerror = () => {
106
+ e(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
107
+ }, document.body.appendChild(t);
106
108
  });
107
109
  return { initPlugin: async (i) => {
108
110
  await h(async () => {
109
- const r = await y();
110
- await E(i, r);
111
+ const r = await C();
112
+ await w(i, r);
111
113
  });
112
114
  } };
113
115
  };
114
116
  export {
115
- J as useStripo
117
+ Y as useStripo
116
118
  };
@@ -0,0 +1,67 @@
1
+ import { useToaster as I } from "./useToaster.js";
2
+ const M = () => {
3
+ const { handleError: d } = I(), a = (n) => /esd-timer-id="(\d+)"/.test(n), c = async (n, s) => {
4
+ try {
5
+ console.debug("[TIMER CLONE] Calling Stripo API to clone timers...");
6
+ const e = await fetch("https://plugins.stripo.email/api/v1/timers/clone", {
7
+ method: "POST",
8
+ headers: {
9
+ "ES-PLUGIN-AUTH": `Bearer ${s}`,
10
+ "Content-Type": "application/json"
11
+ },
12
+ body: JSON.stringify({ html: n })
13
+ });
14
+ if (console.debug("[TIMER CLONE] API response status:", e.status), !e.ok) {
15
+ const r = await e.text();
16
+ throw console.debug("[TIMER CLONE] API error:", r), new Error(`Stripo API error: ${e.status} ${e.statusText}`);
17
+ }
18
+ const t = await e.json();
19
+ return console.debug("[TIMER CLONE] Timers cloned successfully. Map:", t.timersMap), console.debug("[TIMER CLONE] Old HTML length:", n.length), console.debug("[TIMER CLONE] New HTML length:", t.html.length), t.html;
20
+ } catch (e) {
21
+ return console.debug("[TIMER CLONE] Error:", e), d(e, "Failed to clone timer IDs"), null;
22
+ }
23
+ };
24
+ return {
25
+ hasTimerBlocks: a,
26
+ cloneTimersInHtml: c,
27
+ updateTimersOnLoad: async (n) => {
28
+ var s, e, t, r, l, u;
29
+ try {
30
+ console.debug("[TIMER CLONE] Starting timer update on template load...");
31
+ const o = (e = (s = window.UIEditor) == null ? void 0 : s.getHtml) == null ? void 0 : e.call(s);
32
+ if (!o) {
33
+ console.debug("[TIMER CLONE] No HTML found, skipping timer update");
34
+ return;
35
+ }
36
+ const E = a(o);
37
+ if (console.debug("[TIMER CLONE] Has timer blocks?", E), !E)
38
+ return;
39
+ const T = o.match(/esd-timer-id="(\d+)"/g);
40
+ console.debug("[TIMER CLONE] Current timer IDs:", T), console.debug("[TIMER CLONE] Getting auth token...");
41
+ const p = await n();
42
+ if (!p) {
43
+ console.debug("[TIMER CLONE] No auth token available, skipping timer update");
44
+ return;
45
+ }
46
+ const i = await c(o, p);
47
+ if (!i) {
48
+ console.debug("[TIMER CLONE] API returned no updated HTML");
49
+ return;
50
+ }
51
+ if (i === o) {
52
+ console.debug("[TIMER CLONE] HTML unchanged, no update needed");
53
+ return;
54
+ }
55
+ const m = i.match(/esd-timer-id="(\d+)"/g);
56
+ console.debug("[TIMER CLONE] New timer IDs:", m);
57
+ const g = ((r = (t = window.UIEditor) == null ? void 0 : t.getCss) == null ? void 0 : r.call(t)) || "";
58
+ console.debug("[TIMER CLONE] Updating editor with new HTML..."), (u = (l = window.StripoEditorApi) == null ? void 0 : l.actionsApi) != null && u.updateHtmlAndCss ? (window.StripoEditorApi.actionsApi.updateHtmlAndCss(i, g), console.debug("[TIMER CLONE] ✅ Editor updated successfully!")) : console.debug("[TIMER CLONE] updateHtmlAndCss method not available");
59
+ } catch (o) {
60
+ console.debug("[TIMER CLONE] Error updating timers:", o), d(o, "Failed to update timer blocks");
61
+ }
62
+ }
63
+ };
64
+ };
65
+ export {
66
+ M as useTimerClone
67
+ };
@@ -1,70 +1,70 @@
1
1
  var d = Object.defineProperty;
2
2
  var h = (i, t, e) => t in i ? d(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
- var n = (i, t, e) => h(i, typeof t != "symbol" ? t + "" : t, e);
4
- import { ModificationDescription as a, UIElementType as l, UEAttr as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
+ var s = (i, t, e) => h(i, typeof t != "symbol" ? t + "" : t, e);
4
+ import { ModificationDescription as n, UIElementType as a, UEAttr as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
5
  import { CommonControl as c } from "../../../common-control.js";
6
- import { ItemsBlockControlId as p } from "../../enums/controlEnums.js";
6
+ import { ItemsBlockControlId as l } from "../../enums/controlEnums.js";
7
7
  import { SETTINGS_ENUMS as I } from "../../enums/settingsEnums.js";
8
8
  import { useItemsBlockStore as N } from "../../store/items-block.js";
9
- import { syncNameTrimmingFromAttributes as M } from "../../utils/syncAttributesFromConfigBlock.js";
10
- import { updateConfigBlockAttributes as u } from "../../utils/updateAttributes.js";
11
- const y = p.NAME_TRIMMING, o = {
9
+ import { syncNameTrimmingFromAttributes as y } from "../../utils/syncAttributesFromConfigBlock.js";
10
+ import { updateConfigBlockAttributes as M } from "../../utils/updateAttributes.js";
11
+ const f = l.NAME_TRIMMING, r = {
12
12
  TRIMMING: "trimming"
13
13
  };
14
- class _ extends c {
14
+ class R extends c {
15
15
  constructor() {
16
16
  super(...arguments);
17
- n(this, "store", N());
17
+ s(this, "store", N());
18
18
  }
19
19
  getId() {
20
- return y;
20
+ return f;
21
21
  }
22
22
  getTemplate() {
23
23
  return `
24
- <div class="${p.NAME_TRIMMING}">
24
+ <div class="${l.NAME_TRIMMING}">
25
25
  ${this._getTextTrimming()}
26
26
  </div>
27
27
  `;
28
28
  }
29
29
  onRender() {
30
- this.api.updateValues({ [o.TRIMMING]: this.store.nameTrimming }), this.api.onValueChanged(o.TRIMMING, (e) => {
30
+ this.api.updateValues({ [r.TRIMMING]: this.store.nameTrimming }), this.api.onValueChanged(r.TRIMMING, (e) => {
31
31
  this._onTrimmingChange(e);
32
32
  });
33
33
  }
34
34
  onTemplateNodeUpdated(e) {
35
35
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
36
- () => M(this.currentNode),
36
+ () => y(this.currentNode),
37
37
  () => {
38
- this.api.updateValues({ [o.TRIMMING]: this.store.nameTrimming });
38
+ this.api.updateValues({ [r.TRIMMING]: this.store.nameTrimming });
39
39
  }
40
- );
40
+ ), this.store.nameTrimming && this._applyTrimmingStyles();
41
41
  }
42
42
  _onTrimmingChange(e) {
43
- this.store.setNameTrimming(e), u(this.currentNode, this.api), this.api.updateValues({ [o.TRIMMING]: e }), this._applyTrimmingStyles(e);
43
+ this.store.setNameTrimming(e), M(this.currentNode, this.api), this.api.updateValues({ [r.TRIMMING]: e }), this._applyTrimmingStyles(e);
44
44
  }
45
45
  _applyTrimmingStyles(e) {
46
- var s;
47
- const r = (s = this.currentNode) == null ? void 0 : s.querySelector("p > a");
48
- if (!r)
46
+ var m;
47
+ const o = (m = this.currentNode) == null ? void 0 : m.querySelector("p > a");
48
+ if (!o)
49
49
  return;
50
- const T = e !== void 0 ? e : this.store.nameTrimming, m = this.store.orientation === I.ORIENTATION.VERTICAL;
51
- T ? this.api.getDocumentModifier().modifyHtml(r).setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis").setStyle("max-width", m ? "130px" : "520px").apply(new a("Text Trimming Enabled")) : this.api.getDocumentModifier().modifyHtml(r).removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow").removeStyle("max-width").setStyle("max-width", m ? "130px" : "520px").apply(new a("Text Trimming Disabled"));
50
+ const p = e !== void 0 ? e : this.store.nameTrimming, T = this.store.orientation === I.ORIENTATION.VERTICAL;
51
+ p ? this.api.getDocumentModifier().modifyHtml(o).setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis").setStyle("max-width", T ? "130px" : "550px").apply(new n("Text Trimming Enabled")) : this.api.getDocumentModifier().modifyHtml(o).removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow").removeStyle("max-width").apply(new n("Text Trimming Disabled"));
52
52
  }
53
53
  _getTextTrimming() {
54
54
  return `
55
55
  <div class="container">
56
56
  <div class="display-flex align-items-center justify-content-between">
57
- <${l.LABEL}
57
+ <${a.LABEL}
58
58
  ${g.LABEL.text}="${this.api.translate("Text Trimming")}"
59
59
  >
60
- </${l.LABEL}>
61
- ${this._GuToggle(o.TRIMMING)}
60
+ </${a.LABEL}>
61
+ ${this._GuToggle(r.TRIMMING)}
62
62
  </div>
63
63
  </div>
64
64
  `;
65
65
  }
66
66
  }
67
67
  export {
68
- y as CONTROL_BLOCK_ID,
69
- _ as NameTrimmingControl
68
+ f as CONTROL_BLOCK_ID,
69
+ R as NameTrimmingControl
70
70
  };
@@ -1,29 +1,29 @@
1
- var M = Object.defineProperty;
2
- var D = (h, p, e) => p in h ? M(h, p, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[p] = e;
3
- var b = (h, p, e) => D(h, typeof p != "symbol" ? p + "" : p, e);
4
- import { UEAttr as A, ModificationDescription as d } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as x } from "../../common-control.js";
6
- import { ItemsBlockId as l } from "../enums/controlEnums.js";
7
- import { productPairs as T, templateFirstLine as R } from "../enums/productEnums.js";
8
- import { ItemTypeOptions as P, OrientationOptions as L, ItemInCartOptions as N, SETTINGS_ENUMS as S, DefaultConfigValues as H } from "../enums/settingsEnums.js";
9
- import U from "../layouts/horizontal.html.js";
10
- import F from "../layouts/vertical.html.js";
11
- import { useItemsBlockStore as $ } from "../store/items-block.js";
12
- import { getDefaultTemplate as q } from "../template.js";
13
- import { syncCurrencySymbolFromAttributes as k, syncCurrencyLocationFromAttributes as w, syncFormattedPriceFromAttributes as B } from "../utils/syncAttributesFromConfigBlock.js";
1
+ var P = Object.defineProperty;
2
+ var M = (T, u, e) => u in T ? P(T, u, { enumerable: !0, configurable: !0, writable: !0, value: e }) : T[u] = e;
3
+ var C = (T, u, e) => M(T, typeof u != "symbol" ? u + "" : u, e);
4
+ import { UEAttr as b, ModificationDescription as d } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as D } from "../../common-control.js";
6
+ import { ItemsBlockId as m } from "../enums/controlEnums.js";
7
+ import { productPairs as p, templateFirstLine as A } from "../enums/productEnums.js";
8
+ import { ItemTypeOptions as R, OrientationOptions as L, ItemInCartOptions as N, SETTINGS_ENUMS as S } from "../enums/settingsEnums.js";
9
+ import x from "../layouts/horizontal.html.js";
10
+ import H from "../layouts/vertical.html.js";
11
+ import { useItemsBlockStore as U } from "../store/items-block.js";
12
+ import { getDefaultTemplate as F } from "../template.js";
13
+ import { syncCurrencySymbolFromAttributes as $, syncCurrencyLocationFromAttributes as k, syncFormattedPriceFromAttributes as q } from "../utils/syncAttributesFromConfigBlock.js";
14
14
  import { updateConfigBlockAttributes as f } from "../utils/updateAttributes.js";
15
- const G = "ui-elements-items-block", o = {
15
+ const w = "ui-elements-items-block", o = {
16
16
  ITEMS_TYPE: "itemsType",
17
17
  ORIENTATION: "orientation",
18
18
  ITEM_IDS: "itemIds"
19
19
  };
20
- class te extends x {
20
+ class Z extends D {
21
21
  constructor() {
22
22
  super(...arguments);
23
- b(this, "store", $());
23
+ C(this, "store", U());
24
24
  }
25
25
  getId() {
26
- return G;
26
+ return w;
27
27
  }
28
28
  getTemplate() {
29
29
  return `
@@ -44,7 +44,7 @@ class te extends x {
44
44
  onTemplateNodeUpdated(e) {
45
45
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
46
46
  () => {
47
- k(this.currentNode), w(this.currentNode), B(this.currentNode);
47
+ $(this.currentNode), k(this.currentNode), q(this.currentNode);
48
48
  },
49
49
  () => {
50
50
  this.api.updateValues({
@@ -67,7 +67,7 @@ class te extends x {
67
67
  name: o.ITEMS_TYPE,
68
68
  className: "es-100",
69
69
  placeholder: "Select Item Type",
70
- options: P
70
+ options: R
71
71
  })
72
72
  ])}
73
73
  `;
@@ -97,9 +97,7 @@ class te extends x {
97
97
  `;
98
98
  }
99
99
  _onOrientationChange(e) {
100
- console.debug("Orientation changed to: ", e), this.store.setOrientation(e), this.api.updateValues({ [o.ORIENTATION]: e }), f(this.currentNode, this.api), this._reOrderTemplate(), setTimeout(() => {
101
- this._recalculateTrimming();
102
- }, 50);
100
+ console.debug("Orientation changed to: ", e), this.store.setOrientation(e), this.api.updateValues({ [o.ORIENTATION]: e }), f(this.currentNode, this.api), this._reOrderTemplate(), this._recalculateTrimming();
103
101
  }
104
102
  _onItemsTypeChange(e) {
105
103
  const i = S.ITEMS_TYPE[e], t = N[e], r = t == null ? void 0 : t[0];
@@ -111,8 +109,8 @@ class te extends x {
111
109
  _initializeSelectItems() {
112
110
  this.api.setUIEAttribute(
113
111
  o.ITEMS_TYPE,
114
- A.SELECTPICKER.items,
115
- P
112
+ b.SELECTPICKER.items,
113
+ R
116
114
  );
117
115
  const { itemsType: e, itemIds: i } = this.store;
118
116
  this.api.updateValues({
@@ -121,7 +119,7 @@ class te extends x {
121
119
  const t = N[e];
122
120
  this.api.setUIEAttribute(
123
121
  o.ITEM_IDS,
124
- A.SELECTPICKER.items,
122
+ b.SELECTPICKER.items,
125
123
  t
126
124
  ), this.api.updateValues({
127
125
  [o.ITEM_IDS]: i
@@ -148,7 +146,7 @@ class te extends x {
148
146
  currencyLocation: n,
149
147
  formattedPrice: s
150
148
  } = this.store;
151
- this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(q({
149
+ this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(F({
152
150
  orientation: e,
153
151
  itemsType: i,
154
152
  itemId: t,
@@ -160,22 +158,22 @@ class te extends x {
160
158
  _getTemplateData() {
161
159
  const { itemsType: e, itemIds: i, formattedPrice: t } = this.store, r = N[e].findIndex((s) => s.value === i), n = r > -1 ? r : 0;
162
160
  return {
163
- imageSrc: T.PAIRS_FOR_EXTENSION.imageSrc[e].DEFAULT[n],
164
- name: T.PAIRS_FOR_EXTENSION.name[e].DEFAULT[n],
165
- price: t ? T.PAIRS_FOR_EXTENSION.price[e].DEFAULT_PRICE_FORMATTED : T.PAIRS_FOR_EXTENSION.price[e].DEFAULT_PRICE,
166
- originalPrice: t ? T.PAIRS_FOR_EXTENSION.originalPrice[e].DEFAULT_PRICE_FORMATTED : T.PAIRS_FOR_EXTENSION.originalPrice[e].DEFAULT_PRICE,
167
- quantity: T.PAIRS_FOR_EXTENSION.quantity[e].DEFAULT,
168
- button: T.PAIRS_FOR_EXTENSION.button[e].DEFAULT_LABEL
161
+ imageSrc: p.PAIRS_FOR_EXTENSION.imageSrc[e].DEFAULT[n],
162
+ name: p.PAIRS_FOR_EXTENSION.name[e].DEFAULT[n],
163
+ price: t ? p.PAIRS_FOR_EXTENSION.price[e].DEFAULT_PRICE_FORMATTED : p.PAIRS_FOR_EXTENSION.price[e].DEFAULT_PRICE,
164
+ originalPrice: t ? p.PAIRS_FOR_EXTENSION.originalPrice[e].DEFAULT_PRICE_FORMATTED : p.PAIRS_FOR_EXTENSION.originalPrice[e].DEFAULT_PRICE,
165
+ quantity: p.PAIRS_FOR_EXTENSION.quantity[e].DEFAULT,
166
+ button: p.PAIRS_FOR_EXTENSION.button[e].DEFAULT_LABEL
169
167
  };
170
168
  }
171
169
  _updateImageSrc(e) {
172
170
  var t;
173
- const i = (t = this.currentNode) == null ? void 0 : t.querySelector(`[esd-extension-block-id="${l.IMAGE}"] img`);
171
+ const i = (t = this.currentNode) == null ? void 0 : t.querySelector(`[esd-extension-block-id="${m.IMAGE}"] img`);
174
172
  i && this.api.getDocumentModifier().modifyHtml(i).setAttribute("src", e).apply(new d("Updated image src"));
175
173
  }
176
174
  _updateName(e) {
177
175
  var n;
178
- const i = (n = this.currentNode) == null ? void 0 : n.querySelector(`[esd-extension-block-id="${l.NAME}"]`);
176
+ const i = (n = this.currentNode) == null ? void 0 : n.querySelector(`[esd-extension-block-id="${m.NAME}"]`);
179
177
  if (!i)
180
178
  return;
181
179
  const t = i.getInnerText().trim();
@@ -183,20 +181,20 @@ class te extends x {
183
181
  r = r.replace(t, e), this.api.getDocumentModifier().modifyHtml(i).setInnerHtml(r).apply(new d("Updated name"));
184
182
  }
185
183
  _updatePrice(e) {
186
- var g;
187
- const i = (g = this.currentNode) == null ? void 0 : g.querySelector(`[esd-extension-block-id="${l.PRICE}"]`);
184
+ var E;
185
+ const i = (E = this.currentNode) == null ? void 0 : E.querySelector(`[esd-extension-block-id="${m.PRICE}"]`);
188
186
  if (!i)
189
187
  return;
190
188
  const t = this._getParagraphFromBlock(i);
191
189
  if (!t)
192
190
  return;
193
- const r = t.getInnerHTML() || "", n = t.getInnerText() || "", { currencySymbol: s, currencyLocation: a } = this.store, c = (s == null ? void 0 : s.trim()) || "", m = this._removeCurrencySymbol(n, c), u = this._replacePriceNumber(m, e), I = this._buildPriceContent(u, c, a), _ = r.replace(n, I);
191
+ const r = t.getInnerHTML() || "", n = t.getInnerText() || "", { currencySymbol: s, currencyLocation: a } = this.store, l = (s == null ? void 0 : s.trim()) || "", c = this._removeCurrencySymbol(n, l), h = this._replacePriceNumber(c, e), I = this._buildPriceContent(h, l, a), _ = r.replace(n, I);
194
192
  this.api.getDocumentModifier().modifyHtml(t).setInnerHtml(_).apply(new d("Updated price"));
195
193
  }
196
194
  _updateOriginalPrice(e) {
197
195
  var y;
198
196
  const i = (y = this.currentNode) == null ? void 0 : y.querySelector(
199
- `[esd-extension-block-id="${l.ORIGINAL_PRICE}"]`
197
+ `[esd-extension-block-id="${m.ORIGINAL_PRICE}"]`
200
198
  );
201
199
  if (!i)
202
200
  return;
@@ -206,12 +204,12 @@ class te extends x {
206
204
  const r = t.querySelector("s");
207
205
  if (!r)
208
206
  return;
209
- const n = r.getInnerHTML() || "", s = r.getInnerText() || "", { currencySymbol: a, currencyLocation: c } = this.store, m = (a == null ? void 0 : a.trim()) || "", u = this._removeCurrencySymbol(s, m), I = this._replacePriceNumber(u, e), _ = this._buildPriceContent(I, m, c), E = `<s>${n.replace(s, _)}</s>`;
210
- this.api.getDocumentModifier().modifyHtml(t).setInnerHtml(E).apply(new d("Updated original price"));
207
+ const n = r.getInnerHTML() || "", s = r.getInnerText() || "", { currencySymbol: a, currencyLocation: l } = this.store, c = (a == null ? void 0 : a.trim()) || "", h = this._removeCurrencySymbol(s, c), I = this._replacePriceNumber(h, e), _ = this._buildPriceContent(I, c, l), g = `<s>${n.replace(s, _)}</s>`;
208
+ this.api.getDocumentModifier().modifyHtml(t).setInnerHtml(g).apply(new d("Updated original price"));
211
209
  }
212
210
  _updateQuantity(e) {
213
211
  var a;
214
- const i = this.store.itemsType !== S.ITEMS_TYPE.BROWSED_ITEMS, t = (a = this.currentNode) == null ? void 0 : a.querySelector(`[esd-extension-block-id="${l.QUANTITY}"]`);
212
+ const i = this.store.itemsType !== S.ITEMS_TYPE.BROWSED_ITEMS, t = (a = this.currentNode) == null ? void 0 : a.querySelector(`[esd-extension-block-id="${m.QUANTITY}"]`);
215
213
  if (!t)
216
214
  return;
217
215
  const r = t.getStyle("display") === "none", n = t.getInnerText().trim();
@@ -223,17 +221,15 @@ class te extends x {
223
221
  * @description Reorders the template structure based on current orientation and visibility settings.
224
222
  */
225
223
  _reOrderTemplate() {
226
- var I, _, g, E, y, O, C;
227
- const e = (I = this.currentNode) == null ? void 0 : I.querySelector(`[esd-extension-block-id="${l.IMAGE}"]`), i = (_ = this.currentNode) == null ? void 0 : _.querySelector(`[esd-extension-block-id="${l.NAME}"]`), t = (g = this.currentNode) == null ? void 0 : g.querySelector(`[esd-extension-block-id="${l.PRICE}"]`), r = (E = this.currentNode) == null ? void 0 : E.querySelector(
228
- `[esd-extension-block-id="${l.ORIGINAL_PRICE}"]`
229
- ), n = (y = this.currentNode) == null ? void 0 : y.querySelector(`[esd-extension-block-id="${l.QUANTITY}"]`), s = (O = this.currentNode) == null ? void 0 : O.querySelector(`[esd-extension-block-id="${l.BUTTON}"]`), a = (C = this.currentNode) == null ? void 0 : C.querySelector("esd-config-block");
224
+ var h, I, _, E, g, y, O;
225
+ const e = (h = this.currentNode) == null ? void 0 : h.querySelector(`[esd-extension-block-id="${m.IMAGE}"]`), i = (I = this.currentNode) == null ? void 0 : I.querySelector(`[esd-extension-block-id="${m.NAME}"]`), t = (_ = this.currentNode) == null ? void 0 : _.querySelector(`[esd-extension-block-id="${m.PRICE}"]`), r = (E = this.currentNode) == null ? void 0 : E.querySelector(
226
+ `[esd-extension-block-id="${m.ORIGINAL_PRICE}"]`
227
+ ), n = (g = this.currentNode) == null ? void 0 : g.querySelector(`[esd-extension-block-id="${m.QUANTITY}"]`), s = (y = this.currentNode) == null ? void 0 : y.querySelector(`[esd-extension-block-id="${m.BUTTON}"]`), a = (O = this.currentNode) == null ? void 0 : O.querySelector("esd-config-block");
230
228
  if (!e || !i || !t || !r || !n || !s || !a)
231
229
  return;
232
- const { orientation: c } = this.store, m = c === S.ORIENTATION.VERTICAL;
233
- let u = m ? F : U;
234
- this.api.getDocumentModifier().modifyHtml(e.querySelector("img")).setAttribute("width", H.productImageWidth).apply(new d("Updated image width")), setTimeout(() => {
235
- u = u.replace("{-{-TEMPLATE_FIRST_LINE-}-}", m ? R : "").replace("{-{-PRODUCT_IMAGE-}-}", e.getOuterHTML()).replace("{-{-PRODUCT_NAME-}-}", i.getOuterHTML()).replace("{-{-PRODUCT_PRICE-}-}", t.getOuterHTML()).replace("{-{-PRODUCT_ORIGINAL_PRICE-}-}", r.getOuterHTML()).replace("{-{-PRODUCT_QUANTITY-}-}", n.getOuterHTML()).replace("{-{-PRODUCT_BUTTON-}-}", s.getOuterHTML()).replace("{-{-CONFIG_BLOCK-}-}", a.getOuterHTML()), u = u.trim().replace(R, "").slice(0, -5), this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(u).apply(new d("Reordered template"));
236
- }, 50);
230
+ const { orientation: l } = this.store;
231
+ let c = l === S.ORIENTATION.VERTICAL ? H : x;
232
+ c = c.replace("{-{-TEMPLATE_FIRST_LINE-}-}", A).replace("{-{-PRODUCT_IMAGE-}-}", e.getOuterHTML()).replace("{-{-PRODUCT_NAME-}-}", i.getOuterHTML()).replace("{-{-PRODUCT_PRICE-}-}", t.getOuterHTML()).replace("{-{-PRODUCT_ORIGINAL_PRICE-}-}", r.getOuterHTML()).replace("{-{-PRODUCT_QUANTITY-}-}", n.getOuterHTML()).replace("{-{-PRODUCT_BUTTON-}-}", s.getOuterHTML()).replace("{-{-CONFIG_BLOCK-}-}", a.getOuterHTML()), c = c.trim().replace(A, "").slice(0, -5), this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(c).apply(new d("Reordered template"));
237
233
  }
238
234
  _updateDataTypeAttributes(e) {
239
235
  if (!this.currentNode)
@@ -247,21 +243,21 @@ class te extends x {
247
243
  _updateDataNumberAttributes(e) {
248
244
  if (!this.currentNode)
249
245
  return;
250
- const { itemsType: i } = this.store, t = N[i].findIndex((c) => c.value === e);
246
+ const { itemsType: i } = this.store, t = N[i].findIndex((l) => l.value === e);
251
247
  let r = "1";
252
248
  if (t >= 0)
253
249
  r = String(t + 1);
254
250
  else if (e) {
255
- const c = e.match(/\((\d+)\)/);
256
- if (c) {
257
- const [, m] = c;
258
- r = m;
251
+ const l = e.match(/\((\d+)\)/);
252
+ if (l) {
253
+ const [, c] = l;
254
+ r = c;
259
255
  }
260
256
  }
261
257
  const n = this.currentNode.closest(".ins-product-td"), s = this.api.getDocumentModifier();
262
- n && s.modifyHtml(n).setAttribute("data-number", r), this.currentNode.querySelectorAll("[data-number]").forEach((c) => {
263
- const m = c;
264
- s.modifyHtml(m).setAttribute("data-number", r);
258
+ n && s.modifyHtml(n).setAttribute("data-number", r), this.currentNode.querySelectorAll("[data-number]").forEach((l) => {
259
+ const c = l;
260
+ s.modifyHtml(c).setAttribute("data-number", r);
265
261
  }), s.apply(new d("Updated data-number attribute"));
266
262
  }
267
263
  _reFillTemplate() {
@@ -269,17 +265,17 @@ class te extends x {
269
265
  this._updateImageSrc(e.imageSrc), this._updateName(e.name), this._updatePrice(e.price), this._updateOriginalPrice(e.originalPrice), this._updateQuantity(e.quantity);
270
266
  }
271
267
  _recalculateTrimming() {
272
- var n;
273
- if (!this.currentNode)
268
+ var r;
269
+ if (!this.store.nameTrimming || !this.currentNode)
274
270
  return;
275
- const e = (n = this.currentNode) == null ? void 0 : n.querySelector(`[esd-extension-block-id="${l.NAME}"]`);
271
+ const e = (r = this.currentNode) == null ? void 0 : r.querySelector(`[esd-extension-block-id="${m.NAME}"]`);
276
272
  if (!e)
277
273
  return;
278
- const i = e.querySelector("p > a");
274
+ const i = e.querySelector("p");
279
275
  if (!i)
280
276
  return;
281
- const t = this.store.orientation === S.ORIENTATION.VERTICAL, r = this.store.nameTrimming;
282
- this.api.getDocumentModifier().modifyHtml(i).setStyle("overflow", "hidden").setStyle("white-space", r ? "nowrap" : "normal").setStyle("text-overflow", r ? "ellipsis" : "unset").setStyle("max-width", t ? "130px" : "520px").setStyle("width", t ? "130px" : "520px").apply(new d("Recalculated trimming after orientation change"));
277
+ const t = this.store.orientation === S.ORIENTATION.VERTICAL;
278
+ this.api.getDocumentModifier().modifyHtml(i).setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis").setStyle("max-width", t ? "130px" : "100%").apply(new d("Recalculated trimming after orientation change"));
283
279
  }
284
280
  _getParagraphFromBlock(e) {
285
281
  return e.querySelector("p");
@@ -311,6 +307,6 @@ class te extends x {
311
307
  }
312
308
  }
313
309
  export {
314
- G as CONTROL_BLOCK_ID,
315
- te as ItemsBlockControl
310
+ w as CONTROL_BLOCK_ID,
311
+ Z as ItemsBlockControl
316
312
  };
@@ -19,7 +19,7 @@ const e = {
19
19
  itemsType: e.ITEMS_TYPE.CART_ITEMS,
20
20
  cartItemsSelectControlValue: "{{Abandoned Cart Item (1) Url}}",
21
21
  cardOrientationControlValue: e.ORIENTATION.HORIZONTAL,
22
- productNameTrimmingControlValue: "1",
22
+ productNameTrimmingControlValue: "0",
23
23
  productPriceHideDiscountControlValue: "0",
24
24
  productPriceFormattedControlValue: "1",
25
25
  productPriceCurrencySymbolControlValue: "USD",
@@ -34,8 +34,7 @@ const e = {
34
34
  productQuantityVisible: "1",
35
35
  productPriceVisible: "1",
36
36
  productOriginalPriceVisible: "1",
37
- productButtonVisible: "1",
38
- productImageWidth: "70"
37
+ productButtonVisible: "1"
39
38
  }, o = {
40
39
  [e.ITEMS_TYPE.CART_ITEMS]: [
41
40
  { text: "Abandoned Cart Item (1)", value: "{{Abandoned Cart Item (1) Url}}" },
@@ -8,7 +8,7 @@ const n = (t) => t.replace(/Url\}/, "Image}"), o = (t) => t.replace(/Image\}/, "
8
8
  imageLink: n(t),
9
9
  buttonLink: o(t),
10
10
  orientation: e.cardOrientationControlValue,
11
- nameTrimming: !0,
11
+ nameTrimming: !1,
12
12
  hideDiscount: !1,
13
13
  currencySymbol: "USD",
14
14
  currencyLocation: "0",
@@ -1,17 +1,17 @@
1
1
  import { BlockType as l, BlockAttr as _ } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { ItemsBlockId as T } from "./enums/controlEnums.js";
2
+ import { ItemsBlockId as d } from "./enums/controlEnums.js";
3
3
  import { productPairs as i, templateFirstLine as N } from "./enums/productEnums.js";
4
- import { ItemInCartOptions as f, SETTINGS_ENUMS as O, DefaultConfigValues as P } from "./enums/settingsEnums.js";
5
- import B from "./layouts/horizontal.html.js";
6
- import g from "./layouts/vertical.html.js";
7
- let [C] = i.PAIRS_FOR_EXTENSION.imageSrc.CART_ITEMS.DEFAULT, [A] = i.PAIRS_FOR_EXTENSION.name.CART_ITEMS.DEFAULT, [p] = i.PAIRS_FOR_EXTENSION.price.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [I] = i.PAIRS_FOR_EXTENSION.originalPrice.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [u] = i.PAIRS_FOR_EXTENSION.quantity.CART_ITEMS.DEFAULT;
8
- const h = (a, t) => `
4
+ import { ItemInCartOptions as P, SETTINGS_ENUMS as O } from "./enums/settingsEnums.js";
5
+ import f from "./layouts/horizontal.html.js";
6
+ import B from "./layouts/vertical.html.js";
7
+ let [R] = i.PAIRS_FOR_EXTENSION.imageSrc.CART_ITEMS.DEFAULT, [C] = i.PAIRS_FOR_EXTENSION.name.CART_ITEMS.DEFAULT, [I] = i.PAIRS_FOR_EXTENSION.price.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [$] = i.PAIRS_FOR_EXTENSION.originalPrice.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [u] = i.PAIRS_FOR_EXTENSION.quantity.CART_ITEMS.DEFAULT;
8
+ const g = (a, t) => `
9
9
  <${l.BLOCK_IMAGE}
10
- ${_.BLOCK_IMAGE.src}="${C}"
11
- ${_.BLOCK_IMAGE.alt}="${A}"
10
+ ${_.BLOCK_IMAGE.src}="${R}"
11
+ ${_.BLOCK_IMAGE.alt}="Product Image"
12
12
  ${_.BLOCK_IMAGE.href}="#!"
13
- ${_.BLOCK_IMAGE.width}=${P.productImageWidth}
14
- esd-extension-block-id="${T.IMAGE}"
13
+ ${_.BLOCK_IMAGE.width}="70"
14
+ esd-extension-block-id="${d.IMAGE}"
15
15
  data-slot-1
16
16
  product-attr="imageSrc"
17
17
  data-type="${a}"
@@ -23,7 +23,7 @@ const h = (a, t) => `
23
23
  align="center"
24
24
  class="es-p10"
25
25
  data-type="${a}"
26
- esd-extension-block-id="${T.NAME}"
26
+ esd-extension-block-id="${d.NAME}"
27
27
  >
28
28
  <p contenteditable="false">
29
29
  <a
@@ -35,30 +35,24 @@ const h = (a, t) => `
35
35
  line-height: inherit;
36
36
  font-family: inherit;
37
37
  color: inherit;
38
- display: block;
39
- word-wrap:break-word;
40
- white-space: nowrap;
41
- width: 520px;
42
- overflow: hidden;
43
- text-overflow: ellipsis;
44
38
  "
45
39
  product-attr="name"
46
40
  data-slot-2
47
41
  width="100%">
48
- ${A}
42
+ ${C}
49
43
  </a>
50
44
  </p>
51
45
  </${l.BLOCK_TEXT}>
52
- `, S = (a, t, o, e, c) => {
53
- let n = p;
46
+ `, S = (a, t, n, e, c) => {
47
+ let o = I;
54
48
  if (e && e.trim()) {
55
- const E = `&nbsp;${e.trim()}&nbsp;`;
56
- n = (c || "0") === "1" ? `${p}${E}` : `${E}${p}`;
49
+ const T = `&nbsp;${e.trim()}&nbsp;`;
50
+ o = (c || "0") === "1" ? `${I}${T}` : `${T}${I}`;
57
51
  }
58
- const r = c === "1" ? "after" : "before", d = `data-formated="${o ? "true" : "false"}"`, s = `data-curency="${r}"`;
52
+ const r = c === "1" ? "after" : "before", E = `data-formated="${n ? "true" : "false"}"`, s = `data-curency="${r}"`;
59
53
  return `
60
54
  <${l.BLOCK_TEXT}
61
- esd-extension-block-id="${T.PRICE}"
55
+ esd-extension-block-id="${d.PRICE}"
62
56
  class="items-block-price"
63
57
  width="100%"
64
58
  align="center"
@@ -69,25 +63,25 @@ const h = (a, t) => `
69
63
  data-slot-4
70
64
  data-type="${a}"
71
65
  data-number="${t}"
72
- ${d}
66
+ ${E}
73
67
  ${s}
74
68
  ${e ? `data-currency_symbol="${e}"` : ""}
75
69
  >
76
- ${n}
70
+ ${o}
77
71
  </p>
78
72
  </${l.BLOCK_TEXT}>
79
73
  `;
80
- }, L = (a, t, o, e, c) => {
81
- let n = I;
74
+ }, L = (a, t, n, e, c) => {
75
+ let o = $;
82
76
  if (e && e.trim()) {
83
- const E = `&nbsp;${e.trim()}&nbsp;`;
84
- n = (c || "0") === "1" ? `${I}${E}` : `${E}${I}`;
77
+ const T = `&nbsp;${e.trim()}&nbsp;`;
78
+ o = (c || "0") === "1" ? `${$}${T}` : `${T}${$}`;
85
79
  }
86
- const r = c === "1" ? "after" : "before", d = `data-formated="${o ? "true" : "false"}"`, s = `data-curency="${r}"`;
80
+ const r = c === "1" ? "after" : "before", E = `data-formated="${n ? "true" : "false"}"`, s = `data-curency="${r}"`;
87
81
  return `
88
82
  <${l.BLOCK_TEXT}
89
83
  class="items-block-price"
90
- esd-extension-block-id="${T.ORIGINAL_PRICE}"
84
+ esd-extension-block-id="${d.ORIGINAL_PRICE}"
91
85
  width="100%"
92
86
  align="center"
93
87
  >
@@ -98,11 +92,11 @@ const h = (a, t) => `
98
92
  style="color: #cc0000"
99
93
  data-type="${a}"
100
94
  data-number="${t}"
101
- ${d}
95
+ ${E}
102
96
  ${s}
103
97
  ${e ? `data-currency_symbol="${e}"` : ""}
104
98
  >
105
- <s>${n}</s>
99
+ <s>${o}</s>
106
100
  </p>
107
101
  </${l.BLOCK_TEXT}>
108
102
  `;
@@ -111,7 +105,7 @@ const h = (a, t) => `
111
105
  width="100%"
112
106
  align="center"
113
107
  class="es-p10"
114
- esd-extension-block-id="${T.QUANTITY}"
108
+ esd-extension-block-id="${d.QUANTITY}"
115
109
  >
116
110
  <p
117
111
  product-attr="quantity"
@@ -121,75 +115,75 @@ const h = (a, t) => `
121
115
  ${u}
122
116
  </p>
123
117
  </${l.BLOCK_TEXT}>
124
- `, U = (a, t) => `
118
+ `, h = (a, t) => `
125
119
  <${l.BLOCK_BUTTON}
126
120
  width="100%"
127
121
  class="ins-button"
128
122
  name="buy-button"
129
123
  caption="Buy"
130
124
  align="center"
131
- esd-extension-block-id="${T.BUTTON}"
125
+ esd-extension-block-id="${d.BUTTON}"
132
126
  product-attr="button"
133
127
  data-slot-6
134
128
  data-type="${a}"
135
129
  data-number="${t}"
136
130
  >Buy
137
131
  </${l.BLOCK_BUTTON}>
138
- `, D = () => `
132
+ `, U = () => `
139
133
  <esd-config-block style="display: none;"></esd-config-block>
140
- `, R = (a, t, o, e, c, n, r, d) => {
141
- const $ = `${`data-type="${t}" data-number="${o}"`} data-orientation="${e}"`;
134
+ `, p = (a, t, n, e, c, o, r, E) => {
135
+ const A = `${`data-type="${t}" data-number="${n}"`} data-orientation="${e}"`;
142
136
  return a.replace(
143
137
  /<td([^>]*class="[^"]*ins-product-td[^"]*"[^>]*)>/,
144
- `<td$1 ${$}>`
145
- ).replace("{-{-TEMPLATE_FIRST_LINE-}-}", N).replace("{-{-PRODUCT_IMAGE-}-}", h(t, o)).replace("{-{-PRODUCT_NAME-}-}", F(t)).replace(
138
+ `<td$1 ${A}>`
139
+ ).replace("{-{-TEMPLATE_FIRST_LINE-}-}", N).replace("{-{-PRODUCT_IMAGE-}-}", g(t, n)).replace("{-{-PRODUCT_NAME-}-}", F(t)).replace(
146
140
  "{-{-PRODUCT_PRICE-}-}",
147
- S(t, o, c, n, r)
141
+ S(t, n, c, o, r)
148
142
  ).replace(
149
143
  "{-{-PRODUCT_ORIGINAL_PRICE-}-}",
150
144
  L(
151
145
  t,
152
- o,
153
- c,
154
146
  n,
147
+ c,
148
+ o,
155
149
  r
156
150
  )
157
- ).replace("{-{-PRODUCT_QUANTITY-}-}", b()).replace("{-{-PRODUCT_BUTTON-}-}", U(t, o)).replace("{-{-CONFIG_BLOCK-}-}", D());
151
+ ).replace("{-{-PRODUCT_QUANTITY-}-}", b()).replace("{-{-PRODUCT_BUTTON-}-}", h(t, n)).replace("{-{-CONFIG_BLOCK-}-}", U());
158
152
  };
159
- function G({
153
+ function x({
160
154
  orientation: a,
161
155
  itemsType: t = O.ITEMS_TYPE.CART_ITEMS,
162
- itemId: o,
156
+ itemId: n,
163
157
  currencySymbol: e,
164
158
  currencyLocation: c,
165
- formattedPrice: n = !0
159
+ formattedPrice: o = !0
166
160
  }) {
167
- const r = f[t].findIndex((s) => s.value === o);
168
- let d = "1";
161
+ const r = P[t].findIndex((s) => s.value === n);
162
+ let E = "1";
169
163
  if (r >= 0)
170
- d = String(r + 1);
171
- else if (o) {
172
- const s = o.match(/\((\d+)\)/);
173
- s && s[1] && ([, d] = s);
164
+ E = String(r + 1);
165
+ else if (n) {
166
+ const s = n.match(/\((\d+)\)/);
167
+ s && s[1] && ([, E] = s);
174
168
  }
175
- return C = i.PAIRS_FOR_EXTENSION.imageSrc[t].DEFAULT[r >= 0 ? r : 0], A = i.PAIRS_FOR_EXTENSION.name[t].DEFAULT[r >= 0 ? r : 0], p = n ? i.PAIRS_FOR_EXTENSION.price[t].DEFAULT_PRICE_FORMATTED : i.PAIRS_FOR_EXTENSION.price[t].DEFAULT_PRICE, I = n ? i.PAIRS_FOR_EXTENSION.originalPrice[t].DEFAULT_PRICE_FORMATTED : i.PAIRS_FOR_EXTENSION.originalPrice[t].DEFAULT_PRICE, u = i.PAIRS_FOR_EXTENSION.quantity[t].DEFAULT, a === O.ORIENTATION.VERTICAL ? R(
176
- g,
169
+ return R = i.PAIRS_FOR_EXTENSION.imageSrc[t].DEFAULT[r >= 0 ? r : 0], C = i.PAIRS_FOR_EXTENSION.name[t].DEFAULT[r >= 0 ? r : 0], I = o ? i.PAIRS_FOR_EXTENSION.price[t].DEFAULT_PRICE_FORMATTED : i.PAIRS_FOR_EXTENSION.price[t].DEFAULT_PRICE, $ = o ? i.PAIRS_FOR_EXTENSION.originalPrice[t].DEFAULT_PRICE_FORMATTED : i.PAIRS_FOR_EXTENSION.originalPrice[t].DEFAULT_PRICE, u = i.PAIRS_FOR_EXTENSION.quantity[t].DEFAULT, a === O.ORIENTATION.VERTICAL ? p(
170
+ B,
177
171
  t,
178
- d,
172
+ E,
179
173
  a,
180
- n,
174
+ o,
181
175
  e,
182
176
  c
183
- ) : R(
184
- B,
177
+ ) : p(
178
+ f,
185
179
  t,
186
- d,
180
+ E,
187
181
  a,
188
- n,
182
+ o,
189
183
  e,
190
184
  c
191
185
  );
192
186
  }
193
187
  export {
194
- G as getDefaultTemplate
188
+ x as getDefaultTemplate
195
189
  };
@@ -1,17 +1,17 @@
1
- var d = Object.defineProperty;
2
- var _ = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
- var u = (n, i, e) => _(n, typeof i != "symbol" ? i + "" : i, e);
1
+ var _ = Object.defineProperty;
2
+ var S = (n, i, e) => i in n ? _(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
+ var u = (n, i, e) => S(n, typeof i != "symbol" ? i + "" : i, e);
4
4
  import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
5
5
  import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
6
- import { Block as h, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
- import { getDefaultTemplate as L } from "./template.js";
6
+ import { Block as d, BlockCompositionType as L, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
+ import { getDefaultTemplate as h } from "./template.js";
8
8
  import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
9
- import { parsePageList as p } from "./utils/utils.js";
10
- const g = "unsubscribe-block", v = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", B = "{{ins-unsubscribe-link}}", T = {
9
+ import { parsePageList as m } from "./utils/utils.js";
10
+ const v = "unsubscribe-block", g = 'a[data-unsubscribe-link="true"]', T = ".unsubscribe-block-v2", f = "{{ins-unsubscribe-link}}", B = {
11
11
  [E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
12
12
  [E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
13
13
  };
14
- class R extends h {
14
+ class D extends d {
15
15
  constructor() {
16
16
  super();
17
17
  u(this, "selectEventListener", null);
@@ -19,13 +19,13 @@ class R extends h {
19
19
  u(this, "currentNode");
20
20
  }
21
21
  getId() {
22
- return g;
22
+ return v;
23
23
  }
24
24
  getIcon() {
25
25
  return "unsubscribe-icon";
26
26
  }
27
27
  getBlockCompositionType() {
28
- return S.BLOCK;
28
+ return L.BLOCK;
29
29
  }
30
30
  getName() {
31
31
  return this.api.translate("Unsubscribe Block");
@@ -34,10 +34,13 @@ class R extends h {
34
34
  return this.api.translate("Unsubscribe Block Description");
35
35
  }
36
36
  getTemplate() {
37
- return L();
37
+ return h();
38
+ }
39
+ onCreated(e) {
40
+ "getOuterHTML" in e && !e.getOuterHTML() || "getAttribute" in e && e.getAttribute("data-migration") || (this.currentNode = e, this._resetStoreState(), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
38
41
  }
39
42
  onSelect(e) {
40
- this.currentNode = e, !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
43
+ this.currentNode = e, this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener();
41
44
  }
42
45
  onDelete(e) {
43
46
  this._removeEventListeners(), this._removeBlockTemplatesFromStore(e), this._resetStoreState();
@@ -63,13 +66,7 @@ class R extends h {
63
66
  this.cancelEventListener && (document.removeEventListener(a.CANCEL, this.cancelEventListener), this.cancelEventListener = null);
64
67
  }
65
68
  _handleCancel() {
66
- try {
67
- if (!this.currentNode)
68
- return;
69
- this.api.getDocumentModifier().modifyHtml(this.currentNode).delete().apply(new b("Removed unsubscribe block due to cancel"));
70
- } catch (e) {
71
- console.warn("[UnsubscribeBlock] Failed to remove unsubscribe block:", e);
72
- }
69
+ this.currentNode && this.api.getDocumentModifier().modifyHtml(this.currentNode).delete().apply(new b("Removed unsubscribe block due to cancel"));
73
70
  }
74
71
  _removeEventListeners() {
75
72
  this._removeSelectEventListener(), this._removeCancelEventListener();
@@ -77,27 +74,26 @@ class R extends h {
77
74
  _updateBlock(e, s) {
78
75
  if (!this.currentNode || !("querySelector" in this.currentNode))
79
76
  return;
80
- const t = this.currentNode.querySelector(v);
77
+ const t = this.currentNode.querySelector(g);
81
78
  if (!t)
82
79
  return;
83
80
  const r = this._getMergeTag(e);
84
81
  this.api.getDocumentModifier().modifyHtml(t).setAttribute("href", r).apply(new b(`Updated unsubscribe link to ${r}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, s).apply(new b("Updated unsubscribe block metadata"));
85
82
  }
86
83
  _getMergeTag(e) {
87
- return T[e] ?? B;
84
+ return B[e] ?? f;
88
85
  }
89
86
  _openDrawer() {
90
- if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
91
- try {
92
- const e = c();
93
- e.typeSelectionDrawerStatus = !0;
94
- } catch (e) {
95
- console.error("[UnsubscribeBlock] Failed to open drawer:", e);
96
- }
87
+ try {
88
+ const e = c();
89
+ e.typeSelectionDrawerStatus = !0;
90
+ } catch (e) {
91
+ console.error("[UnsubscribeBlock] Failed to open drawer:", e);
92
+ }
97
93
  }
98
94
  _checkExistingBlocks() {
99
95
  const e = c();
100
- e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((t) => {
96
+ e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(T).forEach((t) => {
101
97
  if ("getAttribute" in t) {
102
98
  const r = t.getAttribute(o.PAGE_TYPE);
103
99
  if (r) {
@@ -113,8 +109,8 @@ class R extends h {
113
109
  const s = e.getAttribute(o.PAGE_TYPE), t = e.getAttribute(o.PAGE_LIST);
114
110
  if (!s || !t)
115
111
  return;
116
- const r = c(), l = Number(s), m = p(t);
117
- r.setCollectionWithoutAutoSelection(l), r.loadSelectedTemplates(m);
112
+ const r = c(), l = Number(s), p = m(t);
113
+ r.setCollectionWithoutAutoSelection(l), r.loadSelectedTemplates(p);
118
114
  }
119
115
  _resetStoreState() {
120
116
  c().$reset();
@@ -125,11 +121,11 @@ class R extends h {
125
121
  const s = e.getAttribute(o.PAGE_LIST);
126
122
  if (!s)
127
123
  return;
128
- const t = c(), r = p(s);
124
+ const t = c(), r = m(s);
129
125
  t.removeUnsubscribePages(r);
130
126
  }
131
127
  }
132
128
  export {
133
- g as UNSUBSCRIBE_BLOCK_ID,
134
- R as UnsubscribeBlock
129
+ v as UNSUBSCRIBE_BLOCK_ID,
130
+ D as UnsubscribeBlock
135
131
  };
@@ -5,4 +5,5 @@ export declare const useActionsApi: () => {
5
5
  getTemplateData: () => Promise<TemplateData>;
6
6
  activateCustomViewStyles: (isActive?: boolean) => void;
7
7
  getPreviewData: (options?: CompileEmailOptions) => Promise<CompiledEmailResult>;
8
+ updateTimerInClonedTemplate: () => Promise<string | null>;
8
9
  };
@@ -0,0 +1,5 @@
1
+ export declare const useTimerClone: () => {
2
+ hasTimerBlocks: (html: string) => boolean;
3
+ cloneTimersInHtml: (html: string, authToken: string) => Promise<string | null>;
4
+ updateTimersOnLoad: (getToken: () => Promise<string>) => Promise<void>;
5
+ };
@@ -40,7 +40,6 @@ export declare const DefaultConfigValues: {
40
40
  productPriceVisible: string;
41
41
  productOriginalPriceVisible: string;
42
42
  productButtonVisible: string;
43
- productImageWidth: string;
44
43
  };
45
44
  export declare const ItemInCartOptions: {
46
45
  [x: string]: {
@@ -1,4 +1,4 @@
1
- import type { ImmutableHtmlElementNode } from '@stripoinc/ui-editor-extensions';
1
+ import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
2
2
  import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
3
3
  export declare const UNSUBSCRIBE_BLOCK_ID = "unsubscribe-block";
4
4
  export declare class UnsubscribeBlock extends Block {
@@ -12,8 +12,9 @@ export declare class UnsubscribeBlock extends Block {
12
12
  getName(): string;
13
13
  getDescription(): string;
14
14
  getTemplate(): string;
15
- onSelect(node: ImmutableHtmlElementNode): void;
16
- onDelete(node: ImmutableHtmlElementNode): void;
15
+ onCreated(node: ImmutableHtmlNode): void;
16
+ onSelect(node: ImmutableHtmlNode): undefined;
17
+ onDelete(node: ImmutableHtmlNode): undefined;
17
18
  onDestroy(): void;
18
19
  private _setupSelectEventListener;
19
20
  private _removeSelectEventListener;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "1.0.3-beta.e83334e",
3
+ "version": "1.0.3-beta.ea69f4a",
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",