@useinsider/guido 2.1.0-beta.216503 → 2.1.0-beta.235b052

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 (47) hide show
  1. package/README.md +36 -0
  2. package/dist/@types/config/schemas.js +70 -65
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +69 -58
  5. package/dist/composables/useBlocksConfig.js +26 -16
  6. package/dist/composables/useHtmlValidator.js +107 -119
  7. package/dist/config/compiler/utils/recommendationCompilerUtils.js +27 -22
  8. package/dist/enums/defaults.js +8 -4
  9. package/dist/extensions/Blocks/Recommendation/block.js +26 -23
  10. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +27 -26
  11. package/dist/extensions/Blocks/Recommendation/constants/layout.js +6 -4
  12. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +12 -10
  13. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +103 -70
  14. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +87 -37
  15. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +138 -117
  16. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
  17. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +117 -107
  18. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +25 -30
  19. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +27 -30
  20. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +20 -25
  21. package/dist/extensions/Blocks/Recommendation/templates/utils.js +43 -31
  22. package/dist/extensions/ModulesTabIcons/extension.js +17 -0
  23. package/dist/guido.css +1 -1
  24. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +257 -187
  25. package/dist/services/recommendationApi.js +11 -11
  26. package/dist/src/@types/config/schemas.d.ts +8 -0
  27. package/dist/src/composables/useConfig.d.ts +4 -0
  28. package/dist/src/enums/defaults.d.ts +4 -0
  29. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +2 -2
  30. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +6 -0
  31. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +4 -0
  32. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +12 -1
  33. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +22 -4
  34. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -2
  35. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
  36. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +7 -0
  37. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +1 -1
  38. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +2 -0
  39. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +12 -3
  40. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
  41. package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
  42. package/dist/src/stores/config.d.ts +36 -0
  43. package/dist/static/styles/components/notification.css.js +1 -0
  44. package/dist/static/styles/components/version-history.css.js +10 -2
  45. package/dist/static/styles/components/wide-panel.css.js +18 -2
  46. package/dist/static/styles/customEditorStyle.css.js +10 -9
  47. package/package.json +2 -2
@@ -1,171 +1,159 @@
1
- import { useConfig as D } from "./useConfig.js";
2
- import { TemplateTypes as L } from "../enums/defaults.js";
3
- import { DISPLAY_CONDITIONS_REGEX as V, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as H, CampaignCouldNotBeSavedKey as M, CanNotMakeAnyChangesForRunningKey as $ } from "../enums/html-validator.js";
4
- import { ToasterTypeOptions as l } from "../enums/toaster.js";
5
- import { itemsBlockDynamicVariables as P } from "../extensions/Blocks/Items/enums/productEnums.js";
6
- import { useRecommendationExtensionStore as j } from "../extensions/Blocks/Recommendation/store/recommendation.js";
7
- import { useRecommendationStore as G } from "../stores/recommendation.js";
8
- import { base64EncodeWithSpecialChars as q } from "../utils/base64.js";
9
- import { useHttp as z } from "./useHttp.js";
10
- import { useToaster as U } from "./useToaster.js";
11
- import { useTranslations as X } from "./useTranslations.js";
12
- const K = [
13
- "img",
14
- "url",
15
- "name",
16
- "price",
17
- "currency",
18
- "original_price",
19
- "omnibus_price",
20
- "omnibus_discount"
21
- ];
22
- function Y() {
23
- const a = j();
24
- return Object.keys(a.blockStates).flatMap((d) => {
25
- const f = a.blockStates[Number(d)], i = parseInt(f.recommendationConfigs.size) || 10;
26
- return Array.from({ length: i }, (m, u) => u).flatMap((m) => K.map((u) => `${d}_${m}_${u}`));
27
- });
1
+ import { useConfig as L } from "./useConfig.js";
2
+ import { TemplateTypes as V } from "../enums/defaults.js";
3
+ import { DISPLAY_CONDITIONS_REGEX as _, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as H, CampaignCouldNotBeSavedKey as P, CanNotMakeAnyChangesForRunningKey as G } from "../enums/html-validator.js";
4
+ import { ToasterTypeOptions as c } from "../enums/toaster.js";
5
+ import { itemsBlockDynamicVariables as M } from "../extensions/Blocks/Items/enums/productEnums.js";
6
+ import { useRecommendationStore as $ } from "../stores/recommendation.js";
7
+ import { base64EncodeWithSpecialChars as X } from "../utils/base64.js";
8
+ import { useHttp as j } from "./useHttp.js";
9
+ import { useToaster as q } from "./useToaster.js";
10
+ import { useTranslations as z } from "./useTranslations.js";
11
+ const K = /recommendation-id="(\d+)"/g;
12
+ function U(i) {
13
+ return [...i.matchAll(K)].map((u) => u[1]);
28
14
  }
29
- const le = () => {
30
- var p, y;
31
- const { showToaster: a } = U(), { post: d } = z(), { config: f } = D(), i = X(), g = G(), m = ((y = (p = f.value) == null ? void 0 : p.partner) == null ? void 0 : y.messageType) === L.transactional, u = async (e) => {
32
- const t = await d(
15
+ function Y(i, u) {
16
+ return u.some((d) => i.startsWith(`${d}_`));
17
+ }
18
+ const ce = () => {
19
+ var y, h;
20
+ const { showToaster: i } = q(), { post: u } = j(), { config: d } = L(), r = z(), g = $(), p = ((h = (y = d.value) == null ? void 0 : y.partner) == null ? void 0 : h.messageType) === V.transactional, w = async (e) => {
21
+ const t = await u(
33
22
  "/newsletter/template-library/check-template-html-body",
34
- { html: q(e) }
35
- ), { status: n, message: c } = t.data;
36
- return n || a({
37
- type: l.Alert,
38
- message: n === void 0 ? c : i("newsletter.invalid-url-link-for-toaster")
39
- }), i(M), c === i($) && a({
40
- type: l.Alert,
41
- message: i("newsletter.already-in-progress")
23
+ { html: X(e) }
24
+ ), { status: n, message: l } = t.data;
25
+ return n || i({
26
+ type: c.Alert,
27
+ message: n === void 0 ? l : r("newsletter.invalid-url-link-for-toaster")
28
+ }), r(P), l === r(G) && i({
29
+ type: c.Alert,
30
+ message: r("newsletter.already-in-progress")
42
31
  }), n;
43
- }, b = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), S = (e) => ["if", "endif"].includes(e.toLowerCase()), w = (e, s) => {
32
+ }, b = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), S = (e) => ["if", "endif"].includes(e.toLowerCase()), E = (e, s) => {
44
33
  const t = e.match(/({%(.*?)%})/g);
45
34
  let n = !0;
46
- return t !== null && !m && t.forEach((c) => {
47
- const o = c.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
35
+ return t !== null && !p && t.forEach((l) => {
36
+ const o = l.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
48
37
  if (o && o.length > 0) {
49
- const [r] = o;
50
- b(r) && !s.includes(r) && (a({
51
- type: l.Warning,
52
- message: i("custom-fields.invalid-custom-fields")
38
+ const [a] = o;
39
+ b(a) && !s.includes(a) && (i({
40
+ type: c.Warning,
41
+ message: r("custom-fields.invalid-custom-fields")
53
42
  }), n = !1);
54
43
  }
55
44
  }), n;
56
- }, E = async (e, s, t) => {
57
- const n = t ? await u(e) : !0;
58
- return w(e, s) && n;
59
- }, A = (e) => e.length > 0 ? !0 : (a({
60
- type: l.Warning,
61
- message: i("newsletter.html-content-is-empty")
45
+ }, A = async (e, s, t) => {
46
+ const n = t ? await w(e) : !0;
47
+ return E(e, s) && n;
48
+ }, I = (e) => e.length > 0 ? !0 : (i({
49
+ type: c.Warning,
50
+ message: r("newsletter.html-content-is-empty")
62
51
  }), !1), k = (e) => {
63
52
  const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
64
- return s > t && a({
65
- type: l.Warning,
66
- message: i("custom-fields.missing-closing-braces")
67
- }), s < t && a({
68
- type: l.Warning,
69
- message: i("custom-fields.missing-opening-braces")
53
+ return s > t && i({
54
+ type: c.Warning,
55
+ message: r("custom-fields.missing-closing-braces")
56
+ }), s < t && i({
57
+ type: c.Warning,
58
+ message: r("custom-fields.missing-opening-braces")
70
59
  }), s === t;
71
60
  }, x = (e) => {
72
61
  const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
73
- return s || a({
74
- type: l.Warning,
75
- message: i("custom-fields.invalid-custom-fields")
62
+ return s || i({
63
+ type: c.Warning,
64
+ message: r("custom-fields.invalid-custom-fields")
76
65
  }), s;
77
66
  }, T = (e, s) => {
78
67
  const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
79
- if (t && !m) {
80
- const n = new Set(s.map((o) => o.toLowerCase())), c = [];
81
- if (t.forEach((o) => {
82
- const r = o.slice(2, -2).trim().toLowerCase();
83
- (!n.has(r) || r === "") && c.push(r);
84
- }), c.length > 0) {
85
- const o = `
68
+ if (t && !p) {
69
+ const n = new Set(s.map((a) => a.toLowerCase())), l = U(e), o = [];
70
+ if (t.forEach((a) => {
71
+ const m = a.slice(2, -2).trim().toLowerCase();
72
+ (!n.has(m) || m === "") && !Y(m, l) && o.push(m);
73
+ }), o.length > 0) {
74
+ const a = `
86
75
  <ul>
87
- ${c.map((r) => `<li>${r}</li>`).join("")}
76
+ ${o.map((m) => `<li>${m}</li>`).join("")}
88
77
  </ul>
89
78
  `;
90
- return a({
91
- type: l.Alert,
92
- message: i("custom-fields.invalid-custom-fields") + o
79
+ return i({
80
+ type: c.Alert,
81
+ message: r("custom-fields.invalid-custom-fields") + a
93
82
  }), !1;
94
83
  }
95
84
  }
96
85
  return !0;
97
- }, I = (e) => {
86
+ }, F = (e) => {
98
87
  const s = e.match(/{%(.*?)%}/g), t = [];
99
88
  let n = !0;
100
- if (s && s.forEach((c) => {
101
- const o = c.match(V), r = c.match(H), B = (o == null ? void 0 : o.join("")) || "";
102
- (!o || c !== B) && !r && (a({
103
- type: l.Alert,
104
- message: i("newsletter.display-conditions-invalid-syntax")
105
- }), n = !1), o && o.forEach((h) => {
106
- h.trim() === "=" && (a({
107
- type: l.Alert,
108
- message: i("custom-conditions.wrong-equality-operators")
89
+ if (s && s.forEach((l) => {
90
+ const o = l.match(_), a = l.match(H), m = (o == null ? void 0 : o.join("")) || "";
91
+ (!o || l !== m) && !a && (i({
92
+ type: c.Alert,
93
+ message: r("newsletter.display-conditions-invalid-syntax")
94
+ }), n = !1), o && o.forEach((f) => {
95
+ f.trim() === "=" && (i({
96
+ type: c.Alert,
97
+ message: r("custom-conditions.wrong-equality-operators")
109
98
  }), n = !1);
110
- const C = h.match(/^[a-zA-Z]*$/g);
111
- C && C.forEach((v) => {
112
- S(v) && t.push(v);
99
+ const v = f.match(/^[a-zA-Z]*$/g);
100
+ v && v.forEach((C) => {
101
+ S(C) && t.push(C);
113
102
  });
114
103
  });
115
104
  }), t.length) {
116
- const c = t.filter((r) => r === "if"), o = t.filter((r) => r === "endif");
117
- c.length !== o.length && (a({
118
- type: l.Alert,
119
- message: i("custom-conditions.missing-if-endif-tag")
105
+ const l = t.filter((a) => a === "if"), o = t.filter((a) => a === "endif");
106
+ l.length !== o.length && (i({
107
+ type: c.Alert,
108
+ message: r("custom-conditions.missing-if-endif-tag")
120
109
  }), n = !1);
121
110
  }
122
111
  return n;
123
- }, F = (e) => {
112
+ }, W = (e) => {
124
113
  const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
125
- return n || a({
126
- type: l.Warning,
127
- message: i("custom-conditions.no-space-after-braces")
114
+ return n || i({
115
+ type: c.Warning,
116
+ message: r("custom-conditions.no-space-after-braces")
128
117
  }), n;
129
- }, _ = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (a({
130
- type: l.Warning,
131
- message: i("custom-conditions.no-braces-inside-if-tag")
132
- }), !1) : !0, N = () => g.recommendationConfigs && Object.values(g.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (a({
133
- type: l.Alert,
134
- message: i("newsletter.fill-all-necessary-fields")
135
- }), !1) : !0, O = (e) => {
118
+ }, N = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (i({
119
+ type: c.Warning,
120
+ message: r("custom-conditions.no-braces-inside-if-tag")
121
+ }), !1) : !0, O = () => g.recommendationConfigs && Object.values(g.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (i({
122
+ type: c.Alert,
123
+ message: r("newsletter.fill-all-necessary-fields")
124
+ }), !1) : !0, B = (e) => {
136
125
  const s = /src="[^"]*\.(svg|pst)"/gm;
137
- return e.match(s) === null ? !0 : (a({
138
- type: l.Alert,
139
- message: i("newsletter.invalid-image-type")
126
+ return e.match(s) === null ? !0 : (i({
127
+ type: c.Alert,
128
+ message: r("newsletter.invalid-image-type")
140
129
  }), !1);
141
- }, W = (e) => {
130
+ }, R = (e) => {
142
131
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
143
132
  return Array.from(n).find((o) => {
144
- var r;
145
- return !((r = o.id) != null && r.trim());
146
- }) ? (a({
147
- type: l.Alert,
148
- message: i("unsubscribe-templates.select-checkbox-groups")
133
+ var a;
134
+ return !((a = o.id) != null && a.trim());
135
+ }) ? (i({
136
+ type: c.Alert,
137
+ message: r("unsubscribe-templates.select-checkbox-groups")
149
138
  }), !1) : !0;
150
- }, R = (e) => {
139
+ }, D = (e) => {
151
140
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
152
141
  return Array.from(n).find((o) => {
153
- var r;
154
- return !((r = o.id) != null && r.trim());
155
- }) ? (a({
156
- type: l.Alert,
157
- message: i("unsubscribe-templates.select-radio-button-groups")
142
+ var a;
143
+ return !((a = o.id) != null && a.trim());
144
+ }) ? (i({
145
+ type: c.Alert,
146
+ message: r("unsubscribe-templates.select-radio-button-groups")
158
147
  }), !1) : !0;
159
148
  };
160
149
  return { validateHtml: async (e, s, t = !1) => {
161
150
  const n = [
162
151
  ...s.map((o) => o.value),
163
- ...P,
164
- ...Y()
152
+ ...M
165
153
  ];
166
- return await E(e, n, t) && A(e) && k(e) && x(e) && T(e, n) && I(e) && F(e) && _(e) && N() && O(e) && W(e) && R(e);
154
+ return await A(e, n, t) && I(e) && k(e) && x(e) && T(e, n) && F(e) && W(e) && N(e) && O() && B(e) && R(e) && D(e);
167
155
  } };
168
156
  };
169
157
  export {
170
- le as useHtmlValidator
158
+ ce as useHtmlValidator
171
159
  };
@@ -1,13 +1,13 @@
1
- import { useRecommendation as S } from "../../../composables/useRecommendation.js";
1
+ import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
2
2
  function b(e, u, r, o) {
3
- const s = `{{${e}_${u}_${r}}}`, t = `{{${e}_${u}_currency}}`;
4
- return o === "before" ? `${t} ${s}` : `${s} ${t}`;
3
+ const n = `{{${e}_${u}_${r}}}`, t = `{{${e}_${u}_currency}}`;
4
+ return o === "before" ? `${t} ${n}` : `${n} ${t}`;
5
5
  }
6
- function p(e, u, r, o, s) {
6
+ function p(e, u, r, o, n) {
7
7
  switch (u) {
8
8
  case "productImage": {
9
9
  const t = e.querySelector("img");
10
- t && t.setAttribute("src", `{{${r}_${o}_img}}`);
10
+ t && (t.setAttribute("src", `{{${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${r}_${o}_name}}`));
11
11
  const c = e.querySelector("a");
12
12
  c && c.setAttribute("href", `{{${r}_${o}_url}}`);
13
13
  break;
@@ -24,7 +24,7 @@ function p(e, u, r, o, s) {
24
24
  const t = e.querySelector("p");
25
25
  if (t) {
26
26
  const c = t.querySelector("strong") || t;
27
- c.textContent = b(r, o, "price", s);
27
+ c.textContent = b(r, o, "price", n);
28
28
  }
29
29
  break;
30
30
  }
@@ -36,7 +36,7 @@ function p(e, u, r, o, s) {
36
36
  r,
37
37
  o,
38
38
  "original_price",
39
- s
39
+ n
40
40
  ), t.setAttribute("product-attr", "discount");
41
41
  }
42
42
  break;
@@ -67,22 +67,22 @@ function p(e, u, r, o, s) {
67
67
  }
68
68
  }
69
69
  function $(e, u, r) {
70
- e.querySelectorAll(".recommendation-product-row").forEach((s, t) => {
71
- s.querySelectorAll("[data-attribute-type]").forEach((n) => {
72
- const i = n.getAttribute("data-attribute-type") || "", a = n.querySelectorAll(".attribute-cell");
70
+ e.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
71
+ n.querySelectorAll("[data-attribute-type]").forEach((s) => {
72
+ const i = s.getAttribute("data-attribute-type") || "", a = s.querySelectorAll(".attribute-cell");
73
73
  a.length > 0 ? a.forEach((l) => {
74
74
  p(l, i, u, t, r);
75
- }) : p(n, i, u, t, r);
75
+ }) : p(s, i, u, t, r);
76
76
  });
77
77
  });
78
78
  }
79
- function _(e, u, r) {
79
+ function S(e, u, r) {
80
80
  const o = e.querySelectorAll(".recommendation-product-row");
81
81
  if (!o.length)
82
82
  return;
83
- const [s] = o, t = s.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
84
- o.forEach((n, i) => {
85
- n.querySelectorAll("[data-attribute-type]").forEach((l) => {
83
+ const [n] = o, t = n.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
84
+ o.forEach((s, i) => {
85
+ s.querySelectorAll("[data-attribute-type]").forEach((l) => {
86
86
  const f = l.getAttribute("data-attribute-type") || "";
87
87
  l.querySelectorAll(".attribute-cell").forEach((y, m) => {
88
88
  const A = i * c + m;
@@ -91,11 +91,16 @@ function _(e, u, r) {
91
91
  });
92
92
  });
93
93
  }
94
- function q(e, u) {
95
- const r = e.getAttribute("data-layout") || "grid", o = e.getAttribute("currency-alignment") || "after";
96
- r === "list" ? $(e, u, o) : _(e, u, o);
94
+ function q(e, u, r) {
95
+ e.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
96
+ S(n, u, r);
97
+ });
97
98
  }
98
99
  function d(e, u) {
100
+ const r = e.getAttribute("data-layout") || "grid", o = e.getAttribute("currency-alignment") || "after";
101
+ r === "list" ? $(e, u, o) : q(e, u, o);
102
+ }
103
+ function h(e, u) {
99
104
  const r = e.match(/<!DOCTYPE[^>]*>/i);
100
105
  return (r ? `${r[0]}
101
106
  ` : "") + u.documentElement.outerHTML;
@@ -104,11 +109,11 @@ function w(e) {
104
109
  const u = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(u, "text/html"), o = r.querySelectorAll(".ins-recommendation-v3-block-v2");
105
110
  if (!o.length)
106
111
  return e;
107
- const { buildCampaignUrl: s } = S();
112
+ const { buildCampaignUrl: n } = _();
108
113
  return o.forEach((c) => {
109
- const n = c.getAttribute("recommendation-id");
110
- n && (s(n), q(c, n));
111
- }), d(u, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
114
+ const s = c.getAttribute("recommendation-id");
115
+ s && (n(s), d(c, s));
116
+ }), h(u, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
112
117
  }
113
118
  export {
114
119
  b as formatPriceVariable,
@@ -1,8 +1,12 @@
1
- const t = {
1
+ const e = {
2
2
  transactional: 2
3
- }, o = 2, T = 13;
3
+ }, o = 2, t = 13, s = {
4
+ SAVED_MODULES: "savedModules",
5
+ DEFAULT_MODULES: "defaultModules"
6
+ };
4
7
  export {
5
8
  o as EditorType,
6
- T as MAX_DEFAULT_TEMPLATE_ID,
7
- t as TemplateTypes
9
+ t as MAX_DEFAULT_TEMPLATE_ID,
10
+ s as ModuleFolderDefaults,
11
+ e as TemplateTypes
8
12
  };
@@ -1,12 +1,13 @@
1
- var u = Object.defineProperty;
2
- var p = (r, i, t) => i in r ? u(r, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[i] = t;
3
- var g = (r, i, t) => p(r, typeof i != "symbol" ? i + "" : i, t);
4
- import { Block as f, BlockCompositionType as I, ModificationDescription as h } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
1
+ var p = Object.defineProperty;
2
+ var f = (r, o, t) => o in r ? p(r, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[o] = t;
3
+ var g = (r, o, t) => f(r, typeof o != "symbol" ? o + "" : o, t);
4
+ import { Block as h, BlockCompositionType as I, ModificationDescription as _ } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { ensureMobileCssRulesExist as d } from "./controls/mobileLayout/cssRules.js";
5
6
  import { RecommendationConfigService as s } from "./services/configService.js";
6
- import { useRecommendationExtensionStore as d } from "./store/recommendation.js";
7
- import { getDefaultTemplate as _ } from "./templates/grid/template.js";
8
- const k = "recommendation-block", c = "ins-recommendation-v3-block-v2", m = "recommendation-id";
9
- class b extends f {
7
+ import { useRecommendationExtensionStore as u } from "./store/recommendation.js";
8
+ import { getDefaultTemplate as k } from "./templates/grid/template.js";
9
+ const B = "recommendation-block", c = "ins-recommendation-v3-block-v2", a = "recommendation-id";
10
+ class y extends h {
10
11
  constructor() {
11
12
  super();
12
13
  /**
@@ -16,7 +17,7 @@ class b extends f {
16
17
  g(this, "_pendingBlockId", null);
17
18
  }
18
19
  getId() {
19
- return k;
20
+ return B;
20
21
  }
21
22
  getIcon() {
22
23
  return "recommendation-icon";
@@ -39,7 +40,7 @@ class b extends f {
39
40
  */
40
41
  getTemplate() {
41
42
  const t = this._generateNextId();
42
- return this._pendingBlockId = t, _(t);
43
+ return this._pendingBlockId = t, k(t);
43
44
  }
44
45
  /**
45
46
  * Called when a new block is dropped into the template
@@ -50,7 +51,9 @@ class b extends f {
50
51
  */
51
52
  onCreated(t) {
52
53
  const e = this._pendingBlockId ?? this._generateNextId();
53
- this._pendingBlockId = null, this._assignRecommendationId(t, e), s.initializeConfig(this.api, t, { recommendationId: e }), d().setCurrentBlock(e);
54
+ this._pendingBlockId = null, this._assignRecommendationId(t, e);
55
+ const n = s.initializeConfig(this.api, t, { recommendationId: e }), i = u();
56
+ i.setCurrentBlock(e), d(this.api), i.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 });
54
57
  }
55
58
  /**
56
59
  * Called when the document changes or template is loaded
@@ -70,7 +73,7 @@ class b extends f {
70
73
  "Assign recommendation ID to legacy block"
71
74
  );
72
75
  }
73
- s.needsMigration(t) && this._migrateFromLegacy(t);
76
+ s.needsMigration(t) && this._migrateFromLegacy(t), d(this.api);
74
77
  }
75
78
  }
76
79
  /**
@@ -81,7 +84,7 @@ class b extends f {
81
84
  */
82
85
  onDelete(t) {
83
86
  const e = this._getRecommendationId(t);
84
- e && d().removeBlockState(e);
87
+ e && u().removeBlockState(e);
85
88
  }
86
89
  /**
87
90
  * Generates the next unique recommendation ID by scanning all existing blocks
@@ -91,9 +94,9 @@ class b extends f {
91
94
  let t = 0;
92
95
  try {
93
96
  const e = this.api.getDocumentRoot();
94
- e && "querySelectorAll" in e && e.querySelectorAll(`.${c}`).forEach((o) => {
95
- if ("getAttribute" in o) {
96
- const a = o.getAttribute(m), l = a ? parseInt(a) : 0;
97
+ e && "querySelectorAll" in e && e.querySelectorAll(`.${c}`).forEach((i) => {
98
+ if ("getAttribute" in i) {
99
+ const m = i.getAttribute(a), l = m ? parseInt(m) : 0;
97
100
  l > t && (t = l);
98
101
  }
99
102
  });
@@ -111,8 +114,8 @@ class b extends f {
111
114
  const n = this._getBlockElement(t);
112
115
  if (!n)
113
116
  return;
114
- const o = this.api.getDocumentModifier();
115
- o.modifyHtml(n).setAttribute(m, e.toString()), o.apply(new h(`Assign recommendation ID ${e}`));
117
+ const i = this.api.getDocumentModifier();
118
+ i.modifyHtml(n).setAttribute(a, e.toString()), i.apply(new _(`Assign recommendation ID ${e}`));
116
119
  }
117
120
  /**
118
121
  * Gets the recommendation-id from a block node
@@ -121,11 +124,11 @@ class b extends f {
121
124
  const e = this._getBlockElement(t);
122
125
  if (!e || !("getAttribute" in e))
123
126
  return null;
124
- const n = e.getAttribute(m);
127
+ const n = e.getAttribute(a);
125
128
  if (!n)
126
129
  return null;
127
- const o = parseInt(n);
128
- return Number.isNaN(o) ? null : o;
130
+ const i = parseInt(n);
131
+ return Number.isNaN(i) ? null : i;
129
132
  }
130
133
  /**
131
134
  * Gets the block element (the element with BLOCK_CLASS)
@@ -146,6 +149,6 @@ class b extends f {
146
149
  }
147
150
  }
148
151
  export {
149
- k as BLOCK_ID,
150
- b as RecommendationBlock
152
+ B as BLOCK_ID,
153
+ y as RecommendationBlock
151
154
  };
@@ -1,6 +1,6 @@
1
- import { DEFAULT_ROW_SPACING as n, DEFAULT_COLUMN_SPACING as s, DEFAULT_CARDS_IN_ROW as R } from "./layout.js";
2
- import { ATTR_PRODUCT_IMAGE as t, ATTR_PRODUCT_NAME as e, ATTR_PRODUCT_OLD_PRICE as o, ATTR_PRODUCT_PRICE as T, ATTR_PRODUCT_OMNIBUS_PRICE as _, ATTR_PRODUCT_OMNIBUS_DISCOUNT as r, ATTR_PRODUCT_BUTTON as U } from "./selectors.js";
3
- const I = {
1
+ import { DEFAULT_ROW_SPACING as U, DEFAULT_COLUMN_SPACING as I, DEFAULT_MOBILE_CARDS_IN_ROW as n, DEFAULT_CARDS_IN_ROW as s } from "./layout.js";
2
+ import { ATTR_PRODUCT_IMAGE as t, ATTR_PRODUCT_NAME as e, ATTR_PRODUCT_OLD_PRICE as o, ATTR_PRODUCT_PRICE as _, ATTR_PRODUCT_OMNIBUS_PRICE as T, ATTR_PRODUCT_OMNIBUS_DISCOUNT as r, ATTR_PRODUCT_BUTTON as R } from "./selectors.js";
3
+ const O = {
4
4
  code: "USD",
5
5
  symbol: "USD",
6
6
  alignment: "after",
@@ -10,56 +10,57 @@ const I = {
10
10
  }, i = {
11
11
  textBefore: "",
12
12
  textAfter: ""
13
- }, O = {
13
+ }, C = {
14
14
  textBefore: "",
15
15
  textAfter: ""
16
- }, C = [
16
+ }, D = [
17
17
  t,
18
18
  e,
19
19
  o,
20
- T,
21
20
  _,
21
+ T,
22
22
  r,
23
- U
24
- ], D = {
23
+ R
24
+ ], A = {
25
25
  [t]: !0,
26
26
  [e]: !0,
27
- [T]: !0,
27
+ [_]: !0,
28
28
  [o]: !0,
29
- [_]: !1,
29
+ [T]: !1,
30
30
  [r]: !1,
31
- [U]: !0
32
- }, a = {
31
+ [R]: !0
32
+ }, E = {
33
33
  // Settings
34
34
  strategy: "mostPopular",
35
35
  productIds: [],
36
36
  size: "6",
37
37
  shuffleProducts: !1,
38
38
  language: "en_US",
39
- currency: I,
39
+ currency: O,
40
40
  filters: [],
41
41
  // Layout
42
42
  layout: "grid",
43
- cardsInRow: R,
44
- columnSpacing: s,
45
- rowSpacing: n,
43
+ cardsInRow: s,
44
+ mobileCardsInRow: n,
45
+ columnSpacing: I,
46
+ rowSpacing: U,
46
47
  // Composition
47
- composition: C,
48
- visibility: D,
48
+ composition: D,
49
+ visibility: A,
49
50
  // Element settings
50
51
  omnibusPrice: i,
51
- omnibusDiscount: O,
52
+ omnibusDiscount: C,
52
53
  textTrimming: !1,
53
54
  // Meta
54
55
  configVersion: 1,
55
56
  recommendationId: 0
56
- }, E = 1;
57
+ }, N = 1;
57
58
  export {
58
- E as CURRENT_CONFIG_VERSION,
59
- C as DEFAULT_COMPOSITION,
60
- I as DEFAULT_CURRENCY,
61
- a as DEFAULT_NODE_CONFIG,
62
- O as DEFAULT_OMNIBUS_DISCOUNT,
59
+ N as CURRENT_CONFIG_VERSION,
60
+ D as DEFAULT_COMPOSITION,
61
+ O as DEFAULT_CURRENCY,
62
+ E as DEFAULT_NODE_CONFIG,
63
+ C as DEFAULT_OMNIBUS_DISCOUNT,
63
64
  i as DEFAULT_OMNIBUS_PRICE,
64
- D as DEFAULT_VISIBILITY
65
+ A as DEFAULT_VISIBILITY
65
66
  };
@@ -4,17 +4,19 @@ const _ = {
4
4
  }, o = [
5
5
  { icon: "grid-orientation", value: _.GRID },
6
6
  { icon: "list-orientation", value: _.LIST }
7
- ], t = 3, n = 3, A = 9, T = 4, c = 10, s = 20, O = 0, S = 50, I = 5;
7
+ ], t = 3, n = 3, A = 9, O = 4, R = 1, T = 2, c = 10, s = 20, I = 0, S = 50, P = 5;
8
8
  export {
9
9
  n as DEFAULT_CARDS_IN_ROW,
10
10
  c as DEFAULT_COLUMN_SPACING,
11
+ R as DEFAULT_MOBILE_CARDS_IN_ROW,
11
12
  t as DEFAULT_PRODUCTS_PER_ROW,
12
13
  s as DEFAULT_ROW_SPACING,
13
14
  o as LAYOUT_OPTIONS,
14
15
  _ as LAYOUT_VALUES,
15
- T as MAX_PRODUCTS_PER_ROW,
16
+ T as MAX_MOBILE_PRODUCTS_PER_ROW,
17
+ O as MAX_PRODUCTS_PER_ROW,
16
18
  A as MAX_PRODUCT_COUNT,
17
19
  S as MAX_SPACING,
18
- O as MIN_SPACING,
19
- I as SPACING_STEP
20
+ I as MIN_SPACING,
21
+ P as SPACING_STEP
20
22
  };