@useinsider/guido 2.1.0-beta.038f431 → 2.1.0-beta.07fb1d6

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 (63) hide show
  1. package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
  2. package/dist/composables/useActionsApi.js +15 -13
  3. package/dist/composables/useHtmlValidator.js +95 -87
  4. package/dist/composables/useRecommendation.js +54 -21
  5. package/dist/config/compiler/recommendationCompilerRules.js +45 -39
  6. package/dist/config/compiler/utils/recommendationCompilerUtils.js +116 -0
  7. package/dist/config/migrator/itemsBlockMigrator.js +140 -123
  8. package/dist/enums/extensions/recommendationBlock.js +1 -1
  9. package/dist/enums/recommendation.js +16 -15
  10. package/dist/extensions/Blocks/Items/block.js +19 -28
  11. package/dist/extensions/Blocks/Items/controls/button/link.js +19 -31
  12. package/dist/extensions/Blocks/Items/controls/cardComposition.js +124 -85
  13. package/dist/extensions/Blocks/Items/controls/image/link.js +19 -31
  14. package/dist/extensions/Blocks/Items/controls/name/trimming.js +28 -40
  15. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +35 -47
  16. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +49 -54
  17. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +42 -51
  18. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +23 -36
  19. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +45 -57
  20. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -60
  21. package/dist/extensions/Blocks/Items/controls/settingsControl.js +189 -196
  22. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +0 -2
  23. package/dist/extensions/Blocks/Items/extension.js +8 -9
  24. package/dist/extensions/Blocks/Items/settingsPanel.js +10 -15
  25. package/dist/extensions/Blocks/Items/template.js +181 -175
  26. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
  27. package/dist/extensions/Blocks/Recommendation/block.js +20 -18
  28. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +42 -42
  29. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +114 -102
  30. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +4 -4
  31. package/dist/extensions/Blocks/Recommendation/templates/utils.js +19 -23
  32. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +10 -10
  33. package/dist/extensions/Blocks/common-control.js +91 -92
  34. package/dist/guido.css +1 -1
  35. package/dist/services/recommendationApi.js +11 -9
  36. package/dist/services/templateLibraryApi.js +16 -13
  37. package/dist/src/composables/useRecommendation.d.ts +1 -0
  38. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
  39. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -1
  40. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -1
  41. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +5 -5
  42. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -1
  43. package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +0 -1
  44. package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +0 -1
  45. package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +0 -1
  46. package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +0 -1
  47. package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +0 -1
  48. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +0 -1
  49. package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +0 -5
  50. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +10 -12
  51. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +2 -1
  52. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -1
  53. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +7 -0
  54. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -1
  55. package/dist/src/extensions/Blocks/common-control.d.ts +4 -5
  56. package/dist/static/styles/components/notification.css.js +1 -0
  57. package/dist/static/styles/components/version-history.css.js +10 -2
  58. package/dist/static/styles/components/wide-panel.css.js +18 -2
  59. package/dist/utils/pairProductVariables.js +57 -56
  60. package/dist/utils/templatePreparation.js +15 -14
  61. package/package.json +1 -1
  62. package/dist/extensions/Blocks/Items/store/items-block.js +0 -79
  63. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +0 -45
@@ -1,18 +1,18 @@
1
1
  import o from "./HeaderWrapper.vue2.js";
2
2
  /* empty css */
3
- import s from "../../../_virtual/_plugin-vue2_normalizer.js";
4
- var a = function() {
3
+ import a from "../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var s = function() {
5
5
  var t = this, r = t._self._c, e = t._self._setupProxy;
6
- return r(e.InContainer, { attrs: { border: "bor-w-0 bor-b-w-1 bor-s-s bor-c-6", "border-radius": "bor-r-0" } }, [r("div", { staticClass: "header-wrapper w-1 d-f a-i-c j-c-s-b p-3" }, [r(e.LeftSlot), r(e.MiddleSlot), r(e.RightSlot, { ref: "rightSlotRef" })], 1)]);
7
- }, n = [], _ = /* @__PURE__ */ s(
6
+ return r(e.InContainer, { attrs: { border: "bor-w-0 bor-b-w-1 bor-s-s bor-c-6", "border-radius": "bor-r-0", "data-testid": "guido-header" } }, [r("div", { staticClass: "header-wrapper w-1 d-f a-i-c j-c-s-b p-3" }, [r(e.LeftSlot), r(e.MiddleSlot), r(e.RightSlot, { ref: "rightSlotRef" })], 1)]);
7
+ }, d = [], i = /* @__PURE__ */ a(
8
8
  o,
9
- a,
10
- n,
9
+ s,
10
+ d,
11
11
  !1,
12
12
  null,
13
- "5df46e7a"
13
+ "5c02dcc7"
14
14
  );
15
- const c = _.exports;
15
+ const p = i.exports;
16
16
  export {
17
- c as default
17
+ p as default
18
18
  };
@@ -1,6 +1,6 @@
1
1
  import { useToaster as w } from "./useToaster.js";
2
2
  const v = () => {
3
- const { handleError: l } = w(), r = (t = {}) => new Promise((e, a) => {
3
+ const { handleError: n } = w(), m = (t = {}) => new Promise((e, a) => {
4
4
  const o = { ...{
5
5
  minimize: !0,
6
6
  utmEntity: {
@@ -21,9 +21,9 @@ const v = () => {
21
21
  resetDataSavedFlag: !1,
22
22
  disableLineHeightsReplace: !0
23
23
  }, ...t }, s = {
24
- callback: (n, p, d, c, u) => {
25
- n ? a(n) : e({
26
- html: p,
24
+ callback: (l, r, d, c, u) => {
25
+ l ? a(l) : e({
26
+ html: r,
27
27
  ampHtml: d,
28
28
  ampErrors: c,
29
29
  displayConditions: u
@@ -34,15 +34,15 @@ const v = () => {
34
34
  window.StripoEditorApi.actionsApi.compileEmail(s);
35
35
  });
36
36
  return {
37
- getCompiledEmail: r,
37
+ getCompiledEmail: m,
38
38
  getTemplateData: () => new Promise((t) => {
39
- const e = ({ html: a, css: i, width: o, height: m, utmParams: s, syncModulesIds: n }) => t({
39
+ const e = ({ html: a, css: i, width: o, height: p, utmParams: s, syncModulesIds: l }) => t({
40
40
  html: a,
41
41
  css: i,
42
42
  width: o,
43
- height: m,
43
+ height: p,
44
44
  utmParams: s,
45
- syncModulesIds: n
45
+ syncModulesIds: l
46
46
  });
47
47
  window.StripoEditorApi.actionsApi.getTemplateData(e);
48
48
  }),
@@ -56,7 +56,7 @@ const v = () => {
56
56
  displayConditions: a,
57
57
  ampHtml: i = "",
58
58
  ampErrors: o = []
59
- } = await r({ minimize: !1, resetDataSavedFlag: !1, ...t });
59
+ } = await m({ minimize: !1, resetDataSavedFlag: !1, ...t });
60
60
  return {
61
61
  html: e,
62
62
  ampHtml: i,
@@ -64,7 +64,7 @@ const v = () => {
64
64
  displayConditions: a
65
65
  };
66
66
  } catch (e) {
67
- return l(e, "Error loading preview"), {
67
+ return n(e, "Error loading preview"), {
68
68
  html: "",
69
69
  ampHtml: "",
70
70
  ampErrors: [],
@@ -80,17 +80,19 @@ const v = () => {
80
80
  }
81
81
  try {
82
82
  window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((i, o) => {
83
- i ? (l(i, "Failed to update timer in cloned template"), t(null)) : t(o || null);
83
+ i ? (n(i, "Failed to update timer in cloned template"), t(null)) : t(o || null);
84
84
  });
85
85
  } catch (i) {
86
- l(i, "Failed to call updateTimerInClonedTemplate"), t(null);
86
+ n(i, "Failed to call updateTimerInClonedTemplate"), t(null);
87
87
  }
88
88
  }),
89
89
  updateHtmlAndCss: (t, e) => {
90
90
  window.StripoEditorApi.actionsApi.updateHtmlAndCss(t, e);
91
91
  },
92
92
  editorSave: () => {
93
- window.StripoEditorApi.actionsApi.save();
93
+ window.StripoEditorApi.actionsApi.save((t) => {
94
+ t && n(t, "Failed to save template");
95
+ });
94
96
  }
95
97
  };
96
98
  };
@@ -1,149 +1,157 @@
1
- import { useConfig as D } from "./useConfig.js";
2
- import { TemplateTypes as H } from "../enums/defaults.js";
3
- import { DISPLAY_CONDITIONS_REGEX as P, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as R, CampaignCouldNotBeSavedKey as _, CanNotMakeAnyChangesForRunningKey as G } from "../enums/html-validator.js";
1
+ import { useConfig as R } from "./useConfig.js";
2
+ import { TemplateTypes as D } from "../enums/defaults.js";
3
+ import { DISPLAY_CONDITIONS_REGEX as H, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as _, CampaignCouldNotBeSavedKey as P, CanNotMakeAnyChangesForRunningKey as $ } from "../enums/html-validator.js";
4
4
  import { ToasterTypeOptions as l } from "../enums/toaster.js";
5
- import { itemsBlockDynamicVariables as $ } from "../extensions/Blocks/Items/enums/productEnums.js";
6
- import { useRecommendationStore as j } from "../stores/recommendation.js";
7
- import { base64EncodeWithSpecialChars as q } from "../utils/base64.js";
8
- import { useHttp as M } from "./useHttp.js";
9
- import { useToaster as X } from "./useToaster.js";
10
- import { useTranslations as z } from "./useTranslations.js";
11
- const oe = () => {
12
- var d, f;
13
- const { showToaster: c } = X(), { post: h } = M(), { config: v } = D(), a = z(), m = j(), u = ((f = (d = v.value) == null ? void 0 : d.partner) == null ? void 0 : f.messageType) === H.transactional, C = async (e) => {
14
- const t = await h(
5
+ import { itemsBlockDynamicVariables as j } from "../extensions/Blocks/Items/enums/productEnums.js";
6
+ import { useRecommendationExtensionStore as G } from "../extensions/Blocks/Recommendation/store/recommendation.js";
7
+ import { useRecommendationStore as q } from "../stores/recommendation.js";
8
+ import { base64EncodeWithSpecialChars as M } from "../utils/base64.js";
9
+ import { useHttp as X } from "./useHttp.js";
10
+ import { useToaster as z } from "./useToaster.js";
11
+ import { useTranslations as K } from "./useTranslations.js";
12
+ function U(r) {
13
+ const m = G();
14
+ return Object.keys(m.blockStates).some((i) => r.startsWith(`${i}_`));
15
+ }
16
+ const ce = () => {
17
+ var g, p;
18
+ const { showToaster: r } = z(), { post: m } = X(), { config: u } = R(), i = K(), d = q(), f = ((p = (g = u.value) == null ? void 0 : g.partner) == null ? void 0 : p.messageType) === D.transactional, C = async (e) => {
19
+ const t = await m(
15
20
  "/newsletter/template-library/check-template-html-body",
16
- { html: q(e) }
17
- ), { status: n, message: r } = t.data;
18
- return n || c({
21
+ { html: M(e) }
22
+ ), { status: n, message: c } = t.data;
23
+ return n || r({
19
24
  type: l.Alert,
20
- message: n === void 0 ? r : a("newsletter.invalid-url-link-for-toaster")
21
- }), a(_), r === a(G) && c({
25
+ message: n === void 0 ? c : i("newsletter.invalid-url-link-for-toaster")
26
+ }), i(P), c === i($) && r({
22
27
  type: l.Alert,
23
- message: a("newsletter.already-in-progress")
28
+ message: i("newsletter.already-in-progress")
24
29
  }), n;
25
- }, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), S = (e) => ["if", "endif"].includes(e.toLowerCase()), b = (e, s) => {
30
+ }, b = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), S = (e) => ["if", "endif"].includes(e.toLowerCase()), w = (e, s) => {
26
31
  const t = e.match(/({%(.*?)%})/g);
27
32
  let n = !0;
28
- return t !== null && !u && t.forEach((r) => {
29
- const i = r.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
30
- if (i && i.length > 0) {
31
- const [o] = i;
32
- w(o) && !s.includes(o) && (c({
33
+ return t !== null && !f && t.forEach((c) => {
34
+ const o = c.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
35
+ if (o && o.length > 0) {
36
+ const [a] = o;
37
+ b(a) && !s.includes(a) && (r({
33
38
  type: l.Warning,
34
- message: a("custom-fields.invalid-custom-fields")
39
+ message: i("custom-fields.invalid-custom-fields")
35
40
  }), n = !1);
36
41
  }
37
42
  }), n;
38
43
  }, E = async (e, s, t) => {
39
44
  const n = t ? await C(e) : !0;
40
- return b(e, s) && n;
41
- }, A = (e) => e.length > 0 ? !0 : (c({
45
+ return w(e, s) && n;
46
+ }, k = (e) => e.length > 0 ? !0 : (r({
42
47
  type: l.Warning,
43
- message: a("newsletter.html-content-is-empty")
44
- }), !1), x = (e) => {
48
+ message: i("newsletter.html-content-is-empty")
49
+ }), !1), A = (e) => {
45
50
  const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
46
- return s > t && c({
51
+ return s > t && r({
47
52
  type: l.Warning,
48
- message: a("custom-fields.missing-closing-braces")
49
- }), s < t && c({
53
+ message: i("custom-fields.missing-closing-braces")
54
+ }), s < t && r({
50
55
  type: l.Warning,
51
- message: a("custom-fields.missing-opening-braces")
56
+ message: i("custom-fields.missing-opening-braces")
52
57
  }), s === t;
53
- }, k = (e) => {
58
+ }, x = (e) => {
54
59
  const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
55
- return s || c({
60
+ return s || r({
56
61
  type: l.Warning,
57
- message: a("custom-fields.invalid-custom-fields")
62
+ message: i("custom-fields.invalid-custom-fields")
58
63
  }), s;
59
- }, T = (e, s) => {
64
+ }, I = (e, s) => {
60
65
  const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
61
- if (t && !u) {
62
- const n = new Set(s.map((i) => i.toLowerCase())), r = [];
63
- if (t.forEach((i) => {
64
- const o = i.slice(2, -2).trim().toLowerCase();
65
- (!n.has(o) || o === "") && r.push(o);
66
- }), r.length > 0) {
67
- const i = `
66
+ if (t && !f) {
67
+ const n = new Set(s.map((o) => o.toLowerCase())), c = [];
68
+ if (t.forEach((o) => {
69
+ const a = o.slice(2, -2).trim().toLowerCase();
70
+ (!n.has(a) || a === "") && !U(a) && c.push(a);
71
+ }), c.length > 0) {
72
+ const o = `
68
73
  <ul>
69
- ${r.map((o) => `<li>${o}</li>`).join("")}
74
+ ${c.map((a) => `<li>${a}</li>`).join("")}
70
75
  </ul>
71
76
  `;
72
- return c({
77
+ return r({
73
78
  type: l.Alert,
74
- message: a("custom-fields.invalid-custom-fields") + i
79
+ message: i("custom-fields.invalid-custom-fields") + o
75
80
  }), !1;
76
81
  }
77
82
  }
78
83
  return !0;
79
- }, F = (e) => {
84
+ }, T = (e) => {
80
85
  const s = e.match(/{%(.*?)%}/g), t = [];
81
86
  let n = !0;
82
- if (s && s.forEach((r) => {
83
- const i = r.match(P), o = r.match(R), V = (i == null ? void 0 : i.join("")) || "";
84
- (!i || r !== V) && !o && (c({
87
+ if (s && s.forEach((c) => {
88
+ const o = c.match(H), a = c.match(_), B = (o == null ? void 0 : o.join("")) || "";
89
+ (!o || c !== B) && !a && (r({
85
90
  type: l.Alert,
86
- message: a("newsletter.display-conditions-invalid-syntax")
87
- }), n = !1), i && i.forEach((g) => {
88
- g.trim() === "=" && (c({
91
+ message: i("newsletter.display-conditions-invalid-syntax")
92
+ }), n = !1), o && o.forEach((y) => {
93
+ y.trim() === "=" && (r({
89
94
  type: l.Alert,
90
- message: a("custom-conditions.wrong-equality-operators")
95
+ message: i("custom-conditions.wrong-equality-operators")
91
96
  }), n = !1);
92
- const p = g.match(/^[a-zA-Z]*$/g);
93
- p && p.forEach((y) => {
94
- S(y) && t.push(y);
97
+ const h = y.match(/^[a-zA-Z]*$/g);
98
+ h && h.forEach((v) => {
99
+ S(v) && t.push(v);
95
100
  });
96
101
  });
97
102
  }), t.length) {
98
- const r = t.filter((o) => o === "if"), i = t.filter((o) => o === "endif");
99
- r.length !== i.length && (c({
103
+ const c = t.filter((a) => a === "if"), o = t.filter((a) => a === "endif");
104
+ c.length !== o.length && (r({
100
105
  type: l.Alert,
101
- message: a("custom-conditions.missing-if-endif-tag")
106
+ message: i("custom-conditions.missing-if-endif-tag")
102
107
  }), n = !1);
103
108
  }
104
109
  return n;
105
- }, I = (e) => {
110
+ }, F = (e) => {
106
111
  const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
107
- return n || c({
112
+ return n || r({
108
113
  type: l.Warning,
109
- message: a("custom-conditions.no-space-after-braces")
114
+ message: i("custom-conditions.no-space-after-braces")
110
115
  }), n;
111
- }, W = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (c({
116
+ }, W = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (r({
112
117
  type: l.Warning,
113
- message: a("custom-conditions.no-braces-inside-if-tag")
114
- }), !1) : !0, L = () => m.recommendationConfigs && Object.values(m.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (c({
118
+ message: i("custom-conditions.no-braces-inside-if-tag")
119
+ }), !1) : !0, O = () => d.recommendationConfigs && Object.values(d.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (r({
115
120
  type: l.Alert,
116
- message: a("newsletter.fill-all-necessary-fields")
117
- }), !1) : !0, N = (e) => {
121
+ message: i("newsletter.fill-all-necessary-fields")
122
+ }), !1) : !0, L = (e) => {
118
123
  const s = /src="[^"]*\.(svg|pst)"/gm;
119
- return e.match(s) === null ? !0 : (c({
124
+ return e.match(s) === null ? !0 : (r({
120
125
  type: l.Alert,
121
- message: a("newsletter.invalid-image-type")
126
+ message: i("newsletter.invalid-image-type")
122
127
  }), !1);
123
- }, O = (e) => {
128
+ }, N = (e) => {
124
129
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
125
- return Array.from(n).find((i) => {
126
- var o;
127
- return !((o = i.id) != null && o.trim());
128
- }) ? (c({
130
+ return Array.from(n).find((o) => {
131
+ var a;
132
+ return !((a = o.id) != null && a.trim());
133
+ }) ? (r({
129
134
  type: l.Alert,
130
- message: a("unsubscribe-templates.select-checkbox-groups")
135
+ message: i("unsubscribe-templates.select-checkbox-groups")
131
136
  }), !1) : !0;
132
- }, B = (e) => {
137
+ }, V = (e) => {
133
138
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
134
- return Array.from(n).find((i) => {
135
- var o;
136
- return !((o = i.id) != null && o.trim());
137
- }) ? (c({
139
+ return Array.from(n).find((o) => {
140
+ var a;
141
+ return !((a = o.id) != null && a.trim());
142
+ }) ? (r({
138
143
  type: l.Alert,
139
- message: a("unsubscribe-templates.select-radio-button-groups")
144
+ message: i("unsubscribe-templates.select-radio-button-groups")
140
145
  }), !1) : !0;
141
146
  };
142
147
  return { validateHtml: async (e, s, t = !1) => {
143
- const n = [...s.map((i) => i.value), ...$];
144
- return await E(e, n, t) && A(e) && x(e) && k(e) && T(e, n) && F(e) && I(e) && W(e) && L() && N(e) && O(e) && B(e);
148
+ const n = [
149
+ ...s.map((o) => o.value),
150
+ ...j
151
+ ];
152
+ return await E(e, n, t) && k(e) && A(e) && x(e) && I(e, n) && T(e) && F(e) && W(e) && O() && L(e) && N(e) && V(e);
145
153
  } };
146
154
  };
147
155
  export {
148
- oe as useHtmlValidator
156
+ ce as useHtmlValidator
149
157
  };
@@ -1,27 +1,60 @@
1
- import { MinDeviceViewport as r, DefaultPadding as c } from "../enums/recommendation.js";
2
- const m = () => ({
1
+ import { RecommendationFeedSourceMaps as g, URLS as p } from "../enums/extensions/recommendationBlock.js";
2
+ import { MinDeviceViewport as R, DefaultPadding as b } from "../enums/recommendation.js";
3
+ import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
+ import { generateCompleteFilterQuery as x } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
5
+ import { useConfigStore as C } from "../stores/config.js";
6
+ const N = () => ({
3
7
  calculateCardWidth: ({
4
- mobileLeftPadding: e,
5
- mobileRightPadding: a,
6
- cardsInRow: n,
7
- unresponsive: i
8
+ mobileLeftPadding: i,
9
+ mobileRightPadding: n,
10
+ cardsInRow: o,
11
+ unresponsive: a
8
12
  }) => {
9
- const t = i ? n : 1, o = e + a + (t - 1) * c;
10
- return (r - o) / t;
13
+ const r = a ? o : 1, e = i + n + (r - 1) * b;
14
+ return (R - e) / r;
11
15
  },
12
- getRecommendationCampaignData: (e) => (console.debug(e), {
13
- textTrimming: !1,
14
- orientation: "vertical",
15
- mobileLeftPadding: 0,
16
- mobileRightPadding: 0,
17
- cardsInRow: 2,
18
- unresponsive: !1,
19
- priceBeforeTextValue: "",
20
- priceAfterTextValue: "",
21
- discountBeforeTextValue: "",
22
- discountAfterTextValue: ""
23
- })
16
+ getRecommendationCampaignData: (i) => {
17
+ const n = l(), o = Number(i), a = n.blockStates[o];
18
+ if (!a)
19
+ return {
20
+ textTrimming: !1,
21
+ orientation: "vertical",
22
+ mobileLeftPadding: 0,
23
+ mobileRightPadding: 0,
24
+ cardsInRow: 2,
25
+ unresponsive: !1,
26
+ priceBeforeTextValue: "",
27
+ priceAfterTextValue: "",
28
+ discountBeforeTextValue: "",
29
+ discountAfterTextValue: ""
30
+ };
31
+ const { recommendationConfigs: r } = a, e = r.orientation === "grid" ? "vertical" : "horizontal";
32
+ return {
33
+ textTrimming: r.textTrimming,
34
+ orientation: e,
35
+ mobileLeftPadding: 0,
36
+ mobileRightPadding: 0,
37
+ cardsInRow: r.cardsInRow,
38
+ unresponsive: r.unresponsive,
39
+ priceBeforeTextValue: "",
40
+ priceAfterTextValue: "",
41
+ discountBeforeTextValue: "",
42
+ discountAfterTextValue: ""
43
+ };
44
+ },
45
+ buildCampaignUrl: (i) => {
46
+ var d;
47
+ const n = l(), o = C(), a = Number(i), r = n.blockStates[a];
48
+ if (!r)
49
+ return "";
50
+ const { recommendationConfigs: e } = r, u = ((d = g.find((s) => s.key === e.strategy)) == null ? void 0 : d.path) || "", t = new URLSearchParams();
51
+ t.set("locale", e.language), t.set("currency", e.currencySettings.value), t.set("partnerName", o.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", o.variationId), e.strategy === "manualMerchandising" ? t.set("productId", e.productIds.join(",")) : e.strategy === "similarViewed" && t.set("productId", "{itemId}");
52
+ const f = e.filters.filter((s) => s.isValid), c = x(f);
53
+ c && t.set("filter", c), e.shuffleProducts && t.set("shuffle", "true");
54
+ const m = `${p.RECOMMENDATION_API_URL}/v2/${u}?${t.toString()}`;
55
+ return n.recommendationCampaignUrls[i] = m, m;
56
+ }
24
57
  });
25
58
  export {
26
- m as useRecommendation
59
+ N as useRecommendation
27
60
  };
@@ -1,15 +1,16 @@
1
- import { useRecommendation as u } from "../../composables/useRecommendation.js";
2
- import { DUMMY_IMAGE_MAPPINGS as P, REGEX as i, CSS as e, CONDITIONS as E, ATTRIBUTES as r, HTML as h } from "../../enums/recommendation.js";
3
- const H = [
1
+ import { useRecommendation as f } from "../../composables/useRecommendation.js";
2
+ import { DUMMY_IMAGE_MAPPINGS as P, REGEX as m, VerticalOrientation as g, CSS as e, ATTRIBUTES as a, CONDITIONS as A, HTML as h } from "../../enums/recommendation.js";
3
+ import { prepareRecommendationBlocks as D } from "./utils/recommendationCompilerUtils.js";
4
+ const G = [
4
5
  {
5
6
  id: "replace-images-with-variable-names",
6
7
  description: "Replacing dummy images with variable names in recommendation module",
7
8
  type: "custom",
8
- processor: (a) => {
9
- let t = a;
10
- return Object.entries(P).forEach(([, n]) => {
11
- Object.entries(n).forEach(([s, o]) => {
12
- t = t.replaceAll(o, `{{${s}}}`);
9
+ processor: (s) => {
10
+ let t = s;
11
+ return Object.entries(P).forEach(([, l]) => {
12
+ Object.entries(l).forEach(([n, o]) => {
13
+ t = t.replaceAll(o, `{{${n}}}`);
13
14
  });
14
15
  }), t;
15
16
  },
@@ -28,17 +29,17 @@ const H = [
28
29
  id: "add-recommendation-unresponsive-css",
29
30
  description: "Adding recommendation unresponsive css",
30
31
  type: "custom",
31
- processor: (a) => {
32
- const { getRecommendationCampaignData: t } = u();
33
- let n = a;
34
- const s = n.match(i.ID);
35
- if (s) {
36
- const o = [];
37
- if (s.forEach((c) => {
38
- const m = c.slice(35, c.length - 1).trim();
39
- t(m);
40
- }), o.length) {
41
- const c = `width:${Math.min(...o)}px!important;`;
32
+ processor: (s) => {
33
+ const { calculateCardWidth: t, getRecommendationCampaignData: l } = f();
34
+ let n = s;
35
+ const o = n.match(m.ID);
36
+ if (o) {
37
+ const d = [];
38
+ if (o.forEach((c) => {
39
+ const E = /recommendation-id="(.*?)"/i.exec(c), I = E ? E[1].trim() : "", p = l(I);
40
+ p.textTrimming && p.orientation === g && d.push(t(p));
41
+ }), d.length) {
42
+ const c = `width:${Math.min(...d)}px!important;`;
42
43
  n = n.replace(e.REGULAR_NAME_HEIGHT, `${e.TRIMMED_NAME_HEIGHT} ${c} ${e.ELLIPSIS}`).replace(e.REGULAR_NAME_CONTAINER_HEIGHT, e.TRIMMED_NAME_CONTAINER_CSS).replace(e.RESPONSIVE_NAME_SIZE, `${e.RESPONSIVE_NAME_HEIGHT} ${c} ${e.ELLIPSIS}`).replace(e.RESPONSIVE_NAME_CONTAINER_HEIGHT, e.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
43
44
  }
44
45
  }
@@ -46,32 +47,37 @@ const H = [
46
47
  },
47
48
  priority: 52
48
49
  },
49
- // TODO: prepareRecommendations
50
- // TODO: addRecommendationCustomFields
50
+ {
51
+ id: "prepare-recommendations",
52
+ description: "Replacing product data with template variables in recommendation blocks",
53
+ type: "custom",
54
+ processor: (s) => D(s),
55
+ priority: 48
56
+ },
51
57
  {
52
58
  id: "add-discount-conditions",
53
59
  description: "Adding discount conditions to the recommendation block",
54
60
  type: "custom",
55
- processor: (a) => {
56
- let t = a;
57
- const n = t.match(i.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: s } = u();
58
- return n !== null && n.forEach((o) => {
59
- const c = o.match(i.CUSTOM_FIELD);
60
- if (!c)
61
+ processor: (s) => {
62
+ let t = s;
63
+ const l = t.match(m.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: n } = f();
64
+ return l !== null && l.forEach((o) => {
65
+ const d = o.match(m.CUSTOM_FIELD);
66
+ if (!d)
61
67
  return;
62
- const [m] = c, p = m.match(i.CUSTOM_FIELD_INDEXES_PART), A = m.match(i.CUSTOM_FIELD_NAME_PART), _ = o.match(i.ATTRIBUTE_PARAGRAPH_START_TAG);
63
- if (!p || !A || !_)
68
+ const [c] = d, E = c.match(m.CUSTOM_FIELD_INDEXES_PART), I = c.match(m.CUSTOM_FIELD_NAME_PART), p = o.match(m.ATTRIBUTE_PARAGRAPH_START_TAG);
69
+ if (!E || !I || !p)
64
70
  return;
65
- const [l] = p, [T] = A, [d] = _, N = T.substring(1, T.length - 2), R = d.match(i.COMPOSITION) !== null;
66
- let O = m;
67
- if (R) {
68
- const M = l.substring(2, l.length - 3);
69
- s(M);
71
+ const [u] = E, [R] = I, [_] = p, T = R.substring(1, R.length - 2), S = _.match(m.COMPOSITION) !== null;
72
+ let i = c;
73
+ if (S) {
74
+ const $ = u.substring(2, u.length - 3), r = n($);
75
+ T === a.OMNIBUS_PRICE && (r.priceBeforeTextValue && (i = `${r.priceBeforeTextValue}${i}`), r.priceAfterTextValue && (i = `${i}${r.priceAfterTextValue}`)), T === a.OMNIBUS_DISCOUNT && (r.discountBeforeTextValue && (i = `${r.discountBeforeTextValue}${i}`), r.discountAfterTextValue && (i = `${i}${r.discountAfterTextValue}`));
70
76
  }
71
- const I = l.substring(2);
72
- let S = "";
73
- N in E.IF && (S = E.IF[N].replaceAll(`{${r.DISCOUNT}}`, `${I}${r.DISCOUNT}`).replaceAll(`{${r.OMNIBUS_DISCOUNT}}`, `${I}${r.OMNIBUS_DISCOUNT}`).replaceAll(`{${r.OMNIBUS_PRICE}}`, `${I}${r.OMNIBUS_PRICE}`));
74
- const $ = `${d}${O}${h.PARAGRAPH_END_TAG}`, C = `${S}${R ? $ : o}${E.ELSE}${d}${h.PARAGRAPH_END_TAG}${E.END_IF}`;
77
+ const N = u.substring(2);
78
+ let M = "";
79
+ T in A.IF && (M = A.IF[T].replaceAll(`{${a.DISCOUNT}}`, `${N}${a.DISCOUNT}`).replaceAll(`{${a.OMNIBUS_DISCOUNT}}`, `${N}${a.OMNIBUS_DISCOUNT}`).replaceAll(`{${a.OMNIBUS_PRICE}}`, `${N}${a.OMNIBUS_PRICE}`));
80
+ const O = `${_}${i}${h.PARAGRAPH_END_TAG}`, C = `${M}${S ? O : o}${A.ELSE}${_}${h.PARAGRAPH_END_TAG}${A.END_IF}`;
75
81
  t = t.replace(o, C);
76
82
  }), t;
77
83
  },
@@ -79,5 +85,5 @@ const H = [
79
85
  }
80
86
  ];
81
87
  export {
82
- H as recommendationCompilerRules
88
+ G as recommendationCompilerRules
83
89
  };