@useinsider/guido 3.7.0-beta.a6317a3 → 3.7.0-beta.a8c44c1

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.
@@ -1,172 +1,172 @@
1
1
  import { useConfig as V } from "./useConfig.js";
2
- import { TemplateTypes as M } from "../enums/defaults.js";
3
- import { DISPLAY_CONDITIONS_REGEX as G, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as H, CampaignCouldNotBeSavedKey as P, CanNotMakeAnyChangesForRunningKey as X, DYNAMIC_CONTENT_TAG_REGEX as Y, ALLOWED_DYNAMIC_SYSTEM_TOKENS as $, VALID_DYNAMIC_VARIABLE_REGEX as q } from "../enums/html-validator.js";
2
+ import { TemplateTypes as G } from "../enums/defaults.js";
3
+ import { DISPLAY_CONDITIONS_REGEX as H, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as M, CampaignCouldNotBeSavedKey as X, CanNotMakeAnyChangesForRunningKey as P, DATA_ATTRIBUTE_REGEX as Y, DYNAMIC_CONTENT_TAG_REGEX as $, ALLOWED_DYNAMIC_SYSTEM_TOKENS as q, VALID_DYNAMIC_VARIABLE_REGEX as K } from "../enums/html-validator.js";
4
4
  import { ToasterTypeOptions as c } from "../enums/toaster.js";
5
- import { itemsBlockDynamicVariables as K } from "../extensions/Blocks/Items/enums/productEnums.js";
6
- import { useRecommendationExtensionStore as j } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ import { itemsBlockDynamicVariables as j } from "../extensions/Blocks/Items/enums/productEnums.js";
6
+ import { useRecommendationExtensionStore as U } from "../extensions/Blocks/Recommendation/store/recommendation.js";
7
7
  import { RecommendationRequiredFieldsKey as z } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
8
- import { useRecommendationStore as U } from "../stores/recommendation.js";
9
- import { base64EncodeWithSpecialChars as Z } from "../utils/base64.js";
10
- import { useHttp as J } from "./useHttp.js";
11
- import { useToaster as Q } from "./useToaster.js";
12
- import { useTranslations as ee } from "./useTranslations.js";
13
- const te = /recommendation-id="(\d+)"/g;
14
- function se(o) {
15
- return [...o.matchAll(te)].map((d) => d[1]);
8
+ import { useRecommendationStore as Z } from "../stores/recommendation.js";
9
+ import { base64EncodeWithSpecialChars as J } from "../utils/base64.js";
10
+ import { useHttp as Q } from "./useHttp.js";
11
+ import { useToaster as ee } from "./useToaster.js";
12
+ import { useTranslations as te } from "./useTranslations.js";
13
+ const se = /recommendation-id="(\d+)"/g;
14
+ function ne(i) {
15
+ return [...i.matchAll(se)].map((d) => d[1]);
16
16
  }
17
- function ne(o, d) {
18
- return d.some((f) => o.startsWith(`${f}_`));
17
+ function ie(i, d) {
18
+ return d.some((g) => i.startsWith(`${g}_`));
19
19
  }
20
- function ie(o) {
21
- return (o.match(Y) ?? []).filter((f) => {
22
- const i = f.slice(2, -2), u = i.indexOf("|"), g = (u === -1 ? i : i.slice(0, u)).trim();
23
- return $.includes(g) ? !1 : q.test(g) ? u !== -1 && i.slice(u + 1).trim() === "" : !0;
20
+ function oe(i) {
21
+ return (i.replace(Y, "$1").match($) ?? []).filter((r) => {
22
+ const u = r.slice(2, -2), f = u.indexOf("|"), p = (f === -1 ? u : u.slice(0, f)).trim();
23
+ return q.includes(p) ? !1 : K.test(p) ? f !== -1 && u.slice(f + 1).trim() === "" : !0;
24
24
  });
25
25
  }
26
- const ve = () => {
26
+ const Ce = () => {
27
27
  var h, v;
28
- const { showToaster: o } = Q(), { post: d } = J(), { config: f } = V(), i = ee(), u = U(), g = j(), y = ((v = (h = f.value) == null ? void 0 : h.partner) == null ? void 0 : v.messageType) === M.transactional, A = async (e) => {
28
+ const { showToaster: i } = ee(), { post: d } = Q(), { config: g } = V(), r = te(), u = Z(), f = U(), p = ((v = (h = g.value) == null ? void 0 : h.partner) == null ? void 0 : v.messageType) === G.transactional, A = async (e) => {
29
29
  const t = await d(
30
30
  "/newsletter/template-library/check-template-html-body",
31
- { html: Z(e) }
31
+ { html: J(e) }
32
32
  ), { status: n, message: l } = t.data;
33
- return n || o({
33
+ return n || i({
34
34
  type: c.Alert,
35
- message: n === void 0 ? l : i("newsletter.invalid-url-link-for-toaster")
36
- }), i(P), l === i(X) && o({
35
+ message: n === void 0 ? l : r("newsletter.invalid-url-link-for-toaster")
36
+ }), r(X), l === r(P) && i({
37
37
  type: c.Alert,
38
- message: i("newsletter.already-in-progress")
38
+ message: r("newsletter.already-in-progress")
39
39
  }), n;
40
40
  }, S = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), b = (e) => ["if", "endif"].includes(e.toLowerCase()), I = (e, s) => {
41
41
  const t = e.match(/({%(.*?)%})/g);
42
42
  let n = !0;
43
- return t !== null && !y && t.forEach((l) => {
44
- const a = l.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
45
- if (a && a.length > 0) {
46
- const [r] = a;
47
- S(r) && !s.includes(r) && (o({
43
+ return t !== null && !p && t.forEach((l) => {
44
+ const o = l.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
45
+ if (o && o.length > 0) {
46
+ const [a] = o;
47
+ S(a) && !s.includes(a) && (i({
48
48
  type: c.Warning,
49
- message: i("custom-fields.invalid-custom-fields")
49
+ message: r("custom-fields.invalid-custom-fields")
50
50
  }), n = !1);
51
51
  }
52
52
  }), n;
53
- }, w = async (e, s, t) => {
53
+ }, T = async (e, s, t) => {
54
54
  const n = t ? await A(e) : !0;
55
55
  return I(e, s) && n;
56
- }, x = (e) => e.length > 0 ? !0 : (o({
56
+ }, w = (e) => e.length > 0 ? !0 : (i({
57
57
  type: c.Warning,
58
- message: i("newsletter.html-content-is-empty")
59
- }), !1), T = (e) => {
58
+ message: r("newsletter.html-content-is-empty")
59
+ }), !1), x = (e) => {
60
60
  const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
61
- return s > t && o({
61
+ return s > t && i({
62
62
  type: c.Warning,
63
- message: i("custom-fields.missing-closing-braces")
64
- }), s < t && o({
63
+ message: r("custom-fields.missing-closing-braces")
64
+ }), s < t && i({
65
65
  type: c.Warning,
66
- message: i("custom-fields.missing-opening-braces")
66
+ message: r("custom-fields.missing-opening-braces")
67
67
  }), s === t;
68
- }, k = (e) => {
69
- const s = ie(e).length === 0;
70
- return s || o({
68
+ }, _ = (e) => {
69
+ const s = oe(e).length === 0;
70
+ return s || i({
71
71
  type: c.Warning,
72
- message: i("custom-fields.invalid-custom-fields")
72
+ message: r("custom-fields.invalid-custom-fields")
73
73
  }), s;
74
- }, _ = (e, s) => {
74
+ }, k = (e, s) => {
75
75
  const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
76
- if (t && !y) {
77
- const n = new Set(s.map((r) => r.toLowerCase())), l = se(e), a = [];
78
- if (t.forEach((r) => {
79
- const m = r.slice(2, -2).trim().toLowerCase();
80
- (!n.has(m) || m === "") && !ne(m, l) && a.push(m);
81
- }), a.length > 0) {
82
- const r = `
76
+ if (t && !p) {
77
+ const n = new Set(s.map((a) => a.toLowerCase())), l = ne(e), o = [];
78
+ if (t.forEach((a) => {
79
+ const m = a.slice(2, -2).trim().toLowerCase();
80
+ (!n.has(m) || m === "") && !ie(m, l) && o.push(m);
81
+ }), o.length > 0) {
82
+ const a = `
83
83
  <ul>
84
- ${a.map((m) => `<li>${m}</li>`).join("")}
84
+ ${o.map((m) => `<li>${m}</li>`).join("")}
85
85
  </ul>
86
86
  `;
87
- return o({
87
+ return i({
88
88
  type: c.Alert,
89
- message: i("custom-fields.invalid-custom-fields") + r
89
+ message: r("custom-fields.invalid-custom-fields") + a
90
90
  }), !1;
91
91
  }
92
92
  }
93
93
  return !0;
94
- }, N = (e) => {
94
+ }, R = (e) => {
95
95
  const s = e.match(/{%(.*?)%}/g), t = [];
96
96
  let n = !0;
97
97
  if (s && s.forEach((l) => {
98
- const a = l.match(G), r = l.match(H), m = (a == null ? void 0 : a.join("")) || "";
99
- (!a || l !== m) && !r && (o({
98
+ const o = l.match(H), a = l.match(M), m = (o == null ? void 0 : o.join("")) || "";
99
+ (!o || l !== m) && !a && (i({
100
100
  type: c.Alert,
101
- message: i("newsletter.display-conditions-invalid-syntax")
102
- }), n = !1), a && a.forEach((p) => {
103
- p.trim() === "=" && (o({
101
+ message: r("newsletter.display-conditions-invalid-syntax")
102
+ }), n = !1), o && o.forEach((y) => {
103
+ y.trim() === "=" && (i({
104
104
  type: c.Alert,
105
- message: i("custom-conditions.wrong-equality-operators")
105
+ message: r("custom-conditions.wrong-equality-operators")
106
106
  }), n = !1);
107
- const C = p.match(/^[a-zA-Z]*$/g);
107
+ const C = y.match(/^[a-zA-Z]*$/g);
108
108
  C && C.forEach((E) => {
109
109
  b(E) && t.push(E);
110
110
  });
111
111
  });
112
112
  }), t.length) {
113
- const l = t.filter((r) => r === "if"), a = t.filter((r) => r === "endif");
114
- l.length !== a.length && (o({
113
+ const l = t.filter((a) => a === "if"), o = t.filter((a) => a === "endif");
114
+ l.length !== o.length && (i({
115
115
  type: c.Alert,
116
- message: i("custom-conditions.missing-if-endif-tag")
116
+ message: r("custom-conditions.missing-if-endif-tag")
117
117
  }), n = !1);
118
118
  }
119
119
  return n;
120
- }, R = (e) => {
120
+ }, N = (e) => {
121
121
  const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
122
- return n || o({
122
+ return n || i({
123
123
  type: c.Warning,
124
- message: i("custom-conditions.no-space-after-braces")
124
+ message: r("custom-conditions.no-space-after-braces")
125
125
  }), n;
126
- }, D = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (o({
126
+ }, D = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (i({
127
127
  type: c.Warning,
128
- message: i("custom-conditions.no-braces-inside-if-tag")
129
- }), !1) : !0, F = () => g.hasInvalidBlock() ? (o({
128
+ message: r("custom-conditions.no-braces-inside-if-tag")
129
+ }), !1) : !0, F = () => f.hasInvalidBlock() ? (i({
130
130
  type: c.Alert,
131
- message: i(z)
132
- }), !1) : !0, O = () => u.recommendationConfigs && Object.values(u.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (o({
131
+ message: r(z)
132
+ }), !1) : !0, O = () => u.recommendationConfigs && Object.values(u.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (i({
133
133
  type: c.Alert,
134
- message: i("newsletter.fill-all-necessary-fields")
134
+ message: r("newsletter.fill-all-necessary-fields")
135
135
  }), !1) : !0, B = (e) => {
136
136
  const s = /src="[^"]*\.(svg|pst)"/gm;
137
- return e.match(s) === null ? !0 : (o({
137
+ return e.match(s) === null ? !0 : (i({
138
138
  type: c.Alert,
139
- message: i("newsletter.invalid-image-type")
139
+ message: r("newsletter.invalid-image-type")
140
140
  }), !1);
141
141
  }, L = (e) => {
142
142
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
143
- return Array.from(n).find((a) => {
144
- var r;
145
- return !((r = a.id) != null && r.trim());
146
- }) ? (o({
143
+ return Array.from(n).find((o) => {
144
+ var a;
145
+ return !((a = o.id) != null && a.trim());
146
+ }) ? (i({
147
147
  type: c.Alert,
148
- message: i("unsubscribe-templates.select-checkbox-groups")
148
+ message: r("unsubscribe-templates.select-checkbox-groups")
149
149
  }), !1) : !0;
150
150
  }, W = (e) => {
151
151
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
152
- return Array.from(n).find((a) => {
153
- var r;
154
- return !((r = a.id) != null && r.trim());
155
- }) ? (o({
152
+ return Array.from(n).find((o) => {
153
+ var a;
154
+ return !((a = o.id) != null && a.trim());
155
+ }) ? (i({
156
156
  type: c.Alert,
157
- message: i("unsubscribe-templates.select-radio-button-groups")
157
+ message: r("unsubscribe-templates.select-radio-button-groups")
158
158
  }), !1) : !0;
159
159
  };
160
160
  return { validateHtml: async (e, s, t = !1) => {
161
- var a, r;
161
+ var o, a;
162
162
  const n = [
163
163
  ...s.map((m) => m.value),
164
- ...K,
165
- ...((r = (a = f.value) == null ? void 0 : a.template) == null ? void 0 : r.customFieldAttributes) ?? []
164
+ ...j,
165
+ ...((a = (o = g.value) == null ? void 0 : o.template) == null ? void 0 : a.customFieldAttributes) ?? []
166
166
  ];
167
- return await w(e, n, t) && x(e) && T(e) && k(e) && _(e, n) && N(e) && R(e) && D(e) && F() && O() && B(e) && L(e) && W(e);
167
+ return await T(e, n, t) && w(e) && x(e) && _(e) && k(e, n) && R(e) && N(e) && D(e) && F() && O() && B(e) && L(e) && W(e);
168
168
  } };
169
169
  };
170
170
  export {
171
- ve as useHtmlValidator
171
+ Ce as useHtmlValidator
172
172
  };
@@ -1,15 +1,15 @@
1
- const n = "newsletter.already-in-progress", e = "newsletter.campaign-could-not-be-saved", s = / (==|<=|>=|!=|>|<|in) | (if|elif|endif|else|and|or) |("[\S ]+")|('[\S ]+')|([^”\s\n]+)|(({%)|( %}))/gm, o = /{%( )*now( )(".*")( )*%}/gm, i = /\{\{[^{}]+\}\}/g, E = /^[A-Za-z0-9_.]+$/, _ = [
1
+ const n = "newsletter.already-in-progress", e = "newsletter.campaign-could-not-be-saved", s = / (==|<=|>=|!=|>|<|in) | (if|elif|endif|else|and|or) |("[\S ]+")|('[\S ]+')|([^”\s\n]+)|(({%)|( %}))/gm, o = /{%( )*now( )(".*")( )*%}/gm, E = /\{\{[^{}]+\}\}/g, i = /(\s)data-[\w-]+=(?:"[^"]*"|'[^']*')/g, t = /^[A-Za-z0-9_.]+$/, _ = [
2
2
  "ins-unsubscribe-link",
3
3
  "ins-global-unsubscribe-link",
4
- "ins-preferences-unsubscribe-link",
5
- "@COUPON_CODE"
4
+ "ins-preferences-unsubscribe-link"
6
5
  ];
7
6
  export {
8
7
  _ as ALLOWED_DYNAMIC_SYSTEM_TOKENS,
9
8
  e as CampaignCouldNotBeSavedKey,
10
9
  n as CanNotMakeAnyChangesForRunningKey,
10
+ i as DATA_ATTRIBUTE_REGEX,
11
11
  o as DISPLAY_CONDITIONS_EXCEPTIONS_REGEX,
12
12
  s as DISPLAY_CONDITIONS_REGEX,
13
- i as DYNAMIC_CONTENT_TAG_REGEX,
14
- E as VALID_DYNAMIC_VARIABLE_REGEX
13
+ E as DYNAMIC_CONTENT_TAG_REGEX,
14
+ t as VALID_DYNAMIC_VARIABLE_REGEX
15
15
  };
@@ -5,5 +5,6 @@ export declare const DISPLAY_CONDITIONS_REGEX: RegExp;
5
5
  export declare const DISPLAY_CONDITIONS_EXCEPTIONS_REGEX: RegExp;
6
6
  export declare const REMOVE_CONDITIONS_REGEX: RegExp;
7
7
  export declare const DYNAMIC_CONTENT_TAG_REGEX: RegExp;
8
+ export declare const DATA_ATTRIBUTE_REGEX: RegExp;
8
9
  export declare const VALID_DYNAMIC_VARIABLE_REGEX: RegExp;
9
10
  export declare const ALLOWED_DYNAMIC_SYSTEM_TOKENS: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.7.0-beta.a6317a3",
3
+ "version": "3.7.0-beta.a8c44c1",
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",