@useinsider/guido 1.0.2-beta.bcbaabf → 1.0.2-beta.bfb23c2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -643,7 +643,7 @@ ISC License
643
643
  ## 🎯 TODO:
644
644
  - CSS part should be optimized with variables & `sass-loader`.
645
645
  - Master Version Generator should be fixed.
646
- - Playwright integration
646
+ - Playwright integrationBoilerplate/control.ts
647
647
  - Commitlint & Precommit Hooks integration
648
648
  - Get Pre-built display conditions from API
649
649
 
@@ -1,3 +1,4 @@
1
+ import type { DynamicContent } from '@@/Types/generic';
1
2
  export declare const useHtmlValidator: () => {
2
- validateHtml: (html: string, customFields: string[], isOnSaveValidation?: boolean) => Promise<boolean>;
3
+ validateHtml: (html: string, customFields: DynamicContent[], isOnSaveValidation?: boolean) => Promise<boolean>;
3
4
  };
@@ -1,85 +1,92 @@
1
- import { useConfig as V } from "./useConfig.js";
2
- import { TemplateTypes as H } from "../enums/defaults.js";
3
- import { DISPLAY_CONDITIONS_REGEX as B, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as _, CampaignCouldNotBeSavedKey as D, CanNotMakeAnyChangesForRunningKey as P } from "../enums/html-validator.js";
4
- import { ToasterTypeOptions as r } from "../enums/toaster.js";
5
- import { useRecommendationStore as R } from "../stores/recommendation.js";
6
- import { base64EncodeWithSpecialChars as G } from "../utils/base64.js";
7
- import { useHttp as X } from "./useHttp.js";
8
- import { useToaster as j } from "./useToaster.js";
9
- import { useTranslations as q } from "./useTranslations.js";
10
- const te = () => {
1
+ import { useConfig as H } from "./useConfig.js";
2
+ import { TemplateTypes as V } from "../enums/defaults.js";
3
+ import { DISPLAY_CONDITIONS_REGEX as D, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as P, CampaignCouldNotBeSavedKey as R, CanNotMakeAnyChangesForRunningKey as _ } from "../enums/html-validator.js";
4
+ import { ToasterTypeOptions as l } from "../enums/toaster.js";
5
+ import { useRecommendationStore as G } from "../stores/recommendation.js";
6
+ import { base64EncodeWithSpecialChars as $ } from "../utils/base64.js";
7
+ import { useHttp as j } from "./useHttp.js";
8
+ import { useToaster as q } from "./useToaster.js";
9
+ import { useTranslations as M } from "./useTranslations.js";
10
+ const se = () => {
11
11
  var d;
12
- const { showToaster: a } = j(), { post: y } = X(), { config: h } = V(), i = q(), m = R(), u = ((d = h.partner) == null ? void 0 : d.messageType) === H.transactional, C = async (e) => {
12
+ const { showToaster: c } = q(), { post: y } = j(), { config: h } = H(), a = M(), m = G(), u = ((d = h.partner) == null ? void 0 : d.messageType) === V.transactional, v = async (e) => {
13
13
  const t = await y(
14
14
  "/newsletter/template-library/check-template-html-body",
15
- { html: G(e) }
16
- ), { status: n, message: c } = t.data;
17
- return n || a({
18
- type: r.Alert,
19
- message: n === void 0 ? c : i("newsletter.invalid-url-link-for-toaster")
20
- }), i(D), c === i(P) && a({
21
- type: r.Alert,
22
- message: i("newsletter.already-in-progress")
15
+ { html: $(e) }
16
+ ), { status: n, message: r } = t.data;
17
+ return n || c({
18
+ type: l.Alert,
19
+ message: n === void 0 ? r : a("newsletter.invalid-url-link-for-toaster")
20
+ }), a(R), r === a(_) && c({
21
+ type: l.Alert,
22
+ message: a("newsletter.already-in-progress")
23
23
  }), n;
24
- }, v = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), w = (e) => ["if", "endif"].includes(e.toLowerCase()), S = (e, s) => {
24
+ }, C = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), w = (e) => ["if", "endif"].includes(e.toLowerCase()), S = (e, s) => {
25
25
  const t = e.match(/({%(.*?)%})/g);
26
26
  let n = !0;
27
- return t !== null && !u && t.forEach((c) => {
28
- const o = c.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
27
+ return t !== null && !u && t.forEach((r) => {
28
+ const o = r.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
29
29
  if (o && o.length > 0) {
30
- const [l] = o;
31
- v(l) && !s.includes(l) && (a({
32
- type: r.Warning,
33
- message: i("custom-fields.invalid-custom-fields")
30
+ const [i] = o;
31
+ C(i) && !s.includes(i) && (c({
32
+ type: l.Warning,
33
+ message: a("custom-fields.invalid-custom-fields")
34
34
  }), n = !1);
35
35
  }
36
36
  }), n;
37
37
  }, b = async (e, s, t) => {
38
- const n = t ? await C(e) : !0;
38
+ const n = t ? await v(e) : !0;
39
39
  return S(e, s) && n;
40
- }, E = (e) => e.length > 0 ? !0 : (a({
41
- type: r.Warning,
42
- message: i("newsletter.html-content-is-empty")
43
- }), !1), x = (e) => {
40
+ }, E = (e) => e.length > 0 ? !0 : (c({
41
+ type: l.Warning,
42
+ message: a("newsletter.html-content-is-empty")
43
+ }), !1), A = (e) => {
44
44
  const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
45
- return s > t && a({
46
- type: r.Warning,
47
- message: i("custom-fields.missing-closing-braces")
48
- }), s < t && a({
49
- type: r.Warning,
50
- message: i("custom-fields.missing-opening-braces")
45
+ return s > t && c({
46
+ type: l.Warning,
47
+ message: a("custom-fields.missing-closing-braces")
48
+ }), s < t && c({
49
+ type: l.Warning,
50
+ message: a("custom-fields.missing-opening-braces")
51
51
  }), s === t;
52
- }, A = (e) => {
52
+ }, x = (e) => {
53
53
  const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
54
- return s || a({
55
- type: r.Warning,
56
- message: i("custom-fields.invalid-custom-fields")
54
+ return s || c({
55
+ type: l.Warning,
56
+ message: a("custom-fields.invalid-custom-fields")
57
57
  }), s;
58
- }, T = (e, s) => {
58
+ }, k = (e, s) => {
59
59
  const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
60
60
  if (t && !u) {
61
- const n = s.map((o) => o.toLowerCase()), c = t.some((o) => {
62
- const l = o.replace("{{", "").replace("}}", "").trim().toLowerCase();
63
- return !n.includes(l) || l === "";
64
- });
65
- return c && a({
66
- type: r.Warning,
67
- message: i("custom-fields.invalid-custom-fields")
68
- }), !c;
61
+ const n = new Set(s.map((o) => o.toLowerCase())), r = [];
62
+ if (t.forEach((o) => {
63
+ const i = o.slice(2, -2).trim().toLowerCase();
64
+ (!n.has(i) || i === "") && r.push(i);
65
+ }), r.length > 0) {
66
+ const o = `
67
+ <ul>
68
+ ${r.map((i) => `<li>${i}</li>`).join("")}
69
+ </ul>
70
+ `;
71
+ return c({
72
+ type: l.Alert,
73
+ message: a("custom-fields.invalid-custom-fields") + o
74
+ }), !1;
75
+ }
69
76
  }
70
77
  return !0;
71
- }, k = (e) => {
78
+ }, T = (e) => {
72
79
  const s = e.match(/{%(.*?)%}/g), t = [];
73
80
  let n = !0;
74
- if (s && s.forEach((c) => {
75
- const o = c.match(B), l = c.match(_), O = (o == null ? void 0 : o.join("")) || "";
76
- (!o || c !== O) && !l && (a({
77
- type: r.Alert,
78
- message: i("newsletter.display-conditions-invalid-syntax")
81
+ if (s && s.forEach((r) => {
82
+ const o = r.match(D), i = r.match(P), B = (o == null ? void 0 : o.join("")) || "";
83
+ (!o || r !== B) && !i && (c({
84
+ type: l.Alert,
85
+ message: a("newsletter.display-conditions-invalid-syntax")
79
86
  }), n = !1), o && o.forEach((f) => {
80
- f.trim() === "=" && (a({
81
- type: r.Alert,
82
- message: i("custom-conditions.wrong-equality-operators")
87
+ f.trim() === "=" && (c({
88
+ type: l.Alert,
89
+ message: a("custom-conditions.wrong-equality-operators")
83
90
  }), n = !1);
84
91
  const g = f.match(/^[a-zA-Z]*$/g);
85
92
  g && g.forEach((p) => {
@@ -87,43 +94,55 @@ const te = () => {
87
94
  });
88
95
  });
89
96
  }), t.length) {
90
- const c = t.filter((l) => l === "if"), o = t.filter((l) => l === "endif");
91
- c.length !== o.length && (a({
92
- type: r.Alert,
93
- message: i("custom-conditions.missing-if-endif-tag")
97
+ const r = t.filter((i) => i === "if"), o = t.filter((i) => i === "endif");
98
+ r.length !== o.length && (c({
99
+ type: l.Alert,
100
+ message: a("custom-conditions.missing-if-endif-tag")
94
101
  }), n = !1);
95
102
  }
96
103
  return n;
97
- }, I = (e) => {
104
+ }, F = (e) => {
98
105
  const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
99
- return n || a({
100
- type: r.Warning,
101
- message: i("custom-conditions.no-space-after-braces")
106
+ return n || c({
107
+ type: l.Warning,
108
+ message: a("custom-conditions.no-space-after-braces")
102
109
  }), n;
103
- }, W = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (a({
104
- type: r.Warning,
105
- message: i("custom-conditions.no-braces-inside-if-tag")
106
- }), !1) : !0, F = () => m.recommendationConfigs && Object.values(m.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (a({
107
- type: r.Alert,
108
- message: i("newsletter.fill-all-necessary-fields")
109
- }), !1) : !0, N = (e) => {
110
+ }, I = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (c({
111
+ type: l.Warning,
112
+ message: a("custom-conditions.no-braces-inside-if-tag")
113
+ }), !1) : !0, W = () => m.recommendationConfigs && Object.values(m.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (c({
114
+ type: l.Alert,
115
+ message: a("newsletter.fill-all-necessary-fields")
116
+ }), !1) : !0, L = (e) => {
110
117
  const s = /src="[^"]*\.(svg|pst)"/gm;
111
- return e.match(s) === null ? !0 : (a({
112
- type: r.Alert,
113
- message: i("newsletter.invalid-image-type")
118
+ return e.match(s) === null ? !0 : (c({
119
+ type: l.Alert,
120
+ message: a("newsletter.invalid-image-type")
114
121
  }), !1);
115
- }, L = (e) => {
122
+ }, N = (e) => {
116
123
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
117
124
  return Array.from(n).find((o) => {
118
- var l;
119
- return !((l = o.id) != null && l.trim());
120
- }) ? (a({
121
- type: r.Alert,
122
- message: i("unsubscribe-templates.select-checkbox-groups")
125
+ var i;
126
+ return !((i = o.id) != null && i.trim());
127
+ }) ? (c({
128
+ type: l.Alert,
129
+ message: a("unsubscribe-templates.select-checkbox-groups")
130
+ }), !1) : !0;
131
+ }, O = (e) => {
132
+ const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
133
+ return Array.from(n).find((o) => {
134
+ var i;
135
+ return !((i = o.id) != null && i.trim());
136
+ }) ? (c({
137
+ type: l.Alert,
138
+ message: a("unsubscribe-templates.select-radio-button-groups")
123
139
  }), !1) : !0;
124
140
  };
125
- return { validateHtml: async (e, s, t = !1) => await b(e, s, t) && E(e) && x(e) && A(e) && T(e, s) && k(e) && I(e) && W(e) && F() && N(e) && L(e) };
141
+ return { validateHtml: async (e, s, t = !1) => {
142
+ const n = s.map((o) => o.value);
143
+ return await b(e, n, t) && E(e) && A(e) && x(e) && k(e, n) && T(e) && F(e) && I(e) && W() && L(e) && N(e) && O(e);
144
+ } };
126
145
  };
127
146
  export {
128
- te as useHtmlValidator
147
+ se as useHtmlValidator
129
148
  };
@@ -1,12 +1,12 @@
1
- import { useSaveStart as i, useSaveComplete as l } from "./useGuidoActions.js";
2
- import { useTemplatePreparation as m } from "../utils/templatePreparation.js";
3
- import { useHtmlValidator as n } from "./useHtmlValidator.js";
1
+ import { useSaveStart as i, useSaveComplete as m } from "./useGuidoActions.js";
2
+ import { useTemplatePreparation as n } from "../utils/templatePreparation.js";
3
+ import { useHtmlValidator as l } from "./useHtmlValidator.js";
4
4
  const f = () => {
5
- const e = i(), a = l(), { validateHtml: s } = n();
5
+ const e = i(), a = m(), { validateHtml: s } = l();
6
6
  return { save: async (o = !1) => {
7
7
  e();
8
- const { prepareTemplateDetails: r } = m(), t = await r();
9
- if (await s(t.compiledHtml, [], !0))
8
+ const { prepareTemplateDetails: r } = n(), t = await r();
9
+ if (await s(t.compiledHtml, t.dynamicContentList, !0))
10
10
  return o || a(t), t;
11
11
  } };
12
12
  };
@@ -1,16 +1,17 @@
1
1
  import { useActionsApi as f } from "./useActionsApi.js";
2
2
  import { useCustomInterfaceAppearance as S } from "./useCustomInterfaceAppearance.js";
3
- import { useStripoEventHandler as C } from "./useStripoEventHandler.js";
4
- import { useToaster as E } from "./useToaster.js";
3
+ import { useStripoEventHandler as E } from "./useStripoEventHandler.js";
4
+ import { useToaster as C } from "./useToaster.js";
5
5
  import { displayConditions as y } from "../enums/displayConditions.js";
6
6
  import h from "../extensions/Blocks/Checkbox/extension.js";
7
- import w from "../extensions/DynamicContent/extension.js";
8
- import { useStripoApi as b } from "../services/stripoApi.js";
9
- import k from "../static/styles/customEditorStyle.css.js";
7
+ import w from "../extensions/Blocks/RadioButton/extension.js";
8
+ import b from "../extensions/DynamicContent/extension.js";
9
+ import { useStripoApi as k } from "../services/stripoApi.js";
10
+ import B from "../static/styles/customEditorStyle.css.js";
10
11
  import { useEditorStore as V } from "../stores/editor.js";
11
12
  import { dynamicContentToMergeTags as _ } from "../utils/genericUtil.js";
12
- const H = (s) => {
13
- const { handleError: d } = E(), { getToken: c, getCustomFonts: u } = b(), { handleEvent: l } = C(), m = (r, i = []) => {
13
+ const q = (s) => {
14
+ const { handleError: d } = C(), { getToken: c, getCustomFonts: u } = k(), { handleEvent: l } = E(), m = (r, i = []) => {
14
15
  const o = V(), { html: e, css: a, forceRecreate: g } = r;
15
16
  window.UIEditor.initEditor(
16
17
  document.querySelector("#guido-editor"),
@@ -28,7 +29,7 @@ const H = (s) => {
28
29
  customAppearanceMergetags: !0,
29
30
  customAppearanceMergetagsBorderColor: "#f1f3fe",
30
31
  customAppearanceMergetagsBackgroundColor: "#f1f3fe",
31
- customViewStyles: k,
32
+ customViewStyles: B,
32
33
  conditionsEnabled: !0,
33
34
  customConditionsEnabled: !0,
34
35
  conditionCategories: y,
@@ -77,7 +78,11 @@ const H = (s) => {
77
78
  },
78
79
  onEvent: l,
79
80
  ignoreClickOutsideSelectors: ["#guido-dynamic-content-modal", ".in-on-board-wrapper"],
80
- extensions: [w, h]
81
+ extensions: [
82
+ b,
83
+ h,
84
+ w
85
+ ]
81
86
  }
82
87
  );
83
88
  }, p = (r) => new Promise((i, o) => {
@@ -101,5 +106,5 @@ const H = (s) => {
101
106
  } };
102
107
  };
103
108
  export {
104
- H as useStripo
109
+ q as useStripo
105
110
  };
@@ -1,5 +1,9 @@
1
- import { migrateCheckbox as r } from "./checkboxMigrator.js";
2
- const e = (o) => r(o);
1
+ import { migrateCheckbox as o } from "./checkboxMigrator.js";
2
+ import { migrateRadioButton as e } from "./radioButtonMigrator.js";
3
+ const a = (r) => {
4
+ let t = r;
5
+ return t = o(r), t = e(r), t;
6
+ };
3
7
  export {
4
- e as migrate
8
+ a as migrate
5
9
  };
@@ -0,0 +1 @@
1
+ export declare function migrateRadioButton(html: string): string;
@@ -0,0 +1,86 @@
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
+ };
@@ -0,0 +1,10 @@
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
+ }
@@ -0,0 +1,39 @@
1
+ import { Block as t } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/blocks/Block.js";
2
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/AiAssistantValueType.js";
3
+ import { BlockCompositionType as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockCompositionType.js";
4
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockName.js";
5
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockType.js";
6
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BuiltInControlTypes.js";
7
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/ContextActionType.js";
8
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/EditorStatePropertyType.js";
9
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PanelPosition.js";
10
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/Popover.js";
11
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PreviewDeviceMode.js";
12
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/SettingsTab.js";
13
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementType.js";
14
+ import { getDefaultTemplate as r } from "./template.js";
15
+ const i = "radio-button-block";
16
+ class D extends t {
17
+ getId() {
18
+ return i;
19
+ }
20
+ getIcon() {
21
+ return "circle";
22
+ }
23
+ getBlockCompositionType() {
24
+ return o.BLOCK;
25
+ }
26
+ getName() {
27
+ return this.api.translate("Radio Button Block");
28
+ }
29
+ getDescription() {
30
+ return this.api.translate("Radio Button Block Description");
31
+ }
32
+ getTemplate() {
33
+ return r();
34
+ }
35
+ }
36
+ export {
37
+ i as BLOCK_ID,
38
+ D as RadioButtonCustomBlock
39
+ };
@@ -0,0 +1,17 @@
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
+ }
@@ -0,0 +1,104 @@
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
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@stripoinc/ui-editor-extensions").Extension;
2
+ export default _default;
@@ -0,0 +1,20 @@
1
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/AiAssistantValueType.js";
2
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockCompositionType.js";
3
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockName.js";
4
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockType.js";
5
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BuiltInControlTypes.js";
6
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/ContextActionType.js";
7
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/EditorStatePropertyType.js";
8
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PanelPosition.js";
9
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/Popover.js";
10
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PreviewDeviceMode.js";
11
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/SettingsTab.js";
12
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementType.js";
13
+ import { ExtensionBuilder as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/ExtensionBuilder.js";
14
+ import { RadioButtonCustomBlock as t } from "./block.js";
15
+ import { RadioButtonControl as i } from "./control.js";
16
+ import { RadioButtonBlockSettingsPanel as r } from "./settingsPanel.js";
17
+ const C = new o().addBlock(t).withSettingsPanelRegistry(r).addControl(i).build();
18
+ export {
19
+ C as default
20
+ };
@@ -0,0 +1,4 @@
1
+ import { SettingsPanelRegistry, SettingsPanelTab } from '@stripoinc/ui-editor-extensions';
2
+ export declare class RadioButtonBlockSettingsPanel extends SettingsPanelRegistry {
3
+ registerBlockControls(blockControlsMap: Record<string, SettingsPanelTab[]>): void;
4
+ }
@@ -0,0 +1,39 @@
1
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/AiAssistantValueType.js";
2
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockCompositionType.js";
3
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockName.js";
4
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockType.js";
5
+ import { ContainerControls as t, TextControls as m } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BuiltInControlTypes.js";
6
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/ContextActionType.js";
7
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/EditorStatePropertyType.js";
8
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PanelPosition.js";
9
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/Popover.js";
10
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PreviewDeviceMode.js";
11
+ import { SettingsTab as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/SettingsTab.js";
12
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementType.js";
13
+ import { SettingsPanelRegistry as e } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/controls/SettingsPanelRegistry.js";
14
+ import { SettingsPanelTab as r } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/controls/SettingsPanelTab.js";
15
+ import { BLOCK_ID as p } from "./block.js";
16
+ import { CONTROL_BLOCK_ID as n } from "./control.js";
17
+ class K extends e {
18
+ registerBlockControls(i) {
19
+ i[p] = [
20
+ new r(
21
+ o.SETTINGS,
22
+ [
23
+ n,
24
+ t.EXTERNAL_INDENTS,
25
+ t.DISPLAY_CONDITIONS
26
+ ]
27
+ ),
28
+ new r(
29
+ o.STYLES,
30
+ [
31
+ m.TEXT_BLOCK_BACKGROUND_COLOR
32
+ ]
33
+ )
34
+ ];
35
+ }
36
+ }
37
+ export {
38
+ K as RadioButtonBlockSettingsPanel
39
+ };
@@ -0,0 +1,6 @@
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;
@@ -0,0 +1,160 @@
1
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/AiAssistantValueType.js";
2
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockCompositionType.js";
3
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockName.js";
4
+ import { BlockType as t } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockType.js";
5
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BuiltInControlTypes.js";
6
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/ContextActionType.js";
7
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/EditorStatePropertyType.js";
8
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PanelPosition.js";
9
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/Popover.js";
10
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PreviewDeviceMode.js";
11
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/SettingsTab.js";
12
+ import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementType.js";
13
+ const e = {
14
+ TITLE: "This is a title text",
15
+ DESCRIPTION: "This is a description text",
16
+ YES: "Yes",
17
+ NO: "No"
18
+ }, i = `
19
+ <td align="left" class="radio-button-v2 esd-block-radio es-p10t es-p10b es-p30r es-p30l">
20
+ <table cellpadding="0" cellspacing="0" role="presentation" width="100%">
21
+ <tbody>
22
+ <tr>
23
+ <td align="left" width="70%" style="vertical-align: top;">
24
+ <table cellpadding="0" cellspacing="0" role="presentation" width="100%">
25
+ <tbody>
26
+ <${t.BLOCK_TEXT}>
27
+ {-{-TITLE-}-}
28
+ </${t.BLOCK_TEXT}>
29
+ <${t.BLOCK_TEXT}>
30
+ {-{-DESCRIPTION-}-}
31
+ </${t.BLOCK_TEXT}>
32
+ </tbody>
33
+ </table>
34
+ </td>
35
+ <td align="right" width="30%" style="vertical-align: middle;">
36
+ <table cellpadding="0" cellspacing="0" role="presentation" width="100%">
37
+ <tbody>
38
+ <tr>
39
+ <td width="50%">
40
+ <table width="100%">
41
+ <tr>
42
+ <td width="24">
43
+ <input
44
+ type="radio"
45
+ id="radioYes"
46
+ name="unsubscribe"
47
+ data-cke-editable="1"
48
+ style="margin: 0px; vertical-align: middle;">
49
+ </td>
50
+ <td style="padding-right: 15px;">
51
+ <table width="100%">
52
+ <${t.BLOCK_TEXT}>
53
+ {-{-YES-}-}
54
+ </${t.BLOCK_TEXT}>
55
+ </table>
56
+ </td>
57
+ </tr>
58
+ </table>
59
+ </td>
60
+ <td width="50%">
61
+ <table width="100%">
62
+ <tr>
63
+ <td width="24">
64
+ <input
65
+ type="radio"
66
+ id="radioNo"
67
+ name="unsubscribe"
68
+ data-cke-editable="1"
69
+ style="margin: 0px; vertical-align: middle;">
70
+ </td>
71
+ <td style="padding-right: 15px;">
72
+ <table width="100%">
73
+ <${t.BLOCK_TEXT}>
74
+ {-{-NO-}-}
75
+ </${t.BLOCK_TEXT}>
76
+ </table>
77
+ </td>
78
+ </tr>
79
+ </table>
80
+ </td>
81
+ </tr>
82
+ </tbody>
83
+ </table>
84
+ </td>
85
+ </tr>
86
+ </tbody>
87
+ </table>
88
+ </td>
89
+ `, h = `
90
+ <td
91
+ align="left"
92
+ esd-extension-block-id="radio-button-block"
93
+ esd-handler-name="esd-extension-RadioButtonBlock"
94
+ class="radio-button-v2 esd-block-ra esd-radio-button-block esd-extension-block es-p10t es-p10b es-p30r es-p30l"
95
+ >
96
+ <table cellpadding="0" cellspacing="0" role="presentation" width="100%">
97
+ <tbody>
98
+ <tr>
99
+ <td align="left" width="70%" style="vertical-align: top;">
100
+ <table cellpadding="0" cellspacing="0" role="presentation" width="100%">
101
+ <tbody>
102
+ <tr>
103
+ {-{-TITLE-}-}
104
+ </tr>
105
+ <tr>
106
+ {-{-DESCRIPTION-}-}
107
+ </tr>
108
+ </tbody>
109
+ </table>
110
+ </td>
111
+ <td align="right" width="30%" style="vertical-align: middle;">
112
+ <table cellpadding="0" cellspacing="0" role="presentation" width="100%">
113
+ <tbody>
114
+ <tr>
115
+ <td width="50%">
116
+ <table width="100%">
117
+ <tr>
118
+ <td width="24">
119
+ <input
120
+ type="radio"
121
+ id="radioYes"
122
+ name="unsubscribe"
123
+ data-cke-editable="1"
124
+ style="margin: 0px; vertical-align: middle;>
125
+ </td>
126
+ {-{-YES-}-}
127
+ </tr>
128
+ </table>
129
+ </td>
130
+ <td width="50%">
131
+ <table width="100%">
132
+ <tr>
133
+ <td width="24">
134
+ <input
135
+ type="radio"
136
+ id="radioNo"
137
+ name="unsubscribe"
138
+ data-cke-editable="1"
139
+ style="margin: 0px; vertical-align: middle;">
140
+ </td>
141
+ {-{-NO-}-}
142
+ </tr>
143
+ </table>
144
+ </td>
145
+ </tr>
146
+ </tbody>
147
+ </table>
148
+ </td>
149
+ </tr>
150
+ </tbody>
151
+ </table>
152
+ </td>
153
+ `;
154
+ function m() {
155
+ return i.replace("{-{-TITLE-}-}", `<p path="1">${e.TITLE}</p>`).replace("{-{-DESCRIPTION-}-}", `<p path="1">${e.DESCRIPTION}</p>`).replace("{-{-YES-}-}", `<p path="1">${e.YES}</p>`).replace("{-{-NO-}-}", `<p path="1">${e.NO}</p>`);
156
+ }
157
+ export {
158
+ h as default,
159
+ m as getDefaultTemplate
160
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "1.0.2-beta.bcbaabf",
3
+ "version": "1.0.2-beta.bfb23c2",
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",