@useinsider/guido 1.0.3-beta.9332823 → 1.0.3-beta.9440b5f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +2 -0
  2. package/dist/components/Guido.vue.js +1 -1
  3. package/dist/components/Guido.vue2.js +64 -61
  4. package/dist/composables/useStripo.js +37 -35
  5. package/dist/config/migrator/radioButtonMigrator.js +5 -5
  6. package/dist/enums/defaults.js +2 -1
  7. package/dist/enums/unsubscribe.js +27 -26
  8. package/dist/extensions/Blocks/Checkbox/control.js +15 -14
  9. package/dist/extensions/Blocks/RadioButton/control.js +18 -17
  10. package/dist/extensions/Blocks/RadioButton/template.js +10 -9
  11. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +1 -1
  12. package/dist/extensions/DynamicContent/dynamic-content-modal.js +25 -19
  13. package/dist/extensions/DynamicContent/dynamic-content.js +128 -33
  14. package/dist/guido.css +1 -1
  15. package/dist/package.json.js +1 -1
  16. package/dist/src/@types/generic.d.ts +27 -6
  17. package/dist/src/components/Guido.vue.d.ts +2 -2
  18. package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
  19. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -1
  20. package/dist/src/extensions/DynamicContent/dynamic-content-modal.d.ts +9 -2
  21. package/dist/src/extensions/DynamicContent/dynamic-content.d.ts +52 -2
  22. package/dist/src/stores/config.d.ts +3 -2
  23. package/dist/src/stores/dynamic-content.d.ts +3 -3
  24. package/dist/src/stores/editor.d.ts +1 -1
  25. package/dist/src/stores/onboarding.d.ts +1 -1
  26. package/dist/src/stores/preview.d.ts +1 -1
  27. package/dist/src/stores/recommendation.d.ts +1 -1
  28. package/dist/src/stores/save-as-template.d.ts +1 -1
  29. package/dist/src/stores/toaster.d.ts +1 -1
  30. package/dist/src/stores/unsubscribe.d.ts +1 -1
  31. package/dist/src/stores/version-history.d.ts +1 -1
  32. package/dist/src/utils/environmentUtil.d.ts +2 -5
  33. package/dist/src/utils/genericUtil.d.ts +1 -0
  34. package/dist/stores/config.js +5 -5
  35. package/dist/stores/dynamic-content.js +2 -2
  36. package/dist/stores/editor.js +1 -1
  37. package/dist/stores/onboarding.js +27 -27
  38. package/dist/stores/preview.js +1 -1
  39. package/dist/stores/recommendation.js +3 -3
  40. package/dist/stores/save-as-template.js +2 -2
  41. package/dist/stores/toaster.js +1 -1
  42. package/dist/stores/unsubscribe.js +1 -1
  43. package/dist/stores/version-history.js +4 -4
  44. package/dist/utils/environmentUtil.js +4 -0
  45. package/dist/utils/genericUtil.js +20 -9
  46. package/package.json +2 -2
  47. package/dist/src/enums/environment.d.ts +0 -5
package/README.md CHANGED
@@ -198,6 +198,7 @@ interface GuidoConfig {
198
198
  saveAsTemplate: boolean;
199
199
  versionHistory: boolean;
200
200
  testMessage: boolean;
201
+ displayConditions: boolean;
201
202
  };
202
203
  blocks?: {
203
204
  excludeDefaults?: GuidoBlockType[];
@@ -216,6 +217,7 @@ interface GuidoConfig {
216
217
  | `features.dynamicContent` | `boolean` | `true` | Enable dynamic content insertion feature |
217
218
  | `features.saveAsTemplate` | `boolean` | `true` | Enable save as template feature |
218
219
  | `features.versionHistory` | `boolean` | `true` | Enable version history feature |
220
+ | `features.displayConditions` | `boolean` | `true` | Enable display conditions |
219
221
  | `blocks` | `BlocksConfig` | `{ excludeDefaults: [], includeCustoms: [] }` | Block configuration for excluding default blocks and including custom blocks. See [Blocks Configuration](#-blocks-configuration) section below |
220
222
  | `blocks.excludeDefaults` | `GuidoBlockType[]` | `[]` | Array of default Stripo blocks to exclude from the editor |
221
223
  | `blocks.includeCustoms` | `GuidoCustomBlockType[]` | `[]` | Array of custom blocks to include in the editor |
@@ -12,7 +12,7 @@ var t = function() {
12
12
  n,
13
13
  !1,
14
14
  null,
15
- "e299731b"
15
+ "23c413c9"
16
16
  );
17
17
  const v = s.exports;
18
18
  export {
@@ -1,23 +1,23 @@
1
- import { defineComponent as R, defineAsyncComponent as G, ref as x, computed as I, watch as M, onMounted as z, onUnmounted as B } from "vue";
2
- import { provideGuidoActions as K } from "../composables/useGuidoActions.js";
3
- import { usePartner as O } from "../composables/usePartner.js";
4
- import { useStripo as j } from "../composables/useStripo.js";
5
- import { migrate as U } from "../config/migrator/index.js";
6
- import { DefaultUsername as q, DefaultMessageType as J, DefaultGuidoConfig as Q } from "../enums/defaults.js";
7
- import V from "./organisms/base/Toaster.vue.js";
8
- import X from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
9
- import Y from "./organisms/header/HeaderWrapper.vue.js";
10
- import Z from "./organisms/LoadingWrapper.vue.js";
11
- import $ from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
12
- import ee from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
13
- import { useStripoApi as oe } from "../services/stripoApi.js";
14
- import { useConfigStore as te } from "../stores/config.js";
15
- import { useDynamicContentStore as ne } from "../stores/dynamic-content.js";
16
- import { useEditorStore as re } from "../stores/editor.js";
17
- import { usePreviewStore as ie } from "../stores/preview.js";
18
- import { useUnsubscribeStore as se } from "../stores/unsubscribe.js";
19
- import ae from "../node_modules/lodash-es/merge.js";
20
- const ke = /* @__PURE__ */ R({
1
+ import { defineComponent as O, defineAsyncComponent as I, ref as z, computed as U, watch as B, onMounted as K, onUnmounted as j } from "vue";
2
+ import { provideGuidoActions as q } from "../composables/useGuidoActions.js";
3
+ import { usePartner as J } from "../composables/usePartner.js";
4
+ import { useStripo as Q } from "../composables/useStripo.js";
5
+ import { migrate as L } from "../config/migrator/index.js";
6
+ import { DefaultUsername as V, DefaultMessageType as X, DefaultGuidoConfig as Y } from "../enums/defaults.js";
7
+ import Z from "./organisms/base/Toaster.vue.js";
8
+ import $ from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
9
+ import ee from "./organisms/header/HeaderWrapper.vue.js";
10
+ import oe from "./organisms/LoadingWrapper.vue.js";
11
+ import te from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
12
+ import ne from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
13
+ import { useStripoApi as re } from "../services/stripoApi.js";
14
+ import { useConfigStore as ie } from "../stores/config.js";
15
+ import { useDynamicContentStore as se } from "../stores/dynamic-content.js";
16
+ import { useEditorStore as ae } from "../stores/editor.js";
17
+ import { usePreviewStore as ce } from "../stores/preview.js";
18
+ import { useUnsubscribeStore as me } from "../stores/unsubscribe.js";
19
+ import de from "../node_modules/lodash-es/merge.js";
20
+ const Ue = /* @__PURE__ */ O({
21
21
  __name: "Guido",
22
22
  props: {
23
23
  templateId: null,
@@ -33,45 +33,45 @@ const ke = /* @__PURE__ */ R({
33
33
  },
34
34
  emits: ["dynamic-content:open", "back", "save:start", "save:complete", "on-change", "ready", "onboarding:finished", "test-email:click"],
35
35
  setup(W, { expose: _, emit: o }) {
36
- const l = W, L = G(
36
+ const u = W, A = I(
37
37
  () => import("./organisms/email-preview/PreviewContainer.vue.js")
38
- ), A = G(
38
+ ), N = I(
39
39
  () => import("./organisms/onboarding/OnboardingWrapper.vue.js")
40
- ), u = x(), i = ne(), p = se(), g = te(), s = re(), N = ie(), n = I(() => s.hasChanges), { getPartnerName: f, getProductType: y, isTestPartner: F } = O(), v = () => {
40
+ ), p = z(), i = se(), g = me(), f = ie(), s = ae(), F = ce(), n = U(() => s.hasChanges), { getPartnerName: y, getProductType: v, isTestPartner: H } = J(), b = () => {
41
41
  var e;
42
- return (e = u.value) == null ? void 0 : e.handleSave(!0);
42
+ return (e = p.value) == null ? void 0 : e.handleSave(!0);
43
43
  }, {
44
44
  templateId: a,
45
- userId: b,
46
- guidoConfig: C,
45
+ userId: C,
46
+ guidoConfig: h,
47
47
  templateConfig: t,
48
48
  html: r = "",
49
- css: h = "",
50
- partnerName: c = f(),
51
- productType: d = y(),
52
- messageType: S = J,
53
- username: w = q
54
- } = l, m = (t == null ? void 0 : t.preselectedDynamicContentList) || [];
55
- s.templateId = a, window.GuidoConfig = ae(Q, C), window.GuidoConfig.partner = {
49
+ css: S = "",
50
+ partnerName: c = y(),
51
+ productType: m = v(),
52
+ messageType: w = X,
53
+ username: D = V
54
+ } = u, d = (t == null ? void 0 : t.preselectedDynamicContentList) || [];
55
+ s.templateId = a, window.GuidoConfig = de(Y, h), window.GuidoConfig.partner = {
56
56
  partnerName: c,
57
- productType: d,
58
- messageType: S
59
- }, g.templateConfig = t;
60
- const { initPlugin: D } = j({
57
+ productType: m,
58
+ messageType: w
59
+ }, f.templateConfig = t;
60
+ const { initPlugin: E } = Q({
61
61
  emailId: a,
62
- userId: b,
63
- username: w,
62
+ userId: C,
63
+ username: D,
64
64
  partnerName: c,
65
- productType: d,
66
- preselectedDynamicContentList: m,
65
+ productType: m,
66
+ preselectedDynamicContentList: d,
67
67
  onReady: () => {
68
68
  console.debug("guido:ready"), o("ready");
69
69
  }
70
- }), { getDefaultTemplate: T } = oe(), H = I(() => {
70
+ }), { getDefaultTemplate: T } = re(), R = U(() => {
71
71
  var e;
72
72
  return !((e = window.GuidoConfig) != null && e.useHeader);
73
73
  });
74
- K({
74
+ q({
75
75
  onBack: () => {
76
76
  console.debug("guido:back"), o("back");
77
77
  },
@@ -85,32 +85,35 @@ const ke = /* @__PURE__ */ R({
85
85
  console.debug("guido:test-email:click"), o("test-email:click");
86
86
  }
87
87
  });
88
- const E = (e) => {
88
+ const P = (e) => {
89
89
  console.debug("dynamic-content:close", e), i.setSelectedDynamicContent(e), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: e }));
90
- }, P = () => {
90
+ }, k = () => {
91
91
  console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
92
92
  };
93
- return M(() => n.value, () => {
93
+ B(() => n.value, () => {
94
94
  o("on-change", n.value);
95
- }), z(async () => {
95
+ });
96
+ const l = (e) => {
97
+ const G = e, { attribute: x, position: M } = G.detail;
98
+ console.debug("dynamic-content:open", G.detail), o("dynamic-content:open", x, M);
99
+ };
100
+ return K(async () => {
96
101
  console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow");
97
102
  try {
98
- p.selectedUnsubscribePages = (t == null ? void 0 : t.selectedUnsubscribePages) || [];
103
+ g.selectedUnsubscribePages = (t == null ? void 0 : t.selectedUnsubscribePages) || [];
99
104
  let e = {
100
- html: r && await U(r),
101
- css: h,
105
+ html: r && await L(r),
106
+ css: S,
102
107
  forceRecreate: !0
103
108
  // TODO: It should be false for old templates. We will communicate with Stripo
104
109
  };
105
- e.html || (e = await T(), e.html = await U(e.html)), await D(e), i.selectedDynamicContentList = m;
110
+ e.html || (e = await T(), e.html = await L(e.html)), await E(e), i.selectedDynamicContentList = d;
106
111
  } catch (e) {
107
112
  console.error("Failed to initialize Stripo editor:", e);
108
113
  }
109
- document.addEventListener("dynamic-content:open", (e) => {
110
- const k = e;
111
- console.debug("dynamic-content:open", k.detail), o("dynamic-content:open", k.detail);
112
- });
113
- }), B(() => {
114
+ document.addEventListener("dynamic-content:open", l);
115
+ }), j(() => {
116
+ document.removeEventListener("dynamic-content:open", l);
114
117
  try {
115
118
  window.UIEditor.removeEditor();
116
119
  } catch {
@@ -118,14 +121,14 @@ const ke = /* @__PURE__ */ R({
118
121
  }
119
122
  }), _({
120
123
  dynamicContent: {
121
- insert: E,
122
- close: P
124
+ insert: P,
125
+ close: k
123
126
  },
124
127
  hasChanges: n,
125
- saveSilent: v
126
- }), { __sfc: !0, PreviewContainer: L, OnboardingWrapper: A, headerWrapperRef: u, dynamicContentStore: i, unsubscribeStore: p, props: l, configStore: g, editorStore: s, previewStore: N, hasChanges: n, getPartnerName: f, getProductType: y, isTestPartner: F, saveSilent: v, templateId: a, userId: b, guidoConfig: C, templateConfig: t, html: r, css: h, partnerName: c, productType: d, messageType: S, username: w, preselectedDynamicContentList: m, emit: o, initPlugin: D, getDefaultTemplate: T, noHeader: H, insertDynamicContent: E, closeDynamicContent: P, Toaster: V, FilterSelectionDrawer: X, HeaderWrapper: Y, LoadingWrapper: Z, SaveAsTemplateDrawer: $, UnsubscribeWrapper: ee };
128
+ saveSilent: b
129
+ }), { __sfc: !0, PreviewContainer: A, OnboardingWrapper: N, headerWrapperRef: p, dynamicContentStore: i, unsubscribeStore: g, props: u, configStore: f, editorStore: s, previewStore: F, hasChanges: n, getPartnerName: y, getProductType: v, isTestPartner: H, saveSilent: b, templateId: a, userId: C, guidoConfig: h, templateConfig: t, html: r, css: S, partnerName: c, productType: m, messageType: w, username: D, preselectedDynamicContentList: d, emit: o, initPlugin: E, getDefaultTemplate: T, noHeader: R, insertDynamicContent: P, closeDynamicContent: k, handleDynamicContentOpen: l, Toaster: Z, FilterSelectionDrawer: $, HeaderWrapper: ee, LoadingWrapper: oe, SaveAsTemplateDrawer: te, UnsubscribeWrapper: ne };
127
130
  }
128
131
  });
129
132
  export {
130
- ke as default
133
+ Ue as default
131
134
  };
@@ -1,23 +1,25 @@
1
- import { useActionsApi as y } from "./useActionsApi.js";
2
- import { useBlocksConfig as E } from "./useBlocksConfig.js";
3
- import { useCustomInterfaceAppearance as w } from "./useCustomInterfaceAppearance.js";
4
- import { useStripoEventHandler as h } from "./useStripoEventHandler.js";
5
- import { useToaster as b } from "./useToaster.js";
6
- import { displayConditions as k } from "../enums/displayConditions.js";
7
- import { useStripoApi as B } from "../services/stripoApi.js";
8
- import V from "../static/styles/customEditorStyle.css.js";
9
- import { useEditorStore as _ } from "../stores/editor.js";
10
- import { dynamicContentToMergeTags as F } from "../utils/genericUtil.js";
11
- import A from "../package.json.js";
12
- const L = (d) => {
13
- const { handleError: u } = b(), { getToken: p, getCustomFonts: m } = B(), { handleEvent: g } = h(), { getStripoBlocksConfig: f } = E(), S = async (r, i = []) => {
14
- const t = _(), { html: n, css: l, forceRecreate: a } = r, { baseBlocks: e, extensions: c } = await f();
1
+ import { useActionsApi as h } from "./useActionsApi.js";
2
+ import { useBlocksConfig as b } from "./useBlocksConfig.js";
3
+ import { useConfig as k } from "./useConfig.js";
4
+ import { useCustomInterfaceAppearance as B } from "./useCustomInterfaceAppearance.js";
5
+ import { useStripoEventHandler as V } from "./useStripoEventHandler.js";
6
+ import { useToaster as _ } from "./useToaster.js";
7
+ import { displayConditions as F } from "../enums/displayConditions.js";
8
+ import { useStripoApi as A } from "../services/stripoApi.js";
9
+ import T from "../static/styles/customEditorStyle.css.js";
10
+ import { useEditorStore as v } from "../stores/editor.js";
11
+ import { dynamicContentToMergeTags as I } from "../utils/genericUtil.js";
12
+ import M from "../package.json.js";
13
+ const N = (d) => {
14
+ const { config: u } = k(), { handleError: l } = _(), { getToken: f, getCustomFonts: S } = A(), { handleEvent: C } = V(), { getStripoBlocksConfig: y } = b(), E = async (i, r = []) => {
15
+ var m, g;
16
+ const t = v(), { html: n, css: p, forceRecreate: a } = i, { baseBlocks: e, extensions: c } = await y();
15
17
  window.UIEditor.initEditor(
16
18
  document.querySelector("#guido-editor"),
17
19
  {
18
20
  metadata: d,
19
21
  html: n,
20
- css: l,
22
+ css: p,
21
23
  forceRecreate: a,
22
24
  locale: "en",
23
25
  undoButtonSelector: "#guido__undo-button",
@@ -28,10 +30,10 @@ const L = (d) => {
28
30
  customAppearanceMergetags: !0,
29
31
  customAppearanceMergetagsBorderColor: "#f1f3fe",
30
32
  customAppearanceMergetagsBackgroundColor: "#f1f3fe",
31
- customViewStyles: V,
32
- conditionsEnabled: !0,
33
- customConditionsEnabled: !0,
34
- conditionCategories: k,
33
+ customViewStyles: T,
34
+ conditionsEnabled: ((m = u.features) == null ? void 0 : m.displayConditions) ?? !0,
35
+ customConditionsEnabled: ((g = u.features) == null ? void 0 : g.displayConditions) ?? !0,
36
+ conditionCategories: F,
35
37
  enableXSSSecurity: !0,
36
38
  messageSettingsEnabled: !1,
37
39
  selectBlockAfterDropFromSettingsPanel: !0,
@@ -39,29 +41,29 @@ const L = (d) => {
39
41
  editorFonts: {
40
42
  showDefaultStandardFonts: !0,
41
43
  showDefaultNotStandardFonts: !0,
42
- customFonts: i
44
+ customFonts: r
43
45
  },
44
46
  mergeTags: [
45
47
  {
46
- entries: F(d.preselectedDynamicContentList)
48
+ entries: I(d.preselectedDynamicContentList)
47
49
  }
48
50
  ],
49
51
  async onTokenRefreshRequest(o) {
50
52
  try {
51
- const s = await p();
53
+ const s = await f();
52
54
  o(s);
53
55
  } catch (s) {
54
- u(s, "Failed to refresh token");
56
+ l(s, "Failed to refresh token");
55
57
  }
56
58
  },
57
59
  onTemplateLoaded() {
58
60
  try {
59
- const { importCss: o } = w(), { activateCustomViewStyles: s } = y();
61
+ const { importCss: o } = B(), { activateCustomViewStyles: s } = h();
60
62
  o(), s(), d.onReady(), t.isStripoInitialized = !0, t.loadingStatus = !1, setTimeout(() => {
61
63
  t.hasChanges = !1;
62
64
  }, 1e3);
63
65
  } catch (o) {
64
- u(o, "Failed to load custom interface appearance");
66
+ l(o, "Failed to load custom interface appearance");
65
67
  }
66
68
  },
67
69
  onCodeEditorVisibilityChanged(o) {
@@ -76,7 +78,7 @@ const L = (d) => {
76
78
  onDataChanged() {
77
79
  t.hasChanges = !0;
78
80
  },
79
- onEvent: g,
81
+ onEvent: C,
80
82
  ignoreClickOutsideSelectors: [
81
83
  "#guido-dynamic-content-modal",
82
84
  ".in-on-board-wrapper",
@@ -85,26 +87,26 @@ const L = (d) => {
85
87
  extensions: c
86
88
  }
87
89
  );
88
- }, C = (r) => new Promise((i, t) => {
90
+ }, w = (i) => new Promise((r, t) => {
89
91
  var c;
90
92
  if (document.getElementById("UiEditorScript")) {
91
- r(), i();
93
+ i(), r();
92
94
  return;
93
95
  }
94
- const n = A.guido, a = `https://email-static.useinsider.com/guido/${(c = n == null ? void 0 : n.stripo) == null ? void 0 : c.version}/UIEditor.js`, e = document.createElement("script");
96
+ const n = M.guido, a = `https://email-static.useinsider.com/guido/${(c = n == null ? void 0 : n.stripo) == null ? void 0 : c.version}/UIEditor.js`, e = document.createElement("script");
95
97
  e.id = "UiEditorScript", e.type = "module", e.src = a, e.onload = () => {
96
- r(), i();
98
+ i(), r();
97
99
  }, e.onerror = () => {
98
100
  t(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
99
101
  }, document.body.appendChild(e);
100
102
  });
101
- return { initPlugin: async (r) => {
102
- await C(async () => {
103
- const i = await m();
104
- await S(r, i);
103
+ return { initPlugin: async (i) => {
104
+ await w(async () => {
105
+ const r = await S();
106
+ await E(i, r);
105
107
  });
106
108
  } };
107
109
  };
108
110
  export {
109
- L as useStripo
111
+ N as useStripo
110
112
  };
@@ -11,7 +11,7 @@ class T {
11
11
  try {
12
12
  const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll("td.radio-button-block");
13
13
  return i.length === 0 ? t : (i.forEach((s) => {
14
- const o = s.getAttribute("id"), l = this.extractTextFromElement(s, "ins-title"), a = this.extractTextFromElement(s, "ins-description"), p = this.extractTextFromElement(s, "ins-subscribe"), u = this.extractTextFromElement(s, "ins-unsubscribe"), d = this.buildTextBlock(l), g = this.buildTextBlock(a), m = this.buildTextBlock({ ...p, classList: "" }), n = this.buildTextBlock({ ...u, classList: "" }), c = h.replace("{-{-TITLE-}-}", d).replace("{-{-DESCRIPTION-}-}", g).replace("{-{-YES-}-}", m).replace("{-{-NO-}-}", n), y = this.parser.parseFromString(
14
+ const o = s.getAttribute("id"), l = this.extractTextFromElement(s, "ins-title"), a = this.extractTextFromElement(s, "ins-description"), p = this.extractTextFromElement(s, "ins-subscribe"), u = this.extractTextFromElement(s, "ins-unsubscribe"), g = this.buildTextBlock(l), d = this.buildTextBlock(a), m = this.buildTextBlock({ ...p, classList: "" }), n = this.buildTextBlock({ ...u, classList: "" }), c = h.replace("{-{-TITLE-}-}", g).replace("{-{-DESCRIPTION-}-}", d).replace("{-{-YES-}-}", m).replace("{-{-NO-}-}", n).replace(/{BLOCK_ID}/g, o || ""), y = this.parser.parseFromString(
15
15
  `<table id="tempDoc"><tbody><tr>${c}</tr></tbody></table>`,
16
16
  "text/html"
17
17
  ).querySelector(".radio-button-v2");
@@ -43,13 +43,13 @@ class T {
43
43
  styles: "",
44
44
  classList: ""
45
45
  };
46
- const o = ((c = s.textContent) == null ? void 0 : c.trim()) || (e === "ins-title" ? "Title" : "Description"), l = s.getAttribute("style") || "", a = i.getAttribute("align") || s.getAttribute("align") || "left", p = /font-weight\s*:\s*bold/i.test(l) || !!s.querySelector("b, strong"), u = /font-style\s*:\s*italic/i.test(l) || !!s.querySelector("i, em"), d = this.removeStyleProperties(l, ["font-weight", "font-style"]), g = this.convertInlineToBlock(d), m = i.getAttribute("class") || "";
46
+ const o = ((c = s.textContent) == null ? void 0 : c.trim()) || (e === "ins-title" ? "Title" : "Description"), l = s.getAttribute("style") || "", a = i.getAttribute("align") || s.getAttribute("align") || "left", p = /font-weight\s*:\s*bold/i.test(l) || !!s.querySelector("b, strong"), u = /font-style\s*:\s*italic/i.test(l) || !!s.querySelector("i, em"), g = this.removeStyleProperties(l, ["font-weight", "font-style"]), d = this.convertInlineToBlock(g), m = i.getAttribute("class") || "";
47
47
  return {
48
48
  text: o,
49
49
  isBold: p,
50
50
  isItalic: u,
51
51
  align: a,
52
- styles: g,
52
+ styles: d,
53
53
  classList: m
54
54
  };
55
55
  }
@@ -78,9 +78,9 @@ class T {
78
78
  return /display\s*:/i.test(e) || (e = e ? `${e}; display: block` : "display: block"), e.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
79
79
  }
80
80
  }
81
- function A(r) {
81
+ function I(r) {
82
82
  return new T().migrate(r);
83
83
  }
84
84
  export {
85
- A as migrateRadioButton
85
+ I as migrateRadioButton
86
86
  };
@@ -16,7 +16,8 @@ const e = {
16
16
  dynamicContent: !0,
17
17
  saveAsTemplate: !0,
18
18
  versionHistory: !0,
19
- testMessage: !0
19
+ testMessage: !0,
20
+ displayConditions: !0
20
21
  },
21
22
  useHeader: !0
22
23
  }, t = {
@@ -1,25 +1,26 @@
1
- import { useTranslations as e } from "../composables/useTranslations.js";
2
- const s = e(), R = {
1
+ import { useTranslations as n } from "../composables/useTranslations.js";
2
+ import { getEnvironmentPrefix as R } from "../utils/environmentUtil.js";
3
+ const e = n(), I = {
3
4
  UNSUBSCRIBE_LINK_TYPE: 1,
4
5
  PREFERENCES_LINK_TYPE: 3
5
- }, S = {
6
+ }, r = {
6
7
  UNSUBSCRIBE_LINK_REGEX: /{{ins-unsubscribe-link}}/g,
7
8
  DATA_OGSB_BUTTON_CSS_REGEX: "\\[data-ogsb\\]\\s*\\.es-button\\.es-button-[0-9]+\\s*\\{(?:[^\\}]*)\\}",
8
9
  GLOBAL_UNSUBSCRIBE_LINK_REGEX: /{{ins-global-unsubscribe-link}}/g,
9
10
  PREFERENCES_UNSUBSCRIBE_LINK_REGEX: /{{ins-preferences-unsubscribe-link}}/g
10
- }, N = {
11
- UNSUBSCRIBE_URL: "https://mail.useinsider.com/user/v1/unsub",
12
- PREFERENCES_URL: "https://mail.useinsider.com/user/v1/prefs"
13
- }, I = "iid", _ = {
11
+ }, s = R(), _ = {
12
+ UNSUBSCRIBE_URL: `https://mail.${s}.com/user/v1/unsub`,
13
+ PREFERENCES_URL: `https://mail.${s}.com/user/v1/prefs`
14
+ }, i = "iid", B = {
14
15
  name: "Global Unsubscribe",
15
16
  sendGridId: "G"
16
- }, i = "https://academy.useinsider.com/docs/global-unsubscribe-preference-center", r = "/email/unsubscribe-pages", E = {
17
+ }, C = "https://academy.useinsider.com/docs/global-unsubscribe-preference-center", c = "/email/unsubscribe-pages", E = {
17
18
  GLOBAL_UNSUBSCRIBE: 1,
18
19
  GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE: 2,
19
20
  SUBSCRIPTION_PREFERENCE_CENTER: 3,
20
21
  SUBSCRIPTION_PREFERENCE_CONFIRMATION: 4,
21
22
  RESUBSCRIBE: 5
22
- }, B = {
23
+ }, t = {
23
24
  [E.GLOBAL_UNSUBSCRIBE]: [
24
25
  E.GLOBAL_UNSUBSCRIBE,
25
26
  E.GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE,
@@ -29,27 +30,27 @@ const s = e(), R = {
29
30
  E.SUBSCRIPTION_PREFERENCE_CENTER,
30
31
  E.SUBSCRIPTION_PREFERENCE_CONFIRMATION
31
32
  ]
32
- }, C = {
33
- [E.GLOBAL_UNSUBSCRIBE]: s("unsubscription-preference.type-global-unsubscribe"),
34
- [E.GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE]: s("unsubscription-preference.type-global-unsubscription-confirmation"),
35
- [E.RESUBSCRIBE]: s("unsubscription-preference.type-resubscribe"),
36
- [E.SUBSCRIPTION_PREFERENCE_CENTER]: s("unsubscription-preference.type-subscription-preferences-center"),
37
- [E.SUBSCRIPTION_PREFERENCE_CONFIRMATION]: s("unsubscription-preference.type-subscription-preferences-confirmation")
38
- }, c = {
33
+ }, U = {
34
+ [E.GLOBAL_UNSUBSCRIBE]: e("unsubscription-preference.type-global-unsubscribe"),
35
+ [E.GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE]: e("unsubscription-preference.type-global-unsubscription-confirmation"),
36
+ [E.RESUBSCRIBE]: e("unsubscription-preference.type-resubscribe"),
37
+ [E.SUBSCRIPTION_PREFERENCE_CENTER]: e("unsubscription-preference.type-subscription-preferences-center"),
38
+ [E.SUBSCRIPTION_PREFERENCE_CONFIRMATION]: e("unsubscription-preference.type-subscription-preferences-confirmation")
39
+ }, o = {
39
40
  default: "{{ins-unsubscribe-link}}",
40
41
  [E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
41
42
  [E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
42
43
  };
43
44
  export {
44
- i as ACADEMY_LINK,
45
- _ as DEFAULT_UNSUBSCRIBE_GROUP,
46
- I as INSIDER_ID,
47
- S as LINK_REGEXES,
48
- R as LINK_TYPES,
49
- c as MERGE_TAGS,
45
+ C as ACADEMY_LINK,
46
+ B as DEFAULT_UNSUBSCRIBE_GROUP,
47
+ i as INSIDER_ID,
48
+ r as LINK_REGEXES,
49
+ I as LINK_TYPES,
50
+ o as MERGE_TAGS,
50
51
  E as PAGE_TYPES,
51
- B as TYPE_COLLECTIONS,
52
- C as TYPE_TRANSLATIONS,
53
- r as UNSUBSCRIBE_PAGES_LINK,
54
- N as URLS
52
+ t as TYPE_COLLECTIONS,
53
+ U as TYPE_TRANSLATIONS,
54
+ c as UNSUBSCRIBE_PAGES_LINK,
55
+ _ as URLS
55
56
  };
@@ -2,9 +2,9 @@ var d = Object.defineProperty;
2
2
  var l = (r, n, e) => n in r ? d(r, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[n] = e;
3
3
  var o = (r, n, e) => l(r, typeof n != "symbol" ? n + "" : n, e);
4
4
  import { useHttp as L } from "../../../composables/useHttp.js";
5
- import { DEFAULT_UNSUBSCRIBE_GROUP as u } from "../../../enums/unsubscribe.js";
5
+ import { DEFAULT_UNSUBSCRIBE_GROUP as c } from "../../../enums/unsubscribe.js";
6
6
  import { Control as h, UIElementType as i, UEAttr as t, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
- const m = "ui-elements-checkbox", a = "select", { get: C } = L();
7
+ const m = "ui-elements-checkbox", u = "select", { get: C } = L();
8
8
  class S extends h {
9
9
  constructor() {
10
10
  super(...arguments);
@@ -16,14 +16,15 @@ class S extends h {
16
16
  return m;
17
17
  }
18
18
  _setFormValues() {
19
- if (this.currentNode && "getAttribute" in this.currentNode) {
19
+ if (this.selectedUnsubGroup = "", this.currentNode && "getAttribute" in this.currentNode) {
20
20
  const e = this.currentNode.getAttribute("id");
21
21
  if (e) {
22
- const s = e === u.sendGridId ? e : Number(e);
23
- s && (this.selectedUnsubGroup = s, this.api.updateValues({
24
- [a]: this.selectedUnsubGroup
25
- }));
22
+ const s = e === c.sendGridId ? e : Number(e);
23
+ s && (this.selectedUnsubGroup = s);
26
24
  }
25
+ this.api.updateValues({
26
+ [u]: this.selectedUnsubGroup
27
+ });
27
28
  }
28
29
  }
29
30
  _getLabel(e, s = `${Math.random()}`) {
@@ -54,7 +55,7 @@ class S extends h {
54
55
  </${i.LABEL}>
55
56
 
56
57
  <${i.SELECTPICKER}
57
- ${t.SELECTPICKER.name}="${a}"
58
+ ${t.SELECTPICKER.name}="${u}"
58
59
  ${t.SELECTPICKER.placeholder}="${this.api.translate("Select Unsubscribe Group")}">
59
60
  ${this._getSelect()}
60
61
  </${i.SELECTPICKER}>
@@ -66,21 +67,21 @@ class S extends h {
66
67
  this.currentNode && this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute("id", e.toString()).apply(new p(`Updated text to ${e}`));
67
68
  }
68
69
  _listenToFormUpdates() {
69
- this.api.onValueChanged(a, (e) => this._onSelectChange(e));
70
+ this.api.onValueChanged(u, (e) => this._onSelectChange(e));
70
71
  }
71
72
  onTemplateNodeUpdated(e) {
72
- this.currentNode = e;
73
+ this.currentNode = e, this._setFormValues();
73
74
  }
74
75
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
75
76
  async onRender() {
76
77
  const e = await C(
77
78
  "/unsubscribe-groups/unsubscribe-list"
78
- ), s = [u, ...e.data], E = s.map((c) => ({
79
- [t.SELECT_ITEM.text]: c.name,
80
- [t.SELECT_ITEM.value]: c.sendGridId
79
+ ), s = [c, ...e.data], E = s.map((a) => ({
80
+ [t.SELECT_ITEM.text]: a.name,
81
+ [t.SELECT_ITEM.value]: a.sendGridId
81
82
  }));
82
83
  this.unsubList = s, this.api.setUIEAttribute(
83
- a,
84
+ u,
84
85
  t.SELECTPICKER.items,
85
86
  E
86
87
  ), this._setFormValues(), this._listenToFormUpdates();
@@ -2,10 +2,10 @@ var d = Object.defineProperty;
2
2
  var l = (r, n, t) => n in r ? d(r, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[n] = t;
3
3
  var o = (r, n, t) => l(r, typeof n != "symbol" ? n + "" : n, t);
4
4
  import { useHttp as L } from "../../../composables/useHttp.js";
5
- import { DEFAULT_UNSUBSCRIBE_GROUP as E } from "../../../enums/unsubscribe.js";
5
+ import { DEFAULT_UNSUBSCRIBE_GROUP as c } from "../../../enums/unsubscribe.js";
6
6
  import { Control as p, UIElementType as i, UEAttr as e, ModificationDescription as h } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
- const m = "ui-elements-radio-button", a = "select", { get: $ } = L();
8
- class _ extends p {
7
+ const m = "ui-elements-radio-button", u = "select", { get: $ } = L();
8
+ class S extends p {
9
9
  constructor() {
10
10
  super(...arguments);
11
11
  o(this, "currentNode");
@@ -16,15 +16,16 @@ class _ extends p {
16
16
  return m;
17
17
  }
18
18
  _setFormValues() {
19
- if (this.currentNode && "getAttribute" in this.currentNode) {
19
+ if (this.selectedUnsubGroup = "", this.currentNode && "getAttribute" in this.currentNode) {
20
20
  const t = this.currentNode.getAttribute("id");
21
21
  if (t) {
22
- const s = t === E.sendGridId ? t : Number(t);
23
- s && (this.selectedUnsubGroup = s, this.api.updateValues({
24
- [a]: this.selectedUnsubGroup
25
- }));
22
+ const s = t === c.sendGridId ? t : Number(t);
23
+ s && (this.selectedUnsubGroup = s);
26
24
  }
27
25
  }
26
+ this.api.updateValues({
27
+ [u]: this.selectedUnsubGroup
28
+ });
28
29
  }
29
30
  _getLabel(t, s = `${Math.random()}`) {
30
31
  return `
@@ -54,7 +55,7 @@ class _ extends p {
54
55
  </${i.LABEL}>
55
56
 
56
57
  <${i.SELECTPICKER}
57
- ${e.SELECTPICKER.name}="${a}"
58
+ ${e.SELECTPICKER.name}="${u}"
58
59
  ${e.SELECTPICKER.placeholder}="${this.api.translate("Select Unsubscribe Group")}">
59
60
  ${this._getSelect()}
60
61
  </${i.SELECTPICKER}>
@@ -66,27 +67,27 @@ class _ extends p {
66
67
  this.currentNode && this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute("id", t.toString()).apply(new h(`Updated text to ${t}`));
67
68
  }
68
69
  _listenToFormUpdates() {
69
- this.api.onValueChanged(a, (t) => this._onSelectChange(t));
70
+ this.api.onValueChanged(u, (t) => this._onSelectChange(t));
70
71
  }
71
72
  onTemplateNodeUpdated(t) {
72
- this.currentNode = t;
73
+ this.currentNode = t, this._setFormValues();
73
74
  }
74
75
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
75
76
  async onRender() {
76
77
  const t = await $(
77
78
  "/unsubscribe-groups/unsubscribe-list"
78
- ), s = [E, ...t.data], c = s.map((u) => ({
79
- [e.SELECT_ITEM.text]: u.name,
80
- [e.SELECT_ITEM.value]: u.sendGridId
79
+ ), s = [c, ...t.data], E = s.map((a) => ({
80
+ [e.SELECT_ITEM.text]: a.name,
81
+ [e.SELECT_ITEM.value]: a.sendGridId
81
82
  }));
82
83
  this.unsubList = s, this.api.setUIEAttribute(
83
- a,
84
+ u,
84
85
  e.SELECTPICKER.items,
85
- c
86
+ E
86
87
  ), this._setFormValues(), this._listenToFormUpdates();
87
88
  }
88
89
  }
89
90
  export {
90
91
  m as CONTROL_BLOCK_ID,
91
- _ as RadioButtonControl
92
+ S as RadioButtonControl
92
93
  };