@useinsider/guido 3.15.0 → 3.15.1-beta.6da4177

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 (24) hide show
  1. package/dist/composables/useHtmlValidator.js +50 -50
  2. package/dist/config/i18n/en/labels.json.js +7 -3
  3. package/dist/config/migrator/recommendation/compositionMapper.js +26 -23
  4. package/dist/config/migrator/recommendation/htmlBuilder.js +156 -155
  5. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +18 -15
  6. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +363 -322
  7. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +8 -8
  8. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +271 -231
  9. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +16 -16
  10. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +16 -16
  11. package/dist/extensions/Blocks/Recommendation/templates/utils.js +120 -120
  12. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +55 -54
  13. package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +89 -0
  14. package/dist/extensions/Blocks/common-control.js +42 -35
  15. package/dist/src/composables/useHtmlValidator.d.ts +3 -2
  16. package/dist/src/config/migrator/recommendation/types.d.ts +1 -0
  17. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  18. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +6 -0
  19. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +27 -5
  20. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +4 -2
  21. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +12 -11
  22. package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +47 -0
  23. package/dist/src/extensions/Blocks/common-control.d.ts +3 -1
  24. package/package.json +1 -1
@@ -6,7 +6,7 @@ import { ToasterTypeOptions as c } from "../enums/toaster.js";
6
6
  import { itemsBlockDynamicVariables as q } from "../extensions/Blocks/Items/enums/productEnums.js";
7
7
  import { RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES as K } from "../extensions/Blocks/Recommendation/constants/selectors.js";
8
8
  import { useRecommendationExtensionStore as z } from "../extensions/Blocks/Recommendation/store/recommendation.js";
9
- import { resolveProductAttrValue as Z } from "../extensions/Blocks/Recommendation/templates/utils.js";
9
+ import { filterToProductAttrValue as Z } from "../extensions/Blocks/Recommendation/utils/compositionKeys.js";
10
10
  import { RecommendationRequiredFieldsKey as J } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
11
11
  import { useRecommendationStore as Q } from "../stores/recommendation.js";
12
12
  import { base64EncodeWithSpecialChars as ee } from "../utils/base64.js";
@@ -15,25 +15,25 @@ import { useHttp as ne } from "./useHttp.js";
15
15
  import { useToaster as se } from "./useToaster.js";
16
16
  import { useTranslations as re } from "./useTranslations.js";
17
17
  const oe = /recommendation-id="(\d+)"/g;
18
- function ie(n) {
19
- return [...n.matchAll(oe)].map((m) => m[1]);
18
+ function ie(s) {
19
+ return [...s.matchAll(oe)].map((m) => m[1]);
20
20
  }
21
- function ae(n, m) {
22
- return m.some((f) => n.startsWith(`${f}_`));
21
+ function ae(s, m) {
22
+ return m.some((f) => s.startsWith(`${f}_`));
23
23
  }
24
24
  const ce = /^(\d+)_\d+_(.+)$/;
25
- function le(n) {
26
- const m = n.match(ce);
25
+ function le(s) {
26
+ const m = s.match(ce);
27
27
  return m ? { recoId: m[1], attribute: m[2] } : null;
28
28
  }
29
- function me(n) {
29
+ function me(s) {
30
30
  const m = new Set(K);
31
- return Object.values(n).forEach((f) => {
32
- m.add(Z(f.attributeName, n).toLowerCase());
31
+ return Object.values(s).forEach((f) => {
32
+ m.add(Z(f).toLowerCase());
33
33
  }), m;
34
34
  }
35
- function ue(n, m, f, o, d) {
36
- const u = n.match(/{{([a-zA-Z0-9_.\s]*)}}/gm);
35
+ function ue(s, m, f, o, d) {
36
+ const u = s.match(/{{([a-zA-Z0-9_.\s]*)}}/gm);
37
37
  if (!u)
38
38
  return [];
39
39
  const g = new Set(m.map((h) => h.toLowerCase())), E = [];
@@ -51,14 +51,14 @@ function ue(n, m, f, o, d) {
51
51
  ae(p, f) || p.includes(".") || E.push(p);
52
52
  }), E;
53
53
  }
54
- function de(n) {
55
- return (n.replace($, "$1").match(Y) ?? []).filter((o) => {
54
+ function de(s) {
55
+ return (s.replace($, "$1").match(Y) ?? []).filter((o) => {
56
56
  const d = o.slice(2, -2), u = d.indexOf("|"), g = (u === -1 ? d : d.slice(0, u)).trim();
57
57
  return U.includes(g) ? !1 : j.test(g) ? u !== -1 && d.slice(u + 1).trim() === "" : !0;
58
58
  });
59
59
  }
60
60
  const xe = () => {
61
- const { showToaster: n } = se(), { post: m } = ne(), { config: f } = V(), o = re(), d = Q(), u = z(), g = te(
61
+ const { showToaster: s } = se(), { post: m } = ne(), { config: f } = V(), o = re(), d = Q(), u = z(), g = te(
62
62
  () => {
63
63
  var e, t;
64
64
  return ((t = (e = f.value) == null ? void 0 : e.partner) == null ? void 0 : t.messageType) === W.transactional;
@@ -73,59 +73,59 @@ const xe = () => {
73
73
  }
74
74
  return me(u.filterList);
75
75
  }, h = async (e) => {
76
- const s = await m(
76
+ const n = await m(
77
77
  "/newsletter/template-library/check-template-html-body",
78
78
  { html: ee(e) }
79
- ), { status: r, message: a } = s.data;
80
- return r || n({
79
+ ), { status: r, message: a } = n.data;
80
+ return r || s({
81
81
  type: c.Error,
82
82
  message: r === void 0 ? a : o("newsletter.invalid-url-link-for-toaster")
83
- }), o(P), a === o(X) && n({
83
+ }), o(P), a === o(X) && s({
84
84
  type: c.Error,
85
85
  message: o("newsletter.already-in-progress")
86
86
  }), r;
87
87
  }, p = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), y = (e) => ["if", "endif"].includes(e.toLowerCase()), S = (e, t) => {
88
- const s = e.match(/({%(.*?)%})/g);
88
+ const n = e.match(/({%(.*?)%})/g);
89
89
  let r = !0;
90
- return s !== null && !g.value && s.forEach((a) => {
90
+ return n !== null && !g.value && n.forEach((a) => {
91
91
  const i = a.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
92
92
  if (i && i.length > 0) {
93
93
  const [l] = i;
94
- p(l) && !t.includes(l) && (n({
94
+ p(l) && !t.includes(l) && (s({
95
95
  type: c.Warning,
96
96
  message: o("custom-fields.invalid-custom-fields")
97
97
  }), r = !1);
98
98
  }
99
99
  }), r;
100
- }, A = async (e, t, s) => {
101
- const r = s ? await h(e) : !0;
100
+ }, A = async (e, t, n) => {
101
+ const r = n ? await h(e) : !0;
102
102
  return S(e, t) && r;
103
- }, T = (e) => e.length > 0 ? !0 : (n({
103
+ }, T = (e) => e.length > 0 ? !0 : (s({
104
104
  type: c.Warning,
105
105
  message: o("newsletter.html-content-is-empty")
106
106
  }), !1), w = (e) => {
107
- const t = (e.match(/{/gm) || []).length, s = (e.match(/}/gm) || []).length;
108
- return t > s && n({
107
+ const t = (e.match(/{/gm) || []).length, n = (e.match(/}/gm) || []).length;
108
+ return t > n && s({
109
109
  type: c.Warning,
110
110
  message: o("custom-fields.missing-closing-braces")
111
- }), t < s && n({
111
+ }), t < n && s({
112
112
  type: c.Warning,
113
113
  message: o("custom-fields.missing-opening-braces")
114
- }), t === s;
114
+ }), t === n;
115
115
  }, R = (e) => {
116
116
  const t = de(e).length === 0;
117
- return t || n({
117
+ return t || s({
118
118
  type: c.Warning,
119
119
  message: o("custom-fields.invalid-custom-fields")
120
120
  }), t;
121
- }, _ = (e, t, s, r) => {
121
+ }, _ = (e, t, n, r) => {
122
122
  if (g.value)
123
123
  return !0;
124
124
  const a = ue(
125
125
  e,
126
126
  t,
127
127
  ie(e),
128
- s,
128
+ n,
129
129
  r
130
130
  );
131
131
  if (a.length > 0) {
@@ -134,56 +134,56 @@ const xe = () => {
134
134
  ${a.map((l) => `<li>${l}</li>`).join("")}
135
135
  </ul>
136
136
  `;
137
- return n({
137
+ return s({
138
138
  type: c.Error,
139
139
  message: o("custom-fields.invalid-custom-fields") + i
140
140
  }), !1;
141
141
  }
142
142
  return !0;
143
143
  }, N = (e) => {
144
- const t = e.match(/{%(.*?)%}/g), s = [];
144
+ const t = e.match(/{%(.*?)%}/g), n = [];
145
145
  let r = !0;
146
146
  if (t && t.forEach((a) => {
147
147
  const i = a.match(G), l = a.match(H), C = (i == null ? void 0 : i.join("")) || "";
148
- (!i || a !== C) && !l && (n({
148
+ (!i || a !== C) && !l && (s({
149
149
  type: c.Error,
150
150
  message: o("newsletter.display-conditions-invalid-syntax")
151
151
  }), r = !1), i && i.forEach((v) => {
152
- v.trim() === "=" && (n({
152
+ v.trim() === "=" && (s({
153
153
  type: c.Error,
154
154
  message: o("custom-conditions.wrong-equality-operators")
155
155
  }), r = !1);
156
156
  const I = v.match(/^[a-zA-Z]*$/g);
157
157
  I && I.forEach((b) => {
158
- y(b) && s.push(b);
158
+ y(b) && n.push(b);
159
159
  });
160
160
  });
161
- }), s.length) {
162
- const a = s.filter((l) => l === "if"), i = s.filter((l) => l === "endif");
163
- a.length !== i.length && (n({
161
+ }), n.length) {
162
+ const a = n.filter((l) => l === "if"), i = n.filter((l) => l === "endif");
163
+ a.length !== i.length && (s({
164
164
  type: c.Error,
165
165
  message: o("custom-conditions.missing-if-endif-tag")
166
166
  }), r = !1);
167
167
  }
168
168
  return r;
169
169
  }, x = (e) => {
170
- const t = (e.match(/{% /gm) || []).length, s = (e.match(/ %}/gm) || []).length, r = t === s;
171
- return r || n({
170
+ const t = (e.match(/{% /gm) || []).length, n = (e.match(/ %}/gm) || []).length, r = t === n;
171
+ return r || s({
172
172
  type: c.Warning,
173
173
  message: o("custom-conditions.no-space-after-braces")
174
174
  }), r;
175
- }, O = (e) => (e.match(/({%(.*?)%})/g) || []).filter((s) => s.includes("if")).map((s) => (s.match(/{{.*}}/gm) || []).length).reduce((s, r) => s + r, 0) > 0 ? (n({
175
+ }, O = (e) => (e.match(/({%(.*?)%})/g) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, r) => n + r, 0) > 0 ? (s({
176
176
  type: c.Warning,
177
177
  message: o("custom-conditions.no-braces-inside-if-tag")
178
- }), !1) : !0, k = () => u.hasInvalidBlock() ? (n({
178
+ }), !1) : !0, k = () => u.hasInvalidBlock() ? (s({
179
179
  type: c.Error,
180
180
  message: o(J)
181
- }), !1) : !0, B = () => d.recommendationConfigs && Object.values(d.recommendationConfigs).find((t) => t.filters.find((s) => s.value === "")) !== void 0 ? (n({
181
+ }), !1) : !0, B = () => d.recommendationConfigs && Object.values(d.recommendationConfigs).find((t) => t.filters.find((n) => n.value === "")) !== void 0 ? (s({
182
182
  type: c.Error,
183
183
  message: o("newsletter.fill-all-necessary-fields")
184
184
  }), !1) : !0, D = (e) => {
185
185
  const t = /src="[^"]*\.(svg|pst)"/gm;
186
- return e.match(t) === null ? !0 : (n({
186
+ return e.match(t) === null ? !0 : (s({
187
187
  type: c.Error,
188
188
  message: o("newsletter.invalid-image-type")
189
189
  }), !1);
@@ -192,7 +192,7 @@ const xe = () => {
192
192
  return Array.from(r).find((i) => {
193
193
  var l;
194
194
  return !((l = i.id) != null && l.trim());
195
- }) ? (n({
195
+ }) ? (s({
196
196
  type: c.Error,
197
197
  message: o("unsubscribe-templates.select-checkbox-groups")
198
198
  }), !1) : !0;
@@ -201,19 +201,19 @@ const xe = () => {
201
201
  return Array.from(r).find((i) => {
202
202
  var l;
203
203
  return !((l = i.id) != null && l.trim());
204
- }) ? (n({
204
+ }) ? (s({
205
205
  type: c.Error,
206
206
  message: o("unsubscribe-templates.select-radio-button-groups")
207
207
  }), !1) : !0;
208
208
  };
209
- return { validateHtml: async (e, t, s = !1) => {
209
+ return { validateHtml: async (e, t, n = !1) => {
210
210
  var C, v;
211
211
  const r = [
212
212
  ...t.map((I) => I.value),
213
213
  ...q,
214
214
  ...((v = (C = f.value) == null ? void 0 : C.template) == null ? void 0 : v.customFieldAttributes) ?? []
215
215
  ], a = M(e), i = await E(a);
216
- return await A(e, r, s) && T(e) && w(e) && R(e) && _(e, r, a, i) && N(e) && x(e) && O(e) && k() && B() && D(e) && F(e) && L(e);
216
+ return await A(e, r, n) && T(e) && w(e) && R(e) && _(e, r, a, i) && N(e) && x(e) && O(e) && k() && B() && D(e) && F(e) && L(e);
217
217
  } };
218
218
  };
219
219
  export {
@@ -1,4 +1,4 @@
1
- const e = "Items", o = {
1
+ const e = "Items", o = "Default", t = "Custom", s = {
2
2
  "Global Styles & Layout": "Global Styles and Layout",
3
3
  "Structures & Modules": "Structures and Modules",
4
4
  "Recommendation Block": "Recommendation",
@@ -7,9 +7,13 @@ const e = "Items", o = {
7
7
  "This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.": "This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.",
8
8
  "Pixel Tracking Opt-in": "Pixel Tracking Opt-in",
9
9
  "OPT-IN SELECTION": "OPT-IN SELECTION",
10
- "UNSUBSCRIBE GROUPS": "UNSUBSCRIBE GROUPS"
10
+ "UNSUBSCRIBE GROUPS": "UNSUBSCRIBE GROUPS",
11
+ Default: o,
12
+ Custom: t
11
13
  };
12
14
  export {
15
+ t as Custom,
16
+ o as Default,
13
17
  e as Items,
14
- o as default
18
+ s as default
15
19
  };
@@ -1,4 +1,4 @@
1
- import { DEFAULT_COMPOSITION as d, DEFAULT_VISIBILITY as I } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
1
+ import { DEFAULT_COMPOSITION as p, DEFAULT_VISIBILITY as I } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
2
2
  import { ATTR_CUSTOM_PREFIX as l, ATTR_PRODUCT_BUTTON as k, ATTR_PRODUCT_OMNIBUS_DISCOUNT as A, ATTR_PRODUCT_OMNIBUS_PRICE as x, ATTR_PRODUCT_OLD_PRICE as f, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_NAME as h, ATTR_PRODUCT_IMAGE as y } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
3
3
  import { mapTextTheme as E, mapButtonTheme as O, mapImageTheme as b } from "./themeMapper.js";
4
4
  const C = "__title__", a = "product_attribute.";
@@ -23,19 +23,22 @@ function N(r) {
23
23
  return { key: k, kind: "button" };
24
24
  default:
25
25
  if (r.variableType === "p_attribute" || t.startsWith("p_attribute_")) {
26
- const s = r.value ?? "", o = s.startsWith(a) ? s.slice(a.length) : s;
27
- return o ? {
28
- key: `${l}${o}`,
26
+ const o = r.value ?? "", s = o.startsWith(a) ? o.slice(a.length) : o;
27
+ if (!s)
28
+ return null;
29
+ const e = o || `${a}${s}`;
30
+ return {
31
+ key: `${l}${e}`,
29
32
  kind: "custom",
30
- customAttrName: o,
31
- customAttrValue: s || `${a}${o}`
32
- } : null;
33
+ customAttrName: s,
34
+ customAttrValue: e
35
+ };
33
36
  }
34
37
  return null;
35
38
  }
36
39
  }
37
- function p(r) {
38
- const t = d.indexOf(r);
40
+ function _(r) {
41
+ const t = p.indexOf(r);
39
42
  return t === -1 ? Number.POSITIVE_INFINITY : t;
40
43
  }
41
44
  function S(r) {
@@ -48,8 +51,8 @@ function S(r) {
48
51
  anyTextTrimming: !1
49
52
  };
50
53
  if (!r || r.length === 0)
51
- return t.composition = [...d], t;
52
- const s = [];
54
+ return t.composition = [...p], t;
55
+ const o = [];
53
56
  r.forEach((e, i) => {
54
57
  const n = N(e);
55
58
  if (n) {
@@ -57,7 +60,7 @@ function S(r) {
57
60
  t.titleVariable = e;
58
61
  return;
59
62
  }
60
- s.push({
63
+ o.push({
61
64
  key: n.key,
62
65
  kind: n.kind,
63
66
  hidden: e.hidden === !0,
@@ -68,30 +71,30 @@ function S(r) {
68
71
  originalIndex: i
69
72
  });
70
73
  }
71
- }), s.sort((e, i) => {
74
+ }), o.sort((e, i) => {
72
75
  if (e.positionIdx !== i.positionIdx)
73
76
  return e.positionIdx - i.positionIdx;
74
- const n = p(e.key), u = p(i.key);
77
+ const n = _(e.key), u = _(i.key);
75
78
  return n !== u ? n - u : e.originalIndex - i.originalIndex;
76
79
  });
77
- const o = {};
78
- return s.forEach((e) => {
79
- const { key: i, kind: n, hidden: u, legacy: m, customAttrName: c, customAttrValue: T } = e;
80
- switch (t.composition.push(i), t.visibility[i] = !u, n === "custom" && c && T && (t.customAttributes.includes(c) || t.customAttributes.push(c), t.customAttrValues[i] = T), n) {
80
+ const s = {};
81
+ return o.forEach((e) => {
82
+ const { key: i, kind: n, hidden: u, legacy: c, customAttrName: d, customAttrValue: m } = e;
83
+ switch (t.composition.push(i), t.visibility[i] = !u, n === "custom" && d && m && (t.customAttributes.includes(m) || t.customAttributes.push(m), t.customAttrValues[i] = m), n) {
81
84
  case "image":
82
- o[i] = b(m.theme);
85
+ s[i] = b(c.theme);
83
86
  break;
84
87
  case "button":
85
- o[i] = O(m.theme);
88
+ s[i] = O(c.theme);
86
89
  break;
87
90
  case "text":
88
91
  case "custom": {
89
- const _ = E(m.theme);
90
- o[i] = _, _.textTrimming && (t.anyTextTrimming = !0);
92
+ const T = E(c.theme);
93
+ s[i] = T, T.textTrimming && (t.anyTextTrimming = !0);
91
94
  break;
92
95
  }
93
96
  }
94
- }), t.perElementStyles = o, t;
97
+ }), t.perElementStyles = s, t;
95
98
  }
96
99
  export {
97
100
  S as mapComposition