@useinsider/guido 3.7.0-beta.830822b → 3.7.0-beta.a1aaf44

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.
@@ -16,7 +16,7 @@ var o = function() {
16
16
  i,
17
17
  !1,
18
18
  null,
19
- "df672485"
19
+ "1b31027d"
20
20
  );
21
21
  const _ = c.exports;
22
22
  export {
@@ -1,15 +1,16 @@
1
- import { defineComponent as g, ref as y, computed as n, watch as S } from "vue";
2
- import T from "../../wrappers/WpDrawer.vue.js";
3
- import { useToaster as v } from "../../../composables/useToaster.js";
1
+ import { defineComponent as y, ref as S, computed as a, watch as T } from "vue";
2
+ import v from "../../wrappers/WpDrawer.vue.js";
3
+ import { useToaster as w } from "../../../composables/useToaster.js";
4
4
  import { useTranslations as B } from "../../../composables/useTranslations.js";
5
5
  import { ToasterTypeOptions as C } from "../../../enums/toaster.js";
6
- import { useUnsubscribeStore as w } from "../../../stores/unsubscribe.js";
7
- import { InContainer as h } from "@useinsider/design-system-vue";
8
- import U from "./UnsubscribeBreadcrumb.vue.js";
9
- const F = /* @__PURE__ */ g({
6
+ import { useEditorStore as P } from "../../../stores/editor.js";
7
+ import { useUnsubscribeStore as h } from "../../../stores/unsubscribe.js";
8
+ import { InContainer as U } from "@useinsider/design-system-vue";
9
+ import _ from "./UnsubscribeBreadcrumb.vue.js";
10
+ const G = /* @__PURE__ */ y({
10
11
  __name: "UnsubscribePageSelection",
11
- setup(P) {
12
- const s = B(), e = w(), { showToaster: a } = v(), o = y(!1), c = n(() => e.isActiveTypeLastInCollection ? o.value ? s("unsubscription-preference.applying-changes") : s("statistics.apply") : s("products.select-and-continue")), i = n(() => e.pageSelectionUpdateStatus && e.isActiveTypeFirstInCollection ? s("products.cancel") : s("newsletter.back")), u = n(() => ({
12
+ setup(x) {
13
+ const s = B(), e = h(), r = P(), { showToaster: i } = w(), o = S(!1), c = a(() => e.isActiveTypeLastInCollection ? o.value ? s("unsubscription-preference.applying-changes") : s("statistics.apply") : s("products.select-and-continue")), l = a(() => e.pageSelectionUpdateStatus && e.isActiveTypeFirstInCollection ? s("products.cancel") : s("newsletter.back")), p = a(() => ({
13
14
  primaryButton: {
14
15
  styling: "solid",
15
16
  type: "primary",
@@ -20,45 +21,47 @@ const F = /* @__PURE__ */ g({
20
21
  cancelOrBackButton: {
21
22
  styling: "ghost",
22
23
  type: "secondary",
23
- labelText: i.value,
24
+ labelText: l.value,
24
25
  disabledStatus: o.value
25
26
  }
26
- })), p = (t) => e.getSelectedTemplateByActiveType === t ? "bor-w-3 bor-s-s bor-c-7" : "bor-w-1 bor-s-s bor-c-6", r = (t) => {
27
+ })), d = (t) => e.getSelectedTemplateByActiveType === t ? "bor-w-3 bor-s-s bor-c-7" : "bor-w-1 bor-s-s bor-c-6", n = (t) => {
27
28
  e.pageSelectionDrawerStatus = !1, t && setTimeout(() => {
28
29
  t();
29
30
  }, 500);
30
- }, d = () => {
31
+ }, m = () => {
31
32
  if (e.isActiveTypeFirstInCollection) {
32
- r(), e.pageSelectionUpdateStatus || (e.typeSelectionDrawerStatus = !0);
33
+ n(), e.pageSelectionUpdateStatus || (e.typeSelectionDrawerStatus = !0);
33
34
  return;
34
35
  }
35
36
  e.setPreviousType();
36
- }, m = () => {
37
- if (e.isActiveTypeLastInCollection) {
38
- o.value = !0;
39
- const t = e.selectedCollectionType, l = e.getSelectedTemplatesByCollection(t), f = e.getSelectedUnsubscribePagesByCollection(t);
40
- e.removeUnsubscribePages(f), e.addUnsubscribePages(l), document.dispatchEvent(new CustomEvent("unsubscribe:select", {
41
- detail: {
42
- collectionType: t,
43
- selectedPages: l
44
- }
45
- })), r(() => {
46
- o.value = !1, a({
47
- type: C.Success,
48
- message: s("global-unsubscribe.pages-were-attached")
37
+ }, b = () => {
38
+ if (!r.isPreviewModeOpen) {
39
+ if (e.isActiveTypeLastInCollection) {
40
+ o.value = !0;
41
+ const t = e.selectedCollectionType, u = e.getSelectedTemplatesByCollection(t), g = e.getSelectedUnsubscribePagesByCollection(t);
42
+ e.removeUnsubscribePages(g), e.addUnsubscribePages(u), document.dispatchEvent(new CustomEvent("unsubscribe:select", {
43
+ detail: {
44
+ collectionType: t,
45
+ selectedPages: u
46
+ }
47
+ })), n(() => {
48
+ o.value = !1, i({
49
+ type: C.Success,
50
+ message: s("global-unsubscribe.pages-were-attached")
51
+ });
49
52
  });
50
- });
51
- return;
53
+ return;
54
+ }
55
+ e.setNextType();
52
56
  }
53
- e.setNextType();
54
- }, b = (t) => {
55
- e.setSelectedTemplate(t);
57
+ }, f = (t) => {
58
+ r.isPreviewModeOpen || e.setSelectedTemplate(t);
56
59
  };
57
- return S(() => e.pageSelectionDrawerStatus, (t) => {
60
+ return T(() => e.pageSelectionDrawerStatus, (t) => {
58
61
  t && e.pageSelectionUpdateStatus && e.fetchTemplates();
59
- }), { __sfc: !0, trans: s, unsubscribeStore: e, showToaster: a, isApplying: o, getPrimaryButtonText: c, getCancelOrBackButtonText: i, footerButtonGroupOptions: u, getBorderClass: p, closeModal: r, handleBack: d, handleSave: m, selectTemplate: b, WpDrawer: T, InContainer: h, UnsubscribeBreadcrumb: U };
62
+ }), { __sfc: !0, trans: s, unsubscribeStore: e, editorStore: r, showToaster: i, isApplying: o, getPrimaryButtonText: c, getCancelOrBackButtonText: l, footerButtonGroupOptions: p, getBorderClass: d, closeModal: n, handleBack: m, handleSave: b, selectTemplate: f, WpDrawer: v, InContainer: U, UnsubscribeBreadcrumb: _ };
60
63
  }
61
64
  });
62
65
  export {
63
- F as default
66
+ G as default
64
67
  };
@@ -10,7 +10,7 @@ var i = function() {
10
10
  r,
11
11
  !1,
12
12
  null,
13
- "43c617a7"
13
+ "811cff80"
14
14
  );
15
15
  const _ = c.exports;
16
16
  export {
@@ -1,106 +1,109 @@
1
- import { defineComponent as h, ref as b, computed as g, watch as _ } from "vue";
1
+ import { defineComponent as _, ref as b, computed as m, watch as h } from "vue";
2
2
  import v from "../../wrappers/WpDrawer.vue.js";
3
3
  import { useToaster as U } from "../../../composables/useToaster.js";
4
- import { useTranslations as N } from "../../../composables/useTranslations.js";
5
- import { ACADEMY_LINKS as w } from "../../../enums/academy.js";
6
- import { ToasterTypeOptions as R } from "../../../enums/toaster.js";
7
- import { PAGE_TYPES as l, getTypeTranslations as D, UNSUBSCRIBE_PAGES_LINK as I } from "../../../enums/unsubscribe.js";
8
- import { useUnsubscribeStore as P } from "../../../stores/unsubscribe.js";
9
- import { InSegments as G } from "@useinsider/design-system-vue";
10
- const V = /* @__PURE__ */ h({
4
+ import { useTranslations as w } from "../../../composables/useTranslations.js";
5
+ import { ACADEMY_LINKS as N } from "../../../enums/academy.js";
6
+ import { ToasterTypeOptions as I } from "../../../enums/toaster.js";
7
+ import { PAGE_TYPES as l, getTypeTranslations as R, UNSUBSCRIBE_PAGES_LINK as D } from "../../../enums/unsubscribe.js";
8
+ import { useUnsubscribeStore as L } from "../../../stores/unsubscribe.js";
9
+ import { InSegments as P } from "@useinsider/design-system-vue";
10
+ const V = /* @__PURE__ */ _({
11
11
  __name: "UnsubscribeTypeSelection",
12
- setup(L) {
13
- const e = N(), { showToaster: f } = U(), t = P(), n = b(!1), i = b(!0), o = b(l.GLOBAL_UNSUBSCRIBE), S = e(
12
+ setup(G) {
13
+ const t = w(), { showToaster: f } = U(), e = L(), n = b(!1), o = b(!0), r = b(l.GLOBAL_UNSUBSCRIBE), S = t(
14
14
  "unsubscription-preference.select-unsubscribe-page-description",
15
- { action: `<a href="${w.GLOBAL_UNSUBSCRIBE}" target="_blank">${e("ds-rules.visit-academy")}</a>` }
16
- ), T = g(() => [
15
+ { action: `<a href="${N.GLOBAL_UNSUBSCRIBE}" target="_blank">${t("ds-rules.visit-academy")}</a>` }
16
+ ), T = m(() => [
17
17
  {
18
- description: e("unsubscription-preference.type-global-unsubscribe-description"),
18
+ description: t("unsubscription-preference.type-global-unsubscribe-description"),
19
19
  icon: "line-contact-global-unsub-page",
20
- text: e("unsubscription-preference.type-global-unsubscribe"),
20
+ text: t("unsubscription-preference.type-global-unsubscribe"),
21
21
  value: l.GLOBAL_UNSUBSCRIBE,
22
- disable: t.isGlobalUnsubscribeDisabled,
22
+ disable: e.isGlobalUnsubscribeDisabled,
23
23
  position: "bottom",
24
- tooltipText: t.isGlobalUnsubscribeDisabled ? e("unsubscription-preference.global-unsub-added") : ""
24
+ tooltipText: e.isGlobalUnsubscribeDisabled ? t("unsubscription-preference.global-unsub-added") : ""
25
25
  },
26
26
  {
27
- description: e("unsubscription-preference.type-subscription-preferences-center-description"),
27
+ description: t("unsubscription-preference.type-subscription-preferences-center-description"),
28
28
  icon: "line-contact-sub-pref-center-page",
29
- text: e("unsubscription-preference.type-subscription-preferences-center"),
29
+ text: t("unsubscription-preference.type-subscription-preferences-center"),
30
30
  value: l.SUBSCRIPTION_PREFERENCE_CENTER,
31
- disable: t.isSubscriptionPreferencesCenterDisabled,
32
- tooltipText: t.isSubscriptionPreferencesCenterDisabled ? e("unsubscription-preference.pref-center-added") : ""
31
+ disable: e.isSubscriptionPreferencesCenterDisabled,
32
+ tooltipText: e.isSubscriptionPreferencesCenterDisabled ? t("unsubscription-preference.pref-center-added") : ""
33
33
  }
34
- ]), y = g(() => ({
34
+ ]), y = m(() => ({
35
35
  primaryButton: {
36
36
  styling: "solid",
37
37
  type: "primary",
38
- labelText: e(
38
+ labelText: t(
39
39
  n.value ? "unsubscription-preference.selecting-type" : "products.select-and-continue"
40
40
  ),
41
41
  loadingStatus: n.value,
42
42
  disabledStatus: !1,
43
- skeletonStatus: i.value,
43
+ skeletonStatus: o.value,
44
44
  skeletonSizing: { width: 168, height: 40 }
45
45
  },
46
46
  cancelOrBackButton: {
47
47
  styling: "ghost",
48
48
  type: "secondary",
49
- labelText: e("products.cancel"),
49
+ labelText: t("products.cancel"),
50
50
  disabledStatus: n.value,
51
- skeletonStatus: i.value,
51
+ skeletonStatus: o.value,
52
52
  skeletonSizing: { width: 78, height: 40 }
53
53
  }
54
54
  })), d = (s) => {
55
- t.typeSelectionDrawerStatus = !1, document.dispatchEvent(new CustomEvent("unsubscribe:cancel")), s && setTimeout(() => {
55
+ e.typeSelectionDrawerStatus = !1, document.dispatchEvent(new CustomEvent("unsubscribe:cancel", {
56
+ detail: { blockId: e.pendingBlockId }
57
+ })), s && setTimeout(() => {
56
58
  s();
57
59
  }, 500);
58
60
  }, E = (s) => {
59
- o.value = s;
60
- }, m = () => {
61
- const s = t.hasTemplatesByCollectionType, r = [];
62
- if (Object.entries(s).forEach(([c, p]) => {
63
- p || r.push(Number(c));
64
- }), r.length === 0)
61
+ r.value = s;
62
+ }, g = () => {
63
+ const s = e.hasTemplatesByCollectionType, a = [];
64
+ if (Object.entries(s).forEach(([i, p]) => {
65
+ p || a.push(Number(i));
66
+ }), a.length === 0)
65
67
  return !0;
66
- const B = D(), a = r.map((c) => B[c]);
68
+ const C = R(), c = a.map((i) => C[i]);
67
69
  let u = "";
68
- if (r.length === 1)
69
- u = e("unsubscription-preference.create-page-to-continue", {
70
- page: a[0]
70
+ if (a.length === 1)
71
+ u = t("unsubscription-preference.create-page-to-continue", {
72
+ page: c[0]
71
73
  });
72
- else if (r.length === 2)
73
- u = e("unsubscription-preference.create-pages-to-continue", {
74
- page1: a[0],
75
- page2: a[1]
74
+ else if (a.length === 2)
75
+ u = t("unsubscription-preference.create-pages-to-continue", {
76
+ page1: c[0],
77
+ page2: c[1]
76
78
  });
77
79
  else {
78
- const c = a.pop() ?? "", p = a.join(", ");
79
- u = e("unsubscription-preference.create-multiple-pages-to-continue", {
80
+ const i = c.pop() ?? "", p = c.join(", ");
81
+ u = t("unsubscription-preference.create-multiple-pages-to-continue", {
80
82
  pages: p,
81
- lastPage: c
83
+ lastPage: i
82
84
  });
83
85
  }
84
86
  return f({
85
- type: R.Warning,
87
+ type: I.Warning,
86
88
  message: u,
87
89
  actionButton: {
88
90
  text: "Go to Unsubscribe Pages",
89
91
  onClick: () => {
90
- window.location.href = I;
92
+ const i = new URL(D, window.location.origin).href;
93
+ window.open(i, "_blank", "noopener");
91
94
  }
92
95
  }
93
96
  }), !1;
94
- }, C = async () => {
95
- if (n.value = !0, await t.fetchTemplates(), t.setCollection(o.value), !m()) {
97
+ }, B = async () => {
98
+ if (n.value = !0, await e.fetchTemplates(!0), e.setCollection(r.value), !g()) {
96
99
  n.value = !1, d();
97
100
  return;
98
101
  }
99
- n.value = !1, t.typeSelectionDrawerStatus = !1, t.pageSelectionDrawerStatus = !0;
102
+ n.value = !1, e.typeSelectionDrawerStatus = !1, e.pageSelectionDrawerStatus = !0;
100
103
  };
101
- return _(() => t.typeSelectionDrawerStatus, (s) => {
102
- s && (i.value = !0, o.value = l.GLOBAL_UNSUBSCRIBE, t.isGlobalUnsubscribeDisabled && (o.value = t.isSubscriptionPreferencesCenterDisabled ? 0 : l.SUBSCRIPTION_PREFERENCE_CENTER), i.value = !1);
103
- }), { __sfc: !0, trans: e, showToaster: f, unsubscribeStore: t, isSelecting: n, skeletonStatus: i, selectedCollection: o, descriptionText: S, segmentList: T, footerButtonGroupOptions: y, closeModal: d, changeCollection: E, validateTemplates: m, selectCollection: C, WpDrawer: v, InSegments: G };
104
+ return h(() => e.typeSelectionDrawerStatus, (s) => {
105
+ s && (o.value = !0, r.value = l.GLOBAL_UNSUBSCRIBE, e.isGlobalUnsubscribeDisabled && (r.value = e.isSubscriptionPreferencesCenterDisabled ? 0 : l.SUBSCRIPTION_PREFERENCE_CENTER), o.value = !1);
106
+ }), { __sfc: !0, trans: t, showToaster: f, unsubscribeStore: e, isSelecting: n, skeletonStatus: o, selectedCollection: r, descriptionText: S, segmentList: T, footerButtonGroupOptions: y, closeModal: d, changeCollection: E, validateTemplates: g, selectCollection: B, WpDrawer: v, InSegments: P };
104
107
  }
105
108
  });
106
109
  export {
@@ -1,8 +1,6 @@
1
1
  import { useTranslations as r } from "../../composables/useTranslations.js";
2
2
  const l = {
3
- RECOMMENDATION_API_URL: "https://recommendationv2.api.useinsider.com",
4
- // Relative path → same-origin as the embedding inone dashboard (Dataforce).
5
- PRODUCT_ATTRIBUTES_PATH: "/product-attributes/get-attributes"
3
+ RECOMMENDATION_API_URL: "https://recommendationv2.api.useinsider.com"
6
4
  }, c = {
7
5
  CLIENT_ID: "clientId"
8
6
  }, d = () => {
@@ -6,8 +6,8 @@ import { DEFAULT_CARDS_IN_ROW as F } from "../constants/layout.js";
6
6
  import { EXCLUDED_ALGORITHM_IDS as D } from "../constants/defaultConfig.js";
7
7
  import { getDefaultProducts as S } from "../templates/utils.js";
8
8
  import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
9
- import { getPartnerRecommendationParams as w } from "../utils/partnerCustomizations.js";
10
- import { isFilterValid as v } from "../validation/filterSchema.js";
9
+ import { getPartnerRecommendationParams as v } from "../utils/partnerCustomizations.js";
10
+ import { isFilterValid as w } from "../validation/filterSchema.js";
11
11
  import { isConfigValid as N } from "../validation/requiredFields.js";
12
12
  const h = y();
13
13
  let m = null, u = null, d = null;
@@ -132,7 +132,7 @@ const x = () => ({
132
132
  value: e.text
133
133
  })),
134
134
  getFilterList() {
135
- return Object.values(this.filterList).filter((t) => t.isFilterable !== 0 && t.isFilterable !== !1).map((t) => {
135
+ return Object.values(this.filterList).map((t) => {
136
136
  let e;
137
137
  return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : C.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
138
138
  text: t.displayName,
@@ -379,7 +379,7 @@ const x = () => ({
379
379
  const n = [...e.recommendationConfigs.filters];
380
380
  n[r] = {
381
381
  ...t,
382
- isValid: v(t)
382
+ isValid: w(t)
383
383
  }, e.recommendationConfigs.filters = n;
384
384
  }
385
385
  },
@@ -456,7 +456,7 @@ const x = () => ({
456
456
  };
457
457
  r.strategy === "manualMerchandising" ? a.productId = r.productIds.join(",") : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), c && (a.filter = c), r.shuffleProducts && (a.shuffle = !0), Object.assign(
458
458
  a,
459
- w(o.partnerName, r.strategy)
459
+ v(o.partnerName, r.strategy)
460
460
  );
461
461
  let f;
462
462
  try {
@@ -1,39 +1,40 @@
1
- var g = Object.defineProperty;
2
- var k = (c, n, e) => n in c ? g(c, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[n] = e;
3
- var l = (c, n, e) => k(c, typeof n != "symbol" ? n + "" : n, e);
1
+ var m = Object.defineProperty;
2
+ var k = (c, n, e) => n in c ? m(c, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[n] = e;
3
+ var a = (c, n, e) => k(c, typeof n != "symbol" ? n + "" : n, e);
4
4
  import { useToaster as B } from "../../../composables/useToaster.js";
5
5
  import { ToasterTypeOptions as S } from "../../../enums/toaster.js";
6
6
  import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
7
- import { useUnsubscribeStore as a } from "../../../stores/unsubscribe.js";
8
- import { Block as L, BlockCompositionType as f, ContextActionType as h, ModificationDescription as b, BlockType as v } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
9
- import { getDefaultTemplate as A } from "./template.js";
7
+ import { useEditorStore as f } from "../../../stores/editor.js";
8
+ import { useUnsubscribeStore as l } from "../../../stores/unsubscribe.js";
9
+ import { Block as L, BlockCompositionType as A, ContextActionType as h, ModificationDescription as b, BlockType as v } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
10
+ import { getDefaultTemplate as I } from "./template.js";
10
11
  import { DATA_ATTRIBUTES as i, UNSUBSCRIBE_EVENTS as d } from "./utils/constants.js";
11
12
  import { parsePageList as p } from "./utils/utils.js";
12
- const y = "unsubscribe-block", m = 'a[data-unsubscribe-link="true"]', _ = ".unsubscribe-block-v2", I = "{{ins-unsubscribe-link}}", T = "https://academy.insiderone.com/docs/adding-unsubscribe-pages-into-emails", C = "Removing the unsubscribe text leaves an empty block, but an active unsubscribe link is required. Undo your last action to restore the text, or delete the unsubscribe block entirely.", N = {
13
+ const T = "unsubscribe-block", g = 'a[data-unsubscribe-link="true"]', _ = ".unsubscribe-block-v2", y = "{{ins-unsubscribe-link}}", C = "https://academy.insiderone.com/docs/adding-unsubscribe-pages-into-emails", N = "Removing the unsubscribe text leaves an empty block, but an active unsubscribe link is required. Undo your last action to restore the text, or delete the unsubscribe block entirely.", U = {
13
14
  [E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
14
15
  [E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
15
16
  };
16
- class F extends L {
17
+ class K extends L {
17
18
  constructor() {
18
19
  super();
19
- l(this, "selectEventListener", null);
20
- l(this, "cancelEventListener", null);
21
- l(this, "currentNode");
20
+ a(this, "selectEventListener", null);
21
+ a(this, "cancelEventListener", null);
22
+ a(this, "currentNode");
22
23
  // Per-block "did this instance have a link last time we saw it?" tracking.
23
24
  // Keyed by the stable `data-unsubscribe-block-id` we assign, because
24
25
  // ImmutableHtmlNode instances are recreated on every document mutation and
25
26
  // can't be used as Map keys directly. A singleton boolean here would be
26
27
  // polluted across blocks since Stripo fires onDocumentChanged per-instance.
27
- l(this, "linkStateByBlockId", /* @__PURE__ */ new Map());
28
+ a(this, "linkStateByBlockId", /* @__PURE__ */ new Map());
28
29
  }
29
30
  getId() {
30
- return y;
31
+ return T;
31
32
  }
32
33
  getIcon() {
33
34
  return "unsubscribe-icon";
34
35
  }
35
36
  getBlockCompositionType() {
36
- return f.BLOCK;
37
+ return A.BLOCK;
37
38
  }
38
39
  getName() {
39
40
  return this.api.translate("Unsubscribe Block");
@@ -42,37 +43,49 @@ class F extends L {
42
43
  return this.api.translate("Unsubscribe Block Description");
43
44
  }
44
45
  getTemplate() {
45
- return A();
46
+ return I();
46
47
  }
47
48
  getContextActionsIds() {
48
49
  return [h.MOVE, h.REMOVE];
49
50
  }
50
51
  onSelect(e) {
51
- this.currentNode = e;
52
- const t = this._getOrAssignBlockId(e);
53
- t && this.linkStateByBlockId.set(t, this._hasUnsubscribeLink(e)), !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
52
+ if (this.currentNode = e, f().isPreviewModeOpen)
53
+ return;
54
+ const r = this._readBlockId(e) !== null, t = this._getOrAssignBlockId(e);
55
+ t && this.linkStateByBlockId.set(t, this._hasUnsubscribeLink(e)), !("getAttribute" in e && e.getAttribute("data-migration")) && (r && !this._hasPageSelection(e) || (this._resetStoreState(), t && (l().pendingBlockId = t), this._loadBlockState(e), this._setupSelectEventListener(), this._setupCancelEventListener(t), this._checkExistingBlocks(), this._openDrawer()));
54
56
  }
55
57
  onDocumentChanged(e) {
56
- const t = this._getOrAssignBlockId(e);
57
- if (!t)
58
+ const r = this._getOrAssignBlockId(e);
59
+ if (!r)
58
60
  return;
59
- const r = this._hasUnsubscribeLink(e);
60
- this.linkStateByBlockId.get(t) === !0 && !r && this._warnLinkRemoved(), this.linkStateByBlockId.set(t, r);
61
+ const t = this._hasUnsubscribeLink(e);
62
+ this.linkStateByBlockId.get(r) === !0 && !t && this._warnLinkRemoved(), this.linkStateByBlockId.set(r, t);
61
63
  }
62
64
  onDelete(e) {
63
65
  this._removeEventListeners(), this._removeBlockTemplatesFromStore(e), this._resetStoreState();
64
- const t = this._readBlockId(e);
65
- t && this.linkStateByBlockId.delete(t);
66
+ const r = this._readBlockId(e);
67
+ r && this.linkStateByBlockId.delete(r);
66
68
  }
67
69
  onDestroy() {
68
70
  this._removeEventListeners(), this.currentNode = void 0, this.linkStateByBlockId.clear();
69
71
  }
70
72
  _hasUnsubscribeLink(e) {
71
- return "querySelector" in e ? !!e.querySelector(m) : !1;
73
+ return "querySelector" in e ? !!e.querySelector(g) : !1;
72
74
  }
73
75
  _readBlockId(e) {
74
76
  return "getAttribute" in e ? e.getAttribute(i.BLOCK_ID) : null;
75
77
  }
78
+ /**
79
+ * True when the block has a page type and a page list — i.e. a template was
80
+ * applied. A block with neither, combined with an already-present block id,
81
+ * is an undo-restored orphan of a cancelled block.
82
+ */
83
+ _hasPageSelection(e) {
84
+ if (!("getAttribute" in e))
85
+ return !1;
86
+ const r = e.getAttribute(i.PAGE_TYPE), t = e.getAttribute(i.PAGE_LIST);
87
+ return !!r && !!t;
88
+ }
76
89
  /**
77
90
  * Returns the block's stable id, assigning one via the document modifier if
78
91
  * the node has not been tagged yet. Idempotent: subsequent calls during
@@ -80,18 +93,18 @@ class F extends L {
80
93
  * `apply()`) short-circuit on the existing attribute.
81
94
  */
82
95
  _getOrAssignBlockId(e) {
83
- const t = this._readBlockId(e);
84
- if (t)
85
- return t;
96
+ const r = this._readBlockId(e);
97
+ if (r)
98
+ return r;
86
99
  if (!("getAttribute" in e))
87
100
  return null;
88
- const r = this._generateNextBlockId();
101
+ const t = this._generateNextBlockId();
89
102
  try {
90
- this.api.getDocumentModifier().modifyHtml(e).setAttribute(i.BLOCK_ID, r).apply(new b(`Assign unsubscribe block id ${r}`));
103
+ this.api.getDocumentModifier().modifyHtml(e).setAttribute(i.BLOCK_ID, t).apply(new b(`Assign unsubscribe block id ${t}`));
91
104
  } catch (s) {
92
105
  return console.warn("[UnsubscribeBlock] Failed to assign block id:", s), null;
93
106
  }
94
- return r;
107
+ return t;
95
108
  }
96
109
  /**
97
110
  * Generates a unique id by scanning the document for the highest existing
@@ -101,8 +114,8 @@ class F extends L {
101
114
  _generateNextBlockId() {
102
115
  let e = 0;
103
116
  try {
104
- const t = this.api.getDocumentRoot();
105
- t && "querySelectorAll" in t && t.querySelectorAll(_).forEach((s) => {
117
+ const r = this.api.getDocumentRoot();
118
+ r && "querySelectorAll" in r && r.querySelectorAll(_).forEach((s) => {
106
119
  if ("getAttribute" in s) {
107
120
  const o = s.getAttribute(i.BLOCK_ID), u = o ? parseInt(o) : 0;
108
121
  u > e && (e = u);
@@ -117,11 +130,11 @@ class F extends L {
117
130
  const { showToaster: e } = B();
118
131
  e({
119
132
  type: S.Warning,
120
- message: this.api.translate(C),
133
+ message: this.api.translate(N),
121
134
  actionButton: {
122
135
  text: this.api.translate("Visit Academy"),
123
136
  onClick: () => {
124
- window.open(T, "_blank", "noopener,noreferrer");
137
+ window.open(C, "_blank", "noopener,noreferrer");
125
138
  }
126
139
  }
127
140
  });
@@ -131,16 +144,17 @@ class F extends L {
131
144
  }
132
145
  _setupSelectEventListener() {
133
146
  this._removeSelectEventListener(), this.selectEventListener = (e) => {
134
- const t = e, { collectionType: r, selectedPages: s } = t.detail;
135
- this._updateBlock(r, s.join(","));
147
+ const r = e, { collectionType: t, selectedPages: s } = r.detail;
148
+ this._updateBlock(t, s.join(","));
136
149
  }, document.addEventListener(d.SELECT, this.selectEventListener);
137
150
  }
138
151
  _removeSelectEventListener() {
139
152
  this.selectEventListener && (document.removeEventListener(d.SELECT, this.selectEventListener), this.selectEventListener = null);
140
153
  }
141
- _setupCancelEventListener() {
142
- this._removeCancelEventListener(), this.cancelEventListener = () => {
143
- this._handleCancel();
154
+ _setupCancelEventListener(e) {
155
+ this._removeCancelEventListener(), this.cancelEventListener = (r) => {
156
+ const { detail: t } = r, s = (t == null ? void 0 : t.blockId) ?? null;
157
+ s !== null && s !== e || this._handleCancel();
144
158
  }, document.addEventListener(d.CANCEL, this.cancelEventListener);
145
159
  }
146
160
  _removeCancelEventListener() {
@@ -158,32 +172,32 @@ class F extends L {
158
172
  _removeEventListeners() {
159
173
  this._removeSelectEventListener(), this._removeCancelEventListener();
160
174
  }
161
- _updateBlock(e, t) {
175
+ _updateBlock(e, r) {
162
176
  if (!this.currentNode || !("querySelector" in this.currentNode))
163
177
  return;
164
- const r = this.currentNode.querySelector(m);
165
- if (!r)
178
+ const t = this.currentNode.querySelector(g);
179
+ if (!t)
166
180
  return;
167
181
  const s = this._getMergeTag(e);
168
- this.api.getDocumentModifier().modifyHtml(r).setAttribute("href", s).apply(new b(`Updated unsubscribe link to ${s}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(i.PAGE_TYPE, e.toString()).setAttribute(i.PAGE_LIST, t).apply(new b("Updated unsubscribe block metadata"));
182
+ this.api.getDocumentModifier().modifyHtml(t).setAttribute("href", s).apply(new b(`Updated unsubscribe link to ${s}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(i.PAGE_TYPE, e.toString()).setAttribute(i.PAGE_LIST, r).apply(new b("Updated unsubscribe block metadata"));
169
183
  }
170
184
  _getMergeTag(e) {
171
- return N[e] ?? I;
185
+ return U[e] ?? y;
172
186
  }
173
187
  _openDrawer() {
174
188
  if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
175
189
  try {
176
- const e = a();
190
+ const e = l();
177
191
  e.typeSelectionDrawerStatus = !0;
178
192
  } catch (e) {
179
193
  console.error("[UnsubscribeBlock] Failed to open drawer:", e);
180
194
  }
181
195
  }
182
196
  _checkExistingBlocks() {
183
- const e = a();
184
- e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(_).forEach((r) => {
185
- if ("getAttribute" in r) {
186
- const s = r.getAttribute(i.PAGE_TYPE);
197
+ const e = l();
198
+ e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(_).forEach((t) => {
199
+ if ("getAttribute" in t) {
200
+ const s = t.getAttribute(i.PAGE_TYPE);
187
201
  if (s) {
188
202
  const o = Number(s);
189
203
  o === E.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : o === E.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
@@ -194,26 +208,26 @@ class F extends L {
194
208
  async _loadBlockState(e) {
195
209
  if (!("getAttribute" in e))
196
210
  return;
197
- const t = e.getAttribute(i.PAGE_TYPE), r = e.getAttribute(i.PAGE_LIST);
198
- if (!t || !r)
211
+ const r = e.getAttribute(i.PAGE_TYPE), t = e.getAttribute(i.PAGE_LIST);
212
+ if (!r || !t)
199
213
  return;
200
- const s = a(), o = Number(t), u = p(r);
214
+ const s = l(), o = Number(r), u = p(t);
201
215
  await s.fetchTemplates(), s.setCollectionWithoutAutoSelection(o), s.loadSelectedTemplates(u);
202
216
  }
203
217
  _resetStoreState() {
204
- a().$reset();
218
+ l().$reset();
205
219
  }
206
220
  _removeBlockTemplatesFromStore(e) {
207
221
  if (!("getAttribute" in e))
208
222
  return;
209
- const t = e.getAttribute(i.PAGE_LIST);
210
- if (!t)
223
+ const r = e.getAttribute(i.PAGE_LIST);
224
+ if (!r)
211
225
  return;
212
- const r = a(), s = p(t);
213
- r.removeUnsubscribePages(s);
226
+ const t = l(), s = p(r);
227
+ t.removeUnsubscribePages(s);
214
228
  }
215
229
  }
216
230
  export {
217
- y as UNSUBSCRIBE_BLOCK_ID,
218
- F as UnsubscribeBlock
231
+ T as UNSUBSCRIBE_BLOCK_ID,
232
+ K as UnsubscribeBlock
219
233
  };
@@ -1,10 +1,11 @@
1
- var d = Object.defineProperty;
2
- var h = (a, s, e) => s in a ? d(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e;
3
- var u = (a, s, e) => h(a, typeof s != "symbol" ? s + "" : s, e);
1
+ var T = Object.defineProperty;
2
+ var p = (a, s, e) => s in a ? T(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e;
3
+ var c = (a, s, e) => p(a, typeof s != "symbol" ? s + "" : s, e);
4
+ import { useEditorStore as _ } from "../../../stores/editor.js";
4
5
  import { useUnsubscribeStore as l } from "../../../stores/unsubscribe.js";
5
- import { Control as T, UEAttr as i, UIElementType as n } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
- import { DATA_ATTRIBUTES as p } from "./utils/constants.js";
7
- import { parsePageList as _ } from "./utils/utils.js";
6
+ import { Control as g, UEAttr as i, UIElementType as n } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
+ import { DATA_ATTRIBUTES as d } from "./utils/constants.js";
8
+ import { parsePageList as h } from "./utils/utils.js";
8
9
  const v = "ui-elements-unsubscribe", r = {
9
10
  SELECT_BUTTON: "selectTemplateButton",
10
11
  PREV_BUTTON: "prevButton",
@@ -12,14 +13,14 @@ const v = "ui-elements-unsubscribe", r = {
12
13
  COUNTER_TEXT: "counterText",
13
14
  PREVIEW_IMAGE: "previewImage"
14
15
  };
15
- class B extends T {
16
+ class w extends g {
16
17
  constructor() {
17
18
  super(...arguments);
18
- u(this, "currentPreviewIndex", 0);
19
- u(this, "currentNode");
20
- u(this, "currentPages");
21
- u(this, "valueChangeHandlers", []);
22
- u(this, "lastParsedAttribute");
19
+ c(this, "currentPreviewIndex", 0);
20
+ c(this, "currentNode");
21
+ c(this, "currentPages");
22
+ c(this, "valueChangeHandlers", []);
23
+ c(this, "lastParsedAttribute");
23
24
  }
24
25
  getId() {
25
26
  return v;
@@ -34,8 +35,8 @@ class B extends T {
34
35
  }
35
36
  onTemplateNodeUpdated(e) {
36
37
  if (this.currentNode = e, "getAttribute" in this.currentNode) {
37
- const t = this.currentNode.getAttribute(p.PAGE_LIST);
38
- t && (t !== this.lastParsedAttribute && (this.currentPages = _(t), this.lastParsedAttribute = t, this.currentPreviewIndex = 0), this._updateCounter(), this._loadAndUpdatePreview());
38
+ const t = this.currentNode.getAttribute(d.PAGE_LIST);
39
+ t && (t !== this.lastParsedAttribute && (this.currentPages = h(t), this.lastParsedAttribute = t, this.currentPreviewIndex = 0), this._updateCounter(), this._loadAndUpdatePreview());
39
40
  }
40
41
  }
41
42
  onRender() {
@@ -61,12 +62,20 @@ class B extends T {
61
62
  }
62
63
  _onButtonClick() {
63
64
  try {
65
+ if (_().isPreviewModeOpen)
66
+ return;
64
67
  const e = l();
65
- e.activeType = e.getSelectedCollection[this.currentPreviewIndex], e.pageSelectionUpdateStatus = !0, e.pageSelectionDrawerStatus = !0;
68
+ this._reseedSelectionFromBlock(e), e.activeType = e.getSelectedCollection[this.currentPreviewIndex], e.pageSelectionUpdateStatus = !0, e.pageSelectionDrawerStatus = !0;
66
69
  } catch (e) {
67
70
  console.error("[UnsubscribeControl] Failed to open drawer:", e);
68
71
  }
69
72
  }
73
+ _reseedSelectionFromBlock(e) {
74
+ if (!this.currentNode || !("getAttribute" in this.currentNode))
75
+ return;
76
+ const t = this.currentNode.getAttribute(d.PAGE_TYPE), o = this.currentNode.getAttribute(d.PAGE_LIST);
77
+ !t || !o || (e.$reset(), e.setCollectionWithoutAutoSelection(Number(t)), e.loadSelectedTemplates(h(o)));
78
+ }
70
79
  _onPrevClick() {
71
80
  this.currentPreviewIndex > 0 && (this.currentPreviewIndex--, this._updatePreview(), this._updateCounter());
72
81
  }
@@ -80,21 +89,21 @@ class B extends T {
80
89
  var e;
81
90
  if ((e = this.currentPages) != null && e.length)
82
91
  try {
83
- const t = this.currentPages[this.currentPreviewIndex], o = l().getThumbnailByTemplateId(t);
84
- if (!o) {
92
+ const t = this.currentPages[this.currentPreviewIndex], u = l().getThumbnailByTemplateId(t);
93
+ if (!u) {
85
94
  console.warn("[UnsubscribeControl] No thumbnail found for page:", t);
86
95
  return;
87
96
  }
88
97
  this.api.updateValues({
89
- [r.PREVIEW_IMAGE]: o
98
+ [r.PREVIEW_IMAGE]: u
90
99
  });
91
100
  } catch (t) {
92
101
  console.error("[UnsubscribeControl] Failed to update preview:", t);
93
102
  }
94
103
  }
95
104
  _updateCounter() {
96
- const e = this.currentPreviewIndex + 1, t = this.totalTemplates, c = this.currentPreviewIndex === 0, o = this.currentPreviewIndex >= t - 1;
97
- this.api.setUIEAttribute(r.PREV_BUTTON, i.BUTTON.disabled, c), this.api.setUIEAttribute(r.NEXT_BUTTON, i.BUTTON.disabled, o), this.api.setUIEAttribute(
105
+ const e = this.currentPreviewIndex + 1, t = this.totalTemplates, o = this.currentPreviewIndex === 0, u = this.currentPreviewIndex >= t - 1;
106
+ this.api.setUIEAttribute(r.PREV_BUTTON, i.BUTTON.disabled, o), this.api.setUIEAttribute(r.NEXT_BUTTON, i.BUTTON.disabled, u), this.api.setUIEAttribute(
98
107
  r.COUNTER_TEXT,
99
108
  i.LABEL.text,
100
109
  `${this.api.translate("Showing")} ${e} ${this.api.translate("of")} ${t}`
@@ -135,14 +144,14 @@ class B extends T {
135
144
  </${n.LABEL}>
136
145
  `;
137
146
  }
138
- _getIconButton(e, t, c) {
139
- const o = c ? `${i.BUTTON.disabled}="true"` : "";
147
+ _getIconButton(e, t, o) {
148
+ const u = o ? `${i.BUTTON.disabled}="true"` : "";
140
149
  return `
141
150
  <${n.BUTTON}
142
151
  id="${e}"
143
152
  class="flat-inline flat-white"
144
153
  ${i.BUTTON.name}="${e}"
145
- ${o}
154
+ ${u}
146
155
  >
147
156
  <${n.ICON}
148
157
  src="${t}"
@@ -166,5 +175,5 @@ class B extends T {
166
175
  }
167
176
  export {
168
177
  v as UNSUBSCRIBE_CONTROL_ID,
169
- B as UnsubscribeControl
178
+ w as UnsubscribeControl
170
179
  };
package/dist/guido.css CHANGED
@@ -1 +1 @@
1
- .gap-16[data-v-5553d071],.gap-16[data-v-0e1b0c54]{gap:16px}[data-v-73199fa4] .in-button-v2__wrapper{line-height:0}[data-v-22226124] .in-segments-wrapper__button_selected,[data-v-22226124] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb;color:#0010ac;border-color:#0010ac}[data-v-2cb418af] .in-progress-wrapper__progress p span:last-child{display:none!important}[data-v-2cb418af] .in-progress-description-status{display:none!important}.view-options-wrapper[data-v-195ab6d4]{position:relative;display:inline-block}.new-tag[data-v-195ab6d4]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-195ab6d4] .guido__view-option-selection-desktop svg,[data-v-195ab6d4] .guido__view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-195ab6d4] .in-segments-wrapper__button_selected,[data-v-195ab6d4] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-195ab6d4] .in-tooltip-wrapper__icon{cursor:pointer}.editor-toolbar[data-v-173c3a40]{gap:4px}.version-history-item[data-v-ee4b9c3f]{flex-basis:200px}.version-history[data-v-64c52560]{gap:8px}.version-history__toolbar[data-v-64c52560]{gap:4px}.view-options-wrapper[data-v-d405ca59]{position:relative;display:inline-block}.new-tag[data-v-d405ca59]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-d405ca59] .guido__verion-history-view-option-selection-desktop svg,[data-v-d405ca59] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-d405ca59] .in-segments-wrapper__button_selected,[data-v-d405ca59] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-d405ca59] .in-tooltip-wrapper__icon{cursor:pointer}.auto-save-toggle[data-v-2c964af4]{position:relative}.auto-save-toggle__info-box[data-v-2c964af4]{position:absolute;top:100%;left:0;z-index:10;width:280px}.editor-actions[data-v-82128f7d]{gap:4px}.header-wrapper[data-v-5c02dcc7]{min-width:1000px}.guido-loading__wrapper[data-v-07c4b2d8]{height:100%;top:75px!important;bottom:0!important}.guido-editor__wrapper[data-v-50dac6de]{--ribbon-offset: 0px;position:relative;width:100%;height:calc(100vh - 128px - var(--ribbon-offset))}.guido-editor__container[data-v-50dac6de]{width:100%;height:calc(100vh - 128px - var(--ribbon-offset))}.guido-editor__no-header[data-v-50dac6de]{height:calc(100vh - 75px - var(--ribbon-offset))}[data-v-293f1c47] .in-breadcrumb-wrapper__links{cursor:pointer}.templates-wrapper[data-v-df672485]{gap:16px;grid-template-columns:repeat(3,1fr)}.templates-wrapper .template-wrapper[data-v-df672485]{cursor:pointer}.templates-wrapper .template-wrapper .template-container[data-v-df672485]{height:274px;padding:2px;transition:none}.templates-wrapper .template-wrapper .template-container.selected[data-v-df672485]{padding:1px}.templates-wrapper .template-wrapper .template-container .thumbnail[data-v-df672485]{object-fit:cover;transform:scale(1)}[data-v-43c617a7] .guido__verion-history-view-option-selection-desktop svg,[data-v-43c617a7] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-43c617a7] .in-segments-wrapper__button_selected,[data-v-43c617a7] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}.error-list[data-v-c3fd5d4b]{gap:16px}.desktop-browser-header[data-v-d86c5af5]{height:79px;min-height:79px}.desktop-browser-header__left[data-v-d86c5af5]{-webkit-user-drag:none;height:79px;width:378px}.desktop-browser-header__center[data-v-d86c5af5]{height:79px;background-repeat:repeat-x;background-size:auto 100%;background-position:left top}.desktop-browser-header__right[data-v-d86c5af5]{-webkit-user-drag:none;height:79px;width:112px}.desktop-preview[data-v-988f8da6]{min-width:602px;height:70vh;min-height:583px;border-radius:10px}.desktop-preview iframe[data-v-988f8da6]{min-height:504px}.iframe-wrapper[data-v-e0424e99]{width:258px}.iframe-scaled[data-v-e0424e99]{width:320px;height:124.0310077519%;transform:scale(.80625);transform-origin:top left}.cropped-text[data-v-eb3d05d7]{width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mobile-preview-wrapper__phone[data-v-3f472f96]{width:282px}.mobile-preview-wrapper__phone img[data-v-3f472f96]{object-fit:cover;border-radius:44px}.mobile-preview-wrapper__content[data-v-3f472f96]{width:258px;height:450px;left:12px}[data-v-7419ae06] .vueperslides__bullets,[data-v-796d193b] .vueperslides__bullets{pointer-events:none!important}[data-v-796d193b] .vueperslides__parallax-wrapper{height:110px!important}[data-v-cadfc82d] .vueperslides__bullets{pointer-events:none!important}[data-v-cadfc82d] .vueperslides__parallax-wrapper{height:110px!important}
1
+ .gap-16[data-v-5553d071],.gap-16[data-v-0e1b0c54]{gap:16px}[data-v-73199fa4] .in-button-v2__wrapper{line-height:0}[data-v-22226124] .in-segments-wrapper__button_selected,[data-v-22226124] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb;color:#0010ac;border-color:#0010ac}[data-v-2cb418af] .in-progress-wrapper__progress p span:last-child{display:none!important}[data-v-2cb418af] .in-progress-description-status{display:none!important}.view-options-wrapper[data-v-195ab6d4]{position:relative;display:inline-block}.new-tag[data-v-195ab6d4]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-195ab6d4] .guido__view-option-selection-desktop svg,[data-v-195ab6d4] .guido__view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-195ab6d4] .in-segments-wrapper__button_selected,[data-v-195ab6d4] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-195ab6d4] .in-tooltip-wrapper__icon{cursor:pointer}.editor-toolbar[data-v-173c3a40]{gap:4px}.version-history-item[data-v-ee4b9c3f]{flex-basis:200px}.version-history[data-v-64c52560]{gap:8px}.version-history__toolbar[data-v-64c52560]{gap:4px}.view-options-wrapper[data-v-d405ca59]{position:relative;display:inline-block}.new-tag[data-v-d405ca59]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-d405ca59] .guido__verion-history-view-option-selection-desktop svg,[data-v-d405ca59] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-d405ca59] .in-segments-wrapper__button_selected,[data-v-d405ca59] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-d405ca59] .in-tooltip-wrapper__icon{cursor:pointer}.auto-save-toggle[data-v-2c964af4]{position:relative}.auto-save-toggle__info-box[data-v-2c964af4]{position:absolute;top:100%;left:0;z-index:10;width:280px}.editor-actions[data-v-82128f7d]{gap:4px}.header-wrapper[data-v-5c02dcc7]{min-width:1000px}.guido-loading__wrapper[data-v-07c4b2d8]{height:100%;top:75px!important;bottom:0!important}.guido-editor__wrapper[data-v-50dac6de]{--ribbon-offset: 0px;position:relative;width:100%;height:calc(100vh - 128px - var(--ribbon-offset))}.guido-editor__container[data-v-50dac6de]{width:100%;height:calc(100vh - 128px - var(--ribbon-offset))}.guido-editor__no-header[data-v-50dac6de]{height:calc(100vh - 75px - var(--ribbon-offset))}[data-v-293f1c47] .in-breadcrumb-wrapper__links{cursor:pointer}.templates-wrapper[data-v-1b31027d]{gap:16px;grid-template-columns:repeat(3,1fr)}.templates-wrapper .template-wrapper[data-v-1b31027d]{cursor:pointer}.templates-wrapper .template-wrapper .template-container[data-v-1b31027d]{height:274px;padding:2px;transition:none}.templates-wrapper .template-wrapper .template-container.selected[data-v-1b31027d]{padding:1px}.templates-wrapper .template-wrapper .template-container .thumbnail[data-v-1b31027d]{object-fit:cover;transform:scale(1)}[data-v-811cff80] .guido__verion-history-view-option-selection-desktop svg,[data-v-811cff80] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-811cff80] .in-segments-wrapper__button_selected,[data-v-811cff80] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}.error-list[data-v-c3fd5d4b]{gap:16px}.desktop-browser-header[data-v-d86c5af5]{height:79px;min-height:79px}.desktop-browser-header__left[data-v-d86c5af5]{-webkit-user-drag:none;height:79px;width:378px}.desktop-browser-header__center[data-v-d86c5af5]{height:79px;background-repeat:repeat-x;background-size:auto 100%;background-position:left top}.desktop-browser-header__right[data-v-d86c5af5]{-webkit-user-drag:none;height:79px;width:112px}.desktop-preview[data-v-988f8da6]{min-width:602px;height:70vh;min-height:583px;border-radius:10px}.desktop-preview iframe[data-v-988f8da6]{min-height:504px}.iframe-wrapper[data-v-e0424e99]{width:258px}.iframe-scaled[data-v-e0424e99]{width:320px;height:124.0310077519%;transform:scale(.80625);transform-origin:top left}.cropped-text[data-v-eb3d05d7]{width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mobile-preview-wrapper__phone[data-v-3f472f96]{width:282px}.mobile-preview-wrapper__phone img[data-v-3f472f96]{object-fit:cover;border-radius:44px}.mobile-preview-wrapper__content[data-v-3f472f96]{width:258px;height:450px;left:12px}[data-v-7419ae06] .vueperslides__bullets,[data-v-796d193b] .vueperslides__bullets{pointer-events:none!important}[data-v-796d193b] .vueperslides__parallax-wrapper{height:110px!important}[data-v-cadfc82d] .vueperslides__bullets{pointer-events:none!important}[data-v-cadfc82d] .vueperslides__parallax-wrapper{height:110px!important}
@@ -1,52 +1,40 @@
1
- import { useHttp as d } from "../composables/useHttp.js";
2
- import { QUERY_PARAMS as l, URLS as u } from "../enums/extensions/recommendationBlock.js";
3
- const R = (o) => o.reduce(
4
- (a, t, s) => (a[s] = {
5
- attributeName: t.attributeName,
6
- attributeJs: t.attributeJs,
7
- attributeType: t.attributeType,
8
- type: t.type,
9
- displayName: t.displayName,
10
- isFilterable: t.isFilterable
11
- }, a),
12
- {}
13
- ), f = () => {
14
- const { get: o } = d(), { get: a } = d({ headers: {} }), t = "6KcLM9TwheVB1mgK";
1
+ import { useHttp as a } from "../composables/useHttp.js";
2
+ import { QUERY_PARAMS as d, URLS as h } from "../enums/extensions/recommendationBlock.js";
3
+ const y = () => {
4
+ const { get: r } = a(), { get: s } = a({ headers: {} }), m = "6KcLM9TwheVB1mgK";
15
5
  return {
16
6
  fetchRecommendationCreateData: async () => {
17
7
  try {
18
- return (await o("/newsletter/recommendations/create-data")).data;
8
+ return (await r("/newsletter/recommendations/create-data")).data;
19
9
  } catch (e) {
20
10
  throw console.error("fetchUserModalState error:", e), e;
21
11
  }
22
12
  },
23
13
  fetchRecommendationFilters: async () => {
24
14
  try {
25
- const { data: e } = await o(
26
- u.PRODUCT_ATTRIBUTES_PATH
27
- ), n = Array.isArray(e) ? e : (e == null ? void 0 : e.data) ?? [];
28
- return R(n);
15
+ const { data: e } = await r("/stripo/email-recommendation-attributes");
16
+ return e;
29
17
  } catch (e) {
30
18
  throw console.error("fetchRecommendationFilters error:", e), e;
31
19
  }
32
20
  },
33
- fetchRecommendationProducts: async (e, n) => {
34
- var i;
21
+ fetchRecommendationProducts: async (e, i) => {
22
+ var n;
35
23
  try {
36
- const r = new URLSearchParams(Object.entries(n));
37
- r.set(l.CLIENT_ID, t);
38
- const m = decodeURIComponent(r.toString());
39
- console.debug("🏁 Recommendation API Query:", m);
40
- const c = await a(
41
- `${u.RECOMMENDATION_API_URL}/v2/${e}?${m}`
24
+ const t = new URLSearchParams(Object.entries(i));
25
+ t.set(d.CLIENT_ID, m);
26
+ const c = decodeURIComponent(t.toString());
27
+ console.debug("🏁 Recommendation API Query:", c);
28
+ const o = await s(
29
+ `${h.RECOMMENDATION_API_URL}/v2/${e}?${c}`
42
30
  );
43
- return ((i = c == null ? void 0 : c.data) == null ? void 0 : i.data) ?? [];
44
- } catch (r) {
45
- throw console.error("fetchRecommendationProducts error:", r), r;
31
+ return ((n = o == null ? void 0 : o.data) == null ? void 0 : n.data) ?? [];
32
+ } catch (t) {
33
+ throw console.error("fetchRecommendationProducts error:", t), t;
46
34
  }
47
35
  }
48
36
  };
49
37
  };
50
38
  export {
51
- f as useRecommendationApi
39
+ y as useRecommendationApi
52
40
  };
@@ -2,7 +2,6 @@ import type { TextValueObject } from '@@/Types/generic';
2
2
  import type { RecommendationFeedItem } from '@@/Types/recommendation';
3
3
  export declare const URLS: {
4
4
  RECOMMENDATION_API_URL: string;
5
- PRODUCT_ATTRIBUTES_PATH: string;
6
5
  };
7
6
  export declare const QUERY_PARAMS: {
8
7
  CLIENT_ID: string;
@@ -20,6 +20,12 @@ export declare class UnsubscribeBlock extends Block {
20
20
  onDestroy(): void;
21
21
  private _hasUnsubscribeLink;
22
22
  private _readBlockId;
23
+ /**
24
+ * True when the block has a page type and a page list — i.e. a template was
25
+ * applied. A block with neither, combined with an already-present block id,
26
+ * is an undo-restored orphan of a cancelled block.
27
+ */
28
+ private _hasPageSelection;
23
29
  /**
24
30
  * Returns the block's stable id, assigning one via the document modifier if
25
31
  * the node has not been tagged yet. Idempotent: subsequent calls during
@@ -15,6 +15,7 @@ export declare class UnsubscribeControl extends Control {
15
15
  private get totalTemplates();
16
16
  private _listenToFormUpdates;
17
17
  private _onButtonClick;
18
+ private _reseedSelectionFromBlock;
18
19
  private _onPrevClick;
19
20
  private _onNextClick;
20
21
  private _loadAndUpdatePreview;
@@ -10,6 +10,7 @@ interface StoreState {
10
10
  typeSelectionDrawerStatus: boolean;
11
11
  isGlobalUnsubscribeDisabled: boolean;
12
12
  isSubscriptionPreferencesCenterDisabled: boolean;
13
+ pendingBlockId: string | null;
13
14
  }
14
15
  export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guidoUnsubscribe", StoreState, {
15
16
  getSelectedCollection: (state: {
@@ -35,6 +36,7 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
35
36
  typeSelectionDrawerStatus: boolean;
36
37
  isGlobalUnsubscribeDisabled: boolean;
37
38
  isSubscriptionPreferencesCenterDisabled: boolean;
39
+ pendingBlockId: string | null;
38
40
  } & import("pinia").PiniaCustomStateProperties<StoreState>) => number[];
39
41
  getSelectedTemplateByActiveType: (state: {
40
42
  templates: {
@@ -59,6 +61,7 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
59
61
  typeSelectionDrawerStatus: boolean;
60
62
  isGlobalUnsubscribeDisabled: boolean;
61
63
  isSubscriptionPreferencesCenterDisabled: boolean;
64
+ pendingBlockId: string | null;
62
65
  } & import("pinia").PiniaCustomStateProperties<StoreState>) => number;
63
66
  getTemplatesByActiveType: (state: {
64
67
  templates: {
@@ -83,6 +86,7 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
83
86
  typeSelectionDrawerStatus: boolean;
84
87
  isGlobalUnsubscribeDisabled: boolean;
85
88
  isSubscriptionPreferencesCenterDisabled: boolean;
89
+ pendingBlockId: string | null;
86
90
  } & import("pinia").PiniaCustomStateProperties<StoreState>) => {
87
91
  id: number;
88
92
  name: string;
@@ -119,6 +123,7 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
119
123
  typeSelectionDrawerStatus: boolean;
120
124
  isGlobalUnsubscribeDisabled: boolean;
121
125
  isSubscriptionPreferencesCenterDisabled: boolean;
126
+ pendingBlockId: string | null;
122
127
  } & import("pinia").PiniaCustomStateProperties<StoreState>) => (id: number) => string;
123
128
  getSelectedUnsubscribePagesByCollection: (state: {
124
129
  templates: {
@@ -143,6 +148,7 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
143
148
  typeSelectionDrawerStatus: boolean;
144
149
  isGlobalUnsubscribeDisabled: boolean;
145
150
  isSubscriptionPreferencesCenterDisabled: boolean;
151
+ pendingBlockId: string | null;
146
152
  } & import("pinia").PiniaCustomStateProperties<StoreState>) => (collectionType: number) => number[];
147
153
  isActiveTypeFirstInCollection: (state: {
148
154
  templates: {
@@ -167,6 +173,7 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
167
173
  typeSelectionDrawerStatus: boolean;
168
174
  isGlobalUnsubscribeDisabled: boolean;
169
175
  isSubscriptionPreferencesCenterDisabled: boolean;
176
+ pendingBlockId: string | null;
170
177
  } & import("pinia").PiniaCustomStateProperties<StoreState>) => boolean;
171
178
  isActiveTypeLastInCollection: (state: {
172
179
  templates: {
@@ -191,6 +198,7 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
191
198
  typeSelectionDrawerStatus: boolean;
192
199
  isGlobalUnsubscribeDisabled: boolean;
193
200
  isSubscriptionPreferencesCenterDisabled: boolean;
201
+ pendingBlockId: string | null;
194
202
  } & import("pinia").PiniaCustomStateProperties<StoreState>) => boolean;
195
203
  hasTemplatesByCollectionType: (state: {
196
204
  templates: {
@@ -215,6 +223,7 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
215
223
  typeSelectionDrawerStatus: boolean;
216
224
  isGlobalUnsubscribeDisabled: boolean;
217
225
  isSubscriptionPreferencesCenterDisabled: boolean;
226
+ pendingBlockId: string | null;
218
227
  } & import("pinia").PiniaCustomStateProperties<StoreState>) => Record<number, boolean>;
219
228
  unsubscribePagesStatus: (state: {
220
229
  templates: {
@@ -239,10 +248,11 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
239
248
  typeSelectionDrawerStatus: boolean;
240
249
  isGlobalUnsubscribeDisabled: boolean;
241
250
  isSubscriptionPreferencesCenterDisabled: boolean;
251
+ pendingBlockId: string | null;
242
252
  } & import("pinia").PiniaCustomStateProperties<StoreState>) => boolean;
243
253
  }, {
244
254
  $reset(): void;
245
- fetchTemplates(): Promise<void>;
255
+ fetchTemplates(force?: boolean): Promise<void>;
246
256
  setCollection(collectionType: number): void;
247
257
  setCollectionWithoutAutoSelection(collectionType: number): void;
248
258
  setSelectedTemplate(template: number): void;
@@ -1,6 +1,6 @@
1
1
  import { TYPE_COLLECTIONS as i, PAGE_TYPES as p } from "../enums/unsubscribe.js";
2
2
  import { useUnsubscribeApi as d } from "../services/unsubscribeApi.js";
3
- import { defineStore as h } from "pinia";
3
+ import { defineStore as u } from "pinia";
4
4
  let o = null;
5
5
  const r = () => ({
6
6
  templates: [],
@@ -12,8 +12,9 @@ const r = () => ({
12
12
  pageSelectionDrawerStatus: !1,
13
13
  typeSelectionDrawerStatus: !1,
14
14
  isGlobalUnsubscribeDisabled: !1,
15
- isSubscriptionPreferencesCenterDisabled: !1
16
- }), b = h("guidoUnsubscribe", {
15
+ isSubscriptionPreferencesCenterDisabled: !1,
16
+ pendingBlockId: null
17
+ }), b = u("guidoUnsubscribe", {
17
18
  state: () => r(),
18
19
  getters: {
19
20
  getSelectedCollection: (e) => i[e.selectedCollectionType],
@@ -62,10 +63,10 @@ const r = () => ({
62
63
  selectedUnsubscribePages: t
63
64
  });
64
65
  },
65
- async fetchTemplates() {
66
- this.templates.length || (o || (o = (async () => {
67
- const { getUnsubscribePages: e } = d();
68
- this.templates = await e();
66
+ async fetchTemplates(e = !1) {
67
+ !e && this.templates.length || ((e || !o) && (o = (async () => {
68
+ const { getUnsubscribePages: t } = d();
69
+ this.templates = await t();
69
70
  })().finally(() => {
70
71
  o = null;
71
72
  })), await o);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.7.0-beta.830822b",
3
+ "version": "3.7.0-beta.a1aaf44",
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",