@useinsider/guido 1.0.2-beta.ac0dc8b → 1.0.2-beta.ad1dcd9

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 (58) hide show
  1. package/dist/@types/generic.d.ts +8 -0
  2. package/dist/components/Guido.vue.d.ts +2 -2
  3. package/dist/components/Guido.vue.js +8 -8
  4. package/dist/components/Guido.vue2.js +68 -64
  5. package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue.d.ts +2 -0
  6. package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue.js +18 -0
  7. package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue2.js +16 -0
  8. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.d.ts +2 -0
  9. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +24 -0
  10. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +64 -0
  11. package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.d.ts +2 -0
  12. package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.js +18 -0
  13. package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue2.js +108 -0
  14. package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue.d.ts +2 -0
  15. package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue.js +18 -0
  16. package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue2.js +12 -0
  17. package/dist/components/wrappers/WpDrawer.vue.d.ts +6 -4
  18. package/dist/components/wrappers/WpDrawer.vue.js +6 -4
  19. package/dist/composables/useHtmlValidator.js +52 -61
  20. package/dist/composables/useStripo.js +13 -13
  21. package/dist/config/compiler/unsubscribeCompilerRules.js +19 -19
  22. package/dist/config/migrator/index.d.ts +1 -1
  23. package/dist/config/migrator/index.js +6 -6
  24. package/dist/config/migrator/unsubscribeMigrator.d.ts +1 -0
  25. package/dist/config/migrator/unsubscribeMigrator.js +112 -0
  26. package/dist/enums/defaults.js +6 -3
  27. package/dist/enums/unsubscribe.d.ts +19 -0
  28. package/dist/enums/unsubscribe.js +39 -6
  29. package/dist/extensions/Blocks/Unsubscribe/block.d.ts +30 -0
  30. package/dist/extensions/Blocks/Unsubscribe/block.js +141 -0
  31. package/dist/extensions/Blocks/Unsubscribe/control.d.ts +29 -0
  32. package/dist/extensions/Blocks/Unsubscribe/control.js +180 -0
  33. package/dist/extensions/Blocks/Unsubscribe/elements/preview.d.ts +11 -0
  34. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +54 -0
  35. package/dist/extensions/Blocks/{RadioButton → Unsubscribe}/extension.js +6 -5
  36. package/dist/extensions/Blocks/{RadioButton → Unsubscribe}/settingsPanel.d.ts +1 -1
  37. package/dist/extensions/Blocks/{RadioButton → Unsubscribe}/settingsPanel.js +14 -21
  38. package/dist/extensions/Blocks/Unsubscribe/template.d.ts +3 -0
  39. package/dist/extensions/Blocks/{RadioButton/block.js → Unsubscribe/template.js} +15 -26
  40. package/dist/extensions/Blocks/Unsubscribe/utils/constants.d.ts +9 -0
  41. package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +11 -0
  42. package/dist/extensions/Blocks/Unsubscribe/utils/utils.d.ts +7 -0
  43. package/dist/extensions/Blocks/Unsubscribe/utils/utils.js +6 -0
  44. package/dist/guido.css +1 -1
  45. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementsAttributes.js +2 -1
  46. package/dist/services/unsubscribeApi.d.ts +4 -0
  47. package/dist/services/unsubscribeApi.js +16 -0
  48. package/dist/stores/unsubscribe.d.ts +183 -5
  49. package/dist/stores/unsubscribe.js +125 -6
  50. package/package.json +1 -1
  51. package/dist/config/migrator/radioButtonMigrator.d.ts +0 -1
  52. package/dist/config/migrator/radioButtonMigrator.js +0 -86
  53. package/dist/extensions/Blocks/RadioButton/block.d.ts +0 -10
  54. package/dist/extensions/Blocks/RadioButton/control.d.ts +0 -17
  55. package/dist/extensions/Blocks/RadioButton/control.js +0 -104
  56. package/dist/extensions/Blocks/RadioButton/template.d.ts +0 -6
  57. package/dist/extensions/Blocks/RadioButton/template.js +0 -160
  58. /package/dist/extensions/Blocks/{RadioButton → Unsubscribe}/extension.d.ts +0 -0
@@ -1,8 +1,186 @@
1
- type UnsubscribePage = {
2
- type: number;
3
- };
1
+ import type { UnsubscribePage } from '@@/Types/unsubscribe';
4
2
  interface StoreState {
5
- selectedUnsubscribePages: UnsubscribePage[];
3
+ templates: UnsubscribePage[];
4
+ selectedTemplates: Record<number, number>;
5
+ selectedUnsubscribePages: number[];
6
+ selectedCollectionType: number;
7
+ activeType: number;
8
+ pageSelectionUpdateStatus: boolean;
9
+ pageSelectionDrawerStatus: boolean;
10
+ typeSelectionDrawerStatus: boolean;
11
+ isGlobalUnsubscribeDisabled: boolean;
12
+ isSubscriptionPreferencesCenterDisabled: boolean;
6
13
  }
7
- export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"unsubscribe", StoreState, {}, {}>;
14
+ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"unsubscribe", StoreState, {
15
+ getSelectedCollection: (state: {
16
+ templates: {
17
+ id: number;
18
+ name: string;
19
+ type: number;
20
+ isVisible: number;
21
+ html: string;
22
+ originalHtml: string;
23
+ css: string;
24
+ thumbnail: string;
25
+ createdAt: string;
26
+ updatedAt: string;
27
+ status: number;
28
+ }[];
29
+ selectedTemplates: Record<number, number>;
30
+ selectedUnsubscribePages: number[];
31
+ selectedCollectionType: number;
32
+ activeType: number;
33
+ pageSelectionUpdateStatus: boolean;
34
+ pageSelectionDrawerStatus: boolean;
35
+ typeSelectionDrawerStatus: boolean;
36
+ isGlobalUnsubscribeDisabled: boolean;
37
+ isSubscriptionPreferencesCenterDisabled: boolean;
38
+ } & import("pinia").PiniaCustomStateProperties<StoreState>) => number[];
39
+ getSelectedTemplateByActiveType: (state: {
40
+ templates: {
41
+ id: number;
42
+ name: string;
43
+ type: number;
44
+ isVisible: number;
45
+ html: string;
46
+ originalHtml: string;
47
+ css: string;
48
+ thumbnail: string;
49
+ createdAt: string;
50
+ updatedAt: string;
51
+ status: number;
52
+ }[];
53
+ selectedTemplates: Record<number, number>;
54
+ selectedUnsubscribePages: number[];
55
+ selectedCollectionType: number;
56
+ activeType: number;
57
+ pageSelectionUpdateStatus: boolean;
58
+ pageSelectionDrawerStatus: boolean;
59
+ typeSelectionDrawerStatus: boolean;
60
+ isGlobalUnsubscribeDisabled: boolean;
61
+ isSubscriptionPreferencesCenterDisabled: boolean;
62
+ } & import("pinia").PiniaCustomStateProperties<StoreState>) => number;
63
+ getTemplatesByActiveType: (state: {
64
+ templates: {
65
+ id: number;
66
+ name: string;
67
+ type: number;
68
+ isVisible: number;
69
+ html: string;
70
+ originalHtml: string;
71
+ css: string;
72
+ thumbnail: string;
73
+ createdAt: string;
74
+ updatedAt: string;
75
+ status: number;
76
+ }[];
77
+ selectedTemplates: Record<number, number>;
78
+ selectedUnsubscribePages: number[];
79
+ selectedCollectionType: number;
80
+ activeType: number;
81
+ pageSelectionUpdateStatus: boolean;
82
+ pageSelectionDrawerStatus: boolean;
83
+ typeSelectionDrawerStatus: boolean;
84
+ isGlobalUnsubscribeDisabled: boolean;
85
+ isSubscriptionPreferencesCenterDisabled: boolean;
86
+ } & import("pinia").PiniaCustomStateProperties<StoreState>) => {
87
+ id: number;
88
+ name: string;
89
+ type: number;
90
+ isVisible: number;
91
+ html: string;
92
+ originalHtml: string;
93
+ css: string;
94
+ thumbnail: string;
95
+ createdAt: string;
96
+ updatedAt: string;
97
+ status: number;
98
+ }[];
99
+ isActiveTypeFirstInCollection: (state: {
100
+ templates: {
101
+ id: number;
102
+ name: string;
103
+ type: number;
104
+ isVisible: number;
105
+ html: string;
106
+ originalHtml: string;
107
+ css: string;
108
+ thumbnail: string;
109
+ createdAt: string;
110
+ updatedAt: string;
111
+ status: number;
112
+ }[];
113
+ selectedTemplates: Record<number, number>;
114
+ selectedUnsubscribePages: number[];
115
+ selectedCollectionType: number;
116
+ activeType: number;
117
+ pageSelectionUpdateStatus: boolean;
118
+ pageSelectionDrawerStatus: boolean;
119
+ typeSelectionDrawerStatus: boolean;
120
+ isGlobalUnsubscribeDisabled: boolean;
121
+ isSubscriptionPreferencesCenterDisabled: boolean;
122
+ } & import("pinia").PiniaCustomStateProperties<StoreState>) => boolean;
123
+ isActiveTypeLastInCollection: (state: {
124
+ templates: {
125
+ id: number;
126
+ name: string;
127
+ type: number;
128
+ isVisible: number;
129
+ html: string;
130
+ originalHtml: string;
131
+ css: string;
132
+ thumbnail: string;
133
+ createdAt: string;
134
+ updatedAt: string;
135
+ status: number;
136
+ }[];
137
+ selectedTemplates: Record<number, number>;
138
+ selectedUnsubscribePages: number[];
139
+ selectedCollectionType: number;
140
+ activeType: number;
141
+ pageSelectionUpdateStatus: boolean;
142
+ pageSelectionDrawerStatus: boolean;
143
+ typeSelectionDrawerStatus: boolean;
144
+ isGlobalUnsubscribeDisabled: boolean;
145
+ isSubscriptionPreferencesCenterDisabled: boolean;
146
+ } & import("pinia").PiniaCustomStateProperties<StoreState>) => boolean;
147
+ hasTemplatesByCollectionType: (state: {
148
+ templates: {
149
+ id: number;
150
+ name: string;
151
+ type: number;
152
+ isVisible: number;
153
+ html: string;
154
+ originalHtml: string;
155
+ css: string;
156
+ thumbnail: string;
157
+ createdAt: string;
158
+ updatedAt: string;
159
+ status: number;
160
+ }[];
161
+ selectedTemplates: Record<number, number>;
162
+ selectedUnsubscribePages: number[];
163
+ selectedCollectionType: number;
164
+ activeType: number;
165
+ pageSelectionUpdateStatus: boolean;
166
+ pageSelectionDrawerStatus: boolean;
167
+ typeSelectionDrawerStatus: boolean;
168
+ isGlobalUnsubscribeDisabled: boolean;
169
+ isSubscriptionPreferencesCenterDisabled: boolean;
170
+ } & import("pinia").PiniaCustomStateProperties<StoreState>) => Record<number, boolean>;
171
+ }, {
172
+ $reset(): void;
173
+ fetchTemplates(): Promise<void>;
174
+ setCollection(collectionType: number): void;
175
+ setCollectionWithoutAutoSelection(collectionType: number): void;
176
+ setSelectedTemplate(template: number): void;
177
+ setNextType(): void;
178
+ setPreviousType(): void;
179
+ loadSelectedTemplates(templates: number[]): void;
180
+ getThumbnailByTemplateId(id: number): string;
181
+ getSelectedTemplatesByCollection(type: number): number[];
182
+ addUnsubscribePages(pageIds: number[]): void;
183
+ removeUnsubscribePages(pageIds: number[]): void;
184
+ getSelectedUnsubscribePagesByCollection(collectionType: number): number[];
185
+ }>;
8
186
  export {};
@@ -1,9 +1,128 @@
1
- import { defineStore as e } from "pinia";
2
- const t = () => ({
3
- selectedUnsubscribePages: []
4
- }), r = e("unsubscribe", {
5
- state: () => t()
1
+ import { TYPE_COLLECTIONS as l, PAGE_TYPES as o } from "../enums/unsubscribe.js";
2
+ import { useUnsubscribeApi as p } from "../services/unsubscribeApi.js";
3
+ import { defineStore as r } from "pinia";
4
+ const a = () => ({
5
+ templates: [],
6
+ selectedTemplates: {},
7
+ selectedUnsubscribePages: [],
8
+ selectedCollectionType: o.GLOBAL_UNSUBSCRIBE,
9
+ activeType: o.GLOBAL_UNSUBSCRIBE,
10
+ pageSelectionUpdateStatus: !1,
11
+ pageSelectionDrawerStatus: !1,
12
+ typeSelectionDrawerStatus: !1,
13
+ isGlobalUnsubscribeDisabled: !1,
14
+ isSubscriptionPreferencesCenterDisabled: !1
15
+ }), u = r("unsubscribe", {
16
+ state: () => a(),
17
+ getters: {
18
+ getSelectedCollection: (e) => l[e.selectedCollectionType],
19
+ getSelectedTemplateByActiveType: (e) => e.selectedTemplates[e.activeType],
20
+ getTemplatesByActiveType: (e) => e.templates.filter((t) => t.type === e.activeType),
21
+ isActiveTypeFirstInCollection: (e) => {
22
+ const t = l[e.selectedCollectionType];
23
+ return e.activeType === t[0];
24
+ },
25
+ isActiveTypeLastInCollection: (e) => {
26
+ const t = l[e.selectedCollectionType];
27
+ return e.activeType === t[t.length - 1];
28
+ },
29
+ hasTemplatesByCollectionType: (e) => {
30
+ const t = {};
31
+ return l[e.selectedCollectionType].forEach((s) => {
32
+ t[s] = e.templates.some((i) => i.type === s);
33
+ }), t;
34
+ }
35
+ },
36
+ actions: {
37
+ $reset() {
38
+ const { templates: e, selectedUnsubscribePages: t } = this;
39
+ Object.assign(this, {
40
+ ...a(),
41
+ templates: e,
42
+ selectedUnsubscribePages: t
43
+ });
44
+ },
45
+ async fetchTemplates() {
46
+ if (this.templates.length)
47
+ return;
48
+ const { getUnsubscribePages: e } = p(), t = await e();
49
+ this.templates = t;
50
+ },
51
+ setCollection(e) {
52
+ this.selectedCollectionType = e;
53
+ const t = l[e];
54
+ if (t && t.length > 0) {
55
+ [this.activeType] = t;
56
+ const c = { ...this.selectedTemplates };
57
+ t.forEach((s) => {
58
+ if (!c[s]) {
59
+ const i = this.templates.find((n) => n.type === s);
60
+ i && (c[s] = i.id);
61
+ }
62
+ }), this.selectedTemplates = c;
63
+ }
64
+ },
65
+ setCollectionWithoutAutoSelection(e) {
66
+ this.selectedCollectionType = e;
67
+ const t = l[e];
68
+ t && t.length > 0 && ([this.activeType] = t);
69
+ },
70
+ setSelectedTemplate(e) {
71
+ this.selectedTemplates = {
72
+ ...this.selectedTemplates,
73
+ [this.activeType]: e
74
+ };
75
+ },
76
+ setNextType() {
77
+ const t = this.getSelectedCollection.indexOf(this.activeType) + 1;
78
+ t < this.getSelectedCollection.length && (this.activeType = this.getSelectedCollection[t]);
79
+ },
80
+ setPreviousType() {
81
+ const t = this.getSelectedCollection.indexOf(this.activeType) - 1;
82
+ t >= 0 && (this.activeType = this.getSelectedCollection[t]);
83
+ },
84
+ loadSelectedTemplates(e) {
85
+ const t = new Map(this.templates.map((s) => [s.id, s.type])), c = { ...this.selectedTemplates };
86
+ e.forEach((s) => {
87
+ const i = t.get(s);
88
+ i !== void 0 && (c[i] = s);
89
+ }), this.selectedTemplates = c;
90
+ },
91
+ getThumbnailByTemplateId(e) {
92
+ var t;
93
+ return ((t = this.templates.find((c) => c.id === e)) == null ? void 0 : t.thumbnail) ?? "";
94
+ },
95
+ getSelectedTemplatesByCollection(e) {
96
+ const t = l[e], c = [];
97
+ return t.forEach((s) => {
98
+ this.selectedTemplates[s] && c.push(this.selectedTemplates[s]);
99
+ }), c;
100
+ },
101
+ addUnsubscribePages(e) {
102
+ const t = /* @__PURE__ */ new Set([...this.selectedUnsubscribePages, ...e]);
103
+ this.selectedUnsubscribePages = Array.from(t);
104
+ },
105
+ removeUnsubscribePages(e) {
106
+ this.selectedUnsubscribePages = this.selectedUnsubscribePages.filter(
107
+ (t) => !e.includes(t)
108
+ );
109
+ },
110
+ getSelectedUnsubscribePagesByCollection(e) {
111
+ const t = l[e];
112
+ if (!t)
113
+ return [];
114
+ const c = /* @__PURE__ */ new Map();
115
+ this.templates.forEach((i) => {
116
+ c.set(i.id, i.type);
117
+ });
118
+ const s = new Set(t);
119
+ return this.selectedUnsubscribePages.filter((i) => {
120
+ const n = c.get(i);
121
+ return n !== void 0 && s.has(n);
122
+ });
123
+ }
124
+ }
6
125
  });
7
126
  export {
8
- r as useUnsubscribeStore
127
+ u as useUnsubscribeStore
9
128
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "1.0.2-beta.ac0dc8b",
3
+ "version": "1.0.2-beta.ad1dcd9",
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",
@@ -1 +0,0 @@
1
- export declare function migrateRadioButton(html: string): string;
@@ -1,86 +0,0 @@
1
- var b = Object.defineProperty;
2
- var f = (r, t, e) => t in r ? b(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var x = (r, t, e) => f(r, typeof t != "symbol" ? t + "" : t, e);
4
- import h from "../../extensions/Blocks/RadioButton/template.js";
5
- class T {
6
- constructor() {
7
- x(this, "parser");
8
- this.parser = new DOMParser();
9
- }
10
- migrate(t) {
11
- try {
12
- const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll("td.radio-button-block");
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(
15
- `<table id="tempDoc"><tbody><tr>${c}</tr></tbody></table>`,
16
- "text/html"
17
- ).querySelector(".radio-button-v2");
18
- y && s.parentNode && (y.setAttribute("id", o || ""), s.parentNode.replaceChild(y, s));
19
- }), e.documentElement.outerHTML);
20
- } catch (e) {
21
- return console.error("RadioButtonMigrator failed:", e), t;
22
- }
23
- }
24
- extractTextFromElement(t, e) {
25
- var n, c;
26
- const i = t.querySelector(`.${e}`);
27
- if (!i)
28
- return {
29
- text: e === "ins-title" ? "Title" : "Description",
30
- isBold: !1,
31
- isItalic: !1,
32
- align: "left",
33
- styles: "",
34
- classList: ""
35
- };
36
- const s = i.querySelector("p");
37
- if (!s)
38
- return {
39
- text: ((n = i.textContent) == null ? void 0 : n.trim()) || (e === "ins-title" ? "Title" : "Description"),
40
- isBold: !1,
41
- isItalic: !1,
42
- align: i.getAttribute("align") || "left",
43
- styles: "",
44
- classList: ""
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") || "";
47
- return {
48
- text: o,
49
- isBold: p,
50
- isItalic: u,
51
- align: a,
52
- styles: g,
53
- classList: m
54
- };
55
- }
56
- buildTextBlock(t) {
57
- let e = t.text;
58
- t.isBold && t.isItalic ? e = `<strong path="1,0"><em path="1,0,0">${e}</em></strong>` : t.isBold ? e = `<strong path="1,0">${e}</strong>` : t.isItalic && (e = `<em path="1,0">${e}</em>`);
59
- const i = t.align ? ` align="${t.align}"` : "", s = t.styles ? ` style="${t.styles.replaceAll('"', "'")}"` : "";
60
- return `
61
- <td class="esd-block-text ${t.classList}" ${i}>
62
- <p path="1" ${s}>
63
- ${e}
64
- </p>
65
- </td>
66
- `;
67
- }
68
- removeStyleProperties(t, e) {
69
- return t ? e.reduce((s, o) => {
70
- const l = new RegExp(`${o}\\s*:\\s*[^;]*;?`, "gi");
71
- return s.replace(l, "");
72
- }, t).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
73
- }
74
- convertInlineToBlock(t) {
75
- if (!t)
76
- return "";
77
- let e = t.replace(/display\s*:\s*inline/gi, "display: block");
78
- return /display\s*:/i.test(e) || (e = e ? `${e}; display: block` : "display: block"), e.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
79
- }
80
- }
81
- function A(r) {
82
- return new T().migrate(r);
83
- }
84
- export {
85
- A as migrateRadioButton
86
- };
@@ -1,10 +0,0 @@
1
- import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
2
- export declare const BLOCK_ID = "radio-button-block";
3
- export declare class RadioButtonCustomBlock extends Block {
4
- getId(): string;
5
- getIcon(): string;
6
- getBlockCompositionType(): BlockCompositionType;
7
- getName(): string;
8
- getDescription(): string;
9
- getTemplate(): string;
10
- }
@@ -1,17 +0,0 @@
1
- import { Control, ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
2
- export declare const CONTROL_BLOCK_ID = "ui-elements-radio-button";
3
- export declare class RadioButtonControl extends Control {
4
- private currentNode?;
5
- private selectedUnsubGroup?;
6
- private unsubList;
7
- getId(): string;
8
- _setFormValues(): void;
9
- _getLabel(text: string, name?: string): string;
10
- _getSelectItem(text: string, value: string): string;
11
- _getSelect(): string;
12
- getTemplate(): string;
13
- _onSelectChange(value: string | number): void;
14
- _listenToFormUpdates(): void;
15
- onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
16
- onRender(): Promise<void>;
17
- }
@@ -1,104 +0,0 @@
1
- var E = Object.defineProperty;
2
- var p = (o, i, t) => i in o ? E(o, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[i] = t;
3
- var a = (o, i, t) => p(o, typeof i != "symbol" ? i + "" : i, t);
4
- import { useHttp as m } from "../../../composables/useHttp.js";
5
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/AiAssistantValueType.js";
6
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockCompositionType.js";
7
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockName.js";
8
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockType.js";
9
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BuiltInControlTypes.js";
10
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/ContextActionType.js";
11
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/EditorStatePropertyType.js";
12
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PanelPosition.js";
13
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/Popover.js";
14
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PreviewDeviceMode.js";
15
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/SettingsTab.js";
16
- import { UEAttr as e } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementsAttributes.js";
17
- import { UIElementType as r } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementType.js";
18
- import { Control as c } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/controls/Control.js";
19
- import { ModificationDescription as d } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/modifications/ModificationDescription.js";
20
- const l = "ui-elements-radio-button", n = "select", { get: L } = m();
21
- class R extends c {
22
- constructor() {
23
- super(...arguments);
24
- a(this, "currentNode");
25
- a(this, "selectedUnsubGroup");
26
- a(this, "unsubList", []);
27
- }
28
- getId() {
29
- return l;
30
- }
31
- _setFormValues() {
32
- this.api.updateValues({
33
- [n]: ""
34
- });
35
- }
36
- _getLabel(t, s = `${Math.random()}`) {
37
- return `
38
- <${r.LABEL}
39
- ${e.LABEL.text}="${t}"
40
- ${e.LABEL.name}="${s}">
41
- </${r.LABEL}>
42
- `;
43
- }
44
- _getSelectItem(t, s) {
45
- return `
46
- <${r.SELECT_ITEM}
47
- ${e.SELECT_ITEM.text}="${t}"
48
- ${e.SELECT_ITEM.value}="${s}">
49
- </${r.SELECT_ITEM}>`;
50
- }
51
- _getSelect() {
52
- return this.unsubList.map((t) => this._getSelectItem(t.name, t.sendGridId)).join("");
53
- }
54
- getTemplate() {
55
- return `
56
- <div class="checkbox-controls-container">
57
- <div class="checkbox-select-container container two-columns stretch">
58
- <${r.LABEL}
59
- ${e.LABEL.text}="${this.api.translate("Unsubscribe Group")}"
60
- ${e.LABEL.name}="${Math.random()}">
61
- </${r.LABEL}>
62
-
63
- <${r.SELECTPICKER}
64
- ${e.SELECTPICKER.name}="${n}"
65
- ${e.SELECTPICKER.placeholder}="${this.api.translate("Select Unsubscribe Group")}">
66
- ${this._getSelect()}
67
- </${r.SELECTPICKER}>
68
- </div>
69
- </div>
70
- `;
71
- }
72
- _onSelectChange(t) {
73
- this.currentNode && this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute("id", t.toString()).apply(new d(`Updated text to ${t}`));
74
- }
75
- _listenToFormUpdates() {
76
- this.api.onValueChanged(n, (t) => this._onSelectChange(t));
77
- }
78
- onTemplateNodeUpdated(t) {
79
- if (this.currentNode = t, "getAttribute" in t) {
80
- const s = Number(t.getAttribute("id"));
81
- s && (this.selectedUnsubGroup = s, this.api.updateValues({
82
- [n]: this.selectedUnsubGroup
83
- }));
84
- }
85
- }
86
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
87
- async onRender() {
88
- const t = await L(
89
- "/unsubscribe-groups/unsubscribe-list"
90
- ), s = t.data.map((u) => ({
91
- [e.SELECT_ITEM.text]: u.name,
92
- [e.SELECT_ITEM.value]: u.sendGridId
93
- }));
94
- this.unsubList = t.data, this.api.setUIEAttribute(
95
- n,
96
- e.SELECTPICKER.items,
97
- s
98
- ), this._setFormValues(), this._listenToFormUpdates();
99
- }
100
- }
101
- export {
102
- l as CONTROL_BLOCK_ID,
103
- R as RadioButtonControl
104
- };
@@ -1,6 +0,0 @@
1
- declare const migrationTemplate = "\n <td \n align=\"left\" \n esd-extension-block-id=\"radio-button-block\" \n esd-handler-name=\"esd-extension-RadioButtonBlock\"\n class=\"radio-button-v2 esd-block-ra esd-radio-button-block esd-extension-block es-p10t es-p10b es-p30r es-p30l\"\n >\n <table cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\">\n <tbody>\n <tr>\n <td align=\"left\" width=\"70%\" style=\"vertical-align: top;\">\n <table cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\">\n <tbody>\n <tr>\n {-{-TITLE-}-}\n </tr>\n <tr>\n {-{-DESCRIPTION-}-}\n </tr>\n </tbody>\n </table>\n </td>\n <td align=\"right\" width=\"30%\" style=\"vertical-align: middle;\">\n <table cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" width=\"100%\">\n <tbody>\n <tr>\n <td width=\"50%\">\n <table width=\"100%\">\n <tr>\n <td width=\"24\">\n <input\n type=\"radio\"\n id=\"radioYes\"\n name=\"unsubscribe\"\n data-cke-editable=\"1\"\n style=\"margin: 0px; vertical-align: middle;>\n </td>\n {-{-YES-}-}\n </tr>\n </table>\n </td>\n <td width=\"50%\">\n <table width=\"100%\">\n <tr>\n <td width=\"24\">\n <input\n type=\"radio\"\n id=\"radioNo\"\n name=\"unsubscribe\"\n data-cke-editable=\"1\"\n style=\"margin: 0px; vertical-align: middle;\">\n </td>\n {-{-NO-}-}\n </tr>\n </table>\n </td>\n </tr>\n </tbody>\n </table>\n </td>\n </tr>\n </tbody>\n </table>\n </td>\n";
2
- /**
3
- * @returns The template for the default checkbox block
4
- */
5
- export declare function getDefaultTemplate(): string;
6
- export default migrationTemplate;