@useinsider/guido 1.0.3-beta.63e6005 → 1.0.3-beta.6541b5a
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/dist/@types/generic.d.ts +0 -8
- package/dist/components/Guido.vue.d.ts +2 -2
- package/dist/components/Guido.vue.js +8 -8
- package/dist/components/Guido.vue2.js +64 -68
- package/dist/components/wrappers/WpDrawer.vue.d.ts +4 -6
- package/dist/components/wrappers/WpDrawer.vue.js +4 -6
- package/dist/composables/useStripo.js +13 -17
- package/dist/config/compiler/unsubscribeCompilerRules.js +19 -19
- package/dist/config/migrator/couponBlockMigrator.d.ts +1 -0
- package/dist/config/migrator/couponBlockMigrator.js +64 -0
- package/dist/config/migrator/index.d.ts +1 -1
- package/dist/config/migrator/index.js +7 -7
- package/dist/enums/defaults.js +3 -6
- package/dist/enums/unsubscribe.d.ts +0 -19
- package/dist/enums/unsubscribe.js +6 -39
- package/dist/extensions/Blocks/CouponBlock/block.d.ts +11 -0
- package/dist/extensions/Blocks/{Unsubscribe/template.js → CouponBlock/block.js} +30 -20
- package/dist/extensions/Blocks/{Unsubscribe/tagRegistry.js → CouponBlock/extension.js} +5 -8
- package/dist/extensions/Blocks/{Unsubscribe → CouponBlock}/settingsPanel.d.ts +1 -1
- package/dist/extensions/Blocks/{Unsubscribe → CouponBlock}/settingsPanel.js +17 -12
- package/dist/extensions/Blocks/CouponBlock/template.d.ts +3 -0
- package/dist/extensions/Blocks/CouponBlock/template.js +18 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementsAttributes.js +1 -2
- package/dist/static/assets/icons/coupon.svg.js +4 -0
- package/dist/stores/unsubscribe.d.ts +5 -183
- package/dist/stores/unsubscribe.js +6 -125
- package/package.json +1 -1
- package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue.d.ts +0 -2
- package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue.js +0 -18
- package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue2.js +0 -16
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.d.ts +0 -2
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +0 -24
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +0 -64
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.d.ts +0 -2
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.js +0 -18
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue2.js +0 -108
- package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue.d.ts +0 -2
- package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue.js +0 -18
- package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue2.js +0 -12
- package/dist/config/migrator/unsubscribeMigrator.d.ts +0 -1
- package/dist/config/migrator/unsubscribeMigrator.js +0 -112
- package/dist/extensions/Blocks/Unsubscribe/block.d.ts +0 -31
- package/dist/extensions/Blocks/Unsubscribe/block.js +0 -144
- package/dist/extensions/Blocks/Unsubscribe/control.d.ts +0 -29
- package/dist/extensions/Blocks/Unsubscribe/control.js +0 -180
- package/dist/extensions/Blocks/Unsubscribe/elements/preview.d.ts +0 -11
- package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +0 -54
- package/dist/extensions/Blocks/Unsubscribe/extension.js +0 -32
- package/dist/extensions/Blocks/Unsubscribe/styles.css.js +0 -42
- package/dist/extensions/Blocks/Unsubscribe/tagRegistry.d.ts +0 -4
- package/dist/extensions/Blocks/Unsubscribe/template.d.ts +0 -12
- package/dist/extensions/Blocks/Unsubscribe/utils/constants.d.ts +0 -9
- package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +0 -11
- package/dist/extensions/Blocks/Unsubscribe/utils/utils.d.ts +0 -7
- package/dist/extensions/Blocks/Unsubscribe/utils/utils.js +0 -6
- package/dist/services/unsubscribeApi.d.ts +0 -4
- package/dist/services/unsubscribeApi.js +0 -16
- /package/dist/extensions/Blocks/{Unsubscribe → CouponBlock}/extension.d.ts +0 -0
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import a from "./UnsubscribePageSelection.vue2.js";
|
|
2
|
-
/* empty css */
|
|
3
|
-
import n from "../../../_virtual/_plugin-vue2_normalizer.js";
|
|
4
|
-
var o = function() {
|
|
5
|
-
var r = this, e = r._self._c, t = r._self._setupProxy;
|
|
6
|
-
return e(t.WpDrawer, { attrs: { id: "unsubscribe-modal", "description-status": "", size: "large", "footer-button-group-options": t.footerButtonGroupOptions, status: t.unsubscribeStore.pageSelectionDrawerStatus, "title-text": t.trans("newsletter.select-a-template") }, on: { cancelOrBackButtonEvent: t.handleBack, onCloseEvent: t.closeModal, primaryButtonEvent: t.handleSave }, scopedSlots: r._u([{ key: "headerBottomSlot", fn: function() {
|
|
7
|
-
return [e(t.UnsubscribeBreadcrumb, { staticClass: "px-5 py-3" })];
|
|
8
|
-
}, proxy: !0 }]) }, [e("div", { staticClass: "d-g templates-wrapper" }, r._l(t.unsubscribeStore.getTemplatesByActiveType, function(s) {
|
|
9
|
-
return e("div", { key: s.id, staticClass: "template-wrapper", on: { click: function(u) {
|
|
10
|
-
return t.selectTemplate(s.id);
|
|
11
|
-
} } }, [e(t.InContainer, { staticClass: "template-container o-h", class: { selected: t.unsubscribeStore.getSelectedTemplateByActiveType === s.id }, attrs: { border: t.getBorderClass(s.id) } }, [e("div", { staticClass: "w-1 h-1 d-f j-c-c a-i-c" }, [e("img", { staticClass: "w-1 h-1 thumbnail o-h", attrs: { alt: s.name, src: s.thumbnail } })])]), e("div", { staticClass: "mt-1 f-s-1" }, [r._v(" " + r._s(s.name) + " ")])], 1);
|
|
12
|
-
}), 0)]);
|
|
13
|
-
}, i = [], c = /* @__PURE__ */ n(
|
|
14
|
-
a,
|
|
15
|
-
o,
|
|
16
|
-
i,
|
|
17
|
-
!1,
|
|
18
|
-
null,
|
|
19
|
-
"a86fc486"
|
|
20
|
-
);
|
|
21
|
-
const _ = c.exports;
|
|
22
|
-
export {
|
|
23
|
-
_ as default
|
|
24
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { defineComponent as f, ref as y, computed as n, watch as T } from "vue";
|
|
2
|
-
import g from "../../wrappers/WpDrawer.vue.js";
|
|
3
|
-
import { useToaster as S } from "../../../composables/useToaster.js";
|
|
4
|
-
import { useTranslations as v } from "../../../composables/useTranslations.js";
|
|
5
|
-
import { ToasterTypeOptions as B } from "../../../enums/toaster.js";
|
|
6
|
-
import { useUnsubscribeStore as w } from "../../../stores/unsubscribe.js";
|
|
7
|
-
import { InContainer as C } from "@useinsider/design-system-vue";
|
|
8
|
-
import h from "./UnsubscribeBreadcrumb.vue.js";
|
|
9
|
-
const E = /* @__PURE__ */ f({
|
|
10
|
-
__name: "UnsubscribePageSelection",
|
|
11
|
-
setup(_) {
|
|
12
|
-
const s = v(), e = w(), { showToaster: a } = S(), 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")), p = n(() => ({
|
|
13
|
-
primaryButton: {
|
|
14
|
-
styling: "solid",
|
|
15
|
-
type: "primary",
|
|
16
|
-
labelText: c.value,
|
|
17
|
-
loadingStatus: o.value,
|
|
18
|
-
disabledStatus: !1
|
|
19
|
-
},
|
|
20
|
-
cancelOrBackButton: {
|
|
21
|
-
styling: "ghost",
|
|
22
|
-
type: "secondary",
|
|
23
|
-
labelText: i.value,
|
|
24
|
-
disabledStatus: o.value
|
|
25
|
-
}
|
|
26
|
-
})), u = (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
|
-
e.pageSelectionDrawerStatus = !1, t && setTimeout(() => {
|
|
28
|
-
t();
|
|
29
|
-
}, 500);
|
|
30
|
-
}, m = () => {
|
|
31
|
-
if (e.isActiveTypeFirstInCollection) {
|
|
32
|
-
r(), e.pageSelectionUpdateStatus || (e.typeSelectionDrawerStatus = !0);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
e.setPreviousType();
|
|
36
|
-
}, d = () => {
|
|
37
|
-
if (e.isActiveTypeLastInCollection) {
|
|
38
|
-
o.value = !0;
|
|
39
|
-
const t = e.selectedCollectionType, l = e.getSelectedTemplatesByCollection(t);
|
|
40
|
-
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: B.Success,
|
|
48
|
-
message: s("global-unsubscribe.pages-were-attached")
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
e.setNextType();
|
|
54
|
-
}, b = (t) => {
|
|
55
|
-
e.setSelectedTemplate(t);
|
|
56
|
-
};
|
|
57
|
-
return T(() => e.pageSelectionDrawerStatus, (t) => {
|
|
58
|
-
t && e.pageSelectionUpdateStatus && e.fetchTemplates();
|
|
59
|
-
}), { __sfc: !0, trans: s, unsubscribeStore: e, showToaster: a, isApplying: o, getPrimaryButtonText: c, getCancelOrBackButtonText: i, footerButtonGroupOptions: p, getBorderClass: u, closeModal: r, handleBack: m, handleSave: d, selectTemplate: b, WpDrawer: g, InContainer: C, UnsubscribeBreadcrumb: h };
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
export {
|
|
63
|
-
E as default
|
|
64
|
-
};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
|
|
2
|
-
export default _default;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import n from "./UnsubscribeTypeSelection.vue2.js";
|
|
2
|
-
/* empty css */
|
|
3
|
-
import o from "../../../_virtual/_plugin-vue2_normalizer.js";
|
|
4
|
-
var i = function() {
|
|
5
|
-
var e = this, s = e._self._c, t = e._self._setupProxy;
|
|
6
|
-
return s(t.WpDrawer, { attrs: { id: "unsubscribe-modal", "description-status": "", "description-text": t.descriptionText, "footer-button-group-options": t.footerButtonGroupOptions, status: t.unsubscribeStore.typeSelectionDrawerStatus, "title-text": t.trans("unsubscription-preference.select-unsubscribe-page-title") }, on: { cancelOrBackButtonEvent: t.closeModal, onCloseEvent: t.closeModal, primaryButtonEvent: t.selectCollection } }, [s(t.InSegments, { staticClass: "w-1", attrs: { "with-icon": "", align: "vertical", disable: t.isSelecting, "segment-list": t.segmentList, selected: t.selectedCollection, "skeleton-sizing": { width: 495, height: 180 }, "skeleton-status": t.skeletonStatus }, on: { click: t.changeCollection } })], 1);
|
|
7
|
-
}, r = [], c = /* @__PURE__ */ o(
|
|
8
|
-
n,
|
|
9
|
-
i,
|
|
10
|
-
r,
|
|
11
|
-
!1,
|
|
12
|
-
null,
|
|
13
|
-
"dda47b76"
|
|
14
|
-
);
|
|
15
|
-
const d = c.exports;
|
|
16
|
-
export {
|
|
17
|
-
d as default
|
|
18
|
-
};
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { defineComponent as h, ref as b, computed as m, watch as _ } from "vue";
|
|
2
|
-
import v from "../../wrappers/WpDrawer.vue.js";
|
|
3
|
-
import { useToaster as B } from "../../../composables/useToaster.js";
|
|
4
|
-
import { useTranslations as N } from "../../../composables/useTranslations.js";
|
|
5
|
-
import { ToasterTypeOptions as U } from "../../../enums/toaster.js";
|
|
6
|
-
import { PAGE_TYPES as l, ACADEMY_LINK as w, UNSUBSCRIBE_PAGES_LINK as P, TYPE_TRANSLATIONS as R } from "../../../enums/unsubscribe.js";
|
|
7
|
-
import { useUnsubscribeStore as D } from "../../../stores/unsubscribe.js";
|
|
8
|
-
import { InSegments as I } from "@useinsider/design-system-vue";
|
|
9
|
-
const z = /* @__PURE__ */ h({
|
|
10
|
-
__name: "UnsubscribeTypeSelection",
|
|
11
|
-
setup(G) {
|
|
12
|
-
const e = N(), { showToaster: f } = B(), t = D(), n = b(!1), i = b(!0), r = b(l.GLOBAL_UNSUBSCRIBE), S = e(
|
|
13
|
-
"unsubscription-preference.select-unsubscribe-page-description",
|
|
14
|
-
{ action: `<a href="${w}" target="_blank">${e("ds-rules.visit-academy")}</a>` }
|
|
15
|
-
), T = m(() => [
|
|
16
|
-
{
|
|
17
|
-
description: e("unsubscription-preference.type-global-unsubscribe-description"),
|
|
18
|
-
icon: "line-contact-global-unsub-page",
|
|
19
|
-
text: e("unsubscription-preference.type-global-unsubscribe"),
|
|
20
|
-
value: l.GLOBAL_UNSUBSCRIBE,
|
|
21
|
-
disable: t.isGlobalUnsubscribeDisabled,
|
|
22
|
-
tooltipText: t.isGlobalUnsubscribeDisabled ? e("unsubscription-preference.global-unsub-added") : ""
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
description: e("unsubscription-preference.type-subscription-preferences-center-description"),
|
|
26
|
-
icon: "line-contact-sub-pref-center-page",
|
|
27
|
-
text: e("unsubscription-preference.type-subscription-preferences-center"),
|
|
28
|
-
value: l.SUBSCRIPTION_PREFERENCE_CENTER,
|
|
29
|
-
disable: t.isSubscriptionPreferencesCenterDisabled,
|
|
30
|
-
tooltipText: t.isSubscriptionPreferencesCenterDisabled ? e("unsubscription-preference.pref-center-added") : ""
|
|
31
|
-
}
|
|
32
|
-
]), y = m(() => ({
|
|
33
|
-
primaryButton: {
|
|
34
|
-
styling: "solid",
|
|
35
|
-
type: "primary",
|
|
36
|
-
labelText: e(
|
|
37
|
-
n.value ? "unsubscription-preference.selecting-type" : "products.select-and-continue"
|
|
38
|
-
),
|
|
39
|
-
loadingStatus: n.value,
|
|
40
|
-
disabledStatus: !1,
|
|
41
|
-
skeletonStatus: i.value,
|
|
42
|
-
skeletonSizing: { width: 168, height: 40 }
|
|
43
|
-
},
|
|
44
|
-
cancelOrBackButton: {
|
|
45
|
-
styling: "ghost",
|
|
46
|
-
type: "secondary",
|
|
47
|
-
labelText: e("products.cancel"),
|
|
48
|
-
disabledStatus: n.value,
|
|
49
|
-
skeletonStatus: i.value,
|
|
50
|
-
skeletonSizing: { width: 78, height: 40 }
|
|
51
|
-
}
|
|
52
|
-
})), d = (s) => {
|
|
53
|
-
t.typeSelectionDrawerStatus = !1, document.dispatchEvent(new CustomEvent("unsubscribe:cancel")), s && setTimeout(() => {
|
|
54
|
-
s();
|
|
55
|
-
}, 500);
|
|
56
|
-
}, E = (s) => {
|
|
57
|
-
r.value = s;
|
|
58
|
-
}, g = () => {
|
|
59
|
-
const s = t.hasTemplatesByCollectionType, o = [];
|
|
60
|
-
if (Object.entries(s).forEach(([c, p]) => {
|
|
61
|
-
p || o.push(Number(c));
|
|
62
|
-
}), o.length === 0)
|
|
63
|
-
return !0;
|
|
64
|
-
const a = o.map((c) => R[c]);
|
|
65
|
-
let u = "";
|
|
66
|
-
if (o.length === 1)
|
|
67
|
-
u = e("unsubscription-preference.create-page-to-continue", {
|
|
68
|
-
page: a[0]
|
|
69
|
-
});
|
|
70
|
-
else if (o.length === 2)
|
|
71
|
-
u = e("unsubscription-preference.create-pages-to-continue", {
|
|
72
|
-
page1: a[0],
|
|
73
|
-
page2: a[1]
|
|
74
|
-
});
|
|
75
|
-
else {
|
|
76
|
-
const c = a.pop() ?? "", p = a.join(", ");
|
|
77
|
-
u = e("unsubscription-preference.create-multiple-pages-to-continue", {
|
|
78
|
-
pages: p,
|
|
79
|
-
lastPage: c
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
return f({
|
|
83
|
-
type: U.Warning,
|
|
84
|
-
message: u,
|
|
85
|
-
actionButton: {
|
|
86
|
-
text: "Go to Unsubscribe Pages",
|
|
87
|
-
onClick: () => {
|
|
88
|
-
window.location.href = P;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}), !1;
|
|
92
|
-
}, C = async () => {
|
|
93
|
-
if (n.value = !0, await t.fetchTemplates(), t.setCollection(r.value), !g()) {
|
|
94
|
-
n.value = !1, d();
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
n.value = !1, t.typeSelectionDrawerStatus = !1, t.pageSelectionDrawerStatus = !0;
|
|
98
|
-
};
|
|
99
|
-
return _(() => t.typeSelectionDrawerStatus, (s) => {
|
|
100
|
-
s && (i.value = !0, r.value = l.GLOBAL_UNSUBSCRIBE, t.isGlobalUnsubscribeDisabled && (r.value = t.isSubscriptionPreferencesCenterDisabled ? 0 : l.SUBSCRIPTION_PREFERENCE_CENTER), setTimeout(() => {
|
|
101
|
-
i.value = !1;
|
|
102
|
-
}, 1e3));
|
|
103
|
-
}), { __sfc: !0, trans: e, showToaster: f, unsubscribeStore: t, isSelecting: n, skeletonStatus: i, selectedCollection: r, descriptionText: S, segmentList: T, footerButtonGroupOptions: y, closeModal: d, changeCollection: E, validateTemplates: g, selectCollection: C, WpDrawer: v, InSegments: I };
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
export {
|
|
107
|
-
z as default
|
|
108
|
-
};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
|
|
2
|
-
export default _default;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import o from "./UnsubscribeWrapper.vue2.js";
|
|
2
|
-
import t from "../../../_virtual/_plugin-vue2_normalizer.js";
|
|
3
|
-
var _ = function() {
|
|
4
|
-
var s;
|
|
5
|
-
var e = this, n = e._self._c, r = e._self._setupProxy;
|
|
6
|
-
return (s = r.config.extensions) != null && s.unsubscribe ? n("div", [n(r.UnsubscribeTypeSelection), n(r.UnsubscribePageSelection)], 1) : e._e();
|
|
7
|
-
}, c = [], i = /* @__PURE__ */ t(
|
|
8
|
-
o,
|
|
9
|
-
_,
|
|
10
|
-
c,
|
|
11
|
-
!1,
|
|
12
|
-
null,
|
|
13
|
-
null
|
|
14
|
-
);
|
|
15
|
-
const l = i.exports;
|
|
16
|
-
export {
|
|
17
|
-
l as default
|
|
18
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { defineComponent as t, defineAsyncComponent as e } from "vue";
|
|
2
|
-
import { useConfig as r } from "../../../composables/useConfig.js";
|
|
3
|
-
const m = /* @__PURE__ */ t({
|
|
4
|
-
__name: "UnsubscribeWrapper",
|
|
5
|
-
setup(i) {
|
|
6
|
-
const n = e(() => import("./UnsubscribePageSelection.vue.js")), o = e(() => import("./UnsubscribeTypeSelection.vue.js")), { config: s } = r();
|
|
7
|
-
return { __sfc: !0, UnsubscribePageSelection: n, UnsubscribeTypeSelection: o, config: s };
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
export {
|
|
11
|
-
m as default
|
|
12
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function migrateUnsubscribe(html: string): Promise<string>;
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
var A = Object.defineProperty;
|
|
2
|
-
var T = (l, e, t) => e in l ? A(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
|
|
3
|
-
var d = (l, e, t) => T(l, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { MERGE_TAGS as p, PAGE_TYPES as g } from "../../enums/unsubscribe.js";
|
|
5
|
-
import { DATA_ATTRIBUTES as y } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
6
|
-
import { useUnsubscribeStore as x } from "../../stores/unsubscribe.js";
|
|
7
|
-
class h {
|
|
8
|
-
constructor() {
|
|
9
|
-
d(this, "parser");
|
|
10
|
-
this.parser = new DOMParser();
|
|
11
|
-
}
|
|
12
|
-
async migrate(e) {
|
|
13
|
-
try {
|
|
14
|
-
const t = this.parser.parseFromString(e, "text/html"), s = t.querySelectorAll("td.unsubscribe-block");
|
|
15
|
-
if (!s.length)
|
|
16
|
-
return e;
|
|
17
|
-
const u = x();
|
|
18
|
-
return await u.fetchTemplates(), s.forEach((i) => {
|
|
19
|
-
const a = i.getAttribute("id"), n = this.extractUnsubscribeContent(i), r = this.getCollectionTypeFromMergeTag(n.linkHref), o = u.getSelectedUnsubscribePagesByCollection(r);
|
|
20
|
-
console.debug("[UnsubscribeMigrator]", {
|
|
21
|
-
mergeTag: n.linkHref,
|
|
22
|
-
collectionType: r,
|
|
23
|
-
pageIds: o
|
|
24
|
-
});
|
|
25
|
-
const c = this.buildUnsubscribeBlock(n, r, o), b = this.parser.parseFromString(
|
|
26
|
-
`<table id="tempDoc"><tbody><tr>${c}</tr></tbody></table>`,
|
|
27
|
-
"text/html"
|
|
28
|
-
).querySelector(".unsubscribe-block-v2");
|
|
29
|
-
b && i.parentNode && (b.setAttribute("id", a || ""), i.parentNode.replaceChild(b, i));
|
|
30
|
-
}), t.documentElement.outerHTML;
|
|
31
|
-
} catch (t) {
|
|
32
|
-
return console.error("UnsubscribeMigrator failed:", t), e;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
extractUnsubscribeContent(e) {
|
|
36
|
-
var m;
|
|
37
|
-
const t = e.querySelector("p");
|
|
38
|
-
if (!t)
|
|
39
|
-
return {
|
|
40
|
-
textBefore: "You can ",
|
|
41
|
-
linkText: "unsubscribe",
|
|
42
|
-
linkHref: "{{ins-unsubscribe-link}}",
|
|
43
|
-
linkStyle: "",
|
|
44
|
-
textAfter: " from our emails, if you need to.",
|
|
45
|
-
isBold: !1,
|
|
46
|
-
isItalic: !1,
|
|
47
|
-
align: "center",
|
|
48
|
-
paragraphStyle: ""
|
|
49
|
-
};
|
|
50
|
-
const s = e.getAttribute("align") || t.getAttribute("align") || "center", u = t.getAttribute("style") || "", i = t.querySelector("a.unsubscribe-link") || t.querySelector('a[href*="unsubscribe"]');
|
|
51
|
-
if (!i)
|
|
52
|
-
return {
|
|
53
|
-
textBefore: "You can ",
|
|
54
|
-
linkText: "unsubscribe",
|
|
55
|
-
linkHref: "{{ins-unsubscribe-link}}",
|
|
56
|
-
linkStyle: "",
|
|
57
|
-
textAfter: " from our emails, if you need to.",
|
|
58
|
-
isBold: !1,
|
|
59
|
-
isItalic: !1,
|
|
60
|
-
align: s,
|
|
61
|
-
paragraphStyle: u
|
|
62
|
-
};
|
|
63
|
-
const a = ((m = i.textContent) == null ? void 0 : m.trim()) || "unsubscribe", n = i.getAttribute("href") || "{{ins-unsubscribe-link}}", r = i.getAttribute("style") || "", o = t.textContent || "", c = o.indexOf(a), f = c >= 0 ? o.substring(0, c).trim() : "You can ", b = c >= 0 ? o.substring(c + a.length).trim() : " from our emails, if you need to.", k = !!t.querySelector("b, strong"), S = !!t.querySelector("i, em");
|
|
64
|
-
return {
|
|
65
|
-
textBefore: f,
|
|
66
|
-
linkText: a,
|
|
67
|
-
linkHref: this.normalizeUnsubscribeHref(n),
|
|
68
|
-
linkStyle: r,
|
|
69
|
-
textAfter: b,
|
|
70
|
-
isBold: k,
|
|
71
|
-
isItalic: S,
|
|
72
|
-
align: s,
|
|
73
|
-
paragraphStyle: u
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
buildUnsubscribeBlock(e, t, s) {
|
|
77
|
-
const u = e.linkStyle ? ` style="${e.linkStyle}"` : "", a = `<a ${`href="${e.linkHref}" class="unsubscribe-link" target="_blank" data-unsubscribe-link="true"`}${u}>${e.linkText}</a>`, n = [];
|
|
78
|
-
e.textBefore && n.push(e.textBefore), n.push(a), e.textAfter && n.push(e.textAfter);
|
|
79
|
-
let r = n.join(" ");
|
|
80
|
-
e.isBold && e.isItalic ? r = `<strong path="1,0"><em path="1,0,0">${r}</em></strong>` : e.isBold ? r = `<strong path="1,0">${r}</strong>` : e.isItalic && (r = `<em path="1,0">${r}</em>`);
|
|
81
|
-
const o = e.align ? ` align="${e.align}"` : "", c = e.paragraphStyle ? ` style="${e.paragraphStyle}"` : "", f = s.length > 0 ? ` ${y.PAGE_LIST}="${s.join(",")}"` : "", b = ` ${y.PAGE_TYPE}="${t}"`;
|
|
82
|
-
return `
|
|
83
|
-
<td
|
|
84
|
-
data-migration="true"
|
|
85
|
-
esd-extension-block-id="unsubscribe-block"
|
|
86
|
-
class="esd-block-text unsubscribe-block-v2 esd-block-unsubscribe esd-unsubscribe-block esd-extension-block"
|
|
87
|
-
${o}${b}${f}
|
|
88
|
-
>
|
|
89
|
-
<p path="1"${c}>
|
|
90
|
-
${r}
|
|
91
|
-
</p>
|
|
92
|
-
</td>
|
|
93
|
-
`;
|
|
94
|
-
}
|
|
95
|
-
getCollectionTypeFromMergeTag(e) {
|
|
96
|
-
return e === p[g.SUBSCRIPTION_PREFERENCE_CENTER] ? g.SUBSCRIPTION_PREFERENCE_CENTER : e === p[g.GLOBAL_UNSUBSCRIBE] ? g.GLOBAL_UNSUBSCRIBE : g.GLOBAL_UNSUBSCRIBE;
|
|
97
|
-
}
|
|
98
|
-
normalizeUnsubscribeHref(e) {
|
|
99
|
-
if (Object.values(p).includes(e))
|
|
100
|
-
return e;
|
|
101
|
-
const s = e.match(/{{ins-(?:global-)?(?:preferences-)?unsubscribe-link}}/);
|
|
102
|
-
return s ? s[0] : e.includes("unsubscribe") || e.includes("unsub") ? (console.warn(
|
|
103
|
-
`[UnsubscribeMigrator] Unrecognized unsubscribe href format: "${e}". Defaulting to {{ins-unsubscribe-link}}`
|
|
104
|
-
), "{{ins-unsubscribe-link}}") : e;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
async function $(l) {
|
|
108
|
-
return new h().migrate(l);
|
|
109
|
-
}
|
|
110
|
-
export {
|
|
111
|
-
$ as migrateUnsubscribe
|
|
112
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
2
|
-
import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
|
|
3
|
-
export declare const UNSUBSCRIBE_BLOCK_ID = "unsubscribe-block";
|
|
4
|
-
export declare class UnsubscribeBlock extends Block {
|
|
5
|
-
private selectEventListener;
|
|
6
|
-
private cancelEventListener;
|
|
7
|
-
private currentNode?;
|
|
8
|
-
getId(): string;
|
|
9
|
-
getIcon(): string;
|
|
10
|
-
getBlockCompositionType(): BlockCompositionType;
|
|
11
|
-
getName(): string;
|
|
12
|
-
getDescription(): string;
|
|
13
|
-
getTemplate(): string;
|
|
14
|
-
onCreated(node: ImmutableHtmlNode): void;
|
|
15
|
-
onSelect(node: ImmutableHtmlNode): undefined;
|
|
16
|
-
onDelete(node: ImmutableHtmlNode): undefined;
|
|
17
|
-
onDestroy(): void;
|
|
18
|
-
private _setupSelectEventListener;
|
|
19
|
-
private _removeSelectEventListener;
|
|
20
|
-
private _setupCancelEventListener;
|
|
21
|
-
private _removeCancelEventListener;
|
|
22
|
-
private _handleCancel;
|
|
23
|
-
private _removeEventListeners;
|
|
24
|
-
private _updateBlock;
|
|
25
|
-
private _getMergeTag;
|
|
26
|
-
private _openDrawer;
|
|
27
|
-
private _checkExistingBlocks;
|
|
28
|
-
private _loadBlockState;
|
|
29
|
-
private _resetStoreState;
|
|
30
|
-
private _removeBlockTemplatesFromStore;
|
|
31
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
var _ = Object.defineProperty;
|
|
2
|
-
var d = (n, s, e) => s in n ? _(n, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[s] = e;
|
|
3
|
-
var u = (n, s, e) => d(n, typeof s != "symbol" ? s + "" : s, e);
|
|
4
|
-
import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
|
|
5
|
-
import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
|
|
6
|
-
import { Block as S } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/blocks/Block.js";
|
|
7
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/AiAssistantValueType.js";
|
|
8
|
-
import { BlockCompositionType as h } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockCompositionType.js";
|
|
9
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockName.js";
|
|
10
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockType.js";
|
|
11
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BuiltInControlTypes.js";
|
|
12
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/ContextActionType.js";
|
|
13
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/EditorStatePropertyType.js";
|
|
14
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PanelPosition.js";
|
|
15
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/Popover.js";
|
|
16
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PreviewDeviceMode.js";
|
|
17
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/SettingsTab.js";
|
|
18
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementType.js";
|
|
19
|
-
import { ModificationDescription as m } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/modifications/ModificationDescription.js";
|
|
20
|
-
import { getDefaultTemplate as L } from "./template.js";
|
|
21
|
-
import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
|
|
22
|
-
import { parsePageList as p } from "./utils/utils.js";
|
|
23
|
-
const v = "unsubscribe-block", g = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", B = "{{ins-unsubscribe-link}}", C = {
|
|
24
|
-
[E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
|
|
25
|
-
[E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
|
|
26
|
-
};
|
|
27
|
-
class $ extends S {
|
|
28
|
-
constructor() {
|
|
29
|
-
super(...arguments);
|
|
30
|
-
u(this, "selectEventListener", null);
|
|
31
|
-
u(this, "cancelEventListener", null);
|
|
32
|
-
u(this, "currentNode");
|
|
33
|
-
}
|
|
34
|
-
getId() {
|
|
35
|
-
return v;
|
|
36
|
-
}
|
|
37
|
-
getIcon() {
|
|
38
|
-
return "mail-info";
|
|
39
|
-
}
|
|
40
|
-
getBlockCompositionType() {
|
|
41
|
-
return h.BLOCK;
|
|
42
|
-
}
|
|
43
|
-
getName() {
|
|
44
|
-
return this.api.translate("Unsubscribe Block");
|
|
45
|
-
}
|
|
46
|
-
getDescription() {
|
|
47
|
-
return this.api.translate("Unsubscribe Block Description");
|
|
48
|
-
}
|
|
49
|
-
getTemplate() {
|
|
50
|
-
return L();
|
|
51
|
-
}
|
|
52
|
-
onCreated(e) {
|
|
53
|
-
"getAttribute" in e && e.getAttribute("data-migration") || (this.currentNode = e, this._resetStoreState(), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
|
|
54
|
-
}
|
|
55
|
-
onSelect(e) {
|
|
56
|
-
this.currentNode = e, this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener();
|
|
57
|
-
}
|
|
58
|
-
onDelete(e) {
|
|
59
|
-
this._removeEventListeners(), this._removeBlockTemplatesFromStore(e), this._resetStoreState();
|
|
60
|
-
}
|
|
61
|
-
onDestroy() {
|
|
62
|
-
this._removeEventListeners(), this.currentNode = void 0;
|
|
63
|
-
}
|
|
64
|
-
_setupSelectEventListener() {
|
|
65
|
-
this._removeSelectEventListener(), this.selectEventListener = (e) => {
|
|
66
|
-
const i = e, { collectionType: t, selectedPages: r } = i.detail;
|
|
67
|
-
this._updateBlock(t, r.join(","));
|
|
68
|
-
}, document.addEventListener(a.SELECT, this.selectEventListener);
|
|
69
|
-
}
|
|
70
|
-
_removeSelectEventListener() {
|
|
71
|
-
this.selectEventListener && (document.removeEventListener(a.SELECT, this.selectEventListener), this.selectEventListener = null);
|
|
72
|
-
}
|
|
73
|
-
_setupCancelEventListener() {
|
|
74
|
-
this._removeCancelEventListener(), this.cancelEventListener = () => {
|
|
75
|
-
this._handleCancel();
|
|
76
|
-
}, document.addEventListener(a.CANCEL, this.cancelEventListener);
|
|
77
|
-
}
|
|
78
|
-
_removeCancelEventListener() {
|
|
79
|
-
this.cancelEventListener && (document.removeEventListener(a.CANCEL, this.cancelEventListener), this.cancelEventListener = null);
|
|
80
|
-
}
|
|
81
|
-
_handleCancel() {
|
|
82
|
-
this.currentNode && this.api.getDocumentModifier().modifyHtml(this.currentNode).delete().apply(new m("Removed unsubscribe block due to cancel"));
|
|
83
|
-
}
|
|
84
|
-
_removeEventListeners() {
|
|
85
|
-
this._removeSelectEventListener(), this._removeCancelEventListener();
|
|
86
|
-
}
|
|
87
|
-
_updateBlock(e, i) {
|
|
88
|
-
if (!this.currentNode || !("querySelector" in this.currentNode))
|
|
89
|
-
return;
|
|
90
|
-
const t = this.currentNode.querySelector(g);
|
|
91
|
-
if (!t)
|
|
92
|
-
return;
|
|
93
|
-
const r = this._getMergeTag(e);
|
|
94
|
-
this.api.getDocumentModifier().modifyHtml(t).setAttribute("href", r).apply(new m(`Updated unsubscribe link to ${r}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, i).apply(new m("Updated unsubscribe block metadata"));
|
|
95
|
-
}
|
|
96
|
-
_getMergeTag(e) {
|
|
97
|
-
return C[e] ?? B;
|
|
98
|
-
}
|
|
99
|
-
_openDrawer() {
|
|
100
|
-
try {
|
|
101
|
-
const e = c();
|
|
102
|
-
e.typeSelectionDrawerStatus = !0;
|
|
103
|
-
} catch (e) {
|
|
104
|
-
console.error("[UnsubscribeBlock] Failed to open drawer:", e);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
_checkExistingBlocks() {
|
|
108
|
-
const e = c();
|
|
109
|
-
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((t) => {
|
|
110
|
-
if ("getAttribute" in t) {
|
|
111
|
-
const r = t.getAttribute(o.PAGE_TYPE);
|
|
112
|
-
if (r) {
|
|
113
|
-
const l = Number(r);
|
|
114
|
-
l === E.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : l === E.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
_loadBlockState(e) {
|
|
120
|
-
if (!("getAttribute" in e))
|
|
121
|
-
return;
|
|
122
|
-
const i = e.getAttribute(o.PAGE_TYPE), t = e.getAttribute(o.PAGE_LIST);
|
|
123
|
-
if (!i || !t)
|
|
124
|
-
return;
|
|
125
|
-
const r = c(), l = Number(i), b = p(t);
|
|
126
|
-
r.setCollectionWithoutAutoSelection(l), r.loadSelectedTemplates(b);
|
|
127
|
-
}
|
|
128
|
-
_resetStoreState() {
|
|
129
|
-
c().$reset();
|
|
130
|
-
}
|
|
131
|
-
_removeBlockTemplatesFromStore(e) {
|
|
132
|
-
if (!("getAttribute" in e))
|
|
133
|
-
return;
|
|
134
|
-
const i = e.getAttribute(o.PAGE_LIST);
|
|
135
|
-
if (!i)
|
|
136
|
-
return;
|
|
137
|
-
const t = c(), r = p(i);
|
|
138
|
-
t.removeUnsubscribePages(r);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
export {
|
|
142
|
-
v as UNSUBSCRIBE_BLOCK_ID,
|
|
143
|
-
$ as UnsubscribeBlock
|
|
144
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
2
|
-
import { Control } from '@stripoinc/ui-editor-extensions';
|
|
3
|
-
export declare const UNSUBSCRIBE_CONTROL_ID = "ui-elements-unsubscribe";
|
|
4
|
-
export declare class UnsubscribeControl extends Control {
|
|
5
|
-
private currentPreviewIndex;
|
|
6
|
-
private currentNode?;
|
|
7
|
-
private currentPages?;
|
|
8
|
-
private valueChangeHandlers;
|
|
9
|
-
private lastParsedAttribute?;
|
|
10
|
-
getId(): string;
|
|
11
|
-
getTemplate(): string;
|
|
12
|
-
onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
|
|
13
|
-
onRender(): void;
|
|
14
|
-
onDestroy(): void;
|
|
15
|
-
private get totalTemplates();
|
|
16
|
-
private _listenToFormUpdates;
|
|
17
|
-
private _onButtonClick;
|
|
18
|
-
private _onPrevClick;
|
|
19
|
-
private _onNextClick;
|
|
20
|
-
private _updatePreview;
|
|
21
|
-
private _updateCounter;
|
|
22
|
-
private _getPreview;
|
|
23
|
-
private _getButton;
|
|
24
|
-
private _getLabel;
|
|
25
|
-
private _getIconButton;
|
|
26
|
-
private _getPrevButton;
|
|
27
|
-
private _getNextButton;
|
|
28
|
-
private _getCounterText;
|
|
29
|
-
}
|