@useinsider/guido 3.1.1-beta.6b60896 → 3.1.1-beta.761c167

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 (29) hide show
  1. package/dist/@types/config/schemas.js +7 -9
  2. package/dist/config/compiler/utils/recommendationCompilerUtils.js +53 -55
  3. package/dist/enums/recommendation.js +2 -2
  4. package/dist/extensions/Blocks/Recommendation/block.js +1 -1
  5. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +27 -11
  6. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +185 -172
  7. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +95 -93
  8. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +75 -73
  9. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +7 -5
  10. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -29
  11. package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -7
  12. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +3 -1
  13. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +20 -20
  14. package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -50
  15. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +6 -6
  16. package/dist/extensions/Blocks/Unsubscribe/settingsPanel.js +16 -17
  17. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +324 -218
  18. package/dist/package.json.js +1 -1
  19. package/dist/src/@types/config/schemas.d.ts +0 -4
  20. package/dist/src/composables/useConfig.d.ts +0 -2
  21. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +1 -1
  22. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  23. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +5 -0
  24. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +5 -0
  25. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  26. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  27. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +20 -3
  28. package/dist/src/stores/config.d.ts +0 -18
  29. package/package.json +3 -3
@@ -114,9 +114,7 @@ const m = {
114
114
  /** Enable unsubscribe block */
115
115
  unsubscribe: e(a(), !0),
116
116
  /** Disable modules panel in the editor */
117
- modulesDisabled: e(a(), !1),
118
- /** Enable Liquid template syntax */
119
- liquidSyntax: e(a(), !1)
117
+ modulesDisabled: e(a(), !1)
120
118
  }), E = n([
121
119
  "amp-accordion",
122
120
  "amp-carousel",
@@ -193,12 +191,12 @@ const m = {
193
191
  M,
194
192
  N,
195
193
  D
196
- ]), x = o({
194
+ ]), U = o({
197
195
  /** Custom compiler rules to apply */
198
196
  customRules: e(c(v), []),
199
197
  /** Skip default compiler rules */
200
198
  ignoreDefaultRules: e(a(), !1)
201
- }), U = o({
199
+ }), x = o({
202
200
  /**
203
201
  * External validation handler called before save completes.
204
202
  * Return false to cancel the save operation.
@@ -227,15 +225,15 @@ const m = {
227
225
  /** Block configuration */
228
226
  blocks: e(O, {}),
229
227
  /** Compiler configuration */
230
- compiler: e(x, {}),
228
+ compiler: e(U, {}),
231
229
  /** Callbacks and event handlers */
232
- callbacks: e(U, {})
230
+ callbacks: e(x, {})
233
231
  });
234
232
  export {
235
233
  O as BlocksSchema,
236
- U as CallbacksSchema,
234
+ x as CallbacksSchema,
237
235
  v as CompilerRuleSchema,
238
- x as CompilerSchema,
236
+ U as CompilerSchema,
239
237
  g as CustomBlockTypeSchema,
240
238
  D as CustomRuleSchema,
241
239
  E as DefaultBlockTypeSchema,
@@ -1,23 +1,22 @@
1
- import { useConfig as S } from "../../../composables/useConfig.js";
2
- import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
3
- function y(e, n, r, o, s = "") {
4
- const u = `{{${s}${e}_${n}_${r}}}`, t = `{{${s}${e}_${n}_currency}}`;
5
- return o === "before" ? `${t} ${u}` : `${u} ${t}`;
1
+ import { useRecommendation as $ } from "../../../composables/useRecommendation.js";
2
+ function b(e, u, r, o) {
3
+ const n = `{{${e}_${u}_${r}}}`, t = `{{${e}_${u}_currency}}`;
4
+ return o === "before" ? `${t} ${n}` : `${n} ${t}`;
6
5
  }
7
- function p(e, n, r, o, s, u) {
8
- switch (n) {
6
+ function p(e, u, r, o, n) {
7
+ switch (u) {
9
8
  case "productImage": {
10
9
  const t = e.querySelector("img");
11
- t && (t.setAttribute("src", `{{${u}${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${u}${r}_${o}_name}}`));
10
+ t && (t.setAttribute("src", `{{${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${r}_${o}_name}}`));
12
11
  const c = e.querySelector("a");
13
- c && c.setAttribute("href", `{{${u}${r}_${o}_url}}`);
12
+ c && c.setAttribute("href", `{{${r}_${o}_url}}`);
14
13
  break;
15
14
  }
16
15
  case "productName": {
17
16
  const t = e.querySelector("p");
18
17
  if (t) {
19
18
  const c = t.querySelector("strong") || t;
20
- c.textContent = `{{${u}${r}_${o}_name}}`;
19
+ c.textContent = `{{${r}_${o}_name}}`;
21
20
  }
22
21
  break;
23
22
  }
@@ -25,7 +24,7 @@ function p(e, n, r, o, s, u) {
25
24
  const t = e.querySelector("p");
26
25
  if (t) {
27
26
  const c = t.querySelector("strong") || t;
28
- c.textContent = y(r, o, "price", s, u);
27
+ c.textContent = b(r, o, "price", n);
29
28
  }
30
29
  break;
31
30
  }
@@ -33,25 +32,24 @@ function p(e, n, r, o, s, u) {
33
32
  const t = e.querySelector("p");
34
33
  if (t) {
35
34
  const c = t.querySelector("strong") || t;
36
- c.textContent = y(
35
+ c.textContent = b(
37
36
  r,
38
37
  o,
39
38
  "original_price",
40
- s,
41
- u
39
+ n
42
40
  ), t.setAttribute("product-attr", "discount");
43
41
  }
44
42
  break;
45
43
  }
46
44
  case "productButton": {
47
45
  const t = e.querySelector("a");
48
- t && t.setAttribute("href", `{{${u}${r}_${o}_url}}`);
46
+ t && t.setAttribute("href", `{{${r}_${o}_url}}`);
49
47
  break;
50
48
  }
51
49
  case "productOmnibusPrice": {
52
50
  const t = e.querySelector(".omnibus-price-value");
53
51
  if (t) {
54
- t.textContent = `{{${u}${r}_${o}_omnibus_price}}`;
52
+ t.textContent = `{{${r}_${o}_omnibus_price}}`;
55
53
  const c = t.closest("p");
56
54
  c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
57
55
  }
@@ -60,7 +58,7 @@ function p(e, n, r, o, s, u) {
60
58
  case "productOmnibusDiscount": {
61
59
  const t = e.querySelector(".omnibus-discount-value");
62
60
  if (t) {
63
- t.textContent = `{{${u}${r}_${o}_omnibus_discount}}`;
61
+ t.textContent = `{{${r}_${o}_omnibus_discount}}`;
64
62
  const c = t.closest("p");
65
63
  c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
66
64
  }
@@ -69,66 +67,66 @@ function p(e, n, r, o, s, u) {
69
67
  default: {
70
68
  const t = e.getAttribute("product-attr") ? e : e.querySelector("[product-attr]");
71
69
  if (t) {
72
- const c = t.getAttribute("product-attr"), i = t.querySelector("p");
73
- if (i) {
74
- const a = i.querySelector("strong") || i;
75
- a.textContent = `{{${u}${r}_${o}_${c}}}`;
70
+ const c = t.getAttribute("product-attr"), s = t.querySelector("p");
71
+ if (s) {
72
+ const i = s.querySelector("strong") || s;
73
+ i.textContent = `{{${r}_${o}_${c}}}`;
76
74
  }
77
75
  }
78
76
  break;
79
77
  }
80
78
  }
81
79
  }
82
- function q(e, n, r, o) {
83
- e.querySelectorAll(".recommendation-product-row").forEach((u, t) => {
84
- u.querySelectorAll("[data-attribute-type]").forEach((i) => {
85
- const a = i.getAttribute("data-attribute-type") || "", b = i.querySelectorAll(".attribute-cell");
86
- b.length > 0 ? b.forEach((l) => {
87
- p(l, a, n, t, r, o);
88
- }) : p(i, a, n, t, r, o);
80
+ function S(e, u, r) {
81
+ e.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
82
+ n.querySelectorAll("[data-attribute-type]").forEach((s) => {
83
+ const i = s.getAttribute("data-attribute-type") || "", l = s.querySelectorAll(".attribute-cell");
84
+ l.length > 0 ? l.forEach((a) => {
85
+ p(a, i, u, t, r);
86
+ }) : p(s, i, u, t, r);
89
87
  });
90
88
  });
91
89
  }
92
- function d(e, n, r, o) {
93
- const s = e.querySelectorAll(".recommendation-product-row");
94
- if (!s.length)
90
+ function _(e, u, r) {
91
+ const o = e.querySelectorAll(".recommendation-product-row");
92
+ if (!o.length)
95
93
  return;
96
- const [u] = s, t = u.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
97
- s.forEach((i, a) => {
98
- i.querySelectorAll("[data-attribute-type]").forEach((l) => {
99
- const $ = l.getAttribute("data-attribute-type") || "";
100
- l.querySelectorAll(".attribute-cell").forEach((A, f) => {
101
- const m = a * c + f;
102
- p(A, $, n, m, r, o);
94
+ const [n] = o, t = n.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
95
+ o.forEach((s, i) => {
96
+ s.querySelectorAll("[data-attribute-type]").forEach((a) => {
97
+ const f = a.getAttribute("data-attribute-type") || "";
98
+ a.querySelectorAll(".attribute-cell").forEach((y, A) => {
99
+ const m = i * c + A;
100
+ p(y, f, u, m, r);
103
101
  });
104
102
  });
105
103
  });
106
104
  }
107
- function g(e, n, r, o) {
108
- e.querySelectorAll(".ins-recommendation-product-container").forEach((u) => {
109
- d(u, n, r, o);
105
+ function q(e, u, r) {
106
+ e.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
107
+ _(n, u, r);
110
108
  });
111
109
  }
112
- function h(e, n, r) {
113
- const o = e.getAttribute("data-layout") || "grid", s = e.getAttribute("currency-alignment") || "after";
114
- o === "list" ? q(e, n, s, r) : g(e, n, s, r);
110
+ function d(e, u) {
111
+ const r = e.getAttribute("data-layout") || "grid", o = e.getAttribute("currency-alignment") || "after";
112
+ r === "list" ? S(e, u, o) : q(e, u, o);
115
113
  }
116
- function C(e, n) {
114
+ function g(e, u) {
117
115
  const r = e.match(/<!DOCTYPE[^>]*>/i);
118
116
  return (r ? `${r[0]}
119
- ` : "") + n.documentElement.outerHTML;
117
+ ` : "") + u.documentElement.outerHTML;
120
118
  }
121
- function P(e) {
122
- const n = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(n, "text/html"), o = r.querySelectorAll(".recommendation-block-v2");
119
+ function E(e) {
120
+ const u = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(u, "text/html"), o = r.querySelectorAll(".recommendation-block-v2");
123
121
  if (!o.length)
124
122
  return e;
125
- const { buildCampaignUrl: s } = _(), { isFeatureEnabled: u } = S(), t = u("liquidSyntax") ? "reco_" : "";
126
- return o.forEach((i) => {
127
- const a = i.getAttribute("recommendation-id");
128
- a && (s(a), h(i, a, t));
129
- }), C(n, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
123
+ const { buildCampaignUrl: n } = $();
124
+ return o.forEach((c) => {
125
+ const s = c.getAttribute("recommendation-id");
126
+ s && (n(s), d(c, s));
127
+ }), g(u, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
130
128
  }
131
129
  export {
132
- y as formatPriceVariable,
133
- P as prepareRecommendationBlocks
130
+ b as formatPriceVariable,
131
+ E as prepareRecommendationBlocks
134
132
  };
@@ -28,8 +28,8 @@ const e = 20, s = 320, t = "vertical", m = {
28
28
  ATTRIBUTE_PARAGRAPH: /<p[^>]*?product-attr="(discount|omnibus_discount|omnibus_price)"[^>]*>[\S\s]*?<\/p>/gm,
29
29
  ATTRIBUTE_PARAGRAPH_START_TAG: /<p[^>]*?product-attr="(discount|omnibus_discount|omnibus_price)"[^>]*>/gm,
30
30
  COMPOSITION: /composition="true"/gm,
31
- CUSTOM_FIELD: /{{(?:reco_)?[0-9]+_[0-8]_(discount|omnibus_discount|omnibus_price)}}/gm,
32
- CUSTOM_FIELD_INDEXES_PART: /{{(?:reco_)?[0-9]+_[0-8]_/gm,
31
+ CUSTOM_FIELD: /{{[0-9]+_[0-8]_(discount|omnibus_discount|omnibus_price)}}/gm,
32
+ CUSTOM_FIELD_INDEXES_PART: /{{[0-9]+_[0-8]_/gm,
33
33
  CUSTOM_FIELD_NAME_PART: /_(discount|omnibus_discount|omnibus_price)}}/gm
34
34
  }, n = {
35
35
  PARAGRAPH_END_TAG: "</p>"
@@ -169,7 +169,7 @@ class q extends b {
169
169
  if (e && e.includes(a))
170
170
  return t;
171
171
  }
172
- return "querySelector" in t ? t.querySelector(`.${a}`) : null;
172
+ return "querySelector" in t ? t.querySelector(`.${a}`) ?? null : null;
173
173
  }
174
174
  /**
175
175
  * Migrate configuration from legacy format
@@ -1,26 +1,42 @@
1
- const T = ".recommendation-block-v2", c = ".ins-recommendation-product-container", o = ".ins-recommendation-desktop-container", t = ".ins-recommendation-mobile-container", n = ".ins-recommendation-mobile-row", R = {
1
+ const T = ".recommendation-block-v2", c = ".ins-recommendation-product-container", o = ".ins-recommendation-desktop-container", n = ".ins-recommendation-mobile-container", t = ".ins-recommendation-mobile-row", r = {
2
2
  CURRENCY: "currency",
3
3
  SYMBOL: "currency-symbol",
4
4
  ALIGNMENT: "currency-alignment",
5
5
  THOUSAND_SEPARATOR: "currency-thousand-separator",
6
6
  DECIMAL_SEPARATOR: "currency-decimal-separator",
7
7
  DECIMAL_COUNT: "currency-decimal-count"
8
- }, r = "productImage", O = "productName", _ = "productPrice", e = "productOldPrice", s = "productOmnibusPrice", C = "productOmnibusDiscount", E = "productButton", A = "customAttr:", i = "data-custom-attributes", u = "product-attr";
8
+ }, R = "productImage", _ = "productName", e = "productPrice", O = "productOldPrice", s = "productOmnibusPrice", i = "productOmnibusDiscount", E = "productButton", A = "customAttr:", C = "data-custom-attributes", u = "product-attr", m = /* @__PURE__ */ new Set([
9
+ "name",
10
+ // productName
11
+ "price",
12
+ // productPrice
13
+ "original_price",
14
+ // productOldPrice
15
+ "image_url",
16
+ // productImage
17
+ "url",
18
+ // productButton
19
+ "omnibus_price",
20
+ // productOmnibusPrice
21
+ "omnibus_discount"
22
+ // productOmnibusDiscount
23
+ ]);
9
24
  export {
10
25
  A as ATTR_CUSTOM_PREFIX,
11
- i as ATTR_DATA_CUSTOM_ATTRIBUTES,
26
+ C as ATTR_DATA_CUSTOM_ATTRIBUTES,
12
27
  u as ATTR_PRODUCT_ATTR,
13
28
  E as ATTR_PRODUCT_BUTTON,
14
- r as ATTR_PRODUCT_IMAGE,
15
- O as ATTR_PRODUCT_NAME,
16
- e as ATTR_PRODUCT_OLD_PRICE,
17
- C as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
29
+ R as ATTR_PRODUCT_IMAGE,
30
+ _ as ATTR_PRODUCT_NAME,
31
+ O as ATTR_PRODUCT_OLD_PRICE,
32
+ i as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
18
33
  s as ATTR_PRODUCT_OMNIBUS_PRICE,
19
- _ as ATTR_PRODUCT_PRICE,
34
+ e as ATTR_PRODUCT_PRICE,
20
35
  T as BLOCK_ROOT_SELECTOR,
36
+ m as BUILT_IN_DEFAULT_ATTRIBUTES,
21
37
  c as CONTAINER_SELECTOR,
22
- R as CURRENCY_ATTR,
38
+ r as CURRENCY_ATTR,
23
39
  o as DESKTOP_CONTAINER_SELECTOR,
24
- t as MOBILE_CONTAINER_SELECTOR,
25
- n as MOBILE_ROW_SELECTOR
40
+ n as MOBILE_CONTAINER_SELECTOR,
41
+ t as MOBILE_ROW_SELECTOR
26
42
  };